From c7006b46edab7c00f9579f5161992dc23e0ee86f Mon Sep 17 00:00:00 2001 From: kamilprzyb Date: Thu, 22 Oct 2020 11:28:18 +0200 Subject: [PATCH] EggBuffs now stores debuff timestamp instead of remaining time --- src/NPCManager.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/NPCManager.cpp b/src/NPCManager.cpp index 782e676..128cd17 100644 --- a/src/NPCManager.cpp +++ b/src/NPCManager.cpp @@ -19,7 +19,7 @@ std::map NPCManager::NPCs; std::map NPCManager::Warps; std::vector NPCManager::RespawnPoints; -/// sock, CBFlag -> remaining time +/// sock, CBFlag -> until std::map, time_t> NPCManager::EggBuffs; nlohmann::json NPCManager::NPCData; @@ -694,8 +694,10 @@ int NPCManager::eggBuffPlayer(CNSocket* sock, int skillId, int duration) { sock->sendPacket((void*)&updatePacket, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE)); } - // save the buff serverside; - EggBuffs[key] = duration; + // save the buff serverside; + // if you get the same buff again, new duration will override the previous one + time_t until = getTimestamp() + duration; + EggBuffs[key] = until; return 0; } @@ -704,9 +706,8 @@ void NPCManager::buffStep(CNServer* serv, time_t currTime) { auto it = EggBuffs.begin(); while (it != EggBuffs.end()) { - // decrement remaining time - it->second --; - if (it->second > 0) + // check remaining time + if (it->second > getTimestamp()) it++; // if time reached 0