// File: /workspace/github_cpp_makefile_star2_O1/Jacobious52[P]Tanks/Terrain.cpp
// Function: Terrain::_init()
void Terrain::_init()
{
    _size = ConsoleTools::get_terminal_size();
    _position = Point<int>::zero();

    shuffle_wind_speed();

    // create a array of terrain heights at every x pos
    int *height_map = new int[get_size().x];
    _gen_terrain(0, get_size().x, height_map);

    // fill in the map with sprites for every x pos
    for (int i = 0; i < get_size().x; ++i)
    {
        for (int h = get_size().y - height_map[i]; h < get_size().y; ++h)
        {
            Sprite *tile = new Sprite(" ");
            tile->set_position(Point<int>(i, h));
            if (h == get_size().y - 1)
            {
                tile->set_bcolor(ConsoleTools::white);
                tile->tag = TERRAIN_ROCK;
                tile->set_texture(" ");
            }
            else
            {
                tile->set_bcolor(ConsoleTools::green);
                tile->tag = TERRAIN_DIRT;
            }
            add_child(tile);
        }
    }

    delete[] height_map;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
callq 0x395e
movq %rax, 0x20(%rbx)
movq $0x0, 0x18(%rbx)
callq 0x30d0
cvtsi2ss %eax, %xmm0
mulss 0x490e(%rip), %xmm0     # 0xc1f8
movaps %xmm0, -0x40(%rbp)
callq 0x30d0
testb $0x1, %al
je 0x78fd
movaps -0x40(%rbp), %xmm0
jmp 0x7908
movaps -0x40(%rbp), %xmm0
xorps 0x48f8(%rip), %xmm0     # 0xc200
movss %xmm0, 0x34(%rbx)
movq %rbx, %rdi
callq 0x9a56
shlq $0x20, %rax
movq %rax, %rcx
sarq $0x1e, %rcx
testq %rax, %rax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x3030
movq %rax, %r14
movq %rbx, %rdi
callq 0x9a56
movq %rbx, %rdi
xorl %esi, %esi
movl %eax, %edx
movq %r14, -0x40(%rbp)
movq %r14, %rcx
callq 0x7b4a
movq %rbx, %rdi
callq 0x9a56
testl %eax, %eax
jle 0x7aaf
xorl %r12d, %r12d
leaq -0x68(%rbp), %r13
movq %rbx, -0x48(%rbp)
movq %rbx, %rdi
callq 0x9a56
movq %rax, %r14
shrq $0x20, %r14
movq -0x40(%rbp), %rax
subl (%rax,%r12,4), %r14d
movq %rbx, %rdi
callq 0x9a56
shrq $0x20, %rax
cmpl %eax, %r14d
jge 0x7a99
movl $0x60, %edi
callq 0x3270
movq %rax, %r15
leaq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
movq %r13, %rdi
leaq 0x4716(%rip), %rsi      # 0xc0cd
leaq 0x4710(%rip), %rdx      # 0xc0ce
callq 0x5744
movq %r15, %rdi
movq %r13, %rsi
callq 0x4ee6
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x79e0
callq 0x3240
movq %r14, %rsi
shlq $0x20, %rsi
orq %r12, %rsi
movq %r15, %rdi
callq 0x9a4c
movq %rbx, %rdi
callq 0x9a56
shrq $0x20, %rax
decl %eax
cmpl %eax, %r14d
jne 0x7a71
movq %r12, %rbx
movq %r13, %r12
movq %r15, %rdi
movl $0x25, %esi
callq 0x68fe
movl $0xb, 0x8(%r15)
leaq -0x78(%rbp), %r13
movq %r13, -0x88(%rbp)
leaq -0x88(%rbp), %rdi
leaq 0x4694(%rip), %rsi      # 0xc0cd
leaq 0x468e(%rip), %rdx      # 0xc0ce
callq 0x5744
movq %r15, %rdi
leaq -0x88(%rbp), %rsi
callq 0x6936
movq -0x88(%rbp), %rdi
cmpq %r13, %rdi
movq %r12, %r13
movq %rbx, %r12
movq -0x48(%rbp), %rbx
je 0x7a86
callq 0x3240
jmp 0x7a86
movq %r15, %rdi
movl $0x20, %esi
callq 0x68fe
movl $0xa, 0x8(%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x98f2
incl %r14d
jmp 0x7983
incq %r12
movq %rbx, %rdi
callq 0x9a56
cltq
cmpq %rax, %r12
jl 0x796c
movq -0x40(%rbp), %rdi
callq 0x3300
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r13, %rdi
jne 0x7af5
jmp 0x7afa
movq %rax, %rbx
jmp 0x7af2
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x7af2
callq 0x3240
movq %r15, %rdi
callq 0x3240
movq %rbx, %rdi
callq 0x3440