- split the TObjPtr serializers into a separate file to avoid polluting everything that needs to use the serializer.

To use these it is necessary to include dobject.h and all its dependencies, so this should not be done unless necessary.
This commit is contained in:
Christoph Oelckers 2020-04-11 19:26:28 +02:00
parent f02c5c0a56
commit f74efcf721
18 changed files with 35 additions and 15 deletions

View File

@ -39,6 +39,7 @@
#include "v_video.h"
#include "cmdlib.h"
#include "serializer.h"
#include "serialize_obj.h"
#include "doomstat.h"
#include "vm.h"

View File

@ -49,6 +49,7 @@
#include "d_net.h"
#include "d_player.h"
#include "serializer.h"
#include "serialize_obj.h"
#include "r_utility.h"
#include "cmdlib.h"
#include "g_levellocals.h"

View File

@ -53,6 +53,7 @@
#include "r_utility.h"
#include "r_sky.h"
#include "serializer.h"
#include "serialize_obj.h"
#include "g_levellocals.h"
#include "events.h"
#include "p_destructible.h"

View File

@ -35,6 +35,7 @@
#include "a_sharedglobal.h"
#include "d_player.h"
#include "serializer.h"
#include "serialize_obj.h"
#include "g_levellocals.h"
IMPLEMENT_CLASS(DFlashFader, false, true)

View File

@ -38,6 +38,7 @@
#include "p_spec.h"
#include "c_dispatch.h"
#include "serializer.h"
#include "serialize_obj.h"
#include "g_levellocals.h"
//==========================================================================

View File

@ -42,6 +42,7 @@
#include "t_script.h"
#include "a_pickups.h"
#include "serializer.h"
#include "serialize_obj.h"
#include "g_levellocals.h"

View File

@ -35,6 +35,7 @@
#include "decallib.h"
#include "a_decalfx.h"
#include "serializer.h"
#include "serialize_obj.h"
#include "a_sharedglobal.h"
#include "g_levellocals.h"
#include "m_fixed.h"

View File

@ -34,6 +34,7 @@
#include "doomstat.h"
#include "r_state.h"
#include "serializer.h"
#include "serialize_obj.h"
#include "p_3dmidtex.h"
#include "p_spec.h"
#include "r_data/r_interpolate.h"

View File

@ -38,6 +38,7 @@
#include "g_level.h"
#include "s_sndseq.h"
#include "serializer.h"
#include "serialize_obj.h"
#include "r_data/r_interpolate.h"
#include "g_levellocals.h"

View File

@ -30,6 +30,7 @@
#include "actor.h"
#include "p_spec.h"
#include "serializer.h"
#include "serialize_obj.h"
#include "p_lnspec.h"
#include "p_maputl.h"
#include "p_local.h"

View File

@ -29,6 +29,7 @@
#include "actor.h"
#include "a_sharedglobal.h"
#include "serializer.h"
#include "serialize_obj.h"
#include "d_player.h"
#include "r_utility.h"
#include "g_levellocals.h"

View File

@ -59,6 +59,7 @@
#include "actor.h"
#include "p_spec.h"
#include "serializer.h"
#include "serialize_obj.h"
#include "p_lnspec.h"
#include "r_data/r_interpolate.h"
#include "g_levellocals.h"

View File

@ -78,6 +78,7 @@
#include "c_dispatch.h"
#include "d_net.h"
#include "serializer.h"
#include "serialize_obj.h"
#include "d_player.h"
#include "r_utility.h"
#include "p_blockmap.h"

View File

@ -38,6 +38,7 @@
#include "r_canvastexture.h"
#include "g_levellocals.h"
#include "serializer.h"
#include "serialize_obj.h"
#include "texturemanager.h"
//==========================================================================

17
src/serialize_obj.h Normal file
View File

@ -0,0 +1,17 @@
#pragma once
// These are in a separate header because they require some rather 'dirty' headers to work which should not be part of serializer.h
template<class T>
FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr<T> &value, TObjPtr<T> *)
{
Serialize(arc, key, value.o, nullptr);
return arc;
}
template<class T>
FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr<T> &value, T *)
{
Serialize(arc, key, value.o, nullptr);
return arc;
}

View File

@ -950,7 +950,7 @@ void FSerializer::ReadObjects(bool hubtravel)
{
Printf(TEXTCOLOR_RED "Unknown object class '%s' in savegame\n", clsname.GetChars());
founderrors = true;
r->mDObjects[i] = RUNTIME_CLASS(AActor)->CreateNew(); // make sure we got at least a valid pointer for the duration of the loading process.
r->mDObjects[i] = RUNTIME_CLASS(DObject)->CreateNew(); // make sure we got at least a valid pointer for the duration of the loading process.
r->mDObjects[i]->Destroy(); // but we do not want to keep this around, so destroy it right away.
}
else
@ -1485,7 +1485,8 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FTextureID &value, FTe
arc.WriteKey(key);
arc.w->StartArray();
arc.w->String(name);
arc.w->Int(static_cast<int>(pic->UseType));
int ut = static_cast<int>(pic->GetUseType());
arc.w->Int(ut);
arc.w->EndArray();
}
}

View File

@ -217,19 +217,6 @@ FSerializer &Serialize(FSerializer &arc, const char *key, T *&value, T **)
return arc;
}
template<class T>
FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr<T> &value, TObjPtr<T> *)
{
Serialize(arc, key, value.o, nullptr);
return arc;
}
template<class T>
FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr<T> &value, T *)
{
Serialize(arc, key, value.o, nullptr);
return arc;
}
template<class T, class TT>
FSerializer &Serialize(FSerializer &arc, const char *key, TArray<T, TT> &value, TArray<T, TT> *def)

View File

@ -37,6 +37,7 @@
#include "g_level.h"
#include "serializer.h"
#include "serialize_obj.h"
#include "d_player.h"
#include "g_levellocals.h"
#include "vm.h"