// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlcsg/qcsg.cpp
// Function: GetParamsFromEnt(entity_t*)
void            GetParamsFromEnt(entity_t* mapent)
{
    int     iTmp;
    char    szTmp[256];

    Log("\nCompile Settings detected from info_compile_parameters entity\n");

    // verbose(choices) : "Verbose compile messages" : 0 = [ 0 : "Off" 1 : "On" ]
    iTmp = IntForKey(mapent, "verbose");
    if (iTmp == 1)
    {
        g_verbose = true;
    }
    else if (iTmp == 0)
    {
        g_verbose = false;
    }
    Log("%30s [ %-9s ]\n", "Compile Option", "setting");
    Log("%30s [ %-9s ]\n", "Verbose Compile Messages", g_verbose ? "on" : "off");

    // estimate(choices) :"Estimate Compile Times?" : 0 = [ 0: "Yes" 1: "No" ]
    if (IntForKey(mapent, "estimate")) 
    {
        g_estimate = true;
    }
    else
    {
        g_estimate = false;
    }
    Log("%30s [ %-9s ]\n", "Estimate Compile Times", g_estimate ? "on" : "off");

	// priority(choices) : "Priority Level" : 0 = [	0 : "Normal" 1 : "High"	-1 : "Low" ]
	if (!strcmp(ValueForKey(mapent, "priority"), "1"))
    {
        g_threadpriority = eThreadPriorityHigh;
        Log("%30s [ %-9s ]\n", "Thread Priority", "high");
    }
    else if (!strcmp(ValueForKey(mapent, "priority"), "-1"))
    {
        g_threadpriority = eThreadPriorityLow;
        Log("%30s [ %-9s ]\n", "Thread Priority", "low");
    }

    // texdata(string) : "Texture Data Memory" : "4096"
    iTmp = IntForKey(mapent, "texdata") * 1024;
    if (iTmp > g_max_map_miptex)
    {
        g_max_map_miptex = iTmp;
    }
	sprintf_s(szTmp, "%i", g_max_map_miptex);
    Log("%30s [ %-9s ]\n", "Texture Data Memory", szTmp);

    // hullfile(string) : "Custom Hullfile"
    if (ValueForKey(mapent, "hullfile"))
    {
        g_hullfile = ValueForKey(mapent, "hullfile");
        Log("%30s [ %-9s ]\n", "Custom Hullfile", g_hullfile);
    }

#ifdef HLCSG_AUTOWAD
    // wadautodetect(choices) : "Wad Auto Detect" : 0 =	[ 0 : "Off" 1 : "On" ]
    if (!strcmp(ValueForKey(mapent, "wadautodetect"), "1"))
    { 
        g_bWadAutoDetect = true;
    }
    else
    {
        g_bWadAutoDetect = false;
    }
    Log("%30s [ %-9s ]\n", "Wad Auto Detect", g_bWadAutoDetect ? "on" : "off");
#endif
	
#ifndef HLCSG_WADCFG_NEW
#ifdef HLCSG_WADCFG
	// wadconfig(string) : "Custom Wad Configuration" : ""
    if (strlen(ValueForKey(mapent, "wadconfig")) > 0)
    { 
        safe_strncpy(wadconfigname, ValueForKey(mapent, "wadconfig"), MAX_WAD_CFG_NAME);
        Log("%30s [ %-9s ]\n", "Custom Wad Configuration", wadconfigname);
    }
#endif
#endif
#ifdef HLCSG_WADCFG_NEW
	// wadconfig(string) : "Custom Wad Configuration" : ""
    if (*ValueForKey(mapent, "wadconfig"))
    {
        g_wadconfigname = _strdup (ValueForKey(mapent, "wadconfig"));
        Log("%30s [ %-9s ]\n", "Custom Wad Configuration Name", g_wadconfigname);
    }
	// wadcfgfile(string) : "Custom Wad Configuration File" : ""
    if (*ValueForKey(mapent, "wadcfgfile"))
    {
        g_wadcfgfile = _strdup (ValueForKey(mapent, "wadcfgfile"));
        Log("%30s [ %-9s ]\n", "Custom Wad Configuration File", g_wadcfgfile);
    }
#endif

#ifdef HLCSG_CLIPECONOMY
    // noclipeconomy(choices) : "Strip Uneeded Clipnodes?" : 1 = [ 1 : "Yes" 0 : "No" ]
    iTmp = IntForKey(mapent, "noclipeconomy");
    if (iTmp == 1)
    {
        g_bClipNazi = true;
    }
    else if (iTmp == 0)
    {
        g_bClipNazi = false;
    }        
    Log("%30s [ %-9s ]\n", "Clipnode Economy Mode", g_bClipNazi ? "on" : "off");
#endif

    /*
    hlcsg(choices) : "HLCSG" : 1 =
    [
        1 : "Normal"
        2 : "Onlyents"
        0 : "Off"
    ]
    */
    iTmp = IntForKey(mapent, "hlcsg");
    g_onlyents = false;
    if (iTmp == 2)
    {
        g_onlyents = true;
    }
    else if (iTmp == 0)
    {
        Fatal(assume_TOOL_CANCEL, 
            "%s was set to \"Off\" (0) in info_compile_parameters entity, execution cancelled", g_Program);
        CheckFatal();  
    }
    Log("%30s [ %-9s ]\n", "Onlyents", g_onlyents ? "on" : "off");

    /*
    nocliphull(choices) : "Generate clipping hulls" : 0 =
    [
        0 : "Yes"
        1 : "No"
    ]
    */
    iTmp = IntForKey(mapent, "nocliphull");
    if (iTmp == 1)
    {
        g_noclip = true;
    }
    else 
    {
        g_noclip = false;
    }
    Log("%30s [ %-9s ]\n", "Clipping Hull Generation", g_noclip ? "off" : "on");
#ifdef HLCSG_PRECISIONCLIP
    // cliptype(choices) : "Clip Hull Type" : 4 = [ 0 : "Smallest" 1 : "Normalized" 2: "Simple" 3 : "Precise" 4 : "Legacy" ]
    iTmp = IntForKey(mapent, "cliptype");
	switch(iTmp)
	{
	case 0:
		g_cliptype = clip_smallest;
		break;
	case 1:
		g_cliptype = clip_normalized;
		break;
	case 2:
		g_cliptype = clip_simple;
		break;
	case 3:
		g_cliptype = clip_precise;
		break;
	default:
		g_cliptype = clip_legacy;
		break;
	}
    Log("%30s [ %-9s ]\n", "Clip Hull Type", GetClipTypeString(g_cliptype));
#endif
    /*
    noskyclip(choices) : "No Sky Clip" : 0 =
    [
        1 : "On"
        0 : "Off"
    ]
    */
    iTmp = IntForKey(mapent, "noskyclip");
    if (iTmp == 1)
    {
        g_skyclip = false;
    }
    else 
    {
        g_skyclip = true;
    }
    Log("%30s [ %-9s ]\n", "Sky brush clip generation", g_skyclip ? "on" : "off");

    ///////////////
    Log("\n");
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdi, %rbx
leaq 0xb020(%rip), %rdi      # 0x206e0
xorl %eax, %eax
callq 0x9fb2
leaq 0xb31b(%rip), %rsi      # 0x209e9
movq %rbx, %rdi
callq 0x76cf
cmpl $0x1, %eax
je 0x156e3
testl %eax, %eax
jne 0x156ee
xorl %eax, %eax
jmp 0x156e5
movb $0x1, %al
leaq 0x20a9d88(%rip), %rcx   # 0x20bf474
movb %al, (%rcx)
leaq 0xb02b(%rip), %r15      # 0x20720
leaq 0xb033(%rip), %rsi      # 0x2072f
leaq 0x9670(%rip), %rdx      # 0x1ed73
movq %r15, %rdi
xorl %eax, %eax
callq 0x9fb2
leaq 0x20a9d60(%rip), %rax   # 0x20bf474
leaq 0xb430(%rip), %r12      # 0x20b4b
cmpb $0x0, (%rax)
leaq 0xb032(%rip), %r14      # 0x20757
movq %r14, %rdx
cmovneq %r12, %rdx
leaq 0xb00b(%rip), %rsi      # 0x2073e
movq %r15, %rdi
xorl %eax, %eax
callq 0x9fb2
leaq 0x9d57(%rip), %rsi      # 0x1f49b
movq %rbx, %rdi
callq 0x76cf
testl %eax, %eax
setne 0x13d0d(%rip)           # 0x29462
movq %r14, %rdx
cmovneq %r12, %rdx
leaq 0xaff8(%rip), %rsi      # 0x2075b
movq %r15, %rdi
xorl %eax, %eax
callq 0x9fb2
leaq 0xaa52(%rip), %rsi      # 0x201c6
movq %rbx, %rdi
callq 0x7599
leaq 0xb000(%rip), %rsi      # 0x20783
movq %rax, %rdi
callq 0x4450
testl %eax, %eax
je 0x157bf
leaq 0xaa30(%rip), %rsi      # 0x201c6
movq %rbx, %rdi
callq 0x7599
leaq 0xafdd(%rip), %rsi      # 0x20782
movq %rax, %rdi
callq 0x4450
testl %eax, %eax
jne 0x157e9
leaq 0xb249(%rip), %rdx      # 0x20a01
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x157cb
leaq 0xb240(%rip), %rdx      # 0x20a06
movl $0x1, %eax
leaq 0x20b6dfe(%rip), %rcx   # 0x20cc5d0
movl %eax, (%rcx)
leaq 0xaf45(%rip), %rdi      # 0x20720
leaq 0xaf90(%rip), %rsi      # 0x20772
xorl %eax, %eax
callq 0x9fb2
leaq 0xb33f(%rip), %rsi      # 0x20b2f
movq %rbx, %rdi
callq 0x76cf
shll $0xa, %eax
leaq 0x12b3e(%rip), %rcx     # 0x28340
cmpl (%rcx), %eax
jle 0x15808
movl %eax, (%rcx)
movl (%rcx), %edx
leaq 0xabcb(%rip), %rsi      # 0x203dc
movq %rsp, %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0x40c0
leaq 0xaefb(%rip), %rdi      # 0x20720
leaq 0xaf59(%rip), %rsi      # 0x20785
movq %r15, %rdx
xorl %eax, %eax
callq 0x9fb2
leaq 0xb318(%rip), %rsi      # 0x20b55
movq %rbx, %rdi
callq 0x7599
testq %rax, %rax
je 0x15878
leaq 0xb304(%rip), %rsi      # 0x20b55
movq %rbx, %rdi
callq 0x7599
movq %rax, 0x61b7de0(%rip)   # 0x61cd640
leaq 0xaeb9(%rip), %rdi      # 0x20720
leaq 0xaf2b(%rip), %rsi      # 0x20799
movq %rax, %rdx
xorl %eax, %eax
callq 0x9fb2
leaq 0xb286(%rip), %rsi      # 0x20b05
movq %rbx, %rdi
callq 0x7599
leaq 0xaef5(%rip), %rsi      # 0x20783
movq %rax, %rdi
callq 0x4450
testl %eax, %eax
sete 0x61b7dc2(%rip)         # 0x61cd661
movq %r14, %rdx
cmoveq %r12, %rdx
leaq 0xae73(%rip), %rdi      # 0x20720
leaq 0xaef5(%rip), %rsi      # 0x207a9
xorl %eax, %eax
callq 0x9fb2
leaq 0xb2a9(%rip), %rsi      # 0x20b6b
movq %rbx, %rdi
callq 0x7599
cmpb $0x0, (%rax)
je 0x15905
leaq 0xb295(%rip), %rsi      # 0x20b6b
movq %rbx, %rdi
callq 0x7599
movq %rax, %rdi
callq 0x45c0
movq %rax, 0x61b7d63(%rip)   # 0x61cd650
leaq 0xae2c(%rip), %rdi      # 0x20720
leaq 0xaebe(%rip), %rsi      # 0x207b9
movq %rax, %rdx
xorl %eax, %eax
callq 0x9fb2
leaq 0xb253(%rip), %rsi      # 0x20b5f
movq %rbx, %rdi
callq 0x7599
cmpb $0x0, (%rax)
je 0x1594f
leaq 0xb23f(%rip), %rsi      # 0x20b5f
movq %rbx, %rdi
callq 0x7599
movq %rax, %rdi
callq 0x45c0
movq %rax, 0x61b7d11(%rip)   # 0x61cd648
leaq 0xade2(%rip), %rdi      # 0x20720
leaq 0xae92(%rip), %rsi      # 0x207d7
movq %rax, %rdx
xorl %eax, %eax
callq 0x9fb2
leaq 0xae9f(%rip), %rsi      # 0x207f5
movq %rbx, %rdi
callq 0x76cf
cmpl $0x1, %eax
je 0x1596b
testl %eax, %eax
jne 0x15973
xorl %eax, %eax
jmp 0x1596d
movb $0x1, %al
movb %al, 0x61b7ced(%rip)    # 0x61cd660
cmpb $0x0, 0x61b7ce6(%rip)   # 0x61cd660
movq %r14, %rdx
cmovneq %r12, %rdx
leaq 0xad98(%rip), %rdi      # 0x20720
leaq 0xae74(%rip), %rsi      # 0x20803
xorl %eax, %eax
callq 0x9fb2
leaq 0xae7c(%rip), %rsi      # 0x20819
movq %rbx, %rdi
callq 0x76cf
movb $0x0, 0x61b7c8d(%rip)   # 0x61cd639
testl %eax, %eax
je 0x159be
cmpl $0x2, %eax
jne 0x159e0
movb $0x1, 0x61b7c7d(%rip)   # 0x61cd639
jmp 0x159e0
leaq 0x1298b(%rip), %rax     # 0x28350
movq (%rax), %rdx
leaq 0xae50(%rip), %rsi      # 0x2081f
movl $0x36, %edi
xorl %eax, %eax
callq 0xa38f
callq 0xa28b
cmpb $0x0, 0x61b7c52(%rip)   # 0x61cd639
movq %r14, %rdx
cmovneq %r12, %rdx
leaq 0xad2b(%rip), %r15      # 0x20720
leaq 0xae72(%rip), %rsi      # 0x2086e
movq %r15, %rdi
xorl %eax, %eax
callq 0x9fb2
leaq 0xae6a(%rip), %rsi      # 0x20877
movq %rbx, %rdi
callq 0x76cf
cmpl $0x1, %eax
sete 0x61b7c19(%rip)         # 0x61cd638
movq %r14, %rdx
cmovneq %r12, %rdx
leaq 0xae55(%rip), %rsi      # 0x20882
movq %r15, %rdi
xorl %eax, %eax
callq 0x9fb2
leaq 0xb013(%rip), %rsi      # 0x20a51
movq %rbx, %rdi
callq 0x76cf
cmpl $0x4, %eax
movl $0x4, %edi
cmovbl %eax, %edi
movl %edi, 0x13a11(%rip)     # 0x29468
callq 0xe447
leaq 0xae38(%rip), %rsi      # 0x2089b
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x9fb2
leaq 0xafa5(%rip), %rsi      # 0x20a1c
movq %rbx, %rdi
callq 0x76cf
cmpl $0x1, %eax
setne 0x139d8(%rip)           # 0x29461
cmovneq %r12, %r14
leaq 0xae16(%rip), %rsi      # 0x208aa
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x9fb2
leaq 0x8210(%rip), %rdi      # 0x1dcb8
xorl %eax, %eax
callq 0x9fb2
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r14
popq %r15
retq