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 +++++++++++++++++++++++++++++++++----- src/actormanager.h | 5 ++--- 2 files changed, 35 insertions(+), 8 deletions(-) (limited to 'src') 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, diff --git a/src/actormanager.h b/src/actormanager.h index 59f8552d2..60a0bec00 100644 --- a/src/actormanager.h +++ b/src/actormanager.h @@ -259,10 +259,9 @@ class ActorManager final: public ConfigListener bool isBlocked(const BeingId id) const; - void printAllToChat() const; + void printAllToChat(); - static void printBeingsToChat(const ActorSprites &beings, - const std::string &header); + void printBeingsToChat(const std::string &header); static void printBeingsToChat(const std::vector &beings, const std::string &header); -- cgit v1.2.3-70-g09d2