HUGO: Hopefully fix GCC_PRINTF issue in util

* Add a mask in each call of Warn(), Error() and Box() not using one
* cleanup: use the same wording for 'End of namespace Hugo' in all files

svn-id: r52406
This commit is contained in:
Arnaud Boutonné 2010-08-27 09:48:53 +00:00
parent fd574d5e24
commit ec9708694e
24 changed files with 110 additions and 103 deletions

View file

@ -231,4 +231,5 @@ void HugoEngine::initGamePart(const HugoGameDescription *gd) {
break; break;
} }
} }
} // End of namespace Hugo } // End of namespace Hugo

View file

@ -278,7 +278,7 @@ void Screen::displayList(dupdate_t update, ...) {
break; break;
case D_ADD: // Add a rectangle to list case D_ADD: // Add a rectangle to list
if (addIndex >= DMAX) { if (addIndex >= DMAX) {
Utils::Warn(false, "Display list exceeded"); Utils::Warn(false, "%s", "Display list exceeded");
return; return;
} }
va_start(marker, update); // Initialize variable arguments va_start(marker, update); // Initialize variable arguments
@ -440,7 +440,8 @@ void Screen::loadFont(int16 fontId) {
void Screen::userHelp() { void Screen::userHelp() {
// Introduce user to the game // Introduce user to the game
// DOS versions Only // DOS versions Only
Utils::Box(BOX_ANY , "F1 - Press F1 again\n" Utils::Box(BOX_ANY , "%s",
"F1 - Press F1 again\n"
" for instructions\n" " for instructions\n"
"F2 - Sound on/off\n" "F2 - Sound on/off\n"
"F3 - Recall last line\n" "F3 - Recall last line\n"
@ -452,4 +453,4 @@ void Screen::userHelp() {
"ESC - Return to game"); "ESC - Return to game");
} }
} // end of namespace Hugo } // End of namespace Hugo

View file

@ -98,5 +98,6 @@ private:
int16 center(char *s); int16 center(char *s);
}; };
} // end of namespace Hugo } // End of namespace Hugo
#endif //HUGO_DISPLAY_H #endif //HUGO_DISPLAY_H

View file

@ -848,7 +848,7 @@ void HugoEngine::useObject(int16 objId) {
// Deselect dragged icon if inventory not active // Deselect dragged icon if inventory not active
if (_status.inventoryState != I_ACTIVE) if (_status.inventoryState != I_ACTIVE)
_status.inventoryObjId = -1; _status.inventoryObjId = -1;
Utils::Box(BOX_ANY, _textData[use->dataIndex]); Utils::Box(BOX_ANY, "%s", _textData[use->dataIndex]);
return; return;
} }
} }
@ -988,9 +988,9 @@ void HugoEngine::endGame() {
debugC(1, kDebugEngine, "endGame"); debugC(1, kDebugEngine, "endGame");
if (!_boot.registered) if (!_boot.registered)
Utils::Box(BOX_ANY, _textEngine[kEsAdvertise]); Utils::Box(BOX_ANY, "%s", _textEngine[kEsAdvertise]);
Utils::Box(BOX_ANY, "%s\n%s", _episode, COPYRIGHT); Utils::Box(BOX_ANY, "%s\n%s", _episode, COPYRIGHT);
_status.viewState = V_EXIT; _status.viewState = V_EXIT;
} }
} // end of namespace Hugo } // End of namespace Hugo

View file

@ -39,5 +39,6 @@ enum seqTextEngine {
kEsAdvertise = 0 kEsAdvertise = 0
}; };
} // end of namespace Hugo } // End of namespace Hugo
#endif // HUGO_ENGINE_H #endif // HUGO_ENGINE_H

View file

