]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
Merge remote branch 'origin/master' into tzork/gm_nexball
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index 0d82ed855c7b8a99175d6014c696904d142c63ca..ca94d967abf6afa79cd7b8f3209c49a8db935dc0 100644 (file)
@@ -158,7 +158,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
                if (thisdist < shortest)
                        shortest = thisdist;
        }
-       if(shortest < mindist)
+       if(shortest > mindist)
                prio += SPAWN_PRIO_GOOD_DISTANCE;
 
        spawn_score = prio * '1 0 0' + shortest * '0 1 0';
@@ -311,7 +311,7 @@ entity SelectSpawnPoint (float anypoint)
        if (!spot)
        {
                if(autocvar_spawn_debug)
-                       GotoNextMap();
+                       GotoNextMap(0);
                else
                {
                        if(some_spawn_has_been_used)
@@ -421,9 +421,6 @@ void PutObserverInServer (void)
        if(self.flagcarried)
                DropFlag(self.flagcarried, world, world);
 
-       if(self.ballcarried && g_nexball)
-               DropBall(self.ballcarried, self.origin + self.ballcarried.origin, self.velocity);
-
        WaypointSprite_PlayerDead();
 
        if not(g_ca)  // don't reset teams when moving a ca player to the spectators
@@ -584,13 +581,6 @@ void FixPlayermodel()
                }
        }
 
-       if(self.modelindex == 0 && self.deadflag == DEAD_NO)
-       {
-               if(self.model != "")
-                       bprint("\{1}^1Player ", self.netname, "^1 has a zero modelindex, trying to fix...\n");
-               self.model = ""; // force the != checks to return true
-       }
-
        if(defaultmodel != "")
        {
                if (defaultmodel != self.model)
@@ -925,6 +915,8 @@ void PutClientInServer (void)
 
                if(!self.alivetime)
                        self.alivetime = time;
+
+               antilag_clear(self);
        } else if(self.classname == "observer" || (g_ca && !allowed_to_spawn)) {
                PutObserverInServer ();
        }
@@ -1121,7 +1113,7 @@ void KillIndicator_Think()
                return;
        }
 
