DispInfo_LoadDisplacements
0x0013b450 · 2502 bytes · __cdecl
_Z26DispInfo_LoadDisplacementsP7model_tb
Decompiled
undefined (2 params)
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* DispInfo_LoadDisplacements(model_t*, bool) */
undefined4 DispInfo_LoadDisplacements(model_t *param_1,bool param_2)
{
MaterialSystem_SortInfo_t *pMVar1;
void *pvVar2;
uint uVar3;
int iVar4;
int iVar5;
CCoreDispInfo *pCVar6;
undefined4 uVar7;
CDispInfo *this;
int iVar8;
uint uVar9;
int iVar10;
ddispinfo_t *pdVar11;
int in_GS_OFFSET;
int iStack_59e40;
int iStack_59e3c;
uint uStack_59e38;
CCoreDispInfo **ppCStack_59e28;
int iStack_59e24;
int iStack_59e20;
int iStack_59e1c;
CCoreDispInfo **ppCStack_59e18;
CDispTri aCStack_59e14 [1024];
CDispVert aCStack_59a14 [5780];
ddispinfo_t adStack_58380 [360448];
CMapLoadHelper local_380 [288];
CMapLoadHelper local_260 [288];
CMapLoadHelper local_140 [288];
int local_20;
pMVar1 = materialSortInfoArray;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
uVar3 = CMapLoadHelper::LumpSize(0x1a);
uVar3 = uVar3 / 0xb0;
iVar4 = CMapLoadHelper::LumpSize(0x20);
iVar5 = CMapLoadHelper::LumpSize(0x22);
if (param_2) {
uVar9 = *(uint *)(*(int *)(param_1 + 0x134) + 0x68);
if (uVar9 != uVar3) {
if (uVar9 == 0) {
if (uVar3 != 0) {
uVar7 = 0;
goto LAB_0013b9b2;
}
}
else {
Error("DispInfo_LoadDisplacments: dispcounts (%d and %d) don\'t match.",uVar9,uVar3);
}
}
if (iVar4 != DAT_0039eb7c) {
Error("DispInfo_LoadDisplacements: lightmap alpha counts (%d and %d) don\'t match.",
DAT_0039eb7c,iVar4);
}
}
else {
*(uint *)(*(int *)(param_1 + 0x134) + 0x68) = uVar3;
iVar8 = *(int *)(param_1 + 0x134);
uVar7 = DispInfo_CreateArray(*(int *)(iVar8 + 0x68));
DAT_0039eb7c = 0;
*(undefined4 *)(iVar8 + 0x6c) = uVar7;
iVar8 = DAT_0039eb7c;
pvVar2 = _DAT_0039eb80;
if (((iVar4 != 0) && (iVar8 = iVar4, pvVar2 = g_DispLMAlpha, (int)DAT_0039eb74 < iVar4)) &&
(pvVar2 = g_DispLMAlpha, -1 < DAT_0039eb78)) {
if (DAT_0039eb78 == 0) {
if ((DAT_0039eb74 != 0) || (DAT_0039eb74 = 0x20, 0x20 < iVar4)) {
do {
DAT_0039eb74 = DAT_0039eb74 * 2;
} while ((int)DAT_0039eb74 < iVar4);
}
}
else {
for (DAT_0039eb74 = ((iVar4 + -1) / DAT_0039eb78 + 1) * DAT_0039eb78;
(int)DAT_0039eb74 < iVar4; DAT_0039eb74 = (int)(DAT_0039eb74 + iVar4) / 2) {
}
}
if (g_DispLMAlpha == (void *)0x0) {
g_DispLMAlpha = malloc(DAT_0039eb74);
pvVar2 = g_DispLMAlpha;
}
else {
g_DispLMAlpha = realloc(g_DispLMAlpha,DAT_0039eb74);
iVar10 = DAT_0039eb7c;
iVar8 = iVar4 + DAT_0039eb7c;
pvVar2 = g_DispLMAlpha;
if ((0 < iVar4) && (pvVar2 = g_DispLMAlpha, 0 < DAT_0039eb7c)) {
DAT_0039eb7c = iVar8;
_DAT_0039eb80 = g_DispLMAlpha;
_V_memmove((void *)((int)g_DispLMAlpha + iVar4),g_DispLMAlpha,iVar10);
iVar8 = DAT_0039eb7c;
pvVar2 = _DAT_0039eb80;
}
}
}
_DAT_0039eb80 = pvVar2;
DAT_0039eb7c = iVar8;
CMapLoadHelper::CMapLoadHelper(local_260,0x20);
/* try { // try from 0013bc53 to 0013bc81 has its CatchHandler @ 0013be5d */
CMapLoadHelper::LoadLumpData(local_260,0,iVar4,g_DispLMAlpha);
DAT_0039eb68 = 0;
iVar4 = DAT_0039eb68;
if (iVar5 != 0) {
if (DAT_0039eb64 < iVar5) {
iVar10 = iVar5 - DAT_0039eb64;
/* try { // try from 0013bd3d to 0013bd82 has its CatchHandler @ 0013be5d */
g_DispLightmapSamplePositions = (void *)Hunk_AllocName(iVar10,(char *)0x0,false);
iVar8 = DAT_0039eb68;
iVar4 = iVar5 + DAT_0039eb68;
DAT_0039eb64 = iVar10;
_DAT_0039eb6c = g_DispLightmapSamplePositions;
if ((0 < iVar5) && (0 < DAT_0039eb68)) {
DAT_0039eb68 = iVar4;
_V_memmove((void *)((int)g_DispLightmapSamplePositions + iVar5),
g_DispLightmapSamplePositions,iVar8);
iVar4 = DAT_0039eb68;
}
}
else {
_DAT_0039eb6c = g_DispLightmapSamplePositions;
iVar4 = iVar5;
}
}
DAT_0039eb68 = iVar4;
CMapLoadHelper::CMapLoadHelper(local_140,0x22);
/* try { // try from 0013bca0 to 0013bca4 has its CatchHandler @ 0013be37 */
CMapLoadHelper::LoadLumpData(local_140,0,iVar5,g_DispLightmapSamplePositions);
CMapLoadHelper::~CMapLoadHelper(local_140);
CMapLoadHelper::~CMapLoadHelper(local_260);
}
DispInfo_ReleaseMaterialSystemObjects(param_1);
if (0x800 < uVar3) {
Error("DispInfo_LoadDisplacements: nDisplacements (%d) > MAX_MAP_DISPINFO (%d)",uVar3,0x800);
}
CMapLoadHelper::CMapLoadHelper(local_380,0x1a);
/* try { // try from 0013b590 to 0013b60c has its CatchHandler @ 0013bee6 */
CMapLoadHelper::LoadLumpData(local_380,0,uVar3 * 0xb0,adStack_58380);
DispInfo_LinkToParentFaces(param_1,adStack_58380,uVar3);
DispInfo_CreateMaterialGroups(param_1,pMVar1);
if (g_VBAllocTracker != (int *)0x0) {
(**(code **)(*g_VBAllocTracker + 8))(g_VBAllocTracker,"DispInfo_LoadDisplacements");
}
DispInfo_CreateEmptyStaticBuffers(param_1,adStack_58380);
if (g_VBAllocTracker != (int *)0x0) {
(**(code **)(*g_VBAllocTracker + 8))(g_VBAllocTracker,0);
}
ppCStack_59e28 = (CCoreDispInfo **)0x0;
iStack_59e24 = 0;
iStack_59e20 = 0;
iStack_59e1c = 0;
ppCStack_59e18 = (CCoreDispInfo **)0x0;
uStack_59e38 = 0;
if (uVar3 != 0) {
do {
/* try { // try from 0013b6a8 to 0013b6ac has its CatchHandler @ 0013bead */
pCVar6 = operator_new(0x208);
/* try { // try from 0013b6b2 to 0013b6b6 has its CatchHandler @ 0013be61 */
CCoreDispInfo::CCoreDispInfo(pCVar6);
iVar5 = iStack_59e1c;
iVar4 = iStack_59e1c + 1;
if ((iStack_59e24 < iVar4) && (-1 < iStack_59e20)) {
if (iStack_59e20 == 0) {
if (iStack_59e24 == 0) {
if (iVar4 < 9) {
iStack_59e24 = 8;
goto LAB_0013b6ff;
}
iStack_59e24 = 8;
}
do {
iStack_59e24 = iStack_59e24 * 2;
} while (iStack_59e24 < iVar4);
}
else {
for (iStack_59e24 = (iStack_59e1c / iStack_59e20 + 1) * iStack_59e20; iStack_59e24 < iVar4
; iStack_59e24 = (iStack_59e24 + iVar4) / 2) {
}
}
LAB_0013b6ff:
if (ppCStack_59e28 == (CCoreDispInfo **)0x0) {
ppCStack_59e28 = malloc(iStack_59e24 << 2);
}
else {
ppCStack_59e28 = realloc(ppCStack_59e28,iStack_59e24 << 2);
iVar4 = iStack_59e1c + 1;
}
}
iVar8 = (iVar4 - iVar5) + -1;
iStack_59e1c = iVar4;
ppCStack_59e18 = ppCStack_59e28;
if (0 < iVar8) {
/* try { // try from 0013b74d to 0013b7b3 has its CatchHandler @ 0013bead */
_V_memmove(ppCStack_59e28 + iVar5 + 1,ppCStack_59e28 + iVar5,iVar8 * 4);
}
if (ppCStack_59e28 + iVar5 != (CCoreDispInfo **)0x0) {
ppCStack_59e28[iVar5] = pCVar6;
}
uStack_59e38 = uStack_59e38 + 1;
} while (uVar3 != uStack_59e38);
}
CMapLoadHelper::CMapLoadHelper(local_260,0x21);
/* try { // try from 0013b7cb to 0013b7cf has its CatchHandler @ 0013bed7 */
CMapLoadHelper::CMapLoadHelper(local_140,0x30);
if (uVar3 != 0) {
uStack_59e38 = 0;
pdVar11 = adStack_58380;
iStack_59e40 = 0;
iStack_59e3c = 0;
do {
iVar4 = (1 << ((byte)*(undefined4 *)(pdVar11 + 0x14) & 0x1f)) + 1;
iVar4 = iVar4 * iVar4;
if (0x121 < iVar4) {
/* try { // try from 0013b850 to 0013b94d has its CatchHandler @ 0013beb7 */
Error("DispInfo_LoadDisplacements: invalid vertex count (%d)",iVar4);
}
CMapLoadHelper::LoadLumpData(local_260,iStack_59e3c * 0x14,iVar4 * 0x14,aCStack_59a14);
iStack_59e3c = iStack_59e3c + iVar4;
iVar5 = (1 << ((byte)*(undefined4 *)(pdVar11 + 0x14) & 0x1f)) <<
((byte)*(undefined4 *)(pdVar11 + 0x14) & 0x1f);
iVar4 = iVar5 * 2;
if (0x200 < iVar4) {
Error("DispInfo_LoadDisplacements: invalid tri count (%d)",iVar4);
}
CMapLoadHelper::LoadLumpData(local_140,iStack_59e40 * 2,iVar5 << 2,aCStack_59e14);
iStack_59e40 = iStack_59e40 + iVar4;
uVar7 = DispInfo_CreateFromMapDisp
(param_1,uStack_59e38,pdVar11,ppCStack_59e28[uStack_59e38],aCStack_59a14,
aCStack_59e14,pMVar1,param_2);
if ((char)uVar7 == '\0') goto LAB_0013b956;
uStack_59e38 = uStack_59e38 + 1;
pdVar11 = pdVar11 + 0xb0;
} while (uVar3 != uStack_59e38);
}
/* try { // try from 0013ba19 to 0013bbcd has its CatchHandler @ 0013beb7 */
SmoothDispSurfNormals(ppCStack_59e28,uVar3);
uVar9 = 0;
if (uVar3 != 0) {
do {
DispInfo_CreateStaticBuffersAndTags(param_1,uVar9,ppCStack_59e28[uVar9],aCStack_59a14);
DispInfo_IndexArray(*(void **)(*(int *)(param_1 + 0x134) + 0x6c),uVar9);
uVar9 = uVar9 + 1;
} while (uVar3 != uVar9);
}
iVar4 = 0;
if (0 < iStack_59e1c) {
do {
pCVar6 = ppCStack_59e28[iVar4];
if (pCVar6 != (CCoreDispInfo *)0x0) {
CCoreDispInfo::~CCoreDispInfo(pCVar6);
operator_delete(pCVar6);
}
iVar4 = iVar4 + 1;
} while (iVar4 < iStack_59e1c);
}
uVar9 = 0;
iStack_59e1c = 0;
CUtlMemory<CCoreDispInfo*,int>::Purge((CUtlMemory<CCoreDispInfo*,int> *)&ppCStack_59e28);
ppCStack_59e18 = ppCStack_59e28;
if (uVar3 != 0) {
do {
iVar4 = DispInfo_IndexArray(*(void **)(*(int *)(param_1 + 0x134) + 0x6c),uVar9);
uVar9 = uVar9 + 1;
*(undefined4 *)(iVar4 + 0x118) = *(undefined4 *)(iVar4 + 0x140);
*(undefined4 *)(iVar4 + 0x11c) = *(undefined4 *)(iVar4 + 0x144);
*(undefined4 *)(iVar4 + 0x120) = *(undefined4 *)(iVar4 + 0x148);
*(undefined4 *)(iVar4 + 0x124) = *(undefined4 *)(iVar4 + 0x14c);
*(undefined4 *)(iVar4 + 0x128) = *(undefined4 *)(iVar4 + 0x150);
*(undefined4 *)(iVar4 + 300) = *(undefined4 *)(iVar4 + 0x154);
*(undefined4 *)(iVar4 + 0x130) = *(undefined4 *)(iVar4 + 0x158);
*(undefined4 *)(iVar4 + 0x134) = *(undefined4 *)(iVar4 + 0x15c);
*(undefined4 *)(iVar4 + 0x138) = *(undefined4 *)(iVar4 + 0x160);
*(undefined4 *)(iVar4 + 0x13c) = *(undefined4 *)(iVar4 + 0x164);
} while (uVar3 != uVar9);
uVar9 = 0;
do {
this = (CDispInfo *)DispInfo_IndexArray(*(void **)(*(int *)(param_1 + 0x134) + 0x6c),uVar9);
CDispInfo::TesselateDisplacement(this);
uVar9 = uVar9 + 1;
} while (uVar3 != uVar9);
}
SetupMeshReaders(param_1,uVar3);
UpdateDispBBoxes(param_1,uVar3);
uVar7 = 1;
LAB_0013b956:
CMapLoadHelper::~CMapLoadHelper(local_140);
CMapLoadHelper::~CMapLoadHelper(local_260);
iStack_59e1c = 0;
CUtlMemory<CCoreDispInfo*,int>::Purge((CUtlMemory<CCoreDispInfo*,int> *)&ppCStack_59e28);
ppCStack_59e18 = ppCStack_59e28;
CUtlMemory<CCoreDispInfo*,int>::Purge((CUtlMemory<CCoreDispInfo*,int> *)&ppCStack_59e28);
CMapLoadHelper::~CMapLoadHelper(local_380);
LAB_0013b9b2:
if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
return uVar7;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
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.