mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-03 13:02:42 +02:00
fix saves getting corrupted when saving, fix error messages not showing (correctly)
This commit is contained in:
@@ -756,11 +756,19 @@ RequestStatus Client::UploadSave(SaveInfo & save)
|
|||||||
return RequestFailure;
|
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 * 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 };
|
int postLengths[] = { save.GetName().length(), save.GetDescription().length(), gameDataLength, save.GetPublished()?6:7 };
|
||||||
//std::cout << postNames[0] << " " << postDatas[0] << " " << postLengths[0] << std::endl;
|
//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);
|
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
|
else
|
||||||
{
|
{
|
||||||
@@ -772,8 +780,8 @@ RequestStatus Client::UploadSave(SaveInfo & save)
|
|||||||
if(strncmp((const char *)data, "OK", 2)!=0)
|
if(strncmp((const char *)data, "OK", 2)!=0)
|
||||||
{
|
{
|
||||||
if(gameData) free(gameData);
|
if(gameData) free(gameData);
|
||||||
free(data);
|
|
||||||
lastError = std::string((const char *)data);
|
lastError = std::string((const char *)data);
|
||||||
|
free(data);
|
||||||
return RequestFailure;
|
return RequestFailure;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -955,8 +963,8 @@ RequestStatus Client::ExecVote(int saveID, int direction)
|
|||||||
{
|
{
|
||||||
if(strncmp((const char *)data, "OK", 2)!=0)
|
if(strncmp((const char *)data, "OK", 2)!=0)
|
||||||
{
|
{
|
||||||
free(data);
|
|
||||||
lastError = std::string((const char *)data);
|
lastError = std::string((const char *)data);
|
||||||
|
free(data);
|
||||||
return RequestFailure;
|
return RequestFailure;
|
||||||
}
|
}
|
||||||
free(data);
|
free(data);
|
||||||
|
@@ -153,7 +153,7 @@ void ServerSaveActivity::NotifyDone(Task * task)
|
|||||||
Exit();
|
Exit();
|
||||||
if(!task->GetSuccess())
|
if(!task->GetSuccess())
|
||||||
{
|
{
|
||||||
new ErrorMessage("Error", "Error while saving");
|
new ErrorMessage("Error", Client::Ref().GetLastError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user