[Scummvm-git-logs] scummvm master -> 7204eaaf34d02285601712dbaf18df24d9997a44
athrxx
noreply at scummvm.org
Sat Sep 24 13:44:29 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
7204eaaf34 KYRA: more code style cleanup
Commit: 7204eaaf34d02285601712dbaf18df24d9997a44
https://github.com/scummvm/scummvm/commit/7204eaaf34d02285601712dbaf18df24d9997a44
Author: athrxx (athrxx at scummvm.org)
Date: 2022-09-24T15:44:14+02:00
Commit Message:
KYRA: more code style cleanup
Changed paths:
engines/kyra/engine/lol.cpp
engines/kyra/graphics/screen_mr.cpp
engines/kyra/graphics/screen_v2.cpp
engines/kyra/gui/gui_v1.cpp
engines/kyra/script/script_hof.cpp
engines/kyra/text/text_lol.cpp
diff --git a/engines/kyra/engine/lol.cpp b/engines/kyra/engine/lol.cpp
index 03314335e61..2d8c97fe330 100644
--- a/engines/kyra/engine/lol.cpp
+++ b/engines/kyra/engine/lol.cpp
@@ -494,7 +494,7 @@ void LoLEngine::pauseEngineIntern(bool pause) {
Common::Error LoLEngine::go() {
int action = -1;
-
+
if (_gameToLoad == -1) {
action = processPrologue();
if (action == -1)
diff --git a/engines/kyra/graphics/screen_mr.cpp b/engines/kyra/graphics/screen_mr.cpp
index 9426a3619ae..2e686faf0c5 100644
--- a/engines/kyra/graphics/screen_mr.cpp
+++ b/engines/kyra/graphics/screen_mr.cpp
@@ -52,11 +52,7 @@ int Screen_MR::getLayer(int x, int y) {
pixel &= 0x7F;
pixel >>= 3;
- if (pixel < 1)
- pixel = 1;
- else if (pixel > 15)
- pixel = 15;
- return pixel;
+ return CLIP<uint8>(pixel, 1, 15);
}
byte Screen_MR::getShapeFlag1(int x, int y) {
diff --git a/engines/kyra/graphics/screen_v2.cpp b/engines/kyra/graphics/screen_v2.cpp
index ee524846712..27fc8542d1a 100644
--- a/engines/kyra/graphics/screen_v2.cpp
+++ b/engines/kyra/graphics/screen_v2.cpp
@@ -259,11 +259,7 @@ int Screen_v2::getLayer(int x, int y) {
pixel &= 0x7F;
pixel >>= 3;
- if (pixel < 1)
- pixel = 1;
- else if (pixel > 15)
- pixel = 15;
- return pixel;
+ return CLIP<uint8>(pixel, 1, 15);
}
int Screen_v2::getRectSize(int w, int h) {
diff --git a/engines/kyra/gui/gui_v1.cpp b/engines/kyra/gui/gui_v1.cpp
index ddec7e36359..982238bcc98 100644
--- a/engines/kyra/gui/gui_v1.cpp
+++ b/engines/kyra/gui/gui_v1.cpp
@@ -97,6 +97,8 @@ void GUI_v1::initMenu(Menu &menu) {
printMenuText(getMenuTitle(menu), textX, textY, menu.textColor, 0, 0);
}
+ assert (menu.numberOfItems < ARRAYSIZE(menu.item));
+
int x1, y1, x2, y2;
for (int i = 0; i < menu.numberOfItems; ++i) {
if (!menu.item[i].enabled)
@@ -108,20 +110,18 @@ void GUI_v1::initMenu(Menu &menu) {
x2 = x1 + menu.item[i].width - 1;
y2 = y1 + menu.item[i].height - 1;
- if (i < 7) {
- Button *menuButtonData = getButtonListData() + i;
- menuButtonData->nextButton = nullptr;
- menuButtonData->x = x1;
- menuButtonData->y = y1;
- menuButtonData->width = menu.item[i].width - 1;
- menuButtonData->height = menu.item[i].height - 1;
- menuButtonData->buttonCallback = menu.item[i].callback;
- menuButtonData->keyCode = menu.item[i].keyCode;
- menuButtonData->keyCode2 = 0;
- menuButtonData->arg = menu.item[i].itemId;
-
- _menuButtonList = addButtonToList(_menuButtonList, menuButtonData);
- }
+ Button *menuButtonData = getButtonListData() + i;
+ menuButtonData->nextButton = nullptr;
+ menuButtonData->x = x1;
+ menuButtonData->y = y1;
+ menuButtonData->width = menu.item[i].width - 1;
+ menuButtonData->height = menu.item[i].height - 1;
+ menuButtonData->buttonCallback = menu.item[i].callback;
+ menuButtonData->keyCode = menu.item[i].keyCode;
+ menuButtonData->keyCode2 = 0;
+ menuButtonData->arg = menu.item[i].itemId;
+
+ _menuButtonList = addButtonToList(_menuButtonList, menuButtonData);
_screen->fillRect(x1, y1, x2, y2, menu.item[i].bkgdColor);
_screen->drawShadedBox(x1, y1, x2, y2, menu.item[i].color1, menu.item[i].color2);
diff --git a/engines/kyra/script/script_hof.cpp b/engines/kyra/script/script_hof.cpp
index 023a8e8de60..2140fc823a0 100644
--- a/engines/kyra/script/script_hof.cpp
+++ b/engines/kyra/script/script_hof.cpp
@@ -672,7 +672,7 @@ int KyraEngine_HoF::o2_getSceneExitToFacing(EMCState *script) {
int KyraEngine_HoF::o2_setLayerFlag(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_HoF::o2_setLayerFlag(%p) (%d)", (const void *)script, stackPos(0));
int layer = stackPos(0);
- if (layer >= 1 && layer <= 16)
+ if (layer >= 1 && layer <= 15)
_layerFlagTable[layer] = 1;
return 0;
}
diff --git a/engines/kyra/text/text_lol.cpp b/engines/kyra/text/text_lol.cpp
index 3aebaa23a20..54e760b024e 100644
--- a/engines/kyra/text/text_lol.cpp
+++ b/engines/kyra/text/text_lol.cpp
@@ -305,21 +305,33 @@ void TextDisplayer_LoL::preprocessString(const char *str, EMCState *script, cons
break;
case 'n':
- Common::strlcpy(dst, _vm->_characters[script ? script->stack[script->sp + paramIndex] : paramList[paramIndex]].name, 2560 - (dst - _dialogueBuffer));
- dst += Common::strnlen(dst, 2559 - (dst - _dialogueBuffer));
+ if (script || paramList) {
+ Common::strlcpy(dst, _vm->_characters[script ? script->stack[script->sp + paramIndex] : paramList[paramIndex]].name, 2560 - (dst - _dialogueBuffer));
+ dst += Common::strnlen(dst, 2559 - (dst - _dialogueBuffer));
+ } else {
+ warning("TextDisplayer_LoL::preprocessString(): Missing replacement data for placeholder '%%%c'", para);
+ }
break;
case 's':
- Common::strlcpy(dst, _vm->getLangString(script ? script->stack[script->sp + paramIndex] : paramList[paramIndex]), 2560 - (dst - _dialogueBuffer));
- dst += Common::strnlen(dst, 2559 - (dst - _dialogueBuffer));
+ if (script || paramList) {
+ Common::strlcpy(dst, _vm->getLangString(script ? script->stack[script->sp + paramIndex] : paramList[paramIndex]), 2560 - (dst - _dialogueBuffer));
+ dst += Common::strnlen(dst, 2559 - (dst - _dialogueBuffer));
+ } else {
+ warning("TextDisplayer_LoL::preprocessString(): Missing replacement data for placeholder '%%%c'", para);
+ }
break;
case 'X':
case 'd':
case 'u':
case 'x':
- Common::strlcpy(dst, Common::String::format("%d", script ? script->stack[script->sp + paramIndex] : paramList[paramIndex]).c_str(), 2560 - (dst - _dialogueBuffer));
- dst += Common::strnlen(dst, 2559 - (dst - _dialogueBuffer));
+ if (script || paramList) {
+ Common::strlcpy(dst, Common::String::format("%d", script ? script->stack[script->sp + paramIndex] : paramList[paramIndex]).c_str(), 2560 - (dst - _dialogueBuffer));
+ dst += Common::strnlen(dst, 2559 - (dst - _dialogueBuffer));
+ } else {
+ warning("TextDisplayer_LoL::preprocessString(): Missing replacement data for placeholder '%%%c'", para);
+ }
break;
case '\0':
More information about the Scummvm-git-logs
mailing list