diff --git a/Client/game_sa/CHudSA.cpp b/Client/game_sa/CHudSA.cpp index a1d56313d04..4f6355088f2 100644 --- a/Client/game_sa/CHudSA.cpp +++ b/Client/game_sa/CHudSA.cpp @@ -133,6 +133,10 @@ void CHudSA::InitComponentList() {1, HUD_RADAR_MAP, 1, FUNC_CRadar_DrawRadarMap, 1, 0xCC, 0xC3}, {1, HUD_RADAR_BLIPS, 1, FUNC_CRadar_DrawBlips, 1, 0xCC, 0xC3}, {1, HUD_RADAR_ALTIMETER, 1, CODE_ShowRadarAltimeter, 2, 0xCC, 0xEB30}, + {1, HUD_RADAR_DISC, 1, CODE_ShowRadarDisc, 5, 0xCC, HudMakeRelativeJump(CODE_ShowRadarDisc, CODE_DrawRadarBlipsPart)}, + {1, HUD_RADAR_HORIZON, 1, CODE_ShowRadarHorizon, 2, 0xCC, 0xE990, CODE_ShowRadarMapHorizon, 2, 0xCC, 0xE990}, + {1, HUD_RADAR_AIRSTRIP_BLIP, 1, CODE_ShowRadarAirstripBlip, 2, 0xCC, 0xE990}, + {1, HUD_SNIPER_BACKGROUND, 1, CODE_ShowSniperBackground, 1, 0xCC, 0xFF}, {1, HUD_CLOCK, 0, VAR_DisableClock, 1, 1, 0}, {1, HUD_RADIO, 1, FUNC_DrawRadioName, 1, 0xCC, 0xC3}, {1, HUD_WANTED, 1, FUNC_DrawWantedLevel, 1, 0xCC, 0xC3}, @@ -172,7 +176,9 @@ void CHudSA::SetComponentVisible(eHudComponent component, bool bVisible) // Save original bytes if required if (pComponent->bSaveOriginalBytes) { - pComponent->origData = *(DWORD*)pComponent->uiDataAddr; + pComponent->origData = *(std::uint64_t*)pComponent->uiDataAddr; + if (pComponent->uiDataSize2 > 0) + pComponent->origData2 = *(std::uint64_t*)pComponent->uiDataAddr2; pComponent->bSaveOriginalBytes = false; } @@ -186,6 +192,14 @@ void CHudSA::SetComponentVisible(eHudComponent component, bool bVisible) else MemPutFast(pDest + i, pSrc[i]); } + + if (pComponent->uiDataSize2 > 0) + { + uchar* pSrc2 = (uchar*)(bVisible ? &pComponent->origData2 : &pComponent->disabledData2); + uchar* pDest2 = (uchar*)(pComponent->uiDataAddr2); + for (uint i = 0; i < pComponent->uiDataSize2; i++) + MemPut(pDest2 + i, pSrc2[i]); + } } } diff --git a/Client/game_sa/CHudSA.h b/Client/game_sa/CHudSA.h index 55c956c764a..a5cbf0b919b 100644 --- a/Client/game_sa/CHudSA.h +++ b/Client/game_sa/CHudSA.h @@ -55,6 +55,14 @@ #define CODE_ShowMoney 0x58F47D #define CODE_ShowRadarAltimeter 0x58A5A6 +#define CODE_ShowRadarHorizon 0x58A3C5 +#define CODE_ShowRadarMapHorizon 0x5869D2 +#define CODE_ShowRadarDisc 0x58A782 +#define CODE_DrawRadarBlipsPart 0x58AA2A +#define CODE_ShowRadarAirstripBlip 0x587D35 + +#define CODE_ShowSniperBackground 0x53E31D + #define VAR_CTheScripts_bDrawCrossHair 0xA44490 #define VAR_RSGlobal 0xC17040 #define VAR_ItemToFlash 0xBAB1DC @@ -66,10 +74,23 @@ struct SHudComponent bool bSaveOriginalBytes; DWORD uiDataAddr; DWORD uiDataSize; - DWORD origData; - DWORD disabledData; + std::uint64_t origData; + std::uint64_t disabledData; + + // Second patch location, only used if uiDataSize2 > 0 + DWORD uiDataAddr2{0}; + DWORD uiDataSize2{0}; + std::uint64_t origData2{0}; + std::uint64_t disabledData2{0}; }; +constexpr std::uint64_t HudMakeRelativeJump(std::uint32_t uiFrom, std::uint32_t uiTo) +{ + constexpr std::uint32_t uiJumpInstructionSize = 5; + const std::uint32_t uiRelativeOffset = uiTo - (uiFrom + uiJumpInstructionSize); + return 0xE9 | (static_cast(uiRelativeOffset) << 8); +} + enum class eHudColour { RED, diff --git a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp index 7ae83f8bfbb..60ccbc52975 100644 --- a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp +++ b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp @@ -107,6 +107,10 @@ ADD_ENUM(HUD_RADAR, "radar") ADD_ENUM(HUD_RADAR_MAP, "radar_map") ADD_ENUM(HUD_RADAR_BLIPS, "radar_blips") ADD_ENUM(HUD_RADAR_ALTIMETER, "radar_altimeter") +ADD_ENUM(HUD_RADAR_DISC, "radar_disc") +ADD_ENUM(HUD_RADAR_HORIZON, "radar_horizon") +ADD_ENUM(HUD_RADAR_AIRSTRIP_BLIP, "radar_airstrip_blip") +ADD_ENUM(HUD_SNIPER_BACKGROUND, "sniper_background") ADD_ENUM(HUD_CLOCK, "clock") ADD_ENUM(HUD_RADIO, "radio") ADD_ENUM(HUD_WANTED, "wanted") diff --git a/Client/sdk/game/CHud.h b/Client/sdk/game/CHud.h index da95656daf9..df2a82b83b7 100644 --- a/Client/sdk/game/CHud.h +++ b/Client/sdk/game/CHud.h @@ -34,6 +34,10 @@ enum eHudComponent HUD_RADAR_MAP, HUD_RADAR_BLIPS, HUD_RADAR_ALTIMETER, + HUD_RADAR_DISC, + HUD_RADAR_HORIZON, + HUD_RADAR_AIRSTRIP_BLIP, + HUD_SNIPER_BACKGROUND, }; enum class eHudComponentProperty diff --git a/Server/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp b/Server/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp index ffe4133f790..01af89776bd 100644 --- a/Server/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp +++ b/Server/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp @@ -81,6 +81,10 @@ ADD_ENUM(HUD_RADAR, "radar") ADD_ENUM(HUD_RADAR_MAP, "radar_map") ADD_ENUM(HUD_RADAR_BLIPS, "radar_blips") ADD_ENUM(HUD_RADAR_ALTIMETER, "radar_altimeter") +ADD_ENUM(HUD_RADAR_DISC, "radar_disc") +ADD_ENUM(HUD_RADAR_HORIZON, "radar_horizon") +ADD_ENUM(HUD_RADAR_AIRSTRIP_BLIP, "radar_airstrip_blip") +ADD_ENUM(HUD_SNIPER_BACKGROUND, "sniper_background") ADD_ENUM(HUD_CLOCK, "clock") ADD_ENUM(HUD_RADIO, "radio") ADD_ENUM(HUD_WANTED, "wanted") diff --git a/Server/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h b/Server/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h index 1d5bc7feee7..8d053eb539a 100644 --- a/Server/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h +++ b/Server/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h @@ -61,6 +61,10 @@ enum eHudComponent HUD_RADAR_MAP, HUD_RADAR_BLIPS, HUD_RADAR_ALTIMETER, + HUD_RADAR_DISC, + HUD_RADAR_HORIZON, + HUD_RADAR_AIRSTRIP_BLIP, + HUD_SNIPER_BACKGROUND, }; DECLARE_ENUM(eHudComponent);