From 6953e829c49633f569fe9b3fa255ae8008517260 Mon Sep 17 00:00:00 2001 From: mittorn Date: Mon, 4 Nov 2019 22:34:08 +0700 Subject: [PATCH] lowmemory: prevent redefines --- common/xash3d_types.h | 4 ++-- engine/client/cl_parse.c | 3 ++- engine/common/common.h | 5 +++-- engine/common/net_ws.h | 4 +++- engine/common/netchan.h | 17 +++++++++++++---- engine/common/protocol.h | 21 ++++++++++++++++++++- 6 files changed, 43 insertions(+), 11 deletions(-) diff --git a/common/xash3d_types.h b/common/xash3d_types.h index 6564cf93..f3de92e3 100644 --- a/common/xash3d_types.h +++ b/common/xash3d_types.h @@ -142,9 +142,9 @@ typedef void (*setpair_t)( const char *key, const void *value, void *buffer, voi // config strings are a general means of communication from // the server to all connected clients. // each config string can be at most CS_SIZE characters. - +#if XASH_LOW_MEMORY == 0 #define MAX_QPATH 64 // max length of a game pathname -#if XASH_LOW_MEMORY == 2 +#elif XASH_LOW_MEMORY == 2 #define MAX_QPATH 32 // should be enough for singleplayer #elif XASH_LOW_MEMORY == 1 #define MAX_QPATH 48 diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index e70c6708..da41fac2 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -2754,8 +2754,9 @@ void CL_LegacyUpdateUserinfo( sizebuf_t *msg ) } else memset( player, 0, sizeof( *player )); } +#if XASH_LOW_MEMORY == 0 #define MAX_LEGACY_RESOURCES 2048 -#if XASH_LOW_MEMORY == 2 +#elif XASH_LOW_MEMORY == 2 #define MAX_LEGACY_RESOURCES 1 #elif XASH_LOW_MEMORY == 1 #define MAX_LEGACY_RESOURCES 512 diff --git a/engine/common/common.h b/engine/common/common.h index 0d3b1ce2..33c9fee1 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -137,14 +137,15 @@ typedef enum #define CIN_MAIN 0 #define CIN_LOGO 1 - +#if XASH_LOW_MEMORY == 0 #define MAX_DECALS 512 // touching TE_DECAL messages, etc #define MAX_STATIC_ENTITIES 3096 // static entities that moved on the client when level is spawn -#if XASH_LOW_MEMORY == 2 +#elif XASH_LOW_MEMORY == 2 #define MAX_DECALS 256 // touching TE_DECAL messages, etc #define MAX_STATIC_ENTITIES 32 // static entities that moved on the client when level is spawn #elif XASH_LOW_MEMORY == 1 +#define MAX_DECALS 512 // touching TE_DECAL messages, etc #define MAX_STATIC_ENTITIES 128 // static entities that moved on the client when level is spawn #endif diff --git a/engine/common/net_ws.h b/engine/common/net_ws.h index 1b4c6671..c2e4de33 100644 --- a/engine/common/net_ws.h +++ b/engine/common/net_ws.h @@ -29,8 +29,10 @@ typedef enum // Max length of a multicast message #define MAX_MULTICAST 8192 // some mods spamming for rain effect + +#if !XASH_LOW_MEMORY #define MAX_INIT_MSG 0x20000 // max length of possible message -#if XASH_LOW_MEMORY +#else #define MAX_INIT_MSG 0x8000 #endif // net packets type diff --git a/engine/common/netchan.h b/engine/common/netchan.h index 23ff2f7c..6a321b55 100644 --- a/engine/common/netchan.h +++ b/engine/common/netchan.h @@ -89,16 +89,25 @@ GNU General Public License for more details. #define NETSPLIT_HEADER_SIZE 18 #if XASH_LOW_MEMORY == 2 + #undef MULTIPLAYER_BACKUP + #undef SINGLEPLAYER_BACKUP + #undef NUM_PACKET_ENTITIES + #undef MAX_CUSTOM_BASELINES + #undef NET_MAX_FRAGMENT #define MULTIPLAYER_BACKUP 4 // breaks protocol in legacy mode, new protocol status unknown #define SINGLEPLAYER_BACKUP 4 #define NUM_PACKET_ENTITIES 32 #define MAX_CUSTOM_BASELINES 8 #define NET_MAX_FRAGMENT 32768 #elif XASH_LOW_MEMORY == 1 -#define SINGLEPLAYER_BACKUP 4 -#define NUM_PACKET_ENTITIES 64 -#define MAX_CUSTOM_BASELINES 8 -#define NET_MAX_FRAGMENT 32768 + #undef SINGLEPLAYER_BACKUP + #undef NUM_PACKET_ENTITIES + #undef MAX_CUSTOM_BASELINES + #undef NET_MAX_FRAGMENT + #define SINGLEPLAYER_BACKUP 4 + #define NUM_PACKET_ENTITIES 64 + #define MAX_CUSTOM_BASELINES 8 + #define NET_MAX_FRAGMENT 32768 #endif typedef struct netsplit_chain_packet_s diff --git a/engine/common/protocol.h b/engine/common/protocol.h index 8727c6e5..d43e6aec 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -183,6 +183,17 @@ GNU General Public License for more details. #define FRAGMENT_LOCAL_SIZE FRAGMENT_MAX_SIZE // local connection #if XASH_LOW_MEMORY == 2 +#undef MAX_VISIBLE_PACKET +#undef MAX_VISIBLE_PACKET_VIS_BYTES +#undef MAX_EVENTS +#undef MAX_SUPPORTED_MODELS +#undef MAX_MODELS +#undef MAX_SOUNDS +#undef MAX_CUSTOM +#undef MAX_DLIGHTS +#undef MAX_ELIGHTS +#undef MAX_RENDER_DECALS +#undef MAX_RESOURCES // memory reduced protocol, not for use in multiplayer (but still compatible) #define MAX_VISIBLE_PACKET 128 #define MAX_VISIBLE_PACKET_VIS_BYTES ((MAX_VISIBLE_PACKET + 7) / 8) @@ -202,6 +213,14 @@ GNU General Public License for more details. #define MAX_RENDER_DECALS 64 // max rendering decals per a level #define MAX_RESOURCES 1024 #elif XASH_LOW_MEMORY == 1 +#undef MAX_VISIBLE_PACKET +#undef MAX_VISIBLE_PACKET_VIS_BYTES +#undef MAX_EVENTS +#undef MAX_SUPPORTED_MODELS +#undef MAX_MODELS +#undef MAX_CUSTOM +#undef MAX_RENDER_DECALS +#undef MAX_RESOURCES #define MAX_VISIBLE_PACKET 256 #define MAX_VISIBLE_PACKET_VIS_BYTES ((MAX_VISIBLE_PACKET + 7) / 8) @@ -212,7 +231,7 @@ GNU General Public License for more details. #define MAX_MODELS 1024 #define MAX_CUSTOM 512 - +#define MAX_RENDER_DECALS 128 #define MAX_RESOURCES 1024 #endif