// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %r14d
movl %esi, %r15d
movq %rdi, %rbx
leal -0x1(%r15), %eax
leaq 0x10a23(%rip), %rcx     # 0x31160
movsbl (%rax,%rcx), %edx
leaq 0x10a1e(%rip), %rcx     # 0x31166
movsbl (%rax,%rcx), %ecx
movzbl %r14b, %r8d
leaq -0x40(%rbp), %rdi
movq %rbx, %rsi
callq 0x21fa8
movl $0x20, %edi
callq 0x43e0
movl %r15d, %ecx
leaq (%rcx,%rcx,2), %rcx
leaq 0x2564c(%rip), %rdx     # 0x45dc0
leaq (%rdx,%rcx,8), %r12
leaq 0x1f451(%rip), %rcx     # 0x3fbd0
addq $0x10, %rcx
movq %rcx, 0x10(%rax)
leaq -0x40(%rbp), %r13
movl 0x8(%r13), %ecx
movl 0xb(%r13), %edx
movl %ecx, 0x18(%rax)
movl %edx, 0x1b(%rax)
leaq 0x1f468(%rip), %rcx     # 0x3fc08
addq $0x10, %rcx
movq %rcx, 0x10(%rax)
movb 0xf(%r13), %cl
movb %cl, 0x1f(%rax)
movq %rax, %rdi
movq %r12, %rsi
callq 0x4060
incq 0x10(%r12)
movq %r13, %rdi
callq 0x21f6c
leaq 0x2449a(%rip), %r12     # 0x44c68
movq (%r12), %rax
movswq 0x2(%rbx), %rcx
movq 0x8(%rax), %rdx
leaq (%rcx,%rcx,2), %rcx
movswq (%rbx), %rax
movq (%rdx,%rcx,8), %rcx
cmpb $0x2e, 0x2(%rcx,%rax,4)
je 0x207f5
movl $0x1c2e0005, (%rcx,%rax,4) # imm = 0x1C2E0005
orb $0x20, (%rcx,%rax,4)
cmpl $0x5, %r15d
jne 0x20a1a
movq %rbx, -0x50(%rbp)
cmpw $0x3, %r14w
je 0x20853
movq 0x2562b(%rip), %r15     # 0x45e40
movzwl %r14w, %eax
leaq 0x1094c(%rip), %rcx     # 0x3116c
movb (%rax,%rcx), %cl
movb %cl, 0x1d(%r15)
leaq (%rax,%rax,2), %rax
leaq 0x256ce(%rip), %rcx     # 0x45f00
leaq (%rcx,%rax,8), %r14
movl $0x18, %edi
callq 0x43e0
movq %r15, 0x10(%rax)
movq %rax, %rdi
movq %r14, %rsi
callq 0x4060
incq 0x10(%r14)
leaq -0x40(%rbp), %rax
movl $0x0, (%rax)
xorl %r13d, %r13d
movq (%r12), %r14
movl -0x40(%rbp), %edx
leaq -0x2c(%rbp), %rbx
movq %rbx, %rdi
movq -0x50(%rbp), %rsi
callq 0x2bc76
movswq -0x2a(%rbp), %rax
movq 0x8(%r14), %rcx
leaq (%rax,%rax,2), %rax
movswq -0x2c(%rbp), %r14
movq %r12, %r15
movq (%rcx,%rax,8), %r12
movq %rbx, %rdi
callq 0x2bbf6
movzwl (%r12,%r14,4), %eax
movq %r15, %r12
andl $0x601, %eax            # imm = 0x601
cmpw $0x1, %ax
setne %al
addb %al, %r13b
leaq -0x40(%rbp), %rdi
callq 0x2bb9c
cmpl $0x0, -0x40(%rbp)
jne 0x20860
cmpb $0x4, %r13b
jl 0x20a1a
leaq -0x40(%rbp), %rax
movl $0x0, (%rax)
leaq -0x2c(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2bbe8
movq (%r12), %rax
movswl (%rax), %r13d
leal -0x1(%r13), %r14d
leaq -0x44(%rbp), %r15
movq -0x50(%rbp), %rbx
movl -0x40(%rbp), %edx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2bc76
movl -0x44(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq %r15, %rdi
callq 0x2bbf6
movswl -0x2c(%rbp), %eax
cmpl $0x2, %eax
setge %dl
movzwl -0x2a(%rbp), %ecx
cmpw $0x2, %cx
setge %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x20963
movzwl %cx, %ecx
cmpl %eax, %r14d
setg %dl
cmpl %ecx, %r14d
setg %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x20963
movq (%r12), %rdx
movl %ecx, %ecx
movq 0x8(%rdx), %rdx
leaq (%rcx,%rcx,2), %rcx
movq (%rdx,%rcx,8), %rcx
movzwl %ax, %eax
movl $0x1c2e0005, (%rcx,%rax,4) # imm = 0x1C2E0005
leaq -0x40(%rbp), %rdi
callq 0x2bb9c
cmpl $0x0, -0x40(%rbp)
jne 0x208f3
movzwl 0x2(%rbx), %eax
cmpw $0x4, %ax
movl $0x3, %ecx
cmovll %ecx, %eax
addl $-0x2, %eax
addl $-0x2, %r13d
movw %ax, -0x2a(%rbp)
movzwl %ax, %eax
movswl 0x2(%rbx), %ecx
addl $0x2, %ecx
cmpl %r13d, %ecx
cmovgel %r13d, %ecx
cmpl %eax, %ecx
jl 0x20a11
leaq -0x2c(%rbp), %r14
movswl (%rbx), %eax
cmpw $0x4, %ax
movl $0x3, %ecx
cmovgel %eax, %ecx
addl $-0x2, %ecx
movw %cx, -0x2c(%rbp)
movzwl %cx, %ecx
addl $0x2, %eax
cmpl %r13d, %eax
cmovgel %r13d, %eax
cmpl %ecx, %eax
jl 0x209f4
movq (%r12), %rdi
movq %r14, %rsi
callq 0x16f22
movl -0x2c(%rbp), %eax
incl %eax
movw %ax, -0x2c(%rbp)
cwtl
movswl (%rbx), %ecx
addl $0x2, %ecx
cmpl %r13d, %ecx
cmovgel %r13d, %ecx
cmpl %eax, %ecx
jge 0x209cd
movzwl -0x2a(%rbp), %eax
incl %eax
movw %ax, -0x2a(%rbp)
cwtl
movswl 0x2(%rbx), %ecx
addl $0x2, %ecx
cmpl %r13d, %ecx
cmovgel %r13d, %ecx
cmpl %eax, %ecx
jge 0x209a6
leaq -0x2c(%rbp), %rdi
callq 0x2bbf6
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x21f6c
jmp 0x20a47
jmp 0x20a3b
jmp 0x20a3b
movq %rax, %rbx
leaq -0x2c(%rbp), %rdi
callq 0x2bbf6
movq %rbx, %rdi
callq 0x4750