]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
Merge branch 'master' into Mario/is_macro
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index a49268d194fb872826ca878f575612f796ed5931..b7072849c59b9e9cd9dacf1d7cd5e9fedf2c620b 100644 (file)
@@ -1,18 +1,32 @@
+#include "cl_client.qh"
+
 #include "waypointsprites.qh"
 
+#include "anticheat.qh"
 #include "cl_impulse.qh"
 #include "cl_player.qh"
 #include "ent_cs.qh"
-#include "g_subs.qh"
 #include "ipban.qh"
 #include "miscfunctions.qh"
 #include "portals.qh"
 #include "teamplay.qh"
 #include "playerdemo.qh"
+#include "spawnpoints.qh"
+#include "g_damage.qh"
+#include "g_hook.qh"
+#include "command/common.qh"
+#include "cheats.qh"
+#include "g_world.qh"
+#include "race.qh"
+#include "antilag.qh"
+#include "campaign.qh"
+#include "command/common.qh"
 
 #include "bot/bot.qh"
 #include "bot/navigation.qh"
 
+#include "vehicles/vehicle.qh"
+
 #include "weapons/hitplot.qh"
 #include "weapons/weaponsystem.qh"
 
 #include "../common/triggers/triggers.qh"
 #include "../common/triggers/trigger/secret.qh"
 
+#include "../common/items/inventory.qh"
+
 #include "../common/monsters/sv_monsters.qh"
 
 #include "../warpzonelib/server.qh"
 
