]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
PutClientInServer: cleanup
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 25 Oct 2015 05:57:59 +0000 (16:57 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 25 Oct 2015 22:26:16 +0000 (09:26 +1100)
19 files changed:
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/hook.qc
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/menu/xonotic/playerlist.qc
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc
qcsrc/server/command/cmd.qc
qcsrc/server/defs.qh
qcsrc/server/g_damage.qc
qcsrc/server/miscfunctions.qh
qcsrc/server/mutators/all.inc
qcsrc/server/mutators/mutator/gamemode_ca.qc
qcsrc/server/mutators/mutator/gamemode_cts.qc
qcsrc/server/mutators/mutator/gamemode_lms.qc
qcsrc/server/mutators/mutator/gamemode_race.qc
qcsrc/server/mutators/mutator/mutator_superspec.qc
qcsrc/server/mutators/mutator/mutator_weaponarena_random.qc [new file with mode: 0644]
qcsrc/server/race.qc

index 93f60fe67ac1a7ee576fbe578e162c5348810cd3..4349a1e5e24d9df7167d69919a4b896a4726c9d7 100644 (file)
@@ -2,6 +2,8 @@
 
 #ifdef IMPLEMENTATION
 #ifdef SVQC
+.float metertime;
+
 int autocvar_g_nexball_goalleadlimit;
 #define autocvar_g_nexball_goallimit cvar("g_nexball_goallimit")
 
@@ -984,14 +986,22 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPreThink)
        return false;
 }
 
+MUTATOR_HOOKFUNCTION(nb, SpectateCopy)
+{
+       SELFPARAM();
+       this.metertime = other.metertime;
+}
+
 MUTATOR_HOOKFUNCTION(nb, PlayerSpawn)
-{SELFPARAM();
-       self.weaponentity.weapons = '0 0 0';
+{
+       SELFPARAM();
+       this.metertime = 0;
+       this.weaponentity.weapons = '0 0 0';
 
-       if(nexball_mode & NBM_BASKETBALL)
-               self.weapons |= WEPSET(NEXBALL);
+       if (nexball_mode & NBM_BASKETBALL)
+               this.weapons |= WEPSET(NEXBALL);
        else
-               self.weapons = '0 0 0';
+               this.weapons = '0 0 0';
 
        return false;
 }
index 8c080862db500649b02d61508b1c1ae90b0c4a8d..b9cc0358bbd28c83601549e37f3af0456e73a9c6 100644 (file)
@@ -67,6 +67,8 @@ DEVASTATOR_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 spawnfunc(weapon_devastator) { weapon_defaultspawnfunc(WEP_DEVASTATOR.m_id); }
 spawnfunc(weapon_rocketlauncher) { spawnfunc_weapon_devastator(this); }
 
+.entity lastrocket;
+
 void W_Devastator_Unregister(void)
 {SELFPARAM();
        if(self.realowner && self.realowner.lastrocket == self)
@@ -609,6 +611,7 @@ void W_Devastator_Attack(Weapon thiswep)
                }
                METHOD(Devastator, wr_resetplayer, void(entity thiswep))
                {
+                       self.lastrocket = NULL; // stop rocket guiding, no revenge from the grave!
                        self.rl_release = 0;
                }
                METHOD(Devastator, wr_reload, void(entity thiswep))
index bc79a88a313db91961d254bbb1765966ce384f31..c158d1c3289be58c1881360c35fa8512717dbde8 100644 (file)
@@ -293,6 +293,8 @@ void W_Hook_Attack2(Weapon thiswep, entity actor)
                }
                METHOD(Hook, wr_resetplayer, void(entity thiswep))
                {
+                       RemoveGrapplingHook(self);
+                       self.hook_time = 0;
                        self.hook_refire = time;
                }
                METHOD(Hook, wr_suicidemessage, int(entity thiswep))
index c51028b620b82eafe98006f14786b3662715ba1a..5aca18183e9edfb949e697bf327ffaf537714dfa 100644 (file)
@@ -278,6 +278,12 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary)
                }
                METHOD(Vortex, wr_resetplayer, void(entity thiswep))
                {
+                       if (WEP_CVAR(vortex, charge)) {
+                               if (WEP_CVAR_SEC(vortex, chargepool)) {
+                                       self.vortex_chargepool_ammo = 1;
+                               }
+                               self.vortex_charge = WEP_CVAR(vortex, charge_start);
+                       }
                        self.vortex_lasthit = 0;
                }
                METHOD(Vortex, wr_reload, void(entity thiswep))
index 9ba5d8738df886d573a560e16a5e74943cad1035..3fdea5ae2e513267fa9f10363bf8e08d4f5fc96f 100644 (file)
@@ -128,7 +128,7 @@ void XonoticPlayerList_drawListBoxItem(entity me, int i, vector absSize, bool is
                if((t = strstrofs(score, ",", 0)) >= 0)
                        score = substring(score, 0, t);
 
-               if(stof(score) == -666)
+               if(stof(score) == FRAGS_SPECTATOR)
                        score = _("spectator");
        }
 
index d3c9007f33c5896b2ab8360e3ae786ad56e44d75..7a60823152ed2c72ee095f55e2d67192053401a1 100644 (file)
@@ -2,7 +2,6 @@
 #define SERVER_AUTOCVARS_H
 
 bool autocvar__notarget;
-bool autocvar__independent_players;
 bool autocvar__campaign_testrun;
 int autocvar__campaign_index;
 string autocvar__campaign_name;
index c4b078e14888a82fc1311584f3be5bd064bc7e0f..4bf002d10a74c670466eaedcbd0060cadbefbf55 100644 (file)
@@ -124,7 +124,7 @@ void ClientData_Touch(entity e)
 
 .string netname_previous;
 
