forked from Mirrors/openclonk
Remove some redundant Default methods
Using the same method for the constructing and clearing an instance just leads to leaks and subtle bugs.
parent
01e9dce9ce
commit
f4ee636072
|
@ -647,7 +647,6 @@ void C4Game::Clear()
|
|||
QuitLogPos = GetLogPos();
|
||||
|
||||
fPreinited = false;
|
||||
::GameScript.Default();
|
||||
// FIXME: remove this
|
||||
Default();
|
||||
}
|
||||
|
|
|
@ -28,21 +28,6 @@
|
|||
#include <C4Application.h>
|
||||
#include <StdRegistry.h>
|
||||
|
||||
C4ComponentHost::C4ComponentHost()
|
||||
{
|
||||
}
|
||||
|
||||
C4ComponentHost::~C4ComponentHost()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void C4ComponentHost::Clear()
|
||||
{
|
||||
Data.Clear();
|
||||
OnLoad();
|
||||
}
|
||||
|
||||
bool C4ComponentHost::Load(C4Group &hGroup,
|
||||
const char *fname,
|
||||
const char *szLanguage)
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
class C4ComponentHost
|
||||
{
|
||||
public:
|
||||
C4ComponentHost();
|
||||
virtual ~C4ComponentHost();
|
||||
C4ComponentHost() { }
|
||||
virtual ~C4ComponentHost() { Clear(); }
|
||||
const char *GetFilePath() const { return FilePath.getData(); }
|
||||
void Clear();
|
||||
void Clear() { Data.Clear(); OnLoad(); }
|
||||
const char *GetData() const { return Data.getData(); }
|
||||
const StdStrBuf & GetDataBuf() const { return Data; }
|
||||
size_t GetDataSize() const { return Data.getLength(); }
|
||||
|
|
|
@ -336,7 +336,7 @@ void C4Def::Default()
|
|||
Count=0;
|
||||
TimerCall=NULL;
|
||||
MainFace.Set(NULL,0,0,0,0);
|
||||
Script.Default();
|
||||
Script.Clear();
|
||||
StringTable.Clear();
|
||||
pClonkNames=NULL;
|
||||
pRankNames=NULL;
|
||||
|
|
|
@ -163,7 +163,6 @@ StdStrBuf C4AulScriptFunc::GetFullName()
|
|||
|
||||
C4AulScript::C4AulScript()
|
||||
{
|
||||
// init defaults
|
||||
// not compiled
|
||||
State = ASS_NONE;
|
||||
Script = NULL;
|
||||
|
|
|
@ -34,15 +34,9 @@
|
|||
|
||||
/*--- C4ScriptHost ---*/
|
||||
|
||||
C4ScriptHost::C4ScriptHost() { Default(); }
|
||||
C4ScriptHost::C4ScriptHost() { }
|
||||
C4ScriptHost::~C4ScriptHost() { Clear(); }
|
||||
|
||||
void C4ScriptHost::Default()
|
||||
{
|
||||
C4AulScript::Clear();
|
||||
ComponentHost.Clear();
|
||||
}
|
||||
|
||||
void C4ScriptHost::Clear()
|
||||
{
|
||||
C4AulScript::Clear();
|
||||
|
@ -118,12 +112,6 @@ void C4ScriptHost::SetError(const char *szMessage)
|
|||
|
||||
/*--- C4DefScriptHost ---*/
|
||||
|
||||
void C4DefScriptHost::Default()
|
||||
{
|
||||
C4ScriptHost::Default();
|
||||
SFn_CalcValue = SFn_SellTo = SFn_ControlTransfer = SFn_CustomComponents = NULL;
|
||||
}
|
||||
|
||||
void C4DefScriptHost::AfterLink()
|
||||
{
|
||||
C4AulScript::AfterLink();
|
||||
|
@ -146,14 +134,6 @@ void C4DefScriptHost::AfterLink()
|
|||
C4GameScriptHost::C4GameScriptHost(): Counter(0), Go(false) { }
|
||||
C4GameScriptHost::~C4GameScriptHost() { }
|
||||
|
||||
|
||||
void C4GameScriptHost::Default()
|
||||
{
|
||||
C4ScriptHost::Default();
|
||||
Counter=0;
|
||||
Go=false;
|
||||
}
|
||||
|
||||
bool C4GameScriptHost::Execute()
|
||||
{
|
||||
if (!Script) return false;
|
||||
|
|
|
@ -40,7 +40,6 @@ public:
|
|||
~C4ScriptHost();
|
||||
bool Delete() { return true; }
|
||||
public:
|
||||
void Default();
|
||||
void Clear();
|
||||
bool Load(C4Group &hGroup, const char *szFilename,
|
||||
const char *szLanguage/*=NULL*/, C4Def *pDef/*=NULL*/, class C4LangStringTable *pLocalTable);
|
||||
|
@ -57,9 +56,8 @@ protected:
|
|||
class C4DefScriptHost : public C4ScriptHost
|
||||
{
|
||||
public:
|
||||
C4DefScriptHost() : C4ScriptHost() { Default(); }
|
||||
|
||||
void Default();
|
||||
C4DefScriptHost() : C4ScriptHost() { SFn_CalcValue = SFn_SellTo = SFn_ControlTransfer = SFn_CustomComponents = NULL; }
|
||||
void Clear() { SFn_CalcValue = SFn_SellTo = SFn_ControlTransfer = SFn_CustomComponents = NULL; C4ScriptHost::Clear(); }
|
||||
|
||||
bool Delete() { return false; } // do NOT delete this - it's just a class member!
|
||||
protected:
|
||||
|
@ -79,7 +77,6 @@ public:
|
|||
C4GameScriptHost();
|
||||
~C4GameScriptHost();
|
||||
bool Delete() { return false; } // do NOT delete this - it's a global!
|
||||
void Default();
|
||||
C4Value GRBroadcast(const char *szFunction, C4AulParSet *pPars = 0, bool fPassError=false, bool fRejectTest=false); // call function in scenario script and all goals/rules/environment objects
|
||||
|
||||
// Global script data
|
||||
|
@ -87,6 +84,7 @@ public:
|
|||
int32_t Counter;
|
||||
bool Go;
|
||||
bool Execute();
|
||||
void Clear() { Counter = 0; Go = false; C4ScriptHost::Clear(); }
|
||||
|
||||
// Compile scenario script data
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
|
|
Loading…
Reference in New Issue