-float c1, c2, c3, c4;
 
 void send_CSQC_teamnagger() {
        WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
@@ -171,7 +186,7 @@ void PutObserverInServer (void)
        entity  spot;
     self.hud = HUD_NORMAL;
 
-       if(IS_PLAYER(self)) { pointparticles(particleeffectnum("spawn_event_neutral"), self.origin, '0 0 0', 1); }
+       if(IS_PLAYER(self)) { Send_Effect("spawn_event_neutral", self.origin, '0 0 0', 1); }
 
        spot = SelectSpawnPoint (true);
        if(!spot)
@@ -180,6 +195,7 @@ void PutObserverInServer (void)
 
        if(IS_REAL_CLIENT(self))
        {
+               Item_ItemsTime_SetTimesForPlayer(self);
                msg_entity = self;
                WriteByte(MSG_ONE, SVC_SETVIEW);
                WriteEntity(MSG_ONE, self);
@@ -211,7 +227,8 @@ void PutObserverInServer (void)
        if(self.killcount != -666)
        {
                Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_SPECTATE, self.netname);
-               if(autocvar_g_chat_nospectators == 1 || (cvar("g_warmup") && !(warmup_stage || gameover) && autocvar_g_chat_nospectators == 2))
+               if(!intermission_running)
+               if(autocvar_g_chat_nospectators == 1 || (!(warmup_stage || gameover) && autocvar_g_chat_nospectators == 2))
                        Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CHAT_NOSPECTATORS);
 
                if(self.just_joined == false) {
@@ -305,7 +322,7 @@ void FixPlayermodel()
        defaultskin = 0;
        chmdl = false;
 
-       if(autocvar_sv_defaultcharacter == 1)
+       if(autocvar_sv_defaultcharacter)
        {
                if(teamplay)
                {
@@ -405,7 +422,7 @@ void PutClientInServer (void)
        // reset player keys
        self.itemkeys = 0;
 
-       MUTATOR_CALLHOOK(PutClientInServer);
+       MUTATOR_CALLHOOK(PutClientInServer, self);
 
        if(gameover)
                self.classname = "observer";
@@ -413,7 +430,6 @@ void PutClientInServer (void)
        if(IS_PLAYER(self))
        {
                entity spot, oldself;
-               float j;
 
                accuracy_resend(self);
 
@@ -492,6 +508,9 @@ void PutClientInServer (void)
                else
                        self.superweapons_finished = 0;
 
+               if(!warmup_stage)
+                       Item_ItemsTime_ResetTimesForPlayer(self);
+
                if(g_weaponarena_random) // WEAPONTODO: more stuff that should be in a mutator. also: rename those cvars
                {
                        if(g_weaponarena_random_with_blaster)
@@ -520,7 +539,7 @@ void PutClientInServer (void)
                self.respawn_flags = 0;
                self.respawn_time = 0;
                self.stat_respawn_time = 0;
-               self.scale = 0;
+               self.scale = autocvar_sv_player_scale;
                self.fade_time = 0;
                self.pain_frame = 0;
                self.pain_finished = 0;
@@ -602,13 +621,13 @@ void PutClientInServer (void)
                target_voicescript_clear(self);
 
                // reset fields the weapons may use
-               for (j = WEP_FIRST; j <= WEP_LAST; ++j)
+               for (int j = WEP_FIRST; j <= WEP_LAST; ++j)
                {
                        WEP_ACTION(j, WR_RESETPLAYER);
 
                        // all weapons must be fully loaded when we spawn
                        entity e = get_weaponinfo(j);
-                       if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
+                       if (e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
                                self.(weapon_load[j]) = e.reloading_ammo;
                }
 
@@ -625,8 +644,7 @@ void PutClientInServer (void)
 
                Unfreeze(self);
 
-               spawn_spot = spot;
-               MUTATOR_CALLHOOK(PlayerSpawn);
+               MUTATOR_CALLHOOK(PlayerSpawn, spot);
 
                if(autocvar_spawn_debug)
                {
@@ -655,7 +673,7 @@ void PutClientInServer (void)
 .float ebouncefactor, ebouncestop; // electro's values
 // TODO do we need all these fields, or should we stop autodetecting runtime
 // changes and just have a console command to update this?
-float ClientInit_SendEntity(entity to, float sf)
+float ClientInit_SendEntity(entity to, int sf)
 {
        WriteByte(MSG_ENTITY, ENT_CLIENT_INIT);
        WriteByte(MSG_ENTITY, g_nexball_meter_period * 32);
@@ -1086,6 +1104,7 @@ void ClientConnect (void)
        PlayerScore_Attach(self);
        ClientData_Attach();
        accuracy_init(self);
+       Inventory_new(self);
 
        bot_clientconnect();
 
@@ -1260,7 +1279,7 @@ void ClientConnect (void)
                self = oldself;
        }
 
-       MUTATOR_CALLHOOK(ClientConnect);
+       MUTATOR_CALLHOOK(ClientConnect, self);
 }
 /*
 =============
@@ -1284,7 +1303,7 @@ void ClientDisconnect (void)
 
        PlayerStats_GameReport_FinalizePlayer(self);
 
-       if(IS_PLAYER(self)) { pointparticles(particleeffectnum("spawn_event_neutral"), self.origin, '0 0 0', 1); }
+       if(IS_PLAYER(self)) { Send_Effect("spawn_event_neutral", self.origin, '0 0 0', 1); }
 
        CheatShutdownClient();
 
@@ -1328,6 +1347,7 @@ void ClientDisconnect (void)
        bot_relinkplayerlist();
 
        accuracy_free(self);
+       Inventory_delete(self);
        ClientData_Detach();
        PlayerScore_Detach(self);
 
@@ -1420,7 +1440,7 @@ void respawn(void)
                self.velocity = '0 0 1' * autocvar_g_respawn_ghosts_speed;
                self.avelocity = randomvec() * autocvar_g_respawn_ghosts_speed * 3 - randomvec() * autocvar_g_respawn_ghosts_speed * 3;
                self.effects |= CSQCMODEL_EF_RESPAWNGHOST;
-               pointparticles(particleeffectnum("respawn_ghost"), self.origin, '0 0 0', 1);
+               Send_Effect("respawn_ghost", self.origin, '0 0 0', 1);
                if(autocvar_g_respawn_ghosts_maxtime)
                        SUB_SetFade (self, time + autocvar_g_respawn_ghosts_maxtime / 2 + random () * (autocvar_g_respawn_ghosts_maxtime - autocvar_g_respawn_ghosts_maxtime / 2), 1.5);
        }
@@ -1442,7 +1462,7 @@ void play_countdown(float finished, string samp)
 void player_powerups (void)
 {
        // add a way to see what the items were BEFORE all of these checks for the mutator hook
-       olditems = self.items;
+       int items_prev = self.items;
 
        if((self.items & IT_USING_JETPACK) && !self.deadflag && !gameover)
                self.modelflags |= MF_ROCKET;
@@ -1554,7 +1574,7 @@ void player_powerups (void)
        if (time < self.spawnshieldtime)
                self.effects = self.effects | (EF_ADDITIVE | EF_FULLBRIGHT);
 
-       MUTATOR_CALLHOOK(PlayerPowerups);
+       MUTATOR_CALLHOOK(PlayerPowerups, self, items_prev);
 }
 
 float CalcRegen(float current, float stable, float regenfactor, float regenframetime)
@@ -1606,11 +1626,7 @@ void player_regen (void)
 {
        float max_mod, regen_mod, rot_mod, limit_mod;
        max_mod = regen_mod = rot_mod = limit_mod = 1;
-       regen_mod_max = max_mod;
-       regen_mod_regen = regen_mod;
-       regen_mod_rot = rot_mod;
-       regen_mod_limit = limit_mod;
-       if(!MUTATOR_CALLHOOK(PlayerRegen))
+       if(!MUTATOR_CALLHOOK(PlayerRegen, max_mod, regen_mod, rot_mod, limit_mod))
        if(!self.frozen)
        {
                float minh, mina, maxh, maxa, limith, limita;
@@ -1666,10 +1682,10 @@ void SetZoomState(float z)
 void GetPressedKeys(void) {
        MUTATOR_CALLHOOK(GetPressedKeys);
        #define X(var,bit,flag) (flag ? var |= bit : var &= ~bit)
-       X(self.pressedkeys, KEY_FORWARD,        PHYS_INPUT_MOVEVALUES(self)_x > 0);
-       X(self.pressedkeys, KEY_BACKWARD,       PHYS_INPUT_MOVEVALUES(self)_x < 0);
-       X(self.pressedkeys, KEY_RIGHT,          PHYS_INPUT_MOVEVALUES(self)_y > 0);
-       X(self.pressedkeys, KEY_LEFT,           PHYS_INPUT_MOVEVALUES(self)_y < 0);
+       X(self.pressedkeys, KEY_FORWARD,        self.movement_x > 0);
+       X(self.pressedkeys, KEY_BACKWARD,       self.movement_x < 0);
+       X(self.pressedkeys, KEY_RIGHT,          self.movement_y > 0);
+       X(self.pressedkeys, KEY_LEFT,           self.movement_y < 0);
 
        X(self.pressedkeys, KEY_JUMP,           PHYS_INPUT_BUTTON_JUMP(self));
        X(self.pressedkeys, KEY_CROUCH,         PHYS_INPUT_BUTTON_CROUCH(self));
@@ -1685,8 +1701,7 @@ spectate mode routines
 */
 
 void SpectateCopy(entity spectatee) {
-       other = spectatee;
-       MUTATOR_CALLHOOK(SpectateCopy);
+       MUTATOR_CALLHOOK(SpectateCopy, spectatee, self);
        self.armortype = spectatee.armortype;
        self.armorvalue = spectatee.armorvalue;
        self.ammo_cells = spectatee.ammo_cells;
@@ -2210,6 +2225,8 @@ void PlayerPreThink (void)
        self.stat_allow_oldvortexbeam = autocvar_g_allow_oldvortexbeam;
        self.stat_leadlimit = autocvar_leadlimit;
 
+       self.weaponsinmap = weaponsInMap;
+
        if(frametime)
        {
                // physics frames: update anticheat stuff
@@ -2448,8 +2465,8 @@ void PlayerPreThink (void)
                        if (!self.crouch)
                        {
                                self.crouch = true;
-                               self.view_ofs = PL_CROUCH_VIEW_OFS;
-                               setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX);
+                               self.view_ofs = self.stat_pl_crouch_view_ofs;
+                               setsize (self, self.stat_pl_crouch_min, self.stat_pl_crouch_max);
                                // setanim(self, self.anim_duck, false, true, true); // this anim is BROKEN anyway
                        }
                }
@@ -2457,12 +2474,12 @@ void PlayerPreThink (void)
                {
                        if (self.crouch)
                        {
-                               tracebox(self.origin, PL_MIN, PL_MAX, self.origin, false, self);
+                               tracebox(self.origin, self.stat_pl_min, self.stat_pl_max, self.origin, false, self);
                                if (!trace_startsolid)
                                {
                                        self.crouch = false;
-                                       self.view_ofs = PL_VIEW_OFS;
-                                       setsize (self, PL_MIN, PL_MAX);
+                                       self.view_ofs = self.stat_pl_view_ofs;
+                                       setsize (self, self.stat_pl_min, self.stat_pl_max);
                                }
                        }
                }