// File: lotuskip[P]yuxtapa/server/map.cpp
// Function: Map::LOS_between(Coords const&, Coords const&, char, short)
bool Map::LOS_between(const Coords& c1, const Coords& c2, const char maxrad,
	const short calced_rad)
{
	short r = (calced_rad == -1) ? c2.dist_walk(c1) : calced_rad;
	if(r <= maxrad) // close enough
	{
		// Check if there is a LOS between c1 and c2:
		if(r <= 1)
			return true; // seen, done
		// Construct vector from c1 to c2:
		Coords v(c2.x - c1.x, c2.y - c1.y);
		char line, ind;
		if(v.y == -r) line = v.x + r;
		else if(v.x == r) line = 3*r + v.y;
		else if(v.y == r) line = 5*r - v.x;
		else if(v.x == -r) line = 7*r - v.y;
		else /* v.x == -r */ line = 7*r - v.y;
		for(ind = 0; ind < 2*r; ind += 2)
		{
			if(!(data[loslookup[r-2][line*2*r+ind+1]+c1.y]
				[loslookup[r-2][line*2*r+ind]+c1.x].flags & TF_SEETHRU))
				break;
		}
		if(ind == 2*r) // got all the way!
			return true; // seen, done
		// else, need to check the opposite direction, the line from c2 to c1
		// (but only if the line is one of the unsymmetric ones):
		if(calced_rad == -1 && line%r)
			return LOS_between(c2, c1, maxrad, r);
	}
	return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movw %r8w, %ax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movb %cl, -0x21(%rbp)
movw %ax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movswl -0x24(%rbp), %eax
cmpl $-0x1, %eax
jne 0x2c2f3
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x604f0
movw %ax, -0x4a(%rbp)
jmp 0x2c2fb
movw -0x24(%rbp), %ax
movw %ax, -0x4a(%rbp)
movw -0x4a(%rbp), %ax
movw %ax, -0x26(%rbp)
movswl -0x26(%rbp), %eax
movsbl -0x21(%rbp), %ecx
cmpl %ecx, %eax
jg 0x2c547
movswl -0x26(%rbp), %eax
cmpl $0x1, %eax
jg 0x2c325
movb $0x1, -0x1(%rbp)
jmp 0x2c54b
movq -0x20(%rbp), %rax
movswl (%rax), %eax
movq -0x18(%rbp), %rcx
movswl (%rcx), %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movswl 0x2(%rax), %eax
movq -0x18(%rbp), %rdx
movswl 0x2(%rdx), %edx
subl %edx, %eax
leaq -0x2a(%rbp), %rdi
movswl %cx, %esi
movswl %ax, %edx
callq 0x60430
movswl -0x28(%rbp), %eax
movswl -0x26(%rbp), %edx
xorl %ecx, %ecx
subl %edx, %ecx
cmpl %ecx, %eax
jne 0x2c378
movswl -0x2a(%rbp), %eax
movswl -0x26(%rbp), %ecx
addl %ecx, %eax
movb %al, -0x2b(%rbp)
jmp 0x2c3ec
movswl -0x2a(%rbp), %eax
movswl -0x26(%rbp), %ecx
cmpl %ecx, %eax
jne 0x2c396
movswl -0x26(%rbp), %eax
imull $0x3, %eax, %eax
movswl -0x28(%rbp), %ecx
addl %ecx, %eax
movb %al, -0x2b(%rbp)
jmp 0x2c3ea
movswl -0x28(%rbp), %eax
movswl -0x26(%rbp), %ecx
cmpl %ecx, %eax
jne 0x2c3b4
movswl -0x26(%rbp), %eax
imull $0x5, %eax, %eax
movswl -0x2a(%rbp), %ecx
subl %ecx, %eax
movb %al, -0x2b(%rbp)
jmp 0x2c3e8
movswl -0x2a(%rbp), %eax
movswl -0x26(%rbp), %edx
xorl %ecx, %ecx
subl %edx, %ecx
cmpl %ecx, %eax
jne 0x2c3d6
movswl -0x26(%rbp), %eax
imull $0x7, %eax, %eax
movswl -0x28(%rbp), %ecx
subl %ecx, %eax
movb %al, -0x2b(%rbp)
jmp 0x2c3e6
movswl -0x26(%rbp), %eax
imull $0x7, %eax, %eax
movswl -0x28(%rbp), %ecx
subl %ecx, %eax
movb %al, -0x2b(%rbp)
jmp 0x2c3e8
jmp 0x2c3ea
jmp 0x2c3ec
movb $0x0, -0x2c(%rbp)
movsbl -0x2c(%rbp), %eax
movswl -0x26(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jge 0x2c4af
movq -0x48(%rbp), %rdi
addq $0x8, %rdi
movswl -0x26(%rbp), %eax
subl $0x2, %eax
movslq %eax, %rcx
leaq 0x60565(%rip), %rax     # 0x8c980
movq (%rax,%rcx,8), %rax
movsbl -0x2b(%rbp), %ecx
shll %ecx
movswl -0x26(%rbp), %edx
imull %edx, %ecx
movsbl -0x2c(%rbp), %edx
addl %edx, %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movswl 0x2(%rcx), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x2e6a0
movq %rax, %rdi
movswl -0x26(%rbp), %eax
subl $0x2, %eax
movslq %eax, %rcx
leaq 0x6051e(%rip), %rax     # 0x8c980
movq (%rax,%rcx,8), %rax
movsbl -0x2b(%rbp), %ecx
shll %ecx
movswl -0x26(%rbp), %edx
imull %edx, %ecx
movsbl -0x2c(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movswl (%rcx), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x2e6c0
movzwl (%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x2c49e
jmp 0x2c4af
jmp 0x2c4a0
movsbl -0x2c(%rbp), %eax
addl $0x2, %eax
movb %al, -0x2c(%rbp)
jmp 0x2c3f0
movsbl -0x2c(%rbp), %eax
movswl -0x26(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jne 0x2c4ca
movb $0x1, -0x1(%rbp)
movl $0x1, -0x30(%rbp)
jmp 0x2c531
movswl -0x24(%rbp), %eax
cmpl $-0x1, %eax
jne 0x2c52a
movsbl -0x2b(%rbp), %eax
movswl -0x26(%rbp), %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x2c52a
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
movsbl -0x21(%rbp), %ecx
movswl -0x26(%rbp), %r8d
callq 0x2c2b0
movb %al, -0x4b(%rbp)
jmp 0x2c502
movb -0x4b(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movl $0x1, -0x30(%rbp)
jmp 0x2c531
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x2a(%rbp), %rdi
callq 0x60460
jmp 0x2c556
movl $0x0, -0x30(%rbp)
leaq -0x2a(%rbp), %rdi
callq 0x60460
movl -0x30(%rbp), %eax
testl %eax, %eax
je 0x2c545
jmp 0x2c543
jmp 0x2c54b
jmp 0x2c547
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x5920
nop