// File: lotuskip[P]yuxtapa/server/actives.cpp
// Function: (anonymous namespace)::add_noccent(Coords const&, e_Noccent, short)
void add_noccent(const Coords &c, const e_Noccent type, const short m = 0)
{
	noccents[type].push_back(NOccEnt(c, noccent_symbol[type-1],
		noccent_cpair[type-1], m));
	Tile* tp = Game::curmap->mod_tile(c);
	// A non-occupying entity can be placed in almost any square, but we should
	// ensure that that square won't have "hidden effects":
	if(tp->symbol != '.') // Some "special" tile; replace with ever-safe floor:
		*tp = T_FLOOR;
	tp->flags |= TF_NOCCENT;

	// Special things when placing flags:
	if(type == NOE_FLAG)
	{
		if(m != T_NO_TEAM)
		{
			noccents[NOE_FLAG].back().set_col(team_colour[m]);
			team_flags[m].push_back(--(noccents[NOE_FLAG].end()));
		}
		// The surroundings of a flag should be open enough:
		e_Dir d = D_N;
		char obss = 0; // 'obstructions', unpassable or water or chasm
		do {
			tp = Game::curmap->mod_tile(c.in(d));
			if(!(tp->flags & TF_WALKTHRU) || (tp->flags & (TF_KILLS|TF_DROWNS)))
				++obss;
			++d;
		} while(d != D_N);
		if(obss > 3) // too many!
		{
			// Replace them all with floor:
			d = D_N;
			Coords cn;
			short msize = Game::curmap->get_size();
			do {
				cn = c.in(d);
				// Do not replace outer wall, though:
				if(cn.x > 1 && cn.y > 1 && cn.x < msize-1 && cn.y < msize-1)
					*(Game::curmap->mod_tile(cn)) = T_FLOOR;
				++d;
			} while(d != D_N);
			// Need to update BY_WALL for neighbours of all cns:
			for(cn.y = max(1, c.y-2); cn.y <= min(msize-2, c.y+2); ++cn.y)
			{
				for(cn.x = max(1, c.x-2); cn.x <= min(msize-2, c.x+2); ++cn.x)
					Game::curmap->upd_by_wall_flag(cn);
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movw %dx, %ax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movw %ax, -0xe(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %ecx
movl %ecx, %eax
leaq (%rcx,%rcx,2), %rdx
leaq 0x4b3f5(%rip), %rcx     # 0x92f30
leaq (%rcx,%rdx,8), %rcx
movq %rcx, -0x88(%rbp)
movq -0x8(%rbp), %rsi
decl %eax
cltq
leaq 0x1e783(%rip), %rcx     # 0x662d8
movsbl (%rax,%rcx), %edx
leaq 0x1e77e(%rip), %rcx     # 0x662de
movsbl (%rax,%rcx), %ecx
movzbl -0xe(%rbp), %r8d
leaq -0x20(%rbp), %rdi
movq %rdi, -0x80(%rbp)
callq 0x4d720
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x4bae0
jmp 0x47b88
leaq -0x20(%rbp), %rdi
callq 0x49cd0
leaq 0x4a240(%rip), %rax     # 0x91dd8
movq (%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x3d2d0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x2e, %eax
je 0x47bdd
movq -0x38(%rbp), %rax
movl 0x1e715(%rip), %ecx     # 0x662d4
movl %ecx, (%rax)
jmp 0x47bdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x49cd0
jmp 0x47f0e
movq -0x38(%rbp), %rax
movzwl (%rax), %ecx
orl $0x20, %ecx
movw %cx, (%rax)
cmpl $0x5, -0xc(%rbp)
jne 0x47f05
movswl -0xe(%rbp), %eax
cmpl $0x3, %eax
je 0x47c6b
leaq 0x4b32c(%rip), %rdi     # 0x92f30
addq $0x78, %rdi
callq 0x4bb20
movq %rax, %rdi
movswq -0xe(%rbp), %rcx
leaq 0x1e6c8(%rip), %rax     # 0x662e4
movsbl (%rax,%rcx), %esi
callq 0x49ff0
movswq -0xe(%rbp), %rcx
leaq 0x4b43f(%rip), %rax     # 0x93070
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
leaq 0x4b2ea(%rip), %rdi     # 0x92f30
addq $0x78, %rdi
callq 0x3c9d0
movq %rax, -0x40(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x4bba0
movq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x4bb60
movl $0x0, -0x44(%rbp)
movb $0x0, -0x45(%rbp)
leaq 0x4a15b(%rip), %rax     # 0x91dd8
movq (%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rsi
movl -0x44(%rbp), %edx
leaq -0x4a(%rbp), %rdi
callq 0x60550
movq -0x98(%rbp), %rdi
leaq -0x4a(%rbp), %rsi
callq 0x3d2d0
movq %rax, -0x38(%rbp)
leaq -0x4a(%rbp), %rdi
callq 0x60460
movq -0x38(%rbp), %rax
movzwl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x47cd4
movq -0x38(%rbp), %rax
movzwl (%rax), %eax
andl $0x600, %eax            # imm = 0x600
cmpl $0x0, %eax
je 0x47cdc
movb -0x45(%rbp), %al
addb $0x1, %al
movb %al, -0x45(%rbp)
leaq -0x44(%rbp), %rdi
callq 0x60390
cmpl $0x0, -0x44(%rbp)
jne 0x47c76
movsbl -0x45(%rbp), %eax
cmpl $0x3, %eax
jle 0x47f03
movl $0x0, -0x44(%rbp)
leaq -0x4e(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x60430
leaq 0x4a0c5(%rip), %rax     # 0x91dd8
movq (%rax), %rdi
callq 0x3c930
movw %ax, -0x50(%rbp)
movq -0x8(%rbp), %rsi
movl -0x44(%rbp), %edx
leaq -0x54(%rbp), %rdi
callq 0x60550
jmp 0x47d31
movl -0x54(%rbp), %eax
movl %eax, -0x4e(%rbp)
leaq -0x54(%rbp), %rdi
callq 0x60460
movswl -0x4e(%rbp), %eax
cmpl $0x1, %eax
jle 0x47da7
movswl -0x4c(%rbp), %eax
cmpl $0x1, %eax
jle 0x47da7
movswl -0x4e(%rbp), %eax
movswl -0x50(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x47da7
movswl -0x4c(%rbp), %eax
movswl -0x50(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x47da7
leaq 0x4a061(%rip), %rax     # 0x91dd8
movq (%rax), %rdi
leaq -0x4e(%rbp), %rsi
callq 0x3d2d0
movl 0x1e54b(%rip), %ecx     # 0x662d4
movl %ecx, (%rax)
jmp 0x47da7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x4e(%rbp), %rdi
callq 0x60460
jmp 0x47f0e
leaq -0x44(%rbp), %rdi
callq 0x60390
jmp 0x47db2
jmp 0x47db4
cmpl $0x0, -0x44(%rbp)
jne 0x47d1f
movl $0x1, -0x58(%rbp)
movq -0x8(%rbp), %rax
movswl 0x2(%rax), %eax
addl $-0x2, %eax
movl %eax, -0x5c(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0x2eb30
movq %rax, -0xa0(%rbp)
jmp 0x47de9
movq -0xa0(%rbp), %rax
movl (%rax), %eax
movw %ax, -0x4c(%rbp)
movswl -0x4c(%rbp), %eax
movl %eax, -0xac(%rbp)
movswl -0x50(%rbp), %eax
addl $-0x2, %eax
movl %eax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movswl 0x2(%rax), %eax
addl $0x2, %eax
movl %eax, -0x64(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x64(%rbp), %rsi
callq 0x2eb70
movq %rax, -0xa8(%rbp)
jmp 0x47e2e
movl -0xac(%rbp), %eax
movq -0xa8(%rbp), %rcx
cmpl (%rcx), %eax
jg 0x47efa
movl $0x1, -0x68(%rbp)
movq -0x8(%rbp), %rax
movswl (%rax), %eax
addl $-0x2, %eax
movl %eax, -0x6c(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x6c(%rbp), %rsi
callq 0x2eb30
movq %rax, -0xb8(%rbp)
jmp 0x47e6d
movq -0xb8(%rbp), %rax
movl (%rax), %eax
movw %ax, -0x4e(%rbp)
movswl -0x4e(%rbp), %eax
movl %eax, -0xc4(%rbp)
movswl -0x50(%rbp), %eax
addl $-0x2, %eax
movl %eax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movswl (%rax), %eax
addl $0x2, %eax
movl %eax, -0x74(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x74(%rbp), %rsi
callq 0x2eb70
movq %rax, -0xc0(%rbp)
jmp 0x47eb1
movl -0xc4(%rbp), %eax
movq -0xc0(%rbp), %rcx
cmpl (%rcx), %eax
jg 0x47ee7
leaq 0x49f0f(%rip), %rax     # 0x91dd8
movq (%rax), %rdi
leaq -0x4e(%rbp), %rsi
callq 0x2b890
jmp 0x47ed7
jmp 0x47ed9
movw -0x4e(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x4e(%rbp)
jmp 0x47e7a
jmp 0x47ee9
movw -0x4c(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x4c(%rbp)
jmp 0x47df6
leaq -0x4e(%rbp), %rdi
callq 0x60460
jmp 0x47f05
addq $0xd0, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x5920
nopw (%rax,%rax)