X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fclient.qc;h=d706f8107313d65e8951fb674b9799186bd18fc7;hp=d374876d0456441bc59fdf69fe683a643bb8d42a;hb=bc50c2d7ca3e0a44ed1712400ef8e170e6df8210;hpb=52cdd440f6cfdc9544099ac68455e5361ace00d2 diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index d374876d0..d706f8107 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -152,10 +152,15 @@ void ClientData_Detach(entity this) void ClientData_Touch(entity e) { - CS(e).clientdata.SendFlags = 1; + entity cd = CS(e).clientdata; + if (cd) { cd.SendFlags = 1; } // make it spectatable - FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != e && IS_SPEC(it) && it.enemy == e, { CS(it).clientdata.SendFlags = 1; }); + FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != e && IS_SPEC(it) && it.enemy == e, + { + entity cd = CS(it).clientdata; + if (cd) { cd.SendFlags = 1; } + }); } void SetSpectatee(entity this, entity spectatee); @@ -1219,16 +1224,7 @@ void ClientConnect(entity this) JoinBestTeam(this, false); // if the team number is valid, keep it this.playerid = playerid_save; - if (autocvar_sv_spectate || autocvar_g_campaign || this.team_forced < 0) { - TRANSMUTE(Observer, this); - } else { - if (!teamplay || autocvar_g_balance_teams) { - TRANSMUTE(Player, this); - campaign_bots_may_start = true; - } else { - TRANSMUTE(Observer, this); // do it anyway - } - } + TRANSMUTE(Observer, this); PlayerStats_GameReport_AddEvent(sprintf("kills-%d", this.playerid)); @@ -2139,9 +2135,11 @@ void PrintWelcomeMessage(entity this) } } +const int MIN_SPEC_TIME = 1; bool joinAllowed(entity this) { if (CS(this).version_mismatch) return false; + if (time < CS(this).jointime + MIN_SPEC_TIME) return false; if (!nJoinAllowed(this, this)) return false; if (teamplay && lockteams) return false; if (ShowTeamSelection(this)) return false; @@ -2572,6 +2570,8 @@ void PlayerPreThink (entity this) PrintWelcomeMessage(this); if (IS_PLAYER(this)) { + if (IS_REAL_CLIENT(this) && time < CS(this).jointime + MIN_SPEC_TIME) + error("Client can't be spawned as player on connection!"); if(!PlayerThink(this)) return; } @@ -2580,6 +2580,20 @@ void PlayerPreThink (entity this) IntermissionThink(this); return; } + else if (IS_REAL_CLIENT(this) && !CS(this).autojoin_checked && time >= CS(this).jointime + MIN_SPEC_TIME) + { + CS(this).autojoin_checked = true; + // don't do this in ClientConnect + // many things can go wrong if a client is spawned as player on connection + if (MUTATOR_CALLHOOK(AutoJoinOnConnection, this) + || (!(autocvar_sv_spectate || autocvar_g_campaign || this.team_forced < 0) + && (!teamplay || autocvar_g_balance_teams))) + { + campaign_bots_may_start = true; + Join(this); + return; + } + } else if (IS_OBSERVER(this)) { ObserverThink(this); }