-void SetSpectator(entity player, entity spectatee);
+void SetSpectatee(entity player, entity spectatee);
 
 
 /*
@@ -185,8 +185,8 @@ PutObserverInServer
 putting a client as observer in the server
 =============
 */
-void FixPlayermodel();
-void PutObserverInServer (void)
+void FixPlayermodel(entity player);
+void PutObserverInServer()
 {SELFPARAM();
        entity  spot;
     self.hud = HUD_NORMAL;
@@ -229,7 +229,7 @@ void PutObserverInServer (void)
        if(!mutator_returnvalue)  // mutator prevents resetting teams
                self.team = -1;  // move this as it is needed to log the player spectating in eventlog
 
-       if(self.killcount != -666)
+       if(self.killcount != FRAGS_SPECTATOR)
        {
                Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_SPECTATE, self.netname);
                if(!intermission_running)
@@ -248,11 +248,11 @@ void PutObserverInServer (void)
 
        self.spectatortime = time;
 
-       self.classname = "observer";
+       self.classname = STR_OBSERVER;
        self.iscreature = false;
        self.teleportable = TELEPORT_SIMPLE;
        self.damagedbycontents = false;
-       self.health = -666;
+       self.health = FRAGS_SPECTATOR;
        self.takedamage = DAMAGE_NO;
        self.solid = SOLID_NOT;
        self.movetype = MOVETYPE_FLY_WORLDONLY; // user preference is controlled by playerprethink
@@ -293,7 +293,7 @@ void PutObserverInServer (void)
        self.items = 0;
        self.weapons = '0 0 0';
        self.model = "";
-       FixPlayermodel();
+       FixPlayermodel(self);
        setmodel(self, MDL_Null);
        self.drawonlytoclient = self;
 
@@ -306,7 +306,7 @@ void PutObserverInServer (void)
        self.weaponmodel = "";
        self.weaponentity = world;
        self.exteriorweaponentity = world;
-       self.killcount = -666;
+       self.killcount = FRAGS_SPECTATOR;
        self.velocity = '0 0 0';
        self.avelocity = '0 0 0';
        self.punchangle = '0 0 0';
@@ -317,21 +317,15 @@ void PutObserverInServer (void)
 }
 
 .float model_randomizer;
