-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
helper_functions: added IsPlayer and Center own implementations to not rely on hooked virtual functions #540
Open
SmileyAG
wants to merge
5
commits into
YaLTeR:master
Choose a base branch
from
SmileyAG:fpr_hf_hlsdk_center_and_isplayer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
be4f8a9
helper_functions: added IsPlayer function to determine whether this e…
SmileyAG 007aacf
ServerDLL: the call to the virtual IsPlayer function has been replace…
SmileyAG a868c95
helper_functions: added Center function to determine center point of …
SmileyAG 3b3b249
ServerDLL: the call to the virtual Center function has been replaced …
SmileyAG c12b9a7
HwDLL: used Center helper function in TAS related code
SmileyAG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -510,39 +510,28 @@ void ServerDLL::FindStuff() | |
case 3: // OP4-WON | ||
offm_rgAmmoLast = 0x5C0; | ||
offm_iClientFOV = 0x4A4; | ||
offFuncIsPlayer = 0xA0; | ||
offFuncCenter = 0xCC; | ||
break; | ||
case 4: // OpposingForce | ||
offm_rgAmmoLast = 0x604; | ||
offm_iClientFOV = 0x4E0; | ||
offFuncIsPlayer = 0xA0; | ||
offFuncCenter = 0xCC; | ||
break; | ||
case 5: // OP4-8684 | ||
offm_rgAmmoLast = 0x608; | ||
offm_iClientFOV = 0x4E4; | ||
offFuncIsPlayer = 0xA0; | ||
offFuncCenter = 0xCC; | ||
break; | ||
case 6: // Gunman | ||
offm_rgAmmoLast = 0x53C; | ||
offm_iClientFOV = 0x47C; | ||
offFuncCenter = 0xCC; | ||
break; | ||
case 7: // CSCZDS | ||
offm_rgAmmoLast = 0x53C; | ||
offm_iClientFOV = 0x898; | ||
offFuncIsPlayer = 0xA8; | ||
offFuncCenter = 0xDC; | ||
offFuncObjectCaps = 0x18; | ||
is_czeror = true; | ||
break; | ||
case 8: // CSCZDS-8684 | ||
offm_rgAmmoLast = 0x540; | ||
offm_iClientFOV = 0x89C; | ||
offFuncIsPlayer = 0xA8; | ||
offFuncCenter = 0xDC; | ||
offFuncObjectCaps = 0x18; | ||
is_czeror = true; | ||
break; | ||
|
@@ -553,35 +542,25 @@ void ServerDLL::FindStuff() | |
case 10: // PARANOIA | ||
offm_rgAmmoLast = 0x62C; | ||
offm_iClientFOV = 0x584; | ||
offFuncIsPlayer = 0xD0; | ||
offFuncCenter = 0xFC; | ||
offFuncObjectCaps = 0x40; | ||
break; | ||
case 11: // CStrike-Latest | ||
offFuncIsPlayer = 0xA0; | ||
offFuncCenter = 0xCC; | ||
offFuncObjectCaps = 0x18; | ||
break; | ||
case 12: // TFC-8684 | ||
offm_rgAmmoLast = 0x978; | ||
offm_iClientFOV = 0x8CC; | ||
offFuncIsPlayer = 0x98; | ||
offFuncCenter = 0xC4; | ||
offFuncObjectCaps = 0x18; | ||
break; | ||
case 13: // TWHL-Tower-2 | ||
case 14: // Halfquake Trilogy | ||
offm_rgAmmoLast = 0x5F4; | ||
offm_iClientFOV = 0x548; | ||
offFuncIsPlayer = 0xD4; | ||
offFuncCenter = 0x100; | ||
offFuncObjectCaps = 0x44; | ||
break; | ||
case 15: // Echoes | ||
offm_rgAmmoLast = 0x5F4; | ||
offm_iClientFOV = 0x548; | ||
offFuncIsPlayer = 0xCC; | ||
offFuncCenter = 0xF8; | ||
offFuncObjectCaps = 0x3C; | ||
break; | ||
case 16: // Decay | ||
|
@@ -596,8 +575,6 @@ void ServerDLL::FindStuff() | |
case 18: // Black-Ops | ||
offm_rgAmmoLast = 0x554; | ||
offm_iClientFOV = 0x4AC; | ||
offFuncIsPlayer = 0xA4; | ||
offFuncCenter = 0xD0; | ||
break; | ||
case 19: // Invasion | ||
offm_rgAmmoLast = 0x514; | ||
|
@@ -606,15 +583,11 @@ void ServerDLL::FindStuff() | |
case 20: // Arctic-Incident | ||
offm_rgAmmoLast = 0x5B8; | ||
offm_iClientFOV = 0x510; | ||
offFuncIsPlayer = 0xCC; | ||
offFuncCenter = 0xF8; | ||
offFuncObjectCaps = 0x3C; | ||
break; | ||
case 21: // HL-Delta | ||
offm_rgAmmoLast = 0x5C8; | ||
offm_iClientFOV = 0x51C; | ||
offFuncIsPlayer = 0xCC; | ||
offFuncCenter = 0xF8; | ||
offFuncObjectCaps = 0x3C; | ||
break; | ||
case 23: // OPBT | ||
|
@@ -624,8 +597,6 @@ void ServerDLL::FindStuff() | |
case 24: // Parasomnia | ||
offm_rgAmmoLast = 0x564; | ||
offm_iClientFOV = 0x4B8; | ||
offFuncIsPlayer = 0x98; | ||
offFuncCenter = 0xC4; | ||
break; | ||
case 26: // AVP2 | ||
offm_rgAmmoLast = 0x550; | ||
|
@@ -634,8 +605,6 @@ void ServerDLL::FindStuff() | |
case 27: // CoF-Mod-10 | ||
offm_rgAmmoLast = 0x2440; | ||
offm_iClientFOV = 0x238C; | ||
offFuncIsPlayer = 0xD0; | ||
offFuncCenter = 0xFC; | ||
offFuncObjectCaps = 0x40; | ||
offm_fStamina = 0x2080; | ||
offm_bInfiniteStamina = 0x2078; | ||
|
@@ -647,8 +616,6 @@ void ServerDLL::FindStuff() | |
case 28: // CoF-Mod-11 | ||
offm_rgAmmoLast = 0x2444; | ||
offm_iClientFOV = 0x2390; | ||
offFuncIsPlayer = 0xD0; | ||
offFuncCenter = 0xFC; | ||
offFuncObjectCaps = 0x40; | ||
offm_fStamina = 0x2084; | ||
offm_bInfiniteStamina = 0x207C; | ||
|
@@ -660,8 +627,6 @@ void ServerDLL::FindStuff() | |
case 29: // CoF-Mod-12 | ||
offm_rgAmmoLast = 0x2450; | ||
offm_iClientFOV = 0x239C; | ||
offFuncIsPlayer = 0xD0; | ||
offFuncCenter = 0xFC; | ||
offFuncObjectCaps = 0x40; | ||
offm_fStamina = 0x2090; | ||
offm_bInfiniteStamina = 0x2088; | ||
|
@@ -674,8 +639,6 @@ void ServerDLL::FindStuff() | |
case 30: // CoF-Mod-13-135 | ||
offm_rgAmmoLast = 0x2460; | ||
offm_iClientFOV = 0x23AC; | ||
offFuncIsPlayer = 0xD0; | ||
offFuncCenter = 0xFC; | ||
offFuncObjectCaps = 0x40; | ||
offm_fStamina = 0x20A0; | ||
offm_bInfiniteStamina = 0x2098; | ||
|
@@ -688,8 +651,6 @@ void ServerDLL::FindStuff() | |
case 31: // CoF-Mod-14-155 | ||
offm_rgAmmoLast = 0x2464; | ||
offm_iClientFOV = 0x23B0; | ||
offFuncIsPlayer = 0xD0; | ||
offFuncCenter = 0xFC; | ||
offFuncObjectCaps = 0x40; | ||
offm_fStamina = 0x20A4; | ||
offm_bInfiniteStamina = 0x209C; | ||
|
@@ -702,8 +663,6 @@ void ServerDLL::FindStuff() | |
case 32: // CoF-Steam-Release | ||
offm_rgAmmoLast = 0x2474; | ||
offm_iClientFOV = 0x23C0; | ||
offFuncIsPlayer = 0xD0; | ||
offFuncCenter = 0xFC; | ||
offFuncObjectCaps = 0x40; | ||
offm_fStamina = 0x20B4; | ||
offm_bInfiniteStamina = 0x20AC; | ||
|
@@ -715,8 +674,6 @@ void ServerDLL::FindStuff() | |
case 33: // CoF-Steam-Latest | ||
offm_rgAmmoLast = 0x25C0; | ||
offm_iClientFOV = 0x250C; | ||
offFuncIsPlayer = 0xD0; | ||
offFuncCenter = 0xFC; | ||
offFuncObjectCaps = 0x40; | ||
offm_fStamina = 0x21F0; | ||
offm_bInfiniteStamina = 0x21E8; | ||
|
@@ -726,8 +683,6 @@ void ServerDLL::FindStuff() | |
is_cof = true; | ||
break; | ||
case 34: // DayOfDefeat-Latest | ||
offFuncIsPlayer = 0xB4; | ||
offFuncCenter = 0xE0; | ||
offFuncObjectCaps = 0x20; | ||
break; | ||
case 35: // DeathmatchClassic-Latest | ||
|
@@ -968,8 +923,6 @@ void ServerDLL::FindStuff() | |
if (ClientDLL::GetInstance().DoesGameDirContain("czeror")) { | ||
offm_rgAmmoLast = 0x554; // 6153: 0x550 | ||
offm_iClientFOV = 0x8B0; // 6153: 0x8AC | ||
offFuncIsPlayer = 0xA8; | ||
offFuncCenter = 0xDC; | ||
offFuncObjectCaps = 0x18; | ||
} | ||
if (ClientDLL::GetInstance().DoesGameDirContain("bshift")) { | ||
|
@@ -979,8 +932,6 @@ void ServerDLL::FindStuff() | |
if (ClientDLL::GetInstance().DoesGameDirMatch("cstrike") || ClientDLL::GetInstance().DoesGameDirMatch("czero")) { | ||
offm_rgAmmoLast = 0x674; | ||
offm_iClientFOV = 0x5C4; | ||
offFuncIsPlayer = 0xA0; | ||
offFuncCenter = 0xCC; | ||
offFuncObjectCaps = 0x18; | ||
} | ||
if (ClientDLL::GetInstance().DoesGameDirMatch("tfc")) { | ||
|
@@ -991,8 +942,6 @@ void ServerDLL::FindStuff() | |
if (ClientDLL::GetInstance().DoesGameDirMatch("dod")) { | ||
offm_rgAmmoLast = 0x4F8; // 6153: 0x4F4 | ||
offm_iClientFOV = 0x448; // 6153: 0x444 | ||
offFuncIsPlayer = 0xB4; | ||
offFuncCenter = 0xE0; | ||
offFuncObjectCaps = 0x20; | ||
} | ||
if (ClientDLL::GetInstance().DoesGameDirMatch("dmc")) { | ||
|
@@ -2648,9 +2597,7 @@ bool ServerDLL::IsPlayerMovingPushable(const entvars_t *pevPushable, const entva | |
if (pevToucher->flags & FL_ONGROUND && pevToucher->groundentity && &pevToucher->groundentity->v == pevPushable) | ||
return false; | ||
|
||
void *pToucher = pevToucher->pContainingEntity->pvPrivateData; | ||
_IsPlayer IsPlayerFunc = *reinterpret_cast<_IsPlayer *>(*reinterpret_cast<uintptr_t *>(pToucher) + offFuncIsPlayer); | ||
if (!IsPlayerFunc(pToucher)) | ||
if (!helper_functions::IsPlayer(pevToucher->pContainingEntity)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd squash this commit into the previous one |
||
return false; | ||
|
||
if (push && !(pevToucher->button & (IN_FORWARD | IN_USE))) | ||
|
@@ -2743,14 +2690,10 @@ HOOK_DEF_6(ServerDLL, int, __fastcall, CBasePlayer__TakeDamage, void*, thisptr, | |
damage.direction[1] = 0.0; | ||
damage.direction[2] = 0.0; | ||
} else { | ||
void *pInflictor = pevInflictor->pContainingEntity->pvPrivateData; | ||
_Center playerCenterFunc = *reinterpret_cast<_Center *>(*reinterpret_cast<uintptr_t *>(thisptr) + offFuncCenter); | ||
_Center inflictorCenterFunc = *reinterpret_cast<_Center *>(*reinterpret_cast<uintptr_t *>(pInflictor) + offFuncCenter); | ||
|
||
Vector playerCenter; | ||
Vector inflictorCenter; | ||
playerCenterFunc(thisptr, edx, &playerCenter); | ||
inflictorCenterFunc(pInflictor, edx, &inflictorCenter); | ||
entvars_t *pev = *reinterpret_cast<entvars_t**>(reinterpret_cast<uintptr_t>(thisptr) + 4); // _Smiley: TODO: replace it with GET_PEV macro once it's merged. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, I'd squash. And now you can GET_PEV too |
||
|
||
Vector playerCenter = helper_functions::Center(pev->pContainingEntity); | ||
Vector inflictorCenter = helper_functions::Center(pevInflictor->pContainingEntity); | ||
Vector vecDir = playerCenter + Vector(0, 0, 10) - inflictorCenter; | ||
|
||
damage.direction[0] = vecDir.x; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move this above the strcmp because it's a much cheaper check.