From: FruitieX Date: Tue, 26 Oct 2010 13:12:18 +0000 (+0300) Subject: uid2name backend X-Git-Tag: xonotic-v0.1.0preview~202^2~23 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=38e318418d059dd1be5bdbf230ebc37181b06632;p=xonotic%2Fxonotic-data.pk3dir.git uid2name backend --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index e6c7f39bb..a5558f947 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -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)" diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 9ed7d92e3..924932090 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -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; } diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index a98b70683..e34df2ff0 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -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; diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 262aee4e1..235c2be52 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -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) diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index e5af0f3cf..51ab37a4c 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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))); diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index d1d86ed79..74e5d428f 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -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); diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index b65b8f17d..7eb518caa 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -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)