@@ -41,6 +41,7 @@ DrawBarChartFunc DrawBarChart = reinterpret_cast<DrawBarChartFunc>(FUNC_CSprite2
4141std::unordered_map<eHudComponent, SHudComponentData> defaultComponentProperties = {
4242 {HUD_HEALTH, {CHudSA::GetHUDColour (eHudColour::RED)}},
4343 {HUD_BREATH, {CHudSA::GetHUDColour (eHudColour::LIGHT_BLUE)}},
44+ {HUD_ARMOUR, {CHudSA::GetHUDColour (eHudColour::LIGHT_GRAY)}},
4445 {HUD_CLOCK, {CHudSA::GetHUDColour (eHudColour::LIGHT_GRAY), {}, false , false , COLOR_BLACK, eFontAlignment::ALIGN_RIGHT, eFontStyle::FONT_PRICEDOWN, 2 }},
4546 {HUD_MONEY, {CHudSA::GetHUDColour (eHudColour::GREEN), CHudSA::GetHUDColour (eHudColour::RED), false , false , COLOR_BLACK, eFontAlignment::ALIGN_RIGHT, eFontStyle::FONT_PRICEDOWN, 2 }},
4647 {HUD_AMMO, {CHudSA::GetHUDColour (eHudColour::LIGHT_BLUE), {}, false , false , COLOR_BLACK, eFontAlignment::ALIGN_CENTER, eFontStyle::FONT_SUBTITLES, 1 , 0 , true }},
@@ -543,7 +544,7 @@ void CHudSA::SetComponentColor(const eHudComponent& component, std::uint32_t col
543544 if (!secondColor)
544545 compRef.fillColor = RwColor{newColor.R , newColor.G , newColor.B , newColor.A };
545546 else
546- compRef.fillColor_Second = RwColor{newColor.R , newColor.G , newColor.B , newColor.A };
547+ compRef.fillColorSecondary = RwColor{newColor.R , newColor.G , newColor.B , newColor.A };
547548}
548549
549550void CHudSA::ResetComponentColor (const eHudComponent& component, bool secondColor) noexcept
@@ -557,7 +558,7 @@ void CHudSA::ResetComponentColor(const eHudComponent& component, bool secondColo
557558 if (!secondColor)
558559 componentData.fillColor = defaultRef.fillColor ;
559560 else
560- componentData.fillColor_Second = defaultRef.fillColor_Second ;
561+ componentData.fillColorSecondary = defaultRef.fillColorSecondary ;
561562}
562563
563564void CHudSA::SetComponentFontDropColor (const eHudComponent& component, std::uint32_t color) noexcept
@@ -592,10 +593,10 @@ SColor CHudSA::GetComponentColor(const eHudComponent& component) const noexcept
592593 return SColorRGBA (ref.fillColor .r , ref.fillColor .g , ref.fillColor .b , ref.fillColor .a );
593594}
594595
595- SColor CHudSA::GetComponentSecondColor (const eHudComponent& component) const noexcept
596+ SColor CHudSA::GetComponentSecondaryColor (const eHudComponent& component) const noexcept
596597{
597598 const auto & ref = GetHudComponentRef (component);
598- return SColorRGBA (ref.fillColor_Second .r , ref.fillColor_Second .g , ref.fillColor_Second .b , ref.fillColor_Second .a );
599+ return SColorRGBA (ref.fillColorSecondary .r , ref.fillColorSecondary .g , ref.fillColorSecondary .b , ref.fillColorSecondary .a );
599600}
600601
601602SColor CHudSA::GetComponentFontDropColor (const eHudComponent& component) const
@@ -741,12 +742,12 @@ void CHudSA::RenderText(float x, float y, const char* text, SHudComponentData& p
741742 if (!properties.useCustomAlpha )
742743 {
743744 CFontSA::SetDropColor (RwColor{properties.dropColor .r , properties.dropColor .g , properties.dropColor .b , CFontSA::GetColor ().a });
744- CFontSA::SetColor (useSecondColor ? RwColor{properties.fillColor_Second .r , properties.fillColor_Second .g , properties.fillColor_Second .b , CFontSA::GetColor ().a } : RwColor{properties.fillColor .r , properties.fillColor .g , properties.fillColor .b , CFontSA::GetColor ().a });
745+ CFontSA::SetColor (useSecondColor ? RwColor{properties.fillColorSecondary .r , properties.fillColorSecondary .g , properties.fillColorSecondary .b , CFontSA::GetColor ().a } : RwColor{properties.fillColor .r , properties.fillColor .g , properties.fillColor .b , CFontSA::GetColor ().a });
745746 }
746747 else
747748 {
748749 CFontSA::SetDropColor (properties.dropColor );
749- CFontSA::SetColor (useSecondColor ? properties.fillColor_Second : properties.fillColor );
750+ CFontSA::SetColor (useSecondColor ? properties.fillColorSecondary : properties.fillColor );
750751 }
751752
752753 // Save default position once
@@ -828,12 +829,12 @@ void __fastcall CHudSA::RenderWeaponIcon_Sprite(void* sprite, void*, CRect* rect
828829 rect->bottom = rect->top + (useCustomSize ? properties.placement .customHeight : properties.placement .height );
829830 }
830831
831- color->r = properties.fillColor_Second .r ;
832- color->g = properties.fillColor_Second .g ;
833- color->b = properties.fillColor_Second .b ;
832+ color->r = properties.fillColorSecondary .r ;
833+ color->g = properties.fillColorSecondary .g ;
834+ color->b = properties.fillColorSecondary .b ;
834835
835836 if (properties.useCustomAlpha )
836- color->a = properties.fillColor_Second .a ;
837+ color->a = properties.fillColorSecondary .a ;
837838
838839 // Call CSprite2d::Draw
839840 ((void (__thiscall*)(void *, CRect*, RwColor*))FUNC_CSprie2d_Draw)(sprite, rect, color);
@@ -888,8 +889,8 @@ void CHudSA::RenderWanted(bool empty, float x, float y, const char* strLevel)
888889 RenderText (x, y, strLevel, componentProperties.wanted , empty);
889890}
890891
891- static constexpr DWORD back = 0x58DFD8 ;
892- static void _declspec (naked) RenderWanted_Hook ()
892+ static constexpr std:: uintptr_t CONTINUE_RenderWanted = 0x58DFD8 ;
893+ static void _declspec (naked) HOOK_RenderWanted ()
893894{
894895 _asm
895896 {
@@ -906,58 +907,19 @@ static void _declspec(naked) RenderWanted_Hook()
906907 call CHudSA::RenderWanted
907908 add esp,4
908909
909- jmp back
910+ jmp CONTINUE_RenderWanted
910911 }
911912}
912913
913- static void _declspec (naked) HOOK_RenderHudBar()
914+ static void HOOK_RenderHudBar (int playerId, int x, int y )
914915{
915- _asm
916- {
917- mov eax, [esp]
918-
919- push [esp+0Ch] // y
920- push [esp+0Ch] // x
921-
922- // Health bar
923- cmp eax, 0058EE9Fh
924- jz renderHealthBar
925-
926- cmp eax, 0058EF12h
927- jz renderHealthBar
928-
929- // Breath bar
930- cmp eax, 0058F136h
931- jz renderBreathBar
932-
933- cmp eax, 0058F1B2h
934- jz renderBreathBar
935-
936- // Armor bar
937- cmp eax, 0058EF70h
938- jz renderArmorBar
939-
940- cmp eax, 0058EFE3h
941- jz renderArmorBar
942-
943- jmp skip
944-
945- renderHealthBar:
946- call CHudSA::RenderHealthBar
947- jmp skip
948-
949- renderBreathBar:
950- call CHudSA::RenderBreathBar
951- jmp skip
952-
953- renderArmorBar:
954- call CHudSA::RenderArmorBar
955- jmp skip
956-
957- skip:
958- add esp, 8
959- retn
960- }
916+ void * returnAdress = _ReturnAddress ();
917+ if (returnAdress == (void *)0x58EE9F || returnAdress == (void *)0x58EF12 )
918+ CHudSA::RenderHealthBar (x, y);
919+ else if (returnAdress == (void *)0x58F136 || returnAdress == (void *)0x58F1B2 )
920+ CHudSA::RenderBreathBar (x, y);
921+ else if (returnAdress == (void *)0x58EF70 || returnAdress == (void *)0x58EFE3 )
922+ CHudSA::RenderArmorBar (x, y);
961923}
962924
963925void CHudSA::StaticSetHooks ()
@@ -977,5 +939,5 @@ void CHudSA::StaticSetHooks()
977939 HookInstallCall (0x58D988 , (DWORD)&RenderWeaponIcon_Sprite);
978940 HookInstallCall (0x58D8FD , (DWORD)&RenderWeaponIcon_XLU);
979941
980- HookInstall (0x58DFD3 , (DWORD)&RenderWanted_Hook );
942+ HookInstall (0x58DFD3 , &HOOK_RenderWanted );
981943}
0 commit comments