forked from Mirrors/openclonk
Store global proplist in a C4Value like the Scenario proplist
Since the script engine doesn't have an appropriate function to create the proplist in, simply create it in the constructor and arrange for the string table to be constructed first.
parent
4405ce0798
commit
3aaa37ad41
|
@ -20,14 +20,22 @@
|
|||
|
||||
#include <C4Include.h>
|
||||
#include "C4Application.h"
|
||||
#include "C4Aul.h"
|
||||
#include "C4Console.h"
|
||||
#include "C4FullScreen.h"
|
||||
#include "C4MouseControl.h"
|
||||
#include "C4GameObjects.h"
|
||||
#include <C4DefList.h>
|
||||
#include "C4FullScreen.h"
|
||||
#include "C4Game.h"
|
||||
#include "C4GameObjects.h"
|
||||
#include "C4MouseControl.h"
|
||||
#include "C4Network2.h"
|
||||
#include "C4PropList.h"
|
||||
#include "C4StringTable.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
C4Set<C4PropList *> C4PropList::PropLists;
|
||||
#endif
|
||||
C4StringTable Strings;
|
||||
C4AulScriptEngine ScriptEngine;
|
||||
C4Application Application;
|
||||
C4Console Console;
|
||||
C4FullScreen FullScreen;
|
||||
|
|
|
@ -159,7 +159,8 @@ void C4AulScriptFunc::SetOverloaded(C4AulFunc * f)
|
|||
/*--- C4AulScriptEngine ---*/
|
||||
|
||||
C4AulScriptEngine::C4AulScriptEngine():
|
||||
GlobalPropList(0), warnCnt(0), errCnt(0), lineCnt(0)
|
||||
GlobalPropList(C4PropList::NewAnon(NULL, NULL, ::Strings.RegString("Global"))),
|
||||
warnCnt(0), errCnt(0), lineCnt(0)
|
||||
{
|
||||
// /me r b engine
|
||||
Engine = this;
|
||||
|
@ -172,19 +173,18 @@ C4AulScriptEngine::C4AulScriptEngine():
|
|||
GlobalConsts.Reset();
|
||||
GlobalConsts.SetNameList(&GlobalConstNames);
|
||||
Child0 = ChildL = NULL;
|
||||
RegisterGlobalConstant("Global", GlobalPropList);
|
||||
}
|
||||
|
||||
C4PropList * C4AulScriptEngine::GetPropList()
|
||||
{
|
||||
if (!GlobalPropList)
|
||||
{
|
||||
GlobalPropList = C4PropList::NewAnon(NULL, NULL, ::Strings.RegString("Global"));
|
||||
RegisterGlobalConstant("Global", C4VPropList(GlobalPropList));
|
||||
}
|
||||
return GlobalPropList;
|
||||
return GlobalPropList._getPropList();
|
||||
}
|
||||
|
||||
C4AulScriptEngine::~C4AulScriptEngine() { Clear(); }
|
||||
C4AulScriptEngine::~C4AulScriptEngine()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void C4AulScriptEngine::Clear()
|
||||
{
|
||||
|
@ -196,8 +196,7 @@ void C4AulScriptEngine::Clear()
|
|||
if (Child0->Delete()) delete Child0;
|
||||
else Child0->Unreg();
|
||||
// clear own stuff
|
||||
if (GlobalPropList)
|
||||
GlobalPropList->Clear();
|
||||
GlobalPropList._getPropList()->Clear();
|
||||
// clear inherited
|
||||
C4AulScript::Clear();
|
||||
// reset values
|
||||
|
@ -208,6 +207,7 @@ void C4AulScriptEngine::Clear()
|
|||
GlobalConstNames.Reset();
|
||||
GlobalConsts.Reset();
|
||||
GlobalConsts.SetNameList(&GlobalConstNames);
|
||||
RegisterGlobalConstant("Global", GlobalPropList);
|
||||
GlobalNamed.Reset();
|
||||
GlobalNamed.SetNameList(&GlobalNamedNames);
|
||||
}
|
||||
|
@ -336,5 +336,3 @@ void C4AulFuncMap::Remove(C4AulFunc * func)
|
|||
*pFunc = (*pFunc)->MapNext;
|
||||
--FuncCnt;
|
||||
}
|
||||
|
||||
C4AulScriptEngine ScriptEngine;
|
||||
|
|
|
@ -339,7 +339,7 @@ class C4AulScriptEngine : public C4AulScript
|
|||
{
|
||||
protected:
|
||||
C4AulFuncMap FuncLookUp;
|
||||
C4PropList * GlobalPropList;
|
||||
C4Value GlobalPropList;
|
||||
C4AulScript *Child0, *ChildL; // tree structure
|
||||
|
||||
public:
|
||||
|
|
|
@ -178,10 +178,6 @@ StdStrBuf C4PropListStatic::GetDataString() const
|
|||
return r;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
C4Set<C4PropList *> C4PropList::PropLists;
|
||||
#endif
|
||||
|
||||
C4PropList::C4PropList(C4PropList * prototype):
|
||||
FirstRef(NULL), prototype(prototype),
|
||||
constant(false), Status(1)
|
||||
|
|
|
@ -31,6 +31,12 @@
|
|||
#include <C4Reloc.h>
|
||||
#include <C4Record.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
C4Set<C4PropList *> C4PropList::PropLists;
|
||||
#endif
|
||||
C4StringTable Strings;
|
||||
C4AulScriptEngine ScriptEngine;
|
||||
|
||||
C4Config Config;
|
||||
C4Config::C4Config() {}
|
||||
C4Config::~C4Config() {}
|
||||
|
|
|
@ -196,5 +196,3 @@ C4String *C4StringTable::FindString(const char *strString)
|
|||
{
|
||||
return Set.Get(strString);
|
||||
}
|
||||
|
||||
C4StringTable Strings;
|
||||
|
|
Loading…
Reference in New Issue