many pedantic warning fixes (and some actual potential buglets fixed, too)

svn-id: r7795
This commit is contained in:
Max Horn 2003-05-21 18:09:49 +00:00
parent 11d29b71ab
commit 86d57f3c7a
20 changed files with 62 additions and 58 deletions

View File

@ -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;
}

View File

@ -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) {

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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) {

View File

@ -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;

View File

@ -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;
}

View File

@ -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];
}

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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();

View File

@ -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;

View File

@ -70,6 +70,7 @@ void Scumm::redrawV2Inventory() {
_string[1].xpos = 0;
_messagePtr = getObjOrActorName(obj);
assert(_messagePtr);
drawString(1);
items++;