Browse Source

Implement XASH_LOW_MEMORY, memory-reduced configuration

pull/2/head
mittorn 5 years ago
parent
commit
114a256675
  1. 3
      common/port.h
  2. 5
      engine/client/cl_game.c
  3. 8
      engine/client/cl_parse.c
  4. 4
      engine/client/client.h
  5. 24
      engine/client/console.c
  6. 5
      engine/common/common.h
  7. 6
      engine/common/net_ws.h
  8. 11
      engine/common/netchan.h
  9. 25
      engine/common/protocol.h
  10. 4
      engine/server/server.h
  11. 6
      engine/server/sv_init.c

3
common/port.h

@ -126,6 +126,9 @@ GNU General Public License for more details. @@ -126,6 +126,9 @@ GNU General Public License for more details.
#define XASH_ALLOW_SAVERESTORE_OFFSETS
#endif
#endif //WIN32
#ifndef XASH_LOW_MEMORY
#define XASH_LOW_MEMORY 0
#endif
#include <stdlib.h>
#include <string.h>

5
engine/client/cl_game.c

@ -1123,8 +1123,9 @@ void CL_InitEdicts( void ) @@ -1123,8 +1123,9 @@ void CL_InitEdicts( void )
Assert( clgame.entities == NULL );
if( !clgame.mempool ) return; // Host_Error without client
CL_UPDATE_BACKUP = ( cl.maxclients == 1 ) ? SINGLEPLAYER_BACKUP : MULTIPLAYER_BACKUP;
#if XASH_LOW_MEMORY != 2
CL_UPDATE_BACKUP = ( cl.maxclients <= 1 ) ? SINGLEPLAYER_BACKUP : MULTIPLAYER_BACKUP;
#endif
cls.num_client_entities = CL_UPDATE_BACKUP * NUM_PACKET_ENTITIES;
cls.packet_entities = Mem_Realloc( clgame.mempool, cls.packet_entities, sizeof( entity_state_t ) * cls.num_client_entities );
clgame.entities = Mem_Calloc( clgame.mempool, sizeof( cl_entity_t ) * clgame.maxEntities );

8
engine/client/cl_parse.c

