]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use IS_PLAYER & IS_SPEC instead of classname checks
authorMario <mario.mario@y7mail.com>
Thu, 7 Mar 2013 05:18:09 +0000 (16:18 +1100)
committerMario <mario.mario@y7mail.com>
Thu, 7 Mar 2013 05:18:09 +0000 (16:18 +1100)
qcsrc/server/monsters/lib/monsters.qc
qcsrc/server/monsters/lib/spawn.qc
qcsrc/server/mutators/gamemode_towerdefense.qc

index 9ce62c9c496ebcf5e0c421d00ad81da32bbf7aef..a9d70694582e931b879568f5dea45c9b0f8456f3 100644 (file)
@@ -2,7 +2,7 @@
 
 void M_Item_Touch ()
 {
-       if(self && other.classname == STR_PLAYER && other.deadflag == DEAD_NO)
+       if(self && IS_PLAYER(other) && other.deadflag == DEAD_NO)
        {
                Item_Touch();
                self.think = SUB_Remove;
@@ -88,7 +88,7 @@ float monster_isvalidtarget (entity targ, entity ent, float neutral)
        if(targ.items & IT_INVISIBILITY)
                return FALSE; // enemy is invisible
        
-       if(targ.classname == STR_SPECTATOR || targ.classname == STR_OBSERVER)
+       if(IS_SPEC(targ) || IS_OBSERVER(targ))
                return FALSE; // enemy is a spectator
        
        if(targ.deadflag != DEAD_NO || ent.deadflag != DEAD_NO || targ.health <= 0 || ent.health <= 0)
@@ -693,7 +693,7 @@ void monster_hook_death()
        if(self.realowner.classname == "monster_spawner")
                self.realowner.spawner_monstercount -= 1;
                
-       if(self.realowner.flags & FL_CLIENT)
+       if(IS_CLIENT(self.realowner))
                self.realowner.monstercount -= 1;
                
        totalspawned -= 1;
@@ -757,7 +757,7 @@ float monster_initialize(string  net_name,
 
        if(self.netname == "")
        {
-               if(net_name != "" && self.realowner.classname == STR_PLAYER)
+               if(net_name != "" && IS_PLAYER(self.realowner))
                        net_name = strzone(strdecolorize(sprintf("%s's %s", self.realowner.netname, net_name)));
                self.netname = ((net_name == "") ? self.classname : net_name);
        }
index 467c02a22bdb812903e3ef1421fc019e8719ba63..d9d68f1c65a7db8609cce9e002de6fecfefa88a7 100644 (file)
@@ -12,7 +12,7 @@ entity spawnmonster (string monster, entity spawnedby, entity own, vector orig,
 {
        if not(autocvar_g_monsters)
        {
-               if(spawnedby.flags & FL_CLIENT)
+               if(IS_CLIENT(spawnedby))
                        Send_Notification(NOTIF_ONE, spawnedby, MSG_INFO, INFO_MONSTERS_DISABLED);
                        
                return world;
@@ -46,7 +46,7 @@ entity spawnmonster (string monster, entity spawnedby, entity own, vector orig,
        
        if (spawnedby.classname == "monster_swarm")
                e.monster_owner = own;  
-       else if(spawnedby.flags & FL_CLIENT)
+       else if(IS_CLIENT(spawnedby))
        {
                if(teamplay && autocvar_g_monsters_teams)
                        e.team = spawnedby.team; // colors handled in spawn code
index fc3075078243fa357ff0f8f84876c5db6264951b..e75afac288a3829014d1814269e7ed38733927c6 100644 (file)
@@ -66,7 +66,7 @@ void td_generator_die()
 
 void td_generator_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) 
 {
-       if(attacker.classname == STR_PLAYER || attacker.turrcaps_flags & TFL_TURRCAPS_ISTURRET || attacker.vehicle_flags & VHF_ISVEHICLE)
+       if(IS_PLAYER(attacker) || attacker.turrcaps_flags & TFL_TURRCAPS_ISTURRET || attacker.vehicle_flags & VHF_ISVEHICLE)
                return;
        
        Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_TD_GENDAMAGED);
@@ -236,7 +236,7 @@ void spawn_barricade()
 
 void spawnturret(entity spawnedby, entity own, string turet, vector orig)
 {
-       if(spawnedby.classname != STR_PLAYER)
+       if(!IS_PLAYER(spawnedby))
        {
                dprint("Warning: A non-player entity tried to spawn a turret\n");
                return;
@@ -708,10 +708,10 @@ MUTATOR_HOOKFUNCTION(td_PlayerDamage)
        if(frag_attacker.vehicle_flags & VHF_ISVEHICLE && !(frag_target.flags & FL_MONSTER))
                frag_damage = 0;
                
-       if(!autocvar_g_td_pvp && frag_attacker != frag_target && frag_target.classname == STR_PLAYER && frag_attacker.classname == STR_PLAYER)
+       if(!autocvar_g_td_pvp && frag_attacker != frag_target && IS_PLAYER(frag_target) && IS_PLAYER(frag_attacker))
                frag_damage = 0;
                
-       if(frag_attacker.turrcaps_flags & TFL_TURRCAPS_ISTURRET && frag_target.classname == STR_PLAYER)
+       if(frag_attacker.turrcaps_flags & TFL_TURRCAPS_ISTURRET && IS_PLAYER(frag_target))
                frag_damage = 0;
                
        if((frag_target.turrcaps_flags & TFL_TURRCAPS_ISTURRET) && !(frag_attacker.flags & FL_MONSTER || frag_attacker.turrcaps_flags & TFL_TURRCAPS_SUPPORT))
@@ -822,12 +822,12 @@ MUTATOR_HOOKFUNCTION(td_MonsterDies)
        current_monsters -= 1;
        monsters_killed += 1;
        
-       if(frag_attacker.classname == STR_PLAYER)
+       if(IS_PLAYER(frag_attacker))
        {
                PlayerScore_Add(frag_attacker, SP_TD_SCORE, autocvar_g_td_kill_points);
                PlayerScore_Add(frag_attacker, SP_TD_KILLS, 1);
        }
-       else if(frag_attacker.realowner.classname == STR_PLAYER)
+       else if(IS_PLAYER(frag_attacker.realowner))
        {
                PlayerScore_Add(frag_attacker.realowner, SP_TD_SCORE, autocvar_g_td_turretkill_points);
                PlayerScore_Add(frag_attacker.realowner, SP_TD_TURKILLS, 1);
@@ -921,7 +921,7 @@ MUTATOR_HOOKFUNCTION(td_PlayerCommand)
                        Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_TD_LIST, "mlrs walker plasma towerbuff flac barricade");
                        return TRUE;
                }
-               if(self.classname != STR_PLAYER || self.health <= 0)
+               if(!IS_PLAYER(self) || self.health <= 0)
                { 
                        Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_TD_CANTSPAWN);
                        return TRUE;