mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Start implementing player info serialization
This commit is contained in:
parent
f5b348a1d1
commit
7c8d29b871
@ -16,6 +16,7 @@
|
||||
#include "CMap.h"
|
||||
#include "../CModHandler.h"
|
||||
#include "../VCMI_Lib.h"
|
||||
#include "../StringConstants.h"
|
||||
|
||||
namespace TriggeredEventsDetail
|
||||
{
|
||||
@ -508,7 +509,7 @@ void CMapSaverJson::writeHeader()
|
||||
|
||||
writeTriggeredEvents(header);
|
||||
|
||||
//todo: player info
|
||||
writePlayerInfo(header);
|
||||
|
||||
//todo: allowedHeroes;
|
||||
//todo: placeholdedHeroes;
|
||||
@ -516,6 +517,25 @@ void CMapSaverJson::writeHeader()
|
||||
addToArchive(header, HEADER_FILE_NAME);
|
||||
}
|
||||
|
||||
void CMapSaverJson::writePlayerInfo(JsonNode & output)
|
||||
{
|
||||
JsonNode & dest = output["players"];
|
||||
dest.setType(JsonNode::DATA_STRUCT);
|
||||
|
||||
for(int player = 0; player < PlayerColor::PLAYER_LIMIT_I; player++)
|
||||
{
|
||||
const PlayerInfo & info = map->players[player];
|
||||
|
||||
if(info.canAnyonePlay())
|
||||
writePlayerInfo(info, dest[GameConstants::PLAYER_COLOR_NAMES[player]);
|
||||
}
|
||||
}
|
||||
|
||||
void CMapSaverJson::writePlayerInfo(const PlayerInfo & info, JsonNode & output)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const std::string CMapSaverJson::writeTerrainTile(const TerrainTile & tile)
|
||||
{
|
||||
using namespace TerrainDetail;
|
||||
|
@ -171,7 +171,18 @@ private:
|
||||
void addToArchive(const JsonNode & data, const std::string & filename);
|
||||
|
||||
void writeHeader();
|
||||
|
||||
|
||||
/**
|
||||
* Save all players info to header
|
||||
* @param output serialized header
|
||||
*/
|
||||
void writePlayerInfo(JsonNode & output);
|
||||
/**
|
||||
* Save one player info
|
||||
* @param output empty object
|
||||
*/
|
||||
void writePlayerInfo(const PlayerInfo & info, JsonNode & output);
|
||||
|
||||
const std::string writeTerrainTile(const TerrainTile & tile);
|
||||
|
||||
JsonNode writeTerrainLevel(const int index);
|
||||
|
Loading…
x
Reference in New Issue
Block a user