From 8db56130426f2c61e10219eddb67ee86bea82961 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 4 Feb 2016 00:50:31 +0300 Subject: Extend chat command /all to log corruption in actors lists. --- src/actormanager.cpp | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'src/actormanager.cpp') diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 98e8ef008..1152324c2 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -1481,14 +1481,13 @@ bool ActorManager::isBlocked(const BeingId id) const return mBlockedBeings.find(id) != mBlockedBeings.end(); } -void ActorManager::printAllToChat() const +void ActorManager::printAllToChat() { // TRANSLATORS: visible beings on map - printBeingsToChat(getAll(), _("Visible on map")); + printBeingsToChat(_("Visible on map")); } -void ActorManager::printBeingsToChat(const ActorSprites &beings, - const std::string &header) +void ActorManager::printBeingsToChat(const std::string &header) { if (!debugChatTab) return; @@ -1496,7 +1495,7 @@ void ActorManager::printBeingsToChat(const ActorSprites &beings, debugChatTab->chatLog("---------------------------------------", ChatMsgType::BY_SERVER); debugChatTab->chatLog(header, ChatMsgType::BY_SERVER); - FOR_EACH (std::set::const_iterator, it, beings) + for_actors { if (!*it) continue; @@ -1509,9 +1508,38 @@ void ActorManager::printBeingsToChat(const ActorSprites &beings, debugChatTab->chatLog(strprintf("%s (%d,%d) %d", being->getName().c_str(), being->getTileX(), being->getTileY(), toInt(being->getSubType(), int)), ChatMsgType::BY_SERVER); + if (mActorsIdMap.find(being->getId()) == mActorsIdMap.end()) + { + debugChatTab->chatLog("missing in id map: %s", + being->getName().c_str()); + } } debugChatTab->chatLog("---------------------------------------", ChatMsgType::BY_SERVER); + FOR_EACH (ActorSpritesMapConstIterator, itr, mActorsIdMap) + { + ActorSprite *actor = (*itr).second; + if (!actor) + continue; + if (actor->getId() != (*itr).first) + debugChatTab->chatLog("Actor with wrong key in map", ""); + + bool found(false); + + for_actors + { + if (!*it) + continue; + + if ((*it)->getId() == actor->getId()) + { + found = true; + break; + } + } + if (!found) + debugChatTab->chatLog("Actor present in map but not in set", ""); + } } void ActorManager::printBeingsToChat(const std::vector &beings, -- cgit v1.2.3-60-g2f50