]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
Merge remote branch 'origin/master' into samual/flyingspectators
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index acf399f917b2372f5b2d0b8a3b0a101dc4eafedd..cb92b0711fa7fd878243677453d7adf380153b64 100644 (file)
@@ -132,9 +132,9 @@ vector Spawn_Score(entity spot, entity playerlist, float teamcheck, float anypoi
        prio = 0;
 
        // filter out spots for the wrong team
-       if(teamcheck)
-       if(spot.team != teamcheck)
-               return '-1 0 0';
+       if(teamcheck >= 0)
+               if(spot.team != teamcheck)
+                       return '-1 0 0';
 
        if(race_spawns)
                if(spot.target == "")
@@ -269,7 +269,7 @@ entity Spawn_FilterOutBadSpots(entity firstspot, entity playerlist, float mindis
                                        spotlist = spot;
 
                                /*
-                               if(teamcheck)
+                               if(teamcheck >= 0)
                                if(spot.team != teamcheck)
                                        error("invalid spawn added");
 
@@ -283,7 +283,7 @@ entity Spawn_FilterOutBadSpots(entity firstspot, entity playerlist, float mindis
 
        /*
                entity e;
-               if(teamcheck)
+               if(teamcheck >= 0)
                        for(e = spotlist; e; e = e.chain)
                        {
                                print("seen ", etos(e), "\n");
@@ -325,10 +325,15 @@ entity SelectSpawnPoint (float anypoint)
        if (spot)
                return spot;
 
-       teamcheck = 0;
-
-       if(!anypoint && have_team_spawns > 0)
-               teamcheck = self.team;
+       if(anypoint)
+               teamcheck = -1;
+       else if(have_team_spawns > 0)
+               teamcheck = self.team; // MUST be team
+       else if(have_team_spawns == 0 && have_noteam_spawns)
+               teamcheck = 0; // MUST be noteam
+       else
+               teamcheck = -1;
+               // if we get here, we either require team spawns but have none, or we require non-team spawns and have none; use any spawn then
 
        // get the list of players
        playerlist = findchain(classname, "player");
@@ -368,7 +373,7 @@ entity SelectSpawnPoint (float anypoint)
                print("spot mindistance: ", vtos(spot.spawnpoint_score), "\n");
 
                entity e;
-               if(teamcheck)
+               if(teamcheck >= 0)
                        for(e = firstspot; e; e = e.chain)
                                if(e.team != teamcheck)
                                        error("invalid spawn found");
@@ -638,8 +643,8 @@ void PutObserverInServer (void)
        self.iscreature = FALSE;
        self.health = -666;
        self.takedamage = DAMAGE_NO;
-       self.solid = SOLID_NOT;
-       self.movetype = MOVETYPE_NOCLIP;
+       self.solid = SOLID_TRIGGER; // FIXME: SOLID_TRIGGER doesn't work for doors, and SOLID_NOT doesn't work for teleporters... can we do what warpzones do to fix this?
+       self.movetype = MOVETYPE_FLY;
        self.flags = FL_CLIENT | FL_NOTARGET;
        self.armorvalue = 666;
        self.effects = 0;
@@ -668,9 +673,9 @@ void PutObserverInServer (void)
        self.fixangle = TRUE;
        self.crouch = FALSE;
 
-       self.view_ofs = PL_VIEW_OFS;
+       self.view_ofs = '0 0 0'; // so that you can't go inside walls with MOVETYPE_FLY, previously "PL_VIEW_OFS" - for some reason this is diff from normal players
        setorigin (self, spot.origin);
-       setsize (self, '0 0 0', '0 0 0');
+       setsize (self, '-16 -16 -24', '16 16 24'); // so that you can't go inside walls with MOVETYPE_FLY
        self.prevorigin = self.origin;
        self.items = 0;
        self.weapons = 0;
@@ -1050,8 +1055,16 @@ void PutClientInServer (void)
 
                // reset fields the weapons may use
                for (j = WEP_FIRST; j <= WEP_LAST; ++j)
+               {
                        weapon_action(j, WR_RESETPLAYER);
 
+                       // all weapons must be fully loaded when we spawn
+                       entity e;
+                       e = get_weaponinfo(j);
+                       if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
+                               self.weapon_load[j] = cvar(strcat("g_balance_", e.netname, "_reload_ammo"));
+               }
+
                oldself = self;
                self = spot;
                        activator = oldself;
@@ -1065,8 +1078,6 @@ void PutClientInServer (void)
                self.cnt = self.switchweapon;
                self.weapon = 0;
 
-        self.wish_reload = 0;
-
                if(!self.alivetime)
                        self.alivetime = time;
        } else if(self.classname == "observer" || (g_ca && !allowed_to_spawn)) {
@@ -1109,7 +1120,7 @@ float ClientInit_SendEntity(entity to, float sf)
        WriteByte(MSG_ENTITY, autocvar_g_balance_nex_secondary); // client has to know if it should zoom or not
        WriteByte(MSG_ENTITY, autocvar_g_balance_sniperrifle_secondary); // client has to know if it should zoom or not
        WriteByte(MSG_ENTITY, serverflags); // client has to know if it should zoom or not
-       WriteByte(MSG_ENTITY, autocvar_g_balance_sniperrifle_magazinecapacity); // rifle max bullets
+       WriteByte(MSG_ENTITY, autocvar_g_balance_minelayer_limit); // minelayer max mines
        WriteCoord(MSG_ENTITY, autocvar_g_trueaim_minrange);
        return TRUE;
 }
@@ -2341,6 +2352,8 @@ void SpectateCopy(entity spectatee) {
        self.ammo_nails = spectatee.ammo_nails;
        self.ammo_rockets = spectatee.ammo_rockets;
        self.ammo_fuel = spectatee.ammo_fuel;
+       self.clip_load = spectatee.clip_load;
+       self.clip_size = spectatee.clip_size;
        self.effects = spectatee.effects & EFMASK_CHEAP; // eat performance
        self.health = spectatee.health;
        self.impulse = 0;
@@ -2354,6 +2367,9 @@ void SpectateCopy(entity spectatee) {
        self.weapons = spectatee.weapons;
        self.switchweapon = spectatee.switchweapon;
        self.weapon = spectatee.weapon;
+       self.nex_charge = spectatee.nex_charge;
+       self.nex_chargepool_ammo = spectatee.nex_chargepool_ammo;
+       self.minelayer_mines = spectatee.minelayer_mines;
        self.punchangle = spectatee.punchangle;
        self.view_ofs = spectatee.view_ofs;
        self.v_angle = spectatee.v_angle;
@@ -2365,6 +2381,7 @@ void SpectateCopy(entity spectatee) {
        self.fixangle = TRUE;
        setorigin(self, spectatee.origin);
        setsize(self, spectatee.mins, spectatee.maxs);
+       SetZoomState(spectatee.zoomstate);
 
        anticheat_spectatecopy(spectatee);
 }
@@ -2401,8 +2418,6 @@ float SpectateNext() {
                self.movetype = MOVETYPE_NONE;
                accuracy_resend(self);
 
-               SetZoomState(spectatee.zoomstate);
-
                if(!SpectateUpdate())
                        PutObserverInServer();
 
@@ -2944,6 +2959,10 @@ void PlayerPreThink (void)
        }
 
        target_voicescript_next(self);
+
+       // if a player goes unarmed after holding a loaded weapon, empty his clip size and remove the crosshair ammo ring
+       if(!self.weapon)
+               self.clip_load = self.clip_size = 0;
 }
 
 float isInvisibleString(string s)