Bug 2986 - r1019 ps.clientNum
Status: RESOLVED FIXED
Alias:
Product: ioquake3
Classification: Unclassified
Component: Misc
Version: unspecified
Hardware: PC All
: P2 normal
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2006-12-29 16:42 EST by ensiform
Modified: 2009-09-14 11:46:10 EDT
2 users (show)

See Also:


Attachments
SetTeam fix (2.06 KB, patch)
2007-09-24 20:22 EDT, Martin Doucha
SetTeam fix done right this time (1.07 KB, patch)
2007-09-24 20:59 EDT, Martin Doucha

Description ensiform 2006-12-29 16:42:22 EST
using ps.clientNum is not a good idea, try using cl - level.clients or get the entity and subtract that from g_entities or same as ent->s.number.

otherwise can possibly kick someone spectating them instead...
Comment 1 Tim Angus 2007-01-17 15:22:19 EST
What?
Comment 2 Zachary J. Slater 2007-01-25 17:08:01 EST
What indeed. Get out of my bug list.
Comment 3 Ryan C. Gordon 2007-05-21 11:27:13 EDT
Setting a QA contact on all ioquake3 bugs, even resolved ones. Sorry if you get a flood of email from this, it should only happen once. Apologies for the incovenience.

--ryan.

Comment 4 Martin Doucha 2007-09-24 20:22:50 EDT
Created attachment 1522 [details]
SetTeam fix

Actually, client->ps.clientNum is unsafe. We had a little hunt for this some time ago in Tremulous last year (it caused kick failures, annoying popup windows and other nasty bugs). The problem is that a following spectator gets full copy of client->ps of the followed player including clientNum. If you then try to use this "shared" clientNum, you might affect someone else than you wanted.

r1019 changes are safe as long as bots don't spectate players. However, a brief grep on current code has revealed unsafe client->ps.clientNum usage in SetTeam(). If a following spectator uses team command when forced balance is on, it'll count teams incorrectly and send the error message to the followed player instead. Here's the fix.
Comment 5 Martin Doucha 2007-09-24 20:23:35 EDT
Reopen for SetTeam fix
Comment 6 Martin Doucha 2007-09-24 20:59:56 EDT
Created attachment 1523 [details]
SetTeam fix done right this time

D'oh, I've left changes which belong somewhere else in the patch...
Comment 7 Ryan C. Gordon 2009-09-14 11:46:10 EDT
Fixed in svn revision #1587, thanks!

--ryan.