// File: /workspace/github_cpp_makefile_star2_O1/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 0x11daa
leaq -0x50(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x1483d
movq (%r15), %rsi
leaq -0x258(%rbp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x4780
leaq -0x40(%rbp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x176c5
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x43f0
movq -0x258(%rbp), %rax
movq -0x18(%rax), %rcx
testb $0x5, -0x238(%rbp,%rcx)
je 0x176e2
xorl %r14d, %r14d
jmp 0x177a2
movq %r13, -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 0x4790
movq -0x48(%rbp), %rdx
cmpq 0x2c3bc(%rip), %rdx     # 0x43ae0
jne 0x1778a
testq %rdx, %rdx
je 0x1773f
movq 0x2c3a6(%rip), %rsi     # 0x43ad8
movq -0x50(%rbp), %rdi
callq 0x4400
testl %eax, %eax
jne 0x1778a
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 0x4790
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 0x177c7
xorl %r14d, %r14d
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0x177a2
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x43f0
leaq -0x258(%rbp), %rdi
callq 0x40f0
andb $0x1, %r14b
movl %r14d, %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 0x4790
movq -0x50(%rbp), %r14
movq -0x48(%rbp), %r12
leaq 0x2bd4e(%rip), %r13     # 0x43578
xorl %r15d, %r15d
cmpq (%r13), %r12
jne 0x1784b
testq %r12, %r12
je 0x1785a
movq -0x8(%r13), %rsi
movq %r14, %rdi
movq %r12, %rdx
callq 0x4400
testl %eax, %eax
je 0x1785a
decq %r15
addq $0x20, %r13
cmpq $-0x3, %r15
jne 0x1782d
jmp 0x17868
movl %r15d, %eax
negl %eax
movl %eax, 0x4(%rbx)
cmpq $-0x3, %r15
jne 0x17874
xorl %r14d, %r14d
leaq -0x40(%rbp), %r13
jmp 0x1778d
leaq 0x8(%rbx), %rsi
movq %rbx, %rdi
leaq -0x40(%rbp), %r13
callq 0x16696
movq 0x8(%rbx), %r12
cmpq 0x10(%rbx), %r12
sete %r14b
leaq -0x258(%rbp), %r15
je 0x17a17
movq -0x258(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x43d0
movsbl %al, %edx
movq %r15, %rdi
leaq -0x50(%rbp), %rsi
callq 0x4790
movzwl (%rbx), %eax
cmpq %rax, -0x48(%rbp)
jne 0x1778d
movq (%r12), %rax
cmpq 0x8(%r12), %rax
leaq 0x1525f(%rip), %rdi     # 0x2cb40
je 0x179f5
xorl %ecx, %ecx
movswq %cx, %rdx
movq -0x50(%rbp), %rsi
movb (%rsi,%rdx), %sil
movzbl %sil, %edx
cmpl $0x3a, %edx
jle 0x1792a
cmpl $0x5b, %edx
jg 0x1794a
cmpl $0x48, %edx
jg 0x17965
cmpl $0x3b, %edx
je 0x179c5
cmpl $0x48, %edx
jne 0x1778d
movl $0x1a230000, (%rax)     # imm = 0x1A230000
movw $0x1000, (%rax)         # imm = 0x1000
jmp 0x179e4
addl $-0x20, %edx
cmpl $0xe, %edx
ja 0x1778d
movslq (%rdi,%rdx,4), %rdx
addq %rdi, %rdx
jmpq *%rdx
movl $0x1c200205, (%rax)     # imm = 0x1C200205
jmp 0x179e4
cmpl $0x7b, %edx
jg 0x1797b
cmpl $0x5c, %edx
je 0x179cd
cmpl $0x5f, %edx
jne 0x1778d
movl $0x1c2e0005, (%rax)     # imm = 0x1C2E0005
jmp 0x179e4
cmpl $0x49, %edx
je 0x179de
cmpl $0x54, %edx
jne 0x1778d
movl $0x17540005, (%rax)     # imm = 0x17540005
jmp 0x179e4
cmpl $0x7c, %edx
je 0x17991
cmpl $0x7e, %edx
jne 0x1778d
movl $0x1d7e0405, (%rax)     # imm = 0x1D7E0405
jmp 0x179e4
movl $0x1a7c0004, (%rax)     # imm = 0x1A7C0004
movb %sil, 0x2(%rax)
jmp 0x179e4
movl $0x182e0005, (%rax)     # imm = 0x182E0005
jmp 0x179e4
movl $0x17220007, (%rax)     # imm = 0x17220007
jmp 0x179e4
movl $0x1b2b0000, (%rax)     # imm = 0x1B2B0000
jmp 0x179e4
movl $0x192e0005, (%rax)     # imm = 0x192E0005
jmp 0x179e4
movl $0x1a230000, (%rax)     # imm = 0x1A230000
jmp 0x179e4
movl $0x1a3b0007, (%rax)     # imm = 0x1A3B0007
jmp 0x179e4
movl $0x1b2b0000, (%rax)     # imm = 0x1B2B0000
movb %sil, 0x2(%rax)
movw $0x5, (%rax)
jmp 0x179e4
movl $0x1a230001, (%rax)     # imm = 0x1A230001
incl %ecx
addq $0x4, %rax
cmpq 0x8(%r12), %rax
jne 0x178e9
movq -0x258(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x238(%rbp,%rax)
jne 0x1778d
addq $0x18, %r12
jmp 0x17888
movq %rbx, %rdi
callq 0x16e8e
leaq -0x2c(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2bbe8
movw $0x1, -0x2a(%rbp)
cmpw $0x3, (%rbx)
jl 0x17a7b
leaq -0x2c(%rbp), %r15
movw $0x1, -0x2c(%rbp)
cmpw $0x3, (%rbx)
jl 0x17a67
movq %rbx, %rdi
movq %r15, %rsi
callq 0x16f22
movzwl -0x2c(%rbp), %eax
incl %eax
movw %ax, -0x2c(%rbp)
cwtl
movswl (%rbx), %ecx
decl %ecx
cmpl %eax, %ecx
jg 0x17a48
movzwl -0x2a(%rbp), %eax
incl %eax
movw %ax, -0x2a(%rbp)
cwtl
movswl (%rbx), %ecx
decl %ecx
cmpl %eax, %ecx
jg 0x17a3c
leaq -0x2c(%rbp), %rdi
callq 0x2bbf6
jmp 0x1778d
jmp 0x17aad
jmp 0x17aad
jmp 0x17aad
movq %rax, %rbx
leaq -0x40(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17ae3
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x43f0
jmp 0x17ae3
movq %rax, %rbx
jmp 0x17abe
movq %rax, %rbx
leaq -0x2c(%rbp), %rdi
callq 0x2bbf6
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x17ad7
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x43f0
leaq -0x258(%rbp), %rdi
callq 0x40f0
movq %rbx, %rdi
callq 0x4750
nop