]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into divVerent/crypto2
authorRudolf Polzer <divverent@alientrap.org>
Thu, 7 Oct 2010 13:40:03 +0000 (15:40 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Thu, 7 Oct 2010 13:40:03 +0000 (15:40 +0200)
Conflicts:
qcsrc/server/ipban.qc

1  2 
defaultXonotic.cfg
qcsrc/client/Main.qc
qcsrc/server/cl_client.qc
qcsrc/server/ipban.qc

diff --combined defaultXonotic.cfg
index 555da4afad130949e43b810bf22a302fb6b93a76,e00da32085eb42889faf444dcdc9464384fc005e..7312a34e4aed51515b0c52ef1c62b623f97a0a58
@@@ -198,6 -198,10 +198,10 @@@ seta crosshair_fireball_color_green 1.
  seta crosshair_fireball_color_blue 0.2        "crosshair color blue component to display when wielding the fireball"
  seta crosshair_fireball_color_alpha 1 "crosshair alpha value to display when wielding the fireball"
  seta crosshair_fireball_size 1        "crosshair size when wielding the fireball"
+ seta crosshair_nexvelocity_color_red 0.8
+ seta crosshair_nexvelocity_color_green 0
+ seta crosshair_nexvelocity_color_blue 0
+ seta crosshair_nexvelocity_alpha 0.25
  seta cl_reticle_stretch 0 "whether to stretch reticles so they fit the screen (brakes image proportions)"
  seta cl_reticle_item_nex 1 "draw aiming recticle for the nex weapon's zoom, 0 disables and values between 0 and 1 change alpha"
  seta cl_reticle_item_normal 1 "draw recticle when zooming with the zoom button, 0 disables and values between 0 and 1 change alpha"
@@@ -521,6 -525,7 +525,7 @@@ set g_player_brightness 0  "set to 2 fo
  seta g_balance_cloaked_alpha 0.25
  
  set g_playerclip_collisions 1 "0 = disable collision testing against playerclips, might be useful on some defrag maps"
+ set g_botclip_collisions 1 "0 = disable collision testing against botclips, might be useful on some defrag maps"
  
  set welcome_message_time 8
  
@@@ -1255,9 -1260,8 +1260,9 @@@ set g_keyhunt_teams 
  set cl_gravity 800    "but ignored anyway"
  
  set g_ban_default_bantime 5400        "90 minutes"
- set g_ban_default_masksize 3  "whole 255.255.255.0 networks (set to 4 for single IPs); when UID support is compiled in, masksize 0 means banning by UID"
+ set g_ban_default_masksize 3  "masksize 0 means banning by UID only, 1 means banning by /8 (IPv6: /32) network, 2 means banning by /16 (IPv6: /48) network, 3 means banning by /24 (IPv6: /56) network, 4 means banning by single IP (IPv6: /64 network)"
  set g_banned_list ""  "format: IP remainingtime IP remainingtime ..."
 +set g_banned_list_idmode "1"  "when set, the IP banning system always uses the ID over the IP address (so a user in a banned IP range can connect if they have a valid signed ID)"
  alias bans "sv_cmd bans"
  alias ban "sv_cmd ban $*"         // usage: ban address(maybe incomplete, like 1.2.3) bantime(seconds)
  alias kickban "sv_cmd kickban $*" // usage: kickban # playerno bantime(seconds) masksize(bytes)
diff --combined qcsrc/client/Main.qc
index 320ed94727aed077678eda54eade821b53ece437,27b9284cd1e903e181490fa20470569bf62aa546..8b053cfd38fd553477a140ade161e159aef20dff
@@@ -148,6 -148,23 +148,6 @@@ void CSQC_Init(void
        }
        Tuba_Precache();
  
 -#ifdef UID
 -      {
 -              // find the user ID
 -              string uid;
 -              registercvar("_cl_userid", "", CVAR_SAVE);
 -              uid = cvar_string("_cl_userid");
 -              if(strlen(uid) < 16)
 -              {
 -                      uid = "";
 -                      for(i = 0; i < 4; ++i)
 -                              uid = strcat(uid, substring(ftos(floor(10000 + random() * 10000)), 1, -1));
 -              }
 -              cvar_set("_cl_userid", uid);
 -              localcmd(strcat("\ncmd uid ", uid, "\n"));
 -      }
 -#endif
 -
        get_mi_min_max_texcoords(1); // try the CLEVER way first
        minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
        shortmapname = mi_shortname;
@@@ -1334,6 -1351,11 +1334,11 @@@ float CSQC_Parse_TempEntity(
                        Net_WeaponComplain();
                        bHandled = true;
                        break;
+               case TE_CSQC_NEX_VELOCITY:
+                       nex_minvelocity = ReadShort();
+                       nex_maxvelocity = ReadShort();
+                       bHandled = true;
+                       break;
                default:
                        // No special logic for this temporary entity; return 0 so the engine can handle it
                        bHandled = false;
index 06fbb72895acf2cfd9628d30f1241d0cb329a89f,d5ffae1e50d33f416fa9d05a30185107eb183e2b..bf542ab34f8a4f8dc012a369d0dcf41a684a9dd0
@@@ -6,6 -6,14 +6,14 @@@ void send_CSQC_teamnagger() 
        WriteByte(0, TE_CSQC_TEAMNAGGER);
  }
  
+ void send_CSQC_nexvelocity(entity e) {
+       msg_entity = e;
+       WriteByte(MSG_ONE, SVC_TEMPENTITY);
+       WriteByte(MSG_ONE, TE_CSQC_NEX_VELOCITY);
+       WriteShort(MSG_ONE, cvar("g_balance_nex_velocitydependent_minspeed"));
+       WriteShort(MSG_ONE, cvar("g_balance_nex_velocitydependent_maxspeed"));
+ }
  void Announce(string snd) {
        WriteByte(MSG_ALL, SVC_TEMPENTITY);
        WriteByte(MSG_ALL, TE_CSQC_ANNOUNCE);
@@@ -866,10 -874,11 +874,11 @@@ void PutClientInServer (void
                self.iscreature = TRUE;
                self.movetype = MOVETYPE_WALK;
                self.solid = SOLID_SLIDEBOX;
+               self.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_SOLID;
                if(cvar("g_playerclip_collisions"))
-                       self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
-               else
-                       self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
+                       self.dphitcontentsmask |= DPCONTENTS_PLAYERCLIP;
+               if(clienttype(self) == CLIENTTYPE_BOT && cvar("g_botclip_collisions"))
+                       self.dphitcontentsmask |= DPCONTENTS_BOTCLIP;
                self.frags = FRAGS_PLAYER;
                if(independent_players)
                        MAKE_INDEPENDENT_PLAYER(self);
@@@ -1387,6 -1396,10 +1396,6 @@@ Called when a client connects to the se
  string ColoredTeamName(float t);
  void DecodeLevelParms (void);
  //void dom_player_join_team(entity pl);
 -#ifdef UID
 -.float uid_kicktime;
 -.string uid;
 -#endif
  void ClientConnect (void)
  {
        float t;
        else
                self.hitplotfh = -1;
  
 -#ifdef UID
 -      if(clienttype(self) == CLIENTTYPE_REAL)
 -      if not(self.uid)
 -              self.uid_kicktime = time + 60;
 -#endif
 -
        if(g_race || g_cts) {
                string rr;
                if(g_cts)
        else if(cvar("sv_teamnagger") && !(cvar("bot_vs_human") && (c3==-1 && c4==-1)) && !g_ca) // teamnagger is currently bad for ca
                send_CSQC_teamnagger();
  
+       send_CSQC_nexvelocity(self);
        CheatInitClient();
  }
  
@@@ -2901,6 -2922,16 +2912,6 @@@ void PlayerPostThink (void
                self.stat_count -= 1;
        }
  
 -#ifdef UID
 -      if(self.uid_kicktime)
 -      if(time > self.uid_kicktime)
 -      {
 -              bprint("^3", self.netname, "^3 was kicked for missing UID.\n");
 -              dropclient(self);
 -              return;
 -      }
 -#endif
 -
        if(sv_maxidle && frametime)
        {
                // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
diff --combined qcsrc/server/ipban.qc
index 1240aea6e977b615fc270d1ab38cd361d6416a9e,1ec0f4d3eadc7903f1a6490903283213d50b288c..293a9b4e40497cf4a2302ecf3da74bd1e11c500d
@@@ -160,15 -160,12 +160,15 @@@ void OnlineBanList_URI_Get_Callback(flo
                        continue;
  
                l = strlen(ip);
 -              for(j = 0; j < l; ++j)
 -                      if(strstrofs("0123456789.", substring(ip, j, 1), 0) == -1)
 -                      {
 -                              print("Invalid character ", substring(ip, j, 1), " in IP address ", ip, ". Skipping this ban.\n");
 -                              goto skip;
 -                      }
 +              if(l != 44) // length 44 is a cryptographic ID
 +              {
 +                      for(j = 0; j < l; ++j)
 +                              if(strstrofs("0123456789.", substring(ip, j, 1), 0) == -1)
 +                              {
 +                                      print("Invalid character ", substring(ip, j, 1), " in IP address ", ip, ". Skipping this ban.\n");
 +                                      goto skip;
 +                              }
 +              }
  
                if(cvar("g_ban_sync_trusted_servers_verify"))
                        if((strstrofs(strcat(";", OnlineBanList_Servers, ";"), strcat(";", serverip, ";"), 0) == -1))
@@@ -246,7 -243,9 +246,7 @@@ string ban_ip1
  string ban_ip2;
  string ban_ip3;
  string ban_ip4;
 -#ifdef UID
 -string ban_uid;
 -#endif
 +string ban_idfp;
  
  void Ban_SaveBans()
  {
@@@ -336,45 -335,60 +336,61 @@@ float Ban_GetClientIP(entity client
        float i1, i2, i3, i4;
        string s;
  
 -#ifdef UID
 -      ban_uid = client.uid;
 -#endif
 +      if(client.crypto_keyfp)
 +              ban_idfp = client.crypto_idfp;
 +      else
 +              ban_idfp = string_null;
  
        s = client.netaddress;
  
        i1 = strstrofs(s, ".", 0);
        if(i1 < 0)
-               i1 = strstrofs(s, ":", 0);
-       if(i1 < 0)
-               return FALSE;
+               goto ipv6;
        i2 = strstrofs(s, ".", i1 + 1);
-       if(i2 < 0)
-               i2 = strstrofs(s, ":", i1 + 1);
        if(i2 < 0)
                return FALSE;
        i3 = strstrofs(s, ".", i2 + 1);
-       if(i3 < 0)
-               i3 = strstrofs(s, ":", i2 + 1);
        if(i3 < 0)
                return FALSE;
        i4 = strstrofs(s, ".", i3 + 1);
-       if(i4 < 0)
-               i4 = strstrofs(s, ":", i3 + 1);
        if(i4 >= 0)
                s = substring(s, 0, i4);
+       
+       ban_ip1 = substring(s, 0, i1); // 8
+       ban_ip2 = substring(s, 0, i2); // 16
+       ban_ip3 = substring(s, 0, i3); // 24
+       ban_ip4 = strcat1(s); // 32
+       return TRUE;
  
-       ban_ip1 = substring(s, 0, i1);
-       ban_ip2 = substring(s, 0, i2);
-       ban_ip3 = substring(s, 0, i3);
-       ban_ip4 = strcat1(s);
+ :ipv6
+       i1 = strstrofs(s, ":", 0);
+       if(i1 < 0)
+               return FALSE;
+       i1 = strstrofs(s, ":", i1 + 1);
+       if(i1 < 0)
+               return FALSE;
+       i2 = strstrofs(s, ":", i1 + 1);
+       if(i2 < 0)
+               return FALSE;
+       i3 = strstrofs(s, ":", i2 + 1);
+       if(i3 < 0)
+               return FALSE;
+       ban_ip1 = strcat(substring(s, 0, i1), "::/32"); // 32
+       ban_ip2 = strcat(substring(s, 0, i2), "::/48"); // 48
+       ban_ip4 = strcat(substring(s, 0, i3), "::/64"); // 64
+       if(i3 - i2 > 3) // means there is more than 2 digits and a : in the range
+               ban_ip3 = strcat(substring(s, 0, i2), ":", substring(s, i2 + 1, i3 - i2 - 3), "00::/56");
+       else
+               ban_ip3 = strcat(substring(s, 0, i2), ":0::/56");
  
        return TRUE;
  }
  
  float Ban_IsClientBanned(entity client, float idx)
  {
 -      float i, b, e;
 +      float i, b, e, ipbanned;
        if(!ban_loaded)
                Ban_LoadBans();
        if(!Ban_GetClientIP(client))
                b = idx;
                e = idx + 1;
        }
 +      ipbanned = FALSE;
        for(i = b; i < e; ++i)
        {
                string s;
                if(time > ban_expire[i])
                        continue;
                s = ban_ip[i];
 -              if(ban_ip1 == s) return TRUE;
 -              if(ban_ip2 == s) return TRUE;
 -              if(ban_ip3 == s) return TRUE;
 -              if(ban_ip4 == s) return TRUE;
 -#ifdef UID
 -              if(ban_uid == s) return TRUE;
 -#endif
 +              if(ban_ip1 == s) ipbanned = TRUE;
 +              if(ban_ip2 == s) ipbanned = TRUE;
 +              if(ban_ip3 == s) ipbanned = TRUE;
 +              if(ban_ip4 == s) ipbanned = TRUE;
 +              if(ban_idfp == s) return TRUE;
        }
 +      if(ipbanned)
 +              if(!cvar("g_banned_list_idmode") || !ban_idfp)
 +                      return TRUE;
        return FALSE;
  }
  
@@@ -548,9 -560,12 +564,9 @@@ void Ban_KickBanClient(entity client, f
                default:
                        Ban_Insert(ban_ip4, bantime, reason, 1);
                        break;
 -#ifdef UID
 -              case 0:
 -                      Ban_Insert(ban_uid, bantime, reason, 1);
 -                      break;
 -#endif
        }
 +      if(ban_idfp)
 +              Ban_Insert(ban_idfp, bantime, reason, 1);
        /*
         * not needed, as we enforce the ban in Ban_Insert anyway
        // and kick him