Bug 2970 - level.num*Clients weirdness
Status: RESOLVED FIXED
Alias: None
Product: Tremulous
Classification: Unclassified
Component: Misc
Version: unspecified
Hardware: PC Linux
: P2 normal
Assignee: Tremulous Bugs
QA Contact:
URL:
Depends on:
Blocks:
 
Reported: 2006-12-19 22:05 EST by M. Kristall
Modified: 2007-06-04 15:26:51 EDT
0 users

See Also:


Attachments
new level.num*Clients counting (2.95 KB, patch)
2006-12-19 22:12 EST, M. Kristall
level.numConnectedClients -> level.numVotingClients (729 bytes, patch)
2006-12-19 22:19 EST, M. Kristall
updated CalculateRanks patch (3.25 KB, patch)
2007-04-16 01:56 EDT, M. Kristall
fix a couple potential issues (1.17 KB, patch)
2007-05-21 13:52 EDT, M. Kristall

Description M. Kristall 2006-12-19 22:05:36 EST
level.num*Clients (in g_main.c:CalculateRanks) isn't very straight forward and has some bugs, I think. Anyway, I'll put patches related to level.num*Clients here.
Comment 1 M. Kristall 2006-12-19 22:12:38 EST
Created attachment 1205 [details]
new level.num*Clients counting

CalculateRanks
I think this is much more straight forward. It's also about 40% smaller.
Mostly what I did is changed team variables so the various things should be more accurate. I also removed level.follow1 and level.follow2 since they were unused (though, if I understand their purpose, having them working would be really cool).

I still don't like that
if( level.clients[ i ].sess.sessionTeam != TEAM_SPECTATOR )
but when I used
if( level.clients[ i ].pers.classSelection != PCL_NONE )
games would not end as a win on some systems. That rather discouraged me from trying to find another alternative, especially since this seems to work fine.
Comment 2 M. Kristall 2006-12-19 22:19:01 EST
Created attachment 1206 [details]
level.numConnectedClients -> level.numVotingClients

Currently, CheckTeamVote correctly uses level.numteamVotingClients, but CheckVote uses level.numConnectedClients. If we assume level.numConnectedClients != level.numVotingClients (normally spectators can't vote), this is wrong.

Changes level.numConnectedClients to level.numVotingClients in CheckVote.
Comment 3 M. Kristall 2007-04-16 01:56:23 EDT
Created attachment 1307 [details]
updated CalculateRanks patch

It is possible that voting will be changed again in the future (or that someone wants to use their own way to figure out who can vote). Likewise, level.numVotingClients should be used instead of level.numConnectedClients even though they should currently have the same value (as this patch ensures). This patch is updated for the behavior in svn 925 (all connected players can vote) and fixes the level.numConnectedClients count.
Comment 4 Tony J. White 2007-04-24 23:23:26 EDT
added at revision 935.  Thanks.
Comment 5 M. Kristall 2007-05-21 13:52:52 EDT
Created attachment 1354 [details]
fix a couple potential issues

This puts level.numConnectedClients back in the right spot, moves level.numVotingClients so that only players who are fully connected vote, and makes level.numNonSpectatorClients more literal. (It also makes checking if there are players who aren't fully connected as easy as level.numConnectedClients != level.numVotingClients.)

As far as I can tell, the only real issue is that !listplayers reports the wrong number.
Comment 6 M. Kristall 2007-05-21 13:53:39 EDT
Reopening :-(
Comment 7 M. Kristall 2007-06-04 15:26:51 EDT
Committed at revision 943