From a3390819d16a6911495772b1b2758ed4571f39ef Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sun, 5 Jun 2022 01:01:49 +0300 Subject: [PATCH] Reconcile with reference edition --- src/actions.cc | 4 ++-- src/animation.cc | 9 +++++---- src/cache.cc | 2 +- src/endgame.cc | 7 ++++++- src/game_dialog.cc | 46 ++++++++++++++++++++++++++++++++++++++-------- src/inventory.cc | 27 ++++++++++++++++++--------- src/stat.cc | 1 + 7 files changed, 71 insertions(+), 25 deletions(-) diff --git a/src/actions.cc b/src/actions.cc index e5c4d91..f33793a 100644 --- a/src/actions.cc +++ b/src/actions.cc @@ -40,8 +40,8 @@ int _action_in_explode = 0; const int gNormalDeathAnimations[DAMAGE_TYPE_COUNT] = { ANIM_DANCING_AUTOFIRE, ANIM_SLICED_IN_HALF, - ANIM_CHUNKS_OF_FLESH, - ANIM_CHUNKS_OF_FLESH, + ANIM_CHARRED_BODY, + ANIM_CHARRED_BODY, ANIM_ELECTRIFY, ANIM_FALL_BACK, ANIM_BIG_HOLE, diff --git a/src/animation.cc b/src/animation.cc index dbd6e5a..29bbbb1 100644 --- a/src/animation.cc +++ b/src/animation.cc @@ -1726,7 +1726,7 @@ int _make_straight_path_func(Object* a1, int from, int to, STRUCT_530014_28* a4, int tileY = fromY; int pathNodeIndex = 0; - int v50 = from; + int prevTile = from; int v22 = 0; int tile; @@ -1770,7 +1770,7 @@ int _make_straight_path_func(Object* a1, int from, int to, STRUCT_530014_28* a4, tileY += stepY; middle += v48; - if (tile != v50) { + if (tile != prevTile) { if (a5 != NULL) { Object* obj = a7(a1, tile, a1->elevation); if (obj != NULL) { @@ -1780,7 +1780,7 @@ int _make_straight_path_func(Object* a1, int from, int to, STRUCT_530014_28* a4, } } } - v50 = tile; + prevTile = tile; } } } else { @@ -1823,7 +1823,7 @@ int _make_straight_path_func(Object* a1, int from, int to, STRUCT_530014_28* a4, tileX += stepX; middle += v47; - if (tile != v50) { + if (tile != prevTile) { if (a5 != NULL) { Object* obj = a7(a1, tile, a1->elevation); if (obj != NULL) { @@ -1833,6 +1833,7 @@ int _make_straight_path_func(Object* a1, int from, int to, STRUCT_530014_28* a4, } } } + prevTile = tile; } } } diff --git a/src/cache.cc b/src/cache.cc index e2c77f3..6f2d346 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -5,7 +5,7 @@ #include "sound.h" #include -#include // qsort +#include #include #include diff --git a/src/endgame.cc b/src/endgame.cc index 92dac41..7dd1d61 100644 --- a/src/endgame.cc +++ b/src/endgame.cc @@ -493,7 +493,12 @@ int endgameEndingSlideshowWindowInit() int windowEndgameEndingX = (screenGetWidth() - ENDGAME_ENDING_WINDOW_WIDTH) / 2; int windowEndgameEndingY = (screenGetHeight() - ENDGAME_ENDING_WINDOW_HEIGHT) / 2; - gEndgameEndingSlideshowWindow = windowCreate(windowEndgameEndingX, windowEndgameEndingY, ENDGAME_ENDING_WINDOW_WIDTH, ENDGAME_ENDING_WINDOW_HEIGHT, _colorTable[0], 4); + gEndgameEndingSlideshowWindow = windowCreate(windowEndgameEndingX, + windowEndgameEndingY, + ENDGAME_ENDING_WINDOW_WIDTH, + ENDGAME_ENDING_WINDOW_HEIGHT, + _colorTable[0], + WINDOW_FLAG_0x04); if (gEndgameEndingSlideshowWindow == -1) { return -1; } diff --git a/src/game_dialog.cc b/src/game_dialog.cc index 95d1f7a..476b6a2 100644 --- a/src/game_dialog.cc +++ b/src/game_dialog.cc @@ -571,7 +571,7 @@ void gameDialogEnter(Object* a1, int a2) return; } - if ((a1->pid >> 24) != OBJ_TYPE_ITEM && (a1->pid >> 24) != OBJ_TYPE_CRITTER) { + if ((a1->pid >> 24) != OBJ_TYPE_ITEM && (a1->sid >> 24) != SCRIPT_TYPE_SPATIAL) { MessageListItem messageListItem; int rc = _action_can_talk_to(gDude, a1); @@ -1142,7 +1142,12 @@ int gameDialogReviewWindowInit(int* win) int reviewWindowX = (screenGetWidth() - GAME_DIALOG_REVIEW_WINDOW_WIDTH) / 2; int reviewWindowY = (screenGetHeight() - GAME_DIALOG_REVIEW_WINDOW_HEIGHT) / 2; - *win = windowCreate(reviewWindowX, reviewWindowY, GAME_DIALOG_REVIEW_WINDOW_WIDTH, GAME_DIALOG_REVIEW_WINDOW_HEIGHT, 256, WINDOW_FLAG_0x10 | WINDOW_FLAG_0x04); + *win = windowCreate(reviewWindowX, + reviewWindowY, + GAME_DIALOG_REVIEW_WINDOW_WIDTH, + GAME_DIALOG_REVIEW_WINDOW_HEIGHT, + 256, + WINDOW_FLAG_0x10 | WINDOW_FLAG_0x04); if (*win == -1) { return -1; } @@ -1548,7 +1553,12 @@ int _gdProcessInit() int replyWindowX = (screenGetWidth() - GAME_DIALOG_WINDOW_WIDTH) / 2 + GAME_DIALOG_REPLY_WINDOW_X; int replyWindowY = (screenGetHeight() - GAME_DIALOG_WINDOW_HEIGHT) / 2 + GAME_DIALOG_REPLY_WINDOW_Y; - gGameDialogReplyWindow = windowCreate(replyWindowX, replyWindowY, GAME_DIALOG_REPLY_WINDOW_WIDTH, GAME_DIALOG_REPLY_WINDOW_HEIGHT, 256, WINDOW_FLAG_0x04); + gGameDialogReplyWindow = windowCreate(replyWindowX, + replyWindowY, + GAME_DIALOG_REPLY_WINDOW_WIDTH, + GAME_DIALOG_REPLY_WINDOW_HEIGHT, + 256, + WINDOW_FLAG_0x04); if (gGameDialogReplyWindow == -1) { goto err; } @@ -2174,7 +2184,12 @@ int _gdCreateHeadWindow() int backgroundWindowX = (screenGetWidth() - GAME_DIALOG_WINDOW_WIDTH) / 2; int backgroundWindowY = (screenGetHeight() - GAME_DIALOG_WINDOW_HEIGHT) / 2; - gGameDialogBackgroundWindow = windowCreate(backgroundWindowX, backgroundWindowY, windowWidth, GAME_DIALOG_WINDOW_HEIGHT, 256, WINDOW_FLAG_0x02); + gGameDialogBackgroundWindow = windowCreate(backgroundWindowX, + backgroundWindowY, + windowWidth, + GAME_DIALOG_WINDOW_HEIGHT, + 256, + WINDOW_FLAG_0x02); gameDialogWindowRenderBackground(); unsigned char* buf = windowGetBuffer(gGameDialogBackgroundWindow); @@ -2983,7 +2998,12 @@ int _gdialog_barter_create_win() int barterWindowX = (screenGetWidth() - GAME_DIALOG_WINDOW_WIDTH) / 2; int barterWindowY = (screenGetHeight() - GAME_DIALOG_WINDOW_HEIGHT) / 2 + GAME_DIALOG_WINDOW_HEIGHT - _dialogue_subwin_len; - gGameDialogWindow = windowCreate(barterWindowX, barterWindowY, GAME_DIALOG_WINDOW_WIDTH, _dialogue_subwin_len, 256, WINDOW_FLAG_0x02); + gGameDialogWindow = windowCreate(barterWindowX, + barterWindowY, + GAME_DIALOG_WINDOW_WIDTH, + _dialogue_subwin_len, + 256, + WINDOW_FLAG_0x02); if (gGameDialogWindow == -1) { artUnlock(backgroundHandle); return -1; @@ -3136,7 +3156,12 @@ int partyMemberControlWindowInit() _dialogue_subwin_len = artGetHeight(backgroundFrm, 0, 0); int controlWindowX = (screenGetWidth() - GAME_DIALOG_WINDOW_WIDTH) / 2; int controlWindowY = (screenGetHeight() - GAME_DIALOG_WINDOW_HEIGHT) / 2 + GAME_DIALOG_WINDOW_HEIGHT - _dialogue_subwin_len; - gGameDialogWindow = windowCreate(controlWindowX, controlWindowY, GAME_DIALOG_WINDOW_WIDTH, _dialogue_subwin_len, 256, WINDOW_FLAG_0x02); + gGameDialogWindow = windowCreate(controlWindowX, + controlWindowY, + GAME_DIALOG_WINDOW_WIDTH, + _dialogue_subwin_len, + 256, + WINDOW_FLAG_0x02); if (gGameDialogWindow == -1) { partyMemberControlWindowFree(); return -1; @@ -3570,7 +3595,12 @@ int partyMemberCustomizationWindowInit() int customizationWindowX = (screenGetWidth() - GAME_DIALOG_WINDOW_WIDTH) / 2; int customizationWindowY = (screenGetHeight() - GAME_DIALOG_WINDOW_HEIGHT) / 2 + GAME_DIALOG_WINDOW_HEIGHT - _dialogue_subwin_len; - gGameDialogWindow = windowCreate(customizationWindowX, customizationWindowY, GAME_DIALOG_WINDOW_WIDTH, _dialogue_subwin_len, 256, WINDOW_FLAG_0x02); + gGameDialogWindow = windowCreate(customizationWindowX, + customizationWindowY, + GAME_DIALOG_WINDOW_WIDTH, + _dialogue_subwin_len, + 256, + WINDOW_FLAG_0x02); if (gGameDialogWindow == -1) { partyMemberCustomizationWindowFree(); return -1; @@ -4105,7 +4135,7 @@ int _gdialog_window_create() int dialogSubwindowX = (screenGetWidth() - GAME_DIALOG_WINDOW_WIDTH) / 2; int dialogSubwindowY = (screenGetHeight() - GAME_DIALOG_WINDOW_HEIGHT) / 2 + GAME_DIALOG_WINDOW_HEIGHT - _dialogue_subwin_len; - gGameDialogWindow = windowCreate(dialogSubwindowX, dialogSubwindowY, screenWidth, _dialogue_subwin_len, 256, 2); + gGameDialogWindow = windowCreate(dialogSubwindowX, dialogSubwindowY, screenWidth, _dialogue_subwin_len, 256, WINDOW_FLAG_0x02); if (gGameDialogWindow != -1) { unsigned char* v10 = windowGetBuffer(gGameDialogWindow); diff --git a/src/inventory.cc b/src/inventory.cc index ed2ef57..cf66c12 100644 --- a/src/inventory.cc +++ b/src/inventory.cc @@ -41,6 +41,14 @@ #include +#define INVENTORY_WINDOW_X 80 +#define INVENTORY_WINDOW_Y 0 + +#define INVENTORY_TRADE_WINDOW_X 80 +#define INVENTORY_TRADE_WINDOW_Y 290 +#define INVENTORY_TRADE_WINDOW_WIDTH 480 +#define INVENTORY_TRADE_WINDOW_HEIGHT 180 + #define INVENTORY_LARGE_SLOT_WIDTH 90 #define INVENTORY_LARGE_SLOT_HEIGHT 61 @@ -550,10 +558,10 @@ bool _setup_inventory(int inventoryWindowType) // Maintain original position in original resolution, otherwise center it. int inventoryWindowX = screenGetWidth() != 640 ? (screenGetWidth() - windowDescription->width) / 2 - : 80; + : INVENTORY_WINDOW_X; int inventoryWindowY = screenGetHeight() != 480 ? (screenGetHeight() - windowDescription->height) / 2 - : 0; + : INVENTORY_WINDOW_Y; gInventoryWindow = windowCreate(inventoryWindowX, inventoryWindowY, windowDescription->width, @@ -582,15 +590,15 @@ bool _setup_inventory(int inventoryWindowType) gInventorySlotsCount = 3; // Trade inventory window is a part of game dialog, which is 640x480. - int tradeWindowX = (screenGetWidth() - 640) / 2 + 80; - int tradeWindowY = (screenGetHeight() - 480) / 2 + 290; - gInventoryWindow = windowCreate(tradeWindowX, tradeWindowY, 480, 180, 257, 0); - gInventoryWindowMaxX = tradeWindowX + 480; - gInventoryWindowMaxY = tradeWindowY + 180; + int tradeWindowX = (screenGetWidth() - 640) / 2 + INVENTORY_TRADE_WINDOW_X; + int tradeWindowY = (screenGetHeight() - 480) / 2 + INVENTORY_TRADE_WINDOW_Y; + gInventoryWindow = windowCreate(tradeWindowX, tradeWindowY, INVENTORY_TRADE_WINDOW_WIDTH, INVENTORY_TRADE_WINDOW_HEIGHT, 257, 0); + gInventoryWindowMaxX = tradeWindowX + INVENTORY_TRADE_WINDOW_WIDTH; + gInventoryWindowMaxY = tradeWindowY + INVENTORY_TRADE_WINDOW_HEIGHT; unsigned char* dest = windowGetBuffer(gInventoryWindow); unsigned char* src = windowGetBuffer(_barter_back_win); - blitBufferToBuffer(src + 80, 480, 180, 640, dest, 480); + blitBufferToBuffer(src + INVENTORY_TRADE_WINDOW_X, INVENTORY_TRADE_WINDOW_WIDTH, INVENTORY_TRADE_WINDOW_HEIGHT, 640, dest, INVENTORY_TRADE_WINDOW_WIDTH); gInventoryPrintItemDescriptionHandler = gameDialogRenderSupplementaryMessage; } @@ -606,7 +614,7 @@ bool _setup_inventory(int inventoryWindowType) } int eventCode = 2005; - int y = INVENTORY_SLOT_HEIGHT * 5 + INVENTORY_SLOT_HEIGHT; + int y = INVENTORY_SLOT_HEIGHT * 5 + INVENTORY_LOOT_LEFT_SCROLLER_Y; // Create invisible buttons representing container's inventory item // slots. For unknown reason it loops backwards and it's size is @@ -4476,6 +4484,7 @@ void _container_enter(int keyCode, int inventoryWindowType) _stack[_curr_stack] = item; _stack_offset[_curr_stack] = 0; + _inven_dude = _stack[_curr_stack]; _pud = &(item->data.inventory); _adjust_fid(); diff --git a/src/stat.cc b/src/stat.cc index f08ca84..dcc02c8 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -323,6 +323,7 @@ int critterGetStat(Object* critter, int stat) } break; case STAT_DAMAGE_RESISTANCE: + case STAT_DAMAGE_RESISTANCE_EXPLOSION: if (perkGetRank(critter, PERK_DERMAL_IMPACT_ARMOR)) { value += 5; } else if (perkGetRank(critter, PERK_DERMAL_IMPACT_ASSAULT_ENHANCEMENT)) {