]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote branch 'origin/master' into samual/flyingspectators
authorSamual <samual@xonotic.org>
Wed, 20 Apr 2011 02:53:21 +0000 (22:53 -0400)
committerSamual <samual@xonotic.org>
Wed, 20 Apr 2011 02:53:21 +0000 (22:53 -0400)
1  2 
qcsrc/server/cl_client.qc
qcsrc/server/cl_physics.qc

index 1b259facad870d0fa3159f35a861febd96864501,a1047ea9d07595dae83fcb3fd49953b5b24062c7..cb92b0711fa7fd878243677453d7adf380153b64
@@@ -132,9 -132,9 +132,9 @@@ vector Spawn_Score(entity spot, entity 
        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 +269,7 @@@ entity Spawn_FilterOutBadSpots(entity f
                                        spotlist = spot;
  
                                /*
-                               if(teamcheck)
+                               if(teamcheck >= 0)
                                if(spot.team != teamcheck)
                                        error("invalid spawn added");
  
  
        /*
                entity e;
-               if(teamcheck)
+               if(teamcheck >= 0)
                        for(e = spotlist; e; e = e.chain)
                        {
                                print("seen ", etos(e), "\n");
@@@ -325,10 -325,15 +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");
                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 +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;
        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 +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;
                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 +1120,7 @@@ float ClientInit_SendEntity(entity to, 
        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,11 -2352,14 +2352,14 @@@ 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;
        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.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;
@@@ -2438,7 -2455,7 +2455,7 @@@ void ShowRespawnCountdown(
  
  void LeaveSpectatorMode()
  {
-       if(isJoinAllowed()) {
+       if(nJoinAllowed(1)) {
                if(!teams_matter || autocvar_g_campaign || autocvar_g_balance_teams || (self.wasplayer && autocvar_g_changeteam_banned) || self.team_forced > 0) {
                        self.classname = "player";
  
   * Determines whether the player is allowed to join. This depends on cvar
   * g_maxplayers, if it isn't used this function always return TRUE, otherwise
   * it checks whether the number of currently playing players exceeds g_maxplayers.
-  * @return bool TRUE if the player is allowed to join, false otherwise
+  * @return int number of free slots for players, 0 if none
   */
- float isJoinAllowed() {
+ float nJoinAllowed(float includeMe) {
        if(self.team_forced < 0)
                return FALSE; // forced spectators can never join
  
+       // TODO simplify this
+       local entity e;
+       local float totalClients;
+       FOR_EACH_CLIENT(e)
+               totalClients += 1;
        if (!autocvar_g_maxplayers)
-               return TRUE;
+               return maxclients - totalClients + includeMe;
  
-       local entity e;
        local float currentlyPlaying;
-       FOR_EACH_REALPLAYER(e) {
-               if(e.classname == "player")
-                       currentlyPlaying += 1;
-       }
+       FOR_EACH_REALPLAYER(e)
+               currentlyPlaying += 1;
        if(currentlyPlaying < autocvar_g_maxplayers)
-               return TRUE;
+               return min(maxclients - totalClients + includeMe, autocvar_g_maxplayers - currentlyPlaying);
  
-       return FALSE;
+       return 0;
  }
  
  /**
@@@ -2937,6 -2959,10 +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)
@@@ -3090,7 -3116,7 +3116,7 @@@ void PlayerPostThink (void
  
        playerdemo_write();
  
-       if((g_cts || g_race) && self.cvar_cl_allow_uid2name == 1)
+       if((g_cts || g_race) && self.cvar_cl_allow_uidtracking == 1 && self.cvar_cl_allow_uid2name == 1)
        {
                if(!self.stored_netname)
                        self.stored_netname = strzone(uid2name(self.crypto_idfp));
index 084a383c5b917398a0fab06f3beccd804f1f2077,9662e0ae61035dbe402bfec093c71f0753a99644..f0617740e654210a45af5754dc526b5aaef48625
@@@ -61,7 -61,7 +61,7 @@@ void PlayerJump (void
        if(!doublejump && self.multijump_ready && self.multijump_count < autocvar_g_multijump && self.velocity_z > autocvar_g_multijump_speed)
        {
                // doublejump = FALSE; // checked above in the if
-               if (autocvar_g_multijump > 0)
+               if (autocvar_g_multijump)
                {
                        if (autocvar_g_multijump_add == 0) // in this case we make the z velocity == jumpvelocity
                        {
@@@ -93,7 -93,8 +93,8 @@@
                                        self.velocity_y = wishdir_y * curspeed;
                                        // keep velocity_z unchanged!
                                }
-                               self.multijump_count += 1;
+                               if (autocvar_g_multijump > 0)
+                                       self.multijump_count += 1;
                        }
                }
                self.multijump_ready = FALSE; // require releasing and pressing the jump button again for the next jump
@@@ -891,7 -892,6 +892,7 @@@ void SV_PlayerPhysics(
        }
  
        if(self.flags & FL_ONGROUND)
 +      if(self.classname == "player") // no fall sounds for observers thank you very much
        if(self.wasFlying)
        {
                self.wasFlying = 0;