]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
Merge branch 'master' into Mario/classname_checks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index 5d29bf7e1537e4099fba46418a467cb2bde7cb57..4f741fa4435abe5481cecf737e67e0a1ced851fb 100644 (file)
@@ -17,7 +17,7 @@ float ClientData_Send(entity to, float sf)
        entity e;
 
        e = to;
-       if(to.classname == "spectator")
+       if(IS_SPEC(to))
                e = to.enemy;
 
        sf = 0;
@@ -68,7 +68,7 @@ void ClientData_Touch(entity e)
        FOR_EACH_REALCLIENT(e2)
        {
                if(e2 != e)
-                       if(e2.classname == "spectator")
+                       if(IS_SPEC(e2))
                                if(e2.enemy == e)
                                        e2.clientdata.SendFlags = 1;
        }
@@ -124,7 +124,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
                if(spot.target == "")
                        return '-1 0 0';
 
-       if(clienttype(self) == CLIENTTYPE_REAL)
+       if(IS_REAL_CLIENT(self))
        {
                if(spot.restriction == 1)
                        return '-1 0 0';
@@ -378,7 +378,7 @@ void PutObserverInServer (void)
                error("No spawnpoints for observers?!?\n");
        RemoveGrapplingHook(self); // Wazat's Grappling Hook
 
-       if(clienttype(self) == CLIENTTYPE_REAL)
+       if(IS_REAL_CLIENT(self))
        {
                msg_entity = self;
                WriteByte(MSG_ONE, SVC_SETVIEW);
@@ -627,7 +627,8 @@ void PutClientInServer (void)
        if(gameover)
                self.classname = "observer";
 
-       if(self.classname == "player") {
+       if(IS_PLAYER(self))
+       {
                entity spot, oldself;
                float j;
 
@@ -657,7 +658,7 @@ void PutClientInServer (void)
                self.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_SOLID;
                if(autocvar_g_playerclip_collisions)
                        self.dphitcontentsmask |= DPCONTENTS_PLAYERCLIP;
-               if(clienttype(self) == CLIENTTYPE_BOT && autocvar_g_botclip_collisions)
+               if(IS_BOT_CLIENT(self) && autocvar_g_botclip_collisions)
                        self.dphitcontentsmask |= DPCONTENTS_BOTCLIP;
                self.frags = FRAGS_PLAYER;
                if(INDEPENDENT_PLAYERS)
@@ -868,7 +869,7 @@ void PutClientInServer (void)
 
                if (autocvar_g_spawnsound)
                        soundat(world, self.origin, CH_TRIGGER, "misc/spawn.wav", VOL_BASE, ATTN_NORM);
-       } else if(self.classname == "observer") {
+       } else if(IS_OBSERVER(self)) {
                PutObserverInServer ();
        }
 }
@@ -1082,7 +1083,7 @@ void KillIndicator_Think()
        {
                if(self.cnt <= 10)
                        setmodel(self, strcat("models/sprites/", ftos(self.cnt), ".spr32"));
-               if(clienttype(self.owner) == CLIENTTYPE_REAL)
+               if(IS_REAL_CLIENT(self.owner))
                {
                        if(self.cnt <= 10)
                                { Send_Notification(NOTIF_ONE, self.owner, MSG_ANNCE, Announcer_PickNumber(self.cnt)); }
@@ -1126,7 +1127,7 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2
                        self.clientkill_nexttime = time + killtime + autocvar_g_balance_kill_antispam;
                }
 
-               if(killtime <= 0 || self.classname != "player" || self.deadflag != DEAD_NO)
+               if(killtime <= 0 || !IS_PLAYER(self) || self.deadflag != DEAD_NO)
                {
                        ClientKill_Now();
                }
@@ -1168,28 +1169,28 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2
                if(targetteam == 0) // just die
                {
                        self.killindicator.colormod = '0 0 0';
-                       if(clienttype(self) == CLIENTTYPE_REAL)
+                       if(IS_REAL_CLIENT(self))
                        if(self.killindicator.cnt > 0)
                                Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_TEAMCHANGE_SUICIDE, self.killindicator.cnt);
                }
                else if(targetteam == -1) // auto
                {
                        self.killindicator.colormod = '0 1 0';
-                       if(clienttype(self) == CLIENTTYPE_REAL)
+                       if(IS_REAL_CLIENT(self))
                        if(self.killindicator.cnt > 0)
                                Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_TEAMCHANGE_AUTO, self.killindicator.cnt);
                }
                else if(targetteam == -2) // spectate
                {
                        self.killindicator.colormod = '0.5 0.5 0.5';
-                       if(clienttype(self) == CLIENTTYPE_REAL)
+                       if(IS_REAL_CLIENT(self))
                        if(self.killindicator.cnt > 0)
                                Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_TEAMCHANGE_SPECTATE, self.killindicator.cnt);
                }
                else
                {
                        self.killindicator.colormod = Team_ColorRGB(targetteam);
-                       if(clienttype(self) == CLIENTTYPE_REAL)
+                       if(IS_REAL_CLIENT(self))
                        if(self.killindicator.cnt > 0)
                                Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, APP_TEAM_NUM_4(targetteam, CENTER_TEAMCHANGE_), self.killindicator.cnt);
                }
