// File: /workspace/github_cpp_makefile_star2_O2/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 0xa90c(%rip), %rdi      # 0x1d5f8
xorl %eax, %eax
callq 0x89dc
leaq 0xac04(%rip), %rsi      # 0x1d8fe
movq %rbx, %rdi
callq 0x6adf
cmpl $0x1, %eax
je 0x12d0f
testl %eax, %eax
jne 0x12d1a
xorl %eax, %eax
jmp 0x12d11
movb $0x1, %al
leaq 0x20aa75c(%rip), %rcx   # 0x20bd474
movb %al, (%rcx)
leaq 0xa917(%rip), %r12      # 0x1d638
leaq 0xa91f(%rip), %rsi      # 0x1d647
leaq 0x8fa4(%rip), %rdx      # 0x1bcd3
movq %r12, %rdi
xorl %eax, %eax
callq 0x89dc
leaq 0x20aa734(%rip), %rax   # 0x20bd474
leaq 0xad19(%rip), %r14      # 0x1da60
cmpb $0x0, (%rax)
leaq 0xa91e(%rip), %r15      # 0x1d66f
movq %r15, %rdx
cmovneq %r14, %rdx
leaq 0xa8f7(%rip), %rsi      # 0x1d656
movq %r12, %rdi
xorl %eax, %eax
callq 0x89dc
leaq 0x967b(%rip), %rsi      # 0x1c3eb
movq %rbx, %rdi
callq 0x6adf
testl %eax, %eax
setne 0x146e1(%rip)           # 0x27462
movq %r15, %rdx
cmovneq %r14, %rdx
leaq 0xa8e4(%rip), %rsi      # 0x1d673
movq %r12, %rdi
xorl %eax, %eax
callq 0x89dc
leaq 0xa376(%rip), %rsi      # 0x1d116
movq %rbx, %rdi
callq 0x69ab
cmpb $0x31, (%rax)
jne 0x12db3
cmpb $0x0, 0x1(%rax)
je 0x12dde
leaq 0xa35c(%rip), %rsi      # 0x1d116
movq %rbx, %rdi
callq 0x69ab
cmpb $0x2d, (%rax)
jne 0x12e06
cmpb $0x31, 0x1(%rax)
jne 0x12e06
cmpb $0x0, 0x2(%rax)
jne 0x12e06
leaq 0xab3c(%rip), %rdx      # 0x1d916
pushq $-0x1
jmp 0x12de7
leaq 0xab36(%rip), %rdx      # 0x1d91b
pushq $0x1
popq %rax
leaq 0x20b77e1(%rip), %rcx   # 0x20ca5d0
movl %eax, (%rcx)
leaq 0xa840(%rip), %rdi      # 0x1d638
leaq 0xa88b(%rip), %rsi      # 0x1d68a
xorl %eax, %eax
callq 0x89dc
leaq 0xac37(%rip), %rsi      # 0x1da44
movq %rbx, %rdi
callq 0x6adf
shll $0xa, %eax
leaq 0x13521(%rip), %rcx     # 0x26340
movl (%rcx), %edx
cmpl %edx, %eax
jle 0x12e29
movl %eax, (%rcx)
movl %eax, %edx
leaq 0xa4fc(%rip), %rsi      # 0x1d32c
movq %rsp, %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x40c0
leaq 0xa7f4(%rip), %rdi      # 0x1d638
leaq 0xa84f(%rip), %rsi      # 0x1d69a
movq %r12, %rdx
xorl %eax, %eax
callq 0x89dc
leaq 0xac0e(%rip), %rsi      # 0x1da6a
movq %rbx, %rdi
callq 0x69ab
testq %rax, %rax
je 0x12e97
leaq 0xabfa(%rip), %rsi      # 0x1da6a
movq %rbx, %rdi
callq 0x69ab
movq %rax, 0x61b87c1(%rip)   # 0x61cb640
leaq 0xa7b2(%rip), %rdi      # 0x1d638
leaq 0xa821(%rip), %rsi      # 0x1d6ae
movq %rax, %rdx
xorl %eax, %eax
callq 0x89dc
leaq 0xab7c(%rip), %rsi      # 0x1da1a
movq %rbx, %rdi
callq 0x69ab
cmpb $0x31, (%rax)
jne 0x12eca
cmpb $0x0, 0x1(%rax)
sete 0x61b87ab(%rip)         # 0x61cb661
leaq 0xaba3(%rip), %rax      # 0x1da60
leaq 0xa7ab(%rip), %r15      # 0x1d66f
cmoveq %rax, %r15
jmp 0x12ed1
movb $0x0, 0x61b8790(%rip)   # 0x61cb661
leaq 0xa760(%rip), %rdi      # 0x1d638
leaq 0xa7df(%rip), %rsi      # 0x1d6be
movq %r15, %rdx
xorl %eax, %eax
callq 0x89dc
leaq 0xab90(%rip), %rsi      # 0x1da80
movq %rbx, %rdi
callq 0x69ab
cmpb $0x0, (%rax)
je 0x12f33
leaq 0xab7c(%rip), %rsi      # 0x1da80
movq %rbx, %rdi
callq 0x69ab
movq %rax, %rdi
callq 0x45d0
movq %rax, 0x61b8735(%rip)   # 0x61cb650
leaq 0xa716(%rip), %rdi      # 0x1d638
leaq 0xa7a5(%rip), %rsi      # 0x1d6ce
movq %rax, %rdx
xorl %eax, %eax
callq 0x89dc
leaq 0xab3a(%rip), %rsi      # 0x1da74
movq %rbx, %rdi
callq 0x69ab
cmpb $0x0, (%rax)
je 0x12f7d
leaq 0xab26(%rip), %rsi      # 0x1da74
movq %rbx, %rdi
callq 0x69ab
movq %rax, %rdi
callq 0x45d0
movq %rax, 0x61b86e3(%rip)   # 0x61cb648
leaq 0xa6cc(%rip), %rdi      # 0x1d638
leaq 0xa779(%rip), %rsi      # 0x1d6ec
movq %rax, %rdx
xorl %eax, %eax
callq 0x89dc
leaq 0xa786(%rip), %rsi      # 0x1d70a
movq %rbx, %rdi
callq 0x6adf
testl %eax, %eax
je 0x12f9e
cmpl $0x1, %eax
jne 0x12fae
movb $0x1, 0x61b86c4(%rip)   # 0x61cb660
jmp 0x12fc0
movb $0x0, 0x61b86bb(%rip)   # 0x61cb660
leaq 0xa6c3(%rip), %r14      # 0x1d66f
jmp 0x12fc0
leaq 0xa6ba(%rip), %rax      # 0x1d66f
testb $0x1, 0x61b86a4(%rip)   # 0x61cb660
cmoveq %rax, %r14
leaq 0xa671(%rip), %rdi      # 0x1d638
leaq 0xa74a(%rip), %rsi      # 0x1d718
movq %r14, %rdx
xorl %eax, %eax
callq 0x89dc
leaq 0xa74f(%rip), %rsi      # 0x1d72e
movq %rbx, %rdi
callq 0x6adf
movb $0x0, 0x61b864b(%rip)   # 0x61cb639
leaq 0xa67a(%rip), %r12      # 0x1d66f
testl %eax, %eax
je 0x13011
movq %r12, %rdx
cmpl $0x2, %eax
jne 0x1304a
movb $0x1, 0x61b8631(%rip)   # 0x61cb639
leaq 0xaa51(%rip), %rdx      # 0x1da60
jmp 0x1304a
leaq 0x13338(%rip), %rax     # 0x26350
movq (%rax), %rdx
leaq 0xa712(%rip), %rsi      # 0x1d734
pushq $0x36
popq %rdi
xorl %eax, %eax
callq 0x8e70
callq 0x8d68
leaq 0xaa28(%rip), %rax      # 0x1da60
leaq 0xa630(%rip), %rdx      # 0x1d66f
testb $0x1, 0x61b85f3(%rip)   # 0x61cb639
cmovneq %rax, %rdx
leaq 0xa5e7(%rip), %r14      # 0x1d638
leaq 0xa72b(%rip), %rsi      # 0x1d783
movq %r14, %rdi
xorl %eax, %eax
callq 0x89dc
leaq 0xa723(%rip), %rsi      # 0x1d78c
movq %rbx, %rdi
callq 0x6adf
cmpl $0x1, %eax
sete 0x61b85bd(%rip)         # 0x61cb638
leaq 0xa9de(%rip), %r15      # 0x1da60
movq %r15, %rdx
cmoveq %r12, %rdx
leaq 0xa707(%rip), %rsi      # 0x1d797
movq %r14, %rdi
xorl %eax, %eax
callq 0x89dc
leaq 0xa8c5(%rip), %rsi      # 0x1d966
movq %rbx, %rdi
callq 0x6adf
cmpl $0x4, %eax
pushq $0x4
popq %rdi
cmovbl %eax, %edi
movl %edi, 0x143b0(%rip)     # 0x27468
callq 0xc74d
leaq 0xa6ec(%rip), %rsi      # 0x1d7b0
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x89dc
leaq 0xa859(%rip), %rsi      # 0x1d931
movq %rbx, %rdi
callq 0x6adf
cmpl $0x1, %eax
setne 0x14377(%rip)           # 0x27461
cmoveq %r12, %r15
leaq 0xa6ca(%rip), %rsi      # 0x1d7bf
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x89dc
leaq 0x7b0f(%rip), %rdi      # 0x1ac18
xorl %eax, %eax
callq 0x89dc
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r14
popq %r15
retq