@ -108,12 +108,12 @@ seq_t *FileManager::readPCX(Common::File &f, seq_t *seqPtr, byte *imagePtr, bool
f.read(PCC_header.fill2, sizeof(PCC_header.fill2)); f.read(PCC_header.fill2, sizeof(PCC_header.fill2));
if (PCC_header.mfctr != 10) if (PCC_header.mfctr != 10)
Utils::Error(PCCH_ERR, name); Utils::Error(PCCH_ERR, "%s", name);
// Allocate memory for seq_t if NULL // Allocate memory for seq_t if NULL
if (seqPtr == NULL) if (seqPtr == NULL)
if ((seqPtr = (seq_t *)malloc(sizeof(seq_t))) == NULL) if ((seqPtr = (seq_t *)malloc(sizeof(seq_t))) == NULL)
Utils::Error(HEAP_ERR, name); Utils::Error(HEAP_ERR, "%s", name);
// Find size of image data in 8-bit DIB format // Find size of image data in 8-bit DIB format
// Note save of x2 - marks end of valid data before garbage // Note save of x2 - marks end of valid data before garbage
@ -126,7 +126,7 @@ seq_t *FileManager::readPCX(Common::File &f, seq_t *seqPtr, byte *imagePtr, bool
// Allocate memory for image data if NULL // Allocate memory for image data if NULL
if (imagePtr == NULL) if (imagePtr == NULL)
if ((imagePtr = (byte *)malloc((size_t) size)) == NULL) if ((imagePtr = (byte *)malloc((size_t) size)) == NULL)
Utils::Error(HEAP_ERR, name); Utils::Error(HEAP_ERR, "%s", name);
seqPtr->imagePtr = imagePtr; seqPtr->imagePtr = imagePtr;
// Process the image data, converting to 8-bit DIB format // Process the image data, converting to 8-bit DIB format
@ -176,7 +176,7 @@ void FileManager::readImage(int objNum, object_t *objPtr) {
warning("File %s not found, trying again with %s%s", buf, _vm._arrayNouns[objPtr->nounIndex][0], OBJEXT); warning("File %s not found, trying again with %s%s", buf, _vm._arrayNouns[objPtr->nounIndex][0], OBJEXT);
strcat(strcpy(buf, _vm._arrayNouns[objPtr->nounIndex][0]), OBJEXT); strcat(strcpy(buf, _vm._arrayNouns[objPtr->nounIndex][0]), OBJEXT);
if (!_objectsArchive.open(buf)) if (!_objectsArchive.open(buf))
Utils::Error(FILE_ERR, buf); Utils::Error(FILE_ERR, "%s", buf);
} }
} }
@ -262,7 +262,7 @@ void FileManager::readBackground(int screenIndex) {
warning("File %s not found, trying again with %s.ART", buf, _vm._screenNames[screenIndex]); warning("File %s not found, trying again with %s.ART", buf, _vm._screenNames[screenIndex]);
strcat(strcpy(buf, _vm._screenNames[screenIndex]), ".ART"); strcat(strcpy(buf, _vm._screenNames[screenIndex]), ".ART");
if (!_sceneryArchive.open(buf)) if (!_sceneryArchive.open(buf))
Utils::Error(FILE_ERR, buf); Utils::Error(FILE_ERR, "%s", buf);
} }
} }
@ -290,7 +290,7 @@ sound_pt FileManager::getSound(int16 sound, uint16 *size) {
// Open sounds file // Open sounds file
if (!fp.open(SOUND_FILE)) { if (!fp.open(SOUND_FILE)) {
// Error(FILE_ERR, SOUND_FILE); // Error(FILE_ERR, "%s", SOUND_FILE);
warning("Hugo Error: File not found %s", SOUND_FILE); warning("Hugo Error: File not found %s", SOUND_FILE);
return(NULL); return(NULL);
} }
@ -299,24 +299,24 @@ sound_pt FileManager::getSound(int16 sound, uint16 *size) {
static bool has_read_header = false; static bool has_read_header = false;
if (!has_read_header) { if (!has_read_header) {
if (fp.read(s_hdr, sizeof(s_hdr)) != sizeof(s_hdr)) if (fp.read(s_hdr, sizeof(s_hdr)) != sizeof(s_hdr))
Utils::Error(FILE_ERR, SOUND_FILE); Utils::Error(FILE_ERR, "%s", SOUND_FILE);
has_read_header = true; has_read_header = true;
} }
*size = s_hdr[sound].size; *size = s_hdr[sound].size;
if (*size == 0) if (*size == 0)
Utils::Error(SOUND_ERR, SOUND_FILE); Utils::Error(SOUND_ERR, "%s", SOUND_FILE);
// Allocate memory for sound or music, if possible // Allocate memory for sound or music, if possible
if ((soundPtr = (byte *)malloc(s_hdr[sound].size)) == 0) { if ((soundPtr = (byte *)malloc(s_hdr[sound].size)) == 0) {
Utils::Warn(false, "Low on memory"); Utils::Warn(false, "%s", "Low on memory");
return(NULL); return(NULL);
} }
// Seek to data and read it // Seek to data and read it
fp.seek(s_hdr[sound].offset, SEEK_SET); fp.seek(s_hdr[sound].offset, SEEK_SET);
if (fp.read(soundPtr, s_hdr[sound].size) != s_hdr[sound].size) if (fp.read(soundPtr, s_hdr[sound].size) != s_hdr[sound].size)
Utils::Error(FILE_ERR, SOUND_FILE); Utils::Error(FILE_ERR, "%s", SOUND_FILE);
fp.close(); fp.close();
@ -369,7 +369,7 @@ void FileManager::readOverlay(int screenNum, image_pt image, ovl_t overlayType)
i = sceneBlock.ob_len; i = sceneBlock.ob_len;
break; break;
default: default:
Utils::Error(FILE_ERR, "Bad ovl_type"); Utils::Error(FILE_ERR, "%s", "Bad ovl_type");
break; break;
} }
if (i == 0) { if (i == 0) {
@ -390,7 +390,7 @@ void FileManager::readOverlay(int screenNum, image_pt image, ovl_t overlayType)
} }
if (!_sceneryArchive.open(buf)) if (!_sceneryArchive.open(buf))
Utils::Error(FILE_ERR, buf); Utils::Error(FILE_ERR, "%s", buf);
// if (eof(f_scenery)) { // if (eof(f_scenery)) {
// _lclose(f_scenery); // _lclose(f_scenery);
@ -560,7 +560,7 @@ void FileManager::restoreGame(int16 slot) {
int saveVersion; int saveVersion;
in->read(&saveVersion, sizeof(saveVersion)); in->read(&saveVersion, sizeof(saveVersion));
if (saveVersion != kSavegameVersion) { if (saveVersion != kSavegameVersion) {
Utils::Error(GEN_ERR, "Savegame of incompatible version"); Utils::Error(GEN_ERR, "%s", "Savegame of incompatible version");
return; return;
} }
@ -644,7 +644,7 @@ void FileManager::initSavedGame() {
if (!(in = _vm.getSaveFileManager()->openForLoading(path))) { if (!(in = _vm.getSaveFileManager()->openForLoading(path))) {
saveGame(-1, ""); saveGame(-1, "");
if (!(in = _vm.getSaveFileManager()->openForLoading(path))) { if (!(in = _vm.getSaveFileManager()->openForLoading(path))) {
Utils::Error(WRITE_ERR, path); Utils::Error(WRITE_ERR, "%s", path);
return; return;
} }
} }
@ -655,7 +655,7 @@ void FileManager::initSavedGame() {
// Check sanity - maybe disk full or path set to read-only drive? // Check sanity - maybe disk full or path set to read-only drive?
if (_vm.getGameStatus().saveSize == -1) if (_vm.getGameStatus().saveSize == -1)
Utils::Error(WRITE_ERR, path); Utils::Error(WRITE_ERR, "%s", path);
} }
// Record and playback handling stuff: // Record and playback handling stuff:
@ -671,7 +671,7 @@ void FileManager::openPlaybackFile(bool playbackFl, bool recordFl) {
if (playbackFl) { if (playbackFl) {
if (!(fpb = fopen(PBFILE, "r+b"))) if (!(fpb = fopen(PBFILE, "r+b")))
Utils::Error(FILE_ERR, PBFILE); Utils::Error(FILE_ERR, "%s", PBFILE);
} else if (recordFl) } else if (recordFl)
fpb = fopen(PBFILE, "wb"); fpb = fopen(PBFILE, "wb");
pbdata.time = 0; // Say no key available pbdata.time = 0; // Say no key available
@ -687,13 +687,13 @@ void FileManager::openDatabaseFiles() {
debugC(1, kDebugFile, "openDatabaseFiles"); debugC(1, kDebugFile, "openDatabaseFiles");
if (!_stringArchive.open(STRING_FILE)) if (!_stringArchive.open(STRING_FILE))
// Error(FILE_ERR, STRING_FILE); // Error(FILE_ERR, "%s", STRING_FILE);
warning("Hugo Error: File not found %s", STRING_FILE); warning("Hugo Error: File not found %s", STRING_FILE);
if (_vm.isPacked()) { if (_vm.isPacked()) {
if (!_sceneryArchive.open(SCENERY_FILE)) if (!_sceneryArchive.open(SCENERY_FILE))
Utils::Error(FILE_ERR, SCENERY_FILE); Utils::Error(FILE_ERR, "%s", SCENERY_FILE);
if (!_objectsArchive.open(OBJECTS_FILE)) if (!_objectsArchive.open(OBJECTS_FILE))
Utils::Error(FILE_ERR, OBJECTS_FILE); Utils::Error(FILE_ERR, "%s", OBJECTS_FILE);
} }
} }
@ -718,18 +718,18 @@ char *FileManager::fetchString(int index) {
// Get offset to string[index] (and next for length calculation) // Get offset to string[index] (and next for length calculation)
_stringArchive.seek((uint32)index * sizeof(uint32), SEEK_SET); _stringArchive.seek((uint32)index * sizeof(uint32), SEEK_SET);
if (_stringArchive.read((char *)&off1, sizeof(uint32)) == 0) if (_stringArchive.read((char *)&off1, sizeof(uint32)) == 0)
Utils::Error(FILE_ERR, "String offset"); Utils::Error(FILE_ERR, "%s", "String offset");
if (_stringArchive.read((char *)&off2, sizeof(uint32)) == 0) if (_stringArchive.read((char *)&off2, sizeof(uint32)) == 0)
Utils::Error(FILE_ERR, "String offset"); Utils::Error(FILE_ERR, "%s", "String offset");
// Check size of string // Check size of string
if ((off2 - off1) >= MAX_BOX) if ((off2 - off1) >= MAX_BOX)
Utils::Error(FILE_ERR, "Fetched string too long!"); Utils::Error(FILE_ERR, "%s", "Fetched string too long!");
// Position to string and read it into gen purpose _textBoxBuffer // Position to string and read it into gen purpose _textBoxBuffer
_stringArchive.seek(off1, SEEK_SET); _stringArchive.seek(off1, SEEK_SET);
if (_stringArchive.read(_textBoxBuffer, (uint16)(off2 - off1)) == 0) if (_stringArchive.read(_textBoxBuffer, (uint16)(off2 - off1)) == 0)
Utils::Error(FILE_ERR, "Fetch_string"); Utils::Error(FILE_ERR, "%s", "Fetch_string");
// Null terminate, decode and return it // Null terminate, decode and return it
_textBoxBuffer[off2-off1] = '\0'; _textBoxBuffer[off2-off1] = '\0';
@ -751,7 +751,7 @@ void FileManager::printBootText() {
warning("printBootText - Skipping as H1 Dos may be a freeware"); warning("printBootText - Skipping as H1 Dos may be a freeware");
return; return;
} else } else
Utils::Error(FILE_ERR, BOOTFILE); Utils::Error(FILE_ERR, "%s", BOOTFILE);
} }
// Allocate space for the text and print it // Allocate space for the text and print it
@ -760,14 +760,14 @@ void FileManager::printBootText() {
// Skip over the boot structure (already read) and read exit text // Skip over the boot structure (already read) and read exit text
ofp.seek((long)sizeof(_boot), SEEK_SET); ofp.seek((long)sizeof(_boot), SEEK_SET);
if (ofp.read(buf, _boot.exit_len) != (size_t)_boot.exit_len) if (ofp.read(buf, _boot.exit_len) != (size_t)_boot.exit_len)
Utils::Error(FILE_ERR, BOOTFILE); Utils::Error(FILE_ERR, "%s", BOOTFILE);
// Decrypt the exit text, using CRYPT substring // Decrypt the exit text, using CRYPT substring
for (i = 0; i < _boot.exit_len; i++) for (i = 0; i < _boot.exit_len; i++)
buf[i] ^= CRYPT[i % strlen(CRYPT)]; buf[i] ^= CRYPT[i % strlen(CRYPT)];
buf[i] = '\0'; buf[i] = '\0';
//Box(BOX_OK, buf_p); //Box(BOX_OK, "%s", buf_p);
//MessageBox(hwnd, buf_p, "License", MB_ICONINFORMATION); //MessageBox(hwnd, buf_p, "License", MB_ICONINFORMATION);
warning("printBootText(): License: %s", buf); warning("printBootText(): License: %s", buf);
} }
@ -792,11 +792,11 @@ void FileManager::readBootFile() {
warning("readBootFile - Skipping as H1 Dos may be a freeware"); warning("readBootFile - Skipping as H1 Dos may be a freeware");
return; return;
} else } else
Utils::Error(FILE_ERR, BOOTFILE); Utils::Error(FILE_ERR, "%s", BOOTFILE);
} }
if (ofp.size() < (int32)sizeof(_boot)) if (ofp.size() < (int32)sizeof(_boot))
Utils::Error(FILE_ERR, BOOTFILE); Utils::Error(FILE_ERR, "%s", BOOTFILE);
_boot.checksum = ofp.readByte(); _boot.checksum = ofp.readByte();
_boot.registered = ofp.readByte(); _boot.registered = ofp.readByte();
@ -812,7 +812,7 @@ void FileManager::readBootFile() {
ofp.close(); ofp.close();
if (checksum) if (checksum)
Utils::Error(GEN_ERR, "Program startup file invalid"); Utils::Error(GEN_ERR, "%s", "Program startup file invalid");
} }
void FileManager::readConfig() { void FileManager::readConfig() {
@ -862,10 +862,10 @@ uif_hdr_t *FileManager::getUIFHeader(uif_t id) {
firstFl = false; firstFl = false;
// Open unbuffered to do far read // Open unbuffered to do far read
if (!ip.open(UIF_FILE)) if (!ip.open(UIF_FILE))
Utils::Error(FILE_ERR, UIF_FILE); Utils::Error(FILE_ERR, "%s", UIF_FILE);
if (ip.size() < (int32)sizeof(UIFHeader)) if (ip.size() < (int32)sizeof(UIFHeader))
Utils::Error(FILE_ERR, UIF_FILE); Utils::Error(FILE_ERR, "%s", UIF_FILE);
for (int i = 0; i < MAX_UIFS; ++i) { for (int i = 0; i < MAX_UIFS; ++i) {
UIFHeader[i].size = ip.readUint16LE(); UIFHeader[i].size = ip.readUint16LE();
@ -887,7 +887,7 @@ void FileManager::readUIFItem(int16 id, byte *buf) {
// Open uif file to read data // Open uif file to read data
if (!ip.open(UIF_FILE)) if (!ip.open(UIF_FILE))
Utils::Error(FILE_ERR, UIF_FILE); Utils::Error(FILE_ERR, "%s", UIF_FILE);
// Seek to data // Seek to data
UIFHeaderPtr = getUIFHeader((uif_t)id); UIFHeaderPtr = getUIFHeader((uif_t)id);
@ -900,7 +900,7 @@ void FileManager::readUIFItem(int16 id, byte *buf) {
break; break;
default: // Read file data into supplied array default: // Read file data into supplied array
if (ip.read(buf, UIFHeaderPtr->size) != UIFHeaderPtr->size) if (ip.read(buf, UIFHeaderPtr->size) != UIFHeaderPtr->size)
Utils::Error(FILE_ERR, UIF_FILE); Utils::Error(FILE_ERR, "%s", UIF_FILE);
break; break;
} }
@ -928,11 +928,11 @@ void FileManager::instructions() {
f.read(wrkLine, 1); f.read(wrkLine, 1);
} while (*wrkLine++ != EOP); } while (*wrkLine++ != EOP);
wrkLine[-2] = '\0'; /* Remove EOP and previous CR */ wrkLine[-2] = '\0'; /* Remove EOP and previous CR */
Utils::Box(BOX_ANY, line); Utils::Box(BOX_ANY, "%s", line);
wrkLine = line; wrkLine = line;
f.read(readBuf, 2); /* Remove CRLF after EOP */ f.read(readBuf, 2); /* Remove CRLF after EOP */
} }
f.close(); f.close();
} }
} // end of namespace Hugo } // End of namespace Hugo

