]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
Merge branch 'master' into Mario/vehicles
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index 0e9f0dc919c43be356b6c44c1fda0767ed890f7a..ec9fd19b0e4130994a4f8f5e4892b410a873c32c 100644 (file)
@@ -1,48 +1,36 @@
-#if defined(CSQC)
-#elif defined(MENUQC)
-#elif defined(SVQC)
-       #include "../dpdefs/progsdefs.qh"
-    #include "../dpdefs/dpextensions.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/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)
        {
@@ -209,7 +197,7 @@ void PutObserverInServer (void)
        }
 
        if(self.vehicle)
-               vehicles_exit(VHEF_RELESE);
+               vehicles_exit(VHEF_RELEASE);
 
        WaypointSprite_PlayerDead();
 
@@ -437,9 +425,6 @@ void PutClientInServer (void)
 
                RemoveGrapplingHook(self); // Wazat's Grappling Hook
 
-               if(self.vehicle)
-                       vehicles_exit(VHEF_RELESE);
-
                self.classname = "player";
                self.wasplayer = true;
                self.iscreature = true;
@@ -587,7 +572,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;
@@ -615,8 +600,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;
                }
@@ -809,7 +793,7 @@ void ClientKill_Now()
 {
        if(self.vehicle)
        {
-           vehicles_exit(VHEF_RELESE);
+           vehicles_exit(VHEF_RELEASE);
            if(!self.killindicator_teamchange)
            {
             self.vehicle_health = -1;
@@ -1013,7 +997,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;
 
@@ -1029,6 +1013,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
@@ -1241,6 +1246,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);
 }
 /*
@@ -1255,7 +1267,7 @@ void ReadyCount();
 void ClientDisconnect (void)
 {
        if(self.vehicle)
-           vehicles_exit(VHEF_RELESE);
+           vehicles_exit(VHEF_RELEASE);
 
        if (!IS_CLIENT(self))
        {
@@ -1619,7 +1631,11 @@ void player_regen (void)
        // if player rotted to death...  die!
        // check this outside above checks, as player may still be able to rot to death
        if(self.health < 1)
+       {
+               if(self.vehicle)
+                       vehicles_exit(VHEF_RELEASE);
                self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
+       }
 
        if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
        {
@@ -2168,6 +2184,7 @@ void SpectatorThink()
        self.flags |= FL_CLIENT | FL_NOTARGET;
 }
 
+void vehicles_enter (entity pl, entity veh);
 void PlayerUseKey()
 {
        if (!IS_PLAYER(self))
@@ -2175,8 +2192,41 @@ void PlayerUseKey()
 
        if(self.vehicle)
        {
-        vehicles_exit(VHEF_NORMAL);
-        return;
+               if(!gameover)
+               {
+                       vehicles_exit(VHEF_NORMAL);
+                       return;
+               }
+       }
+       else if(autocvar_g_vehicles_enter)
+       {
+               if(!self.frozen)
+               if(self.deadflag == DEAD_NO)
+               if(!gameover)
+               {
+                       entity head, closest_target = world;
+                       head = WarpZone_FindRadius(self.origin, autocvar_g_vehicles_enter_radius, TRUE);
+
+                       while(head) // find the closest acceptable target to enter
+                       {
+                               if(head.vehicle_flags & VHF_ISVEHICLE)
+                               if(head.deadflag == DEAD_NO)
+                               if(!head.owner || ((head.vehicle_flags & VHF_MULTISLOT) && SAME_TEAM(head.owner, self)))
+                               if(head.takedamage != DAMAGE_NO)
+                               {
+                                       if(closest_target)
+                                       {
+                                               if(vlen(self.origin - head.origin) < vlen(self.origin - closest_target.origin))
+                                               { closest_target = head; }
+                                       }
+                                       else { closest_target = head; }
+                               }
+
+                               head = head.chain;
+                       }
+
+                       if(closest_target) { vehicles_enter(self, closest_target); return; }
+               }
        }
 
        // a use key was pressed; call handlers
@@ -2219,7 +2269,8 @@ Called every frame for each client before the physics are run
 */
 .float usekeypressed;
 void() nexball_setstatus;
-.float items_added;
+.float last_vehiclecheck;
+.int items_added;
 void PlayerPreThink (void)
 {
        WarpZone_PlayerPhysics_FixVAngle();
@@ -2319,11 +2370,11 @@ 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)
-                               vehicles_exit(VHEF_RELESE);
+                               vehicles_exit(VHEF_RELEASE);
                        self.event_damage(self, self.frozen_by, 1, DEATH_NADE_ICE_FREEZE, self.origin, '0 0 0');
                }
                else if ( self.revive_progress <= 0 )
@@ -2332,6 +2383,30 @@ void PlayerPreThink (void)
 
        MUTATOR_CALLHOOK(PlayerPreThink);
 
+       if(autocvar_g_vehicles_enter)
+       if(time > self.last_vehiclecheck)
+       if(IS_PLAYER(self))
+       if(!gameover)
+       if(!self.frozen)
+       if(!self.vehicle)
+       if(self.deadflag == DEAD_NO)
+       {
+               entity veh;
+               for(veh = world; (veh = findflags(veh, vehicle_flags, VHF_ISVEHICLE)); )
+               if(vlen(veh.origin - self.origin) < autocvar_g_vehicles_enter_radius)
+               if(veh.deadflag == DEAD_NO)
+               if(veh.takedamage != DAMAGE_NO)
+               if((veh.vehicle_flags & VHF_MULTISLOT) && SAME_TEAM(veh.owner, self))
+                       Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_VEHICLE_ENTER_GUNNER);
+               else if(!veh.owner)
+               if(!veh.team || SAME_TEAM(self, veh))
+                       Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_VEHICLE_ENTER);
+               else if(autocvar_g_vehicles_steal)
+                       Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_VEHICLE_ENTER_STEAL);
+
+               self.last_vehiclecheck = time + 1;
+       }
+
        if(!self.cvar_cl_newusekeysupported) // FIXME remove this - it was a stupid idea to begin with, we can JUST use the button
        {
                if(self.BUTTON_USE && !self.usekeypressed)
@@ -2458,7 +2533,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;
 
@@ -2507,7 +2582,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);