diff options
Diffstat (limited to 'engines/drascula')
-rw-r--r-- | engines/drascula/drascula.cpp | 12 | ||||
-rw-r--r-- | engines/drascula/drascula.h | 10 | ||||
-rw-r--r-- | engines/drascula/palette.cpp | 2 | ||||
-rw-r--r-- | engines/drascula/rooms.cpp | 41 | ||||
-rw-r--r-- | engines/drascula/talk.cpp | 12 |
5 files changed, 48 insertions, 29 deletions
diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 7aef05357f..7954ada562 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -102,12 +102,16 @@ DrasculaEngine::DrasculaEngine(OSystem *syst, const DrasculaGameDescription *gam _lang = kEnglish; _keyBufferHead = _keyBufferTail = 0; + + _roomHandlers = 0; } DrasculaEngine::~DrasculaEngine() { delete _rnd; stopSound(); + freeRoomsTable(); + free(_charMap); free(_itemLocations); free(_polX); @@ -748,15 +752,15 @@ void DrasculaEngine::updateEvents() { } void DrasculaEngine::delay(int ms) { - _system->delayMillis(ms * 2); // originaly was 1 + _system->delayMillis(ms * 2); // originally was 1 } void DrasculaEngine::pause(int duration) { - _system->delayMillis(duration * 30); // was originaly 2 + _system->delayMillis(duration * 30); // was originally 2 } int DrasculaEngine::getTime() { - return _system->getMillis() / 20; // originaly was 1 + return _system->getMillis() / 20; // originally was 1 } void DrasculaEngine::reduce_hare_chico(int xx1, int yy1, int xx2, int yy2, int width, int height, int factor, byte *dir_inicio, byte *dir_fin) { @@ -1029,7 +1033,7 @@ void DrasculaEngine::freeTexts(char **ptr) { if (!ptr) return; - free(ptr[0]); + free(*ptr); free(ptr); } diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 34439a7373..84faea2c0b 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -311,8 +311,10 @@ public: #define KEYBUFSIZE 16 -static const int interf_x[] ={ 1, 65, 129, 193, 1, 65, 129 }; -static const int interf_y[] ={ 51, 51, 51, 51, 83, 83, 83 }; +static const int interf_x[] = { 1, 65, 129, 193, 1, 65, 129 }; +static const int interf_y[] = { 51, 51, 51, 51, 83, 83, 83 }; + +struct RoomHandlers; class DrasculaEngine : public ::Engine { protected: @@ -597,6 +599,7 @@ public: int whichObject(); bool checkMenuFlags(); void setupRoomsTable(); + void freeRoomsTable(); bool roomParse(int, int); void cleanupString(char *string); void playTalkSequence(int sequence); @@ -780,6 +783,9 @@ private: char **loadTexts(Common::File &in); void freeTexts(char **ptr); + +protected: + RoomHandlers *_roomHandlers; }; diff --git a/engines/drascula/palette.cpp b/engines/drascula/palette.cpp index ba174c9237..1e51deffd9 100644 --- a/engines/drascula/palette.cpp +++ b/engines/drascula/palette.cpp @@ -27,7 +27,7 @@ namespace Drascula { -const char colorTable[][3] = { +static const char colorTable[][3] = { { 0, 0, 0 }, { 0x10, 0x3E, 0x28 }, { 0, 0, 0 }, // unused { 0x16, 0x3F, 0x16 }, { 0x09, 0x3F, 0x12 }, diff --git a/engines/drascula/rooms.cpp b/engines/drascula/rooms.cpp index fcf3ff597b..a71545feca 100644 --- a/engines/drascula/rooms.cpp +++ b/engines/drascula/rooms.cpp @@ -35,7 +35,7 @@ struct doorInfo { int flag; }; -doorInfo doors[] = { +static const doorInfo doors[] = { { 2, 138, 0 }, { 2, 136, 8 }, { 2, 156, 16 }, { 2, 163, 17 }, { 2, 177, 15 }, { 2, 175, 40 }, @@ -63,15 +63,19 @@ struct DrasculaUpdater { Updater proc; }; -Common::Array<DrasculaRoomParser*> _roomParsers; -Common::Array<DrasculaUpdater*> _roomPreupdaters; -Common::Array<DrasculaUpdater*> _roomUpdaters; +struct RoomHandlers { + Common::Array<DrasculaRoomParser *> roomParsers; + Common::Array<DrasculaUpdater *> roomPreupdaters; + Common::Array<DrasculaUpdater *> roomUpdaters; +}; -#define ROOM(x) _roomParsers.push_back(new DrasculaRoomParser(#x, &DrasculaEngine::x)) -#define PREUPDATEROOM(x) _roomPreupdaters.push_back(new DrasculaUpdater(#x, &DrasculaEngine::x)) -#define UPDATEROOM(x) _roomUpdaters.push_back(new DrasculaUpdater(#x, &DrasculaEngine::x)) +#define ROOM(x) _roomHandlers->roomParsers.push_back(new DrasculaRoomParser(#x, &DrasculaEngine::x)) +#define PREUPDATEROOM(x) _roomHandlers->roomPreupdaters.push_back(new DrasculaUpdater(#x, &DrasculaEngine::x)) +#define UPDATEROOM(x) _roomHandlers->roomUpdaters.push_back(new DrasculaUpdater(#x, &DrasculaEngine::x)) void DrasculaEngine::setupRoomsTable() { + _roomHandlers = new RoomHandlers(); + ROOM(room_0); // default ROOM(room_1); ROOM(room_3); @@ -135,6 +139,11 @@ void DrasculaEngine::setupRoomsTable() { UPDATEROOM(update_102); } +void DrasculaEngine::freeRoomsTable() { + delete _roomHandlers; + _roomHandlers = 0; +} + bool DrasculaEngine::roomParse(int rN, int fl) { bool seen = false; @@ -1080,10 +1089,10 @@ void DrasculaEngine::updateRefresh() { // Call room-specific updater char rm[20]; sprintf(rm, "update_%d", roomNumber); - for (uint i = 0; i < _roomUpdaters.size(); i++) { - if (!strcmp(rm, _roomUpdaters[i]->desc)) { + for (uint i = 0; i < _roomHandlers->roomUpdaters.size(); i++) { + if (!strcmp(rm, _roomHandlers->roomUpdaters[i]->desc)) { debug(4, "Calling room updater %d", roomNumber); - (this->*(_roomUpdaters[i]->proc))(); + (this->*(_roomHandlers->roomUpdaters[i]->proc))(); break; } } @@ -1118,10 +1127,10 @@ void DrasculaEngine::updateRefresh_pre() { // Call room-specific preupdater char rm[20]; sprintf(rm, "update_%d_pre", roomNumber); - for (uint i = 0; i < _roomPreupdaters.size(); i++) { - if (!strcmp(rm, _roomPreupdaters[i]->desc)) { + for (uint i = 0; i < _roomHandlers->roomPreupdaters.size(); i++) { + if (!strcmp(rm, _roomHandlers->roomPreupdaters[i]->desc)) { debug(4, "Calling room preupdater %d", roomNumber); - (this->*(_roomPreupdaters[i]->proc))(); + (this->*(_roomHandlers->roomPreupdaters[i]->proc))(); break; } } @@ -1619,11 +1628,11 @@ bool DrasculaEngine::room(int rN, int fl) { // Call room-specific parser char rm[20]; sprintf(rm, "room_%d", rN); - for (uint i = 0; i < _roomParsers.size(); i++) { - if (!strcmp(rm, _roomParsers[i]->desc)) { + for (uint i = 0; i < _roomHandlers->roomParsers.size(); i++) { + if (!strcmp(rm, _roomHandlers->roomParsers[i]->desc)) { debug(4, "Calling room parser %d", rN); - return (this->*(_roomParsers[i]->proc))(fl); + return (this->*(_roomHandlers->roomParsers[i]->proc))(fl); } } diff --git a/engines/drascula/talk.cpp b/engines/drascula/talk.cpp index 4b649ce8db..54175c5e5b 100644 --- a/engines/drascula/talk.cpp +++ b/engines/drascula/talk.cpp @@ -27,8 +27,8 @@ namespace Drascula { -int x_talk_dch[6] = {1, 25, 49, 73, 97, 121}; -int x_talk_izq[6] = {145, 169, 193, 217, 241, 265}; +static const int x_talk_dch[6] = {1, 25, 49, 73, 97, 121}; +static const int x_talk_izq[6] = {145, 169, 193, 217, 241, 265}; void DrasculaEngine::talkInit(const char *filename) { _rnd->setSeed((unsigned int)_system->getMillis() / 2); @@ -55,10 +55,10 @@ void DrasculaEngine::talk_igor(int index, int talkerType) { char filename[20]; sprintf(filename, "I%i.als", index); const char *said = _texti[index]; - int x_talk0[8] = { 56, 82, 108, 134, 160, 186, 212, 238 }; - int x_talk1[8] = { 56, 86, 116, 146, 176, 206, 236, 266 }; - int x_talk3[4] = { 80, 102, 124, 146 }; - int x_talk4[4] = { 119, 158, 197, 236 }; + static const int x_talk0[8] = { 56, 82, 108, 134, 160, 186, 212, 238 }; + static const int x_talk1[8] = { 56, 86, 116, 146, 176, 206, 236, 266 }; + static const int x_talk3[4] = { 80, 102, 124, 146 }; + static const int x_talk4[4] = { 119, 158, 197, 236 }; int face = 0; color_abc(kColorWhite); |