diff --git a/cl_dll/GameStudioModelRenderer.cpp b/cl_dll/GameStudioModelRenderer.cpp index f32def43..3a720ff3 100644 --- a/cl_dll/GameStudioModelRenderer.cpp +++ b/cl_dll/GameStudioModelRenderer.cpp @@ -18,8 +18,6 @@ #include #include -#include -#include #include "studio_util.h" #include "r_studioint.h" diff --git a/cl_dll/GameStudioModelRenderer_Sample.cpp b/cl_dll/GameStudioModelRenderer_Sample.cpp index 8910d809..a840f393 100644 --- a/cl_dll/GameStudioModelRenderer_Sample.cpp +++ b/cl_dll/GameStudioModelRenderer_Sample.cpp @@ -18,8 +18,6 @@ #include #include -#include -#include #include "studio_util.h" #include "r_studioint.h" diff --git a/cl_dll/StudioModelRenderer.cpp b/cl_dll/StudioModelRenderer.cpp index 6f035b7c..b8a182a7 100644 --- a/cl_dll/StudioModelRenderer.cpp +++ b/cl_dll/StudioModelRenderer.cpp @@ -20,8 +20,6 @@ #include #include -#include -#include #include "studio_util.h" #include "r_studioint.h" diff --git a/cl_dll/cl_dll.h b/cl_dll/cl_dll.h index 47845ced..e65a3d94 100644 --- a/cl_dll/cl_dll.h +++ b/cl_dll/cl_dll.h @@ -31,7 +31,8 @@ typedef unsigned char byte; typedef unsigned short word; typedef float vec_t; -typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf ); +// redefine +//typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf ); #include "util_vector.h" @@ -43,7 +44,11 @@ typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf ); #endif #include "exportdef.h" #include - +#if HAVE_CMATH +#include +#else +#include +#endif #if defined(__LP64__) || defined(__LLP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) #define XASH_64BIT #endif diff --git a/cl_dll/demo.cpp b/cl_dll/demo.cpp index 63e333be..8f5fb0a8 100644 --- a/cl_dll/demo.cpp +++ b/cl_dll/demo.cpp @@ -17,7 +17,6 @@ #include "cl_util.h" #include "demo.h" #include "demo_api.h" -#include int g_demosniper = 0; int g_demosniperdamage = 0; diff --git a/cl_dll/entity.cpp b/cl_dll/entity.cpp index 6a7fdc79..287894b8 100644 --- a/cl_dll/entity.cpp +++ b/cl_dll/entity.cpp @@ -7,8 +7,6 @@ // Client side entity management functions -#include - #include "hud.h" #include "cl_util.h" #include "const.h" diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index 6e132dd8..38ef2818 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -353,3 +353,4 @@ int CBasePlayerWeapon::ExtractClipAmmo( CBasePlayerWeapon *pWeapon ) { return 0; void CBasePlayerWeapon::RetireWeapon( void ) { } void CSoundEnt::InsertSound( int iType, const Vector &vecOrigin, int iVolume, float flDuration ) {} void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType ){} +void CSprite::AnimateUntilDead( void ) {} diff --git a/cl_dll/hud_iface.h b/cl_dll/hud_iface.h index 73464c83..be5e390b 100644 --- a/cl_dll/hud_iface.h +++ b/cl_dll/hud_iface.h @@ -10,8 +10,8 @@ #define HUD_IFACEH #include "exportdef.h" - -typedef int (*pfnUserMsgHook)( const char *pszName, int iSize, void *pbuf ); +// redefine +// typedef int (*pfnUserMsgHook)( const char *pszName, int iSize, void *pbuf ); #include "wrect.h" #include "../engine/cdll_int.h" extern cl_enginefunc_t gEngfuncs; diff --git a/cl_dll/hud_update.cpp b/cl_dll/hud_update.cpp index f431bbaf..8c807d1c 100644 --- a/cl_dll/hud_update.cpp +++ b/cl_dll/hud_update.cpp @@ -20,7 +20,6 @@ #include "hud.h" #include "cl_util.h" #include -#include int CL_ButtonBits( int ); void CL_ResetButtonBits( int bits ); diff --git a/cl_dll/studio_util.cpp b/cl_dll/studio_util.cpp index 7ac385fe..3e676654 100644 --- a/cl_dll/studio_util.cpp +++ b/cl_dll/studio_util.cpp @@ -5,7 +5,6 @@ // $NoKeywords: $ //============================================================================= -#include #include "hud.h" #include "cl_util.h" #include "const.h" diff --git a/cl_dll/util.cpp b/cl_dll/util.cpp index cda9fdf4..33e68070 100644 --- a/cl_dll/util.cpp +++ b/cl_dll/util.cpp @@ -33,10 +33,10 @@ #ifndef M_PI_F #define M_PI_F (float)M_PI #endif - extern vec3_t vec3_origin; -#ifdef _MSC_VER +// if C++ mangling differs from C symbol name +#if defined _MSC_VER || defined __WATCOMC__ vec3_t vec3_origin; #endif diff --git a/cl_dll/util_vector.h b/cl_dll/util_vector.h index 93166a6b..c83d347f 100644 --- a/cl_dll/util_vector.h +++ b/cl_dll/util_vector.h @@ -22,8 +22,11 @@ // Misc C-runtime library headers #include #include +#if HAVE_CMATH #include - +#else +#include +#endif // Header file containing definition of globalvars_t and entvars_t typedef unsigned int func_t; // typedef int string_t; // from engine's pr_comp.h; diff --git a/cl_dll/wscript b/cl_dll/wscript index b45242d5..3bc40d56 100644 --- a/cl_dll/wscript +++ b/cl_dll/wscript @@ -53,7 +53,7 @@ def build(bld): if bld.env.DEST_OS == 'win32': libs += ["USER32"] - if bld.env.DEST_OS not in ['android']: + if bld.env.DEST_OS not in ['android', 'dos']: install_path = os.path.join(bld.env.GAMEDIR, bld.env.CLIENT_DIR) else: install_path = bld.env.PREFIX @@ -61,6 +61,7 @@ def build(bld): bld.shlib( source = source, target = 'client' + bld.env.POSTFIX, + name = 'client', features = 'c cxx', includes = includes, defines = defines, diff --git a/common/mathlib.h b/common/mathlib.h index b8baff79..9756f0ad 100644 --- a/common/mathlib.h +++ b/common/mathlib.h @@ -22,7 +22,11 @@ #include #endif // HAVE_TGMATH_H #else // __cplusplus +#if HAVE_CMATH #include +#else +#include +#endif #endif // __cplusplus typedef float vec_t; diff --git a/dlls/animation.cpp b/dlls/animation.cpp index 1e39b951..604ae4d8 100644 --- a/dlls/animation.cpp +++ b/dlls/animation.cpp @@ -13,6 +13,10 @@ * ****/ +/* all this mess was here to use quake mathlib instead of hlsdk vectors +* it may break debug info or even build because global symbols types differ +* it's better to define VectorCopy macro for Vector class */ +#if 0 #include #include #include @@ -50,7 +54,17 @@ typedef unsigned char byte; #include "enginecallback.h" #endif -extern globalvars_t *gpGlobals; +//extern globalvars_t *gpGlobals; +#else +#include "extdll.h" +#include "util.h" +#include "activity.h" +#include "activitymap.h" +#include "animation.h" +#include "scriptevent.h" +#include "studio.h" +#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];} +#endif #pragma warning( disable : 4244 ) diff --git a/dlls/bullsquid.cpp b/dlls/bullsquid.cpp index b1c825a7..cc62e8e1 100644 --- a/dlls/bullsquid.cpp +++ b/dlls/bullsquid.cpp @@ -539,6 +539,9 @@ void CBullsquid::HandleAnimEvent( MonsterEvent_t *pEvent ) { case BSQUID_AE_SPIT: { + if( m_hEnemy == 0 ) + return; + Vector vecSpitOffset; Vector vecSpitDir; diff --git a/dlls/extdll.h b/dlls/extdll.h index eb8c37ec..d8fdb41f 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -42,7 +42,7 @@ #define NOMCX #define NOIME #define HSPRITE HSPRITE_win32 -#include "windows.h" +#include #undef HSPRITE #else // _WIN32 #ifndef FALSE @@ -66,7 +66,11 @@ typedef int BOOL; #include #include #include +#if HAVE_CMATH #include +#else +#include +#endif #ifndef M_PI_F #define M_PI_F (float)M_PI diff --git a/dlls/nodes.cpp b/dlls/nodes.cpp index 14b1f878..8b630fd3 100644 --- a/dlls/nodes.cpp +++ b/dlls/nodes.cpp @@ -45,10 +45,13 @@ CGraph WorldGraph; LINK_ENTITY_TO_CLASS( info_node, CNodeEnt ) LINK_ENTITY_TO_CLASS( info_node_air, CNodeEnt ) -#if !defined _WIN32 +#ifdef __DOS__ +#include +#define CreateDirectoryA(p, n) mkdir(p) +#elif !defined _WIN32 #include #include -#define CreateDirectoryA(p, n) mkdir(p, 0777) +#define CreateDirectoryA(p, n) mkdir(p,777) #endif //========================================================= diff --git a/dlls/util.cpp b/dlls/util.cpp index 906a32be..f18e6157 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -2180,7 +2180,7 @@ void CSaveRestoreBuffer::BufferRewind( int size ) m_pdata->size -= size; } -#ifndef _WIN32 +#if !defined _WIN32 && !defined __WATCOMC__ extern "C" { unsigned _rotr( unsigned val, int shift ) { diff --git a/dlls/wscript b/dlls/wscript index 24e93e71..2a469153 100644 --- a/dlls/wscript +++ b/dlls/wscript @@ -61,7 +61,7 @@ def build(bld): libs = [] - if bld.env.DEST_OS not in ['android']: + if bld.env.DEST_OS not in ['android', 'dos']: install_path = os.path.join(bld.env.GAMEDIR, bld.env.SERVER_DIR) else: install_path = bld.env.PREFIX @@ -69,6 +69,7 @@ def build(bld): bld.shlib( source = source, target = bld.env.SERVER_NAME + bld.env.POSTFIX, + name = 'server', features = 'c cxx', includes = includes, defines = defines, diff --git a/public/build.h b/public/build.h index 9cb7e25b..a087c22c 100644 --- a/public/build.h +++ b/public/build.h @@ -52,7 +52,7 @@ For more information, please refer to #undef XASH_ARMv5 #undef XASH_ARMv6 #undef XASH_ARMv7 -#undef XASH_BIG_ENDIAN +//#undef XASH_BIG_ENDIAN #undef XASH_BSD #undef XASH_E2K #undef XASH_EMSCRIPTEN @@ -60,7 +60,7 @@ For more information, please refer to #undef XASH_IOS #undef XASH_JS #undef XASH_LINUX -#undef XASH_LITTLE_ENDIAN +//#undef XASH_LITTLE_ENDIAN #undef XASH_MINGW #undef XASH_MIPS #undef XASH_MOBILE_PLATFORM @@ -92,12 +92,14 @@ For more information, please refer to #if defined(__ANDROID__) #define XASH_ANDROID 1 #endif // defined(__ANDROID__) + #define XASH_POSIX 1 #elif defined(__APPLE__) #include #define XASH_APPLE 1 #if TARGET_OS_IOS #define XASH_IOS 1 #endif // TARGET_OS_IOS + #define XASH_POSIX 1 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #define XASH_BSD 1 #if defined(__FreeBSD__) @@ -107,8 +109,12 @@ For more information, please refer to #elif defined(__OpenBSD__) #define XASH_OPENBSD 1 #endif + #define XASH_POSIX 1 #elif defined __EMSCRIPTEN__ #define XASH_EMSCRIPTEN 1 +#elif defined __WATCOMC__ && defined __DOS__ + #define XASH_DOS4GW 1 + #define XASH_LITTLE_ENDIAN #else #error "Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug" #endif @@ -127,7 +133,7 @@ For more information, please refer to #error "Both XASH_LITTLE_ENDIAN and XASH_BIG_ENDIAN are defined" #endif -#if !defined(XASH_LITTLE_ENDIAN) || !defined(XASH_BIG_ENDIAN) +#if !defined(XASH_LITTLE_ENDIAN) && !defined(XASH_BIG_ENDIAN) #if defined XASH_MSVC || __LITTLE_ENDIAN__ //!!! Probably all WinNT installations runs in little endian #define XASH_LITTLE_ENDIAN 1 diff --git a/scripts/waifulib/library_naming.py b/scripts/waifulib/library_naming.py index 77dfa6df..827ef76c 100644 --- a/scripts/waifulib/library_naming.py +++ b/scripts/waifulib/library_naming.py @@ -49,7 +49,9 @@ DEFINES = [ 'XASH_OPENBSD', 'XASH_WIN32', 'XASH_WIN64', -'XASH_X86' +'XASH_X86', +'XASH_DOS4GW', +'XASH_POSIX' ] def configure(conf): @@ -75,8 +77,11 @@ def configure(conf): buildos = "openbsd" elif conf.env.XASH_EMSCRIPTEN: buildos = "emscripten" + elif conf.env.XASH_DOS4GW: + buildos = "dos4gw" # unused, just in case else: - conf.fatal("Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug") + conf.fatal("Place your operating system name in build.h and library_naming.py!\n" + "If this is a mistake, try to fix conditions above and report a bug") if conf.env.XASH_AMD64: buildarch = "amd64" @@ -110,7 +115,8 @@ def configure(conf): elif conf.env.XASH_E2K: buildarch = "e2k" else: - raise conf.fatal("Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug") + raise conf.fatal("Place your architecture name in build.h and library_naming.py!\n" + "If this is a mistake, try to fix conditions above and report a bug") conf.env.revert() diff --git a/wscript b/wscript index 15c4b175..b01647df 100644 --- a/wscript +++ b/wscript @@ -43,6 +43,9 @@ def options(opt): grp.add_option('--enable-magx', action = 'store_true', dest = 'MAGX', default = False, help = 'enable targetting for MotoMAGX phones [default: %default]') + grp.add_option('--enable-simple-mod-hacks', action = 'store_true', dest = 'ENABLE_MOD_HACKS', default = False, + help = 'enable hacks for simple mods that mostly compatible with Half-Life but has little changes. Enforced for Android. [default: %default]') + opt.load('xcompile compiler_cxx compiler_c clang_compilation_database strip_on_install') if sys.platform == 'win32': @@ -70,7 +73,7 @@ def configure(conf): conf.fatal('Please set a build type, for example "-T release"') elif not conf.options.BUILD_TYPE in valid_build_types: conf.end_msg(conf.options.BUILD_TYPE, color='RED') - conf.fatal('Invalid build type. Valid are: %s' % valid_build_types.join(', ')) + conf.fatal('Invalid build type. Valid are: %s' % ', '.join(valid_build_types)) conf.end_msg(conf.options.BUILD_TYPE) # -march=native should not be used @@ -180,8 +183,6 @@ def configure(conf): compiler_optional_flags = [ '-fdiagnostics-color=always', - '-Werror=implicit-function-declaration', - '-Werror=int-conversion', '-Werror=return-type', '-Werror=parentheses', '-Werror=vla', @@ -193,6 +194,8 @@ def configure(conf): ] c_compiler_optional_flags = [ + '-Werror=implicit-function-declaration', + '-Werror=int-conversion', '-Werror=implicit-int', '-Werror=declaration-after-statement' ] @@ -246,10 +249,16 @@ def configure(conf): conf.define_cond('HAVE_TGMATH_H', tgmath_usable) else: conf.undefine('HAVE_TGMATH_H') + cmath_usable = conf.check_cxx(fragment='''#include + int main(void){ return (int)sqrt(2.0f); }''', + msg='Checking if cmath is usable', mandatory = False) + conf.define_cond('HAVE_CMATH', cmath_usable) if conf.env.COMPILER_CC == 'msvc': conf.define('_CRT_SECURE_NO_WARNINGS', 1) conf.define('_CRT_NONSTDC_NO_DEPRECATE', 1) + elif conf.env.COMPILER_CC == 'owcc': + pass else: conf.env.append_unique('DEFINES', ['stricmp=strcasecmp', 'strnicmp=strncasecmp', '_snprintf=snprintf', '_vsnprintf=vsnprintf', '_LINUX', 'LINUX']) conf.env.append_unique('CXXFLAGS', ['-Wno-invalid-offsetof', '-fno-rtti', '-fno-exceptions']) @@ -263,6 +272,9 @@ def configure(conf): conf.define('CLIENT_WEAPONS', '1') + if conf.env.DEST_OS == 'android' or conf.options.ENABLE_MOD_HACKS: + conf.define('MOBILE_HACKS', '1') + conf.add_subproject(["cl_dll", "dlls"]) def build(bld):