// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/p_client.c
// Function: ClientDisconnect
void ClientDisconnect (edict_t *ent)
{
	int 	playernum;
	edict_t	*flag;  // CTF CODE -- LM_JORM
	char message[MAX_INFO_STRING];

	if (!ent->client)
		return;
	
	// STATS-BEGIN LM_Hati
	if (ent->client->p_stats_player)
	{
		ent->client->p_stats_player->dropped = true;
		ent->client->p_stats_player->info.teamnum = ent->client->ctf.teamnum;
	}
	// STATS-END LM_Hati

	// Players drop runes on quit. //QW//
	if(ent->client->rune)
		Drop_Rune(ent, ent->client->rune->item);

	// CTF CODE -- LM_JORM
	ent->client->ctf.extra_flags &= ~CTF_EXTRAFLAGS_REFEREE; // Turn off referee mode
	ent->client->ctf.extra_flags &= ~CTF_EXTRAFLAGS_RCON; //turn off rcon mode
	
	// Were we carrying a flag?  MJD Suggest Parens Here
	flag = ClientHasFlag(ent);
	if (flag)//surt to avoid compiler warns on linux/solaris (assignment in conditional)
	{
		if (flag->owner == ent) // We owned this flag
		{
			ctf_playerdropflag(ent, flag->item);
		}
	}
	
	if (ent->client->hook)
	{
		G_FreeEdict (ent->client->hook);
		ent->client->hook = NULL;
	}
	
	
	// END CTF CODE -- LM_JORM
	
	sl_LogPlayerDisconnect( &gi, level, ent ); // StdLog - Mark Davies
	
	sprintf(message, "%s disconnected\n", ent->client->pers.netname);
	ctf_BSafePrint(PRINT_HIGH, message);
	
	// send effect
	gi.WriteByte (svc_muzzleflash);
	gi.WriteShort (ent-g_edicts);
	gi.WriteByte (MZ_LOGOUT);
	gi.multicast (ent->s.origin, MULTICAST_PVS);

	gi.unlinkentity (ent);
	ent->s.modelindex = 0;
	ent->solid = SOLID_NOT;
	ent->inuse = false;
	ent->classname = "disconnected";
	ent->client->p_stats_player = NULL; // LM_Hati
	ent->client->pers.connected = false;

	playernum = ent-g_edicts-1;
	gi.configstring (CS_PLAYERSKINS+playernum, "");
	
	//ctf_ClientDisconnect(ent);
	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x390, %rsp            # imm = 0x390
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x58(%rax)
jne 0x5ba6f
jmp 0x5bd25
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0x0, 0x9138(%rax)
je 0x5bab9
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0x9138(%rax), %rax
movl $0x1, (%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x1100(%rax), %ecx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0x9138(%rax), %rax
movl %ecx, 0x204(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0x0, 0xf68(%rax)
je 0x5baea
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf68(%rax), %rax
movq 0x330(%rax), %rsi
callq 0x19bb0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x1108(%rax), %ecx
andl $-0x3, %ecx
movl %ecx, 0x1108(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x1108(%rax), %ecx
andl $-0x5, %ecx
movl %ecx, 0x1108(%rax)
movq -0x8(%rbp), %rdi
callq 0x18150
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x5bb53
movq -0x18(%rbp), %rax
movq 0x110(%rax), %rax
cmpq -0x8(%rbp), %rax
jne 0x5bb51
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x330(%rax), %rsi
callq 0x19a90
jmp 0x5bb53
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0x0, 0xf60(%rax)
je 0x5bb8c
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf60(%rax), %rdi
callq 0x19cd0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq $0x0, 0xf60(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x230(%rbp)
movq 0x27202(%rip), %rsi     # 0x82da0
movq %rsp, %rdi
movl $0x2b, %ecx
rep  movsq (%rsi), %es:(%rdi)
movq -0x230(%rbp), %rsi
movq 0x26a49(%rip), %rdi     # 0x82600
callq 0x19720
leaq -0x220(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdx
addq $0xc0, %rdx
addq $0x200, %rdx            # imm = 0x200
leaq 0x1b670(%rip), %rsi     # 0x77250
movb $0x0, %al
callq 0x19940
leaq -0x220(%rbp), %rsi
movl $0x2, %edi
callq 0x19470
movl $0x1, %edi
movq 0x269fc(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movq 0x269ef(%rip), %rax     # 0x82600
movq 0xd0(%rax), %rax
movq %rax, -0x228(%rbp)
movq -0x8(%rbp), %rax
movq 0x2692e(%rip), %rcx     # 0x82558
movq (%rcx), %rcx
subq %rcx, %rax
movl $0x4a8, %ecx            # imm = 0x4A8
cqto
idivq %rcx
movq %rax, %rcx
movq -0x228(%rbp), %rax
movl %ecx, %edi
callq *%rax
movl $0xa, %edi
movq 0x269ac(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movq 0x2699f(%rip), %rax     # 0x82600
movq 0xb0(%rax), %rax
movq -0x8(%rbp), %rdi
addq $0x4, %rdi
movl $0x2, %esi
callq *%rax
movq 0x26982(%rip), %rax     # 0x82600
movq 0x98(%rax), %rax
movq -0x8(%rbp), %rdi
callq *%rax
movq -0x8(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x108(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x60(%rax)
movq -0x8(%rbp), %rax
leaq 0x1b5a7(%rip), %rcx     # 0x77261
movq %rcx, 0x138(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq $0x0, 0x9138(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x0, 0x304(%rax)
movq -0x8(%rbp), %rax
movq 0x26867(%rip), %rcx     # 0x82558
movq (%rcx), %rcx
subq %rcx, %rax
movl $0x4a8, %ecx            # imm = 0x4A8
cqto
idivq %rcx
subq $0x1, %rax
movl %eax, -0xc(%rbp)
movq 0x268f1(%rip), %rax     # 0x82600
movq 0x30(%rax), %rax
movl -0xc(%rbp), %edi
addl $0x520, %edi            # imm = 0x520
leaq 0x1525d(%rip), %rsi     # 0x70f80
callq *%rax
addq $0x390, %rsp            # imm = 0x390
popq %rbp
retq
nop