EggBuffs now stores debuff timestamp instead of remaining time

This commit is contained in:
kamilprzyb 2020-10-22 11:28:18 +02:00 committed by Gent
parent 45ed99ae35
commit c7006b46ed

View File

@ -19,7 +19,7 @@
std::map<int32_t, BaseNPC*> NPCManager::NPCs; std::map<int32_t, BaseNPC*> NPCManager::NPCs;
std::map<int32_t, WarpLocation> NPCManager::Warps; std::map<int32_t, WarpLocation> NPCManager::Warps;
std::vector<WarpLocation> NPCManager::RespawnPoints; std::vector<WarpLocation> NPCManager::RespawnPoints;
/// sock, CBFlag -> remaining time /// sock, CBFlag -> until
std::map<std::pair<CNSocket*, int32_t>, time_t> NPCManager::EggBuffs; std::map<std::pair<CNSocket*, int32_t>, time_t> NPCManager::EggBuffs;
nlohmann::json NPCManager::NPCData; nlohmann::json NPCManager::NPCData;
@ -695,7 +695,9 @@ int NPCManager::eggBuffPlayer(CNSocket* sock, int skillId, int duration) {
} }
// save the buff serverside; // save the buff serverside;
EggBuffs[key] = duration; // if you get the same buff again, new duration will override the previous one
time_t until = getTimestamp() + duration;
EggBuffs[key] = until;
return 0; return 0;
} }
@ -704,9 +706,8 @@ void NPCManager::buffStep(CNServer* serv, time_t currTime) {
auto it = EggBuffs.begin(); auto it = EggBuffs.begin();
while (it != EggBuffs.end()) { while (it != EggBuffs.end()) {
// decrement remaining time // check remaining time
it->second --; if (it->second > getTimestamp())
if (it->second > 0)
it++; it++;
// if time reached 0 // if time reached 0