From d8ebbcfc08ced02e3fa7a9cd35d90c596b336198 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 15 Feb 2017 11:55:08 +0100 Subject: [PATCH 1/3] - fixed: When loading a savegame the player class in the userinfo needs to be updated. - fixed: Class pointers should not be added to the list of garbage collected pointers. - fixed several warnings in the event code. --- src/dobjtype.cpp | 11 +++++++++++ src/dobjtype.h | 1 + src/g_level.cpp | 2 +- src/m_cheat.cpp | 2 +- src/p_interaction.cpp | 2 +- src/p_mobj.cpp | 3 +-- src/p_saveg.cpp | 3 +++ src/win32/i_main.cpp | 2 +- 8 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 5d4ec59c97..211c73e824 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -1529,6 +1529,17 @@ bool PClassPointer::isCompatible(PType *type) return (other != nullptr && other->ClassRestriction->IsDescendantOf(ClassRestriction)); } +//========================================================================== +// +// PClassPointer :: SetPointer +// +//========================================================================== + +void PClassPointer::SetPointer(void *base, unsigned offset, TArray *special) const +{ + // Class pointers do not get added to FlatPointers because they are released from the GC. +} + //========================================================================== // // PClassPointer :: IsMatch diff --git a/src/dobjtype.h b/src/dobjtype.h index cc0a17da8d..0151e6c119 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -401,6 +401,7 @@ public: bool isCompatible(PType *type); + void SetPointer(void *base, unsigned offset, TArray *special = NULL) const override; virtual bool IsMatch(intptr_t id1, intptr_t id2) const; virtual void GetTypeIDs(intptr_t &id1, intptr_t &id2) const; }; diff --git a/src/g_level.cpp b/src/g_level.cpp index c34a80bb74..0842f3ec84 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1365,7 +1365,7 @@ void G_FinishTravel () for (int i = 0; i < pawnsnum; i++) { // [ZZ] fire the enter hook. - E_PlayerEntered(pawns[i]->player - players, true); + E_PlayerEntered(int(pawns[i]->player - players), true); // FBehavior::StaticStartTypedScripts(SCRIPT_Return, pawns[i], true); } diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index d11fb95745..c78ab5dde1 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -350,7 +350,7 @@ void cht_DoCheat (player_t *player, int cheat) // player is now alive. // fire E_PlayerRespawned and start the ACS SCRIPT_Respawn. - E_PlayerRespawned(player - players); + E_PlayerRespawned(int(player - players)); // FBehavior::StaticStartTypedScripts(SCRIPT_Respawn, player->mo, true); diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 24b37a56ae..28df6e761f 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -611,7 +611,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags) ClientObituary (this, inflictor, source, dmgflags); // [ZZ] fire player death hook - E_PlayerDied(player - players); + E_PlayerDied(int(player - players)); // Death script execution, care of Skull Tag FBehavior::StaticStartTypedScripts (SCRIPT_Death, this, true); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 81fab5733a..5bf6118004 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -143,7 +143,6 @@ IMPLEMENT_POINTERS_START(AActor) IMPLEMENT_POINTER(LastHeard) IMPLEMENT_POINTER(master) IMPLEMENT_POINTER(Poisoner) - IMPLEMENT_POINTER(DamageFunc) IMPLEMENT_POINTER(alternative) IMPLEMENT_POINTERS_END @@ -5513,7 +5512,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) { // [ZZ] fire non-hub ENTER event // level.time is a hack to make sure that we don't call it on dummy player initialization during hub return. - if (!level.time) E_PlayerEntered(p - players, false); + if (!level.time) E_PlayerEntered(int(p - players), false); FBehavior::StaticStartTypedScripts (SCRIPT_Enter, p->mo, true); } else if (state == PST_REBORN) diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 8f465e081b..a3208598d2 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -832,7 +832,10 @@ void CopyPlayer(player_t *dst, player_t *src, const char *name) else { dst->userinfo.TransferFrom(uibackup); + // The player class must come from the save, so that the menu reflects the currently playing one. + dst->userinfo.PlayerClassChanged(src->mo->GetClass()->DisplayName); } + // Validate the skin dst->userinfo.SkinNumChanged(R_FindSkin(skins[dst->userinfo.GetSkin()].name, dst->CurrentPlayerClass)); diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index 14c4791c60..29aa2e8d77 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -1337,7 +1337,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE nothing, LPSTR cmdline, int n _CrtSetDbgFlag (_CrtSetDbgFlag(0) | _CRTDBG_LEAK_CHECK_DF); // Use this to break at a specific allocation number. - //_crtBreakAlloc = 53039; + _crtBreakAlloc = 165966; #endif DoMain (hInstance); From c8db1f151e656ab4adfa04dd48c60a81b0174f45 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 15 Feb 2017 12:16:24 +0100 Subject: [PATCH 2/3] - fixed: All FNames inside actor classes need to be FNameNoInit or their constructor will overwrite them after copying the defaults. --- src/d_player.h | 12 ++++++------ src/p_user.cpp | 2 -- src/win32/i_main.cpp | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 65f401f2d6..7fa0d45b26 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -155,12 +155,12 @@ public: double ViewBob; // Former class properties that were moved into the object to get rid of the meta class. - FName SoundClass; // Sound class - FName Face; // Doom status bar face (when used) - FName Portrait; - FName Slot[10]; - FName InvulMode; - FName HealingRadiusType; + FNameNoInit SoundClass; // Sound class + FNameNoInit Face; // Doom status bar face (when used) + FNameNoInit Portrait; + FNameNoInit Slot[10]; + FNameNoInit InvulMode; + FNameNoInit HealingRadiusType; double HexenArmor[5]; BYTE ColorRangeStart; // Skin color range BYTE ColorRangeEnd; diff --git a/src/p_user.cpp b/src/p_user.cpp index 6e7d7c8ec7..eea26cc4b1 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -1232,8 +1232,6 @@ const char *APlayerPawn::GetSoundClass() const return skins[player->userinfo.GetSkin()].name; } - // [GRB] - auto pclass = GetClass(); return SoundClass != NAME_None? SoundClass.GetChars() : "player"; } diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index 29aa2e8d77..14c4791c60 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -1337,7 +1337,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE nothing, LPSTR cmdline, int n _CrtSetDbgFlag (_CrtSetDbgFlag(0) | _CRTDBG_LEAK_CHECK_DF); // Use this to break at a specific allocation number. - _crtBreakAlloc = 165966; + //_crtBreakAlloc = 53039; #endif DoMain (hInstance); From d8b8767ee9e907beb6d1223f0243a8bf187c8bd9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 15 Feb 2017 12:27:50 +0100 Subject: [PATCH 3/3] - disabled render events pending further discussion and evaluation. --- src/d_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 04fd24d765..c7a001dfe1 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -779,7 +779,7 @@ void D_Display () viewwindowx + viewwidth, viewwindowy + viewheight); // [ZZ] execute event hook that we just started the frame - E_RenderFrame(); + //E_RenderFrame(); // Renderer->RenderView(&players[consoleplayer]); @@ -900,7 +900,7 @@ void D_Display () NetUpdate (); // send out any new accumulation // normal update // draw ZScript UI stuff - E_RenderOverlay(); + //E_RenderOverlay(); C_DrawConsole (hw2d); // draw console M_Drawer (); // menu is drawn even on top of everything FStat::PrintStat ();