From dfcf6bb3a2b4cd682ce50e0ab32992621f19fffe Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 11 Nov 2019 00:51:25 +0300 Subject: [PATCH 01/10] public: move build.h from engine sources --- public/build.h | 205 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 public/build.h diff --git a/public/build.h b/public/build.h new file mode 100644 index 00000000..96145d2b --- /dev/null +++ b/public/build.h @@ -0,0 +1,205 @@ +/* +build.h - compile-time build information +Copyright (C) 2019 a1batross + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +*/ +#pragma once +#ifndef BUILD_H +#define BUILD_H + +// All XASH_* macros set by this header are guaranteed to have positive value otherwise not defined + +// Any new define must be undefined at first +// You can generate #undef list below with this oneliner: +// $ cat build.h | sed 's/\t//g' | grep '^#define XASH' | awk '{ print $2 }' | sort | uniq | awk '{ print "#undef " $1 }' +// +// So in various buildscripts you can grep for ^#undef XASH and select only second word +// or in another oneliner: +// $ cat build.h | grep '^#undef XASH' | awk '{ print $2 }' + +#undef XASH_64BIT +#undef XASH_AMD64 +#undef XASH_ANDROID +#undef XASH_APPLE +#undef XASH_ARM +#undef XASH_ARM64 +#undef XASH_ARM_HARDFP +#undef XASH_ARM_SOFTFP +#undef XASH_ARMv4 +#undef XASH_ARMv5 +#undef XASH_ARMv6 +#undef XASH_ARMv7 +#undef XASH_BIG_ENDIAN +#undef XASH_BSD +#undef XASH_E2K +#undef XASH_EMSCRIPTEN +#undef XASH_FREEBSD +#undef XASH_IOS +#undef XASH_JS +#undef XASH_LINUX +#undef XASH_LITTLE_ENDIAN +#undef XASH_MINGW +#undef XASH_MIPS +#undef XASH_MOBILE_PLATFORM +#undef XASH_MSVC +#undef XASH_NETBSD +#undef XASH_OPENBSD +#undef XASH_WIN32 +#undef XASH_WIN64 +#undef XASH_X86 + +//================================================================ +// +// OPERATING SYSTEM DEFINES +// +//================================================================ +#if defined(_WIN32) + #define XASH_WIN32 1 + #if defined(__MINGW32__) + #define XASH_MINGW 1 + #elif defined(_MSC_VER) + #define XASH_MSVC 1 + #endif + + #if defined(_WIN64) + #define XASH_WIN64 1 + #endif +#elif defined(__linux__) + #define XASH_LINUX 1 + #if defined(__ANDROID__) + #define XASH_ANDROID 1 + #endif // defined(__ANDROID__) +#elif defined(__APPLE__) + #include + #define XASH_APPLE 1 + #if TARGET_OS_IOS + #define XASH_IOS 1 + #endif // TARGET_OS_IOS +#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) + #define XASH_BSD 1 + #if defined(__FreeBSD__) + #define XASH_FREEBSD 1 + #elif defined(__NetBSD__) + #define XASH_NETBSD 1 + #elif defined(__OpenBSD__) + #define XASH_OPENBSD 1 + #endif +#elif defined __EMSCRIPTEN__ + #define XASH_EMSCRIPTEN 1 +#else +#error "Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug" +#endif + +#if defined XASH_ANDROID || defined XASH_IOS + #define XASH_MOBILE_PLATFORM 1 +#endif + +//================================================================ +// +// ENDIANNESS DEFINES +// +//================================================================ + +#if defined(XASH_LITTLE_ENDIAN) && defined(XASH_BIG_ENDIAN) + #error "Both XASH_LITTLE_ENDIAN and XASH_BIG_ENDIAN are defined" +#endif + +#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 + #elif __BIG_ENDIAN__ + #define XASH_BIG_ENDIAN 1 + #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && defined(__ORDER_LITTLE_ENDIAN__) // some compilers define this + #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + #define XASH_BIG_ENDIAN 1 + #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + #define XASH_LITTLE_ENDIAN 1 + #else + #error "Unknown endianness!" + #endif + #else + #include + #if __BYTE_ORDER == __BIG_ENDIAN + #define XASH_BIG_ENDIAN 1 + #elif __BYTE_ORDER == __LITTLE_ENDIAN + #define XASH_LITTLE_ENDIAN 1 + #else + #error "Unknown endianness!" + #endif + #endif // !XASH_WIN32 +#endif + +//================================================================ +// +// CPU ARCHITECTURE DEFINES +// +//================================================================ +#if defined(__x86_64__) || defined(_M_X64) + #define XASH_64BIT 1 + #define XASH_AMD64 1 +#elif defined(__i386__) || defined(_X86_) || defined(_M_IX86) + #define XASH_X86 1 +#elif defined __aarch64__ + #define XASH_64BIT 1 + #define XASH_ARM64 1 +#elif defined __arm__ || defined _M_ARM + #if defined _M_ARM + // msvc can only armv7 ? + #define XASH_ARM 7 + #elif __ARM_ARCH == 7 || __ARM_ARCH_7__ + #define XASH_ARM 7 + #elif __ARM_ARCH == 6 || __ARM_ARCH_6__ || __ARM_ARCH_6J__ + #define XASH_ARM 6 + #elif __ARM_ARCH == 5 || __ARM_ARCH_5__ + #define XASH_ARM 5 + #elif __ARM_ARCH == 4 || __ARM_ARCH_4__ + #define XASH_ARM 4 + #else + #error "Unknown ARM" + #endif + + #if defined _M_ARM + #error "No WinMobile port yet! Need to determine which ARM float ABI msvc uses if applicable" + #endif + + #if defined __SOFTFP__ || __ARM_PCS_VFP == 0 + #define XASH_ARM_SOFTFP 1 + #else // __SOFTFP__ + #define XASH_ARM_HARDFP 1 + #endif // __SOFTFP__ +#elif defined __mips__ + #define XASH_MIPS 1 +#elif defined __EMSCRIPTEN__ + #define XASH_JS 1 +#elif defined __e2k__ + #define XASH_64BIT 1 + #define XASH_E2K 1 +#else + #error "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug" +#endif + +#if defined(XASH_WAF_DETECTED_64BIT) && !defined(XASH_64BIT) + #define XASH_64BIT 1 +#endif + +#if XASH_ARM == 7 + #define XASH_ARMv7 1 +#elif XASH_ARM == 6 + #define XASH_ARMv6 1 +#elif XASH_ARM == 5 + #define XASH_ARMv5 1 +#elif XASH_ARM == 4 + #define XASH_ARMv4 1 +#endif + +#endif // BUILD_H From c44d777016560ffe2165b573a279d438f8ee70b2 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 11 Nov 2019 01:04:03 +0300 Subject: [PATCH 02/10] public: build.h is under public domain now, so it can be added to any HLSDK --- public/build.h | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/public/build.h b/public/build.h index 96145d2b..6ace3e45 100644 --- a/public/build.h +++ b/public/build.h @@ -1,16 +1,33 @@ /* build.h - compile-time build information -Copyright (C) 2019 a1batross -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +This is free and unencumbered software released into the +public domain. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. +Anyone is free to copy, modify, publish, use, compile, sell, +or distribute this software, either in source code form or as +a compiled binary, for any purpose, commercial or +non-commercial, and by any means. + +In jurisdictions that recognize copyright laws, the author or +authors of this software dedicate any and all copyright +interest in the software to the public domain. We make this +dedication for the benefit of the public at large and to the +detriment of our heirs and successors. We intend this +dedication to be an overtact of relinquishment in perpetuity of +all present and future rights to this software under copyright +law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. + +For more information, please refer to https://unlicense.org */ #pragma once #ifndef BUILD_H From 8622cc945d6df18b13a80b203668cf4683e58367 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 11 Nov 2019 01:05:58 +0300 Subject: [PATCH 03/10] CMakeLists: remove legacy 64 postfix --- cl_dll/CMakeLists.txt | 4 ---- dlls/CMakeLists.txt | 3 --- 2 files changed, 7 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 57d52654..cde35d14 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -139,10 +139,6 @@ set_target_properties (${CLDLL_LIBRARY} PROPERTIES if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(CLDLL_NAME "client") - if(64BIT) - set(CLDLL_NAME "client64") - endif() - set_target_properties(${CLDLL_LIBRARY} PROPERTIES OUTPUT_NAME ${CLDLL_NAME} PREFIX "") diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 9baf9479..67a34e11 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -165,9 +165,6 @@ set_target_properties (${SVDLL_LIBRARY} PROPERTIES if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(SVDLL_NAME "${SERVER_LIBRARY_NAME}") - if(64BIT) - set(SVDLL_NAME "${SERVER_LIBRARY_NAME}64") - endif() set_target_properties(${SVDLL_LIBRARY} PROPERTIES OUTPUT_NAME ${SVDLL_NAME} From d59c169527433b5eb5b6fce3436479a0d1500833 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 11 Nov 2019 01:06:52 +0300 Subject: [PATCH 04/10] cmake: implement library naming for CMake --- CMakeLists.txt | 7 ++- cmake/LibraryNaming.cmake | 103 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 cmake/LibraryNaming.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ffae124c..03d3a004 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,10 @@ if(64BIT AND CMAKE_SIZEOF_VOID_P EQUAL 4) message(FATAL_ERROR "You enabled XASH_64BIT, but compiler can't create 64 bit code!") endif() +# Xash3D FWGS Library Naming Scheme compliance +# see documentation: https://github.com/FWGS/xash3d-fwgs/blob/master/Documentation/library-naming.md +include(LibraryNaming) + if(64BIT) message(STATUS "Building for 64 Bit") else() @@ -87,10 +91,11 @@ if(${CMAKE_VERSION} VERSION_LESS "3.0.2") endif() if(NOT MSVC) - add_compile_options(-Wempty-body) # GCC/Clang flag + #add_compile_options(-Wempty-body) # GCC/Clang flag add_compile_options(-Wreturn-type) # GCC/Clang flag endif() + if(BUILD_CLIENT) add_subdirectory(cl_dll) endif() diff --git a/cmake/LibraryNaming.cmake b/cmake/LibraryNaming.cmake new file mode 100644 index 00000000..faa7c53f --- /dev/null +++ b/cmake/LibraryNaming.cmake @@ -0,0 +1,103 @@ +include(CheckSymbolExists) + +# generated(see comments in public/build.h) +set(CMAKE_REQUIRED_INCLUDES "${CMAKE_SOURCE_DIR}/public/") +check_symbol_exists(XASH_64BIT "build.h" XASH_64BIT) +check_symbol_exists(XASH_AMD64 "build.h" XASH_AMD64) +check_symbol_exists(XASH_ANDROID "build.h" XASH_ANDROID) +check_symbol_exists(XASH_APPLE "build.h" XASH_APPLE) +check_symbol_exists(XASH_ARM "build.h" XASH_ARM) +check_symbol_exists(XASH_ARM64 "build.h" XASH_ARM64) +check_symbol_exists(XASH_ARM_HARDFP "build.h" XASH_ARM_HARDFP) +check_symbol_exists(XASH_ARM_SOFTFP "build.h" XASH_ARM_SOFTFP) +check_symbol_exists(XASH_ARMv4 "build.h" XASH_ARMv4) +check_symbol_exists(XASH_ARMv5 "build.h" XASH_ARMv5) +check_symbol_exists(XASH_ARMv6 "build.h" XASH_ARMv6) +check_symbol_exists(XASH_ARMv7 "build.h" XASH_ARMv7) +check_symbol_exists(XASH_BIG_ENDIAN "build.h" XASH_BIG_ENDIAN) +check_symbol_exists(XASH_BSD "build.h" XASH_BSD) +check_symbol_exists(XASH_E2K "build.h" XASH_E2K) +check_symbol_exists(XASH_EMSCRIPTEN "build.h" XASH_EMSCRIPTEN) +check_symbol_exists(XASH_FREEBSD "build.h" XASH_FREEBSD) +check_symbol_exists(XASH_IOS "build.h" XASH_IOS) +check_symbol_exists(XASH_JS "build.h" XASH_JS) +check_symbol_exists(XASH_LINUX "build.h" XASH_LINUX) +check_symbol_exists(XASH_LITTLE_ENDIAN "build.h" XASH_LITTLE_ENDIAN) +check_symbol_exists(XASH_MINGW "build.h" XASH_MINGW) +check_symbol_exists(XASH_MIPS "build.h" XASH_MIPS) +check_symbol_exists(XASH_MOBILE_PLATFORM "build.h" XASH_MOBILE_PLATFORM) +check_symbol_exists(XASH_MSVC "build.h" XASH_MSVC) +check_symbol_exists(XASH_NETBSD "build.h" XASH_NETBSD) +check_symbol_exists(XASH_OPENBSD "build.h" XASH_OPENBSD) +check_symbol_exists(XASH_WIN32 "build.h" XASH_WIN32) +check_symbol_exists(XASH_WIN64 "build.h" XASH_WIN64) +check_symbol_exists(XASH_X86 "build.h" XASH_X86) +unset(CMAKE_REQUIRED_INCLUDES) + +# engine/common/build.c +if(XASH_ANDROID) + set(BUILDOS "android") +elseif(XASH_WIN32 OR XASH_LINUX OR XASH_APPLE) + set(BUILDOS "") # no prefix for default OS +elseif(XASH_FREEBSD) + set(BUILDOS "freebsd") +elseif(XASH_NETBSD) + set(BUILDOS "netbsd") +elseif(XASH_OPENBSD) + set(BUILDOS "openbsd") +elseif(XASH_EMSCRIPTEN) + set(BUILDOS "emscripten") +else() + message(SEND_ERROR "Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug") +endif() + +if(XASH_AMD64) + set(BUILDARCH "amd64") +elseif(XASH_X86) + set(BUILDARCH "") +elseif(XASH_ARM64) + set(BUILDARCH "arm64") +elseif(XASH_ARM) + set(BUILDARCH "armv") + if(XASH_ARMv7) + set(BUILDARCH "${BUILDARCH}7") + elseif(XASH_ARMv6) + set(BUILDARCH "${BUILDARCH}6") + elseif(XASH_ARMv5) + set(BUILDARCH "${BUILDARCH}5") + elseif(XASH_ARMv4) + set(BUILDARCH "${BUILDARCH}4") + endif() + + if(XASH_ARM_HARDFP) + set(BUILDARCH "${BUILDARCH}hf") + else() + set(BUILDARCH "${BUILDARCH}l") + endif() +elseif(XASH_MIPS AND XASH_BIG_ENDIAN) + set(BUILDARCH "mips") +elseif(XASH_MIPS AND XASH_LITTLE_ENDIAN) + set(BUILDARCH "mipsel") +elseif(XASH_JS) + set(BUILDARCH "javascript") +elseif(XASH_E2K) + set(BUILDARCH "e2k") +else() + message(SEND_ERROR "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug") +endif() + +if(BUILDOS AND BUILDARCH) + set(POSTFIX "_${BUILDOS}_${BUILDARCH}") +elseif(BUILDARCH) + set(POSTFIX "_${BUILDARCH}") +else() + set(POSTFIX "") +endif() + +message(STATUS "Library postfix: " ${POSTFIX}) + +set(CMAKE_RELEASE_POSTFIX ${POSTFIX}) +set(CMAKE_DEBUG_POSTFIX ${POSTFIX}) +set(CMAKE_RELWITHDEBINFO_POSTFIX ${POSTFIX}) +set(CMAKE_MINSIZEREL_POSTFIX ${POSTFIX}) +set(CMAKE_POSTFIX ${POSTFIX}) From 13e17024cc5a01f6966fc9e01cd7c94ec4ad009a Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 11 Nov 2019 01:12:16 +0300 Subject: [PATCH 05/10] public: use unlicense statetemt from their website :) --- public/build.h | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/public/build.h b/public/build.h index 6ace3e45..9cb7e25b 100644 --- a/public/build.h +++ b/public/build.h @@ -1,33 +1,30 @@ /* build.h - compile-time build information -This is free and unencumbered software released into the -public domain. +This is free and unencumbered software released into the public domain. -Anyone is free to copy, modify, publish, use, compile, sell, -or distribute this software, either in source code form or as -a compiled binary, for any purpose, commercial or -non-commercial, and by any means. +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. -In jurisdictions that recognize copyright laws, the author or -authors of this software dedicate any and all copyright -interest in the software to the public domain. We make this -dedication for the benefit of the public at large and to the -detriment of our heirs and successors. We intend this -dedication to be an overtact of relinquishment in perpetuity of -all present and future rights to this software under copyright -law. +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. -For more information, please refer to https://unlicense.org +For more information, please refer to */ #pragma once #ifndef BUILD_H From 043e91866f3655755972712741b3bdb00b61fa96 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 11 Nov 2019 04:02:59 +0300 Subject: [PATCH 06/10] cmake: throw an error if ARM isn't detected --- cmake/LibraryNaming.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/LibraryNaming.cmake b/cmake/LibraryNaming.cmake index faa7c53f..22581078 100644 --- a/cmake/LibraryNaming.cmake +++ b/cmake/LibraryNaming.cmake @@ -67,6 +67,8 @@ elseif(XASH_ARM) set(BUILDARCH "${BUILDARCH}5") elseif(XASH_ARMv4) set(BUILDARCH "${BUILDARCH}4") + else() + message(SEND_ERROR "Unknown ARM") endif() if(XASH_ARM_HARDFP) @@ -86,7 +88,9 @@ else() message(SEND_ERROR "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug") endif() -if(BUILDOS AND BUILDARCH) +if(BUILDOS STREQUAL "android") + set(POSTFIX "") # force disable for Android, as Android ports aren't distributed in normal way and doesn't follow library naming +elif(BUILDOS AND BUILDARCH) set(POSTFIX "_${BUILDOS}_${BUILDARCH}") elseif(BUILDARCH) set(POSTFIX "_${BUILDARCH}") From 94d4c6a0e359e92f9d10208e219106ade1d4ea96 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 11 Nov 2019 04:03:25 +0300 Subject: [PATCH 07/10] wscript: enable library naming for Waf --- scripts/waifulib/library_naming.py | 127 +++++++++++++++++++++++++++++ wscript | 2 +- 2 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 scripts/waifulib/library_naming.py diff --git a/scripts/waifulib/library_naming.py b/scripts/waifulib/library_naming.py new file mode 100644 index 00000000..77dfa6df --- /dev/null +++ b/scripts/waifulib/library_naming.py @@ -0,0 +1,127 @@ +#! /usr/bin/env python +# Copyright 2019 (C) a1batross + +from waflib import Configure, Errors, Utils + +# TODO: make generic +CHECK_SYMBOL_EXISTS_FRAGMENT = ''' +#include "build.h" + +int main(int argc, char** argv) +{ + (void)argv; +#ifndef %s + return ((int*)(&%s))[argc]; +#else + (void)argc; + return 0; +#endif +} +''' + +DEFINES = [ +'XASH_64BIT', +'XASH_AMD64', +'XASH_ANDROID', +'XASH_APPLE', +'XASH_ARM', +'XASH_ARM64', +'XASH_ARM_HARDFP', +'XASH_ARM_SOFTFP', +'XASH_ARMv4', +'XASH_ARMv5', +'XASH_ARMv6', +'XASH_ARMv7', +'XASH_BIG_ENDIAN', +'XASH_BSD', +'XASH_E2K', +'XASH_EMSCRIPTEN', +'XASH_FREEBSD', +'XASH_IOS', +'XASH_JS', +'XASH_LINUX', +'XASH_LITTLE_ENDIAN', +'XASH_MINGW', +'XASH_MIPS', +'XASH_MOBILE_PLATFORM', +'XASH_MSVC', +'XASH_NETBSD', +'XASH_OPENBSD', +'XASH_WIN32', +'XASH_WIN64', +'XASH_X86' +] + +def configure(conf): + conf.env.stash() + conf.start_msg('Determining library postfix') + tests = map(lambda x: { + 'fragment': CHECK_SYMBOL_EXISTS_FRAGMENT % (x, x), + 'includes': [conf.path.find_node('public/').abspath()], + 'define_name': x }, DEFINES ) + + conf.multicheck(*tests, msg = '', mandatory = False, quiet = True) + + # engine/common/build.c + if conf.env.XASH_ANDROID: + buildos = "android" + elif conf.env.XASH_WIN32 or conf.env.XASH_LINUX or conf.env.XASH_APPLE: + buildos = "" # no prefix for default OS + elif conf.env.XASH_FREEBSD: + buildos = "freebsd" + elif conf.env.XASH_NETBSD: + buildos = "netbsd" + elif conf.env.XASH_OPENBSD: + buildos = "openbsd" + elif conf.env.XASH_EMSCRIPTEN: + buildos = "emscripten" + else: + conf.fatal("Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug") + + if conf.env.XASH_AMD64: + buildarch = "amd64" + elif conf.env.XASH_X86: + buildarch = "" + elif conf.env.XASH_ARM64: + buildarch = "arm64" + elif conf.env.XASH_ARM: + buildarch = "armv" + if conf.env.XASH_ARMv7: + buildarch += "7" + elif conf.env.XASH_ARMv6: + buildarch += "6" + elif conf.env.XASH_ARMv5: + buildarch += "5" + elif conf.env.XASH_ARMv4: + buildarch += "4" + else: + raise conf.fatal('Unknown ARM') + + if conf.env.XASH_ARM_HARDFP: + buildarch += "hf" + else: + buildarch += "l" + elif conf.env.XASH_MIPS and conf.env.XASH_BIG_ENDIAN: + buildarch = "mips" + elif conf.env.XASH_MIPS and conf.env.XASH_LITTLE_ENDIAN: + buildarch = "mipsel" + elif conf.env.XASH_JS: + buildarch = "javascript" + 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") + + conf.env.revert() + + if buildos == 'android': + # force disable for Android, as Android ports aren't distributed in normal way and doesn't follow library naming + conf.env.POSTFIX = '' + elif buildos != '' and buildarch != '': + conf.env.POSTFIX = '_%s_%s' % (buildos,buildarch) + elif buildarch != '': + conf.env.POSTFIX = '_%s' % buildarch + else: + conf.env.POSTFIX = '' + + conf.end_msg(conf.env.POSTFIX) diff --git a/wscript b/wscript index af830e72..3a885ac9 100644 --- a/wscript +++ b/wscript @@ -87,7 +87,7 @@ def configure(conf): conf.env.MSVC_TARGETS = ['x86'] # explicitly request x86 target for MSVC if sys.platform == 'win32': conf.load('msvc msdev') - conf.load('xcompile compiler_c compiler_cxx strip_on_install') + conf.load('xcompile compiler_c compiler_cxx strip_on_install library_naming') try: conf.env.CC_VERSION[0] From b4d3b5d8beea2a48e97d993e852cfe2103a83b21 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 11 Nov 2019 04:07:51 +0300 Subject: [PATCH 08/10] wscript: enable library naming --- cl_dll/wscript | 2 +- dlls/wscript | 2 +- wscript | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cl_dll/wscript b/cl_dll/wscript index 02a9d530..b45242d5 100644 --- a/cl_dll/wscript +++ b/cl_dll/wscript @@ -60,7 +60,7 @@ def build(bld): bld.shlib( source = source, - target = 'client', + target = 'client' + bld.env.POSTFIX, features = 'c cxx', includes = includes, defines = defines, diff --git a/dlls/wscript b/dlls/wscript index e5268e05..24e93e71 100644 --- a/dlls/wscript +++ b/dlls/wscript @@ -68,7 +68,7 @@ def build(bld): bld.shlib( source = source, - target = bld.env.SERVER_NAME, + target = bld.env.SERVER_NAME + bld.env.POSTFIX, features = 'c cxx', includes = includes, defines = defines, diff --git a/wscript b/wscript index 3a885ac9..15c4b175 100644 --- a/wscript +++ b/wscript @@ -87,7 +87,7 @@ def configure(conf): conf.env.MSVC_TARGETS = ['x86'] # explicitly request x86 target for MSVC if sys.platform == 'win32': conf.load('msvc msdev') - conf.load('xcompile compiler_c compiler_cxx strip_on_install library_naming') + conf.load('xcompile compiler_c compiler_cxx strip_on_install') try: conf.env.CC_VERSION[0] @@ -122,7 +122,7 @@ def configure(conf): else: conf.env.BIT32_ALLOW64 = True conf.env.BIT32_MANDATORY = not conf.env.BIT32_ALLOW64 - conf.load('force_32bit') + conf.load('force_32bit library_naming') linker_flags = { 'common': { From b8825c2039d91670abc7415733111e89e7ea2e4f Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sat, 16 Nov 2019 13:54:30 +0500 Subject: [PATCH 09/10] Fix some potential troubles. Comment some useless code. --- cl_dll/MOTD.cpp | 4 ++-- cl_dll/StudioModelRenderer.cpp | 4 ++-- cl_dll/cdll_int.cpp | 2 +- cl_dll/demo.cpp | 4 ++-- cl_dll/geiger.cpp | 2 +- cl_dll/health.cpp | 5 +++-- cl_dll/hl/hl_weapons.cpp | 2 +- cl_dll/message.cpp | 2 +- cl_dll/saytext.cpp | 2 +- cl_dll/view.cpp | 2 +- dlls/apache.cpp | 4 ++-- dlls/combat.cpp | 4 ++-- dlls/func_break.cpp | 4 ++-- dlls/hgrunt.cpp | 12 ++++++------ dlls/hornet.cpp | 4 ++-- dlls/islave.cpp | 11 +++++++---- dlls/monsters.cpp | 28 ++++++++++++++++------------ dlls/nihilanth.cpp | 4 ++-- dlls/nodes.cpp | 4 ++-- dlls/osprey.cpp | 15 ++++++++++----- dlls/plats.cpp | 2 +- dlls/sound.cpp | 4 ++-- dlls/squeakgrenade.cpp | 4 ++-- dlls/talkmonster.cpp | 23 +++++++++++++---------- pm_shared/pm_debug.c | 6 +++--- 25 files changed, 87 insertions(+), 71 deletions(-) diff --git a/cl_dll/MOTD.cpp b/cl_dll/MOTD.cpp index 7059948a..7947a15f 100644 --- a/cl_dll/MOTD.cpp +++ b/cl_dll/MOTD.cpp @@ -86,7 +86,7 @@ int CHudMOTD::Draw( float fTime ) ypos_r = ROW_RANGE_MIN; height = ROW_RANGE_MAX; } - int ymax = ypos + height; + // int ymax = ypos + height; if( xmax > ScreenWidth - 30 ) xmax = ScreenWidth - 30; gHUD.DrawDarkRectangle( xpos - 5, ypos_r - 5, xmax - xpos + 10, height + 10 ); while( *ch ) @@ -157,7 +157,7 @@ int CHudMOTD::MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf ) if( length > m_iMaxLength ) { m_iMaxLength = length; - length = 0; + // length = 0; } m_bShow = true; } diff --git a/cl_dll/StudioModelRenderer.cpp b/cl_dll/StudioModelRenderer.cpp index 5350ad10..1994c2a7 100644 --- a/cl_dll/StudioModelRenderer.cpp +++ b/cl_dll/StudioModelRenderer.cpp @@ -684,9 +684,9 @@ void CStudioModelRenderer::StudioFxTransform( cl_entity_t *ent, float transform[ else if( gEngfuncs.pfnRandomLong( 0, 49 ) == 0 ) { float offset; - int axis = gEngfuncs.pfnRandomLong(0,1); + /*int axis = gEngfuncs.pfnRandomLong(0,1); if( axis == 1 ) // Choose between x & z - axis = 2; + axis = 2;*/ offset = gEngfuncs.pfnRandomFloat( -10.0f, 10.0f ); transform[gEngfuncs.pfnRandomLong( 0, 2 )][3] += offset; } diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index 45bbcd67..29edfbde 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -124,7 +124,7 @@ HUD_ConnectionlessPacket int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ) { // Parse stuff from args - int max_buffer_size = *response_buffer_size; + // int max_buffer_size = *response_buffer_size; // Zero it out since we aren't going to respond. // If we wanted to response, we'd write data into response_buffer diff --git a/cl_dll/demo.cpp b/cl_dll/demo.cpp index f114ead0..63e333be 100644 --- a/cl_dll/demo.cpp +++ b/cl_dll/demo.cpp @@ -88,12 +88,12 @@ void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer ) g_demosniperorg[1] = *(float *)&buffer[i]; i += sizeof(float); g_demosniperorg[2] = *(float *)&buffer[i]; - i += sizeof(float); + // i += sizeof(float); } break; case TYPE_ZOOM: g_demozoom = *(float *)&buffer[i]; - i += sizeof(float); + // i += sizeof(float); break; default: gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" ); diff --git a/cl_dll/geiger.cpp b/cl_dll/geiger.cpp index 339c8ee1..89d2b951 100644 --- a/cl_dll/geiger.cpp +++ b/cl_dll/geiger.cpp @@ -66,7 +66,7 @@ int CHudGeiger::Draw( float flTime ) int pct; float flvol = 0.0f; //int rg[3]; - int i; + int i = 0; if( m_iGeigerRange < 1000 && m_iGeigerRange > 0 ) { diff --git a/cl_dll/health.cpp b/cl_dll/health.cpp index 6540671e..e14182b8 100644 --- a/cl_dll/health.cpp +++ b/cl_dll/health.cpp @@ -152,13 +152,14 @@ int CHudHealth::MsgFunc_Damage( const char *pszName, int iSize, void *pbuf ) // Green <-> Yellow <-> Red ramp void CHudHealth::GetPainColor( int &r, int &g, int &b ) { +#if 0 int iHealth = m_iHealth; if( iHealth > 25 ) iHealth -= 25; else if( iHealth < 0 ) iHealth = 0; -#if 0 + g = iHealth * 255 / 100; r = 255 - g; b = 0; @@ -461,7 +462,7 @@ void CHudHealth::UpdateTiles( float flTime, long bitsDamage ) if( pdmg->y ) pdmg->y -= giDmgHeight; } - pdmg = &m_dmg[i]; + // pdmg = &m_dmg[i]; } } diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 63e6f6d8..f305f321 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -307,7 +307,7 @@ Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecD // get circular gaussian spread x = UTIL_SharedRandomFloat( shared_rand + iShot, -0.5f, 0.5f ) + UTIL_SharedRandomFloat( shared_rand + ( 1 + iShot ) , -0.5f, 0.5f ); y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5f, 0.5f ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5f, 0.5f ); - z = x * x + y * y; + // z = x * x + y * y; } } diff --git a/cl_dll/message.cpp b/cl_dll/message.cpp index 15e62188..29834a13 100644 --- a/cl_dll/message.cpp +++ b/cl_dll/message.cpp @@ -352,7 +352,7 @@ int CHudMessage::Draw( float fTime ) // Assume m_parms.time contains last time if( m_pMessages[i] ) { - pMessage = m_pMessages[i]; + // pMessage = m_pMessages[i]; if( m_startTime[i] > gHUD.m_flTime ) m_startTime[i] = gHUD.m_flTime + m_parms.time - m_startTime[i] + 0.2f; // Server takes 0.2 seconds to spawn, adjust for this } diff --git a/cl_dll/saytext.cpp b/cl_dll/saytext.cpp index b084f44b..bf8eca80 100644 --- a/cl_dll/saytext.cpp +++ b/cl_dll/saytext.cpp @@ -259,7 +259,7 @@ void CHudSayText::EnsureTextFitsInOneLineAndWrapIfHaveTo( int line ) if( !last_break ) last_break = x - 1; - x = last_break; + // x = last_break; // find an empty string slot int j; diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index f67a994d..9ce6208e 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -491,7 +491,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) } else { - waterEntity = 0; // Don't need this in software + // waterEntity = 0; // Don't need this in software } VectorCopy( pparams->vieworg, point ); diff --git a/dlls/apache.cpp b/dlls/apache.cpp index a863e3c2..e69d72e9 100644 --- a/dlls/apache.cpp +++ b/dlls/apache.cpp @@ -717,9 +717,9 @@ void CApache::Flight( void ) if( pitch == 100.0f ) pitch = 101.0f; - float flVol = ( m_flForce / 100.0f ) + 0.1f; + /*float flVol = ( m_flForce / 100.0f ) + 0.1f; if( flVol > 1.0f ) - flVol = 1.0f; + flVol = 1.0f;*/ EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_rotor2.wav", 1.0f, 0.3f, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch ); } diff --git a/dlls/combat.cpp b/dlls/combat.cpp index c6ab3efe..df079af7 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -459,10 +459,10 @@ Activity CBaseMonster::GetDeathActivity( void ) Activity CBaseMonster::GetSmallFlinchActivity( void ) { Activity flinchActivity; - BOOL fTriedDirection; + // BOOL fTriedDirection; //float flDot; - fTriedDirection = FALSE; + // fTriedDirection = FALSE; UTIL_MakeVectors( pev->angles ); //flDot = DotProduct( gpGlobals->v_forward, g_vecAttackDir * -1.0f ); diff --git a/dlls/func_break.cpp b/dlls/func_break.cpp index 27324260..98432d06 100644 --- a/dlls/func_break.cpp +++ b/dlls/func_break.cpp @@ -710,11 +710,11 @@ void CBreakable::Die( void ) WRITE_BYTE( cFlag ); MESSAGE_END(); - float size = pev->size.x; + /*float size = pev->size.x; if( size < pev->size.y ) size = pev->size.y; if( size < pev->size.z ) - size = pev->size.z; + size = pev->size.z;*/ // !!! HACK This should work! // Build a box above the entity that looks like an 8 pixel high sheet diff --git a/dlls/hgrunt.cpp b/dlls/hgrunt.cpp index bcb71005..7f7e39e5 100644 --- a/dlls/hgrunt.cpp +++ b/dlls/hgrunt.cpp @@ -423,13 +423,13 @@ BOOL CHGrunt::CheckMeleeAttack1( float flDot, float flDist ) { return FALSE; } - } - if( flDist <= 64.0f && flDot >= 0.7f && - pEnemy->Classify() != CLASS_ALIEN_BIOWEAPON && - pEnemy->Classify() != CLASS_PLAYER_BIOWEAPON ) - { - return TRUE; + if( flDist <= 64.0f && flDot >= 0.7f && + pEnemy->Classify() != CLASS_ALIEN_BIOWEAPON && + pEnemy->Classify() != CLASS_PLAYER_BIOWEAPON ) + { + return TRUE; + } } return FALSE; } diff --git a/dlls/hornet.cpp b/dlls/hornet.cpp index 6fc79aa7..782e1a27 100644 --- a/dlls/hornet.cpp +++ b/dlls/hornet.cpp @@ -95,9 +95,9 @@ void CHornet::Spawn( void ) SetTouch( &CHornet::DieTouch ); SetThink( &CHornet::StartTrack ); - edict_t *pSoundEnt = pev->owner; + /*edict_t *pSoundEnt = pev->owner; if( !pSoundEnt ) - pSoundEnt = edict(); + pSoundEnt = edict();*/ if( !FNullEnt( pev->owner ) && ( pev->owner->v.flags & FL_CLIENT ) ) { diff --git a/dlls/islave.cpp b/dlls/islave.cpp index f66a57aa..51883be3 100644 --- a/dlls/islave.cpp +++ b/dlls/islave.cpp @@ -639,10 +639,13 @@ Schedule_t *CISlave::GetSchedule( void ) ASSERT( pSound != NULL ); - if( pSound && ( pSound->m_iType & bits_SOUND_DANGER ) ) - return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND ); - if( pSound->m_iType & bits_SOUND_COMBAT ) - m_afMemory |= bits_MEMORY_PROVOKED; + if( pSound ) + { + if( pSound->m_iType & bits_SOUND_DANGER ) + return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND ); + if( pSound->m_iType & bits_SOUND_COMBAT ) + m_afMemory |= bits_MEMORY_PROVOKED; + } } switch( m_MonsterState ) diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index 72eb331d..e14dbace 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -262,7 +262,8 @@ void CBaseMonster::Listen( void ) } //iSound = g_pSoundEnt->m_SoundPool[iSound].m_iNext; - iSound = pCurrentSound->m_iNext; + if( pCurrentSound ) + iSound = pCurrentSound->m_iNext; } } @@ -431,18 +432,21 @@ CSound *CBaseMonster::PBestSound( void ) { pSound = CSoundEnt::SoundPointerForIndex( iThisSound ); - if( pSound && pSound->FIsSound() ) + if( pSound ) { - flDist = ( pSound->m_vecOrigin - EarPosition() ).Length(); - - if( flDist < flBestDist ) + if( pSound->FIsSound() ) { - iBestSound = iThisSound; - flBestDist = flDist; - } - } + flDist = ( pSound->m_vecOrigin - EarPosition() ).Length(); - iThisSound = pSound->m_iNextAudible; + if( flDist < flBestDist ) + { + iBestSound = iThisSound; + flBestDist = flDist; + } + } + + iThisSound = pSound->m_iNextAudible; + } } if( iBestSound >= 0 ) { @@ -2367,7 +2371,7 @@ BOOL CBaseMonster::BuildNearestRoute( Vector vecThreat, Vector vecViewOffset, fl // try to actually get there if( BuildRoute( node.m_vecOrigin, bits_MF_TO_LOCATION, NULL ) ) { - flMaxDist = flDist; + // flMaxDist = flDist; m_vecMoveGoal = node.m_vecOrigin; return TRUE; // UNDONE: keep looking for something closer! } @@ -3278,7 +3282,7 @@ BOOL CBaseMonster::BBoxFlat( void ) { return FALSE; } - flLength = flLength2; + // flLength = flLength2; return TRUE; } diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index 5a789f2b..29e1073e 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -944,10 +944,10 @@ void CNihilanth::Flight( void ) m_velocity.y += gpGlobals->v_up.y * m_flForce; m_velocity.z += gpGlobals->v_up.z * m_flForce; - float flSpeed = m_velocity.Length(); + /*float flSpeed = m_velocity.Length(); float flDir = DotProduct( Vector( gpGlobals->v_forward.x, gpGlobals->v_forward.y, 0 ), Vector( m_velocity.x, m_velocity.y, 0 ) ); if( flDir < 0 ) - flSpeed = -flSpeed; + flSpeed = -flSpeed;*/ //float flDist = DotProduct( m_posDesired - vecEst, gpGlobals->v_forward ); diff --git a/dlls/nodes.cpp b/dlls/nodes.cpp index c8d6296c..c8e5649c 100644 --- a/dlls/nodes.cpp +++ b/dlls/nodes.cpp @@ -2533,7 +2533,7 @@ int CGraph::FLoadGraph( const char *szMapName ) if( length < 0 ) goto ShortFile; memcpy( m_pHashLinks, pMemFile, sizeof(short) * m_nHashLinks ); - pMemFile += sizeof(short) * m_nHashLinks; + // pMemFile += sizeof(short) * m_nHashLinks; // Set the graph present flag, clear the pointers set flag // @@ -3641,7 +3641,7 @@ void CNodeViewer::Spawn() int start = 0; int end; do{ - end = m_nVisited; + // end = m_nVisited; // ALERT( at_console, "%d :", m_nVisited ); for( end = m_nVisited; start < end; start++ ) { diff --git a/dlls/osprey.cpp b/dlls/osprey.cpp index 8cd8ed1e..670ad3b7 100644 --- a/dlls/osprey.cpp +++ b/dlls/osprey.cpp @@ -384,13 +384,18 @@ void COsprey::FlyThink( void ) if( gpGlobals->time > m_startTime + m_dTime ) { - if( m_pGoalEnt->pev->speed == 0 ) + if( m_pGoalEnt ) { - SetThink( &COsprey::DeployThink ); + if( m_pGoalEnt->pev->speed == 0 ) + { + SetThink( &COsprey::DeployThink ); + } + + do{ + m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_pGoalEnt->pev->target ) ) ); + } while( m_pGoalEnt && m_pGoalEnt->pev->speed < 400 && !HasDead() ); } - do{ - m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_pGoalEnt->pev->target ) ) ); - } while( m_pGoalEnt->pev->speed < 400 && !HasDead() ); + UpdateGoal(); } diff --git a/dlls/plats.cpp b/dlls/plats.cpp index d74129e7..0f2dbe70 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -1750,7 +1750,7 @@ void CFuncTrackChange::Find( void ) else { ALERT( at_error, "Can't find train for track change! %s\n", STRING( m_trainName ) ); - target = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_trainName ) ); + // target = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_trainName ) ); } } else diff --git a/dlls/sound.cpp b/dlls/sound.cpp index 51f37fbb..c5061da9 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -280,7 +280,7 @@ void CAmbientGeneric::RampThink( void ) if( pitch < m_dpv.pitchstart ) { - pitch = m_dpv.pitchstart; + // pitch = m_dpv.pitchstart; m_dpv.spindown = 0; // done with ramp down // shut sound off @@ -324,7 +324,7 @@ void CAmbientGeneric::RampThink( void ) if( vol < m_dpv.volstart ) { - vol = m_dpv.volstart; + // vol = m_dpv.volstart; m_dpv.fadeout = 0; // done with ramp down // shut sound off diff --git a/dlls/squeakgrenade.cpp b/dlls/squeakgrenade.cpp index f6e2d636..7e8a9d92 100644 --- a/dlls/squeakgrenade.cpp +++ b/dlls/squeakgrenade.cpp @@ -266,9 +266,9 @@ void CSqueakGrenade::HuntThink( void ) } // higher pitch as squeeker gets closer to detonation time - float flpitch = 155.0f - 60.0f * ( ( m_flDie - gpGlobals->time ) / SQUEEK_DETONATE_DELAY ); + /*float flpitch = 155.0f - 60.0f * ( ( m_flDie - gpGlobals->time ) / SQUEEK_DETONATE_DELAY ); if( flpitch < 80.0f ) - flpitch = 80.0f; + flpitch = 80.0f;*/ if( m_hEnemy != 0 ) { diff --git a/dlls/talkmonster.cpp b/dlls/talkmonster.cpp index 295a3260..581d87a9 100644 --- a/dlls/talkmonster.cpp +++ b/dlls/talkmonster.cpp @@ -494,18 +494,21 @@ void CTalkMonster::RunTask( Task_t *pTask ) if( pTask->iTask == TASK_TLK_CLIENT_STARE ) { - // fail out if the player looks away or moves away. - if( ( pPlayer->v.origin - pev->origin ).Length2D() > TLK_STARE_DIST ) + if( pPlayer ) { - // player moved away. - TaskFail(); - } + // fail out if the player looks away or moves away. + if( ( pPlayer->v.origin - pev->origin ).Length2D() > TLK_STARE_DIST ) + { + // player moved away. + TaskFail(); + } - UTIL_MakeVectors( pPlayer->v.angles ); - if( UTIL_DotPoints( pPlayer->v.origin, pev->origin, gpGlobals->v_forward ) < m_flFieldOfView ) - { - // player looked away - TaskFail(); + UTIL_MakeVectors( pPlayer->v.angles ); + if( UTIL_DotPoints( pPlayer->v.origin, pev->origin, gpGlobals->v_forward ) < m_flFieldOfView ) + { + // player looked away + TaskFail(); + } } } diff --git a/pm_shared/pm_debug.c b/pm_shared/pm_debug.c index fbe1e288..a11e0516 100644 --- a/pm_shared/pm_debug.c +++ b/pm_shared/pm_debug.c @@ -289,7 +289,7 @@ void PM_ViewEntity( void ) int i; pmtrace_t trace; int pcolor = 77; - float fup; + // float fup; #if 0 if ( !pm_showclip.value ) @@ -300,9 +300,9 @@ void PM_ViewEntity( void ) VectorCopy( pmove->origin, origin); - fup = 0.5f * ( pmove->player_mins[pmove->usehull][2] + pmove->player_maxs[pmove->usehull][2] ); + /*fup = 0.5f * ( pmove->player_mins[pmove->usehull][2] + pmove->player_maxs[pmove->usehull][2] ); fup += pmove->view_ofs[2]; - fup -= 4; + fup -= 4;*/ for (i = 0; i < 3; i++) { From 52b067fd4fda1288045ccecfd169e8cf81895830 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sat, 16 Nov 2019 14:29:09 +0500 Subject: [PATCH 10/10] Fix possible null pointer dereference. --- dlls/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/sound.cpp b/dlls/sound.cpp index c5061da9..688b4016 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -1762,7 +1762,7 @@ void CSpeaker::Precache( void ) } void CSpeaker::SpeakerThink( void ) { - const char* szSoundFile = NULL; + const char* szSoundFile = ""; float flvolume = pev->health * 0.1f; float flattenuation = 0.3f; int flags = 0;