fixed comments formating, added zeroing out player->toRemoveVehicle after removing vehicle

This commit is contained in:
kamilprzyb 2020-09-23 11:21:32 +02:00
parent 016c48645e
commit 7bcdc111da
5 changed files with 13 additions and 10 deletions

View File

@ -612,22 +612,22 @@ void Database::getInventory(Player* player) {
void Database::removeExpiredVehicles(Player* player) { void Database::removeExpiredVehicles(Player* player) {
int32_t currentTime = getTimestamp(); int32_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)
player->Bank[i] = {}; player->Bank[i] = {};
} }
//for the rest, we want to leave only 1 expired vehicle on player to delete it with the client packet // for the rest, we want to leave only 1 expired vehicle on player to delete it with the client packet
std::vector<sItemBase*> toRemove; std::vector<sItemBase*> toRemove;
//equiped vehicle // equiped vehicle
if (player->Equip[8].iOpt > 0 && player->Equip[8].iTimeLimit < currentTime) if (player->Equip[8].iOpt > 0 && player->Equip[8].iTimeLimit < currentTime)
{ {
toRemove.push_back(&player->Equip[8]); toRemove.push_back(&player->Equip[8]);
player->toRemoveVehicle.eIL = 0; player->toRemoveVehicle.eIL = 0;
player->toRemoveVehicle.iSlotNum = 8; player->toRemoveVehicle.iSlotNum = 8;
} }
//inventory // inventory
for (int i = 0; i < AINVEN_COUNT; i++) { 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) {
toRemove.push_back(&player->Inven[i]); toRemove.push_back(&player->Inven[i]);
@ -636,7 +636,7 @@ void Database::removeExpiredVehicles(Player* player) {
} }
} }
//delete all but one vehicles, leave last one for ceremonial deletion // delete all but one vehicles, leave last one for ceremonial deletion
for (int i = 0; i < (int)toRemove.size()-1; i++) { for (int i = 0; i < (int)toRemove.size()-1; i++) {
memset(toRemove[i], 0, sizeof(sItemBase)); memset(toRemove[i], 0, sizeof(sItemBase));
} }

View File

@ -793,9 +793,12 @@ void ItemManager::checkItemExpire(CNSocket* sock, Player* player) {
itemData->iSlotNum = player->toRemoveVehicle.iSlotNum; itemData->iSlotNum = player->toRemoveVehicle.iSlotNum;
sock->sendPacket((void*)&respbuf, P_FE2CL_PC_DELETE_TIME_LIMIT_ITEM, resplen); sock->sendPacket((void*)&respbuf, P_FE2CL_PC_DELETE_TIME_LIMIT_ITEM, resplen);
//delete serverside // delete serverside
if (player->toRemoveVehicle.eIL == 0) if (player->toRemoveVehicle.eIL == 0)
memset(&player->Equip[8], 0, sizeof(sItemBase)); memset(&player->Equip[8], 0, sizeof(sItemBase));
else else
memset(&player->Inven[player->toRemoveVehicle.iSlotNum], 0, sizeof(sItemBase)); memset(&player->Inven[player->toRemoveVehicle.iSlotNum], 0, sizeof(sItemBase));
player->toRemoveVehicle.eIL = 0;
player->toRemoveVehicle.iSlotNum = 0;
} }

View File

@ -328,7 +328,7 @@ void MissionManager::mobKilled(CNSocket *sock, int mobid) {
if (task["m_iCSUNumToKill"][j] != 0) if (task["m_iCSUNumToKill"][j] != 0)
{ {
missionmob = true; missionmob = true;
//sanity check // sanity check
if (plr->RemainingNPCCount[i][j] == 0) { if (plr->RemainingNPCCount[i][j] == 0) {
std::cout << "[WARN] RemainingNPCCount tries to go below 0?!" << std::endl; std::cout << "[WARN] RemainingNPCCount tries to go below 0?!" << std::endl;
} }

View File

@ -710,7 +710,7 @@ void PlayerManager::enterPlayerVehicle(CNSocket* sock, CNPacketData* data) {
INITSTRUCT(sP_FE2CL_PC_VEHICLE_ON_FAIL, response); INITSTRUCT(sP_FE2CL_PC_VEHICLE_ON_FAIL, response);
sock->sendPacket((void*)&response, P_FE2CL_PC_VEHICLE_ON_FAIL, sizeof(sP_FE2CL_PC_VEHICLE_ON_FAIL)); sock->sendPacket((void*)&response, P_FE2CL_PC_VEHICLE_ON_FAIL, sizeof(sP_FE2CL_PC_VEHICLE_ON_FAIL));
//check if vehicle didn't expire // check if vehicle didn't expire
if (plr.plr->Equip[8].iTimeLimit < getTimestamp()) if (plr.plr->Equip[8].iTimeLimit < getTimestamp())
{ {
plr.plr->toRemoveVehicle.eIL = 0; plr.plr->toRemoveVehicle.eIL = 0;

View File

@ -150,7 +150,7 @@ time_t getTime() {
return (time_t)value.count(); return (time_t)value.count();
} }
//returns system time in seconds // returns system time in seconds
time_t getTimestamp() { time_t getTimestamp() {
using namespace std::chrono; using namespace std::chrono;