}
/** putting a client as observer in the server */
-void PutObserverInServer(entity this, bool is_forced)
+void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint)
{
bool mutator_returnvalue = MUTATOR_CALLHOOK(MakePlayerObserver, this, is_forced);
+ bool recount_ready = false;
PlayerState_detach(this);
if (IS_PLAYER(this))
if(IS_REAL_CLIENT(this))
{
if (vote_called) { VoteCount(false); }
- ReadyCount();
+ this.ready = false;
+ recount_ready = true;
}
entcs_update_players(this);
}
- entity spot = SelectSpawnPoint(this, true);
- if (!spot) LOG_FATAL("No spawnpoints for observers?!?");
- this.angles = vec2(spot.angles);
+ if (use_spawnpoint)
+ {
+ entity spot = SelectSpawnPoint(this, true);
+ if (!spot) LOG_FATAL("No spawnpoints for observers?!?");
+ this.angles = vec2(spot.angles);
+ // offset it so that the spectator spawns higher off the ground, looks better this way
+ setorigin(this, spot.origin + STAT(PL_VIEW_OFS, this));
+ }
+ else // change origin to restore previous view origin
+ setorigin(this, this.origin + STAT(PL_VIEW_OFS, this) - STAT(PL_CROUCH_VIEW_OFS, this));
this.fixangle = true;
- // offset it so that the spectator spawns higher off the ground, looks better this way
- setorigin(this, spot.origin + STAT(PL_VIEW_OFS, this));
+
if (IS_REAL_CLIENT(this))
{
msg_entity = this;
this.monster_attack = false;
STAT(HUD, this) = HUD_NORMAL;
TRANSMUTE(Observer, this);
+ if(recount_ready) ReadyCount();
this.iscreature = false;
this.teleportable = TELEPORT_SIMPLE;
if(this.damagedbycontents)
if (game_stopped)
TRANSMUTE(Observer, this);
+ bool use_spawnpoint = (!this.enemy); // check this.enemy here since SetSpectatee will clear it
SetSpectatee(this, NULL);
// reset player keys
MUTATOR_CALLHOOK(PutClientInServer, this);
if (IS_OBSERVER(this)) {
- PutObserverInServer(this, false);
+ PutObserverInServer(this, false, use_spawnpoint);
} else if (IS_PLAYER(this)) {
PutPlayerInServer(this);
}
void FixClientCvars(entity e)
{
// send prediction settings to the client
- stuffcmd(e, "\nin_bindmap 0 0\n");
if(autocvar_g_antilag == 3) // client side hitscan
stuffcmd(e, "cl_cmd settemp cl_prydoncursor_notrace 0\n");
if(autocvar_sv_gentle)
accuracy_resend(this);
if(!SpectateUpdate(this))
- PutObserverInServer(this, false);
+ PutObserverInServer(this, false, true);
return true;
}
old_spectatee.(weaponentity).arc_beam.SendFlags |= ARC_SF_SETTINGS;
}
}
- if(this.enemy)
+ if(spectatee)
{
for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
.entity weaponentity = weaponentities[slot];
- if(this.enemy.(weaponentity).arc_beam)
- this.enemy.(weaponentity).arc_beam.SendFlags |= ARC_SF_SETTINGS;
+ if(spectatee.(weaponentity).arc_beam)
+ spectatee.(weaponentity).arc_beam.SendFlags |= ARC_SF_SETTINGS;
}
}
- if (this.enemy)
- SetSpectatee_status(this, etof(this.enemy));
+ if (spectatee)
+ SetSpectatee_status(this, etof(spectatee));
// needed to update spectator list
if(old_spectatee) { ClientData_Touch(old_spectatee); }
TRANSMUTE(Observer, this);
PutClientInServer(this);
} else if(!SpectateUpdate(this) && !SpectateNext(this)) {
- PutObserverInServer(this, false);
+ PutObserverInServer(this, false, true);
this.would_spectate = true;
}
}
}
}
if(is_spec && !SpectateUpdate(this))
- PutObserverInServer(this, false);
+ PutObserverInServer(this, false, true);
}
if (is_spec)
this.flags |= FL_CLIENT | FL_NOTARGET;
this.last_vehiclecheck = time + 1;
}
- if(!CS_CVAR(this).cvar_cl_newusekeysupported) // FIXME remove this - it was a stupid idea to begin with, we can JUST use the button
- {
- if(PHYS_INPUT_BUTTON_USE(this) && !CS(this).usekeypressed)
- PlayerUseKey(this);
- CS(this).usekeypressed = PHYS_INPUT_BUTTON_USE(this);
- }
+ if(PHYS_INPUT_BUTTON_USE(this) && !CS(this).usekeypressed)
+ PlayerUseKey(this);
+ CS(this).usekeypressed = PHYS_INPUT_BUTTON_USE(this);
if (IS_REAL_CLIENT(this))
PrintWelcomeMessage(this);
if (IS_PLAYER(this) && autocvar_sv_maxidle_playertospectator > 0)
{
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_MOVETOSPEC_IDLING, this.netname, maxidle_time);
- PutObserverInServer(this, true);
+ PutObserverInServer(this, true, true);
}
else
{