X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Frace.qc;h=32fdbba172faeb67d38f1a14c6f8c46d92e0eded;hb=000b15c528c0f3c9e77f6c86d8756fb8bee46af2;hp=7f2aaaaf58739f8d040460df84e6667340cf93ff;hpb=ae277921268b84c7b7ee5ab901ce7f0088c07605;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index 7f2aaaaf5..32fdbba17 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -11,15 +11,24 @@ #include "../common/deathtypes/all.qh" #include "../common/notifications/all.qh" #include "../common/mapinfo.qh" +#include #include #include -#include "../common/triggers/subs.qh" +#include +#include "../common/mapobjects/subs.qh" +#include #include "../lib/warpzone/util_server.qh" #include "../lib/warpzone/common.qh" +#include #include "../common/mutators/mutator/waypoints/waypointsprites.qh" IntrusiveList g_race_targets; -STATIC_INIT(g_race_targets) { g_race_targets = IL_NEW(); } +IntrusiveList g_racecheckpoints; +STATIC_INIT(g_race) +{ + g_race_targets = IL_NEW(); + g_racecheckpoints = IL_NEW(); +} void race_InitSpectator() { @@ -28,8 +37,6 @@ void race_InitSpectator() race_SendNextCheckpoint(msg_entity.enemy, 1); } -void W_Porto_Fail(entity this, float failhard); - float race_readTime(string map, float pos) { string rr = ((g_cts) ? CTS_RECORD : ((g_ctf) ? CTF_RECORD : RACE_RECORD)); @@ -83,8 +90,11 @@ void race_writeTime(string map, float t, string myuid) // player has no ranked record yet for (i = RANKINGS_CNT; i > newpos; --i) { - db_put(ServerProgsDB, strcat(map, rr, "time", ftos(i)), ftos(race_readTime(map, i - 1))); - db_put(ServerProgsDB, strcat(map, rr, "crypto_idfp", ftos(i)), race_readUID(map, i - 1)); + float other_time = race_readTime(map, i - 1); + if (other_time) { + db_put(ServerProgsDB, strcat(map, rr, "time", ftos(i)), ftos(other_time)); + db_put(ServerProgsDB, strcat(map, rr, "crypto_idfp", ftos(i)), race_readUID(map, i - 1)); + } } } @@ -103,8 +113,6 @@ string race_readName(string map, float pos) const float MAX_CHECKPOINTS = 255; -spawnfunc(target_checkpoint); - .float race_penalty; .float race_penalty_accumulator; .string race_penalty_reason; @@ -223,6 +231,14 @@ void race_send_speedaward_alltimebest(float msg) WriteString(msg, speedaward_alltimebest_holder); } +void race_send_rankings_cnt(float msg) +{ + WriteHeader(msg, TE_CSQC_RACE); + WriteByte(msg, RACE_NET_RANKINGS_CNT); + int m = min(RANKINGS_CNT, autocvar_g_cts_send_rankings_cnt); + WriteByte(msg, m); +} + void race_SendRankings(float pos, float prevpos, float del, float msg) { WriteHeader(msg, TE_CSQC_RACE); @@ -315,9 +331,7 @@ void race_setTime(string map, float t, string myuid, string mynetname, entity e, } race_SendRankings(newpos, player_prevpos, 0, MSG_ALL); - if(rankings_reply) - strunzone(rankings_reply); - rankings_reply = strzone(getrankings()); + strcpy(rankings_reply, getrankings()); if(newpos == player_prevpos) { @@ -365,9 +379,7 @@ void race_deleteTime(string map, float pos) if(pos == 1) race_send_recordtime(MSG_ALL); - if(rankings_reply) - strunzone(rankings_reply); - rankings_reply = strzone(getrankings()); + strcpy(rankings_reply, getrankings()); } void race_SendTime(entity e, float cp, float t, float tvalid) @@ -386,20 +398,20 @@ void race_SendTime(entity e, float cp, float t, float tvalid) float s; if(g_race_qualifying) { - s = PlayerScore_Add(e, SP_RACE_FASTEST, 0); + s = GameRules_scoring_add(e, RACE_FASTEST, 0); if(!s || t < s) - PlayerScore_Add(e, SP_RACE_FASTEST, t - s); + GameRules_scoring_add(e, RACE_FASTEST, t - s); } else { - s = PlayerScore_Add(e, SP_RACE_FASTEST, 0); + s = GameRules_scoring_add(e, RACE_FASTEST, 0); if(!s || t < s) - PlayerScore_Add(e, SP_RACE_FASTEST, t - s); + GameRules_scoring_add(e, RACE_FASTEST, t - s); - s = PlayerScore_Add(e, SP_RACE_TIME, 0); + s = GameRules_scoring_add(e, RACE_TIME, 0); snew = TIME_ENCODE(time - game_starttime); - PlayerScore_Add(e, SP_RACE_TIME, snew - s); - l = PlayerTeamScore_Add(e, SP_RACE_LAPS, ST_RACE_LAPS, 1); + GameRules_scoring_add(e, RACE_TIME, snew - s); + l = GameRules_scoring_add_team(e, RACE_LAPS, 1); if(autocvar_fraglimit) if(l >= autocvar_fraglimit) @@ -441,9 +453,7 @@ void race_SendTime(entity e, float cp, float t, float tvalid) if(t < recordtime || recordtime == 0) { race_checkpoint_records[cp] = t; - if(race_checkpoint_recordholders[cp]) - strunzone(race_checkpoint_recordholders[cp]); - race_checkpoint_recordholders[cp] = strzone(e.netname); + strcpy(race_checkpoint_recordholders[cp], e.netname); if(g_race_qualifying) FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.race_checkpoint == cp, { race_SendNextCheckpoint(it, 0); }); } @@ -485,7 +495,7 @@ void race_SendTime(entity e, float cp, float t, float tvalid) entity oth = race_checkpoint_lastplayers[cp]; if(oth) { - mylaps = PlayerScore_Add(e, SP_RACE_LAPS, 0); + mylaps = GameRules_scoring_add(e, RACE_LAPS, 0); lother = race_checkpoint_lastlaps[cp]; othtime = race_checkpoint_lasttimes[cp]; } @@ -562,6 +572,9 @@ void race_ClearTime(entity e) void checkpoint_passed(entity this, entity player) { + if(IS_VEHICLE(player) && player.owner) + player = player.owner; + if(player.personal && autocvar_g_allow_checkpoints) return; // practice mode! @@ -704,7 +717,7 @@ void checkpoint_passed(entity this, entity player) else { if(this.spawnflags & 4) - Damage (player, this, this, 10000, DEATH_HURTTRIGGER.m_id, player.origin, '0 0 0'); + Damage (player, this, this, 10000, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, player.origin, '0 0 0'); } } @@ -754,7 +767,7 @@ void trigger_race_checkpoint_verify(entity this) // race only (middle of the race) g_race_qualifying = false; pl_race_place = 0; - if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) { + if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false, true)) { error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for respawning in race) - bailing out")); } @@ -762,7 +775,7 @@ void trigger_race_checkpoint_verify(entity this) // qualifying only g_race_qualifying = 1; pl_race_place = race_lowest_place_spawn; - if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) { + if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false, true)) { error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for qualifying) - bailing out")); } @@ -770,7 +783,7 @@ void trigger_race_checkpoint_verify(entity this) g_race_qualifying = 0; for (int p = 1; p <= race_highest_place_spawn; ++p) { pl_race_place = p; - if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) { + if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false, true)) { error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for initially spawning in race) - bailing out")); } } @@ -781,7 +794,7 @@ void trigger_race_checkpoint_verify(entity this) pl_race_checkpoint = race_NextCheckpoint(0); g_race_qualifying = 1; pl_race_place = race_lowest_place_spawn; - if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) { + if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false, true)) { error(strcat("Checkpoint 0 misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for qualifying) - bailing out")); } } else { @@ -994,7 +1007,7 @@ spawnfunc(target_checkpoint) // defrag entity defrag_ents = 1; // if this is targeted, then it probably isn't a trigger - bool is_trigger = !boolean(!this.nottargeted && this.targetname != ""); + bool is_trigger = this.targetname == ""; if(is_trigger) EXACTTRIGGER_INIT; @@ -1088,9 +1101,7 @@ void race_ClearRecords() for(int j = 0; j < MAX_CHECKPOINTS; ++j) { race_checkpoint_records[j] = 0; - if(race_checkpoint_recordholders[j]) - strunzone(race_checkpoint_recordholders[j]); - race_checkpoint_recordholders[j] = string_null; + strfree(race_checkpoint_recordholders[j]); } FOREACH_CLIENT(true, { @@ -1177,7 +1188,7 @@ float race_GetFractionalLapCount(entity e) // links on CP entities) float l; - l = PlayerScore_Add(e, SP_RACE_LAPS, 0); + l = GameRules_scoring_add(e, RACE_LAPS, 0); if(CS(e).race_completed) return l; // not fractional