diff --git a/Sources/Engine/Base/Shell.cpp b/Sources/Engine/Base/Shell.cpp index 396db23..bbdcb30 100644 --- a/Sources/Engine/Base/Shell.cpp +++ b/Sources/Engine/Base/Shell.cpp @@ -148,6 +148,7 @@ CShell::CShell(void) { // allocate undefined symbol _shell_istUndeclared = _shell_ast.Allocate(); + pwoCurrentWorld = NULL; }; CShell::~CShell(void) { @@ -704,7 +705,6 @@ INDEX CShell::GetINDEX(const CTString &strName) return -666; } // get it - STUBBED("64-bit issue"); // the return value is used as a pointer a lot! return *(INDEX*)pss->ss_pvValue; } diff --git a/Sources/Engine/Base/Shell.h b/Sources/Engine/Base/Shell.h index 035cb06..d21c4a5 100644 --- a/Sources/Engine/Base/Shell.h +++ b/Sources/Engine/Base/Shell.h @@ -33,6 +33,8 @@ public: CTCriticalSection sh_csShell; // critical section for access to shell data CDynamicArray sh_assSymbols; // all defined symbols + CWorld* pwoCurrentWorld; + // Get a shell symbol by its name. CShellSymbol *GetSymbol(const CTString &strName, BOOL bDeclaredOnly); // Report error in shell script processing. @@ -59,13 +61,23 @@ public: // get/set symbols FLOAT GetFLOAT(const CTString &strName); void SetFLOAT(const CTString &strName, FLOAT fValue); - INDEX GetINDEX(const CTString &strName); // FIXME DG: maybe this should return size_t or uintptr_t? return value is casted to ptr all the time! + INDEX GetINDEX(const CTString &strName); void SetINDEX(const CTString &strName, INDEX iValue); CTString GetString(const CTString &strName); void SetString(const CTString &strName, const CTString &strValue); CTString GetValue(const CTString &strName); void SetValue(const CTString &strName, const CTString &strValue); + + void SetCurrentWorld(CWorld* pwo) + { + pwoCurrentWorld = pwo; + } + + CWorld* GetCurrentWorld(void) + { + return pwoCurrentWorld; + } }; // pointer to global shell object diff --git a/Sources/Engine/Network/Network.cpp b/Sources/Engine/Network/Network.cpp index 2a0f71e..2ec22f0 100644 --- a/Sources/Engine/Network/Network.cpp +++ b/Sources/Engine/Network/Network.cpp @@ -86,8 +86,6 @@ BOOL _bTempNetwork = FALSE; // set while using temporary second network object extern BOOL con_bCapture; extern CTString con_strCapture; -static CWorld *_pwoCurrentWorld = NULL; - static FLOAT _bStartDemoRecordingNextTime = FALSE; static FLOAT _bStopDemoRecordingNextTime = FALSE; static INDEX dem_iRecordedNumber = 0; @@ -254,8 +252,7 @@ extern void CacheShadows(void) { // mute all sounds _pSound->Mute(); - STUBBED("64-bit issue"); // GetINDEX() returns int32! - CWorld *pwo = (CWorld*)_pShell->GetINDEX("pwoCurrentWorld"); + CWorld *pwo = _pShell->GetCurrentWorld(); if( pwo!=NULL) { pwo->wo_baBrushes.CacheAllShadowmaps(); CPrintF( TRANS("All shadows recached")); @@ -523,8 +520,7 @@ static void StockInfo(void) INDEX ctEntities=0, ctShadowLayers=0, ctPolys=0, ctPlanes=0, ctEdges=0, ctVertices=0, ctSectors=0; SLONG slEntBytes=0, slLyrBytes=0, slPlyBytes=0, slPlnBytes=0, slEdgBytes=0, slVtxBytes=0, slSecBytes=0; SLONG slCgrBytes=0; - STUBBED("64-bit issue"); // GetINDEX() returns int32! - CWorld *pwo = (CWorld*)_pShell->GetINDEX("pwoCurrentWorld"); + CWorld *pwo = _pShell->GetCurrentWorld(); if( pwo!=NULL) { @@ -899,7 +895,6 @@ void CNetworkLibrary::Init(const CTString &strGameID) _pShell->DeclareSymbol("persistent user CTString ga_strMSLegacy;", (void *)&ga_strMSLegacy); _pShell->DeclareSymbol("persistent user INDEX ga_bMSLegacy;", (void *)&ga_bMSLegacy); - _pShell->DeclareSymbol("INDEX pwoCurrentWorld;", (void *)&_pwoCurrentWorld); } /* @@ -1041,8 +1036,7 @@ void CNetworkLibrary::StartPeerToPeer_t(const CTString &strSessionName, throw; } // remember the world pointer - STUBBED("64-bit issue"); - _pShell->SetINDEX("pwoCurrentWorld", (INDEX)(size_t)&ga_World); + _pShell->SetCurrentWorld(&ga_World); SetProgressDescription(TRANS("starting server")); CallProgressHook_t(0.0f); @@ -1279,8 +1273,7 @@ void CNetworkLibrary::JoinSession_t(const CNetworkSession &nsSesssion, INDEX ctL } // remember the world pointer - STUBBED("64-bit issue"); - _pShell->SetINDEX("pwoCurrentWorld", (INDEX)(size_t)&ga_World); + _pShell->SetCurrentWorld(&ga_World); // eventually cache all shadowmaps in world (memory eater!) if( shd_bCacheAll) ga_World.wo_baBrushes.CacheAllShadowmaps(); @@ -1352,8 +1345,7 @@ void CNetworkLibrary::StartDemoPlay_t(const CTFileName &fnDemo) // throw char * _bNeedPretouch = TRUE; // remember the world pointer - STUBBED("64-bit issue"); - _pShell->SetINDEX("pwoCurrentWorld", (INDEX)(size_t)&ga_World); + _pShell->SetCurrentWorld(&ga_World); // demo synchronization starts at the beginning initially ga_fDemoTimer = 0.0f; @@ -1562,7 +1554,7 @@ void CNetworkLibrary::StopGame(void) ga_aplsPlayers.Clear(); ga_aplsPlayers.New(NET_MAXLOCALPLAYERS); // remember the world pointer - _pShell->SetINDEX("pwoCurrentWorld", (INDEX)NULL); + _pShell->SetCurrentWorld(NULL); // rewind the timer _pTimer->SetCurrentTick(0.0f); @@ -1686,8 +1678,7 @@ void CNetworkLibrary::ChangeLevel_internal(void) // remember the world filename ga_fnmWorld = ga_fnmNextLevel; // remember the world pointer - STUBBED("64-bit issue"); - _pShell->SetINDEX("pwoCurrentWorld", (INDEX)(size_t)&ga_World); + _pShell->SetCurrentWorld(&ga_World); // if there is remembered level } else { // restore it @@ -2392,8 +2383,7 @@ extern void NET_MakeDefaultState_t( _pNetwork->ga_fnmWorld = fnmWorld; _pNetwork->ga_fnmNextLevel = CTString(""); // remember the world pointer - STUBBED("64-bit issue"); - _pShell->SetINDEX("pwoCurrentWorld", (INDEX)(size_t)&_pNetwork->ga_World); + _pShell->SetCurrentWorld(&_pNetwork->ga_World); // reset random number generator _pNetwork->ga_sesSessionState.ResetRND(); diff --git a/Sources/Entities/WorldBase.es b/Sources/Entities/WorldBase.es index b7abc26..a66dc19 100644 --- a/Sources/Entities/WorldBase.es +++ b/Sources/Entities/WorldBase.es @@ -86,7 +86,7 @@ EntityStats *FindStats(const CTString &strName) static void MakeWorldStatistics(void) { // get the world pointer - CWorld *pwo = (CWorld *)_pShell->GetINDEX("pwoCurrentWorld"); + CWorld *pwo = _pShell->GetCurrentWorld(); // if there is no current world if (pwo==NULL) { CPrintF("No current world.\n"); @@ -152,7 +152,7 @@ static void MakeWorldStatistics(void) static void ReoptimizeAllBrushes(void) { // get the world pointer - CWorld *pwo = (CWorld *)_pShell->GetINDEX("pwoCurrentWorld"); + CWorld *pwo = _pShell->GetCurrentWorld(); // if there is no current world if (pwo==NULL) { CPrintF("No current world.\n"); diff --git a/Sources/EntitiesMP/WorldBase.es b/Sources/EntitiesMP/WorldBase.es index a7f070d..8cbfb8f 100644 --- a/Sources/EntitiesMP/WorldBase.es +++ b/Sources/EntitiesMP/WorldBase.es @@ -64,7 +64,7 @@ EntityStats *FindStats(const CTString &strName) static void MakeWorldStatistics(void) { // get the world pointer - CWorld *pwo = (CWorld *)_pShell->GetINDEX("pwoCurrentWorld"); + CWorld *pwo = _pShell->GetCurrentWorld(); // if there is no current world if (pwo==NULL) { CPrintF("No current world.\n"); @@ -130,7 +130,7 @@ static void MakeWorldStatistics(void) static void ReoptimizeAllBrushes(void) { // get the world pointer - CWorld *pwo = (CWorld *)_pShell->GetINDEX("pwoCurrentWorld"); + CWorld *pwo = _pShell->GetCurrentWorld(); // if there is no current world if (pwo==NULL) { CPrintF("No current world.\n"); @@ -157,7 +157,7 @@ static void DoLevelSafetyChecks() CPrintF("\n**** BEGIN Level safety checking ****\n\n"); // get the world pointer - CWorld *pwo = (CWorld *)_pShell->GetINDEX("pwoCurrentWorld"); + CWorld *pwo = _pShell->GetCurrentWorld(); // if there is no current world if (pwo==NULL) { CPrintF("Error - no current world.\n"); diff --git a/Sources/WorldEditor/WorldEditor.cpp b/Sources/WorldEditor/WorldEditor.cpp index cac325f..e1ba27c 100644 --- a/Sources/WorldEditor/WorldEditor.cpp +++ b/Sources/WorldEditor/WorldEditor.cpp @@ -2098,7 +2098,7 @@ BOOL CWorldEditorApp::OnIdle(LONG lCount) if (pvCurrent!=NULL) { CWorldEditorDoc *pdocCurrent = pvCurrent->GetDocument(); if (pdocCurrent!=NULL) { - _pShell->SetINDEX("pwoCurrentWorld", (INDEX)&pdocCurrent->m_woWorld); + _pShell->SetCurrentWorld(&pdocCurrent->m_woWorld); } }