]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/client.qc
Fix string length checks in world.qc and add VM_TEMPSTRING_MAXSIZE
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / client.qc
index 886a29163ea8f86e57727e76fa8710f60c1d9b93..00063bba214fae3ba064a144ec18bf2983db2eae 100644 (file)
@@ -52,7 +52,8 @@
 #include <server/chat.qh>
 #include <server/cheats.qh>
 #include <server/clientkill.qh>
-#include <server/command/common.qh>
+#include <server/command/banning.qh>
+#include <server/command/cmd.qh>
 #include <server/command/common.qh>
 #include <server/command/vote.qh>
 #include <server/compat/quake3.qh>
@@ -642,7 +643,8 @@ void PutPlayerInServer(entity this)
        this.respawn_flags = 0;
        this.respawn_time = 0;
        STAT(RESPAWN_TIME, this) = 0;
-       this.scale = ((q3compat && autocvar_sv_q3compat_changehitbox) ? 0.9 : autocvar_sv_player_scale);
+       // DP model scaling uses 1/16 accuracy and 13/16 is closest to 56/69
+       this.scale = ((q3compat && autocvar_sv_q3compat_changehitbox) ? 0.8125 : autocvar_sv_player_scale);
        this.fade_time = 0;
        this.pain_finished = 0;
        this.pushltime = 0;
@@ -980,7 +982,7 @@ bool findinlist_abbrev(string tofind, string list)
                return false; // empty list or search, just return
 
        // this function allows abbreviated strings!
-       FOREACH_WORD(list, it == substring(tofind, 0, strlen(it)),
+       FOREACH_WORD(list, it != "" && it == substring(tofind, 0, strlen(it)),
        {
                return true;
        });
@@ -1008,6 +1010,8 @@ bool PlayerInIDList(entity p, string idlist)
 
 bool PlayerInList(entity player, string list)
 {
+       if (list == "")
+               return false;
        return boolean(PlayerInIDList(player, list) || PlayerInIPList(player, list));
 }
 
@@ -1040,9 +1044,7 @@ void SendWelcomeMessage(entity this, int msg_type)
        WriteByte(msg_type, boolean(autocvar_g_campaign));
        if (boolean(autocvar_g_campaign))
        {
-               WriteString(msg_type, Campaign_GetTitle());
                WriteByte(msg_type, Campaign_GetLevelNum());
-               WriteString(msg_type, Campaign_GetMessage());
                return;
        }
        WriteString(msg_type, autocvar_hostname);
@@ -1186,6 +1188,13 @@ void ClientConnect(entity this)
 
        Handicap_Initialize(this);
 
+       // playban
+       if (PlayerInList(this, autocvar_g_playban_list))
+               TRANSMUTE(Observer, this);
+
+       if (PlayerInList(this, autocvar_g_chatban_list)) // chatban
+               CS(this).muted = true;
+
        MUTATOR_CALLHOOK(ClientConnect, this);
 
        if (player_count == 1)
@@ -1209,6 +1218,20 @@ void ClientDisconnect(entity this)
 {
        assert(IS_CLIENT(this), return);
 
+       /* from "ignore" command */
+       strfree(this.ignore_list);
+       FOREACH_CLIENT(IS_REAL_CLIENT(it) && it.ignore_list,
+       {
+               if(it.crypto_idfp && it.crypto_idfp != "")
+                       continue;
+               string mylist = ignore_removefromlist(it, this);
+               if(it.ignore_list)
+                       strunzone(it.ignore_list);
+
+               it.ignore_list = strzone(mylist);
+       });
+       /* from "ignore" command */
+
        PlayerStats_GameReport_FinalizePlayer(this);
        if (this.vehicle) vehicles_exit(this.vehicle, VHEF_RELEASE);
        if (CS(this).active_minigame) part_minigame(this);
@@ -2026,6 +2049,17 @@ int nJoinAllowed(entity this, entity ignore)
        if(this && (Player_GetForcedTeamIndex(this) == TEAM_FORCE_SPECTATOR))
                return 0; // forced spectators can never join
 
+       static float msg_time = 0;
+       if(this && !INGAME(this) && ignore && PlayerInList(this, autocvar_g_playban_list))
+       {
+               if(time > msg_time)
+               {
+                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_JOIN_PLAYBAN);
+                       msg_time = time + 0.5;
+               }
+               return 0;
+       }
+
        // TODO simplify this
        int totalClients = 0;
        int currentlyPlaying = 0;
@@ -2044,7 +2078,6 @@ int nJoinAllowed(entity this, entity ignore)
        else if(player_limit > 0 && currentlyPlaying < player_limit)
                free_slots = min(maxclients - totalClients, player_limit - currentlyPlaying);
 
-       static float msg_time = 0;
        if(this && !INGAME(this) && ignore && !free_slots && time > msg_time)
        {
                Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_JOIN_PREVENT, player_limit);
@@ -2265,6 +2298,11 @@ void ObserverOrSpectatorThink(entity this)
                CS(this).autojoin_checked = true;
                TRANSMUTE(Player, this);
                PutClientInServer(this);
+
+               .entity weaponentity = weaponentities[0];
+               if(this.(weaponentity).m_weapon == WEP_Null)
+                       W_NextWeapon(this, 0, weaponentity);
+
                return;
        }
 
@@ -2318,6 +2356,7 @@ void ObserverOrSpectatorThink(entity this)
                if ((is_spec && !(PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_ATCK2(this)))
                        || (!is_spec && !(PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_JUMP(this)))) {
                        this.flags |= FL_JUMPRELEASED;
+                       // primary attack pressed
                        if(this.flags & FL_SPAWNING)
                        {
                                this.flags &= ~FL_SPAWNING;