mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +00:00
adjusted timestamp function to always return value in seconds
This commit is contained in:
parent
09f1f67778
commit
016c48645e
@ -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)
|
||||
|
@ -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?
|
||||
|
@ -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;
|
||||
|
@ -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<milliseconds>((time_point_cast<milliseconds>(system_clock::now())).time_since_epoch());
|
||||
seconds value = duration_cast<seconds>((time_point_cast<seconds>(system_clock::now())).time_since_epoch());
|
||||
|
||||
return (time_t)value.count();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user