// File: /workspace/github_cpp_makefile_star2_O1/lotuskip[P]yuxtapa/server/chores.cpp
// Function: (anonymous namespace)::move_player_to(std::_List_iterator<Player>, Coords const&, bool)
void move_player_to(const list<Player>::iterator p, const Coords &c,
	const bool do_flags)
{
	Coords opos = p->own_pc->getpos();
	// must move both the PC entity and the viewpoint:
	p->own_pc->setpos(c);
	p->own_vp->set_pos(c);
	if(p == pl_with_item)
		add_action_ind(c, A_TRAP);
	else // add_action inserts to event_set
		event_set.insert(c);

	// Check if ended up in some special tile: (note that some of
	// these are checked only when *walking* into them, but in
	// this function we don't know the "method of arrival")
	Tile* tile = Game::curmap->mod_tile(c);
	if(tile->flags & TF_KILLS) // chasm
	{
		if(p->warned_of_chasm == Config::int_settings[Config::IS_SAFE_CHASMS])
		{
			player_death(p, " fell into oblivion.", false);
			add_voice(c, "Aieeeee...!");	
			Game::curmap->mod_tile(opos)->flags &= ~(TF_OCCUPIED);
		}
		else
		{
			p->warned_of_chasm++;
			string msg = "You almost fall into a chasm!";
			Network::construct_msg(msg, C_WALL_LIT);
			Network::send_to_player(*p);
			// revert original coords:
			p->own_pc->setpos(opos);
			p->own_vp->set_pos(opos);
		}
		return; // either died or did not move
	}

	if(tile->flags & TF_TRAP)
	{
		list<Trap>::iterator tr_it = any_trap_at(c);
		// A trap is triggered always if not seen and sometimes if it's dark:
		if(!tr_it->is_seen_by(p->team) || p->own_vp->is_blind()
			|| (!(tile->flags & TF_LIT) && random()%100 < 15 && !is_dynlit(c)))
		{
			if(trigger_trap(p, tr_it, false))
			{
				// if returned true, PC died or teleported
				Game::curmap->mod_tile(opos)->flags &= ~(TF_OCCUPIED);
				return;
			}
		}
	}
	
	// If we made it here, the PC survived the checks.
	if(tile->flags & TF_DROWNS) // water slows down
	{
		p->wait_turns += 2;
		if(p->cl != C_ASSASSIN && p->cl != C_SCOUT)
			add_sound(c, S_SPLASH);
	}
	else if((tile->flags & TF_SLOWWALK) // slow non-trappers/scouts
		&& p->cl != C_TRAPPER && p->cl != C_SCOUT)
		p->wait_turns++;
	
	// The occupied flags don't need to be changed when switching places:
	if(do_flags)
	{
		Game::curmap->mod_tile(opos)->flags &= ~(TF_OCCUPIED);
		Game::curmap->mod_tile(c)->flags |= TF_OCCUPIED;
	}
	
	// Check if moved to another sector:
	e_Dir newsector = Game::curmap->coords_in_sector(c);
	if(p->sector != newsector)
	{
		p->sector = newsector;
		p->needs_state_upd = true;
	}

	// Whenever a PC moves, we check if they spot some hiding enemies.
	// The requirement for this is that this PC is facing directly at a hiding
	// enemy, whose position is lit, at a distance of 2.
	opos = c.in(p->facing).in(p->facing); // reusing opos
	list<PCEnt>::iterator pc_it = any_pc_at(opos);
	if(pc_it != PCs.end() && !pc_it->isvoid() && !pc_it->visible_to_team(p->team)
		&& ((Game::curmap->get_tile(opos).flags & TF_LIT) || is_dynlit(opos)))
		pc_it->set_invis_to_team(T_NO_TEAM); // seen!

	// Also, whenever a PC moves, we check if they are seen by enemy scouts:
	if(p->own_pc->visible_to_team(opp_team[p->team]))
	{
		Coords thc; // "their coords"
		char d = classes[C_SCOUT].losr;
		if(!(Game::curmap->get_tile(c).flags & TF_LIT))
			d = (d+5)/3; // not lit, shorter radius
		for(list<Player>::const_iterator pit = cur_players.begin();
			pit != cur_players.end(); ++pit)
		{
			// Search for opponent scouts who are alive...
			if(pit->team != p->team && pit->cl == C_SCOUT && pit->is_alive()
				&& Game::curmap->LOS_between(c, pit->own_pc->getpos(), d))
			{
				p->own_pc->set_seen_by_team(pit->team);
				return; // done
			}
		} // loop through current players
	}
	// If we end up here, was not seen by enemy scouts:
	p->own_pc->set_seen_by_team(T_NO_TEAM);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
movq 0x148(%rdi), %rax
movl 0x8(%rax), %ecx
movl %ecx, -0x2c(%rbp)
movl (%rsi), %ecx
movl %ecx, 0x8(%rax)
movq 0xd0(%rdi), %rdi
callq 0x1ecfc
leaq 0x20e28(%rip), %rax     # 0x46008
cmpq %rbx, (%rax)
je 0x251f6
leaq 0x20dec(%rip), %rdi     # 0x45fd8
movq %r14, %rsi
callq 0x21b9c
jmp 0x25203
movq %r14, %rdi
movl $0x1, %esi
callq 0x20a4f
movl %r15d, -0x34(%rbp)
leaq 0x1fa5a(%rip), %rax     # 0x44c68
movq (%rax), %rax
movswq 0x2(%r14), %rcx
movq 0x8(%rax), %rax
leaq (%rcx,%rcx,2), %rcx
movswq (%r14), %r13
movq (%rax,%rcx,8), %r15
movzwl (%r15,%r13,4), %eax
btl $0x9, %eax
jb 0x252c3
btl $0xb, %eax
jae 0x25285
movq %r14, %rdi
callq 0x21528
movq %rax, %r12
leaq 0x10(%rax), %rdi
movzbl 0xbc(%rbx), %esi
callq 0x22060
movq %r12, -0x60(%rbp)
testb %al, %al
je 0x2526f
movq 0xd0(%rbx), %rax
cmpb $0x0, 0x20(%rax)
je 0x2566a
movq %rbx, %rdi
movq -0x60(%rbp), %rsi
xorl %edx, %edx
callq 0x246f7
testb %al, %al
jne 0x25357
movzwl (%r15,%r13,4), %eax
btl $0xa, %eax
jb 0x25400
testb $0x2, %al
movl -0x34(%rbp), %r12d
je 0x25425
movl 0xc0(%rbx), %eax
cmpl $0x4, %eax
je 0x25425
cmpl $0x9, %eax
je 0x25425
incb 0x141(%rbx)
jmp 0x25425
movzbl 0x172(%rbx), %eax
leaq 0x1d5cf(%rip), %rcx     # 0x428a0
cmpl %eax, 0x28(%rcx)
jne 0x25381
leaq -0x48(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x1035c(%rip), %rsi     # 0x35645
leaq 0x10369(%rip), %rdx     # 0x35659
leaq -0x58(%rbp), %rdi
callq 0xdfec
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x24c43
movq -0x58(%rbp), %rdi
cmpq %r15, %rdi
je 0x2531c
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x43f0
leaq -0x58(%rbp), %rdi
movq %r15, (%rdi)
leaq 0x10330(%rip), %rsi     # 0x3565a
leaq 0x10334(%rip), %rdx     # 0x35665
callq 0xdfec
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x20ba5
movq -0x58(%rbp), %rdi
cmpq %r15, %rdi
je 0x25357
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x43f0
leaq 0x1f90a(%rip), %rax     # 0x44c68
movq (%rax), %rax
movswq -0x2a(%rbp), %rcx
movq 0x8(%rax), %rax
leaq (%rcx,%rcx,2), %rcx
movswq -0x2c(%rbp), %rdx
movq (%rax,%rcx,8), %rax
andw $-0x41, (%rax,%rdx,4)
jmp 0x25652
incb %al
movb %al, 0x172(%rbx)
leaq -0x48(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x102ce(%rip), %rsi     # 0x35666
leaq 0x102e4(%rip), %rdx     # 0x35683
leaq -0x58(%rbp), %rdi
callq 0xdfec
leaq -0x58(%rbp), %rdi
movl $0x2e, %esi
callq 0xf4ed
leaq 0x10(%rbx), %rdi
leaq 0x1bd67(%rip), %rsi     # 0x41128
callq 0xf816
movq 0x148(%rbx), %rax
leaq -0x2c(%rbp), %rsi
movl (%rsi), %ecx
movl %ecx, 0x8(%rax)
movq 0xd0(%rbx), %rdi
callq 0x1ecfc
movq -0x58(%rbp), %rdi
cmpq %r14, %rdi
je 0x25652
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x43f0
jmp 0x25652
addb $0x2, 0x141(%rbx)
movl 0xc0(%rbx), %eax
cmpl $0x1, %eax
movl -0x34(%rbp), %r12d
je 0x25425
cmpl $0x4, %eax
je 0x25425
movq %r14, %rdi
xorl %esi, %esi
callq 0x20b4f
testb %r12b, %r12b
je 0x25465
leaq 0x1f837(%rip), %rax     # 0x44c68
movq (%rax), %rax
movswq -0x2a(%rbp), %rcx
movq 0x8(%rax), %rax
leaq (%rcx,%rcx,2), %rcx
movswq -0x2c(%rbp), %rdx
movq (%rax,%rcx,8), %rcx
andw $-0x41, (%rcx,%rdx,4)
movswq 0x2(%r14), %rcx
leaq (%rcx,%rcx,2), %rcx
movswq (%r14), %rdx
movq (%rax,%rcx,8), %rax
orw $0x40, (%rax,%rdx,4)
leaq 0x1f7fc(%rip), %rax     # 0x44c68
movq (%rax), %rdi
movq %r14, %rsi
callq 0x17406
cmpl %eax, 0x16c(%rbx)
je 0x2548c
movl %eax, 0x16c(%rbx)
movb $0x1, 0x15d(%rbx)
movl 0x168(%rbx), %edx
leaq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x2bc76
movl 0x168(%rbx), %edx
leaq -0x58(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2bc76
leaq -0x58(%rbp), %rdi
movl (%rdi), %eax
leaq -0x2c(%rbp), %r15
movl %eax, (%r15)
callq 0x2bbf6
leaq -0x30(%rbp), %rdi
callq 0x2bbf6
movq %r15, %rdi
callq 0x21415
movq %rax, %r15
cmpq 0x1aad2(%rip), %rax     # 0x3ffb0
je 0x2552e
cmpb $0x0, 0x1e(%r15)
jne 0x2552e
movl 0x28(%r15), %eax
cmpl 0xbc(%rbx), %eax
jne 0x2552e
leaq 0x1f76e(%rip), %rax     # 0x44c68
movq (%rax), %rax
movswq -0x2a(%rbp), %rcx
movq 0x8(%rax), %rax
leaq (%rcx,%rcx,2), %rcx
movswq -0x2c(%rbp), %rdx
movq (%rax,%rcx,8), %rax
testb $0x10, (%rax,%rdx,4)
jne 0x25526
leaq -0x2c(%rbp), %rdi
callq 0x21230
testb %al, %al
je 0x2552e
movl $0x3, 0x28(%r15)
movq 0x148(%rbx), %rax
movl 0xbc(%rbx), %ecx
leaq 0xfcee(%rip), %rdx      # 0x35230
movl 0x18(%rax), %eax
cmpl (%rdx,%rcx,4), %eax
je 0x25644
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2bbe8
leaq 0x1f706(%rip), %rax     # 0x44c68
movq (%rax), %rax
movswq 0x2(%r14), %rcx
movq 0x8(%rax), %rax
leaq (%rcx,%rcx,2), %rcx
movswq (%r14), %rdx
movq (%rax,%rcx,8), %rax
xorl %ecx, %ecx
testb $0x10, (%rax,%rdx,4)
setne %cl
leal (%rcx,%rcx,4), %eax
addl $0x5, %eax
leaq 0x1db30(%rip), %r15     # 0x430c0
movzbl %al, %eax
movl %eax, -0x34(%rbp)
movq %r15, %r12
movq (%r12), %r12
cmpq %r15, %r12
je 0x2563b
movl 0xbc(%r12), %eax
cmpl 0xbc(%rbx), %eax
je 0x25603
cmpl $0x4, 0xc0(%r12)
jne 0x25603
leaq 0x10(%r12), %rdi
callq 0x125e6
testb %al, %al
je 0x25603
leaq 0x1f692(%rip), %rax     # 0x44c68
movq (%rax), %rdi
movq 0x148(%r12), %rax
movl 0x8(%rax), %eax
movl %eax, -0x30(%rbp)
movq %r14, %rsi
leaq -0x30(%rbp), %rdx
movl -0x34(%rbp), %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x174a8
movl %eax, %r13d
movb $0x1, %al
jmp 0x25608
xorl %eax, %eax
xorl %r13d, %r13d
testb %al, %al
je 0x25615
leaq -0x30(%rbp), %rdi
callq 0x2bbf6
testb %r13b, %r13b
je 0x25599
movq 0x148(%rbx), %rax
movl 0xbc(%r12), %ecx
movl %ecx, 0x1c(%rax)
leaq -0x58(%rbp), %rdi
callq 0x2bbf6
jmp 0x25652
leaq -0x58(%rbp), %rdi
callq 0x2bbf6
movq 0x148(%rbx), %rax
movl $0x3, 0x1c(%rax)
leaq -0x2c(%rbp), %rdi
callq 0x2bbf6
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb $0x10, (%r15,%r13,4)
jne 0x25285
callq 0x41d0
movq %rax, %rcx
movabsq $-0x5c28f5c28f5c28f5, %rdx # imm = 0xA3D70A3D70A3D70B
imulq %rdx
addq %rcx, %rdx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x6, %rdx
addq %rax, %rdx
imulq $0x64, %rdx, %rax
subq %rax, %rcx
cmpq $0xe, %rcx
jg 0x25285
movq %r14, %rdi
callq 0x21230
testb %al, %al
je 0x2526f
jmp 0x25285
jmp 0x25724
jmp 0x25724
jmp 0x25724
jmp 0x256cb
jmp 0x25724
movq %rax, %rbx
movq -0x58(%rbp), %rdi
cmpq %r15, %rdi
jne 0x25708
jmp 0x25727
jmp 0x25724
jmp 0x25724
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x2bbf6
jmp 0x25719
jmp 0x25724
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
jmp 0x2571d
jmp 0x25724
jmp 0x25724
jmp 0x25724
movq %rax, %rbx
movq -0x58(%rbp), %rdi
cmpq %r14, %rdi
je 0x25727
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x43f0
jmp 0x25727
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x2bbf6
jmp 0x25727
movq %rax, %rbx
leaq -0x2c(%rbp), %rdi
callq 0x2bbf6
movq %rbx, %rdi
callq 0x4750