mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-11 14:42:05 +08:00
lowmemory: merge
This commit is contained in:
+9
-19
@@ -137,10 +137,18 @@ 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
|
||||
|
||||
#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
|
||||
|
||||
// filesystem flags
|
||||
#define FS_STATIC_PATH ( 1U << 0 ) // FS_ClearSearchPath will be ignore this path
|
||||
#define FS_NOWRITE_PATH ( 1U << 1 ) // default behavior - last added gamedir set as writedir. This flag disables it
|
||||
@@ -811,24 +819,6 @@ void HPAK_CheckIntegrity( const char *filename );
|
||||
void HPAK_CheckSize( const char *filename );
|
||||
void HPAK_FlushHostQueue( void );
|
||||
|
||||
//
|
||||
// keys.c
|
||||
//
|
||||
int Key_IsDown( int keynum );
|
||||
const char *Key_IsBind( int keynum );
|
||||
void Key_Event( int key, int down );
|
||||
void Key_Init( void );
|
||||
void Key_WriteBindings( file_t *f );
|
||||
const char *Key_GetBinding( int keynum );
|
||||
void Key_SetBinding( int keynum, const char *binding );
|
||||
void Key_ClearStates( void );
|
||||
const char *Key_KeynumToString( int keynum );
|
||||
int Key_StringToKeynum( const char *str );
|
||||
int Key_GetKey( const char *binding );
|
||||
void Key_EnumCmds_f( void );
|
||||
void Key_SetKeyDest( int key_dest );
|
||||
void Key_EnableTextInput( qboolean enable, qboolean force );
|
||||
|
||||
#include "avi/avi.h"
|
||||
|
||||
//
|
||||
|
||||
@@ -1588,7 +1588,7 @@ void FS_ParseGenericGameInfo( gameinfo_t *GameInfo, const char *buf, const qbool
|
||||
else if( !Q_stricmp( token, isGameInfo ? "max_edicts" : "edicts" ))
|
||||
{
|
||||
pfile = COM_ParseFile( pfile, token );
|
||||
GameInfo->max_edicts = bound( 600, Q_atoi( token ), MAX_EDICTS );
|
||||
GameInfo->max_edicts = bound( MIN_EDICTS, Q_atoi( token ), MAX_EDICTS );
|
||||
}
|
||||
// only for gameinfo
|
||||
else if( isGameInfo )
|
||||
|
||||
@@ -29,8 +29,12 @@ typedef enum
|
||||
// Max length of a multicast message
|
||||
#define MAX_MULTICAST 8192 // some mods spamming for rain effect
|
||||
|
||||
#define MAX_INIT_MSG 0x20000 // max length of possible message
|
||||
|
||||
#if !XASH_LOW_MEMORY
|
||||
#define MAX_INIT_MSG 0x20000 // max length of possible message
|
||||
#else
|
||||
#define MAX_INIT_MSG 0x8000
|
||||
#endif
|
||||
// net packets type
|
||||
#define NET_HEADER_OUTOFBANDPACKET -1
|
||||
#define NET_HEADER_SPLITPACKET -2
|
||||
|
||||
+23
-2
@@ -78,17 +78,38 @@ GNU General Public License for more details.
|
||||
#define PORT_SERVER 27015
|
||||
|
||||
#define MULTIPLAYER_BACKUP 64 // how many data slots to use when in multiplayer (must be power of 2)
|
||||
#define SINGLEPLAYER_BACKUP 16 // same for single player
|
||||
#define SINGLEPLAYER_BACKUP 16 // same for single player
|
||||
#define CMD_BACKUP 64 // allow a lot of command backups for very fast systems
|
||||
#define CMD_MASK (CMD_BACKUP - 1)
|
||||
#define NUM_PACKET_ENTITIES 256 // 170 Mb for multiplayer with 32 players
|
||||
#define MAX_CUSTOM_BASELINES 64
|
||||
|
||||
#define NET_LEGACY_EXT_SPLIT (1U<<1)
|
||||
#define NETSPLIT_BACKUP 8
|
||||
#define NETSPLIT_BACKUP_MASK (NETSPLIT_BACKUP - 1)
|
||||
#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
|
||||
#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
|
||||
{
|
||||
// bool vector
|
||||
|
||||
@@ -119,12 +119,15 @@ GNU General Public License for more details.
|
||||
|
||||
#define MAX_SOUND_BITS 11
|
||||
#define MAX_SOUNDS (1<<MAX_SOUND_BITS) // 11 bits == 2048 sounds
|
||||
#define MAX_SOUNDS_NONSENTENCE MAX_SOUNDS
|
||||
|
||||
#define MAX_ENTITY_BITS 13 // 13 bits = 8192 edicts
|
||||
#define MAX_EDICTS (1<<MAX_ENTITY_BITS)
|
||||
#define MAX_EDICTS_BYTES ((MAX_EDICTS + 7) / 8)
|
||||
#define LAST_EDICT (MAX_EDICTS - 1)
|
||||
|
||||
#define MIN_EDICTS 64
|
||||
|
||||
#define MAX_CUSTOM_BITS 10
|
||||
#define MAX_CUSTOM (1<<MAX_CUSTOM_BITS)// 10 bits == 1024 generic file
|
||||
#define MAX_USER_MESSAGES 197 // another 58 messages reserved for engine routines
|
||||
@@ -179,6 +182,59 @@ GNU General Public License for more details.
|
||||
#define FRAGMENT_MAX_SIZE 64000 // maximal fragment size
|
||||
#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)
|
||||
|
||||
#define MAX_EVENTS 128
|
||||
|
||||
#define MAX_SUPPORTED_MODELS 512
|
||||
|
||||
#define MAX_MODELS 512
|
||||
|
||||
|
||||
#define MAX_SOUNDS 512
|
||||
#define MAX_CUSTOM 32
|
||||
|
||||
#define MAX_DLIGHTS 16 // dynamic lights (rendered per one frame)
|
||||
#define MAX_ELIGHTS 32 // entity only point lights
|
||||
#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)
|
||||
|
||||
#define MAX_EVENTS 128
|
||||
|
||||
#define MAX_SUPPORTED_MODELS 1024
|
||||
|
||||
#define MAX_MODELS 1024
|
||||
|
||||
#define MAX_CUSTOM 512
|
||||
#define MAX_RENDER_DECALS 128
|
||||
#define MAX_RESOURCES 1024
|
||||
#endif
|
||||
|
||||
// Quake1 Protocol
|
||||
#define PROTOCOL_VERSION_QUAKE 15
|
||||
|
||||
|
||||
+15
-5
@@ -18,6 +18,15 @@ GNU General Public License for more details.
|
||||
#define MEMHEADER_SENTINEL1 0xDEADF00D
|
||||
#define MEMHEADER_SENTINEL2 0xDF
|
||||
|
||||
#ifdef XASH_CUSTOM_SWAP
|
||||
#include "platform/swap/swap.h"
|
||||
#define Q_malloc SWAP_Malloc
|
||||
#define Q_free SWAP_Free
|
||||
#else
|
||||
#define Q_malloc malloc
|
||||
#define Q_free free
|
||||
#endif
|
||||
|
||||
typedef struct memheader_s
|
||||
{
|
||||
struct memheader_s *next; // next and previous memheaders in chain belonging to pool
|
||||
@@ -58,7 +67,7 @@ void *_Mem_Alloc( byte *poolptr, size_t size, qboolean clear, const char *filena
|
||||
|
||||
// big allocations are not clumped
|
||||
pool->realsize += sizeof( memheader_t ) + size + sizeof( int );
|
||||
mem = (memheader_t *)malloc( sizeof( memheader_t ) + size + sizeof( int ));
|
||||
mem = (memheader_t *)Q_malloc( sizeof( memheader_t ) + size + sizeof( int ));
|
||||
if( mem == NULL ) Sys_Error( "Mem_Alloc: out of memory (alloc at %s:%i)\n", filename, fileline );
|
||||
|
||||
mem->filename = filename;
|
||||
@@ -74,7 +83,8 @@ void *_Mem_Alloc( byte *poolptr, size_t size, qboolean clear, const char *filena
|
||||
mem->prev = NULL;
|
||||
pool->chain = mem;
|
||||
if( mem->next ) mem->next->prev = mem;
|
||||
if( clear ) memset((void *)((byte *)mem + sizeof( memheader_t )), 0, mem->size );
|
||||
if( clear )
|
||||
memset((void *)((byte *)mem + sizeof( memheader_t )), 0, mem->size );
|
||||
|
||||
return (void *)((byte *)mem + sizeof( memheader_t ));
|
||||
}
|
||||
@@ -128,7 +138,7 @@ static void Mem_FreeBlock( memheader_t *mem, const char *filename, int fileline
|
||||
pool->totalsize -= mem->size;
|
||||
|
||||
pool->realsize -= sizeof( memheader_t ) + mem->size + sizeof( int );
|
||||
free( mem );
|
||||
Q_free( mem );
|
||||
}
|
||||
|
||||
void _Mem_Free( void *data, const char *filename, int fileline )
|
||||
@@ -166,7 +176,7 @@ byte *_Mem_AllocPool( const char *name, const char *filename, int fileline )
|
||||
{
|
||||
mempool_t *pool;
|
||||
|
||||
pool = (mempool_t *)malloc( sizeof( mempool_t ));
|
||||
pool = (mempool_t *)Q_malloc( sizeof( mempool_t ));
|
||||
if( pool == NULL ) Sys_Error( "Mem_AllocPool: out of memory (allocpool at %s:%i)\n", filename, fileline );
|
||||
memset( pool, 0, sizeof( mempool_t ));
|
||||
|
||||
@@ -203,7 +213,7 @@ void _Mem_FreePool( byte **poolptr, const char *filename, int fileline )
|
||||
while( pool->chain ) Mem_FreeBlock( pool->chain, filename, fileline );
|
||||
// free the pool itself
|
||||
memset( pool, 0xBF, sizeof( mempool_t ));
|
||||
free( pool );
|
||||
Q_free( pool );
|
||||
*poolptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user