1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

First version that works in lobby

This commit is contained in:
Tomasz Zieliński
2024-02-29 12:45:08 +01:00
parent 54fefd34c7
commit 2c32c770f7
11 changed files with 148 additions and 24 deletions

View File

@@ -17,6 +17,7 @@
#include "CRandomGenerator.h"
#include "../VCMI_Lib.h"
#include "../CTownHandler.h"
#include "serializer/JsonSerializeFormat.h"
VCMI_LIB_NAMESPACE_BEGIN
@@ -816,4 +817,45 @@ void CMapGenOptions::CPlayerSettings::setTeam(const TeamID & value)
team = value;
}
void CMapGenOptions::serializeJson(JsonSerializeFormat & handler)
{
handler.serializeInt("width", width);
handler.serializeInt("height", height);
handler.serializeBool("haswoLevels", hasTwoLevels);
handler.serializeInt("humanOrCpuPlayerCount", humanOrCpuPlayerCount);
handler.serializeInt("teamCount", teamCount);
handler.serializeInt("compOnlyPlayerCount", compOnlyPlayerCount);
handler.serializeInt("compOnlyTeamCount", compOnlyTeamCount);
handler.serializeInt("waterContent", waterContent);
handler.serializeInt("monsterStrength", monsterStrength);
std::string templateName;
if(mapTemplate && handler.saving)
{
templateName = mapTemplate->getId();
}
handler.serializeString("templateName", templateName);
if(!handler.saving)
{
// FIXME: doesn't load correctly? Name is "Jebus Cross"
setMapTemplate(templateName);
if (mapTemplate)
{
logGlobal->warn("Loaded previous RMG template");
// FIXME: Update dropdown menu
}
else
{
logGlobal->warn("Failed to deserialize previous map template");
}
}
handler.serializeIdArray("roads", enabledRoads);
//TODO: Serialize CMapGenOptions::CPlayerSettings ? This won't b saved between sessions
if (!handler.saving)
{
resetPlayersMap();
}
}
VCMI_LIB_NAMESPACE_END