From 00f64ce992831364a53a16ac6adadedb8d2b3539 Mon Sep 17 00:00:00 2001 From: kamilprzyb Date: Tue, 22 Sep 2020 10:18:29 +0200 Subject: [PATCH] added sanity check for killing mission mobs --- src/MissionManager.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/MissionManager.cpp b/src/MissionManager.cpp index 769283b..aeff93f 100644 --- a/src/MissionManager.cpp +++ b/src/MissionManager.cpp @@ -328,7 +328,13 @@ void MissionManager::mobKilled(CNSocket *sock, int mobid) { if (task["m_iCSUNumToKill"][j] != 0) { missionmob = true; - plr->RemainingNPCCount[i][j]--; + //sanity check + if (plr->RemainingNPCCount[i][j] == 0) { + std::cout << "[WARN] RemainingNPCCount tries to go below 0?!" << std::endl; + } + else { + plr->RemainingNPCCount[i][j]--; + } } // drop quest item if (task["m_iCSUItemNumNeeded"][j] != 0 && !isQuestItemFull(sock, task["m_iCSUItemID"][j], task["m_iCSUItemNumNeeded"][j]) ) {