// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/p_client.c
// Function: ClientConnect
qboolean ClientConnect (edict_t *ent, char *userinfo)
{
	char	*value;

	// check to see if they are on the banned IP list
	value = Info_ValueForKey (userinfo, "ip");
	if (SV_FilterPacket(value)) {
		Info_SetValueForKey(userinfo, "rejmsg", "Banned.");
		return false;
	}


	// check for a spectator
	value = Info_ValueForKey (userinfo, "spectator");
	if (deathmatch->value && *value && strcmp(value, "0")) {
		int i, numspec;

		if (*spectator_password->string && 
			strcmp(spectator_password->string, "none") && 
			strcmp(spectator_password->string, value)) {
			Info_SetValueForKey(userinfo, "rejmsg", "Spectator password required or incorrect.");
			return false;
		}

		// count spectators
		for (i = numspec = 0; i < maxclients->value; i++)
			if (g_edicts[i+1].inuse && g_edicts[i+1].client->pers.spectator)
				numspec++;

		if (numspec >= maxspectators->value) {
			Info_SetValueForKey(userinfo, "rejmsg", "Server spectator limit is full.");
			return false;
		}
	} else 
	
	{
		// check for a password
		value = Info_ValueForKey (userinfo, "password");
		if (*password->string && strcmp(password->string, "none") && 
			strcmp(password->string, value)) {
			Info_SetValueForKey(userinfo, "rejmsg", "Password required or incorrect.");
			return false;
		}
	}


	// must have name to connect
	value = Info_ValueForKey(userinfo, "name");
	if (strcmp(value, "") == 0)
	{
		Info_SetValueForKey(userinfo, "rejmsg", "You must have a name.");
		return false;
	}
	
	// they can connect
	ent->client = game.clients + (ent - g_edicts - 1);
	
	if (ent->client->p_stats_player)
	{
		ent->client->p_stats_player->dropped = true;
		ent->client->p_stats_player->info.teamnum = ent->client->ctf.teamnum;
		ent->client->p_stats_player = NULL;
	}

	// if there is already a body waiting for us (a loadgame), just
	// take it, otherwise spawn one from scratch
	if (ent->inuse == false)
	{
		// clear the respawning variables
		InitClientResp (ent->client);
		if (!game.autosaved || !ent->client->pers.weapon)
			InitClientPersistent (ent->client);
	}

	ClientUserinfoChanged (ent, userinfo);

#ifdef OLDOBSERVERCODE
	// CTF CODE -- LM_JORM
	value = Info_ValueForKey (userinfo, "autoobserve");
	if (value[0] == '1')
		ent->client->autoobserve = 1;
	else
		ent->client->autoobserve = 0;
#endif

	// Hati - copy enterframe to ctf struct and clear popup entity
	ent->client->ctf.original_enterframe = level.framenum;
	ent->client->ctf.popup_ent = NULL;
	ent->client->last_popup_frame = 0;

	// Hati - initialize spam control variables
	ent->client->spam_band_count = CTF_SPAM_BAND_MAX;
	ent->client->spam_freq_count = CTF_SPAM_FREQ_MIN;
	ent->client->spam_freq_time = level.time;
	
	// STATS-BEGIN LM_Hati
	{
		stats_player_s *p_player = NULL;
		
		if (strcmp(ent->client->pers.netname, "") != 0) //not a blank string
		{
			p_player = stats_find_dropped_player(ent->client->pers.netname);
		}
		if (p_player == NULL)
		{
			p_player = stats_new_player(ent->client->pers.netname);
		}
		ent->client->p_stats_player = p_player;
	}
	// STATS-END LM_Hati

	// END LM_JORM
	

	if (game.maxclients > 1)
		gi.dprintf ("%s connected\n", ent->client->pers.netname);

	ent->svflags = 0; // make sure we start with known default
	ent->client->pers.connected = true;
	return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x13086(%rip), %rsi     # 0x550b9
movq %r14, %rdi
callq 0x18c70
movq %rax, %rdi
callq 0x192c0
testl %eax, %eax
je 0x4206b
leaq 0x144a3(%rip), %rsi     # 0x564f1
leaq 0x144a3(%rip), %rdx     # 0x564f8
movq %r14, %rdi
callq 0x185a0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x14318(%rip), %rsi     # 0x5638a
movq %r14, %rdi
callq 0x18c70
movq %rax, %r15
movq 0x24e3c(%rip), %rax     # 0x66ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x42096
jnp 0x420fc
movzbl (%r15), %eax
testl %eax, %eax
je 0x420fc
cmpl $0x30, %eax
jne 0x420aa
cmpb $0x0, 0x1(%r15)
je 0x420fc
movq 0x24b77(%rip), %rax     # 0x66c28
movq (%rax), %rax
movq 0x8(%rax), %r12
cmpb $0x0, (%r12)
je 0x42164
leaq 0x111e7(%rip), %rsi     # 0x532b1
movq %r12, %rdi
callq 0x18bc0
testl %eax, %eax
je 0x42164
movq %r12, %rdi
movq %r15, %rsi
callq 0x18bc0
testl %eax, %eax
je 0x42164
leaq 0x14401(%rip), %rsi     # 0x564f1
leaq 0x14409(%rip), %rdx     # 0x56500
jmp 0x42055
leaq 0x11df6(%rip), %rsi     # 0x53ef9
movq %r14, %rdi
callq 0x18c70
movq %rax, %r15
movq 0x24743(%rip), %rax     # 0x66858
movq (%rax), %rax
movq 0x8(%rax), %r12
cmpb $0x0, (%r12)
je 0x421d6
leaq 0x11183(%rip), %rsi     # 0x532b1
movq %r12, %rdi
callq 0x18bc0
testl %eax, %eax
je 0x421d6
movq %r12, %rdi
movq %r15, %rsi
callq 0x18bc0
testl %eax, %eax
je 0x421d6
leaq 0x14399(%rip), %rsi     # 0x564f1
leaq 0x143cb(%rip), %rdx     # 0x5652a
jmp 0x42055
movq 0x243c5(%rip), %rax     # 0x66530
movq (%rax), %rax
movss 0x20(%rax), %xmm0
movq 0x243de(%rip), %rcx     # 0x66558
movl $0x508, %eax            # imm = 0x508
addq (%rcx), %rax
xorl %ecx, %ecx
xorl %edx, %edx
imulq $0x4a8, %rcx, %rsi      # imm = 0x4A8
addq %rax, %rsi
cvtsi2ss %ecx, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x421be
incq %rcx
leaq 0x4a8(%rsi), %rdi
cmpl $0x0, (%rsi)
movq %rdi, %rsi
je 0x42190
movq -0x4b0(%rdi), %rsi
cmpl $0x1, 0x750(%rsi)
sbbl $-0x1, %edx
jmp 0x42186
cvtsi2ss %edx, %xmm0
movq 0x24d6f(%rip), %rax     # 0x66f38
movq (%rax), %rax
ucomiss 0x20(%rax), %xmm0
jae 0x4234d
leaq 0x11c34(%rip), %rsi     # 0x53e11
movq %r14, %rdi
callq 0x18c70
cmpb $0x0, (%rax)
je 0x4233a
movq 0x24b4b(%rip), %r15     # 0x66d40
movq 0x408(%r15), %rcx
movq 0x24355(%rip), %rdx     # 0x66558
movq %rbx, %rax
subq (%rdx), %rax
movl $0x4a8, %esi            # imm = 0x4A8
cqto
idivq %rsi
imulq $0x9140, %rax, %rdx     # imm = 0x9140
leaq (%rcx,%rdx), %rdi
addq $-0x9140, %rdi          # imm = 0xFFFF6EC0
movq %rdi, 0x58(%rbx)
movq 0x9138(%rdi), %rax
testq %rax, %rax
je 0x4224f
addq %rdx, %rcx
movl $0x1, (%rax)
movl -0x8040(%rcx), %edx
movl %edx, 0x204(%rax)
andq $0x0, -0x8(%rcx)
cmpl $0x0, 0x60(%rbx)
jne 0x42277
callq 0x18e80
cmpl $0x0, 0x620(%r15)
movq 0x58(%rbx), %rdi
je 0x42272
cmpq $0x0, 0x730(%rdi)
jne 0x42277
callq 0x19af0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x19c98
movq 0x24b17(%rip), %rax     # 0x66da0
movl (%rax), %ecx
movq 0x58(%rbx), %rdi
movl %ecx, 0x9128(%rdi)
andq $0x0, 0x9130(%rdi)
andl $0x0, 0x10fc(%rdi)
movq $0x1c2, 0x10e0(%rdi) # imm = 0x1C2
andq $0x0, 0x10d8(%rdi)
movss 0x4(%rax), %xmm0
movss %xmm0, 0x10d0(%rdi)
cmpb $0x0, 0x2c0(%rdi)
je 0x422e2
addq $0x2c0, %rdi            # imm = 0x2C0
callq 0x190f0
testq %rax, %rax
jne 0x422ee
movq 0x58(%rbx), %rdi
addq $0x2c0, %rdi            # imm = 0x2C0
callq 0x184a0
movq 0x58(%rbx), %rsi
movq %rax, 0x9138(%rsi)
cmpl $0x2, 0x610(%r15)
jl 0x42321
movq 0x242f6(%rip), %rcx     # 0x66600
addq $0x2c0, %rsi            # imm = 0x2C0
leaq 0x14248(%rip), %rdi     # 0x56560
xorl %eax, %eax
callq *0x8(%rcx)
movq 0x58(%rbx), %rsi
andl $0x0, 0xc8(%rbx)
movl $0x1, 0x304(%rsi)
pushq $0x1
popq %rax
jmp 0x4205f
leaq 0x141b0(%rip), %rsi     # 0x564f1
leaq 0x14202(%rip), %rdx     # 0x5654a
jmp 0x42055
leaq 0x1419d(%rip), %rsi     # 0x564f1
leaq 0xf1af(%rip), %rdx      # 0x5150a
jmp 0x42055