// File: /workspace/github_cpp_makefile_star2_O3/lotuskip[P]yuxtapa/server/map.cpp
// Function: Map::load_from_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool Map::load_from_file(const string &mapname)
{
	ifstream file((Config::get_mapdir() + mapname).c_str());
	if(!file)
		return false;
	// else:
	string s;
	getline(file, s);
	if(s != mapfile_begin_string)
		return false; // the map is of a different version; can't be certain it will work
	// else:
	getline(file, s); // (skip comment line)
	file >> mapsize;
	if(mapsize < MIN_MAP_SIZE || mapsize > MAX_MAP_SIZE)
		return false; // a corrupt file or something
	// else
	file >> inhabited; // this should work regardless of locale?
	file.seekg(1, ios_base::cur); // skip newline
	getline(file, s);
	char ch;
	for(ch = 0; ch < MAX_MAPTYPE; ++ch)
	{
		if(s == short_mtype_name[ch])
		{
			maptype = e_MapType(ch);
			break;
		}
	}
	if(ch == MAX_MAPTYPE)
		return false; // no recognized maptype found
		
	make_right_size(data);
	vector<Tile>::iterator i;
	short ind;	
	for(rowit it = data.begin(); it != data.end(); ++it)
	{
		getline(file, s);
		if(s.size() != (unsigned short)mapsize)
			return false; // bogus data!
		ind = 0;
		for(i = it->begin(); i != it->end(); ++i)
		{
			if(tile_from_char(s[ind], *i))
				return false; // bogus data
			++ind;
		}
		if(!file)
			return false; // file corrupt or something else wrong
	}

	// Manually edited maps might have something else than undiggable wall on
	// the edges:
	fix_boundary();
	// Update BY_WALLs:
	Coords c;
	c.y = 1;
	while(c.y < mapsize-1)
	{
		c.x = 1;
		while(c.x < mapsize-1)
		{
			upd_by_wall_flag(c);
			c.x++;
		}
		c.y++;
	}
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rsi, %r14
movq %rdi, %rbx
callq 0x11c49
leaq -0x50(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x146ff
movq (%r15), %rsi
leaq -0x258(%rbp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x4770
leaq -0x40(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x17591
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x43f0
movq -0x258(%rbp), %rax
movq -0x18(%rax), %rcx
testb $0x5, -0x238(%rbp,%rcx)
je 0x175ad
xorl %ebx, %ebx
jmp 0x1766c
movq %r15, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movb $0x0, -0x40(%rbp)
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x43d0
movsbl %al, %edx
leaq -0x258(%rbp), %r14
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x4780
movq -0x48(%rbp), %rdx
cmpq 0x2c4f1(%rip), %rdx     # 0x43ae0
jne 0x17655
testq %rdx, %rdx
je 0x1760a
movq 0x2c4db(%rip), %rsi     # 0x43ad8
movq -0x50(%rbp), %rdi
callq 0x4400
testl %eax, %eax
jne 0x17655
movq -0x258(%rbp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x43d0
movsbl %al, %edx
leaq -0x258(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x4780
leaq -0x258(%rbp), %rdi
movq %rbx, %rsi
callq 0x4070
movl $0xfffffe00, %eax       # imm = 0xFFFFFE00
addl (%rbx), %eax
movzwl %ax, %eax
cmpl $0xfe2a, %eax           # imm = 0xFE2A
jae 0x1768c
xorl %ebx, %ebx
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x1766c
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x43f0
leaq -0x258(%rbp), %rdi
callq 0x40f0
movl %ebx, %eax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2(%rbx), %rsi
leaq -0x258(%rbp), %rdi
callq 0x4350
leaq -0x258(%rbp), %r14
movl $0x1, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0x4570
movq -0x258(%rbp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x43d0
movsbl %al, %edx
leaq -0x258(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x4780
movq -0x50(%rbp), %r14
movq -0x48(%rbp), %r15
leaq 0x2be89(%rip), %r12     # 0x43578
xorl %r13d, %r13d
cmpq (%r12), %r15
jne 0x17711
testq %r15, %r15
je 0x17729
movq -0x8(%r12), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x4400
testl %eax, %eax
je 0x17729
incq %r13
addq $0x20, %r12
cmpq $0x3, %r13
jne 0x176f2
xorl %ebx, %ebx
leaq -0x40(%rbp), %r15
jmp 0x17657
movl %r13d, 0x4(%rbx)
leaq 0x8(%rbx), %rsi
movq %rbx, %rdi
callq 0x16582
movq 0x8(%rbx), %r13
cmpq 0x10(%rbx), %r13
je 0x178c0
leaq -0x258(%rbp), %r14
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq -0x50(%rbp), %r12
leaq 0x153e0(%rip), %r15     # 0x2cb40
leaq (%rax,%rbp), %rdi
addq $-0x258, %rdi           # imm = 0xFDA8
movl $0xa, %esi
callq 0x43d0
movsbl %al, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x4780
movzwl (%rbx), %eax
cmpq %rax, -0x48(%rbp)
jne 0x1771e
movq (%r13), %rax
cmpq 0x8(%r13), %rax
je 0x17899
xorl %ecx, %ecx
movswq %cx, %rdx
movq -0x50(%rbp), %rsi
movb (%rsi,%rdx), %sil
movzbl %sil, %edx
cmpl $0x3a, %edx
jle 0x177d8
cmpl $0x5b, %edx
jg 0x177f8
cmpl $0x48, %edx
jg 0x17813
cmpl $0x3b, %edx
je 0x17873
cmpl $0x48, %edx
jne 0x1771e
movl $0x1a231000, (%rax)     # imm = 0x1A231000
jmp 0x17889
addl $-0x20, %edx
cmpl $0xe, %edx
ja 0x1771e
movslq (%r15,%rdx,4), %rdx
addq %r15, %rdx
jmpq *%rdx
movl $0x1c200205, (%rax)     # imm = 0x1C200205
jmp 0x17889
cmpl $0x7b, %edx
jg 0x17829
cmpl $0x5c, %edx
je 0x1787b
cmpl $0x5f, %edx
jne 0x1771e
movl $0x1c2e0005, (%rax)     # imm = 0x1C2E0005
jmp 0x17889
cmpl $0x49, %edx
je 0x17883
cmpl $0x54, %edx
jne 0x1771e
movl $0x17540005, (%rax)     # imm = 0x17540005
jmp 0x17889
cmpl $0x7c, %edx
je 0x1783f
cmpl $0x7e, %edx
jne 0x1771e
movl $0x1d7e0405, (%rax)     # imm = 0x1D7E0405
jmp 0x17889
movl $0x1a7c0004, (%rax)     # imm = 0x1A7C0004
movb %sil, 0x2(%rax)
jmp 0x17889
movl $0x182e0005, (%rax)     # imm = 0x182E0005
jmp 0x17889
movl $0x17220007, (%rax)     # imm = 0x17220007
jmp 0x17889
movl $0x1b2b0000, (%rax)     # imm = 0x1B2B0000
jmp 0x17889
movl $0x192e0005, (%rax)     # imm = 0x192E0005
jmp 0x17889
movl $0x1a230000, (%rax)     # imm = 0x1A230000
jmp 0x17889
movl $0x1a3b0007, (%rax)     # imm = 0x1A3B0007
jmp 0x17889
movl $0x1b5c0005, (%rax)     # imm = 0x1B5C0005
jmp 0x17889
movl $0x1a230001, (%rax)     # imm = 0x1A230001
incl %ecx
addq $0x4, %rax
cmpq 0x8(%r13), %rax
jne 0x1779c
movq -0x258(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x238(%rbp,%rax)
jne 0x1771e
addq $0x18, %r13
cmpq 0x10(%rbx), %r13
jne 0x17760
movq %rbx, %rdi
callq 0x16d6c
leaq -0x2c(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2b798
movw $0x1, -0x2a(%rbp)
movzwl (%rbx), %eax
cmpw $0x3, %ax
leaq -0x40(%rbp), %r15
jl 0x17936
movw $0x1, %cx
leaq -0x2c(%rbp), %r14
movw $0x1, -0x2c(%rbp)
cmpw $0x3, %ax
jl 0x17924
movq %rbx, %rdi
movq %r14, %rsi
callq 0x16dfe
movzwl -0x2c(%rbp), %eax
incl %eax
movw %ax, -0x2c(%rbp)
movswl %ax, %ecx
movswl (%rbx), %eax
leal -0x1(%rax), %edx
cmpl %ecx, %edx
jg 0x178fc
movzwl -0x2a(%rbp), %ecx
jmp 0x17929
movswl %ax, %edx
decl %edx
incl %ecx
movw %cx, -0x2a(%rbp)
movswl %cx, %esi
cmpl %esi, %edx
jg 0x178f0
leaq -0x2c(%rbp), %rdi
callq 0x2b7a6
movb $0x1, %bl
jmp 0x17657
jmp 0x1796a
jmp 0x1796a
jmp 0x1796a
movq %rax, %rbx
leaq -0x40(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x179a0
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x43f0
jmp 0x179a0
movq %rax, %rbx
jmp 0x1797b
movq %rax, %rbx
leaq -0x2c(%rbp), %rdi
callq 0x2b7a6
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x17994
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x43f0
leaq -0x258(%rbp), %rdi
callq 0x40f0
movq %rbx, %rdi
callq 0x4740