L L4D2node

ReserveThreads

0x00175a80 · 267 bytes · __cdecl

_Z14ReserveThreadsi

Decompiled

undefined (1 param)

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* ReserveThreads(int) */

void ReserveThreads(int param_1)

{
  code *pcVar1;
  int *piVar2;
  int iVar3;
  undefined4 *puVar4;
  int *local_20 [4];
  
  iVar3 = (**(code **)(*_g_pThreadPool + 0x1c))(_g_pThreadPool);
  if (iVar3 < param_1) {
    iVar3 = (**(code **)(*_g_pThreadPool + 0x1c))(_g_pThreadPool);
  }
  else {
    iVar3 = 0;
    if (-1 < param_1) {
      iVar3 = param_1;
    }
  }
  CThreadEvent::Set();
  while (g_NumReservedThreads != 0) {
    ThreadSleep(0);
  }
  CThreadEvent::Reset();
  piVar2 = _g_pThreadPool;
  for (; _g_pThreadPool = piVar2, iVar3 != 0; iVar3 = iVar3 + -1) {
    LOCK();
    g_NumReservedThreads = g_NumReservedThreads + 1;
    UNLOCK();
    pcVar1 = *(code **)(*piVar2 + 0x54);
    puVar4 = operator_new(0x14);
    puVar4[3] = 1;
    *puVar4 = &PTR_AddRef_002b4308;
    puVar4[2] = &PTR__CFunctor0_002b4324;
    puVar4[4] = ThreadPoolReserverFunction;
    (*pcVar1)(piVar2,puVar4,local_20,0,8);
    (**(code **)(*local_20[0] + 4))(local_20[0]);
    piVar2 = _g_pThreadPool;
  }
  Msg("%d threads being reserved\n",g_NumReservedThreads);
  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)