From: TimePath Date: Thu, 17 Mar 2016 09:33:10 +0000 (+1100) Subject: Teams: setteam X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=refs%2Fheads%2FTimePath%2FTEAMNUMBERS_THAT_ARENT_STUPID;p=xonotic%2Fxonotic-data.pk3dir.git Teams: setteam --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index b56504006..258d58e68 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -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; diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index fcafca3fb..614369096 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -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; diff --git a/qcsrc/client/teamradar.qc b/qcsrc/client/teamradar.qc index c832a5866..68f83c242 100644 --- a/qcsrc/client/teamradar.qc +++ b/qcsrc/client/teamradar.qc @@ -220,7 +220,7 @@ NET_HANDLE(ENT_CLIENT_RADARLINK, bool isnew) if(sendflags & 4) { - this.__team = ReadByte(); + setteam(this, ReadByte()); } return = true; diff --git a/qcsrc/client/weapons/projectile.qc b/qcsrc/client/weapons/projectile.qc index ae69b8f5a..704572193 100644 --- a/qcsrc/client/weapons/projectile.qc +++ b/qcsrc/client/weapons/projectile.qc @@ -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) diff --git a/qcsrc/common/effects/qc/damageeffects.qc b/qcsrc/common/effects/qc/damageeffects.qc index 4da72a00e..04a4233b7 100644 --- a/qcsrc/common/effects/qc/damageeffects.qc +++ b/qcsrc/common/effects/qc/damageeffects.qc @@ -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; diff --git a/qcsrc/common/effects/qc/gibs.qc b/qcsrc/common/effects/qc/gibs.qc index 43afbf7e2..ff7046806 100644 --- a/qcsrc/common/effects/qc/gibs.qc +++ b/qcsrc/common/effects/qc/gibs.qc @@ -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; diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index ca299b9a8..5a1ff6e22 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -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(); diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/cl_controlpoint.qc b/qcsrc/common/gamemodes/gamemode/onslaught/cl_controlpoint.qc index 8e973198a..a4f5a424b 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/cl_controlpoint.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/cl_controlpoint.qc @@ -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); } diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/cl_generator.qc b/qcsrc/common/gamemodes/gamemode/onslaught/cl_generator.qc index a4fdcff89..0bbc8f3e3 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/cl_generator.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/cl_generator.qc @@ -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); } diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc index c58577352..a8d34b920 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc @@ -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; diff --git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc index 1d3d21444..1bac4f0c5 100644 --- a/qcsrc/common/mapinfo.qc +++ b/qcsrc/common/mapinfo.qc @@ -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; } diff --git a/qcsrc/common/mapinfo.qh b/qcsrc/common/mapinfo.qh index 7ed9e534c..a7cfa0f08 100644 --- a/qcsrc/common/mapinfo.qh +++ b/qcsrc/common/mapinfo.qh @@ -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; diff --git a/qcsrc/common/minigames/cl_minigames.qc b/qcsrc/common/minigames/cl_minigames.qc index d408b5f0f..6ac616470 100644 --- a/qcsrc/common/minigames/cl_minigames.qc +++ b/qcsrc/common/minigames/cl_minigames.qc @@ -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 ) { diff --git a/qcsrc/common/minigames/minigame/bd.qc b/qcsrc/common/minigames/minigame/bd.qc index 0f243b375..a60d47af0 100644 --- a/qcsrc/common/minigames/minigame/bd.qc +++ b/qcsrc/common/minigames/minigame/bd.qc @@ -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; diff --git a/qcsrc/common/minigames/minigame/nmm.qc b/qcsrc/common/minigames/minigame/nmm.qc index dec04df79..9da419c9f 100644 --- a/qcsrc/common/minigames/minigame/nmm.qc +++ b/qcsrc/common/minigames/minigame/nmm.qc @@ -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; } diff --git a/qcsrc/common/minigames/minigame/pong.qc b/qcsrc/common/minigames/minigame/pong.qc index 335523bd1..a1d01d428 100644 --- a/qcsrc/common/minigames/minigame/pong.qc +++ b/qcsrc/common/minigames/minigame/pong.qc @@ -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); diff --git a/qcsrc/common/minigames/minigame/pp.qc b/qcsrc/common/minigames/minigame/pp.qc index f7980d3fe..ef1aa0d1f 100644 --- a/qcsrc/common/minigames/minigame/pp.qc +++ b/qcsrc/common/minigames/minigame/pp.qc @@ -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); diff --git a/qcsrc/common/minigames/minigame/ps.qc b/qcsrc/common/minigames/minigame/ps.qc index d39a74b1d..de804c5a6 100644 --- a/qcsrc/common/minigames/minigame/ps.qc +++ b/qcsrc/common/minigames/minigame/ps.qc @@ -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); } diff --git a/qcsrc/common/minigames/minigame/snake.qc b/qcsrc/common/minigames/minigame/snake.qc index 56db93ae7..071536d38 100644 --- a/qcsrc/common/minigames/minigame/snake.qc +++ b/qcsrc/common/minigames/minigame/snake.qc @@ -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; diff --git a/qcsrc/common/minigames/minigame/ttt.qc b/qcsrc/common/minigames/minigame/ttt.qc index f6fef7867..3f950314c 100644 --- a/qcsrc/common/minigames/minigame/ttt.qc +++ b/qcsrc/common/minigames/minigame/ttt.qc @@ -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); diff --git a/qcsrc/common/minigames/sv_minigames.qc b/qcsrc/common/minigames/sv_minigames.qc index a4a496400..d28e18217 100644 --- a/qcsrc/common/minigames/sv_minigames.qc +++ b/qcsrc/common/minigames/sv_minigames.qc @@ -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; diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 0cc376018..d4652dd54 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -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 diff --git a/qcsrc/common/mutators/mutator/buffs/all.qh b/qcsrc/common/mutators/mutator/buffs/all.qh index b05aa3ae7..d41d5c0c2 100644 --- a/qcsrc/common/mutators/mutator/buffs/all.qh +++ b/qcsrc/common/mutators/mutator/buffs/all.qh @@ -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) \ diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qc b/qcsrc/common/mutators/mutator/buffs/buffs.qc index f18fc5439..4f0ce51e5 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qc @@ -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; diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc index 6a6e6257d..4587112e2 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc @@ -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) diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index 74faeface..5e80cf078 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -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; diff --git a/qcsrc/common/teams.qh b/qcsrc/common/teams.qh index 5f49faac7..d279831b4 100644 --- a/qcsrc/common/teams.qh +++ b/qcsrc/common/teams.qh @@ -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) diff --git a/qcsrc/common/triggers/func/breakable.qc b/qcsrc/common/triggers/func/breakable.qc index 3e35edd7f..4e9bea522 100644 --- a/qcsrc/common/triggers/func/breakable.qc +++ b/qcsrc/common/triggers/func/breakable.qc @@ -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(); diff --git a/qcsrc/common/triggers/trigger/jumppads.qc b/qcsrc/common/triggers/trigger/jumppads.qc index 1873fe8f9..8fb3ca255 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qc +++ b/qcsrc/common/triggers/trigger/jumppads.qc @@ -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(); diff --git a/qcsrc/common/triggers/trigger/multi.qc b/qcsrc/common/triggers/trigger/multi.qc index 08989688e..950a69d1d 100644 --- a/qcsrc/common/triggers/trigger/multi.qc +++ b/qcsrc/common/triggers/trigger/multi.qc @@ -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 diff --git a/qcsrc/common/triggers/trigger/relay_teamcheck.qc b/qcsrc/common/triggers/trigger/relay_teamcheck.qc index 91b487dfa..747415665 100644 --- a/qcsrc/common/triggers/trigger/relay_teamcheck.qc +++ b/qcsrc/common/triggers/trigger/relay_teamcheck.qc @@ -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) diff --git a/qcsrc/common/triggers/trigger/teleport.qc b/qcsrc/common/triggers/trigger/teleport.qc index 0860264dc..90a2075c4 100644 --- a/qcsrc/common/triggers/trigger/teleport.qc +++ b/qcsrc/common/triggers/trigger/teleport.qc @@ -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(); diff --git a/qcsrc/common/turrets/cl_turrets.qc b/qcsrc/common/turrets/cl_turrets.qc index ae0e15b3c..1ca28f3e0 100644 --- a/qcsrc/common/turrets/cl_turrets.qc +++ b/qcsrc/common/turrets/cl_turrets.qc @@ -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(); } diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index c1b924048..c62c57122 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -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; } diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 8ed633a4c..23b2ca0fe 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -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); diff --git a/qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc b/qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc index 6894c5c7c..f54025fe4 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc +++ b/qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc @@ -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) diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index a1e0c84eb..902e990d2 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -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) { diff --git a/qcsrc/lib/_all.inc b/qcsrc/lib/_all.inc index b6375c067..37e7e09cf 100644 --- a/qcsrc/lib/_all.inc +++ b/qcsrc/lib/_all.inc @@ -25,16 +25,29 @@ #include #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" diff --git a/qcsrc/server/bot/bot.qc b/qcsrc/server/bot/bot.qc index aba8ece03..7bc838760 100644 --- a/qcsrc/server/bot/bot.qc +++ b/qcsrc/server/bot/bot.qc @@ -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); diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index eeca8337d..dbeb28fbe 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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 } diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 8f8d1d89c..222deaa7f 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -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 }); diff --git a/qcsrc/server/mutators/mutator/gamemode_assault.qc b/qcsrc/server/mutators/mutator/gamemode_assault.qc index 466450f92..d929c7164 100644 --- a/qcsrc/server/mutators/mutator/gamemode_assault.qc +++ b/qcsrc/server/mutators/mutator/gamemode_assault.qc @@ -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; } diff --git a/qcsrc/server/mutators/mutator/gamemode_ca.qc b/qcsrc/server/mutators/mutator/gamemode_ca.qc index be7d52fa6..e668e441e 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ca.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ca.qc @@ -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) diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index 7178ffee2..35107b264 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -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 diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qc b/qcsrc/server/mutators/mutator/gamemode_domination.qc index 4313a472f..d52dc1c96 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qc +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qc @@ -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); diff --git a/qcsrc/server/mutators/mutator/gamemode_invasion.qc b/qcsrc/server/mutators/mutator/gamemode_invasion.qc index 29cfbd947..a93d4792f 100644 --- a/qcsrc/server/mutators/mutator/gamemode_invasion.qc +++ b/qcsrc/server/mutators/mutator/gamemode_invasion.qc @@ -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; } } diff --git a/qcsrc/server/mutators/mutator/gamemode_tdm.qc b/qcsrc/server/mutators/mutator/gamemode_tdm.qc index 7f2075ca9..4aeebd7e3 100644 --- a/qcsrc/server/mutators/mutator/gamemode_tdm.qc +++ b/qcsrc/server/mutators/mutator/gamemode_tdm.qc @@ -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 diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index abc88f4c6..442d6bf8a 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -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; diff --git a/qcsrc/server/spawnpoints.qc b/qcsrc/server/spawnpoints.qc index 05c6ae7de..dd0d0c339 100644 --- a/qcsrc/server/spawnpoints.qc +++ b/qcsrc/server/spawnpoints.qc @@ -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); } diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index c94ff92d9..c8c860cb0 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -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)) diff --git a/qcsrc/server/weapons/spawning.qc b/qcsrc/server/weapons/spawning.qc index f84734bd4..220bc1ed9 100644 --- a/qcsrc/server/weapons/spawning.qc +++ b/qcsrc/server/weapons/spawning.qc @@ -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);