diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 44a1b122dd..0f562a330e 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,6 @@ August 21, 2008 (Changes by Graf Zahl) +- Fixed: The conversion of the strings in wbstartstruct_t to FStrings + caused crashes when reloading the hub data. - Replaced WALLF_AUTOCONTRAST with WALLF_NOFAKECONTRAST so that the default setting for the flags is 0. - Added: doom2day's smoothlighting diff --git a/src/g_hub.cpp b/src/g_hub.cpp index 983fa177e6..0afe0d1abd 100644 --- a/src/g_hub.cpp +++ b/src/g_hub.cpp @@ -50,7 +50,31 @@ // //========================================================================== -TArray hubdata; +struct FHubInfo +{ + int finished_ep; + + int maxkills; + int maxitems; + int maxsecret; + int maxfrags; + + wbplayerstruct_s plyr[MAXPLAYERS]; + + FHubInfo &operator=(const wbstartstruct_t &wbs) + { + finished_ep = wbs.finished_ep; + maxkills = wbs.maxkills; + maxsecret= wbs.maxsecret; + maxitems = wbs.maxitems; + maxfrags = wbs.maxfrags; + memcpy(plyr, wbs.plyr, sizeof(plyr)); + return *this; + } +}; + + +TArray hubdata; void G_LeavingHub(int mode, cluster_info_t * cluster, wbstartstruct_t * wbs) { @@ -68,13 +92,13 @@ void G_LeavingHub(int mode, cluster_info_t * cluster, wbstartstruct_t * wbs) } if (i==hubdata.Size()) { - hubdata.Push(*wbs); + hubdata[hubdata.Reserve(1)] = *wbs; } hubdata[i].finished_ep=level.levelnum; if (!multiplayer && !deathmatch) { - // The player counters don't work in hubs! + // The player counters don't work in hubs hubdata[i].plyr[0].skills=level.killed_monsters; hubdata[i].plyr[0].sitems=level.found_items; hubdata[i].plyr[0].ssecret=level.found_secrets; @@ -131,11 +155,11 @@ static void G_SerializeHub(FArchive & arc) arc << i; if (i>0) { - if (arc.IsStoring()) arc.Write(&hubdata[0], i * sizeof(wbstartstruct_t)); + if (arc.IsStoring()) arc.Write(&hubdata[0], i * sizeof(FHubInfo)); else { hubdata.Resize(i); - arc.Read(&hubdata[0], i * sizeof(wbstartstruct_t)); + arc.Read(&hubdata[0], i * sizeof(FHubInfo)); } } else hubdata.Clear(); diff --git a/src/version.h b/src/version.h index 013688fccd..a9e1e4b0c3 100644 --- a/src/version.h +++ b/src/version.h @@ -75,7 +75,7 @@ // SAVESIG should match SAVEVER. // MINSAVEVER is the minimum level snapshot version that can be loaded. -#define MINSAVEVER 1179 +#define MINSAVEVER 1181 #if SVN_REVISION_NUMBER < MINSAVEVER // Never write a savegame with a version lower than what we need