Skip to content

Commit

Permalink
fix unity build
Browse files Browse the repository at this point in the history
  • Loading branch information
MoeMod committed Apr 23, 2021
1 parent a786245 commit 8e82218
Show file tree
Hide file tree
Showing 179 changed files with 1,118 additions and 1,145 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
4 changes: 4 additions & 0 deletions cl_dll/CMakeLists.txt
Original file line number Diff line number Diff line change
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()
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::event::smoke {
namespace cl::event::createsmoke {

#define SMOKE_CLOUDS 20

Expand Down
10 changes: 9 additions & 1 deletion cl_dll/events/event_deagled.cpp
Original file line number Diff line number Diff line change
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
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;
}

namespace cl::event::wpneffects {

extern engine_studio_api_t IEngineStudio;
enum event_effect
{
EVENT_GATLINGRX,
EVENT_DUALSWORD,
EVENT_VOIDPISTOL
};

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

namespace cl::event::elite_left {
namespace cl::event::elite {

enum elite_e
{
Expand Down Expand Up @@ -89,7 +89,7 @@ void EV_FireElite( 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,11 +99,21 @@ void EV_FireElite( event_args_s *args, int sequence )
2 );
}

}

namespace cl::event::elite_left {

using namespace cl::event::elite;
void EV_FireEliteLeft(event_args_s *args)
{
EV_FireElite( args, Com_RandomLong( ELITE_SHOOTLEFT1, ELITE_SHOOTLEFT4 ));
}

}

namespace cl::event::elite_right {

using namespace cl::event::elite;
void EV_FireEliteRight( event_args_s *args )
{
EV_FireElite( args, Com_RandomLong( ELITE_SHOOTRIGHT1, ELITE_SHOOTRIGHT4 ));
Expand Down
6 changes: 4 additions & 2 deletions cl_dll/events/event_gatlingex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
#include "r_studioint.h"
#include <string>

namespace cl::event::gatlingex {
namespace cl {
extern engine_studio_api_t IEngineStudio;
}

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

enum gatling_e
{
Expand Down
5 changes: 4 additions & 1 deletion cl_dll/events/event_glock18.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
*/
#include "events.h"

namespace cl {
bool g_bGlockBurstMode = false;
}

namespace cl::event::glock18 {
bool g_bGlockBurstMode = false;

enum glock18_e
{
Expand Down
7 changes: 4 additions & 3 deletions cl_dll/events/event_gunkata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ GNU General Public License for more details.
#include "r_studioint.h"
#include <string>

namespace cl::event::gunkata {

extern engine_studio_api_t IEngineStudio;
namespace cl {
extern engine_studio_api_t IEngineStudio;
}

namespace cl::event::gunkata {
enum
{
ANIM_IDLE = 0, //6.0
Expand Down
10 changes: 9 additions & 1 deletion cl_dll/events/event_infinity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void EV_FireInfinity( event_args_s *args, int sequence, int direction )
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
Vector vSpread;

vSpread.x = args->fparam1;
vSpread.y = args->fparam2;
EV_HLDM_FireBullets( idx,
Expand All @@ -97,6 +97,10 @@ void EV_FireInfinity( event_args_s *args, int sequence, int direction )
2 );
}

}

namespace cl::event::infinity_left {
using namespace cl::event::infinity;
void EV_FireInfinity_Left(event_args_s *args)
{
if(!args->bparam1)
Expand All @@ -107,6 +111,10 @@ void EV_FireInfinity_Left(event_args_s *args)
EV_FireInfinity(args, ANIM_SP_SHOOT_LEFT2, 0);
}

}

namespace cl::event::infinity_right {
using namespace cl::event::infinity;
void EV_FireInfinity_Right( event_args_s *args )
{
if (!args->bparam1)
Expand Down
21 changes: 21 additions & 0 deletions cl_dll/events/event_infinitys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,24 @@ void EV_FireInfinityS(event_args_t *args)
}

}

namespace cl::event::infinityss {
void EV_FireInfinitySS(event_args_t *args)
{
return cl::event::infinitys::EV_FireInfinityS(args);
}
}

namespace cl::event::infinitysr {
void EV_FireInfinitySR(event_args_t *args)
{
return cl::event::infinitys::EV_FireInfinityS(args);
}
}

namespace cl::event::infinitysb {
void EV_FireInfinitySB(event_args_t *args)
{
return cl::event::infinitys::EV_FireInfinityS(args);
}
}
10 changes: 9 additions & 1 deletion cl_dll/events/event_infinityx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void EV_FireInfinityX( event_args_s *args, int sequence, int direction )
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
Vector vSpread;

vSpread.x = args->fparam1;
vSpread.y = args->fparam2;
EV_HLDM_FireBullets( idx,
Expand All @@ -97,6 +97,10 @@ void EV_FireInfinityX( event_args_s *args, int sequence, int direction )
2 );
}

}

namespace cl::event::infinityx_left {
using namespace cl::event::infinityx;
void EV_FireInfinityX_Left(event_args_s *args)
{
if(!args->bparam1)
Expand All @@ -107,6 +111,10 @@ void EV_FireInfinityX_Left(event_args_s *args)
EV_FireInfinityX(args, ANIM_SP_SHOOT_LEFT2, 0);
}

}

namespace cl::event::infinityx_right {
using namespace cl::event::infinityx;
void EV_FireInfinityX_Right( event_args_s *args )
{
if (!args->bparam1)
Expand Down
14 changes: 12 additions & 2 deletions cl_dll/events/event_m134heroi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void EV_FireM134HeroI(event_args_s *args)
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
Vector vSpread;

vSpread.x = args->fparam1;
vSpread.y = args->fparam2;
EV_HLDM_FireBullets( idx,
Expand All @@ -103,7 +103,6 @@ void EV_FireM134HeroI(event_args_s *args)
2 );
}


//======================
// EGON END
//======================
Expand All @@ -120,6 +119,11 @@ enum EGON_FIREMODE { FIRE_NARROW, FIRE_WIDE};

BEAM *pBeam;
BEAM *pBeam2;
}

namespace cl::event::m134heroi_fire {

using namespace cl::event::m134heroi;

void EV_FireM134HeroI_EgonFire( event_args_t *args )
{
Expand Down Expand Up @@ -211,6 +215,12 @@ void EV_FireM134HeroI_EgonFire( event_args_t *args )
}
}

}

namespace cl::event::m134heroi_stop {

using namespace cl::event::m134heroi;

void EV_FireM134HeroI_EgonStop( event_args_t *args )
{
int idx;
Expand Down
8 changes: 7 additions & 1 deletion cl_dll/events/event_mp7a1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void EV_FireMP7A1D( 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 @@ -98,14 +98,20 @@ void EV_FireMP7A1D( event_args_s *args, int sequence )
vSpread, 8192.0, BULLET_PLAYER_9MM,
2 );
}
}

namespace cl::event::mp7a1d_left {
void EV_FireMP7A1D_Left(event_args_s *args)
{
using namespace cl::event::mp7a1d;
EV_FireMP7A1D( args, Com_RandomLong( ELITE_SHOOTLEFT1, ELITE_SHOOTLEFT4 ));
}

}
namespace cl::event::mp7a1d_right {
void EV_FireMP7A1D_Right( event_args_s *args )
{
using namespace cl::event::mp7a1d;
EV_FireMP7A1D( args, Com_RandomLong( ELITE_SHOOTRIGHT1, ELITE_SHOOTRIGHT4 ));
}

Expand Down
6 changes: 4 additions & 2 deletions cl_dll/events/event_voidpistol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
#include "r_studioint.h"
#include <string>

namespace cl::event::voidpistol {
namespace cl {
extern engine_studio_api_t IEngineStudio;
}

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

enum voidpistol_e
{
Expand Down
6 changes: 3 additions & 3 deletions cl_dll/events/eventdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ HOOK_EVENT(m2, FireM2);
HOOK_EVENT(m134, FireM134);
HOOK_EVENT(m134ex, FireM134ex);
HOOK_EVENT(starchaserar, FireStarchaserar);
HOOK_EVENT(infinityss, FireInfinityS);
HOOK_EVENT(infinitysb, FireInfinityS);
HOOK_EVENT(infinitysr, FireInfinityS);
HOOK_EVENT(infinityss, FireInfinitySS);
HOOK_EVENT(infinitysb, FireInfinitySB);
HOOK_EVENT(infinitysr, FireInfinitySR);
HOOK_EVENT(gungnir, FireGungnir);
HOOK_EVENT(anaconda, FireAnaconda);
HOOK_EVENT(mg36, FireMG36);
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/events/hl_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void Game_HookEvents( void )
{
#define HOOK_EVENT( x, y ) gEngfuncs.pfnHookEvent( "events/" #x ".sc", EV_##y )
#include "eventdef.h"
#undef
#undef HOOK_EVENT

#ifdef XASH_LUASH
LuaCL_HookEvents();
Expand Down
Loading

0 comments on commit 8e82218

Please sign in to comment.