View file

@ -85,6 +85,6 @@ private:
// char pbget(); // char pbget();
}; };
} // End of namespace Hugo
} // end of namespace Hugo
#endif //HUGO_FILE_H #endif //HUGO_FILE_H

View file

@ -51,5 +51,5 @@ namespace Hugo {
#define UIF_FILE "uif.dat" #define UIF_FILE "uif.dat"
static const int kSavegameVersion = 1; static const int kSavegameVersion = 1;
} // Namespace Hugo
} // End of namespace Hugo

View file

@ -1442,5 +1442,4 @@ void HugoEngine::freeTexts(char **ptr) {
free(ptr); free(ptr);
} }
} // End of namespace Hugo } // End of namespace Hugo

View file

@ -116,13 +116,13 @@ bool intro_3w::introPlay() {
// Text boxes at various times // Text boxes at various times
switch (introTicks) { switch (introTicks) {
case 4: case 4:
Utils::Box(BOX_OK, _vm._textIntro[kIntro1]); Utils::Box(BOX_OK, "%s", _vm._textIntro[kIntro1]);
break; break;
case 9: case 9:
Utils::Box(BOX_OK, _vm._textIntro[kIntro2]); Utils::Box(BOX_OK, "%s", _vm._textIntro[kIntro2]);
break; break;
case 35: case 35:
Utils::Box(BOX_OK, _vm._textIntro[kIntro3]); Utils::Box(BOX_OK, "%s", _vm._textIntro[kIntro3]);
break; break;
} }
} }
@ -183,5 +183,4 @@ bool intro_3d::introPlay() {
return true; return true;
} }
} // end of namespace Hugo } // End of namespace Hugo

