// File: /workspace/github_cpp_makefile_star2_O3/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 0x10b76(%rip), %rcx     # 0x31150
movsbl (%rax,%rcx), %edx
leaq 0x10b71(%rip), %rcx     # 0x31156
movsbl (%rax,%rcx), %ecx
movzbl %r14b, %r8d
leaq -0x40(%rbp), %rdi
movq %rbx, %rsi
callq 0x21d38
movl $0x20, %edi
callq 0x43e0
movl %r15d, %ecx
leaq (%rcx,%rcx,2), %rcx
leaq 0x257af(%rip), %rdx     # 0x45dc0
leaq (%rdx,%rcx,8), %r12
leaq -0x40(%rbp), %r13
movl 0x8(%r13), %ecx
movl 0xb(%r13), %edx
movl %edx, 0x1b(%rax)
movl %ecx, 0x18(%rax)
leaq 0x1f58a(%rip), %rcx     # 0x3fbb8
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 0x21cfc
leaq 0x2460c(%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)
jne 0x20685
movzwl (%rcx,%rax,4), %edx
orl $0x20, %edx
jmp 0x20690
movl $0x1c2e0005, (%rcx,%rax,4) # imm = 0x1C2E0005
movw $0x25, %dx
movw %dx, (%rcx,%rax,4)
cmpl $0x5, %r15d
jne 0x208b8
cmpw $0x3, %r14w
je 0x206ea
movq 0x25794(%rip), %r15     # 0x45e40
movzwl %r14w, %eax
leaq 0x10aa5(%rip), %rcx     # 0x3115c
movb (%rax,%rcx), %cl
movb %cl, 0x1d(%r15)
leaq (%rax,%rax,2), %rax
leaq 0x25837(%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 %edx, %edx
xorl %r13d, %r13d
movq (%r12), %r14
leaq -0x2c(%rbp), %rdi
movq %rbx, %rsi
callq 0x2b818
movswq -0x2a(%rbp), %rax
movq 0x8(%r14), %rcx
leaq (%rax,%rax,2), %rax
movswq -0x2c(%rbp), %r14
movq %rbx, %r15
movq %r12, %rbx
movq (%rcx,%rax,8), %r12
leaq -0x2c(%rbp), %rdi
callq 0x2b7a6
movzwl (%r12,%r14,4), %eax
movq %rbx, %r12
movq %r15, %rbx
andl $0x601, %eax            # imm = 0x601
cmpw $0x1, %ax
setne %al
addb %al, %r13b
leaq -0x40(%rbp), %rdi
callq 0x2b74c
movl -0x40(%rbp), %edx
testl %edx, %edx
jne 0x206f9
cmpb $0x4, %r13b
jl 0x208b8
leaq -0x40(%rbp), %r15
movl $0x0, (%r15)
leaq -0x2c(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2b798
movq (%r12), %rax
movswl (%rax), %r13d
leal -0x1(%r13), %r14d
movl (%r15), %edx
leaq -0x44(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2b818
movl -0x44(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq %r15, %rdi
callq 0x2b7a6
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 0x207fa
movzwl %cx, %ecx
cmpl %eax, %r14d
setg %dl
cmpl %ecx, %r14d
setg %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x207fa
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 0x2b74c
movl -0x40(%rbp), %edx
testl %edx, %edx
jne 0x2078d
movswl 0x2(%rbx), %eax
cmpw $0x4, %ax
movl $0x3, %ecx
cmovgel %eax, %ecx
addl $-0x2, %ecx
addl $-0x2, %r13d
movw %cx, -0x2a(%rbp)
movzwl %cx, %edx
movl %eax, %esi
addl $0x2, %esi
cmpl %r13d, %esi
cmovgel %r13d, %esi
cmpl %edx, %esi
jl 0x208af
movzwl (%rbx), %edx
leaq -0x2c(%rbp), %r14
cmpw $0x4, %dx
movl $0x3, %esi
cmovgel %edx, %esi
addl $-0x2, %esi
movw %si, -0x2c(%rbp)
movzwl %si, %esi
movswl %dx, %edi
addl $0x2, %edi
cmpl %r13d, %edi
cmovgel %r13d, %edi
cmpl %esi, %edi
jl 0x20895
movq (%r12), %rdi
movq %r14, %rsi
callq 0x16dfe
movl -0x2c(%rbp), %eax
incl %eax
movw %ax, -0x2c(%rbp)
cwtl
movswl (%rbx), %edx
leal 0x2(%rdx), %ecx
cmpl %r13d, %ecx
cmovgel %r13d, %ecx
cmpl %eax, %ecx
jge 0x20866
movzwl -0x2a(%rbp), %ecx
movzwl 0x2(%rbx), %eax
incl %ecx
movw %cx, -0x2a(%rbp)
movswl %cx, %esi
movswl %ax, %edi
addl $0x2, %edi
cmpl %r13d, %edi
cmovgel %r13d, %edi
cmpl %esi, %edi
jge 0x2083f
leaq -0x2c(%rbp), %rdi
callq 0x2b7a6
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x21cfc
jmp 0x208e5
jmp 0x208d9
jmp 0x208d9
movq %rax, %rbx
leaq -0x2c(%rbp), %rdi
callq 0x2b7a6
movq %rbx, %rdi
callq 0x4740