]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Teams: setteam TimePath/TEAMNUMBERS_THAT_ARENT_STUPID
authorTimePath <andrew.hardaker1995@gmail.com>
Thu, 17 Mar 2016 09:33:10 +0000 (20:33 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 17 Mar 2016 10:19:28 +0000 (21:19 +1100)
51 files changed:
qcsrc/client/main.qc
qcsrc/client/miscfunctions.qc
qcsrc/client/teamradar.qc
qcsrc/client/weapons/projectile.qc
qcsrc/common/effects/qc/damageeffects.qc
qcsrc/common/effects/qc/gibs.qc
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/gamemodes/gamemode/onslaught/cl_controlpoint.qc
qcsrc/common/gamemodes/gamemode/onslaught/cl_generator.qc
qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
qcsrc/common/mapinfo.qc
qcsrc/common/mapinfo.qh
qcsrc/common/minigames/cl_minigames.qc
qcsrc/common/minigames/minigame/bd.qc
qcsrc/common/minigames/minigame/nmm.qc
qcsrc/common/minigames/minigame/pong.qc
qcsrc/common/minigames/minigame/pp.qc
qcsrc/common/minigames/minigame/ps.qc
qcsrc/common/minigames/minigame/snake.qc
qcsrc/common/minigames/minigame/ttt.qc
qcsrc/common/minigames/sv_minigames.qc
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/mutators/mutator/buffs/all.qh
qcsrc/common/mutators/mutator/buffs/buffs.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
qcsrc/common/physics/player.qc
qcsrc/common/teams.qh
qcsrc/common/triggers/func/breakable.qc
qcsrc/common/triggers/trigger/jumppads.qc
qcsrc/common/triggers/trigger/multi.qc
qcsrc/common/triggers/trigger/relay_teamcheck.qc
qcsrc/common/triggers/trigger/teleport.qc
qcsrc/common/turrets/cl_turrets.qc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/lib/_all.inc
qcsrc/server/bot/bot.qc
qcsrc/server/cl_client.qc
qcsrc/server/command/vote.qc
qcsrc/server/mutators/mutator/gamemode_assault.qc
qcsrc/server/mutators/mutator/gamemode_ca.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_domination.qc
qcsrc/server/mutators/mutator/gamemode_invasion.qc
qcsrc/server/mutators/mutator/gamemode_tdm.qc
qcsrc/server/scores.qc
qcsrc/server/spawnpoints.qc
qcsrc/server/sv_main.qc
qcsrc/server/weapons/spawning.qc

index b56504006cfcd4bca350a6eeb12cd056d13515c6..258d58e68ee727e27c4d3d110ea9993014606395 100644 (file)
@@ -270,7 +270,7 @@ float SetTeam(entity o, int _team)
        {
                if (!o.has_team)
                {
-                       o.__team = _team;
+                   setteam(o, _team);
                        tm = GetTeam(_team, true);
                        tm.team_size += 1;
                        o.has_team = 1;
@@ -280,7 +280,7 @@ float SetTeam(entity o, int _team)
                {
                        tm = GetTeam(TMID(o.team), false);
                        tm.team_size -= 1;
-                       o.__team = _team;
+                       setteam(o, _team);
                        tm = GetTeam(_team, true);
                        tm.team_size += 1;
                        return true;
@@ -472,7 +472,7 @@ NET_HANDLE(ENT_CLIENT_TEAMSCORES, bool isnew)
        int i;
        entity o;
 
-       this.__team = ReadByte();
+       setteam(this, ReadByte());
        o = this.owner = GetTeam(TMID(this.team), true); // these team numbers can always be trusted
 
     int sf, lf;
index fcafca3fb38fb17f7be6cf26642bb9b12137b0ae..614369096f5691e0931cbf6e7b056d83f6e46ce1 100644 (file)
@@ -125,7 +125,7 @@ entity GetTeam(int _team, bool add)
        if (!add)
                return world;
        entity tm = new_pure(team);
-       tm.__team = _team;
+       setteam(tm, _team);
        teamslots[num] = tm;
        RegisterTeam(tm);
        return tm;
index c832a5866a5e36c06c48b86d7fdef776b9af36ca..68f83c2420e0120b505b7d446a94fd3a0e841fe2 100644 (file)
@@ -220,7 +220,7 @@ NET_HANDLE(ENT_CLIENT_RADARLINK, bool isnew)
 
        if(sendflags & 4)
        {
-               this.__team = ReadByte();
+               setteam(this, ReadByte());
        }
 
        return = true;
index ae69b8f5a8b232151957ebf19d15b2179229d87b..7045721932838555c80ccbb01260f15d3814e463 100644 (file)
@@ -270,7 +270,7 @@ NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew)
                        this.fade_rate = 0;
                }
 
-               this.__team = ReadByte() - 1;
+               setteam(this, ReadByte() - 1);
        }
 
        if (f & 2)
index 4da72a00e315f0163890a01733275a77152e4bfa..04a4233b7ffc5acc877e239282fa850e25164fc4 100644 (file)
@@ -182,7 +182,7 @@ void DamageEffect(vector hitorg, float thedamage, int type, int specnum)
        setattachment(e, self, gettaginfo_name); // attach to the given bone
        e.owner = self;
        e.cnt = time + life;
-       e.__team = _particleeffectnum(effectname);
+       setteam(e, _particleeffectnum(effectname));
        e.think = DamageEffect_Think;
        e.nextthink = time;
        self.total_damages += 1;
index 43afbf7e21a0c8c16811f8b97aa14bf893385f0a..ff7046806aa911fc2b3620ad92851a52557c297b 100644 (file)
@@ -36,9 +36,9 @@ void Violence_GibSplash_At(vector org, vector dir, float type, float amount, ent
        // if this is a copied dead body, send the num of its player instead
        // TODO: remove this field, read from model txt files
        if(gibowner.classname == "body")
-               e.__team = etof(gibowner.enemy);
+               setteam(e, etof(gibowner.enemy));
        else
-               e.__team = etof(gibowner);
+               setteam(e, etof(gibowner));
 
        setorigin(e, org);
        e.velocity = dir;
index ca299b9a8ef76668ec3cf022b6eaea5c0abc0353..5a1ff6e222b41133ab81769c7f40520ef8ec9bc4 100644 (file)
@@ -236,7 +236,7 @@ void InitBall()
        self.nextthink = time + autocvar_g_nexball_delay_idle + 3;
        self.teamtime = 0;
        self.pusher = world;
-       self.__team = 0;
+       setteam(self, 0);
        _sound(self, CH_TRIGGER, self.noise1, VOL_BASE, ATTEN_NORM);
        WaypointSprite_Ping(self.waypointsprite_attachedforcarrier);
        LogNB("init", world);
@@ -445,7 +445,7 @@ spawnfunc(nexball_team)
                remove(self);
                return;
        }
-       self.__team = self.cnt + 1;
+       setteam(self, self.cnt + 1);
 }
 
 void nb_spawnteam(string teamname, float teamcolor)
