diff --git a/src/Database.cpp b/src/Database.cpp index a478838..9b20bdf 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -611,7 +611,7 @@ void Database::getInventory(Player* player) { } void Database::removeExpiredVehicles(Player* player) { - int32_t currentTime = getTimestamp()/1000; + int32_t currentTime = getTimestamp(); //remove from bank immediately for (int i = 0; i < ABANK_COUNT; i++) { if (player->Bank[i].iType == 10 && player->Bank[i].iTimeLimit < currentTime) diff --git a/src/NPCManager.cpp b/src/NPCManager.cpp index 0f6d940..346de25 100644 --- a/src/NPCManager.cpp +++ b/src/NPCManager.cpp @@ -118,7 +118,7 @@ void NPCManager::npcVendorBuy(CNSocket* sock, CNPacketData* data) { // if vehicle if (req->Item.iType == 10) // set time limit: current time + 7days - req->Item.iTimeLimit = getTimestamp()/1000 + 604800; + req->Item.iTimeLimit = getTimestamp() + 604800; if (slot != req->iInvenSlotNum) { // possible item stacking? diff --git a/src/PlayerManager.cpp b/src/PlayerManager.cpp index 5ea6ffe..4ef26a0 100644 --- a/src/PlayerManager.cpp +++ b/src/PlayerManager.cpp @@ -691,7 +691,7 @@ void PlayerManager::revivePlayer(CNSocket* sock, CNPacketData* data) { void PlayerManager::enterPlayerVehicle(CNSocket* sock, CNPacketData* data) { PlayerView& plr = PlayerManager::players[sock]; - if (plr.plr->Equip[8].iID > 0 && plr.plr->Equip[8].iTimeLimit>(getTimestamp()/1000)) { + if (plr.plr->Equip[8].iID > 0 && plr.plr->Equip[8].iTimeLimit>getTimestamp()) { INITSTRUCT(sP_FE2CL_PC_VEHICLE_ON_SUCC, response); sock->sendPacket((void*)&response, P_FE2CL_PC_VEHICLE_ON_SUCC, sizeof(sP_FE2CL_PC_VEHICLE_ON_SUCC)); @@ -711,7 +711,7 @@ void PlayerManager::enterPlayerVehicle(CNSocket* sock, CNPacketData* data) { sock->sendPacket((void*)&response, P_FE2CL_PC_VEHICLE_ON_FAIL, sizeof(sP_FE2CL_PC_VEHICLE_ON_FAIL)); //check if vehicle didn't expire - if (plr.plr->Equip[8].iTimeLimit < (getTimestamp() / 1000)) + if (plr.plr->Equip[8].iTimeLimit < getTimestamp()) { plr.plr->toRemoveVehicle.eIL = 0; plr.plr->toRemoveVehicle.iSlotNum = 8; diff --git a/src/main.cpp b/src/main.cpp index 1dd3520..fe1ab25 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -150,10 +150,11 @@ time_t getTime() { return (time_t)value.count(); } +//returns system time in seconds time_t getTimestamp() { using namespace std::chrono; - milliseconds value = duration_cast((time_point_cast(system_clock::now())).time_since_epoch()); + seconds value = duration_cast((time_point_cast(system_clock::now())).time_since_epoch()); return (time_t)value.count(); }