From 70d9efc3acb0060b6b59fae9353c7b72c7592dc2 Mon Sep 17 00:00:00 2001 From: g-cont Date: Sat, 3 Feb 2018 00:00:00 +0300 Subject: [PATCH] 03 Feb 2018 --- common/bspfile.h | 23 ++--- common/render_api.h | 4 +- engine/client/cl_game.c | 12 +-- engine/client/cl_parse.c | 6 ++ engine/client/cl_view.c | 2 +- engine/client/client.h | 7 +- engine/client/gl_cull.c | 3 +- engine/client/gl_local.h | 9 +- engine/client/gl_mirror.c | 22 +---- engine/client/gl_rmain.c | 78 +++------------- engine/client/gl_rsurf.c | 88 +----------------- engine/client/gl_vidnt.c | 2 - engine/common/con_utils.c | 23 +---- engine/common/crclib.c | 12 +-- engine/common/host.c | 4 +- engine/common/mod_local.h | 10 +- engine/common/model.c | 188 ++++++++------------------------------ engine/common/protocol.h | 35 +++---- engine/edict.h | 2 +- engine/server/server.h | 2 + engine/server/sv_client.c | 1 + engine/server/sv_game.c | 18 ++-- engine/server/sv_save.c | 15 ++- 23 files changed, 138 insertions(+), 428 deletions(-) diff --git a/common/bspfile.h b/common/bspfile.h index d4cb5562..b5a6393d 100644 --- a/common/bspfile.h +++ b/common/bspfile.h @@ -30,7 +30,6 @@ BRUSH MODELS // header #define Q1BSP_VERSION 29 // quake1 regular version (beta is 28) #define HLBSP_VERSION 30 // half-life regular version -#define XTBSP_VERSION 31 // extended lightmaps and expanded clipnodes limit #define QBSP2_VERSION (('B' << 0) | ('S' << 8) | ('P' << 16) | ('2'<<24)) #define IDEXTRAHEADER (('H'<<24)+('S'<<16)+('A'<<8)+'X') // little-endian "XASH" @@ -65,8 +64,9 @@ BRUSH MODELS #define LS_UNUSED 0xFE #define LS_NONE 0xFF +// these limis not using by modelloader only for display 'mapstats' correctly #ifdef SUPPORT_BSP2_FORMAT -#define MAX_MAP_MODELS 2048 // can be increased up to 2048 if needed +#define MAX_MAP_MODELS 2048 // embedded models #define MAX_MAP_ENTSTRING 0x200000 // 2 Mb should be enough #define MAX_MAP_PLANES 131072 // can be increased without problems #define MAX_MAP_NODES 262144 // because negative shorts are leafs @@ -76,7 +76,7 @@ BRUSH MODELS #define MAX_MAP_FACES 262144 // unsigned short limit #define MAX_MAP_MARKSURFACES 524288 // unsigned short limit #else -#define MAX_MAP_MODELS 1024 // can be increased up to 2048 if needed +#define MAX_MAP_MODELS 512 // embedded models #define MAX_MAP_ENTSTRING 0x80000 // 512 kB should be enough #define MAX_MAP_PLANES 65536 // can be increased without problems #define MAX_MAP_NODES 32767 // because negative shorts are leafs @@ -116,16 +116,12 @@ BRUSH MODELS #define LUMP_MODELS 14 // internal submodels #define HEADER_LUMPS 15 -// version 31 -#define LUMP_CLIPNODES2 15 // hull0 goes into LUMP_NODES, hull1 goes into LUMP_CLIPNODES, -#define LUMP_CLIPNODES3 16 // hull2 goes into LUMP_CLIPNODES2, hull3 goes into LUMP_CLIPNODES3 -#define HEADER_LUMPS_31 17 - +// extra lump ordering #define LUMP_LIGHTVECS 0 // deluxemap data #define LUMP_FACEINFO 1 // landscape and lightmap resolution info #define LUMP_CUBEMAPS 2 // cubemap description #define LUMP_VERTNORMALS 3 // phong shaded vertex normals -#define LUMP_LEAF_LIGHTING 4 // contain compressed light cubes per empty leafs +#define LUMP_VERTEX_LIGHT 4 // contain compressed light cubes per empty leafs #define LUMP_WORLDLIGHTS 5 // list of all the virtual and real lights (used to relight models in-game) #define LUMP_COLLISION 6 // physics engine collision hull dump #define LUMP_AINODEGRAPH 7 // node graph that stored into the bsp @@ -139,6 +135,7 @@ BRUSH MODELS #define TEX_SPECIAL BIT( 0 ) // sky or slime, no lightmap or 256 subdivision #define TEX_WORLD_LUXELS BIT( 1 ) // alternative lightmap matrix will be used (luxels per world units instead of luxels per texels) #define TEX_AXIAL_LUXELS BIT( 2 ) // force world luxels to axial positive scales +#define TEX_EXTRA_LIGHTMAP BIT( 3 ) // bsp31 legacy - using 8 texels per luxel instead of 16 texels per luxel // ambient sound types enum @@ -168,13 +165,7 @@ typedef struct typedef struct { - int version; - dlump_t lumps[HEADER_LUMPS_31]; -} dheader31_t; - -typedef struct -{ - int id; // must be little endian XASH + int id; // must be little endian XASH int version; dlump_t lumps[EXTRA_LUMPS]; } dextrahdr_t; diff --git a/common/render_api.h b/common/render_api.h index 71b15026..890d6cf4 100644 --- a/common/render_api.h +++ b/common/render_api.h @@ -46,7 +46,7 @@ GNU General Public License for more details. #define PARM_TEX_GLFORMAT 13 // get a texture GL-format #define PARM_TEX_ENCODE 14 // custom encoding for DXT image #define PARM_TEX_MIPCOUNT 15 // count of mipmaps (0 - autogenerated, 1 - disabled of mipmapping) -#define PARM_WORLD_VERSION 16 // return the version of bsp +#define PARM_BSP2_SUPPORTED 16 // tell custom renderer what engine is support BSP2 in this build #define PARM_SKY_SPHERE 17 // sky is quake sphere ? #define PARM_MAP_HAS_MIRRORS 18 // current map has mirorrs #define PARM_MAP_HAS_DELUXE 19 // map has deluxedata @@ -225,7 +225,7 @@ typedef struct render_api_s void (*pfnMemFree)( void *mem, const char *filename, const int fileline ); // find in files char **(*pfnGetFilesList)( const char *pattern, int *numFiles, int gamedironly ); - unsigned int (*pfnFileBufferCRC32)( const void *buffer, const int length ); + unsigned long (*pfnFileBufferCRC32)( const void *buffer, const int length ); // ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 35 } render_api_t; diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index f01106be..2c120de0 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -2801,7 +2801,6 @@ void pfnSPR_DrawGeneric( int frame, int x, int y, const wrect_t *prc, int blends ============= pfnDrawString -TODO: implement ============= */ int pfnDrawString( int x, int y, const char *str, int r, int g, int b ) @@ -2817,7 +2816,6 @@ int pfnDrawString( int x, int y, const char *str, int r, int g, int b ) ============= pfnDrawStringReverse -TODO: implement ============= */ int pfnDrawStringReverse( int x, int y, const char *str, int r, int g, int b ) @@ -2847,7 +2845,6 @@ const char *LocalPlayerInfo_ValueForKey( const char* key ) ============= pfnVGUI2DrawCharacter -TODO: implement ============= */ int pfnVGUI2DrawCharacter( int x, int y, int ch, unsigned int font ) @@ -2859,7 +2856,6 @@ int pfnVGUI2DrawCharacter( int x, int y, int ch, unsigned int font ) ============= pfnVGUI2DrawCharacterAdditive -TODO: implement ============= */ int pfnVGUI2DrawCharacterAdditive( int x, int y, int ch, int r, int g, int b, unsigned int font ) @@ -2975,11 +2971,12 @@ int pfnGetAppID( void ) ============= pfnVguiWrap2_GetMouseDelta -TODO: implement ============= */ void pfnVguiWrap2_GetMouseDelta( int *x, int *y ) { + if( x ) *x = 0; + if( y ) *y = 0; } /* @@ -4076,9 +4073,8 @@ qboolean CL_LoadProgs( const char *name ) clgame.mempool = Mem_AllocPool( "Client Edicts Zone" ); clgame.entities = NULL; - // NOTE: important stuff! - // vgui must startup BEFORE loading client.dll to avoid get error ERROR_NOACESS - // during LoadLibrary + // NOTE: important stuff! vgui must startup BEFORE loading client.dll + // to avoid get error ERROR_NOACESS during LoadLibrary VGui_Startup (); clgame.hInstance = Com_LoadLibrary( name, false ); diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index e4e2ccf7..81be6fba 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -513,6 +513,8 @@ void CL_ParseStaticEntity( sizebuf_t *msg ) state.frame = MSG_ReadByte( msg ); state.colormap = MSG_ReadWord( msg ); state.skin = MSG_ReadByte( msg ); + state.body = MSG_ReadByte( msg ); + state.scale = MSG_ReadCoord( msg ); for( i = 0; i < 3; i++ ) { @@ -693,12 +695,16 @@ void CL_ParseServerData( sizebuf_t *msg ) cl.maxclients = MSG_ReadByte( msg ); clgame.maxEntities = MSG_ReadWord( msg ); clgame.maxEntities = bound( 600, 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 ); background = MSG_ReadOneBit( msg ); Q_strncpy( gamefolder, MSG_ReadString( msg ), MAX_STRING ); host.features = (uint)MSG_ReadLong( msg ); + if( clgame.maxModels > MAX_MODELS ) + MsgDev( D_WARN, "server model limit is above client model limit %i > %i\n", clgame.maxModels, MAX_MODELS ); + if( Con_FixedFont( )) { // seperate the printfs so the server message can have a color diff --git a/engine/client/cl_view.c b/engine/client/cl_view.c index 988a397b..02892096 100644 --- a/engine/client/cl_view.c +++ b/engine/client/cl_view.c @@ -92,7 +92,7 @@ void V_SetupViewModel( void ) view->model = Mod_Handle( cl.local.viewmodel ); view->curstate.modelindex = cl.local.viewmodel; view->curstate.sequence = cl.local.weaponsequence; - view->curstate.rendermode = kRenderNormal; // EXPERIMENTAL!!! + view->curstate.rendermode = kRenderNormal; // alias models has another animation methods if( view->model && view->model->type == mod_studio ) diff --git a/engine/client/client.h b/engine/client/client.h index 5fb3ae88..b2858bed 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -243,8 +243,8 @@ typedef struct char event_precache[MAX_EVENTS][CS_SIZE]; lightstyle_t lightstyles[MAX_LIGHTSTYLES]; - int sound_index[MAX_SOUNDS]; - int decal_index[MAX_DECALS]; + short sound_index[MAX_SOUNDS]; + short decal_index[MAX_DECALS]; cl_entity_t *world; model_t *worldmodel; // pointer to world @@ -420,7 +420,7 @@ typedef struct int flags; // FNETAPI_MULTIPLE_RESPONSE etc } net_request_t; -// new versions of client dlls have a sanigle export with all callbacks +// new versions of client dlls have a single export with all callbacks typedef void (*CL_EXPORT_FUNCS)( void *pv ); typedef struct @@ -440,6 +440,7 @@ typedef struct int maxEntities; int maxRemapInfos; // maxEntities + cl.viewEnt; also used for catch entcount int numStatics; // actual static entity count + int maxModels; // movement values from server movevars_t movevars; diff --git a/engine/client/gl_cull.c b/engine/client/gl_cull.c index 4071024a..51fd4d7c 100644 --- a/engine/client/gl_cull.c +++ b/engine/client/gl_cull.c @@ -126,8 +126,7 @@ int R_CullSurface( msurface_t *surf, gl_frustum_t *frustum, uint clipflags ) { vec3_t orthonormal; - if( e == clgame.entities || R_StaticEntity( e )) - orthonormal[2] = surf->plane->normal[2]; + if( e == clgame.entities ) orthonormal[2] = surf->plane->normal[2]; else Matrix4x4_VectorRotate( RI.objectMatrix, surf->plane->normal, orthonormal ); dist = orthonormal[2]; diff --git a/engine/client/gl_local.h b/engine/client/gl_local.h index cfa93133..a4fb5769 100644 --- a/engine/client/gl_local.h +++ b/engine/client/gl_local.h @@ -36,6 +36,7 @@ extern byte *r_temppool; #define SUBDIVIDE_SIZE 64 #define MAX_MIRRORS 32 // per one frame! #define MAX_DECAL_SURFS 4096 +#define MAX_MIRROR_ENTITIES MAX_MIRRORS #define SHADEDOT_QUANT 16 // precalculated dot products for quantized angles #define SHADE_LAMBERT 1.495f @@ -194,11 +195,9 @@ typedef struct int skyboxbasenum; // start with 5800 // entity lists - cl_entity_t *static_entities[MAX_VISIBLE_PACKET]; // opaque non-moved brushes - gl_entity_t mirror_entities[MAX_VISIBLE_PACKET]; // an entities that has mirror + gl_entity_t mirror_entities[MAX_MIRROR_ENTITIES]; // an entities that has mirror cl_entity_t *solid_entities[MAX_VISIBLE_PACKET]; // opaque moving or alpha brushes cl_entity_t *trans_entities[MAX_VISIBLE_PACKET]; // translucent brushes - uint num_static_entities; uint num_mirror_entities; uint num_solid_entities; uint num_trans_entities; @@ -258,7 +257,7 @@ extern mleaf_t *r_viewleaf, *r_oldviewleaf; extern mleaf_t *r_viewleaf2, *r_oldviewleaf2; extern dlight_t cl_dlights[MAX_DLIGHTS]; extern dlight_t cl_elights[MAX_ELIGHTS]; -#define r_numEntities (tr.num_solid_entities + tr.num_trans_entities + tr.num_static_entities) +#define r_numEntities (tr.num_solid_entities + tr.num_trans_entities) #define r_numStatics (r_stats.c_client_ents) extern struct beam_s *cl_active_beams; @@ -368,7 +367,6 @@ void R_LoadIdentity( void ); void R_RenderScene( void ); void R_DrawCubemapView( const vec3_t origin, const vec3_t angles, int size ); void R_SetupRefParams( const struct ref_viewpass_s *rvp ); -qboolean R_StaticEntity( cl_entity_t *ent ); void R_TranslateForEntity( cl_entity_t *e ); void R_RotateForEntity( cl_entity_t *e ); void R_SetupGL( qboolean set_gl_state ); @@ -666,7 +664,6 @@ extern convar_t *gl_lightmap_nearest; extern convar_t *gl_keeptjunctions; extern convar_t *gl_detailscale; extern convar_t *gl_wireframe; -extern convar_t *gl_allow_static; extern convar_t *gl_allow_mirrors; extern convar_t *gl_polyoffset; extern convar_t *gl_finish; diff --git a/engine/client/gl_mirror.c b/engine/client/gl_mirror.c index 82255665..c09c826c 100644 --- a/engine/client/gl_mirror.c +++ b/engine/client/gl_mirror.c @@ -429,6 +429,9 @@ void R_FindBmodelMirrors( cl_entity_t *e, qboolean static_entity ) gl_frustum_t *frustum = NULL; int i; + if( tr.num_mirror_entities >= MAX_MIRROR_ENTITIES ) + return; + clmodel = e->model; // don't draw any water reflections if we underwater @@ -511,24 +514,7 @@ void R_CheckEntitiesOnList( void ) { int i; - // check static entities - for( i = 0; i < tr.num_static_entities; i++ ) - { - RI.currententity = tr.static_entities[i]; - RI.currentmodel = RI.currententity->model; - - ASSERT( RI.currententity != NULL ); - ASSERT( RI.currententity->model != NULL ); - - switch( RI.currentmodel->type ) - { - case mod_brush: - R_FindBmodelMirrors( RI.currententity, true ); - break; - } - } - - // world or static entities has mirror surfaces + // world has mirror surfaces if( tr.mirror_entities[0].chain != NULL ) { tr.mirror_entities[0].ent = clgame.entities; diff --git a/engine/client/gl_rmain.c b/engine/client/gl_rmain.c index b7ae3f65..1ccfc906 100644 --- a/engine/client/gl_rmain.c +++ b/engine/client/gl_rmain.c @@ -61,40 +61,6 @@ void R_AllowFog( int allowed ) } } -/* -=============== -R_StaticEntity - -Static entity is the brush which has no custom origin and not rotated -typically is a func_wall, func_breakable, func_ladder etc -=============== -*/ -qboolean R_StaticEntity( cl_entity_t *ent ) -{ - if( !gl_allow_static->value ) - return false; - - if( ent->curstate.rendermode != kRenderNormal ) - return false; - - if( ent->model->type != mod_brush ) - return false; - - if( ent->curstate.effects & ( EF_NOREFLECT|EF_REFLECTONLY )) - return false; - - if( ent->curstate.frame || ent->model->flags & MODEL_CONVEYOR ) - return false; - - if( ent->curstate.scale ) // waveheight specified - return false; - - if( !VectorIsNull( ent->origin ) || !VectorIsNull( ent->angles )) - return false; - - return true; -} - /* =============== R_OpaqueEntity @@ -106,13 +72,6 @@ static qboolean R_OpaqueEntity( cl_entity_t *ent ) { if( ent->curstate.rendermode == kRenderNormal ) return true; -#if 0 - if( ent->model->type != mod_brush ) - return false; - - if( ent->curstate.rendermode == kRenderTransAlpha ) - return true; -#endif return false; } @@ -237,7 +196,7 @@ R_ClearScene void R_ClearScene( void ) { tr.num_solid_entities = tr.num_trans_entities = 0; - tr.num_static_entities = tr.num_mirror_entities = 0; + tr.num_mirror_entities = 0; cl.num_custombeams = 0; } @@ -265,24 +224,12 @@ qboolean R_AddEntity( struct cl_entity_s *clent, int type ) if( R_OpaqueEntity( clent )) { - if( R_StaticEntity( clent )) - { - // opaque static - if( tr.num_static_entities >= MAX_VISIBLE_PACKET ) - return false; + // opaque + if( tr.num_solid_entities >= MAX_VISIBLE_PACKET ) + return false; - tr.static_entities[tr.num_static_entities] = clent; - tr.num_static_entities++; - } - else - { - // opaque moving - if( tr.num_solid_entities >= MAX_VISIBLE_PACKET ) - return false; - - tr.solid_entities[tr.num_solid_entities] = clent; - tr.num_solid_entities++; - } + tr.solid_entities[tr.num_solid_entities] = clent; + tr.num_solid_entities++; } else { @@ -455,7 +402,7 @@ void R_RotateForEntity( cl_entity_t *e ) { float scale = 1.0f; - if( e == clgame.entities || R_StaticEntity( e )) + if( e == clgame.entities ) { R_LoadIdentity(); return; @@ -481,7 +428,7 @@ void R_TranslateForEntity( cl_entity_t *e ) { float scale = 1.0f; - if( e == clgame.entities || R_StaticEntity( e )) + if( e == clgame.entities ) { R_LoadIdentity(); return; @@ -1209,6 +1156,11 @@ static int GL_RenderGetParm( int parm, int arg ) case PARM_TEX_DEPTH: glt = R_GetTexture( arg ); return glt->depth; + case PARM_BSP2_SUPPORTED: +#ifdef SUPPORT_BSP2_FORMAT + return 1; +#endif + return 0; case PARM_TEX_SKYBOX: ASSERT( arg >= 0 && arg < 6 ); return tr.skyboxTextures[arg]; @@ -1219,10 +1171,6 @@ static int GL_RenderGetParm( int parm, int arg ) return tr.lightmapTextures[arg]; case PARM_SKY_SPHERE: return world.sky_sphere && !world.custom_skybox; - case PARM_WORLD_VERSION: - if( cls.state != ca_active ) - return bmodel_version; - return world.version; case PARM_WIDESCREEN: return glState.wideScreen; case PARM_FULLSCREEN: diff --git a/engine/client/gl_rsurf.c b/engine/client/gl_rsurf.c index 29ed12c3..5ba572d3 100644 --- a/engine/client/gl_rsurf.c +++ b/engine/client/gl_rsurf.c @@ -505,6 +505,8 @@ void R_AddDynamicLights( msurface_t *surf ) { if( surf->texinfo->faceinfo ) sample_frac = surf->texinfo->faceinfo->texture_step; + else if( FBitSet( surf->texinfo->flags, TEX_EXTRA_LIGHTMAP )) + sample_frac = LM_SAMPLE_EXTRASIZE; else sample_frac = LM_SAMPLE_SIZE; } @@ -1607,84 +1609,6 @@ void R_DrawBrushModel( cl_entity_t *e ) R_LoadIdentity(); // restore worldmatrix } -/* -================= -R_DrawStaticModel - -Merge static model brushes with world surfaces -================= -*/ -void R_DrawStaticModel( cl_entity_t *e ) -{ - int i, k; - model_t *clmodel; - msurface_t *psurf; - dlight_t *l; - - clmodel = e->model; - if( R_CullBox( clmodel->mins, clmodel->maxs )) - return; - - // calculate dynamic lighting for bmodel - for( k = 0, l = cl_dlights; k < MAX_DLIGHTS; k++, l++ ) - { - if( l->die < cl.time || !l->radius ) - continue; - R_MarkLights( l, 1<nodes + clmodel->hulls[0].firstclipnode ); - } - - psurf = &clmodel->surfaces[clmodel->firstmodelsurface]; - for( i = 0; i < clmodel->nummodelsurfaces; i++, psurf++ ) - { - if( R_CullSurface( psurf, &RI.frustum, 0 )) - continue; - - if( psurf->flags & SURF_DRAWSKY ) - { - // make sky chain to right clip the skybox - psurf->texturechain = skychain; - skychain = psurf; - } - else - { - psurf->texturechain = psurf->texinfo->texture->texturechain; - psurf->texinfo->texture->texturechain = psurf; - } - } -} - -/* -================= -R_DrawStaticBrushes - -Insert static brushes into world texture chains -================= -*/ -void R_DrawStaticBrushes( void ) -{ - int i; - - // draw static entities - for( i = 0; i < tr.num_static_entities; i++ ) - { - RI.currententity = tr.static_entities[i]; - RI.currentmodel = RI.currententity->model; - - ASSERT( RI.currententity != NULL ); - ASSERT( RI.currententity->model != NULL ); - - switch( RI.currententity->model->type ) - { - case mod_brush: - R_DrawStaticModel( RI.currententity ); - break; - default: - Host_Error( "R_DrawStatics: non bsp model in static list!\n" ); - break; - } - } -} - /* ============================================================= @@ -1998,15 +1922,9 @@ void R_DrawWorld( void ) R_ClearSkyBox (); if( RI.drawOrtho ) - { R_DrawWorldTopView( cl.worldmodel->nodes, RI.frustum.clipFlags ); - } - else - { - R_RecursiveWorldNode( cl.worldmodel->nodes, RI.frustum.clipFlags ); - } + else R_RecursiveWorldNode( cl.worldmodel->nodes, RI.frustum.clipFlags ); - R_DrawStaticBrushes(); R_DrawTextureChains(); if( !CL_IsDevOverviewMode( )) diff --git a/engine/client/gl_vidnt.c b/engine/client/gl_vidnt.c index 4018e0d7..9e004db5 100644 --- a/engine/client/gl_vidnt.c +++ b/engine/client/gl_vidnt.c @@ -36,7 +36,6 @@ convar_t *gl_keeptjunctions; convar_t *gl_showtextures; convar_t *gl_detailscale; convar_t *gl_check_errors; -convar_t *gl_allow_static; convar_t *gl_allow_mirrors; convar_t *gl_polyoffset; convar_t *gl_wireframe; @@ -1593,7 +1592,6 @@ void GL_InitCommands( void ) gl_texture_anisotropy = Cvar_Get( "gl_anisotropy", "2.0", FCVAR_ARCHIVE, "textures anisotropic filter" ); gl_texture_lodbias = Cvar_Get( "gl_texture_lodbias", "0.0", FCVAR_ARCHIVE, "LOD bias for mipmapped textures (prefomance|quality)" ); gl_keeptjunctions = Cvar_Get( "gl_keeptjunctions", "1", FCVAR_ARCHIVE, "removing tjuncs causes blinking pixels" ); - gl_allow_static = Cvar_Get( "gl_allow_static", "0", FCVAR_ARCHIVE, "force to drawing non-moveable brushes as part of world (save FPS)" ); gl_allow_mirrors = Cvar_Get( "gl_allow_mirrors", "1", FCVAR_ARCHIVE, "allow to draw mirror surfaces" ); gl_showtextures = Cvar_Get( "r_showtextures", "0", FCVAR_CHEAT, "show all uploaded textures" ); gl_finish = Cvar_Get( "gl_finish", "0", FCVAR_ARCHIVE, "use glFinish instead of glFlush" ); diff --git a/engine/common/con_utils.c b/engine/common/con_utils.c index 27c95355..dcc93836 100644 --- a/engine/common/con_utils.c +++ b/engine/common/con_utils.c @@ -94,10 +94,7 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length ) { case Q1BSP_VERSION: case HLBSP_VERSION: - case XTBSP_VERSION: -#ifdef SUPPORT_BSP2_FORMAT case QBSP2_VERSION: -#endif if( header->lumps[LUMP_ENTITIES].fileofs <= 1024 && !(header->lumps[LUMP_ENTITIES].filelen % sizeof(dplane_t))) { lumpofs = header->lumps[LUMP_PLANES].fileofs; @@ -113,11 +110,9 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length ) break; } - if( ver == XTBSP_VERSION ) - hdrext = (dextrahdr_t *)((byte *)buf + sizeof( dheader31_t )); - else hdrext = (dextrahdr_t *)((byte *)buf + sizeof( dheader_t )); - - if( hdrext->id == IDEXTRAHEADER ) version = hdrext->version; + hdrext = (dextrahdr_t *)((byte *)buf + sizeof( dheader_t )); + if( hdrext->id == IDEXTRAHEADER ) + version = hdrext->version; Q_strncpy( entfilename, t->filenames[i], sizeof( entfilename )); FS_StripExtension( entfilename ); @@ -169,11 +164,9 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length ) if( mapver == 220 ) Q_strncpy( buf, "Half-Life Alpha", sizeof( buf )); else Q_strncpy( buf, "Quake", sizeof( buf )); break; -#ifdef SUPPORT_BSP2_FORMAT case QBSP2_VERSION: Q_strncpy( buf, "Darkplaces BSP2", sizeof( buf )); break; -#endif case HLBSP_VERSION: if( gearbox ) Q_strncpy( buf, "Blue-Shift", sizeof( buf )); else if( version == 1 ) Q_strncpy( buf, "XashXT old format", sizeof( buf )); @@ -182,13 +175,6 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length ) else if( version == 4 ) Q_strncpy( buf, "Half-Life extended", sizeof( buf )); else Q_strncpy( buf, "Half-Life", sizeof( buf )); break; - case XTBSP_VERSION: - if( version == 1 ) Q_strncpy( buf, "XashXT old format", sizeof( buf )); - else if( version == 2 ) Q_strncpy( buf, "Paranoia 2: Savior", sizeof( buf )); - else if( version == 3 ) Q_strncpy( buf, "not supported", sizeof( buf )); - else if( version == 4 ) Q_strncpy( buf, "Xash3D extended", sizeof( buf )); - else Q_strncpy( buf, "Xash3D", sizeof( buf )); - break; default: Q_strncpy( buf, "??", sizeof( buf )); break; } @@ -751,10 +737,7 @@ qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir ) { case Q1BSP_VERSION: case HLBSP_VERSION: - case XTBSP_VERSION: -#ifdef SUPPORT_BSP2_FORMAT case QBSP2_VERSION: -#endif header = (dheader_t *)buf; if( header->lumps[LUMP_ENTITIES].fileofs <= 1024 ) { diff --git a/engine/common/crclib.c b/engine/common/crclib.c index b9e5be5c..cb20237d 100644 --- a/engine/common/crclib.c +++ b/engine/common/crclib.c @@ -234,8 +234,7 @@ qboolean CRC32_MapFile( dword *crcvalue, const char *filename, qboolean multipla char headbuf[256], buffer[1024]; int i, num_bytes, lumplen; qboolean blue_shift = false; - int NUM_LUMPS, hdr_size; - int version; + int version, hdr_size; if( !crcvalue ) return false; @@ -253,11 +252,7 @@ qboolean CRC32_MapFile( dword *crcvalue, const char *filename, qboolean multipla FS_Read( f, &version, sizeof( int )); FS_Seek( f, 0, SEEK_SET ); - if( version == XTBSP_VERSION ) - NUM_LUMPS = 17; // two extra lumps added - else NUM_LUMPS = HEADER_LUMPS; - - hdr_size = sizeof( int ) + sizeof( dlump_t ) * NUM_LUMPS; + hdr_size = sizeof( int ) + sizeof( dlump_t ) * HEADER_LUMPS; num_bytes = FS_Read( f, headbuf, hdr_size ); // corrupted map ? @@ -274,7 +269,6 @@ qboolean CRC32_MapFile( dword *crcvalue, const char *filename, qboolean multipla { case Q1BSP_VERSION: case HLBSP_VERSION: - case XTBSP_VERSION: case QBSP2_VERSION: break; default: @@ -289,7 +283,7 @@ qboolean CRC32_MapFile( dword *crcvalue, const char *filename, qboolean multipla if( header->lumps[LUMP_ENTITIES].fileofs <= 1024 && (header->lumps[LUMP_ENTITIES].filelen % sizeof( dplane_t )) == 0 ) blue_shift = true; - for( i = 0; i < NUM_LUMPS; i++ ) + for( i = 0; i < HEADER_LUMPS; i++ ) { if( blue_shift && i == LUMP_PLANES ) continue; else if( i == LUMP_ENTITIES ) continue; diff --git a/engine/common/host.c b/engine/common/host.c index f07b8c80..c240ff5b 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -524,7 +524,7 @@ double Host_CalcFPS( void ) { double fps = 0.0; - // NOTE: we should play demos with same fps as is was recorded + // NOTE: we should play demos with same fps as it was recorded if( CL_IsPlaybackDemo() || CL_IsRecordDemo( )) fps = CL_GetDemoFramerate(); else if( Host_IsLocalGame( )) @@ -958,7 +958,7 @@ int EXPORT Host_Main( const char *progname, int bChangeGame, pfnChangeGame func host_limitlocal = Cvar_Get( "host_limitlocal", "0", 0, "apply cl_cmdrate and rate to loopback connection" ); con_gamemaps = Cvar_Get( "con_mapfilter", "1", FCVAR_ARCHIVE, "when true show only maps in game folder" ); build = Cvar_Get( "build", va( "%i", Q_buildnum()), FCVAR_READ_ONLY, "returns a current build number" ); - ver = Cvar_Get( "ver", va( "%i/%g (hw build %i)", PROTOCOL_VERSION, XASH_VERSION, Q_buildnum( )), FCVAR_READ_ONLY, "shows an engine version" ); + ver = Cvar_Get( "ver", va( "%i/%g (hw build %i)", PROTOCOL_VERSION, XASH_VERSION, Q_buildnum()), FCVAR_READ_ONLY, "shows an engine version" ); Mod_Init(); NET_Init(); diff --git a/engine/common/mod_local.h b/engine/common/mod_local.h index 89bbfb4b..73a5dc09 100644 --- a/engine/common/mod_local.h +++ b/engine/common/mod_local.h @@ -26,8 +26,6 @@ GNU General Public License for more details. #define FRAC_EPSILON (1.0f / 1024.0f) #define BACKFACE_EPSILON 0.01f #define MAX_BOX_LEAFS 256 -#define DVIS_PVS 0 -#define DVIS_PHS 1 #define ANIM_CYCLE 2 #define MOD_FRAMES 20 @@ -42,7 +40,8 @@ GNU General Public License for more details. #define PANTS_HUE_START 96 #define PANTS_HUE_END 112 -#define LM_SAMPLE_SIZE world.lm_sample_size // lightmap resoultion +#define LM_SAMPLE_SIZE 16 +#define LM_SAMPLE_EXTRASIZE 8 #define CHECKVISBIT( vis, b ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] & (1 << ((b) & 7))) : (byte)false ) #define SETVISBIT( vis, b )( void ) ((b) >= 0 ? (byte)((vis)[(b) >> 3] |= (1 << ((b) & 7))) : (byte)false ) @@ -79,7 +78,6 @@ typedef struct leaflist_s typedef struct { - int version; // bsp version int mapversion; // map version (an key-value in worldspawn settings) uint checksum; // current map checksum int load_sequence; // increace each map change @@ -91,7 +89,6 @@ typedef struct qboolean has_mirrors; // one or more brush models contain reflective textures qboolean custom_skybox; // if sky_sphere is active and custom skybox set qboolean water_alpha; // allow translucency water - int lm_sample_size; // defaulting to 16 (BSP31 uses 8) int block_size; // lightmap blocksize int lightmap_samples; // samples per pixel color24 *deluxedata; // deluxemap data pointer @@ -127,7 +124,6 @@ extern world_static_t world; extern byte *com_studiocache; extern model_t *loadmodel; extern convar_t *mod_studiocache; -extern int bmodel_version; // only actual during loading // // model.c @@ -152,7 +148,7 @@ model_t *Mod_LoadModel( model_t *mod, qboolean world ); model_t *Mod_ForName( const char *name, qboolean world ); qboolean Mod_RegisterModel( const char *name, int index ); mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node ); -qboolean Mod_HeadnodeVisible( mnode_t *node, const byte *visbits, short *lastleaf ); +qboolean Mod_HeadnodeVisible( mnode_t *node, const byte *visbits, int *lastleaf ); int Mod_BoxLeafnums( const vec3_t mins, const vec3_t maxs, short *list, int listsize, int *lastleaf ); int Mod_FatPVS( const vec3_t org, float radius, byte *visbuffer, int visbytes, qboolean merge, qboolean fullvis ); qboolean Mod_BoxVisible( const vec3_t mins, const vec3_t maxs, const byte *visbits ); diff --git a/engine/common/model.c b/engine/common/model.c index 70f3a9b7..64ea613e 100644 --- a/engine/common/model.c +++ b/engine/common/model.c @@ -33,7 +33,7 @@ static model_t *com_models[MAX_MODELS]; // shared replacement modeltable static model_t cm_models[MAX_MODELS]; static int cm_nummodels = 0; static byte visdata[MAX_MAP_LEAFS/8]; // intermediate buffer -int bmodel_version; // global stuff to detect bsp version +static int bmodel_version; // global stuff to detect bsp version char modelname[64]; // short model name (without path and ext) convar_t *mod_studiocache; convar_t *r_wadtextures; @@ -445,7 +445,7 @@ qboolean Mod_BoxVisible( const vec3_t mins, const vec3_t maxs, const byte *visbi Mod_HeadnodeVisible ============= */ -qboolean Mod_HeadnodeVisible( mnode_t *node, const byte *visbits, short *lastleaf ) +qboolean Mod_HeadnodeVisible( mnode_t *node, const byte *visbits, int *lastleaf ) { if( !node || node->contents == CONTENTS_SOLID ) return false; @@ -499,9 +499,13 @@ int Mod_SampleSizeForFace( msurface_t *surf ) if( !surf || !surf->texinfo ) return LM_SAMPLE_SIZE; + // world luxels has more priority if( FBitSet( surf->texinfo->flags, TEX_WORLD_LUXELS )) return 1; + if( FBitSet( surf->texinfo->flags, TEX_EXTRA_LIGHTMAP )) + return LM_SAMPLE_EXTRASIZE; + if( surf->texinfo->faceinfo ) return surf->texinfo->faceinfo->texture_step; @@ -758,7 +762,7 @@ static void Mod_LoadSubmodels( const dlump_t *l ) // spread the mins / maxs by a unit out->mins[j] = in->mins[j] - 1.0f; out->maxs[j] = in->maxs[j] + 1.0f; - out->origin[j] = in->origin[j]; + out->origin[j] = in->origin[j]; // new P2 compillers fills the origin field } for( j = 0; j < MAX_MAP_HULLS; j++ ) @@ -771,12 +775,6 @@ static void Mod_LoadSubmodels( const dlump_t *l ) if( i == 0 || !world.loading ) continue; // skip the world - if( VectorIsNull( out->origin )) - { - // NOTE: zero origin after recalculating is indicated included origin brush - VectorAverage( out->mins, out->maxs, out->origin ); - } - world.max_surfaces = Q_max( world.max_surfaces, out->numfaces ); } @@ -2426,83 +2424,6 @@ static void Mod_LoadClipnodes( const dlump_t *l ) loadmodel->numclipnodes = count; } -/* -================= -Mod_LoadClipnodes31 -================= -*/ -static void Mod_LoadClipnodes31( const dlump_t *l1, const dlump_t *l2, const dlump_t *l3 ) -{ - dclipnode_t *in1, *in2, *in3; - int i, count1, count2, count3; - dclipnode2_t *out; - - in1 = (dclipnode_t *)(mod_base + l1->fileofs); - if( l1->filelen % sizeof( *in1 )) Host_Error( "Mod_LoadClipnodes1: funny lump size\n" ); - count1 = l1->filelen / sizeof( *in1 ); - - in2 = (dclipnode_t *)(mod_base + l2->fileofs); - if( l2->filelen % sizeof( *in2 )) Host_Error( "Mod_LoadClipnodes2: funny lump size\n" ); - count2 = l2->filelen / sizeof( *in2 ); - - in3 = (dclipnode_t *)(mod_base + l3->fileofs); - if( l3->filelen % sizeof( *in3 )) Host_Error( "Mod_LoadClipnodes3: funny lump size\n" ); - count3 = l3->filelen / sizeof( *in3 ); - - world.clipnodes = out = (dclipnode2_t *)Mem_Alloc( loadmodel->mempool, ( count1 + count2 + count3 ) * sizeof( *out )); - if( world.loading ) world.clipnodesize = sizeof( dclipnode_t ); - world.numclipnodes = 0; - - for( i = 0; i < count1; i++, out++, in1++ ) - { - out->children[0] = in1->children[0]; - out->children[1] = in1->children[1]; - out->planenum = in1->planenum; - world.numclipnodes++; - } - - // merge offsets so we have shared array of clipnodes again - for( i = 0; i < count2; i++, out++, in2++ ) - { - out->children[0] = in2->children[0]; - out->children[1] = in2->children[1]; - out->planenum = in2->planenum; - - if( out->children[0] >= 0 ) - out->children[0] += count1; - if( out->children[1] >= 0 ) - out->children[1] += count1; - world.numclipnodes++; - } - - // merge offsets so we have shared array of clipnodes again - for( i = 0; i < count3; i++, out++, in3++ ) - { - out->children[0] = in3->children[0]; - out->children[1] = in3->children[1]; - out->planenum = in3->planenum; - - if( out->children[0] >= 0 ) - out->children[0] += (count1 + count2); - if( out->children[1] >= 0 ) - out->children[1] += (count1 + count2); - world.numclipnodes++; - } - - // fixup headnode offsets - for( i = 0; i < loadmodel->numsubmodels; i++ ) - { - loadmodel->submodels[i].headnode[2] += (count1); - loadmodel->submodels[i].headnode[3] += (count1 + count2); - } - - if( world.numclipnodes != ( count1 + count2 + count3 )) - Host_Error( "Mod_LoadClipnodes31: mismatch node count (%i should be %i)\n", world.numclipnodes, ( count1 + count2 + count3 )); - - // FIXME: fill loadmodel->clipnodes? - loadmodel->numclipnodes = world.numclipnodes; -} - /* ================= Mod_FindModelOrigin @@ -2518,7 +2439,10 @@ static void Mod_FindModelOrigin( const char *entities, const char *modelname, ve qboolean model_found; qboolean origin_found; - if( !entities || !modelname || !*modelname || !origin ) + if( !entities || !modelname || !*modelname ) + return; + + if( !origin || !VectorIsNull( origin )) return; pfile = (char *)entities; @@ -2644,7 +2568,6 @@ Mod_LoadBrushModel static void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *loaded ) { int i, j; - int sample_size; char *ents; dheader_t *header; dextrahdr_t *extrahdr; @@ -2654,47 +2577,29 @@ static void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *load if( loaded ) *loaded = false; header = (dheader_t *)buffer; loadmodel->type = mod_brush; + extrahdr = (dextrahdr_t *)((byte *)buffer + sizeof( dheader_t )); i = header->version; - // BSP31 and BSP30 have different offsets - if( i == XTBSP_VERSION ) - extrahdr = (dextrahdr_t *)((byte *)buffer + sizeof( dheader31_t )); - else extrahdr = (dextrahdr_t *)((byte *)buffer + sizeof( dheader_t )); - +#ifndef SUPPORT_BSP2_FORMAT + if( header->version == QBSP2_VERSION ) + { + MsgDev( D_ERROR, "%s can't be loaded in this build. Please rebuild engine with enabled SUPPORT_BSP2_FORMAT\n", loadmodel->name ); + return; + } +#endif switch( i ) { - case 28: // get support for quake1 beta - i = Q1BSP_VERSION; - sample_size = 16; - break; case Q1BSP_VERSION: case HLBSP_VERSION: case QBSP2_VERSION: - sample_size = 16; - break; - case XTBSP_VERSION: - sample_size = 8; break; default: - MsgDev( D_ERROR, "%s has wrong version number (%i should be %i)", loadmodel->name, i, HLBSP_VERSION ); + MsgDev( D_ERROR, "%s has wrong version number (%i should be %i)\n", loadmodel->name, i, HLBSP_VERSION ); return; } - // will be merged later - if( world.loading ) - { - world.lm_sample_size = sample_size; - world.version = i; - } - else if( world.lm_sample_size != sample_size ) - { - // can't mixing world and bmodels with different sample sizes! - MsgDev( D_ERROR, "%s has mismatch sample size (%i should be %i)", loadmodel->name, sample_size, world.lm_sample_size ); - return; - } - - loadmodel->numframes = sample_size; // NOTE: world store sample size into model_t->numframes - bmodel_version = i; // share it + loadmodel->numframes = 2; // g-cont. why is it necessary? + bmodel_version = i; // share tp global // swap all the lumps mod_base = (byte *)header; @@ -2730,10 +2635,7 @@ static void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *load Mod_LoadMarkSurfaces( &header->lumps[LUMP_MARKSURFACES] ); Mod_LoadLeafs( &header->lumps[LUMP_LEAFS] ); Mod_LoadNodes( &header->lumps[LUMP_NODES] ); - - if( bmodel_version == XTBSP_VERSION ) - Mod_LoadClipnodes31( &header->lumps[LUMP_CLIPNODES], &header->lumps[LUMP_CLIPNODES2], &header->lumps[LUMP_CLIPNODES3] ); - else Mod_LoadClipnodes( &header->lumps[LUMP_CLIPNODES] ); + Mod_LoadClipnodes( &header->lumps[LUMP_CLIPNODES] ); Mod_MakeHull0 (); @@ -2764,12 +2666,12 @@ static void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *load if( i != 0 ) { - // HACKHACK: c2a1 issues - if( !bm->origin[0] && !bm->origin[1] ) - SetBits( mod->flags, MODEL_HAS_ORIGIN ); - Mod_FindModelOrigin( ents, va( "*%i", i ), bm->origin ); + // HACKHACK: c2a1 issues + if( !Q_stricmp( loadmodel->name, "maps/c2a1.bsp" ) && ( i == 11 )) + SetBits( mod->flags, MODEL_HAS_ORIGIN ); + // flag 2 is indicated model with origin brush! if( !VectorIsNull( bm->origin )) SetBits( mod->flags, MODEL_HAS_ORIGIN ); @@ -2938,10 +2840,7 @@ model_t *Mod_LoadModel( model_t *mod, qboolean crash ) break; case Q1BSP_VERSION: case HLBSP_VERSION: - case XTBSP_VERSION: -#ifdef SUPPORT_BSP2_FORMAT case QBSP2_VERSION: -#endif Mod_LoadBrushModel( mod, buf, &loaded ); break; default: @@ -3293,7 +3192,7 @@ check lump for existing int Mod_CheckLump( const char *filename, const int lump, int *lumpsize ) { file_t *f = FS_Open( filename, "rb", true ); - byte buffer[sizeof( dheader31_t ) + sizeof( dextrahdr_t )]; + byte buffer[sizeof( dheader_t ) + sizeof( dextrahdr_t )]; size_t prefetch_size = sizeof( buffer ); dextrahdr_t *extrahdr; dheader_t *header; @@ -3308,16 +3207,13 @@ int Mod_CheckLump( const char *filename, const int lump, int *lumpsize ) header = (dheader_t *)buffer; - if( header->version != HLBSP_VERSION && header->version != XTBSP_VERSION ) + if( header->version != HLBSP_VERSION ) { FS_Close( f ); return LUMP_LOAD_BAD_VERSION; } - // BSP31 and BSP30 have different offsets - if( header->version == XTBSP_VERSION ) - extrahdr = (dextrahdr_t *)((byte *)buffer + sizeof( dheader31_t )); - else extrahdr = (dextrahdr_t *)((byte *)buffer + sizeof( dheader_t )); + extrahdr = (dextrahdr_t *)((byte *)buffer + sizeof( dheader_t )); if( extrahdr->id != IDEXTRAHEADER || extrahdr->version != EXTRA_VERSION ) { @@ -3355,7 +3251,7 @@ reading random lump by user request int Mod_ReadLump( const char *filename, const int lump, void **lumpdata, int *lumpsize ) { file_t *f = FS_Open( filename, "rb", true ); - byte buffer[sizeof( dheader31_t ) + sizeof( dextrahdr_t )]; + byte buffer[sizeof( dheader_t ) + sizeof( dextrahdr_t )]; size_t prefetch_size = sizeof( buffer ); dextrahdr_t *extrahdr; dheader_t *header; @@ -3372,16 +3268,13 @@ int Mod_ReadLump( const char *filename, const int lump, void **lumpdata, int *lu header = (dheader_t *)buffer; - if( header->version != HLBSP_VERSION && header->version != XTBSP_VERSION ) + if( header->version != HLBSP_VERSION ) { FS_Close( f ); return LUMP_LOAD_BAD_VERSION; } - // BSP31 and BSP30 have different offsets - if( header->version == XTBSP_VERSION ) - extrahdr = (dextrahdr_t *)((byte *)buffer + sizeof( dheader31_t )); - else extrahdr = (dextrahdr_t *)((byte *)buffer + sizeof( dheader_t )); + extrahdr = (dextrahdr_t *)((byte *)buffer + sizeof( dheader_t )); if( extrahdr->id != IDEXTRAHEADER || extrahdr->version != EXTRA_VERSION ) { @@ -3414,7 +3307,7 @@ int Mod_ReadLump( const char *filename, const int lump, void **lumpdata, int *lu if( FS_Read( f, data, length ) != length ) { - Mem_Free( data ); + free( data ); FS_Close( f ); return LUMP_LOAD_CORRUPTED; } @@ -3440,7 +3333,7 @@ only empty lumps is allows int Mod_SaveLump( const char *filename, const int lump, void *lumpdata, int lumpsize ) { file_t *f = FS_Open( filename, "e+b", true ); - byte buffer[sizeof( dheader31_t ) + sizeof( dextrahdr_t )]; + byte buffer[sizeof( dheader_t ) + sizeof( dextrahdr_t )]; size_t prefetch_size = sizeof( buffer ); dextrahdr_t *extrahdr; dheader_t *header; @@ -3458,16 +3351,13 @@ int Mod_SaveLump( const char *filename, const int lump, void *lumpdata, int lump header = (dheader_t *)buffer; - if( header->version != HLBSP_VERSION && header->version != XTBSP_VERSION ) + if( header->version != HLBSP_VERSION ) { FS_Close( f ); return LUMP_SAVE_BAD_VERSION; } - // BSP31 and BSP30 have different offsets - if( header->version == XTBSP_VERSION ) - extrahdr = (dextrahdr_t *)((byte *)buffer + sizeof( dheader31_t )); - else extrahdr = (dextrahdr_t *)((byte *)buffer + sizeof( dheader_t )); + extrahdr = (dextrahdr_t *)((byte *)buffer + sizeof( dheader_t )); if( extrahdr->id != IDEXTRAHEADER || extrahdr->version != EXTRA_VERSION ) { @@ -3500,9 +3390,7 @@ int Mod_SaveLump( const char *filename, const int lump, void *lumpdata, int lump } // update the header - if( header->version == XTBSP_VERSION ) - FS_Seek( f, sizeof( dheader31_t ), SEEK_SET ); - else FS_Seek( f, sizeof( dheader_t ), SEEK_SET ); + FS_Seek( f, sizeof( dheader_t ), SEEK_SET ); if( FS_Write( f, extrahdr, sizeof( dextrahdr_t )) != sizeof( dextrahdr_t )) { diff --git a/engine/common/protocol.h b/engine/common/protocol.h index 62e8f18b..7c2891d8 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -94,11 +94,7 @@ GNU General Public License for more details. #define clc_requestcvarvalue2 10 #define clc_lastmsg 10 // end client messages -#ifdef SUPPORT_BSP2_FORMAT -#define MAX_VISIBLE_PACKET_BITS 11 // 2048 visible entities per frame -#else -#define MAX_VISIBLE_PACKET_BITS 10 // 1024 visible entities per frame (hl1 has 256) -#endif +#define MAX_VISIBLE_PACKET_BITS 11 // 2048 visible entities per frame (hl1 has 256) #define MAX_VISIBLE_PACKET (1<netchan.message, playernum ); MSG_WriteByte( &cl->netchan.message, svgame.globals->maxClients ); MSG_WriteWord( &cl->netchan.message, svgame.globals->maxEntities ); + MSG_WriteWord( &cl->netchan.message, MAX_MODELS ); MSG_WriteString( &cl->netchan.message, sv.name ); MSG_WriteString( &cl->netchan.message, STRING( EDICT_NUM( 0 )->v.message )); // Map Message MSG_WriteOneBit( &cl->netchan.message, sv.background ); // tell client about background map diff --git a/engine/server/sv_game.c b/engine/server/sv_game.c index 16ed4cb8..47543ef7 100644 --- a/engine/server/sv_game.c +++ b/engine/server/sv_game.c @@ -504,6 +504,8 @@ void SV_CreateStaticEntity( sizebuf_t *msg, sv_static_entity_t *ent ) MSG_WriteByte( msg, ent->frame ); MSG_WriteWord( msg, ent->colormap ); MSG_WriteByte( msg, ent->skin ); + MSG_WriteByte( msg, ent->body ); + MSG_WriteCoord( msg, ent->scale ); for( i = 0; i < 3; i++ ) { @@ -587,10 +589,7 @@ void SV_WriteEntityPatch( const char *filename ) { case Q1BSP_VERSION: case HLBSP_VERSION: - case XTBSP_VERSION: -#ifdef SUPPORT_BSP2_FORMAT case QBSP2_VERSION: -#endif header = (dheader_t *)buf; if( header->lumps[LUMP_ENTITIES].fileofs <= 1024 && (header->lumps[LUMP_ENTITIES].filelen % sizeof( dplane_t )) == 0 ) { @@ -657,10 +656,7 @@ char *SV_ReadEntityScript( const char *filename, int *flags ) { case Q1BSP_VERSION: case HLBSP_VERSION: - case XTBSP_VERSION: -#ifdef SUPPORT_BSP2_FORMAT case QBSP2_VERSION: -#endif header = (dheader_t *)buf; if( header->lumps[LUMP_ENTITIES].fileofs <= 1024 && (header->lumps[LUMP_ENTITIES].filelen % sizeof( dplane_t )) == 0 ) { @@ -1124,6 +1120,12 @@ void pfnSetModel( edict_t *e, const char *m ) return; } + if( e == svgame.edicts ) + { + MsgDev( D_ERROR, "SV_SetModel: world model can't be changed\n" ); + return; + } + SV_SetModel( e, m ); } @@ -1689,6 +1691,8 @@ static void pfnMakeStatic( edict_t *ent ) clent->frame = ent->v.frame; clent->colormap = ent->v.colormap; clent->skin = ent->v.skin; + clent->body = ent->v.body; + clent->scale = ent->v.scale; clent->rendermode = ent->v.rendermode; clent->renderamt = ent->v.renderamt; clent->rendercolor.r = ent->v.rendercolor[0]; @@ -4083,7 +4087,7 @@ int pfnCheckVisibility( const edict_t *ent, byte *pset ) } else { - short leafnum; + int leafnum; for( i = 0; i < MAX_ENT_LEAFS; i++ ) { diff --git a/engine/server/sv_save.c b/engine/server/sv_save.c index 98e13102..883a3816 100644 --- a/engine/server/sv_save.c +++ b/engine/server/sv_save.c @@ -30,7 +30,7 @@ half-life implementation of saverestore system #define SAVEFILE_HEADER (('V'<<24)+('L'<<16)+('A'<<8)+'V') // little-endian "VALV" #define SAVEGAME_HEADER (('V'<<24)+('A'<<16)+('S'<<8)+'J') // little-endian "JSAV" #define SAVEGAME_VERSION 0x0065 // Version 0.65 -#define CLIENT_SAVEGAME_VERSION 0x0068 // Version 0.68 +#define CLIENT_SAVEGAME_VERSION 0x0070 // Version 0.70 #define SAVE_AGED_COUNT 2 #define SAVENAME_LENGTH 128 // matches with MAX_OSPATH @@ -39,7 +39,7 @@ half-life implementation of saverestore system #define LUMP_STATIC_OFFSET 1 #define LUMP_SOUNDS_OFFSET 2 #define LUMP_MUSIC_OFFSET 3 -#define NUM_CLIENT_OFFSETS 4 +#define NUM_CLIENT_LUMPS 8 void (__cdecl *pfnSaveGameComment)( char *buffer, int max_length ) = NULL; @@ -60,7 +60,7 @@ typedef struct typedef struct { - int offsets[NUM_CLIENT_OFFSETS]; + int offsets[NUM_CLIENT_LUMPS]; } ClientSections_t; typedef struct @@ -1147,10 +1147,12 @@ void SV_SaveClientState( SAVERESTOREDATA *pSaveData, const char *level ) { sv_static_entity_t *entry; byte nameSize; + word entScale; entry = &sv.static_entities[i]; nameSize = Q_strlen( entry->model ) + 1; + entScale = (entry->scale * 4096); FS_Write( pFile, &nameSize, sizeof( nameSize )); FS_Write( pFile, entry->model, nameSize ); @@ -1160,6 +1162,8 @@ void SV_SaveClientState( SAVERESTOREDATA *pSaveData, const char *level ) FS_Write( pFile, &entry->frame, sizeof( entry->frame )); FS_Write( pFile, &entry->colormap, sizeof( entry->colormap )); FS_Write( pFile, &entry->skin, sizeof( entry->skin )); + FS_Write( pFile, &entry->body, sizeof( entry->body )); + FS_Write( pFile, &entScale, sizeof( entScale )); FS_Write( pFile, &entry->rendermode, sizeof( entry->rendermode )); if( entry->rendermode != kRenderNormal ) @@ -1334,6 +1338,7 @@ void SV_LoadClientState( SAVERESTOREDATA *pSaveData, const char *level, qboolean { sv_static_entity_t *entry; byte nameSize; + word entScale; if( i >= MAX_STATIC_ENTITIES ) { @@ -1351,8 +1356,12 @@ void SV_LoadClientState( SAVERESTOREDATA *pSaveData, const char *level, qboolean FS_Read( pFile, &entry->frame, sizeof( entry->frame )); FS_Read( pFile, &entry->colormap, sizeof( entry->colormap )); FS_Read( pFile, &entry->skin, sizeof( entry->skin )); + FS_Read( pFile, &entry->body, sizeof( entry->body )); + FS_Read( pFile, &entScale, sizeof( entScale )); FS_Read( pFile, &entry->rendermode, sizeof( entry->rendermode )); + entry->scale = ((float)entScale / 4096.0f); + if( entry->rendermode != kRenderNormal ) { // write additional render data