X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Frace.qc;h=6ec8a68e4935cbd9ce7f6ee35e68b90f1f8eb401;hb=02a0bd5bf9eefad8c97b93c8a1c2ea47b3c1f553;hp=911106a30560358e6ae03054ab21526dc0e6ad8a;hpb=d9708336de4c01e81ea08bb205093b676b7cb882;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index 911106a30..6ec8a68e4 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -141,6 +141,7 @@ void race_setTime(string map, float t, string myuid, string mynetname, entity e) newpos = race_readPos(map, t); float i; + player_prevpos = 0; for(i = 1; i <= RANKINGS_CNT; ++i) { if(race_readUID(map, i) == myuid) @@ -148,20 +149,17 @@ void race_setTime(string map, float t, string myuid, string mynetname, entity e) } float oldrec; - string recorddifference, oldrec_holder; + string oldrec_holder; if (player_prevpos && (player_prevpos < newpos || !newpos)) { oldrec = race_readTime(GetMapname(), player_prevpos); - recorddifference = strcat(" ^1[+", TIME_ENCODED_TOSTRING(t - oldrec), "]"); - bprint(mynetname, "^7 couldn't break their ", race_placeName(player_prevpos), " place record of ", TIME_ENCODED_TOSTRING(oldrec), recorddifference, "\n"); race_SendStatus(0, e); // "fail" - Send_KillNotification(e.netname, TIME_ENCODED_TOSTRING(t), "", RACE_FAIL, MSG_RACE); + Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_FAIL_RANKED, mynetname, player_prevpos, t, oldrec); return; } else if (!newpos) { // no ranking, time worse than the worst ranked - recorddifference = strcat(" ^1[+", TIME_ENCODED_TOSTRING(t - race_readTime(GetMapname(), RANKINGS_CNT)), "]"); - bprint(mynetname, "^7 couldn't break the ", race_placeName(RANKINGS_CNT), " place record of ", TIME_ENCODED_TOSTRING(race_readTime(GetMapname(), RANKINGS_CNT)), recorddifference, "\n"); + oldrec = race_readTime(GetMapname(), RANKINGS_CNT); race_SendStatus(0, e); // "fail" - Send_KillNotification(e.netname, TIME_ENCODED_TOSTRING(t), "", RACE_FAIL, MSG_RACE); + Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_FAIL_UNRANKED, mynetname, RANKINGS_CNT, t, oldrec); return; } @@ -170,7 +168,7 @@ void race_setTime(string map, float t, string myuid, string mynetname, entity e) // if the player does not have a UID we can unfortunately not store the record, as the rankings system relies on UIDs if(myuid == "") { - bprint(mynetname, "^1 scored a new record with ^7", TIME_ENCODED_TOSTRING(t), "^1, but lacks a UID, so the record will unfortunately be lost.\n"); + Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_NEW_MISSING_UID, mynetname, t); return; } @@ -189,34 +187,24 @@ void race_setTime(string map, float t, string myuid, string mynetname, entity e) if(rankings_reply) strunzone(rankings_reply); rankings_reply = strzone(getrankings()); - if(newpos == 1) { - if(newpos == player_prevpos) { - recorddifference = strcat(" ^2[-", TIME_ENCODED_TOSTRING(oldrec - t), "]"); - bprint(mynetname, "^1 improved their 1st place record with ", TIME_ENCODED_TOSTRING(t), recorddifference, "\n"); - } else if (oldrec == 0) { - bprint(mynetname, "^1 set the 1st place record with ", TIME_ENCODED_TOSTRING(t), "\n"); - } else { - recorddifference = strcat(" ^2[-", TIME_ENCODED_TOSTRING(oldrec - t), "]"); - bprint(mynetname, "^1 broke ", oldrec_holder, "^1's 1st place record with ", strcat(TIME_ENCODED_TOSTRING(t), recorddifference, "\n")); - } - race_SendStatus(3, e); // "new server record" - Send_KillNotification(e.netname, TIME_ENCODED_TOSTRING(t), "", RACE_SERVER_RECORD, MSG_RACE); - } else { - if(newpos == player_prevpos) { - recorddifference = strcat(" ^2[-", TIME_ENCODED_TOSTRING(oldrec - t), "]"); - bprint(mynetname, "^5 improved their ", race_placeName(newpos), " ^5place record with ", TIME_ENCODED_TOSTRING(t), recorddifference, "\n"); - race_SendStatus(1, e); // "new time" - Send_KillNotification(e.netname, TIME_ENCODED_TOSTRING(t), "", RACE_NEW_TIME, MSG_RACE); - } else if (oldrec == 0) { - bprint(mynetname, "^2 set the ", race_placeName(newpos), " ^2place record with ", TIME_ENCODED_TOSTRING(t), "\n"); - race_SendStatus(2, e); // "new rank" - Send_KillNotification(e.netname, TIME_ENCODED_TOSTRING(t), "", RACE_NEW_RANK, MSG_RACE); - } else { - recorddifference = strcat(" ^2[-", TIME_ENCODED_TOSTRING(oldrec - t), "]"); - bprint(mynetname, "^2 broke ", oldrec_holder, "^2's ", race_placeName(newpos), " ^2place record with ", strcat(TIME_ENCODED_TOSTRING(t), recorddifference, "\n")); - race_SendStatus(2, e); // "new rank" - Send_KillNotification(e.netname, TIME_ENCODED_TOSTRING(t), "", RACE_NEW_TIME, MSG_RACE); - } + + if(newpos == player_prevpos) + { + Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_NEW_IMPROVED, mynetname, newpos, t, oldrec); + if(newpos == 1) { race_SendStatus(3, e); } // "new server record" + else { race_SendStatus(1, e); } // "new time" + } + else if(oldrec == 0) + { + Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_NEW_SET, mynetname, newpos, t); + if(newpos == 1) { race_SendStatus(3, e); } // "new server record" + else { race_SendStatus(2, e); } // "new rank" + } + else + { + Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_NEW_BROKEN, mynetname, oldrec_holder, newpos, t, oldrec); + if(newpos == 1) { race_SendStatus(3, e); } // "new server record" + else { race_SendStatus(2, e); } // "new rank" } } @@ -272,6 +260,10 @@ void race_SendTime(entity e, float cp, float t, float tvalid) } else { + s = PlayerScore_Add(e, SP_RACE_FASTEST, 0); + if(!s || t < s) + PlayerScore_Add(e, SP_RACE_FASTEST, t - s); + s = PlayerScore_Add(e, SP_RACE_TIME, 0); snew = TIME_ENCODE(time - game_starttime); PlayerScore_Add(e, SP_RACE_TIME, snew - s); @@ -285,7 +277,7 @@ void race_SendTime(entity e, float cp, float t, float tvalid) { e.race_completed = 1; MAKE_INDEPENDENT_PLAYER(e); - bprint(e.netname, "^7 has finished the race.\n"); + Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_FINISHED, e.netname); ClientData_Touch(e); } } @@ -490,8 +482,8 @@ void checkpoint_passed() self.race_checkpoint = other.race_checkpoint; } - float largest_cp_id; - float cp_amount; + float largest_cp_id = 0; + float cp_amount = 0; for(cp = world; (cp = find(cp, classname, "target_checkpoint"));) { cp_amount += 1; if(cp.race_checkpoint > largest_cp_id) // update the finish id if someone hit a new checkpoint @@ -664,7 +656,7 @@ void trigger_race_checkpoint_verify() g_race_qualifying = 1; self.race_place = race_lowest_place_spawn; if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, FALSE)) - error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for qualifying) - bailing out")); + error(strcat("Checkpoint 0 misses a spawnpoint with race_place==", ftos(self.race_place), " (used for qualifying) - bailing out")); } else { @@ -710,7 +702,7 @@ void trigger_race_checkpoint_verify() } if(defragcpexists != -1){ - float largest_cp_id; + float largest_cp_id = 0; for(cp = world; (cp = find(cp, classname, "target_checkpoint"));) if(cp.race_checkpoint > largest_cp_id) largest_cp_id = cp.race_checkpoint; @@ -816,11 +808,11 @@ void spawnfunc_trigger_race_checkpoint() waypoint_spawnforitem_force(self, trace_endpos); self.nearestwaypointtimeout = time + 1000000000; - if(!self.message) + if(self.message == "") self.message = "went backwards"; - if (!self.message2) + if (self.message2 == "") self.message2 = "was pushed backwards by"; - if (!self.race_penalty_reason) + if (self.race_penalty_reason == "") self.race_penalty_reason = "missing a checkpoint"; self.race_checkpoint = self.cnt; @@ -869,11 +861,11 @@ void spawnfunc_target_checkpoint() // defrag entity waypoint_spawnforitem_force(self, trace_endpos); self.nearestwaypointtimeout = time + 1000000000; - if(!self.message) + if(self.message == "") self.message = "went backwards"; - if (!self.message2) + if (self.message2 == "") self.message2 = "was pushed backwards by"; - if (!self.race_penalty_reason) + if (self.race_penalty_reason == "") self.race_penalty_reason = "missing a checkpoint"; if(self.classname == "target_startTimer") @@ -902,7 +894,7 @@ void race_AbandonRaceCheck(entity p) { p.race_completed = 1; MAKE_INDEPENDENT_PLAYER(p); - bprint(p.netname, "^7 has abandoned the race.\n"); + Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_ABANDONED, p.netname); ClientData_Touch(p); } } @@ -1025,7 +1017,7 @@ void race_ReadyRestart() Score_NicePrint(world); race_ClearRecords(); - PlayerScore_Sort(race_place); + PlayerScore_Sort(race_place, 0, 1, 0); entity e; FOR_EACH_CLIENT(e) @@ -1101,7 +1093,7 @@ void spawnfunc_trigger_race_penalty() if not(self.spawnflags & 1) self.touch = penalty_touch; - if (!self.race_penalty_reason) + if (self.race_penalty_reason == "") self.race_penalty_reason = "missing a checkpoint"; if (!self.race_penalty) self.race_penalty = 5;