View file

@ -115,6 +115,6 @@ public:
bool introPlay(); bool introPlay();
}; };
} // End of namespace Hugo
} // Namespace Hugo
#endif #endif

View file

@ -51,5 +51,6 @@ private:
void constructInventory(int16 imageTotNumb, int displayNumb, bool scrollFl, int16 firstObjId); void constructInventory(int16 imageTotNumb, int displayNumb, bool scrollFl, int16 firstObjId);
}; };
} // end of namespace Hugo } // End of namespace Hugo
#endif // HUGO_INVENTORY_H #endif // HUGO_INVENTORY_H

View file

@ -135,7 +135,7 @@ void MouseHandler::processRightClick(int16 objId, int16 cx, int16 cy) {
if (_vm._hero->cycling == INVISIBLE) // If invisible do if (_vm._hero->cycling == INVISIBLE) // If invisible do
_vm.useObject(objId); // immediate use _vm.useObject(objId); // immediate use
else else
Utils::Box(BOX_ANY, _vm._textMouse[kMsNoWayText]); // Can't get there Utils::Box(BOX_ANY, "%s", _vm._textMouse[kMsNoWayText]); // Can't get there
} }
break; break;
} }
@ -189,7 +189,7 @@ void MouseHandler::processLeftClick(int16 objId, int16 cx, int16 cy) {
else if (_vm._hotspots[i].direction == Common::KEYCODE_LEFT) else if (_vm._hotspots[i].direction == Common::KEYCODE_LEFT)
x += HERO_MAX_WIDTH; x += HERO_MAX_WIDTH;
if (!_vm.route().startRoute(GO_EXIT, i, x, y)) if (!_vm.route().startRoute(GO_EXIT, i, x, y))
Utils::Box(BOX_ANY, _vm._textMouse[kMsNoWayText]); // Can't get there Utils::Box(BOX_ANY, "%s", _vm._textMouse[kMsNoWayText]); // Can't get there
} }
// Get rid of any attached icon // Get rid of any attached icon
@ -218,7 +218,7 @@ void MouseHandler::processLeftClick(int16 objId, int16 cx, int16 cy) {
if (_vm._hero->cycling == INVISIBLE) // If invisible do if (_vm._hero->cycling == INVISIBLE) // If invisible do
_vm.lookObject(obj); // immediate decription _vm.lookObject(obj); // immediate decription
else else
Utils::Box(BOX_ANY, _vm._textMouse[kMsNoWayText]); // Can't get there Utils::Box(BOX_ANY, "%s", _vm._textMouse[kMsNoWayText]); // Can't get there
} }
break; break;
} }
@ -308,4 +308,4 @@ void MouseHandler::mouseHandler() {
gameStatus.rightButtonFl = false; gameStatus.rightButtonFl = false;
} }
} // end of namespace Hugo } // End of namespace Hugo

