]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
Merge branch 'master' into Melanosuchus/minigames
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index e5f9a77a7993ead4d72a38d67d0d3f4c392d5ac7..e9c9e8615f9fa5f50ba73e4dd97c155fb8a6493f 100644 (file)
@@ -1,49 +1,38 @@
-#if defined(CSQC)
-#elif defined(MENUQC)
-#elif defined(SVQC)
-       #include "../dpdefs/progsdefs.qh"
-    #include "../dpdefs/dpextensions.qh"
-    #include "sys-post.qh"
-    #include "../warpzonelib/server.qh"
-    #include "../common/constants.qh"
-    #include "../common/teams.qh"
-    #include "../common/util.qh"
-    #include "../common/net_notice.qh"
-    #include "../common/monsters/monsters.qh"
-    #include "../common/monsters/sv_monsters.qh"
-    #include "../common/weapons/weapons.qh"
-    #include "t_items.qh"
-    #include "autocvars.qh"
-    #include "constants.qh"
-    #include "defs.qh"
-    #include "../common/notifications.qh"
-    #include "../common/deathtypes.qh"
-    #include "mutators/mutators_include.qh"
-    #include "vehicles/vehicles_def.qh"
-    #include "campaign.qh"
-    #include "../common/mapinfo.qh"
-    #include "command/common.qh"
-    #include "command/vote.qh"
-    #include "../csqcmodellib/sv_model.qh"
-    #include "anticheat.qh"
-    #include "cheats.qh"
-    #include "../common/playerstats.qh"
-    #include "portals.qh"
-    #include "g_hook.qh"
-    #include "scores.qh"
-    #include "spawnpoints.qh"
-    #include "ipban.qh"
-    #include "race.qh"
-    #include "antilag.qh"
-    #include "playerdemo.qh"
-#endif
+#include "waypointsprites.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 "secret.qh"
+
+#include "bot/bot.qh"
+#include "bot/navigation.qh"
+
+#include "weapons/hitplot.qh"
+#include "weapons/weaponsystem.qh"
+
+#include "../common/net_notice.qh"
+
+#include "../common/minigames/sv_minigames.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);
        WriteByte(MSG_BROADCAST, TE_CSQC_TEAMNAGGER);
 }
 
