L L4D2node

CModelRender::ComputeAmbientBoost

0x00187290 · 552 bytes · __thiscall

_ZN12CModelRender19ComputeAmbientBoostEiPK15LightingQuery_tP23MaterialLightingState_t

Decompiled

undefined (4 params)

/* CModelRender::ComputeAmbientBoost(int, LightingQuery_t const*, MaterialLightingState_t*) */

void __thiscall
CModelRender::ComputeAmbientBoost
          (CModelRender *this,int param_1,LightingQuery_t *param_2,MaterialLightingState_t *param_3)

{
  LightingQuery_t *pLVar1;
  float fVar2;
  MaterialLightingState_t *pMVar3;
  MaterialLightingState_t *pMVar4;
  int iVar5;
  float fVar6;
  float fVar7;
  float fVar8;
  float fVar9;
  float fVar10;
  float fVar11;
  
  if ((*(int *)(r_ambientboost._28_4_ + 0x30) != 0) && (0 < param_1)) {
    fVar10 = 0.0;
    fVar9 = 0.0;
    pLVar1 = param_2 + param_1 * 0x14;
    pMVar4 = param_3 + 0x48;
    do {
      if ((param_2[0x10] != (LightingQuery_t)0x0) &&
         (fVar2 = *(float *)(param_3 + 0x54), fVar2 != 0.0)) {
        iVar5 = 6;
        pMVar3 = param_3;
        do {
          iVar5 = iVar5 + -1;
          fVar7 = *(float *)(pMVar3 + 4) * 0.59 + *(float *)pMVar3 * 0.3 +
                  *(float *)(pMVar3 + 8) * 0.11;
          if (fVar10 <= fVar7) {
            fVar10 = fVar7;
          }
          fVar9 = fVar9 + fVar7;
          pMVar3 = pMVar3 + 0xc;
        } while (iVar5 != 0);
        fVar9 = fVar9 * 0.16666667;
        fVar7 = 0.0;
        if (0 < (int)fVar2) {
          fVar6 = 0.0;
          fVar7 = 0.0;
          pMVar3 = param_3;
          do {
            fVar11 = 1.0;
            fVar8 = (*(float *)(pMVar3 + 0x6c) - *(float *)(pMVar4 + 4)) *
                    (*(float *)(pMVar3 + 0x6c) - *(float *)(pMVar4 + 4)) +
                    (*(float *)(pMVar3 + 0x68) - *(float *)pMVar4) *
                    (*(float *)(pMVar3 + 0x68) - *(float *)pMVar4) +
                    (*(float *)(pMVar3 + 0x70) - *(float *)(pMVar4 + 8)) *
                    (*(float *)(pMVar3 + 0x70) - *(float *)(pMVar4 + 8));
            fVar8 = SQRT(fVar8) * *(float *)(pMVar3 + 0x8c) + *(float *)(pMVar3 + 0x88) +
                    fVar8 * *(float *)(pMVar3 + 0x90);
            if (1e-05 < fVar8) {
              fVar11 = 1.0 / fVar8;
            }
            fVar6 = (float)((int)fVar6 + 1);
            fVar7 = fVar7 + (*(float *)(pMVar3 + 0x60) * 0.59 + *(float *)(pMVar3 + 0x5c) * 0.3 +
                            *(float *)(pMVar3 + 100) * 0.11) * fVar11;
            pMVar3 = pMVar3 + 0x58;
          } while (fVar6 != fVar2);
        }
        if ((fVar9 < *(float *)(r_ambientmin._28_4_ + 0x2c)) &&
           (fVar7 = fVar7 * *(float *)(r_ambientfraction._28_4_ + 0x2c), fVar9 < fVar7)) {
          fVar7 = fVar7 / fVar10;
          iVar5 = 6;
          pMVar3 = param_3;
          if (*(float *)(r_ambientfactor._28_4_ + 0x2c) <= fVar7) {
            fVar7 = *(float *)(r_ambientfactor._28_4_ + 0x2c);
          }
          do {
            *(float *)pMVar3 = *(float *)pMVar3 * fVar7;
            *(float *)(pMVar3 + 4) = *(float *)(pMVar3 + 4) * fVar7;
            *(float *)(pMVar3 + 8) = *(float *)(pMVar3 + 8) * fVar7;
            iVar5 = iVar5 + -1;
            pMVar3 = pMVar3 + 0xc;
          } while (iVar5 != 0);
        }
      }
      param_2 = param_2 + 0x14;
      param_3 = param_3 + 0x1b8;
      pMVar4 = pMVar4 + 0x1b8;
    } while (param_2 != pLVar1);
  }
  return;
}

SourceMod gamedata

paste into addons/sourcemod/gamedata/<your_plugin>.txt
used as the SourceMod key — change to fit your plugin's convention
SourceMod library name (server / engine / matchmaking)

Just a Signatures{} block, ready to drop into a gamedata file. Wire it up in your plugin however you like - SDKCall, DHooks, raw memory ops, or anything else.



        

        

          

Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.

Return-type handling cheatsheet (DHookReturn)