// File: /workspace/github_cpp_makefile_star2_O3/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 0x15430(%rip), %rdi     # 0x3bde0
xorl %eax, %eax
callq 0x9c46
leaq 0x15cc3(%rip), %rsi     # 0x3c681
movq %rbx, %rdi
callq 0x7663
shll $0xa, %eax
leaq 0x20964(%rip), %rcx     # 0x47334
cmpl (%rcx), %eax
jle 0x26a06
movl %eax, (%rcx)
leaq 0x1077a(%rip), %rsi     # 0x37157
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x40a0
leaq 0x1542b(%rip), %rdi     # 0x3be20
leaq 0x15433(%rip), %rsi     # 0x3be2f
movq %r14, %rdx
xorl %eax, %eax
callq 0x9c46
leaq 0x15a30(%rip), %rsi     # 0x3c43d
movq %rbx, %rdi
callq 0x7663
cmpl $0x1, %eax
je 0x26a22
testl %eax, %eax
jne 0x26a2d
xorl %eax, %eax
jmp 0x26a24
movb $0x1, %al
leaq 0x2097a19(%rip), %rcx   # 0x20be444
movb %al, (%rcx)
leaq 0x153ec(%rip), %r15     # 0x3be20
leaq 0x15409(%rip), %rsi     # 0x3be44
leaq 0x133a1(%rip), %rdx     # 0x39de3
movq %r15, %rdi
xorl %eax, %eax
callq 0x9c46
leaq 0x20979f1(%rip), %rax   # 0x20be444
leaq 0x153f6(%rip), %r12     # 0x3be50
cmpb $0x0, (%rax)
leaq 0x15408(%rip), %r14     # 0x3be6c
movq %r14, %rdx
cmovneq %r12, %rdx
leaq 0x153e1(%rip), %rsi     # 0x3be53
movq %r15, %rdi
xorl %eax, %eax
callq 0x9c46
leaq 0x13a68(%rip), %rsi     # 0x3a4eb
movq %rbx, %rdi
callq 0x7663
testl %eax, %eax
setne 0x21990(%rip)           # 0x48424
movq %r14, %rdx
cmovneq %r12, %rdx
leaq 0x153ce(%rip), %rsi     # 0x3be70
movq %r15, %rdi
xorl %eax, %eax
callq 0x9c46
leaq 0x153d4(%rip), %rsi     # 0x3be87
movq %rbx, %rdi
callq 0x752d
cmpb $0x31, (%rax)
jne 0x26ac6
cmpb $0x0, 0x1(%rax)
je 0x26af4
leaq 0x153ba(%rip), %rsi     # 0x3be87
movq %rbx, %rdi
callq 0x752d
cmpb $0x2d, (%rax)
jne 0x26b1e
cmpb $0x31, 0x1(%rax)
jne 0x26b1e
cmpb $0x0, 0x2(%rax)
jne 0x26b1e
leaq 0x15b45(%rip), %rdx     # 0x3c632
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x26b00
leaq 0x15b3c(%rip), %rdx     # 0x3c637
movl $0x1, %eax
leaq 0x20a4a99(%rip), %rcx   # 0x20cb5a0
movl %eax, (%rcx)
leaq 0x15310(%rip), %rdi     # 0x3be20
leaq 0x15379(%rip), %rsi     # 0x3be90
xorl %eax, %eax
callq 0x9c46
leaq 0x158db(%rip), %rsi     # 0x3c400
movq %rbx, %rdi
callq 0x7663
testl %eax, %eax
je 0x26b65
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, 0x21886(%rip)     # 0x483c4
leaq 0x158bb(%rip), %rsi     # 0x3c400
movq %rbx, %rdi
callq 0x752d
leaq 0x152cc(%rip), %rdi     # 0x3be20
leaq 0x15345(%rip), %rsi     # 0x3bea0
movq %rax, %rdx
xorl %eax, %eax
callq 0x9c46
leaq 0x15c61(%rip), %rsi     # 0x3c7cd
movq %rbx, %rdi
callq 0x7663
testl %eax, %eax
je 0x26ba6
movb $0x1, 0x54d2ea9(%rip)   # 0x54f9a28
leaq 0x15c47(%rip), %rsi     # 0x3c7cd
movq %rbx, %rdi
callq 0x752d
leaq 0x1528b(%rip), %rdi     # 0x3be20
leaq 0x15320(%rip), %rsi     # 0x3bebc
movq %rax, %rdx
xorl %eax, %eax
callq 0x9c46
leaq 0x15c38(%rip), %rsi     # 0x3c7e5
movq %rbx, %rdi
callq 0x7663
testl %eax, %eax
je 0x26be7
movb $0x1, 0x54d2e69(%rip)   # 0x54f9a29
leaq 0x15c1e(%rip), %rsi     # 0x3c7e5
movq %rbx, %rdi
callq 0x752d
leaq 0x1524a(%rip), %rdi     # 0x3be20
leaq 0x152ff(%rip), %rsi     # 0x3bedc
movq %rax, %rdx
xorl %eax, %eax
callq 0x9c46
leaq 0x159c8(%rip), %rsi     # 0x3c5b6
movq %rbx, %rdi
callq 0x752d
testq %rax, %rax
je 0x26d74
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 0x15eaf(%rip), %rsi     # 0x3cacd
movq %rax, %rdi
xorl %eax, %eax
callq 0x42c0
testl %eax, %eax
je 0x26d66
movss 0xc(%rsp), %xmm1
movss 0x10466(%rip), %xmm0    # 0x370a4
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 0x26cf6
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
leaq 0x15301(%rip), %r8      # 0x3bfa4
leaq 0x11fcf(%rip), %rcx     # 0x38c79
testb $0x1, %al
movq %rcx, %rsi
cmovneq %r8, %rsi
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
testb $0x1, %dl
movq %rcx, %rdx
cmovneq %r8, %rdx
xorps %xmm2, %xmm2
cvtss2sd %xmm3, %xmm2
testb $0x1, %dil
cmovneq %r8, %rcx
leaq 0x15210(%rip), %rdi     # 0x3beea
movb $0x3, %al
callq 0x9f34
xorps %xmm5, %xmm5
movss 0xc(%rsp), %xmm1
movss 0x8(%rsp), %xmm2
movss 0x4(%rsp), %xmm3
ucomiss %xmm5, %xmm1
jne 0x26d0e
jp 0x26d0e
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm2
jne 0x26d0e
jp 0x26d0e
ucomiss %xmm0, %xmm3
jne 0x26d0e
jnp 0x26d74
movss 0x13d76(%rip), %xmm4    # 0x3aa8c
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
mulss %xmm4, %xmm1
movss %xmm1, 0x54d0cbb(%rip)  # 0x54f79e4
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
mulss %xmm4, %xmm2
movss %xmm2, 0x54d0cac(%rip)  # 0x54f79e8
mulss %xmm3, %xmm4
movss %xmm4, 0x54d0ca4(%rip)  # 0x54f79ec
xorps %xmm2, %xmm2
cvtss2sd %xmm3, %xmm2
leaq 0x1525b(%rip), %rdi     # 0x3bfb1
leaq 0x15270(%rip), %rsi     # 0x3bfcd
movb $0x3, %al
callq 0x9c46
jmp 0x26d74
leaq 0x1527c(%rip), %rdi     # 0x3bfe9
xorl %eax, %eax
callq 0x9f34
leaq 0x158e4(%rip), %rsi     # 0x3c65f
movq %rbx, %rdi
callq 0x7fb3
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x26d8d
jnp 0x26dd8
xorps %xmm0, %xmm0
cvtss2sd 0x21644(%rip), %xmm0    # 0x483dc
mulsd 0x13898(%rip), %xmm0    # 0x3a638
callq 0x45f0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x54d2c53(%rip)  # 0x54f9a04
leaq 0x158a7(%rip), %rsi     # 0x3c65f
movq %rbx, %rdi
callq 0x752d
leaq 0x15059(%rip), %rdi     # 0x3be20
leaq 0x152bd(%rip), %rsi     # 0x3c08b
movq %rax, %rdx
xorl %eax, %eax
callq 0x9c46
leaq 0x158f2(%rip), %rsi     # 0x3c6d1
movq %rbx, %rdi
callq 0x7fb3
ucomiss 0x102c2(%rip), %xmm0    # 0x370b0
jne 0x26df2
jnp 0x26e21
movss %xmm0, 0x215c6(%rip)    # 0x483c0
leaq 0x158d0(%rip), %rsi     # 0x3c6d1
movq %rbx, %rdi
callq 0x752d
leaq 0x15010(%rip), %rdi     # 0x3be20
leaq 0x15288(%rip), %rsi     # 0x3c09f
movq %rax, %rdx
xorl %eax, %eax
callq 0x9c46
leaq 0x15676(%rip), %rsi     # 0x3c49e
movq %rbx, %rdi
callq 0x7663
testl %eax, %eax
je 0x26e6a
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x215e5(%rip)    # 0x48428
leaq 0x15654(%rip), %rsi     # 0x3c49e
movq %rbx, %rdi
callq 0x752d
leaq 0x14fc7(%rip), %rdi     # 0x3be20
leaq 0x15263(%rip), %rsi     # 0x3c0c3
movq %rax, %rdx
xorl %eax, %eax
callq 0x9c46
leaq 0x15691(%rip), %rsi     # 0x3c502
movq %rbx, %rdi
callq 0x7fb3
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x26e83
jnp 0x26eb2
movss %xmm0, 0x215a1(%rip)    # 0x4842c
leaq 0x15670(%rip), %rsi     # 0x3c502
movq %rbx, %rdi
callq 0x752d
leaq 0x14f7f(%rip), %rdi     # 0x3be20
leaq 0x1520d(%rip), %rsi     # 0x3c0b5
movq %rax, %rdx
xorl %eax, %eax
callq 0x9c46
leaq 0x15214(%rip), %rsi     # 0x3c0cd
movq %rbx, %rdi
callq 0x7663
cmpl $0x2, %eax
je 0x26eff
cmpl $0x1, %eax
je 0x26ef6
testl %eax, %eax
jne 0x26f06
leaq 0x2046a(%rip), %rax     # 0x47340
movq (%rax), %rcx
leaq 0x151f3(%rip), %rsi     # 0x3c0d3
movl $0x36, %edi
movq %rcx, %rdx
xorl %eax, %eax
callq 0xa023
callq 0x9f1f
jmp 0x26f06
movb $0x0, 0x54d2b04(%rip)   # 0x54f9a01
jmp 0x26f06
movb $0x1, 0x54d2afb(%rip)   # 0x54f9a01
cmpb $0x0, 0x54d2af4(%rip)   # 0x54f9a01
movq %r14, %rdx
cmovneq %r12, %rdx
leaq 0x14f05(%rip), %rdi     # 0x3be20
leaq 0x15206(%rip), %rsi     # 0x3c128
xorl %eax, %eax
callq 0x9c46
leaq 0x15202(%rip), %rsi     # 0x3c132
movq %rbx, %rdi
callq 0x7663
testl %eax, %eax
je 0x26f61
cmpl $0x1, %eax
je 0x26f52
cmpl $0x2, %eax
jne 0x26f70
movl $0x0, 0x21468(%rip)     # 0x483b8
jmp 0x26f6b
movl $0x1, 0x2145c(%rip)     # 0x483b8
movq %r12, %rdx
jmp 0x26f7e
movl $0x2, 0x2144d(%rip)     # 0x483b8
movq %r14, %rdx
jmp 0x26f7e
cmpl $0x1, 0x21441(%rip)     # 0x483b8
movq %r14, %rdx
cmoveq %r12, %rdx
leaq 0x14e9b(%rip), %r15     # 0x3be20
leaq 0x151ad(%rip), %rsi     # 0x3c139
movq %r15, %rdi
xorl %eax, %eax
callq 0x9c46
cmpl $0x2, 0x2141b(%rip)     # 0x483b8
cmoveq %r12, %r14
leaq 0x151a2(%rip), %rsi     # 0x3c14a
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x9c46
leaq 0x15650(%rip), %rsi     # 0x3c60c
movq %rbx, %rdi
callq 0x7663
testl %eax, %eax
je 0x26fdd
cmpl $0x1, %eax
jne 0x26fed
movb $0x1, 0x54d2a38(%rip)   # 0x54f9a0c
leaq 0x14e75(%rip), %rdx     # 0x3be50
jmp 0x27006
movb $0x0, 0x54d2a28(%rip)   # 0x54f9a0c
leaq 0x14e81(%rip), %rdx     # 0x3be6c
jmp 0x27006
leaq 0x14e5c(%rip), %rax     # 0x3be50
leaq 0x14e71(%rip), %rdx     # 0x3be6c
testb $0x1, 0x54d2a0a(%rip)   # 0x54f9a0c
cmovneq %rax, %rdx
leaq 0x14e13(%rip), %rdi     # 0x3be20
leaq 0x15142(%rip), %rsi     # 0x3c156
xorl %eax, %eax
callq 0x9c46
leaq 0x11c56(%rip), %rdi     # 0x38c78
xorl %eax, %eax
callq 0x9c46
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r14
popq %r15
retq