// File: /workspace/github_cpp_makefile_star2_O3/lotuskip[P]yuxtapa/server/chores.cpp
// Function: (anonymous namespace)::trigger_trap(std::_List_iterator<Player>, std::_List_iterator<Trap>, bool)
bool trigger_trap(const list<Player>::iterator pit, const list<Trap>::iterator tr,
	const bool intentional)
{
	Coords pos = pit->own_pc->getpos();
	switch(tr->get_m())
	{
	case TRAP_WATER:
		// Extinguish torch, make splash sound, possibly rust weapon
		if(pit->own_pc->torch_is_lit())
			pit->own_pc->toggle_torch();
		add_sound(pos, S_SPLASH);
		// Rusting happens only once; to see if it has happened we compare
		// the PCs 2-hit to the 2-hit of that class by default:
		if(pit->cl_props.tohit == classes[pit->cl].tohit
			&& random()%100 < CHANCE_RUST)
		{
			string msg = "Your weapon rusts!";
			Network::construct_msg(msg, C_WATER_TRAP_LIT);
			Network::send_to_player(*pit);
			pit->cl_props.tohit -= RUST_MOD;
			pit->cl_props.dam_add -= RUST_MOD;
			pit->needs_state_upd = true;
		}
		break;
	case TRAP_LIGHT:
		flash_at(pos);
		break;
	case TRAP_TELE:
		if(pit->nomagicres())
		{
			// Get a random tile that's walkable and not occupied:
			Coords tar(1 + random()%(Game::curmap->get_size()-1),
				1 + random()%(Game::curmap->get_size()-1));
			init_nearby(tar);
			unsigned short f = Game::curmap->get_tile(tar).flags;
			while(!(f & TF_WALKTHRU) || (f & TF_OCCUPIED))
				f = Game::curmap->get_tile((tar = next_nearby())).flags;
			event_set.insert(pos); // necessary if 'T'riggering the trap
			move_player_to(pit, tar, true);
			// NOTE: do not clear axn queue like in blinking
			return true; // do not make triggered teleportation traps seen
		}
		else
			add_action_ind(pos, A_MISS);
		break;
	case TRAP_BOOBY:
		if(test_hit(pit, 9, 2, 6, 0) // 2d6+0, +9 tohit
			&& pit->cl_props.hp <= 0)
		{
			string msg = " died to a trap.";
			if(tr->get_owner() != cur_players.end())
			{
				msg = intentional ? " decided to step into " : " failed to notice ";
				if(tr->get_owner() == pit)
					msg += "her own";
				else
				{
					if(tr->get_owner()->team == pit->team)
					{
						msg += teammate_str;
						if(!intentional)
							tr->get_owner()->stats_i->tks++;
					}
					else
						record_kill(tr->get_owner(), WTK_BOOBY);
					msg += tr->get_owner()->nick + "\'s";
				}
				msg += " boobytrap.";
			}
			player_death(pit, msg, true);
		}
		add_sound(pos, S_CREAK);
		// Boobytraps are always destroyed:
		traps.erase(tr);
		Game::curmap->mod_tile(pos)->flags &= ~(TF_TRAP);
		return !pit->is_alive(); // cannot set the destroyed trap as seen!
	case TRAP_FIREB:
		fireball_trigger(pos, pit, intentional);
		if(!pit->is_alive())
			return true;
		break;
	case TRAP_ACID:
		if(test_hit(pit, 7, 3, 3, 0) // 3d3+0, +7 tohit
			&& pit->cl_props.hp <= 0)
			player_death(pit, " dissolved.", true);
		add_sound(pos, S_SPLASH);
		if(!pit->is_alive())
			return true;
		break;
	//default: anything else is an error!
	}
	// If here, trap should be made known:
	tr->set_seen_by(pit->team);
	return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x148(%rdi), %rdi
movl 0x8(%rdi), %eax
movl %eax, -0x2c(%rbp)
movzbl 0x1f(%rsi), %eax
cmpq $0x5, %rax
ja 0x24855
movl %edx, %r12d
leaq 0x10(%rbx), %r15
leaq 0x10c64(%rip), %rcx     # 0x35140
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x1, 0x20(%rdi)
jne 0x244f0
callq 0x21eca
leaq -0x2c(%rbp), %rdi
xorl %esi, %esi
callq 0x209ed
movb 0x154(%rbx), %al
movl 0xc0(%rbx), %ecx
leaq (%rcx,%rcx,2), %rdx
leaq (%rcx,%rdx,4), %rcx
leaq 0x10c7a(%rip), %rdx     # 0x35190
cmpb 0x4(%rdx,%rcx), %al
jne 0x24855
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 $0x40, %rcx
jg 0x24855
leaq -0x40(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x10fd8(%rip), %rsi     # 0x3553f
leaq 0x10fe3(%rip), %rdx     # 0x35551
leaq -0x50(%rbp), %rdi
callq 0xe01c
leaq -0x50(%rbp), %rdi
movl $0x35, %esi
callq 0xf3f0
leaq 0x1cb9c(%rip), %rsi     # 0x41128
movq %r15, %rdi
callq 0xf719
addb $-0x2, 0x154(%rbx)
addb $-0x2, 0x157(%rbx)
movb $0x1, 0x15d(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x24855
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x43f0
jmp 0x24855
movzbl %r12b, %edx
leaq -0x2c(%rbp), %rdi
movq %rbx, %rsi
callq 0x2739a
movq %r15, %rdi
callq 0x12496
jmp 0x2483e
movq %r15, %rdi
callq 0x125fe
testb %al, %al
je 0x24847
callq 0x41d0
leaq 0x20668(%rip), %r15     # 0x44c68
movq (%r15), %rcx
movswq (%rcx), %rcx
decq %rcx
cqto
idivq %rcx
movq %rdx, %r14
incl %r14d
callq 0x41d0
movq (%r15), %rcx
movswq (%rcx), %rcx
decq %rcx
cqto
idivq %rcx
incl %edx
movswl %r14w, %esi
movswl %dx, %edx
leaq -0x50(%rbp), %rdi
callq 0x2b798
leaq -0x50(%rbp), %rdi
callq 0x22925
movq (%r15), %rax
movswq -0x4e(%rbp), %rcx
movq 0x8(%rax), %rax
leaq (%rcx,%rcx,2), %rcx
movswq -0x50(%rbp), %rdx
movq (%rax,%rcx,8), %rax
movl (%rax,%rdx,4), %eax
andl $0x41, %eax
cmpl $0x1, %eax
je 0x246ab
leaq -0x70(%rbp), %r14
movq (%r15), %r12
movq %r14, %rdi
callq 0x2294e
movl -0x70(%rbp), %eax
movl %eax, -0x50(%rbp)
movswq %ax, %rcx
shrl $0x10, %eax
movswq %ax, %rax
movq 0x8(%r12), %rdx
leaq (%rax,%rax,2), %rax
movq (%rdx,%rax,8), %rax
movl (%rax,%rcx,4), %r12d
movq %r14, %rdi
callq 0x2b7a6
andl $0x41, %r12d
cmpl $0x1, %r12d
jne 0x2466c
leaq 0x21926(%rip), %rdi     # 0x45fd8
leaq -0x2c(%rbp), %rsi
callq 0x21934
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x24f2b
leaq -0x50(%rbp), %rdi
callq 0x2b7a6
movb $0x1, %r15b
jmp 0x2486b
movq %rbx, %rdi
movl $0x9, %esi
movl $0x2, %edx
movl $0x6, %ecx
xorl %r8d, %r8d
callq 0x26530
testb %al, %al
je 0x2491d
cmpb $0x0, 0x153(%rbx)
jg 0x2491d
leaq -0x40(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0x10e37(%rip), %rsi     # 0x35552
leaq 0x10e40(%rip), %rdx     # 0x35562
leaq -0x50(%rbp), %rdi
callq 0xe01c
movq 0x28(%r14), %rax
cmpq 0x1b87a(%rip), %rax     # 0x3ffb0
je 0x248f7
leaq 0x10e20(%rip), %rax     # 0x35563
leaq 0x10e30(%rip), %rsi     # 0x3557a
testb %r12b, %r12b
cmovneq %rax, %rsi
leaq -0x50(%rbp), %rdi
callq 0x4580
movq 0x28(%r14), %rdi
cmpq %rbx, %rdi
je 0x24886
movl 0xbc(%rdi), %eax
cmpl 0xbc(%rbx), %eax
jne 0x24898
movq 0x227d8(%rip), %rsi     # 0x46f58
movq 0x227d9(%rip), %rdx     # 0x46f60
leaq -0x50(%rbp), %rdi
callq 0x4130
movq 0x28(%r14), %rsi
testb %r12b, %r12b
jne 0x248a6
movq 0x90(%rsi), %rax
incq 0xa0(%rax)
jmp 0x248a6
leaq -0x2c(%rbp), %rdi
callq 0x24d81
jmp 0x24855
movq %rbx, %rdi
movl $0x7, %esi
movl $0x3, %edx
movl $0x3, %ecx
xorl %r8d, %r8d
callq 0x26530
testb %al, %al
je 0x2482b
cmpb $0x0, 0x153(%rbx)
jg 0x2482b
leaq -0x40(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x10da3(%rip), %rsi     # 0x35598
leaq 0x10da7(%rip), %rdx     # 0x355a3
leaq -0x50(%rbp), %rdi
callq 0xe01c
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x249ec
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x2482b
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x43f0
leaq -0x2c(%rbp), %rdi
xorl %esi, %esi
callq 0x209ed
movq %r15, %rdi
callq 0x12496
movb $0x1, %r15b
testb %al, %al
jne 0x24855
jmp 0x2486b
leaq -0x2c(%rbp), %rdi
movl $0x5, %esi
callq 0x208ed
addq $0x10, %r14
movzbl 0xbc(%rbx), %esi
movq %r14, %rdi
callq 0x21dde
xorl %r15d, %r15d
leaq -0x2c(%rbp), %rdi
callq 0x2b7a6
movl %r15d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10d00(%rip), %rsi     # 0x3558d
leaq -0x50(%rbp), %rdi
callq 0x47b0
jmp 0x248e7
movl $0x4, %esi
callq 0x24c07
movq 0x28(%r14), %rsi
addq $0x98, %rsi
leaq 0x10ce1(%rip), %rdx     # 0x35595
leaq -0x70(%rbp), %rdi
callq 0x27b82
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
leaq -0x50(%rbp), %rdi
callq 0x4130
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x248e7
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x43f0
leaq 0x10c05(%rip), %rsi     # 0x354f3
leaq -0x50(%rbp), %rdi
callq 0x47b0
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x249ec
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0x2491d
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x43f0
leaq -0x2c(%rbp), %rdi
movl $0x1, %esi
callq 0x209ed
leaq 0x21536(%rip), %rdi     # 0x45e68
movq %r14, %rsi
callq 0x1d762
leaq 0x20327(%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 $0xf7ff, (%rax,%rdx,4)  # imm = 0xF7FF
movq %r15, %rdi
callq 0x12496
movl %eax, %r15d
xorb $0x1, %r15b
jmp 0x2486b
movq %rax, %rbx
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x249b1
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x43f0
jmp 0x249b1
jmp 0x249ae
jmp 0x2499c
jmp 0x249d8
jmp 0x249d8
jmp 0x249d8
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
jne 0x249ba
jmp 0x249db
jmp 0x249ca
jmp 0x249d8
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0x249db
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x43f0
jmp 0x249db
jmp 0x249ca
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x2b7a6
jmp 0x249db
movq %rax, %rbx
leaq -0x2c(%rbp), %rdi
callq 0x2b7a6
movq %rbx, %rdi
callq 0x4740