31bool Initialize(ISmmAPI* ismm,
char* error,
size_t maxlen,
const InitParams& params)
47 Utils::Log::Info(
"Initializing CS2Kit...");
50 auto resolveEngine = [&](
const char* version) ->
void* {
51 return ismm->VInterfaceMatch(ismm->GetEngineFactory(), version, 0);
53 auto resolveServer = [&](
const char* version) ->
void* {
54 return ismm->VInterfaceMatch(ismm->GetServerFactory(), version, 0);
57 auto& gi = Sdk::GameInterfaces::Instance();
59 gi.ServerGameDLL =
static_cast<IServerGameDLL*
>(resolveServer(INTERFACEVERSION_SERVERGAMEDLL));
60 if (!gi.ServerGameDLL)
62 ismm->Format(error, maxlen,
"Could not find interface: %s", INTERFACEVERSION_SERVERGAMEDLL);
66 gi.ServerGameClients =
static_cast<IServerGameClients*
>(resolveServer(INTERFACEVERSION_SERVERGAMECLIENTS));
67 if (!gi.ServerGameClients)
69 ismm->Format(error, maxlen,
"Could not find interface: %s", INTERFACEVERSION_SERVERGAMECLIENTS);
73 gi.Engine =
static_cast<IVEngineServer2*
>(resolveEngine(INTERFACEVERSION_VENGINESERVER));
76 ismm->Format(error, maxlen,
"Could not find interface: %s", INTERFACEVERSION_VENGINESERVER);
80 gi.GameEventSystem =
static_cast<IGameEventSystem*
>(resolveEngine(GAMEEVENTSYSTEM_INTERFACE_VERSION));
81 if (!gi.GameEventSystem)
83 ismm->Format(error, maxlen,
"Could not find interface: %s", GAMEEVENTSYSTEM_INTERFACE_VERSION);
87 gi.NetworkMessages =
static_cast<INetworkMessages*
>(resolveEngine(NETWORKMESSAGES_INTERFACE_VERSION));
88 if (!gi.NetworkMessages)
90 ismm->Format(error, maxlen,
"Could not find interface: %s", NETWORKMESSAGES_INTERFACE_VERSION);
94 gi.SchemaSystem =
static_cast<ISchemaSystem*
>(resolveEngine(SCHEMASYSTEM_INTERFACE_VERSION));
97 ismm->Format(error, maxlen,
"Could not find interface: %s", SCHEMASYSTEM_INTERFACE_VERSION);
101 gi.CVar =
static_cast<ICvar*
>(resolveEngine(CVAR_INTERFACE_VERSION));
104 ismm->Format(error, maxlen,
"Could not find interface: %s", CVAR_INTERFACE_VERSION);
108 gi.GameResourceService =
109 static_cast<IGameResourceService*
>(resolveEngine(GAMERESOURCESERVICESERVER_INTERFACE_VERSION));
110 if (!gi.GameResourceService)
112 ismm->Format(error, maxlen,
"Could not find interface: %s", GAMERESOURCESERVICESERVER_INTERFACE_VERSION);
120 const char* gameDataPath = params.GameDataPath ? params.GameDataPath :
DefaultGameDataPath;
121 Utils::Log::Info(
"Loading game data from {}...", gameDataPath);
122 Sdk::GameData::Instance().Load(gameDataPath);
125 Utils::Log::Info(
"Initializing SDK message system...");
126 if (!Sdk::MessageSystem::Instance().
Initialize())
128 Utils::Log::Error(
"Failed to initialize message system.");
132 Utils::Log::Info(
"Initializing schema system...");
133 if (!Sdk::SchemaService::Instance().
Initialize())
134 Utils::Log::Warn(
"Schema system init failed (button detection may not work).");
136 Utils::Log::Info(
"Initializing entity system...");
137 if (!Sdk::EntitySystem::Instance().
Initialize())
138 Utils::Log::Warn(
"Entity system init failed (menus may not work).");
140 Utils::Log::Info(
"Resolving game event manager...");
141 if (!Sdk::MessageSystem::Instance().InitGameEventManager())
142 Utils::Log::Warn(
"Game event manager not resolved (center HTML display will not work).");
144 Utils::Log::Info(
"Initializing ConVar service...");
145 if (!Sdk::ConVarService::Instance().
Initialize())
146 Utils::Log::Warn(
"ConVar service init failed.");
148 Utils::Log::Info(
"Initializing game event service...");
149 if (!Sdk::GameEventService::Instance().
Initialize())
150 Utils::Log::Warn(
"Game event service init failed.");
152 Utils::Log::Info(
"CS2Kit initialized.");