-void FixPlayermodel()
-{SELFPARAM();
-       string defaultmodel;
-       float defaultskin, chmdl, oldskin, n, i;
-       vector m1, m2;
-
-       defaultmodel = "";
-       defaultskin = 0;
-       chmdl = false;
-
+void FixPlayermodel(entity player)
+{
+       string defaultmodel = "";
+       int defaultskin = 0;
        if(autocvar_sv_defaultcharacter)
        {
                if(teamplay)
                {
-                       string s = Static_Team_ColorName_Lower(self.team);
+                       string s = Static_Team_ColorName_Lower(player.team);
                        if (s != "neutral")
                        {
                                defaultmodel = cvar_string(strcat("sv_defaultplayermodel_", s));
@@ -345,66 +339,67 @@ void FixPlayermodel()
                        defaultskin = autocvar_sv_defaultplayerskin;
                }
 
-               n = tokenize_console(defaultmodel);
+               int n = tokenize_console(defaultmodel);
                if(n > 0)
                {
-                       defaultmodel = argv(floor(n * self.model_randomizer));
+                       defaultmodel = argv(floor(n * player.model_randomizer));
                        // However, do NOT randomize if the player-selected model is in the list.
-                       for (i = 0; i < n; ++i)
-                               if ((argv(i) == self.playermodel && defaultskin == stof(self.playerskin)) || argv(i) == strcat(self.playermodel, ":", self.playerskin))
+                       for (int i = 0; i < n; ++i)
+                               if ((argv(i) == player.playermodel && defaultskin == stof(player.playerskin)) || argv(i) == strcat(player.playermodel, ":", player.playerskin))
                                        defaultmodel = argv(i);
                }
 
-               i = strstrofs(defaultmodel, ":", 0);
+               int i = strstrofs(defaultmodel, ":", 0);
                if(i >= 0)
                {
                        defaultskin = stof(substring(defaultmodel, i+1, -1));
                        defaultmodel = substring(defaultmodel, 0, i);
                }
        }
-
        MUTATOR_CALLHOOK(FixPlayermodel, defaultmodel, defaultskin);
        defaultmodel = ret_string;
        defaultskin = ret_int;
 
+       bool chmdl = false;
+       int oldskin;
        if(defaultmodel != "")
        {
-               if (defaultmodel != self.model)
+               if (defaultmodel != player.model)
                {
-                       m1 = self.mins;
-                       m2 = self.maxs;
-                       setplayermodel (self, defaultmodel);
-                       setsize (self, m1, m2);
+                       vector m1 = player.mins;
+                       vector m2 = player.maxs;
+                       setplayermodel (player, defaultmodel);
+                       setsize (player, m1, m2);
                        chmdl = true;
                }
 
-               oldskin = self.skin;
-               self.skin = defaultskin;
+               oldskin = player.skin;
+               player.skin = defaultskin;
        } else {
-               if (self.playermodel != self.model || self.playermodel == "")
+               if (player.playermodel != player.model || player.playermodel == "")
                {
-                       self.playermodel = CheckPlayerModel(self.playermodel); // this is never "", so no endless loop
-                       m1 = self.mins;
-                       m2 = self.maxs;
-                       setplayermodel (self, self.playermodel);
-                       setsize (self, m1, m2);
+                       player.playermodel = CheckPlayerModel(player.playermodel); // this is never "", so no endless loop
+                       vector m1 = player.mins;
+                       vector m2 = player.maxs;
+                       setplayermodel (player, player.playermodel);
+                       setsize (player, m1, m2);
                        chmdl = true;
                }
 
-               oldskin = self.skin;
-               self.skin = stof(self.playerskin);
+               oldskin = player.skin;
+               player.skin = stof(player.playerskin);
        }
 
-       if(chmdl || oldskin != self.skin) // model or skin has changed
+       if(chmdl || oldskin != player.skin) // model or skin has changed
        {
-               self.species = player_getspecies(); // update species
+               player.species = player_getspecies(); // update species
                UpdatePlayerSounds(); // update skin sounds
        }
 
        if(!teamplay)
                if(strlen(autocvar_sv_defaultplayercolors))
-                       if(self.clientcolors != stof(autocvar_sv_defaultplayercolors))
-                               setcolor(self, stof(autocvar_sv_defaultplayercolors));
+                       if(player.clientcolors != stof(autocvar_sv_defaultplayercolors))
+                               setcolor(player, stof(autocvar_sv_defaultplayercolors));
 }
 
 
@@ -412,256 +407,216 @@ void FixPlayermodel()
 void PutClientInServer()
 {
        SELFPARAM();
-       if(IS_BOT_CLIENT(self))
-               self.classname = "player";
-       else if(IS_REAL_CLIENT(self))
-       {
-               msg_entity = self;
+       if (IS_BOT_CLIENT(this)) {
+               this.classname = STR_PLAYER;
+       } else if (IS_REAL_CLIENT(this)) {
+               msg_entity = this;
                WriteByte(MSG_ONE, SVC_SETVIEW);
-               WriteEntity(MSG_ONE, self);
+               WriteEntity(MSG_ONE, this);
        }
 
-       SetSpectator(self, world);
+       SetSpectatee(this, NULL);
 
        // reset player keys
-       self.itemkeys = 0;
+       this.itemkeys = 0;
 
-       MUTATOR_CALLHOOK(PutClientInServer, self);
+       MUTATOR_CALLHOOK(PutClientInServer, this);
 
-       if(gameover)
-               self.classname = "observer";
+       if (gameover) {
+               this.classname = STR_OBSERVER;
+               PutObserverInServer();
+               return;
+       }
 
-       if(IS_PLAYER(self))
+       if (IS_PLAYER(this))
        {
-               entity spot;
-
-               accuracy_resend(self);
+               accuracy_resend(this);
 
-               if(self.team < 0)
-                       JoinBestTeam(self, false, true);
+               if (this.team < 0)
+                       JoinBestTeam(this, false, true);
 
-               spot = SelectSpawnPoint (false);
-               if(!spot)
-               {
-                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_JOIN_NOSPAWNS);
+               entity spot = SelectSpawnPoint(false);
+               if (!spot) {
+                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_JOIN_NOSPAWNS);
                        return; // spawn failed
                }
 
-               RemoveGrapplingHook(self); // Wazat's Grappling Hook
-
-               self.classname = "player";
-               self.wasplayer = true;
-               self.iscreature = true;
-               self.teleportable = TELEPORT_NORMAL;
-               self.damagedbycontents = true;
-               self.movetype = MOVETYPE_WALK;
-               self.solid = SOLID_SLIDEBOX;
-               self.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_SOLID;
-               if(autocvar_g_playerclip_collisions)
-                       self.dphitcontentsmask |= DPCONTENTS_PLAYERCLIP;
-               if(IS_BOT_CLIENT(self) && autocvar_g_botclip_collisions)
-                       self.dphitcontentsmask |= DPCONTENTS_BOTCLIP;
-               self.frags = FRAGS_PLAYER;
-               if(INDEPENDENT_PLAYERS)
-                       MAKE_INDEPENDENT_PLAYER(self);
-               self.flags = FL_CLIENT | FL_PICKUPITEMS;
-               if(autocvar__notarget)
-                       self.flags |= FL_NOTARGET;
-               self.takedamage = DAMAGE_AIM;
-               self.effects = 0;
-               self.effects |= EF_TELEPORT_BIT | EF_RESTARTANIM_BIT;
-               self.air_finished = time + 12;
-               self.dmg = 2;
-               if(WEP_CVAR(vortex, charge))
-               {
-                       if(WEP_CVAR_SEC(vortex, chargepool))
-                               self.vortex_chargepool_ammo = 1;
-                       self.vortex_charge = WEP_CVAR(vortex, charge_start);
-               }
-
-               if(warmup_stage)
-               {
-                       self.ammo_shells = warmup_start_ammo_shells;
-                       self.ammo_nails = warmup_start_ammo_nails;
-                       self.ammo_rockets = warmup_start_ammo_rockets;
-                       self.ammo_cells = warmup_start_ammo_cells;
-                       self.ammo_plasma = warmup_start_ammo_plasma;
-                       self.ammo_fuel = warmup_start_ammo_fuel;
-                       self.health = warmup_start_health;
-                       self.armorvalue = warmup_start_armorvalue;
-                       self.weapons = WARMUP_START_WEAPONS;
-               }
-               else
-               {
-                       self.ammo_shells = start_ammo_shells;
-                       self.ammo_nails = start_ammo_nails;
-                       self.ammo_rockets = start_ammo_rockets;
-                       self.ammo_cells = start_ammo_cells;
-                       self.ammo_plasma = start_ammo_plasma;
-                       self.ammo_fuel = start_ammo_fuel;
-                       self.health = start_health;
-                       self.armorvalue = start_armorvalue;
-                       self.weapons = start_weapons;
-               }
-
-               if(self.weapons & WEPSET_SUPERWEAPONS)
-                       self.superweapons_finished = time + autocvar_g_balance_superweapons_time;
-               else
-                       self.superweapons_finished = 0;
-
-               if(g_weaponarena_random) // WEAPONTODO: more stuff that should be in a mutator. also: rename those cvars
-               {
-                       if(g_weaponarena_random_with_blaster)
-                               self.weapons &= ~WEPSET(BLASTER);
-                       W_RandomWeapons(self, g_weaponarena_random);
-                       if(g_weaponarena_random_with_blaster)
-                               self.weapons |= WEPSET(BLASTER);
+               this.classname = STR_PLAYER;
+               this.wasplayer = true;
+               this.iscreature = true;
+               this.teleportable = TELEPORT_NORMAL;
+               this.damagedbycontents = true;
+               this.movetype = MOVETYPE_WALK;
+               this.solid = SOLID_SLIDEBOX;
+               this.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_SOLID;
+               if (autocvar_g_playerclip_collisions)
+                       this.dphitcontentsmask |= DPCONTENTS_PLAYERCLIP;
+               if (IS_BOT_CLIENT(this) && autocvar_g_botclip_collisions)
+                       this.dphitcontentsmask |= DPCONTENTS_BOTCLIP;
+               this.frags = FRAGS_PLAYER;
+               if (INDEPENDENT_PLAYERS) MAKE_INDEPENDENT_PLAYER(this);
+               this.flags = FL_CLIENT | FL_PICKUPITEMS;
+               if (autocvar__notarget)
+                       this.flags |= FL_NOTARGET;
+               this.takedamage = DAMAGE_AIM;
+               this.effects = EF_TELEPORT_BIT | EF_RESTARTANIM_BIT;
+               this.dmg = 2; // WTF
+
+               if (warmup_stage) {
+                       this.ammo_shells = warmup_start_ammo_shells;
+                       this.ammo_nails = warmup_start_ammo_nails;
+                       this.ammo_rockets = warmup_start_ammo_rockets;
+                       this.ammo_cells = warmup_start_ammo_cells;
+                       this.ammo_plasma = warmup_start_ammo_plasma;
+                       this.ammo_fuel = warmup_start_ammo_fuel;
+                       this.health = warmup_start_health;
+                       this.armorvalue = warmup_start_armorvalue;
+                       this.weapons = WARMUP_START_WEAPONS;
+               } else {
+                       this.ammo_shells = start_ammo_shells;
+                       this.ammo_nails = start_ammo_nails;
+                       this.ammo_rockets = start_ammo_rockets;
+                       this.ammo_cells = start_ammo_cells;
+                       this.ammo_plasma = start_ammo_plasma;
+                       this.ammo_fuel = start_ammo_fuel;
+                       this.health = start_health;
+                       this.armorvalue = start_armorvalue;
+                       this.weapons = start_weapons;
                }
 
-               self.items = start_items;
-
-               self.spawnshieldtime = time + autocvar_g_spawnshieldtime;
-               self.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot_spawn;
-               self.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot_spawn;
-               self.pauserotfuel_finished = time + autocvar_g_balance_pause_fuel_rot_spawn;
-               self.pauseregen_finished = time + autocvar_g_balance_pause_health_regen_spawn;
-               //extend the pause of rotting if client was reset at the beginning of the countdown
-               if(!autocvar_sv_ready_restart_after_countdown && time < game_starttime) { // TODO why is this cvar NOTted?
-                       self.spawnshieldtime += game_starttime - time;
-                       self.pauserotarmor_finished += game_starttime - time;
-                       self.pauserothealth_finished += game_starttime - time;
-                       self.pauseregen_finished += game_starttime - time;
+               this.superweapons_finished = (this.weapons & WEPSET_SUPERWEAPONS) ? time + autocvar_g_balance_superweapons_time : 0;
+
+               this.items = start_items;
+
+               this.spawnshieldtime = time + autocvar_g_spawnshieldtime;
+               this.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot_spawn;
+               this.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot_spawn;
+               this.pauserotfuel_finished = time + autocvar_g_balance_pause_fuel_rot_spawn;
+               this.pauseregen_finished = time + autocvar_g_balance_pause_health_regen_spawn;
+               // extend the pause of rotting if client was reset at the beginning of the countdown
+               if (!autocvar_sv_ready_restart_after_countdown && time < game_starttime) { // TODO why is this cvar NOTted?
+                       float f = game_starttime - time;
+                       this.spawnshieldtime += f;
+                       this.pauserotarmor_finished += f;
+                       this.pauserothealth_finished += f;
+                       this.pauseregen_finished += f;
                }
-               self.damageforcescale = 2;
-               self.death_time = 0;
-               self.respawn_flags = 0;
-               self.respawn_time = 0;
-               self.stat_respawn_time = 0;
-               self.scale = autocvar_sv_player_scale;
-               self.fade_time = 0;
-               self.pain_frame = 0;
-               self.pain_finished = 0;
-               self.strength_finished = 0;
-               self.invincible_finished = 0;
-               self.pushltime = 0;
-               // players have no think function
-               self.think = func_null;
-               self.nextthink = 0;
-               self.hook_time = 0;
-               self.dmg_team = 0;
-               self.ballistics_density = autocvar_g_ballistics_density_player;
-
-               self.metertime = 0;
-
-               self.deadflag = DEAD_NO;
-
-               self.angles = spot.angles;
-
-               self.angles_z = 0; // never spawn tilted even if the spot says to
-               if(IS_BOT_CLIENT(self))
-                       self.v_angle = self.angles;
-               self.fixangle = true; // turn this way immediately
-               self.velocity = '0 0 0';
-               self.avelocity = '0 0 0';
-               self.punchangle = '0 0 0';
-               self.punchvector = '0 0 0';
-               self.oldvelocity = self.velocity;
-               self.fire_endtime = -1;
-               self.revival_time = 0;
+               this.damageforcescale = 2;
+               this.death_time = 0;
+               this.respawn_flags = 0;
+               this.respawn_time = 0;
+               this.stat_respawn_time = 0;
+               this.scale = autocvar_sv_player_scale;
+               this.fade_time = 0;
+               this.pain_frame = 0;
+               this.pain_finished = 0;
+               this.pushltime = 0;
+               this.think = func_null; // players have no think function
+               this.nextthink = 0;
+               this.dmg_team = 0;
+               this.ballistics_density = autocvar_g_ballistics_density_player;
+
+               this.deadflag = DEAD_NO;
+
+               this.angles = spot.angles;
+               this.angles_z = 0; // never spawn tilted even if the spot says to
+               if (IS_BOT_CLIENT(this))
+                       this.v_angle = this.angles;
+               this.fixangle = true; // turn this way immediately
+               this.oldvelocity = this.velocity = '0 0 0';
+               this.avelocity = '0 0 0';
+               this.punchangle = '0 0 0';
+               this.punchvector = '0 0 0';
+
+               this.strength_finished = 0;
+               this.invincible_finished = 0;
+               this.fire_endtime = -1;
+               this.revival_time = 0;
+               this.air_finished = time + 12;
 
                entity spawnevent = spawn();
-               spawnevent.owner = self;
+               spawnevent.owner = this;
                Net_LinkEntity(spawnevent, false, 0.5, SpawnEvent_Send);
 
                // Cut off any still running player sounds.
-               stopsound(self, CH_PLAYER_SINGLE);
+               stopsound(this, CH_PLAYER_SINGLE);
 
-               self.model = "";
-               FixPlayermodel();
-               self.drawonlytoclient = world;
+               this.model = "";
+               FixPlayermodel(this);
+               this.drawonlytoclient = NULL;
 
-               self.crouch = false;
-               self.view_ofs = PL_VIEW_OFS;
-               setsize (self, PL_MIN, PL_MAX);
-               self.spawnorigin = spot.origin;
-               setorigin (self, spot.origin + '0 0 1' * (1 - self.mins.z - 24));
+               this.crouch = false;
+               this.view_ofs = PL_VIEW_OFS;
+               setsize(this, PL_MIN, PL_MAX);
+               this.spawnorigin = spot.origin;
+               setorigin(this, spot.origin + '0 0 1' * (1 - this.mins.z - 24));
                // don't reset back to last position, even if new position is stuck in solid
-               self.oldorigin = self.origin;
-               self.prevorigin = self.origin;
-               self.lastrocket = world; // stop rocket guiding, no revenge from the grave!
-               self.lastteleporttime = time; // prevent insane speeds due to changing origin
-        self.hud = HUD_NORMAL;
+               this.oldorigin = this.origin;
+               this.prevorigin = this.origin;
+               this.lastteleporttime = time; // prevent insane speeds due to changing origin
+        this.hud = HUD_NORMAL;
 
-               self.event_damage = PlayerDamage;
+               this.event_damage = PlayerDamage;
 
-               self.bot_attack = true;
-               self.monster_attack = true;
+               this.bot_attack = true;
+               this.monster_attack = true;
 
-               self.spider_slowness = 0;
+               this.spider_slowness = 0;
 
-               self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = 0;
+               this.BUTTON_ATCK = this.BUTTON_JUMP = this.BUTTON_ATCK2 = false;
 
-               if(self.killcount == -666) {
-                       PlayerScore_Clear(self);
-                       self.killcount = 0;
+               if (this.killcount == FRAGS_SPECTATOR) {
+                       PlayerScore_Clear(this);
+                       this.killcount = 0;
                }
 
-               CL_SpawnWeaponentity(self);
-               self.alpha = default_player_alpha;
-               self.colormod = '1 1 1' * autocvar_g_player_brightness;
-               self.exteriorweaponentity.alpha = default_weapon_alpha;
-
-               self.speedrunning = false;
+               CL_SpawnWeaponentity(this);
+               this.alpha = default_player_alpha;
+               this.colormod = '1 1 1' * autocvar_g_player_brightness;
+               this.exteriorweaponentity.alpha = default_weapon_alpha;
 
-               //stuffcmd(self, "chase_active 0");
-               //stuffcmd(self, "set viewsize $tmpviewsize \n");
+               this.speedrunning = false;
 
-               target_voicescript_clear(self);
+               target_voicescript_clear(this);
 
                // reset fields the weapons may use
-               for (int j = WEP_FIRST; j <= WEP_LAST; ++j)
-               {
-                       Weapon w = get_weaponinfo(j);
-                       w.wr_resetplayer(w);
+               FOREACH(Weapons, true, LAMBDA(
+                       it.wr_resetplayer(it);
+                       // reload all reloadable weapons
+                       if (it.spawnflags & WEP_FLAG_RELOADABLE) {
+                               this.weapon_load[it.m_id] = it.reloading_ammo;
+                       }
+               ));
 
-                       // all weapons must be fully loaded when we spawn
-                       entity e = get_weaponinfo(j);
-                       if (e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
-                               self.(weapon_load[j]) = e.reloading_ammo;
+               {
+                       string s = spot.target;
+                       spot.target = string_null;
+                       WITH(entity, activator, this, LAMBDA(
+                               WITH(entity, self, spot, SUB_UseTargets())
+                       ));
+                       spot.target = s;
                }
 
-               string s = spot.target;
-               spot.target = string_null;
-               activator = self;
-               WITH(entity, self, spot, SUB_UseTargets());
-               activator = world;
-               spot.target = s;
-
-               Unfreeze(self);
+               Unfreeze(this);
 
                MUTATOR_CALLHOOK(PlayerSpawn, spot);
 
-               if(autocvar_spawn_debug)
+               if (autocvar_spawn_debug)
                {
-                       sprint(self, strcat("spawnpoint origin:  ", vtos(spot.origin), "\n"));
-                       remove(spot);   // usefull for checking if there are spawnpoints, that let drop through the floor
+                       sprint(this, strcat("spawnpoint origin:  ", vtos(spot.origin), "\n"));
+                       remove(spot); // usefull for checking if there are spawnpoints, that let drop through the floor
                }
 
-               self.switchweapon = w_getbestweapon(self);
-               self.cnt = -1; // W_LastWeapon will not complain
-               self.weapon = 0;
-               self.weaponname = "";
-               self.switchingweapon = 0;
+               this.switchweapon = w_getbestweapon(this);
+               this.cnt = -1; // W_LastWeapon will not complain
+               this.weapon = 0;
+               this.weaponname = "";
+               this.switchingweapon = 0;
 
-               if(!warmup_stage)
-                       if(!self.alivetime)
-                               self.alivetime = time;
+               if (!warmup_stage && !this.alivetime)
+                       this.alivetime = time;
 
-               antilag_clear(self);
-       }
-       else if(IS_OBSERVER(self))
-       {
-               PutObserverInServer ();
+               antilag_clear(this);
        }
 }
 
@@ -1131,23 +1086,23 @@ void ClientConnect (void)
        JoinBestTeam(self, false, false); // if the team number is valid, keep it
 
        if((autocvar_sv_spectate == 1) || autocvar_g_campaign || self.team_forced < 0) {
-               self.classname = "observer";
+               self.classname = STR_OBSERVER;
        } else {
                if(teamplay)
                {
                        if(autocvar_g_balance_teams)
                        {
-                               self.classname = "player";
+                               self.classname = STR_PLAYER;
                                campaign_bots_may_start = 1;
                        }
                        else
                        {
-                               self.classname = "observer"; // do it anyway
+                               self.classname = STR_OBSERVER; // do it anyway
                        }
                }
                else
                {
-                       self.classname = "player";
+                       self.classname = STR_PLAYER;
                        campaign_bots_may_start = 1;
                }
        }
@@ -1712,7 +1667,6 @@ void SpectateCopy(entity spectatee)
        self.items = spectatee.items;
        self.last_pickup = spectatee.last_pickup;
        self.hit_time = spectatee.hit_time;
-       self.metertime = spectatee.metertime;
        self.strength_finished = spectatee.strength_finished;
        self.invincible_finished = spectatee.invincible_finished;
        self.pressedkeys = spectatee.pressedkeys;
@@ -1776,7 +1730,7 @@ bool SpectateUpdate()
 
        if(!IS_PLAYER(self.enemy) || self == self.enemy)
        {
-               SetSpectator(self, world);
+               SetSpectatee(self, NULL);
                return false;
        }
 
@@ -1802,7 +1756,7 @@ bool SpectateSet()
        return true;
 }
 
-void SetSpectator(entity player, entity spectatee)
+void SetSpectatee(entity player, entity spectatee)
 {
        entity old_spectatee = player.enemy;
 
@@ -1820,7 +1774,7 @@ bool Spectate(entity pl)
                return false;
        pl = spec_player;
 
-       SetSpectator(self, pl);
+       SetSpectatee(self, pl);
        return SpectateSet();
 }
 
@@ -1834,7 +1788,7 @@ bool SpectateNext()
        if(!mutator_returnvalue && !other)
                other = find(other, classname, "player");
 
-       if(other) { SetSpectator(self, other); }
+       if(other) { SetSpectatee(self, other); }
 
        return SpectateSet();
 }
@@ -1870,7 +1824,7 @@ bool SpectatePrev()
                }
        }
 
-       SetSpectator(self, other);
+       SetSpectatee(self, other);
        return SpectateSet();
 }
 
@@ -1908,7 +1862,7 @@ void LeaveSpectatorMode()
        {
                if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || (self.wasplayer && autocvar_g_changeteam_banned) || self.team_forced > 0)
                {
-                       self.classname = "player";
+                       self.classname = STR_PLAYER;
                        nades_RemoveBonus(self);
 
                        if(autocvar_g_campaign || autocvar_g_balance_teams)
@@ -2054,7 +2008,7 @@ void ObserverThink()
                } else if(self.BUTTON_ATCK && !self.version_mismatch) {
                        self.flags &= ~FL_JUMPRELEASED;
                        if(SpectateNext()) {
-                               self.classname = "spectator";
+                               self.classname = STR_SPECTATOR;
                        }
                } else {
                        prefered_movetype = ((!self.BUTTON_USE ? self.cvar_cl_clippedspectating : !self.cvar_cl_clippedspectating) ? MOVETYPE_FLY_WORLDONLY : MOVETYPE_NOCLIP);
@@ -2088,24 +2042,24 @@ void SpectatorThink()
                } else if(self.BUTTON_ATCK || self.impulse == 10 || self.impulse == 15 || self.impulse == 18 || (self.impulse >= 200 && self.impulse <= 209)) {
                        self.flags &= ~FL_JUMPRELEASED;
                        if(SpectateNext()) {
-                               self.classname = "spectator";
+                               self.classname = STR_SPECTATOR;
                        } else {
-                               self.classname = "observer";
+                               self.classname = STR_OBSERVER;
                                PutClientInServer();
                        }
                        self.impulse = 0;
                } else if(self.impulse == 12 || self.impulse == 16  || self.impulse == 19 || (self.impulse >= 220 && self.impulse <= 229)) {
                        self.flags &= ~FL_JUMPRELEASED;
                        if(SpectatePrev()) {
-                               self.classname = "spectator";
+                               self.classname = STR_SPECTATOR;
                        } else {
-                               self.classname = "observer";
+                               self.classname = STR_OBSERVER;
                                PutClientInServer();
                        }
                        self.impulse = 0;
                } else if (self.BUTTON_ATCK2) {
                        self.flags &= ~FL_JUMPRELEASED;
-                       self.classname = "observer";
+                       self.classname = STR_OBSERVER;
                        PutClientInServer();
                } else {
                        if(!SpectateUpdate())
@@ -2502,7 +2456,7 @@ void PlayerPreThink (void)
                        }
                }
 
-               FixPlayermodel();
+               FixPlayermodel(self);
 
                // LordHavoc: allow firing on move frames (sub-ticrate), this gives better timing on slow servers
                //if(frametime)
index e4eee69834d4e53632952f8520d8649df34b7bb4..69517738b7aa6cd2721892fdc369b101c55f054c 100644 (file)
@@ -113,7 +113,7 @@ void ClientCommand_clientversion(float request, float argc) // internal command,
                                        }
                                        else if(teamplay && !autocvar_sv_spectate && !(self.team_forced > 0))
                                        {
-                                               self.classname = "observer"; // really?
+                                               self.classname = STR_OBSERVER; // really?
                                                stuffcmd(self, "menu_showteamselect\n");
                                        }
                                }
