diff options
author | Max Horn | 2003-05-21 18:09:49 +0000 |
---|---|---|
committer | Max Horn | 2003-05-21 18:09:49 +0000 |
commit | 86d57f3c7af8fd0d4c6a4d1751ccdaac77c3b2e8 (patch) | |
tree | aa7c2126baa9dd2ca7dd80910f5835b6aa861294 /scumm | |
parent | 11d29b71ab4400e6e732ba7cd49a343150360eaf (diff) | |
download | scummvm-rg350-86d57f3c7af8fd0d4c6a4d1751ccdaac77c3b2e8.tar.gz scummvm-rg350-86d57f3c7af8fd0d4c6a4d1751ccdaac77c3b2e8.tar.bz2 scummvm-rg350-86d57f3c7af8fd0d4c6a4d1751ccdaac77c3b2e8.zip |
many pedantic warning fixes (and some actual potential buglets fixed, too)
svn-id: r7795
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/actor.cpp | 7 | ||||
-rw-r--r-- | scumm/bundle.cpp | 6 | ||||
-rw-r--r-- | scumm/bundle.h | 6 | ||||
-rw-r--r-- | scumm/debugger.cpp | 10 | ||||
-rw-r--r-- | scumm/debugger.h | 2 | ||||
-rw-r--r-- | scumm/gfx.cpp | 3 | ||||
-rw-r--r-- | scumm/imuse.cpp | 8 | ||||
-rw-r--r-- | scumm/imuse_digi.cpp | 8 | ||||
-rw-r--r-- | scumm/object.cpp | 6 | ||||
-rw-r--r-- | scumm/resource.cpp | 2 | ||||
-rw-r--r-- | scumm/script_v2.cpp | 8 | ||||
-rw-r--r-- | scumm/script_v5.cpp | 2 | ||||
-rw-r--r-- | scumm/script_v6.cpp | 7 | ||||
-rw-r--r-- | scumm/script_v8.cpp | 6 | ||||
-rw-r--r-- | scumm/scumm.h | 2 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 4 | ||||
-rw-r--r-- | scumm/sound.cpp | 4 | ||||
-rw-r--r-- | scumm/sound.h | 6 | ||||
-rw-r--r-- | scumm/string.cpp | 22 | ||||
-rw-r--r-- | scumm/verbs.cpp | 1 |
20 files changed, 62 insertions, 58 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp index a99817ff99..2daa42f3c1 100644 --- a/scumm/actor.cpp +++ b/scumm/actor.cpp @@ -1138,7 +1138,7 @@ void Scumm::stopTalk() { } void Scumm::clearMsgQueue() { - _messagePtr = (byte *)" "; + _messagePtr = (const byte *)" "; stopTalk(); } @@ -1425,8 +1425,9 @@ void Actor::walkActorOld() { byte *Actor::getActorName() { byte *ptr = _vm->getResourceAddress(rtActorName, number); - if (ptr == NULL) - return (byte *)" "; + if (ptr == NULL) { + warning("Failed to find name of actor %d\n", number); + } return ptr; } diff --git a/scumm/bundle.cpp b/scumm/bundle.cpp index 0804ca5125..30a722856c 100644 --- a/scumm/bundle.cpp +++ b/scumm/bundle.cpp @@ -353,7 +353,7 @@ int32 Bundle::decompressMusicSampleByIndex(int32 index, int32 number, byte *comp return final_size; } -int32 Bundle::decompressVoiceSampleByName(char *name, byte **comp_final) { +int32 Bundle::decompressVoiceSampleByName(const char *name, byte **comp_final) { int32 final_size = 0, i; if (_voiceFile.isOpen() == false) { @@ -371,7 +371,7 @@ int32 Bundle::decompressVoiceSampleByName(char *name, byte **comp_final) { return final_size; } -int32 Bundle::decompressMusicSampleByName(char *name, int32 number, byte *comp_final) { +int32 Bundle::decompressMusicSampleByName(const char *name, int32 number, byte *comp_final) { int32 final_size = 0, i; if (!name) { @@ -405,7 +405,7 @@ int32 Bundle::getNumberOfMusicSamplesByIndex(int32 index) { return _musicFile.readUint32BE(); } -int32 Bundle::getNumberOfMusicSamplesByName(char *name) { +int32 Bundle::getNumberOfMusicSamplesByName(const char *name) { int32 number = 0, i; if (_musicFile.isOpen() == false) { diff --git a/scumm/bundle.h b/scumm/bundle.h index 7bcb8b27f4..e8d1832e2f 100644 --- a/scumm/bundle.h +++ b/scumm/bundle.h @@ -67,12 +67,12 @@ public: bool openMusicFile(const char *filename, const char *directory); void closeVoiceFile() { _voiceFile.close(); } void closeMusicFile() { _musicFile.close(); } - int32 decompressVoiceSampleByName(char *name, byte **comp_final); + int32 decompressVoiceSampleByName(const char *name, byte **comp_final); int32 decompressVoiceSampleByIndex(int32 index, byte **comp_final); - int32 decompressMusicSampleByName(char *name, int32 number, byte *comp_final); + int32 decompressMusicSampleByName(const char *name, int32 number, byte *comp_final); int32 decompressMusicSampleByIndex(int32 index, int32 number, byte *comp_final); int32 getNumberOfMusicSamplesByIndex(int32 index); - int32 getNumberOfMusicSamplesByName(char *name); + int32 getNumberOfMusicSamplesByName(const char *name); }; #endif diff --git a/scumm/debugger.cpp b/scumm/debugger.cpp index 139ca5bb37..95f8ec0764 100644 --- a/scumm/debugger.cpp +++ b/scumm/debugger.cpp @@ -143,7 +143,7 @@ void ScummDebugger::on_frame() { bool ScummDebugger::debuggerInputCallback(ConsoleDialog *console, const char *input, void *refCon) { ScummDebugger *debugger = (ScummDebugger *)refCon; - return debugger->RunCommand((char*)input); + return debugger->RunCommand(input); } @@ -229,10 +229,11 @@ void ScummDebugger::enter() { } // Command execution loop -bool ScummDebugger::RunCommand(char *input) { +bool ScummDebugger::RunCommand(const char *inputOrig) { int i = 0, num_params = 0; const char *param[256]; - + char *input = strdup(inputOrig); // One of the rare occasions using strdup is OK (although avoiding strtok might be more elegant here). + // Parse out any params char *tok = strtok(input, " "); if (tok) { @@ -245,6 +246,7 @@ bool ScummDebugger::RunCommand(char *input) { for(i=0; i < _dcmd_count; i++) { if (!strcmp(_dcmds[i].name, param[0])) { + free(input); return (this->*_dcmds[i].function)(num_params, param); } } @@ -321,11 +323,13 @@ bool ScummDebugger::RunCommand(char *input) { } } + free(input); return true; } } Debug_Printf("Unknown command or variable\n"); + free(input); return true; } diff --git a/scumm/debugger.h b/scumm/debugger.h index 1dc6054e2e..73e3fe044c 100644 --- a/scumm/debugger.h +++ b/scumm/debugger.h @@ -67,7 +67,7 @@ protected: void DVar_Register(const char *varname, void *pointer, int type, int optional); void DCmd_Register(const char *cmdname, DebugProc pointer); - bool RunCommand(char *input); + bool RunCommand(const char *input); // Commands bool Cmd_Exit(int argc, const char **argv); diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index ca8b4f20c2..50fc505d51 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -1292,9 +1292,8 @@ void Gdi::decodeStripEGA(byte *dst, byte *src, int height) { if(run == 0) { run = *src++; } - const register byte colors[2] = { color >> 4, color & 0xf }; for(z = 0; z < run; z++) { - *(dst + y * _vm->_screenWidth + x) = colors[z&1]; + *(dst + y * _vm->_screenWidth + x) = (z&1) ? (color & 0xf) : (color >> 4); y++; if(y >= height) { diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp index 055731e1b4..cfd7fbf755 100644 --- a/scumm/imuse.cpp +++ b/scumm/imuse.cpp @@ -1192,9 +1192,6 @@ int IMuseInternal::get_music_volume() { int IMuseInternal::set_music_volume(uint vol) { if (vol > 255) vol = 255; - else if (vol < 0) - vol = 0; - if (_music_volume == vol) return 0; _music_volume = vol; @@ -1210,11 +1207,8 @@ int IMuseInternal::set_music_volume(uint vol) { int IMuseInternal::set_master_volume (uint vol) { if (vol > 255) vol = 255; - else if (vol < 0) - vol = 0; if (_master_volume == vol) return 0; - _master_volume = vol; vol = vol * _music_volume / 255; for (uint i = 0; i < ARRAYSIZE (_channel_volume); i++) { @@ -2755,7 +2749,7 @@ int Player::scan(uint totrack, uint tobeat, uint totick) { uint32 curpos, topos; uint32 pos; - assert(totrack >= 0 && tobeat >= 0 && totick >= 0); +// assert(totrack >= 0 && tobeat >= 0 && totick >= 0); // Those are all unsigned numbers anyway... if (!_active) return -1; diff --git a/scumm/imuse_digi.cpp b/scumm/imuse_digi.cpp index fe228baba1..8f122f5021 100644 --- a/scumm/imuse_digi.cpp +++ b/scumm/imuse_digi.cpp @@ -1072,7 +1072,7 @@ int32 IMuseDigital::doCommand(int a, int b, int c, int d, int e, int f, int g, i int16 music = _digStateMusicMap[l].table_index; debug(2, "Play imuse music: %s, %s, %s", _digStateMusicTable[music].name, _digStateMusicTable[music].title, _digStateMusicTable[music].filename); if (_digStateMusicTable[music].filename[0] != 0) { - _scumm->_sound->playBundleMusic((char*)&_digStateMusicTable[music].filename); + _scumm->_sound->playBundleMusic((const char *)_digStateMusicTable[music].filename); } return 0; } @@ -1091,7 +1091,7 @@ int32 IMuseDigital::doCommand(int a, int b, int c, int d, int e, int f, int g, i if ((_comiStateMusicTable[l].index == b)) { debug(2, "Play imuse music: %s, %s, %s", _comiStateMusicTable[l].name, _comiStateMusicTable[l].title, _comiStateMusicTable[l].filename); if (_comiStateMusicTable[l].filename[0] != 0) { - _scumm->_sound->playBundleMusic((char*)&_comiStateMusicTable[l].filename); + _scumm->_sound->playBundleMusic((const char *)_comiStateMusicTable[l].filename); } return 0; } @@ -1125,7 +1125,7 @@ int32 IMuseDigital::doCommand(int a, int b, int c, int d, int e, int f, int g, i if ((_digSeqMusicTable[l].index == b)) { debug(2, "Play imuse music: %s, %s, %s", _digSeqMusicTable[l].name, _digSeqMusicTable[l].title, _digSeqMusicTable[l].filename); if (_digSeqMusicTable[l].filename[0] != 0) { - _scumm->_sound->playBundleMusic((char*)&_digSeqMusicTable[l].filename); + _scumm->_sound->playBundleMusic((const char *)_digSeqMusicTable[l].filename); } return 0; } @@ -1138,7 +1138,7 @@ int32 IMuseDigital::doCommand(int a, int b, int c, int d, int e, int f, int g, i if ((_comiSeqMusicTable[l].index == b)) { debug(2, "Play imuse music: %s, %s, %s", _comiSeqMusicTable[l].name, _comiSeqMusicTable[l].title, _comiSeqMusicTable[l].filename); if (_comiSeqMusicTable[l].filename[0] != 0) { - _scumm->_sound->playBundleMusic((char*)&_comiSeqMusicTable[l].filename); + _scumm->_sound->playBundleMusic((const char *)_comiSeqMusicTable[l].filename); } return 0; } diff --git a/scumm/object.cpp b/scumm/object.cpp index 8b2fa3bb61..15cbcfb346 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -899,7 +899,7 @@ byte *Scumm::getObjOrActorName(int obj) { objptr = getOBCDFromObject(obj); if (objptr == NULL) - return (byte *)" "; + return NULL; return findResourceData(MKID('OBNA'), objptr); } @@ -1596,7 +1596,7 @@ static byte _bompBitsTable[] = { int32 Scumm::setupBompScale(byte * scalling, int32 size, byte scale) { uint32 tmp = (256 - (size >> 1)); int32 count = (size + 7) >> 3; - assert(0 <= tmp && tmp < sizeof(_bompScaleTable)); + assert(tmp < sizeof(_bompScaleTable)); byte * tmp_ptr = _bompScaleTable + tmp; byte * tmp_scalling = scalling; byte a = 0; @@ -1656,7 +1656,7 @@ int32 Scumm::setupBompScale(byte * scalling, int32 size, byte scale) { byte ret_value = 0; while(count--) { tmp = *scalling++; - assert(0 <= tmp && tmp < sizeof(_bompBitsTable)); + assert(tmp < sizeof(_bompBitsTable)); ret_value += _bompBitsTable[tmp]; } diff --git a/scumm/resource.cpp b/scumm/resource.cpp index c44c9c97cd..bb179324e3 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -1597,7 +1597,7 @@ void Scumm::freeResources() { } } -void Scumm::loadPtrToResource(int type, int resindex, byte *source) { +void Scumm::loadPtrToResource(int type, int resindex, const byte *source) { byte *alloced; int i, len; diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp index 53c33af8d9..509775a9a9 100644 --- a/scumm/script_v2.cpp +++ b/scumm/script_v2.cpp @@ -882,7 +882,7 @@ void Scumm_v2::o2_doSentence() { void Scumm_v2::o2_drawSentence() { ScummVM::Rect sentenceline; static char sentence[80]; - byte *temp; + const byte *temp; int slot = getVerbSlot(VAR(VAR_SENTENCE_VERB),0); if (!(_userState & 32)) @@ -893,7 +893,7 @@ void Scumm_v2::o2_drawSentence() { temp = getObjOrActorName(VAR(VAR_SENTENCE_OBJECT1)); if (temp) { strcat(sentence, " "); - strcat(sentence, (char*)temp); + strcat(sentence, (const char*)temp); } } @@ -901,7 +901,7 @@ void Scumm_v2::o2_drawSentence() { temp = getObjOrActorName(VAR(VAR_SENTENCE_OBJECT2)); if (temp) { strcat(sentence, " with "); - strcat(sentence, (char*)temp); + strcat(sentence, (const char*)temp); } } @@ -1263,6 +1263,8 @@ void Scumm_v2::o2_setObjectName() { error("Can't set actor %d name with new-name-of", obj); name = getObjOrActorName(obj); + if (name == NULL) + return; // Silently abort byte *objptr; byte offset = 0; diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp index bc3e3a7830..c2381534dd 100644 --- a/scumm/script_v5.cpp +++ b/scumm/script_v5.cpp @@ -1933,6 +1933,8 @@ void Scumm_v5::o5_setObjectName() { } name = getObjOrActorName(obj); + if (name == NULL) + return; // Silently abort if (_features & GF_SMALL_HEADER) { // FIXME this is hack to make MonkeyVGA work. needed at least for the german diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index 6f68df086a..8ac3b69b5a 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -1761,7 +1761,7 @@ void Scumm_v6::o6_actorOps() { void Scumm_v6::o6_verbOps() { int slot, a, b; VerbSlot *vs; - byte *ptr, op; + byte op; // Full Throttle implements conversation by creating new verbs, one // for each option, but it never tells when to actually draw them. @@ -1853,11 +1853,10 @@ void Scumm_v6::o6_verbOps() { case 137: a = pop(); if (a == 0) { - ptr = (byte *)""; + loadPtrToResource(rtVerb, slot, (const byte *)""); } else { - ptr = getStringAddress(a); + loadPtrToResource(rtVerb, slot, getStringAddress(a)); } - loadPtrToResource(rtVerb, slot, ptr); vs->type = kTextVerbType; vs->imgindex = 0; break; diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index 7ef345029c..e43c15e207 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -1291,7 +1291,7 @@ void Scumm_v8::o8_verbOps() { case 0xA4: // SO_VERB_NAME_STR Set verb name a = pop(); if (a == 0) { - loadPtrToResource(rtVerb, _curVerbSlot, (byte *)""); + loadPtrToResource(rtVerb, _curVerbSlot, (const byte *)""); } else { loadPtrToResource(rtVerb, _curVerbSlot, getStringAddress(a)); } @@ -1343,10 +1343,10 @@ void Scumm_v8::o8_system() { void Scumm_v8::o8_startVideo() { int len = resStrLen(_scriptPointer); - warning("o8_startVideo(%s/%s)", getGameDataPath(), (char*)_scriptPointer); + warning("o8_startVideo(%s/%s)", getGameDataPath(), (const char*)_scriptPointer); SmushPlayer *sp = new SmushPlayer(this, 83333, !_noSubtitles); - sp->play((char*)_scriptPointer, getGameDataPath()); + sp->play((const char*)_scriptPointer, getGameDataPath()); delete sp; _scriptPointer += len + 1; diff --git a/scumm/scumm.h b/scumm/scumm.h index f9772ebd0a..8a45c78fb9 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -579,7 +579,7 @@ protected: bool openResourceFile(const char *filename); protected: - void loadPtrToResource(int type, int i, byte *ptr); + void loadPtrToResource(int type, int i, const byte *ptr); void readResTypeList(int id, uint32 tag, const char *name); char *resTypeFromId(int id); void allocResTypeData(int id, uint32 tag, int num, const char *name, int mode); diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 51cf6092db..949d2159a5 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -525,8 +525,8 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst) _debugLevel = detector->_debugLevel; _dumpScripts = detector->_dumpScripts; _bootParam = detector->_bootParam; - _exe_name = (char*)detector->_gameRealName.c_str(); - _game_name = (char*)detector->_gameFileName.c_str(); + _exe_name = strdup(detector->_gameRealName.c_str()); // FIXME: probably should use String class here + _game_name = strdup(detector->_gameFileName.c_str()); _gameId = detector->_gameId; _features = detector->_features; _noSubtitles = detector->_noSubtitles; diff --git a/scumm/sound.cpp b/scumm/sound.cpp index ff496acd8a..f87ffec927 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -520,7 +520,7 @@ void Sound::processSfxQueues() { } static int compareMP3OffsetTable(const void *a, const void *b) { - return ((MP3OffsetTable *)a)->org_offset - ((MP3OffsetTable *)b)->org_offset; + return ((const MP3OffsetTable *)a)->org_offset - ((const MP3OffsetTable *)b)->org_offset; } int Sound::startTalkSound(uint32 offset, uint32 b, int mode) { @@ -1030,7 +1030,7 @@ static void music_handler (void *engine) { g_scumm->_sound->bundleMusicHandler(g_scumm); } -void Sound::playBundleMusic(char *song) { +void Sound::playBundleMusic(const char *song) { if (_scumm->_silentDigitalImuse == true) { return; } diff --git a/scumm/sound.h b/scumm/sound.h index 3afac58f80..468422e554 100644 --- a/scumm/sound.h +++ b/scumm/sound.h @@ -42,8 +42,8 @@ enum { bool _soundsPaused2; bool _soundVolumePreset; - char *_nameBundleMusic; - char *_newNameBundleMusic; + const char *_nameBundleMusic; + const char *_newNameBundleMusic; byte _musicDisk; byte _voiceDisk; int32 _currentSampleBundleMusic; @@ -162,7 +162,7 @@ public: void stopSfxSound(); bool isSfxFinished(); uint32 decode12BitsSample(byte *src, byte **dst, uint32 size, bool stereo); - void playBundleMusic(char *song); + void playBundleMusic(const char *song); void pauseBundleMusic(bool state); void bundleMusicHandler(Scumm *scumm); void stopBundleMusic(); diff --git a/scumm/string.cpp b/scumm/string.cpp index 0f09ab197f..ffce2e0097 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -677,17 +677,19 @@ void Scumm::addVerbToStack(int var) } } } else { - addMessageToStack((byte *)""); + addMessageToStack((const byte *)""); } } void Scumm::addNameToStack(int var) { int num; + byte *ptr = 0; num = readVar(var); - if (num) { - byte *ptr = getObjOrActorName(num); + if (num) + ptr = getObjOrActorName(num); + if (ptr) { if ((_features & GF_AFTER_V8) && (ptr[0] == '/')) { char pointer[20]; int i, j; @@ -704,7 +706,7 @@ void Scumm::addNameToStack(int var) addMessageToStack(ptr); } } else { - addMessageToStack((byte *)""); + addMessageToStack((const byte *)""); } } @@ -735,7 +737,7 @@ void Scumm::addStringToStack(int var) { } } } else - addMessageToStack((byte *)""); + addMessageToStack((const byte *)""); } void Scumm::initCharset(int charsetno) { @@ -752,8 +754,8 @@ void Scumm::initCharset(int charsetno) { } int indexCompare(const void *p1, const void *p2) { - struct langIndexNode *i1 = (struct langIndexNode *) p1; - struct langIndexNode *i2 = (struct langIndexNode *) p2; + const struct langIndexNode *i1 = (const struct langIndexNode *) p1; + const struct langIndexNode *i2 = (const struct langIndexNode *) p2; return strcmp(i1->tag, i2->tag); } @@ -885,7 +887,7 @@ void Scumm::translateText(const byte *text, byte *trans_buff) { } } } - byte *pointer = (byte *)strchr((char *)text + 1, '/'); + byte *pointer = (byte *)strchr((const char *)text + 1, '/'); if (pointer != NULL) { pointer++; memcpy(trans_buff, pointer, resStrLen(pointer) + 1); @@ -918,7 +920,7 @@ void Scumm::translateText(const byte *text, byte *trans_buff) { // skip translation if flag 'h' exist if (buf[pos] == 'h') { pos += 3; - byte *pointer = (byte *)strchr((char *)text + 1, '/'); + byte *pointer = (byte *)strchr((const char *)text + 1, '/'); if (pointer != NULL) memcpy(trans_buff, pointer + 1, resStrLen(pointer + 1) + 1); else @@ -976,7 +978,7 @@ void Scumm::translateText(const byte *text, byte *trans_buff) { } } } - byte *pointer = (byte *)strchr((char *)text + 1, '/'); + byte *pointer = (byte *)strchr((const char *)text + 1, '/'); if (pointer != NULL) { pointer++; l = 0; diff --git a/scumm/verbs.cpp b/scumm/verbs.cpp index 31f3637f96..5de65a9e3a 100644 --- a/scumm/verbs.cpp +++ b/scumm/verbs.cpp @@ -70,6 +70,7 @@ void Scumm::redrawV2Inventory() { _string[1].xpos = 0; _messagePtr = getObjOrActorName(obj); + assert(_messagePtr); drawString(1); items++; |