2016-09-10 02:28:11 +02: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 10:26:03 +02:00
|
|
|
#include "StdInc.h"
|
|
|
|
#include "CSerializer.h"
|
|
|
|
|
2023-06-23 17:02:48 +02:00
|
|
|
#include "../gameState/CGameState.h"
|
2017-07-13 10:26:03 +02:00
|
|
|
#include "../mapping/CMap.h"
|
|
|
|
#include "../CHeroHandler.h"
|
|
|
|
#include "../mapObjects/CGHeroInstance.h"
|
2016-09-10 02:28:11 +02:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2023-02-11 17:13:21 +02:00
|
|
|
//must be instantiated in .cpp file for access to complete types of all member fields
|
|
|
|
CSerializer::~CSerializer() = default;
|
2016-09-10 02:28:11 +02:00
|
|
|
|
|
|
|
void CSerializer::addStdVecItems(CGameState *gs, LibClasses *lib)
|
|
|
|
{
|
|
|
|
registerVectoredType<CGObjectInstance, ObjectInstanceID>(&gs->map->objects,
|
|
|
|
[](const CGObjectInstance &obj){ return obj.id; });
|
|
|
|
registerVectoredType<CGHeroInstance, HeroTypeID>(&gs->map->allHeroes,
|
2023-01-02 13:27:03 +02:00
|
|
|
[](const CGHeroInstance &h){ return h.type->getId(); });
|
2016-09-10 02:28:11 +02:00
|
|
|
registerVectoredType<CArtifactInstance, ArtifactInstanceID>(&gs->map->artInstances,
|
2023-07-03 22:11:56 +02:00
|
|
|
[](const CArtifactInstance &artInst){ return artInst.getId(); });
|
2016-09-10 02:28:11 +02:00
|
|
|
registerVectoredType<CQuest, si32>(&gs->map->quests,
|
|
|
|
[](const CQuest &q){ return q.qid; });
|
|
|
|
|
|
|
|
smartVectorMembersSerialization = true;
|
|
|
|
}
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|