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

[GoldSource] PEntityOfEntIndex may not return the last player #2272

Open
2010kohtep opened this issue Apr 24, 2019 · 8 comments
Open

[GoldSource] PEntityOfEntIndex may not return the last player #2272

2010kohtep opened this issue Apr 24, 2019 · 8 comments
Assignees
Labels

Comments

@2010kohtep
Copy link

@2010kohtep 2010kohtep commented Apr 24, 2019

PEntityOfEntIndex function has a condition that prevents the last player from being returned. This is because the player index starts at 1, since the map is already located at index 0 and therefore we must perform a check in the range 1 .. sv::maxplayers.

image

The solution is to replace the >= check with > to allow the last player to be checked.

@mikela-valve mikela-valve added this to the Next Release milestone Apr 25, 2019
@mikela-valve mikela-valve self-assigned this Apr 25, 2019
@mikela-valve

This comment has been minimized.

Copy link
Collaborator

@mikela-valve mikela-valve commented May 15, 2019

Fixed, will be in next beta update.

@mikela-valve

This comment has been minimized.

Copy link
Collaborator

@mikela-valve mikela-valve commented May 21, 2019

Fixed in beta 'Exe build: 11:12:36 May 21 2019 (8244)'.

@mikela-valve

This comment has been minimized.

Copy link
Collaborator

@mikela-valve mikela-valve commented Jun 2, 2019

Closing as fixed.

@mikela-valve

This comment has been minimized.

Copy link
Collaborator

@mikela-valve mikela-valve commented Jun 25, 2019

Unfortunately it looks like CZ:DS and likely some other games rely on this bug being present and it's a bit difficult to test for this without playing through every single scene of every single game. I'm going to revert this in PEntityOfEntIndex to avoid causing crashes in places using the returned entity unchecked and revisit actually fixing it later.

For mods using this that want the fixed behaviour, I did add a parallel function to the engine interface, PEntityOfEntIndexAllEntities. This function properly checks the [1, svs.maxclients] range and can be used while PEntityOfEntIndex has this issue.

@mikela-valve

This comment has been minimized.

Copy link
Collaborator

@mikela-valve mikela-valve commented Jun 26, 2019

This has been updated in beta 8279.

@CS-PRO1

This comment has been minimized.

Copy link

@CS-PRO1 CS-PRO1 commented Jun 27, 2019

@mikela-valve Here's all I found in CZ:DS Beta 8265:
Recoil: Crashes the game after helicopter takedown scene (after CS:CZ logo)
Fastline: Crashes the game after the tram explosion (after CS:CZ logo)
Run!: Crashes the game upon loading the mission's first map.
Truth in Chaos & Rise Hard: Crashes the game after the end of conversation with gaurds (when the next map loading screen hits)
Other missions are playing good without crashes. Still we need someone to confirm if this happens in other Single player titles (HL, OF, BS etc..) Since I don't own any of these unfortunately :\

@tschumann

This comment has been minimized.

Copy link

@tschumann tschumann commented Jun 29, 2019

@mikela-valve so right after
int (*pfnCheckParm)( const char *pchCmdLineToken, char **ppnext );
is
edict_t* (*PEntityOfEntIndexAllEntities)(int iEntIndex);
in enginefuncs_t?
And this will be live once the next beta is promoted to release?

@mikela-valve

This comment has been minimized.

Copy link
Collaborator

@mikela-valve mikela-valve commented Jul 2, 2019

Thanks @CS-PRO1.

@tschumann That's correct (though it will be pfnPEntityOfEntIndexAllEntities). I'll update eiface.h when the update is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.