attempt to fix morph out of synch
This commit is contained in:
parent
60a7ea172d
commit
fd9ce54063
|
@ -1033,7 +1033,7 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
|
||||||
throw megaglest_runtime_error(szBuf);
|
throw megaglest_runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
ct= unit->getType()->findCommandTypeById(networkCommand->getCommandTypeId());
|
ct = unit->getType()->findCommandTypeById(networkCommand->getCommandTypeId());
|
||||||
|
|
||||||
if(unit->getFaction()->getIndex() != networkCommand->getUnitFactionIndex()) {
|
if(unit->getFaction()->getIndex() != networkCommand->getUnitFactionIndex()) {
|
||||||
|
|
||||||
|
@ -1077,6 +1077,14 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
|
||||||
// !!!Test out of synch behaviour
|
// !!!Test out of synch behaviour
|
||||||
//ct = NULL;
|
//ct = NULL;
|
||||||
|
|
||||||
|
// Check if the command was for the unit before it morphed, if so cancel it
|
||||||
|
if(ct == NULL && unit->getPreMorphType() != NULL) {
|
||||||
|
const CommandType *ctPreMorph = unit->getPreMorphType()->findCommandTypeById(networkCommand->getCommandTypeId());
|
||||||
|
if(ctPreMorph != NULL) {
|
||||||
|
ct = unit->getType()->getFirstCtOfClass(ccStop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(ct == NULL) {
|
if(ct == NULL) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s Line: %d]\nCan not find command type for network command = [%s]\n%s\nfor unit = %d\n[%s]\n[%s]\nactual local factionIndex = %d.\nUnit Type Info:\n[%s]\nNetwork unit type:\n[%s]\nGame out of synch.",
|
snprintf(szBuf,8096,"In [%s::%s Line: %d]\nCan not find command type for network command = [%s]\n%s\nfor unit = %d\n[%s]\n[%s]\nactual local factionIndex = %d.\nUnit Type Info:\n[%s]\nNetwork unit type:\n[%s]\nGame out of synch.",
|
||||||
|
|
|
@ -3019,6 +3019,9 @@ void ScriptManager::saveGame(XmlNode *rootNode) {
|
||||||
unRegisterCellTriggerEventListNode->addAttribute("eventId",intToStr(unRegisterCellTriggerEventList[i]), mapTagReplacements);
|
unRegisterCellTriggerEventListNode->addAttribute("eventId",intToStr(unRegisterCellTriggerEventList[i]), mapTagReplacements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scriptManagerNode->addAttribute("registeredDayNightEvent",intToStr(registeredDayNightEvent), mapTagReplacements);
|
||||||
|
scriptManagerNode->addAttribute("lastDayNightTriggerStatus",intToStr(lastDayNightTriggerStatus), mapTagReplacements);
|
||||||
|
|
||||||
luaScript.saveGame(scriptManagerNode);
|
luaScript.saveGame(scriptManagerNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3129,6 +3132,13 @@ void ScriptManager::loadGame(const XmlNode *rootNode) {
|
||||||
unRegisterCellTriggerEventList.push_back(node->getAttribute("eventId")->getIntValue());
|
unRegisterCellTriggerEventList.push_back(node->getAttribute("eventId")->getIntValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(scriptManagerNode->hasAttribute("registeredDayNightEvent") == true) {
|
||||||
|
registeredDayNightEvent = scriptManagerNode->getAttribute("registeredDayNightEvent")->getIntValue() != 0;
|
||||||
|
}
|
||||||
|
if(scriptManagerNode->hasAttribute("lastDayNightTriggerStatus") == true) {
|
||||||
|
lastDayNightTriggerStatus = scriptManagerNode->getAttribute("lastDayNightTriggerStatus")->getIntValue();
|
||||||
|
}
|
||||||
|
|
||||||
luaScript.loadGame(scriptManagerNode);
|
luaScript.loadGame(scriptManagerNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2906,7 +2906,7 @@ void Unit::morphAttackBoosts(Unit *unit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Unit::morph(const MorphCommandType *mct){
|
bool Unit::morph(const MorphCommandType *mct) {
|
||||||
|
|
||||||
if(mct == NULL) {
|
if(mct == NULL) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
|
@ -2922,9 +2922,14 @@ bool Unit::morph(const MorphCommandType *mct){
|
||||||
throw megaglest_runtime_error(szBuf);
|
throw megaglest_runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
Field morphUnitField=fLand;
|
Field morphUnitField = fLand;
|
||||||
if(morphUnitType->getField(fAir)) morphUnitField=fAir;
|
if(morphUnitType->getField(fAir)) {
|
||||||
if(morphUnitType->getField(fLand)) morphUnitField=fLand;
|
morphUnitField = fAir;
|
||||||
|
}
|
||||||
|
else if(morphUnitType->getField(fLand)) {
|
||||||
|
morphUnitField = fLand;
|
||||||
|
}
|
||||||
|
|
||||||
map->clearUnitCells(this, pos, false);
|
map->clearUnitCells(this, pos, false);
|
||||||
if(map->isFreeCellsOrHasUnit(pos, morphUnitType->getSize(), morphUnitField, this,morphUnitType)) {
|
if(map->isFreeCellsOrHasUnit(pos, morphUnitType->getSize(), morphUnitField, this,morphUnitType)) {
|
||||||
map->clearUnitCells(this, pos, true);
|
map->clearUnitCells(this, pos, true);
|
||||||
|
@ -2947,6 +2952,7 @@ bool Unit::morph(const MorphCommandType *mct){
|
||||||
|
|
||||||
checkModelStateInfoForNewHpValue();
|
checkModelStateInfoForNewHpValue();
|
||||||
|
|
||||||
|
preMorph_type = type;
|
||||||
type= morphUnitType;
|
type= morphUnitType;
|
||||||
currField=morphUnitField;
|
currField=morphUnitField;
|
||||||
computeTotalUpgrade();
|
computeTotalUpgrade();
|
||||||
|
@ -3848,6 +3854,7 @@ void Unit::saveGame(XmlNode *rootNode) {
|
||||||
unitNode->addAttribute("id",intToStr(id), mapTagReplacements);
|
unitNode->addAttribute("id",intToStr(id), mapTagReplacements);
|
||||||
// For info purposes only
|
// For info purposes only
|
||||||
unitNode->addAttribute("name",type->getName(), mapTagReplacements);
|
unitNode->addAttribute("name",type->getName(), mapTagReplacements);
|
||||||
|
|
||||||
// int hp;
|
// int hp;
|
||||||
unitNode->addAttribute("hp",intToStr(hp), mapTagReplacements);
|
unitNode->addAttribute("hp",intToStr(hp), mapTagReplacements);
|
||||||
// int ep;
|
// int ep;
|
||||||
|
@ -3908,6 +3915,9 @@ void Unit::saveGame(XmlNode *rootNode) {
|
||||||
unitNode->addAttribute("rotationX",floatToStr(rotationX,16), mapTagReplacements);
|
unitNode->addAttribute("rotationX",floatToStr(rotationX,16), mapTagReplacements);
|
||||||
// const UnitType *type;
|
// const UnitType *type;
|
||||||
unitNode->addAttribute("type",type->getName(), mapTagReplacements);
|
unitNode->addAttribute("type",type->getName(), mapTagReplacements);
|
||||||
|
|
||||||
|
unitNode->addAttribute("preMorph_type",(preMorph_type != NULL ? preMorph_type->getName() : ""), mapTagReplacements);
|
||||||
|
|
||||||
// const ResourceType *loadType;
|
// const ResourceType *loadType;
|
||||||
if(loadType != NULL) {
|
if(loadType != NULL) {
|
||||||
unitNode->addAttribute("loadType",loadType->getName(), mapTagReplacements);
|
unitNode->addAttribute("loadType",loadType->getName(), mapTagReplacements);
|
||||||
|
@ -4155,6 +4165,12 @@ 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(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);
|
Unit *result = new Unit(newUnitId, newpath, newUnitPos, ut, faction, world->getMapPtr(), newModelFacing);
|
||||||
|
|
||||||
|
if(unitNode->hasAttribute("preMorph_name") == true) {
|
||||||
|
string newUnitType_preMorph = unitNode->getAttribute("preMorph_name")->getValue();
|
||||||
|
const UnitType *ut_premorph = faction->getType()->getUnitType(newUnitType_preMorph);
|
||||||
|
result->preMorph_type = ut_premorph;
|
||||||
|
}
|
||||||
|
|
||||||
result->lastRotation = unitNode->getAttribute("lastRotation")->getFloatValue();
|
result->lastRotation = unitNode->getAttribute("lastRotation")->getFloatValue();
|
||||||
result->targetRotation = unitNode->getAttribute("targetRotation")->getFloatValue();
|
result->targetRotation = unitNode->getAttribute("targetRotation")->getFloatValue();
|
||||||
result->rotation = unitNode->getAttribute("rotation")->getFloatValue();
|
result->rotation = unitNode->getAttribute("rotation")->getFloatValue();
|
||||||
|
|
|
@ -376,6 +376,7 @@ private:
|
||||||
float rotationZ;
|
float rotationZ;
|
||||||
float rotationX;
|
float rotationX;
|
||||||
|
|
||||||
|
const UnitType *preMorph_type;
|
||||||
const UnitType *type;
|
const UnitType *type;
|
||||||
const ResourceType *loadType;
|
const ResourceType *loadType;
|
||||||
const SkillType *currSkill;
|
const SkillType *currSkill;
|
||||||
|
@ -527,6 +528,8 @@ public:
|
||||||
inline Faction *getFaction() const {return faction;}
|
inline Faction *getFaction() const {return faction;}
|
||||||
inline const ResourceType *getLoadType() const {return loadType;}
|
inline const ResourceType *getLoadType() const {return loadType;}
|
||||||
inline const UnitType *getType() const {return type;}
|
inline const UnitType *getType() const {return type;}
|
||||||
|
inline const UnitType *getPreMorphType() const {return preMorph_type;}
|
||||||
|
|
||||||
inline const SkillType *getCurrSkill() const {return currSkill;}
|
inline const SkillType *getCurrSkill() const {return currSkill;}
|
||||||
inline const TotalUpgrade *getTotalUpgrade() const {return &totalUpgrade;}
|
inline const TotalUpgrade *getTotalUpgrade() const {return &totalUpgrade;}
|
||||||
inline float getRotation() const {return rotation;}
|
inline float getRotation() const {return rotation;}
|
||||||
|
|
Loading…
Reference in New Issue