1 #define MAX_CHECKPOINTS 255
4 .float race_penalty_accumulator;
5 .string race_penalty_reason;
6 .float race_checkpoint; // player: next checkpoint that has to be reached
8 .entity race_lastpenalty;
12 float race_checkpoint_records[MAX_CHECKPOINTS];
13 string race_checkpoint_recordholders[MAX_CHECKPOINTS];
14 float race_checkpoint_lasttimes[MAX_CHECKPOINTS];
15 float race_checkpoint_lastlaps[MAX_CHECKPOINTS];
16 entity race_checkpoint_lastplayers[MAX_CHECKPOINTS];
18 float race_highest_checkpoint;
19 float race_timed_checkpoint;
24 float race_NextCheckpoint(float f)
26 if(f >= race_highest_checkpoint)
32 float race_PreviousCheckpoint(float f)
37 return race_highest_checkpoint;
43 // 0 = common start/finish
46 float race_CheckpointNetworkID(float f)
48 if(race_timed_checkpoint)
52 else if(f == race_timed_checkpoint)
58 void race_SendNextCheckpoint(entity e, float spec) // qualifying only
67 cp = e.race_checkpoint;
68 recordtime = race_checkpoint_records[cp];
69 recordholder = race_checkpoint_recordholders[cp];
70 if(recordholder == e.netname)
75 WRITESPECTATABLE_MSG_ONE({
76 WriteByte(MSG_ONE, SVC_TEMPENTITY);
77 WriteByte(MSG_ONE, TE_CSQC_RACE);
80 WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING);
81 //WriteCoord(MSG_ONE, e.race_laptime - e.race_penalty_accumulator);
82 WriteCoord(MSG_ONE, time - e.race_movetime - e.race_penalty_accumulator);
85 WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_NEXT_QUALIFYING);
86 WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player will be at next
87 WriteInt24_t(MSG_ONE, recordtime);
88 WriteString(MSG_ONE, recordholder);
92 void race_InitSpectator()
95 if(msg_entity.enemy.race_laptime)
96 race_SendNextCheckpoint(msg_entity.enemy, 1);
99 void race_send_recordtime(float t, float msg)
101 // send the server best time
102 WriteByte(msg, SVC_TEMPENTITY);
103 WriteByte(msg, TE_CSQC_RACE);
104 WriteByte(msg, RACE_NET_SERVER_RECORD);
105 WriteInt24_t(msg, t);
108 void race_SendTime(entity e, float cp, float t, float tvalid)
113 if(g_race_qualifying)
114 t += e.race_penalty_accumulator;
116 t = TIME_ENCODE(t); // make integer
117 // adding just 0.4 so it rounds down in the .5 case (matching the timer display)
120 if(cp == race_timed_checkpoint) // finish line
121 if not(e.race_completed)
124 if(g_race_qualifying)
126 s = PlayerScore_Add(e, SP_RACE_FASTEST, 0);
128 PlayerScore_Add(e, SP_RACE_FASTEST, t - s);
132 s = PlayerScore_Add(e, SP_RACE_TIME, 0);
133 snew = TIME_ENCODE(time - game_starttime);
134 PlayerScore_Add(e, SP_RACE_TIME, snew - s);
135 l = PlayerTeamScore_Add(e, SP_RACE_LAPS, ST_RACE_LAPS, 1);
137 if(cvar("fraglimit"))
138 if(l >= cvar("fraglimit"))
139 race_StartCompleting();
143 e.race_completed = 1;
144 MAKE_INDEPENDENT_PLAYER(e);
145 bprint(e.netname, "^7 has finished the race.\n");
153 if(g_race_qualifying)
157 recordtime = race_checkpoint_records[cp];
158 recordholder = strcat1(race_checkpoint_recordholders[cp]); // make a tempstring copy, as we'll possibly strunzone it!
159 if(recordholder == e.netname)
163 if(t < recordtime || recordtime == 0)
165 race_checkpoint_records[cp] = t;
166 if(race_checkpoint_recordholders[cp])
167 strunzone(race_checkpoint_recordholders[cp]);
168 race_checkpoint_recordholders[cp] = strzone(e.netname);
169 if(cp == race_timed_checkpoint)
172 string grecordholder, recorddifference;
178 grecordtime = stof(db_get(ServerProgsDB, strcat(GetMapname(), rr, "time")));
179 grecordholder = db_get(ServerProgsDB, strcat(GetMapname(), rr, "netname"));
180 if(grecordholder == e.netname)
184 bprint(e.netname, "^7 set the all-time fastest lap record with ", TIME_ENCODED_TOSTRING(t), "\n");
185 db_put(ServerProgsDB, strcat(GetMapname(), rr, "time"), ftos(t));
186 db_put(ServerProgsDB, strcat(GetMapname(), rr, "netname"), e.netname);
187 write_recordmarker(e, time - TIME_DECODE(t), TIME_DECODE(t));
188 race_send_recordtime(t, MSG_ALL);
190 else if(t < grecordtime)
192 recorddifference = strcat("^2", " [-", TIME_ENCODED_TOSTRING(grecordtime-t), "]");
193 if(grecordholder == "")
194 bprint(e.netname, strcat("^7 broke their all-time fastest lap record ", TIME_ENCODED_TOSTRING(grecordtime), " with ", TIME_ENCODED_TOSTRING(t), recorddifference), "\n");
196 bprint(e.netname, strcat("^7 broke ", grecordholder, "^7's all-time fastest lap record ", TIME_ENCODED_TOSTRING(grecordtime), " with ", TIME_ENCODED_TOSTRING(t), recorddifference), "\n");
197 db_put(ServerProgsDB, strcat(GetMapname(), rr, "time"), ftos(t));
198 db_put(ServerProgsDB, strcat(GetMapname(), rr, "netname"), e.netname);
199 write_recordmarker(e, time - TIME_DECODE(t), TIME_DECODE(t));
200 race_send_recordtime(t, MSG_ALL);
204 recorddifference = strcat("^1", " [+", TIME_ENCODED_TOSTRING(t-grecordtime), "]");
205 if(grecordholder == "")
206 bprint(e.netname, strcat("^7's new fastest lap ", TIME_ENCODED_TOSTRING(t), " could not break their all-time fastest lap record of ", TIME_ENCODED_TOSTRING(grecordtime), recorddifference), "\n");
208 bprint(e.netname, strcat("^7's new fastest lap ", TIME_ENCODED_TOSTRING(t), " could not break ", grecordholder, "^7's all-time fastest lap record of ", TIME_ENCODED_TOSTRING(grecordtime), recorddifference), "\n");
212 if(g_race_qualifying)
214 FOR_EACH_REALPLAYER(p)
215 if(p.race_checkpoint == cp)
216 race_SendNextCheckpoint(p, 0);
229 if(g_race_qualifying)
231 WRITESPECTATABLE_MSG_ONE_VARNAME(dummy1, {
232 WriteByte(MSG_ONE, SVC_TEMPENTITY);
233 WriteByte(MSG_ONE, TE_CSQC_RACE);
234 WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_HIT_QUALIFYING);
235 WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player now is at
236 WriteInt24_t(MSG_ONE, t); // time to that intermediate
237 WriteInt24_t(MSG_ONE, recordtime); // previously best time
238 WriteString(MSG_ONE, recordholder); // record holder
242 else // RACE! Not Qualifying
244 float lself, lother, othtime;
246 oth = race_checkpoint_lastplayers[cp];
249 lself = PlayerScore_Add(e, SP_RACE_LAPS, 0);
250 lother = race_checkpoint_lastlaps[cp];
251 othtime = race_checkpoint_lasttimes[cp];
254 lself = lother = othtime = 0;
257 WRITESPECTATABLE_MSG_ONE_VARNAME(dummy2, {
258 WriteByte(MSG_ONE, SVC_TEMPENTITY);
259 WriteByte(MSG_ONE, TE_CSQC_RACE);
260 WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_HIT_RACE);
261 WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player now is at
264 WriteInt24_t(MSG_ONE, 0);
265 WriteByte(MSG_ONE, 0);
266 WriteString(MSG_ONE, "");
270 WriteInt24_t(MSG_ONE, TIME_ENCODE(time - race_checkpoint_lasttimes[cp]));
271 WriteByte(MSG_ONE, lself - lother);
272 WriteString(MSG_ONE, oth.netname); // record holder
276 race_checkpoint_lastplayers[cp] = e;
277 race_checkpoint_lasttimes[cp] = time;
278 race_checkpoint_lastlaps[cp] = lself;
281 WRITESPECTATABLE_MSG_ONE_VARNAME(dummy3, {
282 WriteByte(MSG_ONE, SVC_TEMPENTITY);
283 WriteByte(MSG_ONE, TE_CSQC_RACE);
284 WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT);
285 WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player now is at
288 WriteInt24_t(MSG_ONE, 0);
289 WriteByte(MSG_ONE, 0);
290 WriteString(MSG_ONE, "");
294 WriteInt24_t(MSG_ONE, TIME_ENCODE(time - othtime));
295 WriteByte(MSG_ONE, lother - lself);
296 WriteString(MSG_ONE, e.netname); // record holder
302 void race_ClearTime(entity e)
304 e.race_checkpoint = -1;
306 e.race_movetime = e.race_movetime_frac = e.race_movetime_count = 0;
307 e.race_penalty_accumulator = 0;
308 e.race_lastpenalty = world;
311 WRITESPECTATABLE_MSG_ONE({
312 WriteByte(MSG_ONE, SVC_TEMPENTITY);
313 WriteByte(MSG_ONE, TE_CSQC_RACE);
314 WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_CLEAR); // next
318 void dumpsurface(entity e)
322 print("Surfaces of ", etos(e), ":\n");
324 print("TEST = ", ftos(getsurfacenearpoint(e, '0 0 0')), "\n");
328 n = getsurfacenumpoints(e, si);
331 print(" Surface ", ftos(si), ":\n");
332 norm = getsurfacenormal(e, si);
333 print(" Normal = ", vtos(norm), "\n");
334 for(ni = 0; ni < n; ++ni)
336 vec = getsurfacepoint(e, si, ni);
337 print(" Point ", ftos(ni), " = ", vtos(vec), " (", ftos(norm * vec), ")\n");
342 void checkpoint_passed()
347 if(other.classname == "porto")
349 // do not allow portalling through checkpoints
350 trace_plane_normal = normalize(-1 * other.velocity);
359 if not((self.spawnflags & 2) && (other.classname == "player"))
362 oldmsg = self.message;
365 self.message = oldmsg;
368 if(other.classname != "player")
372 * Remove unauthorized equipment
374 Portal_ClearAll(other);
376 other.porto_forbidden = 2; // decreased by 1 each StartFrame
379 if(self.race_checkpoint == -2)
381 self.race_checkpoint = other.race_checkpoint;
386 for(cp = world; (cp = find(cp, classname, "target_checkpoint"));) {
388 if(cp.race_checkpoint > largest_cp_id) // update the finish id if someone hit a new checkpoint
390 largest_cp_id = cp.race_checkpoint;
391 for(cp = world; (cp = find(cp, classname, "target_stopTimer"));)
392 cp.race_checkpoint = largest_cp_id + 1; // finish line
393 race_highest_checkpoint = largest_cp_id + 1;
394 race_timed_checkpoint = largest_cp_id + 1;
396 for(cp = world; (cp = find(cp, classname, "target_checkpoint"));) {
397 if(cp.race_checkpoint == -2) // set defragcpexists to -1 so that the cp id file will be rewritten when someone finishes
403 for(cp = world; (cp = find(cp, classname, "target_stopTimer"));)
404 cp.race_checkpoint = 1;
405 race_highest_checkpoint = 1;
406 race_timed_checkpoint = 1;
410 if((other.race_checkpoint == -1 && self.race_checkpoint == 0) || (other.race_checkpoint == self.race_checkpoint))
412 // once he has seen the start, he can spawn normally at place-0 spawns
413 other.race_started = 1;
415 if(self.race_penalty)
417 if(other.race_lastpenalty != self)
419 other.race_lastpenalty = self;
420 race_ImposePenaltyTime(other, self.race_penalty, self.race_penalty_reason);
424 if(other.race_penalty)
430 if(self.spawnflags & 2)
433 oldmsg = self.message;
436 self.message = oldmsg;
439 if(other.race_respawn_checkpoint != self.race_checkpoint)
440 other.race_respawn_spotref = self; // this is not a spot but a CP, but spawnpoint selection will deal with that
441 other.race_respawn_checkpoint = self.race_checkpoint;
442 other.race_checkpoint = race_NextCheckpoint(self.race_checkpoint);
444 race_SendTime(other, self.race_checkpoint, other.race_movetime, !!other.race_laptime);
446 if(!self.race_checkpoint) // start line
448 other.race_laptime = time;
449 other.race_movetime = other.race_movetime_frac = other.race_movetime_count = 0;
450 other.race_penalty_accumulator = 0;
451 other.race_lastpenalty = world;
454 if(g_race_qualifying)
455 race_SendNextCheckpoint(other, 0);
457 if(defrag_ents && defragcpexists < 0 && self.classname == "target_stopTimer")
460 defragcpexists = fh = fopen(strcat("maps/", GetMapname(), ".defragcp"), FILE_WRITE);
463 for(cp = world; (cp = find(cp, classname, "target_checkpoint"));)
464 fputs(fh, strcat(cp.targetname, " ", ftos(cp.race_checkpoint), "\n"));
469 else if(other.race_checkpoint == race_NextCheckpoint(self.race_checkpoint))
475 if(self.spawnflags & 4)
476 Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
480 void checkpoint_touch()
486 void checkpoint_use()
488 if(other.classname == "info_player_deathmatch") // a spawn, a spawn
495 float race_waypointsprite_visible_for_player(entity e)
497 if(e.race_checkpoint == -1 || e.race_checkpoint == -2)
499 else if(e.race_checkpoint == self.owner.race_checkpoint)
506 void trigger_race_checkpoint_verify()
516 qual = g_race_qualifying;
520 self.classname = "player";
524 for(i = 0; i <= race_highest_checkpoint; ++i)
526 self.race_checkpoint = race_NextCheckpoint(i);
528 // race only (middle of the race)
529 g_race_qualifying = 0;
531 if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), world, 0, FALSE, FALSE))
532 error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for respawning in race) - bailing out"));
537 g_race_qualifying = 1;
538 self.race_place = race_lowest_place_spawn;
539 if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), world, 0, FALSE, FALSE))
540 error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for qualifying) - bailing out"));
542 // race only (initial spawn)
543 g_race_qualifying = 0;
544 for(p = 1; p <= race_highest_place_spawn; ++p)
547 if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), world, 0, FALSE, FALSE))
548 error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for initially spawning in race) - bailing out"));
553 else if(!defrag_ents)
556 self.race_checkpoint = race_NextCheckpoint(0);
557 g_race_qualifying = 1;
558 self.race_place = race_lowest_place_spawn;
559 if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), world, 0, FALSE, FALSE))
560 error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for qualifying) - bailing out"));
564 self.race_checkpoint = race_NextCheckpoint(0);
565 g_race_qualifying = 1;
566 self.race_place = 0; // there's only one spawn on defrag maps
568 // check if a defragcp file already exists, then read it and apply the checkpoint order
573 defragcpexists = fh = fopen(strcat("maps/", GetMapname(), ".defragcp"), FILE_READ);
576 while((l = fgets(fh)))
578 len = tokenize_console(l);
580 defragcpexists = -1; // something's wrong in the defrag cp file, set defragcpexists to -1 so that it will be rewritten when someone finishes
583 for(cp = world; (cp = find(cp, classname, "target_checkpoint"));)
584 if(argv(0) == cp.targetname)
585 cp.race_checkpoint = stof(argv(1));
591 g_race_qualifying = qual;
593 if(race_timed_checkpoint) {
595 for(cp = world; (cp = find(cp, classname, "target_startTimer"));)
596 WaypointSprite_UpdateSprites(cp.sprite, "race-start", "", "");
597 for(cp = world; (cp = find(cp, classname, "target_stopTimer"));)
598 WaypointSprite_UpdateSprites(cp.sprite, "race-finish", "", "");
600 for(cp = world; (cp = find(cp, classname, "target_checkpoint"));) {
601 if(cp.race_checkpoint == -2) // something's wrong with the defrag cp file or it has not been written yet, set defragcpexists to -1 so that it will be rewritten when someone finishes
605 if(defragcpexists != -1){
607 for(cp = world; (cp = find(cp, classname, "target_checkpoint"));)
608 if(cp.race_checkpoint > largest_cp_id)
609 largest_cp_id = cp.race_checkpoint;
610 for(cp = world; (cp = find(cp, classname, "target_stopTimer"));)
611 cp.race_checkpoint = largest_cp_id + 1; // finish line
612 race_highest_checkpoint = largest_cp_id + 1;
613 race_timed_checkpoint = largest_cp_id + 1;
615 for(cp = world; (cp = find(cp, classname, "target_stopTimer"));)
616 cp.race_checkpoint = 255; // finish line
617 race_highest_checkpoint = 255;
618 race_timed_checkpoint = 255;
621 for(targ = world; (targ = find(targ, target, self.targetname)); )
622 if (targ.classname == "trigger_multiple") {
623 targ.wait = -2; // still needs investigating, why cant two players pass a (defrag) checkpoint at the same time?
628 for(cp = world; (cp = find(cp, classname, "trigger_race_checkpoint")); )
631 if(cp.race_checkpoint == 0)
632 WaypointSprite_UpdateSprites(cp.sprite, "race-start", "", "");
633 else if(cp.race_checkpoint == race_timed_checkpoint)
634 WaypointSprite_UpdateSprites(cp.sprite, "race-finish", "", "");
643 void spawnfunc_trigger_race_checkpoint()
646 if(!g_race && !g_cts)
654 self.use = checkpoint_use;
655 if not(self.spawnflags & 1)
656 self.touch = checkpoint_touch;
658 o = (self.absmin + self.absmax) * 0.5;
659 tracebox(o, PL_MIN, PL_MAX, o - '0 0 1' * (o_z - self.absmin_z), MOVE_NORMAL, self);
660 waypoint_spawnforitem_force(self, trace_endpos);
661 self.nearestwaypointtimeout = time + 1000000000;
664 self.message = "went backwards";
666 self.message2 = "was pushed backwards by";
667 if (!self.race_penalty_reason)
668 self.race_penalty_reason = "missing a checkpoint";
670 self.race_checkpoint = self.cnt;
672 if(self.race_checkpoint > race_highest_checkpoint)
674 race_highest_checkpoint = self.race_checkpoint;
675 if(self.spawnflags & 8)
676 race_timed_checkpoint = self.race_checkpoint;
678 race_timed_checkpoint = 0;
681 if(!self.race_penalty)
683 if(self.race_checkpoint)
684 WaypointSprite_SpawnFixed("race-checkpoint", o, self, sprite);
686 WaypointSprite_SpawnFixed("race-finish", o, self, sprite);
689 self.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
691 InitializeEntity(self, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
694 void spawnfunc_target_checkpoint() // defrag entity
697 if(!g_race && !g_cts)
706 self.use = checkpoint_use;
707 //if not(self.spawnflags & 1)
708 // self.touch = checkpoint_touch;
710 o = (self.absmin + self.absmax) * 0.5;
711 tracebox(o, PL_MIN, PL_MAX, o - '0 0 1' * (o_z - self.absmin_z), MOVE_NORMAL, self);
712 waypoint_spawnforitem_force(self, trace_endpos);
713 self.nearestwaypointtimeout = time + 1000000000;
716 self.message = "went backwards";
718 self.message2 = "was pushed backwards by";
719 if (!self.race_penalty_reason)
720 self.race_penalty_reason = "missing a checkpoint";
722 if(self.classname == "target_startTimer")
723 self.race_checkpoint = 0;
725 self.race_checkpoint = -2;
727 race_timed_checkpoint = 1;
729 if(self.race_checkpoint == 0)
730 WaypointSprite_SpawnFixed("race-start", o, self, sprite);
732 WaypointSprite_SpawnFixed("race-checkpoint", o, self, sprite);
734 self.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
736 InitializeEntity(self, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
739 void spawnfunc_target_startTimer() { spawnfunc_target_checkpoint(); }
740 void spawnfunc_target_stopTimer() { spawnfunc_target_checkpoint(); }
742 void race_AbandonRaceCheck(entity p)
744 if(race_completing && !p.race_completed)
746 p.race_completed = 1;
747 MAKE_INDEPENDENT_PLAYER(p);
748 bprint(p.netname, "^7 has abandoned the race.\n");
753 void race_StartCompleting()
758 if(p.deadflag != DEAD_NO)
759 race_AbandonRaceCheck(p);
762 void race_PreparePlayer()
764 race_ClearTime(self);
766 self.race_started = 0;
767 self.race_respawn_checkpoint = -1;
768 self.race_respawn_spotref = world;
771 void race_RetractPlayer()
773 if(!g_race && !g_cts)
775 if(self.race_respawn_checkpoint == 0 || self.race_respawn_checkpoint == -1 || self.race_respawn_checkpoint == race_timed_checkpoint)
776 race_ClearTime(self);
777 self.race_checkpoint = self.race_respawn_checkpoint;
782 if(!g_race && !g_cts)
785 race_AbandonRaceCheck(self);
790 if(!g_race && !g_cts)
792 if(self.killcount == -666 /* initial spawn */ || g_race_qualifying) // spawn
793 race_PreparePlayer();
795 race_RetractPlayer();
797 race_AbandonRaceCheck(self);
800 void race_PostSpawn(entity spot)
802 if(!g_race && !g_cts)
805 if(spot.target == "")
806 // Emergency: this wasn't a real spawnpoint. Can this ever happen?
807 race_PreparePlayer();
809 // if we need to respawn, do it right
810 self.race_respawn_checkpoint = self.race_checkpoint;
811 self.race_respawn_spotref = spot;
816 void race_PreSpawnObserver()
818 if(!g_race && !g_cts)
820 race_PreparePlayer();
823 void spawnfunc_info_player_race (void)
825 if(!g_race && !g_cts)
831 spawnfunc_info_player_deathmatch();
833 if(self.race_place > race_highest_place_spawn)
834 race_highest_place_spawn = self.race_place;
835 if(self.race_place < race_lowest_place_spawn)
836 race_lowest_place_spawn = self.race_place;
839 void race_ClearRecords()
844 for(i = 0; i < MAX_CHECKPOINTS; ++i)
846 race_checkpoint_records[i] = 0;
847 if(race_checkpoint_recordholders[i])
848 strunzone(race_checkpoint_recordholders[i]);
849 race_checkpoint_recordholders[i] = string_null;
853 FOR_EACH_CLIENT(self)
857 race_PreparePlayer();
863 void race_ReadyRestart()
867 Score_NicePrint(world);
870 PlayerScore_Sort(race_place);
877 s = PlayerScore_Add(e, SP_RACE_FASTEST, 0);
881 print(e.netname, " = ", ftos(e.race_place), "\n");
884 if(g_race_qualifying == 2)
886 g_race_qualifying = 0;
887 independent_players = 0;
888 cvar_set("fraglimit", ftos(race_fraglimit));
889 cvar_set("leadlimit", ftos(race_leadlimit));
890 cvar_set("timelimit", ftos(race_timelimit));
895 void race_ImposePenaltyTime(entity pl, float penalty, string reason)
897 if(g_race_qualifying)
899 pl.race_penalty_accumulator += penalty;
901 WRITESPECTATABLE_MSG_ONE({
902 WriteByte(MSG_ONE, SVC_TEMPENTITY);
903 WriteByte(MSG_ONE, TE_CSQC_RACE);
904 WriteByte(MSG_ONE, RACE_NET_PENALTY_QUALIFYING);
905 WriteShort(MSG_ONE, TIME_ENCODE(penalty));
906 WriteString(MSG_ONE, reason);
911 pl.race_penalty = time + penalty;
913 WRITESPECTATABLE_MSG_ONE_VARNAME(dummy, {
914 WriteByte(MSG_ONE, SVC_TEMPENTITY);
915 WriteByte(MSG_ONE, TE_CSQC_RACE);
916 WriteByte(MSG_ONE, RACE_NET_PENALTY_RACE);
917 WriteShort(MSG_ONE, TIME_ENCODE(penalty));
918 WriteString(MSG_ONE, reason);
926 if(other.race_lastpenalty != self)
928 other.race_lastpenalty = self;
929 race_ImposePenaltyTime(other, self.race_penalty, self.race_penalty_reason);
935 race_ImposePenaltyTime(activator, self.race_penalty, self.race_penalty_reason);
938 void spawnfunc_trigger_race_penalty()
942 self.use = penalty_use;
943 if not(self.spawnflags & 1)
944 self.touch = penalty_touch;
946 if (!self.race_penalty_reason)
947 self.race_penalty_reason = "missing a checkpoint";
948 if (!self.race_penalty)
949 self.race_penalty = 5;