From: Mario Date: Sun, 9 Jul 2017 17:28:49 +0000 (+1000) Subject: Don't show an empty race panel in modes where times don't matter, also add a setting... X-Git-Tag: xonotic-v0.8.5~2653 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8c6a08d979d079e72b664ee7e1819deb35ccdf80;p=xonotic%2Fxonotic-data.pk3dir.git Don't show an empty race panel in modes where times don't matter, also add a setting to show only personal race checkpoint times --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 2909b60c8..ba8bdb228 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -1102,6 +1102,8 @@ seta cl_autoscreenshot 1 "Take a screenshot upon the end of a match... 0 = Disab seta cl_jetpack_jump 1 "Activate jetpack by pressing jump in the air. 0 = Disable, 1 = Stop when touching ground, 2 = Enable" +seta cl_race_cptimes_onlyself 0 "Only show your own times on checkpoints in Race/CTS" + // must be at the bottom of this file: set g_bugrigs 0 diff --git a/qcsrc/client/hud/panel/modicons.qc b/qcsrc/client/hud/panel/modicons.qc index e87d64c87..065e632f1 100644 --- a/qcsrc/client/hud/panel/modicons.qc +++ b/qcsrc/client/hud/panel/modicons.qc @@ -512,14 +512,18 @@ void race_showTime(string text, vector pos, vector timeText_ofs, float theTime, void HUD_Mod_Race(vector pos, vector mySize) { - mod_active = 1; // race should never hide the mod icons panel entity me; me = playerslots[player_localnum]; float score; score = me.(scores(ps_primary)); if(!(scores_flags(ps_primary) & SFL_TIME) || teamplay) // race/cts record display on HUD + { + mod_active = 0; // hide it in this case! return; // no records in the actual race + } + + mod_active = 1; // clientside personal record string rr; diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index c53943221..87f3a1bb4 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -131,6 +131,8 @@ void CSQC_Init() registercvar("cl_spawn_near_teammate", "1"); + registercvar("cl_race_cptimes_onlyself", "0"); + if(autocvar_cl_lockview) cvar_set("cl_lockview", "0"); @@ -1044,7 +1046,22 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) race_penaltyaccumulator = 0; race_laptime = time; // valid } + break; + case RACE_NET_CHECKPOINT_HIT_SELF_QUALIFYING: + race_checkpoint = ReadByte(); + race_time = ReadInt24_t(); + race_previousbesttime = ReadInt24_t(); + if(race_previousbestname) + strunzone(race_previousbestname); + race_previousbestname = strzone(""); // handled by MakeRaceString + + race_checkpointtime = time; + if(race_checkpoint == 0 || race_checkpoint == 254) + { + race_penaltyaccumulator = 0; + race_laptime = time; // valid + } break; case RACE_NET_CHECKPOINT_CLEAR: @@ -1065,6 +1082,15 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) race_nextbestname = strzone(ReadString()); break; + case RACE_NET_CHECKPOINT_NEXT_SELF_QUALIFYING: + race_nextcheckpoint = ReadByte(); + + race_nextbesttime = ReadInt24_t(); + if(race_nextbestname) + strunzone(race_nextbestname); + race_nextbestname = strzone(""); // handled by MakeRaceString + break; + case RACE_NET_CHECKPOINT_HIT_RACE: race_mycheckpoint = ReadByte(); race_mycheckpointtime = time; @@ -1074,7 +1100,11 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) race_mycheckpointlapsdelta -= 256; if(race_mycheckpointenemy) strunzone(race_mycheckpointenemy); - race_mycheckpointenemy = strzone(ReadString()); + int who = ReadByte(); + if(who) + race_mycheckpointenemy = strzone(entcs_GetName(who - 1)); + else + race_mycheckpointenemy = strzone(""); // TODO: maybe string_null works fine here? break; case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT: @@ -1086,7 +1116,11 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) race_othercheckpointlapsdelta -= 256; if(race_othercheckpointenemy) strunzone(race_othercheckpointenemy); - race_othercheckpointenemy = strzone(ReadString()); + int what = ReadByte(); + if(what) + race_othercheckpointenemy = strzone(entcs_GetName(what - 1)); + else + race_othercheckpointenemy = strzone(""); // TODO: maybe string_null works fine here? break; case RACE_NET_PENALTY_RACE: diff --git a/qcsrc/common/net_linked.qh b/qcsrc/common/net_linked.qh index de8cf8f92..7b69ad503 100644 --- a/qcsrc/common/net_linked.qh +++ b/qcsrc/common/net_linked.qh @@ -20,6 +20,8 @@ const int RACE_NET_SPEED_AWARD = 9; // speed award, sent to client const int RACE_NET_SPEED_AWARD_BEST = 10; // all time best speed award, sent to client const int RACE_NET_SERVER_RANKINGS = 11; 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 REGISTER_NET_LINKED(_ENT_CLIENT_INIT) #ifdef CSQC diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index ef82cc3d6..80023e76a 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -116,6 +116,8 @@ float race_checkpoint_lasttimes[MAX_CHECKPOINTS]; float race_checkpoint_lastlaps[MAX_CHECKPOINTS]; entity race_checkpoint_lastplayers[MAX_CHECKPOINTS]; +.float race_checkpoint_record[MAX_CHECKPOINTS]; + float race_highest_checkpoint; float race_timed_checkpoint; @@ -158,23 +160,19 @@ float race_CheckpointNetworkID(float f) void race_SendNextCheckpoint(entity e, float spec) // qualifying only { - float recordtime; - string recordholder; - float cp; - if(!e.race_laptime) return; - cp = e.race_checkpoint; - recordtime = race_checkpoint_records[cp]; - recordholder = race_checkpoint_recordholders[cp]; + int cp = e.race_checkpoint; + float recordtime = race_checkpoint_records[cp]; + string recordholder = race_checkpoint_recordholders[cp]; if(recordholder == e.netname) recordholder = ""; if(!IS_REAL_CLIENT(e)) return; - if(!spec) + if(!spec && !e.cvar_cl_race_cptimes_onlyself) // don't show spectators the player's personal time msg_entity = e; WRITESPECTATABLE_MSG_ONE(msg_entity, { WriteHeader(MSG_ONE, TE_CSQC_RACE); @@ -190,6 +188,18 @@ void race_SendNextCheckpoint(entity e, float spec) // qualifying only WriteInt24_t(MSG_ONE, recordtime); WriteString(MSG_ONE, recordholder); }); + + if(!spec && e.cvar_cl_race_cptimes_onlyself) // don't send to spectators! + { + recordtime = e.race_checkpoint_record[cp]; + + // not spectatable + msg_entity = e; + WriteHeader(MSG_ONE, TE_CSQC_RACE); + WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_NEXT_SELF_QUALIFYING); + WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player will be at next + WriteInt24_t(MSG_ONE, recordtime); + } } void race_send_recordtime(float msg) @@ -411,13 +421,16 @@ void race_SendTime(entity e, float cp, float t, float tvalid) } } - float recordtime; - string recordholder; if(g_race_qualifying) { + float recordtime; + float myrecordtime; + string recordholder; + if(tvalid) { recordtime = race_checkpoint_records[cp]; + myrecordtime = e.race_checkpoint_record[cp]; recordholder = strcat1(race_checkpoint_recordholders[cp]); // make a tempstring copy, as we'll possibly strunzone it! if(recordholder == e.netname) recordholder = ""; @@ -436,10 +449,11 @@ void race_SendTime(entity e, float cp, float t, float tvalid) strunzone(race_checkpoint_recordholders[cp]); race_checkpoint_recordholders[cp] = strzone(e.netname); if(g_race_qualifying) - { FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.race_checkpoint == cp, LAMBDA(race_SendNextCheckpoint(it, 0))); - } } + + if(t < myrecordtime || myrecordtime == 0) + e.race_checkpoint_record[cp] = t; // resending done below } } else @@ -447,6 +461,7 @@ void race_SendTime(entity e, float cp, float t, float tvalid) // dummies t = 0; recordtime = 0; + myrecordtime = 0; recordholder = ""; } @@ -455,7 +470,9 @@ void race_SendTime(entity e, float cp, float t, float tvalid) msg_entity = e; if(g_race_qualifying) { - WRITESPECTATABLE_MSG_ONE(msg_entity, { + WRITESPECTATABLE_MSG_ONE(e, { + if(it == e && e.cvar_cl_race_cptimes_onlyself) + continue; WriteHeader(MSG_ONE, TE_CSQC_RACE); WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_HIT_QUALIFYING); WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player now is at @@ -463,14 +480,23 @@ void race_SendTime(entity e, float cp, float t, float tvalid) WriteInt24_t(MSG_ONE, recordtime); // previously best time WriteString(MSG_ONE, recordholder); // record holder }); + + if(e.cvar_cl_race_cptimes_onlyself) + { + msg_entity = e; + WriteHeader(MSG_ONE, TE_CSQC_RACE); + WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_HIT_SELF_QUALIFYING); + WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player now is at + WriteInt24_t(MSG_ONE, t); // time to that intermediate + WriteInt24_t(MSG_ONE, myrecordtime); // previously best time + } } } } else // RACE! Not Qualifying { float mylaps, lother, othtime; - entity oth; - oth = race_checkpoint_lastplayers[cp]; + entity oth = race_checkpoint_lastplayers[cp]; if(oth) { mylaps = PlayerScore_Add(e, SP_RACE_LAPS, 0); @@ -491,13 +517,13 @@ void race_SendTime(entity e, float cp, float t, float tvalid) { WriteInt24_t(MSG_ONE, 0); WriteByte(MSG_ONE, 0); - WriteString(MSG_ONE, ""); + WriteByte(MSG_ONE, 0); } else { WriteInt24_t(MSG_ONE, TIME_ENCODE(time - race_checkpoint_lasttimes[cp])); WriteByte(MSG_ONE, mylaps - lother); - WriteString(MSG_ONE, oth.netname); // record holder + WriteByte(MSG_ONE, etof(oth)); // record holder } }); } @@ -517,13 +543,13 @@ void race_SendTime(entity e, float cp, float t, float tvalid) { WriteInt24_t(MSG_ONE, 0); WriteByte(MSG_ONE, 0); - WriteString(MSG_ONE, ""); + WriteByte(MSG_ONE, 0); } else { WriteInt24_t(MSG_ONE, TIME_ENCODE(time - othtime)); WriteByte(MSG_ONE, lother - mylaps); - WriteString(MSG_ONE, e.netname); // record holder + WriteByte(MSG_ONE, etof(e) - 1); // record holder } }); } diff --git a/qcsrc/server/race.qh b/qcsrc/server/race.qh index 472827efa..7f6a194f2 100644 --- a/qcsrc/server/race.qh +++ b/qcsrc/server/race.qh @@ -66,3 +66,7 @@ void race_SendRankings(float pos, float prevpos, float del, float msg); void race_RetractPlayer(entity this); void race_InitSpectator(); + +.bool cvar_cl_race_cptimes_onlyself; + +REPLICATE(cvar_cl_race_cptimes_onlyself, bool, "cl_race_cptimes_onlyself");