-float ClientData_Send(entity to, float sf)
+float ClientData_Send(entity to, int sf)
 {
        if(to != self.owner)
        {
@@ -314,7 +303,7 @@ void FixPlayermodel()
        defaultskin = 0;
        chmdl = false;
 
-       if(autocvar_sv_defaultcharacter == 1)
+       if(autocvar_sv_defaultcharacter)
        {
                if(teamplay)
                {
@@ -588,7 +577,7 @@ void PutClientInServer (void)
 
                self.bot_attack = true;
                self.monster_attack = true;
-               
+
                self.spider_slowness = 0;
 
                self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = 0;
@@ -616,8 +605,7 @@ void PutClientInServer (void)
                        WEP_ACTION(j, WR_RESETPLAYER);
 
                        // all weapons must be fully loaded when we spawn
-                       entity e;
-                       e = get_weaponinfo(j);
+                       entity e = get_weaponinfo(j);
                        if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
                                self.(weapon_load[j]) = e.reloading_ammo;
                }
@@ -665,7 +653,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);
@@ -1014,7 +1002,7 @@ float PlayerInIDList(entity p, string idlist)
        float n, i;
        string s;
 
-       // NOTE: we do NOT check crypto_keyfp here, an unsigned ID is fine too for this
+       // NOTE: we do NOT check crypto_idfp_signed here, an unsigned ID is fine too for this
        if (!p.crypto_idfp)
                return 0;
 
@@ -1030,6 +1018,27 @@ float PlayerInIDList(entity p, string idlist)
        return 0;
 }
 
+#ifdef DP_EXT_PRECONNECT
+/*
+=============
+ClientPreConnect
+
+Called once (not at each match start) when a client begins a connection to the server
+=============
+*/
+void ClientPreConnect (void)
+{
+       if(autocvar_sv_eventlog)
+       {
+               GameLogEcho(sprintf(":connect:%d:%d:%s",
+                       self.playerid,
+                       num_for_edict(self),
+                       ((IS_REAL_CLIENT(self)) ? self.netaddress : "bot")
+               ));
+       }
+}
+#endif
+
 /*
 =============
 ClientConnect
@@ -1242,6 +1251,13 @@ void ClientConnect (void)
        if(IS_REAL_CLIENT(self))
                sv_notice_join();
 
+       for (entity e = world; (e = findfloat(e, init_for_player_needed, 1)); ) {
+               entity oldself = self;
+               self = e;
+               e.init_for_player(oldself);
+               self = oldself;
+       }
+
        MUTATOR_CALLHOOK(ClientConnect);
 }
 /*
@@ -1266,6 +1282,9 @@ void ClientDisconnect (void)
 
        PlayerStats_GameReport_FinalizePlayer(self);
 
+       if ( self.active_minigame )
+               part_minigame(self);
+
        if(IS_PLAYER(self)) { pointparticles(particleeffectnum("spawn_event_neutral"), self.origin, '0 0 0', 1); }
 
        CheatShutdownClient();
@@ -1343,14 +1362,20 @@ void ChatBubbleThink()
                remove(self);
                return;
        }
-       if ((self.owner.BUTTON_CHAT && !self.owner.deadflag)
-#ifdef TETRIS
-               || self.owner.tetris_on
-#endif
-       )
-               self.model = self.mdl;
-       else
-               self.model = "";
+       
+       self.mdl = "";
+       
+       if ( !self.owner.deadflag && IS_PLAYER(self.owner) )
+       {
+               if ( self.owner.active_minigame )
+                       self.mdl = "models/sprites/minigame_busy.iqm";
+               else if ( self.owner.BUTTON_CHAT )
+                       self.mdl = "models/misc/chatbubble.spr";
+       }
+       
+       if ( self.model != self.mdl )
+               setmodel(self, self.mdl);
+
 }
 
 void UpdateChatBubble()
@@ -1367,10 +1392,10 @@ void UpdateChatBubble()
                self.chatbubbleentity.nextthink = time;
                setmodel(self.chatbubbleentity, "models/misc/chatbubble.spr"); // precision set below
                //setorigin(self.chatbubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1');
-               setorigin(self.chatbubbleentity, '0 0 15' + self.maxs.z * '0 0 1');
+               setorigin(self.chatbubbleentity, '0 0 15' + self.maxs_z * '0 0 1');
                setattachment(self.chatbubbleentity, self, "");  // sticks to moving player better, also conserves bandwidth
                self.chatbubbleentity.mdl = self.chatbubbleentity.model;
-               self.chatbubbleentity.model = "";
+               //self.chatbubbleentity.model = "";
                self.chatbubbleentity.effects = EF_LOWPRECISION;
        }
 }
@@ -2092,6 +2117,11 @@ void PrintWelcomeMessage()
 
 void ObserverThink()
 {
+       if ( self.impulse )
+       {
+               MinigameImpulse(self.impulse);
+               self.impulse = 0;
+       }
        float prefered_movetype;
        if (self.flags & FL_JUMPRELEASED) {
                if (self.BUTTON_JUMP && !self.version_mismatch) {
@@ -2122,6 +2152,11 @@ void ObserverThink()
 
 void SpectatorThink()
 {
+       if ( self.impulse )
+       {
+               MinigameImpulse(self.impulse);
+               self.impulse = 0;
+       }
        if (self.flags & FL_JUMPRELEASED) {
                if (self.BUTTON_JUMP && !self.version_mismatch) {
                        self.flags &= ~FL_JUMPRELEASED;
@@ -2220,7 +2255,7 @@ Called every frame for each client before the physics are run
 */
 .float usekeypressed;
 void() nexball_setstatus;
-.float items_added;
+.int items_added;
 void PlayerPreThink (void)
 {
        WarpZone_PlayerPhysics_FixVAngle();
@@ -2302,11 +2337,6 @@ void PlayerPreThink (void)
                self.max_armorvalue = 0;
        }
 
-#ifdef TETRIS
-       if (TetrisPreFrame())
-               return;
-#endif
-
        if(self.frozen == 2)
        {
                self.revive_progress = bound(0, self.revive_progress + frametime * self.revive_speed, 1);
@@ -2320,7 +2350,7 @@ void PlayerPreThink (void)
        {
                self.revive_progress = bound(0, self.revive_progress - frametime * self.revive_speed, 1);
                self.health = max(0, autocvar_g_nades_ice_health + (start_health-autocvar_g_nades_ice_health) * self.revive_progress );
-               
+
                if(self.health < 1)
                {
                        if(self.vehicle)
@@ -2459,7 +2489,7 @@ void PlayerPreThink (void)
                        do_crouch = 0;
 
                // WEAPONTODO: THIS SHIT NEEDS TO GO EVENTUALLY
-               // It cannot be predicted by the engine! 
+               // It cannot be predicted by the engine!
                if((self.weapon == WEP_SHOCKWAVE || self.weapon == WEP_SHOTGUN) && self.weaponentity.wframe == WFRAME_FIRE2 && time < self.weapon_nextthink)
                        do_crouch = 0;
 
@@ -2508,7 +2538,7 @@ void PlayerPreThink (void)
 
                player_regen();
 
-               // WEAPONTODO: Add a weapon request for this 
+               // WEAPONTODO: Add a weapon request for this
                // rot vortex charge to the charge limit
                if(WEP_CVAR(vortex, charge_rot_rate) && self.vortex_charge > WEP_CVAR(vortex, charge_limit) && self.vortex_charge_rottime < time)
                        self.vortex_charge = bound(WEP_CVAR(vortex, charge_limit), self.vortex_charge - WEP_CVAR(vortex, charge_rot_rate) * frametime / W_TICSPERFRAME, 1);
@@ -2628,13 +2658,6 @@ void PlayerPostThink (void)
                }
        }
 
-#ifdef TETRIS
-       if(self.impulse == 100)
-               ImpulseCommands();
-       if (!TetrisPostFrame())
-       {
-#endif
-
        CheatFrame();
 
        //CheckPlayerJump();
@@ -2649,10 +2672,6 @@ void PlayerPostThink (void)
                GetPressedKeys();
        }
 
-#ifdef TETRIS
-       }
-#endif
-
        /*
        float i;
        for(i = 0; i < 1000; ++i)