- added a new skill to toggle fog of war for any command.

This commit is contained in:
Mark Vejvoda 2013-01-11 18:40:47 +00:00
parent 4ea22920bf
commit 69a15d4544
4 changed files with 20 additions and 4 deletions

View File

@ -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 &&

View File

@ -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<const FogOfWarSkillType*>(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<std::string> skillList;
Tokenize(skillAttachmentNames,skillList,",");

View File

@ -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);

View File

@ -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();}