]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean up GetTeamCount
authorMario <mario@smbclan.net>
Wed, 14 Oct 2015 13:20:44 +0000 (23:20 +1000)
committerMario <mario@smbclan.net>
Wed, 14 Oct 2015 13:20:44 +0000 (23:20 +1000)
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/server/mutators/events.qh
qcsrc/server/mutators/gamemode_assault.qc
qcsrc/server/mutators/gamemode_ca.qc
qcsrc/server/mutators/gamemode_domination.qc
qcsrc/server/mutators/gamemode_keyhunt.qc
qcsrc/server/mutators/gamemode_onslaught.qc
qcsrc/server/teamplay.qc

index 1e60ab8eae3c0e49b492d106096a765808b50ce8..385e4eb097b072dddb363cfe68709808b3a16733 100644 (file)
@@ -1017,6 +1017,12 @@ MUTATOR_HOOKFUNCTION(nb, FilterItem)
        return false;
 }
 
+MUTATOR_HOOKFUNCTION(nb, GetTeamCount)
+{
+       ret_string = "nexball_team";
+       return true;
+}
+
 REGISTER_MUTATOR(nb, g_nexball)
 {
        ActivateTeamplay();
index b71d9f94f966c581608aa589d93b4c434d03f61a..5ab1258e6eec2541e47216972ea532253e591525 100644 (file)
@@ -122,6 +122,8 @@ MUTATOR_HOOKABLE(MatchEnd, EV_NO_ARGS);
 #define EV_GetTeamCount(i, o) \
     /**/ i(float, ret_float) \
     /**/ o(float, ret_float) \
+    /**/ i(string, ret_string) \
+    /**/ o(string, ret_string) \
     /**/
 float ret_float;
 MUTATOR_HOOKABLE(GetTeamCount, EV_GetTeamCount);
index 1ae2a62695c6cda36e939d058df88e1fb54f4f20..c53511cfa0ada4d06451c76f78984900fe27733d 100644 (file)
@@ -530,7 +530,7 @@ void havocbot_ast_reset_role(entity bot)
 }
 
 // mutator hooks
-MUTATOR_HOOKFUNCTION(assault, PlayerSpawn)
+MUTATOR_HOOKFUNCTION(as, PlayerSpawn)
 {SELFPARAM();
        if(self.team == assault_attacker_team)
                Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_ASSAULT_ATTACKING);
