From 1e8180f5ad78580c6cc3a433931762c63e5af79c Mon Sep 17 00:00:00 2001 From: s1lentq Date: Mon, 18 Jul 2016 04:09:31 +0700 Subject: [PATCH] Added gradle task `buildFixes` for faster building. --- README.md | 5 + regamedll/build.gradle | 18 +++ regamedll/common/mathlib.h | 53 ++++++-- regamedll/common/qlimits.h | 39 ++++++ regamedll/dlls/extdll.h | 12 +- regamedll/dlls/player.cpp | 2 +- regamedll/engine/common.h | 108 ++------------- regamedll/extra/cssdk/common/mathlib.h | 128 +++++++++++------- regamedll/extra/cssdk/dlls/extdef.h | 22 +++ regamedll/extra/cssdk/dlls/extdll.h | 5 +- regamedll/extra/cssdk/dlls/regamedll_common.h | 95 +++++++++++++ .../extra/cssdk/dlls/regamedll_interfaces.h | 4 + regamedll/extra/cssdk/engine/cmd_rehlds.h | 3 - regamedll/extra/cssdk/engine/common_rehlds.h | 22 +-- .../extra/cssdk/game_shared/shared_util.h | 4 +- regamedll/extra/cssdk/public/asmlib.h | 123 +++++++++++++++++ regamedll/extra/cssdk/public/tier0/platform.h | 41 ++---- regamedll/game_shared/shared_util.h | 11 +- regamedll/public/regamedll/regamedll_common.h | 95 +++++++++++++ regamedll/regamedll/dlls.h | 1 - regamedll/regamedll/engine.h | 1 + regamedll/regamedll/precompiled.h | 2 + regamedll/regamedll/regamedll_debug.h | 2 + 23 files changed, 563 insertions(+), 233 deletions(-) create mode 100644 regamedll/common/qlimits.h create mode 100644 regamedll/extra/cssdk/dlls/regamedll_common.h create mode 100644 regamedll/extra/cssdk/public/asmlib.h create mode 100644 regamedll/public/regamedll/regamedll_common.h diff --git a/README.md b/README.md index 3f245c6e..12112e26 100644 --- a/README.md +++ b/README.md @@ -66,10 +66,15 @@ icc (ICC) 15.0.1 20141023 ### Building On Windows:
gradlew --max-workers=1 clean buildRelease
+* For faster building without unit tests use this:exclamation: +
gradlew --max-workers=1 clean buildFixes
On Linux:
./gradlew --max-workers=1 clean buildRelease
+* For faster building without unit tests use this:exclamation: +
./gradlew --max-workers=1 clean buildFixes
+ Compiled binaries will be placed in the build/binaries/ directory ### Credits diff --git a/regamedll/build.gradle b/regamedll/build.gradle index 19287ecb..ddca54a8 100644 --- a/regamedll/build.gradle +++ b/regamedll/build.gradle @@ -317,6 +317,24 @@ task buildRelease { } } +task buildFixes { + dependsOn binaries.withType(SharedLibraryBinarySpec).matching { + SharedLibraryBinarySpec blib -> blib.buildable && blib.buildType.name == 'release' && blib.flavor.name == 'regamedllFixes' && blib.component.name == 'regamedll_mp_gamedll' + } +} + +gradle.taskGraph.whenReady { graph -> + if (!graph.hasTask(buildFixes)) { + return; + } + + // skip all tasks with the matched substrings in the name like "test" + def tasks = graph.getAllTasks(); + tasks.findAll { it.name.toLowerCase().contains("test") }.each { task -> + task.enabled = false; + } +} + task prepareDevEnvTests { def regamedllTests = new File(project.projectDir, '_dev/testDemos') diff --git a/regamedll/common/mathlib.h b/regamedll/common/mathlib.h index c213973c..931897a6 100644 --- a/regamedll/common/mathlib.h +++ b/regamedll/common/mathlib.h @@ -26,11 +26,7 @@ * */ -#ifndef MATHLIB_H -#define MATHLIB_H -#ifdef _WIN32 #pragma once -#endif #ifdef PLAY_GAMEDLL @@ -59,15 +55,41 @@ typedef union DLONG_u #define M_PI 3.14159265358979323846 -template -T Q_min(T a, T b) { return (a < b) ? a : b; } +#ifdef __cplusplus +#ifdef min +#undef min +#endif + +#ifdef max +#undef max +#endif + +#ifdef clamp +#undef clamp +#endif template -T Q_max(T a, T b) { return (a > b) ? a : b; } +T min(T a, T b) { return (a < b) ? a : b; } + +template +T max(T a, T b) { return (a > b) ? a : b; } template T clamp(T a, T min, T max) { return (a > max) ? max : (a < min) ? min : a; } +#else // __cplusplus + +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val))) +#endif // __cplusplus + // bitwise operators templates template::type> inline T operator~ (T a) { return (T)~(type)a; } @@ -84,9 +106,22 @@ inline T& operator&= (T& a, T b) { return (T&)((type&)a &= (type)b); } template::type> inline T& operator^= (T& a, T b) { return (T&)((type&)a ^= (type)b); } +inline double M_sqrt(int value) { + return sqrt(value); +} + +inline float M_sqrt(float value) { + return _mm_cvtss_f32(_mm_sqrt_ss(_mm_load_ss(&value))); +} + +inline double M_sqrt(double value) { + double ret; + auto v = _mm_load_sd(&value); + _mm_store_sd(&ret, _mm_sqrt_sd(v, v)); + return ret; +} + #define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];} #define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];} #define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];} #define VectorClear(a) {(a)[0]=0.0;(a)[1]=0.0;(a)[2]=0.0;} - -#endif // MATHLIB_H diff --git a/regamedll/common/qlimits.h b/regamedll/common/qlimits.h new file mode 100644 index 00000000..3fad4036 --- /dev/null +++ b/regamedll/common/qlimits.h @@ -0,0 +1,39 @@ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ========== +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef QLIMITS_H +#define QLIMITS_H + +#if defined( _WIN32 ) +#pragma once +#endif + +// DATA STRUCTURE INFO + +#define MAX_NUM_ARGVS 50 + +// SYSTEM INFO +#define MAX_QPATH 64 // max length of a game pathname +#define MAX_OSPATH 260 // max length of a filesystem pathname + +#define ON_EPSILON 0.1 // point on plane side epsilon + +#define MAX_LIGHTSTYLE_INDEX_BITS 6 +#define MAX_LIGHTSTYLES (1< #include #include - #endif // _WIN32 // Misc C-runtime library headers @@ -82,5 +77,4 @@ typedef float vec_t; // needed before including progdefs.h #include "eiface.h" // Shared header between the client DLL and the game DLLs #include "cdll_dll.h" - -#endif // EXTDLL_H +#include "extdef.h" diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 98e8205c..0cfd8f06 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -597,7 +597,7 @@ void CBasePlayer::Radio(const char *msg_id, const char *msg_verbose, short pitch Place playerPlace = TheNavAreaGrid.GetPlace(&pev->origin); const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); - for (BotPhraseList::const_iterator iter = placeList->begin(); iter != placeList->end(); ++iter) + for (auto iter = placeList->begin(); iter != placeList->end(); ++iter) { if ((*iter)->GetID() == playerPlace) { diff --git a/regamedll/engine/common.h b/regamedll/engine/common.h index ed69b1d4..49276ff8 100644 --- a/regamedll/engine/common.h +++ b/regamedll/engine/common.h @@ -26,33 +26,31 @@ * */ -#ifndef COMMON_H -#define COMMON_H -#ifdef _WIN32 #pragma once -#endif -#include "maintypes.h" -#include "bspfile.h" -#include "FileSystem.h" -#include "info.h" +#include "const.h" +#include "qlimits.h" // Don't allow overflow #define SIZEBUF_CHECK_OVERFLOW 0 #define SIZEBUF_ALLOW_OVERFLOW BIT(0) #define SIZEBUF_OVERFLOWED BIT(1) -/* <6ae> ../common/common.h:82 */ +#define MAX_NUM_ARGVS 50 +#define NUM_SAFE_ARGVS 7 + +#define COM_COPY_CHUNK_SIZE 1024 +#define COM_MAX_CMD_LINE 256 + typedef struct sizebuf_s { const char *buffername; - uint16_t flags; + uint16 flags; byte *data; int maxsize; int cursize; } sizebuf_t; -/* <270aa> ../common/common.h:297 */ typedef struct downloadtime_s { qboolean bUsed; @@ -60,7 +58,6 @@ typedef struct downloadtime_s int nBytesRemaining; } downloadtime_t; -/* <19fa2> ../common/common.h:303 */ typedef struct incomingtransfer_s { qboolean doneregistering; @@ -74,90 +71,3 @@ typedef struct incomingtransfer_s float fLastStatusUpdate; qboolean custom; } incomingtransfer_t; - -#ifndef _WIN32 -#define _strlwr(p) for (int i = 0; p[i] != 0; i++) p[i] = tolower(p[i]); -#endif // _WIN32 - -inline double M_sqrt(int value) { - return sqrt(value); -} - -inline float M_sqrt(float value) { - return _mm_cvtss_f32(_mm_sqrt_ss(_mm_load_ss(&value))); -} - -inline double M_sqrt(double value) { - double ret; - auto v = _mm_load_sd(&value); - _mm_store_sd(&ret, _mm_sqrt_sd(v, v)); - return ret; -} - -#define printf2 _printf2 -#define chatf _print_chat - -#define Q_isspace isspace -#define Q_isalnum isalnum -#define Q_isalpha isalpha - -#define Q_malloc malloc -#define Q_calloc calloc -#define Q_alloca alloca -#define Q_free free - -#define Q_access _access -#define Q_close _close -#define Q_write _write -#define Q_memset memset -#define Q_memcpy memcpy -#define Q_strlen strlen -#define Q_memcmp memcmp -#define Q_strcpy strcpy -#define Q_strncpy strncpy -#define Q_strrchr strrchr -#define Q_strcat strcat -#define Q_strncat strncat -#define Q_strcmp strcmp -#define Q_strncmp strncmp -//#define Q_strcasecmp _stricmp // Use Q_stricmp -//#define Q_strncasecmp _strnicmp // Use Q_strnicmp -#define Q_sscanf sscanf -#define Q_strdup _strdup -#define Q_stricmp _stricmp -#define Q_strnicmp _strnicmp -#define Q_strstr strstr -#define Q_strchr strchr -#define Q_strrchr strrchr -#define Q_strlwr _strlwr -#define Q_sprintf sprintf -#define Q_snprintf _snprintf -#define Q_atoi atoi -#define Q_atof atof -#define Q_toupper toupper -#define Q_memmove memmove -//#define Q_strtoull strtoull -//#define Q_FileNameCmp FileNameCmp -#define Q_vsnprintf _vsnprintf -#define Q_vsnwprintf _vsnwprintf -#define Q_abs abs -#define Q_fabs fabs -#define Q_tan tan -#define Q_atan atan -#define Q_atan2 atan2 -#define Q_acos acos -#define Q_cos cos -#define Q_sin sin -#define Q_sqrt sqrt -#define Q_pow pow -#define Q_fmod fmod -#define Q_fopen fopen -#define Q_fprintf fprintf -#define Q_fclose fclose - -#ifdef REGAMEDLL_FIXES -#undef Q_sqrt -#define Q_sqrt M_sqrt -#endif - -#endif // COMMON_H diff --git a/regamedll/extra/cssdk/common/mathlib.h b/regamedll/extra/cssdk/common/mathlib.h index bc93a60e..336c1f09 100644 --- a/regamedll/extra/cssdk/common/mathlib.h +++ b/regamedll/extra/cssdk/common/mathlib.h @@ -1,37 +1,51 @@ -/*** +/* * -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. +* 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 2 of the License, or (at +* your option) any later version. * -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. +* 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. * -****/ +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ -#ifndef MATHLIB_H -#define MATHLIB_H +#pragma once + +#ifdef PLAY_GAMEDLL + +// probably gamedll compiled with flag /fpmath:fasted, +// so we need to use type double, otherwise will be the test failed + +typedef double float_precision; + +#else + +typedef float float_precision; + +#endif // PLAY_GAMEDLL -/* <42b7f> ../common/mathlib.h:3 */ typedef float vec_t; - -/* <42b91> ../common/mathlib.h:6 */ -#if !defined DID_VEC3_T_DEFINE && !defined vec3_t -#define DID_VEC3_T_DEFINE typedef vec_t vec3_t[3]; -#endif - -/* <80013> ../common/mathlib.h:8 */ typedef vec_t vec4_t[4]; +typedef int fixed16_t; -/* <42bac> ../common/mathlib.h:18 */ -typedef int fixed16_t; /* size: 4 */ - -/* <42bb7> ../common/mathlib.h:60 */ typedef union DLONG_u { int i[2]; @@ -55,36 +69,16 @@ typedef union DLONG_u #endif template -inline T min(T a, T b) { - return (a < b) ? a : b; -} +T min(T a, T b) { return (a < b) ? a : b; } template -inline T max(T a, T b) { - return (a < b) ? b : a; -} +T max(T a, T b) { return (a > b) ? a : b; } template -inline T clamp(T a, T min, T max) { - return (a > max) ? max : (a < min) ? min : a; -} +T clamp(T a, T min, T max) { return (a > max) ? max : (a < min) ? min : a; } -template -inline T bswap(T s) { - switch (sizeof(T)) { -#ifdef _WIN32 - case 2: {auto res = _byteswap_ushort(*(uint16 *)&s); return *(T *)&res;} - case 4: {auto res = _byteswap_ulong(*(uint32 *)(&s)); return *(T *)&res;} - case 8: {auto res = _byteswap_uint64(*(uint64 *)&s); return *(T *)&res;} -#else - case 2: {auto res = _bswap16(*(uint16 *)&s); return *(T *)&res;} - case 4: {auto res = _bswap(*(uint32 *)&s); return *(T *)&res;} - case 8: {auto res = _bswap64(*(uint64 *)&s); return *(T *)&res;} -#endif - default: return s; - } -} #else // __cplusplus + #ifndef max #define max(a,b) (((a) > (b)) ? (a) : (b)) #endif @@ -96,4 +90,38 @@ inline T bswap(T s) { #define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val))) #endif // __cplusplus -#endif // MATHLIB_H +// bitwise operators templates +template::type> +inline T operator~ (T a) { return (T)~(type)a; } +template::type> +inline T operator| (T a, T b) { return (T)((type)a | (type)b); } +template::type> +inline T operator& (T a, T b) { return (T)((type)a & (type)b); } +template::type> +inline T operator^ (T a, T b) { return (T)((type)a ^ (type)b); } +template::type> +inline T& operator|= (T& a, T b) { return (T&)((type&)a |= (type)b); } +template::type> +inline T& operator&= (T& a, T b) { return (T&)((type&)a &= (type)b); } +template::type> +inline T& operator^= (T& a, T b) { return (T&)((type&)a ^= (type)b); } + +inline double M_sqrt(int value) { + return sqrt(value); +} + +inline float M_sqrt(float value) { + return _mm_cvtss_f32(_mm_sqrt_ss(_mm_load_ss(&value))); +} + +inline double M_sqrt(double value) { + double ret; + auto v = _mm_load_sd(&value); + _mm_store_sd(&ret, _mm_sqrt_sd(v, v)); + return ret; +} + +#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];} +#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];} +#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];} +#define VectorClear(a) {(a)[0]=0.0;(a)[1]=0.0;(a)[2]=0.0;} diff --git a/regamedll/extra/cssdk/dlls/extdef.h b/regamedll/extra/cssdk/dlls/extdef.h index 355ef8d5..f18d58fe 100644 --- a/regamedll/extra/cssdk/dlls/extdef.h +++ b/regamedll/extra/cssdk/dlls/extdef.h @@ -29,6 +29,28 @@ #include "regamedll_const.h" +#ifdef _WIN32 + // Attributes to specify an "exported" function, visible from outside the + // DLL. + #undef DLLEXPORT + #define DLLEXPORT __declspec(dllexport) + // WINAPI should be provided in the windows compiler headers. + // It's usually defined to something like "__stdcall". +#else + #undef DLLEXPORT + #define DLLEXPORT __attribute__((visibility("default"))) + #define WINAPI /* */ +#endif // _WIN32 + +// Simplified macro for declaring/defining exported DLL functions. They +// need to be 'extern "C"' so that the C++ compiler enforces parameter +// type-matching, rather than considering routines with mis-matched +// arguments/types to be overloaded functions... +// +// AFAIK, this is os-independent, but it's included here in osdep.h where +// DLLEXPORT is defined, for convenience. +#define C_DLLEXPORT extern "C" DLLEXPORT + enum hash_types_e { CLASSNAME }; // Things that toggle (buttons/triggers/doors) need this diff --git a/regamedll/extra/cssdk/dlls/extdll.h b/regamedll/extra/cssdk/dlls/extdll.h index 23780656..e81fcd1e 100644 --- a/regamedll/extra/cssdk/dlls/extdll.h +++ b/regamedll/extra/cssdk/dlls/extdll.h @@ -25,6 +25,7 @@ * version. * */ + #pragma once #pragma warning(disable:4244) // int or float down-conversion @@ -35,9 +36,9 @@ #include "archtypes.h" #include "maintypes.h" +#include "regamedll_common.h" #ifdef _WIN32 - #define WIN32_LEAN_AND_MEAN #define NOWINRES #define NOSERVICE @@ -48,11 +49,9 @@ #include "winsani_out.h" #undef PlaySound #else - #include #include #include - #endif // _WIN32 // Misc C-runtime library headers diff --git a/regamedll/extra/cssdk/dlls/regamedll_common.h b/regamedll/extra/cssdk/dlls/regamedll_common.h new file mode 100644 index 00000000..638d5dcb --- /dev/null +++ b/regamedll/extra/cssdk/dlls/regamedll_common.h @@ -0,0 +1,95 @@ +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + +#pragma once + +#ifndef _WIN32 +#define _strlwr(p) for (int i = 0; p[i] != 0; i++) p[i] = tolower(p[i]); +#endif + +#define Q_isspace isspace +#define Q_isalnum isalnum +#define Q_isalpha isalpha + +#define Q_malloc malloc +#define Q_calloc calloc +#define Q_alloca alloca +#define Q_free free + +#define Q_min min +#define Q_max max +#define Q_clamp clamp +#define Q_access _access +#define Q_close _close +#define Q_write _write +#define Q_memset memset +#define Q_memcpy memcpy +#define Q_strlen strlen +#define Q_memcmp memcmp +#define Q_strcpy strcpy +#define Q_strncpy strncpy +#define Q_strrchr strrchr +#define Q_strcat strcat +#define Q_strncat strncat +#define Q_strcmp strcmp +#define Q_strncmp strncmp +#define Q_sscanf sscanf +#define Q_strdup _strdup +#define Q_stricmp _stricmp +#define Q_strnicmp _strnicmp +#define Q_strstr strstr +#define Q_strchr strchr +#define Q_strrchr strrchr +#define Q_strlwr _strlwr +#define Q_sprintf sprintf +#define Q_snprintf _snprintf +#define Q_atoi atoi +#define Q_atof atof +#define Q_toupper toupper +#define Q_memmove memmove +#define Q_vsnprintf _vsnprintf +#define Q_vsnwprintf _vsnwprintf +#define Q_abs abs +#define Q_fabs fabs +#define Q_tan tan +#define Q_atan atan +#define Q_atan2 atan2 +#define Q_acos acos +#define Q_cos cos +#define Q_sin sin +#define Q_pow pow +#define Q_fmod fmod +#define Q_fopen fopen +#define Q_fprintf fprintf +#define Q_fclose fclose + +#ifdef REGAMEDLL_FIXES +#define Q_sqrt M_sqrt +#else +#define Q_sqrt sqrt +#endif diff --git a/regamedll/extra/cssdk/dlls/regamedll_interfaces.h b/regamedll/extra/cssdk/dlls/regamedll_interfaces.h index fc86371d..84a749fd 100644 --- a/regamedll/extra/cssdk/dlls/regamedll_interfaces.h +++ b/regamedll/extra/cssdk/dlls/regamedll_interfaces.h @@ -86,6 +86,10 @@ public: virtual bool JoinTeam(TeamName team); virtual void StartObserver(Vector& vecPosition, Vector& vecViewAngle); virtual void TeamChangeUpdate(); + virtual void DropSecondary(); + virtual void DropPrimary(); + virtual bool HasPlayerItem(CBasePlayerItem *pCheckItem); + virtual bool HasNamedPlayerItem(const char *pszItemName); CBasePlayer *BasePlayer() const; public: diff --git a/regamedll/extra/cssdk/engine/cmd_rehlds.h b/regamedll/extra/cssdk/engine/cmd_rehlds.h index fe3b7011..9302f63a 100644 --- a/regamedll/extra/cssdk/engine/cmd_rehlds.h +++ b/regamedll/extra/cssdk/engine/cmd_rehlds.h @@ -29,10 +29,8 @@ #include "archtypes.h" -/* <8f1> ../engine/cmd.h:65 */ typedef void(*xcommand_t)(void); -/* <904> ../engine/cmd.h:71 */ typedef struct cmd_function_s { struct cmd_function_s *next; @@ -41,7 +39,6 @@ typedef struct cmd_function_s int flags; } cmd_function_t; -/* <95a> ../engine/cmd.h:80 */ typedef enum cmd_source_s { src_client = 0, // came in over a net connection as a clc_stringcmd. host_client will be valid during this state. diff --git a/regamedll/extra/cssdk/engine/common_rehlds.h b/regamedll/extra/cssdk/engine/common_rehlds.h index c7c4ed74..c0f4c39d 100644 --- a/regamedll/extra/cssdk/engine/common_rehlds.h +++ b/regamedll/extra/cssdk/engine/common_rehlds.h @@ -25,29 +25,23 @@ * version. * */ + #pragma once #include "const.h" #include "qlimits.h" -#ifdef REHLDS_FIXES -#define COM_TOKEN_LEN 2048 -#else -#define COM_TOKEN_LEN 1024 -#endif - // Don't allow overflow -#define SIZEBUF_CHECK_OVERFLOW 0 -#define SIZEBUF_ALLOW_OVERFLOW BIT(0) +#define SIZEBUF_CHECK_OVERFLOW 0 +#define SIZEBUF_ALLOW_OVERFLOW BIT(0) #define SIZEBUF_OVERFLOWED BIT(1) -#define MAX_NUM_ARGVS 50 -#define NUM_SAFE_ARGVS 7 +#define MAX_NUM_ARGVS 50 +#define NUM_SAFE_ARGVS 7 -#define COM_COPY_CHUNK_SIZE 1024 -#define COM_MAX_CMD_LINE 256 +#define COM_COPY_CHUNK_SIZE 1024 +#define COM_MAX_CMD_LINE 256 -/* <6ae> ../common/common.h:82 */ typedef struct sizebuf_s { const char *buffername; @@ -57,7 +51,6 @@ typedef struct sizebuf_s int cursize; } sizebuf_t; -/* <270aa> ../common/common.h:297 */ typedef struct downloadtime_s { qboolean bUsed; @@ -65,7 +58,6 @@ typedef struct downloadtime_s int nBytesRemaining; } downloadtime_t; -/* <19fa2> ../common/common.h:303 */ typedef struct incomingtransfer_s { qboolean doneregistering; diff --git a/regamedll/extra/cssdk/game_shared/shared_util.h b/regamedll/extra/cssdk/game_shared/shared_util.h index f7670d62..c12156fc 100644 --- a/regamedll/extra/cssdk/game_shared/shared_util.h +++ b/regamedll/extra/cssdk/game_shared/shared_util.h @@ -27,12 +27,10 @@ */ #pragma once -#include "common.h" - #ifndef _WIN32 #include #include -#endif // _WIN32 +#endif // Simple utility function to allocate memory and duplicate a string inline char *CloneString(const char *str) diff --git a/regamedll/extra/cssdk/public/asmlib.h b/regamedll/extra/cssdk/public/asmlib.h new file mode 100644 index 00000000..c1bc9af8 --- /dev/null +++ b/regamedll/extra/cssdk/public/asmlib.h @@ -0,0 +1,123 @@ +/*************************** asmlib.h *************************************** +* Author: Agner Fog +* Date created: 2003-12-12 +* Last modified: 2013-10-04 +* Project: asmlib.zip +* Source URL: www.agner.org/optimize +* +* Description: +* Header file for the asmlib function library. +* This library is available in many versions for different platforms. +* See asmlib-instructions.pdf for details. +* +* (c) Copyright 2003 - 2013 by Agner Fog. +* GNU General Public License http://www.gnu.org/licenses/gpl.html +*****************************************************************************/ + + +#ifndef ASMLIB_H +#define ASMLIB_H + + +/*********************************************************************** +Define compiler-specific types and directives +***********************************************************************/ + +// Define type size_t +#ifndef _SIZE_T_DEFINED +#include "stddef.h" +#endif + +// Define integer types with known size: int32_t, uint32_t, int64_t, uint64_t. +// If this doesn't work then insert compiler-specific definitions here: +#if defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1600) + // Compilers supporting C99 or C++0x have stdint.h defining these integer types + #include + #define INT64_SUPPORTED // Remove this if the compiler doesn't support 64-bit integers +#elif defined(_MSC_VER) + // Older Microsoft compilers have their own definition + typedef signed __int16 int16_t; + typedef unsigned __int16 uint16_t; + typedef signed __int32 int32_t; + typedef unsigned __int32 uint32_t; + typedef signed __int64 int64_t; + typedef unsigned __int64 uint64_t; + #define INT64_SUPPORTED // Remove this if the compiler doesn't support 64-bit integers +#else + // This works with most compilers + typedef signed short int int16_t; + typedef unsigned short int uint16_t; + typedef signed int int32_t; + typedef unsigned int uint32_t; + typedef long long int64_t; + typedef unsigned long long uint64_t; + #define INT64_SUPPORTED // Remove this if the compiler doesn't support 64-bit integers +#endif + + +// Turn off name mangling +#ifdef __cplusplus +extern "C" { +#endif + +/*********************************************************************** +Function prototypes, memory and string functions +***********************************************************************/ +void * A_memcpy (void * dest, const void * src, size_t count); // Copy count bytes from src to dest +void * A_memmove(void * dest, const void * src, size_t count); // Same as memcpy, allows overlap between src and dest +void * A_memset (void * dest, int c, size_t count); // Set count bytes in dest to (char)c +int A_memcmp (const void * buf1, const void * buf2, size_t num); // Compares two blocks of memory +size_t GetMemcpyCacheLimit(void); // Data blocks bigger than this will be copied uncached by memcpy and memmove +void SetMemcpyCacheLimit(size_t); // Change limit in GetMemcpyCacheLimit +size_t GetMemsetCacheLimit(void); // Data blocks bigger than this will be stored uncached by memset +void SetMemsetCacheLimit(size_t); // Change limit in GetMemsetCacheLimit +char * A_strcat (char * dest, const char * src); // Concatenate strings dest and src. Store result in dest +char * A_strcpy (char * dest, const char * src); // Copy string src to dest +size_t A_strlen (const char * str); // Get length of zero-terminated string +int A_strcmp (const char * a, const char * b); // Compare strings. Case sensitive +int A_stricmp (const char *string1, const char *string2); // Compare strings. Case insensitive for A-Z only +char * A_strstr (char * haystack, const char * needle); // Search for substring in string +void A_strtolower(char * string); // Convert string to lower case for A-Z only +void A_strtoupper(char * string); // Convert string to upper case for a-z only +size_t A_substring(char * dest, const char * source, size_t pos, size_t len); // Copy a substring for source into dest +size_t A_strspn (const char * str, const char * set); // Find span of characters that belong to set +size_t A_strcspn(const char * str, const char * set); // Find span of characters that don't belong to set +size_t strCountInSet(const char * str, const char * set); // Count characters that belong to set +size_t strcount_UTF8(const char * str); // Counts the number of characters in a UTF-8 encoded string + + +/*********************************************************************** +Function prototypes, miscellaneous functions +***********************************************************************/ +uint32_t A_popcount(uint32_t x); // Count 1-bits in 32-bit integer +int RoundD (double x); // Round to nearest or even +int RoundF (float x); // Round to nearest or even +int InstructionSet(void); // Tell which instruction set is supported +char * ProcessorName(void); // ASCIIZ text describing microprocessor +void CpuType(int * vendor, int * family, int * model); // Get CPU vendor, family and model +size_t DataCacheSize(int level); // Get size of data cache +void A_DebugBreak(void); // Makes a debug breakpoint +#ifdef INT64_SUPPORTED + uint64_t ReadTSC(void); // Read microprocessor internal clock (64 bits) +#else + uint32_t ReadTSC(void); // Read microprocessor internal clock (only 32 bits supported by compiler) +#endif +void cpuid_ex (int abcd[4], int eax, int ecx); // call CPUID instruction +static inline void cpuid_abcd (int abcd[4], int eax) { + cpuid_ex(abcd, eax, 0);} + +#ifdef __cplusplus +} // end of extern "C" + +// Define overloaded versions if compiling as C++ + +static inline int Round (double x) { // Overload name Round + return RoundD(x);} +static inline int Round (float x) { // Overload name Round + return RoundF(x);} +static inline const char * A_strstr(const char * haystack, const char * needle) { + return A_strstr((char*)haystack, needle);} // Overload A_strstr with const char * version + +#endif // __cplusplus + +#endif // ASMLIB_H diff --git a/regamedll/extra/cssdk/public/tier0/platform.h b/regamedll/extra/cssdk/public/tier0/platform.h index fd9a3046..f9e4e6c2 100644 --- a/regamedll/extra/cssdk/public/tier0/platform.h +++ b/regamedll/extra/cssdk/public/tier0/platform.h @@ -27,28 +27,7 @@ // need this for memset #include -// for when we care about how many bits we use -typedef signed char int8; -typedef signed short int16; - -#ifdef _WIN32 -#ifdef _MSC_VER -typedef signed __int64 int64; -#endif -#elif defined __linux__ -typedef long long int64; -#endif - -typedef unsigned char uint8; -typedef unsigned short uint16; -#ifdef _WIN32 -#ifdef _MSC_VER -typedef unsigned __int64 uint64; -#endif -#elif defined __linux__ -typedef unsigned long long uint64; -#endif - +#include "archtypes.h" typedef float float32; typedef double float64; @@ -86,7 +65,7 @@ FIXME: Enable this when we no longer fear change =) #define UINT8_MAX ((uint8)~0) #define UINT16_MAX ((uint16)~0) -#define UINT32_MAX ((uint32_t)~0) +#define UINT32_MAX ((uint32)~0) #define UINT64_MAX ((uint64)~0) #define UINT8_MIN 0 @@ -259,12 +238,12 @@ inline T WordSwapC(T w) template inline T DWordSwapC(T dw) { - uint32_t temp; - - temp = *((uint32_t *)&dw) >> 24; - temp |= ((*((uint32_t *)&dw) & 0x00FF0000) >> 8); - temp |= ((*((uint32_t *)&dw) & 0x0000FF00) << 8); - temp |= ((*((uint32_t *)&dw) & 0x000000FF) << 24); + uint32 temp; + + temp = *((uint32 *)&dw) >> 24; + temp |= ((*((uint32 *)&dw) & 0x00FF0000) >> 8); + temp |= ((*((uint32 *)&dw) & 0x0000FF00) << 8); + temp |= ((*((uint32 *)&dw) & 0x000000FF) << 24); return *((T*)&temp); } @@ -363,12 +342,12 @@ inline float DWordSwapAsm(float f) inline short BigShort(short val) { int test = 1; return (*(char *)&test == 1) ? WordSwap(val) : val; } inline uint16 BigWord(uint16 val) { int test = 1; return (*(char *)&test == 1) ? WordSwap(val) : val; } inline long BigLong(long val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; } -inline uint32_t BigDWord(uint32_t val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; } +inline uint32 BigDWord(uint32 val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; } inline float BigFloat(float val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; } inline short LittleShort(short val) { int test = 1; return (*(char *)&test == 1) ? val : WordSwap(val); } inline uint16 LittleWord(uint16 val) { int test = 1; return (*(char *)&test == 1) ? val : WordSwap(val); } inline long LittleLong(long val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); } -inline uint32_t LittleDWord(uint32_t val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); } +inline uint32 LittleDWord(uint32 val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); } inline float LittleFloat(float val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); } #endif diff --git a/regamedll/game_shared/shared_util.h b/regamedll/game_shared/shared_util.h index e6567724..73f9686d 100644 --- a/regamedll/game_shared/shared_util.h +++ b/regamedll/game_shared/shared_util.h @@ -26,18 +26,12 @@ * */ -#ifndef SHARED_UTIL -#define SHARED_UTIL -#ifdef _WIN32 #pragma once -#endif - -#include "common.h" #ifndef _WIN32 #include #include -#endif // _WIN32 +#endif wchar_t *SharedWVarArgs(wchar_t *format, ...); char *SharedVarArgs(char *format, ...); @@ -79,5 +73,4 @@ inline wchar_t *CloneWString(const wchar_t *str) wcscpy(cloneStr, str); return cloneStr; } - -#endif // SHARED_UTIL + \ No newline at end of file diff --git a/regamedll/public/regamedll/regamedll_common.h b/regamedll/public/regamedll/regamedll_common.h new file mode 100644 index 00000000..638d5dcb --- /dev/null +++ b/regamedll/public/regamedll/regamedll_common.h @@ -0,0 +1,95 @@ +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + +#pragma once + +#ifndef _WIN32 +#define _strlwr(p) for (int i = 0; p[i] != 0; i++) p[i] = tolower(p[i]); +#endif + +#define Q_isspace isspace +#define Q_isalnum isalnum +#define Q_isalpha isalpha + +#define Q_malloc malloc +#define Q_calloc calloc +#define Q_alloca alloca +#define Q_free free + +#define Q_min min +#define Q_max max +#define Q_clamp clamp +#define Q_access _access +#define Q_close _close +#define Q_write _write +#define Q_memset memset +#define Q_memcpy memcpy +#define Q_strlen strlen +#define Q_memcmp memcmp +#define Q_strcpy strcpy +#define Q_strncpy strncpy +#define Q_strrchr strrchr +#define Q_strcat strcat +#define Q_strncat strncat +#define Q_strcmp strcmp +#define Q_strncmp strncmp +#define Q_sscanf sscanf +#define Q_strdup _strdup +#define Q_stricmp _stricmp +#define Q_strnicmp _strnicmp +#define Q_strstr strstr +#define Q_strchr strchr +#define Q_strrchr strrchr +#define Q_strlwr _strlwr +#define Q_sprintf sprintf +#define Q_snprintf _snprintf +#define Q_atoi atoi +#define Q_atof atof +#define Q_toupper toupper +#define Q_memmove memmove +#define Q_vsnprintf _vsnprintf +#define Q_vsnwprintf _vsnwprintf +#define Q_abs abs +#define Q_fabs fabs +#define Q_tan tan +#define Q_atan atan +#define Q_atan2 atan2 +#define Q_acos acos +#define Q_cos cos +#define Q_sin sin +#define Q_pow pow +#define Q_fmod fmod +#define Q_fopen fopen +#define Q_fprintf fprintf +#define Q_fclose fclose + +#ifdef REGAMEDLL_FIXES +#define Q_sqrt M_sqrt +#else +#define Q_sqrt sqrt +#endif diff --git a/regamedll/regamedll/dlls.h b/regamedll/regamedll/dlls.h index 872d0078..f6f4bd50 100644 --- a/regamedll/regamedll/dlls.h +++ b/regamedll/regamedll/dlls.h @@ -27,7 +27,6 @@ */ #include "extdll.h" -#include "extdef.h" // declared virtual function's and globals for hooks #ifdef HOOK_GAMEDLL diff --git a/regamedll/regamedll/engine.h b/regamedll/regamedll/engine.h index 319c0a16..fd654b13 100644 --- a/regamedll/regamedll/engine.h +++ b/regamedll/regamedll/engine.h @@ -26,6 +26,7 @@ * */ +#include "maintypes.h" #include "common.h" #include "cmd.h" #include "unicode_strtools.h" diff --git a/regamedll/regamedll/precompiled.h b/regamedll/regamedll/precompiled.h index f32c4fe5..2566643e 100644 --- a/regamedll/regamedll/precompiled.h +++ b/regamedll/regamedll/precompiled.h @@ -3,7 +3,9 @@ #include "version/appversion.h" #include "osconfig.h" + #include "basetypes.h" +#include "archtypes.h" #include "asmlib.h" #include "sse_mathfun.h" diff --git a/regamedll/regamedll/regamedll_debug.h b/regamedll/regamedll/regamedll_debug.h index 58a870ec..f6bae133 100644 --- a/regamedll/regamedll/regamedll_debug.h +++ b/regamedll/regamedll/regamedll_debug.h @@ -1,6 +1,8 @@ #pragma once #define _logf regamedll_log +#define printf2 _printf2 +#define chatf _print_chat extern void _printf2(const char *fmt, ...); extern void _print_chat(class CBasePlayer *pPlayer, const char *fmt, ...);