From 5932684d4017381b6e1daaef2b3c24ba0ee6a9b9 Mon Sep 17 00:00:00 2001 From: g-cont Date: Mon, 27 Mar 2017 00:00:00 +0300 Subject: [PATCH] 27 Mar 2017 --- common/event_api.h | 3 +++ common/render_api.h | 9 ++++--- engine/client/cl_frame.c | 6 ++--- engine/client/cl_game.c | 39 ++++++++++++++++++++++++--- engine/client/cl_pmove.c | 8 +++--- engine/client/cl_tent.c | 12 ++++----- engine/client/cl_video.c | 1 + engine/client/client.h | 4 +-- engine/client/gl_image.c | 2 +- engine/client/gl_local.h | 4 ++- engine/client/gl_rlight.c | 9 +------ engine/client/gl_rmain.c | 26 +++++++++++++++--- engine/client/gl_rpart.c | 7 +++-- engine/client/gl_rsurf.c | 5 ++-- engine/client/gl_sprite.c | 4 +-- engine/client/gl_studio.c | 4 +-- engine/client/gl_vidnt.c | 3 ++- engine/common/cmd.c | 55 +++++++++++++++++++++++---------------- engine/common/common.h | 2 +- engine/common/crtlib.h | 1 + engine/common/host.c | 13 +++++---- 21 files changed, 142 insertions(+), 75 deletions(-) diff --git a/common/event_api.h b/common/event_api.h index d29aac99..a18f332e 100644 --- a/common/event_api.h +++ b/common/event_api.h @@ -49,6 +49,9 @@ typedef struct event_api_s void ( *EV_PlayerTraceExt )( float *start, float *end, int traceFlags, int (*pfnIgnore)( struct physent_s *pe ), struct pmtrace_s *tr ); const char *(*EV_SoundForIndex)( int index ); struct msurface_s *( *EV_TraceSurface )( int ground, float *vstart, float *vend ); + struct movevars_s *( *EV_GetMovevars )( void ); + struct pmtrace_s *( *EV_VisTraceLine )( float *start, float *end, int flags ); + struct physent_s *( *EV_GetVisent )( int idx ); } event_api_t; #endif//EVENT_API_H \ No newline at end of file diff --git a/common/render_api.h b/common/render_api.h index 81fdae1b..87c3fd68 100644 --- a/common/render_api.h +++ b/common/render_api.h @@ -58,7 +58,7 @@ GNU General Public License for more details. #define PARM_CLIENT_INGAME 25 #define PARM_FEATURES 26 // same as movevars->features #define PARM_ACTIVE_TMU 27 // for debug -//reserved +#define PARM_LIGHTSTYLEVALUE 28 // second arg is stylenum #define PARM_MAX_IMAGE_UNITS 29 #define PARM_CLIENT_ACTIVE 30 #define PARM_REBUILD_GAMMA 31 // if true lightmaps rebuilding for gamma change @@ -66,6 +66,7 @@ GNU General Public License for more details. #define PARM_SURF_SAMPLESIZE 33 // lightmap resolution per face (second arg interpret as facenumber) #define PARM_GL_CONTEXT_TYPE 34 // opengl or opengles #define PARM_GLES_WRAPPER 35 // +#define PARM_STENCIL_ACTIVE 36 enum { @@ -162,12 +163,12 @@ typedef struct render_api_s dlight_t* (*GetDynamicLight)( int number ); dlight_t* (*GetEntityLight)( int number ); byte (*LightToTexGamma)( byte color ); // software gamma support - void (*Reserved0)( void ); + float (*GetFrameTime)( void ); // Set renderer info (tell engine about changes) void (*R_SetCurrentEntity)( struct cl_entity_s *ent ); // tell engine about both currententity and currentmodel void (*R_SetCurrentModel)( struct model_s *mod ); // change currentmodel but leave currententity unchanged - void (*Reserved1)( void ); + int (*R_FatPVS)( const float *org, float radius, byte *visbuffer, qboolean merge, qboolean fullvis ); void (*R_StoreEfrags)( struct efrag_s **ppefrag, int framecount );// store efrags for static entities // Texture tools @@ -209,7 +210,7 @@ typedef struct render_api_s void (*GL_Reserved2)( void ); // Misc renderer functions - void (*GL_DrawParticles)( const struct ref_viewpass_s *rvp, qboolean solid_pass ); + void (*GL_DrawParticles)( const struct ref_viewpass_s *rvp, qboolean trans_pass ); void (*EnvShot)( const float *vieworg, const char *name, qboolean skyshot, int shotsize ); // creates a cubemap or skybox into gfx\env folder int (*COM_CompareFileTime)( const char *filename1, const char *filename2, int *iCompare ); void (*Host_Error)( const char *error, ... ); // cause Host Error diff --git a/engine/client/cl_frame.c b/engine/client/cl_frame.c index f3f40ae0..4818563e 100644 --- a/engine/client/cl_frame.c +++ b/engine/client/cl_frame.c @@ -1199,6 +1199,9 @@ void CL_EmitEntities( void ) // set client ideal pitch when mlook is disabled CL_SetIdealPitch (); + // think thirdperson camera + clgame.dllFuncs.CAM_Think (); + // link all the visible clients first CL_LinkPlayers ( &cl.frames[cl.parsecountmod] ); @@ -1214,9 +1217,6 @@ void CL_EmitEntities( void ) // fire events (client and server) CL_FireEvents (); - // think thirdperson camera - clgame.dllFuncs.CAM_Think (); - // handle spectator camera movement CL_MoveSpectatorCamera(); diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index c8db29c7..46501424 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -1194,7 +1194,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla } // load new map sprite - if( CL_LoadHudSprite( name, &clgame.sprites[i], type, 0 )) + if( CL_LoadHudSprite( name, &clgame.sprites[i], type, texFlags )) { if( i < ( MAX_IMAGES - 1 )) clgame.sprites[i].needload = clgame.load_sequence; @@ -2293,6 +2293,22 @@ physent_t *pfnGetPhysent( int idx ) return NULL; } +/* +============= +pfnGetVisent + +============= +*/ +physent_t *pfnGetVisent( int idx ) +{ + if( idx >= 0 && idx < clgame.pmove->numvisent ) + { + // return physent + return &clgame.pmove->visents[idx]; + } + return NULL; +} + /* ============= pfnSetTraceHull @@ -2362,6 +2378,17 @@ static struct msurface_s *pfnTraceSurface( int ground, float *vstart, float *ven pe = &clgame.pmove->physents[ground]; return PM_TraceSurface( pe, vstart, vend ); } + +/* +============= +pfnGetMovevars + +============= +*/ +static movevars_t *pfnGetMoveVars( void ) +{ + return &clgame.movevars; +} /* ============= @@ -3763,6 +3790,9 @@ static event_api_t gEventApi = CL_PlayerTraceExt, CL_SoundFromIndex, pfnTraceSurface, + pfnGetMoveVars, + CL_VisTraceLine, + pfnGetVisent, }; static demo_api_t gDemoApi = @@ -4080,8 +4110,11 @@ qboolean CL_LoadProgs( const char *name ) CL_InitStudioAPI( ); - // grab them from client.dll - cl_righthand = Cvar_Get( "cl_righthand", "0", FCVAR_ARCHIVE, "flip viewmodel (left to right)" ); + // trying to grab them from client.dll + cl_righthand = Cvar_FindVar( "cl_righthand" ); + + if( cl_righthand == NULL ) + cl_righthand = Cvar_Get( "cl_righthand", "0", FCVAR_ARCHIVE, "flip viewmodel (left to right)" ); return true; } \ No newline at end of file diff --git a/engine/client/cl_pmove.c b/engine/client/cl_pmove.c index aae59c61..80ad27a5 100644 --- a/engine/client/cl_pmove.c +++ b/engine/client/cl_pmove.c @@ -726,17 +726,17 @@ CL_VisTraceLine trace by visible objects (thats can be non-solid) ============= */ -pmtrace_t CL_VisTraceLine( vec3_t start, vec3_t end, int flags ) +pmtrace_t *CL_VisTraceLine( vec3_t start, vec3_t end, int flags ) { - int old_usehull; - pmtrace_t tr; + int old_usehull; + static pmtrace_t tr; old_usehull = clgame.pmove->usehull; clgame.pmove->usehull = 2; tr = PM_PlayerTraceExt( clgame.pmove, start, end, flags, clgame.pmove->numvisent, clgame.pmove->visents, -1, NULL ); clgame.pmove->usehull = old_usehull; - return tr; + return &tr; } /* diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index 103954e7..31496f13 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -2622,7 +2622,7 @@ void CL_UpdateFlashlight( cl_entity_t *ent ) vec3_t forward, view_ofs; vec3_t vecSrc, vecEnd; float falloff; - pmtrace_t trace; + pmtrace_t *trace; dlight_t *dl; if( ent->index == ( cl.playernum + 1 )) @@ -2658,14 +2658,14 @@ void CL_UpdateFlashlight( cl_entity_t *ent ) dl = CL_AllocDlight( ent->index ); #if 0 // g-cont. disabled until studio lighting will be finished - if( trace.ent > 0 && clgame.pmove->visents[trace.ent].studiomodel ) - VectorCopy( clgame.pmove->visents[trace.ent].origin, dl->origin ); - else VectorCopy( trace.endpos, dl->origin ); + if( trace->ent > 0 && clgame.pmove->visents[trace->ent].studiomodel ) + VectorCopy( clgame.pmove->visents[trace->ent].origin, dl->origin ); + else VectorCopy( trace->endpos, dl->origin ); #else - VectorCopy( trace.endpos, dl->origin ); + VectorCopy( trace->endpos, dl->origin ); #endif // compute falloff - falloff = trace.fraction * FLASHLIGHT_DISTANCE; + falloff = trace->fraction * FLASHLIGHT_DISTANCE; if( falloff < 500.0f ) falloff = 1.0f; else falloff = 500.0f / falloff; falloff *= falloff; diff --git a/engine/client/cl_video.c b/engine/client/cl_video.c index fe1136e3..c317986c 100644 --- a/engine/client/cl_video.c +++ b/engine/client/cl_video.c @@ -119,6 +119,7 @@ void SCR_CheckStartupVids( void ) { cls.movienum = 0; SCR_NextMovie (); + Cbuf_Execute(); } else cls.movienum = -1; } diff --git a/engine/client/client.h b/engine/client/client.h index 6f180042..772cd5eb 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -805,7 +805,7 @@ int CL_PointContents( const vec3_t p ); int CL_WaterEntity( const float *rgflPos ); cl_entity_t *CL_GetWaterEntity( const float *rgflPos ); void CL_SetupPMove( playermove_t *pmove, local_state_t *from, usercmd_t *ucmd, qboolean runfuncs, double time ); -pmtrace_t CL_VisTraceLine( vec3_t start, vec3_t end, int flags ); +pmtrace_t *CL_VisTraceLine( vec3_t start, vec3_t end, int flags ); pmtrace_t CL_TraceLine( vec3_t start, vec3_t end, int flags ); void CL_MoveSpectatorCamera( void ); qboolean CL_LocalWeapons( void ); @@ -853,7 +853,7 @@ void CL_WeaponAnim( int iAnim, int body ); void CL_ClearEffects( void ); void CL_ClearEfrags( void ); void CL_TestLights( void ); -void CL_DrawParticlesExternal( const ref_viewpass_t *rvp, qboolean solid_pass ); +void CL_DrawParticlesExternal( const ref_viewpass_t *rvp, qboolean trans_pass ); void CL_FireCustomDecal( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags, float scale ); void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags ); void CL_PlayerDecal( int textureIndex, int entityIndex, float *pos ); diff --git a/engine/client/gl_image.c b/engine/client/gl_image.c index 549a04b4..b7ca78da 100644 --- a/engine/client/gl_image.c +++ b/engine/client/gl_image.c @@ -808,7 +808,7 @@ byte *GL_ApplyGamma( const byte *source, int pixels, qboolean isNormalMap ) byte *out = (byte *)source; int i; - if( !isNormalMap ) + if( source && !isNormalMap ) { for( i = 0; i < pixels; i++, in += 4 ) { diff --git a/engine/client/gl_local.h b/engine/client/gl_local.h index a63a8013..cb11b416 100644 --- a/engine/client/gl_local.h +++ b/engine/client/gl_local.h @@ -203,8 +203,10 @@ typedef struct int realframecount; // not including viewpasses int framecount; + qboolean fResetVis; + + byte visbytes[(MAX_MAP_LEAFS+7)/8]; // member custom PVS int lightstylevalue[MAX_LIGHTSTYLES]; // value 0 - 65536 - float lightcache[MAX_LIGHTSTYLES]; double frametime; // special frametime for multipass rendering (will set to 0 on a nextview) float blend; // global blend value diff --git a/engine/client/gl_rlight.c b/engine/client/gl_rlight.c index e8c3ba14..f8d144d8 100644 --- a/engine/client/gl_rlight.c +++ b/engine/client/gl_rlight.c @@ -36,7 +36,7 @@ CL_RunLightStyles void CL_RunLightStyles( void ) { int i, k, flight, clight; - float l, c, lerpfrac, backlerp; + float l, lerpfrac, backlerp; float frametime = (cl.time - cl.oldtime); float scale; lightstyle_t *ls; @@ -52,7 +52,6 @@ void CL_RunLightStyles( void ) if( r_fullbright->value || !cl.worldmodel->lightdata ) { tr.lightstylevalue[i] = 256 * 256; - tr.lightcache[i] = 3.0f; continue; } @@ -67,20 +66,17 @@ void CL_RunLightStyles( void ) if( !ls->length ) { tr.lightstylevalue[i] = 256 * scale; - tr.lightcache[i] = 3.0f * scale; continue; } else if( ls->length == 1 ) { // single length style so don't bother interpolating tr.lightstylevalue[i] = ls->map[0] * 22 * scale; - tr.lightcache[i] = ( ls->map[0] / 12.0f ) * 3.0f * scale; continue; } else if( !ls->interp || !cl_lightstyle_lerping->value ) { tr.lightstylevalue[i] = ls->map[flight%ls->length] * 22 * scale; - tr.lightcache[i] = ( ls->map[flight%ls->length] / 12.0f ) * 3.0f * scale; continue; } @@ -88,15 +84,12 @@ void CL_RunLightStyles( void ) // frame just gone k = ls->map[flight % ls->length]; l = (float)( k * 22.0f ) * backlerp; - c = (float)( k / 12.0f ) * backlerp; // upcoming frame k = ls->map[clight % ls->length]; l += (float)( k * 22.0f ) * lerpfrac; - c += (float)( k / 12.0f ) * lerpfrac; tr.lightstylevalue[i] = (int)l * scale; - tr.lightcache[i] = c * 3.0f * scale; } } diff --git a/engine/client/gl_rmain.c b/engine/client/gl_rmain.c index bb6149e4..619f576d 100644 --- a/engine/client/gl_rmain.c +++ b/engine/client/gl_rmain.c @@ -1076,7 +1076,8 @@ void R_RenderFrame( const ref_viewpass_t *rvp ) { if( clgame.drawFuncs.GL_RenderFrame( rvp )) { - RI.viewleaf = NULL; // force markleafs next frame + tr.realframecount++; + tr.fResetVis = true; return; } } @@ -1174,7 +1175,7 @@ static int GL_RenderGetParm( int parm, int arg ) case PARM_TEX_SKYTEXNUM: return tr.skytexturenum; case PARM_TEX_LIGHTMAP: - ASSERT( arg >= 0 && arg < MAX_LIGHTMAPS ); + arg = bound( 0, arg, MAX_LIGHTMAPS - 1 ); return tr.lightmapTextures[arg]; case PARM_SKY_SPHERE: return world.sky_sphere && !world.custom_skybox; @@ -1209,6 +1210,9 @@ static int GL_RenderGetParm( int parm, int arg ) return host.features; case PARM_ACTIVE_TMU: return glState.activeTMU; + case PARM_LIGHTSTYLEVALUE: + arg = bound( 0, arg, MAX_LIGHTSTYLES - 1 ); + return tr.lightstylevalue[arg]; case PARM_MAP_HAS_DELUXE: return (world.deluxedata != NULL); case PARM_MAX_IMAGE_UNITS: @@ -1227,6 +1231,8 @@ static int GL_RenderGetParm( int parm, int arg ) return glConfig.context; case PARM_GLES_WRAPPER: return glConfig.wrapper; + case PARM_STENCIL_ACTIVE: + return glState.stencilEnabled; } return 0; } @@ -1307,6 +1313,13 @@ static void R_SetCurrentModel( model_t *mod ) RI.currentmodel = mod; } +static int R_FatPVS( const vec3_t org, float radius, byte *visbuffer, qboolean merge, qboolean fullvis ) +{ + int bytes = Mod_FatPVS( org, radius, visbuffer, world.visbytes, merge, fullvis ); + if( visbuffer ) memcpy( tr.visbytes, visbuffer, world.visbytes ); + return bytes; +} + static lightstyle_t *CL_GetLightStyle( int number ) { ASSERT( number >= 0 && number < MAX_LIGHTSTYLES ); @@ -1325,6 +1338,11 @@ static dlight_t *CL_GetEntityLight( int number ) return &cl_elights[number]; } +static float R_GetFrameTime( void ) +{ + return tr.frametime; +} + static const char *GL_TextureName( unsigned int texnum ) { return R_GetTexture( texnum )->name; @@ -1398,10 +1416,10 @@ static render_api_t gRenderAPI = CL_GetDynamicLight, CL_GetEntityLight, LightToTexGamma, - NULL, + R_GetFrameTime, R_SetCurrentEntity, R_SetCurrentModel, - NULL, + R_FatPVS, R_StoreEfrags, GL_FindTexture, GL_TextureName, diff --git a/engine/client/gl_rpart.c b/engine/client/gl_rpart.c index 65b6ab5a..18e090b3 100644 --- a/engine/client/gl_rpart.c +++ b/engine/client/gl_rpart.c @@ -655,7 +655,7 @@ CL_DrawParticlesExternal allow to draw effects from custom renderer =============== */ -void CL_DrawParticlesExternal( const ref_viewpass_t *rvp, qboolean solid_pass ) +void CL_DrawParticlesExternal( const ref_viewpass_t *rvp, qboolean trans_pass ) { ref_instance_t oldRI = RI; @@ -664,7 +664,10 @@ void CL_DrawParticlesExternal( const ref_viewpass_t *rvp, qboolean solid_pass ) R_SetupFrustum(); R_SetupGL( false ); // don't touch GL-states - if( solid_pass ) + // setup PVS for frame + memcpy( RI.visbytes, tr.visbytes, world.visbytes ); + + if( trans_pass == false ) { CL_DrawBeams( false ); } diff --git a/engine/client/gl_rsurf.c b/engine/client/gl_rsurf.c index 80199b70..50b9bea9 100644 --- a/engine/client/gl_rsurf.c +++ b/engine/client/gl_rsurf.c @@ -447,7 +447,7 @@ texture_t *R_TextureAnimation( msurface_t *s ) reletive = (int)(cl.time * speed) % base->anim_total; } - count = 0; + count = 0; while( base->anim_min > reletive || base->anim_max <= reletive ) { @@ -1962,10 +1962,11 @@ void R_MarkLeaves( void ) if( !RI.drawWorld ) return; - if( FBitSet( r_novis->flags, FCVAR_CHANGED )) + if( FBitSet( r_novis->flags, FCVAR_CHANGED ) || tr.fResetVis ) { // force recalc viewleaf ClearBits( r_novis->flags, FCVAR_CHANGED ); + tr.fResetVis = false; RI.viewleaf = NULL; } diff --git a/engine/client/gl_sprite.c b/engine/client/gl_sprite.c index 292900e3..0bf6c2c5 100644 --- a/engine/client/gl_sprite.c +++ b/engine/client/gl_sprite.c @@ -781,7 +781,7 @@ static float R_SpriteGlowBlend( vec3_t origin, int rendermode, int renderfx, flo { float dist, brightness; vec3_t glowDist; - pmtrace_t tr; + pmtrace_t *tr; VectorSubtract( origin, RI.vieworg, glowDist ); dist = VectorLength( glowDist ); @@ -790,7 +790,7 @@ static float R_SpriteGlowBlend( vec3_t origin, int rendermode, int renderfx, flo { tr = CL_VisTraceLine( RI.vieworg, origin, r_traceglow->value ? PM_GLASS_IGNORE : (PM_GLASS_IGNORE|PM_STUDIO_IGNORE)); - if(( 1.0f - tr.fraction ) * dist > 8.0f ) + if(( 1.0f - tr->fraction ) * dist > 8.0f ) return 0.0f; } diff --git a/engine/client/gl_studio.c b/engine/client/gl_studio.c index 072f4b25..7eac0e43 100644 --- a/engine/client/gl_studio.c +++ b/engine/client/gl_studio.c @@ -352,8 +352,8 @@ pfnGetEngineTimes static void pfnGetEngineTimes( int *framecount, double *current, double *old ) { if( framecount ) *framecount = tr.realframecount; - if( current ) *current = g_studio.time; - if( old ) *old = g_studio.time - g_studio.frametime; + if( current ) *current = cl.time; + if( old ) *old = cl.oldtime; } /* diff --git a/engine/client/gl_vidnt.c b/engine/client/gl_vidnt.c index d310bb78..ff29b5d2 100644 --- a/engine/client/gl_vidnt.c +++ b/engine/client/gl_vidnt.c @@ -121,6 +121,7 @@ vidmode_t vidmode[] = { "1680 x 1050 (wide)", 1680, 1050, true }, { "1920 x 1080 (wide)", 1920, 1080, true }, { "1920 x 1200 (wide)", 1920, 1200, true }, +{ "2560 x 1440 (wide)", 2560, 1440, true }, { "2560 x 1600 (wide)", 2560, 1600, true }, { "1600 x 900 (wide)", 1600, 900, true }, }; @@ -1584,7 +1585,7 @@ void GL_InitCommands( void ) window_xpos = Cvar_Get( "_window_xpos", "130", FCVAR_RENDERINFO, "window position by horizontal" ); window_ypos = Cvar_Get( "_window_ypos", "48", FCVAR_RENDERINFO, "window position by vertical" ); - gl_extensions = Cvar_Get( "gl_extensions", "1", FCVAR_GLCONFIG, "allow gl_extensions" ); + gl_extensions = Cvar_Get( "gl_allow_extensions", "1", FCVAR_GLCONFIG, "allow gl_extensions" ); gl_compress_textures = Cvar_Get( "gl_compress_textures", "0", FCVAR_GLCONFIG, "compress textures to safe video memory" ); gl_texture_nearest = Cvar_Get( "gl_texture_nearest", "0", FCVAR_ARCHIVE, "disable texture filter" ); gl_max_size = Cvar_Get( "gl_max_size", "512", FCVAR_ARCHIVE, "no effect in Xash3D just a legacy" ); diff --git a/engine/common/cmd.c b/engine/common/cmd.c index 4c11a07f..9a032b61 100644 --- a/engine/common/cmd.c +++ b/engine/common/cmd.c @@ -212,38 +212,22 @@ void Cbuf_Execute( void ) } } -/* -============================================================================== - - SCRIPT COMMANDS - -============================================================================== -*/ /* =============== -Cmd_StuffCmds_f +Cbuf_ExecStuffCmds -Adds command line parameters as script statements -Commands lead with a +, and continue until a - or another + -xash -dev 3 +map c1a0d -xash -nosound -game bshift +execute commandline =============== */ -void Cmd_StuffCmds_f( void ) +void Cbuf_ExecStuffCmds( void ) { - int i, j, l = 0; char build[MAX_CMD_LINE]; // this is for all commandline options combined (and is bounds checked) - - if( Cmd_Argc() != 1 ) - { - Msg( "Usage: stuffcmds : execute command line parameters\n" ); - return; - } + int i, j, l = 0; // no reason to run the commandline arguments twice - if( host.stuffcmdsrun ) return; + if( !host.stuffcmds_pending ) + return; - host.stuffcmdsrun = true; build[0] = 0; for( i = 0; i < host.argc; i++ ) @@ -282,6 +266,33 @@ void Cmd_StuffCmds_f( void ) // we already reserved space for the terminator build[l++] = 0; Cbuf_InsertText( build ); + Cbuf_Execute(); // apply now + + // this command can be called only from .rc + Cmd_RemoveCommand( "stuffcmds" ); + host.stuffcmds_pending = false; +} + +/* +============================================================================== + + SCRIPT COMMANDS + +============================================================================== +*/ +/* +=============== +Cmd_StuffCmds_f + +Adds command line parameters as script statements +Commands lead with a +, and continue until a - or another + +xash -dev 3 +map c1a0d +xash -nosound -game bshift +=============== +*/ +void Cmd_StuffCmds_f( void ) +{ + host.stuffcmds_pending = true; } /* diff --git a/engine/common/common.h b/engine/common/common.h index 7b03a3fe..4c36bc20 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -320,7 +320,7 @@ typedef struct host_parm_s int developer; // show all developer's message int old_developer; // keep real dev state (we need enable dev-mode in multiplayer) qboolean key_overstrike; // key overstrike mode - qboolean stuffcmdsrun; // execute stuff commands + qboolean stuffcmds_pending; // should execute stuff commands qboolean allow_cheats; // this host will allow cheating qboolean con_showalways; // show console always (developer and dedicated) qboolean com_handlecolon; // allow COM_ParseFile to handle colon as single char diff --git a/engine/common/crtlib.h b/engine/common/crtlib.h index 8f749245..ddd6db25 100644 --- a/engine/common/crtlib.h +++ b/engine/common/crtlib.h @@ -40,6 +40,7 @@ void Cbuf_Init( void ); void Cbuf_Clear( void ); void Cbuf_AddText( const char *text ); void Cbuf_InsertText( const char *text ); +void Cbuf_ExecStuffCmds( void ); void Cbuf_Execute (void); uint Cmd_Argc( void ); char *Cmd_Args( void ); diff --git a/engine/common/host.c b/engine/common/host.c index 7d600cff..2c1eba83 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -995,22 +995,21 @@ int EXPORT Host_Main( const char *progname, int bChangeGame, pfnChangeGame func // execute startup config and cmdline Cbuf_AddText( va( "exec %s.rc\n", SI.ModuleName )); Cbuf_AddText( "exec config.cfg\n" ); - // intentional fallthrough - case HOST_DEDICATED: - // if stuffcmds wasn't run, then init.rc is probably missing, use default - if( !host.stuffcmdsrun ) Cbuf_AddText( "stuffcmds\n" ); - Cbuf_Execute(); break; + case HOST_DEDICATED: + // allways parse commandline in dedicated-mode + host.stuffcmds_pending = true; + break; } host.change_game = false; // done Cmd_RemoveCommand( "setr" ); // remove potentially backdoor for change render settings Cmd_RemoveCommand( "setgl" ); + Cbuf_ExecStuffCmds(); // execute stuffcmds (commandline) + SCR_CheckStartupVids(); // must be last - // we need to execute it again here oldtime = Sys_DoubleTime() - 0.1; - SCR_CheckStartupVids(); // must be last // main window message loop while( !host.crashed )