// File: /workspace/github_c_makefile_star2_O1/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 0x4142e(%rip), %r15     # 0x69600
movl $0x1, %edi
callq *0x140(%r15)
movq %rax, %r14
movq 0x415f0(%rip), %rax     # 0x697d8
cmpl $0x6, (%rax)
jne 0x281f8
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x41959(%rip), %rax     # 0x69b58
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
testb $0x8, %al
jne 0x2823c
movq 0x41b2e(%rip), %rax     # 0x69d40
cmpl $0x0, 0x624(%rax)
je 0x28258
movq 0x10(%r15), %rcx
leaq 0x2d5eb(%rip), %rdx     # 0x55811
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 0x2d58d(%rip), %rsi     # 0x557d4
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 0x2c235(%rip), %rsi     # 0x544a7
movq %r14, %rdi
callq 0x18b20
testl %ebp, %ebp
je 0x282a6
testl %eax, %eax
je 0x282f2
leaq 0x2c210(%rip), %rsi     # 0x54499
movq %r14, %rdi
callq 0x18b20
testl %eax, %eax
jne 0x281ed
movl $0x2, 0x1104(%r15)
jmp 0x282fd
testl %eax, %eax
je 0x28316
leaq 0x2c1e8(%rip), %rsi     # 0x54499
movq %r14, %rdi
callq 0x18b20
testl %eax, %eax
je 0x2832b
cmpb $0x0, (%r14)
je 0x28350
callq 0x19a20
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
divss 0x2bfab(%rip), %xmm0    # 0x54288
movss 0x2d11f(%rip), %xmm1    # 0x55404
xorl %esi, %esi
ucomiss %xmm0, %xmm1
setbe %sil
incl %esi
jmp 0x2833e
movl $0x1, 0x1104(%r15)
leaq 0x2d52a(%rip), %rsi     # 0x5582e
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x18c40
movl $0x1, %esi
cmpl $0x1, 0x1100(%r15)
je 0x281ed
jmp 0x2833e
movl $0x2, %esi
cmpl $0x2, 0x1100(%r15)
je 0x281ed
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x18980
movl 0x1100(%r15), %ecx
cmpl $0x1, %ecx
je 0x2836a
cmpl $0x2, %ecx
jne 0x28373
leaq 0x2d4f6(%rip), %r14     # 0x5585e
jmp 0x28390
leaq 0x2d4c9(%rip), %r14     # 0x5583a
jmp 0x28390
leaq 0x2cb8b(%rip), %r14     # 0x54f05
leaq 0x2d502(%rip), %rdx     # 0x55883
movq %r14, %rdi
movl $0x8, %esi
xorl %eax, %eax
callq 0x18e10
movl $0x2, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x18da0
leaq 0x2d4f8(%rip), %rdx     # 0x5589f
movl $0x2, %esi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x18da0