From cae4942779cdce7cbb127a4e59a1faf34f81ca75 Mon Sep 17 00:00:00 2001 From: g-cont Date: Mon, 25 Feb 2013 00:00:00 +0400 Subject: [PATCH] 25 Feb 2013 --- common/render_api.h | 9 ++++++ engine/client/cl_remap.c | 6 ++-- engine/client/gl_backend.c | 7 +++-- engine/client/gl_rmain.c | 62 ++++++++++++++++++++++++++++++++++++-- engine/client/gl_studio.c | 14 ++++----- engine/client/gl_vidnt.c | 29 +++++++++++++++++- engine/common/host.c | 1 + engine/server/sv_phys.c | 29 +++++++++++++++--- engine/server/sv_pmove.c | 2 +- 9 files changed, 139 insertions(+), 20 deletions(-) diff --git a/common/render_api.h b/common/render_api.h index b266327e..865ac854 100644 --- a/common/render_api.h +++ b/common/render_api.h @@ -169,6 +169,13 @@ typedef struct render_api_s // ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 26 void (*R_EntityRemoveDecals)( struct model_s *mod ); // remove all the decals from specified entity (BSP only) float *(*R_DecalSetupVerts)( struct decal_s *pDecal, struct msurface_s *surf, int texture, int *outCount ); + + // find in files + char **(*GetFilesList)( const char *pattern, int *numFiles, int gamedironly ); + + // engine memory manager (permanent safe pool) + void* (*MemAlloc)( size_t cb, const char *filename, const int fileline ); + void (*MemFree)( void *mem, const char *filename, const int fileline ); } render_api_t; // render callbacks @@ -187,6 +194,8 @@ typedef struct render_interface_s int (*R_CreateStudioDecalList)( decallist_t *pList, int count, qboolean changelevel ); // grab r_speeds message qboolean (*R_SpeedsMessage)( char *out, size_t size ); + // replace with built-in R_DrawCubemapView for make skyshots or envshots + qboolean (*R_DrawCubemapView)( const float *origin, const float *angles, int size ); } render_interface_t; #endif//RENDER_API_H \ No newline at end of file diff --git a/engine/client/cl_remap.c b/engine/client/cl_remap.c index e86a61c5..719fbf01 100644 --- a/engine/client/cl_remap.c +++ b/engine/client/cl_remap.c @@ -106,7 +106,7 @@ void CL_DuplicateTexture( mstudiotexture_t *ptexture, int topcolor, int bottomco byte paletteBackup[768]; byte *raw, *pal; - // save of the real texture index + // save off the real texture index index = ptexture->index; glt = R_GetTexture( index ); Q_snprintf( texname, sizeof( texname ), "#%i_%s", RI.currententity->curstate.number, glt->name + 1 ); @@ -219,7 +219,7 @@ void CL_AllocRemapInfo( int topcolor, int bottomcolor ) CL_FreeRemapInfo( clgame.remap_info[i] ); clgame.remap_info[i] = NULL; } - return; // missed or hided model, ignore it + return; // missed or hide model, ignore it } // model doesn't contains remap textures @@ -240,7 +240,7 @@ void CL_AllocRemapInfo( int topcolor, int bottomcolor ) src = (mstudiotexture_t *)(((byte *)phdr) + phdr->textureindex); dst = (clgame.remap_info[i] ? clgame.remap_info[i]->ptexture : NULL); - // NOTE: we must copy all the structures 'mstudiotexture_t' for easy acces when model is rendering + // NOTE: we must copy all the structures 'mstudiotexture_t' for easy access when model is rendering if( !CL_CmpStudioTextures( phdr->numtextures, src, dst ) || clgame.remap_info[i]->model != RI.currentmodel ) { // this code catches studiomodel change with another studiomodel with remap textures diff --git a/engine/client/gl_backend.c b/engine/client/gl_backend.c index bedd3190..4ede61b7 100644 --- a/engine/client/gl_backend.c +++ b/engine/client/gl_backend.c @@ -377,7 +377,7 @@ const envmap_t r_envMapInfo[6] = {{ 0, 90, 0}, 0 }, {{ 0, 270, 180}, 0 }, {{-90, 180, -90}, 0 }, -{{ 90, 180, 90}, 0 } +{{ 90, 0, 90}, 0 } }; /* @@ -498,10 +498,13 @@ qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qbo r_side = Mem_Alloc( r_temppool, sizeof( rgbdata_t )); // use client vieworg - if( !vieworg ) vieworg = r_lastRefdef.vieworg; + if( !vieworg ) vieworg = cl.refdef.vieworg; for( i = 0; i < 6; i++ ) { + // go into 3d mode + R_Set2DMode( false ); + if( skyshot ) { R_DrawCubemapView( vieworg, r_skyBoxInfo[i].angles, size ); diff --git a/engine/client/gl_rmain.c b/engine/client/gl_rmain.c index 25fefa48..74d50ff4 100644 --- a/engine/client/gl_rmain.c +++ b/engine/client/gl_rmain.c @@ -1264,6 +1264,7 @@ void R_RenderFrame( const ref_params_t *fd, qboolean drawWorld ) { if( clgame.drawFuncs.GL_RenderFrame( fd, drawWorld )) { + RI.drawWorld = drawWorld; tr.fResetVis = true; return; } @@ -1334,6 +1335,12 @@ void R_DrawCubemapView( const vec3_t origin, const vec3_t angles, int size ) { ref_params_t *fd; + if( clgame.drawFuncs.R_DrawCubemapView != NULL ) + { + if( clgame.drawFuncs.R_DrawCubemapView( origin, angles, size )) + return; + } + fd = &RI.refdef; *fd = r_lastRefdef; fd->time = 0; @@ -1345,8 +1352,6 @@ void R_DrawCubemapView( const vec3_t origin, const vec3_t angles, int size ) VectorCopy( origin, fd->vieworg ); VectorCopy( angles, fd->viewangles ); VectorCopy( fd->vieworg, RI.pvsorigin ); - - R_Set2DMode( false ); // setup scissor RI.scissor[0] = fd->viewport[0]; @@ -1538,6 +1543,56 @@ static int GL_LoadTextureNoFilter( const char *name, const byte *buf, size_t siz return GL_LoadTexture( name, buf, size, flags, NULL ); } +/* +========= +R_GetFilesList + +release prev search on a next call +========= +*/ +static char **R_GetFilesList( const char *pattern, int *numFiles, int gamedironly ) +{ + static search_t *t = NULL; + + if( t ) Mem_Free( t ); // release prev search + + t = FS_Search( pattern, true, gamedironly ); + + if( !t ) + { + if( numFiles ) + *numFiles = 0; + return NULL; + } + + if( numFiles ) + *numFiles = t->numfilenames; + + return t->filenames; +} + +/* +========= +R_MemAlloc + +========= +*/ +static void *R_MemAlloc( size_t cb, const char *filename, const int fileline ) +{ + return _Mem_Alloc( cls.mempool, cb, filename, fileline ); +} + +/* +========= +R_MemFree + +========= +*/ +static void R_MemFree( void *mem, const char *filename, const int fileline ) +{ + _Mem_Free( mem, filename, fileline ); +} + static render_api_t gRenderAPI = { GL_RenderGetParm, @@ -1580,6 +1635,9 @@ static render_api_t gRenderAPI = GL_TexGen, R_EntityRemoveDecals, R_DecalSetupVerts, + R_GetFilesList, + R_MemAlloc, + R_MemFree, }; /* diff --git a/engine/client/gl_studio.c b/engine/client/gl_studio.c index 1ca585d1..57b826aa 100644 --- a/engine/client/gl_studio.c +++ b/engine/client/gl_studio.c @@ -217,18 +217,19 @@ R_StudioExtractBbox Extract bbox from current sequence ================ */ -int R_StudioExtractBbox( studiohdr_t *phdr, int sequence, float *mins, float *maxs ) +void R_StudioExtractBbox( studiohdr_t *phdr, int sequence, float *mins, float *maxs ) { mstudioseqdesc_t *pseqdesc; - if( !phdr || sequence == -1 ) - return 0; + ASSERT( phdr != NULL ); + + // check sequence range + if( sequence < 0 || sequence >= phdr->numseq ) + sequence = 0; pseqdesc = (mstudioseqdesc_t *)((byte *)phdr + phdr->seqindex); VectorCopy( pseqdesc[sequence].bbmin, mins ); VectorCopy( pseqdesc[sequence].bbmax, maxs ); - - return 1; } /* @@ -244,8 +245,7 @@ static qboolean R_StudioComputeBBox( cl_entity_t *e, vec3_t bbox[8] ) vec3_t vectors[3], angles, p1, p2; int i, seq = e->curstate.sequence; - if( !R_StudioExtractBbox( m_pStudioHeader, seq, tmp_mins, tmp_maxs )) - return false; + R_StudioExtractBbox( m_pStudioHeader, seq, tmp_mins, tmp_maxs ); // copy original bbox VectorCopy( m_pStudioHeader->bbmin, studio_mins ); diff --git a/engine/client/gl_vidnt.c b/engine/client/gl_vidnt.c index ebfad76a..ea021ed4 100644 --- a/engine/client/gl_vidnt.c +++ b/engine/client/gl_vidnt.c @@ -90,6 +90,7 @@ ref_globals_t tr; glconfig_t glConfig; glstate_t glState; glwstate_t glw_state; +uint num_instances; typedef enum { @@ -746,6 +747,27 @@ static int VID_ChoosePFD( PIXELFORMATDESCRIPTOR *pfd, int colorBits, int alphaBi return pixelFormat; } +BOOL CALLBACK pfnEnumWnd( HWND hwnd, LPARAM lParam ) +{ + string wndname; + + if( GetClassName( hwnd, wndname, sizeof( wndname ) - 1 )) + { + if( !Q_strcmp( wndname, WINDOW_NAME )) + num_instances++; + } + return true; +} + +uint VID_EnumerateInstances( void ) +{ + num_instances = 0; + + if( EnumWindows( &pfnEnumWnd, 0 )) + return num_instances; + return 1; +} + void VID_StartupGamma( void ) { size_t gamma_size; @@ -841,7 +863,12 @@ void VID_StartupGamma( void ) void VID_RestoreGamma( void ) { - if( !glw_state.hDC || !glConfig.deviceSupportsGamma ) return; + if( !glw_state.hDC || !glConfig.deviceSupportsGamma ) + return; + + // don't touch gamma if multiple instances was running + if( VID_EnumerateInstances( ) > 1 ) return; + SetDeviceGammaRamp( glw_state.hDC, glState.stateRamp ); } diff --git a/engine/common/host.c b/engine/common/host.c index 4f45b4ab..f56977a6 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -688,6 +688,7 @@ void Host_InitCommon( const char *progname, qboolean bChangeGame ) { // check for duplicate dedicated server host.hMutex = CreateMutex( NULL, 0, "Xash Dedicated Server" ); + if( !host.hMutex ) { MSGBOX( "Dedicated server already running" ); diff --git a/engine/server/sv_phys.c b/engine/server/sv_phys.c index 12311e6e..36e4b7f9 100644 --- a/engine/server/sv_phys.c +++ b/engine/server/sv_phys.c @@ -1040,6 +1040,13 @@ static edict_t *SV_PushRotate( edict_t *pusher, float movetime ) Matrix4x4_VectorTransform( end_l, temp, org2 ); VectorSubtract( org2, org, lmove ); + if( check->v.movetype == MOVETYPE_PUSHSTEP && lmove[2] < 0.0f ) + { + // pushable sliding + check->v.flags &= ~FL_ONGROUND; + lmove[2] = 0.0f; + } + // try moving the contacted entity pusher->v.solid = SOLID_NOT; SV_PushEntity( check, lmove, amove, &block ); @@ -1080,15 +1087,16 @@ void SV_Physics_Pusher( edict_t *ent ) { float oldtime, oldtime2; float thinktime, movetime; + vec3_t last_origin; edict_t *pBlocker; pBlocker = NULL; oldtime = ent->v.ltime; thinktime = ent->v.nextthink; - if( thinktime < ent->v.ltime + host.frametime ) + if( thinktime < oldtime + host.frametime ) { - movetime = thinktime - ent->v.ltime; + movetime = thinktime - oldtime; if( movetime < 0.0f ) movetime = 0.0f; } else movetime = host.frametime; @@ -1108,7 +1116,7 @@ void SV_Physics_Pusher( edict_t *ent ) // reset the local time to what it was before we rotated ent->v.ltime = oldtime; pBlocker = SV_PushMove( ent, movetime ); - if( ent->v.ltime < oldtime2 ) + if( oldtime2 < ent->v.ltime ) ent->v.ltime = oldtime2; } } @@ -1129,10 +1137,23 @@ void SV_Physics_Pusher( edict_t *ent ) if( thinktime > oldtime && (( ent->v.flags & FL_ALWAYSTHINK ) || thinktime <= ent->v.ltime )) { + float diff; + + VectorCopy( ent->v.origin, last_origin ); ent->v.nextthink = 0.0f; svgame.globals->time = sv.time; svgame.dllFuncs.pfnThink( ent ); if( ent->free ) return; + + diff = fabs( ent->v.origin[2] - last_origin[2] ); + + // TESTTEST: remove time glitches to prevent stuck in the trains + if( diff > 0.0f && diff <= 0.5f ) + { + Msg( "restore valid origin from %g to %g( %s )\n", ent->v.origin[2], last_origin[2], SV_ClassName( ent )); + VectorCopy( last_origin, ent->v.origin ); + SV_LinkEdict( ent, false ); + } } } @@ -1155,7 +1176,7 @@ void SV_Physics_Follow( edict_t *ent ) if( !SV_IsValidEdict( parent )) { - MsgDev( D_ERROR, "%s have MOVETYPE_FOLLOW with no corresponding ent!", SV_ClassName( ent )); + MsgDev( D_ERROR, "%s have MOVETYPE_FOLLOW with no corresponding ent!\n", SV_ClassName( ent )); ent->v.movetype = MOVETYPE_NONE; return; } diff --git a/engine/server/sv_pmove.c b/engine/server/sv_pmove.c index d4ed032b..a9c60414 100644 --- a/engine/server/sv_pmove.c +++ b/engine/server/sv_pmove.c @@ -703,7 +703,7 @@ static void SV_FinishPMove( playermove_t *pmove, sv_client_t *cl ) VectorCopy( pmove->movedir, clent->v.movedir ); clent->v.flTimeStepSound = pmove->flTimeStepSound; clent->v.flFallVelocity = pmove->flFallVelocity; - clent->v.oldbuttons = pmove->cmd.buttons; + clent->v.oldbuttons = pmove->oldbuttons; clent->v.waterlevel = pmove->waterlevel; clent->v.watertype = pmove->watertype; clent->v.maxspeed = pmove->clientmaxspeed;