Bug 6030 - Team Arena Single Player broken, always spectator
Status: RESOLVED FIXED
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Misc
Version: GIT MASTER
Hardware: PC Linux
: P3 major
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2013-09-15 17:23 EDT by Pete
Modified: 2017-06-02 23:18:03 EDT
6 users (show)

See Also:


Attachments
allow early team command (1.06 KB, patch)
2013-09-23 23:20 EDT, Zack Middleton
allow early team command v2 (1.21 KB, patch)
2017-01-11 08:11 EST, James Canete

Description Pete 2013-09-15 17:23:35 EDT
I cloned the current git to my Linux machine and after a successful make, tried to play team arena single player. But when I start a single player game I'm always a spectator, I can watch the bots play, but no way to join.

The correct behavior would be to automatically join a team.

I tried this on several PCs with Ubuntu 12.04.3 and Ubuntu 12.10.
Comment 1 JBravo 2013-09-17 14:27:12 EDT
[ra@hamburger ~]$ ll /usr/local/games/quake3/ioquake3.x86_64
-rwxr-xr-x. 1 ra users 2607969 Sep 11 19:27 /usr/local/games/quake3/ioquake3.x86_64

Not exactly current but Sep 11 is close enough.   Also, Im on Fedora 19.

I started quake, clicked team arena in the menu and the game switched over.  Then I just clicked single play and enter arena and I was playing.
I can verify that my binds did not carry over :)

check out http://www.ra.is/missionpack/

That JBravo in those screenshots is me, not a bot.   Are you using some other method to trigger the behaviour you describe?
Comment 2 JBravo 2013-09-17 14:46:45 EDT
Sorry, I spoke to soon.  Once I choose a CTF type game I saw what you see.
It seems that the join menu in TA is broken.  If you pull down the console and join red or blue all works fine.
Comment 3 Zack Middleton 2013-09-23 21:26:04 EDT
Using the Q3 start server menu the player also does not join a team in CTF.

Setting the team from the UI is time based [1], [2]. The command is dropped at the top of ClientCommand in g_cmds.c [3].

Apparently ioq3 is taking too long to get player to connected state in game VM.

[1] https://github.com/ioquake/ioq3/blob/master/code/q3_ui/ui_startserver.c#L818
[2] https://github.com/ioquake/ioq3/blob/master/code/ui/ui_main.c#L3068
[3] https://github.com/ioquake/ioq3/blob/master/code/game/g_cmds.c#L1648
Comment 4 Zack Middleton 2013-09-23 23:20:31 EDT
Created attachment 3387 [details]
allow early team command

As pointed out to me by Ensiform, the issue is caused by a new check added to ClientCommand "|| ent->client->pers.connected != CON_CONNECTED" in commit 56f16e. Using the original id qagame.qvm works.

Adding a special case for allowing early team command for local client fixes joining team. Disabled running early ClientBegin as it may be able to cause problems? Anyone have comments on the patch before it's committed?
Comment 5 Tim Angus 2013-09-24 04:31:24 EDT
In that the original change was a security change, it's probably worth thinking carefully about the ramifications of removing the check. I'm not saying I fully understand what's going on here, just that exceptions to security/safety code need to be thoroughly thought through.
Comment 6 Pete 2013-09-24 11:53:32 EDT
@Zach, When I searched the code last night to find the problem, I came to the same check in line ui_main.c#L3068 you posted.

Why is that security check needed? What was the idea behind adding it? Because a security check that breaks the game, is too much security :)
Comment 7 Kuehnhammer Tobias 2013-09-24 13:58:03 EDT
This check fixed a few bugs iirc.
Though I can't remember the whole list of problems:

1. I think disconnected clients sometimes have broken the configstrings ('ghost'  
   clients with malformated strings).
2. Under some circumstances game crashes (after map_restart?) if kicked bots 
   (because of wrong function 'BotReadSessionData') or related to 1?.
3. Maybe related bug: "Under certain circumstances, already "disconnected" 
   clients can disconnect"?
   http://svn.icculus.org/tremulous?view=rev&revision=2009
4. gameplay bugs like the flag disappearing? (reported by dev/humancontroller)
5. ...

To be honest I can't remember what exactly was the biggest problem without the check, but I'm definitly sure that game.qvm can crash without the check (the already disconnected client is still there as 'ghost').

So, yes it is a security fix. The added check in g_cmd.c fixed the bug(s), though technically I don't understand why!
--------
It seems that the current problem of not joining a team must be OS specific. I neither have problems on WinXP nor on Win7!
Why is this a problem for Non-Windows OS?

Thanks
Comment 8 Pete 2013-09-24 14:36:26 EDT
Thanks for the info on the nature of the problems that were fixed with the added checks. :) What I don't understand yet is, how can something for disconnecting clients affect connecting clients?

I only have linux machines to try it on. Anyone with a mac?
Comment 9 James Canete 2017-01-11 08:11:47 EST
Created attachment 3575 [details]
allow early team command v2

Well, no-one seems to have thought about this patch for a while, so I decided to think about it.

It seems safe to me.  The only behavior changed is when a local client requests a team change when it's technically not connected.  The UDP spoofing protection in Netchan_Process() in net_chan.c should prevent any spoofed messages from triggering this code path, and if that's not reliable, all bets are already off.

The only change I would make is to re-enable the initial connected check and add an exception for a local client, to avoid always calling the trap_Argv() syscall.

Changes attached.
Comment 10 Donny Springer 2017-01-27 20:31:59 EST
g_teamAutoJoin "1"
Comment 11 James Canete 2017-01-28 00:05:58 EST
g_teamAutoJoin isn't a great solution, because of two things.

First, I really don't want to override user cvars.

Second, it can lead to joining the wrong team.  Try starting a CTF game in Quake 3 (through single player...skirmish) with g_teamAutoJoin 1 and using default settings, except change your team to red.  You'll magically join blue when the game starts.

As well, I tried making the g_teamAutoJoin check in g_session.c G_InitSessionData() line 110 to (g_teamAutoJoin.integer || client->pers.localClient) and that didn't work, I'm guessing localClient isn't set at that point.