// File: lotuskip[P]yuxtapa/server/game.cpp
// Function: Game::player_action(std::_List_iterator<Player>, Axn)
void Game::player_action(const list<Player>::iterator pit, const Axn action)
{
	// A spectator is outside of the rules logic, but can only move:
	if(pit->team == T_SPEC)
	{
		// Wants to move and is a "free spectator":
		if(action.xncode == XN_MOVE && pit->viewn_vp == pit->own_vp)
			pit->own_vp->move(e_Dir(action.var1));
		// Wants to switch followed player:
		else if(action.xncode == XN_FOLLOW_SWITCH)
		{
			list<Player>::const_iterator fit = pit->viewn_vp->get_owner();
			// follow next nonspectator (but allow following self)
			do {
				if(++fit == cur_players.end())
					fit = cur_players.begin();
			} while(!fit->is_alive() && fit != pit);
			follow_change(pit, fit);
		}
		else if(action.xncode == XN_FOLLOW_PREV)
		{
			list<Player>::const_iterator fit = pit->viewn_vp->get_owner();
			// follow prev nonspectator (but allow following self)
			do {
				if(fit == cur_players.begin())
					fit = cur_players.end();
				--fit;
			} while(!fit->is_alive() && fit != pit);
			follow_change(pit, fit);
		}
		return;
	}
	// Not spectator:
	if(pit->is_alive())
	{
		// Planewalkers' mind's eye movement is not restricted by timing:
		if(pit->cl == C_PLANEWALKER && pit->limiter && action.xncode == XN_MOVE)
		{
			pit->own_vp->move(e_Dir(action.var1));
			return;
		}
		// Everything else:
		if(action.xncode == XN_FOLLOW_SWITCH || action.xncode == XN_FOLLOW_PREV)
		{
			// these codes makes no sense when alive; resend class info
			send_full_state_refresh(pit);
			return;
		}
		// If this players hasn't acted this turn, we process this new action
		// immediately and empty the queue. Otherwise, we just push it to
		// the back of the queue.
		if(!pit->acted_this_turn && !pit->wait_turns)
		{
			pit->doing_a_chore = 0; // any chore is aborted
			validate_and_process(action, pit);
			pit->action_queue.clear();
		}
		else
			pit->action_queue.push_back(action);
		// Note that the possibility of the queue being full has already been
		// checked in network.cpp
	}
	else // player is dead
	{
		if(action.xncode == XN_FOLLOW_SWITCH)
		{
			list<Player>::const_iterator fit = pit->viewn_vp->get_owner();
			// follow next alive teammate or self:
			do {
				if(++fit == cur_players.end())
					fit = cur_players.begin();
			} while(fit != pit && (!fit->is_alive() || fit->team != pit->team));
			follow_change(pit, fit);
		}
		else if(action.xncode == XN_FOLLOW_PREV)
		{
			list<Player>::const_iterator fit = pit->viewn_vp->get_owner();
			// follow prev alive teammate or self:
			do {
				if(fit == cur_players.begin())
					fit = cur_players.end();
				--fit;
			} while(fit != pit && (!fit->is_alive() || fit->team != pit->team));
			follow_change(pit, fit);
		}
		else // client apparently thinks it's alive:
			send_full_state_refresh(pit);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x8(%rbp)
movw %si, %ax
movw %ax, -0xb(%rbp)
shrl $0x10, %esi
movb %sil, %al
movb %al, -0x9(%rbp)
leaq -0x8(%rbp), %rdi
callq 0x1b050
cmpl $0x2, 0xac(%rax)
jne 0x3ab53
movzbl -0xb(%rbp), %eax
cmpl $0x4, %eax
jne 0x3a94f
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq 0xc8(%rax), %rax
movq %rax, -0x130(%rbp)
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq %rax, %rcx
movq -0x130(%rbp), %rax
cmpq 0xc0(%rcx), %rax
jne 0x3a94f
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq 0xc0(%rax), %rdi
movsbl -0xa(%rbp), %esi
callq 0x42640
jmp 0x3ab4e
movzbl -0xb(%rbp), %eax
cmpl $0x10, %eax
jne 0x3aa4f
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq 0xc8(%rax), %rdi
callq 0x3d580
movq %rax, -0x18(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x250a0
movq %rax, -0x138(%rbp)
leaq 0x558a4(%rip), %rdi     # 0x90230
callq 0x189f0
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x18a20
movq -0x138(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x3d5a0
testb $0x1, %al
jne 0x3a9b8
jmp 0x3a9dd
leaq 0x55871(%rip), %rdi     # 0x90230
callq 0x1b360
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x18a20
movq -0x30(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x3a9df
leaq -0x18(%rbp), %rdi
callq 0x24f40
movq %rax, %rdi
callq 0x21cd0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x139(%rbp)
jne 0x3aa1f
leaq -0x40(%rbp), %rdi
leaq -0x8(%rbp), %rsi
callq 0x18a20
leaq -0x18(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x24f10
movb %al, -0x139(%rbp)
movb -0x139(%rbp), %al
testb $0x1, %al
jne 0x3a975
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x3afb0
jmp 0x3ab4c
movzbl -0xb(%rbp), %eax
cmpl $0x11, %eax
jne 0x3ab4a
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq 0xc8(%rax), %rdi
callq 0x3d580
movq %rax, -0x58(%rbp)
leaq 0x557b4(%rip), %rdi     # 0x90230
callq 0x1b360
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x18a20
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3d5a0
testb $0x1, %al
jne 0x3aaa5
jmp 0x3aaca
leaq 0x55784(%rip), %rdi     # 0x90230
callq 0x189f0
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x18a20
movq -0x70(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x3d5d0
leaq -0x58(%rbp), %rdi
callq 0x24f40
movq %rax, %rdi
callq 0x21cd0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x13a(%rbp)
jne 0x3ab13
leaq -0x80(%rbp), %rdi
leaq -0x8(%rbp), %rsi
callq 0x18a20
leaq -0x58(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x24f10
movb %al, -0x13a(%rbp)
movb -0x13a(%rbp), %al
testb $0x1, %al
jne 0x3aa75
movq -0x8(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x3afb0
jmp 0x3ab4c
jmp 0x3ab4e
jmp 0x3af9b
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
callq 0x21cd0
testb $0x1, %al
jne 0x3ab6d
jmp 0x3ac70
leaq -0x8(%rbp), %rdi
callq 0x1b050
cmpl $0xa, 0xb0(%rax)
jne 0x3abb8
leaq -0x8(%rbp), %rdi
callq 0x1b050
cmpb $0x0, 0x130(%rax)
je 0x3abb8
movzbl -0xb(%rbp), %eax
cmpl $0x4, %eax
jne 0x3abb8
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq 0xc0(%rax), %rdi
movsbl -0xa(%rbp), %esi
callq 0x42640
jmp 0x3af9b
movzbl -0xb(%rbp), %eax
cmpl $0x10, %eax
je 0x3abca
movzbl -0xb(%rbp), %eax
cmpl $0x11, %eax
jne 0x3abe6
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
callq 0x36720
jmp 0x3af9b
leaq -0x8(%rbp), %rdi
callq 0x1b050
testb $0x1, 0x128(%rax)
jne 0x3ac4f
leaq -0x8(%rbp), %rdi
callq 0x1b050
cmpb $0x0, 0x131(%rax)
jne 0x3ac4f
leaq -0x8(%rbp), %rdi
callq 0x1b050
movb $0x0, 0x132(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rsi
leaq -0xb(%rbp), %rdi
callq 0x3a690
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
addq $0xd8, %rdi
callq 0x3d5f0
jmp 0x3ac6b
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
addq $0xd8, %rdi
leaq -0xb(%rbp), %rsi
callq 0x3d630
jmp 0x3af9b
movzbl -0xb(%rbp), %eax
cmpl $0x10, %eax
jne 0x3adfe
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq 0xc8(%rax), %rdi
callq 0x3d580
movq %rax, -0xa8(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x250a0
movq %rax, -0x148(%rbp)
leaq 0x5557d(%rip), %rdi     # 0x90230
callq 0x189f0
movq %rax, -0xb8(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x18a20
movq -0x148(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3d5a0
testb $0x1, %al
jne 0x3aceb
jmp 0x3ad1f
leaq 0x5553e(%rip), %rdi     # 0x90230
callq 0x1b360
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x18a20
movq -0xc0(%rbp), %rax
movq %rax, -0xa8(%rbp)
jmp 0x3ad21
leaq -0xd0(%rbp), %rdi
leaq -0x8(%rbp), %rsi
callq 0x18a20
leaq -0xa8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x24f10
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x149(%rbp)
jne 0x3ad55
jmp 0x3adbf
leaq -0xa8(%rbp), %rdi
callq 0x24f40
movq %rax, %rdi
callq 0x21cd0
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x14a(%rbp)
jne 0x3ad7a
jmp 0x3adb3
leaq -0xa8(%rbp), %rdi
callq 0x24f40
movl 0xac(%rax), %eax
movl %eax, -0x150(%rbp)
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq %rax, %rcx
movl -0x150(%rbp), %eax
cmpl 0xac(%rcx), %eax
setne %al
movb %al, -0x14a(%rbp)
movb -0x14a(%rbp), %al
movb %al, -0x149(%rbp)
movb -0x149(%rbp), %al
testb $0x1, %al
jne 0x3ac99
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
callq 0x3afb0
jmp 0x3af99
movzbl -0xb(%rbp), %eax
cmpl $0x11, %eax
jne 0x3af80
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq 0xc8(%rax), %rdi
callq 0x3d580
movq %rax, -0xe8(%rbp)
leaq 0x55402(%rip), %rdi     # 0x90230
callq 0x1b360
movq %rax, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x18a20
leaq -0xe8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x3d5a0
testb $0x1, %al
jne 0x3ae66
jmp 0x3ae9a
leaq 0x553c3(%rip), %rdi     # 0x90230
callq 0x189f0
movq %rax, -0x108(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x18a20
movq -0x100(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x3d5d0
leaq -0x110(%rbp), %rdi
leaq -0x8(%rbp), %rsi
callq 0x18a20
leaq -0xe8(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x24f10
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x151(%rbp)
jne 0x3aeda
jmp 0x3af44
leaq -0xe8(%rbp), %rdi
callq 0x24f40
movq %rax, %rdi
callq 0x21cd0
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x152(%rbp)
jne 0x3aeff
jmp 0x3af38
leaq -0xe8(%rbp), %rdi
callq 0x24f40
movl 0xac(%rax), %eax
movl %eax, -0x158(%rbp)
leaq -0x8(%rbp), %rdi
callq 0x1b050
movq %rax, %rcx
movl -0x158(%rbp), %eax
cmpl 0xac(%rcx), %eax
setne %al
movb %al, -0x152(%rbp)
movb -0x152(%rbp), %al
movb %al, -0x151(%rbp)
movb -0x151(%rbp), %al
testb $0x1, %al
jne 0x3ae27
movq -0x8(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x118(%rbp), %rdi
movq -0x120(%rbp), %rsi
callq 0x3afb0
jmp 0x3af97
movq -0x8(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rdi
callq 0x36720
jmp 0x3af99
jmp 0x3af9b
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopw %cs:(%rax,%rax)