Bug 5450 - SV_SetUserinfo() incomplete?
Status: RESOLVED WONTFIX
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Misc
Version: GIT MASTER
Hardware: PC Windows Vista
: P3 enhancement
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2012-03-23 11:36 EDT by Gros Bedo
Modified: 2012-04-06 08:22:21 EDT
1 user (show)

See Also:



Description Gros Bedo 2012-03-23 11:36:45 EDT
In sv_init.c, SV_SetUserinfo() does not follow the same procedure as SV_UpdateUserinfo_f() in sv_client.c, basic summary:

SV_SetUserinfo():
- Set the userinfo string for the specified client
- Update the name field

SV_UpdateUserinfo_f():
- Set the userinfo string for the client
- Update ALL client_t fields (by calling SV_UserinfoChanged() )
- Propagate the change to the gamecode via a VM_CALL GAME_CLIENT_USERINFO_CHANGED

As you can see, while the first function only updates one client_t field, the latter one updates all the fields and propagate the changes to the gamecode. Is there a reason for that?

Also, SV_UpdateUserinfo_f() is static, while SV_SetUserinfo() is not, so an external module can only access the incomplete SV_SetUserinfo()...
Comment 1 Zack Middleton 2012-04-04 15:28:19 EDT
Yes, there are reasons.

SV_SetUserinfo is called when the server drops client or game change a client's userinfo string. Game either gets GAME_CLIENT_DISCONNECT or caused the changed.

SV_UpdateUserinfo_f is called when client sends server an updated userinfo string, server calls GAME_CLIENT_USERINFO_CHANGED. Comments above ClientUserinfoChanged in game describes this behavior.

If the server told game userinfo changed when game caused it, might get stuck in a loop (q3a doesn't call trap_SetUserinfo inside GAME_CLIENT_USERINFO_CHANGED, so it would be fine for it but mods might). Game can call it's own ClientUserinfoChanged function, so I see no case where it would be necessary (or desirable really) to add vm call to SV_SetUserinfo.

Calling SV_UserinfoChanged in SV_SetUserinfo seems reasonable, I don't think it would break anything. However, does game have any business changing a client's "rate", "snaps", "cl_voip", or "ip"? I don't think so.

If you modify the server to load an external module, you could add a SV_UpdateUserinfo function.
Comment 2 Gros Bedo 2012-04-06 08:22:21 EDT
Ok thank's for the explanation, seems logical (but it wasn't described in the comments).

Anyway I think that SV_UpdateUserinfo_f() could be declared as non-static, because other servers modules may need it in the future. At least my module for server-side demos recording needs it, but that's another story.