diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 32dd04b6c..3f178620f 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1134,14 +1134,17 @@ using ROTATORp = ROTATOR*; struct USER { - // These are for easy zero-init of USERs without having to be on the lookout for non-trivial members. - void* operator new(size_t alloc) + // C++'s default init rules suck, so we have to help it out a bit to do what we need (i.e. setting all POD members to 0. + USER() { - return M_Calloc(alloc, 1); + memset(&WallP, 0, sizeof(USER) - myoffsetof(USER, WallP)); } - void operator delete (void* mem) + + void Clear() { - M_Free(mem); + rotator.Clear(); + WallShade.Clear(); + memset(&WallP, 0, sizeof(USER) - myoffsetof(USER, WallP)); } // diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 3ea4ff1d0..269c45273 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -284,7 +284,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def if (!def) { def = &nuluser; - if (arc.isReading()) w = {}; + if (arc.isReading()) w.Clear(); } if (arc.BeginObject(keyname)) {