mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +00:00
replaced high_resolution_clock with system_time for timestamps
This commit is contained in:
parent
0931c88541
commit
7ba9b9a54f
@ -33,6 +33,7 @@
|
|||||||
std::string U16toU8(char16_t* src);
|
std::string U16toU8(char16_t* src);
|
||||||
size_t U8toU16(std::string src, char16_t* des); // returns number of char16_t that was written at des
|
size_t U8toU16(std::string src, char16_t* des); // returns number of char16_t that was written at des
|
||||||
time_t getTime();
|
time_t getTime();
|
||||||
|
time_t getTimestamp();
|
||||||
|
|
||||||
// The PROTOCOL_VERSION definition is defined by the build system.
|
// The PROTOCOL_VERSION definition is defined by the build system.
|
||||||
#if !defined(PROTOCOL_VERSION)
|
#if !defined(PROTOCOL_VERSION)
|
||||||
|
@ -128,7 +128,7 @@ int Database::addAccount(std::string login, std::string password)
|
|||||||
account.Login = login;
|
account.Login = login;
|
||||||
account.Password = password;
|
account.Password = password;
|
||||||
account.Selected = 1;
|
account.Selected = 1;
|
||||||
account.Created = getTime();
|
account.Created = getTimestamp();
|
||||||
return db.insert(account);
|
return db.insert(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ void Database::updateSelected(int accountId, int slot)
|
|||||||
Account acc = db.get<Account>(accountId);
|
Account acc = db.get<Account>(accountId);
|
||||||
acc.Selected = slot;
|
acc.Selected = slot;
|
||||||
//timestamp
|
//timestamp
|
||||||
acc.LastLogin = getTime();
|
acc.LastLogin = getTimestamp();
|
||||||
db.update(acc);
|
db.update(acc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
|
|||||||
DbPlayer create = {};
|
DbPlayer create = {};
|
||||||
|
|
||||||
//set timestamp
|
//set timestamp
|
||||||
create.Created = getTime();
|
create.Created = getTimestamp();
|
||||||
// save packet data
|
// save packet data
|
||||||
create.FirstName = U16toU8(save->szFirstName);
|
create.FirstName = U16toU8(save->szFirstName);
|
||||||
create.LastName = U16toU8(save->szLastName);
|
create.LastName = U16toU8(save->szLastName);
|
||||||
@ -380,7 +380,7 @@ Database::DbPlayer Database::playerToDb(Player *player)
|
|||||||
appendBlob(&result.QuestFlag, flag);
|
appendBlob(&result.QuestFlag, flag);
|
||||||
}
|
}
|
||||||
//timestamp
|
//timestamp
|
||||||
result.LastLogin = getTime();
|
result.LastLogin = getTimestamp();
|
||||||
result.Created = getDbPlayerById(player->iID).Created;
|
result.Created = getDbPlayerById(player->iID).Created;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -611,7 +611,7 @@ void Database::getInventory(Player* player) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::removeExpiredVehicles(Player* player) {
|
void Database::removeExpiredVehicles(Player* player) {
|
||||||
uint64_t currentTime = getTime();
|
uint64_t currentTime = getTimestamp();
|
||||||
//remove from bank immediately
|
//remove from bank immediately
|
||||||
for (int i = 0; i < ABANK_COUNT; i++) {
|
for (int i = 0; i < ABANK_COUNT; i++) {
|
||||||
if (player->Bank[i].iType == 10 && player->Bank[i].iTimeLimit < currentTime)
|
if (player->Bank[i].iType == 10 && player->Bank[i].iTimeLimit < currentTime)
|
||||||
|
@ -118,7 +118,7 @@ void NPCManager::npcVendorBuy(CNSocket* sock, CNPacketData* data) {
|
|||||||
// if vehicle
|
// if vehicle
|
||||||
if (req->Item.iType == 10)
|
if (req->Item.iType == 10)
|
||||||
// set time limit: current time + 7days
|
// set time limit: current time + 7days
|
||||||
req->Item.iTimeLimit = getTime() + 604800;
|
req->Item.iTimeLimit = getTimestamp() + 604800;
|
||||||
|
|
||||||
|
|
||||||
if (slot != req->iInvenSlotNum) {
|
if (slot != req->iInvenSlotNum) {
|
||||||
|
@ -149,3 +149,11 @@ time_t getTime() {
|
|||||||
|
|
||||||
return (time_t)value.count();
|
return (time_t)value.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
time_t getTimestamp() {
|
||||||
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
milliseconds value = duration_cast<milliseconds>((time_point_cast<milliseconds>(system_clock::now())).time_since_epoch());
|
||||||
|
|
||||||
|
return (time_t)value.count();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user