diff options
author | Nicola Mettifogo | 2007-03-11 14:14:08 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2007-03-11 14:14:08 +0000 |
commit | 3b5c330cef5d728b10893e40474c47142b57e83e (patch) | |
tree | 98449e39933f485561ded9bd894f8a0e5829d6be /engines/parallaction | |
parent | 981d11dcfdae5efc03f1139523faa451375f7b25 (diff) | |
download | scummvm-rg350-3b5c330cef5d728b10893e40474c47142b57e83e.tar.gz scummvm-rg350-3b5c330cef5d728b10893e40474c47142b57e83e.tar.bz2 scummvm-rg350-3b5c330cef5d728b10893e40474c47142b57e83e.zip |
wrapped active location data into a new structure
svn-id: r26085
Diffstat (limited to 'engines/parallaction')
-rw-r--r-- | engines/parallaction/callables.cpp | 2 | ||||
-rw-r--r-- | engines/parallaction/commands.cpp | 2 | ||||
-rw-r--r-- | engines/parallaction/dialogue.cpp | 4 | ||||
-rw-r--r-- | engines/parallaction/location.cpp | 66 | ||||
-rw-r--r-- | engines/parallaction/menu.cpp | 10 | ||||
-rw-r--r-- | engines/parallaction/music.cpp | 12 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 59 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 32 | ||||
-rw-r--r-- | engines/parallaction/saveload.cpp | 12 | ||||
-rw-r--r-- | engines/parallaction/walk.cpp | 10 |
10 files changed, 116 insertions, 93 deletions
diff --git a/engines/parallaction/callables.cpp b/engines/parallaction/callables.cpp index 20d7a4af20..d77eb3b4d4 100644 --- a/engines/parallaction/callables.cpp +++ b/engines/parallaction/callables.cpp @@ -300,7 +300,7 @@ void _c_finito(void *parm) { _vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBit2); waitUntilLeftClick(); - strcpy(_location, "estgrotta.drki"); + strcpy(_vm->_location._name, "estgrotta.drki"); _engineFlags |= kEngineChangeLocation; } else { diff --git a/engines/parallaction/commands.cpp b/engines/parallaction/commands.cpp index fd55034f0b..898d17007b 100644 --- a/engines/parallaction/commands.cpp +++ b/engines/parallaction/commands.cpp @@ -315,7 +315,7 @@ void runCommands(Command *list, Zone *z) { break; case CMD_LOCATION: // location - strcpy(_location, u->_string); + strcpy(_vm->_location._name, u->_string); _engineFlags |= kEngineChangeLocation; break; diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp index 09c876496b..dc76c43d11 100644 --- a/engines/parallaction/dialogue.cpp +++ b/engines/parallaction/dialogue.cpp @@ -225,7 +225,7 @@ void runDialogue(SpeakData *data) { debugC(1, kDebugDialogue, "runDialogue: enterDialogue ok"); /* // the only character which can have a dialogue inside the museum location is Dino - if (!scumm_stricmp(_location, "museum")) { + if (!scumm_stricmp(_name, "museum")) { _vm->_graphics->freeCnv( &_characterFrames ); debugC(1, kDebugDialogue, "runDialogue: special trick for 'museum' location"); } @@ -507,7 +507,7 @@ void runDialogue(SpeakData *data) { // as mentioned in the comment at the beginning of this routine, the only // character which can have a dialogue inside the museum location is Dino, // that's why this hack (with hardcoded Dino) works - if (!scumm_stricmp(_location, "museum")) { + if (!scumm_stricmp(_name, "museum")) { _vm->_disk->selectArchive("disk1"); _vm->_disk->loadFrames(_dinoName, &_characterFrames); diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp index b8ca1e1892..5a954a5d44 100644 --- a/engines/parallaction/location.cpp +++ b/engines/parallaction/location.cpp @@ -88,8 +88,8 @@ void Parallaction::parseLocation(const char *filename) { _localFlags[_currentLocationIndex] |= kFlagsVisited; // 'visited' } - strcpy(_location, _tokens[1]); - switchBackground(_location, mask); + strcpy(_location._name, _tokens[1]); + switchBackground(_location._name, mask); if (_tokens[2][0] != '\0') { _yourself._zone.pos._position._x = atoi(_tokens[2]); @@ -113,10 +113,10 @@ void Parallaction::parseLocation(const char *filename) { _localFlagNames[_si] = 0; } if (!scumm_stricmp(_tokens[0], "COMMANDS")) { - _locationCommands = parseCommands(*_locationScript); + _location._commands = parseCommands(*_locationScript); } if (!scumm_stricmp(_tokens[0], "ACOMMANDS")) { - _locationACommands = parseCommands(*_locationScript); + _location._aCommands = parseCommands(*_locationScript); } if (!scumm_stricmp(_tokens[0], "FLAGS")) { if ((_localFlags[_currentLocationIndex] & kFlagsVisited) == 0) { @@ -135,16 +135,16 @@ void Parallaction::parseLocation(const char *filename) { } } if (!scumm_stricmp(_tokens[0], "COMMENT")) { - _locationComment = parseComment(*_locationScript); + _location._comment = parseComment(*_locationScript); } if (!scumm_stricmp(_tokens[0], "ENDCOMMENT")) { - _locationEndComment = parseComment(*_locationScript); + _location._endComment = parseComment(*_locationScript); } if (!scumm_stricmp(_tokens[0], "ZONE")) { parseZone(*_locationScript, &_zones, _tokens[1]); } if (!scumm_stricmp(_tokens[0], "NODES")) { - parseWalkNodes(*_locationScript, &_locationWalkNodes); + parseWalkNodes(*_locationScript, &_location._walkNodes); } if (!scumm_stricmp(_tokens[0], "ANIMATION")) { parseAnimation(*_locationScript, &_animations, _tokens[1]); @@ -189,8 +189,8 @@ void freeLocation() { debugC(7, kDebugLocation, "freeLocation: localflags names freed"); - freeNodeList(_locationWalkNodes._next); - _locationWalkNodes._next = NULL; + freeNodeList(_vm->_location._walkNodes._next); + _vm->_location._walkNodes._next = NULL; debugC(7, kDebugLocation, "freeLocation: walk nodes freed"); helperNode._prev = helperNode._next = NULL; @@ -206,22 +206,22 @@ void freeLocation() { memcpy(&_animations, &helperNode, sizeof(Node)); debugC(7, kDebugLocation, "freeLocation: animations freed"); - if (_locationComment) { - free(_locationComment); + if (_vm->_location._comment) { + free(_vm->_location._comment); } - _locationComment = NULL; + _vm->_location._comment = NULL; debugC(7, kDebugLocation, "freeLocation: comments freed"); - if (_locationCommands) { - freeNodeList(&_locationCommands->_node); + if (_vm->_location._commands) { + freeNodeList(&_vm->_location._commands->_node); } - _locationCommands = NULL; + _vm->_location._commands = NULL; debugC(7, kDebugLocation, "freeLocation: commands freed"); - if (_locationACommands) { - freeNodeList(&_locationACommands->_node); + if (_vm->_location._aCommands) { + freeNodeList(&_vm->_location._aCommands->_node); } - _locationACommands = NULL; + _vm->_location._aCommands = NULL; debugC(7, kDebugLocation, "freeLocation: acommands freed"); return; @@ -388,29 +388,29 @@ void Parallaction::changeLocation(char *location) { _yourself._zone.pos._oldposition._y = -1000; _yourself.field_50 = 0; - if (_firstPosition._x != -1000) { - _yourself._zone.pos._position._x = _firstPosition._x; - _yourself._zone.pos._position._y = _firstPosition._y; - _yourself._frame = _firstFrame; - _firstPosition._y = -1000; - _firstPosition._x = -1000; - - debugC(2, kDebugLocation, "changeLocation: initial position set to x: %i, y: %i, f: %i", _firstPosition._x, _firstPosition._y, _firstFrame); + if (_location._startPosition._x != -1000) { + _yourself._zone.pos._position._x = _location._startPosition._x; + _yourself._zone.pos._position._y = _location._startPosition._y; + _yourself._frame = _location._startFrame; + _location._startPosition._y = -1000; + _location._startPosition._x = -1000; + + debugC(2, kDebugLocation, "changeLocation: initial position set to x: %i, y: %i, f: %i", _location._startPosition._x, _location._startPosition._y, _location._startFrame); } byte palette[PALETTE_SIZE]; for (uint16 _si = 0; _si < PALETTE_SIZE; _si++) palette[_si] = 0; _graphics->palUnk0(palette); _graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront); - if (_locationCommands) { - runCommands(_locationCommands); + if (_location._commands) { + runCommands(_location._commands); runJobs(); _graphics->swapBuffers(); runJobs(); _graphics->swapBuffers(); } - if (_locationComment) { + if (_location._comment) { doLocationEnterTransition(); debugC(2, kDebugLocation, "changeLocation: shown location comment"); } @@ -419,8 +419,8 @@ void Parallaction::changeLocation(char *location) { _graphics->swapBuffers(); _graphics->palUnk0(_palette); - if (_locationACommands) { - runCommands(_locationACommands); + if (_location._aCommands) { + runCommands(_location._aCommands); debugC(1, kDebugLocation, "changeLocation: location acommands run"); } @@ -457,10 +457,10 @@ void Parallaction::doLocationEnterTransition() { _vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBitBack); int16 v7C, v7A; - _vm->_graphics->getStringExtent(_locationComment, 130, &v7C, &v7A); + _vm->_graphics->getStringExtent(_vm->_location._comment, 130, &v7C, &v7A); _vm->_graphics->floodFill(0, 5, 5, 10 + v7C, 5 + v7A, Graphics::kBitFront); _vm->_graphics->floodFill(1, 6, 6, 9 + v7C, 4 + v7A, Graphics::kBitFront); - _vm->_graphics->displayWrappedString(_locationComment, 3, 5, 130, 0); + _vm->_graphics->displayWrappedString(_vm->_location._comment, 3, 5, 130, 0); // FIXME: ??? #if 0 diff --git a/engines/parallaction/menu.cpp b/engines/parallaction/menu.cpp index 12d4726ebd..178eec0fb5 100644 --- a/engines/parallaction/menu.cpp +++ b/engines/parallaction/menu.cpp @@ -196,7 +196,7 @@ void Menu::newGame() { selectCharacter(); - char *v4 = strchr(_location, '.') + 1; + char *v4 = strchr(_vm->_location._name, '.') + 1; strcpy(_engine->_characterName, v4); return; // start game @@ -276,7 +276,7 @@ uint16 Menu::selectGame() { // load game - strcpy(_location, "fogne"); + strcpy(_vm->_location._name, "fogne"); strcpy(_engine->_characterName, "dough"); _vm->loadGame(); @@ -391,12 +391,12 @@ void Menu::selectCharacter() { if (_dino_points > _donna_points && _dino_points > _dough_points) { - sprintf(_location, "test.%s", _dinoName); + sprintf(_vm->_location._name, "test.%s", _dinoName); } else { if (_donna_points > _dino_points && _donna_points > _dough_points) { - sprintf(_location, "test.%s", _donnaName); + sprintf(_vm->_location._name, "test.%s", _donnaName); } else { - sprintf(_location, "test.%s", _doughName); + sprintf(_vm->_location._name, "test.%s", _doughName); } } diff --git a/engines/parallaction/music.cpp b/engines/parallaction/music.cpp index 3cc3be5a3a..b203b453be 100644 --- a/engines/parallaction/music.cpp +++ b/engines/parallaction/music.cpp @@ -49,12 +49,12 @@ MidiPlayer::~MidiPlayer() { void MidiPlayer::play(const char *filename) { stop(); - if (!scumm_strnicmp(_location, "museo", 5)) return; - if (!scumm_strnicmp(_location, "intgrottadopo", 13)) return; - if (!scumm_strnicmp(_location, "caveau", 6)) return; - if (!scumm_strnicmp(_location, "estgrotta", 9)) return; - if (!scumm_strnicmp(_location, "plaza1", 6)) return; - if (!scumm_strnicmp(_location, "endtgz", 6)) return; + if (!scumm_strnicmp(_vm->_location._name, "museo", 5)) return; + if (!scumm_strnicmp(_vm->_location._name, "intgrottadopo", 13)) return; + if (!scumm_strnicmp(_vm->_location._name, "caveau", 6)) return; + if (!scumm_strnicmp(_vm->_location._name, "estgrotta", 9)) return; + if (!scumm_strnicmp(_vm->_location._name, "plaza1", 6)) return; + if (!scumm_strnicmp(_vm->_location._name, "endtgz", 6)) return; char path[PATH_LEN]; sprintf(path, "%s.mid", filename); diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 956eb119b2..675d519da8 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -51,7 +51,7 @@ uint16 _mouseButtons = 0; char _saveData1[30] = { '\0' }; uint16 _language = 0; -char _location[100] = "fogne"; +char _slideText[2][40]; uint32 _engineFlags = 0; char *_objectsNames[100]; Zone *_activeZone = NULL; @@ -64,10 +64,7 @@ static Cnv _miniCharacterFrames; Cnv _yourObjects; uint16 _score = 1; -Command *_locationACommands = NULL; -Command *_locationCommands = NULL; -char *_locationComment = NULL; -char *_locationEndComment = NULL; + uint32 _localFlags[120] = { 0 }; static char tmp_visited_str[] = "visited"; @@ -133,13 +130,11 @@ Command * _forwardedCommands[20] = { char _forwardedAnimationNames[20][20]; uint16 _numForwards = 0; char _soundFile[20]; -char _slideText[2][40]; -Point _firstPosition = { -1000, -1000 }; char *_globalTable[32]; -uint16 _firstFrame = 0; + byte _mouseHidden = 0; -Node _locationWalkNodes = { 0, 0 }; + uint32 _commandFlags = 0; uint16 _introSarcData3 = 200; uint16 _introSarcData2 = 1; @@ -221,7 +216,7 @@ int Parallaction::init() { return -1; } /* - strcpy(_location, "taxint"); + strcpy(_name, "taxint"); strcpy(_characterName, "dough"); strcpy(_languageDir, "it/"); _skipMenu = true; @@ -252,7 +247,7 @@ int Parallaction::init() { argv[2][2] = '/'; argv[2][3] = '\0'; - strcpy(_location, argv[0]); + strcpy(_name, argv[0]); strcpy(_characterName, argv[1]); strcpy(_languageDir, argv[2]); _skipMenu = true; @@ -266,6 +261,18 @@ int Parallaction::init() { memset(_locationNames, 0, 120*32); _numLocations = 0; + _location._startPosition._x = -1000; + _location._startPosition._x = -1000; + _location._startFrame = 0; + _location._walkNodes._prev = NULL; + _location._walkNodes._next = NULL; + strcpy(_location._name, "fogne"); + _location._aCommands = NULL; + _location._commands = NULL; + _location._comment = NULL; + _location._endComment = NULL; + + _yourTalk._width = 0; _yourTalk._height = 0; _yourTalk._count = 0; @@ -325,7 +332,7 @@ void Parallaction::initGame() { _menu->start(); } - char *v4 = strchr(_location, '.'); + char *v4 = strchr(_location._name, '.'); if (v4) { *v4 = '\0'; } @@ -333,15 +340,15 @@ void Parallaction::initGame() { _engineFlags &= ~kEngineChangeLocation; changeCharacter(_characterName); - strcpy(_saveData1, _location); - parseLocation(_location); + strcpy(_saveData1, _location._name); + parseLocation(_location._name); - if (_firstPosition._x != -1000) { - _yourself._zone.pos._position._x = _firstPosition._x; - _yourself._zone.pos._position._y = _firstPosition._y; - _yourself._frame = _firstFrame; - _firstPosition._y = -1000; - _firstPosition._x = -1000; + if (_location._startPosition._x != -1000) { + _yourself._zone.pos._position._x = _location._startPosition._x; + _yourself._zone.pos._position._y = _location._startPosition._y; + _yourself._frame = _location._startFrame; + _location._startPosition._y = -1000; + _location._startPosition._x = -1000; } return; @@ -441,20 +448,20 @@ void Parallaction::runGame() { _graphics->copyScreen(Graphics::kBitBack, Graphics::kBit2); - if (_locationCommands) - runCommands(_locationCommands); + if (_location._commands) + runCommands(_location._commands); runJobs(); _graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront); - if (_locationComment) + if (_location._comment) doLocationEnterTransition(); changeCursor(kCursorArrow); - if (_locationACommands) - runCommands(_locationACommands); + if (_location._aCommands) + runCommands(_location._aCommands); // printf("entering game loop...\n"); @@ -488,7 +495,7 @@ void Parallaction::runGame() { if (_engineFlags & kEngineChangeLocation) { _engineFlags &= ~kEngineChangeLocation; - changeLocation(_location); + changeLocation(_location._name); continue; } diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index a07de9389b..4914f3f33e 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -117,8 +117,8 @@ extern uint16 _introSarcData2; // sarcophagus stuff to be saved extern char *_globalTable[]; extern char _saveData1[]; -extern Point _firstPosition; // starting position after load game?? -extern uint16 _firstFrame; // starting frame after load game?? +//extern Point _firstPosition; // starting position after load game?? +//extern uint16 _firstFrame; // starting frame after load game?? extern byte _mouseHidden; extern uint32 _commandFlags; @@ -126,12 +126,12 @@ extern Cnv _yourTalk; extern Cnv _characterFrames; -extern char _location[]; -extern Node _locationWalkNodes; -extern Command *_locationACommands; -extern Command *_locationCommands; -extern char *_locationComment; -extern char *_locationEndComment; +//extern char _locationName[]; +//extern Node _walkNodes; +//extern Command *_aCommands; +//extern Command *_commands; +//extern char *_comment; +//extern char *_endComment; extern char *_objectsNames[]; extern const char *_zoneTypeNames[]; @@ -237,6 +237,20 @@ class Graphics; class Menu; class MidiPlayer; +struct Location { + + Point _startPosition; + uint16 _startFrame; + Node _walkNodes; + char _name[100]; + + Command *_aCommands; + Command *_commands; + char *_comment; + char *_endComment; + +}; + class Parallaction : public Engine { public: @@ -292,6 +306,8 @@ public: int16 _currentLocationIndex; uint16 _numLocations; + Location _location; + InventoryItem _activeItem; Script *_locationScript; diff --git a/engines/parallaction/saveload.cpp b/engines/parallaction/saveload.cpp index dc068abb50..c20a72d168 100644 --- a/engines/parallaction/saveload.cpp +++ b/engines/parallaction/saveload.cpp @@ -64,15 +64,15 @@ void Parallaction::doLoadGame(uint16 slot) { f->readLine(s, 29); f->readLine(_vm->_characterName, 15); - f->readLine(_location, 15); + f->readLine(_vm->_location._name, 15); - strcat(_location, "."); + strcat(_vm->_location._name, "."); f->readLine(s, 15); - _firstPosition._x = atoi(s); + _location._startPosition._x = atoi(s); f->readLine(s, 15); - _firstPosition._y = atoi(s); + _location._startPosition._y = atoi(s); f->readLine(s, 15); _score = atoi(s); @@ -135,7 +135,7 @@ void Parallaction::doLoadGame(uint16 slot) { parseLocation("common"); - strcat(_location, _vm->_characterName); + strcat(_vm->_location._name, _vm->_characterName); _engineFlags |= kEngineChangeLocation; return; @@ -375,7 +375,7 @@ void Parallaction::loadGame() { void Parallaction::saveGame() { - if (!scumm_stricmp(_location, "caveau")) + if (!scumm_stricmp(_vm->_location._name, "caveau")) return; int slot = selectSaveFile( 1, "Save file", "Save" ); diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp index ca313c3a20..e994806728 100644 --- a/engines/parallaction/walk.cpp +++ b/engines/parallaction/walk.cpp @@ -159,7 +159,7 @@ WalkNode *buildWalkPath(uint16 x, uint16 y) { while (_closest_node_found != 0) { _closest_node_found = 0; - WalkNode *location_node = (WalkNode*)_locationWalkNodes._next; + WalkNode *location_node = (WalkNode*)_vm->_location._walkNodes._next; // scans location path nodes searching for the nearest Node // which can't be farther than the target position @@ -448,10 +448,10 @@ uint16 checkDoor() { if (z != NULL) { if ((z->_flags & kFlagsClosed) == 0) { - _firstPosition._x = z->u.door->_startPos._x; - _firstPosition._y = z->u.door->_startPos._y; - _firstFrame = z->u.door->_startFrame; - strcpy( _location, z->u.door->_location ); + _vm->_location._startPosition._x = z->u.door->_startPos._x; + _vm->_location._startPosition._y = z->u.door->_startPos._y; + _vm->_location._startFrame = z->u.door->_startFrame; + strcpy( _vm->_location._name, z->u.door->_location ); _engineFlags |= kEngineChangeLocation; _zoneTrap = NULL; |