// File: Unreality3D[P]Unreality3D/indie-studio/source/MapGenerator/MapGenerator.cpp
// Function: Map::generate_map()
void				Map::generate_map()
{
  std::ofstream			debug;
  Leaf				_root = Leaf(Size(0, 0), Size(map_size.x, map_size.y));
  std::vector<Rooms>		tmpRooms;

  if (_seed != -1)
    srand(_seed);
  else
    srand(time(NULL));
  debug.open("map.txt");
  _leafs.push_back(_root);
  split();
  for(size_t i = 0; i < _leafs.size();i++)
    _leafs[i].create_rooms(tmpRooms, room_max_size);
  for (int i = 0; i < room_nbr;i++)
    _rooms.push_back(tmpRooms[rand() % tmpRooms.size()]);
  for(size_t i = 0; i < _leafs.size();i++)
    {
      delete(_leafs[i].leftChild);
      delete(_leafs[i].rightChild);
    }
  blank_map();
  draw_rooms();
  draw_better_walls();
  draw_hallways();
  draw_hallways_walls();
  draw_angles();
  add_misc();
  draw_rooms_pattern();
  draw_in_out();
  for (size_t i = 0; i < _map.size() ; i++)
    debug << _map[i] << std::endl;
  debug.close();
}

// Assembly:
subq $0x2d8, %rsp            # imm = 0x2D8
movq %rdi, 0x2d0(%rsp)
movq 0x2d0(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x6970
leaq 0xa8(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x6990
jmp 0x6ddc
movq 0x48(%rsp), %rax
movl 0x4(%rax), %esi
movl 0x8(%rax), %edx
leaq 0x94(%rsp), %rdi
callq 0x6990
jmp 0x6df6
movq 0xa8(%rsp), %rsi
movq 0x94(%rsp), %rdx
leaq 0xb0(%rsp), %rdi
callq 0x6210
jmp 0x6e15
leaq 0x78(%rsp), %rdi
callq 0x6150
movq 0x48(%rsp), %rax
cmpl $-0x1, 0x1c(%rax)
je 0x6e52
movq 0x48(%rsp), %rax
movl 0x1c(%rax), %edi
callq 0x6560
jmp 0x6e62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0x7191
xorl %eax, %eax
movl %eax, %edi
callq 0x6520
movl %eax, %edi
callq 0x6560
leaq 0x6197(%rip), %rsi      # 0xd000
leaq 0xd0(%rsp), %rdi
movl $0x10, %edx
callq 0x6030
jmp 0x6e7d
movq 0x48(%rsp), %rdi
addq $0x28, %rdi
leaq 0xb0(%rsp), %rsi
callq 0x6ab0
jmp 0x6e95
movq 0x48(%rsp), %rdi
callq 0x6900
jmp 0x6ea1
movq $0x0, 0x70(%rsp)
movq 0x48(%rsp), %rdi
movq 0x70(%rsp), %rax
movq %rax, 0x40(%rsp)
addq $0x28, %rdi
callq 0x6600
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq %rcx, %rax
jae 0x6f46
movq 0x48(%rsp), %rdi
addq $0x28, %rdi
movq 0x70(%rsp), %rsi
callq 0x6710
movq %rax, %rdi
movq 0x48(%rsp), %rax
movq 0xc(%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rdx
leaq 0x78(%rsp), %rsi
callq 0x69a0
jmp 0x6f04
jmp 0x6f06
movq 0x70(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x70(%rsp)
jmp 0x6eaa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x63a0
leaq 0xb0(%rsp), %rdi
callq 0x6ac0
jmp 0x7191
movl $0x0, 0x64(%rsp)
movq 0x48(%rsp), %rcx
movl 0x64(%rsp), %eax
cmpl (%rcx), %eax
jge 0x6fbc
movq 0x48(%rsp), %rax
addq $0x40, %rax
movq %rax, 0x38(%rsp)
callq 0x60f0
cltq
movq %rax, 0x30(%rsp)
leaq 0x78(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x6360
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movq 0x30(%rsp), %rax
xorl %edx, %edx
divq %rcx
movq %rdx, %rsi
callq 0x6a30
movq 0x38(%rsp), %rdi
movq %rax, %rsi
callq 0x67e0
jmp 0x6fad
jmp 0x6faf
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x6f4e
movq $0x0, 0x58(%rsp)
movq 0x48(%rsp), %rdi
movq 0x58(%rsp), %rax
movq %rax, 0x20(%rsp)
addq $0x28, %rdi
callq 0x6600
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0x706f
movq 0x48(%rsp), %rdi
addq $0x28, %rdi
movq 0x58(%rsp), %rsi
callq 0x6710
movq 0x10(%rax), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x7024
movq 0x18(%rsp), %rdi
callq 0x6ac0
movq 0x18(%rsp), %rdi
callq 0x6530
movq 0x48(%rsp), %rdi
addq $0x28, %rdi
movq 0x58(%rsp), %rsi
callq 0x6710
movq 0x18(%rax), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
je 0x705a
movq 0x10(%rsp), %rdi
callq 0x6ac0
movq 0x10(%rsp), %rdi
callq 0x6530
jmp 0x705c
movq 0x58(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x58(%rsp)
jmp 0x6fc5
movq 0x48(%rsp), %rdi
callq 0x69f0
jmp 0x707b
movq 0x48(%rsp), %rdi
callq 0x6450
jmp 0x7087
movq 0x48(%rsp), %rdi
callq 0x6b00
jmp 0x7093
movq 0x48(%rsp), %rdi
callq 0x6500
jmp 0x709f
movq 0x48(%rsp), %rdi
callq 0x6320
jmp 0x70ab
movq 0x48(%rsp), %rdi
callq 0x6250
jmp 0x70b7
movq 0x48(%rsp), %rdi
callq 0x6200
jmp 0x70c3
movq 0x48(%rsp), %rdi
callq 0x6620
jmp 0x70cf
movq 0x48(%rsp), %rdi
callq 0x63f0
jmp 0x70db
movq $0x0, 0x50(%rsp)
movq 0x48(%rsp), %rdi
movq 0x50(%rsp), %rax
movq %rax, 0x8(%rsp)
addq $0x58, %rdi
callq 0x6a70
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jae 0x7156
movq 0x48(%rsp), %rdi
addq $0x58, %rdi
movq 0x50(%rsp), %rsi
callq 0x6a90
movq %rax, %rsi
leaq 0xd0(%rsp), %rdi
callq 0x64d0
movq %rax, (%rsp)
jmp 0x7132
movq (%rsp), %rdi
movq 0x8e93(%rip), %rsi      # 0xffd0
callq 0x65d0
jmp 0x7144
jmp 0x7146
movq 0x50(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x50(%rsp)
jmp 0x70e4
leaq 0xd0(%rsp), %rdi
callq 0x6770
jmp 0x7165
leaq 0x78(%rsp), %rdi
callq 0x63a0
leaq 0xb0(%rsp), %rdi
callq 0x6ac0
leaq 0xd0(%rsp), %rdi
callq 0x67b0
addq $0x2d8, %rsp            # imm = 0x2D8
retq
leaq 0xd0(%rsp), %rdi
callq 0x67b0
movq 0xa0(%rsp), %rdi
callq 0x6a10
nopl (%rax,%rax)