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;
25 float race_NextCheckpoint(float f)
27 if(f >= race_highest_checkpoint)
33 float race_PreviousCheckpoint(float f)
38 return race_highest_checkpoint;
44 // 0 = common start/finish
47 float race_CheckpointNetworkID(float f)
49 if(race_timed_checkpoint)
53 else if(f == race_timed_checkpoint)
59 void race_SendNextCheckpoint(entity e, float spec) // qualifying only
68 cp = e.race_checkpoint;
69 recordtime = race_checkpoint_records[cp];
70 recordholder = race_checkpoint_recordholders[cp];
71 if(recordholder == e.netname)
76 WRITESPECTATABLE_MSG_ONE({
77 WriteByte(MSG_ONE, SVC_TEMPENTITY);
78 WriteByte(MSG_ONE, TE_CSQC_RACE);
81 WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING);
82 //WriteCoord(MSG_ONE, e.race_laptime - e.race_penalty_accumulator);
83 WriteCoord(MSG_ONE, time - e.race_movetime - e.race_penalty_accumulator);
86 WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_NEXT_QUALIFYING);
87 WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player will be at next
88 WriteInt24_t(MSG_ONE, recordtime);
89 WriteString(MSG_ONE, recordholder);
93 void race_InitSpectator()
96 if(msg_entity.enemy.race_laptime)
97 race_SendNextCheckpoint(msg_entity.enemy, 1);
100 void race_send_recordtime(float t, float msg)
102 // send the server best time
103 WriteByte(msg, SVC_TEMPENTITY);
104 WriteByte(msg, TE_CSQC_RACE);
105 WriteByte(msg, RACE_NET_SERVER_RECORD);
106 WriteInt24_t(msg, t);
109 void race_SendTime(entity e, float cp, float t, float tvalid)
114 if(g_race_qualifying)
115 t += e.race_penalty_accumulator;
117 t = TIME_ENCODE(t); // make integer
118 // adding just 0.4 so it rounds down in the .5 case (matching the timer display)
121 if(cp == race_timed_checkpoint) // finish line
122 if not(e.race_completed)
125 if(g_race_qualifying)
127 s = PlayerScore_Add(e, SP_RACE_FASTEST, 0);
129 PlayerScore_Add(e, SP_RACE_FASTEST, t - s);
133 s = PlayerScore_Add(e, SP_RACE_TIME, 0);
134 snew = TIME_ENCODE(time - game_starttime);
135 PlayerScore_Add(e, SP_RACE_TIME, snew - s);
136 l = PlayerTeamScore_Add(e, SP_RACE_LAPS, ST_RACE_LAPS, 1);
138 if(cvar("fraglimit"))
139 if(l >= cvar("fraglimit"))
140 race_StartCompleting();
144 e.race_completed = 1;
145 MAKE_INDEPENDENT_PLAYER(e);
146 bprint(e.netname, "^7 has finished the race.\n");
154 if(g_race_qualifying)
158 recordtime = race_checkpoint_records[cp];
159 recordholder = strcat1(race_checkpoint_recordholders[cp]); // make a tempstring copy, as we'll possibly strunzone it!
160 if(recordholder == e.netname)
164 if(t < recordtime || recordtime == 0)
166 race_checkpoint_records[cp] = t;
167 if(race_checkpoint_recordholders[cp])
168 strunzone(race_checkpoint_recordholders[cp]);
169 race_checkpoint_recordholders[cp] = strzone(e.netname);
170 if(cp == race_timed_checkpoint)
173 string grecordholder, recorddifference;
179 grecordtime = stof(db_get(ServerProgsDB, strcat(GetMapname(), rr, "time")));
180 grecordholder = db_get(ServerProgsDB, strcat(GetMapname(), rr, "netname"));
181 if(grecordholder == e.netname)
185 bprint(e.netname, "^7 set the all-time fastest lap record with ", TIME_ENCODED_TOSTRING(t), "\n");
186 db_put(ServerProgsDB, strcat(GetMapname(), rr, "time"), ftos(t));
187 db_put(ServerProgsDB, strcat(GetMapname(), rr, "netname"), e.netname);
188 write_recordmarker(e, time - TIME_DECODE(t), TIME_DECODE(t));
189 race_send_recordtime(t, MSG_ALL);
191 else if(t < grecordtime)
193 recorddifference = strcat("^2", " [-", TIME_ENCODED_TOSTRING(grecordtime-t), "]");
194 if(grecordholder == "")
195 bprint(e.netname, strcat("^7 broke their all-time fastest lap record ", TIME_ENCODED_TOSTRING(grecordtime), " with ", TIME_ENCODED_TOSTRING(t), recorddifference), "\n");
197 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");
198 db_put(ServerProgsDB, strcat(GetMapname(), rr, "time"), ftos(t));
199 db_put(ServerProgsDB, strcat(GetMapname(), rr, "netname"), e.netname);
200 write_recordmarker(e, time - TIME_DECODE(t), TIME_DECODE(t));
201 race_send_recordtime(t, MSG_ALL);
205 recorddifference = strcat("^1", " [+", TIME_ENCODED_TOSTRING(t-grecordtime), "]");
206 if(grecordholder == "")
207 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");
209 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");
213 if(g_race_qualifying)
215 FOR_EACH_REALPLAYER(p)
216 if(p.race_checkpoint == cp)
217 race_SendNextCheckpoint(p, 0);
230 if(g_race_qualifying)
232 WRITESPECTATABLE_MSG_ONE_VARNAME(dummy1, {
233 WriteByte(MSG_ONE, SVC_TEMPENTITY);
234 WriteByte(MSG_ONE, TE_CSQC_RACE);
235 WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_HIT_QUALIFYING);
236 WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player now is at
237 WriteInt24_t(MSG_ONE, t); // time to that intermediate
238 WriteInt24_t(MSG_ONE, recordtime); // previously best time
239 WriteString(MSG_ONE, recordholder); // record holder
243 else // RACE! Not Qualifying
245 float lself, lother, othtime;
247 oth = race_checkpoint_lastplayers[cp];
250 lself = PlayerScore_Add(e, SP_RACE_LAPS, 0);
251 lother = race_checkpoint_lastlaps[cp];
252 othtime = race_checkpoint_lasttimes[cp];
255 lself = lother = othtime = 0;
258 WRITESPECTATABLE_MSG_ONE_VARNAME(dummy2, {
259 WriteByte(MSG_ONE, SVC_TEMPENTITY);
260 WriteByte(MSG_ONE, TE_CSQC_RACE);
261 WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_HIT_RACE);
262 WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player now is at
265 WriteInt24_t(MSG_ONE, 0);
266 WriteByte(MSG_ONE, 0);
267 WriteString(MSG_ONE, "");
271 WriteInt24_t(MSG_ONE, TIME_ENCODE(time - race_checkpoint_lasttimes[cp]));
272 WriteByte(MSG_ONE, lself - lother);
273 WriteString(MSG_ONE, oth.netname); // record holder
277 race_checkpoint_lastplayers[cp] = e;
278 race_checkpoint_lasttimes[cp] = time;
279 race_checkpoint_lastlaps[cp] = lself;
282 WRITESPECTATABLE_MSG_ONE_VARNAME(dummy3, {
283 WriteByte(MSG_ONE, SVC_TEMPENTITY);
284 WriteByte(MSG_ONE, TE_CSQC_RACE);
285 WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT);
286 WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player now is at
289 WriteInt24_t(MSG_ONE, 0);
290 WriteByte(MSG_ONE, 0);
291 WriteString(MSG_ONE, "");
295 WriteInt24_t(MSG_ONE, TIME_ENCODE(time - othtime));
296 WriteByte(MSG_ONE, lother - lself);
297 WriteString(MSG_ONE, e.netname); // record holder
303 void race_ClearTime(entity e)
305 e.race_checkpoint = -1;
307 e.race_movetime = e.race_movetime_frac = e.race_movetime_count = 0;
308 e.race_penalty_accumulator = 0;
309 e.race_lastpenalty = world;
312 WRITESPECTATABLE_MSG_ONE({
313 WriteByte(MSG_ONE, SVC_TEMPENTITY);
314 WriteByte(MSG_ONE, TE_CSQC_RACE);
315 WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_CLEAR); // next
319 void dumpsurface(entity e)
323 print("Surfaces of ", etos(e), ":\n");
325 print("TEST = ", ftos(getsurfacenearpoint(e, '0 0 0')), "\n");
329 n = getsurfacenumpoints(e, si);
332 print(" Surface ", ftos(si), ":\n");
333 norm = getsurfacenormal(e, si);
334 print(" Normal = ", vtos(norm), "\n");
335 for(ni = 0; ni < n; ++ni)
337 vec = getsurfacepoint(e, si, ni);
338 print(" Point ", ftos(ni), " = ", vtos(vec), " (", ftos(norm * vec), ")\n");
343 void checkpoint_passed()
348 if(other.classname == "porto")
350 // do not allow portalling through checkpoints
351 trace_plane_normal = normalize(-1 * other.velocity);
360 if not((self.spawnflags & 2) && (other.classname == "player"))
363 oldmsg = self.message;
366 self.message = oldmsg;
369 if(other.classname != "player")
373 * Remove unauthorized equipment
375 Portal_ClearAll(other);
377 other.porto_forbidden = 2; // decreased by 1 each StartFrame
380 if(self.race_checkpoint == -2)
382 self.race_checkpoint = other.race_checkpoint;
387 for(cp = world; (cp = find(cp, classname, "target_checkpoint"));) {
389 if(cp.race_checkpoint > largest_cp_id) // update the finish id if someone hit a new checkpoint
391 largest_cp_id = cp.race_checkpoint;
392 for(cp = world; (cp = find(cp, classname, "target_stopTimer"));)
393 cp.race_checkpoint = largest_cp_id + 1; // finish line
394 race_highest_checkpoint = largest_cp_id + 1;
395 race_timed_checkpoint = largest_cp_id + 1;
397 for(cp = world; (cp = find(cp, classname, "target_checkpoint"));) {
398 if(cp.race_checkpoint == -2) // set defragcpexists to -1 so that the cp id file will be rewritten when someone finishes
404 for(cp = world; (cp = find(cp, classname, "target_stopTimer"));)
405 cp.race_checkpoint = 1;
406 race_highest_checkpoint = 1;
407 race_timed_checkpoint = 1;
411 if(other.race_checkpoint == -1 || other.race_checkpoint == self.race_checkpoint)
413 if(self.race_penalty)
415 if(other.race_lastpenalty != self)
417 other.race_lastpenalty = self;
418 race_ImposePenaltyTime(other, self.race_penalty, self.race_penalty_reason);
422 if(other.race_penalty)
428 if(self.spawnflags & 2)
431 oldmsg = self.message;
434 self.message = oldmsg;
437 other.race_checkpoint = race_NextCheckpoint(self.race_checkpoint);
439 race_SendTime(other, self.race_checkpoint, other.race_movetime, !!other.race_laptime);
441 if(!self.race_checkpoint) // start line
443 other.race_laptime = time;
444 other.race_movetime = other.race_movetime_frac = other.race_movetime_count = 0;
445 other.race_penalty_accumulator = 0;
446 other.race_lastpenalty = world;
449 if(g_race_qualifying)
450 race_SendNextCheckpoint(other, 0);
452 if(defrag_ents && defragcpexists < 0 && self.classname == "target_stopTimer")
455 defragcpexists = fh = fopen(strcat("maps/", GetMapname(), ".defragcp"), FILE_WRITE);
458 for(cp = world; (cp = find(cp, classname, "target_checkpoint"));)
459 fputs(fh, strcat(cp.targetname, " ", ftos(cp.race_checkpoint), "\n"));
464 else if(other.race_checkpoint == race_NextCheckpoint(self.race_checkpoint))
470 if(self.spawnflags & 4)
471 Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
475 void checkpoint_touch()
481 void checkpoint_use()
483 if(other.classname == "info_player_deathmatch") // a spawn, a spawn
490 float race_waypointsprite_visible_for_player(entity e)
492 if(e.race_checkpoint == -1 || e.race_checkpoint == -2)
494 else if(e.race_checkpoint == self.owner.race_checkpoint)
501 void trigger_race_checkpoint_verify()
511 qual = g_race_qualifying;
515 self.classname = "player";
519 for(i = 0; i <= race_highest_checkpoint; ++i)
521 self.race_checkpoint = race_NextCheckpoint(i);
523 // race only (middle of the race)
524 g_race_qualifying = 0;
526 if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), world, 0, FALSE))
527 error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for respawning in race) - bailing out"));
532 g_race_qualifying = 1;
533 self.race_place = race_lowest_place_spawn;
534 if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), world, 0, FALSE))
535 error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for qualifying) - bailing out"));
537 // race only (initial spawn)
538 g_race_qualifying = 0;
539 for(p = 1; p <= race_highest_place_spawn; ++p)
542 if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), world, 0, FALSE))
543 error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for initially spawning in race) - bailing out"));
548 else if(!defrag_ents)
551 self.race_checkpoint = race_NextCheckpoint(0);
552 g_race_qualifying = 1;
553 self.race_place = race_lowest_place_spawn;
554 if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), world, 0, FALSE))
555 error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for qualifying) - bailing out"));
559 self.race_checkpoint = race_NextCheckpoint(0);
560 g_race_qualifying = 1;
561 self.race_place = 0; // there's only one spawn on defrag maps
563 // check if a defragcp file already exists, then read it and apply the checkpoint order
568 defragcpexists = fh = fopen(strcat("maps/", GetMapname(), ".defragcp"), FILE_READ);
571 while((l = fgets(fh)))
573 len = tokenize_console(l);
575 defragcpexists = -1; // something's wrong in the defrag cp file, set defragcpexists to -1 so that it will be rewritten when someone finishes
578 for(cp = world; (cp = find(cp, classname, "target_checkpoint"));)
579 if(argv(0) == cp.targetname)
580 cp.race_checkpoint = stof(argv(1));
586 g_race_qualifying = qual;
588 if(race_timed_checkpoint) {
590 for(cp = world; (cp = find(cp, classname, "target_startTimer"));)
591 WaypointSprite_UpdateSprites(cp.sprite, "race-start", "", "");
592 for(cp = world; (cp = find(cp, classname, "target_stopTimer"));)
593 WaypointSprite_UpdateSprites(cp.sprite, "race-finish", "", "");
595 for(cp = world; (cp = find(cp, classname, "target_checkpoint"));) {
596 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
600 if(defragcpexists != -1){
602 for(cp = world; (cp = find(cp, classname, "target_checkpoint"));)
603 if(cp.race_checkpoint > largest_cp_id)
604 largest_cp_id = cp.race_checkpoint;
605 for(cp = world; (cp = find(cp, classname, "target_stopTimer"));)
606 cp.race_checkpoint = largest_cp_id + 1; // finish line
607 race_highest_checkpoint = largest_cp_id + 1;
608 race_timed_checkpoint = largest_cp_id + 1;
610 for(cp = world; (cp = find(cp, classname, "target_stopTimer"));)
611 cp.race_checkpoint = 255; // finish line
612 race_highest_checkpoint = 255;
613 race_timed_checkpoint = 255;
617 for(cp = world; (cp = find(cp, classname, "trigger_race_checkpoint")); )
620 if(cp.race_checkpoint == 0)
621 WaypointSprite_UpdateSprites(cp.sprite, "race-start", "", "");
622 else if(cp.race_checkpoint == race_timed_checkpoint)
623 WaypointSprite_UpdateSprites(cp.sprite, "race-finish", "", "");
632 void spawnfunc_trigger_race_checkpoint()
635 if(!g_race && !g_cts)
643 self.use = checkpoint_use;
644 if not(self.spawnflags & 1)
645 self.touch = checkpoint_touch;
647 o = (self.absmin + self.absmax) * 0.5;
648 tracebox(o, PL_MIN, PL_MAX, o - '0 0 1' * (o_z - self.absmin_z), MOVE_NORMAL, self);
649 waypoint_spawnforitem_force(self, trace_endpos);
650 self.nearestwaypointtimeout = time + 1000000000;
653 self.message = "went backwards";
655 self.message2 = "was pushed backwards by";
656 if (!self.race_penalty_reason)
657 self.race_penalty_reason = "missing a checkpoint";
659 self.race_checkpoint = self.cnt;
661 if(self.race_checkpoint > race_highest_checkpoint)
663 race_highest_checkpoint = self.race_checkpoint;
664 if(self.spawnflags & 8)
665 race_timed_checkpoint = self.race_checkpoint;
667 race_timed_checkpoint = 0;
670 if(!self.race_penalty)
672 if(self.race_checkpoint)
673 WaypointSprite_SpawnFixed("race-checkpoint", o, self, sprite);
675 WaypointSprite_SpawnFixed("race-finish", o, self, sprite);
678 self.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
680 InitializeEntity(self, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
683 void spawnfunc_target_checkpoint() // defrag entity
686 if(!g_race && !g_cts)
696 self.use = checkpoint_use;
697 //if not(self.spawnflags & 1)
698 // self.touch = checkpoint_touch;
700 o = (self.absmin + self.absmax) * 0.5;
701 tracebox(o, PL_MIN, PL_MAX, o - '0 0 1' * (o_z - self.absmin_z), MOVE_NORMAL, self);
702 waypoint_spawnforitem_force(self, trace_endpos);
703 self.nearestwaypointtimeout = time + 1000000000;
706 self.message = "went backwards";
708 self.message2 = "was pushed backwards by";
709 if (!self.race_penalty_reason)
710 self.race_penalty_reason = "missing a checkpoint";
712 if(self.classname == "target_startTimer")
713 self.race_checkpoint = 0;
715 self.race_checkpoint = -2;
717 race_timed_checkpoint = 1;
719 if(self.race_checkpoint == 0)
720 WaypointSprite_SpawnFixed("race-start", o, self, sprite);
722 WaypointSprite_SpawnFixed("race-checkpoint", o, self, sprite);
724 self.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
726 InitializeEntity(self, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
729 void spawnfunc_target_startTimer() { spawnfunc_target_checkpoint(); }
730 void spawnfunc_target_stopTimer() { spawnfunc_target_checkpoint(); }
732 void race_AbandonRaceCheck(entity p)
734 if(race_completing && !p.race_completed)
736 p.race_completed = 1;
737 MAKE_INDEPENDENT_PLAYER(p);
738 bprint(p.netname, "^7 has abandoned the race.\n");
743 void race_StartCompleting()
748 if(p.deadflag != DEAD_NO)
749 race_AbandonRaceCheck(p);
752 void race_PreparePlayer()
754 race_ClearTime(self);
758 void race_RetractPlayer()
760 if(!g_race && !g_cts)
762 self.race_checkpoint = race_PreviousCheckpoint(self.race_checkpoint);
763 if(self.race_checkpoint == 0)
765 race_ClearTime(self);
766 self.race_checkpoint = 0;
772 if(!g_race && !g_cts)
775 race_AbandonRaceCheck(self);
780 if(!g_race && !g_cts)
782 if(self.killcount == -666 || g_race_qualifying)
783 race_PreparePlayer();
785 race_AbandonRaceCheck(self);
788 void race_PostSpawn(entity spot)
790 if(!g_race && !g_cts)
792 if(self.killcount != -666 && !g_race_qualifying)
794 if(spot.target == "")
795 // let the player run without timing, if he did not spawn at a targetting spawnpoint
796 race_PreparePlayer();
798 race_RetractPlayer();
801 if(spot.target != "" && self.race_checkpoint == -1)
802 self.race_checkpoint = 0;
807 void race_PreSpawnObserver()
809 if(!g_race && !g_cts)
811 race_PreparePlayer();
814 void spawnfunc_info_player_race (void)
816 if(!g_race && !g_cts)
822 spawnfunc_info_player_deathmatch();
824 if(self.race_place > race_highest_place_spawn)
825 race_highest_place_spawn = self.race_place;
826 if(self.race_place < race_lowest_place_spawn)
827 race_lowest_place_spawn = self.race_place;
830 void race_ClearRecords()
835 for(i = 0; i < MAX_CHECKPOINTS; ++i)
837 race_checkpoint_records[i] = 0;
838 if(race_checkpoint_recordholders[i])
839 strunzone(race_checkpoint_recordholders[i]);
840 race_checkpoint_recordholders[i] = string_null;
847 void race_ReadyRestart()
851 Score_NicePrint(world);
854 PlayerScore_Sort(race_place);
861 s = PlayerScore_Add(e, SP_RACE_FASTEST, 0);
865 print(e.netname, " = ", ftos(e.race_place), "\n");
868 if(g_race_qualifying == 2)
870 g_race_qualifying = 0;
871 independent_players = 0;
872 cvar_set("fraglimit", ftos(race_fraglimit));
873 cvar_set("leadlimit", ftos(race_leadlimit));
874 cvar_set("timelimit", ftos(race_timelimit));
879 void race_ImposePenaltyTime(entity pl, float penalty, string reason)
881 if(g_race_qualifying)
883 pl.race_penalty_accumulator += penalty;
885 WRITESPECTATABLE_MSG_ONE({
886 WriteByte(MSG_ONE, SVC_TEMPENTITY);
887 WriteByte(MSG_ONE, TE_CSQC_RACE);
888 WriteByte(MSG_ONE, RACE_NET_PENALTY_QUALIFYING);
889 WriteShort(MSG_ONE, TIME_ENCODE(penalty));
890 WriteString(MSG_ONE, reason);
895 pl.race_penalty = time + penalty;
897 WRITESPECTATABLE_MSG_ONE_VARNAME(dummy, {
898 WriteByte(MSG_ONE, SVC_TEMPENTITY);
899 WriteByte(MSG_ONE, TE_CSQC_RACE);
900 WriteByte(MSG_ONE, RACE_NET_PENALTY_RACE);
901 WriteShort(MSG_ONE, TIME_ENCODE(penalty));
902 WriteString(MSG_ONE, reason);
910 if(other.race_lastpenalty != self)
912 other.race_lastpenalty = self;
913 race_ImposePenaltyTime(other, self.race_penalty, self.race_penalty_reason);
919 race_ImposePenaltyTime(activator, self.race_penalty, self.race_penalty_reason);
922 void spawnfunc_trigger_race_penalty()
926 self.use = penalty_use;
927 if not(self.spawnflags & 1)
928 self.touch = penalty_touch;
930 if (!self.race_penalty_reason)
931 self.race_penalty_reason = "missing a checkpoint";
932 if (!self.race_penalty)
933 self.race_penalty = 5;