diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lab/dispman.cpp | 6 | ||||
-rw-r--r-- | engines/lab/dispman.h | 4 | ||||
-rw-r--r-- | engines/lab/intro.cpp | 6 | ||||
-rw-r--r-- | engines/lab/intro.h | 4 | ||||
-rw-r--r-- | engines/lab/labsets.cpp | 2 | ||||
-rw-r--r-- | engines/lab/labsets.h | 2 | ||||
-rw-r--r-- | engines/lab/music.cpp | 6 | ||||
-rw-r--r-- | engines/lab/music.h | 4 | ||||
-rw-r--r-- | engines/lab/processroom.cpp | 6 | ||||
-rw-r--r-- | engines/lab/resource.cpp | 38 | ||||
-rw-r--r-- | engines/lab/resource.h | 10 | ||||
-rw-r--r-- | engines/lab/special.cpp | 6 |
12 files changed, 40 insertions, 54 deletions
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp index bb07ba3f66..32c33885af 100644 --- a/engines/lab/dispman.cpp +++ b/engines/lab/dispman.cpp @@ -70,15 +70,15 @@ DisplayMan::~DisplayMan() { } // From readPict.c. Reads in pictures and animations from disk. -void DisplayMan::loadPict(const char *filename) { +void DisplayMan::loadPict(const Common::String filename) { freePict(); _curBitmap = _vm->_resource->openDataFile(filename); } -void DisplayMan::loadBackPict(const char *fileName, uint16 *highPal) { +void DisplayMan::loadBackPict(const Common::String fileName, uint16 *highPal) { _fadePalette = highPal; _vm->_anim->_noPalChange = true; - readPict(fileName, true); + readPict(fileName.c_str(), true); for (uint16 i = 0; i < 16; i++) { highPal[i] = ((_vm->_anim->_diffPalette[i * 3] >> 2) << 8) + diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h index 6be377d843..3ada808e95 100644 --- a/engines/lab/dispman.h +++ b/engines/lab/dispman.h @@ -79,8 +79,8 @@ public: DisplayMan(LabEngine *lab); virtual ~DisplayMan(); - void loadPict(const char *filename); - void loadBackPict(const char *fileName, uint16 *highPal); + void loadPict(const Common::String filename); + void loadBackPict(const Common::String fileName, uint16 *highPal); /** * Reads in a picture into the display bitmap. diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp index 5e1a8ce81f..4f9ba59217 100644 --- a/engines/lab/intro.cpp +++ b/engines/lab/intro.cpp @@ -63,7 +63,7 @@ void Intro::introEatMessages() { } } -void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) { +void Intro::doPictText(const Common::String filename, TextFont *msgFont, bool isScreen) { Common::String path = Common::String("Lab:rooms/Intro/") + filename; uint timeDelay = (isScreen) ? 35 : 7; @@ -77,7 +77,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) { bool doneFl = false; bool begin = true; - Common::File *textFile = _vm->_resource->openDataFile(path.c_str()); + Common::File *textFile = _vm->_resource->openDataFile(path); byte *textBuffer = new byte[textFile->size()]; textFile->read(textBuffer, textFile->size()); delete textFile; @@ -203,7 +203,7 @@ void Intro::musicDelay() { } } -void Intro::nReadPict(const char *filename, bool playOnce) { +void Intro::nReadPict(const Common::String filename, bool playOnce) { Common::String finalFileName = Common::String("P:Intro/") + filename; _vm->_music->updateMusic(); diff --git a/engines/lab/intro.h b/engines/lab/intro.h index ac292d0769..6f7bc97cfa 100644 --- a/engines/lab/intro.h +++ b/engines/lab/intro.h @@ -52,13 +52,13 @@ private: /** * Reads in a picture. */ - void doPictText(const char *Filename, TextFont *msgFont, bool isscreen); + void doPictText(const Common::String Filename, TextFont *msgFont, bool isScreen); /** * Does a one second delay, but checks the music while doing it. */ void musicDelay(); - void nReadPict(const char *Filename, bool PlayOnce); + void nReadPict(const Common::String Filename, bool PlayOnce); LabEngine *_vm; bool _quitIntro, _introDoBlack; diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp index b19755e622..3e84275fa4 100644 --- a/engines/lab/labsets.cpp +++ b/engines/lab/labsets.cpp @@ -61,7 +61,7 @@ void LargeSet::exclElement(uint16 element) { _array[(element - 1) >> 4] &= ~(1 << ((element - 1) % 16)); } -bool LargeSet::readInitialConditions(const char *fileName) { +bool LargeSet::readInitialConditions(const Common::String fileName) { Common::File *file = _vm->_resource->openDataFile(fileName, MKTAG('C', 'O', 'N', '0')); uint16 conditions = file->readUint16LE(); diff --git a/engines/lab/labsets.h b/engines/lab/labsets.h index 0c1af77de1..afd997e9eb 100644 --- a/engines/lab/labsets.h +++ b/engines/lab/labsets.h @@ -46,7 +46,7 @@ public: bool in(uint16 element); void inclElement(uint16 element); void exclElement(uint16 element); - bool readInitialConditions(const char *fileName); + bool readInitialConditions(const Common::String fileName); private: LabEngine *_vm; diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp index a6f50b7cdf..5ff23ea87b 100644 --- a/engines/lab/music.cpp +++ b/engines/lab/music.cpp @@ -170,7 +170,7 @@ void Music::startMusic(bool restartFl) { /** * Initializes the music buffers. */ -bool Music::initMusic(const char *filename) { +bool Music::initMusic(const Common::String filename) { _musicOn = true; _musicPaused = false; _file = _vm->_resource->openDataFile(filename); @@ -268,7 +268,7 @@ void Music::changeMusic(const Common::String filename) { _tLeftInFile = _leftInFile; } - _file = _vm->_resource->openDataFile(filename.c_str()); + _file = _vm->_resource->openDataFile(filename); // turn music off _musicOn = true; setMusic(false); @@ -311,7 +311,7 @@ void Music::resetMusic() { /** * Reads in a music file. Ignores any graphics. */ -bool Music::readMusic(const char *filename, bool waitTillFinished) { +bool Music::readMusic(const Common::String filename, bool waitTillFinished) { Common::File *file = _vm->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F')); updateMusic(); if (!_loopSoundEffect) diff --git a/engines/lab/music.h b/engines/lab/music.h index 820d403f81..a6f836952c 100644 --- a/engines/lab/music.h +++ b/engines/lab/music.h @@ -83,10 +83,10 @@ public: void changeMusic(const Common::String filename); void checkRoomMusic(); void freeMusic(); - bool initMusic(const char *filename); + bool initMusic(const Common::String filename); bool isSoundEffectActive() const; void playSoundEffect(uint16 sampleSpeed, uint32 length, Common::File *dataFile); - bool readMusic(const char *filename, bool waitTillFinished); + bool readMusic(const Common::String filename, bool waitTillFinished); void resetMusic(); void resumeBackMusic(); void setMusic(bool on); diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp index 07e9633f44..b5979636a4 100644 --- a/engines/lab/processroom.cpp +++ b/engines/lab/processroom.cpp @@ -243,19 +243,19 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) { case PLAYSOUND: _music->_loopSoundEffect = false; _music->_waitTillFinished = true; - _music->readMusic(actionList->_messages[0].c_str(), true); + _music->readMusic(actionList->_messages[0], true); _music->_waitTillFinished = false; break; case PLAYSOUNDB: _music->_loopSoundEffect = false; _music->_waitTillFinished = false; - _music->readMusic(actionList->_messages[0].c_str(), false); + _music->readMusic(actionList->_messages[0], false); break; case PLAYSOUNDCONT: _music->_loopSoundEffect = true; - _music->readMusic(actionList->_messages[0].c_str(), _music->_waitTillFinished); + _music->readMusic(actionList->_messages[0], _music->_waitTillFinished); break; case SHOWDIFF: diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp index a0f635069e..4c0de7b9ff 100644 --- a/engines/lab/resource.cpp +++ b/engines/lab/resource.cpp @@ -50,7 +50,7 @@ void Resource::readStaticText() { delete labTextFile; } -TextFont *Resource::getFont(const char *fileName) { +TextFont *Resource::getFont(const Common::String fileName) { // TODO: Add support for the font format of the Amiga version Common::File *dataFile = openDataFile(fileName, MKTAG('V', 'G', 'A', 'F')); @@ -73,7 +73,7 @@ TextFont *Resource::getFont(const char *fileName) { return textfont; } -Common::String Resource::getText(const char *fileName) { +Common::String Resource::getText(const Common::String fileName) { Common::File *dataFile = openDataFile(fileName); _vm->_music->updateMusic(); @@ -94,7 +94,7 @@ Common::String Resource::getText(const char *fileName) { return str; } -bool Resource::readRoomData(const char *fileName) { +bool Resource::readRoomData(const Common::String fileName) { Common::File *dataFile = openDataFile(fileName, MKTAG('D', 'O', 'R', '1')); _vm->_manyRooms = dataFile->readUint16LE(); @@ -121,7 +121,7 @@ bool Resource::readRoomData(const char *fileName) { return true; } -InventoryData *Resource::readInventory(const char *fileName) { +InventoryData *Resource::readInventory(const Common::String fileName) { Common::File *dataFile = openDataFile(fileName, MKTAG('I', 'N', 'V', '1')); _vm->_numInv = dataFile->readUint16LE(); @@ -140,7 +140,7 @@ InventoryData *Resource::readInventory(const char *fileName) { bool Resource::readViews(uint16 roomNum) { Common::String fileName = "LAB:Rooms/" + Common::String::format("%d", roomNum); - Common::File *dataFile = openDataFile(fileName.c_str(), MKTAG('R', 'O', 'M', '4')); + Common::File *dataFile = openDataFile(fileName, MKTAG('R', 'O', 'M', '4')); freeViews(roomNum); @@ -205,7 +205,7 @@ Common::String Resource::translateFileName(Common::String filename) { return fileNameStrFinal; } -Common::File *Resource::openDataFile(const char *fileName, uint32 fileHeader) { +Common::File *Resource::openDataFile(const Common::String fileName, uint32 fileHeader) { Common::File *dataFile = new Common::File(); dataFile->open(translateFileName(fileName)); if (!dataFile->isOpen()) @@ -310,21 +310,13 @@ Action *Resource::readAction(Common::File *file) { action->_param3 = file->readSint16LE(); if (action->_actionType == SHOWMESSAGES) { - char **messages = (char **)malloc(action->_param1 * sizeof(char *)); - Common::String tmp; + action->_messages = new Common::String[action->_param1]; - for (int i = 0; i < action->_param1; i++) { - tmp = readString(file); - messages[i] = (char *)malloc(tmp.size()); - memcpy(messages[i], tmp.c_str(), tmp.size()); - } - - action->_data = (byte *)messages; + for (int i = 0; i < action->_param1; i++) + action->_messages[i] = readString(file); } else { - Common::String tmp; - tmp = readString(file); - action->_data = (byte *)malloc(tmp.size()); - memcpy(action->_data, tmp.c_str(), tmp.size()); + action->_messages = new Common::String[1]; + action->_messages[0] = readString(file); } action->_nextAction = nullptr; @@ -338,13 +330,7 @@ Action *Resource::readAction(Common::File *file) { void Resource::freeAction(Action *action) { while (action) { Action *nextAction = action->_nextAction; - if (action->_actionType == SHOWMESSAGES) { - char **messages = (char **)action->_data; - for (int i = 0; i < action->_param1; i++) - free(messages[i]); - free(messages); - } else - free(action->_data); + delete[] action->_messages; delete action; action = nextAction; } diff --git a/engines/lab/resource.h b/engines/lab/resource.h index 26607f23c7..f4aa35738e 100644 --- a/engines/lab/resource.h +++ b/engines/lab/resource.h @@ -97,13 +97,13 @@ public: Resource(LabEngine *vm); ~Resource() {} - Common::File *openDataFile(const char * fileName, uint32 fileHeader = 0); - bool readRoomData(const char *fileName); - InventoryData *readInventory(const char *fileName); + Common::File *openDataFile(const Common::String fileName, uint32 fileHeader = 0); + bool readRoomData(const Common::String fileName); + InventoryData *readInventory(const Common::String fileName); bool readViews(uint16 roomNum); void freeViews(uint16 roomNum); - TextFont *getFont(const char *fileName); - Common::String getText(const char *fileName); + TextFont *getFont(const Common::String fileName); + Common::String getText(const Common::String fileName); Common::String getStaticText(byte index) const { return _staticText[index]; } private: diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 9f33d9626d..a45a8fa840 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -126,7 +126,7 @@ void LabEngine::loadJournalData() { else if (bridge) filename += '1'; - _journalText = _resource->getText(filename.c_str()); + _journalText = _resource->getText(filename); _journalTextTitle = _resource->getText("Lab:Rooms/jt"); Common::File *journalFile = _resource->openDataFile("P:JImage"); @@ -463,8 +463,8 @@ void LabEngine::doMonitor(Common::String background, Common::String textfile, bo _monitorButton = new Image(buttonFile, this); delete buttonFile; - Common::String ntext = _resource->getText(textfile.c_str()); - _graphics->loadBackPict(background.c_str(), _highPalette); + Common::String ntext = _resource->getText(textfile); + _graphics->loadBackPict(background, _highPalette); drawMonText((char *)ntext.c_str(), monitorFont, scaledRect, isinteractive); _event->mouseShow(); _graphics->fade(true, 0); |