From 69a15d45443ce0235ccfdfa6bfce426f9ec97f15 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Fri, 11 Jan 2013 18:40:47 +0000 Subject: [PATCH] - added a new skill to toggle fog of war for any command. --- source/glest_game/type_instances/unit.cpp | 10 ++++++++-- source/glest_game/types/command_type.cpp | 2 +- source/glest_game/world/world.cpp | 11 ++++++++++- source/glest_game/world/world.h | 1 + 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 270cbe5c..4fa98041 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -981,15 +981,21 @@ void Unit::setCurrSkill(const SkillType *currSkill) { } Command *cmd = getCurrrentCommandThreadSafe(); - // Remove old fog of war skill type if need be - game->getWorld()->removeFogOfWarSkillType(this); // Set mew fog of war skill type if need be if(cmd != NULL && cmd->getCommandType() != NULL && cmd->getCommandType()->hasFogOfWarSkillType(currSkill->getName())) { const FogOfWarSkillType *fowst = cmd->getCommandType()->getFogOfWarSkillType(); + + // Remove old fog of war skill type if need be + game->getWorld()->removeFogOfWarSkillTypeFromList(this); + game->getWorld()->addFogOfWarSkillType(this,fowst); } + else { + // Remove old fog of war skill type if need be + game->getWorld()->removeFogOfWarSkillType(this); + } } if(showUnitParticles == true && currSkill->unitParticleSystemTypes.empty() == false && diff --git a/source/glest_game/types/command_type.cpp b/source/glest_game/types/command_type.cpp index d8e759a4..d90324d2 100644 --- a/source/glest_game/types/command_type.cpp +++ b/source/glest_game/types/command_type.cpp @@ -83,7 +83,7 @@ void CommandType::load(int id, const XmlNode *n, const string &dir, string skillName= n->getChild("fog-of-war-skill")->getAttribute("value")->getRestrictedValue(); fogOfWarSkillType = static_cast(ut.getSkillType(skillName, scFogOfWar)); - string skillAttachmentNames = n->getChild("fog-of-war-skill")->getAttribute("skill-attachments")->getRestrictedValue(); + string skillAttachmentNames = n->getChild("fog-of-war-skill")->getAttribute("skill-attachments")->getValue(); std::vector skillList; Tokenize(skillAttachmentNames,skillList,","); diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index 1ea30048..b7d634fb 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -214,10 +214,19 @@ void World::addFogOfWarSkillType(const Unit *unit,const FogOfWarSkillType *fowst } } } -void World::removeFogOfWarSkillType(const Unit *unit) { + +bool World::removeFogOfWarSkillTypeFromList(const Unit *unit) { + bool result = false; if(mapFogOfWarUnitList.find(unit->getId()) != mapFogOfWarUnitList.end()) { mapFogOfWarUnitList.erase(unit->getId()); + result = true; + } + return result; +} +void World::removeFogOfWarSkillType(const Unit *unit) { + bool removedFromList = removeFogOfWarSkillTypeFromList(unit); + if(removedFromList == true) { if(mapFogOfWarUnitList.empty() == true) { //printf("In [%s::%s Line: %d] current = %d new = %d\n",__FILE__,__FUNCTION__,__LINE__,fogOfWar,originalGameFogOfWar); diff --git a/source/glest_game/world/world.h b/source/glest_game/world/world.h index 85f7a599..69aa76ad 100644 --- a/source/glest_game/world/world.h +++ b/source/glest_game/world/world.h @@ -159,6 +159,7 @@ public: void addFogOfWarSkillType(const Unit *unit,const FogOfWarSkillType *fowst); void removeFogOfWarSkillType(const Unit *unit); + bool removeFogOfWarSkillTypeFromList(const Unit *unit); //get inline int getMaxPlayers() const {return map.getMaxPlayers();}