Initial commit

This commit is contained in:
Michal 2026-01-11 18:57:42 +04:00 • committed by GitHub
commit 3dd53cf457
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
105 changed files with 35670 additions and 0 deletions

62
src/Shared.cpp Normal file
View file

@ -0,0 +1,62 @@
//
// Created by Michal Přikryl on 20.09.2025.
// Copyright (c) 2025 slynxcz. All rights reserved.
//
#include "Shared.h"
#include <icvar.h>
#include <iserver.h>
#include <schemasystem.h>
#include <sourcehook/sourcehook.h>
#include <sourcehook/sourcehook_impl.h>
namespace TemplatePlugin::shared
{
ICvar* g_pCVar = nullptr;
IServerGameDLL* g_pServer = nullptr;
ISource2Server* g_pSource2Server = nullptr;
IVEngineServer* g_pEngine = nullptr;
CSchemaSystem* g_pSchemaSystem = nullptr;
IGameEventManager2* g_pGameEventManager = nullptr;
IGameEventSystem* g_pGameEventSystem = nullptr;
ISource2GameEntities* g_pGameEntities = nullptr;
INetworkMessages* g_pNetworkMessages = nullptr;
INetworkServerService* g_pNetworkServerService = nullptr;
CGameEntitySystem* g_pEntitySystem = nullptr;
IServerGameClients* g_pGameClients = nullptr;
CGlobalVars *g_pGlobalVars = nullptr;
CGameResourceService *g_pGameResourceServiceServer = nullptr;
CGameConfig *g_pGameConfig = nullptr;
SourceHook::Impl::CSourceHookImpl source_hook_impl;
SourceHook::ISourceHook* source_hook = &source_hook_impl;
int source_hook_pluginid = 0;
CGlobalVars *getGlobalVars() {
INetworkGameServer *server = g_pNetworkServerService->GetIGameServer();
if (!server) return nullptr;
if (!g_pGlobalVars) g_pGlobalVars = server->GetGlobals();
return g_pNetworkServerService->GetIGameServer()->GetGlobals();
}
constexpr float engine_fixed_tick_interval = 0.015625f;
const char* GetMapName()
{
if (getGlobalVars() == nullptr) return nullptr;
return getGlobalVars()->mapname.ToCStr();
}
void ServerCommand(const char* command)
{
auto clean_command = std::string(command);
clean_command.append("\n\0");
g_pEngine->ServerCommand(clean_command.c_str());
}
double GetEngineTime() { return Plat_FloatTime(); }
float GetTickInterval() { return engine_fixed_tick_interval; }
float GetCurrentTime() { return getGlobalVars()->curtime; }
int GetTickCount() { return getGlobalVars()->tickcount; }
float GetGameFrameTime() { return getGlobalVars()->frametime; }
bool g_bHasTicked = false;
bool g_bDetoursLoaded = false;
}