summaryrefslogtreecommitdiff
path: root/src/client/Client.cpp
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2012-09-30 19:10:11 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-09-30 19:46:08 (GMT)
commitf65278655724686d772d099664c77d3602f9ce8a (patch)
tree955226bdfcd9625e4018cc45f36004a9145061d9 /src/client/Client.cpp
parentbe1b9112e85c270920a559acd790340ca32bce7f (diff)
downloadpowder-f65278655724686d772d099664c77d3602f9ce8a.zip
powder-f65278655724686d772d099664c77d3602f9ce8a.tar.gz
fix saves getting corrupted when saving, fix error messages not showing (correctly)
Diffstat (limited to 'src/client/Client.cpp')
-rw-r--r--src/client/Client.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/client/Client.cpp b/src/client/Client.cpp
index 1490f5f..0353d0e 100644
--- a/src/client/Client.cpp
+++ b/src/client/Client.cpp
@@ -756,11 +756,19 @@ RequestStatus Client::UploadSave(SaveInfo & save)
return RequestFailure;
}
+ char *saveName = new char[save.GetName().length() + 1];
+ std::strcpy ( saveName, save.GetName().c_str() );
+ char *saveDescription = new char[save.GetDescription().length() + 1];
+ std::strcpy ( saveDescription, save.GetDescription().c_str() );
+
char * postNames[] = { "Name", "Description", "Data:save.bin", "Publish", NULL };
- char * postDatas[] = { (char *)(save.GetName().c_str()), (char *)(save.GetDescription().c_str()), gameData, (char *)(save.GetPublished()?"Public":"Private") };
+ char * postDatas[] = { saveName, saveDescription, gameData, (char *)(save.GetPublished()?"Public":"Private") };
int postLengths[] = { save.GetName().length(), save.GetDescription().length(), gameDataLength, save.GetPublished()?6:7 };
//std::cout << postNames[0] << " " << postDatas[0] << " " << postLengths[0] << std::endl;
data = http_multipart_post("http://" SERVER "/Save.api", postNames, postDatas, postLengths, (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
+
+ delete[] saveDescription;
+ delete[] saveName;
}
else
{
@@ -772,8 +780,8 @@ RequestStatus Client::UploadSave(SaveInfo & save)
if(strncmp((const char *)data, "OK", 2)!=0)
{
if(gameData) free(gameData);
- free(data);
lastError = std::string((const char *)data);
+ free(data);
return RequestFailure;
}
else
@@ -955,8 +963,8 @@ RequestStatus Client::ExecVote(int saveID, int direction)
{
if(strncmp((const char *)data, "OK", 2)!=0)
{
- free(data);
lastError = std::string((const char *)data);
+ free(data);
return RequestFailure;
}
free(data);