From 902cae9438642eaef516a9509d02476345f34018 Mon Sep 17 00:00:00 2001 From: fruitiex Date: Wed, 2 Dec 2009 21:42:34 +0000 Subject: [PATCH] bugfix: defrag compat now works with defrag maps that have 0 checkpoints git-svn-id: svn://svn.icculus.org/nexuiz/trunk@8360 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/race.qc | 47 ++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/data/qcsrc/server/race.qc b/data/qcsrc/server/race.qc index 4f8e4caaa..7fcf5e255 100644 --- a/data/qcsrc/server/race.qc +++ b/data/qcsrc/server/race.qc @@ -375,27 +375,38 @@ void checkpoint_passed() other.porto_forbidden = 2; // decreased by 1 each StartFrame - if(self.race_checkpoint == -2) - { - self.race_checkpoint = other.race_checkpoint; - } - - entity cp; - float largest_cp_id; - for(cp = world; (cp = find(cp, classname, "target_checkpoint"));) - if(cp.race_checkpoint > largest_cp_id) // update the finish id if someone hit a new checkpoint + if(defrag_ents) { + if(self.race_checkpoint == -2) { - largest_cp_id = cp.race_checkpoint; - for(cp = world; (cp = find(cp, classname, "target_stopTimer"));) - cp.race_checkpoint = largest_cp_id + 1; // finish line - race_highest_checkpoint = largest_cp_id + 1; - race_timed_checkpoint = largest_cp_id + 1; + self.race_checkpoint = other.race_checkpoint; + } - for(cp = world; (cp = find(cp, classname, "target_checkpoint"));) { - if(cp.race_checkpoint == -2) // set defragcpexists to -1 so that the cp id file will be rewritten when someone finishes - defragcpexists = -1; - } + entity cp; + float largest_cp_id; + float cp_amount; + 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 + { + largest_cp_id = cp.race_checkpoint; + for(cp = world; (cp = find(cp, classname, "target_stopTimer"));) + cp.race_checkpoint = largest_cp_id + 1; // finish line + race_highest_checkpoint = largest_cp_id + 1; + race_timed_checkpoint = largest_cp_id + 1; + + for(cp = world; (cp = find(cp, classname, "target_checkpoint"));) { + if(cp.race_checkpoint == -2) // set defragcpexists to -1 so that the cp id file will be rewritten when someone finishes + defragcpexists = -1; + } + } + } + if(cp_amount == 0) { + for(cp = world; (cp = find(cp, classname, "target_stopTimer"));) + cp.race_checkpoint = 1; + race_highest_checkpoint = 1; + race_timed_checkpoint = 1; } + } if(other.race_checkpoint == -1 || other.race_checkpoint == self.race_checkpoint) { -- 2.39.2