Skip to content

Fix SV_DropClient detour on non-ReHLDS servers - #1168

Merged
dvander merged 4 commits into
alliedmodders:masterfrom
szGabu:fix/sv_dropclient_correct_detour
Oct 11, 2026
Merged

dvander merged 4 commits into
alliedmodders:masterfrom
szGabu:fix/sv_dropclient_correct_detour

Conversation

@szGabu

@szGabu szGabu commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

This PR does two things

First, it fixes a bug it was introduced years ago back in #446. Basically whenever you used vanilla HLDS, SV_DropClient would never detour, as it would never enable, this resulted in AMXX just falling back to Metamod's pfnClientDisconnect. (It's the reason why would you get garbage, nulled data in the client_disconnected() AMXX forward). I suspect this was never reported due to more people moving to ReHLDS and not actually using the parameters of this forward. The fix is very straightforward and just involves removing a single line.

Second, it fixes two bugs introduced by this due to HL25 and Svengine engine changes. Again, the detour will call but the AMXX forward doesn't, due to how the struct is different in each engine version. To solve this issue I added new structs where AMXX will use the correct one based on the EngineType key value in the gamedata.

Three values are accepted, check gamedata file for formatting:

  • HL25
  • Svengine
  • Legacy

Missing or invalid value will fallback to Legacy, as it was done on the assumption that custom engines like Cry of Fear or Xash may be based on the Legacy branch of GoldSrc. (I mean, if people are crazy enough to run AMXX on Xash which is unsupported anyway)

Example plugin output.

public client_disconnected(iClient, bool:bCrash, szReason[], iMaxLength)
{
	server_print("Client %n disconnected. (Crashed? %b) (Reason size: %d) (Reason: %s)", iClient, bCrash, iMaxLength, szReason);
}

HL25 (Before)
Client Player disconnected (Crashed? 0) (Reason size: 0) (Reason: K�H�

Svengine (Before)
Client Player disconnected. (Crashed? 0) (Reason size: 0) (Reason: �����d���8PHHh���@�4�)*

* varies, sometimes prints previously print lines or just blank spaces

All Engine Branches (After)
Client Player disconnected. (Crashed? 1) (Reason size: 1023) (Reason: Client sent 'drop')

As an additional note, offsets were proposed to tackle this issue, removing the need for struct usage but the idea was discarded mid-development. It still remains as an option that may be explored in the future. This PR doesn't affect ReHLDS, which uses ReAPI.

@dvander
dvander merged commit 8fc1267 into alliedmodders:master Oct 11, 2026
3 checks passed
@szGabu
szGabu deleted the fix/sv_dropclient_correct_detour branch October 15, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants