// File: lotuskip[P]yuxtapa/server/game.cpp
// Function: (anonymous namespace)::spawn_team(e_Team)
bool spawn_team(const e_Team t)
{
	// If there are no flags, this means the other team has won!
	if(team_flags[t].empty())
		return true;

	// Do the check for boulder destruction:
	if(gamemode == GM_DESTR && t == T_PURPLE)
	{
		unsigned short obl = boulders_left;
		upd_num_boulders();
		if(!boulders_left)
		{
			team_flags[T_PURPLE].clear();
			return true; // Green has won!
		}
		if(obl != boulders_left) // amount changed!
			Game::send_team_upds(cur_players.end());
	}

	list<list<NOccEnt>::iterator>::const_iterator fit
		= --(team_flags[t].end());
	char spawned = 0;

	nearby_set_dim(Game::curmap->get_size());
	Coords c = (*fit)->getpos();
	init_nearby(c);

	for(list<Player>::iterator it = cur_players.begin();
		it != cur_players.end(); ++it)
	{
		// Player is to spawn if she is in this team and dead:
		if(it->team == t && !it->is_alive())
		{
			// Spawn this player around 'c';
			// For spawning, must be unoccupied & walkthru
			while(Game::curmap->get_tile(c).flags
				& (TF_OCCUPIED|TF_KILLS|TF_DROWNS)
				|| !(Game::curmap->get_tile(c).flags & TF_WALKTHRU))
				c = next_nearby();
			Game::curmap->mod_tile(c)->flags |= TF_OCCUPIED;
			PCs.push_back(PCEnt(c, it));
			it->own_pc = &(*(--PCs.end()));
			it->own_vp->set_pos(c);
			it->sector = Game::curmap->coords_in_sector(c);
			follow_change(it, it);

			it->action_queue.clear();
			it->set_class();
			it->own_vp->set_losr(it->cl_props.losr);
			it->init_torch();
			send_state_upd(it);

			// After placing 9 players, place the next 9 at the next spawn
			// place, if any:
			if(++spawned == 9)
			{
				if(fit == team_flags[t].begin())
					fit = --(team_flags[t].end());
				else
					--fit;
				c = (*fit)->getpos();
				init_nearby(c);
				spawned = 0;
			}
			else
				c = next_nearby();
		} // player in this team and dead
	} // go through players
	return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movl %edi, -0x8(%rbp)
movl -0x8(%rbp), %eax
leaq 0x59508(%rip), %rdi     # 0x93070
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x3d7b0
testb $0x1, %al
jne 0x39b7a
jmp 0x39b83
movb $0x1, -0x1(%rbp)
jmp 0x3a0e1
cmpl $0x3, 0x5780a(%rip)     # 0x91394
jne 0x39bfc
cmpl $0x1, -0x8(%rbp)
jne 0x39bfc
movw 0x58a67(%rip), %ax      # 0x92600
movw %ax, -0xa(%rbp)
callq 0x37e00
cmpw $0x0, 0x58a56(%rip)     # 0x92600
jne 0x39bc5
leaq 0x594bd(%rip), %rdi     # 0x93070
addq $0x18, %rdi
callq 0x3dc50
movb $0x1, -0x1(%rbp)
jmp 0x3a0e1
movzwl -0xa(%rbp), %eax
movzwl 0x58a30(%rip), %ecx     # 0x92600
cmpl %ecx, %eax
je 0x39bfa
leaq 0x56655(%rip), %rdi     # 0x90230
callq 0x189f0
movq %rax, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x18a20
movq -0x18(%rbp), %rdi
callq 0x36ce0
jmp 0x39bfc
movl -0x8(%rbp), %eax
leaq (%rax,%rax,2), %rcx
leaq 0x59466(%rip), %rax     # 0x93070
leaq (%rax,%rcx,8), %rdi
callq 0x3d900
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3d930
movq %rax, %rsi
leaq -0x28(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x3dc80
movb $0x0, -0x31(%rbp)
movq 0x5819a(%rip), %rdi     # 0x91dd8
callq 0x3c930
movswl %ax, %edi
callq 0x4ebd0
movq -0xf0(%rbp), %rdi
callq 0x3dca0
movq %rax, %rdi
callq 0x3cdf0
movq %rax, %rsi
leaq -0x38(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x1b190
movq -0xe8(%rbp), %rdi
callq 0x4ebf0
jmp 0x39c80
leaq 0x565a9(%rip), %rdi     # 0x90230
callq 0x1b360
movq %rax, -0x50(%rbp)
leaq 0x56599(%rip), %rdi     # 0x90230
callq 0x189f0
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x1b100
testb $0x1, %al
jne 0x39cb6
jmp 0x3a0c7
leaq -0x50(%rbp), %rdi
callq 0x1b050
movl 0xac(%rax), %eax
cmpl -0x8(%rbp), %eax
jne 0x3a0b7
leaq -0x50(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
callq 0x21cd0
movb %al, -0xf1(%rbp)
jmp 0x39ce7
movb -0xf1(%rbp), %al
testb $0x1, %al
jne 0x3a0b7
jmp 0x39cf7
jmp 0x39cf9
movq 0x580d8(%rip), %rdi     # 0x91dd8
leaq -0x38(%rbp), %rsi
callq 0x3dcd0
movl %eax, -0xf8(%rbp)
jmp 0x39d11
movl -0xf8(%rbp), %eax
movl %eax, -0x5c(%rbp)
movzwl -0x5c(%rbp), %ecx
andl $0x640, %ecx            # imm = 0x640
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0xf9(%rbp)
jne 0x39d67
movq 0x580a0(%rip), %rdi     # 0x91dd8
leaq -0x38(%rbp), %rsi
callq 0x3dcd0
movl %eax, -0x100(%rbp)
jmp 0x39d49
movl -0x100(%rbp), %eax
movl %eax, -0x60(%rbp)
movzwl -0x60(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0xf9(%rbp)
movb -0xf9(%rbp), %al
testb $0x1, %al
jne 0x39d73
jmp 0x39da3
leaq -0x64(%rbp), %rdi
callq 0x4ec30
jmp 0x39d7e
movl -0x64(%rbp), %eax
movl %eax, -0x38(%rbp)
leaq -0x64(%rbp), %rdi
callq 0x60460
jmp 0x39cf9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3a0d6
movq 0x5802e(%rip), %rdi     # 0x91dd8
leaq -0x38(%rbp), %rsi
callq 0x3d2d0
movq %rax, -0x108(%rbp)
jmp 0x39dbc
movq -0x108(%rbp), %rax
movb (%rax), %cl
orb $0x40, %cl
movb %cl, (%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdx
leaq -0x90(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4d9d0
jmp 0x39dee
leaq 0x5925b(%rip), %rdi     # 0x93050
leaq -0x90(%rbp), %rsi
callq 0x3dd20
jmp 0x39e03
leaq -0x90(%rbp), %rdi
callq 0x3dd60
leaq 0x5923a(%rip), %rdi     # 0x93050
callq 0x3d010
movq %rax, -0xa0(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3dd80
movq %rax, %rdi
callq 0x3dda0
movq %rax, -0x118(%rbp)
leaq -0x50(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x1b050
movq -0x118(%rbp), %rcx
movq -0x110(%rbp), %rdi
movq %rcx, 0x138(%rax)
callq 0x1b050
movq 0xc0(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x426b0
jmp 0x39e79
movq 0x57f58(%rip), %rdi     # 0x91dd8
leaq -0x38(%rbp), %rsi
callq 0x2c120
movl %eax, -0x11c(%rbp)
jmp 0x39e91
leaq -0x50(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x1b050
movl -0x11c(%rbp), %ecx
movq -0x128(%rbp), %rsi
movl %ecx, 0x15c(%rax)
movq -0x50(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x18a20
movq -0xa8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x3afb0
jmp 0x39ee0
leaq -0x50(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x1b050
movq %rax, %rdi
addq $0xd8, %rdi
callq 0x3d5f0
movq -0x130(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
callq 0x21d10
jmp 0x39f15
leaq -0x50(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x1b050
movq -0x140(%rbp), %rdi
movq 0xc0(%rax), %rax
movq %rax, -0x138(%rbp)
callq 0x1b050
movq -0x138(%rbp), %rdi
movsbl 0x14a(%rax), %esi
callq 0x3d970
jmp 0x39f54
leaq -0x50(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
callq 0x21d90
jmp 0x39f67
movq -0x50(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x3a720
jmp 0x39f80
movb -0x31(%rbp), %al
addb $0x1, %al
movb %al, -0x31(%rbp)
movsbl %al, %eax
cmpl $0x9, %eax
jne 0x3a092
movl -0x8(%rbp), %eax
leaq 0x590d2(%rip), %rdi     # 0x93070
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x3ddf0
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x3dc80
leaq -0x28(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3ddc0
testb $0x1, %al
jne 0x39fda
jmp 0x3a03c
movl -0x8(%rbp), %eax
leaq 0x5908c(%rip), %rdi     # 0x93070
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x3d900
movq %rax, -0xd8(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x3d930
movq %rax, %rsi
leaq -0xd0(%rbp), %rdi
callq 0x3dc80
movq -0xd0(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x3a045
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x3dd60
jmp 0x3a0d6
leaq -0x28(%rbp), %rdi
callq 0x3de20
leaq -0x28(%rbp), %rdi
callq 0x3dca0
movq %rax, %rdi
callq 0x3cdf0
movq %rax, %rsi
leaq -0xdc(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x1b190
movq -0x148(%rbp), %rdi
movl -0xdc(%rbp), %eax
movl %eax, -0x38(%rbp)
callq 0x60460
leaq -0x38(%rbp), %rdi
callq 0x4ebf0
jmp 0x3a08c
movb $0x0, -0x31(%rbp)
jmp 0x3a0b5
leaq -0xe0(%rbp), %rdi
callq 0x4ec30
jmp 0x3a0a0
movl -0xe0(%rbp), %eax
movl %eax, -0x38(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x60460
jmp 0x3a0b7
jmp 0x3a0b9
leaq -0x50(%rbp), %rdi
callq 0x1b3c0
jmp 0x39c90
movb $0x0, -0x1(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x60460
jmp 0x3a0e1
leaq -0x38(%rbp), %rdi
callq 0x60460
jmp 0x3a0ef
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x5920
nopl (%rax,%rax)