Host_Init
0x0017a0f0 · 2128 bytes · __cdecl
_Z9Host_Initb
Decompiled
undefined (1 param)
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* Host_Init(bool) */
void Host_Init(bool param_1)
{
char cVar1;
int *piVar2;
int iVar3;
undefined4 *puVar4;
undefined4 uVar5;
int *piVar6;
CDevShotGenerator *this;
CMapReslistGenerator *this_00;
float fVar7;
int in_GS_OFFSET;
longdouble lVar8;
double dVar9;
undefined1 *puVar10;
char *pcVar11;
char *local_644;
undefined4 local_640;
undefined4 local_63c;
undefined4 local_638;
undefined4 local_634;
undefined4 local_630;
byte local_52c;
CCommand local_528 [1288];
int local_20;
realtime = 0;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
piVar2 = (int *)CommandLine_Tier0();
iVar3 = (**(code **)(*piVar2 + 0x28))(piVar2,"-fork");
if (iVar3 != 0) {
g_nForkID = 0xffffffff;
}
local_52c = local_52c & 0xf8;
local_640 = 0xffffffff;
local_63c = 0xffffffff;
local_638 = 2;
local_634 = 0xffffffff;
local_630 = 0xffff8000;
if (!param_1) {
local_638 = 1;
}
if (_g_pThreadPool != (int *)0x0) {
(**(code **)(*_g_pThreadPool + 0x10))(_g_pThreadPool,&local_640);
}
DAT_003a1730 = 0x3c888889;
InstallBitBufErrorHandler();
InstallConVarHook();
TraceInit("Memory_Init()","Memory_Shutdown()",0);
Memory_Init();
TraceInit("Con_Init()","Con_Shutdown()",0);
Con_Init();
TraceInit("Cbuf_Init()","Cbuf_Shutdown()",0);
Cbuf_Init();
TraceInit("Cmd_Init()","Cmd_Shutdown()",0);
Cmd_Init();
TraceInit("g_pCVar->Init()","g_pCVar->Shutdown()",0);
(**(code **)(*g_pCVar + 0xc))(g_pCVar);
TraceInit("COM_Init()","COM_Shutdown()",0);
COM_Init();
TraceInit("Filter_Init()","Filter_Shutdown()",0);
Filter_Init();
piVar2 = (int *)CommandLine_Tier0();
iVar3 = (**(code **)(*piVar2 + 0x28))(piVar2,&DAT_002b2f1c);
if (iVar3 == 0) {
puVar10 = (undefined1 *)CommandLine_Tier0();
pcVar11 = "-allowdebug";
iVar3 = (**(code **)(*(int *)puVar10 + 0x28))(puVar10,"-allowdebug");
if (iVar3 == 0) goto LAB_0017a2e1;
puVar10 = (undefined1 *)CommandLine_Tier0();
pcVar11 = "-nodev";
iVar3 = (**(code **)(*(int *)puVar10 + 0x28))(puVar10,"-nodev");
if (iVar3 != 0) goto LAB_0017a2e1;
}
ConVar::SetValue(0x3b7de0);
pcVar11 = (char *)0x1;
puVar10 = developer;
ConVar::SetValue(0x3a1100);
LAB_0017a2e1:
piVar2 = (int *)CommandLine_Tier0(puVar10,pcVar11);
iVar3 = (**(code **)(*piVar2 + 0x28))(piVar2,"-nocrashdialog");
if (iVar3 != 0) {
Sys_NoCrashDialog();
}
if (param_1) {
piVar2 = (int *)CommandLine_Tier0();
iVar3 = (**(code **)(*piVar2 + 0x28))(piVar2,"-xlsp");
if (iVar3 != 0) {
NET_SetDedicated();
}
}
Host_ParseConfiguration(param_1);
lVar8 = (longdouble)Plat_FloatTime();
fVar7 = ABS((float)lVar8);
RandomSeed(fVar7);
dVar9 = (double)(float)lVar8;
DevMsg("Seeded random number generator @ %d ( %.3f )\n",fVar7,SUB84(dVar9,0),
(int)((ulonglong)dVar9 >> 0x20));
TraceInit("g_pSteamSocketMgr->Init()","g_pSteamSocketMgr->Shutdown()",0);
(*(code *)**(undefined4 **)g_pSteamSocketMgr)(g_pSteamSocketMgr);
TraceInit("NET_Init( bDedicated )","NET_Shutdown()",0);
NET_Init(param_1);
TraceInit("g_GameEventManager.Init()","g_GameEventManager.Shutdown()",0);
CGameEventManager::Init((CGameEventManager *)&s_GameEventManager);
TraceInit("sv.Init( bDedicated )","sv.Shutdown()",0);
CGameServer::Init((CGameServer *)&sv,param_1);
piVar2 = (int *)CommandLine_Tier0();
iVar3 = (**(code **)(*piVar2 + 0x28))(piVar2,"-nogamedll");
if (iVar3 == 0) {
SV_InitGameDLL();
}
TraceInit("g_pMaster->Init()","g_pMaster->Shutdown()",0);
(*(code *)**(undefined4 **)g_pMaster)(g_pMaster);
TraceInit("g_Log.Init()","g_Log.Shutdown()",0);
CLog::Init((CLog *)g_Log);
TraceInit("HLTV_Init()","HLTV_Shutdown()",0);
ConDMsg("Heap: %5.2f Mb\n",
(double)(((float)(DAT_003a1548 >> 0x10) * 65536.0 + (float)(DAT_003a1548 & 0xffff)) *
9.536743e-07));
Host_CheckGore();
TraceInit("InitMaterialSystem()","ShutdownMaterialSystem()",0);
InitMaterialSystem();
TraceInit("modelloader->Init()","modelloader->Shutdown()",0);
(*(code *)**(undefined4 **)modelloader)(modelloader);
TraceInit("StaticPropMgr()->Init()","StaticPropMgr()->Shutdown()",0);
puVar4 = (undefined4 *)StaticPropMgr();
(**(code **)*puVar4)(puVar4);
TraceInit("InitStudioRender()","ShutdownStudioRender()",0);
InitStudioRender();
if (g_pMatchFramework != (int *)0x0) {
(**(code **)(*g_pMatchFramework + 0xc))(g_pMatchFramework);
}
TraceInit("Decal_Init()","Decal_Shutdown()",0);
Decal_Init();
iVar3 = GetSteamUniverse();
if (((g_bRunningFromPerforce != '\0') || (iVar3 == 2)) || (iVar3 == 4)) {
CCvarUtilities::EnableDevCvars();
}
piVar2 = (int *)(**(code **)(*g_pCVar + 0x38))(g_pCVar,"update_addon_paths");
if (piVar2 != (int *)0x0) {
local_644 = "update_addon_paths";
CCommand::CCommand(local_528,1,&local_644);
(**(code **)(*piVar2 + 0x3c))(piVar2,local_528);
}
piVar2 = (int *)(**(code **)(*g_pCVar + 0x38))(g_pCVar,"mission_reload");
if (piVar2 != (int *)0x0) {
local_644 = "mission_reload";
CCommand::CCommand(local_528,1,&local_644);
(**(code **)(*piVar2 + 0x3c))(piVar2,local_528);
}
uVar5 = Cbuf_GetCurrentPlayer();
Cbuf_AddText(uVar5,"exec valve.rc\n",0);
cVar1 = (**(code **)(*(int *)(g_pFileSystem + 4) + 0x28))
(g_pFileSystem + 4,"//mod/cfg/modsettings.cfg",0);
if (cVar1 != '\0') {
uVar5 = Cbuf_GetCurrentPlayer();
Cbuf_AddText(uVar5,"exec modsettings.cfg mod\n",0);
}
TelemetryTick();
Host_InitProcessor();
Hunk_AllocName(0,"-HOST_HUNKLEVEL-",true);
host_hunklevel = Hunk_LowMark();
piVar2 = (int *)CommandLine_Tier0();
iVar3 = (**(code **)(*piVar2 + 0x28))(piVar2,"-swapcores");
uVar5 = g_nServerThread;
if (iVar3 != 0) {
g_nServerThread = g_nMaterialSystemThread;
g_nMaterialSystemThread = uVar5;
}
host_initialized = 1;
piVar2 = (int *)CommandLine_Tier0();
iVar3 = (**(code **)(*piVar2 + 0x28))(piVar2,"-heapcheck");
host_checkheap = iVar3 != 0;
HostState_Init();
piVar2 = (int *)CommandLine_Tier0();
iVar3 = (**(code **)(*piVar2 + 0x28))(piVar2,"-makereslists");
if (iVar3 != 0) {
this_00 = (CMapReslistGenerator *)MapReslistGenerator();
CMapReslistGenerator::StartReslistGeneration(this_00);
}
piVar2 = (int *)CommandLine_Tier0();
iVar3 = (**(code **)(*piVar2 + 0x28))(piVar2,"-makedevshots");
if (iVar3 != 0) {
this = (CDevShotGenerator *)DevShotGenerator();
CDevShotGenerator::StartDevShotGeneration(this);
}
if (DAT_003b8088 != '\0') {
piVar2 = (int *)CommandLine_Tier0();
(**(code **)(*piVar2 + 0x28))(piVar2,"-phonehome");
}
if (serverGameDLL != (int *)0x0) {
(**(code **)(*serverGameDLL + 0x78))(serverGameDLL);
}
piVar2 = (int *)(**(code **)(*g_pMaterialSystem + 0x180))(g_pMaterialSystem);
if (piVar2 != (int *)0x0) {
/* try { // try from 0017a799 to 0017a79b has its CatchHandler @ 0017a991 */
(**(code **)(*piVar2 + 8))(piVar2);
}
/* try { // try from 0017a7b1 to 0017a827 has its CatchHandler @ 0017a977 */
(**(code **)(*piVar2 + 0x2b8))(piVar2,0,0);
(**(code **)(*piVar2 + 0x2b4))(piVar2,0,0,0,0);
(**(code **)(*g_pMaterialSystem + 0x1cc))(g_pMaterialSystem);
piVar6 = (int *)CommandLine_Tier0();
iVar3 = (**(code **)(*piVar6 + 0x28))(piVar6,"-profileinit");
if (iVar3 != 0) {
uVar5 = Cbuf_GetCurrentPlayer();
Cbuf_AddText(uVar5,"quit\n",0);
}
(**(code **)(*piVar2 + 0xc))(piVar2);
(**(code **)(*piVar2 + 4))(piVar2);
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.