// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x405f3(%rip), %r15     # 0x68600
movl $0x1, %edi
callq *0x140(%r15)
movq %rax, %r14
movq 0x407b5(%rip), %rax     # 0x687d8
cmpl $0x6, (%rax)
jne 0x28033
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x40b1e(%rip), %rax     # 0x68b58
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
testb $0x8, %al
jne 0x28077
movq 0x40cf3(%rip), %rax     # 0x68d40
cmpl $0x0, 0x624(%rax)
je 0x28093
movq 0x10(%r15), %rcx
leaq 0x2c7d0(%rip), %rdx     # 0x54831
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *%rcx
movq 0x18(%r15), %rcx
leaq 0x2c772(%rip), %rsi     # 0x547f4
movq %rbx, %rdi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *%rcx
movq %r14, %rdi
callq 0x18d00
movq 0x58(%rbx), %r15
movl 0xe04(%r15), %ebp
leaq 0x2b42a(%rip), %rsi     # 0x534d7
movq %r14, %rdi
callq 0x18b20
testl %ebp, %ebp
je 0x280e1
testl %eax, %eax
je 0x2812d
leaq 0x2b405(%rip), %rsi     # 0x534c9
movq %r14, %rdi
callq 0x18b20
testl %eax, %eax
jne 0x28028
movl $0x2, 0x1104(%r15)
jmp 0x28138
testl %eax, %eax
je 0x28151
leaq 0x2b3dd(%rip), %rsi     # 0x534c9
movq %r14, %rdi
callq 0x18b20
testl %eax, %eax
je 0x28166
cmpb $0x0, (%r14)
je 0x2818b
callq 0x19a10
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
divss 0x2b170(%rip), %xmm0    # 0x53288
movss 0x2c2e0(%rip), %xmm1    # 0x54400
xorl %esi, %esi
ucomiss %xmm0, %xmm1
setbe %sil
incl %esi
jmp 0x28179
movl $0x1, 0x1104(%r15)
leaq 0x2c70f(%rip), %rsi     # 0x5484e
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x18c40
movl $0x1, %esi
cmpl $0x1, 0x1100(%r15)
je 0x28028
jmp 0x28179
movl $0x2, %esi
cmpl $0x2, 0x1100(%r15)
je 0x28028
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x18980
movl 0x1100(%r15), %ecx
cmpl $0x1, %ecx
je 0x281a5
cmpl $0x2, %ecx
jne 0x281ae
leaq 0x2c6db(%rip), %r14     # 0x5487e
jmp 0x281cb
leaq 0x2c6ae(%rip), %r14     # 0x5485a
jmp 0x281cb
leaq 0x2bd90(%rip), %r14     # 0x53f45
leaq 0x2c6e7(%rip), %rdx     # 0x548a3
movq %r14, %rdi
movl $0x8, %esi
xorl %eax, %eax
callq 0x18e10
movl $0x2, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x18da0
leaq 0x2c6dd(%rip), %rdx     # 0x548bf
movl $0x2, %esi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x18da0