mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-22 22:13:35 +02:00
Remove logic for serialization of VLC entities
This commit is contained in:
parent
01d787fb5a
commit
c4481f3797
@ -235,25 +235,6 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPointerImpl(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename T, typename std::enable_if_t < std::is_base_of_v<Entity, std::remove_pointer_t<T>>, int > = 0 >
|
|
||||||
void loadPointerImpl(T &data)
|
|
||||||
{
|
|
||||||
using DataType = std::remove_pointer_t<T>;
|
|
||||||
|
|
||||||
typename DataType::IdentifierType index;
|
|
||||||
load(index);
|
|
||||||
|
|
||||||
auto * constEntity = index.toEntity(VLC);
|
|
||||||
auto * constData = dynamic_cast<const DataType *>(constEntity);
|
|
||||||
data = const_cast<DataType *>(constData);
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename T, typename std::enable_if_t < !std::is_base_of_v<Entity, std::remove_pointer_t<T>>, int > = 0 >
|
|
||||||
void loadPointerImpl(T &data)
|
|
||||||
{
|
|
||||||
if(reader->smartVectorMembersSerialization)
|
if(reader->smartVectorMembersSerialization)
|
||||||
{
|
{
|
||||||
typedef typename std::remove_const_t<typename std::remove_pointer_t<T>> TObjectType; //eg: const CGHeroInstance * => CGHeroInstance
|
typedef typename std::remove_const_t<typename std::remove_pointer_t<T>> TObjectType; //eg: const CGHeroInstance * => CGHeroInstance
|
||||||
|
@ -186,19 +186,6 @@ public:
|
|||||||
if(data == nullptr)
|
if(data == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
savePointerImpl(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename T, typename std::enable_if_t < std::is_base_of_v<Entity, std::remove_pointer_t<T>>, int > = 0 >
|
|
||||||
void savePointerImpl(const T &data)
|
|
||||||
{
|
|
||||||
auto index = data->getId();
|
|
||||||
save(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename T, typename std::enable_if_t < !std::is_base_of_v<Entity, std::remove_pointer_t<T>>, int > = 0 >
|
|
||||||
void savePointerImpl(const T &data)
|
|
||||||
{
|
|
||||||
typedef typename std::remove_const_t<typename std::remove_pointer_t<T>> TObjectType;
|
typedef typename std::remove_const_t<typename std::remove_pointer_t<T>> TObjectType;
|
||||||
|
|
||||||
if(writer->smartVectorMembersSerialization)
|
if(writer->smartVectorMembersSerialization)
|
||||||
|
Loading…
Reference in New Issue
Block a user