View file

@ -49,5 +49,6 @@ private:
void processLeftClick(int16 objId, int16 cx, int16 cy); void processLeftClick(int16 objId, int16 cx, int16 cy);
}; };
} // end of namespace Hugo } // End of namespace Hugo
#endif //HUGO_MOUSE_H #endif //HUGO_MOUSE_H

View file

@ -304,7 +304,7 @@ void Parser::lineHandler() {
// Special meta commands // Special meta commands
// EXIT/QUIT // EXIT/QUIT
if (!strcmp("exit", _line) || strstr(_line, "quit")) { if (!strcmp("exit", _line) || strstr(_line, "quit")) {
Utils::Box(BOX_ANY, _vm._textParser[kTBExit]); Utils::Box(BOX_ANY, "%s", _vm._textParser[kTBExit]);
return; return;
} }
@ -362,7 +362,7 @@ void Parser::lineHandler() {
// If a not-near comment was generated, print it // If a not-near comment was generated, print it
if (*farComment != '\0') { if (*farComment != '\0') {
Utils::Box(BOX_ANY, farComment); Utils::Box(BOX_ANY, "%s", farComment);
return; return;
} }
@ -370,16 +370,16 @@ void Parser::lineHandler() {
verb = findVerb(_line); verb = findVerb(_line);
noun = findNoun(_line); noun = findNoun(_line);
if (verb == _vm._arrayVerbs[_vm._look][0] && _maze.enabledFl) { if (verb == _vm._arrayVerbs[_vm._look][0] && _maze.enabledFl) {
Utils::Box(BOX_ANY, _vm._textParser[kTBMaze]); Utils::Box(BOX_ANY, "%s", _vm._textParser[kTBMaze]);
showTakeables(); showTakeables();
} else if (verb && noun) // A combination I didn't think of } else if (verb && noun) // A combination I didn't think of
Utils::Box(BOX_ANY, _vm._textParser[kTBNoPoint]); Utils::Box(BOX_ANY, "%s", _vm._textParser[kTBNoPoint]);
else if (noun) else if (noun)
Utils::Box(BOX_ANY, _vm._textParser[kTBNoun]); Utils::Box(BOX_ANY, "%s", _vm._textParser[kTBNoun]);
else if (verb) else if (verb)
Utils::Box(BOX_ANY, _vm._textParser[kTBVerb]); Utils::Box(BOX_ANY, "%s", _vm._textParser[kTBVerb]);
else else
Utils::Box(BOX_ANY, _vm._textParser[kTBEh]); Utils::Box(BOX_ANY, "%s", _vm._textParser[kTBEh]);
} }
// Search for matching verb/noun pairs in background command list // Search for matching verb/noun pairs in background command list
@ -392,7 +392,7 @@ bool Parser::isBackgroundWord(objectList_t obj, char *line) {
isWordPresent(_vm._arrayNouns[obj[i].nounIndex]) && isWordPresent(_vm._arrayNouns[obj[i].nounIndex]) &&
((obj[i].roomState == DONT_CARE) || ((obj[i].roomState == DONT_CARE) ||
(obj[i].roomState == _vm._screenStates[*_vm._screen_p]))) { (obj[i].roomState == _vm._screenStates[*_vm._screen_p]))) {
Utils::Box(BOX_ANY, _vm.file().fetchString(obj[i].commentIndex)); Utils::Box(BOX_ANY, "%s", _vm.file().fetchString(obj[i].commentIndex));
_vm.scheduler().processBonus(obj[i].bonusIndex); _vm.scheduler().processBonus(obj[i].bonusIndex);
return true; return true;
} }
@ -411,7 +411,7 @@ bool Parser::isCatchallVerb(objectList_t obj, char *line) {
(!obj[i].matchFl || !findNoun(line)) && (!obj[i].matchFl || !findNoun(line)) &&
((obj[i].roomState == DONT_CARE) || ((obj[i].roomState == DONT_CARE) ||
(obj[i].roomState == _vm._screenStates[*_vm._screen_p]))) { (obj[i].roomState == _vm._screenStates[*_vm._screen_p]))) {
Utils::Box(BOX_ANY, _vm.file().fetchString(obj[i].commentIndex)); Utils::Box(BOX_ANY, "%s", _vm.file().fetchString(obj[i].commentIndex));
_vm.scheduler().processBonus(obj[i].bonusIndex); _vm.scheduler().processBonus(obj[i].bonusIndex);
// If this is LOOK (without a noun), show any takeable objects // If this is LOOK (without a noun), show any takeable objects
@ -524,8 +524,8 @@ void Parser::showTakeables() {
if ((obj->cycling != INVISIBLE) && if ((obj->cycling != INVISIBLE) &&
(obj->screenIndex == *_vm._screen_p) && (obj->screenIndex == *_vm._screen_p) &&
(((TAKE & obj->genericCmd) == TAKE) || obj->objValue)) { (((TAKE & obj->genericCmd) == TAKE) || obj->objValue)) {
sprintf(_textBoxBuffer, "You can also see:\n%s.", _vm._arrayNouns[obj->nounIndex][LOOK_NAME]); // sprintf(_textBoxBuffer, "You can also see:\n%s.", _vm._arrayNouns[obj->nounIndex][LOOK_NAME]);
Utils::Box(BOX_ANY, _textBoxBuffer); Utils::Box(BOX_ANY, "You can also see:\n%s.", _vm._arrayNouns[obj->nounIndex][LOOK_NAME]);
} }
} }
} }
@ -561,7 +561,7 @@ void Parser::dropObject(object_t *obj) {
obj->y = _vm._hero->y + _vm._hero->currImagePtr->y2 - 1; obj->y = _vm._hero->y + _vm._hero->currImagePtr->y2 - 1;
obj->y = (obj->y + obj->currImagePtr->y2 < YPIX) ? obj->y : YPIX - obj->currImagePtr->y2 - 10; obj->y = (obj->y + obj->currImagePtr->y2 < YPIX) ? obj->y : YPIX - obj->currImagePtr->y2 - 10;
_vm.adjustScore(-obj->objValue); _vm.adjustScore(-obj->objValue);
Utils::Box(BOX_ANY, _vm._textParser[kTBOk]); Utils::Box(BOX_ANY, "%s", _vm._textParser[kTBOk]);
} }
// Test whether command line contains one of the generic actions // Test whether command line contains one of the generic actions
@ -575,35 +575,35 @@ bool Parser::isGenericVerb(object_t *obj, char *line, char *comment) {
if (isWordPresent(_vm._arrayVerbs[_vm._look]) && isNear(obj, _vm._arrayVerbs[_vm._look][0], comment)) { if (isWordPresent(_vm._arrayVerbs[_vm._look]) && isNear(obj, _vm._arrayVerbs[_vm._look][0], comment)) {
// Test state-dependent look before general look // Test state-dependent look before general look
if ((obj->genericCmd & LOOK_S) == LOOK_S) { if ((obj->genericCmd & LOOK_S) == LOOK_S) {
Utils::Box(BOX_ANY, _vm._textData[obj->stateDataIndex[obj->state]]); Utils::Box(BOX_ANY, "%s", _vm._textData[obj->stateDataIndex[obj->state]]);
warning("isGenericVerb: use of state dependant look - To be validated"); warning("isGenericVerb: use of state dependant look - To be validated");
} else { } else {
if ((LOOK & obj->genericCmd) == LOOK) if ((LOOK & obj->genericCmd) == LOOK)
if (_vm._textData[obj->dataIndex]) if (_vm._textData[obj->dataIndex])
Utils::Box(BOX_ANY, _vm._textData[obj->dataIndex]); Utils::Box(BOX_ANY, "%s", _vm._textData[obj->dataIndex]);
else else
return(false); return(false);
else else
Utils::Box(BOX_ANY, _vm._textParser[kTBUnusual]); Utils::Box(BOX_ANY, "%s", _vm._textParser[kTBUnusual]);
} }
} else if (isWordPresent(_vm._arrayVerbs[_vm._take]) && isNear(obj, _vm._arrayVerbs[_vm._take][0], comment)) { } else if (isWordPresent(_vm._arrayVerbs[_vm._take]) && isNear(obj, _vm._arrayVerbs[_vm._take][0], comment)) {
if (obj->carriedFl) if (obj->carriedFl)
Utils::Box(BOX_ANY, _vm._textParser[kTBHave]); Utils::Box(BOX_ANY, "%s", _vm._textParser[kTBHave]);
else if ((TAKE & obj->genericCmd) == TAKE) else if ((TAKE & obj->genericCmd) == TAKE)
takeObject(obj); takeObject(obj);
else if (obj->cmdIndex != 0) // No comment if possible commands else if (obj->cmdIndex != 0) // No comment if possible commands
return false; return false;
else if (!obj->verbOnlyFl && (TAKE & obj->genericCmd) == TAKE) // Make sure not taking object in context! else if (!obj->verbOnlyFl && (TAKE & obj->genericCmd) == TAKE) // Make sure not taking object in context!
Utils::Box(BOX_ANY, _vm._textParser[kTBNoUse]); Utils::Box(BOX_ANY, "%s", _vm._textParser[kTBNoUse]);
else else
return false; return false;
} else if (isWordPresent(_vm._arrayVerbs[_vm._drop])) { } else if (isWordPresent(_vm._arrayVerbs[_vm._drop])) {
if (!obj->carriedFl && ((DROP & obj->genericCmd) == DROP)) if (!obj->carriedFl && ((DROP & obj->genericCmd) == DROP))
Utils::Box(BOX_ANY, _vm._textParser[kTBDontHave]); Utils::Box(BOX_ANY, "%s", _vm._textParser[kTBDontHave]);
else if (obj->carriedFl && ((DROP & obj->genericCmd) == DROP)) else if (obj->carriedFl && ((DROP & obj->genericCmd) == DROP))
dropObject(obj); dropObject(obj);
else if (obj->cmdIndex == 0) else if (obj->cmdIndex == 0)
Utils::Box(BOX_ANY, _vm._textParser[kTBNeed]); Utils::Box(BOX_ANY, "%s", _vm._textParser[kTBNeed]);
else else
return false; return false;
} else // It was not a generic cmd } else // It was not a generic cmd
@ -656,21 +656,21 @@ bool Parser::isObjectVerb(object_t *obj, char *line, char *comment) {
reqs = _vm._arrayReqs[cmnd->reqIndex]; // ptr to list of required objects reqs = _vm._arrayReqs[cmnd->reqIndex]; // ptr to list of required objects
for (i = 0; reqs[i]; i++) // for each obj for (i = 0; reqs[i]; i++) // for each obj
if (!isCarrying(reqs[i])) { if (!isCarrying(reqs[i])) {
Utils::Box(BOX_ANY, _vm._textData[cmnd->textDataNoCarryIndex]); Utils::Box(BOX_ANY, "%s", _vm._textData[cmnd->textDataNoCarryIndex]);
return true; return true;
} }
} }
// Required objects are present, now check state is correct // Required objects are present, now check state is correct
if ((obj->state != cmnd->reqState) && (cmnd->reqState != DONT_CARE)) { if ((obj->state != cmnd->reqState) && (cmnd->reqState != DONT_CARE)) {
Utils::Box(BOX_ANY, _vm._textData[cmnd->textDataWrongIndex]); Utils::Box(BOX_ANY, "%s", _vm._textData[cmnd->textDataWrongIndex]);
return true; return true;
} }
// Everything checked. Change the state and carry out any actions // Everything checked. Change the state and carry out any actions
if (cmnd->reqState != DONT_CARE) // Don't change new state if required state didn't care if (cmnd->reqState != DONT_CARE) // Don't change new state if required state didn't care
obj->state = cmnd->newState; obj->state = cmnd->newState;
Utils::Box(BOX_ANY, _vm._textData[cmnd->textDataDoneIndex]); Utils::Box(BOX_ANY, "%s", _vm._textData[cmnd->textDataDoneIndex]);
_vm.scheduler().insertActionList(cmnd->actIndex); _vm.scheduler().insertActionList(cmnd->actIndex);
// See if any additional generic actions // See if any additional generic actions
@ -714,8 +714,7 @@ void Parser::showDosInventory() {
strcat(buffer, "\n"); strcat(buffer, "\n");
strcat(buffer, _vm._textParser[kTBOutro]); strcat(buffer, _vm._textParser[kTBOutro]);
Utils::Box(BOX_ANY, buffer); Utils::Box(BOX_ANY, "%s", buffer);
} }
} // End of namespace Hugo
} // end of namespace Hugo