@ -21,9 +21,9 @@ GNU General Public License for more details. @@ -21,9 +21,9 @@ GNU General Public License for more details.
#include "shake.h"
#include "hltv.h"
#include "input.h"
#if XASH_LOW_MEMORY != 2
int CL_UPDATE_BACKUP = SINGLEPLAYER_BACKUP;
#endif
/*
===============
CL_UserMsgStub
@ -881,7 +881,7 @@ void CL_ParseServerData( sizebuf_t *msg ) @@ -881,7 +881,7 @@ void CL_ParseServerData( sizebuf_t *msg )
cl.playernum = MSG_ReadByte( msg );
cl.maxclients = MSG_ReadByte( msg );
clgame.maxEntities = MSG_ReadWord( msg );
clgame.maxEntities = bound( 600, clgame.maxEntities, MAX_EDICTS );
clgame.maxEntities = bound( 30, clgame.maxEntities, MAX_EDICTS );
clgame.maxModels = MSG_ReadWord( msg );
Q_strncpy( clgame.mapname, MSG_ReadString( msg ), MAX_STRING );
Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), MAX_STRING );
@ -2394,7 +2394,7 @@ void CL_ParseLegacyServerData( sizebuf_t *msg ) @@ -2394,7 +2394,7 @@ void CL_ParseLegacyServerData( sizebuf_t *msg )
cl.playernum = MSG_ReadByte( msg );
cl.maxclients = MSG_ReadByte( msg );
clgame.maxEntities = MSG_ReadWord( msg );
clgame.maxEntities = bound( 600, clgame.maxEntities, 4096 );
clgame.maxEntities = bound( 30, clgame.maxEntities, 4096 );
clgame.maxModels = 512;
Q_strncpy( clgame.mapname, MSG_ReadString( msg ), MAX_STRING );
Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), MAX_STRING );

4
engine/client/client.h

@ -96,7 +96,11 @@ typedef struct @@ -96,7 +96,11 @@ typedef struct
#define ANGLE_MASK (ANGLE_BACKUP - 1)
#define CL_UPDATE_MASK (CL_UPDATE_BACKUP - 1)
#if XASH_LOW_MEMORY == 2
#define CL_UPDATE_BACKUP SINGLEPLAYER_BACKUP
#else
extern int CL_UPDATE_BACKUP;
#endif
#define SIGNONS 2 // signon messages to receive before connected
#define INVALID_HANDLE 0xFFFF // for XashXT cache system

24
engine/client/console.c

@ -37,15 +37,19 @@ static qboolean g_utf8 = false; @@ -37,15 +37,19 @@ static qboolean g_utf8 = false;
#define COLOR_DEFAULT '7'
#define CON_HISTORY 64
#define MAX_DBG_NOTIFY 128
#if XASH_LOW_MEMORY
#define CON_NUMFONTS 1 // do not load different font textures
#define CON_TEXTSIZE 32768 // max scrollback buffer characters in console (32 kb)
#define CON_MAXLINES 2048 // max scrollback buffer lines in console
#else
#define CON_NUMFONTS 3 // maxfonts
#define CON_TEXTSIZE 1048576 // max scrollback buffer characters in console (1 Mb)
#define CON_MAXLINES 16384 // max scrollback buffer lines in console
#endif
#define CON_LINES( i ) (con.lines[(con.lines_first + (i)) % con.maxlines])
#define CON_LINES_COUNT con.lines_count
#define CON_LINES_LAST() CON_LINES( CON_LINES_COUNT - 1 )
#define CON_TEXTSIZE 1048576 // max scrollback buffer characters in console (1 Mb)
#define CON_MAXLINES 16384 // max scrollback buffer lines in console
// console color typeing
rgba_t g_color_table[8] =
{
@ -663,7 +667,7 @@ static void Con_LoadConchars( void ) @@ -663,7 +667,7 @@ static void Con_LoadConchars( void )
int i, fontSize;
// load all the console fonts
for( i = 0; i < 3; i++ )
for( i = 0; i < CON_NUMFONTS; i++ )
Con_LoadConsoleFont( i, con.chars + i );
// select properly fontsize
@ -673,6 +677,9 @@ static void Con_LoadConchars( void ) @@ -673,6 +677,9 @@ static void Con_LoadConchars( void )
fontSize = 2;
else fontSize = 1;
if( fontSize > CON_NUMFONTS - 1 )
fontSize = CON_NUMFONTS - 1;
// sets the current font
con.lastUsedFont = con.curFont = &con.chars[fontSize];
}
@ -929,7 +936,7 @@ choose font size @@ -929,7 +936,7 @@ choose font size
*/
void Con_SetFont( int fontNum )
{
fontNum = bound( 0, fontNum, 2 );
fontNum = bound( 0, fontNum, CON_NUMFONTS - 1 );
con.curFont = &con.chars[fontNum];
}
@ -2359,7 +2366,9 @@ void Con_VidInit( void ) @@ -2359,7 +2366,9 @@ void Con_VidInit( void )
Con_CheckResize();
Con_LoadConchars();
#if XASH_LOW_MEMORY
con.background = R_GetBuiltinTexture( REF_BLACK_TEXTURE );
#else
// loading console image
if( host.allow_console )
{
@ -2434,6 +2443,7 @@ void Con_VidInit( void ) @@ -2434,6 +2443,7 @@ void Con_VidInit( void )
// missed console image will be replaced as gray background like X-Ray or Crysis
if( con.background == R_GetBuiltinTexture( REF_DEFAULT_TEXTURE ) || con.background == 0 )
con.background = R_GetBuiltinTexture( REF_GRAY_TEXTURE );
#endif
}
/*

5
engine/common/common.h

@ -141,6 +141,11 @@ typedef enum @@ -141,6 +141,11 @@ typedef enum
#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
#define MAX_DECALS 32 // touching TE_DECAL messages, etc
#define MAX_STATIC_ENTITIES 32 // 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

6
engine/common/net_ws.h

@ -30,7 +30,11 @@ typedef enum @@ -30,7 +30,11 @@ typedef enum
#define MAX_MULTICAST 8192 // some mods spamming for rain effect
#define MAX_INIT_MSG 0x20000 // max length of possible message
#if XASH_LOW_MEMORY == 2
#define MAX_INIT_MSG 0x8000
#define MAX_DATAGRAM 1024
#define MAX_MULTICAST 1024
#endif
// net packets type
#define NET_HEADER_OUTOFBANDPACKET -1
#define NET_HEADER_SPLITPACKET -2

11
engine/common/netchan.h

@ -78,17 +78,24 @@ GNU General Public License for more details. @@ -78,17 +78,24 @@ 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
#define MULTIPLAYER_BACKUP 4 // how many data slots to use when in multiplayer (must be power of 2)
#define SINGLEPLAYER_BACKUP 4 // same for single player
#define NUM_PACKET_ENTITIES 32 // 170 Mb for multiplayer with 32 players
#define MAX_CUSTOM_BASELINES 8
#define NET_MAX_FRAGMENT 32768
#endif
typedef struct netsplit_chain_packet_s
{
// bool vector

25
engine/common/protocol.h

@ -133,6 +133,31 @@ GNU General Public License for more details. @@ -133,6 +133,31 @@ GNU General Public License for more details.
#define MAX_LIGHTSTYLES 64 // original quake limit
#define MAX_RENDER_DECALS 4096 // max rendering decals per a level
#if XASH_LOW_MEMORY == 2
// memory reduced protocol, not for use in multiplayer
#define MAX_VISIBLE_PACKET_BITS 7 // 2048 visible entities per frame (hl1 has 256)
#define MAX_VISIBLE_PACKET (1<<MAX_VISIBLE_PACKET_BITS)
#define MAX_VISIBLE_PACKET_VIS_BYTES ((MAX_VISIBLE_PACKET + 7) / 8)
#define MAX_EVENT_BITS 7
#define MAX_EVENTS (1<<MAX_EVENT_BITS) // 10 bits == 1024 events (the original Half-Life limit)
#define MAX_MODEL_BITS 8 // 12 bits == 4096 models
#define MAX_SUPPORTED_MODELS (1<<MAX_MODEL_BITS)
#define MAX_MODELS 256
#define MAX_SOUND_BITS 8
#define MAX_SOUNDS (1<<MAX_SOUND_BITS) // 11 bits == 2048 sounds
#define MAX_CUSTOM_BITS 4
#define MAX_CUSTOM (1<<MAX_CUSTOM_BITS)// 10 bits == 1024 generic file
#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
#endif
// sound proto
#define MAX_SND_FLAGS_BITS 14
#define MAX_SND_CHAN_BITS 4

4
engine/server/server.h

@ -32,7 +32,11 @@ GNU General Public License for more details. @@ -32,7 +32,11 @@ GNU General Public License for more details.
//=============================================================================
#define SV_UPDATE_MASK (SV_UPDATE_BACKUP - 1)
#if XASH_LOW_MEMORY == 2
#define SV_UPDATE_BACKUP SINGLEPLAYER_BACKUP
#else
extern int SV_UPDATE_BACKUP;
#endif
// hostflags
#define SVF_SKIPLOCALHOST BIT( 0 )

6
engine/server/sv_init.c

@ -17,9 +17,9 @@ GNU General Public License for more details. @@ -17,9 +17,9 @@ GNU General Public License for more details.
#include "server.h"
#include "net_encode.h"
#include "library.h"
#if XASH_LOW_MEMORY != 2
int SV_UPDATE_BACKUP = SINGLEPLAYER_BACKUP;
#endif
server_t sv; // local server
server_static_t svs; // persistant server info
svgame_static_t svgame; // persistant game info
@ -752,7 +752,9 @@ void SV_SetupClients( void ) @@ -752,7 +752,9 @@ void SV_SetupClients( void )
// feedback for cvar
Cvar_FullSet( "maxplayers", va( "%d", svs.maxclients ), FCVAR_LATCH );
#if XASH_LOW_MEMORY != 2
SV_UPDATE_BACKUP = ( svs.maxclients == 1 ) ? SINGLEPLAYER_BACKUP : MULTIPLAYER_BACKUP;
#endif
svs.clients = Z_Realloc( svs.clients, sizeof( sv_client_t ) * svs.maxclients );
svs.num_client_entities = svs.maxclients * SV_UPDATE_BACKUP * NUM_PACKET_ENTITIES;

Loading…
Cancel
Save