From 9aeeed4eaa98fc6e3a5454fe9a902e0c91058e27 Mon Sep 17 00:00:00 2001 From: div0 Date: Fri, 25 Jul 2008 17:28:26 +0000 Subject: [PATCH] possibly a LMS fix, possibly major screwage git-svn-id: svn://svn.icculus.org/nexuiz/trunk@3914 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/cl_client.qc | 17 +++-- data/qcsrc/server/clientcommands.qc | 2 - data/qcsrc/server/ctf.qc | 2 +- data/qcsrc/server/domination.qc | 10 ++- data/qcsrc/server/g_damage.qc | 5 +- data/qcsrc/server/g_world.qc | 111 +++++----------------------- data/qcsrc/server/gamecommand.qc | 6 -- data/qcsrc/server/miscfunctions.qc | 40 ---------- data/qcsrc/server/teamplay.qc | 74 ++++++++----------- 9 files changed, 67 insertions(+), 200 deletions(-) diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index bf32fe513..dc1ac8541 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -1,3 +1,6 @@ +// let's abuse an existing field +#define SPAWNPOINT_SCORE frags + .float wantswelcomemessage; .string netname_previous; @@ -77,12 +80,12 @@ entity Spawn_FilterOutBadSpots(entity firstspot, entity playerlist, float mindis for(spot = firstspot; spot; spot = spot.chain) { - spot.frags = Spawn_Score(spot, playerlist, teamcheck); + spot.SPAWNPOINT_SCORE = Spawn_Score(spot, playerlist, teamcheck); if(cvar("spawn_debugview")) { setmodel(spot, "models/runematch/rune.mdl"); - if(spot.frags < mindist) + if(spot.SPAWNPOINT_SCORE < mindist) { spot.colormod = '1 0 0'; spot.scale = 1; @@ -90,13 +93,13 @@ entity Spawn_FilterOutBadSpots(entity firstspot, entity playerlist, float mindis else { spot.colormod = '0 1 0'; - spot.scale = spot.frags / mindist; + spot.scale = spot.SPAWNPOINT_SCORE / mindist; } } - if(spot.frags >= 0) // spawning allowed here + if(spot.SPAWNPOINT_SCORE >= 0) // spawning allowed here { - if(spot.frags < mindist) + if(spot.SPAWNPOINT_SCORE < mindist) { // too short distance spawn_allgood = FALSE; @@ -147,7 +150,7 @@ entity Spawn_WeightedPoint(entity firstspot, float lower, float upper, float exp RandomSelection_Init(); for(spot = firstspot; spot; spot = spot.chain) - RandomSelection_Add(spot, 0, pow(bound(lower, spot.frags, upper), exponent) * spot.cnt, spot.frags >= lower); + RandomSelection_Add(spot, 0, pow(bound(lower, spot.SPAWNPOINT_SCORE, upper), exponent) * spot.cnt, spot.SPAWNPOINT_SCORE >= lower); return RandomSelection_chosen_ent; } @@ -202,7 +205,7 @@ entity SelectSpawnPoint (float anypoint) if(cvar("spawn_debugview")) { - print("spot mindistance: ", ftos(spot.frags), "\n"); + print("spot mindistance: ", ftos(spot.SPAWNPOINT_SCORE), "\n"); entity e; if(teamcheck) diff --git a/data/qcsrc/server/clientcommands.qc b/data/qcsrc/server/clientcommands.qc index 0cf19f572..27460347d 100644 --- a/data/qcsrc/server/clientcommands.qc +++ b/data/qcsrc/server/clientcommands.qc @@ -308,8 +308,6 @@ void SV_ParseClientCommand(string s) { } sprint(self, "\n"); #endif - } else if(argv(0) == "teamstatus") { - PrintScoreboard(self); } else if(argv(0) == "voice") { VoiceMessage(argv(1)); } else if(argv(0) == "say") { diff --git a/data/qcsrc/server/ctf.qc b/data/qcsrc/server/ctf.qc index a31c3219c..59598672b 100644 --- a/data/qcsrc/server/ctf.qc +++ b/data/qcsrc/server/ctf.qc @@ -816,7 +816,7 @@ void(float cteam) ctf_new_commander = if(pl.iscommander) { // don't reassign if alreay there return; } - if(plmax == world || plmax.frags < pl.frags) + if(plmax == world || plmax.frags < pl.frags) <<<<<<<<<<<<<<<<< BROKEN in new scoring system plmax = pl; } } diff --git a/data/qcsrc/server/domination.qc b/data/qcsrc/server/domination.qc index 1dc743e7a..16584c9fb 100644 --- a/data/qcsrc/server/domination.qc +++ b/data/qcsrc/server/domination.qc @@ -15,6 +15,8 @@ dom_init(); Note: The only teams who can use dom control points are identified by spawnfunc_dom_team entities (if none exist these default to red and blue and use only quake models/sounds). */ +#define DOMPOINT_FRAGS frags + void() dom_controlpoint_setup; void LogDom(string mode, float team_before, entity actor) @@ -126,7 +128,7 @@ void dompointthink() { teamfragamt = cvar("g_domination_point_teamamt"); if(!teamfragamt) - teamfragamt = self.frags; + teamfragamt = self.DOMPOINTFRAGS; TeamScore_AddToTeam(self.goalentity.team, ST_DOM_DOMPOINTS, teamfragamt); } @@ -151,7 +153,7 @@ void dompointthink() { individualfragamt = cvar("g_domination_point_amt"); if(!individualfragamt) - individualfragamt = self.frags; + individualfragamt = self.DOMPOINTFRAGS; UpdateFrags(self.enemy, individualfragamt); PlayerScore_Add(self.enemy, SP_DOM_DOMPOINTS, individualfragamt); } @@ -269,8 +271,8 @@ void dom_controlpoint_setup() if(!self.message) self.message = " has captured a control point"; - if(!self.frags) - self.frags = 1; + if(!self.DOMPOINTFRAGS) + self.DOMPOINTFRAGS = 1; if(!self.wait) self.wait = 5; diff --git a/data/qcsrc/server/g_damage.qc b/data/qcsrc/server/g_damage.qc index 7f7f2bac7..b1769dcfe 100644 --- a/data/qcsrc/server/g_damage.qc +++ b/data/qcsrc/server/g_damage.qc @@ -107,6 +107,8 @@ void GiveFrags (entity attacker, entity targ, float f) f = 0; } + attacker.totalfrags += f; + if(f) UpdateFrags(attacker, f); } @@ -465,8 +467,7 @@ void Obituary (entity attacker, entity targ, float deathtype) else bprint ("^1",s, "^1 died\n"); GiveFrags(targ, targ, -1); - // FIXME move this into winning condition checking? or allow READING of the scores? - if(targ.frags == -5) { + if(PlayerScore_Add(targ, SP_SCORE, 0) == -5) { announce(targ, "announcer/male/botlike.ogg"); } diff --git a/data/qcsrc/server/g_world.qc b/data/qcsrc/server/g_world.qc index 68950fbdc..ace032311 100644 --- a/data/qcsrc/server/g_world.qc +++ b/data/qcsrc/server/g_world.qc @@ -47,14 +47,14 @@ void fteqcc_testbugs() else dprint("*** fteqcc test: same-function-twice bug got FINALLY FIXED! HOORAY!\n"); - world.frags = -10; + world.cnt = -10; world.enemy = world; - world.enemy.frags += 10; - if(world.frags > 0.2 || world.frags < -0.2) // don't error out if it's just roundoff errors + world.enemy.cnt += 10; + if(world.cnt > 0.2 || world.cnt < -0.2) // don't error out if it's just roundoff errors dprint("*** fteqcc test: found += bug\n"); else dprint("*** fteqcc test: += bug got FINALLY FIXED! HOORAY!\n"); - world.frags = 0; + world.cnt = 0; } /** @@ -1203,16 +1203,6 @@ void AddWinners(.float field, float value) head.winning = 1; } -// clear frags for all players but the team given (when they ran out of spawnpoints) -void ClearFragsForEveryoneBut(.float field, float value) -{ - // FIXME make this use the new score system (probably not needed any more, can just send this as an event) - entity head; - FOR_EACH_PLAYER(head) - if(head.field != value) - head.frags = max(head.frags, 0); -} - // clear the .winning flags void ClearWinners(void) { @@ -1415,68 +1405,6 @@ void print_to(entity e, string s) ServerConsoleEcho(s, TRUE); } -void PrintScoreboardFor(entity e, string name, string colorcode, float whichteam) -{ - // FIXME kill this, or make it support the new scoring system - entity head; - float v; - float teamvalue; - float fragtotal; - string s; - float found; - found = FALSE; - teamvalue = 0; - FOR_EACH_PLAYER(head) - { - if(!whichteam || head.team == whichteam) - { - if(name != "") - if(!found) - print_to(e, strcat(" ", colorcode, name, ":")); - found = TRUE; - fragtotal = fragtotal + head.frags; - s = ftos(head.frags); - s = strcat(s, "/", ftos(head.deaths)); - s = strcat(s, " @ ", ftos(head.ping)); - if(clienttype(head) == CLIENTTYPE_BOT) - s = strcat(s, "botms"); - else - s = strcat(s, "ms"); - v = PlayerValue(head); - teamvalue += v; - s = strcat(s, " / ", ftos(v)); - print_to(e, strcat(" ", colorcode, head.netname, colorcode, " (", s, ")")); - } - } - if(whichteam && found) - { - s = ftos(fragtotal); - s = strcat(s, " / ", ftos(teamvalue)); - print_to(e, strcat(colorcode, " (total: ", s, ")")); - } -} - -void PrintScoreboard(entity e) -{ - // FIXME kill this, or make it support the new scoring system - print_to(e, strcat("Time: ", ftos(time / 60))); - print_to(e, strcat("Timelimit: ", ftos(cvar("timelimit")))); - print_to(e, strcat("Fraglimit: ", ftos(cvar("fraglimit")))); - print_to(e, "Scoreboard:"); - if(teams_matter) - { - PrintScoreboardFor(e, "Red", "^1", COLOR_TEAM1); - PrintScoreboardFor(e, "Blue", "^4", COLOR_TEAM2); - PrintScoreboardFor(e, "Yellow", "^3", COLOR_TEAM3); - PrintScoreboardFor(e, "Pink", "^6", COLOR_TEAM4); - } - else - { - PrintScoreboardFor(e, "", "^7", 0); - } - print_to(e, "."); -} - void ShuffleMaplist() { string result; @@ -1585,26 +1513,21 @@ float WinningCondition_RanOutOfSpawns() } else if(team1_score + team2_score + team3_score + team4_score == 1) { - if(team1_score) - { - AddWinners(team, COLOR_TEAM1); - ClearFragsForEveryoneBut(team, COLOR_TEAM1); - } - if(team2_score) - { - AddWinners(team, COLOR_TEAM2); - ClearFragsForEveryoneBut(team, COLOR_TEAM2); - } - if(team3_score) - { - AddWinners(team, COLOR_TEAM3); - ClearFragsForEveryoneBut(team, COLOR_TEAM3); - } - if(team4_score) + float t, i; + if(team1_score) t = COLOR_TEAM1; + if(team2_score) t = COLOR_TEAM2; + if(team3_score) t = COLOR_TEAM3; + if(team4_score) t = COLOR_TEAM4; + CheckAllowedTeams(world); + for(i = 0; i < MAX_TEAMSCORE; ++i) { - AddWinners(team, COLOR_TEAM4); - ClearFragsForEveryoneBut(team, COLOR_TEAM4); + if(t != COLOR_TEAM1) if(c1 >= 0) TeamScore_Add(COLOR_TEAM1, i, -1000); + if(t != COLOR_TEAM2) if(c2 >= 0) TeamScore_Add(COLOR_TEAM2, i, -1000); + if(t != COLOR_TEAM3) if(c3 >= 0) TeamScore_Add(COLOR_TEAM3, i, -1000); + if(t != COLOR_TEAM4) if(c4 >= 0) TeamScore_Add(COLOR_TEAM4, i, -1000); } + + AddWinners(team, t); return WINNING_YES; } else diff --git a/data/qcsrc/server/gamecommand.qc b/data/qcsrc/server/gamecommand.qc index b07dd0a34..6d26c1263 100644 --- a/data/qcsrc/server/gamecommand.qc +++ b/data/qcsrc/server/gamecommand.qc @@ -48,12 +48,6 @@ void GameCommand(string command) if(GameCommand_Generic(command)) return; - if(argv(0) == "teamstatus") - { - PrintScoreboard(world); - return; - } - if(argv(0) == "printstats") { DumpStats(FALSE); diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index 3ef74200f..704b7f7d4 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -533,46 +533,6 @@ void backtrace(string msg) cvar_set("developer", ftos(dev)); } -#if 0 -void DistributeFragsAmongTeam(entity p, float targetteam, float factor) -{ - float nTeam; - entity head; - float f; - - if(!teams_matter) - return; - - //if(p.frags < 0) - //{ - // p.frags = 0; // do not harm the new team! - // return; // won't distribute negative scores - //} - - if(p.frags == -666) - return; - - f = ceil(factor * p.frags); - p.frags = p.frags - f; - - nTeam = 0; - FOR_EACH_PLAYER(head) - if(head != p) - if(head.team == targetteam) - nTeam = nTeam + 1; - - if(nTeam == 0) - return; - - DistributeEvenly_Init(f, nTeam); - - FOR_EACH_PLAYER(head) - if(head != p) - if(head.team == targetteam) - head.frags = head.frags + DistributeEvenly_Get(1); -} -#endif - string Team_ColorCode(float teamid) { if(teamid == COLOR_TEAM1) diff --git a/data/qcsrc/server/teamplay.qc b/data/qcsrc/server/teamplay.qc index a7dbd1c1a..191d28060 100644 --- a/data/qcsrc/server/teamplay.qc +++ b/data/qcsrc/server/teamplay.qc @@ -386,27 +386,36 @@ void PrintWelcomeMessage(entity pl) { if(self.classname == "observer") { - // FIXME this is broken for LMS, fix it - if(g_lms && self.frags <= 0 && self.frags > -666) - return centerprint_atprio(self, CENTERPRIO_SPAM, strcat(NEWLINES, "^1You have no more lives left\nwait for next round\n\n\n^7press attack to spectate other players")); - else if(g_lms && self.frags == -666) - return centerprint_atprio(self, CENTERPRIO_SPAM, strcat(NEWLINES, "^1Match has already begun\nwait for next round\n\n\n^7press attack to spectate other players")); + if(g_lms) + { + float p; + p = PlayerScore_Add(self, SP_LMS_PLACE, 0); + if(p >= 666) + return centerprint_atprio(self, CENTERPRIO_SPAM, strcat(NEWLINES, "^1Match has already begun\nwait for next round\n\n\n^7press attack to spectate other players")); + else if(p > 0) + return centerprint_atprio(self, CENTERPRIO_SPAM, strcat(NEWLINES, "^1You have no more lives left\nwait for next round\n\n\n^7press attack to spectate other players")); + } } else if(self.classname == "spectator") { - // FIXME this is broken for LMS, fix it - if ((g_lms && self.frags < 1) || g_arena) - return centerprint_atprio(self, CENTERPRIO_SPAM, strcat(NEWLINES, "spectating ", self.enemy.netname, "\n\n\n^7press attack for next player\npress attack2 for free fly mode")); - else { - local string specString; - specString = strcat(NEWLINES, "spectating ", self.enemy.netname, "\n\n\n^7press jump to play\n^7press attack for next player\npress attack2 for free fly mode"); - - if(time < restart_countdown) //also show the countdown when being a spectator - specString = strcat(specString, "\n\n^1Game starts in ", ftos(restartAnnouncer.cnt + 1), " seconds^7"); - else if (timeoutStatus != 0) - specString = strcat(specString, "\n\n", getTimeoutText(1)); - return centerprint_atprio(self, CENTERPRIO_SPAM, specString); + if(g_lms) + { + float p; + p = PlayerScore_Add(self, SP_LMS_PLACE, 0); + if(p) + return centerprint_atprio(self, CENTERPRIO_SPAM, strcat(NEWLINES, "spectating ", self.enemy.netname, "\n\n\n^7press attack for next player\npress attack2 for free fly mode")); } + if (g_arena) + return centerprint_atprio(self, CENTERPRIO_SPAM, strcat(NEWLINES, "spectating ", self.enemy.netname, "\n\n\n^7press attack for next player\npress attack2 for free fly mode")); + + local string specString; + specString = strcat(NEWLINES, "spectating ", self.enemy.netname, "\n\n\n^7press jump to play\n^7press attack for next player\npress attack2 for free fly mode"); + + if(time < restart_countdown) //also show the countdown when being a spectator + specString = strcat(specString, "\n\n^1Game starts in ", ftos(restartAnnouncer.cnt + 1), " seconds^7"); + else if (timeoutStatus != 0) + specString = strcat(specString, "\n\n", getTimeoutText(1)); + return centerprint_atprio(self, CENTERPRIO_SPAM, specString); } } @@ -1123,25 +1132,24 @@ void ShufflePlayerOutOfTeam (float source_team) lowest_player_score = 999999999; // find the lowest-scoring player & bot of that team - // FIXME this is broken in new scoring system, add a helper to find the worst bot of a team FOR_EACH_PLAYER(head) { if(head.team == steam) { if(head.isbot) { - if(head.frags < lowest_bot_score) + if(head.totalfrags < lowest_bot_score) { lowest_bot = head; - lowest_bot_score = head.frags; + lowest_bot_score = head.totalfrags; } } else { - if(head.frags < lowest_player_score) + if(head.totalfrags < lowest_player_score) { lowest_player = head; - lowest_player_score = head.frags; + lowest_player_score = head.totalfrags; } } } @@ -1326,28 +1334,6 @@ void AuditTeams() -/*void UpdateTeamScore(entity e, float first) -{ - clientno = e.FIXME; - if(first) - { - WriteByte (MSG_ALL, SVC_UPDATENAME); - WriteByte (MSG_ALL, clientno); - WriteString (MSG_ALL, e.netname); - - WriteByte (MSG_ALL, SVC_UPDATECOLORS); - WriteByte (MSG_ALL, clientno); - WriteByte (MSG_ALL, e.b_shirt * 16 + who.b_pants); - } - - WriteByte (MSG_ALL, SVC_UPDATEFRAGS); - WriteByte (MSG_ALL, clientno); - WriteShort (MSG_ALL, e.frags + 10000); -}; - -*/ - - // code from here on is just to support maps that don't have team entities void tdm_spawnteam (string teamname, float teamcolor) { -- 2.39.2