diff options
author | Filippos Karapetis | 2015-07-17 10:45:26 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2015-12-15 00:05:02 +0100 |
commit | 9a12f6be3fc48f4fa4cc3dc45fce7a0b406bff9b (patch) | |
tree | a2966e661956940f882fb8b6a4c77e27b1826cdf | |
parent | e031359d9933cc9c7ce88e1b99876b4ec257437d (diff) | |
download | scummvm-rg350-9a12f6be3fc48f4fa4cc3dc45fce7a0b406bff9b.tar.gz scummvm-rg350-9a12f6be3fc48f4fa4cc3dc45fce7a0b406bff9b.tar.bz2 scummvm-rg350-9a12f6be3fc48f4fa4cc3dc45fce7a0b406bff9b.zip |
LAB: Simplify translateFileName()
-rw-r--r-- | engines/lab/intro.cpp | 2 | ||||
-rw-r--r-- | engines/lab/machine.cpp | 85 | ||||
-rw-r--r-- | engines/lab/special.cpp | 2 |
3 files changed, 24 insertions, 65 deletions
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp index c14546e4df..1f05afe231 100644 --- a/engines/lab/intro.cpp +++ b/engines/lab/intro.cpp @@ -364,7 +364,7 @@ void introSequence() { blackAllScreen(); g_music->fillUpMusic(true); - getFont("P:Map.font", msgfont); + getFont("P:Map.fon", msgfont); nopalchange = true; NReadPict("Intro.1", true); diff --git a/engines/lab/machine.cpp b/engines/lab/machine.cpp index 3806b5f6e1..61375d6867 100644 --- a/engines/lab/machine.cpp +++ b/engines/lab/machine.cpp @@ -28,6 +28,8 @@ * */ +#include "common/str.h" + #include "lab/stddefines.h" namespace Lab { @@ -45,9 +47,6 @@ uint16 scaleX(uint16 x) { return (uint16)((x * 8) / 9); } - - - /*****************************************************************************/ /* Scales the y co-ordinates to that of the new display. In the room parser */ /* file, co-ordinates are set up on a 368x336 display. */ @@ -59,9 +58,6 @@ uint16 scaleY(uint16 y) { return ((y * 10) / 24); } - - - /*****************************************************************************/ /* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords. */ /*****************************************************************************/ @@ -120,9 +116,6 @@ uint16 SVGACord(uint16 cord) { return 0; } - - - /*****************************************************************************/ /* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords. */ /*****************************************************************************/ @@ -133,9 +126,6 @@ uint16 VGAUnScaleX(uint16 x) { return x; } - - - /*****************************************************************************/ /* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords. */ /*****************************************************************************/ @@ -146,29 +136,6 @@ uint16 VGAUnScaleY(uint16 y) { return y; } - -/*****************************************************************************/ -/* Checks to see if all the characters in the second string are at the start */ -/* of the first. */ -/*****************************************************************************/ -static bool strstart(const char **Source, const char *Start) { - uint16 len1, len2, counter; - - len1 = strlen(*Source); - len2 = strlen(Start); - - if (len1 < len2) - return false; - - for (counter = 0; counter < len2; counter++) - if ((*Source)[counter] != Start[counter]) - return false; - - (*Source) += len2; - return true; -} - - static char NewFileName[255]; /*****************************************************************************/ @@ -180,40 +147,32 @@ static char NewFileName[255]; /* attention to one file at a time, it would be fine to have one variable */ /* not on the stack which is used to store the new filename. */ /*****************************************************************************/ -static void mystrupr(char *s) { - char c; - - while ((c = *s) != 0) - *s++ = toupper(c); -} - char *translateFileName(const char *filename) { - char tempfilename[255]; - char *dot; - - strcpy(tempfilename, filename); - mystrupr(tempfilename); - - *NewFileName = 0; - filename = tempfilename; + Common::String fileNameStr = filename; + fileNameStr.toUppercase(); + Common::String fileNameStrFinal; - if (strstart(&filename, "P:")) { + if (fileNameStr.hasPrefix("P:")) { if (IsHiRes) - strcat(NewFileName, "GAME/SPICT/"); + fileNameStrFinal = "GAME/SPICT/"; else - strcat(NewFileName, "GAME/PICT/"); - } else if (strstart(&filename, "LAB:")) - strcat(NewFileName, "GAME/"); - else if (strstart(&filename, "MUSIC:")) - strcat(NewFileName, "GAME/MUSIC/"); - - strcat(NewFileName, filename); + fileNameStrFinal = "GAME/PICT/"; + } else if (fileNameStr.hasPrefix("LAB:")) + fileNameStrFinal = "GAME/"; + else if (fileNameStr.hasPrefix("MUSIC:")) + fileNameStrFinal = "GAME/MUSIC/"; + + if (fileNameStr.contains(':')) { + while (fileNameStr[0] != ':') { + fileNameStr.deleteChar(0); + } + + fileNameStr.deleteChar(0); + } - dot = strrchr(NewFileName, '.'); + fileNameStrFinal += fileNameStr; - if (dot != NewFileName && dot != NULL && dot[4] != '/') { // Linux may start with '.' - dot[4] = 0; // Back to the days of 8.3, even if your OS was never DOSish!! - } + strcpy(NewFileName, fileNameStrFinal.c_str()); return NewFileName; } diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 74625a63f4..603dfbe348 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -1193,7 +1193,7 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, BigMsgFont = &bmfont; - if (!getFont("P:Map.font", BigMsgFont)) { + if (!getFont("P:Map.fon", BigMsgFont)) { freeAllStolenMem(); BigMsgFont = NULL; return; |