// File: /workspace/github_cpp_makefile_star2_O3/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 0xb5b4(%rip), %rdi      # 0x20708
xorl %eax, %eax
callq 0x9e76
leaq 0xb8ac(%rip), %rsi      # 0x20a0e
movq %rbx, %rdi
callq 0x7678
cmpl $0x1, %eax
je 0x15177
testl %eax, %eax
jne 0x15182
xorl %eax, %eax
jmp 0x15179
movb $0x1, %al
leaq 0x20aa2e4(%rip), %rcx   # 0x20bf464
movb %al, (%rcx)
leaq 0xb5bf(%rip), %r12      # 0x20748
leaq 0xb5c7(%rip), %rsi      # 0x20757
leaq 0x9bcc(%rip), %rdx      # 0x1ed63
movq %r12, %rdi
xorl %eax, %eax
callq 0x9e76
leaq 0x20aa2bc(%rip), %rax   # 0x20bf464
leaq 0xb9c1(%rip), %r14      # 0x20b70
cmpb $0x0, (%rax)
leaq 0xb5c6(%rip), %r15      # 0x2077f
movq %r15, %rdx
cmovneq %r14, %rdx
leaq 0xb59f(%rip), %rsi      # 0x20766
movq %r12, %rdi
xorl %eax, %eax
callq 0x9e76
leaq 0xa2a3(%rip), %rsi      # 0x1f47b
movq %rbx, %rdi
callq 0x7678
testl %eax, %eax
setne 0x14269(%rip)           # 0x29452
movq %r15, %rdx
cmovneq %r14, %rdx
leaq 0xb58c(%rip), %rsi      # 0x20783
movq %r12, %rdi
xorl %eax, %eax
callq 0x9e76
leaq 0xafde(%rip), %rsi      # 0x201e6
movq %rbx, %rdi
callq 0x7542
cmpb $0x31, (%rax)
jne 0x1521b
cmpb $0x0, 0x1(%rax)
je 0x15249
leaq 0xafc4(%rip), %rsi      # 0x201e6
movq %rbx, %rdi
callq 0x7542
cmpb $0x2d, (%rax)
jne 0x15273
cmpb $0x31, 0x1(%rax)
jne 0x15273
cmpb $0x0, 0x2(%rax)
jne 0x15273
leaq 0xb7e4(%rip), %rdx      # 0x20a26
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x15255
leaq 0xb7db(%rip), %rdx      # 0x20a2b
movl $0x1, %eax
leaq 0x20b7364(%rip), %rcx   # 0x20cc5c0
movl %eax, (%rcx)
leaq 0xb4e3(%rip), %rdi      # 0x20748
leaq 0xb52e(%rip), %rsi      # 0x2079a
xorl %eax, %eax
callq 0x9e76
leaq 0xb8da(%rip), %rsi      # 0x20b54
movq %rbx, %rdi
callq 0x7678
shll $0xa, %eax
leaq 0x130a4(%rip), %rcx     # 0x28330
movl (%rcx), %edx
cmpl %edx, %eax
jle 0x15296
movl %eax, (%rcx)
movl %eax, %edx
leaq 0xb15f(%rip), %rsi      # 0x203fc
movq %rsp, %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x40c0
leaq 0xb497(%rip), %rdi      # 0x20748
leaq 0xb4f2(%rip), %rsi      # 0x207aa
movq %r12, %rdx
xorl %eax, %eax
callq 0x9e76
leaq 0xb8b1(%rip), %rsi      # 0x20b7a
movq %rbx, %rdi
callq 0x7542
testq %rax, %rax
je 0x15304
leaq 0xb89d(%rip), %rsi      # 0x20b7a
movq %rbx, %rdi
callq 0x7542
movq %rax, 0x61b8344(%rip)   # 0x61cd630
leaq 0xb455(%rip), %rdi      # 0x20748
leaq 0xb4c4(%rip), %rsi      # 0x207be
movq %rax, %rdx
xorl %eax, %eax
callq 0x9e76
leaq 0xb81f(%rip), %rsi      # 0x20b2a
movq %rbx, %rdi
callq 0x7542
cmpb $0x31, (%rax)
jne 0x15337
cmpb $0x0, 0x1(%rax)
sete 0x61b832e(%rip)         # 0x61cd651
leaq 0xb846(%rip), %rax      # 0x20b70
leaq 0xb44e(%rip), %r15      # 0x2077f
cmoveq %rax, %r15
jmp 0x1533e
movb $0x0, 0x61b8313(%rip)   # 0x61cd651
leaq 0xb403(%rip), %rdi      # 0x20748
leaq 0xb482(%rip), %rsi      # 0x207ce
movq %r15, %rdx
xorl %eax, %eax
callq 0x9e76
leaq 0xb833(%rip), %rsi      # 0x20b90
movq %rbx, %rdi
callq 0x7542
cmpb $0x0, (%rax)
je 0x153a0
leaq 0xb81f(%rip), %rsi      # 0x20b90
movq %rbx, %rdi
callq 0x7542
movq %rax, %rdi
callq 0x45a0
movq %rax, 0x61b82b8(%rip)   # 0x61cd640
leaq 0xb3b9(%rip), %rdi      # 0x20748
leaq 0xb448(%rip), %rsi      # 0x207de
movq %rax, %rdx
xorl %eax, %eax
callq 0x9e76
leaq 0xb7dd(%rip), %rsi      # 0x20b84
movq %rbx, %rdi
callq 0x7542
cmpb $0x0, (%rax)
je 0x153ea
leaq 0xb7c9(%rip), %rsi      # 0x20b84
movq %rbx, %rdi
callq 0x7542
movq %rax, %rdi
callq 0x45a0
movq %rax, 0x61b8266(%rip)   # 0x61cd638
leaq 0xb36f(%rip), %rdi      # 0x20748
leaq 0xb41c(%rip), %rsi      # 0x207fc
movq %rax, %rdx
xorl %eax, %eax
callq 0x9e76
leaq 0xb429(%rip), %rsi      # 0x2081a
movq %rbx, %rdi
callq 0x7678
testl %eax, %eax
je 0x1540b
cmpl $0x1, %eax
jne 0x1541b
movb $0x1, 0x61b8247(%rip)   # 0x61cd650
jmp 0x1542d
movb $0x0, 0x61b823e(%rip)   # 0x61cd650
leaq 0xb366(%rip), %r14      # 0x2077f
jmp 0x1542d
leaq 0xb35d(%rip), %rax      # 0x2077f
testb $0x1, 0x61b8227(%rip)   # 0x61cd650
cmoveq %rax, %r14
leaq 0xb314(%rip), %rdi      # 0x20748
leaq 0xb3ed(%rip), %rsi      # 0x20828
movq %r14, %rdx
xorl %eax, %eax
callq 0x9e76
leaq 0xb3f2(%rip), %rsi      # 0x2083e
movq %rbx, %rdi
callq 0x7678
movb $0x0, 0x61b81ce(%rip)   # 0x61cd629
leaq 0xb31d(%rip), %r12      # 0x2077f
testl %eax, %eax
je 0x1547e
movq %r12, %rdx
cmpl $0x2, %eax
jne 0x154b9
movb $0x1, 0x61b81b4(%rip)   # 0x61cd629
leaq 0xb6f4(%rip), %rdx      # 0x20b70
jmp 0x154b9
leaq 0x12ebb(%rip), %rax     # 0x28340
movq (%rax), %rdx
leaq 0xb3b5(%rip), %rsi      # 0x20844
movl $0x36, %edi
xorl %eax, %eax
callq 0xa253
callq 0xa14f
leaq 0xb6c9(%rip), %rax      # 0x20b70
leaq 0xb2d1(%rip), %rdx      # 0x2077f
testb $0x1, 0x61b8174(%rip)   # 0x61cd629
cmovneq %rax, %rdx
leaq 0xb288(%rip), %r14      # 0x20748
leaq 0xb3cc(%rip), %rsi      # 0x20893
movq %r14, %rdi
xorl %eax, %eax
callq 0x9e76
leaq 0xb3c4(%rip), %rsi      # 0x2089c
movq %rbx, %rdi
callq 0x7678
cmpl $0x1, %eax
sete 0x61b813e(%rip)         # 0x61cd628
leaq 0xb67f(%rip), %r15      # 0x20b70
movq %r15, %rdx
cmoveq %r12, %rdx
leaq 0xb3a8(%rip), %rsi      # 0x208a7
movq %r14, %rdi
xorl %eax, %eax
callq 0x9e76
leaq 0xb566(%rip), %rsi      # 0x20a76
movq %rbx, %rdi
callq 0x7678
cmpl $0x4, %eax
movl $0x4, %edi
cmovbl %eax, %edi
movl %edi, 0x13f2f(%rip)     # 0x29458
callq 0xe1ff
leaq 0xb38b(%rip), %rsi      # 0x208c0
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x9e76
leaq 0xb4f8(%rip), %rsi      # 0x20a41
movq %rbx, %rdi
callq 0x7678
cmpl $0x1, %eax
setne 0x13ef6(%rip)           # 0x29451
cmoveq %r12, %r15
leaq 0xb369(%rip), %rsi      # 0x208cf
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x9e76
leaq 0x872e(%rip), %rdi      # 0x1dca8
xorl %eax, %eax
callq 0x9e76
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r14
popq %r15
retq