Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Client/game_sa/CHudSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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;
}

Expand All @@ -186,6 +192,14 @@ void CHudSA::SetComponentVisible(eHudComponent component, bool bVisible)
else
MemPutFast<BYTE>(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<BYTE>(pDest2 + i, pSrc2[i]);
}
}
}

Expand Down
25 changes: 23 additions & 2 deletions Client/game_sa/CHudSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<std::uint64_t>(uiRelativeOffset) << 8);
}

enum class eHudColour
{
RED,
Expand Down
4 changes: 4 additions & 0 deletions Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions Client/sdk/game/CHud.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Server/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions Server/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down