#include "../lib/warpzone/server.qh"
+STATIC_METHOD(Client, Add, void(Client this, int _team))
+{
+ WITH(entity, self, this, ClientConnect());
+ TRANSMUTE(Player, this);
+ this.frame = 12; // 7
+ this.team = _team;
+ WITH(entity, self, this, PutClientInServer());
+}
+
+void PutObserverInServer();
+void ClientDisconnect();
+
+STATIC_METHOD(Client, Remove, void(Client this))
+{
+ TRANSMUTE(Observer, this);
+ WITH(entity, self, this, PutClientInServer(); ClientDisconnect());
+}
void send_CSQC_teamnagger() {
WriteHeader(MSG_BROADCAST, TE_CSQC_TEAMNAGGER);
void ClientData_Attach(entity this)
{
Net_LinkEntity(this.clientdata = new_pure(clientdata), false, 0, ClientData_Send);
- self.clientdata.drawonlytoclient = this;
- self.clientdata.owner = this;
+ this.clientdata.drawonlytoclient = this;
+ this.clientdata.owner = this;
}
void ClientData_Detach(entity this)
{
remove(this.clientdata);
- self.clientdata = NULL;
+ this.clientdata = NULL;
}
void ClientData_Touch(entity e)
this.spectatortime = time;
this.bot_attack = false;
this.hud = HUD_NORMAL;
- this.classname = STR_OBSERVER;
+ TRANSMUTE(Observer, this);
this.iscreature = false;
this.teleportable = TELEPORT_SIMPLE;
this.damagedbycontents = false;
{
SELFPARAM();
if (IS_BOT_CLIENT(this)) {
- this.classname = STR_PLAYER;
+ TRANSMUTE(Player, this);
} else if (IS_REAL_CLIENT(this)) {
msg_entity = this;
WriteByte(MSG_ONE, SVC_SETVIEW);
WriteEntity(MSG_ONE, this);
}
if (gameover) {
- this.classname = STR_OBSERVER;
+ TRANSMUTE(Observer, this);
}
SetSpectatee(this, NULL);
return; // spawn failed
}
- this.classname = STR_PLAYER;
+ TRANSMUTE(Player, this);
this.wasplayer = true;
this.iscreature = true;
this.teleportable = TELEPORT_NORMAL;
}
void ClientInit_misc()
{
+ SELFPARAM();
int channel = MSG_ONE;
WriteHeader(channel, ENT_CLIENT_INIT);
WriteByte(channel, g_nexball_meter_period * 32);
SELFPARAM();
if (Ban_MaybeEnforceBanOnce(this)) return;
assert(!IS_CLIENT(this), return);
+ this.flags |= FL_CLIENT;
assert(player_count >= 0, player_count = 0);
- this.classname = "player_joining";
- this.flags = FL_CLIENT;
#ifdef WATERMARK
Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_WATERMARK, WATERMARK);
#endif
this.version_nagtime = time + 10 + random() * 10;
-
- ClientState_attach(this);
+ TRANSMUTE(Client, this);
// identify the right forced team
if (autocvar_g_campaign)
}
if (!teamplay && this.team_forced > 0) this.team_forced = 0;
- JoinBestTeam(this, false, false); // if the team number is valid, keep it
+ {
+ int id = this.playerid;
+ this.playerid = 0; // silent
+ JoinBestTeam(this, false, false); // if the team number is valid, keep it
+ this.playerid = id;
+ }
if (autocvar_sv_spectate || autocvar_g_campaign || this.team_forced < 0) {
- this.classname = STR_OBSERVER;
+ TRANSMUTE(Observer, this);
} else {
- if (!teamplay || autocvar_g_balance_teams)
- {
- this.classname = STR_PLAYER;
- campaign_bots_may_start = 1;
- }
- else
- {
- this.classname = STR_OBSERVER; // do it anyway
+ if (!teamplay || autocvar_g_balance_teams) {
+ TRANSMUTE(Player, this);
+ campaign_bots_may_start = true;
+ } else {
+ TRANSMUTE(Observer, this); // do it anyway
}
}
- this.playerid = ++playerid_last;
-
PlayerStats_GameReport_AddEvent(sprintf("kills-%d", this.playerid));
// always track bots, don't ask for cl_allow_uidtracking
setsize(this, spectatee.mins, spectatee.maxs);
SetZoomState(spectatee.zoomstate);
- anticheat_spectatecopy(spectatee);
+ anticheat_spectatecopy(this, spectatee);
this.hud = spectatee.hud;
if(spectatee.vehicle)
{
{
if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || (self.wasplayer && autocvar_g_changeteam_banned) || self.team_forced > 0)
{
- self.classname = STR_PLAYER;
+ TRANSMUTE(Player, self);
if(autocvar_g_campaign || autocvar_g_balance_teams)
{ JoinBestTeam(self, false, true); }
if(autocvar_g_campaign)
- { campaign_bots_may_start = 1; }
+ { campaign_bots_may_start = true; }
Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CPID_PREVENT_JOIN);
} else if(PHYS_INPUT_BUTTON_ATCK(self) && !self.version_mismatch) {
self.flags &= ~FL_JUMPRELEASED;
if(SpectateNext()) {
- self.classname = STR_SPECTATOR;
+ TRANSMUTE(Spectator, self);
}
} else {
prefered_movetype = ((!PHYS_INPUT_BUTTON_USE(self) ? self.cvar_cl_clippedspectating : !self.cvar_cl_clippedspectating) ? MOVETYPE_FLY_WORLDONLY : MOVETYPE_NOCLIP);
} else if(PHYS_INPUT_BUTTON_ATCK(self) || self.impulse == 10 || self.impulse == 15 || self.impulse == 18 || (self.impulse >= 200 && self.impulse <= 209)) {
self.flags &= ~FL_JUMPRELEASED;
if(SpectateNext()) {
- self.classname = STR_SPECTATOR;
+ TRANSMUTE(Spectator, self);
} else {
- self.classname = STR_OBSERVER;
+ TRANSMUTE(Observer, self);
PutClientInServer();
}
self.impulse = 0;
} else if(self.impulse == 12 || self.impulse == 16 || self.impulse == 19 || (self.impulse >= 220 && self.impulse <= 229)) {
self.flags &= ~FL_JUMPRELEASED;
if(SpectatePrev()) {
- self.classname = STR_SPECTATOR;
+ TRANSMUTE(Spectator, self);
} else {
- self.classname = STR_OBSERVER;
+ TRANSMUTE(Observer, self);
PutClientInServer();
}
self.impulse = 0;
} else if (PHYS_INPUT_BUTTON_ATCK2(self)) {
self.flags &= ~FL_JUMPRELEASED;
- self.classname = STR_OBSERVER;
+ TRANSMUTE(Observer, self);
PutClientInServer();
} else {
if(!SpectateUpdate())
.int items_added;
void PlayerPreThink ()
{SELFPARAM();
- WarpZone_PlayerPhysics_FixVAngle();
+ WarpZone_PlayerPhysics_FixVAngle(self);
self.stat_game_starttime = game_starttime;
self.stat_round_starttime = round_starttime;
if(frametime)
{
// physics frames: update anticheat stuff
- anticheat_prethink();
+ anticheat_prethink(self);
}
if(blockSpectators && frametime)