From d913ef0fc47b6355f0a2f87fb5429b0cacd70490 Mon Sep 17 00:00:00 2001 From: mittorn Date: Thu, 7 Feb 2019 02:36:34 +0700 Subject: [PATCH 01/22] Port r_studio_drawelements render --- engine/client/gl_studio.c | 325 +++++++++++++++++++++++++++++++++++--- 1 file changed, 304 insertions(+), 21 deletions(-) diff --git a/engine/client/gl_studio.c b/engine/client/gl_studio.c index ed0ceff4..814a3ad0 100644 --- a/engine/client/gl_studio.c +++ b/engine/client/gl_studio.c @@ -102,13 +102,22 @@ typedef struct vec4_t lightpos[MAXSTUDIOVERTS][MAX_LOCALLIGHTS]; vec3_t lightbonepos[MAXSTUDIOBONES][MAX_LOCALLIGHTS]; float locallightR2[MAX_LOCALLIGHTS]; + + // drawelements renderer + vec3_t arrayverts[MAXSTUDIOVERTS]; + vec2_t arraycoord[MAXSTUDIOVERTS]; + unsigned short arrayelems[MAXSTUDIOVERTS*6]; + GLubyte arraycolor[MAXSTUDIOVERTS][4]; + uint numverts; + uint numelems; } studio_draw_state_t; // studio-related cvars -convar_t *r_studio_sort_textures; -convar_t *r_drawviewmodel; +static convar_t *r_studio_sort_textures; +static convar_t *r_drawviewmodel; convar_t *cl_righthand = NULL; -convar_t *cl_himodels; +static convar_t *cl_himodels; +static convar_t *r_studio_drawelements; static r_studio_interface_t *pStudioDraw; static studio_draw_state_t g_studio; // global studio state @@ -135,6 +144,7 @@ void R_StudioInit( void ) cl_himodels = Cvar_Get( "cl_himodels", "1", FCVAR_ARCHIVE, "draw high-resolution player models in multiplayer" ); r_studio_sort_textures = Cvar_Get( "r_studio_sort_textures", "0", FCVAR_ARCHIVE, "change draw order for additive meshes" ); r_drawviewmodel = Cvar_Get( "r_drawviewmodel", "1", 0, "draw firstperson weapon model" ); + r_studio_drawelements = Cvar_Get( "r_studio_drawelements", "1", FCVAR_ARCHIVE, "use glDrawElements for studiomodels" ); Matrix3x4_LoadIdentity( g_studio.rotationmatrix ); Cvar_RegisterVariable( &r_glowshellfreq ); @@ -1723,7 +1733,7 @@ R_LightLambert ==================== */ -void R_LightLambert( vec4_t light[MAX_LOCALLIGHTS], vec3_t normal, vec3_t color ) +void R_LightLambert( vec4_t light[MAX_LOCALLIGHTS], vec3_t normal, vec3_t color, byte *out ) { vec3_t finalLight; vec3_t localLight; @@ -1761,7 +1771,53 @@ void R_LightLambert( vec4_t light[MAX_LOCALLIGHTS], vec3_t normal, vec3_t color } } - pglColor4f( finalLight[0], finalLight[1], finalLight[2], tr.blend ); + out[0] = finalLight[0] * 255; + out[1] = finalLight[1] * 255; + out[2] = finalLight[2] * 255; +} + +static void R_StudioSetColorBegin(short *ptricmds, vec3_t *pstudionorms ) +{ + float *lv = (float *)g_studio.lightvalues[ptricmds[1]]; + rgba_t color; + + if( g_studio.numlocallights ) + { + color[3] = tr.blend * 255; + R_LightLambert( g_studio.lightpos[ptricmds[0]], pstudionorms[ptricmds[1]], lv, color ); + pglColor4ubv( color ); + } + else + { + if( RI.currententity->curstate.rendermode == kRenderTransColor ) + { + color[3] = tr.blend * 255; + VectorCopy( (byte*)&RI.currententity->curstate.rendercolor, color ); + pglColor4ubv( color ); + } + else pglColor4f( lv[0], lv[1], lv[2], tr.blend ); + } +} + +static void R_StudioSetColorArray(short *ptricmds, vec3_t *pstudionorms, byte *color ) +{ + float *lv = (float *)g_studio.lightvalues[ptricmds[1]]; + + color[3] = tr.blend * 255; + + if( g_studio.numlocallights ) + R_LightLambert( g_studio.lightpos[ptricmds[0]], pstudionorms[ptricmds[1]], lv, color ); + else + { + if( RI.currententity->curstate.rendermode == kRenderTransColor ) + VectorCopy( (byte*)&RI.currententity->curstate.rendercolor, color ); + else + { + color[0] = lv[0] * 255; + color[1] = lv[1] * 255; + color[2] = lv[2] * 255; + } + } } /* @@ -1934,11 +1990,8 @@ _inline void R_StudioDrawNormalMesh( short *ptricmds, vec3_t *pstudionorms, floa for( ; i > 0; i--, ptricmds += 4 ) { - lv = (float *)g_studio.lightvalues[ptricmds[1]]; + R_StudioSetColorBegin( ptricmds, pstudionorms ); - if( g_studio.numlocallights ) - R_LightLambert( g_studio.lightpos[ptricmds[0]], pstudionorms[ptricmds[1]], lv ); - else pglColor4f( lv[0], lv[1], lv[2], tr.blend ); pglTexCoord2f( ptricmds[2] * s, ptricmds[3] * t ); pglVertex3fv( g_studio.verts[ptricmds[0]] ); } @@ -1970,10 +2023,7 @@ _inline void R_StudioDrawFloatMesh( short *ptricmds, vec3_t *pstudionorms ) for( ; i > 0; i--, ptricmds += 4 ) { - lv = (float *)g_studio.lightvalues[ptricmds[1]]; - if( g_studio.numlocallights ) - R_LightLambert( g_studio.lightpos[ptricmds[0]], pstudionorms[ptricmds[1]], lv ); - else pglColor4f( lv[0], lv[1], lv[2], tr.blend ); + R_StudioSetColorBegin( ptricmds, pstudionorms ); pglTexCoord2f( HalfToFloat( ptricmds[2] ), HalfToFloat( ptricmds[3] )); pglVertex3fv( g_studio.verts[ptricmds[0]] ); } @@ -2009,10 +2059,13 @@ _inline void R_StudioDrawChromeMesh( short *ptricmds, vec3_t *pstudionorms, floa { if( glowShell ) { + color24 *clr = &RI.currententity->curstate.rendercolor; + idx = g_studio.normaltable[ptricmds[0]]; av = g_studio.verts[ptricmds[0]]; lv = g_studio.norms[ptricmds[0]]; VectorMA( av, scale, lv, vert ); + pglColor4ub( clr->r, clr->g, clr->b, 255 ); pglTexCoord2f( g_studio.chrome[idx][0] * s, g_studio.chrome[idx][1] * t ); pglVertex3fv( vert ); } @@ -2020,9 +2073,7 @@ _inline void R_StudioDrawChromeMesh( short *ptricmds, vec3_t *pstudionorms, floa { idx = ptricmds[1]; lv = (float *)g_studio.lightvalues[ptricmds[1]]; - if( g_studio.numlocallights ) - R_LightLambert( g_studio.lightpos[ptricmds[0]], pstudionorms[ptricmds[1]], lv ); - else pglColor4f( lv[0], lv[1], lv[2], tr.blend ); + R_StudioSetColorBegin( ptricmds, pstudionorms ); pglTexCoord2f( g_studio.chrome[idx][0] * s, g_studio.chrome[idx][1] * t ); pglVertex3fv( g_studio.verts[ptricmds[0]] ); } @@ -2032,6 +2083,220 @@ _inline void R_StudioDrawChromeMesh( short *ptricmds, vec3_t *pstudionorms, floa } } + +_inline int R_StudioBuildIndices( qboolean tri_strip, int vertexState ) +{ + // build in indices + if( vertexState++ < 3 ) + { + g_studio.arrayelems[g_studio.numelems++] = g_studio.numverts; + } + else if( tri_strip ) + { + // flip triangles between clockwise and counter clockwise + if( vertexState & 1 ) + { + // draw triangle [n-2 n-1 n] + g_studio.arrayelems[g_studio.numelems++] = g_studio.numverts - 2; + g_studio.arrayelems[g_studio.numelems++] = g_studio.numverts - 1; + g_studio.arrayelems[g_studio.numelems++] = g_studio.numverts; + } + else + { + // draw triangle [n-1 n-2 n] + g_studio.arrayelems[g_studio.numelems++] = g_studio.numverts - 1; + g_studio.arrayelems[g_studio.numelems++] = g_studio.numverts - 2; + g_studio.arrayelems[g_studio.numelems++] = g_studio.numverts; + } + } + else + { + // draw triangle fan [0 n-1 n] + g_studio.arrayelems[g_studio.numelems++] = g_studio.numverts - ( vertexState - 1 ); + g_studio.arrayelems[g_studio.numelems++] = g_studio.numverts - 1; + g_studio.arrayelems[g_studio.numelems++] = g_studio.numverts; + } + + return vertexState; +} + +/* +=============== +R_StudioDrawNormalMesh + +generic path +=============== +*/ +_inline void R_StudioBuildArrayNormalMesh( short *ptricmds, vec3_t *pstudionorms, float s, float t ) +{ + float *lv; + int i; + float alpha = tr.blend; + + while( i = *( ptricmds++ )) + { + int vertexState = 0; + qboolean tri_strip = true; + + if( i < 0 ) + { + tri_strip = false; + i = -i; + } + + for( ; i > 0; i--, ptricmds += 4 ) + { + GLubyte *cl; + cl = g_studio.arraycolor[g_studio.numverts]; + lv = (float *)g_studio.lightvalues[ptricmds[1]]; + + vertexState = R_StudioBuildIndices( tri_strip, vertexState ); + + R_StudioSetColorArray( ptricmds, pstudionorms, cl ); + + g_studio.arraycoord[g_studio.numverts][0] = ptricmds[2] * s; + g_studio.arraycoord[g_studio.numverts][1] = ptricmds[3] * t; + + VectorCopy( g_studio.verts[ptricmds[0]], g_studio.arrayverts[g_studio.numverts] ); + g_studio.numverts++; + } + } +} + +/* +=============== +R_StudioDrawNormalMesh + +generic path +=============== +*/ +_inline void R_StudioBuildArrayFloatMesh( short *ptricmds, vec3_t *pstudionorms ) +{ + float *lv; + int i; + float alpha = tr.blend; + + while( i = *( ptricmds++ )) + { + int vertexState = 0; + qboolean tri_strip = true; + + if( i < 0 ) + { + tri_strip = false; + i = -i; + } + + for( ; i > 0; i--, ptricmds += 4 ) + { + GLubyte *cl; + cl = g_studio.arraycolor[g_studio.numverts]; + lv = (float *)g_studio.lightvalues[ptricmds[1]]; + + vertexState = R_StudioBuildIndices( tri_strip, vertexState ); + + R_StudioSetColorArray( ptricmds, pstudionorms, cl ); + + g_studio.arraycoord[g_studio.numverts][0] = HalfToFloat( ptricmds[2] ); + g_studio.arraycoord[g_studio.numverts][1] = HalfToFloat( ptricmds[3] ); + + VectorCopy( g_studio.verts[ptricmds[0]], g_studio.arrayverts[g_studio.numverts] ); + g_studio.numverts++; + } + } +} + +/* +=============== +R_StudioDrawNormalMesh + +generic path +=============== +*/ +_inline void R_StudioBuildArrayChromeMesh( short *ptricmds, vec3_t *pstudionorms, float s, float t, float scale ) +{ + float *lv, *av; + int i, idx; + qboolean glowShell = (scale > 0.0f) ? true : false; + vec3_t vert; + float alpha = tr.blend; + + while( i = *( ptricmds++ )) + { + int vertexState = 0; + qboolean tri_strip = true; + + if( i < 0 ) + { + tri_strip = false; + i = -i; + } + + for( ; i > 0; i--, ptricmds += 4 ) + { + GLubyte *cl; + cl = g_studio.arraycolor[g_studio.numverts]; + lv = (float *)g_studio.lightvalues[ptricmds[1]]; + + vertexState = R_StudioBuildIndices( tri_strip, vertexState ); + + if( glowShell ) + { + idx = g_studio.normaltable[ptricmds[0]]; + av = g_studio.verts[ptricmds[0]]; + lv = g_studio.norms[ptricmds[0]]; + + cl[0] = RI.currententity->curstate.rendercolor.r; + cl[1] = RI.currententity->curstate.rendercolor.g; + cl[2] = RI.currententity->curstate.rendercolor.b; + cl[3] = 255; + + VectorMA( av, scale, lv, vert ); + VectorCopy( vert, g_studio.arrayverts[g_studio.numverts] ); + } + else + { + idx = ptricmds[1]; + R_StudioSetColorArray( ptricmds, pstudionorms, cl ); + + VectorCopy( g_studio.verts[ptricmds[0]], g_studio.arrayverts[g_studio.numverts] ); + } + + g_studio.arraycoord[g_studio.numverts][0] = g_studio.chrome[idx][0] * s; + g_studio.arraycoord[g_studio.numverts][1] = g_studio.chrome[idx][1] * t; + + g_studio.numverts++; + } + } +} + +_inline void R_StudioDrawArrays( uint startverts, uint startelems ) +{ + pglEnableClientState( GL_VERTEX_ARRAY ); + pglVertexPointer( 3, GL_FLOAT, 12, g_studio.arrayverts ); + + pglEnableClientState( GL_TEXTURE_COORD_ARRAY ); + pglTexCoordPointer( 2, GL_FLOAT, 0, g_studio.arraycoord ); + + if( !( g_nForceFaceFlags & STUDIO_NF_CHROME ) ) + { + pglEnableClientState( GL_COLOR_ARRAY ); + pglColorPointer( 4, GL_UNSIGNED_BYTE, 0, g_studio.arraycolor ); + } + +#if !defined XASH_NANOGL || defined XASH_WES && defined __EMSCRIPTEN__ // WebGL need to know array sizes + if( pglDrawRangeElements ) + pglDrawRangeElements( GL_TRIANGLES, startverts, g_studio.numverts, + g_studio.numelems - startelems, GL_UNSIGNED_SHORT, &g_studio.arrayelems[startelems] ); + else +#endif + pglDrawElements( GL_TRIANGLES, g_studio.numelems - startelems, GL_UNSIGNED_SHORT, &g_studio.arrayelems[startelems] ); + pglDisableClientState( GL_VERTEX_ARRAY ); + pglDisableClientState( GL_TEXTURE_COORD_ARRAY ); + if( !( g_nForceFaceFlags & STUDIO_NF_CHROME ) ) + pglDisableClientState( GL_COLOR_ARRAY ); +} + /* =============== R_StudioDrawPoints @@ -2054,6 +2319,9 @@ static void R_StudioDrawPoints( void ) if( !m_pStudioHeader ) return; + + g_studio.numverts = g_studio.numelems = 0; + // safety bounding the skinnum m_skinnum = bound( 0, RI.currententity->curstate.skin, ( m_pStudioHeader->numskinfamilies - 1 )); ptexture = (mstudiotexture_t *)((byte *)m_pStudioHeader + m_pStudioHeader->textureindex); @@ -2151,6 +2419,8 @@ static void R_StudioDrawPoints( void ) for( j = 0; j < m_pSubModel->nummesh; j++ ) { float oldblend = tr.blend; + uint startArrayVerts = g_studio.numverts; + uint startArrayElems = g_studio.numelems; short *ptricmds; float s, t; @@ -2184,11 +2454,24 @@ static void R_StudioDrawPoints( void ) R_StudioSetupSkin( m_pStudioHeader, pskinref[pmesh->skinref] ); - if( FBitSet( g_nFaceFlags, STUDIO_NF_CHROME )) - R_StudioDrawChromeMesh( ptricmds, pstudionorms, s, t, shellscale ); - else if( FBitSet( g_nFaceFlags, STUDIO_NF_UV_COORDS )) - R_StudioDrawFloatMesh( ptricmds, pstudionorms ); - else R_StudioDrawNormalMesh( ptricmds, pstudionorms, s, t ); + if( CVAR_TO_BOOL(r_studio_drawelements) ) + { + if( FBitSet( g_nFaceFlags, STUDIO_NF_CHROME )) + R_StudioBuildArrayChromeMesh( ptricmds, pstudionorms, s, t, shellscale ); + else if( FBitSet( g_nFaceFlags, STUDIO_NF_UV_COORDS )) + R_StudioBuildArrayFloatMesh( ptricmds, pstudionorms ); + else R_StudioBuildArrayNormalMesh( ptricmds, pstudionorms, s, t ); + + R_StudioDrawArrays( startArrayVerts, startArrayElems ); + } + else + { + if( FBitSet( g_nFaceFlags, STUDIO_NF_CHROME )) + R_StudioDrawChromeMesh( ptricmds, pstudionorms, s, t, shellscale ); + else if( FBitSet( g_nFaceFlags, STUDIO_NF_UV_COORDS )) + R_StudioDrawFloatMesh( ptricmds, pstudionorms ); + else R_StudioDrawNormalMesh( ptricmds, pstudionorms, s, t ); + } if( FBitSet( g_nFaceFlags, STUDIO_NF_MASKED )) { From 119b458b0f50756b987435367648b97cf13786e7 Mon Sep 17 00:00:00 2001 From: mittorn Date: Thu, 7 Feb 2019 04:35:42 +0700 Subject: [PATCH 02/22] vbo: optimize buffer usage, fix some rendermodes --- engine/client/gl_rsurf.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/engine/client/gl_rsurf.c b/engine/client/gl_rsurf.c index 76c0e81e..c99de9aa 100644 --- a/engine/client/gl_rsurf.c +++ b/engine/client/gl_rsurf.c @@ -1584,7 +1584,13 @@ void R_DrawBrushModel( cl_entity_t *e ) GL_SetupFogColorForSurfaces (); if( e->curstate.rendermode == kRenderTransAdd ) + { R_AllowFog( false ); + allow_vbo = false; + } + + if( e->curstate.rendermode == kRenderTransColor || e->curstate.rendermode == kRenderTransTexture ) + allow_vbo = false; psurf = &clmodel->surfaces[clmodel->firstmodelsurface]; num_sorted = 0; @@ -1959,7 +1965,7 @@ void R_GenerateVBO() // prepare decal array pglGenBuffersARB( 1, &vbos.decaldata->decalvbo ); pglBindBufferARB( GL_ARRAY_BUFFER_ARB, vbos.decaldata->decalvbo ); - pglBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof( vbovertex_t ) * DECAL_VERTS_CUT * MAX_RENDER_DECALS, vbos.decaldata->decalarray, GL_STATIC_DRAW_ARB ); + pglBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof( vbovertex_t ) * DECAL_VERTS_CUT * MAX_RENDER_DECALS, vbos.decaldata->decalarray, GL_DYNAMIC_DRAW_ARB ); // preallocate dlight arrays vbos.dlight_index = Mem_Calloc( vbos.mempool, maxindex * sizeof( unsigned short ) * 6 ); @@ -1971,10 +1977,10 @@ void R_GenerateVBO() { pglGenBuffersARB( 1, &vbos.dlight_vbo ); pglBindBufferARB( GL_ARRAY_BUFFER_ARB, vbos.dlight_vbo ); - pglBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof( vec2_t ) * (int)(vbos.arraylist->next?USHRT_MAX + 1:vbos.arraylist->array_len + 1) , vbos.dlight_tc, GL_DYNAMIC_DRAW_ARB ); + pglBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof( vec2_t ) * (int)(vbos.arraylist->next?USHRT_MAX + 1:vbos.arraylist->array_len + 1) , vbos.dlight_tc, GL_STREAM_DRAW_ARB ); pglGenBuffersARB( 1, &vbos.decal_dlight_vbo ); pglBindBufferARB( GL_ARRAY_BUFFER_ARB, vbos.decal_dlight_vbo ); - pglBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof( vbos.decal_dlight ), vbos.decal_dlight, GL_DYNAMIC_DRAW_ARB ); + pglBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof( vbos.decal_dlight ), vbos.decal_dlight, GL_STREAM_DRAW_ARB ); } From f7c60ea9d15d6fb6e55266717477a02315b707d3 Mon Sep 17 00:00:00 2001 From: mittorn Date: Thu, 7 Feb 2019 04:58:18 +0700 Subject: [PATCH 03/22] vbo: Fix return value --- engine/client/gl_rsurf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/client/gl_rsurf.c b/engine/client/gl_rsurf.c index c99de9aa..f3358346 100644 --- a/engine/client/gl_rsurf.c +++ b/engine/client/gl_rsurf.c @@ -885,7 +885,7 @@ _inline qboolean R_HasLightmap( void ) if( RI.currententity ) { if( RI.currententity->curstate.effects & EF_FULLBRIGHT ) - return; // disabled by user + return false; // disabled by user // check for rendermode switch( RI.currententity->curstate.rendermode ) From 1b372115a54b4467fab666f2a9d8f197b12d1c7b Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 19 Feb 2019 16:33:14 +0300 Subject: [PATCH 04/22] wscript: move options to subgroups, reorder option plugins loading --- engine/wscript | 15 +++++++++------ scripts/waflib/sdl2.py | 9 +++++---- vgui_support/wscript | 11 +++++------ wscript | 15 ++++++++------- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/engine/wscript b/engine/wscript index 213a88ef..93c1309c 100644 --- a/engine/wscript +++ b/engine/wscript @@ -9,17 +9,20 @@ from fwgslib import get_subproject_name top = '.' def options(opt): - opt.load('sdl2') - opt.add_option( - '--enable-bsp2', action = 'store_true', dest = 'SUPPORT_BSP2_FORMAT', default = False, - help = 'build engine with BSP2 map support(recommended for Quake, breaks compability!)') - opt.add_option( + grp = opt.add_option_group('Engine options') + grp.add_option( + '--enable-bsp2', action = 'store_true', dest = 'SUPPORT_BSP2_FORMAT', default = False, + help = 'build engine with BSP2 map support(recommended for Quake, breaks compatibility!)') + + grp.add_option( '--single-binary', action = 'store_true', dest = 'SINGLE_BINARY', default = None, help = 'build single "xash" binary instead of xash.dll/libxash.so (default for dedicated)') - opt.add_option( + + grp.add_option( '--stdin-input', action = 'store_true', dest = 'USE_SELECT', default = None, help = 'enable console input from stdin (default for dedicated)') + opt.load('sdl2') def configure(conf): # check for dedicated server build diff --git a/scripts/waflib/sdl2.py b/scripts/waflib/sdl2.py index 0f20fcd5..30d46b53 100644 --- a/scripts/waflib/sdl2.py +++ b/scripts/waflib/sdl2.py @@ -14,13 +14,14 @@ import os def options(opt): - opt.add_option( + grp = opt.add_option_group('SDL2 options') + grp.add_option( '--sdl2', action='store', type='string', dest = 'SDL2_PATH', default = None, - help = 'SDL2 path to build(required for Windows)') + help = 'path to precompiled SDL2 library(required for Windows)') - opt.add_option( + grp.add_option( '--skip-sdl2-sanity-check', action='store_false', default = True, dest='SDL2_SANITY_CHECK', - help = 'Skip checking SDL2 sanity') + help = 'skip checking SDL2 sanity') def my_dirname(path): # really dumb, will not work with /path/framework//, but still enough diff --git a/vgui_support/wscript b/vgui_support/wscript index e9e987f2..29d163d4 100644 --- a/vgui_support/wscript +++ b/vgui_support/wscript @@ -9,19 +9,18 @@ from fwgslib import get_subproject_name top = '.' def options(opt): - opt.add_option( + grp = opt.add_option_group('VGUI options') + grp.add_option( '--vgui', action = 'store', type='string', dest = 'VGUI_DEV', help = 'path to vgui-dev repo', default='' ) - opt.add_option( + grp.add_option( '--disable-vgui', action = 'store_true', dest = 'NO_VGUI', help = 'disable vgui_support', default=False ) - opt.add_option( + grp.add_option( '--skip-vgui-sanity-check', action = 'store_false', dest = 'VGUI_SANITY_CHECK', - help = 'Skip checking VGUI sanity', default=True ) - - # stub + help = 'skip checking VGUI sanity', default=True ) return def configure(conf): diff --git a/wscript b/wscript index 09070f1b..8ff7a82f 100644 --- a/wscript +++ b/wscript @@ -17,27 +17,28 @@ SUBDIRS = [ 'engine', 'game_launch', 'mainui', 'vgui_support' ] top = '.' def options(opt): - opt.load('xcompile compiler_cxx compiler_c') - if sys.platform == 'win32': - opt.load('msvc msvs') + grp = opt.add_option_group('Common options') - opt.add_option( + grp.add_option( '--build-type', action='store', type='string', dest='BUILD_TYPE', default = None, help = 'build type: debug, release or none(custom flags)') - opt.add_option( + grp.add_option( '--dedicated', action = 'store_true', dest = 'DEDICATED', default = False, help = 'build Xash Dedicated Server(XashDS)') - opt.add_option( + grp.add_option( '--64bits', action = 'store_true', dest = 'ALLOW64', default = False, help = 'allow targetting 64-bit engine') - opt.add_option( + grp.add_option( '--win-style-install', action = 'store_true', dest = 'WIN_INSTALL', default = False, help = 'install like Windows build, ignore prefix, useful for development') opt.recurse(SUBDIRS) + opt.load('xcompile compiler_cxx compiler_c') + if sys.platform == 'win32': + opt.load('msvc msvs') def configure(conf): conf.start_msg('Build type') From 2c17dce25b2ac6732f21ea3a11d239f20de51900 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 19 Feb 2019 17:49:09 +0300 Subject: [PATCH 05/22] wscript: check for dedicated or singlebinary before recurse into subdirectory, add a chance to skip some subprojects on configuration stage --- engine/wscript | 9 +---- game_launch/wscript | 13 ++----- mainui | 2 +- vgui_support/wscript | 4 +-- wscript | 84 +++++++++++++++++++++++++++++++++++++++----- 5 files changed, 82 insertions(+), 30 deletions(-) diff --git a/engine/wscript b/engine/wscript index 93c1309c..58578030 100644 --- a/engine/wscript +++ b/engine/wscript @@ -14,10 +14,6 @@ def options(opt): '--enable-bsp2', action = 'store_true', dest = 'SUPPORT_BSP2_FORMAT', default = False, help = 'build engine with BSP2 map support(recommended for Quake, breaks compatibility!)') - grp.add_option( - '--single-binary', action = 'store_true', dest = 'SINGLE_BINARY', default = None, - help = 'build single "xash" binary instead of xash.dll/libxash.so (default for dedicated)') - grp.add_option( '--stdin-input', action = 'store_true', dest = 'USE_SELECT', default = None, help = 'enable console input from stdin (default for dedicated)') @@ -38,10 +34,7 @@ def configure(conf): conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated') conf.env.append_unique('DEFINES', 'XASH_SDL') - if conf.options.SINGLE_BINARY == None: - conf.options.SINGLE_BINARY = conf.options.DEDICATED # We don't need game launcher on dedicated - conf.env.SINGLE_BINARY = conf.options.SINGLE_BINARY - if conf.options.SINGLE_BINARY: + if conf.env.SINGLE_BINARY: conf.env.append_unique('DEFINES', 'SINGLE_BINARY') if conf.options.USE_SELECT == None: diff --git a/game_launch/wscript b/game_launch/wscript index 2e650bc9..99608a83 100644 --- a/game_launch/wscript +++ b/game_launch/wscript @@ -10,22 +10,13 @@ from fwgslib import get_subproject_name top = '.' def options(opt): - # stub return def configure(conf): - if conf.env.SINGLE_BINARY: - return - - # check for dedicated server build - if not conf.env.DEDICATED: - if conf.env.DEST_OS == 'win32': - conf.load('winres') + if conf.env.DEST_OS == 'win32': + conf.load('winres') def build(bld): - if bld.env.SINGLE_BINARY: - return - bld.load_envs() bld.env = bld.all_envs[get_subproject_name(bld)] diff --git a/mainui b/mainui index 33e6e585..9acf8b75 160000 --- a/mainui +++ b/mainui @@ -1 +1 @@ -Subproject commit 33e6e585e875d91ae44b22d5425f1c38f2413741 +Subproject commit 9acf8b75d9d167ac63efd6db8f35c42a2d325082 diff --git a/vgui_support/wscript b/vgui_support/wscript index 29d163d4..0cdc0b18 100644 --- a/vgui_support/wscript +++ b/vgui_support/wscript @@ -25,7 +25,7 @@ def options(opt): def configure(conf): conf.env.NO_VGUI = conf.options.NO_VGUI - if conf.options.DEDICATED or conf.options.NO_VGUI: + if conf.options.NO_VGUI: return conf.start_msg('Configuring VGUI by provided path') @@ -74,7 +74,7 @@ def build(bld): bld.load_envs() bld.env = bld.all_envs[get_subproject_name(bld)] - if bld.env.DEDICATED or bld.env.NO_VGUI: + if bld.env.NO_VGUI: return libs = [] diff --git a/wscript b/wscript index 8ff7a82f..acf7642b 100644 --- a/wscript +++ b/wscript @@ -13,9 +13,29 @@ import fwgslib VERSION = '0.99' APPNAME = 'xash3d-fwgs' -SUBDIRS = [ 'engine', 'game_launch', 'mainui', 'vgui_support' ] top = '.' +class Subproject: + name = '' + dedicated = True # if true will be ignored when building dedicated server + singlebin = False # if true will be ignored when singlebinary is set + ignore = False # if true will be ignored, set by user request + + def __init__(self, name, dedicated=True, singlebin=False): + self.name = name + self.dedicated = dedicated + self.singlebin = singlebin + +SUBDIRS = [ + Subproject('engine', dedicated=False), + Subproject('game_launch', singlebin=True), + Subproject('mainui'), + Subproject('vgui_support'), +] + +def subdirs(): + return map(lambda x: x.name, SUBDIRS) + def options(opt): grp = opt.add_option_group('Common options') @@ -27,6 +47,10 @@ def options(opt): '--dedicated', action = 'store_true', dest = 'DEDICATED', default = False, help = 'build Xash Dedicated Server(XashDS)') + grp.add_option( + '--single-binary', action = 'store_true', dest = 'SINGLE_BINARY', default = False, + help = 'build single "xash" binary instead of xash.dll/libxash.so (forced for dedicated)') + grp.add_option( '--64bits', action = 'store_true', dest = 'ALLOW64', default = False, help = 'allow targetting 64-bit engine') @@ -35,11 +59,29 @@ def options(opt): '--win-style-install', action = 'store_true', dest = 'WIN_INSTALL', default = False, help = 'install like Windows build, ignore prefix, useful for development') - opt.recurse(SUBDIRS) + grp.add_option( + '--skip-subprojects', action='store', type = 'string', dest = 'SKIP_SUBDIRS', default=None, + help = 'don\'t recurse into specified subprojects. Current subdirs: ' + str(subdirs())) + + for i in SUBDIRS: + if not os.path.isfile(os.path.join(i.name, 'wscript')): + # HACKHACK: this way we get warning message right in the help + # so this just becomes more noticeable + opt.add_option_group('Cannot find wscript in ' + i.name + '. You probably missed submodule update') + else: opt.recurse(i.name) + opt.load('xcompile compiler_cxx compiler_c') if sys.platform == 'win32': opt.load('msvc msvs') +def set_ignored_subdirs(subdirs): + for i in SUBDIRS: + if i.ignore: + continue + + if i.name in subdirs: + i.ignore = True + def configure(conf): conf.start_msg('Build type') if conf.options.BUILD_TYPE == None: @@ -50,6 +92,11 @@ def configure(conf): conf.fatal('Invalid build type. Valid are "debug", "release" or "none"') conf.end_msg(conf.options.BUILD_TYPE) + # skip some subdirectories, if requested + if conf.options.SKIP_SUBDIRS: + skip_subdirs = conf.options.SKIP_SUBDIRS.split(',') + set_ignored_subdirs(skip_subdirs) + # Force XP compability, all build targets should add # subsystem=bld.env.MSVC_SUBSYSTEM # TODO: wrapper around bld.stlib, bld.shlib and so on? @@ -101,6 +148,8 @@ def configure(conf): linker_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC)) conf.env.DEDICATED = conf.options.DEDICATED + # we don't need game launcher on dedicated + conf.env.SINGLE_BINARY = conf.options.SINGLE_BINARY or conf.env.DEDICATED if conf.env.DEST_OS == 'linux': conf.check_cc( lib='dl' ) @@ -132,13 +181,32 @@ def configure(conf): conf.env.append_unique('DEFINES', 'XASH_BUILD_COMMIT="{0}"'.format(conf.env.GIT_VERSION if conf.env.GIT_VERSION else 'notset')) for i in SUBDIRS: - conf.setenv(i, conf.env) # derive new env from global one - conf.env.ENVNAME = i - conf.msg(msg='--> ' + i, result='in progress', color='BLUE') + if conf.env.SINGLE_BINARY and i.singlebin: + continue + + if conf.env.DEDICATED and not i.dedicated: + continue + + if i.ignore: + continue + + conf.setenv(i.name, conf.env) # derive new env from global one + conf.env.ENVNAME = i.name + conf.msg(msg='--> ' + i.name, result='in progress', color='BLUE') # configure in standalone env - conf.recurse(i) - conf.msg(msg='<-- ' + i, result='done', color='BLUE') + conf.recurse(i.name) + conf.msg(msg='<-- ' + i.name, result='done', color='BLUE') conf.setenv('') def build(bld): - bld.recurse(SUBDIRS) + for i in SUBDIRS: + if bld.env.SINGLE_BINARY and i.singlebin: + continue + + if bld.env.DEDICATED and not i.dedicated: + continue + + if i.ignore: + continue + + bld.recurse(i.name) From 5e17b4bf17394afafa82699dcf988f8d0827dfc0 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 19 Feb 2019 17:55:45 +0300 Subject: [PATCH 06/22] wscript: remove useless option type specifier --- scripts/waflib/sdl2.py | 6 ++---- scripts/waflib/xcompile.py | 2 +- vgui_support/wscript | 9 +++------ wscript | 18 ++++++------------ 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/scripts/waflib/sdl2.py b/scripts/waflib/sdl2.py index 30d46b53..d3679726 100644 --- a/scripts/waflib/sdl2.py +++ b/scripts/waflib/sdl2.py @@ -15,12 +15,10 @@ import os def options(opt): grp = opt.add_option_group('SDL2 options') - grp.add_option( - '--sdl2', action='store', type='string', dest = 'SDL2_PATH', default = None, + grp.add_option('--sdl2', action='store', dest = 'SDL2_PATH', default = None, help = 'path to precompiled SDL2 library(required for Windows)') - grp.add_option( - '--skip-sdl2-sanity-check', action='store_false', default = True, dest='SDL2_SANITY_CHECK', + grp.add_option('--skip-sdl2-sanity-check', action='store_false', default = True, dest='SDL2_SANITY_CHECK', help = 'skip checking SDL2 sanity') def my_dirname(path): diff --git a/scripts/waflib/xcompile.py b/scripts/waflib/xcompile.py index 4a2ec5cb..b83cc314 100644 --- a/scripts/waflib/xcompile.py +++ b/scripts/waflib/xcompile.py @@ -111,7 +111,7 @@ class Android: def options(opt): android = opt.add_option_group('Android options') - android.add_option('--android', action='store', type='string', dest='ANDROID_OPTS', default=None, + android.add_option('--android', action='store', dest='ANDROID_OPTS', default=None, help='enable building for android, format: --android=,,, example: --android=arm,4.9,26') def configure(conf): diff --git a/vgui_support/wscript b/vgui_support/wscript index 0cdc0b18..20aa25a8 100644 --- a/vgui_support/wscript +++ b/vgui_support/wscript @@ -10,16 +10,13 @@ top = '.' def options(opt): grp = opt.add_option_group('VGUI options') - grp.add_option( - '--vgui', action = 'store', type='string', dest = 'VGUI_DEV', + grp.add_option('--vgui', action = 'store', dest = 'VGUI_DEV', help = 'path to vgui-dev repo', default='' ) - grp.add_option( - '--disable-vgui', action = 'store_true', dest = 'NO_VGUI', + grp.add_option('--disable-vgui', action = 'store_true', dest = 'NO_VGUI', help = 'disable vgui_support', default=False ) - grp.add_option( - '--skip-vgui-sanity-check', action = 'store_false', dest = 'VGUI_SANITY_CHECK', + grp.add_option('--skip-vgui-sanity-check', action = 'store_false', dest = 'VGUI_SANITY_CHECK', help = 'skip checking VGUI sanity', default=True ) return diff --git a/wscript b/wscript index acf7642b..da503401 100644 --- a/wscript +++ b/wscript @@ -39,28 +39,22 @@ def subdirs(): def options(opt): grp = opt.add_option_group('Common options') - grp.add_option( - '--build-type', action='store', type='string', dest='BUILD_TYPE', default = None, + grp.add_option('--build-type', action='store', dest='BUILD_TYPE', default = None, help = 'build type: debug, release or none(custom flags)') - grp.add_option( - '--dedicated', action = 'store_true', dest = 'DEDICATED', default = False, + grp.add_option('--dedicated', action = 'store_true', dest = 'DEDICATED', default = False, help = 'build Xash Dedicated Server(XashDS)') - grp.add_option( - '--single-binary', action = 'store_true', dest = 'SINGLE_BINARY', default = False, + grp.add_option( '--single-binary', action = 'store_true', dest = 'SINGLE_BINARY', default = False, help = 'build single "xash" binary instead of xash.dll/libxash.so (forced for dedicated)') - grp.add_option( - '--64bits', action = 'store_true', dest = 'ALLOW64', default = False, + grp.add_option('--64bits', action = 'store_true', dest = 'ALLOW64', default = False, help = 'allow targetting 64-bit engine') - grp.add_option( - '--win-style-install', action = 'store_true', dest = 'WIN_INSTALL', default = False, + grp.add_option('--win-style-install', action = 'store_true', dest = 'WIN_INSTALL', default = False, help = 'install like Windows build, ignore prefix, useful for development') - grp.add_option( - '--skip-subprojects', action='store', type = 'string', dest = 'SKIP_SUBDIRS', default=None, + grp.add_option('--skip-subprojects', action='store', dest = 'SKIP_SUBDIRS', default=None, help = 'don\'t recurse into specified subprojects. Current subdirs: ' + str(subdirs())) for i in SUBDIRS: From 7299ee9f117dda049792f867c1503d9d912cee89 Mon Sep 17 00:00:00 2001 From: mittorn Date: Sat, 23 Feb 2019 18:32:49 +0700 Subject: [PATCH 07/22] Try fix mingw linking --- scripts/build_mingw_engine.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/build_mingw_engine.sh b/scripts/build_mingw_engine.sh index 50d5c445..8c660020 100755 --- a/scripts/build_mingw_engine.sh +++ b/scripts/build_mingw_engine.sh @@ -7,7 +7,9 @@ cd $TRAVIS_BUILD_DIR export CC="ccache i686-w64-mingw32-gcc" export CXX="ccache i686-w64-mingw32-g++" export CFLAGS="-static-libgcc -no-pthread" -export CXXFLAGS="-static-libgcc -static-libstdc++" +export CXXFLAGS="-static-libgcc -static-libstdc++ -no-pthread" +export LDFLAGS="-static-libgcc -static-libstdc++ -no-pthread" +export LINKFLAGS="-static-libgcc -static-libstdc++ -no-pthread" export WINRC="i686-w64-mingw32-windres" rm -rf build # clean build directory ./waf configure --sdl2=$TRAVIS_BUILD_DIR/SDL2_mingw/i686-w64-mingw32/ --disable-vgui --build-type=debug --verbose || die # can't compile VGUI support on MinGW, due to differnet C++ ABI From 955dde6d5f565749e188c25c8c6ef88ae827988b Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 5 Nov 2018 02:06:08 +0300 Subject: [PATCH 08/22] Create README.md --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..1749197b --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Xash3D FWGS Engine + +Xash3D FWGS is a fork of Xash3D Engine by Unkle Mike. + +``` +Xash3D is a game engine, aimed to provide compatibility with Half-Life Engine, +as well as to give game developers well known workflow and extend it. +Read more about Xash3D on ModDB: https://www.moddb.com/engines/xash3d-engine +``` + +## Fork features +* HLSDK 2.4 support. +* Crossplatform: officially supported x86 and ARM on Windows/Linux/BSD/macOS/Android/iOS/Haiku. +* Modern compilers support, say no more to VC6. +* Better multiplayer support: multiple master servers, headless dedicated server. +* Mobility API, which allows better game integration on mobile devices(vibration, touch controls) +* Different input methods: touch, gamepad and classic mouse & keyboard. +* TrueType font rendering, as a part of mainui_cpp. +* A set of small improvements, without broken compatibility. + +## Planned fork features +* Voice support +* Multiple renderers support(OpenGL, GLES, Vulkan, software) + +## Contributing +* Before sending an issue, check if someone already reported your issue. Make sure you're following "How To Ask Questions The Smart Way" guide by Eric Steven Raymond. Read more: http://www.catb.org/~esr/faqs/smart-questions.html +* Before sending a PR, check if you followed our coding guide in CODING_STYLE.md file. + +## Build instructions +We are using Waf build system. If you have some Waf-related questions, I recommend you to read https://waf.io/book/ + +1) Clone this repository: `git clone --recursive https://github.com/FWGS/xash3d-fwgs` +2) Examine which build options are available: `waf --help` +3) Configure build: `waf configure` +4) Compile: `waf build` +5) Install(optional): `waf install` + +## Running +1) Copy libraries and main executable somewhere, if you're skipped installation stage. +2) Copy game files to same directory +3) Run `xash3d.exe`/`xash3d.sh`/`xash3d` depending on which platform you're using. + +For additional info, run Xash3D with `-help` command line key. From 48808e4ede077b45549f618ea27eb8a232305494 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 13 Dec 2018 09:17:11 +0300 Subject: [PATCH 09/22] Update readme [ci skip] --- README.md | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1749197b..eeec991a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Xash3D FWGS Engine +![](https://api.travis-ci.org/FWGS/xash3d-fwgs.svg?branch=master) ![](https://img.shields.io/discord/355697768582610945.svg) -Xash3D FWGS is a fork of Xash3D Engine by Unkle Mike. +Xash3D FWGS is a fork of Xash3D Engine by Unkle Mike with extended features and crossplatform. ``` Xash3D is a game engine, aimed to provide compatibility with Half-Life Engine, @@ -8,17 +9,21 @@ as well as to give game developers well known workflow and extend it. Read more about Xash3D on ModDB: https://www.moddb.com/engines/xash3d-engine ``` +Latest release build: https://github.com/FWGS/xash3d-fwgs/releases/latest +Latest development build: https://github.com/FWGS/xash3d-deploy/tree/newengine-latest + ## Fork features * HLSDK 2.4 support. * Crossplatform: officially supported x86 and ARM on Windows/Linux/BSD/macOS/Android/iOS/Haiku. -* Modern compilers support, say no more to VC6. +* Modern compilers support: say no more to MSVC6. * Better multiplayer support: multiple master servers, headless dedicated server. -* Mobility API, which allows better game integration on mobile devices(vibration, touch controls) +* Mobility API: allows better game integration on mobile devices(vibration, touch controls) * Different input methods: touch, gamepad and classic mouse & keyboard. * TrueType font rendering, as a part of mainui_cpp. * A set of small improvements, without broken compatibility. ## Planned fork features +* Virtual Reality support and game API(in development!) * Voice support * Multiple renderers support(OpenGL, GLES, Vulkan, software) @@ -29,11 +34,40 @@ Read more about Xash3D on ModDB: https://www.moddb.com/engines/xash3d-engine ## Build instructions We are using Waf build system. If you have some Waf-related questions, I recommend you to read https://waf.io/book/ -1) Clone this repository: `git clone --recursive https://github.com/FWGS/xash3d-fwgs` -2) Examine which build options are available: `waf --help` -3) Configure build: `waf configure` +If you're stuck somewhere and you need a clear example, open `.travis.yml`. + +### Prerequisites +#### Windows(Visual Studio) +* Install Visual Studio. +* Install latest [Python](https://python.org) *OR* run `cinst python.install` if you have Chocolatey. +* Install latest [Git](https://git-scm.com/download/win) *OR* run `cinst git.install` if you have Chocolatey. +* Download [SDL2](https://libsdl.org/download-2.0.php) development package for Visual Studio. +* Clone this repository: `git clone --recursive https://github.com/FWGS/xash3d-fwgs`. +* Clone `vgui-dev` repository: `git clone https://github.com/FWGS/vgui-dev`. +* Make sure you have at least 12GB of free space to store all build-time dependencies: ~10GB for Visual Studio, 300 MB for Git, 100 MB for Python and other. + +#### Linux +NOTE: Make sure you're OK with targetting 32-bit. +Even if Xash3D FWGS does support targetting 64-bit, anything can happen, not to mention that you can't load games without recompiling them from source code! + +* *Gentoo*: TODO +* *Debian*: TODO +* *ArchLinux*: TODO + +### Building +#### Windows(Visual Studio) +0) Open command line +1) Navigate to `xash3d-fwgs` directory. +2) Carefully examine which build options are available: `waf --help` +3) Configure build: `waf configure --build-type=release --sdl2=c:/path/to/SDL2 --vgui-dev=c:/path/to/vgui-dev --prefix=c:/path/to/any/output/directory` 4) Compile: `waf build` -5) Install(optional): `waf install` +5) Install: `waf install` + +#### Linux +0) Examine which build options are available: `./waf --help` +1) Configure build: `./waf configure --build-type=release` +2) Compile: `./waf build` +3) Install(optional): `./waf install` ## Running 1) Copy libraries and main executable somewhere, if you're skipped installation stage. From 2ecfa20f949c6b062e60df1ec63c2db744eed7e6 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 13 Dec 2018 09:19:49 +0300 Subject: [PATCH 10/22] Fix formatting [ci skip] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index eeec991a..bd3383be 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Read more about Xash3D on ModDB: https://www.moddb.com/engines/xash3d-engine ``` Latest release build: https://github.com/FWGS/xash3d-fwgs/releases/latest + Latest development build: https://github.com/FWGS/xash3d-deploy/tree/newengine-latest ## Fork features From 6ede01ea05add36980ea065190981369c29ac05c Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 13 Dec 2018 09:23:21 +0300 Subject: [PATCH 11/22] Fix italic to bold [ci skip] --- README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index bd3383be..f99b5f93 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,8 @@ If you're stuck somewhere and you need a clear example, open `.travis.yml`. ### Prerequisites #### Windows(Visual Studio) * Install Visual Studio. -* Install latest [Python](https://python.org) *OR* run `cinst python.install` if you have Chocolatey. -* Install latest [Git](https://git-scm.com/download/win) *OR* run `cinst git.install` if you have Chocolatey. +* Install latest [Python](https://python.org) **OR** run `cinst python.install` if you have Chocolatey. +* Install latest [Git](https://git-scm.com/download/win) **OR** run `cinst git.install` if you have Chocolatey. * Download [SDL2](https://libsdl.org/download-2.0.php) development package for Visual Studio. * Clone this repository: `git clone --recursive https://github.com/FWGS/xash3d-fwgs`. * Clone `vgui-dev` repository: `git clone https://github.com/FWGS/vgui-dev`. @@ -49,11 +49,12 @@ If you're stuck somewhere and you need a clear example, open `.travis.yml`. #### Linux NOTE: Make sure you're OK with targetting 32-bit. + Even if Xash3D FWGS does support targetting 64-bit, anything can happen, not to mention that you can't load games without recompiling them from source code! -* *Gentoo*: TODO -* *Debian*: TODO -* *ArchLinux*: TODO +* **Gentoo**: TODO +* **Debian**: TODO +* **ArchLinux**: TODO ### Building #### Windows(Visual Studio) @@ -71,8 +72,8 @@ Even if Xash3D FWGS does support targetting 64-bit, anything can happen, not to 3) Install(optional): `./waf install` ## Running -1) Copy libraries and main executable somewhere, if you're skipped installation stage. -2) Copy game files to same directory -3) Run `xash3d.exe`/`xash3d.sh`/`xash3d` depending on which platform you're using. +0) Copy libraries and main executable somewhere, if you're skipped installation stage. +1) Copy game files to same directory +2) Run `xash3d.exe`/`xash3d.sh`/`xash3d` depending on which platform you're using. For additional info, run Xash3D with `-help` command line key. From dbb4b2c1f9884be018171b7e998bf9c621c917f6 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 13 Dec 2018 09:32:24 +0300 Subject: [PATCH 12/22] Fix some mistypes [ci skip] --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f99b5f93..5a6d5583 100644 --- a/README.md +++ b/README.md @@ -61,13 +61,13 @@ Even if Xash3D FWGS does support targetting 64-bit, anything can happen, not to 0) Open command line 1) Navigate to `xash3d-fwgs` directory. 2) Carefully examine which build options are available: `waf --help` -3) Configure build: `waf configure --build-type=release --sdl2=c:/path/to/SDL2 --vgui-dev=c:/path/to/vgui-dev --prefix=c:/path/to/any/output/directory` +3) Configure build: `waf configure --build-type=release --sdl2=c:/path/to/SDL2 --vgui=c:/path/to/vgui-dev --prefix=c:/path/to/any/output/directory` 4) Compile: `waf build` 5) Install: `waf install` #### Linux 0) Examine which build options are available: `./waf --help` -1) Configure build: `./waf configure --build-type=release` +1) Configure build: `./waf configure --build-type=release --vgui=vgui-dev` 2) Compile: `./waf build` 3) Install(optional): `./waf install` From 94cfe1217a05b89c3fbedb3ab1a985f2dc770e71 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 19 Feb 2019 18:07:09 +0300 Subject: [PATCH 13/22] Create CONTRIBUTING.md --- CONTRIBUTING.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..3078977d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,53 @@ +# Contributing to Xash3D FWGS + +Third-party patches for Xash3D FWGS are great idea. +But if you want your patch to be accepted, we can give you few guidelines. + +## If you are reporting bugs + +1. Check you are using latest version. You can build latest Xash3D FWGS for yourself, look to README.md. +2. Check open issues is your bug is already reported and closed issues if it reported and fixed. Don't send bug if it's already reported. +3. Now you can write bugreport. +4. Describe steps to reproduce bug. +5. Describe which OS and architecture you are using. +6. Re-run engine with `-dev 2 -log` arguments, reproduce bug and post engine.log which can be found in your working directory. +7. Attach screenshot if it will help clarify the situation. + +## If you are contributing code + +### Which branch? + +* We recommend using `master` branch. But you still can use any of our branches, if they are up-to-date. + +### Third-party libraries + +* Philosophy of any Xash Project by Uncle Mike: don't be bloated. We follow it too. +* There is allowed only these libraries, which is used in Linux GoldSrc version or if there is a REAL reason to use library. + +### Portability level + +* Xash3D have it's own crt library. It's recommended to use it. It most cases it's just a wrappers around standart C library. +* If your feature need platform-specific code, try to implement to every supported OS and every supported compiler. +* You must put it under appopriate macro. It's a rule: Xash3D FWGS must at least compile everywhere. + +| OS | Macro | +| -- | ----- | +| Linux | `defined(__linux__)` | +| FreeBSD | `defined(__FreeBSD__)` | +| NetBSD | `defined(__NetBSD__)` | +| OpenBSD | `defined(__OpenBSD__)` | +| OS X/iOS | `defined(__APPLE__)` and TargetConditionals macros | +| Windows | `defined(_WIN32)` | +| Android | `defined(__ANDROID__)` | +| Emscripten | `defined(__EMSCRIPTEN__)` | + +### Code style + +* This project uses mixed Quake's and HLSDK's C/C++ code style convention. +* In short: + * Use spaces in parenthesis. Even in empty. + * Use tabs, not spaces, for indentation. + * Any brace must have it's own line. + * Short blocks, if statements and loops on single line are allowed. + * Try to avoid magic numbers. +* If you unsure, try to mimic code style from anywhere else of engine source code. From 2bf2b95b3aabeb28090e34e17a02df0ba61167f8 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 19 Feb 2019 18:16:10 +0300 Subject: [PATCH 14/22] Correct & simplify CONTRIBUTING.md --- CONTRIBUTING.md | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3078977d..b0d7e482 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,33 +1,28 @@ -# Contributing to Xash3D FWGS - -Third-party patches for Xash3D FWGS are great idea. -But if you want your patch to be accepted, we can give you few guidelines. - ## If you are reporting bugs 1. Check you are using latest version. You can build latest Xash3D FWGS for yourself, look to README.md. 2. Check open issues is your bug is already reported and closed issues if it reported and fixed. Don't send bug if it's already reported. -3. Now you can write bugreport. -4. Describe steps to reproduce bug. -5. Describe which OS and architecture you are using. -6. Re-run engine with `-dev 2 -log` arguments, reproduce bug and post engine.log which can be found in your working directory. -7. Attach screenshot if it will help clarify the situation. +3. Re-run engine with `-dev 2 -log` arguments, reproduce bug and post engine.log which can be found in your working directory. +3. Describe steps to reproduce bug. +4. Describe which OS and architecture you are using. +6. Attach screenshot if it will help clarify the situation. ## If you are contributing code ### Which branch? -* We recommend using `master` branch. But you still can use any of our branches, if they are up-to-date. +* We recommend using `master` branch. ### Third-party libraries * Philosophy of any Xash Project by Uncle Mike: don't be bloated. We follow it too. -* There is allowed only these libraries, which is used in Linux GoldSrc version or if there is a REAL reason to use library. +* There is allowed only these libraries, if there is a REAL reason to use library and library is crossplatform. It's will be nice, if you will leave a possibility to remove new dependency at build-time. +* Adding new dependencies for Waf Build System is not welcomed. ### Portability level * Xash3D have it's own crt library. It's recommended to use it. It most cases it's just a wrappers around standart C library. -* If your feature need platform-specific code, try to implement to every supported OS and every supported compiler. +* If your feature need platform-specific code, move it to `engine/platform` and try to implement to every supported OS and every supported compiler or at least leave a stubs. * You must put it under appopriate macro. It's a rule: Xash3D FWGS must at least compile everywhere. | OS | Macro | @@ -45,9 +40,10 @@ But if you want your patch to be accepted, we can give you few guidelines. * This project uses mixed Quake's and HLSDK's C/C++ code style convention. * In short: - * Use spaces in parenthesis. Even in empty. - * Use tabs, not spaces, for indentation. + * Use spaces in parenthesis. + * Only tabs for indentation. * Any brace must have it's own line. * Short blocks, if statements and loops on single line are allowed. - * Try to avoid magic numbers. + * Avoid magic numbers. + * While macros are powerful, it's better to avoid overusing them. * If you unsure, try to mimic code style from anywhere else of engine source code. From e50b91b559f2b1a653d6582f7cd2167b96861ec7 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 23 Feb 2019 13:46:03 +0300 Subject: [PATCH 15/22] Update note on 64-bit engine [ci skip] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a6d5583..ddb199dd 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ If you're stuck somewhere and you need a clear example, open `.travis.yml`. #### Linux NOTE: Make sure you're OK with targetting 32-bit. -Even if Xash3D FWGS does support targetting 64-bit, anything can happen, not to mention that you can't load games without recompiling them from source code! +Even if Xash3D FWGS does support targetting 64-bit, you can't load games without recompiling them from source code! * **Gentoo**: TODO * **Debian**: TODO From 142a38f3dcf34d1d1848291145980baf6bd9fda1 Mon Sep 17 00:00:00 2001 From: Gianluca Boiano Date: Sat, 23 Feb 2019 15:51:03 +0100 Subject: [PATCH 16/22] fixed taberror: inconsistent use of tabs and spaces in indentation --- wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wscript b/wscript index da503401..7706e82e 100644 --- a/wscript +++ b/wscript @@ -45,7 +45,7 @@ def options(opt): grp.add_option('--dedicated', action = 'store_true', dest = 'DEDICATED', default = False, help = 'build Xash Dedicated Server(XashDS)') - grp.add_option( '--single-binary', action = 'store_true', dest = 'SINGLE_BINARY', default = False, + grp.add_option( '--single-binary', action = 'store_true', dest = 'SINGLE_BINARY', default = False, help = 'build single "xash" binary instead of xash.dll/libxash.so (forced for dedicated)') grp.add_option('--64bits', action = 'store_true', dest = 'ALLOW64', default = False, From 8b5c5826a8ec8e592f83f28ce9f57617aaf492ac Mon Sep 17 00:00:00 2001 From: mittorn Date: Sun, 24 Feb 2019 02:48:22 +0700 Subject: [PATCH 17/22] legacymode: prevent dropping from server when fps too high --- engine/client/cl_main.c | 2 +- engine/common/protocol.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index f1fc316f..a732208d 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -796,7 +796,7 @@ void CL_WritePacket( void ) newcmds = ( cls.netchan.outgoing_sequence - cls.lastoutgoingcommand ); // put an upper/lower bound on this - newcmds = bound( 0, newcmds, MAX_TOTAL_CMDS ); + newcmds = bound( 0, newcmds, cls.legacymode?MAX_LEGACY_TOTAL_CMDS:MAX_TOTAL_CMDS ); if( cls.state == ca_connected ) newcmds = 0; MSG_WriteByte( &buf, newcmds ); diff --git a/engine/common/protocol.h b/engine/common/protocol.h index 559652ee..4e9e54ee 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -260,5 +260,6 @@ extern const char *clc_strings[clc_lastmsg+1]; #define MAX_LEGACY_WEAPON_BITS 5 #define MAX_LEGACY_MODEL_BITS 11 #define MAX_LEGACY_SERVERS 32 +#define MAX_LEGACY_TOTAL_CMDS 28 // magic number from old engine's sv_client.c #endif//NET_PROTOCOL_H From faee0307408a13a3ce2bf309dd7c458cfcf018e5 Mon Sep 17 00:00:00 2001 From: Gianluca Boiano <491117+M0Rf30@users.noreply.github.com> Date: Sat, 23 Feb 2019 18:20:06 +0100 Subject: [PATCH 18/22] Updated instructions for Arch Linux --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ddb199dd..4d557638 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Even if Xash3D FWGS does support targetting 64-bit, you can't load games without * **Gentoo**: TODO * **Debian**: TODO -* **ArchLinux**: TODO +* **ArchLinux**: ` -S xash3d-git` ### Building #### Windows(Visual Studio) From 576b78799ee1884f5fa90ddba3b6b57b0ddf9b20 Mon Sep 17 00:00:00 2001 From: mittorn Date: Sun, 24 Feb 2019 05:47:57 +0700 Subject: [PATCH 19/22] readme: fix links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4d557638..b4c4787a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Xash3D FWGS Engine -![](https://api.travis-ci.org/FWGS/xash3d-fwgs.svg?branch=master) ![](https://img.shields.io/discord/355697768582610945.svg) +[![Build Status](https://api.travis-ci.org/FWGS/xash3d-fwgs.svg?branch=master)](https://travis-ci.org/FWGS/xash3d-fwgs) [![Discord Server](https://img.shields.io/discord/355697768582610945.svg)](https://discord.gg/TbnHcVb) Xash3D FWGS is a fork of Xash3D Engine by Unkle Mike with extended features and crossplatform. @@ -35,7 +35,7 @@ Latest development build: https://github.com/FWGS/xash3d-deploy/tree/newengine-l ## Build instructions We are using Waf build system. If you have some Waf-related questions, I recommend you to read https://waf.io/book/ -If you're stuck somewhere and you need a clear example, open `.travis.yml`. +If you're stuck somewhere and you need a clear example, read `.travis.yml` and `scripts/build*.sh`. ### Prerequisites #### Windows(Visual Studio) From a69bda0b9bb34a4989d7a8473b2c5ef1cc43e81a Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 24 Feb 2019 01:09:35 +0300 Subject: [PATCH 20/22] readme: add note about commit tags --- CONTRIBUTING.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b0d7e482..12e5530b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,4 +46,11 @@ * Short blocks, if statements and loops on single line are allowed. * Avoid magic numbers. * While macros are powerful, it's better to avoid overusing them. -* If you unsure, try to mimic code style from anywhere else of engine source code. + * If you unsure, try to mimic code style from anywhere else of engine source code. +* **ANY** commit message should start from declaring a tags, in format: + `tag: added some bugs` + `tag: subtag: fixed some features` + + Tags can be any: subsystem, simple feature name or even just a filename, without extension. + Just keep them always same, it helps keep history clean and commit messages short. + From c3abec51278a47a6a095c42e1596660b7f15503d Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 24 Feb 2019 01:11:23 +0300 Subject: [PATCH 21/22] readme: add missed newlines --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 12e5530b..602f897c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,7 +48,9 @@ * While macros are powerful, it's better to avoid overusing them. * If you unsure, try to mimic code style from anywhere else of engine source code. * **ANY** commit message should start from declaring a tags, in format: + `tag: added some bugs` + `tag: subtag: fixed some features` Tags can be any: subsystem, simple feature name or even just a filename, without extension. From 94cbb4e1e0c7a0d7d3c87563da72f91c034414b0 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 3 Mar 2019 03:38:02 +0300 Subject: [PATCH 22/22] wscript: fix wrong dedicated skip subproject check --- wscript | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wscript b/wscript index 7706e82e..98d487be 100644 --- a/wscript +++ b/wscript @@ -178,7 +178,7 @@ def configure(conf): if conf.env.SINGLE_BINARY and i.singlebin: continue - if conf.env.DEDICATED and not i.dedicated: + if conf.env.DEDICATED and i.dedicated: continue if i.ignore: @@ -197,7 +197,7 @@ def build(bld): if bld.env.SINGLE_BINARY and i.singlebin: continue - if bld.env.DEDICATED and not i.dedicated: + if bld.env.DEDICATED and i.dedicated: continue if i.ignore: