From d4eb10d10dc32b025755dcf5b7df49b3c9a81aea Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Thu, 28 Nov 2019 23:22:01 +0000 Subject: [PATCH 1/2] SW: Fix saves Dynamically-allocated structs strike again. git-svn-id: https://svn.eduke32.com/eduke32@8325 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/sw/src/saveable.h --- source/sw/src/game.cpp | 25 +++++++++++-------------- source/sw/src/saveable.cpp | 2 ++ source/sw/src/saveable.h | 14 +++++++++++--- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 437d5eadf..59a44d5c3 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -4810,23 +4810,20 @@ void G_Polymer_UnInit(void) { } #include "saveable.h" -static saveable_data saveable_build_data[] = -{ - SAVE_DATA(sector), - SAVE_DATA(sprite), - SAVE_DATA(wall) -}; +saveable_module saveable_build{}; -saveable_module saveable_build = +void Saveable_Init_Dynamic() { - // code - NULL, - 0, + static saveable_data saveable_build_data[] = + { + {sector, MAXSECTORS*sizeof(sectortype)}, + {sprite, MAXSPRITES*sizeof(spritetype)}, + {wall, MAXWALLS*sizeof(walltype)}, + }; - // data - saveable_build_data, - NUM_SAVEABLE_ITEMS(saveable_build_data) -}; + saveable_build.data = saveable_build_data; + saveable_build.numdata = NUM_SAVEABLE_ITEMS(saveable_build_data); +} /*extern*/ bool GameInterface::validate_hud(int requested_size) { return requested_size; } /*extern*/ void GameInterface::set_hud_layout(int requested_size) { /* the relevant setting is gs.BorderNum */} diff --git a/source/sw/src/saveable.cpp b/source/sw/src/saveable.cpp index c568b1593..67e8339da 100644 --- a/source/sw/src/saveable.cpp +++ b/source/sw/src/saveable.cpp @@ -38,6 +38,8 @@ void Saveable_Init(void) { if (nummodules > 0) return; + Saveable_Init_Dynamic(); + #define MODULE(x) { \ extern saveable_module saveable_ ## x; \ saveablemodules[nummodules++] = &saveable_ ## x; \ diff --git a/source/sw/src/saveable.h b/source/sw/src/saveable.h index 657abadf4..0a288d058 100644 --- a/source/sw/src/saveable.h +++ b/source/sw/src/saveable.h @@ -24,6 +24,7 @@ #ifndef SAVEABLE_H #define SAVEABLE_H +#include "compat.h" typedef void *saveable_code; @@ -42,10 +43,16 @@ typedef struct unsigned int numdata; } saveable_module; -#define SAVE_CODE(s) (void*)s -#define SAVE_DATA(s) { (void*)&s, sizeof(s) } +template +static FORCE_INLINE constexpr enable_if_t::value, size_t> SAVE_SIZEOF(T const & obj) noexcept +{ + return sizeof(obj); +} -#define NUM_SAVEABLE_ITEMS(x) (sizeof(x)/sizeof(x[0])) +#define SAVE_CODE(s) (void*)(s) +#define SAVE_DATA(s) { (void*)&(s), SAVE_SIZEOF(s) } + +#define NUM_SAVEABLE_ITEMS(x) ARRAY_SIZE(x) typedef struct { @@ -61,6 +68,7 @@ typedef struct } saveddatasym; void Saveable_Init(void); +void Saveable_Init_Dynamic(void); int Saveable_FindCodeSym(void *ptr, savedcodesym *sym); int Saveable_FindDataSym(void *ptr, saveddatasym *sym); From 0dbf0a36a1e9e0fe6beb8c13e7cc9d7aac997cbb Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Thu, 28 Nov 2019 23:22:05 +0000 Subject: [PATCH 2/2] SW: Rename the poorly named "Cool Stuff" menu entry to "Credits" and clean it up git-svn-id: https://svn.eduke32.com/eduke32@8326 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/sw/src/menus.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/source/sw/src/menus.cpp b/source/sw/src/menus.cpp index 0144da70d..933dd75d5 100644 --- a/source/sw/src/menus.cpp +++ b/source/sw/src/menus.cpp @@ -521,7 +521,7 @@ MenuGroup LoadGameGroup = {100, 5, "^Load Game", load_i, pic_loadgame, 0, m_defs #define MAIN_XSTART 55 #define MAIN_LINE(line) (MAIN_YSTART + (MAIN_YOFF * line)) -#define MAIN_MENU_COOL_STUFF "^Cool Stuff" +#define MAIN_MENU_COOL_STUFF "^Credits" #define MAIN_MENU_HOW_TO_ORDER "^How to Order" MenuItem main_i[] = @@ -1258,29 +1258,24 @@ MNU_OrderCustom(UserCall call, MenuItem *item) static short RegOrderScreen[] = { - 5262, - 5261, - 4979, + // 5262, + // 5261, 5111, 5118, + 4979, 5113, - //5111, - //5118, - //4979, - //5261, - //5262 5120 // 5114 // JBF: for my credits }; static short SWOrderScreen[] = { - 5262, 5110, 5112, - 5113, + // 5262, 5111, 5118, 4979, + 5113, 5120 // 5114 // JBF: for my credits };