@@ -175,7 +175,7 @@ void ClientCommand_join(float request)
                                        {
                                                if(autocvar_g_campaign) { campaign_bots_may_start = 1; }
 
-                                               self.classname = "player";
+                                               self.classname = STR_PLAYER;
                                                PlayerScore_Clear(self);
                                                Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_PREVENT_JOIN);
                                                Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_JOIN_PLAY, self.netname);
index 5e86dea0f7378d19028c793135c110a07b733a81..463d0bc8f316defbad7d50a356a7107332118a77 100644 (file)
@@ -378,11 +378,11 @@ float GetPlayerSoundSampleField_notFound;
 
 .float version_mismatch;
 
-float independent_players;
+int autocvar__independent_players;
+bool independent_players;
 #define INDEPENDENT_PLAYERS (autocvar__independent_players ? (autocvar__independent_players > 0) : independent_players)
 #define IS_INDEPENDENT_PLAYER(e) ((e).solid == SOLID_TRIGGER)
-#define MAKE_INDEPENDENT_PLAYER(e) (((e).solid = SOLID_TRIGGER) + ((e).frags = FRAGS_PLAYER_NONSOLID))
-// we're using + here instead of , because fteqcc sucks
+#define MAKE_INDEPENDENT_PLAYER(e) (((e).solid = SOLID_TRIGGER), ((e).frags = FRAGS_PLAYER_NONSOLID))
 
 string clientstuff;
 .float phase;
@@ -413,7 +413,6 @@ void W_Porto_Remove (entity p);
 
 // Nexball
 .entity ballcarried; // Also used for keepaway
-.float metertime;
 float g_nexball_meter_period;
 
 void SUB_DontUseTargets();
@@ -469,7 +468,6 @@ float client_cefc_accumulatortime;
 .float old_clip_load;
 .float clip_size;
 
-.entity lastrocket;
 .float minelayer_mines;
 .float vortex_charge;
 .float vortex_charge_rottime;
index 8354007aa0fc2b3ac463cb5416354109e33a08c0..802eabd7fd7219d12b8eea680b1985e3eddfec2b 100644 (file)
@@ -626,7 +626,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
        mirrordamage = 0;
        mirrorforce = 0;
 
-       if (gameover || targ.killcount == -666)
+       if (gameover || targ.killcount == FRAGS_SPECTATOR)
                return;
 
        setself(targ);
index c61e505e91a4be949255b0decfa43d6c8f01b7f0..8d23f511139ea7d6fb956f68ca0c7e4194379a43 100644 (file)
@@ -138,9 +138,9 @@ const string STR_PLAYER = "player";
 const string STR_SPECTATOR = "spectator";
 const string STR_OBSERVER = "observer";
 
-#define IS_PLAYER(v)                   (v.classname == STR_PLAYER)
-#define IS_SPEC(v)                             (v.classname == STR_SPECTATOR)
-#define IS_OBSERVER(v)                         (v.classname == STR_OBSERVER)
+#define IS_PLAYER(v)                   ((v).classname == STR_PLAYER)
+#define IS_SPEC(v)                             ((v).classname == STR_SPECTATOR)
+#define IS_OBSERVER(v)                         ((v).classname == STR_OBSERVER)
 #define IS_CLIENT(v)                   (v.flags & FL_CLIENT)
 #define IS_BOT_CLIENT(v)               (clienttype(v) == CLIENTTYPE_BOT)
 #define IS_REAL_CLIENT(v)              (clienttype(v) == CLIENTTYPE_REAL)
