// File: lotuskip[P]yuxtapa/server/chores.cpp
// Function: process_swaps()
void process_swaps()
{
	for(list<Player>::iterator it = cur_players.begin();
		it != cur_players.end(); ++it)
	{
		if(it->is_alive() && it->wants_to_move_to != MAX_D)
		{
			Coords tarpos = it->own_pc->getpos().in(it->wants_to_move_to);
			if(Game::curmap->get_tile(tarpos).flags & TF_OCCUPIED)
			{
				// Check if there is teammate willing to swap:
				list<PCEnt>::iterator pc_it = any_pc_at(tarpos);
				if(pc_it != PCs.end())
				{
					list<Player>::iterator pp = pc_it->get_owner();
					if(pp->team == it->team
						&& (pp->wants_to_move_to == !(it->wants_to_move_to)
						|| pp->turns_without_axn >= IDLE_TURNS_TO_AUTOSWAP))
						swap_places(pp, it);
				}
			}
			else // not occupied; can move there!
			{
				move_player_to(it, tarpos, true);
				it->wants_to_move_to = MAX_D;
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
leaq 0x3b5be(%rip), %rdi     # 0x90230
callq 0x1b360
movq %rax, -0x8(%rbp)
leaq 0x3b5ae(%rip), %rdi     # 0x90230
callq 0x189f0
movq %rax, -0x10(%rbp)
leaq -0x8(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x1b100
testb $0x1, %al
jne 0x54ca1
jmp 0x54ec7
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
callq 0x21cd0
testb $0x1, %al
jne 0x54cbb
jmp 0x54eb7
leaq -0x8(%rbp), %rdi
callq 0x1b050
cmpl $0x8, 0x12c(%rax)
je 0x54eb7
leaq -0x8(%rbp), %rdi
movq %rdi, -0x68(%rbp)
callq 0x1b050
movq 0x138(%rax), %rsi
leaq -0x18(%rbp), %rdi
movq %rdi, -0x60(%rbp)
callq 0x1b190
movq -0x68(%rbp), %rdi
callq 0x1b050
movq -0x60(%rbp), %rsi
movl 0x12c(%rax), %edx
leaq -0x14(%rbp), %rdi
callq 0x60550
jmp 0x54d10
leaq -0x18(%rbp), %rdi
callq 0x60460
leaq 0x3d0b8(%rip), %rax     # 0x91dd8
movq (%rax), %rdi
leaq -0x14(%rbp), %rsi
callq 0x3dcd0
movl %eax, -0x6c(%rbp)
jmp 0x54d31
movl -0x6c(%rbp), %eax
movl %eax, -0x28(%rbp)
movzwl -0x28(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x54e7f
leaq -0x14(%rbp), %rdi
callq 0x49290
movq %rax, -0x78(%rbp)
jmp 0x54d56
movq -0x78(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq 0x3e2eb(%rip), %rdi     # 0x93050
callq 0x3d010
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3cfe0
testb $0x1, %al
jne 0x54d84
jmp 0x54e7d
leaq -0x30(%rbp), %rdi
callq 0x3d040
movq %rax, %rdi
callq 0x3d0f0
movq %rax, -0x80(%rbp)
jmp 0x54d9b
movq -0x80(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x1b050
movl 0xac(%rax), %eax
movl %eax, -0x84(%rbp)
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq %rax, %rcx
movl -0x84(%rbp), %eax
cmpl 0xac(%rcx), %eax
jne 0x54e7b
leaq -0x40(%rbp), %rdi
callq 0x1b050
movl 0x12c(%rax), %eax
movl %eax, -0x8c(%rbp)
leaq -0x8(%rbp), %rdi
callq 0x1b050
movl 0x12c(%rax), %edi
callq 0x60410
movl %eax, -0x88(%rbp)
jmp 0x54e07
movl -0x8c(%rbp), %eax
movl -0x88(%rbp), %ecx
cmpl %ecx, %eax
je 0x54e2c
leaq -0x40(%rbp), %rdi
callq 0x1b050
movzwl 0x12a(%rax), %eax
cmpl $0x8, %eax
jl 0x54e7b
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x54ee0
jmp 0x54e4b
jmp 0x54e7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x60460
jmp 0x54ed0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x14(%rbp), %rdi
callq 0x60460
jmp 0x54ed0
jmp 0x54e7d
jmp 0x54eae
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
leaq -0x14(%rbp), %rsi
movl $0x1, %edx
callq 0x53890
jmp 0x54e9b
leaq -0x8(%rbp), %rdi
callq 0x1b050
movl $0x8, 0x12c(%rax)
leaq -0x14(%rbp), %rdi
callq 0x60460
jmp 0x54eb9
leaq -0x8(%rbp), %rdi
callq 0x1b3c0
jmp 0x54c7b
addq $0x90, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x5920
nopl (%rax)