@@ -540,7 +540,7 @@ MUTATOR_HOOKFUNCTION(assault, PlayerSpawn)
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(assault, TurretSpawn)
+MUTATOR_HOOKFUNCTION(as, TurretSpawn)
 {SELFPARAM();
        if(!self.team || self.team == MAX_SHOT_DISTANCE)
                self.team = 5; // this gets reversed when match starts?
@@ -548,24 +548,31 @@ MUTATOR_HOOKFUNCTION(assault, TurretSpawn)
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(assault, VehicleSpawn)
+MUTATOR_HOOKFUNCTION(as, VehicleSpawn)
 {SELFPARAM();
        self.nextthink = time + 0.5;
 
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(assault, HavocBot_ChooseRole)
+MUTATOR_HOOKFUNCTION(as, HavocBot_ChooseRole)
 {SELFPARAM();
        havocbot_ast_reset_role(self);
        return true;
 }
 
-MUTATOR_HOOKFUNCTION(assault, PlayHitsound)
+MUTATOR_HOOKFUNCTION(as, PlayHitsound)
 {
        return (frag_victim.classname == "func_assault_destructible");
 }
 
+MUTATOR_HOOKFUNCTION(as, GetTeamCount)
+{
+       // assault always has 2 teams
+       c1 = c2 = 0;
+       return true;
+}
+
 // scoreboard setup
 void assault_ScoreRules()
 {
@@ -575,7 +582,7 @@ void assault_ScoreRules()
        ScoreRules_basics_end();
 }
 
-REGISTER_MUTATOR(assault, g_assault)
+REGISTER_MUTATOR(as, g_assault)
 {
        ActivateTeamplay();
        have_team_spawns = -1; // request team spawns
index b514fa296a0050cca7d2b3890c33057f4f982fc6..dc6dca02148e1d1728e65c17161c4a479eaec521 100644 (file)
@@ -255,7 +255,7 @@ MUTATOR_HOOKFUNCTION(ca, reset_map_global)
 MUTATOR_HOOKFUNCTION(ca, GetTeamCount, CBC_ORDER_EXCLUSIVE)
 {
        ret_float = ca_teams;
-       return 0;
+       return false;
 }
 
 entity ca_LastPlayerForTeam()
index 740d16c621522778b564340ecf22de6e524bd95a..2c124b5dec61c4b37b81d256af5a752d7210427f 100644 (file)
@@ -417,8 +417,30 @@ void havocbot_role_dom()
 
 MUTATOR_HOOKFUNCTION(dom, GetTeamCount)
 {
+       // fallback?
        ret_float = domination_teams;
-       return 0;
+       ret_string = "dom_team";
+
+       entity head = find(world, classname, ret_string);
+       while(head)
+       {
+               if(head.netname != "")
+               {
+                       switch(head.team)
+                       {
+                               case NUM_TEAM_1: c1 = 0; break;
+                               case NUM_TEAM_2: c2 = 0; break;
+                               case NUM_TEAM_3: c3 = 0; break;
+                               case NUM_TEAM_4: c4 = 0; break;
+                       }
+               }
+
+               head = find(head, classname, ret_string);
+       }
+
+       ret_string = string_null;
+
+       return true;
 }
 
 MUTATOR_HOOKFUNCTION(dom, reset_map_players)
index 5ff4524084db2025b948912c17bf95a1738006c6..1affe8ed04b1b1deb65301f01821857eae854e5c 100644 (file)
@@ -1082,7 +1082,7 @@ MUTATOR_HOOKFUNCTION(kh, MatchEnd)
 MUTATOR_HOOKFUNCTION(kh, GetTeamCount, CBC_ORDER_EXCLUSIVE)
 {
        ret_float = kh_teams;
-       return 0;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(kh, SpectateCopy)
index 869cd90d2dbfcfb3e14fd1fab5a5ed3567360f32..cc6ad200cd05c4d01e5be035ab72e5f0f2832a54 100644 (file)
@@ -1937,8 +1937,7 @@ MUTATOR_HOOKFUNCTION(ons, HavocBot_ChooseRole)
 MUTATOR_HOOKFUNCTION(ons, GetTeamCount)
 {
        // onslaught is special
-       entity tmp_entity;
-       for(tmp_entity = ons_worldgeneratorlist; tmp_entity; tmp_entity = tmp_entity.ons_worldgeneratornext)
+       for(entity tmp_entity = ons_worldgeneratorlist; tmp_entity; tmp_entity = tmp_entity.ons_worldgeneratornext)
        {
                switch(tmp_entity.team)
                {
index 73ab0cefec5c37b5f5295b11ffd9c641465a15f0..253697905951f55f784a12ba7067c2311919c2aa 100644 (file)
@@ -231,45 +231,19 @@ void SetPlayerTeam(entity pl, float t, float s, float noprint)
 // set c1...c4 to show what teams are allowed
 void CheckAllowedTeams (entity for_whom)
 {SELFPARAM();
-       float dm;
-       entity head;
-       string teament_name;
+       int dm = 0;
 
        c1 = c2 = c3 = c4 = -1;
        cb1 = cb2 = cb3 = cb4 = 0;
 
-       teament_name = string_null;
-       if(g_onslaught)
-       {
-               // onslaught is special
-               head = findchain(classname, "onslaught_generator");
-               while (head)
-               {
-                       if (head.team == NUM_TEAM_1) c1 = 0;
-                       if (head.team == NUM_TEAM_2) c2 = 0;
-                       if (head.team == NUM_TEAM_3) c3 = 0;
-                       if (head.team == NUM_TEAM_4) c4 = 0;
-                       head = head.chain;
-               }
-       }
-       else if(g_domination)
-               teament_name = "dom_team";
-       else if(g_ctf)
-               teament_name = "ctf_team";
-       else if(g_tdm)
-               teament_name = "tdm_team";
-       else if(g_nexball)
-               teament_name = "nexball_team";
-       else if(g_assault)
-               c1 = c2 = 0; // Assault always has 2 teams
-       else
-       {
-               // cover anything else by treating it like tdm with no teams spawned
-               dm = 2;
+       string teament_name = string_null;
 
-               MUTATOR_CALLHOOK(GetTeamCount, dm);
-               dm = ret_float;
+       bool mutator_returnvalue = MUTATOR_CALLHOOK(GetTeamCount, dm, teament_name);
+       teament_name = ret_string;
+       dm = ret_float;
 
+       if(!mutator_returnvalue)
+       {
                if(dm >= 4)
                        c1 = c2 = c3 = c4 = 0;
                else if(dm >= 3)
@@ -281,20 +255,17 @@ void CheckAllowedTeams (entity for_whom)
        // find out what teams are allowed if necessary
        if(teament_name)
        {
-               head = find(world, classname, teament_name);
+               entity head = find(world, classname, teament_name);
                while(head)
                {
-                       if(!(g_domination && head.netname == ""))
+                       switch(head.team)
                        {
-                               if(head.team == NUM_TEAM_1)
-                                       c1 = 0;
-                               else if(head.team == NUM_TEAM_2)
-                                       c2 = 0;
-                               else if(head.team == NUM_TEAM_3)
-                                       c3 = 0;
-                               else if(head.team == NUM_TEAM_4)
-                                       c4 = 0;
+                               case NUM_TEAM_1: c1 = 0; break;
+                               case NUM_TEAM_2: c2 = 0; break;
+                               case NUM_TEAM_3: c3 = 0; break;
+                               case NUM_TEAM_4: c4 = 0; break;
                        }
+
                        head = find(head, classname, teament_name);
                }
        }