WriteByte(msg, SVC_TEMPENTITY);
WriteByte(msg, TE_CSQC_RACE);
WriteByte(msg, RACE_NET_SERVER_RECORD);
- WriteInt24_t(msg, race_readTime(MapInfo_Map_bspname, 1));
+ WriteInt24_t(msg, race_readTime(GetMapname(), 1));
}
void race_SendRankings(float pos, float prevpos, float del, float msg)
WriteShort(msg, pos);
WriteShort(msg, prevpos);
WriteShort(msg, del);
- WriteString(msg, race_readName(MapInfo_Map_bspname, pos));
- WriteInt24_t(msg, race_readTime(MapInfo_Map_bspname, pos));
+ WriteString(msg, race_readName(GetMapname(), pos));
+ WriteInt24_t(msg, race_readTime(GetMapname(), pos));
}
void race_SendStatus(float id, entity e)
string recorddifference, oldrec_holder;
if (player_prevpos && (player_prevpos < newpos || !newpos))
{
- oldrec = race_readTime(MapInfo_Map_bspname, player_prevpos);
+ 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);
return;
} else if (!newpos) { // no ranking, time worse than the worst ranked
- recorddifference = strcat(" ^1[+", TIME_ENCODED_TOSTRING(t - race_readTime(MapInfo_Map_bspname, RANKINGS_CNT)), "]");
- bprint(mynetname, "^7 couldn't break the ", race_placeName(RANKINGS_CNT), " place record of ", TIME_ENCODED_TOSTRING(race_readTime(MapInfo_Map_bspname, RANKINGS_CNT)), recorddifference, "\n");
+ 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");
race_SendStatus(0, e); // "fail"
+ Send_KillNotification(e.netname, TIME_ENCODED_TOSTRING(t), "", RACE_FAIL, MSG_RACE);
return;
}
// if we didn't hit a return yet, we have a new record!
- oldrec = race_readTime(MapInfo_Map_bspname, newpos);
- oldrec_holder = race_readName(MapInfo_Map_bspname, newpos);
-
- // move other rankings out of the way
- if (player_prevpos) { // player improved his existing record, only have to iterate on ranks between new and old recs
- for (i = player_prevpos; i > newpos; --i) {
- race_writeTime(GetMapname(), race_readTime(GetMapname(), newpos-1), race_readUID(GetMapname(), newpos-1));
- }
- } else { // player has no ranked record yet
- for (i = RANKINGS_CNT; i > newpos; --i) {
- race_writeTime(GetMapname(), race_readTime(GetMapname(), newpos-1), race_readUID(GetMapname(), newpos-1));
- }
+ // 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");
+ return;
}
+
+ oldrec = race_readTime(GetMapname(), newpos);
+ oldrec_holder = race_readName(GetMapname(), newpos);
// store new ranking
race_writeTime(GetMapname(), t, myuid);
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);
}
}
}
PlayerScore_Add(e, SP_RACE_TIME, snew - s);
l = PlayerTeamScore_Add(e, SP_RACE_LAPS, ST_RACE_LAPS, 1);
- if(cvar("fraglimit"))
- if(l >= cvar("fraglimit"))
+ if(autocvar_fraglimit)
+ if(l >= autocvar_fraglimit)
race_StartCompleting();
if(race_completing)
if(t != 0) {
if(cp == race_timed_checkpoint)
{
- race_setTime(MapInfo_Map_bspname, t, e.crypto_idfp, e.netname, e);
- if(g_cts && cvar("g_cts_finish_kill_delay"))
+ race_setTime(GetMapname(), t, e.crypto_idfp, e.netname, e);
+ if(g_cts && autocvar_g_cts_finish_kill_delay)
{
- CTS_ClientKill(cvar("g_cts_finish_kill_delay"));
+ CTS_ClientKill(e);
}
}
if(t < recordtime || recordtime == 0)
// race only (middle of the race)
g_race_qualifying = 0;
self.race_place = 0;
- if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), world, 0, FALSE, FALSE))
+ 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 respawning in race) - bailing out"));
if(i == 0)
// qualifying only
g_race_qualifying = 1;
self.race_place = race_lowest_place_spawn;
- if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), world, 0, FALSE, FALSE))
+ 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"));
// race only (initial spawn)
for(p = 1; p <= race_highest_place_spawn; ++p)
{
self.race_place = p;
- if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), world, 0, FALSE, FALSE))
+ 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 initially spawning in race) - bailing out"));
}
}
self.race_checkpoint = race_NextCheckpoint(0);
g_race_qualifying = 1;
self.race_place = race_lowest_place_spawn;
- if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), world, 0, FALSE, FALSE))
+ 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"));
}
else
for(trigger = world; (trigger = find(trigger, classname, "trigger_multiple")); )
for(targ = world; (targ = find(targ, targetname, trigger.target)); )
if (targ.classname == "target_checkpoint" || targ.classname == "target_startTimer" || targ.classname == "target_stopTimer") {
- targ.wait = -2;
+ trigger.wait = 0;
+ trigger.delay = 0;
+ targ.wait = 0;
targ.delay = 0;
- setsize(targ, trigger.mins, trigger.maxs);
- setorigin(targ, trigger.origin);
+ // These just make the game crash on some maps with oddly shaped triggers.
+ // (on the other hand they used to fix the case when two players ran through a checkpoint at once,
+ // and often one of them just passed through without being registered. Hope it's fixed in a better way now.
+ // (happened on item triggers too)
+ //
+ //targ.wait = -2;
+ //targ.delay = 0;
+
+ //setsize(targ, trigger.mins, trigger.maxs);
+ //setorigin(targ, trigger.origin);
//remove(trigger);
}
}
self = oldself;
}
+vector trigger_race_checkpoint_spawn_evalfunc(entity player, entity spot, vector current)
+{
+ if(g_race_qualifying)
+ {
+ // spawn at first
+ if(self.race_checkpoint != 0)
+ return '-1 0 0';
+ if(spot.race_place != race_lowest_place_spawn)
+ return '-1 0 0';
+ }
+ else
+ {
+ if(self.race_checkpoint != player.race_respawn_checkpoint)
+ return '-1 0 0';
+ // try reusing the previous spawn
+ if(self == player.race_respawn_spotref || spot == player.race_respawn_spotref)
+ current_x += SPAWN_PRIO_RACE_PREVIOUS_SPAWN;
+ if(self.race_checkpoint == 0)
+ {
+ float pl;
+ pl = player.race_place;
+ if(pl > race_highest_place_spawn)
+ pl = 0;
+ if(pl == 0 && !player.race_started)
+ pl = race_highest_place_spawn; // use last place if he has not even touched finish yet
+ if(spot.race_place != pl)
+ return '-1 0 0';
+ }
+ }
+ return current;
+}
+
void spawnfunc_trigger_race_checkpoint()
{
vector o;
if(!self.race_penalty)
{
if(self.race_checkpoint)
- WaypointSprite_SpawnFixed("race-checkpoint", o, self, sprite);
+ WaypointSprite_SpawnFixed("race-checkpoint", o, self, sprite, RADARICON_NONE, '1 0.5 0');
else
- WaypointSprite_SpawnFixed("race-finish", o, self, sprite);
+ WaypointSprite_SpawnFixed("race-start-finish", o, self, sprite, RADARICON_NONE, '1 0.5 0');
}
self.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
+ self.spawn_evalfunc = trigger_race_checkpoint_spawn_evalfunc;
InitializeEntity(self, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
}
race_timed_checkpoint = 1;
if(self.race_checkpoint == 0)
- WaypointSprite_SpawnFixed("race-start", o, self, sprite);
+ WaypointSprite_SpawnFixed("race-start", o, self, sprite, RADARICON_NONE, '1 0.5 0');
else
- WaypointSprite_SpawnFixed("race-checkpoint", o, self, sprite);
+ WaypointSprite_SpawnFixed("race-checkpoint", o, self, sprite, RADARICON_NONE, '1 0.5 0');
self.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;