mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
- Made improvements so that the FOptionalMapinfoData class is easier to use.
SVN r1401 (trunk)
This commit is contained in:
parent
b387752f2f
commit
84c5c7d38e
2 changed files with 34 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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<FName, FOptionalMapinfoDataPtr> FOptData;
|
||||
|
||||
struct level_info_t
|
||||
{
|
||||
char mapname[9];
|
||||
|
@ -278,6 +287,8 @@ struct level_info_t
|
|||
|
||||
float teamdamage;
|
||||
|
||||
FOptData optdata;
|
||||
|
||||
TArray<FSpecialAction> specialactions;
|
||||
|
||||
level_info_t()
|
||||
|
@ -296,6 +307,23 @@ struct level_info_t
|
|||
void ClearDefered();
|
||||
level_info_t *CheckLevelRedirect ();
|
||||
|
||||
template<class T>
|
||||
T *GetOptData(FName id, bool create = true)
|
||||
{
|
||||
FOptionalMapinfoDataPtr *pdat = optdata.CheckKey(id);
|
||||
|
||||
if (pdat != NULL)
|
||||
{
|
||||
return static_cast<T*>(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.
|
||||
|
|
Loading…
Reference in a new issue