improved server
This commit is contained in:
12
build.cpp
12
build.cpp
@@ -37,6 +37,7 @@ extern "C" void Preinit()
|
|||||||
{
|
{
|
||||||
case TARGET_KERNEL_WINDOWS:
|
case TARGET_KERNEL_WINDOWS:
|
||||||
bSteam = true;
|
bSteam = true;
|
||||||
|
steam_lib = "external/steamworks/redistributable_bin/win64/steam_api64.dll";
|
||||||
break;
|
break;
|
||||||
case TARGET_KERNEL_LINUX:
|
case TARGET_KERNEL_LINUX:
|
||||||
bSteam = true;
|
bSteam = true;
|
||||||
@@ -50,8 +51,15 @@ extern "C" void Preinit()
|
|||||||
}
|
}
|
||||||
if (bSteam)
|
if (bSteam)
|
||||||
{
|
{
|
||||||
IFileSystem2::MakeDirectory(CUtlString("%s/bin", szOutputDir.GetString()));
|
if (bStaticBuild)
|
||||||
IFileSystem2::CopyFile(CUtlString("%s/bin", szOutputDir.GetString()), steam_lib);
|
{
|
||||||
|
IFileSystem2::MakeDirectory(CUtlString("%s/bin", szOutputDir.GetString()));
|
||||||
|
IFileSystem2::CopyFile(CUtlString("%s/bin", szOutputDir.GetString()), steam_lib);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
IFileSystem2::MakeDirectory(CUtlString("%s/bin", szOutputDir.GetString()));
|
||||||
|
IFileSystem2::CopyFile(CUtlString("%s/bin", szOutputDir.GetString()), steam_lib);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ CUtlVector<CUtlString> engine_CompiledFiles = {
|
|||||||
"engine/input.cpp",
|
"engine/input.cpp",
|
||||||
"engine/networking.cpp",
|
"engine/networking.cpp",
|
||||||
|
|
||||||
|
"engine/mesh.cpp",
|
||||||
|
|
||||||
/* entities */
|
/* entities */
|
||||||
"engine/baseentity.cpp",
|
"engine/baseentity.cpp",
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ void C_BrushEntity::Think( float fDelta )
|
|||||||
g_BrushVertices.AppendTail(vertexBuffer);
|
g_BrushVertices.AppendTail(vertexBuffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
IGraphicsPipeline *g_BrushPipeline;
|
|
||||||
|
|
||||||
class CBrushRendering: public IRenderingPipelineStep
|
class CBrushRendering: public IRenderingPipelineStep
|
||||||
{
|
{
|
||||||
@@ -126,6 +125,7 @@ private:
|
|||||||
DECLARE_MESH_RENDERING_STAGE(CBrushRendering, brush_rasterizer);
|
DECLARE_MESH_RENDERING_STAGE(CBrushRendering, brush_rasterizer);
|
||||||
|
|
||||||
|
|
||||||
|
IGraphicsPipeline *g_BrushPipeline;
|
||||||
ITexture *bricks;
|
ITexture *bricks;
|
||||||
void CBrushRendering::Init()
|
void CBrushRendering::Init()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#include "fgui/fgui.h"
|
#include "fgui/fgui.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "networking.h"
|
#include "networking.h"
|
||||||
#include "steam/isteamgameserver.h"
|
|
||||||
#include "tier0/network.h"
|
#include "tier0/network.h"
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "tier1/commandline.h"
|
#include "tier1/commandline.h"
|
||||||
@@ -17,6 +16,7 @@
|
|||||||
#include "physics.h"
|
#include "physics.h"
|
||||||
#include "signal.h"
|
#include "signal.h"
|
||||||
#include "steam/steam_api.h"
|
#include "steam/steam_api.h"
|
||||||
|
#include "steam/isteamgameserver.h"
|
||||||
#include "steam/steam_gameserver.h"
|
#include "steam/steam_gameserver.h"
|
||||||
#include "networking.h"
|
#include "networking.h"
|
||||||
|
|
||||||
@@ -109,14 +109,6 @@ void IEngine::Init()
|
|||||||
|
|
||||||
if (!ICommandLine::CheckParam("-dedicated"))
|
if (!ICommandLine::CheckParam("-dedicated"))
|
||||||
{
|
{
|
||||||
#ifdef STEAM_ENABLED
|
|
||||||
// Log in into steam
|
|
||||||
if (!SteamUser()->BLoggedOn())
|
|
||||||
{
|
|
||||||
SteamAPI_Shutdown();
|
|
||||||
Plat_FatalErrorFunc("User must be logged in to Steam");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// Run local client
|
// Run local client
|
||||||
g_localClient = new IIClient();
|
g_localClient = new IIClient();
|
||||||
IIEngine::ConnectClient(g_localClient);
|
IIEngine::ConnectClient(g_localClient);
|
||||||
@@ -126,21 +118,7 @@ void IEngine::Init()
|
|||||||
IInput::Init();
|
IInput::Init();
|
||||||
IInput::SetMouseMode(MOUSE_MODE_GAME);
|
IInput::SetMouseMode(MOUSE_MODE_GAME);
|
||||||
IFGUI::Init();
|
IFGUI::Init();
|
||||||
} else {
|
};
|
||||||
#ifdef STEAM_ENABLED
|
|
||||||
// Run dedicated server with steam
|
|
||||||
SteamGameServer_Init(0, 27015, 27016, eServerModeAuthentication, "0.0.0.0");
|
|
||||||
SteamGameServer()->SetProduct("funnygame");
|
|
||||||
SteamGameServer()->SetGameDescription("not that funny but ok");
|
|
||||||
SteamGameServer()->SetModDir("funnygame");
|
|
||||||
SteamGameServer()->SetDedicatedServer(true);
|
|
||||||
|
|
||||||
SteamGameServer()->LogOnAnonymous();
|
|
||||||
int nMaxPlayers = atoi(ICommandLine::ParamValue("-maxplayers", "128"));
|
|
||||||
SteamGameServer()->SetMaxPlayerCount(nMaxPlayers);
|
|
||||||
SteamGameServer()->SetAdvertiseServerActive(true);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
INetworking::Init();
|
INetworking::Init();
|
||||||
|
|
||||||
@@ -164,8 +142,8 @@ void IEngine::Frame(float fDelta)
|
|||||||
#ifdef STEAM_ENABLED
|
#ifdef STEAM_ENABLED
|
||||||
SteamAPI_RunCallbacks();
|
SteamAPI_RunCallbacks();
|
||||||
#endif
|
#endif
|
||||||
INetworking::Frame();
|
|
||||||
IServer::Think(fDelta);
|
IServer::Think(fDelta);
|
||||||
|
INetworking::Frame();
|
||||||
if (!ICommandLine::CheckParam("-dedicated"))
|
if (!ICommandLine::CheckParam("-dedicated"))
|
||||||
{
|
{
|
||||||
IFGUI::Frame();
|
IFGUI::Frame();
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ void IGameModeManager::Frame( void )
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void IGameModeManager::StartGameMode( const char *szName )
|
void IGameModeManager::StartGameMode( const char *szName )
|
||||||
{
|
{
|
||||||
V_printf("starting game mode %s\n", szName);
|
|
||||||
if (pCurrentMode)
|
if (pCurrentMode)
|
||||||
{
|
{
|
||||||
pCurrentMode->RoundEnd();
|
pCurrentMode->RoundEnd();
|
||||||
@@ -112,13 +111,10 @@ void IGameModeManager::RestartCurrentGameMode( void )
|
|||||||
PacketGameMode_t mode = {};
|
PacketGameMode_t mode = {};
|
||||||
mode.type = PACKET_TYPE_GAMEMODE_START;
|
mode.type = PACKET_TYPE_GAMEMODE_START;
|
||||||
V_memcpy(mode.szName,szCurrentModeName, min(szCurrentModeName.GetLenght(), 255));
|
V_memcpy(mode.szName,szCurrentModeName, min(szCurrentModeName.GetLenght(), 255));
|
||||||
V_printf("%u clients connected\n",g_clients.GetSize());
|
|
||||||
for (auto &client: g_clients)
|
for (auto &client: g_clients)
|
||||||
{
|
{
|
||||||
INetworking::SendData(&mode, sizeof(mode), client, MESSAGE_MODE_RELIABLE);
|
INetworking::SendData(&mode, sizeof(mode), client, MESSAGE_MODE_RELIABLE);
|
||||||
V_printf("sending to %u\n",client->playerHandle);
|
|
||||||
};
|
};
|
||||||
V_printf("restarting game mode\n");
|
|
||||||
};
|
};
|
||||||
pCurrentMode->RoundEnd();
|
pCurrentMode->RoundEnd();
|
||||||
pCurrentMode->RoundBegin();
|
pCurrentMode->RoundBegin();
|
||||||
|
|||||||
@@ -168,7 +168,6 @@ void IInput_Bind( int argc, char **argv )
|
|||||||
g_bindings[key].AppendTail(argv[i]);
|
g_bindings[key].AppendTail(argv[i]);
|
||||||
g_bindings[key].AppendTail(" ");
|
g_bindings[key].AppendTail(" ");
|
||||||
}
|
}
|
||||||
V_printf("%s\n",g_bindings[key].GetString());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|||||||
155
engine/mesh.cpp
155
engine/mesh.cpp
@@ -0,0 +1,155 @@
|
|||||||
|
#include "mesh.h"
|
||||||
|
#include "cglm/mat4.h"
|
||||||
|
#include "rendering.h"
|
||||||
|
|
||||||
|
|
||||||
|
CUtlVector<IMeshInstance*> g_meshes;
|
||||||
|
class CMeshInstance: public IMeshInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void SetPosition( vec3 position ) override;
|
||||||
|
virtual void SetRotationEuler( vec3 angle ) override;
|
||||||
|
virtual void SetRotationQuat( vec4 quaternion) override;
|
||||||
|
virtual void SetMatrix( mat4 matrix ) override;
|
||||||
|
virtual void SetScale( vec3 scale ) override;
|
||||||
|
|
||||||
|
virtual void Draw() override;
|
||||||
|
|
||||||
|
mat4 m_matrix;
|
||||||
|
vec3 m_position;
|
||||||
|
|
||||||
|
IVertexBuffer *m_pVertexBuffer;
|
||||||
|
IIndexBuffer *m_pIndexBuffer;
|
||||||
|
|
||||||
|
};
|
||||||
|
void CMeshInstance::SetPosition( vec3 position )
|
||||||
|
{
|
||||||
|
glm_vec3_copy(position, m_position);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMeshInstance::SetRotationEuler( vec3 angle )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMeshInstance::SetRotationQuat( vec4 quaternion)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMeshInstance::SetMatrix( mat4 matrix )
|
||||||
|
{
|
||||||
|
glm_mat4_copy(matrix, m_matrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMeshInstance::SetScale( vec3 scale )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMeshInstance::Draw()
|
||||||
|
{
|
||||||
|
g_meshes.AppendTail(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class CMesh: public IMesh
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void SetVertexBuffer( IVertexBuffer *pBuffer ) override;
|
||||||
|
virtual void SetIndexBuffer( IIndexBuffer *pBuffer ) override;
|
||||||
|
|
||||||
|
virtual IMeshInstance *CreateInstance() override;
|
||||||
|
|
||||||
|
IVertexBuffer *m_pVertexBuffer = 0;
|
||||||
|
IIndexBuffer *m_pIndexBuffer = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
void CMesh::SetVertexBuffer( IVertexBuffer *pBuffer )
|
||||||
|
{
|
||||||
|
m_pVertexBuffer = pBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMesh::SetIndexBuffer( IIndexBuffer *pBuffer )
|
||||||
|
{
|
||||||
|
m_pIndexBuffer = pBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
IMeshInstance *CMesh::CreateInstance()
|
||||||
|
{
|
||||||
|
CMeshInstance *pInstance = new CMeshInstance;
|
||||||
|
pInstance->m_pVertexBuffer = m_pVertexBuffer;
|
||||||
|
pInstance->m_pIndexBuffer = m_pIndexBuffer;
|
||||||
|
return pInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
IGraphicsPipeline *g_MeshPipeline;
|
||||||
|
class CMeshRendering: public IMeshRendering
|
||||||
|
{
|
||||||
|
virtual void Init() override;
|
||||||
|
virtual void Frame( float fDelta ) override;
|
||||||
|
virtual void Deinit() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
void CMeshRendering::Init()
|
||||||
|
{
|
||||||
|
g_MeshPipeline = IRenderer::CreateGraphicsPipeline(
|
||||||
|
{
|
||||||
|
{"gfx/mesh_vert.shader", SHADER_TYPE_VERTEX},
|
||||||
|
{"gfx/mesh_frag.shader", SHADER_TYPE_FRAGMENT},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{SHADER_INPUT_TYPE_UNIFORM_BUFFER,0},
|
||||||
|
{SHADER_INPUT_TYPE_TEXTURES,1},
|
||||||
|
},
|
||||||
|
80,
|
||||||
|
20,
|
||||||
|
{{0,0,EVertexFormat::VERTEX_FORMAT_X32Y32Z32}, {12,1,EVertexFormat::VERTEX_FORMAT_X32Y32}},
|
||||||
|
{EImageFormat::IMAGE_FORMAT_R8G8B8A8},
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CMeshRendering::Frame( float fDelta )
|
||||||
|
{
|
||||||
|
IRenderer::ResetState();
|
||||||
|
IRenderer::SetDepthMode(DEPTH_MODE_LESS);
|
||||||
|
IRenderer::BindPipeline(g_MeshPipeline);
|
||||||
|
IRenderer::BindData(0, IRenderer::GetCameraMatrix(), 0);
|
||||||
|
IRenderer::PushBindings();
|
||||||
|
for (auto &v: g_meshes)
|
||||||
|
{
|
||||||
|
CMeshInstance *pMesh = (CMeshInstance*)v;
|
||||||
|
struct {
|
||||||
|
mat4 i;
|
||||||
|
uint32_t a = 0;
|
||||||
|
uint32_t b = 0;
|
||||||
|
uint32_t c = 0;
|
||||||
|
} constants;
|
||||||
|
glm_mat4_copy(pMesh->m_matrix,constants.i);
|
||||||
|
constants.i[3][0] = pMesh->m_position[0];
|
||||||
|
constants.i[3][1] = pMesh->m_position[1];
|
||||||
|
constants.i[3][2] = pMesh->m_position[2];
|
||||||
|
IRenderer::SetConstants(sizeof(constants), &constants);
|
||||||
|
IRenderer::Draw(pMesh->m_pVertexBuffer, pMesh->m_pIndexBuffer);
|
||||||
|
}
|
||||||
|
g_meshes = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMeshRendering::Deinit()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
IMesh *IMeshRendering::CreateMesh()
|
||||||
|
{
|
||||||
|
CMesh *pMesh = new CMesh;
|
||||||
|
return pMesh;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DECLARE_MESH_RENDERING_STAGE(CMeshRendering, mesh_rendering)
|
||||||
|
|||||||
@@ -614,7 +614,7 @@ void IMetal::Frame()
|
|||||||
{
|
{
|
||||||
mat4 perspective;
|
mat4 perspective;
|
||||||
glm_mat4_inv(g_cameraView, g_cameraDataMap->viewprojection);
|
glm_mat4_inv(g_cameraView, g_cameraDataMap->viewprojection);
|
||||||
glm_perspective(glm_rad(90),(float)g_nWindowWidth/g_nWindowHeight, 0.01, 100, perspective);
|
glm_perspective(glm_rad(68),(float)g_nWindowWidth/g_nWindowHeight, 0.01, 10000, perspective);
|
||||||
glm_rotate(perspective, glm_rad(90), (vec4){1,0,0,0});
|
glm_rotate(perspective, glm_rad(90), (vec4){1,0,0,0});
|
||||||
glm_scale(perspective, (vec4){1,-1,1,1});
|
glm_scale(perspective, (vec4){1,-1,1,1});
|
||||||
glm_rotate(perspective, glm_rad(90), (vec4){0,0,1,0});
|
glm_rotate(perspective, glm_rad(90), (vec4){0,0,1,0});
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "steam/isteamfriends.h"
|
#include "steam/isteamfriends.h"
|
||||||
#include "steam/isteamnetworking.h"
|
#include "steam/isteamnetworking.h"
|
||||||
|
#include "steam/isteamnetworkingsockets.h"
|
||||||
|
#include "steam/steam_api_common.h"
|
||||||
|
#include "steam/steamnetworkingtypes.h"
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "tier0/lib.h"
|
#include "tier0/lib.h"
|
||||||
#include "tier1/commandline.h"
|
#include "tier1/commandline.h"
|
||||||
@@ -12,7 +15,10 @@
|
|||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
#include "baseplayer.h"
|
#include "baseplayer.h"
|
||||||
|
|
||||||
|
#include "steam/steam_api.h"
|
||||||
|
#include "steam/steam_gameserver.h"
|
||||||
#include "steam/steamnetworkingsockets.h"
|
#include "steam/steamnetworkingsockets.h"
|
||||||
|
#include "steam/isteamgameserver.h"
|
||||||
#include "steam/isteamnetworkingutils.h"
|
#include "steam/isteamnetworkingutils.h"
|
||||||
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
|
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
|
||||||
#include "steam/steam_api.h"
|
#include "steam/steam_api.h"
|
||||||
@@ -23,40 +29,88 @@ HSteamNetConnection net_server = 0;
|
|||||||
HSteamListenSocket net_listenSocket = -1;
|
HSteamListenSocket net_listenSocket = -1;
|
||||||
CUtlVector<IIClient*> net_clients;
|
CUtlVector<IIClient*> net_clients;
|
||||||
|
|
||||||
class CNetworkingCallbacks
|
bool net_bIsServer = false;
|
||||||
|
static int net_nMaxPlayers = 0;
|
||||||
|
static uint64_t net_nLastSteamID = 90071992547409920;
|
||||||
|
|
||||||
|
class CClientNetworkingCallbacks
|
||||||
|
{
|
||||||
|
STEAM_CALLBACK(CClientNetworkingCallbacks, RelayNetworkStatusChanged, SteamRelayNetworkStatus_t);
|
||||||
|
};
|
||||||
|
void CClientNetworkingCallbacks::RelayNetworkStatusChanged( SteamRelayNetworkStatus_t *pCallback )
|
||||||
{
|
{
|
||||||
STEAM_CALLBACK(CNetworkingCallbacks, ClientConnectedCallback, SteamNetConnectionStatusChangedCallback_t);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void CNetworkingCallbacks::ClientConnectedCallback( SteamNetConnectionStatusChangedCallback_t *pCallback )
|
class CServerNetworkingCallbacks
|
||||||
|
{
|
||||||
|
STEAM_GAMESERVER_CALLBACK(CServerNetworkingCallbacks, ClientConnected, SteamNetConnectionStatusChangedCallback_t);
|
||||||
|
STEAM_GAMESERVER_CALLBACK(CServerNetworkingCallbacks, SteamNetAuthenticated, SteamNetAuthenticationStatus_t);
|
||||||
|
};
|
||||||
|
|
||||||
|
void CServerNetworkingCallbacks::ClientConnected( SteamNetConnectionStatusChangedCallback_t *pCallback )
|
||||||
{
|
{
|
||||||
INetworking::ClientConnectedCallback(pCallback);
|
INetworking::ClientConnectedCallback(pCallback);
|
||||||
};
|
};
|
||||||
|
void CServerNetworkingCallbacks::SteamNetAuthenticated( SteamNetAuthenticationStatus_t *pCallback )
|
||||||
|
{
|
||||||
|
if (net_nLastSteamID == SteamGameServer()->GetSteamID().ConvertToUint64())
|
||||||
|
return;
|
||||||
|
net_nLastSteamID = SteamGameServer()->GetSteamID().ConvertToUint64();
|
||||||
|
V_printf("-------------- SERVER INFO ----------------\n");
|
||||||
|
V_printf(" STEAMID64:\t%llu\n", net_nLastSteamID);
|
||||||
|
V_printf(" MAX PLAYERS:\t%i\n", net_nMaxPlayers);
|
||||||
|
V_printf("-------------- TIPS -----------------------\n");
|
||||||
|
V_printf(" players can join by using connect <STEAMID64>\n");
|
||||||
|
V_printf("-------------------------------------------\n");
|
||||||
|
};
|
||||||
|
|
||||||
|
static CServerNetworkingCallbacks *net_pServerCallbacks;
|
||||||
bool net_bIsServer = false;
|
static CClientNetworkingCallbacks *net_pClientCallbacks;
|
||||||
static CNetworkingCallbacks *pCallbacks;
|
|
||||||
|
|
||||||
void INetworking::Init()
|
void INetworking::Init()
|
||||||
{
|
{
|
||||||
|
|
||||||
Net_Init();
|
Net_Init();
|
||||||
|
|
||||||
SteamDatagramErrMsg errMsg = {};
|
|
||||||
#ifdef STEAMNETWORKINGSOCKETS_OPENSOURCE
|
#ifdef STEAMNETWORKINGSOCKETS_OPENSOURCE
|
||||||
GameNetworkingSockets_Init(NULL, &errMsg)
|
GameNetworkingSockets_Init(NULL, &errMsg)
|
||||||
#endif
|
#endif
|
||||||
SteamNetworkingUtils()->SetDebugOutputFunction(k_ESteamNetworkingSocketsDebugOutputType_Msg,
|
if (ICommandLine::CheckParam("-steamdebug"))
|
||||||
[](ESteamNetworkingSocketsDebugOutputType severity, const char *szMessage) {
|
{
|
||||||
V_printf("Steam: %s\n", szMessage);
|
SteamNetworkingUtils()->SetDebugOutputFunction(k_ESteamNetworkingSocketsDebugOutputType_Msg,
|
||||||
});
|
[](ESteamNetworkingSocketsDebugOutputType severity, const char *szMessage) {
|
||||||
|
V_printf("Steam: %s\n", szMessage);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (ICommandLine::CheckParam("-dedicated"))
|
if (ICommandLine::CheckParam("-dedicated"))
|
||||||
{
|
{
|
||||||
pCallbacks = new CNetworkingCallbacks;
|
net_pServerCallbacks = new CServerNetworkingCallbacks;
|
||||||
SteamNetworkingIPAddr localAddress = {};
|
|
||||||
localAddress.Clear();
|
// Run dedicated server with steam
|
||||||
localAddress.SetIPv4(0x7F000001, 27015);
|
SteamGameServer_Init(0, 27015, 27016, eServerModeAuthentication, "0.0.0.0");
|
||||||
net_listenSocket = SteamNetworkingSockets()->CreateListenSocketIP(localAddress, 0, NULL);
|
SteamGameServer()->SetProduct("funnygame");
|
||||||
|
SteamGameServer()->SetGameDescription("not that funny but ok");
|
||||||
|
SteamGameServer()->SetModDir("funnygame");
|
||||||
|
SteamGameServer()->SetDedicatedServer(true);
|
||||||
|
|
||||||
|
SteamGameServer()->LogOnAnonymous();
|
||||||
|
|
||||||
|
|
||||||
|
net_nMaxPlayers = atoi(ICommandLine::ParamValue("-maxplayers", "128"));
|
||||||
|
SteamGameServer()->SetMaxPlayerCount(net_nMaxPlayers);
|
||||||
|
SteamGameServer()->SetAdvertiseServerActive(true);
|
||||||
|
} else {
|
||||||
|
net_pClientCallbacks = new CClientNetworkingCallbacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
SteamDatagramErrMsg errMsg = {};
|
||||||
|
|
||||||
|
SteamNetworkingUtils()->InitRelayNetworkAccess();
|
||||||
|
|
||||||
|
if (ICommandLine::CheckParam("-dedicated"))
|
||||||
|
{
|
||||||
|
net_listenSocket = SteamGameServerNetworkingSockets()->CreateListenSocketP2P(0, 0, NULL);
|
||||||
net_bIsServer = true;
|
net_bIsServer = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,7 +119,7 @@ void INetworking::Deinit()
|
|||||||
if (net_listenSocket == -1)
|
if (net_listenSocket == -1)
|
||||||
return;
|
return;
|
||||||
if (ICommandLine::CheckParam("-dedicated"))
|
if (ICommandLine::CheckParam("-dedicated"))
|
||||||
SteamNetworkingSockets()->CloseListenSocket(net_listenSocket);
|
SteamGameServerNetworkingSockets()->CloseListenSocket(net_listenSocket);
|
||||||
else
|
else
|
||||||
SteamNetworkingSockets()->CloseConnection(net_listenSocket, 0, NULL, false);
|
SteamNetworkingSockets()->CloseConnection(net_listenSocket, 0, NULL, false);
|
||||||
}
|
}
|
||||||
@@ -86,17 +140,16 @@ bool INetworking::IsConnected()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void INetworking::Frame()
|
void INetworking::Frame()
|
||||||
{
|
{
|
||||||
SteamNetworkingSockets()->RunCallbacks();
|
|
||||||
|
|
||||||
if (IsServer())
|
if (IsServer())
|
||||||
{
|
{
|
||||||
|
SteamGameServer_RunCallbacks();
|
||||||
for (auto &client: g_clients)
|
for (auto &client: g_clients)
|
||||||
{
|
{
|
||||||
SteamNetworkingMessage_t *pMessages[64];
|
SteamNetworkingMessage_t *pMessages[64];
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int nMessages = SteamNetworkingSockets()->ReceiveMessagesOnConnection(client->playerHandle, pMessages, 64);
|
int nMessages = SteamGameServerNetworkingSockets()->ReceiveMessagesOnConnection(client->playerHandle, pMessages, 64);
|
||||||
if ( nMessages <= 0 )
|
if ( nMessages <= 0 )
|
||||||
break;
|
break;
|
||||||
for ( int i = 0; i < nMessages; i++ )
|
for ( int i = 0; i < nMessages; i++ )
|
||||||
@@ -106,6 +159,7 @@ void INetworking::Frame()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
SteamNetworkingSockets()->RunCallbacks();
|
||||||
SteamNetworkingMessage_t *pMessages[64];
|
SteamNetworkingMessage_t *pMessages[64];
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
@@ -140,7 +194,7 @@ void INetworking::SendData( void *pData, uint32_t nSize, IIClient *pClient, EMes
|
|||||||
if (pClient == NULL)
|
if (pClient == NULL)
|
||||||
r = SteamNetworkingSockets()->SendMessageToConnection(net_server, pData, nSize, nSendFlags, NULL);
|
r = SteamNetworkingSockets()->SendMessageToConnection(net_server, pData, nSize, nSendFlags, NULL);
|
||||||
else
|
else
|
||||||
r = SteamNetworkingSockets()->SendMessageToConnection(pClient->playerHandle, pData, nSize, nSendFlags, NULL);
|
r = SteamGameServerNetworkingSockets()->SendMessageToConnection(pClient->playerHandle, pData, nSize, nSendFlags, NULL);
|
||||||
}
|
}
|
||||||
void INetworking::SendDataEverybody( void *pData, uint32_t nSize, EMessageMode messageMode )
|
void INetworking::SendDataEverybody( void *pData, uint32_t nSize, EMessageMode messageMode )
|
||||||
{
|
{
|
||||||
@@ -211,6 +265,7 @@ void INetworking::ProcessPacket( void *pData, uint32_t nSize, IIClient *pClient
|
|||||||
.playerID = pPlayerPacket->playerID,
|
.playerID = pPlayerPacket->playerID,
|
||||||
.playerHandle = pPlayerPacket->playerHandle,
|
.playerHandle = pPlayerPacket->playerHandle,
|
||||||
};
|
};
|
||||||
|
V_printf("%i\n",g_clients.GetSize());
|
||||||
IIEngine::ConnectClient(pNewClient);
|
IIEngine::ConnectClient(pNewClient);
|
||||||
|
|
||||||
for (auto &client: g_clients)
|
for (auto &client: g_clients)
|
||||||
@@ -258,9 +313,9 @@ uint32_t INetworking_IPv4ToUint(const char *szIP) {
|
|||||||
|
|
||||||
void INetworking::JoinServer( const char *szIP )
|
void INetworking::JoinServer( const char *szIP )
|
||||||
{
|
{
|
||||||
|
g_clients = {};
|
||||||
if (net_connection)
|
if (net_connection)
|
||||||
{
|
{
|
||||||
g_clients = {};
|
|
||||||
SteamNetworkingSockets()->CloseConnection(net_connection, 0, NULL, false);
|
SteamNetworkingSockets()->CloseConnection(net_connection, 0, NULL, false);
|
||||||
}
|
}
|
||||||
SteamNetworkingIPAddr localAddress = {};
|
SteamNetworkingIPAddr localAddress = {};
|
||||||
@@ -270,6 +325,21 @@ void INetworking::JoinServer( const char *szIP )
|
|||||||
net_server = net_connection;
|
net_server = net_connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void INetworking::JoinServer( uint64_t nSteamID )
|
||||||
|
{
|
||||||
|
g_clients = {};
|
||||||
|
if (net_connection)
|
||||||
|
{
|
||||||
|
SteamNetworkingSockets()->CloseConnection(net_connection, 0, NULL, false);
|
||||||
|
}
|
||||||
|
SteamNetworkingIdentity remoteIdentity = {};
|
||||||
|
remoteIdentity.Clear();
|
||||||
|
remoteIdentity.SetSteamID64(nSteamID);
|
||||||
|
|
||||||
|
net_connection = SteamNetworkingSockets()->ConnectP2P(remoteIdentity, 0, 0, 0);
|
||||||
|
net_server = net_connection;
|
||||||
|
}
|
||||||
|
|
||||||
void INetworking::ClientConnectedCallback( SteamNetConnectionStatusChangedCallback_t *pCallback )
|
void INetworking::ClientConnectedCallback( SteamNetConnectionStatusChangedCallback_t *pCallback )
|
||||||
{
|
{
|
||||||
IIClient *pClient = new IIClient;
|
IIClient *pClient = new IIClient;
|
||||||
@@ -353,4 +423,20 @@ void INetworking_Connect( int argc, char **argv )
|
|||||||
INetworking::JoinServer(argv[1]);
|
INetworking::JoinServer(argv[1]);
|
||||||
};
|
};
|
||||||
|
|
||||||
ConCommand ConnectCmd("connect", INetworking_Connect);
|
void INetworking_ConnectFriend( int argc, char **argv )
|
||||||
|
{
|
||||||
|
if (ICommandLine::CheckParam("-dedicated"))
|
||||||
|
return;
|
||||||
|
if (argc != 2)
|
||||||
|
{
|
||||||
|
V_printf("connect_friend <steamid>\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint64_t nFriendID = 0;
|
||||||
|
V_sscanf(argv[1], "%llu\n", &nFriendID);
|
||||||
|
V_printf("Connecting to %llu\n",nFriendID);
|
||||||
|
|
||||||
|
INetworking::JoinServer(nFriendID);
|
||||||
|
};
|
||||||
|
|
||||||
|
ConCommand ConnectCmd("connect", INetworking_ConnectFriend);
|
||||||
|
|||||||
@@ -54,9 +54,6 @@ void IServer::Think( float fDelta )
|
|||||||
/* tickrate */
|
/* tickrate */
|
||||||
while(g_fAccumulator>=fTickrate)
|
while(g_fAccumulator>=fTickrate)
|
||||||
{
|
{
|
||||||
#ifdef STEAM_ENABLED
|
|
||||||
SteamGameServer_RunCallbacks();
|
|
||||||
#endif
|
|
||||||
IInput::Frame();
|
IInput::Frame();
|
||||||
IConsole::Execute();
|
IConsole::Execute();
|
||||||
g_fAccumulator-=fTickrate;
|
g_fAccumulator-=fTickrate;
|
||||||
@@ -66,6 +63,7 @@ void IServer::Think( float fDelta )
|
|||||||
entity->Sync(0, 0);
|
entity->Sync(0, 0);
|
||||||
}
|
}
|
||||||
px_frame(px, fTickrate);
|
px_frame(px, fTickrate);
|
||||||
|
INetworking::Frame();
|
||||||
}
|
}
|
||||||
for (auto &entity: g_entities)
|
for (auto &entity: g_entities)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ void IVulkan::Frame()
|
|||||||
{
|
{
|
||||||
mat4 perspective;
|
mat4 perspective;
|
||||||
glm_mat4_inv(g_cameraView, g_cameraDataMap->viewprojection);
|
glm_mat4_inv(g_cameraView, g_cameraDataMap->viewprojection);
|
||||||
glm_perspective(glm_rad(90),(float)g_nWindowWidth/g_nWindowHeight, 0.01, 100, perspective);
|
glm_perspective(glm_rad(68),(float)g_nWindowWidth/g_nWindowHeight, 0.01, 10000, perspective);
|
||||||
glm_rotate(perspective, glm_rad(90), (vec4){1,0,0,0});
|
glm_rotate(perspective, glm_rad(90), (vec4){1,0,0,0});
|
||||||
glm_scale(perspective, (vec4){1,-1,1,1});
|
glm_scale(perspective, (vec4){1,-1,1,1});
|
||||||
glm_rotate(perspective, glm_rad(90), (vec4){0,0,1,0});
|
glm_rotate(perspective, glm_rad(90), (vec4){0,0,1,0});
|
||||||
@@ -270,28 +270,26 @@ void IVulkan::Frame()
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
VkImageCopy imageCopyRegion = {};
|
VkImageBlit imageCopyRegion = {};
|
||||||
imageCopyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
imageCopyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
imageCopyRegion.srcSubresource.mipLevel = 0;
|
imageCopyRegion.srcSubresource.mipLevel = 0;
|
||||||
imageCopyRegion.srcSubresource.baseArrayLayer = 0;
|
imageCopyRegion.srcSubresource.baseArrayLayer = 0;
|
||||||
imageCopyRegion.srcSubresource.layerCount = 1;
|
imageCopyRegion.srcSubresource.layerCount = 1;
|
||||||
imageCopyRegion.srcOffset = {0, 0, 0};
|
imageCopyRegion.srcOffsets[0] = {0, 0, 0};
|
||||||
|
imageCopyRegion.srcOffsets[1] = {(int)g_nWindowWidth, (int)g_nWindowHeight, 1};
|
||||||
|
|
||||||
imageCopyRegion.dstSubresource = imageCopyRegion.srcSubresource;
|
imageCopyRegion.dstSubresource = imageCopyRegion.srcSubresource;
|
||||||
imageCopyRegion.dstOffset = {0, 0, 0};
|
imageCopyRegion.dstOffsets[0] = {0, 0, 0};
|
||||||
|
imageCopyRegion.dstOffsets[1] = {(int)g_nWindowWidth, (int)g_nWindowHeight, 1};
|
||||||
|
|
||||||
imageCopyRegion.extent.width = g_nWindowWidth;
|
vkCmdBlitImage(
|
||||||
imageCopyRegion.extent.height = g_nWindowHeight;
|
|
||||||
imageCopyRegion.extent.depth = 1;
|
|
||||||
|
|
||||||
vkCmdCopyImage(
|
|
||||||
g_vkCommandBuffer,
|
g_vkCommandBuffer,
|
||||||
((CVkImage*)g_meshColor)->m_image.m_image,
|
((CVkImage*)g_meshColor)->m_image.m_image,
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||||
g_swapchainImage,
|
g_swapchainImage,
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||||
1,
|
1, &imageCopyRegion,
|
||||||
&imageCopyRegion
|
VK_FILTER_NEAREST
|
||||||
);
|
);
|
||||||
for (auto &step: g_StepShading)
|
for (auto &step: g_StepShading)
|
||||||
step.pPipeline->Frame(0);
|
step.pPipeline->Frame(0);
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ void IVideo_SwapchainInit()
|
|||||||
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(g_vkPhysicalDevice, g_surface, &surfaceCapatibilities);
|
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(g_vkPhysicalDevice, g_surface, &surfaceCapatibilities);
|
||||||
|
|
||||||
const VkFormat preferedSurfaceFormats[] = {
|
const VkFormat preferedSurfaceFormats[] = {
|
||||||
VK_FORMAT_R8G8B8A8_UNORM,
|
|
||||||
VK_FORMAT_B8G8R8A8_UNORM,
|
VK_FORMAT_B8G8R8A8_UNORM,
|
||||||
|
VK_FORMAT_R8G8B8A8_UNORM,
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t numSurfaceFormats = 0;
|
uint32_t numSurfaceFormats = 0;
|
||||||
@@ -88,9 +88,14 @@ void IVideo_SwapchainInit()
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < sizeof(preferedSurfaceFormats)/sizeof(VkFormat); i++)
|
for (int i = 0; i < sizeof(preferedSurfaceFormats)/sizeof(VkFormat); i++)
|
||||||
{
|
{
|
||||||
selectedFormat = surfaceFormats[i];
|
if (format.format == preferedSurfaceFormats[i])
|
||||||
|
{
|
||||||
|
selectedFormat = format;
|
||||||
|
goto formatPicked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
formatPicked:
|
||||||
|
|
||||||
uint32_t numSurfacePresentModes = 0;
|
uint32_t numSurfacePresentModes = 0;
|
||||||
vkGetPhysicalDeviceSurfacePresentModesKHR(g_vkPhysicalDevice, g_surface, &numSurfacePresentModes, NULL);
|
vkGetPhysicalDeviceSurfacePresentModesKHR(g_vkPhysicalDevice, g_surface, &numSurfacePresentModes, NULL);
|
||||||
|
|||||||
@@ -74,11 +74,6 @@ CUtlString CLDProject::Link( void )
|
|||||||
"-target",
|
"-target",
|
||||||
m_target.GetTriplet(),
|
m_target.GetTriplet(),
|
||||||
};
|
};
|
||||||
if (m_target.kernel == TARGET_KERNEL_WINDOWS)
|
|
||||||
{
|
|
||||||
args.AppendTail("-fuse-ld=lld");
|
|
||||||
args.AppendTail("-Wl,--whole-archive");
|
|
||||||
}
|
|
||||||
if (m_target.kernel == TARGET_KERNEL_DARWIN)
|
if (m_target.kernel == TARGET_KERNEL_DARWIN)
|
||||||
{
|
{
|
||||||
args.AppendTail("-isysroot");
|
args.AppendTail("-isysroot");
|
||||||
@@ -97,25 +92,24 @@ CUtlString CLDProject::Link( void )
|
|||||||
args.AppendTail("-Wl,-all_load");
|
args.AppendTail("-Wl,-all_load");
|
||||||
args.AppendTail("-w");
|
args.AppendTail("-w");
|
||||||
}
|
}
|
||||||
|
if (m_target.kernel == TARGET_KERNEL_WINDOWS)
|
||||||
|
{
|
||||||
|
args.AppendTail("-fuse-ld=ld");
|
||||||
|
}
|
||||||
if (m_target.kernel == TARGET_KERNEL_LINUX)
|
if (m_target.kernel == TARGET_KERNEL_LINUX)
|
||||||
{
|
{
|
||||||
args.AppendTail("-rdynamic");
|
args.AppendTail("-rdynamic");
|
||||||
args.AppendTail("-Wl,--whole-archive");
|
|
||||||
}
|
}
|
||||||
if (linkType == ELINK_DYNAMIC_LIBRARY)
|
if (linkType == ELINK_DYNAMIC_LIBRARY)
|
||||||
{
|
{
|
||||||
args.AppendTail("-shared");
|
args.AppendTail("-shared");
|
||||||
}
|
}
|
||||||
|
if (m_target.kernel == TARGET_KERNEL_WINDOWS || m_target.kernel == TARGET_KERNEL_LINUX)
|
||||||
|
args.AppendTail("-Wl,--whole-archive");
|
||||||
for (auto object: objects)
|
for (auto object: objects)
|
||||||
args.AppendTail(object.m_szObjectFile);
|
args.AppendTail(object.m_szObjectFile);
|
||||||
if (m_target.kernel == TARGET_KERNEL_WINDOWS)
|
if (m_target.kernel == TARGET_KERNEL_WINDOWS || m_target.kernel == TARGET_KERNEL_LINUX)
|
||||||
{
|
|
||||||
args.AppendTail("-Wl,--no-whole-archive");
|
args.AppendTail("-Wl,--no-whole-archive");
|
||||||
}
|
|
||||||
if (m_target.kernel == TARGET_KERNEL_LINUX)
|
|
||||||
{
|
|
||||||
args.AppendTail("-Wl,--no-whole-archive");
|
|
||||||
}
|
|
||||||
for (auto lib: libraries)
|
for (auto lib: libraries)
|
||||||
{
|
{
|
||||||
args.AppendTail("-l");
|
args.AppendTail("-l");
|
||||||
|
|||||||
@@ -3,4 +3,4 @@ bind a +left;
|
|||||||
bind d +right;
|
bind d +right;
|
||||||
bind w +forward;
|
bind w +forward;
|
||||||
bind s +back;
|
bind s +back;
|
||||||
bind o connect 127.0.0.1;
|
bind o connect 90271142097538072;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "fgui/widget.h"
|
#include "fgui/widget.h"
|
||||||
#include "fgui/label.h"
|
#include "fgui/label.h"
|
||||||
|
#include "mesh.h"
|
||||||
|
|
||||||
class C_MOBAPlayer: public C_BaseEntity
|
class C_MOBAPlayer: public C_BaseEntity
|
||||||
{
|
{
|
||||||
@@ -14,11 +15,13 @@ public:
|
|||||||
virtual void Spawn( void ) override;
|
virtual void Spawn( void ) override;
|
||||||
virtual void Destroy( void ) override;
|
virtual void Destroy( void ) override;
|
||||||
virtual void Think( float fDelta ) override;
|
virtual void Think( float fDelta ) override;
|
||||||
|
|
||||||
|
IMesh *m_pMesh;
|
||||||
|
IMeshInstance *m_pMeshInstance;
|
||||||
};
|
};
|
||||||
|
|
||||||
void C_MOBAPlayer::Precache()
|
void C_MOBAPlayer::Precache()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
CFGUI_Label *pText = new CFGUI_Label();
|
CFGUI_Label *pText = new CFGUI_Label();
|
||||||
void C_MOBAPlayer::Spawn()
|
void C_MOBAPlayer::Spawn()
|
||||||
@@ -27,6 +30,67 @@ void C_MOBAPlayer::Spawn()
|
|||||||
pText->SetPosition(100, 100);
|
pText->SetPosition(100, 100);
|
||||||
pText->SetLabelSize(15);
|
pText->SetLabelSize(15);
|
||||||
pText->SetLabel("Hello, world!");
|
pText->SetLabel("Hello, world!");
|
||||||
|
|
||||||
|
|
||||||
|
float cubeVertices[] = {
|
||||||
|
// Front face
|
||||||
|
-0.1f, -0.1f, 0.1f, 0, 0,
|
||||||
|
0.1f, -0.1f, 0.1f, 1, 0,
|
||||||
|
0.1f, 0.1f, 0.1f, 1, 1,
|
||||||
|
-0.1f, -0.1f, 0.1f, 0, 0,
|
||||||
|
0.1f, 0.1f, 0.1f, 1, 1,
|
||||||
|
-0.1f, 0.1f, 0.1f, 0, 1,
|
||||||
|
|
||||||
|
// Back face
|
||||||
|
0.1f, -0.1f, -0.1f, 0, 0,
|
||||||
|
-0.1f, -0.1f, -0.1f, 1, 0,
|
||||||
|
-0.1f, 0.1f, -0.1f, 1, 1,
|
||||||
|
0.1f, -0.1f, -0.1f, 0, 0,
|
||||||
|
-0.1f, 0.1f, -0.1f, 1, 1,
|
||||||
|
0.1f, 0.1f, -0.1f, 0, 1,
|
||||||
|
|
||||||
|
// Left face
|
||||||
|
-0.1f, -0.1f, -0.1f, 0, 0,
|
||||||
|
-0.1f, -0.1f, 0.1f, 1, 0,
|
||||||
|
-0.1f, 0.1f, 0.1f, 1, 1,
|
||||||
|
-0.1f, -0.1f, -0.1f, 0, 0,
|
||||||
|
-0.1f, 0.1f, 0.1f, 1, 1,
|
||||||
|
-0.1f, 0.1f, -0.1f, 0, 1,
|
||||||
|
|
||||||
|
// Right face
|
||||||
|
0.1f, -0.1f, 0.1f, 0, 0,
|
||||||
|
0.1f, -0.1f, -0.1f, 1, 0,
|
||||||
|
0.1f, 0.1f, -0.1f, 1, 1,
|
||||||
|
0.1f, -0.1f, 0.1f, 0, 0,
|
||||||
|
0.1f, 0.1f, -0.1f, 1, 1,
|
||||||
|
0.1f, 0.1f, 0.1f, 0, 1,
|
||||||
|
|
||||||
|
// Top face
|
||||||
|
-0.1f, 0.1f, 0.1f, 0, 0,
|
||||||
|
0.1f, 0.1f, 0.1f, 1, 0,
|
||||||
|
0.1f, 0.1f, -0.1f, 1, 1,
|
||||||
|
-0.1f, 0.1f, 0.1f, 0, 0,
|
||||||
|
0.1f, 0.1f, -0.1f, 1, 1,
|
||||||
|
-0.1f, 0.1f, -0.1f, 0, 1,
|
||||||
|
|
||||||
|
// Bottom face
|
||||||
|
-0.1f, -0.1f, -0.1f, 0, 0,
|
||||||
|
0.1f, -0.1f, -0.1f, 1, 0,
|
||||||
|
0.1f, -0.1f, 0.1f, 1, 1,
|
||||||
|
-0.1f, -0.1f, -0.1f, 0, 0,
|
||||||
|
0.1f, -0.1f, 0.1f, 1, 1,
|
||||||
|
-0.1f, -0.1f, 0.1f, 0, 1
|
||||||
|
};
|
||||||
|
|
||||||
|
IVertexBuffer *pVertexBuffer = IRenderer::CreateVertexBuffer(sizeof(cubeVertices));
|
||||||
|
void *pMapping = pVertexBuffer->Map();
|
||||||
|
V_memcpy(pMapping, cubeVertices, sizeof(cubeVertices));
|
||||||
|
pVertexBuffer->Unmap();
|
||||||
|
|
||||||
|
m_pMesh = IMeshRendering::CreateMesh();
|
||||||
|
m_pMesh->SetVertexBuffer(pVertexBuffer);
|
||||||
|
m_pMeshInstance = m_pMesh->CreateInstance();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void C_MOBAPlayer::Destroy()
|
void C_MOBAPlayer::Destroy()
|
||||||
@@ -48,6 +112,11 @@ void C_MOBAPlayer::Think( float fDelta )
|
|||||||
g_cameraView[3][1] = pEntity->m_position[1];
|
g_cameraView[3][1] = pEntity->m_position[1];
|
||||||
g_cameraView[3][2] = pEntity->m_position[2]+0.7;
|
g_cameraView[3][2] = pEntity->m_position[2]+0.7;
|
||||||
}
|
}
|
||||||
|
mat4 m;
|
||||||
|
glm_mat4_identity(m);
|
||||||
|
m_pMeshInstance->SetMatrix(m);
|
||||||
|
m_pMeshInstance->SetPosition(pEntity->m_position);
|
||||||
|
m_pMeshInstance->Draw();
|
||||||
};
|
};
|
||||||
|
|
||||||
LINK_CLIENT_ENTITY(C_MOBAPlayer, CMOBAPlayer)
|
LINK_CLIENT_ENTITY(C_MOBAPlayer, CMOBAPlayer)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ CUtlVector<CUtlString> launcher_CompiledFiles = {
|
|||||||
|
|
||||||
int launcher_build()
|
int launcher_build()
|
||||||
{
|
{
|
||||||
|
IFileSystem2::MakeDirectory(CUtlString("%s/bin",szOutputDir.GetString()));
|
||||||
CCProject compileProject = {};
|
CCProject compileProject = {};
|
||||||
CLDProject ldProject = {};
|
CLDProject ldProject = {};
|
||||||
|
|
||||||
@@ -52,6 +53,8 @@ int launcher_build()
|
|||||||
ldProject.objects.AppendTail((CObject){"external/windows/libdbghelp.a"});
|
ldProject.objects.AppendTail((CObject){"external/windows/libdbghelp.a"});
|
||||||
ldProject.objects.AppendTail((CObject){"external/windows/libpthread.a"});
|
ldProject.objects.AppendTail((CObject){"external/windows/libpthread.a"});
|
||||||
ldProject.objects.AppendTail((CObject){"external/windows/libstdc++.a"});
|
ldProject.objects.AppendTail((CObject){"external/windows/libstdc++.a"});
|
||||||
|
if (bSteam)
|
||||||
|
ldProject.objects.AppendTail((CObject){"external/steamworks/redistributable_bin/win64/steam_api64.dll"});
|
||||||
ldProject.libraries.AppendTail("ws2_32");
|
ldProject.libraries.AppendTail("ws2_32");
|
||||||
ldProject.libraries.AppendTail("ntdll");
|
ldProject.libraries.AppendTail("ntdll");
|
||||||
ldProject.libraries.AppendTail("userenv");
|
ldProject.libraries.AppendTail("userenv");
|
||||||
@@ -70,7 +73,6 @@ int launcher_build()
|
|||||||
};
|
};
|
||||||
|
|
||||||
CUtlString outputProject = ldProject.Link();
|
CUtlString outputProject = ldProject.Link();
|
||||||
IFileSystem2::MakeDirectory(CUtlString("%s/bin",szOutputDir.GetString()));
|
|
||||||
IFileSystem2::CopyFile(CUtlString("%s/bin/funnygame", szOutputDir.GetString()), outputProject);
|
IFileSystem2::CopyFile(CUtlString("%s/bin/funnygame", szOutputDir.GetString()), outputProject);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "tier1/utlbuffer.h"
|
#include "tier1/utlbuffer.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
#include "engine.h"
|
|
||||||
|
|
||||||
|
|
||||||
enum EFileOptions
|
enum EFileOptions
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
#include "rendering.h"
|
#include "rendering.h"
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// Mesh handler for the rendering
|
// Mesh instance used in rendering.
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
abstract_class IMesh
|
abstract_class IMeshInstance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void SetVertexBuffer( IVertexBuffer *pBuffer ) = 0;
|
|
||||||
virtual void SetIndexBuffer( IIndexBuffer *pBuffer ) = 0;
|
|
||||||
|
|
||||||
virtual void SetPosition( vec3 position ) = 0;
|
virtual void SetPosition( vec3 position ) = 0;
|
||||||
virtual void SetRotationEuler( vec3 angle ) = 0;
|
virtual void SetRotationEuler( vec3 angle ) = 0;
|
||||||
virtual void SetRotationQuat( vec4 quaternion) = 0;
|
virtual void SetRotationQuat( vec4 quaternion) = 0;
|
||||||
@@ -18,10 +16,20 @@ public:
|
|||||||
virtual void Draw() = 0;
|
virtual void Draw() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
abstract_class IMesh
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void SetVertexBuffer( IVertexBuffer *pBuffer ) = 0;
|
||||||
|
virtual void SetIndexBuffer( IIndexBuffer *pBuffer ) = 0;
|
||||||
|
|
||||||
|
virtual IMeshInstance *CreateInstance() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
interface IMeshRendering: public IRenderingPipelineStep
|
interface IMeshRendering: public IRenderingPipelineStep
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual IMesh *CreateMesh();
|
static IMesh *CreateMesh();
|
||||||
};
|
};
|
||||||
|
|
||||||
interface IModelManager
|
interface IModelManager
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ public:
|
|||||||
static void CreateServer();
|
static void CreateServer();
|
||||||
static void GetServerInfo();
|
static void GetServerInfo();
|
||||||
static void JoinServer( const char *szIP );
|
static void JoinServer( const char *szIP );
|
||||||
|
static void JoinServer( uint64_t nSteamID );
|
||||||
static void ClientConnectedCallback( SteamNetConnectionStatusChangedCallback_t *pCallback );
|
static void ClientConnectedCallback( SteamNetConnectionStatusChangedCallback_t *pCallback );
|
||||||
|
|
||||||
static bool IsServer();
|
static bool IsServer();
|
||||||
|
|||||||
@@ -3,7 +3,13 @@
|
|||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "steam/isteamnetworkingsockets.h"
|
#include "steam/isteamnetworkingsockets.h"
|
||||||
|
#ifdef __linux__
|
||||||
#include "arpa/inet.h"
|
#include "arpa/inet.h"
|
||||||
|
#endif
|
||||||
|
#ifdef __WIN32__
|
||||||
|
#include "winsock2.h"
|
||||||
|
#include "ws2tcpip.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_INTERFACE void Net_Init();
|
PLATFORM_INTERFACE void Net_Init();
|
||||||
|
|||||||
Reference in New Issue
Block a user