From 277d7944ae9881919ebcf0a7f0aaa05d330bc04d Mon Sep 17 00:00:00 2001 From: z411 Date: Mon, 24 Jan 2022 17:52:45 -0300 Subject: [PATCH] Allow strings as ranks --- qcsrc/client/hud/panel/scoreboard.qc | 8 +++----- qcsrc/client/hud/panel/spect.qc | 10 ++++------ qcsrc/client/main.qh | 2 +- qcsrc/common/ent_cs.qc | 4 ++-- qcsrc/common/ent_cs.qh | 4 ++-- qcsrc/server/client.qc | 2 +- qcsrc/server/client.qh | 4 ++-- qcsrc/server/command/sv_cmd.qc | 4 ++-- 8 files changed, 17 insertions(+), 21 deletions(-) diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index 7eaabacc9..fe096ecd1 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -1300,10 +1300,8 @@ void Scoreboard_Duel_DrawTable(vector pos, bool invert, entity pl, entity tm) tmp_in.y += (duel_score_size.y - duel_name_fontsize.y) / 2; // RJZ rank - int rank = entcs_GetRank(pl.sv_entnum); - string rank_str = ""; - if(rank) { - rank_str = strcat("(", ftos(rank), ")"); + string rank_str = entcs_GetRank(pl.sv_entnum); + if(rank_str) { if(invert) tmp_in.x -= stringwidth_colors(rank_str, duel_name_fontsize) + duel_name_fontsize.x * 0.5; else @@ -1319,7 +1317,7 @@ void Scoreboard_Duel_DrawTable(vector pos, bool invert, entity pl, entity tm) if(invert) tmp_in.x -= stringwidth_colors(tmp_str, duel_name_fontsize) + duel_name_fontsize.x * 0.5; else - tmp_in.x += (rank ? stringwidth_colors(rank_str, duel_name_fontsize) : duel_score_size.x) + duel_name_fontsize.x * 0.5; + tmp_in.x += (rank_str ? stringwidth_colors(rank_str, duel_name_fontsize) : duel_score_size.x) + duel_name_fontsize.x * 0.5; drawcolorcodedstring(tmp_in, tmp_str, duel_name_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); //LegendGuard adds a conditional sentence for country column 05-04-2021 diff --git a/qcsrc/client/hud/panel/spect.qc b/qcsrc/client/hud/panel/spect.qc index e5ab12308..da20acf33 100644 --- a/qcsrc/client/hud/panel/spect.qc +++ b/qcsrc/client/hud/panel/spect.qc @@ -256,11 +256,9 @@ void HUD_SpectHUD_drawDuelScore(vector pos, entity pl, bool invert) tmp.y += ((teamscore_size.y / 2) - teamname_fontsize.y) / 2; tmp.y += teamscore_size.y / 2; - // RJZ rank - int rank = entcs_GetRank(pl.sv_entnum); - string rank_str = ""; - if(rank) { - rank_str = strcat("(", ftos(rank), ")"); + // RJZ rank + string rank_str = entcs_GetRank(pl.sv_entnum); + if(rank_str) { if(invert) tmp.x -= stringwidth_colors(rank_str, teamname_fontsize) + teamname_fontsize.x * 0.5; else @@ -277,7 +275,7 @@ void HUD_SpectHUD_drawDuelScore(vector pos, entity pl, bool invert) if(invert) tmp.x -= stringwidth_colors(tmp_str, teamname_fontsize) + teamname_fontsize.x * 0.5; else - tmp.x += (rank ? stringwidth_colors(rank_str, teamname_fontsize) : teamscore_size.x) + teamname_fontsize.x * 0.5; + tmp.x += (rank_str ? stringwidth_colors(rank_str, teamname_fontsize) : teamscore_size.x) + teamname_fontsize.x * 0.5; drawcolorcodedstring(tmp, tmp_str, teamname_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); } diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index f65107398..41fdb48e6 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -169,7 +169,7 @@ string GetSpeedUnit(int speed_unit); .int team; .int team_size; .int countrycode; -.int rank; +.string rank; int binddb; diff --git a/qcsrc/common/ent_cs.qc b/qcsrc/common/ent_cs.qc index 151f4ac32..06d9440ad 100644 --- a/qcsrc/common/ent_cs.qc +++ b/qcsrc/common/ent_cs.qc @@ -157,8 +157,8 @@ ENTCS_PROP(COUNTRYCODE, true, countrycode, countrycode, ENTCS_SET_NORMAL, { ent.countrycode = ReadByte(); }) ENTCS_PROP(RANK, true, rank, rank, ENTCS_SET_NORMAL, - { WriteByte(chan, ent.rank); }, - { ent.rank = ReadByte(); }) + { WriteString(chan, ent.rank); }, + { strcpy(ent.rank, ReadString()); }) // use sv_solid to avoid changing solidity state of entcs entities ENTCS_PROP(SOLID, true, sv_solid, solid, ENTCS_SET_NORMAL, diff --git a/qcsrc/common/ent_cs.qh b/qcsrc/common/ent_cs.qh index cec8fbf21..90a6550c5 100644 --- a/qcsrc/common/ent_cs.qh +++ b/qcsrc/common/ent_cs.qh @@ -140,10 +140,10 @@ REGISTER_NET_TEMP(CLIENT_ENTCS) return e.countrycode; } - int entcs_GetRank(int i) + string entcs_GetRank(int i) { entity e = entcs_receiver(i); - return e.rank; + return (e.rank != "" ? e.rank : string_null); } /** diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index cafa65cc8..fcf25b476 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1145,7 +1145,7 @@ void ClientConnect(entity this) GameLogEcho(strcat(":join:", ftos(this.playerid), ":", ftos(etof(this)), ":", ((IS_REAL_CLIENT(this)) ? GameLog_ProcessIP(this.netaddress) : "bot"), ":", playername(this.netname, this.team, false))); /* z411 for RJZ */ - if(autocvar_rjz_ranks) GameLogEcho(strcat(":idfp:", this.crypto_idfp)); + if(autocvar_rjz_ranks) GameLogEcho(strcat(":idfp:", ftos(etof(this)), ":", this.crypto_idfp)); } CS(this).just_joined = true; // stop spamming the eventlog with additional lines when the client connects diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 6afd74638..52fc31472 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -108,7 +108,7 @@ CLASS(Client, Object) ATTRIB(Client, team, int, this.team); ATTRIB(Client, clientcolors, int, this.clientcolors); ATTRIB(Client, countrycode, int, this.countrycode); - ATTRIB(Client, rank, int, this.rank); + ATTRIB(Client, rank, string, this.rank); /** Client IP */ ATTRIB(Client, netaddress, string, this.netaddress); ATTRIB(Client, playermodel, string, this.playermodel); @@ -337,7 +337,7 @@ bool independent_players; .float lastkill; .int countrycode; .int killcount; -.int rank; +.string rank; // RJZ //flood fields .float nickspamtime; // time of last nick change diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 65b550848..4895866ea 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -1121,11 +1121,11 @@ void GameCommand_setrank(int request, int argc) if (accepted <= 0) { LOG_INFO("^1ERROR^7: Couldn't set player rank"); - LOG_HELP("Usage:^3 sv_cmd setrank #client_id #rank"); + LOG_HELP("Usage:^3 sv_cmd setrank #client_id rank"); return; } - client.rank = stof(argv(2)); + client.rank = strzone(argv(2)); LOG_INFO("^2SUCCESS^7: Player rank set!"); return; } -- 2.39.2