// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
leaq 0x13750(%rip), %rdi     # 0x36d60
xorl %eax, %eax
callq 0x8790
leaq 0x13fe3(%rip), %rsi     # 0x37601
movq %rbx, %rdi
callq 0x6a5d
shll $0xa, %eax
leaq 0x20d14(%rip), %rcx     # 0x44344
cmpl (%rcx), %eax
jle 0x23666
movl %eax, (%rcx)
leaq 0xea82(%rip), %rsi      # 0x320bf
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x40a0
leaq 0x1374b(%rip), %rdi     # 0x36da0
leaq 0x13753(%rip), %rsi     # 0x36daf
movq %r14, %rdx
xorl %eax, %eax
callq 0x8790
leaq 0x13d50(%rip), %rsi     # 0x373bd
movq %rbx, %rdi
callq 0x6a5d
cmpl $0x1, %eax
je 0x23682
testl %eax, %eax
jne 0x2368d
xorl %eax, %eax
jmp 0x23684
movb $0x1, %al
leaq 0x2097dc9(%rip), %rcx   # 0x20bb454
movb %al, (%rcx)
leaq 0x1370c(%rip), %r15     # 0x36da0
leaq 0x13729(%rip), %rsi     # 0x36dc4
leaq 0x116a1(%rip), %rdx     # 0x34d43
movq %r15, %rdi
xorl %eax, %eax
callq 0x8790
leaq 0x2097da1(%rip), %rax   # 0x20bb454
leaq 0x13716(%rip), %r12     # 0x36dd0
cmpb $0x0, (%rax)
leaq 0x13728(%rip), %r14     # 0x36dec
movq %r14, %rdx
cmovneq %r12, %rdx
leaq 0x13701(%rip), %rsi     # 0x36dd3
movq %r15, %rdi
xorl %eax, %eax
callq 0x8790
leaq 0x11d50(%rip), %rsi     # 0x35433
movq %rbx, %rdi
callq 0x6a5d
testl %eax, %eax
setne 0x21d40(%rip)           # 0x45434
movq %r14, %rdx
cmovneq %r12, %rdx
leaq 0x136ee(%rip), %rsi     # 0x36df0
movq %r15, %rdi
xorl %eax, %eax
callq 0x8790
leaq 0x136f4(%rip), %rsi     # 0x36e07
movq %rbx, %rdi
callq 0x6929
cmpb $0x31, (%rax)
jne 0x23726
cmpb $0x0, 0x1(%rax)
je 0x23751
leaq 0x136da(%rip), %rsi     # 0x36e07
movq %rbx, %rdi
callq 0x6929
cmpb $0x2d, (%rax)
jne 0x23779
cmpb $0x31, 0x1(%rax)
jne 0x23779
cmpb $0x0, 0x2(%rax)
jne 0x23779
leaq 0x13e65(%rip), %rdx     # 0x375b2
pushq $-0x1
jmp 0x2375a
leaq 0x13e5f(%rip), %rdx     # 0x375b7
pushq $0x1
popq %rax
leaq 0x20a4e4e(%rip), %rcx   # 0x20c85b0
movl %eax, (%rcx)
leaq 0x13635(%rip), %rdi     # 0x36da0
leaq 0x1369e(%rip), %rsi     # 0x36e10
xorl %eax, %eax
callq 0x8790
leaq 0x13c00(%rip), %rsi     # 0x37380
movq %rbx, %rdi
callq 0x6a5d
testl %eax, %eax
je 0x237c0
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, 0x21c3b(%rip)     # 0x453d4
leaq 0x13be0(%rip), %rsi     # 0x37380
movq %rbx, %rdi
callq 0x6929
leaq 0x135f1(%rip), %rdi     # 0x36da0
leaq 0x1366a(%rip), %rsi     # 0x36e20
movq %rax, %rdx
xorl %eax, %eax
callq 0x8790
leaq 0x13f86(%rip), %rsi     # 0x3774d
movq %rbx, %rdi
callq 0x6a5d
testl %eax, %eax
je 0x23801
movb $0x1, 0x54d325e(%rip)   # 0x54f6a38
leaq 0x13f6c(%rip), %rsi     # 0x3774d
movq %rbx, %rdi
callq 0x6929
leaq 0x135b0(%rip), %rdi     # 0x36da0
leaq 0x13645(%rip), %rsi     # 0x36e3c
movq %rax, %rdx
xorl %eax, %eax
callq 0x8790
leaq 0x13f5d(%rip), %rsi     # 0x37765
movq %rbx, %rdi
callq 0x6a5d
testl %eax, %eax
je 0x23842
movb $0x1, 0x54d321e(%rip)   # 0x54f6a39
leaq 0x13f43(%rip), %rsi     # 0x37765
movq %rbx, %rdi
callq 0x6929
leaq 0x1356f(%rip), %rdi     # 0x36da0
leaq 0x13624(%rip), %rsi     # 0x36e5c
movq %rax, %rdx
xorl %eax, %eax
callq 0x8790
leaq 0x13ced(%rip), %rsi     # 0x37536
movq %rbx, %rdi
callq 0x6929
testq %rax, %rax
je 0x239be
leaq 0xc(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0x8(%rsp), %rcx
andl $0x0, (%rcx)
leaq 0x4(%rsp), %r8
andl $0x0, (%r8)
leaq 0x141d3(%rip), %rsi     # 0x37a4d
movq %rax, %rdi
xorl %eax, %eax
callq 0x42c0
testl %eax, %eax
je 0x239b0
movss 0xc(%rsp), %xmm1
movss 0xe7ca(%rip), %xmm0     # 0x32064
movaps %xmm0, %xmm2
cmpltps %xmm1, %xmm2
xorps %xmm5, %xmm5
movaps %xmm1, %xmm3
cmpltps %xmm5, %xmm3
orps %xmm2, %xmm3
movd %xmm3, %eax
movss 0x8(%rsp), %xmm2
movaps %xmm0, %xmm3
cmpltps %xmm2, %xmm3
movaps %xmm2, %xmm4
cmpltps %xmm5, %xmm4
orps %xmm3, %xmm4
movd %xmm4, %edx
movl %eax, %ecx
orb %dl, %cl
movss 0x4(%rsp), %xmm3
cmpltps %xmm3, %xmm0
movaps %xmm3, %xmm4
cmpltps %xmm5, %xmm4
orps %xmm0, %xmm4
movd %xmm4, %edi
orb %dil, %cl
testb $0x1, %cl
je 0x23949
cvtss2sd %xmm1, %xmm0
leaq 0x13628(%rip), %r8      # 0x36f24
leaq 0x102d6(%rip), %rcx     # 0x33bd9
testb $0x1, %al
movq %rcx, %rsi
cmovneq %r8, %rsi
cvtss2sd %xmm2, %xmm1
testb $0x1, %dl
movq %rcx, %rdx
cmovneq %r8, %rdx
cvtss2sd %xmm3, %xmm2
testb $0x1, %dil
cmovneq %r8, %rcx
leaq 0x1353d(%rip), %rdi     # 0x36e6a
movb $0x3, %al
callq 0x8b2f
xorps %xmm5, %xmm5
movss 0xc(%rsp), %xmm1
movss 0x8(%rsp), %xmm2
movss 0x4(%rsp), %xmm3
ucomiss %xmm5, %xmm1
jne 0x23961
jp 0x23961
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm2
jne 0x23961
jp 0x23961
ucomiss %xmm0, %xmm3
jne 0x23961
jnp 0x239be
movss 0x120b3(%rip), %xmm4    # 0x35a1c
cvtss2sd %xmm1, %xmm0
mulss %xmm4, %xmm1
movss %xmm1, 0x54d107b(%rip)  # 0x54f49f4
cvtss2sd %xmm2, %xmm1
mulss %xmm4, %xmm2
movss %xmm2, 0x54d106f(%rip)  # 0x54f49f8
mulss %xmm3, %xmm4
movss %xmm4, 0x54d1067(%rip)  # 0x54f49fc
cvtss2sd %xmm3, %xmm2
leaq 0x13591(%rip), %rdi     # 0x36f31
leaq 0x135a6(%rip), %rsi     # 0x36f4d
movb $0x3, %al
callq 0x8790
jmp 0x239be
leaq 0x135b2(%rip), %rdi     # 0x36f69
xorl %eax, %eax
callq 0x8b2f
leaq 0x13c1a(%rip), %rsi     # 0x375df
movq %rbx, %rdi
callq 0x7126
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x239d7
jnp 0x23a1f
cvtss2sd 0x21a0d(%rip), %xmm0    # 0x453ec
mulsd 0x11c19(%rip), %xmm0    # 0x35600
callq 0x4600
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x54d301c(%rip)  # 0x54f6a14
leaq 0x13be0(%rip), %rsi     # 0x375df
movq %rbx, %rdi
callq 0x6929
leaq 0x13392(%rip), %rdi     # 0x36da0
leaq 0x135f6(%rip), %rsi     # 0x3700b
movq %rax, %rdx
xorl %eax, %eax
callq 0x8790
leaq 0x13c2b(%rip), %rsi     # 0x37651
movq %rbx, %rdi
callq 0x7126
ucomiss 0xe63b(%rip), %xmm0     # 0x32070
jne 0x23a39
jnp 0x23a68
movss %xmm0, 0x2198f(%rip)    # 0x453d0
leaq 0x13c09(%rip), %rsi     # 0x37651
movq %rbx, %rdi
callq 0x6929
leaq 0x13349(%rip), %rdi     # 0x36da0
leaq 0x135c1(%rip), %rsi     # 0x3701f
movq %rax, %rdx
xorl %eax, %eax
callq 0x8790
leaq 0x139af(%rip), %rsi     # 0x3741e
movq %rbx, %rdi
callq 0x6a5d
testl %eax, %eax
je 0x23aae
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x219b1(%rip)    # 0x45438
leaq 0x13990(%rip), %rsi     # 0x3741e
movq %rbx, %rdi
callq 0x6929
leaq 0x13303(%rip), %rdi     # 0x36da0
leaq 0x1359f(%rip), %rsi     # 0x37043
movq %rax, %rdx
xorl %eax, %eax
callq 0x8790
leaq 0x139cd(%rip), %rsi     # 0x37482
movq %rbx, %rdi
callq 0x7126
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x23ac7
jnp 0x23af6
movss %xmm0, 0x2196d(%rip)    # 0x4543c
leaq 0x139ac(%rip), %rsi     # 0x37482
movq %rbx, %rdi
callq 0x6929
leaq 0x132bb(%rip), %rdi     # 0x36da0
leaq 0x13549(%rip), %rsi     # 0x37035
movq %rax, %rdx
xorl %eax, %eax
callq 0x8790
leaq 0x13550(%rip), %rsi     # 0x3704d
movq %rbx, %rdi
callq 0x6a5d
cmpl $0x2, %eax
je 0x23b41
cmpl $0x1, %eax
je 0x23b38
testl %eax, %eax
jne 0x23b48
leaq 0x20836(%rip), %rax     # 0x44350
movq (%rax), %rcx
leaq 0x1352f(%rip), %rsi     # 0x37053
pushq $0x36
popq %rdi
movq %rcx, %rdx
xorl %eax, %eax
callq 0x8c24
callq 0x8b1c
jmp 0x23b48
movb $0x0, 0x54d2ed2(%rip)   # 0x54f6a11
jmp 0x23b48
movb $0x1, 0x54d2ec9(%rip)   # 0x54f6a11
cmpb $0x0, 0x54d2ec2(%rip)   # 0x54f6a11
movq %r14, %rdx
cmovneq %r12, %rdx
leaq 0x13243(%rip), %rdi     # 0x36da0
leaq 0x13544(%rip), %rsi     # 0x370a8
xorl %eax, %eax
callq 0x8790
leaq 0x13540(%rip), %rsi     # 0x370b2
movq %rbx, %rdi
callq 0x6a5d
testl %eax, %eax
je 0x23ba0
cmpl $0x1, %eax
je 0x23b91
cmpl $0x2, %eax
jne 0x23baf
andl $0x0, 0x21839(%rip)     # 0x453c8
jmp 0x23baa
movl $0x1, 0x2182d(%rip)     # 0x453c8
movq %r12, %rdx
jmp 0x23bbd
movl $0x2, 0x2181e(%rip)     # 0x453c8
movq %r14, %rdx
jmp 0x23bbd
cmpl $0x1, 0x21812(%rip)     # 0x453c8
movq %r14, %rdx
cmoveq %r12, %rdx
leaq 0x131dc(%rip), %r15     # 0x36da0
leaq 0x134ee(%rip), %rsi     # 0x370b9
movq %r15, %rdi
xorl %eax, %eax
callq 0x8790
cmpl $0x2, 0x217ec(%rip)     # 0x453c8
cmoveq %r12, %r14
leaq 0x134e3(%rip), %rsi     # 0x370ca
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x8790
leaq 0x13991(%rip), %rsi     # 0x3758c
movq %rbx, %rdi
callq 0x6a5d
testl %eax, %eax
je 0x23c1c
cmpl $0x1, %eax
jne 0x23c2c
movb $0x1, 0x54d2e09(%rip)   # 0x54f6a1c
leaq 0x131b6(%rip), %rdx     # 0x36dd0
jmp 0x23c45
movb $0x0, 0x54d2df9(%rip)   # 0x54f6a1c
leaq 0x131c2(%rip), %rdx     # 0x36dec
jmp 0x23c45
leaq 0x1319d(%rip), %rax     # 0x36dd0
leaq 0x131b2(%rip), %rdx     # 0x36dec
testb $0x1, 0x54d2ddb(%rip)   # 0x54f6a1c
cmovneq %rax, %rdx
leaq 0x13154(%rip), %rdi     # 0x36da0
leaq 0x13483(%rip), %rsi     # 0x370d6
xorl %eax, %eax
callq 0x8790
leaq 0xff77(%rip), %rdi      # 0x33bd8
xorl %eax, %eax
callq 0x8790
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r14
popq %r15
retq