L L4D2node

CResponseSystem::GetBestResponse

0x005b7bf0 · 604 bytes · __thiscall

_ZN15CResponseSystem15GetBestResponseERNS_20ResponseSearchResultEP4RulebP15IResponseFilter

Decompiled

undefined (5 params)

/* CResponseSystem::GetBestResponse(CResponseSystem::ResponseSearchResult&, Rule*, bool,
   IResponseFilter*) */

undefined4 __thiscall
CResponseSystem::GetBestResponse
          (CResponseSystem *this,ResponseSearchResult *param_1,Rule *param_2,bool param_3,
          IResponseFilter *param_4)

{
  ResponseGroup *pRVar1;
  byte bVar2;
  byte bVar3;
  int iVar4;
  char cVar5;
  ushort uVar6;
  int iVar7;
  uint uVar8;
  int iVar9;
  undefined4 uVar10;
  undefined1 *puVar11;
  int iVar12;
  int iVar13;
  undefined4 local_24 [5];
  
  if (*(int *)(param_2 + 0x18) != 0) {
    iVar7 = (**(code **)(*random_valve + 8))(random_valve,0,*(int *)(param_2 + 0x18) + -1);
    iVar7 = (uint)*(ushort *)(*(int *)(param_2 + 0x10) + iVar7 * 2) * 0x20;
    iVar13 = iVar7 + *(int *)(this + 0x10);
    if ((*(char *)(iVar13 + 0x1c) != '\0') && (iVar4 = *(int *)(iVar13 + 0x14), iVar4 != 0)) {
      pRVar1 = (ResponseGroup *)(iVar13 + 0xc);
      if ((*(byte *)(iVar13 + 0x1f) & 8) == 0) {
        uVar8 = SelectWeightedResponseFromResponseGroup(this,pRVar1,param_4);
        if (-1 < (int)uVar8) {
          iVar12 = uVar8 * 0x50;
LAB_005b7cc4:
          iVar12 = iVar12 + *(int *)(iVar13 + 0xc);
          if (param_3) {
            local_24[0] = *(undefined4 *)(*(int *)(this + 0x10) + 8 + iVar7);
            uVar6 = CUtlRBTree<CUtlMap<unsigned_int,char_const*,unsigned_short>::Node_t,unsigned_short,CUtlMap<unsigned_int,char_const*,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<unsigned_int,char_const*,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
                    ::Find((CUtlRBTree<CUtlMap<unsigned_int,char_const*,unsigned_short>::Node_t,unsigned_short,CUtlMap<unsigned_int,char_const*,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<unsigned_int,char_const*,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
                            *)(this + 0x28),(Node_t *)local_24);
            if (uVar6 == 0xffff) {
              puVar11 = &DAT_00d539c2;
            }
            else {
              puVar11 = *(undefined1 **)((uint)uVar6 * 0x10 + *(int *)(this + 0x2c) + 0xc);
            }
            DebugPrint(this,0,"%s\n",puVar11);
            DebugPrint(this,0,"{\n");
            DescribeResponseGroup(this,pRVar1,uVar8,0);
          }
          if ((*(byte *)(iVar12 + 0x2f) & 0x3f) == 4) {
            uVar10 = ResolveResponse(this,param_1,1,*(char **)(iVar12 + 0x28),param_3,param_4);
          }
          else {
            *(int *)(param_1 + 4) = iVar12;
            *(ResponseGroup **)param_1 = pRVar1;
            uVar10 = 1;
          }
          if (param_3) {
            DebugPrint(this,0,"}\n");
            return uVar10;
          }
          return uVar10;
        }
      }
      else {
        bVar2 = *(byte *)(iVar13 + 0x1d);
        bVar3 = bVar2;
        do {
          uVar8 = (uint)bVar3;
          *(byte *)(iVar13 + 0x1d) = bVar3 + 1;
          if ((int)uVar8 < iVar4) {
            iVar12 = uVar8 * 0x50;
          }
          else {
            if ((*(byte *)(iVar13 + 0x1f) & 0x10) != 0) {
              *(undefined1 *)(iVar13 + 0x1c) = 0;
              return 0;
            }
            *(undefined1 *)(iVar13 + 0x1d) = 0;
            iVar12 = 0;
            uVar8 = 0;
          }
          if ((param_4 == (IResponseFilter *)0x0) ||
             (iVar9 = iVar12 + *(int *)(iVar13 + 0xc),
             cVar5 = (*(code *)**(undefined4 **)param_4)
                               (param_4,*(byte *)(iVar9 + 0x2f) & 0x3f,*(undefined4 *)(iVar9 + 0x28)
                               ), cVar5 != '\0')) goto LAB_005b7cc4;
          bVar3 = *(byte *)(iVar13 + 0x1d);
        } while (bVar2 != bVar3);
      }
    }
  }
  return 0;
}

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)