From f74efcf7215726ad82d6909fdac64fac01a6d0f1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 11 Apr 2020 19:26:28 +0200 Subject: [PATCH] - 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. --- src/g_statusbar/hudmessages.cpp | 1 + src/g_statusbar/shared_sbar.cpp | 1 + src/p_saveg.cpp | 1 + src/playsim/a_flashfader.cpp | 1 + src/playsim/fragglescript/t_script.cpp | 1 + src/playsim/fragglescript/t_variable.cpp | 1 + src/playsim/mapthinkers/a_decalfx.cpp | 1 + src/playsim/mapthinkers/a_floor.cpp | 1 + src/playsim/mapthinkers/a_pillar.cpp | 1 + src/playsim/mapthinkers/a_pusher.cpp | 1 + src/playsim/mapthinkers/a_quake.cpp | 1 + src/playsim/mapthinkers/a_scroll.cpp | 1 + src/playsim/p_user.cpp | 1 + src/r_data/r_canvastexture.cpp | 1 + src/serialize_obj.h | 17 +++++++++++++++++ src/serializer.cpp | 5 +++-- src/serializer.h | 13 ------------- src/sound/s_sndseq.cpp | 1 + 18 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 src/serialize_obj.h diff --git a/src/g_statusbar/hudmessages.cpp b/src/g_statusbar/hudmessages.cpp index c4ea1cf8d..a708cf168 100644 --- a/src/g_statusbar/hudmessages.cpp +++ b/src/g_statusbar/hudmessages.cpp @@ -39,6 +39,7 @@ #include "v_video.h" #include "cmdlib.h" #include "serializer.h" +#include "serialize_obj.h" #include "doomstat.h" #include "vm.h" diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index a8487c349..48b3326e8 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -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" diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 5b6d530d0..d84634f5f 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -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" diff --git a/src/playsim/a_flashfader.cpp b/src/playsim/a_flashfader.cpp index e08ae8bf6..41dcc2d88 100644 --- a/src/playsim/a_flashfader.cpp +++ b/src/playsim/a_flashfader.cpp @@ -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) diff --git a/src/playsim/fragglescript/t_script.cpp b/src/playsim/fragglescript/t_script.cpp index 435c68d31..2eb3ef229 100644 --- a/src/playsim/fragglescript/t_script.cpp +++ b/src/playsim/fragglescript/t_script.cpp @@ -38,6 +38,7 @@ #include "p_spec.h" #include "c_dispatch.h" #include "serializer.h" +#include "serialize_obj.h" #include "g_levellocals.h" //========================================================================== diff --git a/src/playsim/fragglescript/t_variable.cpp b/src/playsim/fragglescript/t_variable.cpp index 8c596832d..424490805 100644 --- a/src/playsim/fragglescript/t_variable.cpp +++ b/src/playsim/fragglescript/t_variable.cpp @@ -42,6 +42,7 @@ #include "t_script.h" #include "a_pickups.h" #include "serializer.h" +#include "serialize_obj.h" #include "g_levellocals.h" diff --git a/src/playsim/mapthinkers/a_decalfx.cpp b/src/playsim/mapthinkers/a_decalfx.cpp index 33b5e3607..76b78ea29 100644 --- a/src/playsim/mapthinkers/a_decalfx.cpp +++ b/src/playsim/mapthinkers/a_decalfx.cpp @@ -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" diff --git a/src/playsim/mapthinkers/a_floor.cpp b/src/playsim/mapthinkers/a_floor.cpp index 0bd2ae5b7..9bb937e7a 100644 --- a/src/playsim/mapthinkers/a_floor.cpp +++ b/src/playsim/mapthinkers/a_floor.cpp @@ -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" diff --git a/src/playsim/mapthinkers/a_pillar.cpp b/src/playsim/mapthinkers/a_pillar.cpp index fb7605617..c5a9c2877 100644 --- a/src/playsim/mapthinkers/a_pillar.cpp +++ b/src/playsim/mapthinkers/a_pillar.cpp @@ -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" diff --git a/src/playsim/mapthinkers/a_pusher.cpp b/src/playsim/mapthinkers/a_pusher.cpp index 92cb502f7..f024cbb3e 100644 --- a/src/playsim/mapthinkers/a_pusher.cpp +++ b/src/playsim/mapthinkers/a_pusher.cpp @@ -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" diff --git a/src/playsim/mapthinkers/a_quake.cpp b/src/playsim/mapthinkers/a_quake.cpp index e21c3c313..b906665e8 100644 --- a/src/playsim/mapthinkers/a_quake.cpp +++ b/src/playsim/mapthinkers/a_quake.cpp @@ -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" diff --git a/src/playsim/mapthinkers/a_scroll.cpp b/src/playsim/mapthinkers/a_scroll.cpp index c62aafe6f..66cb2731d 100644 --- a/src/playsim/mapthinkers/a_scroll.cpp +++ b/src/playsim/mapthinkers/a_scroll.cpp @@ -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" diff --git a/src/playsim/p_user.cpp b/src/playsim/p_user.cpp index df8ab96de..93df0fe1f 100644 --- a/src/playsim/p_user.cpp +++ b/src/playsim/p_user.cpp @@ -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" diff --git a/src/r_data/r_canvastexture.cpp b/src/r_data/r_canvastexture.cpp index c0d0187bb..4e7e4a107 100644 --- a/src/r_data/r_canvastexture.cpp +++ b/src/r_data/r_canvastexture.cpp @@ -38,6 +38,7 @@ #include "r_canvastexture.h" #include "g_levellocals.h" #include "serializer.h" +#include "serialize_obj.h" #include "texturemanager.h" //========================================================================== diff --git a/src/serialize_obj.h b/src/serialize_obj.h new file mode 100644 index 000000000..c818d08fa --- /dev/null +++ b/src/serialize_obj.h @@ -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 +FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr &value, TObjPtr *) +{ + Serialize(arc, key, value.o, nullptr); + return arc; +} + +template +FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr &value, T *) +{ + Serialize(arc, key, value.o, nullptr); + return arc; +} diff --git a/src/serializer.cpp b/src/serializer.cpp index 79d12ec37..5fed64f9a 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -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(pic->UseType)); + int ut = static_cast(pic->GetUseType()); + arc.w->Int(ut); arc.w->EndArray(); } } diff --git a/src/serializer.h b/src/serializer.h index e0da50aed..fcfbcaa18 100644 --- a/src/serializer.h +++ b/src/serializer.h @@ -217,19 +217,6 @@ FSerializer &Serialize(FSerializer &arc, const char *key, T *&value, T **) return arc; } -template -FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr &value, TObjPtr *) -{ - Serialize(arc, key, value.o, nullptr); - return arc; -} - -template -FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr &value, T *) -{ - Serialize(arc, key, value.o, nullptr); - return arc; -} template FSerializer &Serialize(FSerializer &arc, const char *key, TArray &value, TArray *def) diff --git a/src/sound/s_sndseq.cpp b/src/sound/s_sndseq.cpp index a2be7721c..01b30f5e4 100644 --- a/src/sound/s_sndseq.cpp +++ b/src/sound/s_sndseq.cpp @@ -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"