]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move the code that stores player name into the server db into its own function
authorterencehill <piuntn@gmail.com>
Sat, 13 Feb 2021 11:13:11 +0000 (12:13 +0100)
committerterencehill <piuntn@gmail.com>
Sat, 13 Feb 2021 11:58:29 +0000 (12:58 +0100)
qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc
qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc
qcsrc/common/gamemodes/gamemode/race/sv_race.qc
qcsrc/server/race.qc
qcsrc/server/race.qh

index 83f9d2fb644a056156fe0b3374267d1352639b1b..7ec85cdaf1958a67aea7b2d14b3267e16cc1bf9f 100644 (file)
@@ -2318,16 +2318,7 @@ MUTATOR_HOOKFUNCTION(ctf, GetPressedKeys)
 
        entity player = M_ARGV(0, entity);
 
-       if(CS_CVAR(player).cvar_cl_allow_uidtracking == 1 && CS_CVAR(player).cvar_cl_allow_uid2name == 1)
-       {
-               if (!player.stored_netname)
-                       player.stored_netname = strzone(uid2name(player.crypto_idfp));
-               if(player.stored_netname != player.netname)
-               {
-                       db_put(ServerProgsDB, strcat("/uid2name/", player.crypto_idfp), player.netname);
-                       strcpy(player.stored_netname, player.netname);
-               }
-       }
+       race_checkAndWriteName(player);
 }
 
 MUTATOR_HOOKFUNCTION(ctf, PortalTeleport)
index bca0d1077dd31590472242102fd478b394265c06..9861ab887cc8ff49a92f74fa2e5372e85d821b12 100644 (file)
@@ -282,16 +282,7 @@ MUTATOR_HOOKFUNCTION(cts, GetPressedKeys)
 {
        entity player = M_ARGV(0, entity);
 
-       if(CS_CVAR(player).cvar_cl_allow_uidtracking == 1 && CS_CVAR(player).cvar_cl_allow_uid2name == 1)
-       {
-               if (!player.stored_netname)
-                       player.stored_netname = strzone(uid2name(player.crypto_idfp));
-               if(player.stored_netname != player.netname)
-               {
-                       db_put(ServerProgsDB, strcat("/uid2name/", player.crypto_idfp), player.netname);
-                       strcpy(player.stored_netname, player.netname);
-               }
-       }
+       race_checkAndWriteName(player);
 
        if (!IS_OBSERVER(player))
        {
index 8148dda2d39f6964a503a3bc8229a8d317673fc6..e092c91f126ab58d2f3d585411db7fadda29b248 100644 (file)
@@ -328,16 +328,7 @@ MUTATOR_HOOKFUNCTION(rc, GetPressedKeys)
 {
        entity player = M_ARGV(0, entity);
 
-       if(CS_CVAR(player).cvar_cl_allow_uidtracking == 1 && CS_CVAR(player).cvar_cl_allow_uid2name == 1)
-       {
-               if (!player.stored_netname)
-                       player.stored_netname = strzone(uid2name(player.crypto_idfp));
-               if(player.stored_netname != player.netname)
-               {
-                       db_put(ServerProgsDB, strcat("/uid2name/", player.crypto_idfp), player.netname);
-                       strcpy(player.stored_netname, player.netname);
-               }
-       }
+       race_checkAndWriteName(player);
 
        if (!IS_OBSERVER(player))
        {
index 70a98083efb22a03171f78a0adae0fe623c189ac..40b2ca148483f50707a5c9c155a62005404881be 100644 (file)
@@ -30,6 +30,8 @@
 #include <server/weapons/common.qh>
 #include <server/world.qh>
 
+.string stored_netname; // TODO: store this information independently of race-based gamemodes
+
 string uid2name(string myuid)
 {
        string s = db_get(ServerProgsDB, strcat("/uid2name/", myuid));
@@ -150,6 +152,20 @@ string race_readName(string map, float pos)
        return uid2name(db_get(ServerProgsDB, strcat(map, rr, "crypto_idfp", ftos(pos))));
 }
 
+void race_checkAndWriteName(entity player)
+{
+       if(CS_CVAR(player).cvar_cl_allow_uidtracking == 1 && CS_CVAR(player).cvar_cl_allow_uid2name == 1)
+       {
+               if (!player.stored_netname)
+                       player.stored_netname = strzone(uid2name(player.crypto_idfp));
+               if(player.stored_netname != player.netname)
+               {
+                       db_put(ServerProgsDB, strcat("/uid2name/", player.crypto_idfp), player.netname);
+                       strcpy(player.stored_netname, player.netname);
+               }
+       }
+}
+
 
 const float MAX_CHECKPOINTS = 255;
 
index 0bef0b59a66033d0f5fe436cbef7aad4f76393b7..09aec88236194121289efb34973a7ad6b4a6fd0a 100644 (file)
@@ -2,8 +2,6 @@
 
 bool autocvar_g_allow_checkpoints;
 
-.string stored_netname; // TODO: store this information independently of race-based gamemodes
-
 float race_teams;
 
 // scores
@@ -47,6 +45,7 @@ float race_GetFractionalLapCount(entity e);
 float race_readTime(string map, float pos);
 string race_readUID(string map, float pos);
 string race_readName(string map, float pos);
+void race_checkAndWriteName(entity player);
 void race_ClearRecords();
 void race_SendNextCheckpoint(entity e, float spec);
 void race_PreparePlayer(entity this);