mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-12 20:17:49 +00:00
CINE: Avoid using static objects with destructors
This commit is contained in:
parent
0b90777721
commit
74129492ba
@ -126,6 +126,7 @@ Common::Error CineEngine::run() {
|
||||
|
||||
delete renderer;
|
||||
delete[] collisionPage;
|
||||
delete _scriptInfo;
|
||||
} while (_restartRequested);
|
||||
|
||||
delete g_sound;
|
||||
@ -176,7 +177,7 @@ void CineEngine::initialize() {
|
||||
Common::fill(g_cine->_zoneQuery.begin(), g_cine->_zoneQuery.end(), 0);
|
||||
|
||||
setDefaultGameSpeed();
|
||||
setupOpcodes();
|
||||
_scriptInfo = setupOpcodes();
|
||||
|
||||
initLanguage(getLanguage());
|
||||
|
||||
|
@ -184,6 +184,7 @@ public:
|
||||
*/
|
||||
ScriptVars _globalVars;
|
||||
RawScriptArray _scriptTable; ///< Table of script bytecode
|
||||
FWScriptInfo *_scriptInfo;
|
||||
|
||||
Common::Array<int16> _zoneData;
|
||||
Common::Array<uint16> _zoneQuery; ///< Only exists in Operation Stealth
|
||||
|
@ -85,7 +85,7 @@ bool loadPrc(const char *pPrcName) {
|
||||
uint16 size = g_cine->_scriptTable[i]->_size;
|
||||
// TODO: delete the test?
|
||||
if (size) {
|
||||
g_cine->_scriptTable[i]->setData(*scriptInfo, scriptPtr);
|
||||
g_cine->_scriptTable[i]->setData(*g_cine->_scriptInfo, scriptPtr);
|
||||
scriptPtr += size;
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ void loadRel(char *pRelName) {
|
||||
size = g_cine->_relTable[i]->_size;
|
||||
// TODO: delete the test?
|
||||
if (size) {
|
||||
g_cine->_relTable[i]->setData(*scriptInfo, ptr);
|
||||
g_cine->_relTable[i]->setData(*g_cine->_scriptInfo, ptr);
|
||||
ptr += size;
|
||||
}
|
||||
}
|
||||
|
@ -210,11 +210,11 @@ void loadScriptFromSave(Common::SeekableReadStream &fHandle, bool isGlobal) {
|
||||
// original code loaded everything into globalScripts, this should be
|
||||
// the correct behavior
|
||||
if (isGlobal) {
|
||||
ScriptPtr tmp(scriptInfo->create(*g_cine->_scriptTable[idx], idx, labels, localVars, compare, pos));
|
||||
ScriptPtr tmp(g_cine->_scriptInfo->create(*g_cine->_scriptTable[idx], idx, labels, localVars, compare, pos));
|
||||
assert(tmp);
|
||||
g_cine->_globalScripts.push_back(tmp);
|
||||
} else {
|
||||
ScriptPtr tmp(scriptInfo->create(*g_cine->_relTable[idx], idx, labels, localVars, compare, pos));
|
||||
ScriptPtr tmp(g_cine->_scriptInfo->create(*g_cine->_relTable[idx], idx, labels, localVars, compare, pos));
|
||||
assert(tmp);
|
||||
g_cine->_objectScripts.push_back(tmp);
|
||||
}
|
||||
|
@ -367,9 +367,7 @@ typedef Common::Array<RawObjectScriptPtr> RawObjectScriptArray;
|
||||
|
||||
#define NUM_MAX_SCRIPT 50
|
||||
|
||||
extern FWScriptInfo *scriptInfo;
|
||||
|
||||
void setupOpcodes();
|
||||
FWScriptInfo *setupOpcodes();
|
||||
|
||||
void decompileScript(const byte *scriptPtr, uint16 scriptSize, uint16 scriptIdx);
|
||||
void dumpScript(char *dumpName);
|
||||
|
@ -206,20 +206,16 @@ void FWScript::setupTable() {
|
||||
FWScript::_numOpcodes = ARRAYSIZE(opcodeTable);
|
||||
}
|
||||
|
||||
FWScriptInfo *scriptInfo; ///< Script factory
|
||||
|
||||
/**
|
||||
* @todo replace with script subsystem
|
||||
*/
|
||||
void setupOpcodes() {
|
||||
static FWScriptInfo fw;
|
||||
static OSScriptInfo os;
|
||||
FWScriptInfo *setupOpcodes() {
|
||||
if (g_cine->getGameType() == Cine::GType_FW) {
|
||||
FWScript::setupTable();
|
||||
scriptInfo = &fw;
|
||||
return new FWScriptInfo();
|
||||
} else {
|
||||
OSScript::setupTable();
|
||||
scriptInfo = &os;
|
||||
return new OSScriptInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2015,7 +2011,7 @@ int FWScript::o1_unloadMask5() {
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void addScriptToGlobalScripts(uint16 idx) {
|
||||
ScriptPtr tmp(scriptInfo->create(*g_cine->_scriptTable[idx], idx));
|
||||
ScriptPtr tmp(g_cine->_scriptInfo->create(*g_cine->_scriptTable[idx], idx));
|
||||
assert(tmp);
|
||||
g_cine->_globalScripts.push_back(tmp);
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ uint safeControlAccessMinMs() {
|
||||
}
|
||||
|
||||
void runObjectScript(int16 entryIdx) {
|
||||
ScriptPtr tmp(scriptInfo->create(*g_cine->_relTable[entryIdx], entryIdx));
|
||||
ScriptPtr tmp(g_cine->_scriptInfo->create(*g_cine->_relTable[entryIdx], entryIdx));
|
||||
assert(tmp);
|
||||
g_cine->_objectScripts.push_back(tmp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user