ED_Alloc
0x001d6a40 · 458 bytes · __cdecl
_Z8ED_Alloci
Decompiled
undefined (1 param)
/* ED_Alloc(int) */
edict_t * ED_Alloc(int param_1)
{
int iVar1;
int iVar2;
edict_t *peVar3;
int iVar4;
longdouble lVar5;
float fVar6;
iVar2 = DAT_003b8174;
if (-1 < param_1) {
if (DAT_003b816c <= param_1) {
Warning("ED_Alloc( %d ) - invalid edict index specified.",param_1);
return (edict_t *)0x0;
}
peVar3 = (edict_t *)(param_1 * 0x10 + DAT_003b8174);
if (((byte)*peVar3 & 2) == 0) {
return (edict_t *)0x0;
}
ED_ClearEdict(peVar3);
return peVar3;
}
iVar1 = CBaseServer::GetMaxClients((CBaseServer *)&sv);
peVar3 = (edict_t *)(iVar2 + (iVar1 + 1) * 0x10);
iVar2 = CBaseServer::GetMaxClients((CBaseServer *)&sv);
iVar2 = iVar2 + 1;
iVar1 = DAT_003b816c;
if (iVar2 < DAT_003b816c) {
iVar4 = -1;
do {
if (((byte)*peVar3 & 2) != 0) {
fVar6 = *(float *)(g_EdictFreeTime + iVar2 * 4);
if (2.0 <= fVar6) {
lVar5 = (longdouble)CBaseServer::GetTime((CBaseServer *)&sv);
fVar6 = *(float *)(g_EdictFreeTime + iVar2 * 4);
iVar1 = DAT_003b816c;
iVar4 = iVar2;
if ((float)lVar5 - fVar6 < 1.0) goto LAB_001d6b60;
}
if ((fVar6 == 0.0) && (*(int *)(sv_useexplicitdelete._28_4_ + 0x30) != 0)) {
CFrameSnapshotManager::AddExplicitDelete
((CFrameSnapshotManager *)framesnapshotmanager,iVar2);
}
goto LAB_001d6b08;
}
LAB_001d6b60:
iVar2 = iVar2 + 1;
peVar3 = peVar3 + 0x10;
} while (iVar2 < iVar1);
if (iVar1 < DAT_003b8170) goto LAB_001d6bd8;
if (-1 < iVar4) {
if ((*(float *)(g_EdictFreeTime + iVar4 * 4) == 0.0) &&
(*(int *)(sv_useexplicitdelete._28_4_ + 0x30) != 0)) {
CFrameSnapshotManager::AddExplicitDelete
((CFrameSnapshotManager *)framesnapshotmanager,iVar4);
}
peVar3 = (edict_t *)(DAT_003b8174 + iVar4 * 0x10);
LAB_001d6b08:
ED_ClearEdict(peVar3);
return peVar3;
}
}
else if (DAT_003b816c < DAT_003b8170) goto LAB_001d6bd8;
if (DAT_003b8170 == 0) {
Sys_Error("ED_Alloc: No edicts yet");
}
Sys_Error("ED_Alloc: no free edicts");
iVar1 = DAT_003b816c;
LAB_001d6bd8:
DAT_003b816c = iVar1 + 1;
ED_ClearEdict(peVar3);
return peVar3;
}
SourceMod gamedata
paste intoaddons/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.
Signatures + Functions block. The plugin uses
DHookCreateFromConf - DHooks reads return type, this-type,
calling convention, and argument types straight from the gamedata. Less
boilerplate in the plugin, types travel with the gamedata.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.