1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Load object appearance and pos before addNewObject call, it is required for block-visit calculation.

Added a test for tile block-visit.
This commit is contained in:
AlexVinS
2016-02-23 23:46:33 +03:00
parent c3775486db
commit d2f04332d0
3 changed files with 27 additions and 20 deletions

View File

@ -322,31 +322,24 @@ bool CGObjectInstance::passableFor(PlayerColor color) const
void CGObjectInstance::serializeJson(JsonSerializeFormat & handler)
{
//only save here, loading is handled by map loader
if(handler.saving)
{
handler.serializeString("type", typeName);
handler.serializeString("subtype", subTypeName);
}
handler.serializeNumeric("x", pos.x);
handler.serializeNumeric("y", pos.y);
handler.serializeNumeric("l", pos.z);
if(handler.saving)
{
handler.serializeNumeric("x", pos.x);
handler.serializeNumeric("y", pos.y);
handler.serializeNumeric("l", pos.z);
appearance.writeJson(handler.getCurrent()["template"], false);
}
else
{
appearance.readJson(handler.getCurrent()["template"], false);
}
{
auto options = handler.enterStruct("options");
serializeJsonOptions(handler);
}
if(handler.saving && handler.getCurrent()["options"].isNull())
if(handler.saving && handler.getCurrent()["options"].Struct().empty())
{
handler.getCurrent().Struct().erase("options");
}