networking i guess
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -31,3 +31,6 @@
|
|||||||
[submodule "external/funnystdlib"]
|
[submodule "external/funnystdlib"]
|
||||||
path = external/funnystdlib
|
path = external/funnystdlib
|
||||||
url = https://github.com/KoT3isGood/funnystdlib.git
|
url = https://github.com/KoT3isGood/funnystdlib.git
|
||||||
|
[submodule "external/SPIRV-Tools"]
|
||||||
|
path = external/SPIRV-Tools
|
||||||
|
url = https://github.com/KoT3isGood/SPIRV-Tools.git
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ DECLARE_BUILD_STAGE(install_game)
|
|||||||
filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(Server, "server"));
|
filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(Server, "server"));
|
||||||
filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(Client, "client"));
|
filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(Client, "client"));
|
||||||
}
|
}
|
||||||
|
if ( GET_PROJECT_VALUE(config, "steam") == "true" ) {
|
||||||
|
filesystem2->CopyFile(szOutputDir, EXTERNAL"steamworks/redistributable_bin/linux64/libsteam_api.so");
|
||||||
|
}
|
||||||
filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(launcher, "launcher"));
|
filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(launcher, "launcher"));
|
||||||
filesystem2->CopyDirectory(CUtlString("%s/core/",szOutputDir.GetString()), "funnyassets/models");
|
filesystem2->CopyDirectory(CUtlString("%s/core/",szOutputDir.GetString()), "funnyassets/models");
|
||||||
filesystem2->CopyDirectory(CUtlString("%s/core/",szOutputDir.GetString()), "funnyassets/meshes");
|
filesystem2->CopyDirectory(CUtlString("%s/core/",szOutputDir.GetString()), "funnyassets/meshes");
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
|
#include "tier0/commandline.h"
|
||||||
|
|
||||||
DECLARE_BUILD_STAGE(config)
|
DECLARE_BUILD_STAGE(config)
|
||||||
{
|
{
|
||||||
if (Target_t::DefaultTarget().kernel == TARGET_KERNEL_IOS)
|
if (Target_t::DefaultTarget().kernel == TARGET_KERNEL_IOS)
|
||||||
{
|
{
|
||||||
ADD_OUTPUT_VALUE("static", "true");
|
ADD_OUTPUT_VALUE("static", "true");
|
||||||
|
ADD_OUTPUT_VALUE("steam", "false");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ADD_OUTPUT_VALUE("static", "false");
|
ADD_OUTPUT_VALUE("static", "false");
|
||||||
|
ADD_OUTPUT_VALUE("steam", "true");
|
||||||
}
|
}
|
||||||
ADD_OUTPUT_VALUE("static", "true");
|
ADD_OUTPUT_VALUE("static", "true");
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "ld.h"
|
#include "ld.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
|
|
||||||
|
#define EXTERNAL "../external/"
|
||||||
#define FUNNYSTDLIB "../external/funnystdlib/"
|
#define FUNNYSTDLIB "../external/funnystdlib/"
|
||||||
ADD_DEPENDENCY_BUILD_FILE(cfg, "../buildcfg.cpp");
|
ADD_DEPENDENCY_BUILD_FILE(cfg, "../buildcfg.cpp");
|
||||||
ADD_DEPENDENCY_BUILD_FILE(MaterialSystem, "../materialsystem/build.cpp")
|
ADD_DEPENDENCY_BUILD_FILE(MaterialSystem, "../materialsystem/build.cpp")
|
||||||
@@ -19,6 +20,9 @@ DECLARE_BUILD_STAGE(engine)
|
|||||||
compileProject.files = {
|
compileProject.files = {
|
||||||
"engine.cpp",
|
"engine.cpp",
|
||||||
"cvar.cpp",
|
"cvar.cpp",
|
||||||
|
"localnetwork.cpp",
|
||||||
|
"socketnetwork.cpp",
|
||||||
|
"steamnetwork.cpp",
|
||||||
|
|
||||||
"sv_dll.cpp",
|
"sv_dll.cpp",
|
||||||
"cl_dll.cpp",
|
"cl_dll.cpp",
|
||||||
@@ -29,7 +33,10 @@ DECLARE_BUILD_STAGE(engine)
|
|||||||
"../external/SDL/include",
|
"../external/SDL/include",
|
||||||
"../external/cglm/include",
|
"../external/cglm/include",
|
||||||
FUNNYSTDLIB"public",
|
FUNNYSTDLIB"public",
|
||||||
|
EXTERNAL"steamworks/public",
|
||||||
};
|
};
|
||||||
|
if ( GET_PROJECT_VALUE(config, "steam") == "true" )
|
||||||
|
compileProject.macros.AppendTail({"STEAM", "TRUE"});
|
||||||
compileProject.bFPIC = true;
|
compileProject.bFPIC = true;
|
||||||
ldProject = ccompiler->Compile(&compileProject);
|
ldProject = ccompiler->Compile(&compileProject);
|
||||||
|
|
||||||
@@ -39,6 +46,10 @@ DECLARE_BUILD_STAGE(engine)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if ( GET_PROJECT_VALUE(config, "steam") == "true" ) {
|
||||||
|
ldProject.libraryDirectories.AppendTail(EXTERNAL"steamworks/redistributable_bin/linux64");
|
||||||
|
ldProject.libraries.AppendTail("steam_api");
|
||||||
|
}
|
||||||
ldProject.linkType = ELINK_DYNAMIC_LIBRARY;
|
ldProject.linkType = ELINK_DYNAMIC_LIBRARY;
|
||||||
ldProject.libraryObjects = {
|
ldProject.libraryObjects = {
|
||||||
GET_PROJECT_LIBRARY(tier0, "tier0"),
|
GET_PROJECT_LIBRARY(tier0, "tier0"),
|
||||||
@@ -49,7 +60,7 @@ DECLARE_BUILD_STAGE(engine)
|
|||||||
|
|
||||||
if (ldProject.m_target.kernel & TARGET_KERNEL_WINDOWS_DEVICES)
|
if (ldProject.m_target.kernel & TARGET_KERNEL_WINDOWS_DEVICES)
|
||||||
{
|
{
|
||||||
ldProject.libraryDirectories = {"../external/windows"};
|
ldProject.libraryDirectories.AppendTail(EXTERNAL"windows");
|
||||||
ldProject.libraries.AppendTail("winpthread-1");
|
ldProject.libraries.AppendTail("winpthread-1");
|
||||||
ldProject.libraries.AppendTail("winmm");
|
ldProject.libraries.AppendTail("winmm");
|
||||||
ldProject.libraries.AppendTail("ole32");
|
ldProject.libraries.AppendTail("ole32");
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ void CClientGameDLL::Init()
|
|||||||
pEngineBridge->ConnectInterface(RENDER_CONTEXT_INTERFACE_VERSION, m_pRenderContext);
|
pEngineBridge->ConnectInterface(RENDER_CONTEXT_INTERFACE_VERSION, m_pRenderContext);
|
||||||
pEngineBridge->ConnectInterface("MainWindow", m_pGameWindow);
|
pEngineBridge->ConnectInterface("MainWindow", m_pGameWindow);
|
||||||
pEngineBridge->ConnectInterface(FILESYSTEM_INTERFACE_VERSION, filesystem);
|
pEngineBridge->ConnectInterface(FILESYSTEM_INTERFACE_VERSION, filesystem);
|
||||||
|
pEngineBridge->ConnectInterface("EngineConstants", m_pEngineConsts);
|
||||||
pEngineBridge->Init();
|
pEngineBridge->Init();
|
||||||
m_pBridge = pEngineBridge;
|
m_pBridge = pEngineBridge;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,12 @@
|
|||||||
#include "tier0/mem.h"
|
#include "tier0/mem.h"
|
||||||
#include "sv_dll.h"
|
#include "sv_dll.h"
|
||||||
#include "cl_dll.h"
|
#include "cl_dll.h"
|
||||||
|
#include "inetworkserver.h"
|
||||||
|
#include "inetworkclient.h"
|
||||||
|
|
||||||
|
#ifdef STEAM
|
||||||
|
#include "steam/steam_api.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
IRenderContext *g_pRenderContext;
|
IRenderContext *g_pRenderContext;
|
||||||
IFileSystem *filesystem;
|
IFileSystem *filesystem;
|
||||||
@@ -19,38 +25,52 @@ extern "C" void FunnyMain( int argc, char **argv )
|
|||||||
{
|
{
|
||||||
CommandLine()->CreateCommandLine(argc, argv);
|
CommandLine()->CreateCommandLine(argc, argv);
|
||||||
|
|
||||||
|
EngineConsts_t stConstants = {};
|
||||||
|
#ifdef STEAM
|
||||||
|
stConstants.m_bIsSteam = true;
|
||||||
|
if (!SteamAPI_Init())
|
||||||
|
Plat_FatalErrorFunc("SteamAPI_Init failed lol\n");
|
||||||
|
stConstants.LaunchServer = LaunchLocalBridge;
|
||||||
|
stConstants.ConnectSteamServer = ConnectBySteamID;
|
||||||
|
#endif
|
||||||
|
stConstants.m_bIsDedicated = CommandLine()->CheckParam("-dedicated");
|
||||||
|
stConstants.LaunchLocalBridge = LaunchLocalBridge;
|
||||||
|
stConstants.ConnectLocalBridge = ConnectByLocalBridge;
|
||||||
CreateInterfaceFn pFilesystemFactory = Sys_GetFactory("filesystem_std");
|
CreateInterfaceFn pFilesystemFactory = Sys_GetFactory("filesystem_std");
|
||||||
CreateInterfaceFn pMaterialSystemFactory = Sys_GetFactory("MaterialSystem");
|
CreateInterfaceFn pMaterialSystemFactory = Sys_GetFactory("MaterialSystem");
|
||||||
CreateInterfaceFn pRenderSystemFactory = Sys_GetFactory("RenderSystemVulkan");
|
CreateInterfaceFn pRenderSystemFactory = Sys_GetFactory("RenderSystemVulkan");
|
||||||
|
IGameWindow *pWindow;
|
||||||
|
|
||||||
filesystem = (IFileSystem*)pFilesystemFactory(FILESYSTEM_INTERFACE_VERSION, NULL);
|
filesystem = (IFileSystem*)pFilesystemFactory(FILESYSTEM_INTERFACE_VERSION, NULL);
|
||||||
filesystem->Init();
|
filesystem->Init();
|
||||||
|
|
||||||
g_pWindowManager = (IGameWindowManager*)pRenderSystemFactory(GAME_WINDOW_MANAGER_INTERFACE_VERSION, NULL);
|
if (!stConstants.m_bIsDedicated)
|
||||||
V_printf("%s\n", GAME_WINDOW_MANAGER_INTERFACE_VERSION);
|
{
|
||||||
g_pWindowManager->Init();
|
g_pWindowManager = (IGameWindowManager*)pRenderSystemFactory(GAME_WINDOW_MANAGER_INTERFACE_VERSION, NULL);
|
||||||
|
g_pWindowManager->Init();
|
||||||
|
|
||||||
IGameWindow *pWindow = g_pWindowManager->CreateWindow();
|
pWindow = g_pWindowManager->CreateWindow();
|
||||||
pWindow->Init();
|
pWindow->Init();
|
||||||
|
|
||||||
|
|
||||||
g_pRenderContext = (IRenderContext*)pRenderSystemFactory(RENDER_CONTEXT_INTERFACE_VERSION, NULL);
|
|
||||||
g_pRenderContext->SetMainWindowManager(g_pWindowManager);
|
|
||||||
g_pRenderContext->Init();
|
|
||||||
|
|
||||||
g_pRenderContext->RegisterGameWindow(pWindow);
|
|
||||||
|
|
||||||
|
g_pRenderContext = (IRenderContext*)pRenderSystemFactory(RENDER_CONTEXT_INTERFACE_VERSION, NULL);
|
||||||
|
g_pRenderContext->SetMainWindowManager(g_pWindowManager);
|
||||||
|
g_pRenderContext->Init();
|
||||||
|
|
||||||
|
g_pRenderContext->RegisterGameWindow(pWindow);
|
||||||
|
}
|
||||||
|
|
||||||
g_pServerGame = new CServerGameDLL;
|
g_pServerGame = new CServerGameDLL;
|
||||||
g_pServerGame->m_pGameWindow = pWindow;
|
g_pServerGame->m_pEngineConsts = &stConstants;
|
||||||
g_pServerGame->m_pRenderContext = g_pRenderContext;
|
|
||||||
g_pServerGame->Init();
|
g_pServerGame->Init();
|
||||||
|
|
||||||
g_pClientGame = new CClientGameDLL;
|
if (!stConstants.m_bIsDedicated)
|
||||||
g_pClientGame->m_pGameWindow = pWindow;
|
{
|
||||||
g_pClientGame->m_pRenderContext = g_pRenderContext;
|
g_pClientGame = new CClientGameDLL;
|
||||||
g_pClientGame->Init();
|
g_pClientGame->m_pGameWindow = pWindow;
|
||||||
|
g_pClientGame->m_pRenderContext = g_pRenderContext;
|
||||||
|
g_pClientGame->m_pEngineConsts = &stConstants;
|
||||||
|
g_pClientGame->Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
double fPrevious = Plat_GetTime();
|
double fPrevious = Plat_GetTime();
|
||||||
@@ -58,11 +78,15 @@ extern "C" void FunnyMain( int argc, char **argv )
|
|||||||
double fCurrent = Plat_GetTime();
|
double fCurrent = Plat_GetTime();
|
||||||
double fDelta = fCurrent-fPrevious;
|
double fDelta = fCurrent-fPrevious;
|
||||||
fPrevious = fCurrent;
|
fPrevious = fCurrent;
|
||||||
g_pWindowManager->Frame(fDelta);
|
|
||||||
g_pServerGame->m_pBridge->Frame(fDelta);
|
g_pServerGame->m_pBridge->Frame(fDelta);
|
||||||
g_pClientGame->m_pBridge->Frame(fDelta);
|
|
||||||
|
|
||||||
g_pRenderContext->Frame(fDelta);
|
if (!stConstants.m_bIsDedicated)
|
||||||
|
{
|
||||||
|
g_pWindowManager->Frame(fDelta);
|
||||||
|
g_pClientGame->m_pBridge->Frame(fDelta);
|
||||||
|
g_pRenderContext->Frame(fDelta);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
5
engine/inetwork.cpp
Normal file
5
engine/inetwork.cpp
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
class CUnsecureNetworkManager
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
218
engine/localnetwork.cpp
Normal file
218
engine/localnetwork.cpp
Normal file
@@ -0,0 +1,218 @@
|
|||||||
|
#include "inetworkserver.h"
|
||||||
|
#include "tier1/utlmutex.h"
|
||||||
|
#include "tier1/utlvector.h"
|
||||||
|
|
||||||
|
class CLocalNetworkServer;
|
||||||
|
static CLocalNetworkServer *s_pLocalServers[128];
|
||||||
|
|
||||||
|
class CLocalNetworkServer: public INetworkBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CLocalNetworkServer( uint16_t uPort );
|
||||||
|
virtual ~CLocalNetworkServer() override;
|
||||||
|
|
||||||
|
virtual void NetThink() override;
|
||||||
|
|
||||||
|
virtual uint32_t BHasUpdates() override;
|
||||||
|
virtual NetPacket_t RecievePacket() override;
|
||||||
|
virtual NetPacket_t PeekPacket() override;
|
||||||
|
|
||||||
|
virtual void SendPacket( NetPacket_t stPacket ) override;
|
||||||
|
|
||||||
|
virtual uint64_t GetSteamID() override;
|
||||||
|
virtual const char *GetIP() override;
|
||||||
|
virtual uint16_t GetPort() override;
|
||||||
|
|
||||||
|
CUtlLock m_lock;
|
||||||
|
CUtlVector<NetPacket_t> m_packets;
|
||||||
|
CUtlVector<NetPacket_t> m_clientPackets;
|
||||||
|
CUtlVector<void*> m_freedPackets;
|
||||||
|
const uint16_t m_uPort;
|
||||||
|
};
|
||||||
|
|
||||||
|
CLocalNetworkServer::CLocalNetworkServer( uint16_t uPort ) : m_uPort(uPort)
|
||||||
|
{
|
||||||
|
s_pLocalServers[uPort] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLocalNetworkServer::~CLocalNetworkServer()
|
||||||
|
{
|
||||||
|
s_pLocalServers[m_uPort] = NULL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CLocalNetworkServer::NetThink()
|
||||||
|
{
|
||||||
|
m_lock.Lock();
|
||||||
|
for ( auto p: m_freedPackets)
|
||||||
|
{
|
||||||
|
V_free(p);
|
||||||
|
}
|
||||||
|
m_freedPackets = {};
|
||||||
|
m_lock.Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t CLocalNetworkServer::BHasUpdates()
|
||||||
|
{
|
||||||
|
return m_clientPackets.GetSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
NetPacket_t CLocalNetworkServer::RecievePacket()
|
||||||
|
{
|
||||||
|
m_lock.Lock();
|
||||||
|
if (!BHasUpdates())
|
||||||
|
return {};
|
||||||
|
NetPacket_t p = m_clientPackets[0];
|
||||||
|
m_clientPackets.RemoveHead(1);
|
||||||
|
m_freedPackets.AppendTail(p.pData);
|
||||||
|
m_lock.Unlock();
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetPacket_t CLocalNetworkServer::PeekPacket()
|
||||||
|
{
|
||||||
|
m_lock.Lock();
|
||||||
|
if (!BHasUpdates())
|
||||||
|
return {};
|
||||||
|
NetPacket_t p = m_clientPackets[0];
|
||||||
|
m_lock.Unlock();
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CLocalNetworkServer::SendPacket( NetPacket_t stPacket )
|
||||||
|
{
|
||||||
|
NetPacket_t stSavedPacked;
|
||||||
|
stSavedPacked.uSize = stPacket.uSize;
|
||||||
|
stSavedPacked.pData = V_malloc(stPacket.uSize);
|
||||||
|
V_memcpy(stSavedPacked.pData, stPacket.pData, stPacket.uSize);
|
||||||
|
|
||||||
|
m_lock.Lock();
|
||||||
|
m_packets.AppendTail(stSavedPacked);
|
||||||
|
m_lock.Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint64_t CLocalNetworkServer::GetSteamID()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *CLocalNetworkServer::GetIP()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t CLocalNetworkServer::GetPort()
|
||||||
|
{
|
||||||
|
return m_uPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
class CLocalNetworkClient: public INetworkBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CLocalNetworkClient( uint16_t uPort );
|
||||||
|
virtual ~CLocalNetworkClient() override;
|
||||||
|
|
||||||
|
virtual void NetThink() override;
|
||||||
|
|
||||||
|
virtual uint32_t BHasUpdates() override;
|
||||||
|
virtual NetPacket_t RecievePacket() override;
|
||||||
|
virtual NetPacket_t PeekPacket() override;
|
||||||
|
|
||||||
|
virtual void SendPacket( NetPacket_t stPacket ) override;
|
||||||
|
|
||||||
|
virtual uint64_t GetSteamID() override;
|
||||||
|
virtual const char *GetIP() override;
|
||||||
|
virtual uint16_t GetPort() override;
|
||||||
|
|
||||||
|
CLocalNetworkServer *m_pServer;
|
||||||
|
};
|
||||||
|
|
||||||
|
CLocalNetworkClient::CLocalNetworkClient( uint16_t uPort )
|
||||||
|
{
|
||||||
|
m_pServer = s_pLocalServers[uPort];
|
||||||
|
}
|
||||||
|
|
||||||
|
CLocalNetworkClient::~CLocalNetworkClient()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CLocalNetworkClient::NetThink()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t CLocalNetworkClient::BHasUpdates()
|
||||||
|
{
|
||||||
|
return m_pServer->m_packets.GetSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
NetPacket_t CLocalNetworkClient::RecievePacket()
|
||||||
|
{
|
||||||
|
m_pServer->m_lock.Lock();
|
||||||
|
if (!BHasUpdates())
|
||||||
|
return {};
|
||||||
|
NetPacket_t p = m_pServer->m_packets[0];
|
||||||
|
m_pServer->m_packets.RemoveHead(1);
|
||||||
|
m_pServer->m_freedPackets.AppendTail(p.pData);
|
||||||
|
m_pServer->m_lock.Unlock();
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetPacket_t CLocalNetworkClient::PeekPacket()
|
||||||
|
{
|
||||||
|
m_pServer->m_lock.Lock();
|
||||||
|
if (!BHasUpdates())
|
||||||
|
return {};
|
||||||
|
NetPacket_t p = m_pServer->m_packets[0];
|
||||||
|
m_pServer->m_lock.Unlock();
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CLocalNetworkClient::SendPacket( NetPacket_t stPacket )
|
||||||
|
{
|
||||||
|
NetPacket_t stSavedPacked;
|
||||||
|
stSavedPacked.uSize = stPacket.uSize;
|
||||||
|
stSavedPacked.pData = V_malloc(stPacket.uSize);
|
||||||
|
V_memcpy(stSavedPacked.pData, stPacket.pData, stPacket.uSize);
|
||||||
|
|
||||||
|
m_pServer->m_lock.Lock();
|
||||||
|
m_pServer->m_clientPackets.AppendTail(stSavedPacked);
|
||||||
|
m_pServer->m_lock.Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint64_t CLocalNetworkClient::GetSteamID()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *CLocalNetworkClient::GetIP()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t CLocalNetworkClient::GetPort()
|
||||||
|
{
|
||||||
|
return m_pServer->m_uPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
INetworkBase *LaunchLocalBridge( uint16_t uPort )
|
||||||
|
{
|
||||||
|
INetworkBase *pBase = new CLocalNetworkServer(uPort);
|
||||||
|
return pBase;
|
||||||
|
}
|
||||||
|
INetworkBase *ConnectByLocalBridge( uint16_t uPort )
|
||||||
|
{
|
||||||
|
if (s_pLocalServers[uPort] == 0)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return new CLocalNetworkClient(uPort);
|
||||||
|
}
|
||||||
0
engine/socketnetwork.cpp
Normal file
0
engine/socketnetwork.cpp
Normal file
82
engine/steamnetwork.cpp
Normal file
82
engine/steamnetwork.cpp
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
#include "inetworkserver.h"
|
||||||
|
#include "inetworkclient.h"
|
||||||
|
#include "steam/isteamnetworkingsockets.h"
|
||||||
|
|
||||||
|
class CSteamNetworkServer: public INetworkBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSteamNetworkServer( uint16_t uPort );
|
||||||
|
virtual ~CSteamNetworkServer() override;
|
||||||
|
|
||||||
|
virtual void NetThink() override;
|
||||||
|
|
||||||
|
virtual uint32_t BHasUpdates() override;
|
||||||
|
virtual NetPacket_t RecievePacket() override;
|
||||||
|
|
||||||
|
virtual void SendPacket( NetPacket_t stPacket ) override;
|
||||||
|
|
||||||
|
virtual uint64_t GetSteamID() override;
|
||||||
|
virtual const char *GetIP() override;
|
||||||
|
virtual uint16_t GetPort() override;
|
||||||
|
HSteamListenSocket m_hSocket;
|
||||||
|
};
|
||||||
|
|
||||||
|
CSteamNetworkServer::CSteamNetworkServer( uint16_t uPort )
|
||||||
|
{
|
||||||
|
m_hSocket = SteamNetworkingSockets()->CreateListenSocketP2P(uPort, 0, NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CSteamNetworkServer::~CSteamNetworkServer()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CSteamNetworkServer::NetThink()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t CSteamNetworkServer::BHasUpdates()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NetPacket_t CSteamNetworkServer::RecievePacket()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CSteamNetworkServer::SendPacket( NetPacket_t stPacket )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint64_t CSteamNetworkServer::GetSteamID()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *CSteamNetworkServer::GetIP()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t CSteamNetworkServer::GetPort()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
INetworkBase *LaunchServerAtSteamRelay( uint16_t uPort )
|
||||||
|
{
|
||||||
|
INetworkBase *pBase = new CSteamNetworkServer(uPort);
|
||||||
|
return pBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
INetworkBase *ConnectBySteamID( uint64_t uID, uint16_t uPort )
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@ void CServerGameDLL::Init()
|
|||||||
|
|
||||||
CreateInterfaceFn pfnServerFactory = Sys_GetFactory(pLib);
|
CreateInterfaceFn pfnServerFactory = Sys_GetFactory(pLib);
|
||||||
IEngineBridge *pEngineBridge = (IEngineBridge*)pfnServerFactory(ENGINE_BRIDGE_INTERFACE_VERSION, NULL);
|
IEngineBridge *pEngineBridge = (IEngineBridge*)pfnServerFactory(ENGINE_BRIDGE_INTERFACE_VERSION, NULL);
|
||||||
|
pEngineBridge->ConnectInterface("EngineConstants", m_pEngineConsts);
|
||||||
pEngineBridge->Init();
|
pEngineBridge->Init();
|
||||||
m_pBridge = pEngineBridge;
|
m_pBridge = pEngineBridge;
|
||||||
}
|
}
|
||||||
|
|||||||
1
external/SPIRV-Tools
vendored
Submodule
1
external/SPIRV-Tools
vendored
Submodule
Submodule external/SPIRV-Tools added at 0436c4b055
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"mesh": "game/core/meshes/cube.fmesh_c",
|
"mesh": "game/core/meshes/cube.fmesh_c",
|
||||||
"material": "cube.fmat"
|
"material": "game/core/materials/cube.fmat"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,12 @@
|
|||||||
#define PS namespace PixelShader_DO_NOT_USE
|
#define PS namespace PixelShader_DO_NOT_USE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef RAY_SHADER
|
||||||
|
#define RAY using namespace RAYShader; namespace RAYShader
|
||||||
|
#else
|
||||||
|
#define RAY namespace RAYShader_DO_NOT_USE
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef BRDF_SHADER
|
#ifdef BRDF_SHADER
|
||||||
#define BRDF using namespace BRDFShader; namespace BRDFShader
|
#define BRDF using namespace BRDFShader; namespace BRDFShader
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -1 +1,30 @@
|
|||||||
#include "macros.hlsl"
|
#include "macros.hlsl"
|
||||||
|
#include "ray_trace.hlsl"
|
||||||
|
|
||||||
|
struct MeshPayload
|
||||||
|
{
|
||||||
|
float3 m_vColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
RAY
|
||||||
|
{
|
||||||
|
funnyAccelerationStructure g_asGlobal;
|
||||||
|
Texture2D<float> g_tWorldSpaceCoords;
|
||||||
|
RWTexture2D<float> g_tDirectImage;
|
||||||
|
RWTexture2D<float> g_tIndirectImage;
|
||||||
|
|
||||||
|
|
||||||
|
void rayMain()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
uint2 pixel = DispatchRaysIndex().xy;
|
||||||
|
MeshPayload p;
|
||||||
|
RayDesc ray;
|
||||||
|
ray.Origin = g_tWorldSpaceCoords[pixel];
|
||||||
|
ray.Direction = float3(1,0,0);
|
||||||
|
ray.TMin = 0.001;
|
||||||
|
ray.TMax = 10000;
|
||||||
|
funnyHitObject hit = funnyHitObject::TraceRay(g_asGlobal, RAY_FLAG_NONE, 0xFF, 0, 1, 0, ray, p);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,15 +2,9 @@
|
|||||||
#define RAY_TRACE_H
|
#define RAY_TRACE_H
|
||||||
|
|
||||||
#ifdef SOFTWARE_RAY_TRACING
|
#ifdef SOFTWARE_RAY_TRACING
|
||||||
struct funnyAccelerationStructure
|
typedef Buffer<uint8_t> funnyAccelerationStructure
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
struct funnyAccelerationStructure
|
typedef RaytracingAccelerationStructure funnyAccelerationStructure
|
||||||
{
|
|
||||||
RaytracingAccelerationStructure accel;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct funnyHitObject
|
struct funnyHitObject
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public:
|
|||||||
FunnyModel_t *LoadModelFromParams( const char *szMesh, const char *szMaterial );
|
FunnyModel_t *LoadModelFromParams( const char *szMesh, const char *szMaterial );
|
||||||
|
|
||||||
uint32_t LoadShader( const char *szName );
|
uint32_t LoadShader( const char *szName );
|
||||||
|
FunnyShader_t *GetShaderByIndex( uint32_t uIndex );
|
||||||
void UnrefShader( uint32_t uIndex );
|
void UnrefShader( uint32_t uIndex );
|
||||||
|
|
||||||
FunnyModel_t *m_models[MAX_MODEL_COUNT] = {};
|
FunnyModel_t *m_models[MAX_MODEL_COUNT] = {};
|
||||||
@@ -46,6 +47,10 @@ FunnyMaterial_t *CAssetManager::GetMaterialByIndex( uint32_t uIndex )
|
|||||||
{
|
{
|
||||||
return m_materials[uIndex];
|
return m_materials[uIndex];
|
||||||
}
|
}
|
||||||
|
FunnyShader_t *CAssetManager::GetShaderByIndex( uint32_t uIndex )
|
||||||
|
{
|
||||||
|
return m_shaders[uIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t CAssetManager::LoadModel( const char *szName )
|
uint32_t CAssetManager::LoadModel( const char *szName )
|
||||||
@@ -116,7 +121,7 @@ uint32_t CAssetManager::LoadMaterial( const char *szName )
|
|||||||
{
|
{
|
||||||
uint32_t u = 0;
|
uint32_t u = 0;
|
||||||
uint32_t uFoundIndex = 1;
|
uint32_t uFoundIndex = 1;
|
||||||
for ( auto &m: m_models)
|
for ( auto &m: m_materials)
|
||||||
{
|
{
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
{
|
{
|
||||||
@@ -125,17 +130,51 @@ uint32_t CAssetManager::LoadMaterial( const char *szName )
|
|||||||
}
|
}
|
||||||
if (m->m_szName == szName)
|
if (m->m_szName == szName)
|
||||||
{
|
{
|
||||||
m_modelUsages[uFoundIndex]++;
|
m_materialsUsages[uFoundIndex]++;
|
||||||
return u;
|
return u;
|
||||||
}
|
}
|
||||||
u++;
|
u++;
|
||||||
}
|
}
|
||||||
for ( auto &m: m_models)
|
for ( auto &m: m_materials)
|
||||||
{
|
{
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
break;
|
break;
|
||||||
uFoundIndex++;
|
uFoundIndex++;
|
||||||
}
|
}
|
||||||
|
IFileHandle *pHandle = filesystem->Open(szName, FILEMODE_READ);
|
||||||
|
CUtlString szProperties = filesystem->ReadString(pHandle);
|
||||||
|
IJSONValue *pRoot = JSONManager()->ReadString(szProperties);
|
||||||
|
IJSONObject *pMainObject;
|
||||||
|
switch (pRoot->GetType())
|
||||||
|
{
|
||||||
|
case JSON_PARAMETER_OBJECT:
|
||||||
|
{
|
||||||
|
pMainObject = pRoot->GetObject();
|
||||||
|
if (!pMainObject)
|
||||||
|
{
|
||||||
|
V_printf("Failed to load properties\n");
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
IJSONValue *pShaderValue = pMainObject->GetValue("shader");
|
||||||
|
CUtlString szShader = pShaderValue->GetStringValue();
|
||||||
|
CBaseMaterial *pMaterial = CreateMaterial(szShader);
|
||||||
|
|
||||||
|
uint32_t uShaderId = LoadShader(pMaterial->GetShaderPath());
|
||||||
|
FunnyShader_t *pShader = GetShaderByIndex(uShaderId);
|
||||||
|
m_materials[uFoundIndex] = new FunnyMaterial_t;
|
||||||
|
m_materials[uFoundIndex]->m_pShaders = pShader->m_pShader;
|
||||||
|
m_materials[uFoundIndex]->m_pMaterial = g_pRenderContext->CreateMaterial(pShader->m_pShader);
|
||||||
|
m_materials[uFoundIndex]->m_pLayout = pMaterial;
|
||||||
|
m_materialsUsages[uFoundIndex]++;
|
||||||
|
|
||||||
|
return uFoundIndex;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return uFoundIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAssetManager::UnrefMaterial( uint32_t uIndex )
|
void CAssetManager::UnrefMaterial( uint32_t uIndex )
|
||||||
@@ -163,6 +202,8 @@ FunnyModel_t *CAssetManager::LoadModelFromParams( const char *szMesh, const char
|
|||||||
pModel->m_szName = szMesh;
|
pModel->m_szName = szMesh;
|
||||||
pModel->m_pMesh = g_pWorldRenderer->CreateMesh(szMesh);
|
pModel->m_pMesh = g_pWorldRenderer->CreateMesh(szMesh);
|
||||||
pModel->m_pMesh->SetVertices(pVertexBuffer);
|
pModel->m_pMesh->SetVertices(pVertexBuffer);
|
||||||
|
uint32_t uMaterial = LoadMaterial(szMaterial);
|
||||||
|
pModel->m_pFunnyMaterial = GetMaterialByIndex(uMaterial);
|
||||||
return pModel;
|
return pModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,6 +241,7 @@ uint32_t CAssetManager::LoadShader( const char *szName )
|
|||||||
FunnyShader_t *pFunnyShader = new FunnyShader_t;
|
FunnyShader_t *pFunnyShader = new FunnyShader_t;
|
||||||
pFunnyShader->m_szName = szName;
|
pFunnyShader->m_szName = szName;
|
||||||
pFunnyShader->m_pShader = pShader;
|
pFunnyShader->m_pShader = pShader;
|
||||||
|
m_shaders[uFoundIndex] = pFunnyShader;
|
||||||
return uFoundIndex;
|
return uFoundIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "baseentity.h"
|
#include "baseentity.h"
|
||||||
#include "datamap.h"
|
#include "datamap.h"
|
||||||
#include "tier0/lib.h"
|
#include "tier0/lib.h"
|
||||||
|
#include "cglm/cglm.h"
|
||||||
|
|
||||||
C_BaseEntity::~C_BaseEntity()
|
C_BaseEntity::~C_BaseEntity()
|
||||||
{
|
{
|
||||||
@@ -19,11 +20,20 @@ void C_BaseEntity::Precache()
|
|||||||
|
|
||||||
void C_BaseEntity::Spawn()
|
void C_BaseEntity::Spawn()
|
||||||
{
|
{
|
||||||
|
Precache();
|
||||||
|
SetAbsOrigin({0, 0, 0});
|
||||||
|
SetAbsAngles(0, 0, 0);
|
||||||
|
SetScale(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_BaseEntity::SetAbsAngles( float fPitch, float fYaw, float fRoll )
|
void C_BaseEntity::SetAbsAngles( float fPitch, float fYaw, float fRoll )
|
||||||
{
|
{
|
||||||
|
versor q;
|
||||||
|
glm_euler_yzx_quat((vec3){fPitch, fYaw, fRoll}, q);
|
||||||
|
m_vRotation.x = q[0];
|
||||||
|
m_vRotation.y = q[1];
|
||||||
|
m_vRotation.z = q[2];
|
||||||
|
m_vRotation.w = q[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_BaseEntity::SetAbsOrigin( Vector origin )
|
void C_BaseEntity::SetAbsOrigin( Vector origin )
|
||||||
@@ -39,19 +49,24 @@ void C_BaseEntity::SetScale( float fScale )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QAngle C_BaseEntity::GetAbsAngles( void )
|
QAngle C_BaseEntity::GetAbsQAngles( void )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Quat C_BaseEntity::GetAbsAngles( void )
|
||||||
|
{
|
||||||
|
return m_vRotation;
|
||||||
|
}
|
||||||
|
|
||||||
Vector C_BaseEntity::GetAbsOrigin( void )
|
Vector C_BaseEntity::GetAbsOrigin( void )
|
||||||
{
|
{
|
||||||
|
return m_vPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
float C_BaseEntity::GetScale( void )
|
float C_BaseEntity::GetScale( void )
|
||||||
{
|
{
|
||||||
|
return m_vScale.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_BaseEntity::SetThinkImpl( fnThink pfnThink )
|
void C_BaseEntity::SetThinkImpl( fnThink pfnThink )
|
||||||
@@ -111,3 +126,9 @@ BEGIN_DATADESC_NOBASE(C_BaseEntity)
|
|||||||
DEFINE_KEYFIELD(m_vRotation, FIELD_QUATERNION, "angles")
|
DEFINE_KEYFIELD(m_vRotation, FIELD_QUATERNION, "angles")
|
||||||
DEFINE_KEYFIELD(m_vScale, FIELD_FLOAT3, "scales")
|
DEFINE_KEYFIELD(m_vScale, FIELD_FLOAT3, "scales")
|
||||||
END_DATADESC()
|
END_DATADESC()
|
||||||
|
|
||||||
|
IMPLEMENT_RECV_DT_NOBASE(C_BaseEntity)
|
||||||
|
NetPropFloat3(m_vPosition)
|
||||||
|
END_RECV_DT()
|
||||||
|
|
||||||
|
IMPLEMENT_EMPTY_SEND_DT_NOBASE(C_BaseEntity)
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
#include "entitysystem.h"
|
#include "entitysystem.h"
|
||||||
#include "datamap.h"
|
#include "datamap.h"
|
||||||
#include "trig.h"
|
#include "trig.h"
|
||||||
|
#include "netmap.h"
|
||||||
|
#include "tier1/utlstring.h"
|
||||||
|
|
||||||
#define DECLARE_CLASS_NOBASE( className ) \
|
#define DECLARE_CLASS_NOBASE( className ) \
|
||||||
typedef className ThisClass;
|
typedef className ThisClass;
|
||||||
@@ -18,7 +20,7 @@
|
|||||||
typedef className ThisClass;
|
typedef className ThisClass;
|
||||||
|
|
||||||
#define LINK_ENTITY_TO_CLASS( mapClassName, DLLClassName) \
|
#define LINK_ENTITY_TO_CLASS( mapClassName, DLLClassName) \
|
||||||
static CEntityFactory<DLLClassName> g_EntityFactory_##mapClassName( #mapClassName );
|
static CEntityFactory<DLLClassName> g_EntityFactory_##mapClassName( #mapClassName ); \
|
||||||
|
|
||||||
class C_BaseEntity;
|
class C_BaseEntity;
|
||||||
|
|
||||||
@@ -50,6 +52,7 @@ class C_BaseEntity
|
|||||||
public:
|
public:
|
||||||
DECLARE_CLASS_NOBASE(C_BaseEntity);
|
DECLARE_CLASS_NOBASE(C_BaseEntity);
|
||||||
DECLARE_DATADESC_NOBASE()
|
DECLARE_DATADESC_NOBASE()
|
||||||
|
DECLARE_CLIENTCLASS_NOBASE()
|
||||||
|
|
||||||
typedescription_t *FindDataByName( const char *szName );
|
typedescription_t *FindDataByName( const char *szName );
|
||||||
typedescription_t *FindDataByMapName( const char *szName );
|
typedescription_t *FindDataByMapName( const char *szName );
|
||||||
@@ -62,7 +65,8 @@ public:
|
|||||||
virtual void SetAbsOrigin( Vector origin );
|
virtual void SetAbsOrigin( Vector origin );
|
||||||
virtual void SetScale( float fScale );
|
virtual void SetScale( float fScale );
|
||||||
|
|
||||||
virtual QAngle GetAbsAngles( void );
|
virtual QAngle GetAbsQAngles( void );
|
||||||
|
virtual Quat GetAbsAngles( void );
|
||||||
virtual Vector GetAbsOrigin( void );
|
virtual Vector GetAbsOrigin( void );
|
||||||
virtual float GetScale( void );
|
virtual float GetScale( void );
|
||||||
|
|
||||||
@@ -71,6 +75,7 @@ public:
|
|||||||
virtual void SetNextThink( float fThink );
|
virtual void SetNextThink( float fThink );
|
||||||
|
|
||||||
fnThink m_pfnThink = NULL;
|
fnThink m_pfnThink = NULL;
|
||||||
|
CUtlString m_szClassName;
|
||||||
private:
|
private:
|
||||||
Vector m_vPosition;
|
Vector m_vPosition;
|
||||||
Quat m_vRotation;
|
Quat m_vRotation;
|
||||||
|
|||||||
34
game/client/basemodelentity.cpp
Normal file
34
game/client/basemodelentity.cpp
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#include "basemodelentity.h"
|
||||||
|
|
||||||
|
void C_BaseModelEntity::Precache()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void C_BaseModelEntity::Spawn()
|
||||||
|
{
|
||||||
|
BaseClass::Spawn();
|
||||||
|
SetThink(Think);
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_BaseModelEntity::Think( float fDelta )
|
||||||
|
{
|
||||||
|
m_pInstance->SetPosition(GetAbsOrigin());
|
||||||
|
m_pInstance->SetRotation(GetAbsAngles());
|
||||||
|
m_pInstance->SetScale({GetScale(),GetScale(),GetScale()});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void C_BaseModelEntity::SetModel( const char *szName )
|
||||||
|
{
|
||||||
|
if (m_uModelIndex)
|
||||||
|
{
|
||||||
|
g_pAssetManager->UnrefModel(m_uModelIndex);
|
||||||
|
}
|
||||||
|
m_uModelIndex = g_pAssetManager->LoadModel(szName);
|
||||||
|
m_pModel = g_pAssetManager->GetModelByIndex(m_uModelIndex);
|
||||||
|
m_pInstance = g_pWorldRenderer->CreateInstance(m_pModel->m_pMesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
BEGIN_DATADESC(C_BaseModelEntity)
|
||||||
|
|
||||||
|
END_DATADESC()
|
||||||
27
game/client/basemodelentity.h
Normal file
27
game/client/basemodelentity.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
#ifndef BASE_MODEL_ENTITY_H
|
||||||
|
#define BASE_MODEL_ENTITY_H
|
||||||
|
|
||||||
|
#include "baseentity.h"
|
||||||
|
#include "worldrender.h"
|
||||||
|
#include "assetmgr.h"
|
||||||
|
|
||||||
|
class C_BaseModelEntity: public C_BaseEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_CLASS(C_BaseModelEntity, C_BaseEntity);
|
||||||
|
DECLARE_DATADESC();
|
||||||
|
|
||||||
|
virtual void Precache() override;
|
||||||
|
virtual void Spawn() override;
|
||||||
|
void Think( float fDelta );
|
||||||
|
|
||||||
|
void SetModel( const char *szName );
|
||||||
|
private:
|
||||||
|
|
||||||
|
uint32_t m_uModelIndex;
|
||||||
|
FunnyModel_t *m_pModel;
|
||||||
|
IMeshInstance *m_pInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -18,6 +18,7 @@ DECLARE_BUILD_STAGE(Client)
|
|||||||
"game.cpp",
|
"game.cpp",
|
||||||
|
|
||||||
"baseentity.cpp",
|
"baseentity.cpp",
|
||||||
|
"basemodelentity.cpp",
|
||||||
"entitysystem.cpp",
|
"entitysystem.cpp",
|
||||||
|
|
||||||
"worldrender.cpp",
|
"worldrender.cpp",
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
#ifndef ENGINE_H
|
|
||||||
#define ENGINE_H
|
|
||||||
|
|
||||||
#include "tier2/ifilesystem.h"
|
|
||||||
#include "materialsystem/imaterialsystem.h"
|
|
||||||
#include "materialsystem/igamewindow.h"
|
|
||||||
|
|
||||||
extern IFileSystem *filesystem;
|
|
||||||
extern IRenderContext *g_pRenderContext;
|
|
||||||
extern IGameWindow *g_pMainWindow;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -81,10 +81,30 @@ C_BaseEntity *CEntitySystem::CreateByClassname( const char *szName )
|
|||||||
}
|
}
|
||||||
|
|
||||||
pEntity = pFactory->Create();
|
pEntity = pFactory->Create();
|
||||||
|
pEntity->m_szClassName = szName;
|
||||||
m_pEntities[iSelectedSlot] = pEntity;
|
m_pEntities[iSelectedSlot] = pEntity;
|
||||||
m_nEntityCount++;
|
m_nEntityCount++;
|
||||||
return pEntity;
|
return pEntity;
|
||||||
}
|
}
|
||||||
|
C_BaseEntity *CEntitySystem::CreateByClassnameWithIndex( const char *szName, uint32_t uIndex )
|
||||||
|
{
|
||||||
|
IEntityFactory *pFactory;
|
||||||
|
C_BaseEntity *pEntity;
|
||||||
|
|
||||||
|
// Do not create such shit
|
||||||
|
if (uIndex >= MAX_EDICTS)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
pFactory = GetFactoryByClassname(szName);
|
||||||
|
if ( !pFactory )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
pEntity = pFactory->Create();
|
||||||
|
pEntity->m_szClassName = szName;
|
||||||
|
m_pEntities[uIndex] = pEntity;
|
||||||
|
m_nEntityCount++;
|
||||||
|
return pEntity;
|
||||||
|
}
|
||||||
|
|
||||||
IEntityFactory *CEntitySystem::GetFactoryByClassname( const char *szName )
|
IEntityFactory *CEntitySystem::GetFactoryByClassname( const char *szName )
|
||||||
{
|
{
|
||||||
@@ -118,3 +138,8 @@ void CEntitySystem::Think()
|
|||||||
(pEntity->*pEntity->m_pfnThink)(0);
|
(pEntity->*pEntity->m_pfnThink)(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
C_BaseEntity **CEntitySystem::GetEntities()
|
||||||
|
{
|
||||||
|
return m_pEntities;
|
||||||
|
};
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
#ifndef ENTITIES_H
|
#ifndef ENTITIES_H
|
||||||
#define ENTITIES_H
|
#define ENTITIES_H
|
||||||
|
|
||||||
|
#include "stdint.h"
|
||||||
|
|
||||||
class IEntityFactory;
|
class IEntityFactory;
|
||||||
class C_BaseEntity;
|
class C_BaseEntity;
|
||||||
|
|
||||||
@@ -19,10 +21,12 @@ public:
|
|||||||
|
|
||||||
virtual void RegisterEntityClass( IEntityFactory *pEntityFactory, const char *szClassName );
|
virtual void RegisterEntityClass( IEntityFactory *pEntityFactory, const char *szClassName );
|
||||||
virtual C_BaseEntity *CreateByClassname( const char *szName );
|
virtual C_BaseEntity *CreateByClassname( const char *szName );
|
||||||
|
virtual C_BaseEntity *CreateByClassnameWithIndex( const char *szName, uint32_t uIndex );
|
||||||
|
|
||||||
virtual IEntityFactory *GetFactoryByClassname( const char *szName );
|
virtual IEntityFactory *GetFactoryByClassname( const char *szName );
|
||||||
|
|
||||||
virtual void Think();
|
virtual void Think();
|
||||||
|
virtual C_BaseEntity **GetEntities();
|
||||||
private:
|
private:
|
||||||
C_BaseEntity *m_pEntities[MAX_EDICTS];
|
C_BaseEntity *m_pEntities[MAX_EDICTS];
|
||||||
int m_nEntityCount;
|
int m_nEntityCount;
|
||||||
|
|||||||
@@ -7,12 +7,16 @@
|
|||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "cglm/mat4.h"
|
#include "cglm/mat4.h"
|
||||||
#include "cglm/cglm.h"
|
#include "cglm/cglm.h"
|
||||||
|
#include "inetworkclient.h"
|
||||||
|
#include "netprotocol.h"
|
||||||
|
|
||||||
IFileSystem *filesystem;
|
IFileSystem *filesystem;
|
||||||
IRenderContext *g_pRenderContext;
|
IRenderContext *g_pRenderContext;
|
||||||
IGameWindow *g_pMainWindow;
|
IGameWindow *g_pMainWindow;
|
||||||
static CEngineVars s_vars;
|
static CEngineVars s_vars;
|
||||||
CEngineVars *g_pEngineVars = &s_vars;
|
CEngineVars *g_pEngineVars = &s_vars;
|
||||||
|
EngineConsts_t *g_pEngineConstants;
|
||||||
|
INetworkBase *g_pServerBridge;
|
||||||
|
|
||||||
class CFunnyGameBridge: public IEngineBridge
|
class CFunnyGameBridge: public IEngineBridge
|
||||||
{
|
{
|
||||||
@@ -34,18 +38,90 @@ EXPOSE_INTERFACE_FN(EngineBridge, IEngineBridge, ENGINE_BRIDGE_INTERFACE_VERSION
|
|||||||
void CFunnyGameBridge::Init()
|
void CFunnyGameBridge::Init()
|
||||||
{
|
{
|
||||||
g_pWorldRenderer->Init();
|
g_pWorldRenderer->Init();
|
||||||
C_BaseEntity *pEntity = EntitySystem()->CreateByClassname("player");
|
g_pServerBridge = g_pEngineConstants->ConnectLocalBridge(0);
|
||||||
pEntity->Spawn();
|
|
||||||
|
PlayerJoined_t join = {
|
||||||
|
MESSAGE_PLAYER_JOINED,
|
||||||
|
"LocalPlayer"
|
||||||
|
};
|
||||||
|
g_pServerBridge->SendPacket({&join, sizeof(join)});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFunnyGameBridge::Tick( float fDelta )
|
void CFunnyGameBridge::Tick( float fDelta )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *ENT_GetNetMapData(C_BaseEntity *pEntity, netmap_t *pMap, uint32_t uIndex )
|
||||||
|
{
|
||||||
|
netmap_t *pCurrentMap = pMap;
|
||||||
|
uint32_t uCurrentIndex = uIndex;
|
||||||
|
searchIndex:
|
||||||
|
if (uCurrentIndex >= pCurrentMap->m_uFieldCount)
|
||||||
|
{
|
||||||
|
if (!pCurrentMap->m_uFieldCount)
|
||||||
|
return NULL;
|
||||||
|
uCurrentIndex -= pCurrentMap->m_uFieldCount;
|
||||||
|
pCurrentMap = pCurrentMap->m_pBase;
|
||||||
|
if (!pCurrentMap)
|
||||||
|
return NULL;
|
||||||
|
goto searchIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (char*)pEntity+pCurrentMap->m_pFields[uCurrentIndex].m_uOffset;
|
||||||
|
}
|
||||||
|
|
||||||
void CFunnyGameBridge::Frame( float fDelta )
|
void CFunnyGameBridge::Frame( float fDelta )
|
||||||
{
|
{
|
||||||
g_pEngineVars->m_fTime += fDelta;
|
g_pEngineVars->m_fTime += fDelta;
|
||||||
g_pEngineVars->m_fDeltaTime = fDelta;
|
g_pEngineVars->m_fDeltaTime = fDelta;
|
||||||
|
|
||||||
|
g_pServerBridge->NetThink();
|
||||||
|
while ( g_pServerBridge->BHasUpdates() )
|
||||||
|
{
|
||||||
|
NetPacket_t packet = g_pServerBridge->PeekPacket();
|
||||||
|
// discard it
|
||||||
|
if (packet.uSize < sizeof (EMessageType))
|
||||||
|
continue;
|
||||||
|
PlayerPacket_t *pPacket = (PlayerPacket_t*)packet.pData;
|
||||||
|
C_BaseEntity *pEntity;
|
||||||
|
switch (pPacket->m_eType)
|
||||||
|
{
|
||||||
|
case MESSAGE_ENTITY_CLASS_SYNC:
|
||||||
|
pEntity = EntitySystem()->CreateByClassnameWithIndex(
|
||||||
|
(char*)pPacket->m_entityClass.m_szEntityName, pPacket->m_entityClass.m_uIndex
|
||||||
|
);
|
||||||
|
pEntity->Spawn();
|
||||||
|
g_pServerBridge->RecievePacket();
|
||||||
|
break;
|
||||||
|
case MESSAGE_ENTITY_DATA_SYNC:
|
||||||
|
pEntity = EntitySystem()->GetEntities()[pPacket->m_entityData.m_uIndex];
|
||||||
|
union {
|
||||||
|
void *pData;
|
||||||
|
char *pcCurrentData;
|
||||||
|
EntityDataSyncValue_t *pcSyncValue;
|
||||||
|
};
|
||||||
|
pData = pPacket;
|
||||||
|
pcCurrentData += sizeof(EntityDataSync_t);
|
||||||
|
for ( uint32_t u = 0; u < pPacket->m_entityData.m_uCount; u++ )
|
||||||
|
{
|
||||||
|
uint32_t uVariableSize = pcSyncValue->m_uVariableSize;
|
||||||
|
void *pValueData = (float*)ENT_GetNetMapData(
|
||||||
|
pEntity,
|
||||||
|
pEntity->GetRecvMap(),
|
||||||
|
pcSyncValue->m_uVariableIndex);
|
||||||
|
|
||||||
|
pcCurrentData += sizeof(EntityDataSyncValue_t);
|
||||||
|
if (pValueData)
|
||||||
|
V_memcpy(pValueData, pcCurrentData, uVariableSize);
|
||||||
|
pcCurrentData += (uVariableSize+7) & ~7;
|
||||||
|
}
|
||||||
|
g_pServerBridge->RecievePacket();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EntitySystem()->Think();
|
EntitySystem()->Think();
|
||||||
g_pWorldRenderer->Frame(fDelta);
|
g_pWorldRenderer->Frame(fDelta);
|
||||||
}
|
}
|
||||||
@@ -61,5 +137,6 @@ void CFunnyGameBridge::ConnectInterface( const char *psz, void *pInterface )
|
|||||||
CONNECT_INTERFACE(RENDER_CONTEXT_INTERFACE_VERSION, g_pRenderContext);
|
CONNECT_INTERFACE(RENDER_CONTEXT_INTERFACE_VERSION, g_pRenderContext);
|
||||||
CONNECT_INTERFACE(FILESYSTEM_INTERFACE_VERSION, filesystem);
|
CONNECT_INTERFACE(FILESYSTEM_INTERFACE_VERSION, filesystem);
|
||||||
CONNECT_INTERFACE("MainWindow", g_pMainWindow);
|
CONNECT_INTERFACE("MainWindow", g_pMainWindow);
|
||||||
|
CONNECT_INTERFACE("EngineConstants", g_pEngineConstants);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
0
game/client/mapmgr.cpp
Normal file
0
game/client/mapmgr.cpp
Normal file
0
game/client/mapmgr.h
Normal file
0
game/client/mapmgr.h
Normal file
0
game/client/milmoba/baseprojectile.cpp
Normal file
0
game/client/milmoba/baseprojectile.cpp
Normal file
0
game/client/milmoba/baseprojectile.h
Normal file
0
game/client/milmoba/baseprojectile.h
Normal file
0
game/client/milmoba/baseweapon.cpp
Normal file
0
game/client/milmoba/baseweapon.cpp
Normal file
0
game/client/milmoba/baseweapon.h
Normal file
0
game/client/milmoba/baseweapon.h
Normal file
@@ -4,21 +4,29 @@
|
|||||||
|
|
||||||
void C_MOBAPlayer::Precache()
|
void C_MOBAPlayer::Precache()
|
||||||
{
|
{
|
||||||
uint32_t uIndex = g_pAssetManager->LoadModel("game/core/models/cube.fmdl");
|
SetModel("game/core/models/cube.fmdl");
|
||||||
V_printf("%u\n", uIndex);
|
|
||||||
pModel = g_pAssetManager->GetModelByIndex(uIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void C_MOBAPlayer::Spawn()
|
void C_MOBAPlayer::Spawn()
|
||||||
{
|
{
|
||||||
Precache();
|
BaseClass::Spawn();
|
||||||
SetThink(Think);
|
SetThink(Think);
|
||||||
|
g_pWorldRenderer->SetCameraPosition({0, 0, -20});
|
||||||
};
|
};
|
||||||
|
|
||||||
void C_MOBAPlayer::Think( float fDelta )
|
void C_MOBAPlayer::Think( float fDelta )
|
||||||
{
|
{
|
||||||
|
BaseClass::Think(fDelta);
|
||||||
};
|
};
|
||||||
|
|
||||||
LINK_ENTITY_TO_CLASS(player, C_MOBAPlayer)
|
LINK_ENTITY_TO_CLASS(player, C_MOBAPlayer)
|
||||||
|
|
||||||
|
BEGIN_DATADESC(C_MOBAPlayer)
|
||||||
|
END_DATADESC()
|
||||||
|
|
||||||
|
IMPLEMENT_RECV_DT(C_MOBAPlayer)
|
||||||
|
NetPropFloat(m_fTimer),
|
||||||
|
END_RECV_DT()
|
||||||
|
IMPLEMENT_EMPTY_SEND_DT(C_MOBAPlayer)
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
|
|
||||||
#include "baseentity.h"
|
#ifndef MILMOBA_PLAYER_H
|
||||||
#include "worldrender.h"
|
#define MILMOBA_PLAYER_H
|
||||||
#include "game.h"
|
#include "basemodelentity.h"
|
||||||
#include "assetmgr.h"
|
|
||||||
|
|
||||||
|
|
||||||
class C_MOBAPlayer: public C_BaseEntity
|
class C_MOBAPlayer: public C_BaseModelEntity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_CLASS(C_MOBAPlayer, C_BaseEntity)
|
DECLARE_CLASS(C_MOBAPlayer, C_BaseModelEntity);
|
||||||
|
DECLARE_DATADESC();
|
||||||
|
DECLARE_CLIENTCLASS()
|
||||||
|
|
||||||
virtual void Precache ( void ) override;
|
virtual void Precache ( void ) override;
|
||||||
virtual void Spawn( void ) override;
|
virtual void Spawn( void ) override;
|
||||||
virtual void Think( float fDelta );
|
void Think( float fDelta );
|
||||||
|
|
||||||
FunnyModel_t *pModel;
|
float m_fTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -134,6 +134,8 @@ private:
|
|||||||
ViewBuffer_t *m_pViewBufferData;
|
ViewBuffer_t *m_pViewBufferData;
|
||||||
|
|
||||||
ITextureArray *m_pTextures;
|
ITextureArray *m_pTextures;
|
||||||
|
IShader *m_pRasterShader;
|
||||||
|
IMaterial *m_pRasterMaterial;
|
||||||
|
|
||||||
vec3 m_vPos;
|
vec3 m_vPos;
|
||||||
versor m_vRot;
|
versor m_vRot;
|
||||||
@@ -192,6 +194,10 @@ void CFunnyWorldRenderer::Init()
|
|||||||
IMAGE_FORMAT_D32_SFLOAT,
|
IMAGE_FORMAT_D32_SFLOAT,
|
||||||
MULTISAMPLE_TYPE_4_SAMPLES
|
MULTISAMPLE_TYPE_4_SAMPLES
|
||||||
);
|
);
|
||||||
|
m_pRasterShader = g_pRenderContext->CreateShader("game/core/shaders/mesh_raster.shader_c");
|
||||||
|
ConfigureShader(m_pRasterShader);
|
||||||
|
m_pRasterShader->Build();
|
||||||
|
m_pRasterMaterial = g_pRenderContext->CreateMaterial(m_pRasterShader);
|
||||||
|
|
||||||
g_pMainWindow->SetOutputImage(m_pResolvedOutputImage);
|
g_pMainWindow->SetOutputImage(m_pResolvedOutputImage);
|
||||||
|
|
||||||
@@ -291,16 +297,16 @@ void CFunnyWorldRenderer::Frame( float fDelta )
|
|||||||
}
|
}
|
||||||
pDataBuffer->Unmap();
|
pDataBuffer->Unmap();
|
||||||
pDataBuffer->Unlock();
|
pDataBuffer->Unlock();
|
||||||
mesh->m_pMaterial->VSSetConstantsBuffer(0, m_pViewBuffer);
|
m_pRasterMaterial->VSSetConstantsBuffer(0, m_pViewBuffer);
|
||||||
mesh->m_pMaterial->VSSetConstantsBuffer(1, pDataBuffer);
|
m_pRasterMaterial->VSSetConstantsBuffer(1, pDataBuffer);
|
||||||
mesh->m_pMaterial->PSSetTextureArray(1, m_pTextures);
|
m_pRasterMaterial->PSSetTextureArray(1, m_pTextures);
|
||||||
g_pRenderContext->DestroyBuffer(pDataBuffer);
|
g_pRenderContext->DestroyBuffer(pDataBuffer);
|
||||||
}
|
}
|
||||||
for ( auto mesh: m_pMeshes)
|
for ( auto mesh: m_pMeshes)
|
||||||
{
|
{
|
||||||
if (mesh->m_instances.GetSize()==0)
|
if (mesh->m_instances.GetSize()==0)
|
||||||
continue;
|
continue;
|
||||||
m_pRasterCommandList->SetMaterial(mesh->m_pMaterial);
|
m_pRasterCommandList->SetMaterial(m_pRasterMaterial);
|
||||||
m_pRasterCommandList->SetVertexBuffer(0, mesh->m_pVertexBuffer);
|
m_pRasterCommandList->SetVertexBuffer(0, mesh->m_pVertexBuffer);
|
||||||
m_pRasterCommandList->DrawPrimitives(mesh->m_pVertexBuffer->GetSize()/32, 0, mesh->m_instances.GetSize(), 0);
|
m_pRasterCommandList->DrawPrimitives(mesh->m_pVertexBuffer->GetSize()/32, 0, mesh->m_instances.GetSize(), 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,16 @@ public:
|
|||||||
virtual void SetMaterial( IMaterial *pMaterial ) = 0;
|
virtual void SetMaterial( IMaterial *pMaterial ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
abstract_class IPointLight
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void SetColor( Vector vColor ) = 0;
|
||||||
|
virtual void SetRadius( Vector vColor ) = 0;
|
||||||
|
virtual void SetPosition( Vector vPosition ) = 0;
|
||||||
|
virtual void SetRotation( Quat vRotation ) = 0;
|
||||||
|
virtual void SetScale( Vector vScale ) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
abstract_class IMeshInstance
|
abstract_class IMeshInstance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -7,15 +7,20 @@
|
|||||||
#include "baseentity.h"
|
#include "baseentity.h"
|
||||||
#include "datamap.h"
|
#include "datamap.h"
|
||||||
#include "tier0/lib.h"
|
#include "tier0/lib.h"
|
||||||
|
#include "tier0/mem.h"
|
||||||
|
|
||||||
CBaseEntity::~CBaseEntity()
|
CBaseEntity::~CBaseEntity()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void CBaseEntity::Precache()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBaseEntity::Spawn()
|
void CBaseEntity::Spawn()
|
||||||
{
|
{
|
||||||
|
Precache();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBaseEntity::SetAbsAngles( float fPitch, float fYaw, float fRoll )
|
void CBaseEntity::SetAbsAngles( float fPitch, float fYaw, float fRoll )
|
||||||
@@ -35,22 +40,27 @@ void CBaseEntity::SetScale( float fScale )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QAngle CBaseEntity::GetAbsAngles( void )
|
QAngle CBaseEntity::GetAbsQAngles( void )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Quat CBaseEntity::GetAbsAngles( void )
|
||||||
|
{
|
||||||
|
return m_vRotation;
|
||||||
|
}
|
||||||
|
|
||||||
Vector CBaseEntity::GetAbsOrigin( void )
|
Vector CBaseEntity::GetAbsOrigin( void )
|
||||||
{
|
{
|
||||||
|
return m_vPosition;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float CBaseEntity::GetScale( void )
|
float CBaseEntity::GetScale( void )
|
||||||
{
|
{
|
||||||
|
return m_vScale.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBaseEntity::SetThink( fnThink pfnThink )
|
void CBaseEntity::SetThinkImpl( fnThink pfnThink )
|
||||||
{
|
{
|
||||||
m_pfnThink = pfnThink;
|
m_pfnThink = pfnThink;
|
||||||
}
|
}
|
||||||
@@ -107,3 +117,9 @@ BEGIN_DATADESC_NOBASE(CBaseEntity)
|
|||||||
DEFINE_KEYFIELD(m_vRotation, FIELD_QUATERNION, "angles")
|
DEFINE_KEYFIELD(m_vRotation, FIELD_QUATERNION, "angles")
|
||||||
DEFINE_KEYFIELD(m_vScale, FIELD_FLOAT3, "scales")
|
DEFINE_KEYFIELD(m_vScale, FIELD_FLOAT3, "scales")
|
||||||
END_DATADESC()
|
END_DATADESC()
|
||||||
|
|
||||||
|
IMPLEMENT_SEND_DT_NOBASE(CBaseEntity)
|
||||||
|
NetPropFloat3(m_vPosition)
|
||||||
|
END_SEND_DT()
|
||||||
|
|
||||||
|
IMPLEMENT_EMPTY_RECV_DT_NOBASE(CBaseEntity)
|
||||||
|
|||||||
@@ -11,15 +11,12 @@
|
|||||||
#include "datamap.h"
|
#include "datamap.h"
|
||||||
#include "cglm/cglm.h"
|
#include "cglm/cglm.h"
|
||||||
#include "trig.h"
|
#include "trig.h"
|
||||||
|
#include "netmap.h"
|
||||||
|
|
||||||
#define DECLARE_CLASS_NOBASE( className ) \
|
|
||||||
typedef className ThisClass;
|
|
||||||
#define DECLARE_CLASS( className, baseName ) \
|
|
||||||
typedef baseName BaseClass; \
|
|
||||||
typedef className ThisClass;
|
|
||||||
|
|
||||||
#define LINK_ENTITY_TO_CLASS( mapClassName, DLLClassName) \
|
#define LINK_ENTITY_TO_CLASS( mapClassName, DLLClassName) \
|
||||||
static CEntityFactory<DLLClassName> g_EntityFactory_##mapClassName( #mapClassName );
|
static CEntityFactory<DLLClassName> g_EntityFactory_##mapClassName( #mapClassName ); \
|
||||||
|
|
||||||
|
|
||||||
class CBaseEntity;
|
class CBaseEntity;
|
||||||
|
|
||||||
@@ -45,35 +42,46 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
class CBaseEntity;
|
class CBaseEntity;
|
||||||
typedef void(*fnThink)( float fTime );
|
typedef void(CBaseEntity::*fnThink)( float fTime );
|
||||||
class CBaseEntity
|
class CBaseEntity
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DECLARE_CLASS_NOBASE(CBaseEntity);
|
DECLARE_CLASS_NOBASE(CBaseEntity);
|
||||||
DECLARE_DATADESC_NOBASE()
|
DECLARE_DATADESC_NOBASE()
|
||||||
|
DECLARE_SERVERCLASS_NOBASE()
|
||||||
|
|
||||||
typedescription_t *FindDataByName( const char *szName );
|
typedescription_t *FindDataByName( const char *szName );
|
||||||
typedescription_t *FindDataByMapName( const char *szName );
|
typedescription_t *FindDataByMapName( const char *szName );
|
||||||
|
|
||||||
|
const char *GetClassName();
|
||||||
|
|
||||||
virtual ~CBaseEntity();
|
virtual ~CBaseEntity();
|
||||||
|
virtual void Precache();
|
||||||
virtual void Spawn();
|
virtual void Spawn();
|
||||||
|
|
||||||
virtual void SetAbsAngles( float fPitch, float fYaw, float fRoll );
|
virtual void SetAbsAngles( float fPitch, float fYaw, float fRoll );
|
||||||
virtual void SetAbsOrigin( Vector origin );
|
virtual void SetAbsOrigin( Vector origin );
|
||||||
virtual void SetScale( float fScale );
|
virtual void SetScale( float fScale );
|
||||||
|
|
||||||
virtual QAngle GetAbsAngles( void );
|
virtual QAngle GetAbsQAngles( void );
|
||||||
|
virtual Quat GetAbsAngles( void );
|
||||||
virtual Vector GetAbsOrigin( void );
|
virtual Vector GetAbsOrigin( void );
|
||||||
virtual float GetScale( void );
|
virtual float GetScale( void );
|
||||||
|
|
||||||
virtual void SetThink( fnThink pfnThink );
|
#define SetThink(fn) SetThinkImpl((fnThink)&ThisClass::fn)
|
||||||
|
virtual void SetThinkImpl( fnThink pfnThink );
|
||||||
virtual void SetNextThink( float fThink );
|
virtual void SetNextThink( float fThink );
|
||||||
|
|
||||||
fnThink m_pfnThink = NULL;
|
fnThink m_pfnThink = NULL;
|
||||||
|
const char *m_szClassName;
|
||||||
private:
|
private:
|
||||||
Vector m_vPosition;
|
Vector m_vPosition;
|
||||||
Quat m_vRotation;
|
Quat m_vRotation;
|
||||||
Vector m_vScale;
|
Vector m_vScale;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
1
game/server/basemodelentity.cpp
Normal file
1
game/server/basemodelentity.cpp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
12
game/server/basemodelentity.h
Normal file
12
game/server/basemodelentity.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#ifndef BASE_MODEL_ENTITY_H
|
||||||
|
#define BASE_MODEL_ENTITY_H
|
||||||
|
|
||||||
|
#include "baseentity.h"
|
||||||
|
|
||||||
|
class CBaseModelEntity: public CBaseEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_CLASS(CBaseModelEntity, CBaseEntity);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -18,6 +18,9 @@ DECLARE_BUILD_STAGE(Server)
|
|||||||
"game.cpp",
|
"game.cpp",
|
||||||
"entitysystem.cpp",
|
"entitysystem.cpp",
|
||||||
"baseentity.cpp",
|
"baseentity.cpp",
|
||||||
|
"basemodelentity.cpp",
|
||||||
|
|
||||||
|
"milmoba/player.cpp",
|
||||||
};
|
};
|
||||||
compileProject.includeDirectories = {
|
compileProject.includeDirectories = {
|
||||||
"../../public",
|
"../../public",
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#include "stddef.h"
|
#include "stddef.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
|
#include "engine.h"
|
||||||
|
#include "netprotocol.h"
|
||||||
|
|
||||||
|
|
||||||
CEntitySystem *EntitySystem()
|
CEntitySystem *EntitySystem()
|
||||||
@@ -81,11 +83,18 @@ CBaseEntity *CEntitySystem::CreateByClassname( const char *szName )
|
|||||||
}
|
}
|
||||||
|
|
||||||
pEntity = pFactory->Create();
|
pEntity = pFactory->Create();
|
||||||
|
pEntity->m_szClassName = szName;
|
||||||
m_pEntities[iSelectedSlot] = pEntity;
|
m_pEntities[iSelectedSlot] = pEntity;
|
||||||
m_nEntityCount++;
|
m_nEntityCount++;
|
||||||
|
|
||||||
|
EntityClass_t stClassSync = {
|
||||||
|
MESSAGE_ENTITY_CLASS_SYNC,
|
||||||
|
iSelectedSlot,
|
||||||
|
};
|
||||||
|
V_strncpy((char*)stClassSync.m_szEntityName, szName, 256);
|
||||||
|
g_pClientBridge->SendPacket({&stClassSync, sizeof(stClassSync)});
|
||||||
return pEntity;
|
return pEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
IEntityFactory *CEntitySystem::GetFactoryByClassname( const char *szName )
|
IEntityFactory *CEntitySystem::GetFactoryByClassname( const char *szName )
|
||||||
{
|
{
|
||||||
EntityRegistry_t *pEntity;
|
EntityRegistry_t *pEntity;
|
||||||
@@ -99,15 +108,27 @@ IEntityFactory *CEntitySystem::GetFactoryByClassname( const char *szName )
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CEntitySystem::Think()
|
void CEntitySystem::Think()
|
||||||
{
|
{
|
||||||
CBaseEntity *pEntity;
|
CBaseEntity *pEntity;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
uint32_t u;
|
||||||
|
uint32_t x;
|
||||||
|
uint32_t uSize;
|
||||||
|
netmap_t *pNetMap;
|
||||||
|
void *pData;
|
||||||
|
union {
|
||||||
|
void *pCurrentData;
|
||||||
|
char *pcCurrentData;
|
||||||
|
EntityDataSync_t *pSync;
|
||||||
|
EntityDataSyncValue_t *pValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
for ( i = 0; i < MAX_EDICTS; i++ )
|
for ( i = 0; i < MAX_EDICTS; i++ )
|
||||||
{
|
{
|
||||||
|
|
||||||
pEntity = m_pEntities[i];
|
pEntity = m_pEntities[i];
|
||||||
if ( pEntity == NULL )
|
if ( pEntity == NULL )
|
||||||
continue;
|
continue;
|
||||||
@@ -115,6 +136,54 @@ void CEntitySystem::Think()
|
|||||||
if ( !pEntity->m_pfnThink )
|
if ( !pEntity->m_pfnThink )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pEntity->m_pfnThink(0);
|
(pEntity->*pEntity->m_pfnThink)(0);
|
||||||
|
|
||||||
|
pNetMap = pEntity->GetSendMap();
|
||||||
|
uSize = sizeof(EntityDataSyncValue_t);
|
||||||
|
x = 0;
|
||||||
|
while ( pNetMap )
|
||||||
|
{
|
||||||
|
for ( u = 0; u < pNetMap->m_uFieldCount; u++ )
|
||||||
|
{
|
||||||
|
x++;
|
||||||
|
uSize += (pNetMap->m_pFields[u].m_uSize+7) & ~7;
|
||||||
|
uSize += sizeof(EntityDataSyncValue_t);
|
||||||
|
}
|
||||||
|
pNetMap = pNetMap->m_pBase;
|
||||||
|
}
|
||||||
|
pData = V_malloc(uSize);
|
||||||
|
V_memset(pData, 0, uSize);
|
||||||
|
pCurrentData = pData;
|
||||||
|
pSync->m_eType = MESSAGE_ENTITY_DATA_SYNC;
|
||||||
|
pSync->m_uIndex = i;
|
||||||
|
pSync->m_uCount = x;
|
||||||
|
|
||||||
|
pcCurrentData += sizeof(EntityDataSync_t);
|
||||||
|
pNetMap = pEntity->GetSendMap();
|
||||||
|
x = 0;
|
||||||
|
while ( pNetMap )
|
||||||
|
{
|
||||||
|
for ( u = 0; u < pNetMap->m_uFieldCount; u++ )
|
||||||
|
{
|
||||||
|
pValue->m_uVariableSize = pNetMap->m_pFields[u].m_uSize;
|
||||||
|
pValue->m_uVariableIndex = x;
|
||||||
|
uint32_t uVariableSize;
|
||||||
|
pcCurrentData += sizeof(EntityDataSyncValue_t);
|
||||||
|
V_memcpy(pcCurrentData,
|
||||||
|
pNetMap->m_pFields[u].m_uOffset+(char*)pEntity,
|
||||||
|
pNetMap->m_pFields[u].m_uSize);
|
||||||
|
pcCurrentData += (pNetMap->m_pFields[u].m_uSize+7) & ~7;
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
pNetMap = pNetMap->m_pBase;
|
||||||
|
}
|
||||||
|
g_pClientBridge->SendPacket({pData, uSize});
|
||||||
|
V_free(pData);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CBaseEntity **CEntitySystem::GetEntities()
|
||||||
|
{
|
||||||
|
return m_pEntities;
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public:
|
|||||||
virtual IEntityFactory *GetFactoryByClassname( const char *szName );
|
virtual IEntityFactory *GetFactoryByClassname( const char *szName );
|
||||||
|
|
||||||
virtual void Think();
|
virtual void Think();
|
||||||
|
virtual CBaseEntity **GetEntities();
|
||||||
private:
|
private:
|
||||||
CBaseEntity *m_pEntities[MAX_EDICTS];
|
CBaseEntity *m_pEntities[MAX_EDICTS];
|
||||||
int m_nEntityCount;
|
int m_nEntityCount;
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
#include "tier2/ifilesystem.h"
|
#include "tier2/ifilesystem.h"
|
||||||
#include "materialsystem/imaterialsystem.h"
|
#include "entitysystem.h"
|
||||||
|
#include "baseentity.h"
|
||||||
#include "enginebridge.h"
|
#include "enginebridge.h"
|
||||||
|
#include "game.h"
|
||||||
|
#include "inetworkserver.h"
|
||||||
|
#include "netprotocol.h"
|
||||||
|
|
||||||
IFileSystem *filesystem;
|
IFileSystem *filesystem;
|
||||||
IRenderContext *g_pRenderContext;
|
IRenderContext *g_pRenderContext;
|
||||||
IGameWindow *g_pMainWindow;
|
IGameWindow *g_pMainWindow;
|
||||||
|
static CEngineVars s_vars;
|
||||||
|
CEngineVars *g_pEngineVars = &s_vars;
|
||||||
|
EngineConsts_t *g_pEngineConstants;
|
||||||
|
INetworkBase *g_pClientBridge;
|
||||||
|
|
||||||
class CFunnyGameBridge: public IEngineBridge
|
class CFunnyGameBridge: public IEngineBridge
|
||||||
{
|
{
|
||||||
@@ -13,6 +21,7 @@ class CFunnyGameBridge: public IEngineBridge
|
|||||||
virtual void Frame( float fDelta ) override;
|
virtual void Frame( float fDelta ) override;
|
||||||
virtual void Shutdown() override;
|
virtual void Shutdown() override;
|
||||||
virtual void ConnectInterface( const char *psz, void *pInterface ) override;
|
virtual void ConnectInterface( const char *psz, void *pInterface ) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IEngineBridge *EngineBridge()
|
IEngineBridge *EngineBridge()
|
||||||
@@ -24,7 +33,8 @@ IEngineBridge *EngineBridge()
|
|||||||
EXPOSE_INTERFACE_FN(EngineBridge, IEngineBridge, ENGINE_BRIDGE_INTERFACE_VERSION)
|
EXPOSE_INTERFACE_FN(EngineBridge, IEngineBridge, ENGINE_BRIDGE_INTERFACE_VERSION)
|
||||||
|
|
||||||
void CFunnyGameBridge::Init()
|
void CFunnyGameBridge::Init()
|
||||||
{
|
{
|
||||||
|
g_pClientBridge = g_pEngineConstants->LaunchLocalBridge(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFunnyGameBridge::Tick( float fDelta )
|
void CFunnyGameBridge::Tick( float fDelta )
|
||||||
@@ -34,6 +44,32 @@ void CFunnyGameBridge::Tick( float fDelta )
|
|||||||
|
|
||||||
void CFunnyGameBridge::Frame( float fDelta )
|
void CFunnyGameBridge::Frame( float fDelta )
|
||||||
{
|
{
|
||||||
|
g_pEngineVars->m_fTime += fDelta;
|
||||||
|
g_pEngineVars->m_fDeltaTime = fDelta;
|
||||||
|
|
||||||
|
g_pClientBridge->NetThink();
|
||||||
|
while (g_pClientBridge->BHasUpdates())
|
||||||
|
{
|
||||||
|
NetPacket_t packet = g_pClientBridge->PeekPacket();
|
||||||
|
// discard it
|
||||||
|
if (packet.uSize < sizeof (EMessageType))
|
||||||
|
continue;
|
||||||
|
PlayerPacket_t *pPacket = (PlayerPacket_t*)packet.pData;
|
||||||
|
CBaseEntity *pEntity;
|
||||||
|
switch (pPacket->m_eType)
|
||||||
|
{
|
||||||
|
case MESSAGE_PLAYER_JOINED:
|
||||||
|
g_pClientBridge->RecievePacket();
|
||||||
|
V_printf("Hi %s\n",pPacket->m_playerJoined.m_szPlayerName);
|
||||||
|
pEntity = EntitySystem()->CreateByClassname("player");
|
||||||
|
pEntity->Spawn();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EntitySystem()->Think();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,5 +81,6 @@ void CFunnyGameBridge::Shutdown()
|
|||||||
#define CONNECT_INTERFACE(szName, pGlobal) if (!V_strcmp(psz, szName)) { pGlobal = (typeof(pGlobal))pInterface; return; }
|
#define CONNECT_INTERFACE(szName, pGlobal) if (!V_strcmp(psz, szName)) { pGlobal = (typeof(pGlobal))pInterface; return; }
|
||||||
void CFunnyGameBridge::ConnectInterface( const char *psz, void *pInterface )
|
void CFunnyGameBridge::ConnectInterface( const char *psz, void *pInterface )
|
||||||
{
|
{
|
||||||
|
CONNECT_INTERFACE("EngineConstants", g_pEngineConstants)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
26
game/server/milmoba/player.cpp
Normal file
26
game/server/milmoba/player.cpp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#include "player.h"
|
||||||
|
#include "game.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CMOBAPlayer::Spawn()
|
||||||
|
{
|
||||||
|
SetThink(Think);
|
||||||
|
};
|
||||||
|
|
||||||
|
void CMOBAPlayer::Think( float fDelta )
|
||||||
|
{
|
||||||
|
m_fTimer = g_pEngineVars->m_fTime;
|
||||||
|
SetAbsOrigin({m_fTimer,0,0});
|
||||||
|
};
|
||||||
|
|
||||||
|
LINK_ENTITY_TO_CLASS(player, CMOBAPlayer)
|
||||||
|
|
||||||
|
BEGIN_DATADESC(CMOBAPlayer)
|
||||||
|
END_DATADESC()
|
||||||
|
|
||||||
|
IMPLEMENT_SEND_DT(CMOBAPlayer)
|
||||||
|
NetPropFloat(m_fTimer)
|
||||||
|
END_SEND_DT()
|
||||||
|
|
||||||
|
IMPLEMENT_EMPTY_RECV_DT(CMOBAPlayer)
|
||||||
19
game/server/milmoba/player.h
Normal file
19
game/server/milmoba/player.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef MILMOBA_PLAYER_H
|
||||||
|
#define MILMOBA_PLAYER_H
|
||||||
|
#include "basemodelentity.h"
|
||||||
|
|
||||||
|
|
||||||
|
class CMOBAPlayer: public CBaseModelEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_CLASS(CMOBAPlayer, CBaseModelEntity);
|
||||||
|
DECLARE_DATADESC();
|
||||||
|
DECLARE_SERVERCLASS()
|
||||||
|
|
||||||
|
virtual void Spawn( void ) override;
|
||||||
|
void Think( float fDelta );
|
||||||
|
|
||||||
|
float m_fTimer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
1
game/server/pointentity.cpp
Normal file
1
game/server/pointentity.cpp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include "pointentity.h"
|
||||||
10
game/server/pointentity.h
Normal file
10
game/server/pointentity.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef POINT_ENTITY_H
|
||||||
|
#define POINT_ENTITY_H
|
||||||
|
|
||||||
|
#include "baseentity.h"
|
||||||
|
class CPointEntity: public CBaseEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
#ifndef DATAMAP_H
|
#ifndef DATAMAP_H
|
||||||
#define DATAMAP_H
|
#define DATAMAP_H
|
||||||
#include "stddef.h"
|
#include "stddef.h"
|
||||||
|
#include "gameclass.h"
|
||||||
|
|
||||||
enum fieldtype_t {
|
enum fieldtype_t {
|
||||||
FIELD_VOID = 0,
|
FIELD_VOID = 0,
|
||||||
@@ -57,12 +58,6 @@ struct datamap_t
|
|||||||
int m_iNumFields;
|
int m_iNumFields;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DECLARE_CLASS_NOBASE( className ) \
|
|
||||||
typedef className ThisClass;
|
|
||||||
#define DECLARE_CLASS( className, baseName ) \
|
|
||||||
typedef baseName BaseClass; \
|
|
||||||
typedef className ThisClass;
|
|
||||||
|
|
||||||
#define DECLARE_DATADESC() \
|
#define DECLARE_DATADESC() \
|
||||||
datamap_t *GetBaseMap(); \
|
datamap_t *GetBaseMap(); \
|
||||||
virtual datamap_t *GetDataMap() override; \
|
virtual datamap_t *GetDataMap() override; \
|
||||||
@@ -103,6 +98,7 @@ struct datamap_t
|
|||||||
#define _class_offsetof( class, var ) ((size_t)&(((class*)0)->var))
|
#define _class_offsetof( class, var ) ((size_t)&(((class*)0)->var))
|
||||||
|
|
||||||
#define _FIELD( name, fieldtype, count, flags, mapname, tolerance) { #name, mapname, fieldtype, _class_offsetof(ThisClass, name), count, sizeof(((ThisClass*)0)->name), flags },
|
#define _FIELD( name, fieldtype, count, flags, mapname, tolerance) { #name, mapname, fieldtype, _class_offsetof(ThisClass, name), count, sizeof(((ThisClass*)0)->name), flags },
|
||||||
|
#define DEFINE_FIELD( name, fieldtype ) _FIELD( name, fieldtype, 1, FTYPEDESC_KEY, 0, 0)
|
||||||
#define DEFINE_KEYFIELD( name, fieldtype, mapname ) _FIELD( name, fieldtype, 1, FTYPEDESC_KEY, mapname, 0)
|
#define DEFINE_KEYFIELD( name, fieldtype, mapname ) _FIELD( name, fieldtype, 1, FTYPEDESC_KEY, mapname, 0)
|
||||||
|
|
||||||
#define FTYPEDESC_KEY 0x0004
|
#define FTYPEDESC_KEY 0x0004
|
||||||
|
|||||||
26
game/shared/engine.h
Normal file
26
game/shared/engine.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#ifndef ENGINE_H
|
||||||
|
#define ENGINE_H
|
||||||
|
|
||||||
|
#include "tier2/ifilesystem.h"
|
||||||
|
#include "materialsystem/imaterialsystem.h"
|
||||||
|
#include "materialsystem/igamewindow.h"
|
||||||
|
#include "networkbase.h"
|
||||||
|
|
||||||
|
struct EngineConsts_t
|
||||||
|
{
|
||||||
|
bool m_bIsDedicated;
|
||||||
|
bool m_bIsSteam;
|
||||||
|
INetworkBase *(LaunchLocalBridge)(uint16_t uPort);
|
||||||
|
INetworkBase *(LaunchServer)(uint16_t uPort);
|
||||||
|
INetworkBase *(ConnectLocalBridge)(uint16_t uPort);
|
||||||
|
INetworkBase *(ConnectSteamServer)(uint64_t uServer, uint16_t uPort);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern IFileSystem *filesystem;
|
||||||
|
extern IRenderContext *g_pRenderContext;
|
||||||
|
extern IGameWindow *g_pMainWindow;
|
||||||
|
extern EngineConsts_t *g_pEngineConstants;
|
||||||
|
extern INetworkBase *g_pServerBridge;
|
||||||
|
extern INetworkBase *g_pClientBridge;
|
||||||
|
|
||||||
|
#endif
|
||||||
9
game/shared/gameclass.h
Normal file
9
game/shared/gameclass.h
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#ifndef GAMECLASS_H
|
||||||
|
#define GAMECLASS_H
|
||||||
|
|
||||||
|
#define DECLARE_CLASS_NOBASE( className ) \
|
||||||
|
typedef className ThisClass;
|
||||||
|
#define DECLARE_CLASS( className, baseName ) \
|
||||||
|
typedef baseName BaseClass; \
|
||||||
|
typedef className ThisClass;
|
||||||
|
#endif
|
||||||
118
game/shared/netmap.h
Normal file
118
game/shared/netmap.h
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
#ifndef NETMAP_H
|
||||||
|
#define NETMAP_H
|
||||||
|
#include "stddef.h"
|
||||||
|
#include "stdint.h"
|
||||||
|
#include "datamap.h"
|
||||||
|
|
||||||
|
struct netfield_t
|
||||||
|
{
|
||||||
|
const char *m_szName;
|
||||||
|
fieldtype_t m_eType;
|
||||||
|
size_t m_uOffset;
|
||||||
|
size_t m_uSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct netmap_t
|
||||||
|
{
|
||||||
|
struct netmap_t *m_pBase;
|
||||||
|
netfield_t *m_pFields;
|
||||||
|
uint32_t m_uFieldCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NetPropInt(name) { #name, FIELD_INT, _class_offsetof(ThisClass, name), sizeof(name)}
|
||||||
|
#define NetPropFloat(name) { #name, FIELD_FLOAT, _class_offsetof(ThisClass, name), sizeof(name)}
|
||||||
|
#define NetPropFloat3(name) \
|
||||||
|
NetPropFloat(name.x), \
|
||||||
|
NetPropFloat(name.y), \
|
||||||
|
NetPropFloat(name.z)
|
||||||
|
#define NetPropQuaternion(name) \
|
||||||
|
NetPropFloat(name.x), \
|
||||||
|
NetPropFloat(name.y), \
|
||||||
|
NetPropFloat(name.z), \
|
||||||
|
NetPropFloat(name.w) \
|
||||||
|
|
||||||
|
#define __DECLARE_NETCLASS_NOBASE() \
|
||||||
|
netmap_t *GetBaseSendMap(); \
|
||||||
|
virtual netmap_t *GetSendMap(); \
|
||||||
|
virtual netmap_t SendMapInit(); \
|
||||||
|
netmap_t *GetBaseRecvMap(); \
|
||||||
|
virtual netmap_t *GetRecvMap(); \
|
||||||
|
virtual netmap_t RecvMapInit(); \
|
||||||
|
|
||||||
|
#define __DECLARE_NETCLASS() \
|
||||||
|
netmap_t *GetBaseSendMap(); \
|
||||||
|
virtual netmap_t *GetSendMap() override; \
|
||||||
|
virtual netmap_t SendMapInit() override; \
|
||||||
|
netmap_t *GetBaseRecvMap(); \
|
||||||
|
virtual netmap_t *GetRecvMap() override; \
|
||||||
|
virtual netmap_t RecvMapInit() override; \
|
||||||
|
|
||||||
|
#define DECLARE_SERVERCLASS_NOBASE() \
|
||||||
|
__DECLARE_NETCLASS_NOBASE() \
|
||||||
|
|
||||||
|
#define DECLARE_CLIENTCLASS_NOBASE() \
|
||||||
|
__DECLARE_NETCLASS_NOBASE() \
|
||||||
|
|
||||||
|
#define DECLARE_SERVERCLASS() \
|
||||||
|
__DECLARE_NETCLASS() \
|
||||||
|
|
||||||
|
#define DECLARE_CLIENTCLASS() \
|
||||||
|
__DECLARE_NETCLASS() \
|
||||||
|
|
||||||
|
#define IMPLEMENT_SEND_DT_INTERNAL(className) \
|
||||||
|
netmap_t *className::GetSendMap() { static netmap_t s_DataMap = ThisClass::SendMapInit(); return &s_DataMap; } \
|
||||||
|
netmap_t className::SendMapInit() { \
|
||||||
|
netmap_t map; \
|
||||||
|
map.m_pBase = ThisClass::GetBaseSendMap(); \
|
||||||
|
static netfield_t dataDesc[] \
|
||||||
|
{\
|
||||||
|
|
||||||
|
#define IMPLEMENT_SEND_DT_NOBASE(className) \
|
||||||
|
netmap_t *className::GetBaseSendMap() { return NULL; } \
|
||||||
|
IMPLEMENT_SEND_DT_INTERNAL(className)
|
||||||
|
#define IMPLEMENT_SEND_DT(className) \
|
||||||
|
netmap_t *className::GetBaseSendMap() { return BaseClass::GetSendMap(); } \
|
||||||
|
IMPLEMENT_SEND_DT_INTERNAL(className)
|
||||||
|
|
||||||
|
#define IMPLEMENT_RECV_DT_INTERNAL(className) \
|
||||||
|
netmap_t *className::GetRecvMap() { static netmap_t s_DataMap = ThisClass::RecvMapInit(); return &s_DataMap; } \
|
||||||
|
netmap_t className::RecvMapInit() { \
|
||||||
|
netmap_t map; \
|
||||||
|
map.m_pBase = ThisClass::GetBaseRecvMap(); \
|
||||||
|
static netfield_t dataDesc[] \
|
||||||
|
{\
|
||||||
|
|
||||||
|
#define IMPLEMENT_RECV_DT_NOBASE(className) \
|
||||||
|
netmap_t *className::GetBaseRecvMap() { return NULL; } \
|
||||||
|
IMPLEMENT_RECV_DT_INTERNAL(className)
|
||||||
|
#define IMPLEMENT_RECV_DT(className) \
|
||||||
|
netmap_t *className::GetBaseRecvMap() { return BaseClass::GetRecvMap(); } \
|
||||||
|
IMPLEMENT_RECV_DT_INTERNAL(className)
|
||||||
|
|
||||||
|
#define END_NET_DT_INTERNAL() \
|
||||||
|
}; \
|
||||||
|
map.m_uFieldCount = sizeof(dataDesc)/sizeof(netfield_t); \
|
||||||
|
map.m_pFields = dataDesc; \
|
||||||
|
return map; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define END_SEND_DT() \
|
||||||
|
END_NET_DT_INTERNAL()
|
||||||
|
#define END_RECV_DT() \
|
||||||
|
END_NET_DT_INTERNAL()
|
||||||
|
|
||||||
|
#define IMPLEMENT_EMPTY_SEND_DT_NOBASE(className) \
|
||||||
|
IMPLEMENT_SEND_DT_NOBASE(className) \
|
||||||
|
END_RECV_DT()
|
||||||
|
#define IMPLEMENT_EMPTY_SEND_DT(className) \
|
||||||
|
IMPLEMENT_SEND_DT(className) \
|
||||||
|
END_RECV_DT()
|
||||||
|
#define IMPLEMENT_EMPTY_RECV_DT_NOBASE(className) \
|
||||||
|
IMPLEMENT_RECV_DT_NOBASE(className) \
|
||||||
|
END_RECV_DT()
|
||||||
|
#define IMPLEMENT_EMPTY_RECV_DT(className) \
|
||||||
|
IMPLEMENT_RECV_DT(className) \
|
||||||
|
END_RECV_DT()
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
76
game/shared/netprotocol.h
Normal file
76
game/shared/netprotocol.h
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
#ifndef NET_PROTOCOL_H
|
||||||
|
#define NET_PROTOCOL_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "stdint.h"
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
class CNetworkUInt32
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CNetworkUInt32() : m_uValue(0) {}
|
||||||
|
CNetworkUInt32( uint32_t uValue ) : m_uValue(htonl(uValue)) {}
|
||||||
|
operator uint32_t() const {
|
||||||
|
return htonl(m_uValue);
|
||||||
|
}
|
||||||
|
uint32_t m_uValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum EMessageType: uint32_t
|
||||||
|
{
|
||||||
|
MESSAGE_PLAYER_JOINED,
|
||||||
|
MESSAGE_PLAYER_JOINED_CALLBACK,
|
||||||
|
MESSAGE_PLAYER_LEFT,
|
||||||
|
MESSAGE_ENTITY_CLASS_SYNC,
|
||||||
|
MESSAGE_ENTITY_DATA_SYNC,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PlayerJoined_t
|
||||||
|
{
|
||||||
|
EMessageType m_eType;
|
||||||
|
int8_t m_szPlayerName[256];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PlayerJoinedCallback_t
|
||||||
|
{
|
||||||
|
EMessageType m_eType;
|
||||||
|
CNetworkUInt32 m_uPlayerIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PlayerLeft_t
|
||||||
|
{
|
||||||
|
EMessageType m_eType;
|
||||||
|
CNetworkUInt32 m_uPlayerIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EntityClass_t
|
||||||
|
{
|
||||||
|
EMessageType m_eType;
|
||||||
|
CNetworkUInt32 m_uIndex;
|
||||||
|
int8_t m_szEntityName[256];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EntityDataSync_t
|
||||||
|
{
|
||||||
|
EMessageType m_eType;
|
||||||
|
CNetworkUInt32 m_uIndex;
|
||||||
|
CNetworkUInt32 m_uCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EntityDataSyncValue_t
|
||||||
|
{
|
||||||
|
CNetworkUInt32 m_uVariableIndex;
|
||||||
|
CNetworkUInt32 m_uVariableSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
union PlayerPacket_t
|
||||||
|
{
|
||||||
|
EMessageType m_eType;
|
||||||
|
PlayerJoined_t m_playerJoined;
|
||||||
|
PlayerJoinedCallback_t m_playerJoinedCallback;
|
||||||
|
PlayerLeft_t m_playerLeft;
|
||||||
|
EntityClass_t m_entityClass;
|
||||||
|
EntityDataSync_t m_entityData;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
CVkMaterial::CVkMaterial( IShader *pShader )
|
CVkMaterial::CVkMaterial( IShader *pShader )
|
||||||
{
|
{
|
||||||
m_pVkShader = (CVkShader*)pShader;
|
m_pVkShader = (CVkShader*)pShader;
|
||||||
|
if ( m_pVkShader->m_setLayouts.GetSize() == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
VkDescriptorPoolSize pools[4] =
|
VkDescriptorPoolSize pools[4] =
|
||||||
{
|
{
|
||||||
@@ -76,6 +78,8 @@ void CVkMaterial::PSSetTextureArray( uint32_t uSet, ITextureArray *pArray )
|
|||||||
|
|
||||||
void CVkMaterial::SetShaderResource( uint32_t uRegister, uint32_t uSet, IRenderingObject *pObject)
|
void CVkMaterial::SetShaderResource( uint32_t uRegister, uint32_t uSet, IRenderingObject *pObject)
|
||||||
{
|
{
|
||||||
|
if ( m_pVkShader->m_setLayouts.GetSize() == 0 )
|
||||||
|
return;
|
||||||
union {
|
union {
|
||||||
IRenderingObject *pVkObject;
|
IRenderingObject *pVkObject;
|
||||||
CVkBuffer *pBuffer;
|
CVkBuffer *pBuffer;
|
||||||
|
|||||||
@@ -935,6 +935,7 @@ void CVkRenderContext::Frame( float fDeltaTime )
|
|||||||
stPresentInfo.pImageIndices = uImageIndexes.GetData();
|
stPresentInfo.pImageIndices = uImageIndexes.GetData();
|
||||||
|
|
||||||
vkQueuePresentKHR(s_vkPresentQueue, &stPresentInfo);
|
vkQueuePresentKHR(s_vkPresentQueue, &stPresentInfo);
|
||||||
|
vkDeviceWaitIdle(s_vkDevice);
|
||||||
|
|
||||||
for ( auto &s: m_renderWindows )
|
for ( auto &s: m_renderWindows )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,10 +2,7 @@
|
|||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
#include "vulkan_state.h"
|
#include "vulkan_state.h"
|
||||||
#include "shaderparser.h"
|
#include "shaderparser.h"
|
||||||
CVkShader::~CVkShader()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
void CVkShader::AddLayout( int iIndex, int iStride )
|
void CVkShader::AddLayout( int iIndex, int iStride )
|
||||||
{
|
{
|
||||||
VkVertexInputBindingDescription layout = {};
|
VkVertexInputBindingDescription layout = {};
|
||||||
@@ -208,12 +205,7 @@ void CVkShader::Build()
|
|||||||
vkCreateGraphicsPipelines(m_hDevice, NULL, 1, &createInfo, NULL, &m_hPipeline);
|
vkCreateGraphicsPipelines(m_hDevice, NULL, 1, &createInfo, NULL, &m_hPipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CVkShader::PSGetResourceByName( const char *szName )
|
uint32_t CVkShader::GetResourceByName( const char *szName )
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t CVkShader::VSGetResourceByName( const char *szName )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,6 +115,10 @@ VkShaderStageFlagBits VulkanGetShaderStage( EShaderStage eStage )
|
|||||||
{
|
{
|
||||||
case SHADER_STAGE_VERTEX: return VK_SHADER_STAGE_VERTEX_BIT;
|
case SHADER_STAGE_VERTEX: return VK_SHADER_STAGE_VERTEX_BIT;
|
||||||
case SHADER_STAGE_PIXEL: return VK_SHADER_STAGE_FRAGMENT_BIT;
|
case SHADER_STAGE_PIXEL: return VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||||
|
case SHADER_STAGE_COMPUTE: return VK_SHADER_STAGE_COMPUTE_BIT;
|
||||||
|
case SHADER_STAGE_RAYGEN: return VK_SHADER_STAGE_RAYGEN_BIT_KHR;
|
||||||
|
case SHADER_STAGE_RAYGEN_SOFTWARE:
|
||||||
|
return VK_SHADER_STAGE_COMPUTE_BIT;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,9 +261,7 @@ void CVk##name##PipelineLibrary::Build() \
|
|||||||
class CVkShader : public IShader
|
class CVkShader : public IShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~CVkShader();
|
virtual uint32_t GetResourceByName( const char *szName ) override;
|
||||||
virtual uint32_t PSGetResourceByName( const char *szName ) override;
|
|
||||||
virtual uint32_t VSGetResourceByName( const char *szName ) override;
|
|
||||||
virtual void AddLayout( int iIndex, int iStride ) override;
|
virtual void AddLayout( int iIndex, int iStride ) override;
|
||||||
virtual void AddAttribute( int iBufferIndex, int iLocation, EVertexFormat eFormat, int iOffset ) override;
|
virtual void AddAttribute( int iBufferIndex, int iLocation, EVertexFormat eFormat, int iOffset ) override;
|
||||||
virtual void SetTopology( ETopologyMode eTopology ) override;
|
virtual void SetTopology( ETopologyMode eTopology ) override;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public:
|
|||||||
|
|
||||||
IGameWindow *m_pGameWindow;
|
IGameWindow *m_pGameWindow;
|
||||||
IRenderContext *m_pRenderContext;
|
IRenderContext *m_pRenderContext;
|
||||||
|
EngineConsts_t *m_pEngineConsts;
|
||||||
|
|
||||||
IEngineBridge *m_pBridge;
|
IEngineBridge *m_pBridge;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,17 @@
|
|||||||
#define ENGINE_BRIDGE_H
|
#define ENGINE_BRIDGE_H
|
||||||
|
|
||||||
#include "gamesystem.h"
|
#include "gamesystem.h"
|
||||||
|
#include "networkbase.h"
|
||||||
|
|
||||||
|
struct EngineConsts_t
|
||||||
|
{
|
||||||
|
bool m_bIsDedicated;
|
||||||
|
bool m_bIsSteam;
|
||||||
|
INetworkBase *(*LaunchLocalBridge)(uint16_t uPort);
|
||||||
|
INetworkBase *(*LaunchServer)(uint16_t uPort);
|
||||||
|
INetworkBase *(*ConnectLocalBridge)(uint16_t uPort);
|
||||||
|
INetworkBase *(*ConnectSteamServer)(uint64_t uServer, uint16_t uPort);
|
||||||
|
};
|
||||||
abstract_class IEngineBridge: public IGameSystem
|
abstract_class IEngineBridge: public IGameSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef NETWORK_CLIENT_H
|
||||||
|
#define NETWORK_CLIENT_H
|
||||||
|
|
||||||
|
#include "networkbase.h"
|
||||||
|
|
||||||
|
INetworkBase *ConnectByLocalBridge( uint16_t uPort );
|
||||||
|
INetworkBase *ConnectByIP( const char *szIP, uint16_t uPort );
|
||||||
|
INetworkBase *ConnectBySteamID( uint64_t uID, uint16_t uPort );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef NETWORK_SERVER_H
|
||||||
|
#define NETWORK_SERVER_H
|
||||||
|
|
||||||
|
#include "networkbase.h"
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Launches local server
|
||||||
|
// Good to pass data between server and client
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
INetworkBase *LaunchLocalBridge( uint16_t uPort );
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Launches public server at port
|
||||||
|
// Public if you open ports :0
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
INetworkBase *LaunchServerAtPort( uint16_t uPort );
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Launches public server at steam datagram relay
|
||||||
|
// We just trust this method
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
INetworkBase *LaunchServerAtSteamRelay( uint16_t uPort );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -109,6 +109,13 @@ enum EStoreMode
|
|||||||
STORE_MODE_DONT_CARE,
|
STORE_MODE_DONT_CARE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ECullingMode
|
||||||
|
{
|
||||||
|
CULL_MODE_NONE,
|
||||||
|
CULL_MODE_FRONT,
|
||||||
|
CULL_MODE_BACK,
|
||||||
|
};
|
||||||
|
|
||||||
enum ETopologyMode
|
enum ETopologyMode
|
||||||
{
|
{
|
||||||
TOPOLOGY_MODE_POINT_LIST,
|
TOPOLOGY_MODE_POINT_LIST,
|
||||||
@@ -168,15 +175,41 @@ public:
|
|||||||
virtual void UnloadTexture( uint32_t uTextureID ) = 0;
|
virtual void UnloadTexture( uint32_t uTextureID ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
abstract_class ITriangleAccelerationStructure: public IRenderingObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void SetVertices( IVertexBuffer *pBuffer, EVertexFormat eFormat, int iStride ) = 0;
|
||||||
|
virtual void SetIndicies( IVertexBuffer *pBuffer, EIndexFormat eFormat ) = 0;
|
||||||
|
virtual void SetTopology( ETopologyMode eTopology ) = 0;
|
||||||
|
virtual void Build() = 0;
|
||||||
|
virtual void Update( IVertexBuffer *pBuffer ) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
abstract_class IAABBAccelerationStructure: public IRenderingObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void Build() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
abstract_class IWorldAccelerationStructure: public IRenderingObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void Build() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
abstract_class IBaseShader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void Build() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Shader object
|
// Shader object
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
abstract_class IShader
|
abstract_class IShader: public IBaseShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~IShader() = default;
|
virtual uint32_t GetResourceByName( const char *szName ) = 0;
|
||||||
virtual uint32_t PSGetResourceByName( const char *szName ) = 0;
|
|
||||||
virtual uint32_t VSGetResourceByName( const char *szName ) = 0;
|
|
||||||
virtual void AddLayout( int iIndex, int iStride ) = 0;
|
virtual void AddLayout( int iIndex, int iStride ) = 0;
|
||||||
virtual void AddAttribute( int iBufferIndex, int iLocation, EVertexFormat eFormat, int iOffset ) = 0;
|
virtual void AddAttribute( int iBufferIndex, int iLocation, EVertexFormat eFormat, int iOffset ) = 0;
|
||||||
virtual void SetTopology( ETopologyMode eTopology ) = 0;
|
virtual void SetTopology( ETopologyMode eTopology ) = 0;
|
||||||
@@ -184,7 +217,19 @@ public:
|
|||||||
virtual void SetDepthImage( EImageFormat eFormat ) = 0;
|
virtual void SetDepthImage( EImageFormat eFormat ) = 0;
|
||||||
virtual void SetMultisampling( EMultisampleType eFormat ) = 0;
|
virtual void SetMultisampling( EMultisampleType eFormat ) = 0;
|
||||||
virtual void DisablePixelShader( bool bDisable) = 0;
|
virtual void DisablePixelShader( bool bDisable) = 0;
|
||||||
virtual void Build() = 0;
|
};
|
||||||
|
|
||||||
|
abstract_class IComputeShader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
|
abstract_class IRayTracingShader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual uint32_t GetMissShaderBinding( const char *szName );
|
||||||
|
virtual uint32_t GetClosestHitShaderBinding( const char *szName );
|
||||||
|
virtual uint32_t GetCallableShaderBinding( const char *szName );
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -37,6 +37,12 @@ enum EShaderStage: uint32_t
|
|||||||
SHADER_STAGE_MISS,
|
SHADER_STAGE_MISS,
|
||||||
SHADER_STAGE_CALLABLE,
|
SHADER_STAGE_CALLABLE,
|
||||||
|
|
||||||
|
SHADER_STAGE_RAYGEN_SOFTWARE,
|
||||||
|
SHADER_STAGE_ANY_HIT_SOFTWARE,
|
||||||
|
SHADER_STAGE_CLOSEST_HIT_SOFTWARE,
|
||||||
|
SHADER_STAGE_MISS_SOFTWARE,
|
||||||
|
SHADER_STAGE_CALLABLE_SOFTWARE,
|
||||||
|
|
||||||
SHADER_STAGE_TASK,
|
SHADER_STAGE_TASK,
|
||||||
SHADER_STAGE_MESH,
|
SHADER_STAGE_MESH,
|
||||||
|
|
||||||
|
|||||||
30
public/networkbase.h
Normal file
30
public/networkbase.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
#ifndef NETWORK_BASE_H
|
||||||
|
#define NETWORK_BASE_H
|
||||||
|
#include "tier1/interface.h"
|
||||||
|
|
||||||
|
struct NetPacket_t
|
||||||
|
{
|
||||||
|
void *pData;
|
||||||
|
uint32_t uSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
abstract_class INetworkBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~INetworkBase() = default;
|
||||||
|
|
||||||
|
virtual void NetThink() = 0;
|
||||||
|
|
||||||
|
virtual uint32_t BHasUpdates() = 0;
|
||||||
|
virtual NetPacket_t RecievePacket() = 0;
|
||||||
|
virtual NetPacket_t PeekPacket() = 0;
|
||||||
|
|
||||||
|
virtual void SendPacket( NetPacket_t stPacket ) = 0;
|
||||||
|
|
||||||
|
virtual uint64_t GetSteamID() = 0;
|
||||||
|
virtual const char *GetIP() = 0;
|
||||||
|
virtual uint16_t GetPort() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -14,6 +14,7 @@ public:
|
|||||||
|
|
||||||
IGameWindow *m_pGameWindow;
|
IGameWindow *m_pGameWindow;
|
||||||
IRenderContext *m_pRenderContext;
|
IRenderContext *m_pRenderContext;
|
||||||
|
EngineConsts_t *m_pEngineConsts;
|
||||||
|
|
||||||
IEngineBridge *m_pBridge;
|
IEngineBridge *m_pBridge;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,17 @@ struct Vector {
|
|||||||
float y;
|
float y;
|
||||||
float z;
|
float z;
|
||||||
};
|
};
|
||||||
|
struct Color {
|
||||||
|
float r;
|
||||||
|
float g;
|
||||||
|
float b;
|
||||||
|
};
|
||||||
|
struct ColorAlpha {
|
||||||
|
float r;
|
||||||
|
float g;
|
||||||
|
float b;
|
||||||
|
float a;
|
||||||
|
};
|
||||||
struct QAngle {
|
struct QAngle {
|
||||||
float pitch;
|
float pitch;
|
||||||
float yaw;
|
float yaw;
|
||||||
|
|||||||
@@ -63,6 +63,12 @@ void CSlangVulkanSpirvShaderCompiler::CompileShaderStage( EShaderStage eStage, c
|
|||||||
case SHADER_STAGE_PIXEL:
|
case SHADER_STAGE_PIXEL:
|
||||||
eSlangStage = SLANG_STAGE_PIXEL;
|
eSlangStage = SLANG_STAGE_PIXEL;
|
||||||
break;
|
break;
|
||||||
|
case SHADER_STAGE_RAYGEN:
|
||||||
|
eSlangStage = SLANG_STAGE_RAY_GENERATION;
|
||||||
|
break;
|
||||||
|
case SHADER_STAGE_RAYGEN_SOFTWARE:
|
||||||
|
eSlangStage = SLANG_STAGE_COMPUTE;
|
||||||
|
break;
|
||||||
case SHADER_STAGE_CALLABLE:
|
case SHADER_STAGE_CALLABLE:
|
||||||
eSlangStage = SLANG_STAGE_CALLABLE;
|
eSlangStage = SLANG_STAGE_CALLABLE;
|
||||||
break;
|
break;
|
||||||
@@ -104,6 +110,20 @@ trygetkind:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case slang::TypeReflection::Kind::Resource:
|
||||||
|
V_printf("%s: %i\n", pType->getName(), pType->getResourceShape());
|
||||||
|
switch(pType->getResourceShape())
|
||||||
|
{
|
||||||
|
case SLANG_TEXTURE_2D:
|
||||||
|
input.eDescriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
|
||||||
|
break;
|
||||||
|
case SLANG_STRUCTURED_BUFFER:
|
||||||
|
input.eDescriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case slang::TypeReflection::Kind::Array:
|
case slang::TypeReflection::Kind::Array:
|
||||||
{
|
{
|
||||||
size_t uCount = pType->getTotalArrayElementCount();
|
size_t uCount = pType->getTotalArrayElementCount();
|
||||||
@@ -123,7 +143,7 @@ trygetkind:
|
|||||||
V_strncpy(input.szName, pVar->getName(), 32);
|
V_strncpy(input.szName, pVar->getName(), 32);
|
||||||
input.uBinding = pVar->getBindingIndex();
|
input.uBinding = pVar->getBindingIndex();
|
||||||
input.uSet = pVar->getBindingSpace();
|
input.uSet = pVar->getBindingSpace();
|
||||||
V_printf("%i\n", input.uCount);
|
//V_printf("%i\n", input.uCount);
|
||||||
inputs.AppendTail(input);
|
inputs.AppendTail(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +202,7 @@ void CSlangVulkanSpirvShaderCompiler::CompileShader( const char *szInput, CCompi
|
|||||||
{
|
{
|
||||||
SessionDesc stSessionDesc = {};
|
SessionDesc stSessionDesc = {};
|
||||||
TargetDesc stTargetDesc = {};
|
TargetDesc stTargetDesc = {};
|
||||||
PreprocessorMacroDesc stStageMacroDesc = {};
|
PreprocessorMacroDesc stStageMacroDesc[2] = {};
|
||||||
const char *szMainName;
|
const char *szMainName;
|
||||||
IModule *pModule = NULL;
|
IModule *pModule = NULL;
|
||||||
ISession *pSession = NULL;
|
ISession *pSession = NULL;
|
||||||
@@ -215,25 +235,35 @@ void CSlangVulkanSpirvShaderCompiler::CompileShader( const char *szInput, CCompi
|
|||||||
for ( i = 0; i<SHADER_STAGE_COUNT; i++ )
|
for ( i = 0; i<SHADER_STAGE_COUNT; i++ )
|
||||||
{
|
{
|
||||||
szMainName = NULL;
|
szMainName = NULL;
|
||||||
|
stSessionDesc.preprocessorMacroCount = 1;
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case SHADER_STAGE_VERTEX:
|
case SHADER_STAGE_VERTEX:
|
||||||
szMainName = "vsMain";
|
szMainName = "vsMain";
|
||||||
stStageMacroDesc = { "VS_SHADER", "Enabled" };
|
stStageMacroDesc[0] = { "VS_SHADER", "Enabled" };
|
||||||
break;
|
break;
|
||||||
case SHADER_STAGE_PIXEL:
|
case SHADER_STAGE_PIXEL:
|
||||||
szMainName = "psMain";
|
szMainName = "psMain";
|
||||||
stStageMacroDesc = { "PS_SHADER", "Enabled" };
|
stStageMacroDesc[0] = { "PS_SHADER", "Enabled" };
|
||||||
break;
|
break;
|
||||||
case SHADER_STAGE_CALLABLE:
|
case SHADER_STAGE_CALLABLE:
|
||||||
szMainName = "brdfMain";
|
szMainName = "brdfMain";
|
||||||
stStageMacroDesc = { "BRDF_SHADER", "Enabled" };
|
stStageMacroDesc[0] = { "BRDF_SHADER", "Enabled" };
|
||||||
|
break;
|
||||||
|
case SHADER_STAGE_RAYGEN:
|
||||||
|
szMainName = "rayMain";
|
||||||
|
stStageMacroDesc[0] = { "RAY_SHADER", "Enabled" };
|
||||||
|
break;
|
||||||
|
case SHADER_STAGE_RAYGEN_SOFTWARE:
|
||||||
|
szMainName = "rayMain";
|
||||||
|
stStageMacroDesc[0] = { "RAY_SHADER", "Enabled" };
|
||||||
|
stStageMacroDesc[1] = { "SOFTWARE_RAY_TRACING", "Enabled" };
|
||||||
|
stSessionDesc.preprocessorMacroCount = 2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
stSessionDesc.preprocessorMacroCount = 1;
|
stSessionDesc.preprocessorMacros = stStageMacroDesc;
|
||||||
stSessionDesc.preprocessorMacros = &stStageMacroDesc;
|
|
||||||
if ( szMainName == NULL )
|
if ( szMainName == NULL )
|
||||||
continue;
|
continue;
|
||||||
pSession = NULL;
|
pSession = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user