mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 09:06:46 +00:00
[Repositories] Fix datetime zero-value save behavior (#3976)
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
#include "../../strings.h"
|
||||
#include <ctime>
|
||||
|
||||
|
||||
class BaseObjectContentsRepository {
|
||||
public:
|
||||
struct ObjectContents {
|
||||
@@ -164,14 +163,14 @@ public:
|
||||
e.parentid = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.bagidx = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.itemid = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.charges = static_cast<int16_t>(atoi(row[4]));
|
||||
e.charges = row[4] ? static_cast<int16_t>(atoi(row[4])) : 0;
|
||||
e.droptime = strtoll(row[5] ? row[5] : "-1", nullptr, 10);
|
||||
e.augslot1 = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.augslot2 = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.augslot3 = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.augslot4 = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.augslot5 = row[10] ? static_cast<uint32_t>(strtoul(row[10], nullptr, 10)) : 0;
|
||||
e.augslot6 = static_cast<int32_t>(atoi(row[11]));
|
||||
e.augslot6 = row[11] ? static_cast<int32_t>(atoi(row[11])) : 0;
|
||||
|
||||
return e;
|
||||
}
|
||||
@@ -210,7 +209,7 @@ public:
|
||||
v.push_back(columns[2] + " = " + std::to_string(e.bagidx));
|
||||
v.push_back(columns[3] + " = " + std::to_string(e.itemid));
|
||||
v.push_back(columns[4] + " = " + std::to_string(e.charges));
|
||||
v.push_back(columns[5] + " = FROM_UNIXTIME(" + (e.droptime > 0 ? std::to_string(e.droptime) : "null") + ")");
|
||||
v.push_back(columns[5] + " = FROM_UNIXTIME(" + (e.droptime > 0 ? std::to_string(e.droptime) : "UNIX_TIMESTAMP()") + ")");
|
||||
v.push_back(columns[6] + " = " + std::to_string(e.augslot1));
|
||||
v.push_back(columns[7] + " = " + std::to_string(e.augslot2));
|
||||
v.push_back(columns[8] + " = " + std::to_string(e.augslot3));
|
||||
@@ -243,7 +242,7 @@ public:
|
||||
v.push_back(std::to_string(e.bagidx));
|
||||
v.push_back(std::to_string(e.itemid));
|
||||
v.push_back(std::to_string(e.charges));
|
||||
v.push_back("FROM_UNIXTIME(" + (e.droptime > 0 ? std::to_string(e.droptime) : "null") + ")");
|
||||
v.push_back("FROM_UNIXTIME(" + (e.droptime > 0 ? std::to_string(e.droptime) : "UNIX_TIMESTAMP()") + ")");
|
||||
v.push_back(std::to_string(e.augslot1));
|
||||
v.push_back(std::to_string(e.augslot2));
|
||||
v.push_back(std::to_string(e.augslot3));
|
||||
@@ -284,7 +283,7 @@ public:
|
||||
v.push_back(std::to_string(e.bagidx));
|
||||
v.push_back(std::to_string(e.itemid));
|
||||
v.push_back(std::to_string(e.charges));
|
||||
v.push_back("FROM_UNIXTIME(" + (e.droptime > 0 ? std::to_string(e.droptime) : "null") + ")");
|
||||
v.push_back("FROM_UNIXTIME(" + (e.droptime > 0 ? std::to_string(e.droptime) : "UNIX_TIMESTAMP()") + ")");
|
||||
v.push_back(std::to_string(e.augslot1));
|
||||
v.push_back(std::to_string(e.augslot2));
|
||||
v.push_back(std::to_string(e.augslot3));
|
||||
@@ -328,14 +327,14 @@ public:
|
||||
e.parentid = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.bagidx = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.itemid = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.charges = static_cast<int16_t>(atoi(row[4]));
|
||||
e.charges = row[4] ? static_cast<int16_t>(atoi(row[4])) : 0;
|
||||
e.droptime = strtoll(row[5] ? row[5] : "-1", nullptr, 10);
|
||||
e.augslot1 = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.augslot2 = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.augslot3 = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.augslot4 = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.augslot5 = row[10] ? static_cast<uint32_t>(strtoul(row[10], nullptr, 10)) : 0;
|
||||
e.augslot6 = static_cast<int32_t>(atoi(row[11]));
|
||||
e.augslot6 = row[11] ? static_cast<int32_t>(atoi(row[11])) : 0;
|
||||
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
@@ -364,14 +363,14 @@ public:
|
||||
e.parentid = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.bagidx = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.itemid = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.charges = static_cast<int16_t>(atoi(row[4]));
|
||||
e.charges = row[4] ? static_cast<int16_t>(atoi(row[4])) : 0;
|
||||
e.droptime = strtoll(row[5] ? row[5] : "-1", nullptr, 10);
|
||||
e.augslot1 = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.augslot2 = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.augslot3 = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.augslot4 = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.augslot5 = row[10] ? static_cast<uint32_t>(strtoul(row[10], nullptr, 10)) : 0;
|
||||
e.augslot6 = static_cast<int32_t>(atoi(row[11]));
|
||||
e.augslot6 = row[11] ? static_cast<int32_t>(atoi(row[11])) : 0;
|
||||
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
@@ -451,7 +450,7 @@ public:
|
||||
v.push_back(std::to_string(e.bagidx));
|
||||
v.push_back(std::to_string(e.itemid));
|
||||
v.push_back(std::to_string(e.charges));
|
||||
v.push_back("FROM_UNIXTIME(" + (e.droptime > 0 ? std::to_string(e.droptime) : "null") + ")");
|
||||
v.push_back("FROM_UNIXTIME(" + (e.droptime > 0 ? std::to_string(e.droptime) : "UNIX_TIMESTAMP()") + ")");
|
||||
v.push_back(std::to_string(e.augslot1));
|
||||
v.push_back(std::to_string(e.augslot2));
|
||||
v.push_back(std::to_string(e.augslot3));
|
||||
@@ -485,7 +484,7 @@ public:
|
||||
v.push_back(std::to_string(e.bagidx));
|
||||
v.push_back(std::to_string(e.itemid));
|
||||
v.push_back(std::to_string(e.charges));
|
||||
v.push_back("FROM_UNIXTIME(" + (e.droptime > 0 ? std::to_string(e.droptime) : "null") + ")");
|
||||
v.push_back("FROM_UNIXTIME(" + (e.droptime > 0 ? std::to_string(e.droptime) : "UNIX_TIMESTAMP()") + ")");
|
||||
v.push_back(std::to_string(e.augslot1));
|
||||
v.push_back(std::to_string(e.augslot2));
|
||||
v.push_back(std::to_string(e.augslot3));
|
||||
|
||||
Reference in New Issue
Block a user