Skip to content
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

Pass a handle instead of entptr to ProcessCondChange for stability. #314

Merged
merged 1 commit into from Apr 2, 2015

Conversation

psychonic
Copy link
Member

@voided had seen some crashes on his TF2 servers after the new TF2 player conditions change detection was implemented. The crashes were in CHalfLife2::EntityToBCompatRef, called from PlayerConditionsMgr::ProcessCondChange.

This change makes it so that we pass an entity handle around instead of the raw player pointer, and checking it for validity before use in an attempt to quash the crash from the player no longer being valid.

int client = gamehelpers->EntityToBCompatRef(pCondData->pPlayer);
if (!playerhelpers->GetGamePlayer(client)->IsInGame())
auto *pEdict = gamehelpers->GetHandleEntity(pCondData->hPlayer);
auto *pPlayer = playerhelpers->GetGamePlayer(pEdict);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not safe on >= L4D as pEdict can be NULL (compat_wrappers doesn't check, I'm not sure about in the engine). Otherwise, as this is for TF only, everything seems more safe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make a note to fix it when we port the TF2 extension to L4D.

psychonic added a commit that referenced this pull request Apr 2, 2015
Pass a handle instead of entptr to ProcessCondChange for stability.
@psychonic psychonic merged commit ea7d5ad into master Apr 2, 2015
@KyleSanderson KyleSanderson deleted the tfconds-reducks branch September 8, 2015 01: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.

None yet

2 participants