Skip to content

Commit

Permalink
Merge pull request #444 from zer0k-z/hudmsg-fix
Browse files Browse the repository at this point in the history
Fix HUD text display taking over other plugins' display
  • Loading branch information
zealain authored Feb 5, 2023
2 parents 28e4d8a + 7ad5942 commit 592b2f5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/gokz-hud/racing_text.sp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static void ShowCountdownText(KZPlayer player, KZPlayer targetPlayer)
int colour[4];
GetCountdownColour(timeToStart, colour);

SetHudTextParams(-1.0, 0.3, 1.0, colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0);
SetHudTextParams(-1.0, 0.3, GetTextHoldTime(gB_FastUpdateRate[player.ID] ? 3 : 6), colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0);
ShowSyncHudText(player.ID, racingHudSynchronizer, "%t\n\n%d", "Get Ready", IntMax(RoundToCeil(timeToStart), 1));
}

Expand Down Expand Up @@ -162,6 +162,6 @@ static void ShowStartedText(KZPlayer player, KZPlayer targetPlayer)
return;
}

SetHudTextParams(-1.0, 0.3, 1.0, 0, 255, 0, 255, 0, 1.0, 0.0, 0.0);
SetHudTextParams(-1.0, 0.3, GetTextHoldTime(gB_FastUpdateRate[player.ID] ? 3 : 6), 0, 255, 0, 255, 0, 1.0, 0.0, 0.0);
ShowSyncHudText(player.ID, racingHudSynchronizer, "%t", "Go!");
}
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/gokz-hud/speed_text.sp
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ static void ShowSpeedText(KZPlayer player, HUDInfo info)
// Set params based on the available screen space at max scaling HUD
if (!IsDrawingInfoPanel(player.ID))
{
SetHudTextParams(-1.0, 0.75, 1.0, colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0);
SetHudTextParams(-1.0, 0.75, GetTextHoldTime(gB_FastUpdateRate[player.ID] ? 3 : 6), colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0);
}
else
{
SetHudTextParams(-1.0, 0.65, 1.0, colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0);
SetHudTextParams(-1.0, 0.65, GetTextHoldTime(gB_FastUpdateRate[player.ID] ? 3 : 6), colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/gokz-hud/timer_text.sp
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ static void ShowTimerText(KZPlayer player, HUDInfo info)
{
case TimerText_Top:
{
SetHudTextParams(-1.0, 0.07, 1.0, colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0);
SetHudTextParams(-1.0, 0.07, GetTextHoldTime(gB_FastUpdateRate[player.ID] ? 3 : 6), colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0);
}
case TimerText_Bottom:
{
SetHudTextParams(-1.0, 0.9, 1.0, colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0);
SetHudTextParams(-1.0, 0.9, GetTextHoldTime(gB_FastUpdateRate[player.ID] ? 3 : 6), colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0);
}
}

Expand Down
16 changes: 16 additions & 0 deletions addons/sourcemod/scripting/include/gokz.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1019,3 +1019,19 @@ stock int GOKZGetClientFromGameMovementAddress(Address addr, int offsetCGameMove
Address playerAddr = view_as<Address>(LoadFromAddress(view_as<Address>(view_as<int>(addr) + offsetCGameMovement_player), NumberType_Int32));
return GOKZGetEntityFromAddress(playerAddr);
}

/**
* Gets the ideal amount of time the text should be held for HUD messages.
*
* The message buffer is only 16 slots long, and it is shared between 6 channels maximum.
* Assuming a message is sent every game frame, each channel used should be only taking around 2.5 slots on average.
* This also assumes all channels are used equally (so no other plugin taking all the channel buffer for itself).
* We want to use as much of the message buffer as possible to take into account latency variances.
*
* @param interval HUD message update interval, in tick intervals.
* @return How long the text should be held for.
*/
stock float GetTextHoldTime(int interval)
{
return 3 * interval * GetTickInterval();
}

0 comments on commit 592b2f5

Please sign in to comment.