index f67ceaee65d92f89bbf4e6ef4b7a2ef60d4c8827..d1cd583b15503dffb5b5b1242325341d16f37217 100644 (file)
@@ -37,5 +37,6 @@
 #include "mutator/mutator_touchexplode.qc"
 #include "mutator/mutator_vampirehook.qc"
 #include "mutator/mutator_vampire.qc"
+#include "mutator/mutator_weaponarena_random.qc"
 
 #include "mutator/sandbox.qc"
index 88e56bb9d208fc8ce49d397c7341d2c86a9d8dab..b9621cdadaf1822535d7a3f6d3a4c7e8f091b5fb 100644 (file)
@@ -237,7 +237,7 @@ MUTATOR_HOOKFUNCTION(ca, PutClientInServer)
        if(!allowed_to_spawn)
        if(IS_PLAYER(self)) // this is true even when player is trying to join
        {
-               self.classname = "observer";
+               self.classname = STR_OBSERVER;
                if(self.jointime != time) //not when connecting
                if(!self.caplayer)
                {
@@ -263,7 +263,7 @@ MUTATOR_HOOKFUNCTION(ca, reset_map_players)
                }
                if(self.caplayer)
                {
-                       self.classname = "player";
+                       self.classname = STR_PLAYER;
                        self.caplayer = 1;
                        PutClientInServer();
                }
@@ -273,7 +273,7 @@ MUTATOR_HOOKFUNCTION(ca, reset_map_players)
 
 MUTATOR_HOOKFUNCTION(ca, ClientConnect)
 {SELFPARAM();
-       self.classname = "observer";
+       self.classname = STR_OBSERVER;
        return 1;
 }
 
index 064031153cd2a6974e6f95ce5a8b2045b4800ffa..982da6ea3e6307699aead50e51b4fafe666ec05a 100644 (file)
@@ -286,7 +286,7 @@ MUTATOR_HOOKFUNCTION(cts, PutClientInServer)
        if(IS_PLAYER(self))
        if(!gameover)
        {
-               if(self.killcount == -666 /* initial spawn */ || g_race_qualifying) // spawn
+               if(self.killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn
                        race_PreparePlayer();
                else // respawn
                        race_RetractPlayer();
index de11a6739e9b01415ffa34e9d532806641f152fe..f2ee672dad4026b425160afb8e3771f7fd93c100 100644 (file)
@@ -178,7 +178,7 @@ MUTATOR_HOOKFUNCTION(lms, PutClientInServer)
        // FIXME fix LMS scoring for new system
        if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0)
        {
-               self.classname = "observer";
+               self.classname = STR_OBSERVER;
                Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_LMS_NOLIVES);
        }
 
@@ -200,7 +200,7 @@ void lms_RemovePlayer(entity player)
        else
                player.frags = FRAGS_LMS_LOSER;
 
-       if(player.killcount != -666)
+       if(player.killcount != FRAGS_SPECTATOR)
                if(PlayerScore_Add(player, SP_LMS_RANK, 0) > 0 && player.lms_spectate_warning != 2)
                        Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_LMS_NOLIVES, player.netname);
                else
