Browse Source

Merge pull request #15 from pchan126/feature/stringTable

incorporate global string table code from t3d.
MelvMay-GG 12 years ago
parent
commit
c33f68e

+ 0 - 1
engine/source/game/defaultGame.cc

@@ -111,7 +111,6 @@ static U32 frameTotalCount = 0;
 bool initializeLibraries()
 {
     PlatformAssert::create();
-    _StringTable::create();
     Con::init();
     Sim::init();
 

+ 6 - 4
engine/source/string/stringTable.cc

@@ -23,7 +23,7 @@
 #include "platform/platform.h"
 #include "stringTable.h"
 
-_StringTable *StringTable = NULL;
+_StringTable *_gStringTable = NULL;
 const U32 _StringTable::csm_stInitSize = 29;
 StringTableEntry _StringTable::EmptyString;
 
@@ -102,8 +102,10 @@ _StringTable::~_StringTable()
 //--------------------------------------
 void _StringTable::create()
 {
-   AssertFatal(StringTable == NULL, "StringTable::create: StringTable already exists.");
-   StringTable = new _StringTable;
+    if(!_gStringTable)
+    {
+        _gStringTable = new _StringTable;
+    }
 }
 
 
@@ -112,7 +114,7 @@ void _StringTable::destroy()
 {
    AssertFatal(StringTable != NULL, "StringTable::destroy: StringTable does not exist.");
    delete StringTable;
-   StringTable = NULL;
+   _gStringTable = NULL;
 }
 
 //--------------------------------------

+ 8 - 1
engine/source/string/stringTable.h

@@ -162,9 +162,16 @@ private:
    static StringTableEntry EmptyString;
 };
 
+extern _StringTable *_gStringTable;
 
-extern _StringTable *StringTable;
+inline _StringTable* _getStringTable()
+{
+    if(_gStringTable == NULL)
+        _StringTable::create();
+    return _gStringTable;
+}
 
+#define StringTable _getStringTable()
 
 #endif //_STRINGTABLE_H_