@@ -454,7 +454,7 @@ void nb_spawnteam(string teamname, float teamcolor)
        entity e = new(nexball_team);
        e.netname = teamname;
        e.cnt = teamcolor;
-       e.__team = e.cnt + 1;
+       setteam(e, e.cnt + 1);
        nb_teams += 1;
 }
 
@@ -628,28 +628,28 @@ void SpawnGoal()
 
 spawnfunc(nexball_redgoal)
 {
-       self.__team = NUM_TEAM_1;
+       setteam(self, NUM_TEAM_1);
        SpawnGoal();
 }
 spawnfunc(nexball_bluegoal)
 {
-       self.__team = NUM_TEAM_2;
+       setteam(self, NUM_TEAM_2);
        SpawnGoal();
 }
 spawnfunc(nexball_yellowgoal)
 {
-       self.__team = NUM_TEAM_3;
+       setteam(self, NUM_TEAM_3);
        SpawnGoal();
 }
 spawnfunc(nexball_pinkgoal)
 {
-       self.__team = NUM_TEAM_4;
+       setteam(self, NUM_TEAM_4);
        SpawnGoal();
 }
 
 spawnfunc(nexball_fault)
 {
-       self.__team = GOAL_FAULT;
+       setteam(self, GOAL_FAULT);
        if(self.noise == "")
                self.noise = strzone(SND(TYPEHIT));
        SpawnGoal();
@@ -657,7 +657,7 @@ spawnfunc(nexball_fault)
 
 spawnfunc(nexball_out)
 {
-       self.__team = GOAL_OUT;
+       setteam(self, GOAL_OUT);
        if(self.noise == "")
                self.noise = strzone(SND(TYPEHIT));
        SpawnGoal();
index 8e973198a0304a96fc755c7e1d56525a894fb040..a4f5a424bab94b5bdee3f3d07417d059556c2806 100644 (file)
@@ -169,7 +169,7 @@ NET_HANDLE(ENT_CLIENT_CONTROLPOINT_ICON, bool isnew)
                this.health = ReadByte();
                this.max_health = ReadByte();
                this.count = ReadByte();
-               this.__team = ReadByte();
+               setteam(this, ReadByte());
                this.iscaptured = ReadByte();
 
                if(!this.count)
@@ -184,7 +184,7 @@ NET_HANDLE(ENT_CLIENT_CONTROLPOINT_ICON, bool isnew)
                int _tmp = ReadByte();
                if(_tmp != TMID(this.team))
                {
-                       this.__team = _tmp;
+                       setteam(this, _tmp);
                        cpicon_changeteam(this);
                }
 
index a4fdcff89970134b57b94b277f27e6eb601073d9..0bbc8f3e38467025e7786e2f6e6dc344abee2134 100644 (file)
@@ -194,7 +194,7 @@ NET_HANDLE(ENT_CLIENT_GENERATOR, bool isnew)
                this.health = ReadByte();
                this.max_health = ReadByte();
                this.count = ReadByte();
-               this.__team = ReadByte();
+               setteam(this, ReadByte());
 
                if(!this.count)
                        this.count = 40;
@@ -209,7 +209,7 @@ NET_HANDLE(ENT_CLIENT_GENERATOR, bool isnew)
                _tmp = ReadByte();
                if(_tmp != TMID(this.team))
                {
-                       this.__team = _tmp;
+                       setteam(this, _tmp);
                        generator_changeteam(this);
                }
 
index c585773520d389255b9c580b5e0644610c562c7e..a8d34b9201c973f3074adeeb6c72df24db797c54 100644 (file)
@@ -538,7 +538,7 @@ void ons_ControlPoint_Icon_Damage(entity this, entity inflictor, entity attacker
                this.owner.goalentity = world;
                this.owner.islinked = false;
                this.owner.iscaptured = false;
-               this.owner.__team = 0;
+               setteam(this.owner, 0);
                this.owner.colormap = 1024;
 
                WaypointSprite_UpdateMaxHealth(this.owner.sprite, 0);
@@ -609,14 +609,14 @@ void ons_ControlPoint_Icon_Think()
                // unteam the spawnpoint if needed
                int t = TMID(self.owner.team);
                if(!self.owner.islinked)
-                       self.owner.__team = 0;
+                       setteam(self.owner, 0);
 
                setself(self.owner);
                activator = self;
                SUB_UseTargets ();
                setself(this);
 
-               self.owner.__team = t;
+               setteam(self.owner, t);
 
                self.owner.waslinked = self.owner.islinked;
        }
@@ -834,7 +834,7 @@ void ons_ControlPoint_Reset(entity this)
                remove(this.goalentity);
 
        this.goalentity = world;
-       this.__team = 0;
+       setteam(this, 0);
        this.colormap = 1024;
        this.iscaptured = false;
        this.islinked = false;
@@ -875,7 +875,7 @@ void ons_ControlPoint_Setup(entity cp)
        ons_worldcplist = cp;
 
        cp.netname = "Control point";
-       cp.__team = 0;
+       setteam(cp, 0);
        cp.solid = SOLID_BBOX;
        cp.movetype = MOVETYPE_NONE;
        cp.touch = ons_ControlPoint_Touch;
@@ -1058,7 +1058,7 @@ void ons_GeneratorThink()
 
 void ons_GeneratorReset(entity this)
 {
-       this.__team = this.team_saved;
+       setteam(this, this.team_saved);
        this.lasthealth = this.max_health = this.health = autocvar_g_onslaught_gen_health;
        this.takedamage = DAMAGE_AIM;
        this.bot_attack = true;
index 1d3d21444bfe50fd77eda1706d0d1a5875b2e431..1bac4f0c555ce91f1f647ad52a2369a049f332e2 100644 (file)
@@ -601,9 +601,9 @@ string _MapInfo_GetDefaultEx(float t)
        return "";
 }
 
-float _MapInfo_GetTeamPlayBool(float t)
+bool _MapInfo_GetTeamPlayBool(float t)
 {
-       FOREACH(Gametypes, it.items == t, return it.__team);
+       FOREACH(Gametypes, it.items == t, return it.m_teamplay);
        return false;
 }
 
index 7ed9e534c8c0df33aea1877bd9c0925ca90dd5e1..a7cfa0f08dbf7858d65a2d46bb74e7f49f3113c4 100644 (file)
@@ -19,7 +19,7 @@ CLASS(Gametype, Object)
     /** human readable name */
     ATTRIB(Gametype, message, string, string_null)
     /** does this gametype support teamplay? */
-    ATTRIB(Gametype, __team, bool, false)
+    ATTRIB(Gametype, m_teamplay, bool, false)
     /** game type defaults */
     ATTRIB(Gametype, model2, string, string_null)
     /** game type description */
@@ -40,7 +40,7 @@ CLASS(Gametype, Object)
         this.netname = g_name;
         this.mdl = sname;
         this.message = hname;
-        this.__team = gteamplay;
+        this.m_teamplay = gteamplay;
         this.m_mutators = mutators;
         this.model2 = defaults;
         this.gametype_description = gdescription;
index d408b5f0f983a967f84840a3c367341c63f5d8ee..6ac6164704fe2a424fd0ad5d3530b7c4bdab2124 100644 (file)
@@ -220,7 +220,7 @@ NET_HANDLE(ENT_CLIENT_MINIGAME, bool isnew)
                minigame_ent = self.owner;
 
                if ( sf & MINIG_SF_UPDATE )
-                       self.__team = ReadByte();
+                       setteam(self, ReadByte());
 
                if ( activate )
                {
index 0f243b37574240e01e62061209d38bc6c81f2160..a60d47af0aedb53cdd235263cd5518011c5693f1 100644 (file)
@@ -255,7 +255,7 @@ void bd_editor_place(entity minigame, entity player, string pos, int thetile, st
                        }
 
                        entity piece = msle_spawn(minigame,"minigame_board_piece");
-                       piece.__team = 1;
+                       setteam(piece, 1);
                        piece.netname = strzone(pos);
                        piece.bd_tiletype = thetile;
                        piece.bd_dir = '0 -1 0';
@@ -467,7 +467,7 @@ entity bd_load_piece(entity minigame, string s)
        tokenize_console(bd_string);
 
        entity e = msle_spawn(minigame,"minigame_board_piece");
-       e.__team = 1;
+       setteam(e, 1);
        e.bd_dir = '0 -1 0';
 
        int argv_num = 0;
index dec04df798b2a6b15cec6ed0a49ebbf418486e61..9da419c9f4d0ccaf482281558b2656a02fade039 100644 (file)
@@ -83,7 +83,7 @@ void nmm_spawn_tile(string id, entity minig, int distance)
        e.origin = minigame_tile_pos(id,7,7);
        e.netname = id;
        e.owner = minig;
-       e.__team = 0;
+       setteam(e, 0);
        e.nmm_tile_distance = distance;
        e.nmm_tile_hmill = strzone(nmm_tile_build_hmill(e));
        e.nmm_tile_vmill = strzone(nmm_tile_build_vmill(e));
@@ -222,10 +222,10 @@ int nmm_server_event(entity minigame, string event, ...)
                for ( int i = 0; i < 7; i++ )
                {
                        e = msle_spawn(minigame,"minigame_board_piece");
-                       e.__team = 1;
+                       setteam(e, 1);
                        e.minigame_flags = NMM_PIECE_HOME;
                        e = msle_spawn(minigame,"minigame_board_piece");
-                       e.__team = 2;
+                       setteam(e, 2);
                        e.minigame_flags = NMM_PIECE_HOME;
                }
 
index 335523bd1c8d812289355ffc6133673a0204bdf4..a1d01d428c80957dd0a97198beccd441fe986c85 100644 (file)
@@ -49,7 +49,7 @@ void pong_ball_throw(entity ball)
        ball.velocity_y = sin(angle)*autocvar_sv_minigames_pong_ball_speed;
        ball.think = pong_ball_think;
        ball.nextthink = time;
-       ball.__team = 0;
+       setteam(ball, 0);
        ball.SendFlags |= MINIG_SF_UPDATE|PONG_SF_BALLTEAM;
 }
 
@@ -65,7 +65,7 @@ void pong_ball_reset(entity ball)
        ball.velocity = '0 0 0';
        ball.origin = '0.5 0.5 0';
        ball.think = SUB_NullThink;
-       ball.__team = 0;
+       setteam(ball, 0);
        ball.SendFlags |= MINIG_SF_UPDATE|PONG_SF_BALLTEAM;
        ball.think = pong_ball_throwthink;
        ball.nextthink = time + autocvar_sv_minigames_pong_ball_wait;
@@ -159,7 +159,7 @@ void pong_ball_think()
                if ( pong_paddle_hit(self, i) )
                {
                        pong_paddle_bounce(self,i);
-                       self.__team = i;
+                       setteam(self, i);
                        self.SendFlags |= PONG_SF_BALLTEAM;
                        return;
                }
@@ -317,7 +317,7 @@ entity pong_paddle_spawn(entity minigame, int pl_team, entity real_player)
        paddle.origin = pong_team_to_paddlepos(pl_team);
        paddle.think = pong_paddle_think;
        paddle.nextthink = time;
-       paddle.__team = pl_team;
+       setteam(paddle, pl_team);
        paddle.mins = pong_team_to_box_halfsize(pl_team,-paddle.pong_length,-1/16);
        paddle.maxs = pong_team_to_box_halfsize(pl_team,paddle.pong_length,1/16);
 
index f7980d3fe6eb73ccbdce66a7ab1ceaff1ada32ca..ef1aa0d1f15c349cf0bb0d1fef59fc08a3075082 100644 (file)
@@ -114,7 +114,7 @@ void pp_move(entity minigame, entity player, string pos )
                        if(minigame.pp_curr_piece)
                        {
                                minigame.pp_curr_piece.cnt = 0;
-                               minigame.pp_curr_piece.__team = 5;
+                               setteam(minigame.pp_curr_piece, 5);
                                minigame_server_sendflags(minigame.pp_curr_piece,MINIG_SF_ALL);
                        }
 
@@ -157,7 +157,7 @@ void pp_setup_pieces(entity minigame)
                if(t1_true || t2_true)
                {
                        entity piece = msle_spawn(minigame,"minigame_board_piece");
-                       piece.__team = ((t1_true) ? 1 : 2);
+                       setteam(piece, ((t1_true) ? 1 : 2));
                        piece.netname = strzone(minigame_tile_buildname(i,t));
                        minigame_server_sendflags(piece,MINIG_SF_ALL);
                        minigame_server_sendflags(minigame,MINIG_SF_UPDATE);
index d39a74b1daa99b14cf1abf3b3ee71853b33f63f7..de804c5a6ee95b995de05d1e51c430cec8ec178e 100644 (file)
@@ -120,7 +120,7 @@ void ps_setup_pieces(entity minigame)
                if(i == floor(PS_NUM_CNT * 0.5) && t == floor(PS_LET_CNT * 0.5))
                        continue; // middle piece is empty
                entity piece = msle_spawn(minigame,"minigame_board_piece");
-               piece.__team = 1; // init default team?
+               setteam(piece, 1); // init default team?
                piece.netname = strzone(minigame_tile_buildname(t,i));
                minigame_server_sendflags(piece,MINIG_SF_ALL);
        }
index 56db93ae7a4d25cec9b619848a95197d36640f0b..071536d38af16e29a4b55a0680f696a7b29dfaa3 100644 (file)
@@ -98,7 +98,7 @@ void snake_new_mouse(entity minigame)
        }
 
        entity piece = msle_spawn(minigame,"minigame_board_piece");
-       piece.__team = 0;
+       setteam(piece, 0);
        piece.netname = strzone(RandomSelection_chosen_string);
        minigame_server_sendflags(piece,MINIG_SF_ALL);
 
@@ -178,7 +178,7 @@ void minigame_setup_snake(entity minigame, int pteam)
        }
 
        entity piece = msle_spawn(minigame,"minigame_board_piece");
