@@ -771,8 +771,8 @@ static void __fastcall wmDetectHotspotHover(long wmMouseX, long wmMouseY) {
771771 }
772772 // redraw rectangle on worldmap interface
773773 RECT rect;
774- rect.top = y;
775774 rect.left = x_offset;
775+ rect.top = y;
776776 rect.right = x + TerrainHoverImage::width;
777777 rect.bottom = y + TerrainHoverImage::height;
778778 fo::func::win_draw_rect (fo::var::wmBkWin, &rect);
@@ -1043,16 +1043,62 @@ static __declspec(naked) void gmouse_bk_process_hook() {
10431043 }
10441044}
10451045
1046- static long ammoBarXPos = 463 ; // default position
1047-
10481046static __declspec (naked) void intface_update_ammo_lights_hack() {
10491047 __asm {
10501048 mov eax, 70 ; // 70 - full ammo bar
10511049 cmp edx, eax;
10521050 cmovg edx, eax;
10531051 cmp edx, ebx; // ebx = 0 (empty ammo bar)
10541052 cmovl edx, ebx;
1055- mov eax, ammoBarXPos; // overwritten engine code
1053+ mov eax, 463 ; // overwritten engine code
1054+ retn;
1055+ }
1056+ }
1057+
1058+ // Implementation from HRP by Mash
1059+ static void __fastcall DrawAmmoBar (long barX, long barFillHeight) {
1060+ fo::Window* win = fo::func::GNW_find (fo::var::interfaceWindow);
1061+ if (win == nullptr ) return ;
1062+
1063+ barX += win->width - 640 ;
1064+
1065+ long barFillHeightMax = 70 ;
1066+
1067+ if (barFillHeight & 1 ) barFillHeight--;
1068+ BYTE * buff = win->surface ;
1069+ buff += (26 * win->width ) + barX;
1070+
1071+ while (barFillHeightMax > barFillHeight) {
1072+ buff[0 ] = 14 ;
1073+ buff[1 ] = 14 ;
1074+ buff += win->width ;
1075+ barFillHeightMax--;
1076+ }
1077+
1078+ while (barFillHeight > 0 ) {
1079+ buff[0 ] = 196 ;
1080+ buff[1 ] = 196 ;
1081+ buff += win->width ;
1082+ buff[0 ] = 14 ;
1083+ buff[1 ] = 14 ;
1084+ buff += win->width ;
1085+ barFillHeight -= 2 ;
1086+ }
1087+
1088+ RECT rect;
1089+ rect.left = barX;
1090+ rect.top = 26 ;
1091+ rect.right = barX + 2 ;
1092+ rect.bottom = 26 + 70 ;
1093+ fo::func::win_draw_rect (fo::var::interfaceWindow, &rect);
1094+ }
1095+
1096+ static __declspec (naked) void intface_update_ammo_lights_hook() {
1097+ __asm {
1098+ push ecx;
1099+ mov ecx, eax;
1100+ call DrawAmmoBar;
1101+ pop ecx;
10561102 retn;
10571103 }
10581104}
@@ -1475,12 +1521,11 @@ void Interface::init() {
14751521
14761522 // Fix crash when the player equips a weapon overloaded with ammo (ammo bar overflow)
14771523 MakeCall (0x45F94F , intface_update_ammo_lights_hack);
1478- // Tweak for ammo bar position with HRP by Mash
1479- if (HRP::Setting::ExternalEnabled ()) {
1480- // ammoBarXPos = 467;
1481- if (!IniReader::GetInt (" IFACE" , " ALTERNATE_AMMO_METRE" , 0 , " .\\ f2_res.ini" )) {
1482- ammoBarXPos += 4 ;
1483- }
1524+ // Ammo bar graphics patch (when not using ALTERNATE_AMMO_METRE from HRP)
1525+ if ((HRP::Setting::ExternalEnabled () && IniReader::GetInt (" IFACE" , " ALTERNATE_AMMO_METRE" , 0 , " .\\ f2_res.ini" ) == 0 ) ||
1526+ (!HRP::Setting::ExternalEnabled () && HRP ::IFaceBar::ALTERNATE_AMMO_METRE == 0 ))
1527+ {
1528+ HookCall (0x45F954 , intface_update_ammo_lights_hook); // replace intface_draw_ammo_lights_
14841529 }
14851530
14861531 // Add missing sounds to the 'Done' and 'Cancel' buttons in the 'Custom' disposition of the combat control panel
0 commit comments