10 Dec 2016

This commit is contained in:
g-cont 2016-12-10 00:00:00 +03:00 committed by Alibek Omarov
parent 042eb225cd
commit 102a5f8400
18 changed files with 100 additions and 34 deletions

View File

@ -238,7 +238,7 @@ typedef struct render_interface_s
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 );
// alloc or destroy studiomodel custom data
// alloc or destroy model custom data
void (*Mod_ProcessUserData)( struct model_s *mod, qboolean create, const byte *buffer );
// alloc or destroy entity custom data
void (*R_ProcessEntData)( qboolean allocate );

View File

@ -735,7 +735,7 @@ qboolean CL_DemoReadMessage( byte *buffer, size_t *length )
bSkipMessage = ((demo.timestamp - cl_serverframetime()) >= fElapsedTime) ? true : false;
if( cls.changelevel ) demo.framecount = 1;
// HACKHACK: changelevel issues
// changelevel issues
if( demo.framecount <= 2 && ( fElapsedTime - demo.timestamp ) > host.frametime )
demo.starttime = CL_GetDemoPlaybackClock();

View File

@ -4050,7 +4050,7 @@ qboolean CL_LoadProgs( const char *name )
return false;
}
Cvar_Get( "cl_nopred", "1", CVAR_ARCHIVE|CVAR_USERINFO, "disable client movement predicting" );
Cvar_Get( "cl_nopred", "1", CVAR_ARCHIVE, "disable client movement predicting" );
cl_lw = Cvar_Get( "cl_lw", "0", CVAR_ARCHIVE|CVAR_USERINFO, "enable client weapon predicting" );
Cvar_Get( "cl_lc", "0", CVAR_ARCHIVE|CVAR_USERINFO, "enable lag compensation" );
Cvar_FullSet( "host_clientloaded", "1", CVAR_INIT );

View File

@ -453,7 +453,7 @@ void CL_CreateCmd( void )
input_override |= CL_ProcessOverviewCmds( &pcmd->cmd );
input_override |= CL_ProcessShowTexturesCmds( &pcmd->cmd );
if(( cl.background && !cls.demoplayback ) || input_override || gl_overview->integer || cls.changelevel )
if(( cl.background && !cls.demoplayback ) || input_override || cls.changelevel )
{
VectorCopy( angles, cl.refdef.cl_viewangles );
VectorCopy( angles, pcmd->cmd.viewangles );
@ -1377,7 +1377,6 @@ void CL_PrepSound( void )
}
S_EndRegistration();
cl.audio_prepped = true;
}
@ -1867,7 +1866,7 @@ void CL_InitLocal( void )
cls.state = ca_disconnected;
// register our variables
cl_predict = Cvar_Get( "cl_predict", "0", CVAR_ARCHIVE, "enable client movement prediction" );
cl_predict = Cvar_Get( "cl_predict", "0", CVAR_ARCHIVE|CVAR_USERINFO, "enable client movement prediction" );
cl_crosshair = Cvar_Get( "crosshair", "1", CVAR_ARCHIVE, "show weapon chrosshair" );
cl_nodelta = Cvar_Get ("cl_nodelta", "0", 0, "disable delta-compression for usercommnds" );
cl_idealpitchscale = Cvar_Get( "cl_idealpitchscale", "0.8", 0, "how much to look up/down slopes and stairs when not using freelook" );

View File

