diff options
author | Filippos Karapetis | 2015-10-11 22:10:46 +0300 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:33:40 +0100 |
commit | b033b7e539d356b5e94987dfa8d3be68c2acf4ab (patch) | |
tree | 456dca09dfff764a42c57bd8824d311e0bcf1277 /engines/lab | |
parent | 77608bfc66d3b8b8d7414d005fbde39b2af67658 (diff) | |
download | scummvm-rg350-b033b7e539d356b5e94987dfa8d3be68c2acf4ab.tar.gz scummvm-rg350-b033b7e539d356b5e94987dfa8d3be68c2acf4ab.tar.bz2 scummvm-rg350-b033b7e539d356b5e94987dfa8d3be68c2acf4ab.zip |
LAB: Simplify readInitialConditions()
Diffstat (limited to 'engines/lab')
-rw-r--r-- | engines/lab/labsets.cpp | 31 | ||||
-rw-r--r-- | engines/lab/resource.cpp | 6 | ||||
-rw-r--r-- | engines/lab/resource.h | 2 |
3 files changed, 13 insertions, 26 deletions
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp index ae70d817d5..4dcc0c8ebc 100644 --- a/engines/lab/labsets.cpp +++ b/engines/lab/labsets.cpp @@ -30,6 +30,7 @@ #include "lab/stddefines.h" #include "lab/labfun.h" +#include "lab/resource.h" namespace Lab { @@ -57,29 +58,19 @@ void LargeSet::exclElement(uint16 element) { } bool LargeSet::readInitialConditions(const char *fileName) { - byte **file; - uint16 many, set; - char temp[5]; + Common::File *file; - if ((file = g_music->newOpen(fileName)) != NULL) { - memcpy(&temp, file, 4); file += 4; - temp[4] = '\0'; - - if (strcmp(temp, "CON0") != 0) - return false; - - memcpy(&many, file, 2); file += 2; - swapUShortPtr(&many, 1); - - for (int counter = 0; counter < many; counter++) { - memcpy(&set, file, 2); file += 2; - swapUShortPtr(&set, 1); - inclElement(set); + if (file = g_resource->openDataFile(fileName, MKTAG('C', 'O', 'N', '0'))) { + uint16 conditions = file->readUint16LE(); + for (int i = 0; i < conditions; i++) { + inclElement(file->readUint16LE()); } - } else - return false; - return true; + delete file; + return true; + } + + return false; } diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp index dcce41b922..268b4b6c1d 100644 --- a/engines/lab/resource.cpp +++ b/engines/lab/resource.cpp @@ -28,10 +28,6 @@ * */ -//#include "lab/labfun.h" -//#include "lab/parsetypes.h" -//#include "lab/parsefun.h" -//#include "lab/stddefines.h" #include "lab/text.h" #include "lab/resource.h" @@ -152,7 +148,7 @@ bool Resource::readViews(uint16 roomNum) { return true; } -Common::File *Resource::openDataFile(const char * fileName, uint32 fileHeader) { +Common::File *Resource::openDataFile(const char *fileName, uint32 fileHeader) { Common::File *dataFile = new Common::File(); dataFile->open(translateFileName(fileName)); if (dataFile->readUint32BE() != fileHeader) { diff --git a/engines/lab/resource.h b/engines/lab/resource.h index 59240a3505..f9ec4f633e 100644 --- a/engines/lab/resource.h +++ b/engines/lab/resource.h @@ -98,6 +98,7 @@ public: Resource(); ~Resource() {} + Common::File *openDataFile(const char * fileName, uint32 fileHeader); bool readRoomData(const char *fileName); bool readInventory(const char *fileName); bool readViews(uint16 roomNum); @@ -105,7 +106,6 @@ public: Common::String getStaticText(byte index) const { return _staticText[index]; } private: - Common::File *openDataFile(const char * fileName, uint32 fileHeader); char *readString(Common::File *file); int16 *readConditions(Common::File *file); Rule *readRule(Common::File *file); |