View file

@ -81,5 +81,6 @@ private:
void takeObject(object_t *obj); void takeObject(object_t *obj);
}; };
} // end of namespace Hugo } // End of namespace Hugo
#endif //HUGO_PARSER_H #endif //HUGO_PARSER_H

View file

@ -469,4 +469,4 @@ bool Route::startRoute(go_t go_for, int16 id, int16 cx, int16 cy) {
return foundFl; return foundFl;
} }
} // end of namespace Hugo } // End of namespace Hugo

View file

@ -80,5 +80,6 @@ private:
Point *newNode(); Point *newNode();
}; };
} // end of namespace Hugo } // End of namespace Hugo
#endif //HUGO_ROUTE_H #endif //HUGO_ROUTE_H

View file

@ -76,7 +76,7 @@ event_t *Scheduler::getQueue() {
event_t *resEvent; event_t *resEvent;
if (!_freeEvent) // Error: no more events available if (!_freeEvent) // Error: no more events available
Utils::Error(EVNT_ERR, "getQueue"); Utils::Error(EVNT_ERR, "%s", "getQueue");
resEvent = _freeEvent; resEvent = _freeEvent;
_freeEvent = _freeEvent->nextEvent; _freeEvent = _freeEvent->nextEvent;
resEvent->nextEvent = 0; resEvent->nextEvent = 0;
@ -216,7 +216,7 @@ event_t *Scheduler::doAction(event_t *curEvent) {
break; break;
case PROMPT: // act3: Prompt user for key phrase case PROMPT: // act3: Prompt user for key phrase
// TODO : Add specific code for Hugo 1 DOS, which is handled differently, // TODO : Add specific code for Hugo 1 DOS, which is handled differently,
response = Utils::Box(BOX_PROMPT, _vm.file().fetchString(action->a3.promptIndex)); response = Utils::Box(BOX_PROMPT, "%s", _vm.file().fetchString(action->a3.promptIndex));
warning("STUB: doAction(act3), expecting answer %s", response); warning("STUB: doAction(act3), expecting answer %s", response);
@ -273,7 +273,7 @@ event_t *Scheduler::doAction(event_t *curEvent) {
insertActionList(action->a11.actFailIndex); insertActionList(action->a11.actFailIndex);
break; break;
case TEXT: // act12: Text box (CF WARN) case TEXT: // act12: Text box (CF WARN)
Utils::Box(BOX_ANY, _vm.file().fetchString(action->a12.stringIndex)); // Fetch string from file Utils::Box(BOX_ANY, "%s", _vm.file().fetchString(action->a12.stringIndex)); // Fetch string from file
break; break;
case SWAP_IMAGES: // act13: Swap 2 object images case SWAP_IMAGES: // act13: Swap 2 object images
swapImages(action->a13.obj1, action->a13.obj2); swapImages(action->a13.obj1, action->a13.obj2);
@ -427,7 +427,7 @@ event_t *Scheduler::doAction(event_t *curEvent) {
_vm.endGame(); _vm.endGame();
break; break;
case WARN: // act40: Text box (CF TEXT) case WARN: // act40: Text box (CF TEXT)
Utils::Box(BOX_OK, _vm.file().fetchString(action->a40.stringIndex)); Utils::Box(BOX_OK, "%s", _vm.file().fetchString(action->a40.stringIndex));
break; break;
case COND_BONUS: // act41: Perform action if got bonus case COND_BONUS: // act41: Perform action if got bonus
if (_vm._points[action->a41.BonusIndex].scoredFl) if (_vm._points[action->a41.BonusIndex].scoredFl)
@ -436,11 +436,11 @@ event_t *Scheduler::doAction(event_t *curEvent) {
insertActionList(action->a41.actFailIndex); insertActionList(action->a41.actFailIndex);
break; break;
case TEXT_TAKE: // act42: Text box with "take" message case TEXT_TAKE: // act42: Text box with "take" message
Utils::Box(BOX_ANY, TAKE_TEXT, _vm._arrayNouns[_vm._objects[action->a42.objNumb].nounIndex][TAKE_NAME]); Utils::Box(BOX_ANY, "%s", TAKE_TEXT, _vm._arrayNouns[_vm._objects[action->a42.objNumb].nounIndex][TAKE_NAME]);
break; break;
case YESNO: // act43: Prompt user for Yes or No case YESNO: // act43: Prompt user for Yes or No
warning("doAction(act43) - Yes/No Box"); warning("doAction(act43) - Yes/No Box");
if (Utils::Box(BOX_YESNO, _vm.file().fetchString(action->a43.promptIndex)) != NULL) if (Utils::Box(BOX_YESNO, "%s", _vm.file().fetchString(action->a43.promptIndex)) != NULL)
insertActionList(action->a43.actYesIndex); insertActionList(action->a43.actYesIndex);
else else
insertActionList(action->a43.actNoIndex); insertActionList(action->a43.actNoIndex);
@ -479,7 +479,7 @@ event_t *Scheduler::doAction(event_t *curEvent) {
warning("STUB: doAction(act49)"); warning("STUB: doAction(act49)");
break; break;
default: default:
Utils::Error(EVNT_ERR, "doAction"); Utils::Error(EVNT_ERR, "%s", "doAction");
break; break;
} }
@ -537,7 +537,7 @@ void Scheduler::newScreen(int screenIndex) {
char line[32]; char line[32];
if (!_vm.file().fileExists(strcat(strncat(strcpy(line, _vm._picDir), _vm._screenNames[screenIndex], NAME_LEN), BKGEXT)) && if (!_vm.file().fileExists(strcat(strncat(strcpy(line, _vm._picDir), _vm._screenNames[screenIndex], NAME_LEN), BKGEXT)) &&
!_vm.file().fileExists(strcat(strcpy(line, _vm._screenNames[screenIndex]), ".ART"))) { !_vm.file().fileExists(strcat(strcpy(line, _vm._screenNames[screenIndex]), ".ART"))) {
Utils::Box(BOX_ANY, _vm._textSchedule[kSsNoBackground]); Utils::Box(BOX_ANY, "%s", _vm._textSchedule[kSsNoBackground]);
return; return;
} }
} }
@ -675,4 +675,4 @@ void Scheduler::swapImages(int objNumb1, int objNumb2) {
_vm._objects[objNumb1].y += _vm._objects[objNumb2].currImagePtr->y2 - _vm._objects[objNumb1].currImagePtr->y2; _vm._objects[objNumb1].y += _vm._objects[objNumb2].currImagePtr->y2 - _vm._objects[objNumb1].currImagePtr->y2;
} }
} // end of namespace Hugo } // End of namespace Hugo

View file

@ -81,5 +81,6 @@ private:
event_t *doAction(event_t *curEvent); event_t *doAction(event_t *curEvent);
}; };
} // end of namespace Hugo } // End of namespace Hugo
#endif //HUGO_SCHEDULE_H #endif //HUGO_SCHEDULE_H