@ -110,11 +110,10 @@ void CL_SetUpPlayerPrediction( int dopred, int bIncludeLocalClient )
clent = CL_GetEntityByIndex( i + 1 );
// special for EF_NODRAW and local client?
if(( state->effects & EF_NODRAW ) && !bIncludeLocalClient )
if( FBitSet( state->effects, EF_NODRAW ) && !bIncludeLocalClient )
{
// don't include local player?
if( cl.playernum == i )
continue;
if( cl.playernum == i ) continue;
player->active = true;
player->movetype = state->movetype;

View File

@ -149,7 +149,10 @@ void SCR_RunCinematic( void )
return;
if( !AVI_IsActive( cin_state ))
{
SCR_NextMovie( );
return;
}
if( UI_IsVisible( ))
{

View File

@ -397,9 +397,9 @@ typedef struct
movevars_t oldmovevars;
playermove_t *pmove; // pmove state
qboolean pushed; // used by PM_Push\Pop state
int oldviscount; // used by PM_Push\Pop state
int oldphyscount; // used by PM_Push\Pop state
qboolean pushed; // used by PM_Push\Pop state
int oldviscount; // used by PM_Push\Pop state
int oldphyscount; // used by PM_Push\Pop state
vec3_t player_mins[MAX_MAP_HULLS]; // 4 hulls allowed
vec3_t player_maxs[MAX_MAP_HULLS]; // 4 hulls allowed

View File

@ -304,6 +304,8 @@ void S_StreamSoundTrack( void )
{
wavdata_t *info = SCR_GetMovieInfo();
if( !info ) break; // bad soundtrack?
bufferSamples = ch->max_samples - (ch->s_rawend - soundtime);
// decide how much data needs to be read from the file

View File

@ -20,10 +20,6 @@ extern byte *sndpool;
#include "mathlib.h"
// local flags (never sending acorss the net)
#define SND_LOCALSOUND (1<<9) // not paused, not looped, for internal use
#define SND_STOP_LOOPING (1<<10) // stop all looping sounds on the entity.
// sound engine rate defines
#define SOUND_DMA_SPEED 44100 // hardware playback rate
#define SOUND_11k 11025 // 11khz sample rate

View File

@ -279,6 +279,11 @@ typedef struct host_redirect_s
void (*flush)( netadr_t adr, rdtype_t target, char *buffer );
} host_redirect_t;
// local flags (never sending acorss the net)
#define SND_LOCALSOUND (1<<9) // not paused, not looped, for internal use
#define SND_STOP_LOOPING (1<<10) // stop all looping sounds on the entity.
#define SND_FILTER_CLIENT (1<<11) // don't send sound from local player if prediction was enabled
typedef struct
{
char name[64];

View File

@ -177,6 +177,11 @@ void Image_Init( void )
image.loadformats = load_game;
image.saveformats = save_game;
break;
case HOST_DEDICATED:
image.cmd_flags = 0;
image.loadformats = load_game;
image.saveformats = save_null;
break;
default: // all other instances not using imagelib or will be reinstalling later
image.loadformats = load_null;
image.saveformats = save_null;

View File

@ -22,7 +22,7 @@ GNU General Public License for more details.
#include "gl_local.h"
#include "features.h"
#include "client.h"
#include "physint.h" // LUMP_ error codes
#include "server.h" // LUMP_ error codes
#define MAX_SIDE_VERTS 512 // per one polygon
@ -582,10 +582,21 @@ static void Mod_FreeUserData( model_t *mod )
if( !mod || !mod->name[0] )
return;
if( clgame.drawFuncs.Mod_ProcessUserData != NULL )
if( host.type == HOST_DEDICATED )
{
// let the client.dll free custom data
clgame.drawFuncs.Mod_ProcessUserData( mod, false, NULL );
if( svgame.physFuncs.Mod_ProcessUserData != NULL )
{
// let the server.dll free custom data
svgame.physFuncs.Mod_ProcessUserData( mod, false, NULL );
}
}
else
{
if( clgame.drawFuncs.Mod_ProcessUserData != NULL )
{
// let the client.dll free custom data
clgame.drawFuncs.Mod_ProcessUserData( mod, false, NULL );
}
}
}
@ -3068,10 +3079,24 @@ model_t *Mod_LoadModel( model_t *mod, qboolean crash )
return NULL;
}
else if( clgame.drawFuncs.Mod_ProcessUserData != NULL )
else
{
// let the client.dll load custom data
clgame.drawFuncs.Mod_ProcessUserData( mod, true, buf );
if( host.type == HOST_DEDICATED )
{
if( svgame.physFuncs.Mod_ProcessUserData != NULL )
{
// let the server.dll load custom data
svgame.physFuncs.Mod_ProcessUserData( mod, true, buf );
}
}
else
{
if( clgame.drawFuncs.Mod_ProcessUserData != NULL )
{
// let the client.dll load custom data
clgame.drawFuncs.Mod_ProcessUserData( mod, true, buf );
}
}
}
Mem_Free( buf );

View File

@ -101,7 +101,9 @@ typedef struct server_physics_api_s
int (*pfnReadLump)( const char *filename, const int lump, void **lumpdata, int *lumpsize );
int (*pfnSaveLump)( const char *filename, const int lump, void *lumpdata, int lumpsize );
// FS tools
int (*pfnSaveFile)( const char *filename, const void *data, long len );
const byte *(*pfnLoadImagePixels)( const char *filename, int *width, int *height );
} server_physics_api_t;
// physic callbacks
@ -149,6 +151,8 @@ typedef struct physics_interface_s
int (*pfnRestoreDecal)( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent );
// handle custom trigger touching for player
void (*PM_PlayerTouch)( struct playermove_s *ppmove, edict_t *client );
// alloc or destroy model custom data (called only for dedicated servers, otherwise using an client version)
void (*Mod_ProcessUserData)( struct model_s *mod, qboolean create, const byte *buffer );
} physics_interface_t;
#endif//PHYSINT_H

