]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Country flag support
authorz411 <z411@omaera.org>
Thu, 15 Oct 2020 05:37:27 +0000 (02:37 -0300)
committerz411 <z411@omaera.org>
Thu, 15 Oct 2020 05:37:27 +0000 (02:37 -0300)
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/main.qc
qcsrc/client/main.qh
qcsrc/common/ent_cs.qc
qcsrc/common/ent_cs.qh
qcsrc/server/client.qh
qcsrc/server/command/sv_cmd.qc
qcsrc/server/world.qc

index f3bb2d3d859cac6f729687383449a934ab5eb968..f53a29976ab7ff3a2d09566a53a3d52ae5a8d397 100644 (file)
@@ -599,7 +599,7 @@ string Scoreboard_GetName(entity pl)
        {
                sbt_field_icon0 = "gfx/scoreboard/player_ready";
        }
-       else if(!teamplay)
+       /*else if(!teamplay)
        {
                int f = entcs_GetClientColors(pl.sv_entnum);
                {
@@ -609,7 +609,14 @@ string Scoreboard_GetName(entity pl)
                        sbt_field_icon2 = "gfx/scoreboard/playercolor_pants";
                        sbt_field_icon2_rgb = colormapPaletteColor(f % 16, 1);
                }
+       }*/
+       else
+       {
+               int ccode = entcs_GetCountryCode(pl.sv_entnum);
+               if(ccode)
+                       sbt_field_icon0 = strcat("gfx/flags/", ftos(ccode));
        }
+       
        return entcs_GetName(pl.sv_entnum);
 }
 
index 69cec830d8018730eea2c6c5adaa969aae56688d..f81bfc1a4e13fa7bfc045e5c8dd583c999e38131 100644 (file)
@@ -554,6 +554,7 @@ NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew)
                for(i = 1; i <= maxclients; i += 8)
                {
                        f = ReadByte();
+                       LOG_INFOF("%d", f);
                        for(j = i-1, b = BIT(0); b < BIT(8); b <<= 1, ++j)
                                if (!(f & b))
                                        if(playerslots[j])
index e46bb748a27fa61ef819a0bc18cb87fc52dfc7a3..4189c372355acd99fb4a3c5ba6de6a584a03e5fb 100644 (file)
@@ -131,6 +131,7 @@ string GetSpeedUnit(int speed_unit);
 
 .int team;
 .int team_size;
+.int countrycode;
 
 int binddb;
 
index 4ef6b2f793b819805c3a78c5f0fb0e32f190ab2d..2861ae0cd4d1bb46402b77dea7f50ce9131923c9 100644 (file)
@@ -146,6 +146,10 @@ ENTCS_PROP(CLIENTCOLORS, true, clientcolors, clientcolors, ENTCS_SET_NORMAL,
 ENTCS_PROP(FRAGS, true, frags, frags, ENTCS_SET_NORMAL,
        { WriteShort(chan, ent.frags); },
        { ent.frags = ReadShort(); })
+       
+ENTCS_PROP(COUNTRYCODE, true, countrycode, countrycode, ENTCS_SET_NORMAL,
+       { WriteByte(chan, ent.countrycode); },
+       { ent.countrycode = ReadByte(); })
 
 // use sv_solid to avoid changing solidity state of entcs entities
 ENTCS_PROP(SOLID, true, sv_solid, solid, ENTCS_SET_NORMAL,
index 8ae89fd3b6c49707e06a958ea31ae1700159a8b6..30ee83bbcb4d96b017ce43968b3b6f3cc3bf8a38 100644 (file)
@@ -133,6 +133,12 @@ REGISTER_NET_TEMP(CLIENT_ENTCS)
                entity e = entcs_receiver(i);
                return ColorTranslateRGB(e ? e.netname : getplayerkeyvalue(i, "name"));
        }
+       
+       int entcs_GetCountryCode(int i)
+       {
+               entity e = entcs_receiver(i);
+               return e.countrycode;
+       }
 
     /**
      * @param i zero indexed player
index c6c69380cf876c994645bffe570322fbe810860b..a36758b676f1e1358effef6226109c6804fd0e97 100644 (file)
@@ -40,6 +40,7 @@ CLASS(Client, Object)
     ATTRIB(Client, colormap, int, this.colormap);
     ATTRIB(Client, team, int, this.team);
     ATTRIB(Client, clientcolors, int, this.clientcolors);
+       ATTRIB(Client, countrycode, int, this.countrycode);
     /** Client IP */
     ATTRIB(Client, netaddress, string, this.netaddress);
     ATTRIB(Client, playermodel, string, this.playermodel);
@@ -265,6 +266,7 @@ bool independent_players;
 #define MAKE_INDEPENDENT_PLAYER(e) (((e).solid = SOLID_TRIGGER), ((e).frags = FRAGS_PLAYER_OUT_OF_GAME))
 
 .float lastkill;
+.int countrycode;
 .int killcount;
 
 //flood fields
index 7a3ca3c76f97d1406d9a2b72e69b6a621b3fb005..526775c7c862112bab285153e62ebe5672ee55b9 100644 (file)
@@ -160,7 +160,7 @@ void GameCommand_adminmsg(int request, int argc)
        }
 }
 
-void GameCommand_team_name(int request, int argc)
+void GameCommand_teamname(int request, int argc)
 {
        switch (request)
        {
@@ -183,9 +183,9 @@ void GameCommand_team_name(int request, int argc)
                                case "yellow":
                                case "pink":
                                {
+                                       int tm = Team_ColorToTeam(argv(1));
                                        if(argv(2) != "") {
                                                cvar_set(strcat("g_teamnames_", argv(1)), argv(2));
-                                               int tm = Team_ColorToTeam(argv(1));
                                                bprintf("\{1}%s%s^7 team is now known as %s^7\n", Team_ColorCode(tm), Team_ColorName(tm), argv(2));
                                        } else {
                                                cvar_set(strcat("g_teamnames_", argv(1)), "");
@@ -1023,6 +1023,37 @@ void GameCommand_make_mapinfo(int request)
        }
 }
 
+void GameCommand_setflag(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("setflag error");
+                               return;
+                       }
+                       
+                       client.countrycode = stof(argv(2));
+               }
+               default:
+                       LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
+               case CMD_REQUEST_USAGE:
+               {
+                       LOG_HELP("Usage:^3 sv_cmd setflag client countrycode");
+                       return;
+               }
+       }
+}
+
 void GameCommand_moveplayer(int request, int argc)
 {
        switch (request)
@@ -1679,7 +1710,8 @@ void GameCommand_(int request)
 // ==================================
 
 // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
-SERVER_COMMAND(team_name, "Set team name") { GameCommand_team_name(request, arguments); }
+SERVER_COMMAND(setflag, "Set client flag") { GameCommand_setflag(request, arguments); }
+SERVER_COMMAND(teamname, "Set team name") { GameCommand_teamname(request, arguments); }
 
 SERVER_COMMAND(adminmsg, "Send an admin message to a client directly") { GameCommand_adminmsg(request, arguments); }
 SERVER_COMMAND(allready, "Restart the server and reset the players") { GameCommand_allready(request); }
index e0181c92c3ae3dddca7de2062dae08beb48bdd8c..891131b38dce5db49590163ba22cba944f355013 100644 (file)
@@ -314,6 +314,8 @@ void cvar_changes_init()
                BADCVAR("g_maplist");
                BADCVAR("g_maplist_mostrecent");
                BADCVAR("sv_motd");
+               
+               BADPREFIX("g_teamnames_");
 
                v = cvar_string(k);
                d = cvar_defstring(k);