mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Fix few cases of tempOwner initialization.
This commit is contained in:
parent
709dd833d5
commit
800f32c4cb
@ -1481,8 +1481,9 @@ void CGHeroInstance::writeJsonOptions(JsonNode& json) const
|
||||
json["type"].String() = VLC->heroh->heroes[subID]->identifier;
|
||||
}
|
||||
|
||||
CCreatureSet::writeJson(json["army"]);
|
||||
CGObjectInstance::writeOwner(json);
|
||||
|
||||
CCreatureSet::writeJson(json["army"]);
|
||||
CArtifactSet::writeJson(json["artifacts"]);
|
||||
|
||||
}
|
||||
@ -1501,10 +1502,12 @@ void CGHeroInstance::readJsonOptions(const JsonNode& json)
|
||||
subID = 0; //fallback to Orrin, throw error instead?
|
||||
}
|
||||
|
||||
CCreatureSet::readJson(json["army"]);
|
||||
CGObjectInstance::readOwner(json);
|
||||
|
||||
CCreatureSet::readJson(json["army"]);
|
||||
CArtifactSet::readJson(json["artifacts"]);
|
||||
}
|
||||
|
||||
bool CGHeroInstance::isMissionCritical() const
|
||||
{
|
||||
for(const TriggeredEvent & event : IObjectInterface::cb->getMapHeader()->triggeredEvents)
|
||||
|
@ -373,19 +373,22 @@ void CGObjectInstance::readJsonOptions(const JsonNode & json)
|
||||
|
||||
void CGObjectInstance::writeOwner(JsonNode & json) const
|
||||
{
|
||||
if(tempOwner != PlayerColor::UNFLAGGABLE)
|
||||
if(tempOwner.isValidPlayer())
|
||||
{
|
||||
PlayerColor p (tempOwner);
|
||||
if(p.isValidPlayer())
|
||||
json["owner"].String() = GameConstants::PLAYER_COLOR_NAMES[p.getNum()];
|
||||
json["owner"].String() = GameConstants::PLAYER_COLOR_NAMES[tempOwner.getNum()];
|
||||
}
|
||||
}
|
||||
|
||||
void CGObjectInstance::readOwner(const JsonNode & json)
|
||||
{
|
||||
tempOwner = PlayerColor::NEUTRAL;//this method assumes that object is ownable
|
||||
if(json["owner"].getType() == JsonNode::DATA_STRING)
|
||||
{
|
||||
tempOwner = PlayerColor(vstd::find_pos(GameConstants::PLAYER_COLOR_NAMES, json["owner"].String()));
|
||||
auto rawOwner = vstd::find_pos(GameConstants::PLAYER_COLOR_NAMES, json["owner"].String());
|
||||
if(rawOwner >=0)
|
||||
tempOwner = PlayerColor(rawOwner);
|
||||
else
|
||||
logGlobal->errorStream() << "Invalid owner :" << json["owner"].String();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1510,6 +1510,7 @@ bool CRmgTemplateZone::placeMines (CMapGenerator* gen)
|
||||
{
|
||||
auto mine = (CGMine *) factory.at(static_cast<si32>(res))->create(ObjectTemplate());
|
||||
mine->producedResource = res;
|
||||
mine->tempOwner = PlayerColor::NEUTRAL;
|
||||
mine->producedQuantity = mine->defaultResProduction();
|
||||
if (!i)
|
||||
addCloseObject(mine, 1500); //only firts one is close
|
||||
@ -1523,6 +1524,7 @@ bool CRmgTemplateZone::placeMines (CMapGenerator* gen)
|
||||
{
|
||||
auto mine = (CGMine *) factory.at(static_cast<si32>(res))->create(ObjectTemplate());
|
||||
mine->producedResource = res;
|
||||
mine->tempOwner = PlayerColor::NEUTRAL;
|
||||
mine->producedQuantity = mine->defaultResProduction();
|
||||
addRequiredObject(mine, 3500);
|
||||
}
|
||||
@ -1531,6 +1533,7 @@ bool CRmgTemplateZone::placeMines (CMapGenerator* gen)
|
||||
{
|
||||
auto mine = (CGMine *) factory.at(Res::GOLD)->create(ObjectTemplate());
|
||||
mine->producedResource = Res::GOLD;
|
||||
mine->tempOwner = PlayerColor::NEUTRAL;
|
||||
mine->producedQuantity = mine->defaultResProduction();
|
||||
addRequiredObject(mine, 7000);
|
||||
}
|
||||
|
@ -153,12 +153,12 @@ void MapComparer::compareObject(const CGObjectInstance * actual, const CGObjectI
|
||||
BOOST_CHECK_EQUAL(actual->getStringId(), expected->getStringId());
|
||||
BOOST_CHECK_EQUAL(typeid(actual).name(), typeid(expected).name());//todo: remove and use just comparison
|
||||
|
||||
std::string actualFullID = boost::to_string(boost::format("%s(%d)|%s(%d)") % actual->typeName % actual->id % actual->subTypeName % actual->subID);
|
||||
std::string expectedFullID = boost::to_string(boost::format("%s(%d)|%s(%d)") % expected->typeName % expected->id % expected->subTypeName % expected->subID);
|
||||
std::string actualFullID = boost::to_string(boost::format("%s(%d)|%s(%d) %d") % actual->typeName % actual->ID % actual->subTypeName % actual->subID % actual->tempOwner);
|
||||
std::string expectedFullID = boost::to_string(boost::format("%s(%d)|%s(%d) %d") % expected->typeName % expected->ID % expected->subTypeName % expected->subID % expected->tempOwner);
|
||||
|
||||
BOOST_CHECK_EQUAL(actualFullID, expectedFullID);
|
||||
BOOST_CHECK_EQUAL(actual->pos, expected->pos);
|
||||
BOOST_CHECK_EQUAL(actual->tempOwner,expected->tempOwner);
|
||||
//BOOST_CHECK_EQUAL(actual->tempOwner,expected->tempOwner);
|
||||
}
|
||||
|
||||
void MapComparer::compareObjects()
|
||||
|
Loading…
Reference in New Issue
Block a user