@@ -1202,7 +1203,7 @@ void ClientKill (void)
        if(gameover) return;
        if(self.player_blocked) return;
        if(self.freezetag_frozen) return;
-
+       
        ClientKill_TeamChange(0);
 }
 
@@ -1281,7 +1282,7 @@ void ClientConnect (void)
 {
        float t;
 
-       if(self.flags & FL_CLIENT)
+       if(IS_CLIENT(self))
        {
                print("Warning: ClientConnect, but already connected!\n");
                return;
@@ -1322,7 +1323,7 @@ void ClientConnect (void)
        // identify the right forced team
        if(autocvar_g_campaign)
        {
-               if(clienttype(self) == CLIENTTYPE_REAL) // only players, not bots
+               if(IS_REAL_CLIENT(self)) // only players, not bots
                {
                        switch(autocvar_g_campaign_forceteam)
                        {
@@ -1389,11 +1390,11 @@ void ClientConnect (void)
 
        PlayerStats_AddEvent(sprintf("kills-%d", self.playerid));
 
-    if(clienttype(self) == CLIENTTYPE_BOT)
+    if(IS_BOT_CLIENT(self))
         PlayerStats_AddPlayer(self);
 
        if(autocvar_sv_eventlog)
-               GameLogEcho(strcat(":join:", ftos(self.playerid), ":", ftos(num_for_edict(self)), ":", ((clienttype(self) == CLIENTTYPE_REAL) ? self.netaddress : "bot"), ":", self.netname));
+               GameLogEcho(strcat(":join:", ftos(self.playerid), ":", ftos(num_for_edict(self)), ":", ((IS_REAL_CLIENT(self)) ? self.netaddress : "bot"), ":", self.netname));
 
        LogTeamchange(self.playerid, self.team, 1);
 
@@ -1401,7 +1402,7 @@ void ClientConnect (void)
 
        self.netname_previous = strzone(self.netname);
 
-       if((self.classname == STR_PLAYER && teamplay))
+       if(IS_PLAYER(self) && teamplay)
                Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT_4(self, INFO_JOIN_CONNECT_TEAM_), self.netname);
        else
                Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_JOIN_CONNECT, self.netname);
@@ -1446,7 +1447,7 @@ void ClientConnect (void)
        self.jointime = time;
        self.allowed_timeouts = autocvar_sv_timeout_number;
 
-       if(clienttype(self) == CLIENTTYPE_REAL)
+       if(IS_REAL_CLIENT(self))
        {
                if(!autocvar_g_campaign)
                {
@@ -1507,7 +1508,7 @@ void ClientConnect (void)
 
        self.model_randomizer = random();
 
-       if(clienttype(self) == CLIENTTYPE_REAL)
+       if(IS_REAL_CLIENT(self))
                sv_notice_join();
 
        MUTATOR_CALLHOOK(ClientConnect);
@@ -1526,7 +1527,7 @@ void ClientDisconnect (void)
        if(self.vehicle)
            vehicles_exit(VHEF_RELESE);
 
-       if not(self.flags & FL_CLIENT)
+       if not(IS_CLIENT(self))
        {
                print("Warning: ClientDisconnect without ClientConnect\n");
                return;
@@ -1683,7 +1684,7 @@ void respawn(void)
 
 void play_countdown(float finished, string samp)
 {
-       if(clienttype(self) == CLIENTTYPE_REAL)
+       if(IS_REAL_CLIENT(self))
                if(floor(finished - time - frametime) != floor(finished - time))
                        if(finished - time < 6)
                                sound (self, CH_INFO, samp, VOL_BASE, ATTN_NORM);
@@ -2100,7 +2101,7 @@ float SpectateUpdate() {
        if (self == self.enemy)
                return 0;
 
-       if(self.enemy.classname != "player")
+       if not(IS_PLAYER(self.enemy))
                return 0;
 
        SpectateCopy(self.enemy);
@@ -2151,7 +2152,7 @@ float SpectateNext(entity _prefer) {
        if (other)
                self.enemy = other;
 
-       if(self.enemy.classname == "player") {
+       if(IS_PLAYER(self.enemy)) {
            /*if(self.enemy.vehicle)
            {      
             
@@ -2271,7 +2272,7 @@ float nJoinAllowed(entity ignore) {
 
        float currentlyPlaying = 0;
        FOR_EACH_REALCLIENT(e)
-               if(e.classname == "player" || e.caplayer == 1)
+               if(IS_PLAYER(e) || e.caplayer == 1)
                        currentlyPlaying += 1;
 
        if(currentlyPlaying < autocvar_g_maxplayers)
@@ -2285,7 +2286,7 @@ float nJoinAllowed(entity ignore) {
  * g_maxplayers_spectator_blocktime seconds
  */
 void checkSpectatorBlock() {
-       if(self.classname == "spectator" || self.classname == "observer") {
+       if(IS_SPEC(self) || IS_OBSERVER(self)) {
                if( time > (self.spectatortime + autocvar_g_maxplayers_spectator_blocktime) ) {
                        Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_QUIT_KICK_SPECTATING);
                        dropclient(self);
@@ -2298,7 +2299,7 @@ void PrintWelcomeMessage()
        if(self.motd_actived_time == 0)
        {
                if (autocvar_g_campaign) {
-                       if ((self.classname == "player" && self.BUTTON_INFO) || (self.classname != "player")) {
+                       if ((IS_PLAYER(self) && self.BUTTON_INFO) || (!IS_PLAYER(self))) {
                                self.motd_actived_time = time;
                                Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_MOTD, campaign_message);
                        }
@@ -2314,7 +2315,7 @@ void PrintWelcomeMessage()
                if (autocvar_g_campaign) {
                        if (self.BUTTON_INFO)
                                self.motd_actived_time = time;
-                       else if ((time - self.motd_actived_time > 2) && self.classname == "player") { // hide it some seconds after BUTTON_INFO has been released
+                       else if ((time - self.motd_actived_time > 2) && IS_PLAYER(self)) { // hide it some seconds after BUTTON_INFO has been released
                                self.motd_actived_time = 0;
                                Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_MOTD);
                        }
@@ -2411,7 +2412,7 @@ void SpectatorThink()
 
 void PlayerUseKey()
 {
-       if(self.classname != "player")
+       if not(IS_PLAYER(self))
                return;
 
        if(self.vehicle)
@@ -2520,10 +2521,11 @@ void PlayerPreThink (void)
                self.usekeypressed = self.BUTTON_USE;
        }
 
-       if(clienttype(self) == CLIENTTYPE_REAL)
+       if(IS_REAL_CLIENT(self))
                PrintWelcomeMessage();
 
-       if(self.classname == "player") {
+       if(IS_PLAYER(self))
+       {
 
                CheckRules_Player();
 
@@ -2746,9 +2748,9 @@ void PlayerPreThink (void)
                if (intermission_running)
                        IntermissionThink ();   // otherwise a button could be missed between
                return;
-       } else if(self.classname == "observer") {
+       } else if(IS_OBSERVER(self)) {
                ObserverThink();
-       } else if(self.classname == "spectator") {
+       } else if(IS_SPEC(self)) {
                SpectatorThink();
        }
 
@@ -2757,9 +2759,9 @@ void PlayerPreThink (void)
 
        float oldspectatee_status;
        oldspectatee_status = self.spectatee_status;
-       if(self.classname == "spectator")
+       if(IS_SPEC(self))
                self.spectatee_status = num_for_edict(self.enemy);
-       else if(self.classname == "observer")
+       else if(IS_OBSERVER(self))
                self.spectatee_status = num_for_edict(self);
        else
                self.spectatee_status = 0;
@@ -2884,7 +2886,7 @@ void PlayerPostThink (void)
 
        //CheckPlayerJump();
 
-       if(self.classname == "player") {
+       if(IS_PLAYER(self)) {
                CheckRules_Player();
                UpdateChatBubble();
                if (self.impulse)