KYRA: more code style cleanup

This commit is contained in:
athrxx
2022-09-24 15:44:14 +02:00
parent 49b609c237
commit 7204eaaf34
6 changed files with 35 additions and 31 deletions
+1 -1
View File
@@ -494,7 +494,7 @@ void LoLEngine::pauseEngineIntern(bool pause) {
Common::Error LoLEngine::go() {
int action = -1;
if (_gameToLoad == -1) {
action = processPrologue();
if (action == -1)
+1 -5
View File
@@ -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) {
+1 -5
View File
@@ -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) {
+13 -13
View File
@@ -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;
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);
}
_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);
+1 -1
View File
@@ -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;
}
+18 -6
View File
@@ -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':