Add 'engine_cl' project to SDK and fix compiler errors

The 'engine_cl' library defines 'CLIENT_DLL', which prunes server specific code. This is used for the 'client.dll' project. Also fixed a compile error in 'CClient::VActivatePlayer', as it used a server only cvar. Ideally, this entire file gets ifdef'd out for engine_cl, currently it doesn't matter as nothing gets compiled in.
This commit is contained in:
Kawe Mazidjatari 2023-07-19 02:30:07 +02:00
parent 6ccf3baa5a
commit ad6466fa6c
4 changed files with 43 additions and 34 deletions

View File

@ -97,15 +97,8 @@ target_link_libraries( ${PROJECT_NAME} PRIVATE
"vgui" "vgui"
"rui" "rui"
"engine"
"d3d11.lib" "d3d11.lib"
) )
else()
target_link_libraries( ${PROJECT_NAME} PRIVATE
"materialsystem_nodx" # Needs the No-DirectX version for patching.
"engine_ds"
)
endif() endif()
# Determine the compiler definitions and link libraries per project. # Determine the compiler definitions and link libraries per project.
@ -113,6 +106,7 @@ if( ${PROJECT_NAME} STREQUAL "gamesdk" )
end_sources() end_sources()
target_link_libraries( ${PROJECT_NAME} PRIVATE target_link_libraries( ${PROJECT_NAME} PRIVATE
"engine"
"server_static" "server_static"
"client_static" "client_static"
) )
@ -124,6 +118,8 @@ elseif( ${PROJECT_NAME} STREQUAL "dedicated" )
end_sources() end_sources()
target_link_libraries( ${PROJECT_NAME} PRIVATE target_link_libraries( ${PROJECT_NAME} PRIVATE
"materialsystem_nodx" # Needs the No-DirectX version for patching.
"engine_ds"
"server_static" "server_static"
) )
target_compile_definitions( ${PROJECT_NAME} PRIVATE target_compile_definitions( ${PROJECT_NAME} PRIVATE
@ -136,6 +132,7 @@ elseif( ${PROJECT_NAME} STREQUAL "client" )
end_sources( "${BUILD_OUTPUT_DIR}/bin/x64_retail/" ) end_sources( "${BUILD_OUTPUT_DIR}/bin/x64_retail/" )
target_link_libraries( ${PROJECT_NAME} PRIVATE target_link_libraries( ${PROJECT_NAME} PRIVATE
"engine_cl"
"client_static" "client_static"
) )
target_compile_definitions( ${PROJECT_NAME} PRIVATE target_compile_definitions( ${PROJECT_NAME} PRIVATE

View File

@ -20,14 +20,12 @@ add_sources( SOURCE_GROUP "Collision"
"traceinit.h" "traceinit.h"
) )
if( ${PROJECT_NAME} STREQUAL "engine" ) if( NOT ${PROJECT_NAME} STREQUAL "engine_ds" )
add_sources( SOURCE_GROUP "Debug" add_sources( SOURCE_GROUP "Debug"
"debugoverlay.cpp" "debugoverlay.cpp"
"debugoverlay.h" "debugoverlay.h"
) )
endif()
if( ${PROJECT_NAME} STREQUAL "engine" )
add_sources( SOURCE_GROUP "Render" add_sources( SOURCE_GROUP "Render"
"gl_matsysiface.h" "gl_matsysiface.h"
"gl_model_private.h" "gl_model_private.h"
@ -89,7 +87,7 @@ add_sources( SOURCE_GROUP "System"
"sdk_dll.h" "sdk_dll.h"
) )
if( ${PROJECT_NAME} STREQUAL "engine" ) if( NOT ${PROJECT_NAME} STREQUAL "engine_ds" )
add_sources( SOURCE_GROUP "System" add_sources( SOURCE_GROUP "System"
"sys_getmodes.cpp" "sys_getmodes.cpp"
"sys_getmodes.h" "sys_getmodes.h"
@ -98,6 +96,7 @@ add_sources( SOURCE_GROUP "System"
) )
endif() endif()
if( NOT ${PROJECT_NAME} STREQUAL "engine_cl" )
add_sources( SOURCE_GROUP "Server" add_sources( SOURCE_GROUP "Server"
"server/persistence.cpp" "server/persistence.cpp"
"server/persistence.h" "server/persistence.h"
@ -112,6 +111,7 @@ add_sources( SOURCE_GROUP "Server"
"server/datablock_sender.cpp" "server/datablock_sender.cpp"
"server/datablock_sender.h" "server/datablock_sender.h"
) )
endif()
add_sources( SOURCE_GROUP "Client" add_sources( SOURCE_GROUP "Client"
"client/cdll_engine_int.cpp" "client/cdll_engine_int.cpp"
@ -129,7 +129,7 @@ add_sources( SOURCE_GROUP "Shared"
"shared/shared_rcon.h" "shared/shared_rcon.h"
) )
if( ${PROJECT_NAME} STREQUAL "engine" ) if( NOT ${PROJECT_NAME} STREQUAL "engine_ds" )
add_sources( SOURCE_GROUP "Client" # Client only. add_sources( SOURCE_GROUP "Client" # Client only.
"client/clientstate.cpp" "client/clientstate.cpp"
"client/clientstate.h" "client/clientstate.h"
@ -144,9 +144,7 @@ add_sources( SOURCE_GROUP "Client" # Client only.
"client/datablock_receiver.cpp" "client/datablock_receiver.cpp"
"client/datablock_receiver.h" "client/datablock_receiver.h"
) )
endif()
if( ${PROJECT_NAME} STREQUAL "engine" )
add_sources( SOURCE_GROUP "GameUI" add_sources( SOURCE_GROUP "GameUI"
"${ENGINE_SOURCE_DIR}/gameui/IBrowser.cpp" "${ENGINE_SOURCE_DIR}/gameui/IBrowser.cpp"
"${ENGINE_SOURCE_DIR}/gameui/IBrowser.h" "${ENGINE_SOURCE_DIR}/gameui/IBrowser.h"
@ -218,7 +216,7 @@ add_sources( SOURCE_GROUP "Public"
"${ENGINE_SOURCE_DIR}/public/gamebspfile.h" "${ENGINE_SOURCE_DIR}/public/gamebspfile.h"
) )
if( ${PROJECT_NAME} STREQUAL "engine" ) if( NOT ${PROJECT_NAME} STREQUAL "engine_ds" )
add_sources( SOURCE_GROUP "Public" add_sources( SOURCE_GROUP "Public"
"${ENGINE_SOURCE_DIR}/public/client_class.h" "${ENGINE_SOURCE_DIR}/public/client_class.h"
"${ENGINE_SOURCE_DIR}/public/ivrenderview.h" "${ENGINE_SOURCE_DIR}/public/ivrenderview.h"
@ -232,8 +230,14 @@ if( ${PROJECT_NAME} STREQUAL "engine_ds" )
target_compile_definitions( ${PROJECT_NAME} PRIVATE target_compile_definitions( ${PROJECT_NAME} PRIVATE
"DEDICATED" "DEDICATED"
) )
elseif( ${PROJECT_NAME} STREQUAL "engine_cl" )
target_compile_definitions( ${PROJECT_NAME} PRIVATE
"CLIENT_DLL"
)
endif() endif()
endmacro() endmacro()
add_engine_project( "engine" ) add_engine_project( "engine" )
add_engine_project( "engine_ds" ) add_engine_project( "engine_ds" )
add_engine_project( "engine_cl" )

View File

@ -103,6 +103,7 @@ void CClient::VActivatePlayer(CClient* pClient)
pClient->SetPersistenceState(PERSISTENCE::PERSISTENCE_READY); pClient->SetPersistenceState(PERSISTENCE::PERSISTENCE_READY);
v_CClient_ActivatePlayer(pClient); v_CClient_ActivatePlayer(pClient);
#ifndef CLIENT_DLL
const CNetChan* pNetChan = pClient->GetNetChan(); const CNetChan* pNetChan = pClient->GetNetChan();
if (pNetChan && sv_showconnecting->GetBool()) if (pNetChan && sv_showconnecting->GetBool())
@ -110,6 +111,7 @@ void CClient::VActivatePlayer(CClient* pClient)
DevMsg(eDLL_T::SERVER, "Activated player #%d; channel %s(%s) ('%llu')\n", DevMsg(eDLL_T::SERVER, "Activated player #%d; channel %s(%s) ('%llu')\n",
pClient->GetUserID(), pNetChan->GetName(), pNetChan->GetAddress(), pClient->GetNucleusID()); pClient->GetUserID(), pNetChan->GetName(), pNetChan->GetAddress(), pClient->GetNucleusID());
} }
#endif // !CLIENT_DLL
} }
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
@ -216,3 +218,26 @@ bool CClient::VSendNetMsgEx(CClient* pClient, CNetMessage* pMsg, char bLocal, bo
{ {
return pClient->SendNetMsgEx(pMsg, bLocal, bForceReliable, bVoice); return pClient->SendNetMsgEx(pMsg, bLocal, bForceReliable, bVoice);
} }
void VClient::Attach(void) const
{
#ifndef CLIENT_DLL
DetourAttach((LPVOID*)&v_CClient_Clear, &CClient::VClear);
DetourAttach((LPVOID*)&v_CClient_Connect, &CClient::VConnect);
DetourAttach((LPVOID*)&v_CClient_ActivatePlayer, &CClient::VActivatePlayer);
DetourAttach((LPVOID*)&v_CClient_ProcessStringCmd, &CClient::VProcessStringCmd);
DetourAttach((LPVOID*)&v_CClient_SendNetMsgEx, &CClient::VSendNetMsgEx);
//DetourAttach((LPVOID*)&p_CClient_SendSnapshot, &CClient::VSendSnapshot);
#endif // !CLIENT_DLL
}
void VClient::Detach(void) const
{
#ifndef CLIENT_DLL
DetourDetach((LPVOID*)&v_CClient_Clear, &CClient::VClear);
DetourDetach((LPVOID*)&v_CClient_Connect, &CClient::VConnect);
DetourDetach((LPVOID*)&v_CClient_ActivatePlayer, &CClient::VActivatePlayer);
DetourDetach((LPVOID*)&v_CClient_ProcessStringCmd, &CClient::VProcessStringCmd);
DetourDetach((LPVOID*)&v_CClient_SendNetMsgEx, &CClient::VSendNetMsgEx);
//DetourDetach((LPVOID*)&p_CClient_SendSnapshot, &CClient::VSendSnapshot);
#endif // !CLIENT_DLL
}

View File

@ -268,24 +268,7 @@ class VClient : public IDetour
} }
virtual void GetVar(void) const { } virtual void GetVar(void) const { }
virtual void GetCon(void) const { } virtual void GetCon(void) const { }
virtual void Attach(void) const virtual void Attach(void) const;
{ virtual void Detach(void) const;
DetourAttach((LPVOID*)&v_CClient_Clear, &CClient::VClear);
DetourAttach((LPVOID*)&v_CClient_Connect, &CClient::VConnect);
DetourAttach((LPVOID*)&v_CClient_ActivatePlayer, &CClient::VActivatePlayer);
DetourAttach((LPVOID*)&v_CClient_ProcessStringCmd, &CClient::VProcessStringCmd);
DetourAttach((LPVOID*)&v_CClient_SendNetMsgEx, &CClient::VSendNetMsgEx);
//DetourAttach((LPVOID*)&p_CClient_SendSnapshot, &CClient::VSendSnapshot);
}
virtual void Detach(void) const
{
DetourDetach((LPVOID*)&v_CClient_Clear, &CClient::VClear);
DetourDetach((LPVOID*)&v_CClient_Connect, &CClient::VConnect);
DetourDetach((LPVOID*)&v_CClient_ActivatePlayer, &CClient::VActivatePlayer);
DetourDetach((LPVOID*)&v_CClient_ProcessStringCmd, &CClient::VProcessStringCmd);
DetourDetach((LPVOID*)&v_CClient_SendNetMsgEx, &CClient::VSendNetMsgEx);
//DetourDetach((LPVOID*)&p_CClient_SendSnapshot, &CClient::VSendSnapshot);
}
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////