// File: lotuskip[P]yuxtapa/server/map.cpp
// Function: Map::save_to_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) const
bool Map::save_to_file(const std::string &mapname) const
{
	ofstream file((Config::get_mapdir() + mapname).c_str());
	if(!file)
		return false;
	// else:
	file << mapfile_begin_string << endl;

	time_t rawtime;
	struct tm *timeinfo;
	char buffer[17]; // eg. "01/02/2011 12:13" (and '\0')
	time(&rawtime);
 	timeinfo = localtime(&rawtime);
	strftime(buffer, 17, "%d/%m/%Y %H:%M", timeinfo);
	file << "Saved on: " << buffer << endl;

	file << mapsize << endl;
	// force using "1" for true and "0" for false; can't trust locales:
	if(inhabited)
		file << '1';
	else
		file << '0';
	file << endl;
	file << short_mtype_name[maptype] << endl;

	vector<Tile>::const_iterator i;	
	for(vector< vector<Tile> >::const_iterator it = data.begin(); it != data.end(); ++it)
	{
		for(i = it->begin(); i != it->end(); ++i)
			file << char_from_tile(*i);
		file << endl;
	}
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x2a8(%rbp)
callq 0x1f300
movq %rax, %rsi
movq -0x18(%rbp), %rdx
leaq -0x238(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x24cb0
movq -0x2a0(%rbp), %rdi
callq 0x5200
movq %rax, %rsi
leaq -0x218(%rbp), %rdi
movl $0x10, %edx
callq 0x55a0
jmp 0x2ccbf
leaq -0x238(%rbp), %rdi
callq 0x5a48
movq -0x218(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x218(%rbp,%rax), %rdi
callq 0x5250
movb %al, -0x2a9(%rbp)
jmp 0x2cceb
movb -0x2a9(%rbp), %al
testb $0x1, %al
jne 0x2ccf7
jmp 0x2cd50
movb $0x0, -0x1(%rbp)
movl $0x1, -0x248(%rbp)
jmp 0x2d001
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x5a48
jmp 0x2d01b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x57d0
jmp 0x2d01b
leaq 0x63ef1(%rip), %rsi     # 0x90c48
leaq -0x218(%rbp), %rdi
callq 0x5470
movq %rax, -0x2b8(%rbp)
jmp 0x2cd6c
movq -0x2b8(%rbp), %rdi
movq 0x6022e(%rip), %rsi     # 0x8cfa8
callq 0x5560
jmp 0x2cd81
leaq -0x250(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
callq 0x54c0
movq -0x2c8(%rbp), %rdi
callq 0x5380
movq %rax, -0x258(%rbp)
movq -0x258(%rbp), %rcx
leaq 0x3706f(%rip), %rdx     # 0x63e24
leaq -0x270(%rbp), %rdi
movl $0x11, %esi
callq 0x5400
leaq 0x37066(%rip), %rsi     # 0x63e33
leaq -0x218(%rbp), %rdi
callq 0x5510
movq %rax, -0x2c0(%rbp)
jmp 0x2cde2
movq -0x2c0(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x5510
movq %rax, -0x2d0(%rbp)
jmp 0x2cdfe
movq -0x2d0(%rbp), %rdi
movq 0x6019c(%rip), %rsi     # 0x8cfa8
callq 0x5560
jmp 0x2ce13
movq -0x2a8(%rbp), %rax
movswl (%rax), %esi
leaq -0x218(%rbp), %rdi
callq 0x54b0
movq %rax, -0x2d8(%rbp)
jmp 0x2ce32
movq -0x2d8(%rbp), %rdi
movq 0x60168(%rip), %rsi     # 0x8cfa8
callq 0x5560
jmp 0x2ce47
movq -0x2a8(%rbp), %rax
testb $0x1, 0x2(%rax)
je 0x2ce69
leaq -0x218(%rbp), %rdi
movl $0x31, %esi
callq 0x5600
jmp 0x2ce67
jmp 0x2ce7e
leaq -0x218(%rbp), %rdi
movl $0x30, %esi
callq 0x5600
jmp 0x2ce7c
jmp 0x2ce7e
movq 0x60123(%rip), %rsi     # 0x8cfa8
leaq -0x218(%rbp), %rdi
callq 0x5560
jmp 0x2ce93
movq -0x2a8(%rbp), %rax
movl 0x4(%rax), %eax
shlq $0x5, %rax
leaq 0x63838(%rip), %rsi     # 0x906e0
addq %rax, %rsi
leaq -0x218(%rbp), %rdi
callq 0x5470
movq %rax, -0x2e0(%rbp)
jmp 0x2cec0
movq -0x2e0(%rbp), %rdi
movq 0x600da(%rip), %rsi     # 0x8cfa8
callq 0x5560
jmp 0x2ced5
leaq -0x278(%rbp), %rdi
callq 0x2f190
movq -0x2a8(%rbp), %rdi
addq $0x8, %rdi
callq 0x2f1b0
movq %rax, -0x280(%rbp)
movq -0x2a8(%rbp), %rdi
addq $0x8, %rdi
callq 0x2f220
movq %rax, -0x288(%rbp)
leaq -0x280(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x2f1e0
testb $0x1, %al
jne 0x2cf2b
jmp 0x2cff3
leaq -0x280(%rbp), %rdi
callq 0x2f250
movq %rax, %rdi
callq 0x2f270
movq %rax, -0x290(%rbp)
movq -0x290(%rbp), %rax
movq %rax, -0x278(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x2f250
movq %rax, %rdi
callq 0x2f2e0
movq %rax, -0x298(%rbp)
leaq -0x278(%rbp), %rdi
leaq -0x298(%rbp), %rsi
callq 0x2f2a0
testb $0x1, %al
jne 0x2cf88
jmp 0x2cfcb
leaq -0x278(%rbp), %rdi
callq 0x2f310
movq %rax, %rdi
callq 0x2d030
movb %al, -0x2e1(%rbp)
jmp 0x2cfa4
movb -0x2e1(%rbp), %al
movsbl %al, %esi
leaq -0x218(%rbp), %rdi
callq 0x5600
jmp 0x2cfbb
jmp 0x2cfbd
leaq -0x278(%rbp), %rdi
callq 0x2f330
jmp 0x2cf54
movq 0x5ffd6(%rip), %rsi     # 0x8cfa8
leaq -0x218(%rbp), %rdi
callq 0x5560
jmp 0x2cfe0
jmp 0x2cfe2
leaq -0x280(%rbp), %rdi
callq 0x2f350
jmp 0x2cef8
movb $0x1, -0x1(%rbp)
movl $0x1, -0x248(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x57d0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
movq -0x240(%rbp), %rdi
callq 0x5920
nopw (%rax,%rax)