diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-21 12:30:30 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-21 12:30:30 (GMT) |
| commit | b639da369225e1ba32b305599ec70eab792669d5 (patch) | |
| tree | 660a2169c9870d410275113289c24e90153e9f5e /src/client/Client.cpp | |
| parent | b6736f967e9889c7fc8a68b11abd5be1ad4cc5d7 (diff) | |
| download | powder-b639da369225e1ba32b305599ec70eab792669d5.zip powder-b639da369225e1ba32b305599ec70eab792669d5.tar.gz | |
Use collapsed saves when using stamp browser, fix memory leak when saving stamps
Diffstat (limited to 'src/client/Client.cpp')
| -rw-r--r-- | src/client/Client.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/client/Client.cpp b/src/client/Client.cpp index 4799d9a..a2ae2e7 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -805,7 +805,26 @@ RequestStatus Client::UploadSave(SaveInfo & save) SaveFile * Client::GetStamp(std::string stampID) { - std::ifstream stampFile; + std::string stampFile = std::string(STAMPS_DIR PATH_SEP + stampID + ".stm"); + if(FileExists(stampFile)) + { + SaveFile * file = new SaveFile(stampID); + try + { + GameSave * tempSave = new GameSave(ReadFile(stampFile)); + file->SetGameSave(tempSave); + } + catch (ParseException & e) + { + std::cerr << "Client: Invalid stamp file, " << stampID << " " << std::string(e.what()) << std::endl; + } + return file; + } + else + { + return NULL; + } + /*std::ifstream stampFile; stampFile.open(std::string(STAMPS_DIR PATH_SEP + stampID + ".stm").c_str(), std::ios::binary); if(stampFile.is_open()) { @@ -835,7 +854,7 @@ SaveFile * Client::GetStamp(std::string stampID) else { return NULL; - } + }*/ } void Client::DeleteStamp(std::string stampID) @@ -886,6 +905,8 @@ std::string Client::AddStamp(GameSave * saveData) stampStream.write((const char *)gameData, gameDataLength); stampStream.close(); + delete[] gameData; + stampIDs.push_front(saveID.str()); updateStamps(); |
