L L4D2node

CAI_BehaviorBase::MaintainSchedule

0x005a6700 · 660 bytes · __thiscall

_ZN16CAI_BehaviorBase16MaintainScheduleEi

Decompiled

undefined (2 params)

/* CAI_BehaviorBase::MaintainSchedule(int) */

void __thiscall CAI_BehaviorBase::MaintainSchedule(CAI_BehaviorBase *this,int param_1)

{
  AIChannelScheduleState_t AVar1;
  int iVar2;
  char cVar3;
  AIChannelScheduleState_t AVar4;
  int iVar5;
  int *piVar6;
  undefined4 uVar7;
  undefined1 *puVar8;
  CAI_Schedule *pCVar9;
  int iVar10;
  AIChannelScheduleState_t *pAVar11;
  char *local_30;
  int local_20;
  
  local_20 = 0;
  iVar5 = param_1 * 0x28;
  pAVar11 = (AIChannelScheduleState_t *)(*(int *)(this + 0xc) + iVar5);
  AVar1 = *pAVar11;
  if (AVar1 == (AIChannelScheduleState_t)0x0) {
    return;
  }
  do {
    if ((*(int *)(pAVar11 + 4) != 0) && (*(int *)(pAVar11 + 0x14) == 4)) {
      *(int *)(pAVar11 + 0x10) = *(int *)(pAVar11 + 0x10) + 1;
      *(undefined4 *)(pAVar11 + 0x14) = 0;
    }
    cVar3 = IsScheduleValid(this,pAVar11);
    if (cVar3 == '\0') {
      pAVar11[0x24] = (AIChannelScheduleState_t)0x1;
      (**(code **)(*(int *)this + 0x198))(this,param_1);
      if (*(int *)(pAVar11 + 0x20) == 0) {
        pCVar9 = (CAI_Schedule *)GetNewSchedule(this,param_1);
        SetSchedule(this,param_1,pCVar9);
        goto LAB_005a675d;
      }
      pCVar9 = (CAI_Schedule *)GetFailSchedule(this,pAVar11);
      *(undefined4 *)(pAVar11 + 8) = *(undefined4 *)pCVar9;
      if (*(int *)(pAVar11 + 4) == 0) {
        local_30 = "GetCurSchedule() == NULL";
      }
      else {
        local_30 = *(char **)(*(int *)(pAVar11 + 4) + 0x2c);
      }
      puVar8 = *(undefined1 **)(*(int *)(this + 4) + 0x154);
      if (puVar8 == (undefined1 *)0x0) {
        puVar8 = &DAT_00d539c2;
      }
      DevWarning(2,"(%s) Schedule (%s) Failed at %d!\n",puVar8,local_30,
                 *(undefined4 *)(pAVar11 + 0x10));
      SetSchedule(this,param_1,pCVar9);
      piVar6 = *(int **)(pAVar11 + 4);
    }
    else {
LAB_005a675d:
      piVar6 = *(int **)(pAVar11 + 4);
    }
    if (piVar6 == (int *)0x0) {
      pCVar9 = (CAI_Schedule *)GetNewSchedule(this,param_1);
      if (pCVar9 != (CAI_Schedule *)0x0) {
        SetSchedule(this,param_1,pCVar9);
      }
      piVar6 = *(int **)(pAVar11 + 4);
      if (piVar6 == (int *)0x0) {
        return;
      }
    }
    if (piVar6[2] == 0) {
      return;
    }
    if (*(int *)(pAVar11 + 0x14) == 0) {
      if (*(int *)(pAVar11 + 0x10) == 0) {
        iVar2 = *piVar6;
        iVar10 = (**(code **)(*(int *)this + 0x180))(this);
        iVar10 = CAI_LocalIdSpace::GlobalToLocal((CAI_LocalIdSpace *)(iVar10 + 4),iVar2);
        if (iVar10 == -1) {
          iVar10 = iVar2;
        }
        (**(code **)(*(int *)this + 0x19c))(this,param_1,iVar10);
      }
      uVar7 = GetCurTask(this,param_1);
      iVar2 = gpGlobals;
      *(undefined4 *)(pAVar11 + 0x14) = 1;
      *(undefined4 *)(pAVar11 + 0x20) = 0;
      *(undefined4 *)(pAVar11 + 0x1c) = *(undefined4 *)(iVar2 + 0xc);
      (**(code **)(*(int *)this + 0x1ac))(this,param_1,uVar7);
    }
    AVar4 = AVar1;
    if ((*(int *)(*(int *)(this + 0xc) + 0x14 + iVar5) != 4) &&
       (iVar2 = *(int *)(pAVar11 + 0x14), iVar2 != 0)) {
      if (iVar2 == 2) {
        return;
      }
      if (iVar2 == 4) {
        return;
      }
      if (*(int *)(pAVar11 + 0x20) != 0) {
        return;
      }
      uVar7 = GetCurTask(this,param_1);
      (**(code **)(*(int *)this + 0x1b0))(this,param_1,uVar7);
      AVar4 = (AIChannelScheduleState_t)(*(int *)(*(int *)(this + 0xc) + 0x14 + iVar5) == 4);
    }
    local_20 = local_20 + 1;
    if (AVar4 == (AIChannelScheduleState_t)0x0) {
      return;
    }
    if (9 < local_20) {
      return;
    }
  } while( true );
}

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)