- check if unit is dead when loading game and do NOT set cell map for dead unit

This commit is contained in:
Mark Vejvoda 2012-03-13 23:51:39 +00:00
parent d4ca1c36cb
commit 4481151c5b
3 changed files with 30 additions and 4 deletions

View File

@ -1922,6 +1922,25 @@ void Faction::loadGame(const XmlNode *rootNode, int factionIndex,GameSettings *s
}
upgradeManager.loadGame(factionNode,this);
// ControlType control;
control = static_cast<ControlType>(factionNode->getAttribute("control")->getIntValue());
// Texture2D *texture;
// FactionType *factionType;
//factionNode->addAttribute("factiontype",factionType->getName(), mapTagReplacements);
// int index;
//factionNode->addAttribute("index",intToStr(index), mapTagReplacements);
// int teamIndex;
//factionNode->addAttribute("teamIndex",intToStr(teamIndex), mapTagReplacements);
teamIndex = factionNode->getAttribute("teamIndex")->getIntValue();
// int startLocationIndex;
startLocationIndex = factionNode->getAttribute("startLocationIndex")->getIntValue();
// bool thisFaction;
thisFaction = factionNode->getAttribute("thisFaction")->getIntValue();
// bool factionDisconnectHandled;
// RandomGen random;
random.setLastNumber(factionNode->getAttribute("random")->getIntValue());
}
}

View File

@ -3661,7 +3661,9 @@ void Unit::saveGame(XmlNode *rootNode) {
// std::vector<UnitAttackBoostEffect *> currentAttackBoostEffects;
for(unsigned int i = 0; i < currentAttackBoostEffects.size(); ++i) {
UnitAttackBoostEffect *uabe= currentAttackBoostEffects[i];
uabe->saveGame(unitNode);
if(uabe != NULL) {
uabe->saveGame(unitNode);
}
}
// Mutex *mutexCommands;
@ -3707,9 +3709,6 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction *
//Unit(int id, UnitPathInterface *path, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, CardinalDir placeFacing);
Unit *result = new Unit(newUnitId, newpath, newUnitPos, ut, faction, world->getMapPtr(), newModelFacing);
world->getMapPtr()->putUnitCells(result, newUnitPos);
//result->born();
result->lastRotation = unitNode->getAttribute("lastRotation")->getFloatValue();
result->targetRotation = unitNode->getAttribute("targetRotation")->getFloatValue();
result->rotation = unitNode->getAttribute("rotation")->getFloatValue();
@ -3964,6 +3963,11 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction *
// CauseOfDeathType causeOfDeath;
result->causeOfDeath = static_cast<CauseOfDeathType>(unitNode->getAttribute("causeOfDeath")->getIntValue());
if(result->alive) {
world->getMapPtr()->putUnitCells(result, newUnitPos);
//result->born();
}
return result;
}

View File

@ -2028,6 +2028,9 @@ void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attac
if(ast == NULL) {
throw runtime_error("ast == NULL");
}
if(attacked == NULL) {
throw runtime_error("attacked == NULL");
}
//get vars
float damage = ast->getTotalAttackStrength(attacker->getTotalUpgrade());