// File: 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:
subq $0x128, %rsp            # imm = 0x128
movq %rdi, 0x120(%rsp)
leaq 0xf002(%rip), %rdi      # 0x2e7a8
movb $0x0, %al
callq 0xb5d0
movq 0x120(%rsp), %rdi
leaq 0xf2f5(%rip), %rsi      # 0x2eab1
callq 0x8210
movl %eax, 0x11c(%rsp)
cmpl $0x1, 0x11c(%rsp)
jne 0x1f7de
leaq 0x20adceb(%rip), %rax   # 0x20cd4c4
movb $0x1, (%rax)
jmp 0x1f7f4
cmpl $0x0, 0x11c(%rsp)
jne 0x1f7f2
leaq 0x20adcd5(%rip), %rax   # 0x20cd4c4
movb $0x0, (%rax)
jmp 0x1f7f4
leaq 0xefed(%rip), %rdi      # 0x2e7e8
leaq 0xeff5(%rip), %rsi      # 0x2e7f7
leaq 0xd5ea(%rip), %rdx      # 0x2cdf3
movb $0x0, %al
callq 0xb5d0
leaq 0x20adcad(%rip), %rax   # 0x20cd4c4
movb (%rax), %cl
leaq 0xefff(%rip), %rdx      # 0x2e81f
leaq 0xf3ec(%rip), %rax      # 0x2ec13
testb $0x1, %cl
cmovneq %rax, %rdx
leaq 0xefb3(%rip), %rdi      # 0x2e7e8
leaq 0xefca(%rip), %rsi      # 0x2e806
movb $0x0, %al
callq 0xb5d0
movq 0x120(%rsp), %rdi
leaq 0xddd9(%rip), %rsi      # 0x2d62b
callq 0x8210
cmpl $0x0, %eax
je 0x1f865
movb $0x1, 0x17c4f(%rip)     # 0x374b2
jmp 0x1f86c
movb $0x0, 0x17c46(%rip)     # 0x374b2
movb 0x17c40(%rip), %cl      # 0x374b2
leaq 0xefa6(%rip), %rdx      # 0x2e81f
leaq 0xf393(%rip), %rax      # 0x2ec13
testb $0x1, %cl
cmovneq %rax, %rdx
leaq 0xef5a(%rip), %rdi      # 0x2e7e8
leaq 0xef8e(%rip), %rsi      # 0x2e823
movb $0x0, %al
callq 0xb5d0
movq 0x120(%rsp), %rdi
leaq 0xea2b(%rip), %rsi      # 0x2e2d6
callq 0x7ff0
movq %rax, %rdi
leaq 0xef91(%rip), %rsi      # 0x2e84b
callq 0x4530
cmpl $0x0, %eax
jne 0x1f8ef
leaq 0x20bad55(%rip), %rax   # 0x20da620
movl $0x1, (%rax)
leaq 0xef10(%rip), %rdi      # 0x2e7e8
leaq 0xef5b(%rip), %rsi      # 0x2e83a
leaq 0xf1e8(%rip), %rdx      # 0x2eace
movb $0x0, %al
callq 0xb5d0
jmp 0x1f942
movq 0x120(%rsp), %rdi
leaq 0xe9d8(%rip), %rsi      # 0x2e2d6
callq 0x7ff0
movq %rax, %rdi
leaq 0xef3d(%rip), %rsi      # 0x2e84a
callq 0x4530
cmpl $0x0, %eax
jne 0x1f940
leaq 0x20bad02(%rip), %rax   # 0x20da620
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
leaq 0xeebd(%rip), %rdi      # 0x2e7e8
leaq 0xef08(%rip), %rsi      # 0x2e83a
leaq 0xf190(%rip), %rdx      # 0x2eac9
movb $0x0, %al
callq 0xb5d0
jmp 0x1f942
movq 0x120(%rsp), %rdi
leaq 0xf2a6(%rip), %rsi      # 0x2ebf7
callq 0x8210
shll $0xa, %eax
movl %eax, 0x11c(%rsp)
movl 0x11c(%rsp), %eax
leaq 0x16a52(%rip), %rcx     # 0x363c0
cmpl (%rcx), %eax
jle 0x1f982
movl 0x11c(%rsp), %ecx
leaq 0x16a40(%rip), %rax     # 0x363c0
movl %ecx, (%rax)
leaq 0x10(%rsp), %rdi
leaq 0x16a32(%rip), %rax     # 0x363c0
movl (%rax), %edx
leaq 0xeb59(%rip), %rsi      # 0x2e4f0
movb $0x0, %al
callq 0x40d0
leaq 0x10(%rsp), %rdx
leaq 0xee3e(%rip), %rdi      # 0x2e7e8
leaq 0xee9c(%rip), %rsi      # 0x2e84d
movb $0x0, %al
callq 0xb5d0
movq 0x120(%rsp), %rdi
leaq 0xf256(%rip), %rsi      # 0x2ec1d
callq 0x7ff0
cmpq $0x0, %rax
je 0x1fa09
movq 0x120(%rsp), %rdi
leaq 0xf23c(%rip), %rsi      # 0x2ec1d
callq 0x7ff0
movq %rax, 0x61bbce3(%rip)   # 0x61db6d0
movq 0x61bbcdc(%rip), %rdx   # 0x61db6d0
leaq 0xeded(%rip), %rdi      # 0x2e7e8
leaq 0xee5f(%rip), %rsi      # 0x2e861
movb $0x0, %al
callq 0xb5d0
movq 0x120(%rsp), %rdi
leaq 0xf1b5(%rip), %rsi      # 0x2ebcd
callq 0x7ff0
movq %rax, %rdi
leaq 0xee24(%rip), %rsi      # 0x2e84b
callq 0x4530
cmpl $0x0, %eax
jne 0x1fa3a
movb $0x1, 0x61bbcb9(%rip)   # 0x61db6f1
jmp 0x1fa41
movb $0x0, 0x61bbcb0(%rip)   # 0x61db6f1
movb 0x61bbcaa(%rip), %cl    # 0x61db6f1
leaq 0xedd1(%rip), %rdx      # 0x2e81f
leaq 0xf1be(%rip), %rax      # 0x2ec13
testb $0x1, %cl
cmovneq %rax, %rdx
leaq 0xed85(%rip), %rdi      # 0x2e7e8
leaq 0xee07(%rip), %rsi      # 0x2e871
movb $0x0, %al
callq 0xb5d0
movq 0x120(%rsp), %rdi
leaq 0xf1b3(%rip), %rsi      # 0x2ec33
callq 0x7ff0
cmpb $0x0, (%rax)
je 0x1fac9
movq 0x120(%rsp), %rdi
leaq 0xf19a(%rip), %rsi      # 0x2ec33
callq 0x7ff0
movq %rax, %rdi
callq 0x46b0
movq %rax, 0x61bbc33(%rip)   # 0x61db6e0
movq 0x61bbc2c(%rip), %rdx   # 0x61db6e0
leaq 0xed2d(%rip), %rdi      # 0x2e7e8
leaq 0xedbf(%rip), %rsi      # 0x2e881
movb $0x0, %al
callq 0xb5d0
movq 0x120(%rsp), %rdi
leaq 0xf14f(%rip), %rsi      # 0x2ec27
callq 0x7ff0
cmpb $0x0, (%rax)
je 0x1fb21
movq 0x120(%rsp), %rdi
leaq 0xf136(%rip), %rsi      # 0x2ec27
callq 0x7ff0
movq %rax, %rdi
callq 0x46b0
movq %rax, 0x61bbbd3(%rip)   # 0x61db6d8
movq 0x61bbbcc(%rip), %rdx   # 0x61db6d8
leaq 0xecd5(%rip), %rdi      # 0x2e7e8
leaq 0xed85(%rip), %rsi      # 0x2e89f
movb $0x0, %al
callq 0xb5d0
movq 0x120(%rsp), %rdi
leaq 0xed8d(%rip), %rsi      # 0x2e8bd
callq 0x8210
movl %eax, 0x11c(%rsp)
cmpl $0x1, 0x11c(%rsp)
jne 0x1fb4f
movb $0x1, 0x61bbba3(%rip)   # 0x61db6f0
jmp 0x1fb62
cmpl $0x0, 0x11c(%rsp)
jne 0x1fb60
movb $0x0, 0x61bbb90(%rip)   # 0x61db6f0
jmp 0x1fb62
movb 0x61bbb88(%rip), %cl    # 0x61db6f0
leaq 0xecb0(%rip), %rdx      # 0x2e81f
leaq 0xf09d(%rip), %rax      # 0x2ec13
testb $0x1, %cl
cmovneq %rax, %rdx
leaq 0xec64(%rip), %rdi      # 0x2e7e8
leaq 0xed40(%rip), %rsi      # 0x2e8cb
movb $0x0, %al
callq 0xb5d0
movq 0x120(%rsp), %rdi
leaq 0xed40(%rip), %rsi      # 0x2e8e1
callq 0x8210
movl %eax, 0x11c(%rsp)
movb $0x0, 0x61bbb15(%rip)   # 0x61db6c9
cmpl $0x2, 0x11c(%rsp)
jne 0x1fbc7
movb $0x1, 0x61bbb04(%rip)   # 0x61db6c9
jmp 0x1fbf5
cmpl $0x0, 0x11c(%rsp)
jne 0x1fbf3
leaq 0x167f8(%rip), %rax     # 0x363d0
movq (%rax), %rdx
movl $0x36, %edi
leaq 0xed00(%rip), %rsi      # 0x2e8e7
movb $0x0, %al
callq 0xbbb0
callq 0xba60
jmp 0x1fbf5
movb 0x61bbace(%rip), %cl    # 0x61db6c9
leaq 0xec1d(%rip), %rdx      # 0x2e81f
leaq 0xf00a(%rip), %rax      # 0x2ec13
testb $0x1, %cl
cmovneq %rax, %rdx
leaq 0xebd1(%rip), %rdi      # 0x2e7e8
leaq 0xed18(%rip), %rsi      # 0x2e936
movb $0x0, %al
callq 0xb5d0
movq 0x120(%rsp), %rdi
leaq 0xed0b(%rip), %rsi      # 0x2e93f
callq 0x8210
movl %eax, 0x11c(%rsp)
cmpl $0x1, 0x11c(%rsp)
jne 0x1fc53
movb $0x1, 0x61bba77(%rip)   # 0x61db6c8
jmp 0x1fc5a
movb $0x0, 0x61bba6e(%rip)   # 0x61db6c8
movb 0x61bba68(%rip), %cl    # 0x61db6c8
leaq 0xebb8(%rip), %rax      # 0x2e81f
leaq 0xefa5(%rip), %rdx      # 0x2ec13
testb $0x1, %cl
cmovneq %rax, %rdx
leaq 0xeb6c(%rip), %rdi      # 0x2e7e8
leaq 0xecc7(%rip), %rsi      # 0x2e94a
xorl %eax, %eax
callq 0xb5d0
movq 0x120(%rsp), %rdi
leaq 0xee80(%rip), %rsi      # 0x2eb19
callq 0x8210
movl %eax, 0x11c(%rsp)
movl 0x11c(%rsp), %eax
movq %rax, 0x8(%rsp)
subq $0x3, %rax
ja 0x1fcfc
movq 0x8(%rsp), %rax
leaq 0xeaad(%rip), %rcx      # 0x2e770
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, 0x177e2(%rip)     # 0x374b8
jmp 0x1fd06
movl $0x1, 0x177d6(%rip)     # 0x374b8
jmp 0x1fd06
movl $0x2, 0x177ca(%rip)     # 0x374b8
jmp 0x1fd06
movl $0x3, 0x177be(%rip)     # 0x374b8
jmp 0x1fd06
movl $0x4, 0x177b2(%rip)     # 0x374b8
movl 0x177ac(%rip), %edi     # 0x374b8
callq 0x12bd0
movq %rax, %rdx
leaq 0xeacd(%rip), %rdi      # 0x2e7e8
leaq 0xec41(%rip), %rsi      # 0x2e963
movb $0x0, %al
callq 0xb5d0
movq 0x120(%rsp), %rdi
leaq 0xedac(%rip), %rsi      # 0x2eae4
callq 0x8210
movl %eax, 0x11c(%rsp)
cmpl $0x1, 0x11c(%rsp)
jne 0x1fd57
movb $0x0, 0x1775c(%rip)     # 0x374b1
jmp 0x1fd5e
movb $0x1, 0x17753(%rip)     # 0x374b1
movb 0x1774d(%rip), %cl      # 0x374b1
leaq 0xeab4(%rip), %rdx      # 0x2e81f
leaq 0xeea1(%rip), %rax      # 0x2ec13
testb $0x1, %cl
cmovneq %rax, %rdx
leaq 0xea68(%rip), %rdi      # 0x2e7e8
leaq 0xebeb(%rip), %rsi      # 0x2e972
movb $0x0, %al
callq 0xb5d0
leaq 0xbfa3(%rip), %rdi      # 0x2bd38
movb $0x0, %al
callq 0xb5d0
addq $0x128, %rsp            # imm = 0x128
retq
nopw %cs:(%rax,%rax)