Stop using 32-bit time in SaveInfo

This commit is contained in:
Tamás Bálint Misius 2023-06-11 15:36:45 +02:00
parent daabe6a116
commit 5e15d02eb8
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
5 changed files with 12 additions and 11 deletions

View File

@ -1,7 +1,7 @@
#include "SaveInfo.h" #include "SaveInfo.h"
#include "GameSave.h" #include "GameSave.h"
SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, ByteString _userName, String _name): SaveInfo::SaveInfo(int _id, time_t _createdDate, time_t _updatedDate, int _votesUp, int _votesDown, ByteString _userName, String _name):
id(_id), id(_id),
createdDate(_createdDate), createdDate(_createdDate),
updatedDate(_updatedDate), updatedDate(_updatedDate),
@ -20,7 +20,7 @@ SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, in
} }
SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, int _vote, ByteString _userName, String _name, String description_, bool published_, std::list<ByteString> tags_): SaveInfo::SaveInfo(int _id, time_t _createdDate, time_t _updatedDate, int _votesUp, int _votesDown, int _vote, ByteString _userName, String _name, String description_, bool published_, std::list<ByteString> tags_):
id(_id), id(_id),
createdDate(_createdDate), createdDate(_createdDate),
updatedDate(_updatedDate), updatedDate(_updatedDate),

View File

@ -2,6 +2,7 @@
#include "common/String.h" #include "common/String.h"
#include <list> #include <list>
#include <memory> #include <memory>
#include <ctime>
#ifdef GetUserName #ifdef GetUserName
# undef GetUserName // dammit windows # undef GetUserName // dammit windows
@ -14,8 +15,8 @@ class SaveInfo
private: private:
public: public:
int id; int id;
int createdDate; time_t createdDate;
int updatedDate; time_t updatedDate;
int votesUp, votesDown; int votesUp, votesDown;
int vote; int vote;
bool Favourite; bool Favourite;
@ -32,9 +33,9 @@ public:
std::list<ByteString> tags; std::list<ByteString> tags;
std::unique_ptr<GameSave> gameSave; std::unique_ptr<GameSave> gameSave;
SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, ByteString _userName, String _name); SaveInfo(int _id, time_t _createdDate, time_t _updatedDate, int _votesUp, int _votesDown, ByteString _userName, String _name);
SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, int _vote, ByteString _userName, String _name, String description_, bool published_, std::list<ByteString> tags); SaveInfo(int _id, time_t _createdDate, time_t _updatedDate, int _votesUp, int _votesDown, int _vote, ByteString _userName, String _name, String description_, bool published_, std::list<ByteString> tags);
void SetName(String name); void SetName(String name);
const String &GetName() const; const String &GetName() const;

View File

@ -44,8 +44,8 @@ namespace http
} }
saveInfo = std::make_unique<SaveInfo>( saveInfo = std::make_unique<SaveInfo>(
document["ID"].asInt(), document["ID"].asInt(),
document["DateCreated"].asInt(), document["DateCreated"].asInt64(),
document["Date"].asInt(), document["Date"].asInt64(),
document["ScoreUp"].asInt(), document["ScoreUp"].asInt(),
document["ScoreDown"].asInt(), document["ScoreDown"].asInt(),
document["ScoreMine"].asInt(), document["ScoreMine"].asInt(),

View File

@ -64,8 +64,8 @@ namespace http
{ {
auto saveInfo = std::make_unique<SaveInfo>( auto saveInfo = std::make_unique<SaveInfo>(
save["ID"].asInt(), save["ID"].asInt(),
save["Created"].asInt(), save["Created"].asInt64(),
save["Updated"].asInt(), save["Updated"].asInt64(),
save["ScoreUp"].asInt(), save["ScoreUp"].asInt(),
save["ScoreDown"].asInt(), save["ScoreDown"].asInt(),
save["Username"].asString(), save["Username"].asString(),

View File

@ -1004,7 +1004,7 @@ void GameModel::SetSave(std::unique_ptr<SaveInfo> newSave, bool invertIncludePre
gameSave->authors["title"] = currentSave->name.ToUtf8(); gameSave->authors["title"] = currentSave->name.ToUtf8();
gameSave->authors["description"] = currentSave->Description.ToUtf8(); gameSave->authors["description"] = currentSave->Description.ToUtf8();
gameSave->authors["published"] = (int)currentSave->Published; gameSave->authors["published"] = (int)currentSave->Published;
gameSave->authors["date"] = currentSave->updatedDate; gameSave->authors["date"] = (Json::Value::UInt64)currentSave->updatedDate;
currentSave->SetGameSave(std::move(gameSave)); currentSave->SetGameSave(std::move(gameSave));
} }
// This save was probably just created, and we didn't know the ID when creating it // This save was probably just created, and we didn't know the ID when creating it