From 6dcf737c171bf956dab4c5df1723dc8ff0ed4e68 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 26 Apr 2019 21:49:27 +0200 Subject: [PATCH] Clean up CheckStoreBtn --- Source/stores.cpp | 85 +++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 51 deletions(-) diff --git a/Source/stores.cpp b/Source/stores.cpp index aaf735171..40a1d5af1 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -3039,75 +3039,58 @@ void STextEnter() void CheckStoreBtn() { - BOOLEAN v0; // sf - //unsigned char v1; // of - int v2; // eax - int *v3; // ecx + int y; if (qtextflag) { qtextflag = FALSE; if (leveltype == DTYPE_TOWN) sfx_stop(); } else if (stextsel != -1 && MouseY >= 32 && MouseY <= 320) { - if (stextsize) { - //v1 = __OFSUB__(MouseX, 24); - v0 = MouseX - 24 < 0; + if (!stextsize) { + if (MouseX < 344 || MouseX > 616) + return; } else { - //v1 = __OFSUB__(MouseX, 344); - v0 = MouseX - 344 < 0; - } - if (!v0 && MouseX <= 616) { //if (!(v0 ^ v1) && MouseX <= 616) { - v2 = (MouseY - 32) / 12; - if (stextscrl && MouseX > 600) { - if (v2 == 4) { - if (stextscrlubtn <= 0) { - STextUp(); - stextscrlubtn = 10; - return; - } + if (MouseX < 3 || MouseX > 616) + return; + } + y = (MouseY - 32) / 12; + if (stextscrl && MouseX > 600) { + if (y == 4) { + if (stextscrlubtn <= 0) { + STextUp(); + stextscrlubtn = 10; + } else { --stextscrlubtn; } - if (v2 == 20) { - if (stextscrldbtn > 0) { - --stextscrldbtn; - } else { - STextDown(); - stextscrldbtn = 10; - } - } - } else if (v2 >= 5) { - if (v2 >= 23) - v2 = 22; - if (stextscrl) { - if (v2 < 21) { - v3 = &stext[v2]._ssel; - if (!*v3) { - if (stext[v2 - 2]._ssel) { - v2 -= 2; - } else if (*(v3 - 39)) { - --v2; - } - } - } + } + if (y == 20) { + if (stextscrldbtn <= 0) { + STextDown(); + stextscrldbtn = 10; + } else { + --stextscrldbtn; } - if (stext[v2]._ssel || stextscrl && v2 == 22) { - stextsel = v2; - STextEnter(); + } + } else if (y >= 5) { + if (y >= 23) + y = 22; + if (stextscrl && y < 21 && !stext[y]._ssel) { + if (stext[y - 2]._ssel) { + y -= 2; + } else if (stext[y - 1]._ssel) { + --y; } } + if (stext[y]._ssel || stextscrl && y == 22) { + stextsel = y; + STextEnter(); + } } } } -// 646D00: using guessed type char qtextflag; -// 6A09E0: using guessed type char stextsize; -// 6A8A28: using guessed type int stextsel; -// 6A8A2C: using guessed type char stextscrldbtn; -// 6AA704: using guessed type char stextscrlubtn; void ReleaseStoreBtn() { stextscrlubtn = -1; stextscrldbtn = -1; } -// 6A8A2C: using guessed type char stextscrldbtn; -// 6AA704: using guessed type char stextscrlubtn;