-       piece.__team = pteam;
+       setteam(piece, pteam);
        piece.netname = strzone(RandomSelection_chosen_string);
        piece.cnt = 1;
        piece.snake_next = world;
index f6fef78673beda76d3b64d9b519a6f1cfac015c7..3f950314cf7b523a7a89774b9867753eeb8e13b3 100644 (file)
@@ -644,7 +644,7 @@ int ttt_client_event(entity minigame, string event, ...)
                                        {
                                                entity aiplayer = new(minigame_player);
                                                aiplayer.owner = minigame;
-                                               aiplayer.__team = ai;
+                                               setteam(aiplayer, ai);
                                                aiplayer.minigame_playerslot = 0;
                                                aiplayer.minigame_autoclean = 1;
                                                ttt_aimove(minigame);
index a4a496400302c8d85b4fa057968d31f647693f39..d28e18217b15eb9cfba0f87bb303e913bfd448fc 100644 (file)
@@ -136,7 +136,7 @@ int minigame_addplayer(entity minigame_session, entity player)
        {
                player_pointer.owner = minigame_session;
                player_pointer.minigame_players = player;
-               player_pointer.__team = mgteam;
+               setteam(player_pointer, mgteam);
                player_pointer.list_next = minigame_session.minigame_players;
                minigame_session.minigame_players = player_pointer;
                player.active_minigame = minigame_session;
index 0cc3760186db25a281cb9af97414f2f09aefcac5..d4652dd54a9da030b0d05e0a76aee420fa4d4d34 100644 (file)
@@ -177,7 +177,7 @@ void monster_changeteam(entity ent, float newteam)
 {
        if(!teamplay) { return; }
 
-       ent.__team = newteam;
+       setteam(ent, newteam);
        ent.monster_attack = true; // new team, activate attacking
        monster_setupcolors(ent);
 
@@ -185,7 +185,7 @@ void monster_changeteam(entity ent, float newteam)
        {
                WaypointSprite_UpdateTeamRadar(ent.sprite, RADARICON_DANGER, ((newteam) ? Team_ColorRGB(newteam) : '1 0 0'));
 
-               ent.sprite.__team = newteam;
+               setteam(ent.sprite, newteam);
                ent.sprite.SendFlags |= 1;
        }
 }
@@ -1313,7 +1313,7 @@ bool Monster_Spawn(entity this, int mon_id)
        if(this.monster_skill == MONSTER_SKILL_HARD) if(this.spawnflags & MONSTERSKILL_NOTHARD) { Monster_Remove(this); return false; }
 
        if(this.team && !teamplay)
-               this.__team = 0;
+               setteam(this, 0);
 
        if(!(this.spawnflags & MONSTERFLAG_SPAWNED)) // naturally spawned monster
        if(!(this.spawnflags & MONSTERFLAG_RESPAWNED)) // don't count re-spawning monsters either
index b05aa3ae70e35c8f84567533ded3de829e86f02b..d41d5c0c23642653d03cd58bd6e250b9000181e0 100644 (file)
@@ -45,7 +45,7 @@ ENDCLASS(Buff)
        void buff_Init_Compat(entity ent, entity replacement);
        #define BUFF_SPAWNFUNC(e, b, t) spawnfunc(item_buff_##e) { \
                self.buffs = b.m_itemid; \
-               self.__team = t; \
+               setteam(self, t); \
                buff_Init(self); \
        }
        #define BUFF_SPAWNFUNCS(e, b)                       \
index f18fc5439f10b052c72369d6c2a75815aa72c0f0..4f0ce51e53ef4a092b0198b4320782820541b26c 100644 (file)
@@ -412,7 +412,7 @@ void buff_Init(entity ent)
 {SELFPARAM();
        if(!cvar("g_buffs")) { remove(ent); return; }
 
-       if(!teamplay && ent.team) { ent.__team = 0; }
+       if(!teamplay && ent.team) { setteam(ent, 0); }
 
        entity buff = buff_FirstFromFlags(self.buffs);
 
@@ -459,9 +459,9 @@ void buff_Init(entity ent)
 void buff_Init_Compat(entity ent, entity replacement)
 {
        if (ent.spawnflags & 2)
-               ent.__team = NUM_TEAM_1;
+               setteam(ent, NUM_TEAM_1);
        else if (ent.spawnflags & 4)
-               ent.__team = NUM_TEAM_2;
+               setteam(ent, NUM_TEAM_2);
 
        ent.buffs = replacement.m_itemid;
 
index 6a6e6257dd5607fc121f106cd512ea79fed4d23a..4587112e23af5004582cece6577a0a44bd82f7ab 100644 (file)
@@ -161,7 +161,7 @@ void Ent_WaypointSprite(entity this)
 
     if (sendflags & 1)
     {
-        this.__team = ReadByte();
+        setteam(this, ReadByte());
         this.rule = ReadByte();
     }
 
@@ -818,7 +818,7 @@ void WaypointSprite_UpdateRule(entity e, float t, float r)
 {
     // no check, as this is never called without doing an actual change (usually only once)
     e.rule = r;
-    e.__team = t;
+    setteam(e, t);
     e.SendFlags |= 1;
 }
 
@@ -1008,7 +1008,7 @@ entity WaypointSprite_Spawn(
     else
         setorigin(wp, ofs);
     wp.enemy = showto;
-    wp.__team = t;
+    setteam(wp, t);
     wp.owner = own;
     wp.currentammo = hideable;
     if (own)
index 74faeface68859c5aedaa14e105aefee5872f45d..5e80cf07818a6219db38fb8710e040e6c56ba9fc 100644 (file)
@@ -1304,7 +1304,7 @@ void PM_Main(entity this)
        this.v_angle = PHYS_INPUT_ANGLES(this);
        this.angles = PHYS_WORLD_ANGLES(this);
 
-       this.__team = myteam + 1; // is this correct?
+       setteam(this, myteam);
        if (!(PHYS_INPUT_BUTTON_JUMP(this))) // !jump
                UNSET_JUMP_HELD(this); // canjump = true
        pmove_waterjumptime -= PHYS_INPUT_TIMELENGTH;
index 5f49faac730771dd4cb26411a16898516d0eb810..d279831b4a5f93610d0354a4ef50dd915590d7d8 100644 (file)
@@ -65,10 +65,11 @@ float myteam;
 #endif
 
 Team TM(int teamid) {
-    if (teamid == 0) return NULL;
+    return = TEAM_SPEC;
+    if (teamid == -1) return;  // catch off-by-one from server NULL.team (0) - 1
+    if (teamid == 0) return;
     FOREACH(Teams, it.Team_id == teamid, return it);
     LOG_SEVEREF("Unknown team: %d", teamid);
-    return NULL;
 }
 
 #define Team_ColorCode(this) (TM(this).m_colorstr)
index 3e35edd7f3c90a9fd1e9f966d87c538aec57640f..4e9bea522050ac77f6f02d80567c5f70d62a6e43 100644 (file)
@@ -267,7 +267,7 @@ void func_breakable_damage(entity this, entity inflictor, entity attacker, float
 
 void func_breakable_reset(entity this)
 {
-       this.__team = this.team_saved;
+       setteam(this, this.team_saved);
        func_breakable_look_restore();
        if(this.spawnflags & 1)
                func_breakable_behave_destroyed();
index 1873fe8f9a05b3d06eb4e00a049ca531bda1fa43..8fb3ca2559f1d7a1288bac185b375b83d8ca20f3 100644 (file)
@@ -442,7 +442,7 @@ NET_HANDLE(ENT_CLIENT_TRIGGER_PUSH, bool isnew)
        make_pure(this);
 
        self.classname = "jumppad";
-       int mytm = ReadByte(); if(mytm) { self.__team = mytm - 1; }
+       int mytm = ReadByte(); if(mytm) { setteam(self, mytm - 1); }
        self.spawnflags = ReadInt24_t();
        self.active = ReadByte();
        self.height = ReadCoord();
index 08989688ed93d499fa2eab6cea59d5fb33d3cc01..950a69d1d0d92bae02338dbf1baab0925fccd10a 100644 (file)
@@ -127,7 +127,7 @@ void multi_reset(entity this)
        }
        this.think = func_null;
        this.nextthink = 0;
-       this.__team = this.team_saved;
+       setteam(this, this.team_saved);
 }
 
 /*QUAKED spawnfunc_trigger_multiple (.5 .5 .5) ? notouch
index 91b487dfaaaf56596e53df7283f6064d4b410c6f..7474156650616f750cfeaaa28be40720e312dfd0 100644 (file)
@@ -23,7 +23,7 @@ void trigger_relay_teamcheck_use()
 
 void trigger_relay_teamcheck_reset(entity this)
 {
-       this.__team = this.team_saved;
+       setteam(this, this.team_saved);
 }
 
 spawnfunc(trigger_relay_teamcheck)
index 0860264dcd466515fcf8367edcccad7719e13c29..90a2075c414c8fc6e9b7be8e5a21bc6f48e36722 100644 (file)
@@ -106,7 +106,7 @@ spawnfunc(trigger_teleport)
 NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew)
 {
        self.classname = "trigger_teleport";
-       int mytm = ReadByte(); if(mytm) { self.__team = mytm - 1; }
+       int mytm = ReadByte(); if(mytm) { setteam(self, mytm - 1); }
        self.spawnflags = ReadInt24_t();
        self.active = ReadByte();
        self.speed = ReadCoord();
index ae0e15b3ccfaf0820f151725b466253208e66e72..1ca28f3e06ab25659ae2ff9ccd4f56f214b47a54 100644 (file)
@@ -426,7 +426,7 @@ NET_HANDLE(ENT_CLIENT_TURRET, bool isnew)
                _tmp = ReadByte();
                if(_tmp != TMID(self.team))
                {
-                       self.__team = _tmp;
+                       setteam(self, _tmp);
                        turret_changeteam();
                }
 
index c1b92404893c1fda0adc08d25e9eac97ad9fe380..c62c571223797f37bd671d851e733eae18089472 100644 (file)
@@ -1271,7 +1271,7 @@ float turret_initialize(Turret tur)
        self.netname = tur.netname;
        load_unit_settings(self, 0);
 
-       if(!self.team || !teamplay)             { self.__team = MAX_SHOT_DISTANCE; }
+       if(!self.team || !teamplay)             { setteam(self, MAX_SHOT_DISTANCE); }
        if(!self.ticrate)                               { self.ticrate = ((self.turret_flags & TUR_FLAG_SUPPORT) ? 0.2 : 0.1); }
        if(!self.health)                                { self.health = 1000; }
        if(!self.shot_refire)                   { self.shot_refire = 1; }
index 8ed633a4c4356d25c2a5486cdb13916202382b93..23b2ca0fe1ba2700e2a53ae32ca4c87c2c5f5b20 100644 (file)
@@ -882,7 +882,7 @@ void vehicles_exit(bool eject)
        _vehicle.tur_head.nodrawtoclient = world;
 
        if(!teamplay)
-               _vehicle.__team = 0;
+               setteam(_vehicle, 0);
 
        Kill_Notification(NOTIF_ONE, _player, MSG_CENTER, CPID_VEHICLES);
        Kill_Notification(NOTIF_ONE, _player, MSG_CENTER, CPID_VEHICLES_OTHER); // kill all vehicle notifications when exiting a vehicle?
@@ -1212,7 +1212,7 @@ bool vehicle_initialize(entity veh, bool nodrop)
        else { self.active = ACTIVE_ACTIVE; }
 
        if(self.team && (!teamplay || !autocvar_g_vehicles_teams))
-               self.__team = 0;
+               setteam(self, 0);
 
        if(self.mdl == "" || !self.mdl)
                _setmodel(self, veh.model);
index 6894c5c7c8efa41dee83da0e6dcb1aecb7e34ca3..f54025fe41318291f02ed57dc0729b72b2b344db 100644 (file)
@@ -72,7 +72,7 @@ NET_HANDLE(ENT_CLIENT_BUMBLE_RAYGUN, bool isnew)
     if(sf & BRG_SETUP)
     {
         self.cnt    = ReadByte();
-        self.__team = ReadByte();
+        setteam(self, ReadByte());
         self.cnt    = ReadByte();
 
         if(self.cnt)
index a1e0c84ebe71cd813987c4806aef26c80525bee8..902e990d217c84204a837126848d0f45f3bd128e 100644 (file)
@@ -148,7 +148,7 @@ NET_HANDLE(TE_CSQC_VAPORBEAMPARTICLE, bool isNew)
        int myowner = ReadByte();
        this.owner = playerslots[myowner - 1];
        this.sv_entnum = myowner;
-       this.__team = ReadByte() - 1;
+       setteam(this, ReadByte() - 1);
 
        if(autocvar_cl_vaporizerbeam_particle)
        {
index b6375c067f6e600d792e159a39035a02b95940af..37e7e09cfa68a5b07503becf3d844cb0dc44b782 100644 (file)
        #include <dpdefs/keycodes.qh>
 #endif
 
+#define DEBUG_TEAM_ENTS 1
+
 .int team;
-.int __team = team;
 .entity m_team;
-#if 1
-#define team_t int
-#define TMID(t) (t)
+.int __team = team;
+
+#if DEBUG_TEAM_ENTS
+    #define team_t int
+    #define TMID(t) (t)
+    #define team team
+    #define setteam(e, t) MACRO_BEGIN { \
+        (e).team = (t); \
+    } MACRO_END
 #else
-#define team_t Team
-#define TMID(t) (t.Team_id)
-#define team m_team
+    #define team_t Team
+    #define TMID(t) ((t).m_playercolor)
+    #define team m_team
+    #define setteam(e, t) MACRO_BEGIN { \
+        entity _e = (e); \
+        int _t = (t); \
+        _e.__team = _t; \
+        _e.team = TM(_t); \
+    } MACRO_END
 #endif
 
 #include "macro.qh"
index aba8ece03706f8efad44118ebd9b21b7e20081d1..7bc83876087187c9308e8d9b359d8ef6740f55cc 100644 (file)
@@ -414,13 +414,13 @@ void bot_clientconnect(entity this)
                bot_setnameandstuff();
 
        if(self.bot_forced_team==1)
-               self.__team = NUM_TEAM_1;
+               setteam(self, NUM_TEAM_1);
        else if(self.bot_forced_team==2)
-               self.__team = NUM_TEAM_2;
+               setteam(self, NUM_TEAM_2);
        else if(self.bot_forced_team==3)
-               self.__team = NUM_TEAM_3;
+               setteam(self, NUM_TEAM_3);
        else if(self.bot_forced_team==4)
-               self.__team = NUM_TEAM_4;
+               setteam(self, NUM_TEAM_4);
        else
                JoinBestTeam(self, false, true);
 
index eeca8337d7c09c9e236bc95a6e3024bf6b551e07..dbeb28fbe8cd86587e0518f11624066f912458a1 100644 (file)
@@ -215,7 +215,7 @@ void PutObserverInServer()
        if (mutator_returnvalue) {
            // mutator prevents resetting teams+score
        } else {
-               this.__team = -1;  // move this as it is needed to log the player spectating in eventlog
+               setteam(this, -1);  // move this as it is needed to log the player spectating in eventlog
         this.frags = FRAGS_SPECTATOR;
         PlayerScore_Clear(this);  // clear scores when needed
     }
index 8f8d1d89cd2d3e94572fc6db99eb09e6f15f3279..222deaa7fe98c4aad0ff16c7db1500e2fdd34b75 100644 (file)
@@ -347,7 +347,7 @@ void reset_map(bool dorespawn)
                        WITH(entity, self, it, it.reset(it));
                        continue;
                }
-               if (it.team_saved) it.__team = it.team_saved;
+               if (it.team_saved) setteam(it, it.team_saved);
                if (it.flags & FL_PROJECTILE) remove(it);  // remove any projectiles left
        });
 
index 466450f92946777fda78396d575e94817190997d..d929c71640db741a14f638527dd7a87c2c49d8e4 100644 (file)
@@ -234,9 +234,9 @@ void assault_roundstart_use()
        FOREACH_ENTITY_CLASS("turret_main", true, {
                // Swap turret teams
                if(TMID(it.team) == NUM_TEAM_1)
-                       it.__team = NUM_TEAM_2;
+                       setteam(it, NUM_TEAM_2);
                else
-                       it.__team = NUM_TEAM_1;
+                       setteam(it, NUM_TEAM_1);
 
                // Doubles as teamchange
                WITH(entity, self, it, turret_respawn());
@@ -344,7 +344,7 @@ spawnfunc(info_player_attacker)
 {
        if (!g_assault) { remove(self); return; }
 
-       self.__team = NUM_TEAM_1; // red, gets swapped every round
+       setteam(self, NUM_TEAM_1); // red, gets swapped every round
        spawnfunc_info_player_deathmatch(this);
 }
 
@@ -352,7 +352,7 @@ spawnfunc(info_player_defender)
 {
        if (!g_assault) { remove(self); return; }
 
-       self.__team = NUM_TEAM_2; // blue, gets swapped every round
+       setteam(self, NUM_TEAM_2); // blue, gets swapped every round
        spawnfunc_info_player_deathmatch(this);
 }
 
@@ -394,9 +394,9 @@ spawnfunc(func_assault_destructible)
        self.classname = "func_assault_destructible";
 
        if(assault_attacker_team == NUM_TEAM_1)
-               self.__team = NUM_TEAM_2;
+               setteam(self, NUM_TEAM_2);
        else
-               self.__team = NUM_TEAM_1;
+               setteam(self, NUM_TEAM_1);
 
        spawnfunc_func_breakable(this);
 }
@@ -633,7 +633,7 @@ MUTATOR_HOOKFUNCTION(as, PlayerSpawn)
 MUTATOR_HOOKFUNCTION(as, TurretSpawn)
 {SELFPARAM();
        if(!self.team || TMID(self.team) == MAX_SHOT_DISTANCE)
-               self.__team = 5; // this gets reversed when match starts?
+               setteam(self, 5); // this gets reversed when match starts?
 
        return false;
 }
index be7d52fa671ee30af0ae1dd27d41f79e7d305391..e668e441e38e793bac4955dcf02bf9061cfe815e 100644 (file)
@@ -246,7 +246,7 @@ MUTATOR_HOOKFUNCTION(ca, reset_map_players)
                it.killcount = 0;
                if (!it.caplayer && IS_BOT_CLIENT(it))
                {
-                       it.__team = -1;
+                       setteam(it, -1);
                        it.caplayer = 1;
                }
                if (it.caplayer)
index 7178ffee2fc52cbf08ffe4c7f3f023f6d4f079e7..35107b2645fb649790692244b90acebc7726cc46 100644 (file)
@@ -1198,7 +1198,7 @@ void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag e
        setattachment(flag, world, "");
 
        flag.netname = strzone(sprintf("%s%s^7 flag", Team_ColorCode(teamnumber), Team_ColorName_Upper(teamnumber)));
-       flag.__team = teamnumber;
+       setteam(flag, teamnumber);
        flag.classname = "item_flag_team";
        flag.target = "###item###"; // wut?
        flag.flags = FL_ITEM | FL_NOTARGET;
@@ -2507,7 +2507,7 @@ spawnfunc(ctf_team)
        if(!g_ctf) { remove(self); return; }
 
        self.classname = "ctf_team";
-       self.__team = self.cnt + 1;
+       setteam(self, self.cnt + 1);
 }
 
 // compatibility for quake maps
index 4313a472f0b096bfd62912a3b76ea20151f96838..d52dc1c965ab885934a724d335f42fedc8ecceb4 100644 (file)
@@ -148,12 +148,12 @@ void dompoint_captured ()
        // do trigger work
        old_delay = self.delay;
        old_team = TMID(self.team);
-       self.__team = real_team;
+       setteam(self, real_team);
        self.delay = 0;
        activator = self;
        SUB_UseTargets ();
        self.delay = old_delay;
-       self.__team = old_team;
+       setteam(self, old_team);
 
        entity msg = WP_DomNeut;
        switch(TMID(self.team))
@@ -600,7 +600,7 @@ spawnfunc(dom_team)
        self.modelindex = 0;
        // this would have to be changed if used in quakeworld
        if(self.cnt)
-               self.__team = self.cnt + 1; // WHY are these different anyway?
+               setteam(self, self.cnt + 1); // WHY are these different anyway?
 }
 
 // scoreboard setup
@@ -649,7 +649,7 @@ void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float p
        self.model = "";
        self.modelindex = 0;
        // this would have to be changed if used in quakeworld
-       self.__team = self.cnt + 1;
+       setteam(self, self.cnt + 1);
 
        //eprint(self);
        setself(this);
index 29cfbd94730b821ebff2b849294a3fd38857e1fd..a93d4792fcefaff9c6ad8afde357c67adb411b7b 100644 (file)
@@ -162,7 +162,7 @@ void invasion_SpawnChosenMonster(float mon)
                if(invasion_teams >= 3) if(inv_monsters_perteam[NUM_TEAM_3] > 0) { RandomSelection_Add(world, NUM_TEAM_3, string_null, 1, 1); }
                if(invasion_teams >= 4) if(inv_monsters_perteam[NUM_TEAM_4] > 0) { RandomSelection_Add(world, NUM_TEAM_4, string_null, 1, 1); }
 
-               monster.__team = RandomSelection_chosen_float;
+               setteam(monster, RandomSelection_chosen_float);
        }
 
        if(teamplay)
@@ -173,7 +173,7 @@ void invasion_SpawnChosenMonster(float mon)
                {
                        WaypointSprite_UpdateTeamRadar(monster.sprite, RADARICON_DANGER, ((monster.team) ? Team_ColorRGB(TMID(monster.team)) : '1 0 0'));
 
-                       monster.sprite.__team = 0;
+                       setteam(monster.sprite, 0);
                        monster.sprite.SendFlags |= 1;
                }
        }
index 7f2075ca954025feb23619a329d925eaa08f39d7..4aeebd7e39869862947cd6e2993251ffa5385bed 100644 (file)
@@ -54,7 +54,7 @@ spawnfunc(tdm_team)
        if(!g_tdm || !self.cnt) { remove(self); return; }
 
        self.classname = "tdm_team";
-       self.__team = self.cnt + 1;
+       setteam(self, self.cnt + 1);
 }
 
 // code from here on is just to support maps that don't have team entities
index abc88f4c6a537cfd6d849de828fd4adca713846f..442d6bf8af81db078938d9eb99ee530370442f90 100644 (file)
@@ -91,7 +91,7 @@ void TeamScore_Spawn(float t, string name)
 {
        entity ts = new_pure(csqc_score_team);
        ts.netname = name; // not used yet, FIXME
-       ts.__team = t;
+       setteam(ts, t);
        Net_LinkEntity(ts, false, 0, TeamScore_SendEntity);
        teamscorekeepers[t - 1] = ts;
        ++teamscores_entities_count;
index 05c6ae7de0827644f701ab79695018da15db2a8c..dd0d0c33979b030c1583e993ce0d29d514f6511d 100644 (file)
@@ -174,7 +174,7 @@ Starting point for a player in team one (Red).
 Keys: "angle" viewing angle when spawning. */
 spawnfunc(info_player_team1)
 {
-       this.__team = NUM_TEAM_1; // red
+       setteam(this, NUM_TEAM_1); // red
        spawnfunc_info_player_deathmatch(this);
 }
 
@@ -184,7 +184,7 @@ Starting point for a player in team two (Blue).
 Keys: "angle" viewing angle when spawning. */
 spawnfunc(info_player_team2)
 {
-       this.__team = NUM_TEAM_2; // blue
+       setteam(this, NUM_TEAM_2); // blue
        spawnfunc_info_player_deathmatch(this);
 }
 
@@ -193,7 +193,7 @@ Starting point for a player in team three (Yellow).
 Keys: "angle" viewing angle when spawning. */
 spawnfunc(info_player_team3)
 {
-       this.__team = NUM_TEAM_3; // yellow
+       setteam(this, NUM_TEAM_3); // yellow
        spawnfunc_info_player_deathmatch(this);
 }
 
@@ -203,7 +203,7 @@ Starting point for a player in team four (Purple).
 Keys: "angle" viewing angle when spawning. */
 spawnfunc(info_player_team4)
 {
-       this.__team = NUM_TEAM_4; // purple
+       setteam(this, NUM_TEAM_4); // purple
        spawnfunc_info_player_deathmatch(this);
 }
 
index c94ff92d98c2ae5d2aaf32753f48b7fb771dfcb7..c8c860cb0469a64e8cf1cfcc6d6dbe44b946d557 100644 (file)
@@ -242,6 +242,7 @@ float DoesQ3ARemoveThisEntity();
 void SV_OnEntityPreSpawnFunction()
 {SELFPARAM();
        __spawnfunc_expect = this;
+       setteam(this, this.__team);
        if (self)
        if (self.gametypefilter != "")
        if (!isGametypeInFilter(MapInfo_LoadedGametype, teamplay, have_team_spawns, self.gametypefilter))
index f84734bd45d22983ded3a5a30865a35d39e376fc..220bc1ed972d563c7c26dc3dfe1770ad1a5ba5f3 100644 (file)
@@ -46,7 +46,7 @@ void weapon_defaultspawnfunc(entity this, Weapon e)
                int t = tokenize_console(s);
                if (t >= 2)
                {
-                       this.__team = --internalteam;
+                       setteam(this, --internalteam);
                        for (int i = 1; i < t; ++i)
                        {
                                s = argv(i);