@@ -221,7 +221,7 @@ MUTATOR_HOOKFUNCTION(lms, MakePlayerObserver)
 
 MUTATOR_HOOKFUNCTION(lms, ClientConnect)
 {SELFPARAM();
-       self.classname = "player";
+       self.classname = STR_PLAYER;
        campaign_bots_may_start = 1;
 
        if(PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives()) <= 0)
index cc250dfc73e75f870ee649071ac9e2d6c3655b41..229242f8b3cca30c17feb55aaafdf0f08ac249c5 100644 (file)
@@ -284,7 +284,7 @@ MUTATOR_HOOKFUNCTION(rc, PutClientInServer)
        if(IS_PLAYER(self))
        if(!gameover)
        {
-               if(self.killcount == -666 /* initial spawn */ || g_race_qualifying) // spawn
+               if(self.killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn
                        race_PreparePlayer();
                else // respawn
                        race_RetractPlayer();
index f24b3233546a4d1dbb1a59c4e8c4d87a4cb6e51c..00ebbafe08e1f784624b5275d809b636c135c9f2 100644 (file)
@@ -26,7 +26,7 @@ const float SSF_ITEMMSG = 4;
 bool superspec_Spectate(entity _player)
 {SELFPARAM();
        if(Spectate(_player) == 1)
-               self.classname = "spectator";
+               self.classname = STR_SPECTATOR;
 
        return true;
 }
diff --git a/qcsrc/server/mutators/mutator/mutator_weaponarena_random.qc b/qcsrc/server/mutators/mutator/mutator_weaponarena_random.qc
new file mode 100644 (file)
index 0000000..5c82100
--- /dev/null
@@ -0,0 +1,13 @@
+#ifdef IMPLEMENTATION
+// WEAPONTODO: rename the cvars
+REGISTER_MUTATOR(weaponarena_random, true);
+
+MUTATOR_HOOKFUNCTION(weaponarena_random, PlayerSpawn) {
+    SELFPARAM();
+    if (!g_weaponarena_random) return;
+    if (g_weaponarena_random_with_blaster) this.weapons &= ~WEPSET(BLASTER);
+    W_RandomWeapons(this, g_weaponarena_random);
+    if (g_weaponarena_random_with_blaster) this.weapons |= WEPSET(BLASTER);
+}
+
+#endif
index 4f8298238fcaf7755799c08ea0af8cd84e56a0d0..fe7606a39ba1ebba3dbe87b009a8ded4669289b5 100644 (file)
@@ -746,7 +746,7 @@ void trigger_race_checkpoint_verify()
        qual = g_race_qualifying;
 
        setself(spawn());
-       self.classname = "player";
+       self.classname = STR_PLAYER;
 
        if(g_race)
        {