]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
NIX mutator: remove the on-remove erorr, and handle it gracefully
authorRudolf Polzer <rpolzer@nb-04.(none)>
Fri, 19 Mar 2010 20:45:12 +0000 (21:45 +0100)
committerRudolf Polzer <rpolzer@nb-04.(none)>
Fri, 19 Mar 2010 20:45:12 +0000 (21:45 +0100)
qcsrc/server/cl_client.qc
qcsrc/server/mutators/mutator_nix.qc

index c97e53460e803cd4f78905103407fbc353fd256d..593a0cac3263639dcaa373e0302ab186a358cc55 100644 (file)
@@ -899,9 +899,6 @@ void PutClientInServer (void)
                        self.weapons = randombits(self.weapons, g_weaponarena_random, FALSE);
 
                self.items = start_items;
-               self.switchweapon = w_getbestweapon(self);
-               self.cnt = self.switchweapon;
-               self.weapon = 0;
                self.jump_interval = time;
 
                self.spawnshieldtime = time + cvar("g_spawnshieldtime");
@@ -1039,6 +1036,10 @@ void PutClientInServer (void)
                self = oldself;
 
                MUTATOR_CALLHOOK(PlayerSpawn);
+
+               self.switchweapon = w_getbestweapon(self);
+               self.cnt = self.switchweapon;
+               self.weapon = 0;
        } else if(self.classname == "observer" || (g_ca && !allowed_to_spawn)) {
                PutObserverInServer ();
        }
index b328e6de86cd1edb99144f621b7882ec1e20181a..dc1794c5cccf1697f065d366d1c6bd9a1bf86a54 100644 (file)
@@ -126,6 +126,14 @@ void NIX_GiveCurrentWeapon()
                                W_SwitchWeapon(nix_weapon);
 }
 
+void NIX_precache()
+{
+       float i;
+       for (i = WEP_FIRST; i <= WEP_LAST; ++i)
+               if (NIX_CanChooseWeapon(i))
+                       weapon_action(i, WR_PRECACHE);
+}
+
 MUTATOR_HOOKFUNCTION(nix_ForbidThrowCurrentWeapon)
 {
        return 1; // no throwing in NIX
@@ -133,12 +141,10 @@ MUTATOR_HOOKFUNCTION(nix_ForbidThrowCurrentWeapon)
 
 MUTATOR_HOOKFUNCTION(nix_SetStartItems)
 {
-       float i;
-       start_weapons = 0; // will be done later, when player spawns
-       warmup_start_weapons = 0; // will be done later, when player spawns
-       for (i = WEP_FIRST; i <= WEP_LAST; ++i)
-               if (NIX_CanChooseWeapon(i))
-                       weapon_action(i, WR_PRECACHE);
+       NIX_precache();
+       // we do NOT change the start weapons any more, so we can later turn off the mutator!
+       //   start_weapons = 0; // will be done later, when player spawns
+       //   warmup_start_weapons = 0; // will be done later, when player spawns
        return 0;
 }
 
@@ -195,6 +201,7 @@ MUTATOR_HOOKFUNCTION(nix_PlayerPreThink)
 MUTATOR_HOOKFUNCTION(nix_PlayerSpawn)
 {
        self.nix_lastchange_id = -1;
+       NIX_GiveCurrentWeapon(); // overrides the weapons you got when spawning
        return 0;
 }
 
@@ -215,12 +222,15 @@ MUTATOR_DEFINITION(mutator_nix)
                g_nix_with_laser = cvar("g_nix_with_laser");
 
                nix_nextchange = time;
+               nix_nextweapon = 0;
+
+               NIX_precache();
        }
 
        MUTATOR_ONREMOVE
        {
-               error("NIX currently cannot be shut down.");
                g_nix = 0;
+               // as the PlayerSpawn hook will no longer run, NIX is turned off by this!
        }
 
        return 0;