// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/p_client.c
// Function: ClientBegin
void ClientBegin (edict_t *ent)
{
	int 	i;
	char	message[MAX_INFO_STRING];
	
	ent->client = game.clients + (ent - g_edicts - 1);

	//sprintf(DBuffer, "cb0 t %d p %d r %d", ent->client->ctf.teamnum,
	//	ent->client->pers.spectator, ent->client->resp.spectator);
	//Debug_Show(DBuffer);
	//ctf_BSafePrint(PRINT_HIGH, DBuffer);

	//if(ent->client->ctf.teamnum <= CTF_TEAM_OBSERVER)
	//{
	//	ent->client->pers.spectator = 1;
	//	ent->client->resp.spectator = 1;
	//}
	//else
	//{
	//	ent->client->pers.spectator = 0;
	//	ent->client->resp.spectator = 0;
	//}


	if (deathmatch->value)
	{
		ClientBeginDeathmatch (ent);
		return;
	}

	// if there is already a body waiting for us (a loadgame), just
	// take it, otherwise spawn one from scratch
	if (ent->inuse == true)
	{
		// the client has cleared the client side viewangles upon
		// connecting to the server, which is different than the
		// state when the game is saved, so we need to compensate
		// with deltaangles
		for (i=0 ; i<3 ; i++)
			ent->client->ps.pmove.delta_angles[i] = ANGLE2SHORT(ent->client->ps.viewangles[i]);
	}
	else
	{
		// a spawn point will completely reinitialize the entity
		// except for the persistent data that was initialized at
		// ClientConnect() time
		G_InitEdict (ent);
		ent->classname = "player";
		InitClientResp (ent->client);
		PutClientInServer (ent);
	}


	//sprintf(DBuffer, "cb1 t %d p %d r %d", ent->client->ctf.teamnum,
	//	ent->client->pers.spectator, ent->client->resp.spectator);
	//Debug_Show(DBuffer);

	if (level.intermissiontime)
	{
		MoveClientToIntermission (ent);
	}
	else
	{
		// send effect if in a multiplayer game
		if (game.maxclients > 1)
		{
			gi.WriteByte (svc_muzzleflash);
			gi.WriteShort (ent-g_edicts);
			gi.WriteByte (MZ_LOGIN);
			gi.multicast (ent->s.origin, MULTICAST_PVS);

			sprintf(message, "%s entered the game\n", ent->client->pers.netname);
			ctf_BSafePrint(PRINT_HIGH, message);
		}
	}

	// make sure all view stuff is valid
	ClientEndServerFrame (ent);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movq %rdi, %rbx
movq 0x24e9c(%rip), %r15     # 0x66d40
movq 0x408(%r15), %rcx
movq 0x246a6(%rip), %r14     # 0x66558
movq %rdi, %rax
subq (%r14), %rax
movl $0x4a8, %esi            # imm = 0x4A8
cqto
idivq %rsi
imulq $0x9140, %rax, %rax     # imm = 0x9140
leaq (%rcx,%rax), %rdx
addq $-0x9140, %rdx          # imm = 0xFFFF6EC0
movq %rdx, 0x58(%rdi)
movq 0x24fe1(%rip), %rdx     # 0x66ec0
movq (%rdx), %rdx
movss 0x20(%rdx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x41ef1
jnp 0x41f05
movq %rbx, %rdi
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r14
popq %r15
jmp 0x18fc0
cmpl $0x1, 0x60(%rbx)
jne 0x41f4b
addq %rax, %rcx
movq $-0x2449, %rax          # imm = 0xDBB7
movss 0xde43(%rip), %xmm0     # 0x4fd60
movss 0xde3f(%rip), %xmm1     # 0x4fd64
cmpq $-0x2446, %rax          # imm = 0xDBBA
je 0x41f72
movss (%rcx,%rax,4), %xmm2
mulss %xmm0, %xmm2
divss %xmm1, %xmm2
cvttss2si %xmm2, %edx
movw %dx, -0x489a(%rcx,%rax,2)
incq %rax
jmp 0x41f25
movq %rbx, %rdi
callq 0x18ef0
leaq 0xe435(%rip), %rax      # 0x5038f
movq %rax, 0x138(%rbx)
movq 0x58(%rbx), %rdi
callq 0x18e80
movq %rbx, %rdi
callq 0x18ac0
movq 0x24e27(%rip), %rax     # 0x66da0
movss 0xc8(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x41f8b
jnp 0x41f95
movq %rbx, %rdi
callq 0x19250
jmp 0x42009
cmpl $0x2, 0x610(%r15)
jl 0x42009
movq 0x2465a(%rip), %r15     # 0x66600
pushq $0x1
popq %rdi
callq *0xc8(%r15)
movq %rbx, %rax
subq (%r14), %rax
movl $0x4a8, %ecx            # imm = 0x4A8
cqto
idivq %rcx
movl %eax, %edi
callq *0xd0(%r15)
pushq $0x9
popq %rdi
callq *0xc8(%r15)
leaq 0x4(%rbx), %rdi
pushq $0x2
popq %rsi
callq *0xb0(%r15)
movl $0x2c0, %edx            # imm = 0x2C0
addq 0x58(%rbx), %rdx
leaq 0x144bc(%rip), %rsi     # 0x564ad
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x198c0
pushq $0x2
popq %rdi
movq %r14, %rsi
callq 0x193f0
movq %rbx, %rdi
callq 0x18ba0
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r14
popq %r15
retq