// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlrad/qrad.cpp
// Function: GetParamsFromEnt(entity_t*)
void            GetParamsFromEnt(entity_t* mapent)
{
    int     iTmp;
    float   flTmp;
    char    szTmp[256]; //lightdata
    const char* pszTmp;

    Log("\nCompile Settings detected from info_compile_parameters entity\n");

    // lightdata(string) : "Lighting Data Memory" : "8192"
    iTmp = IntForKey(mapent, "lightdata") * 1024; //lightdata
    if (iTmp > g_max_map_lightdata) //--vluzacn
    {
        g_max_map_lightdata = iTmp;
        sprintf_s(szTmp, "%i", g_max_map_lightdata);
        Log("%30s [ %-9s ]\n", "Lighting Data Memory", szTmp);
    }

    // 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");
    }

    // bounce(integer) : "Number of radiosity bounces" : 0 
    iTmp = IntForKey(mapent, "bounce");
    if (iTmp)
    {
        g_numbounce = abs(iTmp);
        Log("%30s [ %-9s ]\n", "Number of radiosity bounces", ValueForKey(mapent, "bounce"));
    }
    
#ifdef HLRAD_HULLU
    iTmp = IntForKey(mapent, "customshadowwithbounce");
    if (iTmp)
    {  
    	g_customshadow_with_bouncelight = true;
    	Log("%30s [ %-9s ]\n", "Custom Shadow with Bounce Light", ValueForKey(mapent, "customshadowwithbounce"));
    }
    iTmp = IntForKey(mapent, "rgbtransfers");
    if (iTmp)
    {  
    	g_rgb_transfers = true;
    	Log("%30s [ %-9s ]\n", "RGB Transfers", ValueForKey(mapent, "rgbtransfers"));
    }
