// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/g_cmds.c
// Function: Cmd_Team_f
void Cmd_Team_f (edict_t *ent)
{
	char *rawnew = gi.argv(1);
//	int len = strlen(rawnew)+1;
	int newnum = 0;
	char *message = "";

	if(matchstate == MATCH_RAILGUN_INPLAY)
		return;

	if ((int)ctfflags->value & CTF_TEAM_NOSWITCH)
	{
		gi.centerprintf (ent, "Sorry.  Team switching has been turned\n off on this server.\n");
		return;
	}

	if (game.teamslocked) {
		gi.cprintf(ent, PRINT_HIGH, "Teams are currently locked.\n");
		return;
	}

	LowerCase(rawnew); //converts to lower case

	//If they are a spectator, team code screwed up, so do this instead.
	//if(ent->client->pers.spectator)
	if(ent->client->resp.spectator)
	{
		if(strcmp(rawnew, "red") == 0)
		{
			//ctf_SetEntTeam(ent, CTF_TEAM_RED);
			ent->client->ctf.New_Team = CTF_TEAM_RED;
			ForceCommand(ent, "spectator 0");
		}
		else if(strcmp(rawnew, "blue") == 0)
		{
			//ctf_SetEntTeam(ent, CTF_TEAM_BLUE);
			ent->client->ctf.New_Team = CTF_TEAM_BLUE;
			ForceCommand(ent, "spectator 0");
		}

		return;
	}

	if (!strcmp(rawnew, "red"))
	{
		if (ent->client->ctf.teamnum != CTF_TEAM_RED)
		{
			//bat
			//ent->client->pers.My_Team = CTF_TEAM_RED;
			newnum = 1;
		}
		else
			return; // Same team
	}
	else if (!strcmp(rawnew, "blue"))// Blue
	{
		if (ent->client->ctf.teamnum != CTF_TEAM_BLUE)
		{
			//bat
			//ent->client->pers.My_Team = CTF_TEAM_RED;
			newnum = 2;
		}
		else
			return; // Same team
	}

	//surt this was if, but we want to do something about 'team green'
	else if (rawnew[0] == 0) // Null string
	{
		if (ent->client->ctf.teamnum == CTF_TEAM_RED)
		{
			ctf_SafePrint(ent, PRINT_HIGH, "You are currently on the red team.\n");
		}
		else if (ent->client->ctf.teamnum == CTF_TEAM_BLUE)
		{
			ctf_SafePrint(ent, PRINT_HIGH, "You are currently on the blue team.\n");
		}
		else
		{
			Com_sprintf(message, sizeof message, "You are currently team %d.\n", ent->client->ctf.teamnum);
			ctf_SafePrint(ent,  PRINT_HIGH, message);
		}
		ctf_SafePrint(ent, PRINT_HIGH, "Use 'team red' or 'team blue' to change teams.\n");
		return;
	}

	//surt, new case to avoid 'team green'
	else
	{
		if (random() < 0.5)
			newnum = 1;
		else
			newnum = 2;
	}

	Team_Change(ent, newnum);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl $0x1, %edi
movq 0x54c38(%rip), %rax     # 0x82600
callq *0x140(%rax)
movq %rax, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
leaq 0x435a0(%rip), %rax     # 0x70f80
movq %rax, -0x20(%rbp)
movq 0x54ded(%rip), %rax     # 0x827d8
cmpl $0x6, (%rax)
jne 0x2d9f5
jmp 0x2dc60
movq 0x5515c(%rip), %rax     # 0x82b58
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x2da2b
movq 0x54bed(%rip), %rax     # 0x82600
movq 0x18(%rax), %rcx
movq -0x8(%rbp), %rdi
leaq 0x43d56(%rip), %rsi     # 0x71778
movb $0x0, %al
callq *%rcx
jmp 0x2dc60
movq 0x5530e(%rip), %rax     # 0x82d40
cmpl $0x0, 0x624(%rax)
je 0x2da5f
movq 0x54bbe(%rip), %rax     # 0x82600
movq 0x10(%rax), %rcx
movq -0x8(%rbp), %rdi
movl $0x2, %esi
leaq 0x43d5f(%rip), %rdx     # 0x717b5
movb $0x0, %al
callq *%rcx
jmp 0x2dc60
movq -0x10(%rbp), %rdi
callq 0x18e60
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x0, 0xe04(%rax)
je 0x2daf0
movq -0x10(%rbp), %rdi
leaq 0x42a2b(%rip), %rsi     # 0x704af
callq 0x18bf0
cmpl $0x0, %eax
jne 0x2dab2
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x1, 0x1104(%rax)
movq -0x8(%rbp), %rdi
leaq 0x43d27(%rip), %rsi     # 0x717d2
callq 0x18d80
jmp 0x2daeb
movq -0x10(%rbp), %rdi
leaq 0x429e4(%rip), %rsi     # 0x704a1
callq 0x18bf0
cmpl $0x0, %eax
jne 0x2dae9
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x2, 0x1104(%rax)
movq -0x8(%rbp), %rdi
leaq 0x43cee(%rip), %rsi     # 0x717d2
callq 0x18d80
jmp 0x2daeb
jmp 0x2dc60
movq -0x10(%rbp), %rdi
leaq 0x429b4(%rip), %rsi     # 0x704af
callq 0x18bf0
cmpl $0x0, %eax
jne 0x2db29
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x1, 0x1100(%rax)
je 0x2db1f
movl $0x1, -0x14(%rbp)
jmp 0x2db24
jmp 0x2dc60
jmp 0x2dc54
movq -0x10(%rbp), %rdi
leaq 0x4296d(%rip), %rsi     # 0x704a1
callq 0x18bf0
cmpl $0x0, %eax
jne 0x2db62
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x2, 0x1100(%rax)
je 0x2db58
movl $0x2, -0x14(%rbp)
jmp 0x2db5d
jmp 0x2dc60
jmp 0x2dc52
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x2dc12
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x1, 0x1100(%rax)
jne 0x2db9a
movq -0x8(%rbp), %rdi
movl $0x2, %esi
leaq 0x43c4b(%rip), %rdx     # 0x717de
callq 0x18f20
jmp 0x2dbfb
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x2, 0x1100(%rax)
jne 0x2dbc2
movq -0x8(%rbp), %rdi
movl $0x2, %esi
leaq 0x43c47(%rip), %rdx     # 0x71802
callq 0x18f20
jmp 0x2dbf9
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x1100(%rax), %ecx
movl $0x8, %esi
leaq 0x43c47(%rip), %rdx     # 0x71827
movb $0x0, %al
callq 0x18f90
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x2, %esi
callq 0x18f20
jmp 0x2dbfb
movq -0x8(%rbp), %rdi
movl $0x2, %esi
leaq 0x43c38(%rip), %rdx     # 0x71843
callq 0x18f20
jmp 0x2dc60
callq 0x19c80
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x42660(%rip), %xmm1    # 0x70288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x437f0(%rip), %xmm0    # 0x71428
ucomisd %xmm1, %xmm0
jbe 0x2dc47
movl $0x1, -0x14(%rbp)
jmp 0x2dc4e
movl $0x2, -0x14(%rbp)
jmp 0x2dc50
jmp 0x2dc52
jmp 0x2dc54
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x18a20
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)