diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 767e3a3b2b..98f102e16f 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,6 @@ +February 5, 2009 (Changes by Graf Zahl) +- Made improvements so that the FOptionalMapinfoData class is easier to use. + February 3, 2009 - Moved the MF_INCHASE recursion check from A_Look() into A_Chase(). This lets A_Look() always put the actor into its see state. This problem could diff --git a/src/g_level.h b/src/g_level.h index 593bd34238..48db7b197f 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -212,9 +212,6 @@ class DScroller; class FScanner; struct level_info_t; -typedef void (*MIParseFunc)(FScanner &sc, level_info_t *info); - -void AddOptionalMapinfoParser(const char *keyword, MIParseFunc parsefunc); struct FOptionalMapinfoData { @@ -225,6 +222,18 @@ struct FOptionalMapinfoData virtual FOptionalMapinfoData *Clone() const = 0; }; +struct FOptionalMapinfoDataPtr +{ + FOptionalMapinfoData *Ptr; + + FOptionalMapinfoDataPtr() throw() : Ptr(NULL) {} + ~FOptionalMapinfoDataPtr() { if (Ptr!=NULL) delete Ptr; } + FOptionalMapinfoDataPtr(const FOptionalMapinfoDataPtr &p) throw() : Ptr(p.Ptr->Clone()) {} + FOptionalMapinfoDataPtr &operator= (FOptionalMapinfoDataPtr &p) throw() { Ptr = p.Ptr->Clone(); return *this; } +}; + +typedef TMap FOptData; + struct level_info_t { char mapname[9]; @@ -278,6 +287,8 @@ struct level_info_t float teamdamage; + FOptData optdata; + TArray specialactions; level_info_t() @@ -296,6 +307,23 @@ struct level_info_t void ClearDefered(); level_info_t *CheckLevelRedirect (); + template + T *GetOptData(FName id, bool create = true) + { + FOptionalMapinfoDataPtr *pdat = optdata.CheckKey(id); + + if (pdat != NULL) + { + return static_cast(pdat->Ptr); + } + else if (create) + { + T *newobj = new T; + optdata[id].Ptr = newobj; + return newobj; + } + else return NULL; + } }; // [RH] These get zeroed every tic and are updated by thinkers.