#endif

    // ambient(string) : "Ambient world light (0.0 to 1.0, R G B)" : "0 0 0" 
    //vec3_t          g_ambient = { DEFAULT_AMBIENT_RED, DEFAULT_AMBIENT_GREEN, DEFAULT_AMBIENT_BLUE };
    pszTmp = ValueForKey(mapent, "ambient");
    if (pszTmp)
    {
        float red = 0, green = 0, blue = 0;
        if (sscanf(pszTmp, "%f %f %f", &red, &green, &blue))
        {
            if (red < 0 || red > 1 || green < 0 || green > 1 || blue < 0 || blue > 1)
            {
                Error("info_compile_parameters: Ambient World Light (ambient) all 3 values must be within the range of 0.0 to 1.0\n"
                      "Parsed values:\n"
                      "    red [ %1.3f ] %s\n"
                      "  green [ %1.3f ] %s\n"
                      "   blue [ %1.3f ] %s\n"
                      , red,    (red   < 0 || red   > 1) ? "OUT OF RANGE" : ""
                      , green,  (green < 0 || green > 1) ? "OUT OF RANGE" : ""
                      , blue,   (blue  < 0 || blue  > 1) ? "OUT OF RANGE" : "" );
            }

            if (red == 0 && green == 0 && blue == 0)
            {} // dont bother setting null values
            else
            {
                g_ambient[0] = red * 128;
                g_ambient[1] = green * 128;
                g_ambient[2] = blue * 128;
                Log("%30s [ %1.3f %1.3f %1.3f ]\n", "Ambient world light (R G B)", red, green, blue);
            }
        }
        else
        {
            Error("info_compile_parameters: Ambient World Light (ambient) has unrecognised value\n"
                  "This keyvalue accepts 3 numeric values from 0.000 to 1.000, use \"0 0 0\" if in doubt");
        }
    }

    // smooth(integer) : "Smoothing threshold (in degrees)" : 0 
    flTmp = FloatForKey(mapent, "smooth");
    if (flTmp)
    {
        /*g_smoothing_threshold = flTmp;*/
		g_smoothing_threshold = cos(g_smoothing_value * (Q_PI / 180.0)); // --vluzacn
        Log("%30s [ %-9s ]\n", "Smoothing threshold", ValueForKey(mapent, "smooth"));
    }

    // dscale(integer) : "Direct Lighting Scale" : 1 
    flTmp = FloatForKey(mapent, "dscale");
    if (flTmp)
    {
        g_direct_scale = flTmp;
        Log("%30s [ %-9s ]\n", "Direct Lighting Scale", ValueForKey(mapent, "dscale"));
    }

    // chop(integer) : "Chop Size" : 64 
    iTmp = IntForKey(mapent, "chop");
    if (iTmp)
    {
        g_chop = iTmp;
        Log("%30s [ %-9s ]\n", "Chop Size", ValueForKey(mapent, "chop"));
    }

    // texchop(integer) : "Texture Light Chop Size" : 32 
    flTmp = FloatForKey(mapent, "texchop");
    if (flTmp)
    {
        g_texchop = flTmp;
        Log("%30s [ %-9s ]\n", "Texture Light Chop Size", ValueForKey(mapent, "texchop"));
    }

    /* 
    hlrad(choices) : "HLRAD" : 0 =
    [
        0 : "Off"
        1 : "Normal"
        2 : "Extra"
    ]
    */
    iTmp = IntForKey(mapent, "hlrad");
    if (iTmp == 0)
    {
        Fatal(assume_TOOL_CANCEL, 
            "%s flag was not checked in info_compile_parameters entity, execution of %s cancelled", g_Program, g_Program);
        CheckFatal();  
    }
    else if (iTmp == 1)
    {
        g_extra = false;
    }
    else if (iTmp == 2)
    {
        g_extra = true;
    }
    Log("%30s [ %-9s ]\n", "Extra RAD", g_extra ? "on" : "off");
 
    /*
    sparse(choices) : "Vismatrix Method" : 2 =
    [
        0 : "No Vismatrix"
        1 : "Sparse Vismatrix"
        2 : "Normal"
    ]
    */
    iTmp = IntForKey(mapent, "sparse");
    if (iTmp == 1)
    {
        g_method = eMethodSparseVismatrix;
    }
    else if (iTmp == 0)
    {
        g_method = eMethodNoVismatrix;
    }
    else if (iTmp == 2)
    {
        g_method = eMethodVismatrix;
    }
    Log("%30s [ %-9s ]\n", "Sparse Vismatrix",  g_method == eMethodSparseVismatrix ? "on" : "off");
    Log("%30s [ %-9s ]\n", "NoVismatrix",  g_method == eMethodNoVismatrix ? "on" : "off");

    /*
    circus(choices) : "Circus RAD lighting" : 0 =
    [
        0 : "Off"
        1 : "On"
    ]
    */
    iTmp = IntForKey(mapent, "circus");
    if (iTmp == 0)
    {
        g_circus = false;
    }
    else if (iTmp == 1)
    {
        g_circus = true;
    }

    Log("%30s [ %-9s ]\n", "Circus Lighting Mode", g_circus ? "on" : "off");

    ////////////////////
    Log("\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
movq %rdi, %rbx
leaq 0x1558f(%rip), %rdi     # 0x3ce60
xorl %eax, %eax
callq 0x9d2e
leaq 0x15e25(%rip), %rsi     # 0x3d704
movq %rbx, %rdi
callq 0x76a7
shll $0xa, %eax
leaq 0x20a43(%rip), %rcx     # 0x48334
cmpl (%rcx), %eax
jle 0x27927
movl %eax, (%rcx)
leaq 0x10861(%rip), %rsi     # 0x3815f
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x40a0
leaq 0x1558a(%rip), %rdi     # 0x3cea0
leaq 0x15592(%rip), %rsi     # 0x3ceaf
movq %r14, %rdx
xorl %eax, %eax
callq 0x9d2e
leaq 0x15b92(%rip), %rsi     # 0x3d4c0
movq %rbx, %rdi
callq 0x76a7
cmpl $0x1, %eax
je 0x27943
testl %eax, %eax
jne 0x2794e
xorl %eax, %eax
jmp 0x27945
movb $0x1, %al
leaq 0x2097af8(%rip), %rcx   # 0x20bf444
movb %al, (%rcx)
leaq 0x1554b(%rip), %r15     # 0x3cea0
leaq 0x15568(%rip), %rsi     # 0x3cec4
leaq 0x13480(%rip), %rdx     # 0x3ade3
movq %r15, %rdi
xorl %eax, %eax
callq 0x9d2e
leaq 0x2097ad0(%rip), %rax   # 0x20bf444
leaq 0x15555(%rip), %r12     # 0x3ced0
cmpb $0x0, (%rax)
leaq 0x15567(%rip), %r14     # 0x3ceec
movq %r14, %rdx
cmovneq %r12, %rdx
leaq 0x15540(%rip), %rsi     # 0x3ced3
movq %r15, %rdi
xorl %eax, %eax
callq 0x9d2e
leaq 0x13b37(%rip), %rsi     # 0x3b4db
movq %rbx, %rdi
callq 0x76a7
testl %eax, %eax
setne 0x21a6f(%rip)           # 0x49424
movq %r14, %rdx
cmovneq %r12, %rdx
leaq 0x1552d(%rip), %rsi     # 0x3cef0
movq %r15, %rdi
xorl %eax, %eax
callq 0x9d2e
leaq 0x15533(%rip), %rsi     # 0x3cf07
movq %rbx, %rdi
callq 0x7571
leaq 0x1553e(%rip), %rsi     # 0x3cf21
movq %rax, %rdi
callq 0x4440
testl %eax, %eax
je 0x27a1f
leaq 0x15511(%rip), %rsi     # 0x3cf07
movq %rbx, %rdi
callq 0x7571
leaq 0x1551b(%rip), %rsi     # 0x3cf20
movq %rax, %rdi
callq 0x4440
testl %eax, %eax
jne 0x27a49
leaq 0x15c9d(%rip), %rdx     # 0x3d6b5
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x27a2b
leaq 0x15c94(%rip), %rdx     # 0x3d6ba
movl $0x1, %eax
leaq 0x20a4b6e(%rip), %rcx   # 0x20cc5a0
movl %eax, (%rcx)
leaq 0x15465(%rip), %rdi     # 0x3cea0
leaq 0x154ce(%rip), %rsi     # 0x3cf10
xorl %eax, %eax
callq 0x9d2e
leaq 0x15a33(%rip), %rsi     # 0x3d483
movq %rbx, %rdi
callq 0x76a7
testl %eax, %eax
je 0x27a90
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, 0x2195b(%rip)     # 0x493c4
leaq 0x15a13(%rip), %rsi     # 0x3d483
movq %rbx, %rdi
callq 0x7571
leaq 0x15421(%rip), %rdi     # 0x3cea0
leaq 0x1549d(%rip), %rsi     # 0x3cf23
movq %rax, %rdx
xorl %eax, %eax
callq 0x9d2e
leaq 0x15db9(%rip), %rsi     # 0x3d850
movq %rbx, %rdi
callq 0x76a7
testl %eax, %eax
je 0x27ad1
movb $0x1, 0x54d2f7e(%rip)   # 0x54faa28
leaq 0x15d9f(%rip), %rsi     # 0x3d850
movq %rbx, %rdi
callq 0x7571
leaq 0x153e0(%rip), %rdi     # 0x3cea0
leaq 0x15478(%rip), %rsi     # 0x3cf3f
movq %rax, %rdx
xorl %eax, %eax
callq 0x9d2e
leaq 0x15d90(%rip), %rsi     # 0x3d868
movq %rbx, %rdi
callq 0x76a7
testl %eax, %eax
je 0x27b12
movb $0x1, 0x54d2f3e(%rip)   # 0x54faa29
leaq 0x15d76(%rip), %rsi     # 0x3d868
movq %rbx, %rdi
callq 0x7571
leaq 0x1539f(%rip), %rdi     # 0x3cea0
leaq 0x15457(%rip), %rsi     # 0x3cf5f
movq %rax, %rdx
xorl %eax, %eax
callq 0x9d2e
leaq 0x15b20(%rip), %rsi     # 0x3d639
movq %rbx, %rdi
callq 0x7571
testq %rax, %rax
je 0x27c88
xorl %esi, %esi
leaq 0xc(%rsp), %rdx
movl %esi, (%rdx)
leaq 0x8(%rsp), %rcx
movl %esi, (%rcx)
leaq 0x4(%rsp), %r8
movl %esi, (%r8)
leaq 0x16007(%rip), %rsi     # 0x3db50
movq %rax, %rdi
xorl %eax, %eax
callq 0x42d0
testl %eax, %eax
je 0x27c7a
movss 0xc(%rsp), %xmm0
movss 0x105cf(%rip), %xmm3    # 0x38138
movaps %xmm3, %xmm1
cmpltps %xmm0, %xmm1
xorps %xmm5, %xmm5
movaps %xmm0, %xmm2
cmpltps %xmm5, %xmm2
orps %xmm1, %xmm2
movd %xmm2, %eax
movss 0x8(%rsp), %xmm1
movaps %xmm3, %xmm2
cmpltps %xmm1, %xmm2
movaps %xmm1, %xmm4
cmpltps %xmm5, %xmm4
orps %xmm2, %xmm4
movd %xmm4, %edx
movl %eax, %ecx
orb %dl, %cl
movss 0x4(%rsp), %xmm2
cmpltps %xmm2, %xmm3
movaps %xmm2, %xmm4
cmpltps %xmm5, %xmm4
orps %xmm3, %xmm4
movd %xmm4, %edi
orb %dil, %cl
testb $0x1, %cl
je 0x27c06
cvtss2sd %xmm0, %xmm0
leaq 0x1545c(%rip), %r8      # 0x3d027
leaq 0x120a7(%rip), %rcx     # 0x39c79
testb $0x1, %al
movq %rcx, %rsi
cmovneq %r8, %rsi
cvtss2sd %xmm1, %xmm1
testb $0x1, %dl
movq %rcx, %rdx
cmovneq %r8, %rdx
cvtss2sd %xmm2, %xmm2
testb $0x1, %dil
cmovneq %r8, %rcx
leaq 0x15371(%rip), %rdi     # 0x3cf6d
movb $0x3, %al
callq 0xa01c
xorps %xmm5, %xmm5
movss 0xc(%rsp), %xmm2
ucomiss %xmm5, %xmm2
movss 0x8(%rsp), %xmm1
movss 0x4(%rsp), %xmm3
jne 0x27c30
jp 0x27c30
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x27c30
jp 0x27c30
ucomiss %xmm0, %xmm3
jne 0x27c30
jnp 0x27c88
xorps %xmm0, %xmm0
cvtss2sd %xmm2, %xmm0
unpcklps %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
mulps 0x1506f(%rip), %xmm2    # 0x3ccb0
movlps %xmm2, 0x54d0da0(%rip)  # 0x54f89e8
xorps %xmm2, %xmm2
cvtss2sd %xmm3, %xmm2
mulss 0x13e85(%rip), %xmm3    # 0x3badc
movss %xmm3, 0x54d0d91(%rip)  # 0x54f89f0
cvtss2sd %xmm1, %xmm1
leaq 0x153ca(%rip), %rdi     # 0x3d034
leaq 0x153df(%rip), %rsi     # 0x3d050
movb $0x3, %al
callq 0x9d2e
jmp 0x27c88
leaq 0x153eb(%rip), %rdi     # 0x3d06c
xorl %eax, %eax
callq 0xa01c
leaq 0x15a53(%rip), %rsi     # 0x3d6e2
movq %rbx, %rdi
callq 0x807d
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x27ca1
jnp 0x27cec
xorps %xmm0, %xmm0
cvtss2sd 0x21730(%rip), %xmm0    # 0x493dc
mulsd 0x139d4(%rip), %xmm0    # 0x3b688
callq 0x4600
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x54d2d3f(%rip)  # 0x54faa04
leaq 0x15a16(%rip), %rsi     # 0x3d6e2
movq %rbx, %rdi
callq 0x7571
leaq 0x151c5(%rip), %rdi     # 0x3cea0
leaq 0x1542c(%rip), %rsi     # 0x3d10e
movq %rax, %rdx
xorl %eax, %eax
callq 0x9d2e
leaq 0x15a61(%rip), %rsi     # 0x3d754
movq %rbx, %rdi
callq 0x807d
ucomiss 0x10442(%rip), %xmm0    # 0x38144
jne 0x27d06
jnp 0x27d35
movss %xmm0, 0x216b2(%rip)    # 0x493c0
leaq 0x15a3f(%rip), %rsi     # 0x3d754
movq %rbx, %rdi
callq 0x7571
leaq 0x1517c(%rip), %rdi     # 0x3cea0
leaq 0x153f7(%rip), %rsi     # 0x3d122
movq %rax, %rdx
xorl %eax, %eax
callq 0x9d2e
leaq 0x157e5(%rip), %rsi     # 0x3d521
movq %rbx, %rdi
callq 0x76a7
testl %eax, %eax
je 0x27d7e
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x216d1(%rip)    # 0x49428
leaq 0x157c3(%rip), %rsi     # 0x3d521
movq %rbx, %rdi
callq 0x7571
leaq 0x15133(%rip), %rdi     # 0x3cea0
leaq 0x153d2(%rip), %rsi     # 0x3d146
movq %rax, %rdx
xorl %eax, %eax
callq 0x9d2e
leaq 0x15800(%rip), %rsi     # 0x3d585
movq %rbx, %rdi
callq 0x807d
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x27d97
jnp 0x27dc6
movss %xmm0, 0x2168d(%rip)    # 0x4942c
leaq 0x157df(%rip), %rsi     # 0x3d585
movq %rbx, %rdi
callq 0x7571
leaq 0x150eb(%rip), %rdi     # 0x3cea0
leaq 0x1537c(%rip), %rsi     # 0x3d138
movq %rax, %rdx
xorl %eax, %eax
callq 0x9d2e
leaq 0x15383(%rip), %rsi     # 0x3d150
movq %rbx, %rdi
callq 0x76a7
cmpl $0x2, %eax
je 0x27e13
cmpl $0x1, %eax
je 0x27e0a
testl %eax, %eax
jne 0x27e1a
leaq 0x20556(%rip), %rax     # 0x48340
movq (%rax), %rcx
leaq 0x15362(%rip), %rsi     # 0x3d156
movl $0x36, %edi
movq %rcx, %rdx
xorl %eax, %eax
callq 0xa10b
callq 0xa007
jmp 0x27e1a
movb $0x0, 0x54d2bf0(%rip)   # 0x54faa01
jmp 0x27e1a
movb $0x1, 0x54d2be7(%rip)   # 0x54faa01
cmpb $0x0, 0x54d2be0(%rip)   # 0x54faa01
movq %r14, %rdx
cmovneq %r12, %rdx
leaq 0x15071(%rip), %rdi     # 0x3cea0
leaq 0x15375(%rip), %rsi     # 0x3d1ab
xorl %eax, %eax
callq 0x9d2e
leaq 0x15371(%rip), %rsi     # 0x3d1b5
movq %rbx, %rdi
callq 0x76a7
cmpl $0x2, %eax
ja 0x27e5e
movl $0x2, %ecx
subl %eax, %ecx
movl %ecx, 0x2155a(%rip)     # 0x493b8
cmpl $0x1, 0x21553(%rip)     # 0x493b8
movq %r14, %rdx
cmoveq %r12, %rdx
leaq 0x1502d(%rip), %r15     # 0x3cea0
leaq 0x15342(%rip), %rsi     # 0x3d1bc
xorl %ebp, %ebp
movq %r15, %rdi
xorl %eax, %eax
callq 0x9d2e
cmpl $0x2, 0x2152b(%rip)     # 0x493b8
movq %r14, %rdx
cmoveq %r12, %rdx
leaq 0x15332(%rip), %rsi     # 0x3d1cd
movq %r15, %rdi
xorl %eax, %eax
callq 0x9d2e
leaq 0x157e3(%rip), %rsi     # 0x3d68f
movq %rbx, %rdi
callq 0x76a7
testl %eax, %eax
je 0x27ec0
cmpl $0x1, %eax
jne 0x27ec7
movb $0x1, %bpl
movb %bpl, 0x54d2b45(%rip)   # 0x54faa0c
cmpb $0x0, 0x54d2b3e(%rip)   # 0x54faa0c
cmovneq %r12, %r14
leaq 0x14fc7(%rip), %rdi     # 0x3cea0
leaq 0x152f9(%rip), %rsi     # 0x3d1d9
movq %r14, %rdx
xorl %eax, %eax
callq 0x9d2e
leaq 0x11d87(%rip), %rdi     # 0x39c78
xorl %eax, %eax
callq 0x9d2e
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq