CMapLoadHelper::Init
0x001951a0 · 1146 bytes · __cdecl
_ZN14CMapLoadHelper4InitEP7model_tPKc
Decompiled
undefined (2 params)
/* CMapLoadHelper::Init(model_t*, char const*) */
void CMapLoadHelper::Init(model_t *param_1,char *param_2)
{
char cVar1;
int iVar2;
int iVar3;
int iVar4;
int in_GS_OFFSET;
undefined4 local_634;
uint local_630;
undefined4 local_62c [257];
char local_228 [260];
undefined1 local_124 [260];
int local_20;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
s_nMapLoadRecursion = s_nMapLoadRecursion + 1;
if (s_nMapLoadRecursion < 2) {
s_pMap = (undefined *)0x0;
s_MapFileHandle = 0;
_V_memset(&s_MapHeader,0,0x40c);
_V_memset(&s_MapLumpFiles,0,0x700);
if (param_1 == (model_t *)0x0) {
V_strncpy(s_szMapPathName,param_2,0x104);
}
else {
V_strncpy(s_szMapPathName,(char *)(param_1 + 4),0x104);
}
V_strncpy(local_228,s_szMapPathName,0x104);
s_MapFileHandle =
(**(code **)(*g_pFileSystem + 0x114))(g_pFileSystem,local_228,&DAT_002a3e98,0,0,0);
if (s_MapFileHandle == 0) {
s_nMapLoadRecursion = s_nMapLoadRecursion + -1;
Host_Error("CMapLoadHelper::Init, unable to open %s\n",local_228);
}
else {
(**(code **)g_pFileSystem[1])(g_pFileSystem + 1,&s_MapHeader,0x40c,s_MapFileHandle);
iVar4 = DAT_003a8704;
if (s_MapHeader == 0x50534256) {
if (DAT_003a8704 < 0x15) {
memcpy(&local_634,&s_MapHeader,0x40c);
iVar3 = 0;
do {
*(undefined4 *)((int)&DAT_003a870c + iVar3) = *(undefined4 *)((int)local_62c + iVar3);
*(undefined4 *)((int)&DAT_003a8710 + iVar3) =
*(undefined4 *)((int)local_62c + iVar3 + 4);
iVar2 = iVar3 + 0x10;
*(undefined4 *)((int)&DAT_003a8708 + iVar3) =
*(undefined4 *)((int)local_62c + iVar3 + 8);
iVar3 = iVar2;
} while (iVar2 != 0x400);
}
if (iVar4 - 0x13U < 3) {
if (g_ServerGlobalVariables._64_4_ == 0) {
g_ServerGlobalVariables._64_4_ = DAT_003a8b08;
}
s_pMap = &DAT_003a8b88;
iVar4 = 0;
do {
if (serverGameDLL != (int *)0x0) {
(**(code **)(*serverGameDLL + 0xa0))
(serverGameDLL,s_szMapPathName,local_124,0x104,iVar4);
}
cVar1 = (**(code **)(g_pFileSystem[1] + 0x28))(g_pFileSystem + 1,local_124,0);
if (cVar1 == '\0') break;
iVar3 = (**(code **)(g_pFileSystem[1] + 8))(g_pFileSystem + 1,local_124,&DAT_002a3e98,0)
;
if (iVar3 == 0) {
s_nMapLoadRecursion = s_nMapLoadRecursion + -1;
if (s_nMapLoadRecursion < 1) {
Shutdown();
}
Host_Error("CMapLoadHelper::Init, failed to load lump file %s\n",local_124);
break;
}
local_634 = 0;
local_630 = 0;
local_62c[0] = 0;
local_62c[1] = 0;
local_62c[2] = 0;
(**(code **)g_pFileSystem[1])(g_pFileSystem + 1,&local_634,0x14,iVar3);
if (local_630 < 0x40) {
if ((&s_MapLumpFiles)[local_630 * 7] != 0) {
(**(code **)(g_pFileSystem[1] + 0xc))
(g_pFileSystem + 1,(&s_MapLumpFiles)[local_630 * 7]);
}
iVar2 = local_630 * 0x1c;
(&s_MapLumpFiles)[local_630 * 7] = iVar3;
*(int *)(&DAT_003a7d64 + iVar2) = iVar4;
*(undefined4 *)(&DAT_003a7d68 + iVar2) = local_634;
*(uint *)(&DAT_003a7d6c + iVar2) = local_630;
*(undefined4 *)(&DAT_003a7d70 + iVar2) = local_62c[0];
*(undefined4 *)(&DAT_003a7d74 + iVar2) = local_62c[1];
*(undefined4 *)(&DAT_003a7d78 + iVar2) = local_62c[2];
}
else {
Warning("Found invalid lump file \'%s\'. Lump Id: %d\n",local_124,local_630);
}
iVar4 = iVar4 + 1;
} while (iVar4 != 0x80);
}
else {
(**(code **)(g_pFileSystem[1] + 0xc))(g_pFileSystem + 1,s_MapFileHandle);
s_nMapLoadRecursion = s_nMapLoadRecursion + -1;
s_MapFileHandle = 0;
Host_Error("CMapLoadHelper::Init, map %s has wrong version (%i when expecting %i)\n",
local_228,DAT_003a8704,0x15);
}
}
else {
(**(code **)(g_pFileSystem[1] + 0xc))(g_pFileSystem + 1,s_MapFileHandle);
s_nMapLoadRecursion = s_nMapLoadRecursion + -1;
s_MapFileHandle = 0;
Host_Error("CMapLoadHelper::Init, map %s has wrong identifier\n",local_228);
}
}
}
if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
return;
}
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.