set g_cts 0 "CTS: complete the stage"
set g_cts_selfdamage 1 "0 = disable all selfdamage and falldamage in cts"
set g_cts_finish_kill_delay 10 "prevent cheating by running back to the start line, and starting out with more speed than otherwise possible"
+set g_cts_send_rankings_cnt 15 "send this number of map records to clients"
// ==========================
strcpy(race_speedaward_alltimebest_holder, ReadString());
strcpy(race_speedaward_alltimebest_unit, GetSpeedUnit(autocvar_hud_panel_physics_speed_unit));
break;
+ case RACE_NET_RANKINGS_CNT:
+ RANKINGS_RECEIVED_CNT = ReadByte();
+ break;
case RACE_NET_SERVER_RANKINGS:
float prevpos, del;
int pos = ReadShort();
// move other rankings out of the way
int i;
if (prevpos) {
- for (i=prevpos-1;i>pos-1;--i) {
+ int m = min(prevpos, RANKINGS_RECEIVED_CNT);
+ for (i=m-1; i>pos-1; --i) {
grecordtime[i] = grecordtime[i-1];
strcpy(grecordholder[i], grecordholder[i-1]);
}
} else if (del) { // a record has been deleted by the admin
- for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
- if (i == RANKINGS_CNT-1) { // clear out last record
+ for (i=pos-1; i<= RANKINGS_RECEIVED_CNT-1; ++i) {
+ if (i == RANKINGS_RECEIVED_CNT-1) { // clear out last record
grecordtime[i] = 0;
strfree(grecordholder[i]);
}
}
}
} else { // player has no ranked record yet
- for (i=RANKINGS_CNT-1;i>pos-1;--i) {
+ for (i=RANKINGS_RECEIVED_CNT-1;i>pos-1;--i) {
grecordtime[i] = grecordtime[i-1];
strcpy(grecordholder[i], grecordholder[i-1]);
}
}
+ if (grecordtime[RANKINGS_RECEIVED_CNT]) {
+ // kick off the player who fell from the last displayed position
+ grecordtime[RANKINGS_RECEIVED_CNT] = 0;
+ strfree(grecordholder[RANKINGS_RECEIVED_CNT]);
+ }
+
// store new ranking
strcpy(grecordholder[pos-1], ReadString());
grecordtime[pos-1] = ReadInt24_t();
#pragma once
-const int RANKINGS_CNT = 100;
+const int RANKINGS_CNT = 99;
///////////////////////////
// keys pressed
const int RACE_NET_SERVER_STATUS = 12;
const int RACE_NET_CHECKPOINT_HIT_SELF_QUALIFYING = 13; // byte checkpoint, short time, short recordtime
const int RACE_NET_CHECKPOINT_NEXT_SELF_QUALIFYING = 14; // byte nextcheckpoint, short recordtime
+const int RACE_NET_RANKINGS_CNT = 15;
REGISTER_NET_LINKED(_ENT_CLIENT_INIT)
#ifdef CSQC
if(IS_REAL_CLIENT(player))
{
- for(int i = 1; i <= RANKINGS_CNT; ++i)
+ int m = min(RANKINGS_CNT, autocvar_g_cts_send_rankings_cnt);
+ race_send_rankings_cnt(MSG_ONE);
+ for (int i = 1; i <= m; ++i)
{
race_SendRankings(i, 0, 0, MSG_ONE);
}
race_send_speedaward_alltimebest(MSG_ONE);
float i;
- for (i = 1; i <= RANKINGS_CNT; ++i)
+ int m = min(RANKINGS_CNT, autocvar_g_cts_send_rankings_cnt);
+ race_send_rankings_cnt(MSG_ONE);
+ for (i = 1; i <= m; ++i)
{
race_SendRankings(i, 0, 0, MSG_ONE);
}
race_send_speedaward_alltimebest(MSG_ONE);
float i;
- for (i = 1; i <= RANKINGS_CNT; ++i)
+ int m = min(RANKINGS_CNT, autocvar_g_cts_send_rankings_cnt);
+ race_send_rankings_cnt(MSG_ONE);
+ for (i = 1; i <= m; ++i)
{
race_SendRankings(i, 0, 0, MSG_ONE);
}
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);
// scores
const float ST_RACE_LAPS = 1;
+int autocvar_g_cts_send_rankings_cnt = 15;
+
bool g_race_qualifying;
float speedaward_lastsent;
void race_send_speedaward_alltimebest(float msg);
+void race_send_rankings_cnt(float msg);
+
void race_SendRankings(float pos, float prevpos, float del, float msg);
void race_RetractPlayer(entity this);