summaryrefslogtreecommitdiffstats
path: root/source/cPlayer.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-01 14:43:47 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-01 14:43:47 +0100
commit2568bad3cc1ae70350f5ad31e97b4c13194e437e (patch)
tree31d0713dfe1b4e42c1f17ddae8ea0114c420fc61 /source/cPlayer.cpp
parentRemoved a few duplicate includes (diff)
downloadcuberite-2568bad3cc1ae70350f5ad31e97b4c13194e437e.tar
cuberite-2568bad3cc1ae70350f5ad31e97b4c13194e437e.tar.gz
cuberite-2568bad3cc1ae70350f5ad31e97b4c13194e437e.tar.bz2
cuberite-2568bad3cc1ae70350f5ad31e97b4c13194e437e.tar.lz
cuberite-2568bad3cc1ae70350f5ad31e97b4c13194e437e.tar.xz
cuberite-2568bad3cc1ae70350f5ad31e97b4c13194e437e.tar.zst
cuberite-2568bad3cc1ae70350f5ad31e97b4c13194e437e.zip
Diffstat (limited to 'source/cPlayer.cpp')
-rw-r--r--source/cPlayer.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
index 0dd5695a4..f10dc3586 100644
--- a/source/cPlayer.cpp
+++ b/source/cPlayer.cpp
@@ -784,8 +784,8 @@ bool cPlayer::LoadFromDisk()
if( itr->second ) LOGINFO("%s", itr->first.c_str() );
}
- char SourceFile[128];
- sprintf_s(SourceFile, 128, "players/%s.json", m_pState->PlayerName.c_str() );
+ AString SourceFile;
+ Printf(SourceFile, "players/%s.json", m_pState->PlayerName.c_str() );
cFile f;
if (!f.Open(SourceFile, cFile::fmRead))
@@ -796,8 +796,8 @@ bool cPlayer::LoadFromDisk()
// Get file size
long FileSize = f.GetSize();
- char * buffer = new char[FileSize];
- if (f.Read(buffer, FileSize) != FileSize )
+ std::auto_ptr<char> buffer(new char[FileSize]);
+ if (f.Read(buffer.get(), FileSize) != FileSize)
{
LOGERROR("ERROR READING FROM FILE \"%s\"", SourceFile);
return false;
@@ -806,12 +806,12 @@ bool cPlayer::LoadFromDisk()
Json::Value root;
Json::Reader reader;
- if( !reader.parse( buffer, root, false ) )
+ if (!reader.parse(buffer.get(), root, false))
{
LOGERROR("ERROR WHILE PARSING JSON FROM FILE %s", SourceFile);
}
- delete [] buffer;
+ buffer.reset();
Json::Value & JSON_PlayerPosition = root["position"];
if( JSON_PlayerPosition.size() == 3 )
@@ -876,8 +876,8 @@ bool cPlayer::SaveToDisk()
Json::StyledWriter writer;
std::string JsonData = writer.write( root );
- char SourceFile[128];
- sprintf_s(SourceFile, 128, "players/%s.json", m_pState->PlayerName.c_str() );
+ AString SourceFile;
+ Printf(SourceFile, "players/%s.json", m_pState->PlayerName.c_str() );
cFile f;
if (!f.Open(SourceFile, cFile::fmWrite))