From e53f15cabfb9f1141770b93378fe1a2acd316363 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 2 Dec 2019 02:28:51 +0300 Subject: [PATCH 01/11] wscript: add option to turn on simple mod hacks --- wscript | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wscript b/wscript index 15c4b175..1dc0bb39 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': @@ -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' ] @@ -263,6 +266,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): From 701d78dcecf27f9f463c44f39b163a9299b10f05 Mon Sep 17 00:00:00 2001 From: Aimless-Wanderer <53096779+Aimless-Wanderer@users.noreply.github.com> Date: Sun, 8 Dec 2019 14:20:24 +0200 Subject: [PATCH 02/11] wscript: fix join method usage --- wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wscript b/wscript index 1dc0bb39..0e98480f 100644 --- a/wscript +++ b/wscript @@ -73,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 From 3a2d8ef5f9599564c3b6dea8e870200e07a3374e Mon Sep 17 00:00:00 2001 From: mittorn Date: Wed, 12 Feb 2020 15:28:50 +0700 Subject: [PATCH 03/11] client: remove useless defines --- cl_dll/GameStudioModelRenderer.cpp | 2 -- cl_dll/GameStudioModelRenderer_Sample.cpp | 2 -- cl_dll/StudioModelRenderer.cpp | 2 -- cl_dll/demo.cpp | 1 - cl_dll/entity.cpp | 2 -- cl_dll/hud_iface.h | 4 ++-- cl_dll/hud_update.cpp | 1 - cl_dll/studio_util.cpp | 1 - 8 files changed, 2 insertions(+), 13 deletions(-) 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 1994c2a7..fc168dfa 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/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/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" From 8bf08e261ca52a5f8652bd1eb5043728de90bb53 Mon Sep 17 00:00:00 2001 From: mittorn Date: Wed, 12 Feb 2020 15:30:58 +0700 Subject: [PATCH 04/11] update build.h, add new defines to library_naming.py --- public/build.h | 12 +++++++++--- scripts/waifulib/library_naming.py | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) 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() From 2ba907179843350afd1e697b66db4562c1f5f95c Mon Sep 17 00:00:00 2001 From: mittorn Date: Wed, 12 Feb 2020 15:34:05 +0700 Subject: [PATCH 05/11] check if cmath useful, remove posix defines when using owcc --- cl_dll/cl_dll.h | 9 +++++++-- cl_dll/util_vector.h | 5 ++++- common/mathlib.h | 4 ++++ dlls/extdll.h | 4 ++++ wscript | 6 ++++++ 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/cl_dll/cl_dll.h b/cl_dll/cl_dll.h index 6ba3db67..232df68e 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/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/common/mathlib.h b/common/mathlib.h index afe44352..62f04d93 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/extdll.h b/dlls/extdll.h index eb8c37ec..1f932dc7 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -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/wscript b/wscript index 0e98480f..b01647df 100644 --- a/wscript +++ b/wscript @@ -249,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']) From 3ebf7f097bcf28c19c3cc76c6adfb571541f45a5 Mon Sep 17 00:00:00 2001 From: mittorn Date: Wed, 12 Feb 2020 15:35:25 +0700 Subject: [PATCH 06/11] server: fix include hell in animation.cpp --- dlls/animation.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dlls/animation.cpp b/dlls/animation.cpp index 6ebddc01..0efada33 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(x,y) (y = x) +#endif #pragma warning( disable : 4244 ) From 9a08968453412b7279498d813f7c0b94444e7fae Mon Sep 17 00:00:00 2001 From: mittorn Date: Wed, 12 Feb 2020 15:37:46 +0700 Subject: [PATCH 07/11] fix undefined symbols and conflicts on OpenWatcom --- cl_dll/hl/hl_baseentity.cpp | 1 + cl_dll/util.cpp | 4 ++-- dlls/nodes.cpp | 7 +++++-- dlls/util.cpp | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index 38978f6a..2e2ec2d6 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -347,3 +347,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/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/dlls/nodes.cpp b/dlls/nodes.cpp index c8e5649c..f5f399a0 100644 --- a/dlls/nodes.cpp +++ b/dlls/nodes.cpp @@ -42,10 +42,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 018a2f8e..e2e4292d 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1729,7 +1729,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 ) { From c6d793231c4044eb1e57b227e44b200dc1858228 Mon Sep 17 00:00:00 2001 From: mittorn Date: Wed, 12 Feb 2020 15:40:06 +0700 Subject: [PATCH 08/11] wscript: do not set install_path on dos target, set build task names to "server" and "client" --- cl_dll/wscript | 3 ++- dlls/wscript | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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/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, From 18127ef8488e679bbc2e33140ae30a253c74f181 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sun, 16 Feb 2020 11:19:30 +0300 Subject: [PATCH 09/11] Fix VectorCopy to work correctly with pointers again --- dlls/animation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/animation.cpp b/dlls/animation.cpp index 0efada33..10a1241d 100644 --- a/dlls/animation.cpp +++ b/dlls/animation.cpp @@ -63,7 +63,7 @@ typedef unsigned char byte; #include "animation.h" #include "scriptevent.h" #include "studio.h" -#define VectorCopy(x,y) (y = x) +#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];} #endif #pragma warning( disable : 4244 ) From 9f93606b500d971e077663f2db62c71258a21a17 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sat, 21 Mar 2020 18:45:13 +0500 Subject: [PATCH 10/11] Fix possible null pointer dereference. --- dlls/bullsquid.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/bullsquid.cpp b/dlls/bullsquid.cpp index 01c9e590..e035b0c9 100644 --- a/dlls/bullsquid.cpp +++ b/dlls/bullsquid.cpp @@ -536,6 +536,9 @@ void CBullsquid::HandleAnimEvent( MonsterEvent_t *pEvent ) { case BSQUID_AE_SPIT: { + if( m_hEnemy == 0 ) + return; + Vector vecSpitOffset; Vector vecSpitDir; From fa50aeeb0cacb313265632fad6a793e55eebfded Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sat, 21 Mar 2020 18:51:14 +0500 Subject: [PATCH 11/11] Fix wrong quotes. --- dlls/extdll.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/extdll.h b/dlls/extdll.h index 1f932dc7..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