From f28c643b48b6e0f0026a90eeed2cc7ae80167b0d Mon Sep 17 00:00:00 2001 From: kamilprzyb <64405781+kamilprzyb@users.noreply.github.com> Date: Tue, 22 Dec 2020 22:52:25 +0100 Subject: [PATCH] Allow permanent vehicles --- src/Database.cpp | 6 +++--- src/PlayerManager.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Database.cpp b/src/Database.cpp index b5d8ba9..9d0df37 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -1304,7 +1304,7 @@ void Database::removeExpiredVehicles(Player* player) { // if there are expired vehicles in bank just remove them silently 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 && player->Bank[i].iTimeLimit != 0) { memset(&player->Bank[i], 0, sizeof(sItemBase)); } } @@ -1313,14 +1313,14 @@ void Database::removeExpiredVehicles(Player* player) { std::vector toRemove; // equipped vehicle - if (player->Equip[8].iOpt > 0 && player->Equip[8].iTimeLimit < currentTime) { + if (player->Equip[8].iOpt > 0 && player->Equip[8].iTimeLimit < currentTime && player->Equip[8].iTimeLimit != 0) { toRemove.push_back(&player->Equip[8]); player->toRemoveVehicle.eIL = 0; player->toRemoveVehicle.iSlotNum = 8; } // inventory for (int i = 0; i < AINVEN_COUNT; i++) { - if (player->Inven[i].iType == 10 && player->Inven[i].iTimeLimit < currentTime) { + if (player->Inven[i].iType == 10 && player->Inven[i].iTimeLimit < currentTime && player->Inven[i].iTimeLimit != 0) { toRemove.push_back(&player->Inven[i]); player->toRemoveVehicle.eIL = 1; player->toRemoveVehicle.iSlotNum = i; diff --git a/src/PlayerManager.cpp b/src/PlayerManager.cpp index b84cf74..6bb2d0f 100644 --- a/src/PlayerManager.cpp +++ b/src/PlayerManager.cpp @@ -839,7 +839,9 @@ void PlayerManager::revivePlayer(CNSocket* sock, CNPacketData* data) { void PlayerManager::enterPlayerVehicle(CNSocket* sock, CNPacketData* data) { Player* plr = getPlayer(sock); - if (plr->Equip[8].iID > 0 && plr->Equip[8].iTimeLimit>getTimestamp()) { + bool expired = plr->Equip[8].iTimeLimit < getTimestamp() && plr->Equip[8].iTimeLimit != 0; + + if (plr->Equip[8].iID > 0 && !expired) { 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)); @@ -855,7 +857,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->Equip[8].iTimeLimit < getTimestamp()) { + if (expired) { plr->toRemoveVehicle.eIL = 0; plr->toRemoveVehicle.iSlotNum = 8; ItemManager::checkItemExpire(sock, plr);