From: Rudolf Polzer Date: Fri, 19 Mar 2010 20:45:12 +0000 (+0100) Subject: NIX mutator: remove the on-remove erorr, and handle it gracefully X-Git-Tag: xonotic-v0.1.0preview~682 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=cff5b8df279d8d7842dea0273ef8773825b2995e;p=xonotic%2Fxonotic-data.pk3dir.git NIX mutator: remove the on-remove erorr, and handle it gracefully --- diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index c97e53460..593a0cac3 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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 (); } diff --git a/qcsrc/server/mutators/mutator_nix.qc b/qcsrc/server/mutators/mutator_nix.qc index b328e6de8..dc1794c5c 100644 --- a/qcsrc/server/mutators/mutator_nix.qc +++ b/qcsrc/server/mutators/mutator_nix.qc @@ -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;