// File: /workspace/github_c_makefile_star2_O2/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 %r12
pushq %rbx
movq %rdi, %rbx
movq 0x40862(%rip), %r15     # 0x66600
pushq $0x1
popq %rbp
movl %ebp, %edi
callq *0x140(%r15)
movq %rax, %r14
movq 0x40a24(%rip), %rax     # 0x667d8
cmpl $0x6, (%rax)
jne 0x25dc2
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x40d8f(%rip), %rax     # 0x66b58
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
testb $0x8, %al
jne 0x25e02
movq 0x40f64(%rip), %rax     # 0x66d40
cmpl $0x0, 0x624(%rax)
je 0x25e1c
movq 0x10(%r15), %rcx
leaq 0x2aa21(%rip), %rdx     # 0x50811
pushq $0x2
popq %rsi
movq %rbx, %rdi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmpq *%rcx
movq 0x18(%r15), %rcx
leaq 0x2a9c7(%rip), %rsi     # 0x507d4
movq %rbx, %rdi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmpq *%rcx
movq %r14, %rdi
callq 0x18e00
movq 0x58(%rbx), %r15
movl 0xe04(%r15), %r12d
leaq 0x296a1(%rip), %rsi     # 0x4f4d7
movq %r14, %rdi
callq 0x18bc0
testl %r12d, %r12d
je 0x25e6b
testl %eax, %eax
je 0x25eb7
leaq 0x2967b(%rip), %rsi     # 0x4f4c9
movq %r14, %rdi
callq 0x18bc0
testl %eax, %eax
jne 0x25db9
movl $0x2, 0x1104(%r15)
jmp 0x25ec2
testl %eax, %eax
je 0x25ed9
leaq 0x29653(%rip), %rsi     # 0x4f4c9
movq %r14, %rdi
callq 0x18bc0
testl %eax, %eax
je 0x25ee9
cmpb $0x0, (%r14)
je 0x25f0c
callq 0x19bf0
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
divss 0x293e6(%rip), %xmm0    # 0x4f288
movss 0x2a556(%rip), %xmm1    # 0x50400
xorl %ebp, %ebp
ucomiss %xmm0, %xmm1
setbe %bpl
incl %ebp
jmp 0x25efa
movl $0x1, 0x1104(%r15)
leaq 0x2a965(%rip), %rsi     # 0x5082e
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x18d20
cmpl $0x1, 0x1100(%r15)
je 0x25db9
jmp 0x25efa
cmpl $0x2, 0x1100(%r15)
je 0x25db9
pushq $0x2
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x18a00
movl 0x1100(%r15), %ecx
cmpl $0x1, %ecx
je 0x25f26
cmpl $0x2, %ecx
jne 0x25f2f
leaq 0x2a93a(%rip), %r14     # 0x5085e
jmp 0x25f4a
leaq 0x2a90d(%rip), %r14     # 0x5083a
jmp 0x25f4a
leaq 0x2a00f(%rip), %r14     # 0x4ff45
leaq 0x2a946(%rip), %rdx     # 0x50883
pushq $0x8
popq %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x18f30
pushq $0x2
popq %r15
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x18ec0
leaq 0x2a93c(%rip), %rdx     # 0x5089f
movq %rbx, %rdi
movq %r15, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x18ec0