From 5ba7efaf4385a8db077ebe026ae3107889cb7048 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Thu, 16 Jan 2025 23:13:52 +0300 Subject: [PATCH 1/3] Fix negative weapon ammo --- src/object.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/object.cc b/src/object.cc index 93486443..51095f5c 100644 --- a/src/object.cc +++ b/src/object.cc @@ -449,6 +449,12 @@ int objectRead(Object* obj, File* stream) if (PID_TYPE(obj->pid) == 0 && !(gMapHeader.flags & 0x01)) { _object_fix_weapon_ammo(obj); } + + if (PID_TYPE(obj->pid) == OBJ_TYPE_ITEM + && itemGetType(obj) == ITEM_TYPE_WEAPON + && obj->data.item.weapon.ammoQuantity < 0) { + obj->data.item.weapon.ammoQuantity = 0; + } } return 0; From f53f0bf62425681295a41929ae0d8c22e2162a2f Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Tue, 21 Jan 2025 21:30:34 +0300 Subject: [PATCH 2/3] Fix world map tabs Closes #419 --- src/worldmap.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/worldmap.cc b/src/worldmap.cc index 4d2495f0..909d545d 100644 --- a/src/worldmap.cc +++ b/src/worldmap.cc @@ -4380,14 +4380,10 @@ static void wmPartyWalkingStep() // 0x4C219C static void wmInterfaceScrollTabsStart(int delta) { - for (int index = 0; index < 7; index++) { - buttonDisable(wmTownMapSubButtonIds[index]); - } - - wmGenData.oldTabsOffsetY = wmGenData.tabsOffsetY; - + // SFALL: Fix world map cities list scrolling bug that might leave buttons + // in the disabled state. if (delta >= 0) { - if (wmGenData.oldTabsOffsetY < wmGenData.tabsBackgroundFrmImage.getHeight() - 230) { + if (wmGenData.tabsOffsetY < wmGenData.tabsBackgroundFrmImage.getHeight() - 230) { wmGenData.oldTabsOffsetY = std::min(wmGenData.tabsOffsetY + 7 * delta, wmGenData.tabsBackgroundFrmImage.getHeight() - 230); wmGenData.tabsScrollingDelta = delta; } @@ -4398,7 +4394,14 @@ static void wmInterfaceScrollTabsStart(int delta) } } - // NOTE: Uninline. + if (wmGenData.tabsScrollingDelta == 0) { + return; + } + + for (int index = 0; index < 7; index++) { + buttonDisable(wmTownMapSubButtonIds[index]); + } + wmInterfaceScrollTabsUpdate(); } @@ -6247,7 +6250,10 @@ static int wmRefreshTabs() unsigned char* v13; FrmImage labelFrm; - blitBufferToBufferTrans(wmGenData.tabsBackgroundFrmImage.getData() + wmGenData.tabsBackgroundFrmImage.getWidth() * wmGenData.tabsOffsetY + 9, + // CE: Skip first empty tab (original code does this in the + // `wmInterfaceInit`). + unsigned char* src = wmGenData.tabsBackgroundFrmImage.getData() + wmGenData.tabsBackgroundFrmImage.getWidth() * 27; + blitBufferToBufferTrans(src + wmGenData.tabsBackgroundFrmImage.getWidth() * wmGenData.tabsOffsetY + 9, 119, 178, wmGenData.tabsBackgroundFrmImage.getWidth(), From 5d3244f3530d08e7836d2d26079163d791f2b8a4 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Tue, 21 Jan 2025 21:38:26 +0300 Subject: [PATCH 3/3] Revert "Fix world map tabs" Wrong branch. --- src/worldmap.cc | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/worldmap.cc b/src/worldmap.cc index 909d545d..4d2495f0 100644 --- a/src/worldmap.cc +++ b/src/worldmap.cc @@ -4380,10 +4380,14 @@ static void wmPartyWalkingStep() // 0x4C219C static void wmInterfaceScrollTabsStart(int delta) { - // SFALL: Fix world map cities list scrolling bug that might leave buttons - // in the disabled state. + for (int index = 0; index < 7; index++) { + buttonDisable(wmTownMapSubButtonIds[index]); + } + + wmGenData.oldTabsOffsetY = wmGenData.tabsOffsetY; + if (delta >= 0) { - if (wmGenData.tabsOffsetY < wmGenData.tabsBackgroundFrmImage.getHeight() - 230) { + if (wmGenData.oldTabsOffsetY < wmGenData.tabsBackgroundFrmImage.getHeight() - 230) { wmGenData.oldTabsOffsetY = std::min(wmGenData.tabsOffsetY + 7 * delta, wmGenData.tabsBackgroundFrmImage.getHeight() - 230); wmGenData.tabsScrollingDelta = delta; } @@ -4394,14 +4398,7 @@ static void wmInterfaceScrollTabsStart(int delta) } } - if (wmGenData.tabsScrollingDelta == 0) { - return; - } - - for (int index = 0; index < 7; index++) { - buttonDisable(wmTownMapSubButtonIds[index]); - } - + // NOTE: Uninline. wmInterfaceScrollTabsUpdate(); } @@ -6250,10 +6247,7 @@ static int wmRefreshTabs() unsigned char* v13; FrmImage labelFrm; - // CE: Skip first empty tab (original code does this in the - // `wmInterfaceInit`). - unsigned char* src = wmGenData.tabsBackgroundFrmImage.getData() + wmGenData.tabsBackgroundFrmImage.getWidth() * 27; - blitBufferToBufferTrans(src + wmGenData.tabsBackgroundFrmImage.getWidth() * wmGenData.tabsOffsetY + 9, + blitBufferToBufferTrans(wmGenData.tabsBackgroundFrmImage.getData() + wmGenData.tabsBackgroundFrmImage.getWidth() * wmGenData.tabsOffsetY + 9, 119, 178, wmGenData.tabsBackgroundFrmImage.getWidth(),