From c3775486db329407add070ec4c8e1870132bbc71 Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Tue, 23 Feb 2016 23:23:39 +0300 Subject: [PATCH] Serizlize main town info --- lib/mapping/MapFormatJson.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/mapping/MapFormatJson.cpp b/lib/mapping/MapFormatJson.cpp index 9b33d2b52..5cc7edd55 100644 --- a/lib/mapping/MapFormatJson.cpp +++ b/lib/mapping/MapFormatJson.cpp @@ -237,27 +237,26 @@ void CMapFormatJson::serializePlayerInfo(JsonSerializeFormat & handler) handler.serializeEnum("canPlay", "PlayerOrAI", "AIOnly", info.canHumanPlay); - //mainTown - if(handler.saving) + //saving whole structure only if position is valid + if(!handler.saving || info.posOfMainTown.valid()) { - + auto mainTown = handler.enterStruct("mainTown"); + handler.serializeBool("generateHero", info.generateHeroAtMainTown); + handler.serializeNumeric("x", info.posOfMainTown.x); + handler.serializeNumeric("y", info.posOfMainTown.y); + handler.serializeNumeric("l", info.posOfMainTown.z); } - else + if(!handler.saving) { - + info.hasMainTown = info.posOfMainTown.valid(); } - handler.serializeBool("generateHeroAtMainTown", info.generateHeroAtMainTown); - - //mainHero //mainHeroPortrait //mainCustomHeroName - //towns - //heroes { //auto heroes = playerData.enterStruct("heroes"); @@ -270,10 +269,8 @@ void CMapFormatJson::serializePlayerInfo(JsonSerializeFormat & handler) // true if main town is random and generateHeroAtMainTown==true // or main hero is random //TODO: recheck mechanics - // info.isFactionRandom = + info.isFactionRandom = info.allowedFactions.size() > 1; } - - } }