]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
uid2name backend
authorFruitieX <rasse@rasse-laptop.(none)>
Tue, 26 Oct 2010 13:12:18 +0000 (16:12 +0300)
committerFruitieX <rasse@rasse-laptop.(none)>
Tue, 26 Oct 2010 13:12:18 +0000 (16:12 +0300)
defaultXonotic.cfg
qcsrc/client/Main.qc
qcsrc/client/autocvars.qh
qcsrc/client/hud.qc
qcsrc/server/cl_client.qc
qcsrc/server/defs.qh
qcsrc/server/miscfunctions.qc

index e6c7f39bb166cedce305712769e68cf127d7f48b..a5558f947c46a32597b932e46a6726bd11377047 100644 (file)
@@ -1990,3 +1990,6 @@ utf8_enable 1
 r_font_hinting 1
 r_font_disable_freetype 0
 r_font_size_snapping 2
+
+// uid2name
+seta cl_allow_uid2name -1 "-1 = ask if the player wants to disable/enable this feature, 0 = disable, 1 = enable uid2name (allows showing your name in race rankings for instance)"
index 9ed7d92e3630a5c6e115c3c044ba98390f7b8fd7..924932090e219c963c96ff8a68f676c1ed148f82 100644 (file)
@@ -633,6 +633,39 @@ float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
        if(menu_visible)
                if(menu_action(bInputType, nPrimary, nSecondary))
                        return TRUE;
+
+       if(autocvar_g_allow_uid2name == -1 && gametype == GAME_CTS || gametype == GAME_RACE && panel_fg_alpha) // don't lock keys before we actually see what's going on
+       {
+               string vyes_keys;
+               float keys;
+               vyes_keys = findkeysforcommand("vyes");
+               keys = tokenize(vyes_keys);
+
+               float i;
+               for (i = 0; i < keys; ++i)
+               {
+                       if(nPrimary == stof(argv(i)))
+                       {
+                               cvar_set("cl_allow_uid2name", "1");
+                               return true;
+                       }
+               }
+
+               string vno_keys;
+               vno_keys = findkeysforcommand("vno");
+               keys = tokenize(vno_keys);
+
+               float i;
+               for (i = 0; i < keys; ++i)
+               {
+                       if(nPrimary == stof(argv(i)))
+                       {
+                               cvar_set("cl_allow_uid2name", "0");
+                               return true;
+                       }
+               }
+       }
+
        return bSkipKey;
 }
 
index a98b70683ab62b05760434e58efbde9961a25747..e34df2ff06ce2935feb9dc828697e952ccd89e61 100644 (file)
@@ -236,3 +236,5 @@ var string autocvar_hud_panel_infomessages_bg_padding;
 var float autocvar_hud_panel_infomessages_flip;
 
 var float autocvar_scoreboard_border_thickness;
+
+var float autocvar_cl_allow_uid2name;
index 262aee4e11b5f5d7ebf96f0b356e48a0d0a98c81..235c2be52645c14f826453b13340406689a852bd 100644 (file)
@@ -3767,6 +3767,12 @@ float vote_change; // "time" when vote_active changed
 
 void HUD_VoteWindow(void) 
 {
+       if(autocvar_cl_allow_uid2name == -1 && gametype == GAME_CTS || gametype == GAME_RACE)
+       {
+               vote_active = 1;
+               vote_called_vote = "This allows your name to be identified in stats instead of \"Unregistered player\"";
+       }
+
        if(!autocvar_hud_panel_vote && !autocvar__hud_configure)
                return;
 
@@ -3837,6 +3843,8 @@ void HUD_VoteWindow(void)
        mySize = newSize;
 
        s = "A vote has been called for:";
+       if(autocvar_cl_allow_uid2name == -1 && gametype == GAME_CTS || gametype == GAME_RACE)
+               s = "Allow servers to store and display your name?"
        drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
        s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1.75/8), stringwidth_colors);
        if(autocvar__hud_configure)
index e5af0f3cf8196f8073cd2f4cfa747575ed82a316..51ab37a4c8b708cdcd82556c55c5b3379b3535da 100644 (file)
@@ -3026,6 +3026,18 @@ void PlayerPostThink (void)
 
        playerdemo_write();
 
+       if((g_cts || g_race) && self.cvar_cl_allow_uid2name)
+       {
+               if(!self.stored_netname)
+                       self.stored_netname = strzone(uid2name(self.crypto_idfp));
+               if(self.stored_netname != self.stored_netname)
+               {
+                       db_put(ServerProgsDB, strcat("uid2name", self.crypto_idfp), self.netname);
+                       strunzone(self.stored_netname);
+                       self.stored_netname = strzone(self.netname);
+               }
+       }
+
        /*
        if(g_race)
                dprint(sprintf("%f %.6f\n", time, race_GetFractionalLapCount(self)));
index d1d86ed79a19703ceb266b0f5d8bf40e6836d7d2..74e5d428f3a7cba8c0e7c14e4508796128f9a482 100644 (file)
@@ -329,6 +329,9 @@ float sv_loddistance2;
 .float cvar_cl_gunalign;
 .float cvar_cl_noantilag;
 
+.float cvar_cl_allow_uid2name;
+.string stored_netname;
+
 void Announce(string snd);
 void AnnounceTo(entity e, string snd);
 
index b65b8f17dedc4232f0354fcce07b07e07da092d4..7eb518caac41d044fb9cb44c64f25531020344ae 100644 (file)
@@ -625,6 +625,7 @@ void GetCvars(float f)
        GetCvars_handleFloat(s, f, cvar_cl_forceplayermodelsfromxonotic, "cl_forceplayermodelsfromxonotic");
 #endif
        GetCvars_handleFloatOnce(s, f, cvar_cl_gunalign, "cl_gunalign");
+       GetCvars_handleFloat(s, f, cvar_cl_allow_uid2name, "cl_allow_uid2name");
 
        // fixup of switchweapon (needed for LMS or when spectating is disabled, as PutClientInServer comes too early)
        if (f > 0)