2016-09-10 03:28:11 +03:00
|
|
|
/*
|
|
|
|
* CSerializer.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2017-07-13 11:26:03 +03:00
|
|
|
#include "StdInc.h"
|
|
|
|
#include "CSerializer.h"
|
|
|
|
|
2023-06-23 18:02:48 +03:00
|
|
|
#include "../gameState/CGameState.h"
|
2017-07-13 11:26:03 +03:00
|
|
|
#include "../mapping/CMap.h"
|
|
|
|
#include "../CHeroHandler.h"
|
|
|
|
#include "../mapObjects/CGHeroInstance.h"
|
2024-01-09 16:43:36 +02:00
|
|
|
#include "../mapObjects/CQuest.h"
|
2016-09-10 03:28:11 +03:00
|
|
|
|
2022-07-26 16:07:42 +03:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2023-02-11 18:13:21 +03:00
|
|
|
//must be instantiated in .cpp file for access to complete types of all member fields
|
|
|
|
CSerializer::~CSerializer() = default;
|
2016-09-10 03:28:11 +03:00
|
|
|
|
|
|
|
void CSerializer::addStdVecItems(CGameState *gs, LibClasses *lib)
|
|
|
|
{
|
|
|
|
registerVectoredType<CGObjectInstance, ObjectInstanceID>(&gs->map->objects,
|
|
|
|
[](const CGObjectInstance &obj){ return obj.id; });
|
2024-01-09 16:43:36 +02:00
|
|
|
registerVectoredType<CHero, HeroTypeID>(&lib->heroh->objects,
|
|
|
|
[](const CHero &h){ return h.getId(); });
|
2016-09-10 03:28:11 +03:00
|
|
|
registerVectoredType<CGHeroInstance, HeroTypeID>(&gs->map->allHeroes,
|
2023-01-02 13:27:03 +02:00
|
|
|
[](const CGHeroInstance &h){ return h.type->getId(); });
|
2024-01-09 16:43:36 +02:00
|
|
|
registerVectoredType<CCreature, CreatureID>(&lib->creh->objects,
|
|
|
|
[](const CCreature &cre){ return cre.getId(); });
|
|
|
|
registerVectoredType<CArtifact, ArtifactID>(&lib->arth->objects,
|
|
|
|
[](const CArtifact &art){ return art.getId(); });
|
2016-09-10 03:28:11 +03:00
|
|
|
registerVectoredType<CArtifactInstance, ArtifactInstanceID>(&gs->map->artInstances,
|
2023-07-03 23:11:56 +03:00
|
|
|
[](const CArtifactInstance &artInst){ return artInst.getId(); });
|
2016-09-10 03:28:11 +03:00
|
|
|
registerVectoredType<CQuest, si32>(&gs->map->quests,
|
|
|
|
[](const CQuest &q){ return q.qid; });
|
|
|
|
|
|
|
|
smartVectorMembersSerialization = true;
|
|
|
|
}
|
2022-07-26 16:07:42 +03:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|