View file

@ -328,4 +328,4 @@ void SoundHandler::initSound() {
_midiPlayer->open(); _midiPlayer->open();
} }
} // end of namespace Hugo } // End of namespace Hugo

View file

@ -60,5 +60,6 @@ private:
void playMIDI(sound_pt seq_p, uint16 size); void playMIDI(sound_pt seq_p, uint16 size);
}; };
} // end of namespace Hugo } // End of namespace Hugo
#endif //HUGO_SOUND_H #endif //HUGO_SOUND_H

View file

@ -182,4 +182,4 @@ void Utils::gameOverMsg(void) {
warning("STUB: Gameover_msg(): %s", HugoEngine::get()._textUtil[kGameOver]); warning("STUB: Gameover_msg(): %s", HugoEngine::get()._textUtil[kGameOver]);
} }
} // end of namespace Hugo } // End of namespace Hugo

View file

@ -53,11 +53,11 @@ int firstBit(byte data);
int lastBit(byte data); int lastBit(byte data);
void reverseByte(byte *data); void reverseByte(byte *data);
void Warn(bool technote, const char *format, ...) GCC_PRINTF(2, 3); void Warn(bool technote, const char *format, ...) GCC_PRINTF(2, 3);
void Error(int code, const char *format, ...); // FIXME GCC_PRINTF(2, 3); void Error(int code, const char *format, ...) GCC_PRINTF(2, 3);
void gameOverMsg(); void gameOverMsg();
// void Debug_out(char *format, ...) GCC_PRINTF(1, 2); char *Box(box_t, const char *, ...) GCC_PRINTF(2, 3);
char *Box(box_t, const char *, ...); // FIXME GCC_PRINTF(2, 3);
} }
} // Namespace Hugo } // End of namespace Hugo
#endif #endif