diff options
author | Filippos Karapetis | 2015-10-14 01:51:18 +0300 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:33:41 +0100 |
commit | 09a7232daa00b5bcb039a3e3a06b3ee4d541460d (patch) | |
tree | 7a2a3028b35ae74eca102d4b6d98f9e4cc4bf3ea /engines/lab | |
parent | 95d91d81e53955a47b7e0edd293be135331ca6f8 (diff) | |
download | scummvm-rg350-09a7232daa00b5bcb039a3e3a06b3ee4d541460d.tar.gz scummvm-rg350-09a7232daa00b5bcb039a3e3a06b3ee4d541460d.tar.bz2 scummvm-rg350-09a7232daa00b5bcb039a3e3a06b3ee4d541460d.zip |
LAB: Use Common::File to load map data
Diffstat (limited to 'engines/lab')
-rw-r--r-- | engines/lab/map.cpp | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index ceddc4bdf4..a096d28326 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -188,13 +188,11 @@ static uint16 mapScaleY(uint16 y) { } - - /*****************************************************************************/ /* Loads in the map data. */ /*****************************************************************************/ static bool loadMapData() { - byte **buffer, Temp[5]; + byte **buffer; uint32 Size; Gadget *gptr; uint16 counter; @@ -254,28 +252,33 @@ static bool loadMapData() { counter++; } - uint32 bufferSize; - buffer = g_music->newOpen("Lab:Maps", bufferSize); - stealBufMem(bufferSize); /* Freeze the memory for the maps */ - readBlock(Temp, 4L, buffer); - Temp[4] = 0; + Common::File *mapFile = g_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); + if (!mapFile) + error("Corrupt map file"); + g_music->updateMusic(); + if (!g_music->_doNotFilestopSoundEffect) + g_music->stopSoundEffect(); + + MaxRooms = mapFile->readUint16LE(); + Maps = new MapData[MaxRooms]; // will be freed when the user exits the map + for (int i = 0; i < MaxRooms; i++) { + Maps[i].x = mapFile->readUint16LE(); + Maps[i].y = mapFile->readUint16LE(); + Maps[i].PageNumber = mapFile->readUint16LE(); + Maps[i].SpecialID = mapFile->readUint16LE(); + Maps[i].MapFlags = mapFile->readUint32LE(); + } - if (strcmp((char *)Temp, "MAP0") == 0) { - readBlock(&MaxRooms, 2L, buffer); - swapUShortPtr(&MaxRooms, 1); - Maps = (MapData *)(*buffer); - - for (counter = 1; counter <= MaxRooms; counter++) { - swapUShortPtr(&Maps[counter].x, 4); - swapULong(&Maps[counter].MapFlags); - } - } else - return false; + delete mapFile; return true; } +static void freeMapData() { + delete[] Maps; + Maps = NULL; +} static uint16 fadeNumIn(uint16 num, uint16 res, uint16 counter) { @@ -543,7 +546,7 @@ static void getDownFloor(uint16 *Floor, bool *isfloor) { *isfloor = false; return; } else if (*Floor > UPPERFLOOR) { - /* LAB: Labyrinth specific code */ + // Labyrinth specific code if (*Floor == HEDGEMAZEFLOOR) *Floor = UPPERFLOOR; else if ((*Floor == CARNIVAL) || (*Floor == MEDMAZEFLOOR)) @@ -616,7 +619,7 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b else ghoastGadget(&downgadget, 12); - /* LAB: Labyrinth specific code */ + // Labyrinth specific code if (Floor == LOWERFLOOR) { if (onFloor(SURMAZEFLOOR)) drawImage(Maze, mapScaleX(538), mapScaleY(277)); @@ -634,7 +637,6 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); } - switch (Floor) { case LOWERFLOOR: sptr = (char *)g_resource->getStaticText(kTextLowerFloor).c_str(); @@ -879,7 +881,7 @@ void doMap(uint16 CurRoom) { mouseHide(); setAPen(0); rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); - freeAllStolenMem(); + freeMapData(); blackAllScreen(); mouseShow(); WSDL_UpdateScreen(); |