void player_clear_minigame(entity player)
{
- player.active_minigame = NULL;
+ CS(player).active_minigame = NULL;
player.minigame_players = NULL;
if ( IS_PLAYER(player) )
set_movetype(player, MOVETYPE_WALK);
int minigame_addplayer(entity minigame_session, entity player)
{
- if ( player.active_minigame )
+ if ( CS(player).active_minigame )
{
- if ( player.active_minigame == minigame_session )
+ if ( CS(player).active_minigame == minigame_session )
return 0;
- minigame_rmplayer(player.active_minigame,player);
+ minigame_rmplayer(CS(player).active_minigame,player);
}
entity player_pointer = new(minigame_player);
int mgteam = minigame_session.minigame_event(minigame_session,"join",player,player_pointer);
player_pointer.team = mgteam;
player_pointer.list_next = minigame_session.minigame_players;
minigame_session.minigame_players = player_pointer;
- player.active_minigame = minigame_session;
+ CS(player).active_minigame = minigame_session;
player.minigame_players = player_pointer;
setcefc(player_pointer, minigame_CheckSend);
Net_LinkEntity(player_pointer, false, 0, minigame_SendEntity);
void part_minigame(entity player )
{
- entity minig = player.active_minigame;
+ entity minig = CS(player).active_minigame;
if ( minig && minig.classname == "minigame" )
minigame_rmplayer(minig,player);
string invite_minigame(entity inviter, entity player)
{
- if ( !inviter || !inviter.active_minigame )
+ if ( !inviter || !CS(inviter).active_minigame )
return "Invalid minigame";
if ( VerifyClientEntity(player, true, false) <= 0 )
return "Invalid player";
if ( inviter == player )
return "You can't invite yourself";
- if ( player.active_minigame == inviter.active_minigame )
+ if ( CS(player).active_minigame == CS(inviter).active_minigame )
return strcat(player.netname," is already playing");
Send_Notification(NOTIF_ONE, player, MSG_INFO, INFO_MINIGAME_INVITE,
- inviter.active_minigame.netname, inviter.netname );
+ CS(inviter).active_minigame.netname, inviter.netname );
- GameLogEcho(strcat(":minigame:invite:",inviter.active_minigame.netname,":",
+ GameLogEcho(strcat(":minigame:invite:",CS(inviter).active_minigame.netname,":",
ftos(etof(player)),":",player.netname));
return "";
entity minigame_find_player(entity client)
{
- if ( ! client.active_minigame )
+ if ( ! CS(client).active_minigame )
return NULL;
entity e;
- for ( e = client.active_minigame.minigame_players; e; e = e.list_next )
+ for ( e = CS(client).active_minigame.minigame_players; e; e = e.list_next )
if ( e.minigame_players == client )
return e;
return NULL;
bool MinigameImpulse(entity this, int imp)
{
- if (!this.active_minigame) return false;
+ if (!CS(this).active_minigame) return false;
entity e = minigame_find_player(this);
- if ( imp && this.active_minigame && e )
+ if ( imp && CS(this).active_minigame && e )
{
- return this.active_minigame.minigame_event(this.active_minigame,"impulse",e,imp);
+ return CS(this).active_minigame.minigame_event(CS(this).active_minigame,"impulse",e,imp);
}
return false;
}
}
else if ( minig_cmd == "end" || minig_cmd == "part" )
{
- if ( caller.active_minigame )
+ if ( CS(caller).active_minigame )
{
part_minigame(caller);
sprint(caller,"Left minigame session\n");
}
else if ( minig_cmd == "invite" && argc > 2 )
{
- if ( caller.active_minigame )
+ if ( CS(caller).active_minigame )
{
entity client = GetIndexedEntity(argc, 2);
string error = invite_minigame(caller,client);
if ( error == "" )
{
sprint(caller,"You have invited ",client.netname,
- " to join your game of ", caller.active_minigame.descriptor.message, "\n");
+ " to join your game of ", CS(caller).active_minigame.descriptor.message, "\n");
}
else
sprint(caller,"Could not invite: ", error, ".\n");
sprint(caller,"You aren't playing any minigame...\n");
return;
}
- else if ( caller.active_minigame )
+ else if ( CS(caller).active_minigame )
{
entity e = minigame_find_player(caller);
string subcommand = substring(command,argv_end_index(0),-1);
int arg_c = tokenize_console(subcommand);
- if ( caller.active_minigame.minigame_event(caller.active_minigame,"cmd",e,arg_c,subcommand) )
+ if ( CS(caller).active_minigame.minigame_event(CS(caller).active_minigame,"cmd",e,arg_c,subcommand) )
return;
}
}
CS(this).jointime = time;
- this.allowed_timeouts = autocvar_sv_timeout_number;
+ CS(this).allowed_timeouts = autocvar_sv_timeout_number;
if (IS_REAL_CLIENT(this))
{
PlayerStats_GameReport_FinalizePlayer(this);
if (this.vehicle) vehicles_exit(this.vehicle, VHEF_RELEASE);
- if (this.active_minigame) part_minigame(this);
+ if (CS(this).active_minigame) part_minigame(this);
if (IS_PLAYER(this)) Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1);
if (autocvar_sv_eventlog)
MUTATOR_CALLHOOK(ClientDisconnect, this);
+ if (CS(this).netname_previous) strunzone(CS(this).netname_previous); // needs to be before the CS entity is removed!
ClientState_detach(this);
Portal_ClearAll(this);
bot_relinkplayerlist();
- if (CS(this).netname_previous) strunzone(CS(this).netname_previous);
if (this.clientstatus) strunzone(this.clientstatus);
if (this.weaponorder_byimpulse) strunzone(this.weaponorder_byimpulse);
if (this.personal) delete(this.personal);
if ( !IS_DEAD(this.owner) && IS_PLAYER(this.owner) )
{
- if ( this.owner.active_minigame )
+ if ( CS(this.owner).active_minigame )
this.mdl = "models/sprites/minigame_busy.iqm";
else if (PHYS_INPUT_BUTTON_CHAT(this.owner))
this.mdl = "models/misc/chatbubble.spr";