Move ::Game.ScriptEngine.Strings to ::Strings

This saves some typing and better reflects the role of the object:
It's no longer the list of strings that has to be saved in the savegame,
but is only used to ensure that no string is duplicated.
stable-5.2
Günther Brammer 2009-04-03 23:53:48 +02:00
parent 42d3b6e79a
commit c4b68c771d
10 changed files with 22 additions and 22 deletions

View File

@ -536,8 +536,6 @@ class C4AulScriptEngine : public C4AulScript
C4ValueMapNames GlobalNamedNames;
C4ValueMapData GlobalNamed;
C4StringTable Strings;
// global constants (such as "static const C4D_Structure = 2;")
// cannot share var lists, because it's so closely tied to the data lists
// constants are used by the Parser only, anyway, so it's not

View File

@ -168,9 +168,8 @@ P_LAST };
// There is only one Stringtable in Game.ScriptEngine
class C4StringTable
{
C4StringTable();
friend class C4AulScriptEngine;
public:
C4StringTable();
virtual ~C4StringTable();
void Clear();
@ -191,4 +190,6 @@ public:
C4String * P[P_LAST];
};
extern C4StringTable Strings;
#endif

View File

@ -795,7 +795,7 @@ C4AulTokenType C4AulParseState::GetNextToken(char *pToken, long int *pInt, HoldS
if(HoldStrings == Discard) return ATT_STRING;
// reg string (if not already done so)
C4String *pString;
pString = a->Engine->Strings.RegString(StdStrBuf(StrBuff,static_cast<long>(pStrPos - StrBuff)));
pString = Strings.RegString(StdStrBuf(StrBuff,static_cast<long>(pStrPos - StrBuff)));
// return pointer on string object
*pInt = (long) pString;
return ATT_STRING;
@ -2905,7 +2905,7 @@ void C4AulParseState::Parse_Expression2(int iParentPrio)
}
if (Type == PARSER)
{
pName = Game.ScriptEngine.Strings.RegString(Idtf);
pName = Strings.RegString(Idtf);
}
// add call chunk
Shift();

View File

@ -2292,7 +2292,7 @@ void C4Command::CompileFunc(StdCompiler *pComp)
if(TextBuf == "0")
{ Text = NULL; }
else
{ Text = Game.ScriptEngine.Strings.RegString(TextBuf); Text->IncRef(); }
{ Text = Strings.RegString(TextBuf); Text->IncRef(); }
}
}

View File

@ -771,7 +771,7 @@ int32_t FnFxFireStop(C4AulContext *ctx, C4Object *pObj, int32_t iNumber, int32_t
C4String *FnFxFireInfo(C4AulContext *ctx, C4Object *pObj, int32_t iNumber)
{
return Game.ScriptEngine.Strings.RegString(LoadResStr("IDS_OBJ_BURNS"));
return Strings.RegString(LoadResStr("IDS_OBJ_BURNS"));
}

View File

@ -230,7 +230,7 @@ BOOL C4Game::OpenScenario()
// Load Strings (since kept objects aren't denumerated in sect-load, no problems should occur...)
if (ScenarioFile.FindEntry(C4CFN_Strings))
if (!ScriptEngine.Strings.Load(ScenarioFile))
if (!Strings.Load(ScenarioFile))
{ LogFatal(LoadResStr("IDS_ERR_STRINGS")); return FALSE; }
SetInitProgress(4);

View File

@ -82,6 +82,6 @@ void C4PropList::SetProperty(C4String * k, C4Value & to)
C4Property p = { k, to };
Properties.Add(p);
}
if (k == Game.ScriptEngine.Strings.P[P_PROTOTYPE])
if (k == Strings.P[P_PROTOTYPE])
prototype = to.getPropList();
}

View File

@ -49,7 +49,7 @@ inline const static char *FnStringPar(C4String *pString)
}
inline C4String *String(const char * str)
{
return str ? Game.ScriptEngine.Strings.RegString(str) : NULL;
return str ? Strings.RegString(str) : NULL;
}
static StdStrBuf FnStringFormat(C4AulContext *cthr, const char *szFormatPar, C4Value * Par0=0, C4Value * Par1=0, C4Value * Par2=0, C4Value * Par3=0,

View File

@ -22,8 +22,7 @@
#ifndef BIG_C4INCLUDE
#include <C4Group.h>
#include <C4Components.h>
#include <C4Aul.h>
#include <C4Game.h>
//#include <C4Aul.h>
#endif
// *** C4Set
@ -52,14 +51,14 @@ C4String::C4String(StdStrBuf strString)
Data.Take(strString);
Hash = C4Set<C4String*>::Hash(Data.getData());
// reg
Game.ScriptEngine.Strings.Set.Add(this);
Strings.Set.Add(this);
}
C4String::~C4String()
{
// unreg
iRefCnt = 1;
Game.ScriptEngine.Strings.Set.Remove(this);
Strings.Set.Remove(this);
}
void C4String::IncRef()
@ -132,8 +131,8 @@ bool C4StringTable::Load(C4Group& ParentGroup)
if(!ParentGroup.LoadEntry(C4CFN_Strings, &pData, NULL, 1))
return false;
// read all strings
char strBuf[C4AUL_MAX_String + 1];
for(int i = 0; SCopySegment(pData, i, strBuf, 0x0A, C4AUL_MAX_String); i++)
char strBuf[1024 + 1]; // 1024 was the last used value to write the Strings.txt
for(int i = 0; SCopySegment(pData, i, strBuf, 0x0A, 1024); i++)
{
SReplaceChar(strBuf, 0x0D, 0x00);
// add string to list
@ -146,3 +145,5 @@ bool C4StringTable::Load(C4Group& ParentGroup)
delete[] pData;
return true;
}
C4StringTable Strings;

View File

@ -271,7 +271,7 @@ C4V_Type C4Value::GuessType()
}
// string?
if (Game.ScriptEngine.Strings.FindString(Data.Str))
if (Strings.FindString(Data.Str))
{
assert(false);
Type = C4V_String;
@ -605,7 +605,7 @@ C4Value C4VString(const char *strString)
#ifdef C4ENGINE
// safety
if(!strString) return C4Value();
return C4Value(Game.ScriptEngine.Strings.RegString(strString));
return C4Value(Strings.RegString(strString));
#else
return C4Value();
#endif
@ -616,7 +616,7 @@ C4Value C4VString(StdStrBuf Str)
#ifdef C4ENGINE
// safety
if(Str.isNull()) return C4Value();
return C4Value(Game.ScriptEngine.Strings.RegString(Str));
return C4Value(Strings.RegString(Str));
#else
return C4Value();
#endif
@ -693,7 +693,7 @@ void C4Value::CompileFunc(StdCompiler *pComp)
int32_t iTmp;
pComp->Value(iTmp);
// search
C4String *pString = Game.ScriptEngine.Strings.FindString(iTmp);
C4String *pString = Strings.FindString(iTmp);
if(pString)
{
Data.Str = pString;
@ -752,7 +752,7 @@ void C4Value::CompileFunc(StdCompiler *pComp)
pComp->Value(s);
if(fCompiler)
{
C4String *pString = Game.ScriptEngine.Strings.RegString(s);
C4String *pString = Strings.RegString(s);
if(pString)
{
Data.Str = pString;