Skip to content

Commit

Permalink
Merge pull request #289 from MoeMod/unity_build
Browse files Browse the repository at this point in the history
Unity build
  • Loading branch information
MoeMod authored Apr 24, 2021
2 parents e4b3990 + 8e82218 commit 699a35e
Show file tree
Hide file tree
Showing 295 changed files with 1,574 additions and 2,466 deletions.
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ set(XASH_LIBDL true)
set(CMAKE_CXX_STANDARD 17)

if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
option(XASH_PCH "Enable PCH support." OFF)
option(XASH_PCH "Enable PCH support." ON)
option(XASH_UNITY_BUILD "Enable Unity Build support." ON)
endif()

option(XASH_VCPKG "Enable VCPKG support." OFF)
Expand All @@ -38,6 +39,14 @@ if(XASH_PCH)
if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
message(FATAL_ERROR "PCH is not supported. Please update to CMake 3.16 or higher.")
endif()
add_definitions(-DXASH_PCH=1)
endif()

if(XASH_UNITY_BUILD)
if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
message(FATAL_ERROR "Unity build is not supported. Please update to CMake 3.16 or higher.")
endif()
add_definitions(-DXASH_UNITY_BUILD=1)
endif()

if(XASH_STATIC_GAMELIB)
Expand All @@ -60,6 +69,11 @@ else()
add_compile_options( -Wall -Wextra -Wno-unused-parameter -Wl,--no-undefined )
endif()

# Important, as HLSDK and engine shares some symbol names!
if(NOT WIN32) # Windows by default have hidden visibility and better linker
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
endif()

if(CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(-Wpedantic)
add_compile_options(-fPIC)
Expand Down Expand Up @@ -157,6 +171,10 @@ if(XASH_IMGUI)
target_include_directories(imgui_ext PRIVATE ${CMAKE_SOURCE_DIR}/imgui_ext/dirent)
endif()
target_link_libraries(imgui_ext PUBLIC imgui)
if(XASH_UNITY_BUILD)
set_target_properties(imgui PROPERTIES UNITY_BUILD ON)
set_target_properties(imgui_ext PROPERTIES UNITY_BUILD ON)
endif()
endif()

if(XASH_LUASH)
Expand Down
6 changes: 5 additions & 1 deletion cl_dll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ include_directories (
)

if(XASH_STATIC_GAMELIB)
add_library (${CLIENT_LIBRARY} STATIC ${CLDLL_SOURCES})
add_library (${CLIENT_LIBRARY} STATIC ${CLDLL_SOURCES} "events/eventdef.h")
else()
add_library (${CLIENT_LIBRARY} SHARED ${CLDLL_SOURCES})
endif()
Expand Down Expand Up @@ -385,3 +385,7 @@ endif()
if(XASH_PCH)
target_precompile_headers(${CLIENT_LIBRARY} PRIVATE stdafx.h)
endif()

if(XASH_UNITY_BUILD)
set_target_properties(${CLIENT_LIBRARY} PROPERTIES UNITY_BUILD ON)
endif()
4 changes: 0 additions & 4 deletions cl_dll/cl_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ inline void PlaySound( const char *szSound, float vol ) { gEngfuncs.pfnPlaySound
inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); }

#include "minmax.h"
#ifndef __APPLE__
// template functions are considered after non-template functions, so it will not conflict with math.h
template<class T> constexpr T fabs(T x) { return ((x) > 0 ? (x) : 0 - (x)); }
#endif

#ifdef VectorSubtract
#undef VectorSubtract
Expand Down
16 changes: 0 additions & 16 deletions cl_dll/com_weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,6 @@ void HUD_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short event
bparam1, bparam2 );
}



/*
=====================
UTIL_WeaponTimeBase
Always 0.0 on client, even if not predicting weapons ( won't get called
in that case )
=====================
*/
inline std::chrono::duration<float> UTIL_WeaponTimeBase( void )
{
return {};
}


static unsigned int glSeed = 0;

unsigned int seed_table[ 256 ] =
Expand Down
3 changes: 0 additions & 3 deletions cl_dll/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@

#include "angledef.h"

#define DECLARE_EVENT( x ) void EV_##x( struct event_args_s *args )
#define HOOK_EVENT( x, y ) gEngfuncs.pfnHookEvent( "events/" #x ".sc", EV_##y )

#define PLAY_EVENT_SOUND( x ) gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, (x), VOL_NORM, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 15 ) )


