sourcemod icon indicating copy to clipboard operation
sourcemod copied to clipboard

TF2_OnIsHolidayActive does not catch all cases

Open Mikusch opened this issue 2 years ago • 4 comments

Many years ago, #42 changed the TF2_OnIsHolidayActive forward from a TF_IsHolidayActive detour to a CTFGameRules::IsHolidayActive virtual hook.

I'm not quite sure how these functions looked like back then, but the current behavior of the TF2_OnIsHolidayActive forward is most certainly wrong. TF2 has direct calls to TF_IsHolidayActive all over game code, meaning that the forward does not get called for these invocations.

However, CTFGameRules::IsHolidayActive directly calls TF_IsHolidayActive, meaning that this can be fixed without breaking anything in the process by changing the forward to the signature call (again).

Mikusch avatar Jun 24 '22 09:06 Mikusch

This was an intentional trade off, the reasoning is given in the linked PR.

We could do both, but that would result in differing behaviour between Windows and Linux which I think would be much worse.

asherkin avatar Jun 24 '22 10:06 asherkin

the reasoning is given in the linked PR

If this is about it being inlined; it's not. At least not anymore. The function was expanded over the years.

Here are the current signatures: Linux: @_Z18TF_IsHolidayActivei Windows: \x55\x8B\xEC\xA1\x2A\x2A\x2A\x2A\x83\x78\x30\x00\x74\x2A\x32\xC0

Mikusch avatar Jun 24 '22 10:06 Mikusch

I agree, with that explanation, switching back seems reasonable.

psychonic avatar Jun 24 '22 21:06 psychonic

does hooking multiple vtables here help? or is it really that direct on the call

KyleSanderson avatar Jun 25 '22 06:06 KyleSanderson