-       if (!self.owner.modelindex)
+       if (self.owner.effects & CSQCMODEL_EF_INVISIBLE)
        {
                self.owner.killindicator = world;
                remove(self);
@@ -1181,7 +1173,7 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2
 
     if(!self.killindicator)
        {
-               if(self.modelindex && self.deadflag == DEAD_NO)
+               if(self.deadflag == DEAD_NO)
                {
                        killtime = max(killtime, self.clientkill_nexttime - time);
                        self.clientkill_nexttime = time + killtime + autocvar_g_balance_kill_antispam;
@@ -1509,8 +1501,6 @@ void ClientConnect (void)
        else
                stuffcmd(self, "set _teams_available 0\n");
 
-       stuffcmd(self, strcat("set gametype ", ftos(game), "\n"));
-
        if(g_arena || g_ca)
        {
                self.classname = "observer";
@@ -1655,8 +1645,6 @@ void ClientDisconnect (void)
        RemoveGrapplingHook(self);
        if(self.flagcarried)
                DropFlag(self.flagcarried, world, world);
-       if(self.ballcarried && g_nexball)
-               DropBall(self.ballcarried, self.origin + self.ballcarried.origin, self.velocity);
 
        // Here, everything has been done that requires this player to be a client.
 
@@ -1705,7 +1693,7 @@ void ClientDisconnect (void)
 void ChatBubbleThink()
 {
        self.nextthink = time;
-       if (!self.owner.modelindex || self.owner.chatbubbleentity != self)
+       if ((self.owner.effects & CSQCMODEL_EF_INVISIBLE) || self.owner.chatbubbleentity != self)
        {
                if(self.owner) // but why can that ever be world?
                        self.owner.chatbubbleentity = world;
@@ -1724,7 +1712,7 @@ void ChatBubbleThink()
 
 void UpdateChatBubble()
 {
-       if (!self.modelindex)
+       if (self.effects & CSQCMODEL_EF_INVISIBLE)
                return;
        // spawn a chatbubble entity if needed
        if (!self.chatbubbleentity)
@@ -1764,7 +1752,7 @@ void UpdateChatBubble()
 .float oldcolormap;
 void respawn(void)
 {
-       if(self.modelindex != 0 && autocvar_g_respawn_ghosts)
+       if(!(self.effects & CSQCMODEL_EF_INVISIBLE) && autocvar_g_respawn_ghosts)
        {
                self.solid = SOLID_NOT;
                self.takedamage = DAMAGE_NO;
@@ -1813,9 +1801,9 @@ void player_powerups (void)
                self.modelflags &~= MF_ROCKET;
        }
 
-       self.effects &~= (EF_DIMLIGHT | EF_RED | EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT | EF_FLAME | EF_NODEPTHTEST);
+       self.effects &~= (EF_RED | EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT | EF_FLAME | EF_NODEPTHTEST);
 
-       if(!self.modelindex || self.deadflag) // don't apply the flags if the player is gibbed
+       if((self.effects & CSQCMODEL_EF_INVISIBLE) || self.deadflag) // don't apply the flags if the player is gibbed
                return;
 
        Fire_ApplyDamage(self);
@@ -1850,7 +1838,7 @@ void player_powerups (void)
                if (self.items & IT_INVINCIBLE)
                {
                        play_countdown(self.invincible_finished, "misc/poweroff.wav");
-                       if (time > self.invincible_finished && autocvar_g_balance_powerup_timer)
+                       if (time > self.invincible_finished)
                        {
                                self.items = self.items - (self.items & IT_INVINCIBLE);
                                sprint(self, "^3Speed has worn off\n");
@@ -1871,7 +1859,7 @@ void player_powerups (void)
                {
                        play_countdown(self.strength_finished, "misc/poweroff.wav");
                        self.effects = self.effects | (EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT);
-                       if (time > self.strength_finished && autocvar_g_balance_powerup_timer)
+                       if (time > self.strength_finished)
                        {
                                self.items = self.items - (self.items & IT_STRENGTH);
                                sprint(self, "^3Strength has worn off\n");
@@ -1889,7 +1877,7 @@ void player_powerups (void)
                {
                        play_countdown(self.invincible_finished, "misc/poweroff.wav");
                        self.effects = self.effects | (EF_RED | EF_ADDITIVE | EF_FULLBRIGHT);
-                       if (time > self.invincible_finished && autocvar_g_balance_powerup_timer)
+                       if (time > self.invincible_finished)
                        {
                                self.items = self.items - (self.items & IT_INVINCIBLE);
                                sprint(self, "^3Shield has worn off\n");
@@ -2928,10 +2916,8 @@ void PlayerPostThink (void)
                stuffcmd(self, strcat("name ", self.netname, substring(ftos(random()), 2, -1), "\n"));
        }
 
-       if(sv_maxidle && frametime)
+       if(sv_maxidle && frametime) // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
        {
-               // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
-               float timeleft;
                if (time - self.parm_idlesince < 1) // instead of (time == self.parm_idlesince) to support sv_maxidle <= 10
                {
                        if(self.idlekick_lasttimeleft)
@@ -2939,34 +2925,37 @@ void PlayerPostThink (void)
                                Send_CSQC_Centerprint_Generic_Expire(self, CPID_DISCONNECT_IDLING);
                                self.idlekick_lasttimeleft = 0;
                        }
-                       return;
-               }
-               timeleft = ceil(sv_maxidle - (time - self.parm_idlesince));
-               if(timeleft == min(10, sv_maxidle - 1)) // - 1 to support sv_maxidle <= 10
-               {
-                       if(!self.idlekick_lasttimeleft)
-                               Send_CSQC_Centerprint_Generic(self, CPID_DISCONNECT_IDLING, "^3Stop idling!\n^3Disconnecting in %d seconds...", 1, timeleft);
-               }
-               if(timeleft <= 0)
-               {
-                       bprint("^3", self.netname, "^3 was kicked for idling.\n");
-                       AnnounceTo(self, "terminated");
-                       dropclient(self);
-                       return;
                }
-               else if(timeleft <= 10)
+               else
                {
-                       if(timeleft != self.idlekick_lasttimeleft)
-                               AnnounceTo(self, ftos(timeleft));
-                       self.idlekick_lasttimeleft = timeleft;
+                       float timeleft;
+                       timeleft = ceil(sv_maxidle - (time - self.parm_idlesince));
+                       if(timeleft == min(10, sv_maxidle - 1)) // - 1 to support sv_maxidle <= 10
+                       {
+                               if(!self.idlekick_lasttimeleft)
+                                       Send_CSQC_Centerprint_Generic(self, CPID_DISCONNECT_IDLING, "^3Stop idling!\n^3Disconnecting in %d seconds...", 1, timeleft);
+                       }
+                       if(timeleft <= 0)
+                       {
+                               bprint("^3", self.netname, "^3 was kicked for idling.\n");
+                               AnnounceTo(self, "terminated");
+                               dropclient(self);
+                               return;
+                       }
+                       else if(timeleft <= 10)
+                       {
+                               if(timeleft != self.idlekick_lasttimeleft)
+                                       AnnounceTo(self, ftos(timeleft));
+                               self.idlekick_lasttimeleft = timeleft;
+                       }
                }
        }
 
 #ifdef TETRIS
        if(self.impulse == 100)
                ImpulseCommands();
-       if (TetrisPostFrame())
-               return;
+       if (!TetrisPostFrame())
+       {
 #endif
 
        CheatFrame();
@@ -2987,6 +2976,10 @@ void PlayerPostThink (void)
                //do nothing
        }
        
+#ifdef TETRIS
+       }
+#endif
+
        /*
        float i;
        for(i = 0; i < 1000; ++i)