From c0e2f1c6f8f7df66ae6c090f6c16aea14ebe8bf3 Mon Sep 17 00:00:00 2001 From: Lars Persson Date: Wed, 13 Oct 2010 07:14:38 +0000 Subject: TOON: Updated code to build properly for WINSCW and GCCE(symbian) Added templates to MAX & MIN functions. Correct usage of OpcodeV2(instead of Opcode) Match implementation with function definition. (int32 is not == int on all platforms) svn-id: r53401 --- engines/toon/audio.cpp | 6 +++--- engines/toon/audio.h | 2 +- engines/toon/character.cpp | 8 ++++---- engines/toon/path.cpp | 24 ++++++++++++------------ engines/toon/script.cpp | 2 +- engines/toon/script.h | 7 ++++--- engines/toon/script_func.cpp | 3 +-- engines/toon/script_func.h | 5 ++++- engines/toon/toon.cpp | 6 +++--- 9 files changed, 33 insertions(+), 30 deletions(-) (limited to 'engines') diff --git a/engines/toon/audio.cpp b/engines/toon/audio.cpp index 496d626201..2ae2b2cc31 100644 --- a/engines/toon/audio.cpp +++ b/engines/toon/audio.cpp @@ -128,7 +128,7 @@ void AudioManager::playVoice(int32 id, bool genericVoice) { } -void AudioManager::playSFX(int32 id, int32 volume , bool genericSFX) { +void AudioManager::playSFX(int32 id, int volume , bool genericSFX) { debugC(4, kDebugAudio, "playSFX(%d, %d)", id, (genericSFX) ? 1 : 0); // find a free SFX channel @@ -218,7 +218,7 @@ AudioStreamInstance::AudioStreamInstance(AudioManager *man, Audio::Mixer *mixer, } } -int32 AudioStreamInstance::readBuffer(int16 *buffer, const int numSamples) { +int AudioStreamInstance::readBuffer(int16 *buffer, const int numSamples) { debugC(5, kDebugAudio, "readBuffer(buffer, %d)", numSamples); handleFade(numSamples); @@ -353,7 +353,7 @@ void AudioStreamInstance::play(bool fade, Audio::Mixer::SoundType soundType) { handleFade(0); } -void AudioStreamInstance::handleFade(int numSamples) { +void AudioStreamInstance::handleFade(int32 numSamples) { debugC(5, kDebugAudio, "handleFade(%d)", numSamples); // Fading enabled only for music diff --git a/engines/toon/audio.h b/engines/toon/audio.h index 5a8274e086..4527e1fe4b 100644 --- a/engines/toon/audio.h +++ b/engines/toon/audio.h @@ -54,7 +54,7 @@ public: void setVolume(int32 volume); protected: - int32 readBuffer(int16 *buffer, const int numSamples); + int readBuffer(int16 *buffer, const int numSamples); bool isStereo() const { return false; } diff --git a/engines/toon/character.cpp b/engines/toon/character.cpp index 50913f89c7..81e175d663 100644 --- a/engines/toon/character.cpp +++ b/engines/toon/character.cpp @@ -96,8 +96,8 @@ bool Character::walkTo(int32 newPosX, int32 newPosY) { _vm->getPathFinding()->resetBlockingRects(); if (_id == 1) { - int32 sizeX = MAX(5, 40 * _vm->getDrew()->getScale() / 1024); - int32 sizeY = MAX(2, 20 * _vm->getDrew()->getScale() / 1024); + int32 sizeX = MAX(5, 40 * _vm->getDrew()->getScale() / 1024); + int32 sizeY = MAX(2, 20 * _vm->getDrew()->getScale() / 1024); _vm->getPathFinding()->addBlockingEllipse(_vm->getDrew()->getFinalX(), _vm->getDrew()->getFinalY(), sizeX, sizeY); } @@ -126,7 +126,7 @@ bool Character::walkTo(int32 newPosX, int32 newPosY) { if (_blockingWalk) { while ((_x != newPosX || _y != newPosY) && _currentPathNode < _currentPathNodeCount && !_vm->shouldQuitGame()) { if (_currentPathNode < _currentPathNodeCount - 10) { - int32 delta = MIN(10, _currentPathNodeCount - _currentPathNode); + int32 delta = MIN(10, _currentPathNodeCount - _currentPathNode); int32 dx = _currentPathX[_currentPathNode+delta] - _x; int32 dy = _currentPathY[_currentPathNode+delta] - _y; setFacing(getFacingFromDirection(dx, dy)); @@ -265,7 +265,7 @@ void Character::update(int32 timeIncrement) { if ((_flags & 0x1) && _currentPathNodeCount > 0) { if (_currentPathNode < _currentPathNodeCount) { if (_currentPathNode < _currentPathNodeCount - 10) { - int32 delta = MIN(10, _currentPathNodeCount - _currentPathNode); + int32 delta = MIN(10, _currentPathNodeCount - _currentPathNode); int32 dx = _currentPathX[_currentPathNode+delta] - _x; int32 dy = _currentPathY[_currentPathNode+delta] - _y; setFacing(getFacingFromDirection(dx, dy)); diff --git a/engines/toon/path.cpp b/engines/toon/path.cpp index 484e621a64..cec9c7dbf0 100644 --- a/engines/toon/path.cpp +++ b/engines/toon/path.cpp @@ -37,13 +37,13 @@ int32 PathFindingHeap::init(int32 size) { return size; } -int PathFindingHeap::unload() { +int32 PathFindingHeap::unload() { if (_data) delete[] _data; return 0; } -int PathFindingHeap::clear() { +int32 PathFindingHeap::clear() { //debugC(1, kDebugPath, "clear()"); _count = 0; @@ -51,7 +51,7 @@ int PathFindingHeap::clear() { return 1; } -int PathFindingHeap::push(int x, int y, int weight) { +int32 PathFindingHeap::push(int32 x, int32 y, int32 weight) { //debugC(6, kDebugPath, "push(%d, %d, %d)", x, y, weight); _count++; @@ -193,7 +193,7 @@ int32 PathFinding::findClosestWalkingPoint(int32 xx, int32 yy, int32 *fxx, int32 } } -int PathFinding::findPath(int32 x, int32 y, int32 destx, int32 desty) { +int32 PathFinding::findPath(int32 x, int32 y, int32 destx, int32 desty) { debugC(1, kDebugPath, "findPath(%d, %d, %d, %d)", x, y, destx, desty); if (x == destx && y == desty) { @@ -220,10 +220,10 @@ int PathFinding::findPath(int32 x, int32 y, int32 destx, int32 desty) { _heap->pop(&curX, &curY, &curWeight); int curNode = curX + curY * _width; - int32 endX = MIN(curX + 1, _width - 1); - int32 endY = MIN(curY + 1, _height - 1); - int32 startX = MAX(curX - 1, 0); - int32 startY = MAX(curY - 1, 0); + int32 endX = MIN(curX + 1, _width - 1); + int32 endY = MIN(curY + 1, _height - 1); + int32 startX = MAX(curX - 1, 0); + int32 startY = MAX(curY - 1, 0); for (int32 px = startX; px <= endX; px++) { for (int py = startY; py <= endY; py++) { @@ -271,10 +271,10 @@ next: int32 bestX = -1; int32 bestY = -1; - int32 endX = MIN(curX + 1, _width - 1); - int32 endY = MIN(curY + 1, _height - 1); - int32 startX = MAX(curX - 1, 0); - int32 startY = MAX(curY - 1, 0); + int32 endX = MIN(curX + 1, _width - 1); + int32 endY = MIN(curY + 1, _height - 1); + int32 startX = MAX(curX - 1, 0); + int32 startY = MAX(curY - 1, 0); for (int32 px = startX; px <= endX; px++) { for (int32 py = startY; py <= endY; py++) { diff --git a/engines/toon/script.cpp b/engines/toon/script.cpp index 06d482f4e2..31d9f94f36 100644 --- a/engines/toon/script.cpp +++ b/engines/toon/script.cpp @@ -102,7 +102,7 @@ bool EMCInterpreter::callback(Common::IFFChunk &chunk) { return false; } -bool EMCInterpreter::load(const char *filename, EMCData *scriptData, const Common::Array *opcodes) { +bool EMCInterpreter::load(const char *filename, EMCData *scriptData, const Common::Array *opcodes) { Common::SeekableReadStream *stream = _vm->resources()->openFile(filename); if (!stream) { error("Couldn't open script file '%s'", filename); diff --git a/engines/toon/script.h b/engines/toon/script.h index 47e04e8c82..d7f45096c2 100644 --- a/engines/toon/script.h +++ b/engines/toon/script.h @@ -36,7 +36,8 @@ namespace Toon { struct EMCState; -typedef Common::Functor1 Opcode; +class ScriptFunc; +typedef Common::Functor1Mem OpcodeV2; struct EMCData { char filename[13]; @@ -46,7 +47,7 @@ struct EMCData { uint16 *ordr; uint16 dataSize; - const Common::Array *sysFuncs; + const Common::Array *sysFuncs; }; struct EMCState { @@ -98,7 +99,7 @@ class EMCInterpreter { public: EMCInterpreter(ToonEngine *vm); - bool load(const char *filename, EMCData *data, const Common::Array *opcodes); + bool load(const char *filename, EMCData *data, const Common::Array *opcodes); void unload(EMCData *data); void init(EMCState *scriptState, const EMCData *data); diff --git a/engines/toon/script_func.cpp b/engines/toon/script_func.cpp index 821a8971de..8755caeab9 100644 --- a/engines/toon/script_func.cpp +++ b/engines/toon/script_func.cpp @@ -34,13 +34,12 @@ namespace Toon { -typedef Common::Functor1Mem OpcodeV2; #define SetOpcodeTable(x) table = &x; #define Opcode(x) table->push_back(new OpcodeV2(this, &ScriptFunc::x)) #define OpcodeUnImpl() table->push_back(new OpcodeV2(this, 0)) ScriptFunc::ScriptFunc(ToonEngine *vm) { - Common::Array *table = 0; + Common::Array *table = 0; _vm = vm; _opcodes.reserve(176); diff --git a/engines/toon/script_func.h b/engines/toon/script_func.h index 2f8972134c..76b7b0ada1 100644 --- a/engines/toon/script_func.h +++ b/engines/toon/script_func.h @@ -31,12 +31,15 @@ namespace Toon { +class ScriptFunc; + +typedef Common::Functor1Mem OpcodeV2; class ScriptFunc { public: ScriptFunc(ToonEngine *vm); ~ScriptFunc(void); - Common::Array _opcodes; + Common::Array _opcodes; ToonEngine *_vm; #define SYSFUNC(x) int32 x(EMCState*) diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp index 7489f5c5d9..dae258adc1 100644 --- a/engines/toon/toon.cpp +++ b/engines/toon/toon.cpp @@ -1099,7 +1099,7 @@ void ToonEngine::loadCursor() { setCursor(5); } -void ToonEngine::setCursor(int32 type, bool inventory, int32 offsetX, int32 offsetY) { +void ToonEngine::setCursor(int32 type, bool inventory, int32 offsetX, int offsetY) { static const int32 offsets[] = { 0, 1, 1, 6, 7, 1, 8, 10, 18, 10, @@ -2234,7 +2234,7 @@ int32 ToonEngine::getConversationFlag(int32 locationId, int32 param) { return 1; } -int ToonEngine::runConversationCommand(int16 **command) { +int32 ToonEngine::runConversationCommand(int16 **command) { // Strangerke - Commented (not used) // int16 com = **command; @@ -2822,7 +2822,7 @@ bool ToonEngine::loadGame(int32 slot) { _sceneAnimationScripts[i]._active = loadFile->readByte(); _sceneAnimationScripts[i]._frozen = loadFile->readByte(); int32 oldTimer = loadFile->readSint32BE(); - _sceneAnimationScripts[i]._lastTimer = MAX(0,oldTimer + timerDiff); + _sceneAnimationScripts[i]._lastTimer = MAX(0,oldTimer + timerDiff); _script->loadState(&_sceneAnimationScripts[i]._state, loadFile); } -- cgit v1.2.3