diff options
Diffstat (limited to 'engines/toon/script.cpp')
-rw-r--r-- | engines/toon/script.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/engines/toon/script.cpp b/engines/toon/script.cpp index 06d482f4e2..3cd56761f6 100644 --- a/engines/toon/script.cpp +++ b/engines/toon/script.cpp @@ -66,9 +66,13 @@ EMCInterpreter::EMCInterpreter(ToonEngine *vm) : _vm(vm), _scriptData(0), _filen #undef OPCODE } +EMCInterpreter::~EMCInterpreter() { +} + bool EMCInterpreter::callback(Common::IFFChunk &chunk) { switch (chunk._type) { case MKID_BE('TEXT'): + delete[] _scriptData->text; _scriptData->text = new byte[chunk._size]; assert(_scriptData->text); if (chunk._stream->read(_scriptData->text, chunk._size) != chunk._size) @@ -76,6 +80,7 @@ bool EMCInterpreter::callback(Common::IFFChunk &chunk) { break; case MKID_BE('ORDR'): + delete[] _scriptData->ordr; _scriptData->ordr = new uint16[chunk._size >> 1]; assert(_scriptData->ordr); if (chunk._stream->read(_scriptData->ordr, chunk._size) != chunk._size) @@ -86,6 +91,7 @@ bool EMCInterpreter::callback(Common::IFFChunk &chunk) { break; case MKID_BE('DATA'): + delete[] _scriptData->data; _scriptData->data = new uint16[chunk._size >> 1]; assert(_scriptData->data); if (chunk._stream->read(_scriptData->data, chunk._size) != chunk._size) @@ -102,7 +108,7 @@ bool EMCInterpreter::callback(Common::IFFChunk &chunk) { return false; } -bool EMCInterpreter::load(const char *filename, EMCData *scriptData, const Common::Array<const Opcode *> *opcodes) { +bool EMCInterpreter::load(const char *filename, EMCData *scriptData, const Common::Array<const OpcodeV2 *> *opcodes) { Common::SeekableReadStream *stream = _vm->resources()->openFile(filename); if (!stream) { error("Couldn't open script file '%s'", filename); @@ -145,11 +151,13 @@ void EMCInterpreter::unload(EMCData *data) { return; delete[] data->text; + data->text = NULL; + delete[] data->ordr; - delete[] data->data; + data->ordr = NULL; - data->text = 0; - data->ordr = data->data = 0; + delete[] data->data; + data->data = NULL; } void EMCInterpreter::init(EMCState *scriptStat, const EMCData *data) { @@ -181,7 +189,6 @@ bool EMCInterpreter::isValid(EMCState *script) { } bool EMCInterpreter::run(EMCState *script) { - if (script->running) return false; @@ -192,7 +199,6 @@ bool EMCInterpreter::run(EMCState *script) { script->running = true; - // Should be no Problem at all to cast to uint32 here, since that's the biggest ptrdiff the original // would allow, of course that's not realistic to happen to be somewhere near the limit of uint32 anyway. const uint32 instOffset = (uint32)((const byte *)script->ip - (const byte *)script->dataPtr->data); @@ -216,7 +222,7 @@ bool EMCInterpreter::run(EMCState *script) { static bool EMCDebug = false; if (EMCDebug) debugC(5, 0, "[0x%.08X] EMCInterpreter::%s([%d/%u])", instOffset * 2, _opcodes[opcode].desc, _parameter, (uint)_parameter); - //debug(0, "[0x%.08X] EMCInterpreter::%s([%d/%u])", instOffset, _opcodes[opcode].desc, _parameter, (uint)_parameter); + //printf( "[0x%.08X] EMCInterpreter::%s([%d/%u])\n", instOffset, _opcodes[opcode].desc, _parameter, (uint)_parameter); (this->*(_opcodes[opcode].proc))(script); } |