X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcl_client.qc;h=a1047ea9d07595dae83fcb3fd49953b5b24062c7;hb=7ff8197dd5b6a83f66976c09e4f0a7bf75c32825;hp=77d00be41913a82f817ef5036178dbb0aceaa254;hpb=36810e8ddba12c1959bc07e4c80630454c6f85a8;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 77d00be41..a1047ea9d 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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"); @@ -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; @@ -1107,6 +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_minelayer_limit); // minelayer max mines WriteCoord(MSG_ENTITY, autocvar_g_trueaim_minrange); return TRUE; } @@ -2345,6 +2359,7 @@ void SpectateCopy(entity spectatee) { 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; @@ -2352,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; @@ -2437,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"; @@ -2474,25 +2492,30 @@ void LeaveSpectatorMode() * 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; } /** @@ -3093,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));