Expand Down
4 changes: 2 additions & 2 deletions cl_dll/events/event_ak47.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
*/
#include "events.h"

namespace cl {

namespace cl::event::ak47 {
enum ak47_e
{
AK47_IDLE1 = 0,
Expand Down
4 changes: 2 additions & 2 deletions cl_dll/events/event_ak47dragon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
*/
#include "events.h"

namespace cl {

namespace cl::event::ak47dragon {
enum ak47_e
{
AK47_IDLE1 = 0,
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_ak47l.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::ak47l {

enum ak47_e
{
Expand Down
22 changes: 11 additions & 11 deletions cl_dll/events/event_ak47x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ GNU General Public License for more details.
*/
#include "events.h"

namespace cl {

enum
{
ANIM_IDLE1 = 0,
ANIM_RELOAD,
ANIM_DRAW,
ANIM_SHOOT1,
ANIM_SHOOT2,
ANIM_SHOOT3
};
namespace cl::event::ak47x {
enum
{
ANIM_IDLE1 = 0,
ANIM_RELOAD,
ANIM_DRAW,
ANIM_SHOOT1,
ANIM_SHOOT2,
ANIM_SHOOT3
};

static const char *SOUNDS_NAME[] =
{
Expand Down
4 changes: 2 additions & 2 deletions cl_dll/events/event_anaconda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
*/
#include "events.h"

namespace cl {

namespace cl::event::anaconda {
enum deagle_e
{
DEAGLE_IDLE1 = 0,
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_as50.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::as50 {

enum as50_e
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_aug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::aug {

enum aug_e
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_awp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::awp {

enum awp_e
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_balrog7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::balrog7 {

enum balrog7_e
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_bizon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::bizon {

enum bizon_e
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_bow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::bow {

enum bow_e
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_cannon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::cannon {

enum cannon_e
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_cannonplasma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::cannonplasma {

enum cannonplasma_e
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_cannontiger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::cannontiger {

enum cannontiger_e
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_chainsaw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::chainsaw {

enum chainsaw_e
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_createexplo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::createexplo {

void EV_CreateExplo(event_args_s *args)
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_createsmoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include "com_model.h"

namespace cl {
namespace cl::event::createsmoke {

#define SMOKE_CLOUDS 20

Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_cz75.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::cz75 {

enum cz75_e
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_deagle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::deagle {

enum deagle_e
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_deagleb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::deagleb {

enum
{
Expand Down
12 changes: 10 additions & 2 deletions cl_dll/events/event_deagled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::deagled {

enum elite_e
{
Expand Down Expand Up @@ -89,7 +89,7 @@ void EV_FireDeagleD( event_args_s *args, int sequence )
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
Vector vSpread;

vSpread.x = args->fparam1;
vSpread.y = args->fparam2;
EV_HLDM_FireBullets( idx,
Expand All @@ -99,13 +99,21 @@ void EV_FireDeagleD( event_args_s *args, int sequence )
2 );
}

}

namespace cl::event::deagled_left {
void EV_FireDeagleD_Left(event_args_s *args)
{
using namespace cl::event::deagled;
EV_FireDeagleD( args, Com_RandomLong( ELITE_SHOOTLEFT1, ELITE_SHOOTLEFT4 ));
}

}

namespace cl::event::deagled_right {
void EV_FireDeagleD_Right( event_args_s *args )
{
using namespace cl::event::deagled;
EV_FireDeagleD( args, Com_RandomLong( ELITE_SHOOTRIGHT1, ELITE_SHOOTRIGHT4 ));
}

Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_decal_reset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

float g_flRoundTime = 0.0f;

namespace cl {
namespace cl::event::decal_reset {

void EV_DecalReset(event_args_s *args)
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/event_desperado.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
#include "events.h"

namespace cl {
namespace cl::event::desperado {

enum desperado_e
{
Expand Down
17 changes: 10 additions & 7 deletions cl_dll/events/event_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@
#include "r_studioint.h"
#include <string>

enum event_effect
{
EVENT_GATLINGRX,
EVENT_DUALSWORD,
EVENT_VOIDPISTOL
};

namespace cl {
extern engine_studio_api_t IEngineStudio;
}

extern engine_studio_api_t IEngineStudio;
namespace cl::event::wpneffects {

enum event_effect
{
EVENT_GATLINGRX,
EVENT_DUALSWORD,
EVENT_VOIDPISTOL
};

static const char* SOUNDS_NAME[] =
{
Expand Down
Loading

0 comments on commit 699a35e

Please sign in to comment.