diff options
-rw-r--r-- | engines/cruise/font.cpp | 8 | ||||
-rw-r--r-- | engines/cruise/script.cpp | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/engines/cruise/font.cpp b/engines/cruise/font.cpp index 5c04154b01..2ef43c952a 100644 --- a/engines/cruise/font.cpp +++ b/engines/cruise/font.cpp @@ -50,7 +50,7 @@ int32 getLineHeight(int16 charCount, const FontEntry *fontPtr) { } /** - * This function determins how many lines the text will have + * This function determines how many lines the text will have */ int32 getTextLineCount(int32 rightBorder_X, int16 wordSpacingWidth, const FontEntry *fontData, const char *textString) { @@ -59,6 +59,9 @@ int32 getTextLineCount(int32 rightBorder_X, int16 wordSpacingWidth, uint8 ch; int32 total = 0, lineLength = 0; + if (rightBorder_X == 0) + error("getTextLineCount() - invalid parameter"); + if (!*textString) return (0); @@ -89,7 +92,8 @@ int32 getTextLineCount(int32 rightBorder_X, int16 wordSpacingWidth, if (lineLength > 0) total += rightBorder_X; - return (total / (rightBorder_X == 0 ? 1 : rightBorder_X)); + + return (total / rightBorder_X); } void loadFNT(const char *fileName) { diff --git a/engines/cruise/script.cpp b/engines/cruise/script.cpp index 75cf428787..764a458b8f 100644 --- a/engines/cruise/script.cpp +++ b/engines/cruise/script.cpp @@ -415,7 +415,9 @@ int32 opcodeType3() { // math return (0); } case 1: { - pushVar(pop1 / (pop2 == 0 ? 1 : pop2)); + if (pop2 == 0) + error("opcodeType3 - Invalid value for pop2"); + pushVar(pop1 / pop2); return (0); } case 2: { @@ -427,7 +429,9 @@ int32 opcodeType3() { // math return (0); } case 4: { - pushVar(pop1 % (pop2 == 0 ? 1 : pop2)); + if (pop2 == 0) + error("opcodeType3 - Invalid value for pop2"); + pushVar(pop1 % pop2); return (0); } case 7: |