View File

@ -713,7 +713,7 @@ void SV_SendClientMessages( void )
int i;
svs.currentPlayer = NULL;
svs.currentPlayerNum = 0;
svs.currentPlayerNum = -1;
if( sv.state == ss_dead )
return;
@ -787,7 +787,7 @@ void SV_SendClientMessages( void )
// reset current client
svs.currentPlayer = NULL;
svs.currentPlayerNum = 0;
svs.currentPlayerNum = -1;
}
/*

View File

@ -266,7 +266,7 @@ MSG_PVS send to clients potentially visible from org
MSG_PHS send to clients potentially audible from org
=================
*/
qboolean SV_Send( int dest, const vec3_t origin, const edict_t *ent, qboolean usermessage )
qboolean SV_Send( int dest, const vec3_t origin, const edict_t *ent, qboolean usermessage, qboolean filter )
{
byte *mask = NULL;
int j, numclients = sv_maxclients->integer;
@ -340,6 +340,11 @@ qboolean SV_Send( int dest, const vec3_t origin, const edict_t *ent, qboolean us
if( !cl->edict || FBitSet( cl->flags, FCL_FAKECLIENT ))
continue;
// reject step sounds while predicting is enabled
// FIXME: make sure what this code doesn't cutoff something important!!!
if( filter && cl == svs.currentPlayer && FBitSet( svs.currentPlayer->flags, FCL_PREDICT_MOVEMENT ))
continue;
if( ent != NULL && ent->v.groupinfo && cl->edict->v.groupinfo )
{
if(( !svs.groupop && !( cl->edict->v.groupinfo & ent->v.groupinfo )) || (svs.groupop == 1 && ( cl->edict->v.groupinfo & ent->v.groupinfo ) != 0 ))
@ -1862,6 +1867,7 @@ void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float
{
int sound_idx;
int entityIndex;
qboolean filter = false;
int msg_dest;
vec3_t origin;
@ -1892,7 +1898,7 @@ void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float
VectorAverage( ent->v.mins, ent->v.maxs, origin );
VectorAdd( origin, ent->v.origin, origin );
if( flags & SND_SPAWNING )
if( FBitSet( flags, SND_SPAWNING ))
msg_dest = MSG_INIT;
else if( chan == CHAN_STATIC )
msg_dest = MSG_ALL;
@ -1900,6 +1906,7 @@ void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float
// always sending stop sound command
if( flags & SND_STOP ) msg_dest = MSG_ALL;
if( flags & SND_FILTER_CLIENT ) filter = true;
if( sample[0] == '!' && Q_isdigit( sample + 1 ))
{
@ -1925,6 +1932,7 @@ void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float
if( sound_idx > 255 ) flags |= SND_LARGE_INDEX;
// not sending (because this is out of range)
flags &= ~SND_FILTER_CLIENT;
flags &= ~SND_SPAWNING;
MSG_WriteByte( &sv.multicast, svc_sound );
@ -1941,7 +1949,7 @@ void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float
MSG_WriteWord( &sv.multicast, entityIndex );
MSG_WriteVec3Coord( &sv.multicast, origin );
SV_Send( msg_dest, origin, NULL, false );
SV_Send( msg_dest, origin, NULL, false, filter );
}
/*
@ -2021,7 +2029,7 @@ void pfnEmitAmbientSound( edict_t *ent, float *pos, const char *sample, float vo
MSG_WriteWord( &sv.multicast, number );
MSG_WriteVec3Coord( &sv.multicast, pos );
SV_Send( msg_dest, pos, NULL, false );
SV_Send( msg_dest, pos, NULL, false, false );
}
/*
@ -2034,7 +2042,7 @@ void SV_StartMusic( const char *curtrack, const char *looptrack, long position )
{
MSG_WriteByte( &sv.multicast, svc_stufftext );
MSG_WriteString( &sv.multicast, va( "music \"%s\" \"%s\" %i\n", curtrack, looptrack, position ));
SV_Send( MSG_ALL, NULL, NULL, false );
SV_Send( MSG_ALL, NULL, NULL, false, false );
}
/*
@ -2348,7 +2356,7 @@ void pfnParticleEffect( const float *org, const float *dir, float color, float c
MSG_WriteByte( &sv.multicast, color );
MSG_WriteByte( &sv.multicast, 0 );
SV_Send( MSG_PVS, org, NULL, false );
SV_Send( MSG_PVS, org, NULL, false, false );
}
/*
@ -2564,7 +2572,7 @@ void pfnMessageEnd( void )
if( !VectorIsNull( svgame.msg_org )) org = svgame.msg_org;
svgame.msg_dest = bound( MSG_BROADCAST, svgame.msg_dest, MSG_SPEC );
SV_Send( svgame.msg_dest, org, svgame.msg_ent, true );
SV_Send( svgame.msg_dest, org, svgame.msg_ent, true, false );
}
/*
@ -3074,7 +3082,7 @@ int pfnRegUserMsg( const char *pszName, int iSize )
MSG_WriteByte( &sv.multicast, svgame.msg[i].number );
MSG_WriteByte( &sv.multicast, (byte)iSize );
MSG_WriteString( &sv.multicast, svgame.msg[i].name );
SV_Send( MSG_ALL, NULL, NULL, false );
SV_Send( MSG_ALL, NULL, NULL, false, false );
}
return svgame.msg[i].number;

View File

@ -420,6 +420,9 @@ void SV_ReadPackets( void )
if( i != sv_maxclients->integer )
continue;
}
svs.currentPlayer = NULL;
svs.currentPlayerNum = -1;
}
/*

View File

@ -1951,6 +1951,22 @@ static int pfnPointContents( const float *pos, int groupmask )
return cont;
}
const byte *pfnLoadImagePixels( const char *filename, int *width, int *height )
{
rgbdata_t *pic = FS_LoadImage( filename, NULL, 0 );
byte *buffer;
if( !pic ) return NULL;
buffer = Mem_Alloc( svgame.mempool, pic->size );
if( buffer ) memcpy( buffer, pic->buffer, pic->size );
if( width ) *width = pic->width;
if( height ) *height = pic->height;
FS_FreeImage( pic );
return buffer;
}
static server_physics_api_t gPhysicsAPI =
{
SV_LinkEdict,
@ -1982,6 +1998,7 @@ static server_physics_api_t gPhysicsAPI =
Mod_ReadLump,
Mod_SaveLump,
COM_SaveFile,
pfnLoadImagePixels,
};
/*

View File

@ -478,7 +478,7 @@ static void pfnPlaySound( int channel, const char *sample, float volume, float a
ent = EDICT_NUM( svgame.pmove->player_index + 1 );
if( !SV_IsValidEdict( ent )) return;
SV_StartSound( ent, channel, sample, volume, attenuation, fFlags, pitch );
SV_StartSound( ent, channel, sample, volume, attenuation, fFlags|SND_FILTER_CLIENT, pitch );
}
static void pfnPlaybackEventFull( int flags, int clientindex, word eventindex, float delay, float *origin,