]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add player ranks
authorz411 <z411@omaera.org>
Mon, 24 Jan 2022 01:01:00 +0000 (22:01 -0300)
committerz411 <z411@omaera.org>
Mon, 24 Jan 2022 01:01:00 +0000 (22:01 -0300)
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/hud/panel/spect.qc
qcsrc/client/main.qh
qcsrc/common/ent_cs.qc
qcsrc/common/ent_cs.qh
qcsrc/server/client.qc
qcsrc/server/client.qh
qcsrc/server/command/sv_cmd.qc
qcsrc/server/world.qh

index ba223d9af38d5290e45da9efb6cfd0eea3739379..7eaabacc9d7db8d65b786cad4e19ad56e8f9f7b9 100644 (file)
@@ -1296,14 +1296,30 @@ void Scoreboard_Duel_DrawTable(vector pos, bool invert, entity pl, entity tm)
        drawstring(tmp_in, tmp_str, duel_score_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
        draw_endBoldFont();
        
+       tmp_in = tmp;
+       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), ")");
+               if(invert)
+                       tmp_in.x -= stringwidth_colors(rank_str, duel_name_fontsize) + duel_name_fontsize.x * 0.5;
+               else
+                       tmp_in.x += duel_score_size.x + duel_name_fontsize.x * 0.5;
+               
+               draw_beginBoldFont();
+               drawcolorcodedstring(tmp_in, rank_str, teamname_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+               draw_endBoldFont();
+       }
+       
        // Player name
        tmp_str = Scoreboard_GetField(pl, SP_NAME);
-       tmp_in = tmp;
        if(invert)
                tmp_in.x -= stringwidth_colors(tmp_str, duel_name_fontsize) + duel_name_fontsize.x * 0.5;
        else
-               tmp_in.x += duel_score_size.x + duel_name_fontsize.x * 0.5;
-       tmp_in.y += (duel_score_size.y - duel_name_fontsize.y) / 2;
+               tmp_in.x += (rank ? 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
index dedfde612b7f4197dbc21afbacf22a904e26220b..e5ab123083b3010584a3ff6b7741445f8fe575e3 100644 (file)
@@ -251,16 +251,33 @@ void HUD_SpectHUD_drawDuelScore(vector pos, entity pl, bool invert)
                drawfill(tmp, vec2(armor, armor_sz.y), autocvar_hud_progressbar_armor_color, 0.7, DRAWFLAG_NORMAL);
        }
        
+       // Align vertically
+       tmp = pos;
+       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), ")");
+               if(invert)
+                       tmp.x -= stringwidth_colors(rank_str, teamname_fontsize) + teamname_fontsize.x * 0.5;
+               else
+                       tmp.x += teamscore_size.x + teamname_fontsize.x * 0.5;
+               
+               draw_beginBoldFont();
+               drawcolorcodedstring(tmp, rank_str, teamname_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+               draw_endBoldFont();
+       }
+       
        // Player name
        tmp_str = entcs_GetName(pl.sv_entnum);
        
-       tmp = pos;
        if(invert)
                tmp.x -= stringwidth_colors(tmp_str, teamname_fontsize) + teamname_fontsize.x * 0.5;
        else
-               tmp.x += teamscore_size.x + teamname_fontsize.x * 0.5;
-       tmp.y += ((teamscore_size.y / 2) - teamname_fontsize.y) / 2;
-       tmp.y += teamscore_size.y / 2;
+               tmp.x += (rank ? 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);
 }
index f456260476a70025a44e6110fea2c1ad1c3de0c7..f65107398c0f51dea7562e19047af2f2a107efc5 100644 (file)
@@ -169,6 +169,7 @@ string GetSpeedUnit(int speed_unit);
 .int team;
 .int team_size;
 .int countrycode;
+.int rank;
 
 int binddb;
 
index a394683e534ef707786f15d744acfb8aebd28839..151f4ac321cfce5e3a97a3d365ef76763fa95962 100644 (file)
@@ -156,6 +156,10 @@ ENTCS_PROP(COUNTRYCODE, true, countrycode, countrycode, ENTCS_SET_NORMAL,
        { WriteByte(chan, ent.countrycode); },
        { ent.countrycode = ReadByte(); })
 
+ENTCS_PROP(RANK, true, rank, rank, ENTCS_SET_NORMAL,
+       { WriteByte(chan, ent.rank); },
+       { ent.rank = ReadByte(); })
+
 // use sv_solid to avoid changing solidity state of entcs entities
 ENTCS_PROP(SOLID, true, sv_solid, solid, ENTCS_SET_NORMAL,
        { WriteByte(chan, ent.sv_solid); },
index 0b65c08cbb25c512b116938216b3b8a651168221..cec8fbf211748fa220ae512b661bd85dd8e43732 100644 (file)
@@ -139,6 +139,12 @@ REGISTER_NET_TEMP(CLIENT_ENTCS)
                entity e = entcs_receiver(i);
                return e.countrycode;
        }
+       
+       int entcs_GetRank(int i)
+       {
+               entity e = entcs_receiver(i);
+               return e.rank;
+       }
 
     /**
      * @param i zero indexed player
index ad1af0280030b41143b3678a2e47fd38a572b0ff..cafa65cc8fb9d80e16fb0567c728f004d8acb77c 100644 (file)
@@ -1141,8 +1141,12 @@ void ClientConnect(entity this)
        else
                CS(this).allowed_timeouts = autocvar_sv_timeout_number;
 
-       if (autocvar_sv_eventlog)
+       if (autocvar_sv_eventlog) {
                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));
+       }
 
        CS(this).just_joined = true;  // stop spamming the eventlog with additional lines when the client connects
 
index 8a30b00834b334c4b13aa579d49c1a09ded342bd..6afd74638efe3c109ab6344c2ab8539de433a477 100644 (file)
@@ -108,6 +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);
     /** Client IP */
     ATTRIB(Client, netaddress, string, this.netaddress);
     ATTRIB(Client, playermodel, string, this.playermodel);
@@ -336,6 +337,7 @@ bool independent_players;
 .float lastkill;
 .int countrycode;
 .int killcount;
+.int rank;
 
 //flood fields
 .float nickspamtime; // time of last nick change
index 2112d2f4489a9a8fc2a755464eeff8bb6f2ccb08..65b550848bd51b0474fbd56a734d3ae63f4f870a 100644 (file)
@@ -1106,6 +1106,39 @@ void GameCommand_setflag(int request, int argc)
        }
 }
 
+void GameCommand_setrank(int request, int argc)
+{
+       switch (request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       entity client;
+                       float accepted;
+                       
+                       client = GetFilteredEntity(argv(1));
+                       accepted = VerifyClientEntity(client, false, false);
+
+                       if (accepted <= 0)
+                       {
+                               LOG_INFO("^1ERROR^7: Couldn't set player rank");
+                               LOG_HELP("Usage:^3 sv_cmd setrank #client_id #rank");
+                               return;
+                       }
+                       
+                       client.rank = stof(argv(2));
+                       LOG_INFO("^2SUCCESS^7: Player rank set!");
+                       return;
+               }
+               default:
+                       LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
+               case CMD_REQUEST_USAGE:
+               {
+                       LOG_HELP("Usage:^3 sv_cmd setrank #client_id #rank");
+                       return;
+               }
+       }
+}
+
 void GameCommand_moveplayer(int request, int argc)
 {
        switch (request)
@@ -1807,6 +1840,7 @@ SERVER_COMMAND(reducematchtime, "Decrease the timelimit value incrementally") {
 SERVER_COMMAND(resetmatch, "Soft restart the game without changing teams; goes back to warmup if enabled") { GameCommand_resetmatch(request); }
 SERVER_COMMAND(setbots, "Adjust how many bots are in the match") { GameCommand_setbots(request, arguments); }
 SERVER_COMMAND(setflag, "Set client flag") { GameCommand_setflag(request, arguments); }
+SERVER_COMMAND(setrank, "Set client rank") { GameCommand_setrank(request, arguments); }
 SERVER_COMMAND(shuffleteams, "Randomly move players to different teams") { GameCommand_shuffleteams(request); }
 SERVER_COMMAND(stuffto, "Send a command to be executed on a client") { GameCommand_stuffto(request, arguments); }
 SERVER_COMMAND(teamname, "Set team name") { GameCommand_teamname(request, arguments); }
index 2844a0a660b3b17ef408263fc9834eaf8a43958b..1cca0f90e66c5d5e731114585da47a1082f6d227 100644 (file)
@@ -162,6 +162,7 @@ void droptofloor(entity this);
 
 /* z411 for RJZ */
 bool autocvar_rjz_count_shards = false;
+bool autocvar_rjz_ranks = false;
 int  total_shards = 0;
 void send_TotalShards(entity to);
 void send_TotalShardsAll();