diff --git a/common/gameinfo.h b/common/gameinfo.h index 511b3718..aacc74d3 100644 --- a/common/gameinfo.h +++ b/common/gameinfo.h @@ -17,6 +17,7 @@ GNU General Public License for more details. #define GAMEINFO_H #define GFL_NOMODELS (1<<0) +#define GFL_NOSKILLS (1<<1) /* ======================================================================== diff --git a/common/render_api.h b/common/render_api.h index b6b8f462..77c8bedf 100644 --- a/common/render_api.h +++ b/common/render_api.h @@ -79,7 +79,7 @@ typedef enum TF_KEEP_SOURCE = (1<<1), // some images keep source TF_NOFLIP_TGA = (1<<2), // Steam background completely ignore tga attribute 0x20 TF_EXPAND_SOURCE = (1<<3), // Don't keep source as 8-bit expand to RGBA -// reserved + TF_ALLOW_EMBOSS = (1<<4), // Allow emboss-mapping for this image TF_RECTANGLE = (1<<5), // this is GL_TEXTURE_RECTANGLE TF_CUBEMAP = (1<<6), // it's cubemap texture TF_DEPTHMAP = (1<<7), // custom texture filter used @@ -183,16 +183,16 @@ typedef struct render_api_s void (*R_EntityRemoveDecals)( struct model_s *mod ); // remove all the decals from specified entity (BSP only) // AVIkit support - void *(*AVI_LoadVideo)( const char *filename ); + void *(*AVI_LoadVideo)( const char *filename, qboolean load_audio ); int (*AVI_GetVideoInfo)( void *Avi, long *xres, long *yres, float *duration ); long (*AVI_GetVideoFrameNumber)( void *Avi, float time ); byte *(*AVI_GetVideoFrame)( void *Avi, long frame ); void (*AVI_UploadRawFrame)( int texture, int cols, int rows, int width, int height, const byte *data ); void (*AVI_FreeVideo)( void *Avi ); int (*AVI_IsActive)( void *Avi ); + void (*AVI_StreamSound)( void *Avi, int entnum, float fvol, float attn, float synctime ); void (*AVI_Reserved0)( void ); // for potential interface expansion without broken compatibility void (*AVI_Reserved1)( void ); - void (*AVI_Reserved2)( void ); // glState related calls (must use this instead of normal gl-calls to prevent de-synchornize local states between engine and the client) void (*GL_Bind)( int tmu, unsigned int texnum ); diff --git a/engine/client/cl_demo.c b/engine/client/cl_demo.c index c37cba7e..f1ffbc27 100644 --- a/engine/client/cl_demo.c +++ b/engine/client/cl_demo.c @@ -725,7 +725,7 @@ void CL_DemoCompleted( void ) CL_StopPlayback(); - if( !CL_NextDemo() && host_developer.value <= DEV_NONE ) + if( !CL_NextDemo() && !cls.changedemo ) UI_SetActiveMenu( true ); Cvar_SetValue( "v_dark", 0.0f ); @@ -795,6 +795,8 @@ qboolean CL_ReadRawNetworkData( byte *buffer, size_t *length ) } } + cls.netchan.last_received = host.realtime; + cls.netchan.total_received += msglen; *length = msglen; if( cls.state != ca_active ) @@ -812,6 +814,7 @@ reads demo data and write it to client */ qboolean CL_DemoReadMessageQuake( byte *buffer, size_t *length ) { + vec3_t viewangles; int msglen = 0; demoangle_t *a; @@ -841,10 +844,12 @@ qboolean CL_DemoReadMessageQuake( byte *buffer, size_t *length ) // get the next message FS_Read( cls.demofile, &msglen, sizeof( int )); - FS_Read( cls.demofile, &cl.viewangles[0], sizeof( float )); - FS_Read( cls.demofile, &cl.viewangles[1], sizeof( float )); - FS_Read( cls.demofile, &cl.viewangles[2], sizeof( float )); + FS_Read( cls.demofile, &viewangles[0], sizeof( float )); + FS_Read( cls.demofile, &viewangles[1], sizeof( float )); + FS_Read( cls.demofile, &viewangles[2], sizeof( float )); cls.netchan.incoming_sequence++; + demo.timestamp = cl.mtime[0]; + cl.skip_interp = false; // make sure what interp info contain angles from different frames // or lerping will stop working @@ -856,7 +861,7 @@ qboolean CL_DemoReadMessageQuake( byte *buffer, size_t *length ) // record update a->starttime = demo.timestamp; - VectorCopy( cl.viewangles, a->viewangles ); + VectorCopy( viewangles, a->viewangles ); demo.lasttime = demo.timestamp; } @@ -884,6 +889,8 @@ qboolean CL_DemoReadMessageQuake( byte *buffer, size_t *length ) } } + cls.netchan.last_received = host.realtime; + cls.netchan.total_received += msglen; *length = msglen; if( cls.state != ca_active ) @@ -1073,14 +1080,26 @@ but viewangles interpolate here */ void CL_DemoInterpolateAngles( void ) { - float curtime = (CL_GetDemoPlaybackClock() - demo.starttime) - host.frametime; demoangle_t *prev = NULL, *next = NULL; float frac = 0.0f; + float curtime; - if( curtime > demo.timestamp ) - curtime = demo.timestamp; // don't run too far + if( cls.demoplayback == DEMO_QUAKE1 ) + { + // manually select next & prev states + next = &demo.cmds[(demo.angle_position - 0) & ANGLE_MASK]; + prev = &demo.cmds[(demo.angle_position - 1) & ANGLE_MASK]; + if( cl.skip_interp ) *prev = *next; // camera was teleported + frac = cl.lerpFrac; + } + else + { + curtime = (CL_GetDemoPlaybackClock() - demo.starttime) - host.frametime; + if( curtime > demo.timestamp ) + curtime = demo.timestamp; // don't run too far - CL_DemoFindInterpolatedViewAngles( curtime, &frac, &prev, &next ); + CL_DemoFindInterpolatedViewAngles( curtime, &frac, &prev, &next ); + } if( prev && next ) { @@ -1091,7 +1110,7 @@ void CL_DemoInterpolateAngles( void ) QuaternionSlerp( q2, q1, frac, q ); QuaternionAngle( q, cl.viewangles ); } - else if( cls.demoplayback != DEMO_QUAKE1 ) + else if( cl.cmd != NULL ) VectorCopy( cl.cmd->viewangles, cl.viewangles ); } @@ -1295,6 +1314,7 @@ void CL_CheckStartupDemos( void ) // run demos loop in background mode Cvar_SetValue( "v_dark", 1.0f ); + cls.demos_pending = false; cls.demonum = 0; CL_NextDemo (); } @@ -1304,11 +1324,10 @@ void CL_CheckStartupDemos( void ) CL_DemoGetName ================== */ -void CL_DemoGetName( int lastnum, char *filename ) +static void CL_DemoGetName( int lastnum, char *filename ) { int a, b, c, d; - if( !filename ) return; if( lastnum < 0 || lastnum > 9999 ) { // bound @@ -1584,17 +1603,15 @@ void CL_Demos_f( void ) return; } - cls.demonum = cls.olddemonum; + // demos loop are not running + if( cls.olddemonum == -1 ) + return; - if( cls.demonum == -1 ) - cls.demonum = 0; + cls.demonum = cls.olddemonum; + // run demos loop in background mode if( !SV_Active() && !cls.demoplayback ) - { - // run demos loop in background mode - cls.changedemo = true; CL_NextDemo (); - } } diff --git a/engine/client/cl_frame.c b/engine/client/cl_frame.c index 661059fc..a968d75b 100644 --- a/engine/client/cl_frame.c +++ b/engine/client/cl_frame.c @@ -96,7 +96,7 @@ we don't want interpolate this */ qboolean CL_EntityTeleported( cl_entity_t *ent ) { - int len, maxlen; + float len, maxlen; vec3_t delta; VectorSubtract( ent->curstate.origin, ent->prevstate.origin, delta ); @@ -407,7 +407,21 @@ int CL_InterpolateModel( cl_entity_t *e ) VectorCopy( e->curstate.origin, e->origin ); VectorCopy( e->curstate.angles, e->angles ); - if( cls.timedemo || !e->model || cl.maxclients <= 1 ) + if( cls.timedemo || !e->model ) + return 1; + + if( cls.demoplayback == DEMO_QUAKE1 ) + { + // quake lerping is easy + VectorLerp( e->prevstate.origin, cl.lerpFrac, e->curstate.origin, e->origin ); + AngleQuaternion( e->prevstate.angles, q1, false ); + AngleQuaternion( e->curstate.angles, q2, false ); + QuaternionSlerp( q1, q2, cl.lerpFrac, q ); + QuaternionAngle( q, e->angles ); + return 1; + } + + if( cl.maxclients <= 1 ) return 1; if( e->model->type == mod_brush && !cl_bmodelinterp->value ) @@ -474,12 +488,24 @@ interpolate non-local clients void CL_ComputePlayerOrigin( cl_entity_t *ent ) { float targettime; + vec4_t q, q1, q2; vec3_t origin; vec3_t angles; if( !ent->player || ent->index == ( cl.playernum + 1 )) return; + if( cls.demoplayback == DEMO_QUAKE1 ) + { + // quake lerping is easy + VectorLerp( ent->prevstate.origin, cl.lerpFrac, ent->curstate.origin, ent->origin ); + AngleQuaternion( ent->prevstate.angles, q1, false ); + AngleQuaternion( ent->curstate.angles, q2, false ); + QuaternionSlerp( q1, q2, cl.lerpFrac, q ); + QuaternionAngle( q, ent->angles ); + return; + } + targettime = cl.time - cl_interp->value; CL_PureOrigin( ent, targettime, origin, angles ); @@ -985,9 +1011,12 @@ void CL_LinkPlayers( frame_t *frame ) if( i == cl.playernum ) { - VectorCopy( state->origin, ent->origin ); - VectorCopy( state->origin, ent->prevstate.origin ); - VectorCopy( state->origin, ent->curstate.origin ); + if( cls.demoplayback != DEMO_QUAKE1 ) + { + VectorCopy( state->origin, ent->origin ); + VectorCopy( state->origin, ent->prevstate.origin ); + VectorCopy( state->origin, ent->curstate.origin ); + } VectorCopy( ent->curstate.angles, ent->angles ); } @@ -1003,6 +1032,8 @@ void CL_LinkPlayers( frame_t *frame ) if ( i == cl.playernum ) { + if( cls.demoplayback == DEMO_QUAKE1 ) + VectorLerp( ent->prevstate.origin, cl.lerpFrac, ent->curstate.origin, cl.simorg ); VectorCopy( cl.simorg, ent->origin ); } else @@ -1321,8 +1352,25 @@ qboolean CL_GetEntitySpatialization( channel_t *ch ) qboolean CL_GetMovieSpatialization( rawchan_t *ch ) { - // UNDONE - return false; + cl_entity_t *ent; + qboolean valid_origin; + + valid_origin = VectorIsNull( ch->origin ) ? false : true; + ent = CL_GetEntityByIndex( ch->entnum ); + + // entity is not present on the client but has valid origin + if( !ent || !ent->index || ent->curstate.messagenum == 0 ) + return valid_origin; + + // setup origin + VectorAverage( ent->curstate.mins, ent->curstate.maxs, ch->origin ); + VectorAdd( ch->origin, ent->curstate.origin, ch->origin ); + + // setup radius + if( ent->model != NULL && ent->model->radius ) ch->radius = ent->model->radius; + else ch->radius = RadiusFromBounds( ent->curstate.mins, ent->curstate.maxs ); + + return true; } void CL_ExtraUpdate( void ) diff --git a/engine/client/cl_gameui.c b/engine/client/cl_gameui.c index dce138b9..7bfa0a31 100644 --- a/engine/client/cl_gameui.c +++ b/engine/client/cl_gameui.c @@ -260,6 +260,8 @@ static void UI_ConvertGameInfo( GAMEINFO *out, gameinfo_t *in ) if( in->nomodels ) out->flags |= GFL_NOMODELS; + if( in->noskills ) + out->flags |= GFL_NOSKILLS; } static qboolean PIC_Scissor( float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 ) @@ -386,7 +388,7 @@ static HIMAGE pfnPIC_Load( const char *szPicName, const byte *image_buf, long im SetBits( flags, TF_IMAGE ); Image_SetForceFlags( IL_LOAD_DECAL ); // allow decal images for menu - tx = GL_LoadTexture( szPicName, image_buf, image_size, flags, NULL ); + tx = GL_LoadTexture( szPicName, image_buf, image_size, flags ); Image_ClearForceFlags(); return tx; diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index a156a8b4..73dd1c41 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -913,16 +913,10 @@ void CL_BeginUpload_f( void ) name = Cmd_Argv( 1 ); if( !COM_CheckString( name )) - { - MsgDev( D_ERROR, "upload without filename\n" ); return; - } if( !cl_allow_upload.value ) - { - MsgDev( D_WARN, "ingoring decal upload ( cl_allow_upload is 0 )\n" ); return; - } if( Q_strlen( name ) != 36 || Q_strnicmp( name, "!MD5", 4 )) { @@ -937,7 +931,7 @@ void CL_BeginUpload_f( void ) { if( memcmp( md5, custResource.rgucMD5_hash, 16 )) { - MsgDev( D_REPORT, "Bogus data retrieved from %s, attempting to delete entry\n", CUSTOM_RES_PATH ); + Con_Reportf( "Bogus data retrieved from %s, attempting to delete entry\n", CUSTOM_RES_PATH ); HPAK_RemoveLump( CUSTOM_RES_PATH, &custResource ); return; } @@ -954,26 +948,22 @@ void CL_BeginUpload_f( void ) if( memcmp( custResource.rgucMD5_hash, md5, 16 )) { - MsgDev( D_REPORT, "HPAK_AddLump called with bogus lump, md5 mismatch\n" ); - MsgDev( D_REPORT, "Purported: %s\n", MD5_Print( custResource.rgucMD5_hash ) ); - MsgDev( D_REPORT, "Actual : %s\n", MD5_Print( md5 ) ); - MsgDev( D_REPORT, "Removing conflicting lump\n" ); + Con_Reportf( "HPAK_AddLump called with bogus lump, md5 mismatch\n" ); + Con_Reportf( "Purported: %s\n", MD5_Print( custResource.rgucMD5_hash ) ); + Con_Reportf( "Actual : %s\n", MD5_Print( md5 ) ); + Con_Reportf( "Removing conflicting lump\n" ); HPAK_RemoveLump( CUSTOM_RES_PATH, &custResource ); return; } } } - if( buf && size ) + if( buf && size > 0 ) { Netchan_CreateFileFragmentsFromBuffer( &cls.netchan, name, buf, size ); Netchan_FragSend( &cls.netchan ); Mem_Free( buf ); } - else - { - MsgDev( D_REPORT, "ingoring customization upload, couldn't find decal locally\n" ); - } } /* @@ -1103,7 +1093,6 @@ void CL_CheckForResend( void ) if( !NET_StringToAdr( cls.servername, &adr )) { - MsgDev( D_ERROR, "CL_CheckForResend: bad server address\n" ); CL_Disconnect(); return; } @@ -1111,7 +1100,7 @@ void CL_CheckForResend( void ) // only retry so many times before failure. if( cls.connect_retry >= CL_CONNECTION_RETRIES ) { - MsgDev( D_ERROR, "CL_CheckForResend: couldn't connected\n" ); + Con_DPrintf( S_ERROR "CL_CheckForResend: couldn't connected\n" ); CL_Disconnect(); return; } @@ -1493,12 +1482,15 @@ void CL_InternetServers_f( void ) int remaining = sizeof( fullquery ) - sizeof( MS_SCAN_REQUEST ); netadr_t adr; - Con_Printf( "Scanning for servers on the internet area...\n" ); NET_Config( true ); // allow remote if( !NET_StringToAdr( MASTERSERVER_ADR, &adr ) ) - MsgDev( D_ERROR, "Can't resolve adr: %s\n", MASTERSERVER_ADR ); + { + Con_DPrintf( S_ERROR "Can't resolve adr: %s\n", MASTERSERVER_ADR ); + return; + } + Con_Printf( "Scanning for servers on the internet area...\n" ); Info_SetValueForKey( info, "gamedir", GI->gamefolder, remaining ); Info_SetValueForKey( info, "clver", XASH_VERSION, remaining ); // let master know about client version @@ -1788,7 +1780,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) { if( cls.state == ca_connected ) { - MsgDev( D_ERROR, "dup connect received. ignored\n"); + Con_DPrintf( S_ERROR "dup connect received. ignored\n"); return; } @@ -1972,7 +1964,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) // user out of band message (must be handled in CL_ConnectionlessPacket) if( len > 0 ) Netchan_OutOfBand( NS_SERVER, from, len, buf ); } - else MsgDev( D_ERROR, "bad connectionless packet from %s:\n%s\n", NET_AdrToString( from ), args ); + else Con_DPrintf( S_ERROR "bad connectionless packet from %s:\n%s\n", NET_AdrToString( from ), args ); } /* @@ -2021,14 +2013,14 @@ void CL_ReadNetMessage( void ) if( !cls.demoplayback && MSG_GetMaxBytes( &net_message ) < 8 ) { - MsgDev( D_WARN, "%s: runt packet\n", NET_AdrToString( net_from )); + Con_Printf( S_WARN "CL_ReadPackets: %s:runt packet\n", NET_AdrToString( net_from )); continue; } // packet from server if( !cls.demoplayback && !NET_CompareAdr( net_from, cls.netchan.remote_address )) { - MsgDev( D_ERROR, "CL_ReadPackets: %s:sequenced packet without connection\n", NET_AdrToString( net_from )); + Con_DPrintf( S_ERROR "CL_ReadPackets: %s:sequenced packet without connection\n", NET_AdrToString( net_from )); continue; } @@ -2516,7 +2508,6 @@ qboolean CL_PrecacheResources( void ) CL_SetEventIndex( cl.event_precache[pRes->nIndex], pRes->nIndex ); break; default: - MsgDev( D_REPORT, "unknown resource type\n" ); break; } diff --git a/engine/client/cl_pmove.c b/engine/client/cl_pmove.c index dc76da16..a5618af1 100644 --- a/engine/client/cl_pmove.c +++ b/engine/client/cl_pmove.c @@ -1239,7 +1239,7 @@ void CL_PredictMovement( qboolean repredicting ) if( cls.state != ca_active || cls.spectator ) return; - if( cls.demoplayback && cl.cmd != NULL && !repredicting ) + if( cls.demoplayback && !repredicting ) CL_DemoInterpolateAngles(); CL_SetUpPlayerPrediction( false, false ); diff --git a/engine/client/cl_qparse.c b/engine/client/cl_qparse.c index 912a9b70..f669ff2c 100644 --- a/engine/client/cl_qparse.c +++ b/engine/client/cl_qparse.c @@ -40,6 +40,7 @@ GNU General Public License for more details. #define STAT_MONSTERS 14 // bumped by svc_killedmonster #define MAX_STATS 32 +static char cmd_buf[8192]; static char msg_buf[8192]; static sizebuf_t msg_demo; @@ -69,6 +70,28 @@ static void CL_ParseQuakeStats( sizebuf_t *msg ) CL_DispatchQuakeMessage( "Stats" ); } +/* +================== +CL_EntityTeleported + +check for instant movement in case +we don't want interpolate this +================== +*/ +static qboolean CL_QuakeEntityTeleported( cl_entity_t *ent, entity_state_t *newstate ) +{ + float len, maxlen; + vec3_t delta; + + VectorSubtract( newstate->origin, ent->prevstate.origin, delta ); + + // compute potential max movement in units per frame and compare with entity movement + maxlen = ( clgame.movevars.maxvelocity * ( 1.0 / GAME_FPS )); + len = VectorLength( delta ); + + return (len > maxlen); +} + /* ================== CL_ParseQuakeStats @@ -304,6 +327,7 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg ) clgame.movevars.waveHeight = 0.0f; clgame.movevars.zmax = 14172.0f; // 8192 * 1.74 clgame.movevars.gravity = 800.0f; // quake doesn't write gravity in demos + clgame.movevars.maxvelocity = 2000.0f; memcpy( &clgame.oldmovevars, &clgame.movevars, sizeof( movevars_t )); } @@ -501,7 +525,16 @@ void CL_ParseQuakeEntityData( sizebuf_t *msg, int bits ) } if( FBitSet( bits, U_NOLERP )) + state->movetype = MOVETYPE_STEP; + else state->movetype = MOVETYPE_NOCLIP; + + if( CL_QuakeEntityTeleported( ent, state )) + { + // remove smooth stepping + if( cl.viewentity == ent->index ) + cl.skip_interp = true; forcelink = true; + } if( FBitSet( state->effects, 16 )) SetBits( state->effects, EF_NODRAW ); @@ -511,6 +544,10 @@ void CL_ParseQuakeEntityData( sizebuf_t *msg, int bits ) if( forcelink ) { + VectorCopy( state->origin, ent->baseline.vuser1 ); + + SetBits( state->effects, EF_NOINTERP ); + // interpolation must be reset SETVISBIT( frame->flags, pack ); @@ -697,6 +734,9 @@ static void CL_ParseQuakeTempEntity( sizebuf_t *msg ) MSG_WriteByte( &msg_demo, type ); + if( type == 17 ) + MSG_WriteString( &msg_demo, MSG_ReadString( msg )); + // TE_LIGHTNING1, TE_LIGHTNING2, TE_LIGHTNING3, TE_BEAM, TE_LIGHTNING4 if( type == 5 || type == 6 || type == 9 || type == 13 || type == 17 ) MSG_WriteWord( &msg_demo, MSG_ReadWord( msg )); @@ -722,9 +762,6 @@ static void CL_ParseQuakeTempEntity( sizebuf_t *msg ) MSG_WriteByte( &msg_demo, MSG_ReadByte( msg )); } - if( type == 17 ) - MSG_WriteString( &msg_demo, MSG_ReadString( msg )); - // TE_SMOKE (nehahra) if( type == 18 ) MSG_WriteByte( &msg_demo, MSG_ReadByte( msg )); @@ -744,7 +781,7 @@ static void CL_ParseQuakeSignon( sizebuf_t *msg ) int i = MSG_ReadByte( msg ); if( i == 3 ) cls.signon = SIGNONS - 1; - Con_Printf( "CL_Signon: %d\n", i ); + Con_Reportf( "CL_Signon: %d\n", i ); } /* @@ -776,6 +813,75 @@ static void CL_ParseNehahraHideLMP( sizebuf_t *msg ) CL_DispatchQuakeMessage( "Stats" ); } +/* +================== +CL_QuakeStuffText + +================== +*/ +void CL_QuakeStuffText( const char *text ) +{ + Q_strncat( cmd_buf, text, sizeof( cmd_buf )); + Cbuf_AddText( text ); +} + +/* +================== +CL_QuakeExecStuff + +================== +*/ +void CL_QuakeExecStuff( void ) +{ + char *text = cmd_buf; + char token[256]; + int argc = 0; + + // check if no commands this frame + if( !COM_CheckString( text )) + return; + + while( 1 ) + { + // skip whitespace up to a /n + while( *text && ((byte)*text) <= ' ' && *text != '\r' && *text != '\n' ) + text++; + + if( *text == '\n' || *text == '\r' ) + { + // a newline seperates commands in the buffer + if( *text == '\r' && text[1] == '\n' ) + text++; + argc = 0; + text++; + } + + if( !*text ) break; + + host.com_ignorebracket = true; + text = COM_ParseFile( text, token ); + host.com_ignorebracket = false; + + if( !text ) break; + + if( argc == 0 ) + { + // debug: find all missed commands and cvars to add them into QWrap + if( !Cvar_Exists( token ) && !Cmd_Exists( token )) + Con_Printf( S_WARN "'%s' is not exist\n", token ); +// else Msg( "cmd: %s\n", token ); + + // process some special commands + if( !Q_stricmp( token, "playdemo" )) + cls.changedemo = true; + argc++; + } + } + + // reset the buffer + cmd_buf[0] = '\0'; +} + /* ================== CL_ParseQuakeMessage @@ -861,16 +967,15 @@ void CL_ParseQuakeMessage( sizebuf_t *msg, qboolean normal_message ) cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart; break; case svc_time: + Cbuf_AddText( "\n" ); // new frame was started CL_ParseServerTime( msg ); break; case svc_print: - Con_Printf( "%s", MSG_ReadString( msg )); + str = MSG_ReadString( msg ); + Con_Printf( "%s%s", str, *str == 2 ? "\n" : "" ); break; case svc_stufftext: - // FIXME: do revision for all Quake and Nehahra console commands - str = MSG_ReadString( msg ); - Msg( "%s\n", str ); - Cbuf_AddText( str ); + CL_QuakeStuffText( MSG_ReadString( msg )); break; case svc_setangle: cl.viewangles[0] = MSG_ReadAngle( msg ); @@ -909,8 +1014,8 @@ void CL_ParseQuakeMessage( sizebuf_t *msg, qboolean normal_message ) case svc_updatecolors: param1 = MSG_ReadByte( msg ); param2 = MSG_ReadByte( msg ); - cl.players[param1].topcolor = param2 & 0xF0; - cl.players[param1].bottomcolor = (param2 & 15) << 4; + cl.players[param1].topcolor = param2 & 0xF; + cl.players[param1].bottomcolor = (param2 & 0xF0) >> 4; break; case svc_particle: CL_ParseQuakeParticle( msg ); @@ -1018,4 +1123,7 @@ void CL_ParseQuakeMessage( sizebuf_t *msg, qboolean normal_message ) // add new entities into physic lists CL_SetSolidEntities(); + + // check deferred cmds + CL_QuakeExecStuff(); } \ No newline at end of file diff --git a/engine/client/cl_remap.c b/engine/client/cl_remap.c index f445ef7a..dfa7af55 100644 --- a/engine/client/cl_remap.c +++ b/engine/client/cl_remap.c @@ -126,7 +126,7 @@ void CL_DuplicateTexture( mstudiotexture_t *ptexture, int topcolor, int bottomco memcpy( paletteBackup, pal, 768 ); raw = CL_CreateRawTextureFromPixels( tx, &size, topcolor, bottomcolor ); - ptexture->index = GL_LoadTexture( texname, raw, size, TF_FORCE_COLOR, NULL ); // do copy + ptexture->index = GL_LoadTexture( texname, raw, size, TF_FORCE_COLOR ); // do copy // restore original palette memcpy( pal, paletteBackup, 768 ); @@ -213,7 +213,7 @@ void CL_UpdateAliasTexture( unsigned short *texture, int skinnum, int topcolor, if( *texture == 0 ) { - Q_snprintf( texname, sizeof( texname ), "%s:remap%i", RI.currentmodel->name, skinnum ); + Q_snprintf( texname, sizeof( texname ), "%s:remap%i_%i", RI.currentmodel->name, skinnum, RI.currententity->index ); skin.width = tx->width; skin.height = tx->height; skin.depth = skin.numMips = 1; diff --git a/engine/client/cl_scrn.c b/engine/client/cl_scrn.c index cc600be3..c5b89bc6 100644 --- a/engine/client/cl_scrn.c +++ b/engine/client/cl_scrn.c @@ -296,7 +296,7 @@ void SCR_DrawPlaque( void ) { if(( cl_allow_levelshots->value && !cls.changelevel ) || cl.background ) { - int levelshot = GL_LoadTexture( cl_levelshot_name->string, NULL, 0, TF_IMAGE, NULL ); + int levelshot = GL_LoadTexture( cl_levelshot_name->string, NULL, 0, TF_IMAGE ); GL_SetRenderMode( kRenderNormal ); R_DrawStretchPic( 0, 0, glState.width, glState.height, 0, 0, 1, 1, levelshot ); if( !cl.background ) CL_DrawHUD( CL_LOADING ); @@ -496,7 +496,7 @@ qboolean SCR_LoadFixedWidthFont( const char *fontname ) if( !FS_FileExists( fontname, false )) return false; - cls.creditsFont.hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_IMAGE|TF_KEEP_SOURCE, NULL ); + cls.creditsFont.hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_IMAGE|TF_KEEP_SOURCE ); R_GetTextureParms( &fontWidth, NULL, cls.creditsFont.hFontTexture ); cls.creditsFont.charHeight = clgame.scrInfo.iCharHeight = fontWidth / 16; cls.creditsFont.type = FONT_FIXED; @@ -528,7 +528,7 @@ qboolean SCR_LoadVariableWidthFont( const char *fontname ) if( !FS_FileExists( fontname, false )) return false; - cls.creditsFont.hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_IMAGE, NULL ); + cls.creditsFont.hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_IMAGE ); R_GetTextureParms( &fontWidth, NULL, cls.creditsFont.hFontTexture ); // half-life font with variable chars witdh @@ -626,24 +626,24 @@ void SCR_RegisterTextures( void ) // register gfx.wad images if( FS_FileExists( "gfx/paused.lmp", false )) - cls.pauseIcon = GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE, NULL ); + cls.pauseIcon = GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE ); else if( FS_FileExists( "gfx/pause.lmp", false )) - cls.pauseIcon = GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE, NULL ); + cls.pauseIcon = GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE ); if( FS_FileExists( "gfx/lambda.lmp", false )) { if( cl_allow_levelshots->value ) - cls.loadingBar = GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE, NULL ); - else cls.loadingBar = GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE, NULL ); + cls.loadingBar = GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE ); + else cls.loadingBar = GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE ); } else if( FS_FileExists( "gfx/loading.lmp", false )) { if( cl_allow_levelshots->value ) - cls.loadingBar = GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE, NULL ); - else cls.loadingBar = GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE, NULL ); + cls.loadingBar = GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE ); + else cls.loadingBar = GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE ); } - cls.tileImage = GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP, NULL ); + cls.tileImage = GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP ); } /* diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index 6202f33f..b23ad52c 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -2838,7 +2838,7 @@ void CL_AddEntityEffects( cl_entity_t *ent ) } // studio models are handle muzzleflashes difference - if( FBitSet( ent->curstate.effects, EF_MUZZLEFLASH ) && ent->model->type == mod_alias ) + if( FBitSet( ent->curstate.effects, EF_MUZZLEFLASH ) && Mod_AliasExtradata( ent->model )) { dlight_t *dl = CL_AllocDlight( ent->index ); vec3_t fv; @@ -2864,6 +2864,7 @@ these effects will be enable by flag in model header */ void CL_AddModelEffects( cl_entity_t *ent ) { + vec3_t neworigin; vec3_t oldorigin; if( !ent->model ) return; @@ -2876,23 +2877,33 @@ void CL_AddModelEffects( cl_entity_t *ent ) default: return; } - VectorCopy( ent->prevstate.origin, oldorigin ); + if( cls.demoplayback == DEMO_QUAKE1 ) + { + VectorCopy( ent->baseline.vuser1, oldorigin ); + VectorCopy( ent->origin, ent->baseline.vuser1 ); + VectorCopy( ent->origin, neworigin ); + } + else + { + VectorCopy( ent->prevstate.origin, oldorigin ); + VectorCopy( ent->curstate.origin, neworigin ); + } // NOTE: this completely over control about angles and don't broke interpolation if( FBitSet( ent->model->flags, STUDIO_ROTATE )) ent->angles[1] = anglemod( 100.0f * cl.time ); if( FBitSet( ent->model->flags, STUDIO_GIB )) - R_RocketTrail( oldorigin, ent->curstate.origin, 2 ); + R_RocketTrail( oldorigin, neworigin, 2 ); if( FBitSet( ent->model->flags, STUDIO_ZOMGIB )) - R_RocketTrail( oldorigin, ent->curstate.origin, 4 ); + R_RocketTrail( oldorigin, neworigin, 4 ); if( FBitSet( ent->model->flags, STUDIO_TRACER )) - R_RocketTrail( oldorigin, ent->curstate.origin, 3 ); + R_RocketTrail( oldorigin, neworigin, 3 ); if( FBitSet( ent->model->flags, STUDIO_TRACER2 )) - R_RocketTrail( oldorigin, ent->curstate.origin, 5 ); + R_RocketTrail( oldorigin, neworigin, 5 ); if( FBitSet( ent->model->flags, STUDIO_ROCKET )) { @@ -2908,14 +2919,14 @@ void CL_AddModelEffects( cl_entity_t *ent ) dl->die = cl.time + 0.01f; - R_RocketTrail( oldorigin, ent->curstate.origin, 0 ); + R_RocketTrail( oldorigin, neworigin, 0 ); } if( FBitSet( ent->model->flags, STUDIO_GRENADE )) - R_RocketTrail( oldorigin, ent->curstate.origin, 1 ); + R_RocketTrail( oldorigin, neworigin, 1 ); if( FBitSet( ent->model->flags, STUDIO_TRACER3 )) - R_RocketTrail( oldorigin, ent->curstate.origin, 6 ); + R_RocketTrail( oldorigin, neworigin, 6 ); } /* @@ -3053,7 +3064,7 @@ int CL_DecalIndex( int id ) if( cl.decal_index[id] == 0 ) { Image_SetForceFlags( IL_LOAD_DECAL ); - cl.decal_index[id] = GL_LoadTexture( host.draw_decals[id], NULL, 0, TF_DECAL, NULL ); + cl.decal_index[id] = GL_LoadTexture( host.draw_decals[id], NULL, 0, TF_DECAL ); Image_ClearForceFlags(); } diff --git a/engine/client/cl_view.c b/engine/client/cl_view.c index 78ab8722..7db22f67 100644 --- a/engine/client/cl_view.c +++ b/engine/client/cl_view.c @@ -19,6 +19,7 @@ GNU General Public License for more details. #include "entity_types.h" #include "gl_local.h" #include "vgui_draw.h" +#include "sound.h" /* =============== @@ -143,7 +144,7 @@ void V_SetRefParams( ref_params_t *fd ) fd->demoplayback = cls.demoplayback; fd->hardware = 1; // OpenGL - if( cl.first_frame ) + if( cl.first_frame || cl.skip_interp ) { cl.first_frame = false; // now can be unlocked fd->smoothing = true; // NOTE: currently this used to prevent ugly un-duck effect while level is changed @@ -334,6 +335,7 @@ void V_RenderView( void ) } R_RenderFrame( &rvp ); + S_UpdateFrame( &rvp ); viewnum++; } while( rp.nextView ); diff --git a/engine/client/client.h b/engine/client/client.h index a5b3ad0f..385e18dc 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -221,6 +221,7 @@ typedef struct qboolean background; // not real game, just a background qboolean first_frame; // first rendering frame qboolean proxy_redirect; // spectator stuff + qboolean skip_interp; // skip interpolation this frame uint checksum; // for catching cheater maps @@ -1034,6 +1035,7 @@ void Con_FastClose( void ); // s_main.c // void S_StreamRawSamples( int samples, int rate, int width, int channels, const byte *data ); +void S_StreamAviSamples( void *Avi, int entnum, float fvol, float attn, float synctime ); void S_StartBackgroundTrack( const char *intro, const char *loop, long position, qboolean fullpath ); void S_StopBackgroundTrack( void ); void S_StreamSetPause( int pause ); diff --git a/engine/client/gl_alias.c b/engine/client/gl_alias.c index e7df65d8..35cfe0dc 100644 --- a/engine/client/gl_alias.c +++ b/engine/client/gl_alias.c @@ -618,10 +618,9 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded ) daliashdr_t *pinmodel; stvert_t *pinstverts; dtriangle_t *pintriangles; - int numframes, size; daliasframetype_t *pframetype; daliasskintype_t *pskintype; - int i, j; + int i, j, size; if( loaded ) *loaded = false; pinmodel = (daliashdr_t *)buffer; @@ -629,10 +628,13 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded ) if( i != ALIAS_VERSION ) { - MsgDev( D_ERROR, "%s has wrong version number (%i should be %i)\n", mod->name, i, ALIAS_VERSION ); + Con_DPrintf( S_ERROR "%s has wrong version number (%i should be %i)\n", mod->name, i, ALIAS_VERSION ); return; } + if( pinmodel->numverts <= 0 || pinmodel->numtris <= 0 || pinmodel->numframes <= 0 ) + return; // how to possible is make that? + mod->mempool = Mem_AllocPool( va( "^2%s^7", mod->name )); // allocate space for a working header, plus all the data except the frames, @@ -648,33 +650,12 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded ) m_pAliasHeader->skinwidth = pinmodel->skinwidth; m_pAliasHeader->skinheight = pinmodel->skinheight; m_pAliasHeader->numverts = pinmodel->numverts; - - if( m_pAliasHeader->numverts <= 0 ) - { - MsgDev( D_ERROR, "model %s has no vertices\n", mod->name ); - return; - } - - if( m_pAliasHeader->numverts > MAXALIASVERTS ) - { - MsgDev( D_ERROR, "model %s has too many vertices\n", mod->name ); - return; - } - m_pAliasHeader->numtris = pinmodel->numtris; - - if( m_pAliasHeader->numtris <= 0 ) - { - MsgDev( D_ERROR, "model %s has no triangles\n", mod->name ); - return; - } - m_pAliasHeader->numframes = pinmodel->numframes; - numframes = m_pAliasHeader->numframes; - if( numframes < 1 ) + if( m_pAliasHeader->numverts > MAXALIASVERTS ) { - MsgDev( D_ERROR, "Mod_LoadAliasModel: Invalid # of frames: %d\n", numframes ); + Con_DPrintf( S_ERROR "model %s has too many vertices\n", mod->name ); return; } @@ -718,7 +699,7 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded ) pframetype = (daliasframetype_t *)&pintriangles[m_pAliasHeader->numtris]; g_posenum = 0; - for( i = 0; i < numframes; i++ ) + for( i = 0; i < m_pAliasHeader->numframes; i++ ) { aliasframetype_t frametype = pframetype->type; @@ -1193,15 +1174,18 @@ void R_AliasLerpMovement( cl_entity_t *e ) if( g_alias.interpolate && ( g_alias.time < e->curstate.animtime + 1.0f ) && ( e->curstate.animtime != e->latched.prevanimtime )) f = ( g_alias.time - e->curstate.animtime ) / ( e->curstate.animtime - e->latched.prevanimtime ); + if( cls.demoplayback == DEMO_QUAKE1 ) + f = f + 1.0f; + g_alias.lerpfrac = bound( 0.0f, f, 1.0f ); if( e->player || e->curstate.movetype != MOVETYPE_STEP ) return; // monsters only - // Con_Printf( "%4.2f %.2f %.2f\n", f, e->curstate.animtime, g_studio.time ); + // Con_Printf( "%4.2f %.2f %.2f\n", f, e->curstate.animtime, g_alias.time ); VectorLerp( e->latched.prevorigin, f, e->curstate.origin, e->origin ); - if( !VectorCompare( e->curstate.angles, e->latched.prevangles )) + if( !VectorCompareEpsilon( e->curstate.angles, e->latched.prevangles, ON_EPSILON )) { vec4_t q, q1, q2; @@ -1240,7 +1224,7 @@ void R_SetupAliasFrame( cl_entity_t *e, aliashdr_t *paliashdr ) else if( newframe >= paliashdr->numframes ) { if( newframe > paliashdr->numframes ) - MsgDev( D_WARN, "R_GetAliasFrame: no such frame %d (%s)\n", newframe, e->model->name ); + Con_Reportf( S_WARN "R_GetAliasFrame: no such frame %d (%s)\n", newframe, e->model->name ); newframe = paliashdr->numframes - 1; } diff --git a/engine/client/gl_backend.c b/engine/client/gl_backend.c index 003c4683..a4f267df 100644 --- a/engine/client/gl_backend.c +++ b/engine/client/gl_backend.c @@ -536,7 +536,7 @@ qboolean VID_ScreenShot( const char *filename, int shot_type ) break; } - Image_Process( &r_shot, width, height, flags, NULL ); + Image_Process( &r_shot, width, height, flags, 0.0f ); // write image result = FS_SaveImage( filename, r_shot ); @@ -605,7 +605,7 @@ qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qbo r_side->size = r_side->width * r_side->height * 3; r_side->buffer = temp; - if( flags ) Image_Process( &r_side, 0, 0, flags, NULL ); + if( flags ) Image_Process( &r_side, 0, 0, flags, 0.0f ); memcpy( buffer + (size * size * 3 * i), r_side->buffer, size * size * 3 ); } diff --git a/engine/client/gl_image.c b/engine/client/gl_image.c index 7006b0dc..1c1436e5 100644 --- a/engine/client/gl_image.c +++ b/engine/client/gl_image.c @@ -684,8 +684,8 @@ static void GL_SetTextureFormat( gl_texture_t *tex, pixformat_t format, int chan else if( haveAlpha ) { if( FBitSet( tex->flags, TF_ARB_16BIT ) || glw_state.desktopBitsPixel == 16 ) - tex->format = GL_LUMINANCE_ALPHA16F_ARB; - else tex->format = GL_LUMINANCE_ALPHA32F_ARB; + tex->format = GL_RG16F; + else tex->format = GL_RG32F; } else { @@ -1208,7 +1208,7 @@ GL_ProcessImage do specified actions on pixels =============== */ -static void GL_ProcessImage( gl_texture_t *tex, rgbdata_t *pic, imgfilter_t *filter ) +static void GL_ProcessImage( gl_texture_t *tex, rgbdata_t *pic ) { uint img_flags = 0; @@ -1242,6 +1242,12 @@ static void GL_ProcessImage( gl_texture_t *tex, rgbdata_t *pic, imgfilter_t *fil tex->flags &= ~TF_MAKELUMA; } + if( tex->flags & TF_ALLOW_EMBOSS ) + { + img_flags |= IMAGE_EMBOSS; + tex->flags &= ~TF_ALLOW_EMBOSS; + } + if( !FBitSet( tex->flags, TF_IMG_UPLOADED ) && FBitSet( tex->flags, TF_KEEP_SOURCE )) tex->original = FS_CopyImage( pic ); // because current pic will be expanded to rgba @@ -1250,7 +1256,7 @@ static void GL_ProcessImage( gl_texture_t *tex, rgbdata_t *pic, imgfilter_t *fil img_flags |= IMAGE_FORCE_RGBA; // processing image before uploading (force to rgba, make luma etc) - if( pic->buffer ) Image_Process( &pic, 0, 0, img_flags, filter ); + if( pic->buffer ) Image_Process( &pic, 0, 0, img_flags, gl_emboss_scale->value ); if( FBitSet( tex->flags, TF_LUMINANCE )) ClearBits( pic->flags, IMAGE_HAS_COLOR ); @@ -1421,7 +1427,7 @@ void GL_UpdateTexSize( int texnum, int width, int height, int depth ) GL_LoadTexture ================ */ -int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags, imgfilter_t *filter ) +int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags ) { gl_texture_t *tex; rgbdata_t *pic; @@ -1448,7 +1454,7 @@ int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags, i // allocate the new one tex = GL_AllocTexture( name, flags ); - GL_ProcessImage( tex, pic, filter ); + GL_ProcessImage( tex, pic ); if( !GL_UploadTexture( tex, pic )) { @@ -1469,7 +1475,7 @@ int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags, i GL_LoadTextureArray ================ */ -int GL_LoadTextureArray( const char **names, int flags, imgfilter_t *filter ) +int GL_LoadTextureArray( const char **names, int flags ) { rgbdata_t *pic, *src; char basename[256]; @@ -1538,7 +1544,7 @@ int GL_LoadTextureArray( const char **names, int flags, imgfilter_t *filter ) // but allow to rescale raw images if( ImageRAW( pic->type ) && ImageRAW( src->type ) && ( pic->width != src->width || pic->height != src->height )) - Image_Process( &src, pic->width, pic->height, IMAGE_RESAMPLE, NULL ); + Image_Process( &src, pic->width, pic->height, IMAGE_RESAMPLE, 0.0f ); if( pic->size != src->size ) { @@ -1589,7 +1595,7 @@ int GL_LoadTextureArray( const char **names, int flags, imgfilter_t *filter ) // allocate the new one tex = GL_AllocTexture( name, flags ); - GL_ProcessImage( tex, pic, filter ); + GL_ProcessImage( tex, pic ); if( !GL_UploadTexture( tex, pic )) { @@ -1636,7 +1642,7 @@ int GL_LoadTextureFromBuffer( const char *name, rgbdata_t *pic, texFlags_t flags tex = GL_AllocTexture( name, flags ); } - GL_ProcessImage( tex, pic, NULL ); + GL_ProcessImage( tex, pic ); if( !GL_UploadTexture( tex, pic )) { memset( tex, 0, sizeof( gl_texture_t )); @@ -1828,7 +1834,7 @@ void GL_ProcessTexture( int texnum, float gamma, int topColor, int bottomColor ) // all the operations makes over the image copy not an original pic = FS_CopyImage( image->original ); - Image_Process( &pic, topColor, bottomColor, flags, NULL ); + Image_Process( &pic, topColor, bottomColor, flags, 0.0f ); GL_UploadTexture( image, pic ); GL_ApplyTextureParams( image ); // update texture filter, wrap etc @@ -2077,6 +2083,12 @@ void R_TextureList_f( void ) case GL_LUMINANCE_ALPHA32F_ARB: Con_Printf( "LA32F " ); break; + case GL_RG16F: + Con_Printf( "RG16F " ); + break; + case GL_RG32F: + Con_Printf( "RG32F " ); + break; case GL_RGB16F_ARB: Con_Printf( "RGB16F" ); break; @@ -2185,7 +2197,6 @@ void R_InitImages( void ) R_SetTextureParameters(); GL_CreateInternalTextures(); - R_ParseTexFilters( "scripts/texfilter.txt" ); Cmd_AddCommand( "texturelist", R_TextureList_f, "display loaded textures list" ); } diff --git a/engine/client/gl_local.h b/engine/client/gl_local.h index 3ec2c89d..c8edd17c 100644 --- a/engine/client/gl_local.h +++ b/engine/client/gl_local.h @@ -309,8 +309,8 @@ void R_SetTextureParameters( void ); gl_texture_t *R_GetTexture( GLenum texnum ); #define GL_LoadTextureInternal( name, pic, flags ) GL_LoadTextureFromBuffer( name, pic, flags, false ) #define GL_UpdateTextureInternal( name, pic, flags ) GL_LoadTextureFromBuffer( name, pic, flags, true ) -int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags, imgfilter_t *filter ); -int GL_LoadTextureArray( const char **names, int flags, imgfilter_t *filter ); +int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags ); +int GL_LoadTextureArray( const char **names, int flags ); int GL_LoadTextureFromBuffer( const char *name, rgbdata_t *pic, texFlags_t flags, qboolean update ); byte *GL_ResampleTexture( const byte *source, int in_w, int in_h, int out_w, int out_h, qboolean isNormalMap ); int GL_CreateTexture( const char *name, int width, int height, const void *buffer, texFlags_t flags ); @@ -387,8 +387,7 @@ void Matrix4x4_CreateModelview( matrix4x4 out ); // // gl_rmisc. // -void R_ParseTexFilters( const char *filename ); -imgfilter_t *R_FindTexFilter( const char *texname ); +void R_ClearStaticEntities( void ); // // gl_rsurf.c @@ -469,7 +468,7 @@ void R_Shutdown( void ); qboolean R_Init( void ); void R_Shutdown( void ); void VID_CheckChanges( void ); -int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags, imgfilter_t *filter ); +int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags ); void GL_FreeImage( const char *name ); qboolean VID_ScreenShot( const char *filename, int shot_type ); qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qboolean skyshot ); @@ -642,6 +641,7 @@ extern convar_t *gl_texture_lodbias; extern convar_t *gl_texture_nearest; extern convar_t *gl_lightmap_nearest; extern convar_t *gl_keeptjunctions; +extern convar_t *gl_emboss_scale; extern convar_t *gl_round_down; extern convar_t *gl_detailscale; extern convar_t *gl_wireframe; diff --git a/engine/client/gl_rmain.c b/engine/client/gl_rmain.c index c4b64023..1b82f595 100644 --- a/engine/client/gl_rmain.c +++ b/engine/client/gl_rmain.c @@ -1381,16 +1381,6 @@ const byte *GL_TextureData( unsigned int texnum ) return NULL; } -static int GL_LoadTextureNoFilter( const char *name, const byte *buf, size_t size, int flags ) -{ - return GL_LoadTexture( name, buf, size, flags, NULL ); -} - -static int GL_LoadTextureArrayNoFilter( const char **names, int flags ) -{ - return GL_LoadTextureArray( names, flags, NULL ); -} - static const ref_overview_t *GL_GetOverviewParms( void ) { return &clgame.overView; @@ -1473,22 +1463,22 @@ static render_api_t gRenderAPI = GL_FindTexture, GL_TextureName, GL_TextureData, - GL_LoadTextureNoFilter, + GL_LoadTexture, GL_CreateTexture, - GL_LoadTextureArrayNoFilter, + GL_LoadTextureArray, GL_CreateTextureArray, GL_FreeTexture, DrawSingleDecal, R_DecalSetupVerts, R_EntityRemoveDecals, - AVI_LoadVideoNoSound, + AVI_LoadVideo, AVI_GetVideoInfo, AVI_GetVideoFrameNumber, AVI_GetVideoFrame, R_UploadStretchRaw, AVI_FreeVideo, AVI_IsActive, - NULL, + S_StreamAviSamples, NULL, NULL, GL_Bind, diff --git a/engine/client/gl_rmisc.c b/engine/client/gl_rmisc.c index ee8cd302..727f3fa4 100644 --- a/engine/client/gl_rmisc.c +++ b/engine/client/gl_rmisc.c @@ -19,16 +19,7 @@ GNU General Public License for more details. #include "mod_local.h" #include "shake.h" -typedef struct -{ - char texname[64]; // shortname - imgfilter_t filter; -} dfilter_t; - -dfilter_t *tex_filters[MAX_TEXTURES]; -int num_texfilters; - -void R_ParseDetailTextures( const char *filename ) +static void R_ParseDetailTextures( const char *filename ) { char *afile, *pfile; string token, texname; @@ -95,7 +86,7 @@ void R_ParseDetailTextures( const char *filename ) if( Q_stricmp( tex->name, texname )) continue; - tex->dt_texturenum = GL_LoadTexture( detail_path, NULL, 0, TF_FORCE_COLOR, NULL ); + tex->dt_texturenum = GL_LoadTexture( detail_path, NULL, 0, TF_FORCE_COLOR ); // texture is loaded if( tex->dt_texturenum ) @@ -113,110 +104,6 @@ void R_ParseDetailTextures( const char *filename ) Mem_Free( afile ); } -void R_ParseTexFilters( const char *filename ) -{ - char *afile, *pfile; - string token, texname; - dfilter_t *tf; - int i; - - afile = FS_LoadFile( filename, NULL, false ); - if( !afile ) return; - - pfile = afile; - - // format: 'texturename' 'filtername' 'factor' 'bias' 'blendmode' 'grayscale' - while(( pfile = COM_ParseFile( pfile, token )) != NULL ) - { - imgfilter_t filter; - - memset( &filter, 0, sizeof( filter )); - Q_strncpy( texname, token, sizeof( texname )); - - // parse filter - pfile = COM_ParseFile( pfile, token ); - if( !Q_stricmp( token, "blur" )) - filter.filter = BLUR_FILTER; - else if( !Q_stricmp( token, "blur2" )) - filter.filter = BLUR_FILTER2; - else if( !Q_stricmp( token, "edge" )) - filter.filter = EDGE_FILTER; - else if( !Q_stricmp( token, "emboss" )) - filter.filter = EMBOSS_FILTER; - - // reading factor - pfile = COM_ParseFile( pfile, token ); - filter.factor = Q_atof( token ); - - // reading bias - pfile = COM_ParseFile( pfile, token ); - filter.bias = Q_atof( token ); - - // reading blendFunc - pfile = COM_ParseFile( pfile, token ); - if( !Q_stricmp( token, "modulate" ) || !Q_stricmp( token, "GL_MODULATE" )) - filter.blendFunc = GL_MODULATE; - else if( !Q_stricmp( token, "replace" ) || !Q_stricmp( token, "GL_REPLACE" )) - filter.blendFunc = GL_REPLACE; - else if( !Q_stricmp( token, "add" ) || !Q_stricmp( token, "GL_ADD" )) - filter.blendFunc = GL_ADD; - else if( !Q_stricmp( token, "decal" ) || !Q_stricmp( token, "GL_DECAL" )) - filter.blendFunc = GL_DECAL; - else if( !Q_stricmp( token, "blend" ) || !Q_stricmp( token, "GL_BLEND" )) - filter.blendFunc = GL_BLEND; - else if( !Q_stricmp( token, "add_signed" ) || !Q_stricmp( token, "GL_ADD_SIGNED" )) - filter.blendFunc = GL_ADD_SIGNED; - else filter.blendFunc = GL_REPLACE; // defaulting to replace - - // reading flags - pfile = COM_ParseFile( pfile, token ); - filter.flags = Q_atoi( token ); - - // make sure what factor is not zeroed - if( filter.factor == 0.0f ) - continue; - - // check if already existed - for( i = 0; i < num_texfilters; i++ ) - { - tf = tex_filters[i]; - - if( !Q_stricmp( tf->texname, texname )) - break; - } - - if( i != num_texfilters ) - continue; // already specified - - // allocate new texfilter - tf = Z_Malloc( sizeof( dfilter_t )); - tex_filters[num_texfilters++] = tf; - - Q_strncpy( tf->texname, texname, sizeof( tf->texname )); - tf->filter = filter; - } - - Con_Reportf( "%i texture filters parsed\n", num_texfilters ); - - Mem_Free( afile ); -} - -imgfilter_t *R_FindTexFilter( const char *texname ) -{ - dfilter_t *tf; - int i; - - for( i = 0; i < num_texfilters; i++ ) - { - tf = tex_filters[i]; - - if( !Q_stricmp( tf->texname, texname )) - return &tf->filter; - } - - return NULL; -} - /* ======================= R_ClearStaticEntities diff --git a/engine/client/gl_sprite.c b/engine/client/gl_sprite.c index 23b05534..67b5fa9e 100644 --- a/engine/client/gl_sprite.c +++ b/engine/client/gl_sprite.c @@ -69,12 +69,12 @@ static dframetype_t *R_SpriteLoadFrame( model_t *mod, void *pin, mspriteframe_t if( FBitSet( mod->flags, MODEL_CLIENT )) // it's a HUD sprite { Q_snprintf( texname, sizeof( texname ), "#HUD/%s(%s:%i%i).spr", sprite_name, group_suffix, num / 10, num % 10 ); - gl_texturenum = GL_LoadTexture( texname, pin, pinframe->width * pinframe->height * bytes, r_texFlags, NULL ); + gl_texturenum = GL_LoadTexture( texname, pin, pinframe->width * pinframe->height * bytes, r_texFlags ); } else { Q_snprintf( texname, sizeof( texname ), "#%s(%s:%i%i).spr", sprite_name, group_suffix, num / 10, num % 10 ); - gl_texturenum = GL_LoadTexture( texname, pin, pinframe->width * pinframe->height * bytes, r_texFlags, NULL ); + gl_texturenum = GL_LoadTexture( texname, pin, pinframe->width * pinframe->height * bytes, r_texFlags ); } // setup frame description @@ -162,13 +162,13 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui if( pin->ident != IDSPRITEHEADER ) { - MsgDev( D_ERROR, "%s has wrong id (%x should be %x)\n", mod->name, pin->ident, IDSPRITEHEADER ); + Con_DPrintf( S_ERROR "%s has wrong id (%x should be %x)\n", mod->name, pin->ident, IDSPRITEHEADER ); return; } if( i != SPRITE_VERSION_Q1 && i != SPRITE_VERSION_HL && i != SPRITE_VERSION_32 ) { - MsgDev( D_ERROR, "%s has wrong version number (%i should be %i or %i)\n", mod->name, i, SPRITE_VERSION_Q1, SPRITE_VERSION_HL ); + Con_DPrintf( S_ERROR "%s has wrong version number (%i should be %i or %i)\n", mod->name, i, SPRITE_VERSION_Q1, SPRITE_VERSION_HL ); return; } @@ -259,15 +259,12 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui } else { - MsgDev( D_ERROR, "%s has wrong number of palette colors %i (should be 256)\n", mod->name, *numi ); + Con_DPrintf( S_ERROR "%s has wrong number of palette colors %i (should be 256)\n", mod->name, *numi ); return; } if( mod->numframes < 1 ) - { - MsgDev( D_ERROR, "%s has invalid # of frames: %d\n", mod->name, mod->numframes ); return; - } for( i = 0; i < mod->numframes; i++ ) { @@ -336,7 +333,7 @@ void Mod_LoadMapSprite( model_t *mod, const void *buffer, size_t size, qboolean if( h < MAPSPRITE_SIZE ) h = MAPSPRITE_SIZE; // resample image if needed - Image_Process( &pix, w, h, IMAGE_FORCE_RGBA|IMAGE_RESAMPLE, NULL ); + Image_Process( &pix, w, h, IMAGE_FORCE_RGBA|IMAGE_RESAMPLE, 0.0f ); w = h = MAPSPRITE_SIZE; diff --git a/engine/client/gl_studio.c b/engine/client/gl_studio.c index 38e4ee70..675a99c5 100644 --- a/engine/client/gl_studio.c +++ b/engine/client/gl_studio.c @@ -1680,7 +1680,7 @@ void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight ) } } - if(( light.r + light.g + light.b ) == 0 ) + if(( light.r + light.g + light.b ) < 16 ) // TESTTEST { colorVec gcolor; float grad[4]; @@ -3740,7 +3740,6 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture size_t size; int flags = 0; char texname[128], name[128], mdlname[128]; - imgfilter_t *filter = NULL; texture_t *tx = NULL; if( ptexture->flags & STUDIO_NF_NORMALMAP ) @@ -3797,10 +3796,6 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture COM_FileBase( ptexture->name, name ); COM_StripExtension( mdlname ); - // loading texture filter for studiomodel - if( !FBitSet( ptexture->flags, STUDIO_NF_COLORMAP )) - filter = R_FindTexFilter( va( "%s.mdl/%s", mdlname, name )); // grab texture filter - if( FBitSet( ptexture->flags, STUDIO_NF_NOMIPS )) SetBits( flags, TF_NOMIPMAP ); @@ -3813,7 +3808,7 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture // build the texname Q_snprintf( texname, sizeof( texname ), "#%s/%s.mdl", mdlname, name ); - ptexture->index = GL_LoadTexture( texname, (byte *)ptexture, size, flags, filter ); + ptexture->index = GL_LoadTexture( texname, (byte *)ptexture, size, flags ); if( !ptexture->index ) { diff --git a/engine/client/gl_vidnt.c b/engine/client/gl_vidnt.c index 42212239..8f84d0fd 100644 --- a/engine/client/gl_vidnt.c +++ b/engine/client/gl_vidnt.c @@ -35,6 +35,7 @@ convar_t *gl_texture_nearest; convar_t *gl_lightmap_nearest; convar_t *gl_wgl_msaa_samples; convar_t *gl_keeptjunctions; +convar_t *gl_emboss_scale; convar_t *gl_showtextures; convar_t *gl_detailscale; convar_t *gl_check_errors; @@ -434,7 +435,7 @@ void GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cv convar_t *parm = NULL; const char *extensions_string; - MsgDev( D_NOTE, "GL_CheckExtension: %s ", name ); + Con_Reportf( "GL_CheckExtension: %s ", name ); GL_SetExtension( r_ext, true ); if( cvarname ) @@ -445,7 +446,7 @@ void GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cv if(( parm && !CVAR_TO_BOOL( parm )) || ( !CVAR_TO_BOOL( gl_extensions ) && r_ext != GL_OPENGL_110 )) { - MsgDev( D_NOTE, "- disabled\n" ); + Con_Reportf( "- disabled\n" ); GL_SetExtension( r_ext, false ); return; // nothing to process at } @@ -458,7 +459,7 @@ void GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cv if(( name[2] == '_' || name[3] == '_' ) && !Q_strstr( extensions_string, name )) { GL_SetExtension( r_ext, false ); // update render info - MsgDev( D_NOTE, "- ^1failed\n" ); + Con_Reportf( "- ^1failed\n" ); return; } @@ -474,8 +475,8 @@ void GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cv } if( GL_Support( r_ext )) - MsgDev( D_NOTE, "- ^2enabled\n" ); - else MsgDev( D_NOTE, "- ^1failed\n" ); + Con_Reportf( "- ^2enabled\n" ); + else Con_Reportf( "- ^1failed\n" ); } /* @@ -624,7 +625,7 @@ qboolean GL_CreateContext( void ) return true; } - MsgDev( D_NOTE, "GL_CreateContext: using extended context\n" ); + Con_Reportf( "GL_CreateContext: using extended context\n" ); pwglDeleteContext( hBaseRC ); // release first context glw_state.extended = true; } @@ -769,7 +770,7 @@ VID_StartupGamma void VID_StartupGamma( void ) { BuildGammaTable( vid_gamma->value, vid_brightness->value ); - MsgDev( D_NOTE, "VID_StartupGamma: gamma %g brightness %g\n", vid_gamma->value, vid_brightness->value ); + Con_Reportf( "VID_StartupGamma: gamma %g brightness %g\n", vid_gamma->value, vid_brightness->value ); ClearBits( vid_brightness->flags, FCVAR_CHANGED ); ClearBits( vid_gamma->flags, FCVAR_CHANGED ); } @@ -975,7 +976,7 @@ qboolean GL_SetPixelformat( void ) { if( PFD.dwFlags & PFD_GENERIC_ACCELERATED ) { - MsgDev( D_NOTE, "VID_ChoosePFD: using Generic MCD acceleration\n" ); + Con_Reportf( "VID_ChoosePFD: using Generic MCD acceleration\n" ); } else { @@ -985,7 +986,7 @@ qboolean GL_SetPixelformat( void ) } else { - MsgDev( D_NOTE, "VID_ChoosePFD: using hardware acceleration\n"); + Con_Reportf( "VID_ChoosePFD: using hardware acceleration\n" ); } glConfig.color_bits = PFD.cColorBits; @@ -1019,7 +1020,7 @@ void R_SaveVideoMode( int vid_mode ) Cvar_FullSet( "height", va( "%i", glState.height ), FCVAR_READ_ONLY ); Cvar_SetValue( "vid_mode", mode ); // merge if it out of bounds - MsgDev( D_NOTE, "Set: %s [%dx%d]\n", vidmode[mode].desc, vidmode[mode].width, vidmode[mode].height ); + Con_Reportf( "Set: %s [%dx%d]\n", vidmode[mode].desc, vidmode[mode].width, vidmode[mode].height ); } /* @@ -1366,12 +1367,12 @@ qboolean VID_SetMode( void ) if( R_DescribeVIDMode( iScreenWidth, iScreenHeight )) { - MsgDev( D_NOTE, "found specified vid mode %i [%ix%i]\n", (int)vid_mode->value, iScreenWidth, iScreenHeight ); + Con_Reportf( "found specified vid mode %i [%ix%i]\n", (int)vid_mode->value, iScreenWidth, iScreenHeight ); Cvar_SetValue( "fullscreen", 1 ); } else { - MsgDev( D_NOTE, "failed to set specified vid mode [%ix%i]\n", iScreenWidth, iScreenHeight ); + Con_Reportf( "failed to set specified vid mode [%ix%i]\n", iScreenWidth, iScreenHeight ); Cvar_SetValue( "vid_mode", VID_DEFAULTMODE ); } } @@ -1608,6 +1609,7 @@ void GL_InitCommands( void ) gl_texture_anisotropy = Cvar_Get( "gl_anisotropy", "8", FCVAR_ARCHIVE, "textures anisotropic filter" ); gl_texture_lodbias = Cvar_Get( "gl_texture_lodbias", "0.0", FCVAR_ARCHIVE, "LOD bias for mipmapped textures (perfomance|quality)" ); gl_keeptjunctions = Cvar_Get( "gl_keeptjunctions", "1", FCVAR_ARCHIVE, "removing tjuncs causes blinking pixels" ); + gl_emboss_scale = Cvar_Get( "gl_emboss_scale", "0", FCVAR_ARCHIVE|FCVAR_LATCH, "fake bumpmapping scale" ); gl_showtextures = Cvar_Get( "r_showtextures", "0", FCVAR_CHEAT, "show all uploaded textures" ); gl_finish = Cvar_Get( "gl_finish", "0", FCVAR_ARCHIVE, "use glFinish instead of glFlush" ); gl_nosort = Cvar_Get( "gl_nosort", "0", FCVAR_ARCHIVE, "disable sorting of translucent surfaces" ); diff --git a/engine/client/gl_warp.c b/engine/client/gl_warp.c index bb91e4a5..a6b71a6e 100644 --- a/engine/client/gl_warp.c +++ b/engine/client/gl_warp.c @@ -441,7 +441,7 @@ void R_SetupSky( const char *skyboxname ) Q_snprintf( sidename, sizeof( sidename ), "%s%s", loadname, r_skyBoxSuffix[i] ); else Q_snprintf( sidename, sizeof( sidename ), "%s_%s", loadname, r_skyBoxSuffix[i] ); - tr.skyboxTextures[i] = GL_LoadTexture( sidename, NULL, 0, TF_CLAMP|TF_SKY, NULL ); + tr.skyboxTextures[i] = GL_LoadTexture( sidename, NULL, 0, TF_CLAMP|TF_SKY ); if( !tr.skyboxTextures[i] ) break; Con_DPrintf( "%s%s%s", skyboxname, r_skyBoxSuffix[i], i != 5 ? ", " : ". " ); } diff --git a/engine/client/s_load.c b/engine/client/s_load.c index 92f52056..0cef0550 100644 --- a/engine/client/s_load.c +++ b/engine/client/s_load.c @@ -135,15 +135,17 @@ wavdata_t *S_LoadSound( sfx_t *sfx ) return sfx->cache; if( !COM_CheckString( sfx->name )) - { - // debug - Con_Printf( "S_LoadSound: sfx %d has NULL name\n", sfx - s_knownSfx ); return NULL; - } // load it from disk if( Q_stricmp( sfx->name, "*default" )) - sc = FS_LoadSound( sfx->name, NULL, 0 ); + { + // load it from disk + if( sfx->name[0] == '*' ) + sc = FS_LoadSound( sfx->name + 1, NULL, 0 ); + else sc = FS_LoadSound( sfx->name, NULL, 0 ); + } + if( !sc ) sc = S_CreateDefaultSound(); if( sc->rate < SOUND_11k ) // some bad sounds @@ -301,7 +303,7 @@ void S_EndRegistration( void ) // free any sounds not from this registration sequence for( i = 0, sfx = s_knownSfx; i < s_numSfx; i++, sfx++ ) { - if( !sfx->name[0] || sfx->name[0] == '*' ) + if( !sfx->name[0] || !Q_stricmp( sfx->name, "*default" )) continue; // don't release default sound if( sfx->servercount != s_registration_sequence ) diff --git a/engine/client/s_main.c b/engine/client/s_main.c index 78fd04a2..270c275b 100644 --- a/engine/client/s_main.c +++ b/engine/client/s_main.c @@ -1592,19 +1592,79 @@ void S_RawSamples( uint samples, uint rate, word width, word channels, const byt S_PositionedRawSamples =================== */ -static void S_PositionedRawSamples( int entnum, float fvol, float attn, uint samples, uint rate, word width, word channels, const byte *data ) +void S_StreamAviSamples( void *Avi, int entnum, float fvol, float attn, float synctime ) { - rawchan_t *ch; - + int bufferSamples; + int fileSamples; + byte raw[MAX_RAW_SAMPLES]; + float duration = 0.0f; + int r, fileBytes; + rawchan_t *ch = NULL; + + if( !dma.initialized || s_listener.paused || !CL_IsInGame( )) + return; + if( entnum < 0 || entnum >= GI->max_edicts ) return; if( !( ch = S_FindRawChannel( entnum, true ))) return; + if( ch->sound_info.rate == 0 ) + { + if( !AVI_GetAudioInfo( Avi, &ch->sound_info )) + return; // no audiotrack + } + ch->master_vol = bound( 0, fvol * 255, 255 ); ch->dist_mult = (attn / SND_CLIP_DISTANCE); - ch->s_rawend = S_RawSamplesStereo( ch->rawsamples, ch->s_rawend, ch->max_samples, samples, rate, width, channels, data ); + + // see how many samples should be copied into the raw buffer + if( ch->s_rawend < soundtime ) + ch->s_rawend = soundtime; + + // position is changed, synchronization is lost etc + if( fabs( ch->oldtime - synctime ) > s_mixahead->value ) + ch->sound_info.loopStart = AVI_TimeToSoundPosition( Avi, synctime * 1000 ); + ch->oldtime = synctime; // keep actual time + + while( ch->s_rawend < soundtime + ch->max_samples ) + { + wavdata_t *info = &ch->sound_info; + + bufferSamples = ch->max_samples - (ch->s_rawend - soundtime); + + // decide how much data needs to be read from the file + fileSamples = bufferSamples * ((float)info->rate / SOUND_DMA_SPEED ); + if( fileSamples <= 1 ) return; // no more samples need + + // our max buffer size + fileBytes = fileSamples * ( info->width * info->channels ); + + if( fileBytes > sizeof( raw )) + { + fileBytes = sizeof( raw ); + fileSamples = fileBytes / ( info->width * info->channels ); + } + + // read audio stream + r = AVI_GetAudioChunk( Avi, raw, info->loopStart, fileBytes ); + info->loopStart += r; // advance play position + + if( r < fileBytes ) + { + fileBytes = r; + fileSamples = r / ( info->width * info->channels ); + } + + if( r > 0 ) + { + // add to raw buffer + ch->s_rawend = S_RawSamplesStereo( ch->rawsamples, ch->s_rawend, ch->max_samples, + fileSamples, info->rate, info->width, info->channels, raw ); + } + else break; // no more samples for this frame + } } /* @@ -1680,6 +1740,7 @@ static void S_ClearRawChannels( void ) if( !ch ) continue; ch->s_rawend = 0; + ch->oldtime = -1; } } @@ -1883,6 +1944,23 @@ void S_ExtraUpdate( void ) S_UpdateChannels (); } +/* +============ +S_UpdateFrame + +update listener position +============ +*/ +void S_UpdateFrame( ref_viewpass_t *rvp ) +{ + if( !FBitSet( rvp->flags, RF_DRAW_WORLD ) || FBitSet( rvp->flags, RF_ONLY_CLIENTDRAW )) + return; + + VectorCopy( rvp->vieworigin, s_listener.origin ); + AngleVectors( rvp->viewangles, s_listener.forward, s_listener.right, s_listener.up ); + s_listener.entnum = rvp->viewentity; // can be camera entity too +} + /* ============ SND_UpdateSound @@ -1907,17 +1985,13 @@ void SND_UpdateSound( void ) // release raw-channels that no longer used more than 10 secs S_FreeIdleRawChannels(); - s_listener.entnum = cl.viewentity; // can be camera entity too + VectorCopy( cl.simvel, s_listener.velocity ); s_listener.frametime = (cl.time - cl.oldtime); s_listener.waterlevel = cl.local.waterlevel; s_listener.active = CL_IsInGame(); s_listener.inmenu = CL_IsInMenu(); s_listener.paused = cl.paused; - VectorCopy( RI.vieworg, s_listener.origin ); - VectorCopy( cl.simvel, s_listener.velocity ); - AngleVectors( RI.viewangles, s_listener.forward, s_listener.right, s_listener.up ); - if( cl.worldmodel != NULL ) Mod_FatPVS( s_listener.origin, FATPHS_RADIUS, s_listener.pasbytes, world.visbytes, false, !s_phs->value ); @@ -2040,7 +2114,7 @@ void S_Play2_f( void ) if( Cmd_Argc() == 1 ) { - Con_Printf( S_USAGE "play \n" ); + Con_Printf( S_USAGE "play2 \n" ); return; } diff --git a/engine/client/sound.h b/engine/client/sound.h index 6da7ec9d..58d77f10 100644 --- a/engine/client/sound.h +++ b/engine/client/sound.h @@ -81,6 +81,8 @@ extern byte *sndpool; #define S_RAW_SOUND_SOUNDTRACK -1 #define S_RAW_SAMPLES_PRECISION_BITS 14 +#define CIN_FRAMETIME (1.0f / 30.0f) + typedef struct { int left; @@ -156,6 +158,8 @@ typedef struct rawchan_s vec3_t origin; // only use if fixed_origin is set float radius; // radius of this sound effect volatile uint s_rawend; + wavdata_t sound_info; // advance play position + float oldtime; // catch time jumps size_t max_samples; // buffer length portable_samplepair_t rawsamples[1]; // variable sized } rawchan_t; @@ -316,6 +320,7 @@ sfx_t *S_GetSfxByHandle( sound_t handle ); rawchan_t *S_FindRawChannel( int entnum, qboolean create ); void S_RawSamples( uint samples, uint rate, word width, word channels, const byte *data, int entnum ); void S_StopSound( int entnum, int channel, const char *soundname ); +void S_UpdateFrame( struct ref_viewpass_s *rvp ); uint S_GetRawSamplesLength( int entnum ); void S_ClearRawChannel( int entnum ); void S_StopAllSounds( qboolean ambient ); diff --git a/engine/client/vgui/vgui_int.cpp b/engine/client/vgui/vgui_int.cpp index 7971c441..2c85e0fa 100644 --- a/engine/client/vgui/vgui_int.cpp +++ b/engine/client/vgui/vgui_int.cpp @@ -120,7 +120,7 @@ void VGui_Paint( int paintAll ) void VGui_ViewportPaintBackground( int extents[4] ) { -// Msg( "Vgui_ViewportPaintBackground( %i, %i, %i, %i )\n", extents[0], extents[1], extents[2], extents[3] ); + // not used } void *VGui_GetPanel( void ) diff --git a/engine/common/avikit.c b/engine/common/avikit.c index e2c80705..c2cc4c63 100644 --- a/engine/common/avikit.c +++ b/engine/common/avikit.c @@ -58,6 +58,7 @@ dll_info_t msacm_dll = { "msacm32.dll", msacm_funcs, false }; static int (_stdcall *pAVIStreamInfo)( PAVISTREAM pavi, AVISTREAMINFO *psi, LONG lSize ); static int (_stdcall *pAVIStreamRead)( PAVISTREAM pavi, LONG lStart, LONG lSamples, void *lpBuffer, LONG cbBuffer, LONG *plBytes, LONG *plSamples ); static PGETFRAME (_stdcall *pAVIStreamGetFrameOpen)( PAVISTREAM pavi, LPBITMAPINFOHEADER lpbiWanted ); +static long (_stdcall *pAVIStreamTimeToSample)( PAVISTREAM pavi, LONG lTime ); static void* (_stdcall *pAVIStreamGetFrame)( PGETFRAME pg, LONG lPos ); static int (_stdcall *pAVIStreamGetFrameClose)( PGETFRAME pg ); static dword (_stdcall *pAVIStreamRelease)( PAVISTREAM pavi ); @@ -84,6 +85,7 @@ static dllfunc_t avifile_funcs[] = { "AVIStreamReadFormat", (void **) &pAVIStreamReadFormat }, { "AVIStreamRelease", (void **) &pAVIStreamRelease }, { "AVIStreamStart", (void **) &pAVIStreamStart }, +{ "AVIStreamTimeToSample", (void **) &pAVIStreamTimeToSample }, { NULL, NULL } }; @@ -275,6 +277,23 @@ long AVI_GetVideoFrameNumber( movie_state_t *Avi, float time ) return (time * Avi->video_fps); } +long AVI_GetVideoFrameCount( movie_state_t *Avi ) +{ + if( !Avi->active ) + return 0; + + return Avi->video_frames; +} + +long AVI_TimeToSoundPosition( movie_state_t *Avi, long time ) +{ + if( !Avi->active || !Avi->audio_stream ) + return 0; + + // UNDONE: what about compressed audio? + return pAVIStreamTimeToSample( Avi->audio_stream, time ) * Avi->audio_bytes_per_sample; +} + // gets the raw frame data byte *AVI_GetVideoFrame( movie_state_t *Avi, long frame ) { @@ -656,11 +675,6 @@ movie_state_t *AVI_LoadVideo( const char *filename, qboolean load_audio ) return Avi; } -movie_state_t *AVI_LoadVideoNoSound( const char *filename ) -{ - return AVI_LoadVideo( filename, false ); -} - void AVI_FreeVideo( movie_state_t *state ) { if( !state ) return; diff --git a/engine/common/build.c b/engine/common/build.c index dac721ac..04c52685 100644 --- a/engine/common/build.c +++ b/engine/common/build.c @@ -48,6 +48,6 @@ int Q_buildnum( void ) return b; #else - return 4140; + return 4260; #endif } \ No newline at end of file diff --git a/engine/common/cfgscript.c b/engine/common/cfgscript.c index f61e5041..e469cb09 100644 --- a/engine/common/cfgscript.c +++ b/engine/common/cfgscript.c @@ -63,7 +63,7 @@ qboolean CSCR_ExpectString( parserstate_t *ps, const char *pExpect, qboolean ski } if( skip ) ps->buf = tmp; - if( error ) MsgDev( D_ERROR, "Syntax error in %s: got \"%s\" instead of \"%s\"\n", ps->filename, ps->token, pExpect ); + if( error ) Con_DPrintf( S_ERROR "Syntax error in %s: got \"%s\" instead of \"%s\"\n", ps->filename, ps->token, pExpect ); return false; } @@ -85,7 +85,7 @@ cvartype_t CSCR_ParseType( parserstate_t *ps ) return i; } - MsgDev( D_ERROR, "Cannot parse %s: Bad type %s\n", ps->filename, ps->token ); + Con_DPrintf( S_ERROR "Cannot parse %s: Bad type %s\n", ps->filename, ps->token ); return T_NONE; } @@ -181,7 +181,7 @@ qboolean CSCR_ParseHeader( parserstate_t *ps ) if( Q_atof( ps->token ) != 1 ) { - MsgDev( D_ERROR, "File %s has wrong version %s!\n", ps->filename, ps->token ); + Con_DPrintf( S_ERROR "File %s has wrong version %s!\n", ps->filename, ps->token ); return false; } @@ -192,7 +192,7 @@ qboolean CSCR_ParseHeader( parserstate_t *ps ) if( Q_stricmp( ps->token, "INFO_OPTIONS") && Q_stricmp( ps->token, "SERVER_OPTIONS" )) { - MsgDev( D_ERROR, "DESCRIPTION must be INFO_OPTIONS or SERVER_OPTIONS\n"); + Con_DPrintf( S_ERROR "DESCRIPTION must be INFO_OPTIONS or SERVER_OPTIONS\n"); return false; } @@ -223,13 +223,10 @@ int CSCR_WriteGameCVars( file_t *cfg, const char *scriptfilename ) if( !state.buf || !length ) return 0; - MsgDev( D_INFO, "Reading config script file %s\n", scriptfilename ); + Con_DPrintf( "Reading config script file %s\n", scriptfilename ); if( !CSCR_ParseHeader( &state )) - { - MsgDev( D_ERROR, "Failed to parse header!\n" ); goto finish; - } while( !CSCR_ExpectString( &state, "}", false, false )) { @@ -258,7 +255,7 @@ int CSCR_WriteGameCVars( file_t *cfg, const char *scriptfilename ) } if( COM_ParseFile( state.buf, state.token )) - MsgDev( D_ERROR, "Got extra tokens!\n" ); + Con_DPrintf( S_ERROR "Got extra tokens!\n" ); else success = true; finish: if( !success ) @@ -266,8 +263,8 @@ finish: state.token[sizeof( state.token ) - 1] = 0; if( start && state.buf ) - MsgDev( D_ERROR, "Parse error in %s, byte %d, token %s\n", scriptfilename, (int)( state.buf - start ), state.token ); - else MsgDev( D_ERROR, "Parse error in %s, token %s\n", scriptfilename, state.token ); + Con_DPrintf( S_ERROR "Parse error in %s, byte %d, token %s\n", scriptfilename, (int)( state.buf - start ), state.token ); + else Con_DPrintf( S_ERROR "Parse error in %s, token %s\n", scriptfilename, state.token ); } if( start ) Mem_Free( start ); @@ -296,13 +293,10 @@ int CSCR_LoadDefaultCVars( const char *scriptfilename ) if( !state.buf || !length ) return 0; - MsgDev( D_INFO, "Reading config script file %s\n", scriptfilename ); + Con_DPrintf( "Reading config script file %s\n", scriptfilename ); if( !CSCR_ParseHeader( &state )) - { - MsgDev( D_ERROR, "Failed to parse header!\n" ); goto finish; - } while( !CSCR_ExpectString( &state, "}", false, false )) { @@ -322,15 +316,15 @@ int CSCR_LoadDefaultCVars( const char *scriptfilename ) } if( COM_ParseFile( state.buf, state.token )) - MsgDev( D_ERROR, "Got extra tokens!\n" ); + Con_DPrintf( S_ERROR "Got extra tokens!\n" ); else success = true; finish: if( !success ) { state.token[sizeof( state.token ) - 1] = 0; if( start && state.buf ) - MsgDev( D_ERROR, "Parse error in %s, byte %d, token %s\n", scriptfilename, (int)( state.buf - start ), state.token ); - else MsgDev( D_ERROR, "Parse error in %s, token %s\n", scriptfilename, state.token ); + Con_DPrintf( S_ERROR "Parse error in %s, byte %d, token %s\n", scriptfilename, (int)( state.buf - start ), state.token ); + else Con_DPrintf( S_ERROR "Parse error in %s, token %s\n", scriptfilename, state.token ); } if( start ) Mem_Free( start ); diff --git a/engine/common/cmd.c b/engine/common/cmd.c index e508025b..24ef5622 100644 --- a/engine/common/cmd.c +++ b/engine/common/cmd.c @@ -539,11 +539,11 @@ void Cmd_TokenizeString( char *text ) if( !*text ) return; - + if( cmd_argc == 1 ) cmd_args = text; - host.com_ignorebracket = true; + host.com_ignorebracket = true; text = COM_ParseFile( text, cmd_token ); host.com_ignorebracket = false; @@ -973,12 +973,14 @@ void Cmd_ExecuteString( char *text ) if( host.type == HOST_NORMAL ) { if( cls.state >= ca_connected ) + { Cmd_ForwardToServer(); - } - else if( text[0] != '@' && host.type == HOST_NORMAL ) - { - // commands with leading '@' are hidden system commands - Con_Printf( S_WARN "Unknown command \"%s\"\n", text ); + } + else if( text[0] != '@' && Cvar_VariableInteger( "host_gameloaded" )) + { + // commands with leading '@' are hidden system commands + Con_Printf( S_WARN "Unknown command \"%s\"\n", text ); + } } } diff --git a/engine/common/common.h b/engine/common/common.h index 11cc46f4..4dc4f60e 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -57,7 +57,7 @@ XASH SPECIFIC - sort of hack that works only in Xash3D not in GoldSrc #define MAX_SERVERINFO_STRING 512 // server handles too many settings. expand to 1024? #define MAX_LOCALINFO_STRING 32768 // localinfo used on server and not sended to the clients #define MAX_SYSPATH 1024 // system filepath -#define MAX_PRINT_MSG 8192 // how many symbols can handle single call of Msg or MsgDev +#define MAX_PRINT_MSG 8192 // how many symbols can handle single call of Con_Printf or Con_DPrintf #define MAX_TOKEN 2048 // parse token length #define MAX_MODS 512 // environment games that engine can keep visible #define MAX_USERMSG_LENGTH 2048 // don't modify it's relies on a client-side definitions @@ -228,9 +228,11 @@ typedef struct gameinfo_s int gamemode; qboolean secure; // prevent to console acess qboolean nomodels; // don't let player to choose model (use player.mdl always) + qboolean noskills; // disable skill menu selection char sp_entity[32]; // e.g. info_player_start char mp_entity[32]; // e.g. info_player_deathmatch + char mp_filter[32]; // filtering multiplayer-maps char ambientsound[NUM_AMBIENTS][MAX_QPATH]; // quake ambient sounds @@ -576,7 +578,7 @@ typedef enum IMAGE_ROT_90 = BIT(18), // flip from upper left corner to down right corner IMAGE_ROT180 = IMAGE_FLIP_X|IMAGE_FLIP_Y, IMAGE_ROT270 = IMAGE_FLIP_X|IMAGE_FLIP_Y|IMAGE_ROT_90, -// reserved + IMAGE_EMBOSS = BIT(19), // apply emboss mapping IMAGE_RESAMPLE = BIT(20), // resample image to specified dims // reserved // reserved @@ -587,16 +589,6 @@ typedef enum IMAGE_REMAP = BIT(27), // interpret width and height as top and bottom color } imgFlags_t; -// ordering is important! -typedef enum -{ - BLUR_FILTER = 0, - BLUR_FILTER2, - EDGE_FILTER, - EMBOSS_FILTER, - NUM_FILTERS, -} pixfilter_t; - typedef struct rgbdata_s { word width; // image width @@ -612,21 +604,6 @@ typedef struct rgbdata_s size_t size; // for bounds checking } rgbdata_t; -// imgfilter processing flags -typedef enum -{ - FILTER_GRAYSCALE = BIT(0), -} flFlags_t; - -typedef struct imgfilter_s -{ - int filter; // pixfilter_t - float factor; // filter factor value - float bias; // filter bias value - flFlags_t flags; // filter additional flags - uint blendFunc; // blending mode -} imgfilter_t; - // // imagelib // @@ -638,7 +615,7 @@ qboolean FS_SaveImage( const char *filename, rgbdata_t *pix ); rgbdata_t *FS_CopyImage( rgbdata_t *in ); void FS_FreeImage( rgbdata_t *pack ); extern const bpc_desc_t PFDesc[]; // image get pixelformat -qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, imgfilter_t *filter ); +qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, float bumpscale ); void Image_PaletteHueReplace( byte *palSrc, int newHue, int start, int end, int pal_size ); void Image_PaletteTranslate( byte *palSrc, int top, int bottom, int pal_size ); void Image_SetForceFlags( uint flags ); // set image force flags on loading @@ -882,7 +859,8 @@ qboolean AVI_GetAudioInfo( movie_state_t *Avi, wavdata_t *snd_info ); long AVI_GetAudioChunk( movie_state_t *Avi, char *audiodata, long offset, long length ); void AVI_OpenVideo( movie_state_t *Avi, const char *filename, qboolean load_audio, int quiet ); movie_state_t *AVI_LoadVideo( const char *filename, qboolean load_audio ); -movie_state_t *AVI_LoadVideoNoSound( const char *filename ); +long AVI_TimeToSoundPosition( movie_state_t *Avi, long time ); +long AVI_GetVideoFrameCount( movie_state_t *Avi ); void AVI_CloseVideo( movie_state_t *Avi ); qboolean AVI_IsActive( movie_state_t *Avi ); void AVI_FreeVideo( movie_state_t *Avi ); @@ -929,6 +907,7 @@ void SV_DrawDebugTriangles( void ); void SV_DrawOrthoTriangles( void ); double CL_GetDemoFramerate( void ); qboolean UI_CreditsActive( void ); +void CL_StopPlayback( void ); void CL_ExtraUpdate( void ); int CL_GetMaxClients( void ); int SV_GetMaxClients( void ); diff --git a/engine/common/con_utils.c b/engine/common/con_utils.c index be3f4500..04bf2d2b 100644 --- a/engine/common/con_utils.c +++ b/engine/common/con_utils.c @@ -667,7 +667,9 @@ qboolean Cmd_GetCDList( const char *s, char *completedname, int length ) qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir ) { + qboolean use_filter = false; byte buf[MAX_SYSPATH]; + string mpfilter; char *buffer; string result; int i, size; @@ -677,6 +679,8 @@ qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir ) if( FS_FileSize( "maps.lst", onlyingamedir ) > 0 && !fRefresh ) return true; // exist + // setup mpfilter + Q_snprintf( mpfilter, sizeof( mpfilter ), "maps/%s", GI->mp_filter ); t = FS_Search( "maps/*.bsp", false, onlyingamedir ); if( !t ) @@ -690,6 +694,7 @@ qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir ) } buffer = Mem_Calloc( host.mempool, t->numfilenames * 2 * sizeof( result )); + use_filter = Q_strlen( GI->mp_filter ) ? true : false; for( i = 0; i < t->numfilenames; i++ ) { @@ -700,6 +705,9 @@ qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir ) if( Q_stricmp( COM_FileExtension( t->filenames[i] ), "bsp" )) continue; + if( use_filter && !Q_strnicmp( t->filenames[i], mpfilter, Q_strlen( mpfilter ))) + continue; + f = FS_Open( t->filenames[i], "rb", onlyingamedir ); COM_FileBase( t->filenames[i], mapname ); @@ -757,7 +765,7 @@ qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir ) else if( !Q_strcmp( token, "classname" )) { pfile = COM_ParseFile( pfile, token ); - if( !Q_strcmp( token, GI->mp_entity )) + if( !Q_strcmp( token, GI->mp_entity ) || use_filter ) num_spawnpoints++; } if( num_spawnpoints ) break; // valid map @@ -805,6 +813,7 @@ qboolean Cmd_CheckMapsList( qboolean fRefresh ) autocomplete_list_t cmd_list[] = { { "map_background", Cmd_GetMapList }, +{ "changelevel2", Cmd_GetMapList }, { "changelevel", Cmd_GetMapList }, { "playdemo", Cmd_GetDemoList, }, { "timedemo", Cmd_GetDemoList, }, diff --git a/engine/common/console.c b/engine/common/console.c index 17c40965..59e39853 100644 --- a/engine/common/console.c +++ b/engine/common/console.c @@ -559,7 +559,7 @@ static qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font ) return false; // keep source to print directly into conback image - font->hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_KEEP_SOURCE, NULL ); + font->hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_KEEP_SOURCE ); R_GetTextureParms( &fontWidth, NULL, font->hFontTexture ); if( font->hFontTexture && fontWidth != 0 ) @@ -595,7 +595,7 @@ static qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font if( !FS_FileExists( fontname, false )) return false; - font->hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_NEAREST, NULL ); + font->hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_NEAREST ); R_GetTextureParms( &fontWidth, NULL, font->hFontTexture ); // setup consolefont @@ -2340,28 +2340,28 @@ void Con_VidInit( void ) { // trying to load truecolor image first if( FS_FileExists( "gfx/shell/conback.bmp", false ) || FS_FileExists( "gfx/shell/conback.tga", false )) - con.background = GL_LoadTexture( "gfx/shell/conback", NULL, 0, TF_IMAGE, NULL ); + con.background = GL_LoadTexture( "gfx/shell/conback", NULL, 0, TF_IMAGE ); if( !con.background ) { if( FS_FileExists( "cached/conback640", false )) - con.background = GL_LoadTexture( "cached/conback640", NULL, 0, TF_IMAGE, NULL ); + con.background = GL_LoadTexture( "cached/conback640", NULL, 0, TF_IMAGE ); else if( FS_FileExists( "cached/conback", false )) - con.background = GL_LoadTexture( "cached/conback", NULL, 0, TF_IMAGE, NULL ); + con.background = GL_LoadTexture( "cached/conback", NULL, 0, TF_IMAGE ); } } else { // trying to load truecolor image first if( FS_FileExists( "gfx/shell/loading.bmp", false ) || FS_FileExists( "gfx/shell/loading.tga", false )) - con.background = GL_LoadTexture( "gfx/shell/loading", NULL, 0, TF_IMAGE, NULL ); + con.background = GL_LoadTexture( "gfx/shell/loading", NULL, 0, TF_IMAGE ); if( !con.background ) { if( FS_FileExists( "cached/loading640", false )) - con.background = GL_LoadTexture( "cached/loading640", NULL, 0, TF_IMAGE, NULL ); + con.background = GL_LoadTexture( "cached/loading640", NULL, 0, TF_IMAGE ); else if( FS_FileExists( "cached/loading", false )) - con.background = GL_LoadTexture( "cached/loading", NULL, 0, TF_IMAGE, NULL ); + con.background = GL_LoadTexture( "cached/loading", NULL, 0, TF_IMAGE ); } } @@ -2396,13 +2396,13 @@ void Con_VidInit( void ) y = Q_strlen( ver ); for( x = 0; x < y; x++ ) Con_DrawCharToConback( ver[x], chars->original->buffer, dest + (x << 3)); - con.background = GL_LoadTexture( "#gfx/conback.lmp", (byte *)cb, length, TF_IMAGE, NULL ); + con.background = GL_LoadTexture( "#gfx/conback.lmp", (byte *)cb, length, TF_IMAGE ); } if( cb ) Mem_Free( cb ); } if( !con.background ) // trying the load unmodified conback - con.background = GL_LoadTexture( "gfx/conback.lmp", NULL, 0, TF_IMAGE, NULL ); + con.background = GL_LoadTexture( "gfx/conback.lmp", NULL, 0, TF_IMAGE ); } // missed console image will be replaced as gray background like X-Ray or Crysis diff --git a/engine/common/crtlib.c b/engine/common/crtlib.c index 0f01795d..0fe7678a 100644 --- a/engine/common/crtlib.c +++ b/engine/common/crtlib.c @@ -570,7 +570,6 @@ int Q_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list ar __except( EXCEPTION_EXECUTE_HANDLER ) { Q_strncpy( buffer, "^1sprintf throw exception^7\n", buffersize ); -// memset( buffer, 0, buffersize ); result = buffersize; } diff --git a/engine/common/cvar.c b/engine/common/cvar.c index 42e28605..11feb8cb 100644 --- a/engine/common/cvar.c +++ b/engine/common/cvar.c @@ -639,6 +639,18 @@ char *Cvar_VariableString( const char *var_name ) return var->string; } +/* +============ +Cvar_Exists +============ +*/ +qboolean Cvar_Exists( const char *var_name ) +{ + if( Cvar_FindVar( var_name )) + return true; + return false; +} + /* ============ Cvar_SetCheatState diff --git a/engine/common/cvar.h b/engine/common/cvar.h index e190b109..eb51199a 100644 --- a/engine/common/cvar.h +++ b/engine/common/cvar.h @@ -62,6 +62,7 @@ float Cvar_VariableValue( const char *var_name ); int Cvar_VariableInteger( const char *var_name ); char *Cvar_VariableString( const char *var_name ); void Cvar_WriteVariables( file_t *f, int group ); +qboolean Cvar_Exists( const char *var_name ); void Cvar_Reset( const char *var_name ); void Cvar_SetCheatState( void ); qboolean Cvar_Command( void ); diff --git a/engine/common/filesystem.c b/engine/common/filesystem.c index 1f0b2e25..fa293745 100644 --- a/engine/common/filesystem.c +++ b/engine/common/filesystem.c @@ -255,7 +255,7 @@ static void listlowercase( stringlist_t *list ) } } -static void listdirectory( stringlist_t *list, const char *path ) +static void listdirectory( stringlist_t *list, const char *path, int lower ) { char pattern[4096]; struct _finddata_t n_file; @@ -277,7 +277,7 @@ static void listdirectory( stringlist_t *list, const char *path ) _findclose( hFile ); // g-cont. disabled for some reasons -// listlowercase( list ); + if( lower ) listlowercase( list ); } /* @@ -310,8 +310,8 @@ static dpackfile_t *FS_AddFileToPack( const char *name, pack_t *pack, long offse middle = (left + right) / 2; diff = Q_stricmp( pack->files[middle].name, name ); - // If we found the file, there's a problem - if( !diff ) MsgDev( D_WARN, "package %s contains the file %s several times\n", pack->filename, name ); + // If we found the file, there's a problem (but don't confuse the users) + if( !diff ) Con_Reportf( S_WARN "package %s contains the file %s several times\n", pack->filename, name ); // If we're too far in the list if( diff > 0 ) right = middle - 1; @@ -413,7 +413,7 @@ pack_t *FS_LoadPackPAK( const char *packfile, int *error ) if( packhandle < 0 ) { - MsgDev( D_NOTE, "%s couldn't open\n", packfile ); + Con_Reportf( "%s couldn't open\n", packfile ); if( error ) *error = PAK_LOAD_COULDNT_OPEN; return NULL; } @@ -422,7 +422,7 @@ pack_t *FS_LoadPackPAK( const char *packfile, int *error ) if( header.ident != IDPACKV1HEADER ) { - MsgDev( D_NOTE, "%s is not a packfile. Ignored.\n", packfile ); + Con_Reportf( "%s is not a packfile. Ignored.\n", packfile ); if( error ) *error = PAK_LOAD_BAD_HEADER; close( packhandle ); return NULL; @@ -430,7 +430,7 @@ pack_t *FS_LoadPackPAK( const char *packfile, int *error ) if( header.dirlen % sizeof( dpackfile_t )) { - MsgDev( D_ERROR, "%s has an invalid directory size. Ignored.\n", packfile ); + Con_Reportf( "%s has an invalid directory size. Ignored.\n", packfile ); if( error ) *error = PAK_LOAD_BAD_FOLDERS; close( packhandle ); return NULL; @@ -440,7 +440,7 @@ pack_t *FS_LoadPackPAK( const char *packfile, int *error ) if( numpackfiles > MAX_FILES_IN_PACK ) { - MsgDev( D_ERROR, "%s has too many files ( %i ). Ignored.\n", packfile, numpackfiles ); + Con_DPrintf( S_ERROR "%s has too many files ( %i ). Ignored.\n", packfile, numpackfiles ); if( error ) *error = PAK_LOAD_TOO_MANY_FILES; close( packhandle ); return NULL; @@ -448,7 +448,7 @@ pack_t *FS_LoadPackPAK( const char *packfile, int *error ) if( numpackfiles <= 0 ) { - MsgDev( D_NOTE, "%s has no files. Ignored.\n", packfile ); + Con_Reportf( "%s has no files. Ignored.\n", packfile ); if( error ) *error = PAK_LOAD_NO_FILES; close( packhandle ); return NULL; @@ -459,7 +459,7 @@ pack_t *FS_LoadPackPAK( const char *packfile, int *error ) if( header.dirlen != read( packhandle, (void *)info, header.dirlen )) { - MsgDev( D_NOTE, "%s is an incomplete PAK, not loading\n", packfile ); + Con_Reportf( "%s is an incomplete PAK, not loading\n", packfile ); if( error ) *error = PAK_LOAD_CORRUPTED; close( packhandle ); Mem_Free( info ); @@ -504,9 +504,11 @@ static qboolean FS_AddWad_Fullpath( const char *wadfile, qboolean *already_loade } } - if( already_loaded ) *already_loaded = false; - if( !Q_stricmp( ext, "wad" )) wad = W_Open( wadfile, &errorcode ); - else MsgDev( D_ERROR, "\"%s\" doesn't have a wad extension\n", wadfile ); + if( already_loaded ) + *already_loaded = false; + + if( !Q_stricmp( ext, "wad" )) + wad = W_Open( wadfile, &errorcode ); if( wad ) { @@ -516,13 +518,13 @@ static qboolean FS_AddWad_Fullpath( const char *wadfile, qboolean *already_loade search->flags |= flags; fs_searchpaths = search; - MsgDev( D_REPORT, "Adding wadfile: %s (%i files)\n", wadfile, wad->numlumps ); + Con_Reportf( "Adding wadfile: %s (%i files)\n", wadfile, wad->numlumps ); return true; } else { if( errorcode != WAD_LOAD_NO_FILES ) - MsgDev( D_ERROR, "FS_AddWad_Fullpath: unable to load wad \"%s\"\n", wadfile ); + Con_DPrintf( S_ERROR "FS_AddWad_Fullpath: unable to load wad \"%s\"\n", wadfile ); return false; } } @@ -557,10 +559,11 @@ static qboolean FS_AddPak_Fullpath( const char *pakfile, qboolean *already_loade } } - if( already_loaded ) *already_loaded = false; + if( already_loaded ) + *already_loaded = false; - if( !Q_stricmp( ext, "pak" )) pak = FS_LoadPackPAK( pakfile, &errorcode ); - else MsgDev( D_ERROR, "\"%s\" does not have a pack extension\n", pakfile ); + if( !Q_stricmp( ext, "pak" )) + pak = FS_LoadPackPAK( pakfile, &errorcode ); if( pak ) { @@ -572,7 +575,7 @@ static qboolean FS_AddPak_Fullpath( const char *pakfile, qboolean *already_loade search->flags |= flags; fs_searchpaths = search; - MsgDev( D_REPORT, "Adding pakfile: %s (%i files)\n", pakfile, pak->numfiles ); + Con_Reportf( "Adding pakfile: %s (%i files)\n", pakfile, pak->numfiles ); // time to add in search list all the wads that contains in current pakfile (if do) for( i = 0; i < pak->numfiles; i++ ) @@ -589,7 +592,7 @@ static qboolean FS_AddPak_Fullpath( const char *pakfile, qboolean *already_loade else { if( errorcode != PAK_LOAD_NO_FILES ) - MsgDev( D_ERROR, "FS_AddPak_Fullpath: unable to load pak \"%s\"\n", pakfile ); + Con_DPrintf( S_ERROR "FS_AddPak_Fullpath: unable to load pak \"%s\"\n", pakfile ); return false; } } @@ -613,7 +616,7 @@ void FS_AddGameDirectory( const char *dir, int flags ) Q_strncpy( fs_writedir, dir, sizeof( fs_writedir )); stringlistinit( &list ); - listdirectory( &list, dir ); + listdirectory( &list, dir, true ); stringlistsort( &list ); // add any PAK package in the directory @@ -750,7 +753,7 @@ FS_Rescan */ void FS_Rescan( void ) { - MsgDev( D_NOTE, "FS_Rescan( %s )\n", GI->title ); + Con_Reportf( "FS_Rescan( %s )\n", GI->title ); FS_ClearSearchPath(); @@ -785,6 +788,8 @@ assume GameInfo is valid static void FS_WriteGameInfo( const char *filepath, gameinfo_t *GameInfo ) { file_t *f = FS_Open( filepath, "w", false ); // we in binary-mode + int i, write_ambients = false; + if( !f ) Sys_Error( "FS_WriteGameInfo: can't write %s\n", filepath ); // may be disk-space is out? FS_Print( f, "// generated by Xash3D\n\n\n" ); @@ -843,6 +848,8 @@ static void FS_WriteGameInfo( const char *filepath, gameinfo_t *GameInfo ) FS_Printf( f, "sp_entity\t\t\"%s\"\n", GameInfo->sp_entity ); if( Q_strlen( GameInfo->mp_entity )) FS_Printf( f, "mp_entity\t\t\"%s\"\n", GameInfo->mp_entity ); + if( Q_strlen( GameInfo->mp_filter )) + FS_Printf( f, "mp_filter\t\t\"%s\"\n", GameInfo->mp_filter ); if( GameInfo->secure ) FS_Printf( f, "secure\t\t\"%i\"\n", GameInfo->secure ); @@ -859,6 +866,19 @@ static void FS_WriteGameInfo( const char *filepath, gameinfo_t *GameInfo ) if( GameInfo->max_particles > 0 ) FS_Printf( f, "max_particles\t%i\n", GameInfo->max_particles ); + for( i = 0; i < NUM_AMBIENTS; i++ ) + { + if( *GameInfo->ambientsound[i] ) + { + if( !write_ambients ) + { + FS_Print( f, "\n" ); + write_ambients = true; + } + FS_Printf( f, "ambient%i\t\t%s\n", i, GameInfo->ambientsound[i] ); + } + } + FS_Print( f, "\n\n\n" ); FS_Close( f ); // all done } @@ -1013,6 +1033,10 @@ static qboolean FS_ParseLiblistGam( const char *filename, const char *gamedir, g { pfile = COM_ParseFile( pfile, GameInfo->mp_entity ); } + else if( !Q_stricmp( token, "mpfilter" )) + { + pfile = COM_ParseFile( pfile, GameInfo->mp_filter ); + } else if( !Q_stricmp( token, "secure" )) { pfile = COM_ParseFile( pfile, token ); @@ -1119,6 +1143,10 @@ static qboolean FS_ReadGameInfo( const char *filepath, const char *gamedir, game { pfile = COM_ParseFile( pfile, GameInfo->mp_entity ); } + else if( !Q_stricmp( token, "mp_filter" )) + { + pfile = COM_ParseFile( pfile, GameInfo->mp_filter ); + } else if( !Q_stricmp( token, "gamedll" )) { pfile = COM_ParseFile( pfile, GameInfo->game_dll ); @@ -1206,18 +1234,18 @@ static qboolean FS_ReadGameInfo( const char *filepath, const char *gamedir, game pfile = COM_ParseFile( pfile, token ); GameInfo->nomodels = Q_atoi( token ); } + else if( !Q_stricmp( token, "noskills" )) + { + pfile = COM_ParseFile( pfile, token ); + GameInfo->noskills = Q_atoi( token ); + } else if( !Q_strnicmp( token, "ambient", 7 )) { int ambientNum = Q_atoi( token + 7 ); if( ambientNum < 0 || ambientNum > ( NUM_AMBIENTS - 1 )) - { - MsgDev( D_ERROR, "FS_ReadGameInfo: Invalid ambient number %i. Ignored.\n", ambientNum ); - } - else - { - pfile = COM_ParseFile( pfile, GameInfo->ambientsound[ambientNum] ); - } + ambientNum = 0; + pfile = COM_ParseFile( pfile, GameInfo->ambientsound[ambientNum] ); } } @@ -1316,7 +1344,7 @@ void FS_LoadGameInfo( const char *rootfolder ) fs_ext_path = false; if( rootfolder ) Q_strcpy( fs_gamedir, rootfolder ); - MsgDev( D_NOTE, "FS_LoadGameInfo( %s )\n", fs_gamedir ); + Con_Reportf( "FS_LoadGameInfo( %s )\n", fs_gamedir ); // clear any old pathes FS_ClearSearchPath(); @@ -1357,7 +1385,7 @@ void FS_Init( void ) // ignore commandlineoption "-game" for other stuff stringlistinit( &dirs ); - listdirectory( &dirs, "./" ); + listdirectory( &dirs, "./", true ); stringlistsort( &dirs ); SI.numgames = 0; @@ -1487,7 +1515,6 @@ static file_t *FS_SysOpen( const char *filepath, const char *mode ) opt = O_CREAT; break; default: - MsgDev( D_ERROR, "FS_SysOpen(%s, %s): invalid mode\n", filepath, mode ); return NULL; } @@ -1502,7 +1529,6 @@ static file_t *FS_SysOpen( const char *filepath, const char *mode ) opt |= O_BINARY; break; default: - MsgDev( D_ERROR, "FS_SysOpen: %s: unknown char (%c) in mode (%s)\n", filepath, mode[ind], mode ); break; } } @@ -2222,7 +2248,7 @@ qboolean FS_WriteFile( const char *filename, const void *data, long len ) if( !file ) { - MsgDev( D_ERROR, "FS_WriteFile: failed on %s\n", filename); + Con_DPrintf( S_ERROR "FS_WriteFile: failed on %s\n", filename ); return false; } @@ -2512,7 +2538,7 @@ qboolean FS_FileCopy( file_t *pOutput, file_t *pInput, int fileSize ) if(( readSize = FS_Read( pInput, buf, size )) < size ) { - MsgDev( D_ERROR, "FS_FileCopy: unexpected end of input file (%d < %d)\n", readSize, size ); + Con_DPrintf( S_ERROR "FS_FileCopy: unexpected end of input file (%d < %d)\n", readSize, size ); fileSize = 0; done = false; break; @@ -2687,7 +2713,7 @@ search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly ) // get a directory listing and look at each name Q_sprintf( netpath, "%s%s", searchpath->filename, basepath ); stringlistinit( &dirlist ); - listdirectory( &dirlist, netpath ); + listdirectory( &dirlist, netpath, false ); for( dirlistindex = 0; dirlistindex < dirlist.numstrings; dirlistindex++ ) { @@ -2885,7 +2911,7 @@ static dlumpinfo_t *W_AddFileToWad( const char *name, wfile_t *wad, dlumpinfo_t diff = 1; else if( wad->lumps[middle].type > newlump->type ) diff = -1; - else MsgDev( D_WARN, "Wad %s contains the file %s several times\n", wad->filename, name ); + else Con_Reportf( S_WARN "Wad %s contains the file %s several times\n", wad->filename, name ); } // If we're too far in the list @@ -2926,7 +2952,7 @@ byte *W_ReadLump( wfile_t *wad, dlumpinfo_t *lump, long *lumpsizeptr ) if( FS_Seek( wad->handle, lump->filepos, SEEK_SET ) == -1 ) { - MsgDev( D_ERROR, "W_ReadLump: %s is corrupted\n", lump->name ); + Con_DPrintf( S_ERROR "W_ReadLump: %s is corrupted\n", lump->name ); FS_Seek( wad->handle, oldpos, SEEK_SET ); return NULL; } @@ -2936,7 +2962,7 @@ byte *W_ReadLump( wfile_t *wad, dlumpinfo_t *lump, long *lumpsizeptr ) if( size < lump->disksize ) { - MsgDev( D_WARN, "W_ReadLump: %s is probably corrupted\n", lump->name ); + Con_DPrintf( S_WARN "W_ReadLump: %s is probably corrupted\n", lump->name ); FS_Seek( wad->handle, oldpos, SEEK_SET ); Mem_Free( buf ); return NULL; @@ -2976,7 +3002,7 @@ wfile_t *W_Open( const char *filename, int *error ) if( wad->handle == NULL ) { - MsgDev( D_ERROR, "W_Open: couldn't open %s\n", filename ); + Con_DPrintf( S_ERROR "W_Open: couldn't open %s\n", filename ); if( error ) *error = WAD_LOAD_COULDNT_OPEN; W_Close( wad ); return NULL; @@ -2989,7 +3015,7 @@ wfile_t *W_Open( const char *filename, int *error ) if( FS_Read( wad->handle, &header, sizeof( dwadinfo_t )) != sizeof( dwadinfo_t )) { - MsgDev( D_ERROR, "W_Open: %s can't read header\n", filename ); + Con_DPrintf( S_ERROR "W_Open: %s can't read header\n", filename ); if( error ) *error = WAD_LOAD_BAD_HEADER; W_Close( wad ); return NULL; @@ -2997,7 +3023,7 @@ wfile_t *W_Open( const char *filename, int *error ) if( header.ident != IDWAD2HEADER && header.ident != IDWAD3HEADER ) { - MsgDev( D_ERROR, "W_Open: %s is not a WAD2 or WAD3 file\n", filename ); + Con_DPrintf( S_ERROR "W_Open: %s is not a WAD2 or WAD3 file\n", filename ); if( error ) *error = WAD_LOAD_BAD_HEADER; W_Close( wad ); return NULL; @@ -3007,12 +3033,12 @@ wfile_t *W_Open( const char *filename, int *error ) if( lumpcount >= MAX_FILES_IN_WAD ) { - MsgDev( D_WARN, "W_Open: %s is full (%i lumps)\n", filename, lumpcount ); + Con_DPrintf( S_WARN "W_Open: %s is full (%i lumps)\n", filename, lumpcount ); if( error ) *error = WAD_LOAD_TOO_MANY_FILES; } else if( lumpcount <= 0 ) { - MsgDev( D_ERROR, "W_Open: %s has no lumps\n", filename ); + Con_DPrintf( S_ERROR "W_Open: %s has no lumps\n", filename ); if( error ) *error = WAD_LOAD_NO_FILES; W_Close( wad ); return NULL; @@ -3023,7 +3049,7 @@ wfile_t *W_Open( const char *filename, int *error ) if( FS_Seek( wad->handle, wad->infotableofs, SEEK_SET ) == -1 ) { - MsgDev( D_ERROR, "W_Open: %s can't find lump allocation table\n", filename ); + Con_DPrintf( S_ERROR "W_Open: %s can't find lump allocation table\n", filename ); if( error ) *error = WAD_LOAD_BAD_FOLDERS; W_Close( wad ); return NULL; @@ -3036,7 +3062,7 @@ wfile_t *W_Open( const char *filename, int *error ) if( FS_Read( wad->handle, srclumps, lat_size ) != lat_size ) { - MsgDev( D_ERROR, "W_ReadLumpTable: %s has corrupted lump allocation table\n", wad->filename ); + Con_DPrintf( S_ERROR "W_ReadLumpTable: %s has corrupted lump allocation table\n", wad->filename ); if( error ) *error = WAD_LOAD_CORRUPTED; Mem_Free( srclumps ); W_Close( wad ); diff --git a/engine/common/host.c b/engine/common/host.c index cb25e0d9..6f959d1f 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -418,7 +418,7 @@ double Host_CalcFPS( void ) if( host.type != HOST_DEDICATED && Host_IsLocalGame( ) && !CL_IsTimeDemo( )) { // ajdust fps for vertical synchronization - if( gl_vsync != NULL && gl_vsync->value ) + if( CVAR_TO_BOOL( gl_vsync )) { if( vid_displayfrequency->value != 0.0f ) fps = vid_displayfrequency->value; @@ -647,7 +647,8 @@ void Host_InitCommon( const char *hostname, qboolean bChangeGame ) } else { - if( *in == ' ' ) + // now we found cmdline + if( *in == ' ' && ( in[1] == '+' || in[1] == '-' )) { parse_cmdline = true; *out++ = '\0'; @@ -663,8 +664,12 @@ void Host_InitCommon( const char *hostname, qboolean bChangeGame ) host.mempool = Mem_AllocPool( "Zone Engine" ); + // get name of executable + if( GetModuleFileName( NULL, szTemp, sizeof( szTemp ))) + COM_FileBase( szTemp, SI.exeName ); + // HACKHACK: Quake console is always allowed - if( Sys_CheckParm( "-console" ) || !Q_stricmp( progname, "id1" )) + if( Sys_CheckParm( "-console" ) || !Q_stricmp( SI.exeName, "quake" )) host.allow_console = true; if( Sys_CheckParm( "-dev" )) @@ -682,10 +687,6 @@ void Host_InitCommon( const char *hostname, qboolean bChangeGame ) host.type = HOST_NORMAL; // predict state host.con_showalways = true; - // we can specified custom name, from Sys_NewInstance - if( GetModuleFileName( NULL, szTemp, sizeof( szTemp )) && !host.change_game ) - COM_FileBase( szTemp, SI.exeName ); - COM_ExtractFilePath( szTemp, szRootPath ); if( Q_stricmp( host.rootdir, szRootPath )) { diff --git a/engine/common/hpak.c b/engine/common/hpak.c index e5a77697..bfb131c5 100644 --- a/engine/common/hpak.c +++ b/engine/common/hpak.c @@ -95,20 +95,17 @@ void HPAK_CreatePak( const char *filename, resource_t *pResource, byte *pData, f return; if(( fin != NULL && pData != NULL ) || ( fin == NULL && pData == NULL )) - { - MsgDev( D_ERROR, "HPAK_CreatePak, must specify one of pData or fpSource\n" ); return; - } Q_strncpy( pakname, filename, sizeof( pakname )); COM_ReplaceExtension( pakname, ".hpk" ); - MsgDev( D_INFO, "creating HPAK %s.\n", pakname ); + Con_Printf( "creating HPAK %s.\n", pakname ); fout = FS_Open( pakname, "wb", false ); if( !fout ) { - MsgDev( D_ERROR, "HPAK_CreatePak: can't write %s.\n", pakname ); + Con_DPrintf( S_ERROR "HPAK_CreatePak: can't write %s.\n", pakname ); return; } @@ -135,7 +132,7 @@ void HPAK_CreatePak( const char *filename, resource_t *pResource, byte *pData, f if( memcmp( md5, pResource->rgucMD5_hash, 16 )) { - MsgDev( D_ERROR, "HPAK_CreatePak: bad checksum for %s. Ignored\n", pakname ); + Con_DPrintf( S_ERROR "HPAK_CreatePak: bad checksum for %s. Ignored\n", pakname ); return; } @@ -204,10 +201,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource, MD5Context_t ctx; if( pData == NULL && pFile == NULL ) - { - MsgDev( D_ERROR, "HPAK_AddLump: no data\n" ); return; - } if( pResource->nDownloadSize < HPAK_MIN_SIZE || pResource->nDownloadSize > HPAK_MAX_SIZE ) { @@ -238,7 +232,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource, if( memcmp( md5, pResource->rgucMD5_hash, 16 )) { - MsgDev( D_ERROR, "HPAK_AddLump: bad checksum for %s. Ignored\n", pResource->szFileName ); + Con_DPrintf( S_ERROR "HPAK_AddLump: bad checksum for %s. Ignored\n", pResource->szFileName ); return; } @@ -267,7 +261,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource, if( !file_dst ) { - MsgDev( D_ERROR, "HPAK_AddLump: couldn't open %s.\n", srcname ); + Con_DPrintf( S_ERROR "HPAK_AddLump: couldn't open %s.\n", srcname ); FS_Close( file_src ); return; } @@ -278,7 +272,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource, if( hash_pack_header.version != IDHPAK_VERSION ) { // we don't check the HPAK bit for some reason. - MsgDev( D_ERROR, "HPAK_AddLump: %s does not have a valid header.\n", srcname ); + Con_DPrintf( S_ERROR "HPAK_AddLump: %s does not have a valid header.\n", srcname ); FS_Close( file_src ); FS_Close( file_dst ); } @@ -292,7 +286,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource, if( srcpak.count < 1 || srcpak.count > HPAK_MAX_ENTRIES ) { - MsgDev( D_ERROR, "HPAK_AddLump: %s contain too many lumps.\n", srcname ); + Con_DPrintf( S_ERROR "HPAK_AddLump: %s contain too many lumps.\n", srcname ); FS_Close( file_src ); FS_Close( file_dst ); return; @@ -386,16 +380,16 @@ static qboolean HPAK_Validate( const char *filename, qboolean quiet ) f = FS_Open( pakname, "rb", false ); if( !f ) { - MsgDev( D_INFO, "Couldn't find %s.\n", pakname ); + Con_DPrintf( S_ERROR "Couldn't find %s.\n", pakname ); return true; } - if( !quiet ) MsgDev( D_INFO, "Validating %s\n", pakname ); + if( !quiet ) Con_Printf( "Validating %s\n", pakname ); FS_Read( f, &hdr, sizeof( hdr )); if( hdr.ident != IDHPAKHEADER || hdr.version != IDHPAK_VERSION ) { - MsgDev( D_ERROR, "HPAK_ValidatePak: %s does not have a valid HPAK header.\n", pakname ); + Con_DPrintf( S_ERROR "HPAK_ValidatePak: %s does not have a valid HPAK header.\n", pakname ); FS_Close( f ); return false; } @@ -405,24 +399,24 @@ static qboolean HPAK_Validate( const char *filename, qboolean quiet ) if( num_lumps < 1 || num_lumps > MAX_FILES_IN_WAD ) { - MsgDev( D_ERROR, "HPAK_ValidatePak: %s has too many lumps %u.\n", pakname, num_lumps ); + Con_DPrintf( S_ERROR "HPAK_ValidatePak: %s has too many lumps %u.\n", pakname, num_lumps ); FS_Close( f ); return false; } - if( !quiet ) MsgDev( D_INFO, "# of Entries: %i\n", num_lumps ); + if( !quiet ) Con_Printf( "# of Entries: %i\n", num_lumps ); dataDir = Z_Malloc( sizeof( hpak_lump_t ) * num_lumps ); FS_Read( f, dataDir, sizeof( hpak_lump_t ) * num_lumps ); - if( !quiet ) MsgDev( D_INFO, "# Type Size FileName : MD5 Hash\n" ); + if( !quiet ) Con_Printf( "# Type Size FileName : MD5 Hash\n" ); for( i = 0; i < num_lumps; i++ ) { if( dataDir[i].disksize < 1 || dataDir[i].disksize > 131071 ) { // odd max size - MsgDev( D_ERROR, "HPAK_ValidatePak: lump %i has invalid size %s\n", i, Q_pretifymem( dataDir[i].disksize, 2 )); + Con_DPrintf( S_ERROR "HPAK_ValidatePak: lump %i has invalid size %s\n", i, Q_pretifymem( dataDir[i].disksize, 2 )); Mem_Free( dataDir ); FS_Close(f); return false; @@ -439,24 +433,24 @@ static qboolean HPAK_Validate( const char *filename, qboolean quiet ) pRes = &dataDir[i].resource; - MsgDev( D_INFO, "%i: %s %s %s: ", i, HPAK_TypeFromIndex( pRes->type ), + Con_Printf( "%i: %s %s %s: ", i, HPAK_TypeFromIndex( pRes->type ), Q_pretifymem( pRes->nDownloadSize, 2 ), pRes->szFileName ); if( memcmp( md5, pRes->rgucMD5_hash, 0x10 )) { if( quiet ) { - MsgDev( D_ERROR, "HPAK_ValidatePak: %s has invalid checksum.\n", pakname ); + Con_DPrintf( S_ERROR "HPAK_ValidatePak: %s has invalid checksum.\n", pakname ); Mem_Free( dataPak ); Mem_Free( dataDir ); FS_Close( f ); return false; } - else MsgDev( D_INFO, "failed\n" ); + else Con_DPrintf( S_ERROR "failed\n" ); } else { - if( !quiet ) MsgDev( D_INFO, "OK\n" ); + if( !quiet ) Con_Printf( "OK\n" ); } // at this point, it's passed our checks. @@ -584,21 +578,21 @@ static qboolean HPAK_ResourceForIndex( const char *filename, int index, resource f = FS_Open( pakname, "rb", false ); if( !f ) { - MsgDev( D_ERROR, "couldn't open %s.\n", pakname ); + Con_DPrintf( S_ERROR "couldn't open %s.\n", pakname ); return false; } FS_Read( f, &header, sizeof( header )); if( header.ident != IDHPAKHEADER ) { - MsgDev( D_ERROR, "%s is not an HPAK file\n", pakname ); + Con_DPrintf( S_ERROR "%s is not an HPAK file\n", pakname ); FS_Close( f ); return false; } if( header.version != IDHPAK_VERSION ) { - MsgDev( D_ERROR, "%s has invalid version (%i should be %i).\n", pakname, header.version, IDHPAK_VERSION ); + Con_DPrintf( S_ERROR "%s has invalid version (%i should be %i).\n", pakname, header.version, IDHPAK_VERSION ); FS_Close( f ); return false; } @@ -608,14 +602,14 @@ static qboolean HPAK_ResourceForIndex( const char *filename, int index, resource if( directory.count < 1 || directory.count > HPAK_MAX_ENTRIES ) { - MsgDev( D_ERROR, "%s has too many lumps %u.\n", pakname, directory.count ); + Con_DPrintf( S_ERROR "%s has too many lumps %u.\n", pakname, directory.count ); FS_Close( f ); return false; } if( index < 1 || index > directory.count ) { - MsgDev( D_ERROR, "%s, lump with index %i doesn't exist.\n", pakname, index ); + Con_DPrintf( S_ERROR "%s, lump with index %i doesn't exist.\n", pakname, index ); FS_Close( f ); return false; } @@ -674,14 +668,14 @@ qboolean HPAK_GetDataPointer( const char *filename, resource_t *pResource, byte if( header.ident != IDHPAKHEADER ) { - MsgDev( D_ERROR, "%s it's not a HPK file.\n", pakname ); + Con_DPrintf( S_ERROR "%s it's not a HPK file.\n", pakname ); FS_Close( f ); return false; } if( header.version != IDHPAK_VERSION ) { - MsgDev( D_ERROR, "%s has invalid version (%i should be %i).\n", pakname, header.version, IDHPAK_VERSION ); + Con_DPrintf( S_ERROR "%s has invalid version (%i should be %i).\n", pakname, header.version, IDHPAK_VERSION ); FS_Close( f ); return false; } @@ -691,7 +685,7 @@ qboolean HPAK_GetDataPointer( const char *filename, resource_t *pResource, byte if( directory.count < 1 || directory.count > HPAK_MAX_ENTRIES ) { - MsgDev( D_ERROR, "HPAK_GetDataPointer: %s has too many lumps %u.\n", filename, directory.count ); + Con_DPrintf( S_ERROR "HPAK_GetDataPointer: %s has too many lumps %u.\n", filename, directory.count ); FS_Close( f ); return false; } @@ -751,7 +745,7 @@ void HPAK_RemoveLump( const char *name, resource_t *pResource ) file_src = FS_Open( read_path, "rb", false ); if( !file_src ) { - MsgDev( D_ERROR, "%s couldn't open.\n", read_path ); + Con_DPrintf( S_ERROR "%s couldn't open.\n", read_path ); return; } @@ -761,7 +755,7 @@ void HPAK_RemoveLump( const char *name, resource_t *pResource ) if( !file_dst ) { - MsgDev( D_ERROR, "%s couldn't open.\n", save_path ); + Con_DPrintf( S_ERROR "%s couldn't open.\n", save_path ); FS_Close( file_src ); return; } @@ -775,7 +769,7 @@ void HPAK_RemoveLump( const char *name, resource_t *pResource ) if( hash_pack_header.ident != IDHPAKHEADER || hash_pack_header.version != IDHPAK_VERSION ) { - MsgDev( D_ERROR, "%s has invalid header.\n", read_path ); + Con_DPrintf( S_ERROR "%s has invalid header.\n", read_path ); FS_Close( file_src ); FS_Close( file_dst ); FS_Delete( save_path ); // delete temp file @@ -787,7 +781,7 @@ void HPAK_RemoveLump( const char *name, resource_t *pResource ) if( hpak_read.count < 1 || hpak_read.count > HPAK_MAX_ENTRIES ) { - MsgDev( D_ERROR, "%s has invalid number of lumps.\n", read_path ); + Con_DPrintf( S_ERROR "%s has invalid number of lumps.\n", read_path ); FS_Close( file_src ); FS_Close( file_dst ); FS_Delete( save_path ); // delete temp file @@ -796,7 +790,7 @@ void HPAK_RemoveLump( const char *name, resource_t *pResource ) if( hpak_read.count == 1 ) { - MsgDev( D_WARN, "%s only has one element, so HPAK will be removed\n", read_path ); + Con_DPrintf( S_WARN "%s only has one element, so HPAK will be removed\n", read_path ); FS_Close( file_src ); FS_Close( file_dst ); FS_Delete( read_path ); @@ -812,7 +806,7 @@ void HPAK_RemoveLump( const char *name, resource_t *pResource ) if( !HPAK_FindResource( &hpak_read, pResource->rgucMD5_hash, NULL )) { - MsgDev( D_ERROR, "HPAK doesn't contain specified lump: %s\n", pResource->szFileName, read_path ); + Con_DPrintf( S_ERROR "HPAK doesn't contain specified lump: %s\n", pResource->szFileName, read_path ); Mem_Free( hpak_read.entries ); Mem_Free( hpak_save.entries ); FS_Close( file_src ); @@ -821,7 +815,7 @@ void HPAK_RemoveLump( const char *name, resource_t *pResource ) return; } - MsgDev( D_INFO, "Removing %s from HPAK %s.\n", pResource->szFileName, read_path ); + Con_Printf( "Removing %s from HPAK %s.\n", pResource->szFileName, read_path ); // If there's a collision, we've just corrupted this hpak. for( i = 0, j = 0; i < hpak_read.count; i++ ) @@ -881,7 +875,7 @@ void HPAK_List_f( void ) f = FS_Open( pakname, "rb", false ); if( !f ) { - MsgDev( D_ERROR, "couldn't open %s.\n", pakname ); + Con_DPrintf( S_ERROR "couldn't open %s.\n", pakname ); return; } @@ -889,14 +883,14 @@ void HPAK_List_f( void ) if( header.ident != IDHPAKHEADER ) { - MsgDev( D_ERROR, "%s is not an HPAK file\n", pakname ); + Con_DPrintf( S_ERROR "%s is not an HPAK file\n", pakname ); FS_Close( f ); return; } if( header.version != IDHPAK_VERSION ) { - MsgDev( D_ERROR, "%s has invalid version (%i should be %i).\n", pakname, header.version, IDHPAK_VERSION ); + Con_DPrintf( S_ERROR "%s has invalid version (%i should be %i).\n", pakname, header.version, IDHPAK_VERSION ); FS_Close( f ); return; } @@ -906,7 +900,7 @@ void HPAK_List_f( void ) if( directory.count < 1 || directory.count > HPAK_MAX_ENTRIES ) { - MsgDev( D_ERROR, "%s has too many lumps %u.\n", pakname, directory.count ); + Con_DPrintf( S_ERROR "%s has too many lumps %u.\n", pakname, directory.count ); FS_Close( f ); return; } @@ -972,7 +966,7 @@ void HPAK_Extract_f( void ) f = FS_Open( pakname, "rb", false ); if( !f ) { - MsgDev( D_ERROR, "couldn't open %s.\n", pakname ); + Con_DPrintf( S_ERROR "couldn't open %s.\n", pakname ); return; } @@ -980,14 +974,14 @@ void HPAK_Extract_f( void ) if( header.ident != IDHPAKHEADER ) { - MsgDev( D_ERROR, "%s is not an HPAK file\n", pakname ); + Con_DPrintf( S_ERROR "%s is not an HPAK file\n", pakname ); FS_Close( f ); return; } if( header.version != IDHPAK_VERSION ) { - MsgDev( D_ERROR, "%s has invalid version (%i should be %i).\n", pakname, header.version, IDHPAK_VERSION ); + Con_DPrintf( S_ERROR "%s has invalid version (%i should be %i).\n", pakname, header.version, IDHPAK_VERSION ); FS_Close( f ); return; } @@ -997,7 +991,7 @@ void HPAK_Extract_f( void ) if( directory.count < 1 || directory.count > HPAK_MAX_ENTRIES ) { - MsgDev( D_ERROR, "%s has too many lumps %u.\n", pakname, directory.count ); + Con_DPrintf( S_ERROR "%s has too many lumps %u.\n", pakname, directory.count ); FS_Close( f ); return; } @@ -1023,7 +1017,7 @@ void HPAK_Extract_f( void ) if( entry->disksize <= 0 || entry->disksize >= HPAK_MAX_SIZE ) { - MsgDev( D_WARN, "Unable to extract data, size invalid: %s\n", Q_memprint( entry->disksize )); + Con_DPrintf( S_WARN "Unable to extract data, size invalid: %s\n", Q_memprint( entry->disksize )); continue; } @@ -1061,7 +1055,7 @@ void HPAK_Remove_f( void ) } else { - MsgDev( D_ERROR, "Could not locate resource %i in %s\n", Q_atoi( Cmd_Argv( 2 )), Cmd_Argv( 1 )); + Con_DPrintf( S_ERROR "Could not locate resource %i in %s\n", Q_atoi( Cmd_Argv( 2 )), Cmd_Argv( 1 )); } } diff --git a/engine/common/imagelib/img_bmp.c b/engine/common/imagelib/img_bmp.c index c4640367..8a2479bf 100644 --- a/engine/common/imagelib/img_bmp.c +++ b/engine/common/imagelib/img_bmp.c @@ -57,13 +57,13 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, size_t filesize ) if( memcmp( bhdr.id, "BM", 2 )) { - MsgDev( D_ERROR, "Image_LoadBMP: only Windows-style BMP files supported (%s)\n", name ); + Con_DPrintf( S_ERROR "Image_LoadBMP: only Windows-style BMP files supported (%s)\n", name ); return false; } if( bhdr.bitmapHeaderSize != 0x28 ) { - MsgDev( D_ERROR, "Image_LoadBMP: invalid header size %i\n", bhdr.bitmapHeaderSize ); + Con_DPrintf( S_ERROR "Image_LoadBMP: invalid header size %i\n", bhdr.bitmapHeaderSize ); return false; } @@ -71,13 +71,13 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, size_t filesize ) if( bhdr.fileSize != filesize ) { // Sweet Half-Life issues. splash.bmp have bogus filesize - MsgDev( D_REPORT, "Image_LoadBMP: %s have incorrect file size %i should be %i\n", name, filesize, bhdr.fileSize ); + Con_Reportf( S_WARN "Image_LoadBMP: %s have incorrect file size %i should be %i\n", name, filesize, bhdr.fileSize ); } // bogus compression? Only non-compressed supported. if( bhdr.compression != BI_RGB ) { - MsgDev( D_ERROR, "Image_LoadBMP: only uncompressed BMP files supported (%s)\n", name ); + Con_DPrintf( S_ERROR "Image_LoadBMP: only uncompressed BMP files supported (%s)\n", name ); return false; } @@ -284,7 +284,6 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, size_t filesize ) if( alpha != 255 ) image.flags |= IMAGE_HAS_ALPHA; break; default: - MsgDev( D_ERROR, "Image_LoadBMP: illegal pixel_size (%s)\n", name ); Mem_Free( image.palette ); Mem_Free( image.rgba ); return false; @@ -343,7 +342,6 @@ qboolean Image_SaveBMP( const char *name, rgbdata_t *pix ) pixel_size = 4; break; default: - MsgDev( D_ERROR, "Image_SaveBMP: unsupported image type %s\n", PFDesc[pix->type].name ); return false; } diff --git a/engine/common/imagelib/img_dds.c b/engine/common/imagelib/img_dds.c index 1e24176d..9db234ec 100644 --- a/engine/common/imagelib/img_dds.c +++ b/engine/common/imagelib/img_dds.c @@ -217,7 +217,7 @@ uint Image_DXTCalcSize( const char *name, dds_t *hdr, size_t filesize ) if( filesize != buffsize ) // main check { - MsgDev( D_WARN, "Image_LoadDDS: (%s) probably corrupted(%i should be %i)\n", name, buffsize, filesize ); + Con_DPrintf( S_WARN "Image_LoadDDS: (%s) probably corrupted (%i should be %i)\n", name, buffsize, filesize ); if( buffsize > filesize ) return false; } @@ -245,10 +245,7 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, size_t filesize ) byte *fin; if( filesize < sizeof( dds_t )) - { - MsgDev( D_ERROR, "Image_LoadDDS: file (%s) have invalid size\n", name ); return false; - } memcpy( &header, buffer, sizeof( dds_t )); @@ -257,13 +254,13 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, size_t filesize ) if( header.dwSize != sizeof( dds_t ) - sizeof( uint )) // size of the structure (minus MagicNum) { - MsgDev( D_ERROR, "Image_LoadDDS: (%s) have corrupted header\n", name ); + Con_DPrintf( S_ERROR "Image_LoadDDS: (%s) have corrupted header\n", name ); return false; } if( header.dsPixelFormat.dwSize != sizeof( dds_pixf_t )) // size of the structure { - MsgDev( D_ERROR, "Image_LoadDDS: (%s) have corrupt pixelformat header\n", name ); + Con_DPrintf( S_ERROR "Image_LoadDDS: (%s) have corrupt pixelformat header\n", name ); return false; } @@ -284,7 +281,7 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, size_t filesize ) if( image.type == PF_UNKNOWN ) { - MsgDev( D_WARN, "Image_LoadDDS: (%s) has unrecognized type\n", name ); + Con_DPrintf( S_ERROR "Image_LoadDDS: (%s) has unrecognized type\n", name ); return false; } diff --git a/engine/common/imagelib/img_tga.c b/engine/common/imagelib/img_tga.c index e336ef32..0d883b2c 100644 --- a/engine/common/imagelib/img_tga.c +++ b/engine/common/imagelib/img_tga.c @@ -60,17 +60,17 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, size_t filesize ) // uncompressed colormapped image if( targa_header.pixel_size != 8 ) { - MsgDev( D_WARN, "Image_LoadTGA: (%s) Only 8 bit images supported for type 1 and 9\n", name ); + Con_DPrintf( S_ERROR "Image_LoadTGA: (%s) Only 8 bit images supported for type 1 and 9\n", name ); return false; } if( targa_header.colormap_length != 256 ) { - MsgDev( D_WARN, "Image_LoadTGA: (%s) Only 8 bit colormaps are supported for type 1 and 9\n", name ); + Con_DPrintf( S_ERROR "Image_LoadTGA: (%s) Only 8 bit colormaps are supported for type 1 and 9\n", name ); return false; } if( targa_header.colormap_index ) { - MsgDev( D_WARN, "Image_LoadTGA: (%s) colormap_index is not supported for type 1 and 9\n", name ); + Con_DPrintf( S_ERROR "Image_LoadTGA: (%s) colormap_index is not supported for type 1 and 9\n", name ); return false; } if( targa_header.colormap_size == 24 ) @@ -95,7 +95,7 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, size_t filesize ) } else { - MsgDev( D_WARN, "Image_LoadTGA: (%s) only 24 and 32 bit colormaps are supported for type 1 and 9\n", name ); + Con_DPrintf( S_ERROR "Image_LoadTGA: (%s) only 24 and 32 bit colormaps are supported for type 1 and 9\n", name ); return false; } } @@ -104,7 +104,7 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, size_t filesize ) // uncompressed or RLE compressed RGB if( targa_header.pixel_size != 32 && targa_header.pixel_size != 24 ) { - MsgDev( D_WARN, "Image_LoadTGA: (%s) Only 32 or 24 bit images supported for type 2 and 10\n", name ); + Con_DPrintf( S_ERROR "Image_LoadTGA: (%s) Only 32 or 24 bit images supported for type 2 and 10\n", name ); return false; } } @@ -113,7 +113,7 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, size_t filesize ) // uncompressed greyscale if( targa_header.pixel_size != 8 ) { - MsgDev( D_WARN, "Image_LoadTGA: (%s) Only 8 bit images supported for type 3 and 11\n", name ); + Con_DPrintf( S_ERROR "Image_LoadTGA: (%s) Only 8 bit images supported for type 3 and 11\n", name ); return false; } } @@ -257,7 +257,6 @@ qboolean Image_SaveTGA( const char *name, rgbdata_t *pix ) case PF_RGBA_32: case PF_BGRA_32: pixel_size = 4; break; default: - MsgDev( D_ERROR, "Image_SaveTGA: unsupported image type %s\n", PFDesc[pix->type].name ); Mem_Free( buffer ); return false; } diff --git a/engine/common/imagelib/img_utils.c b/engine/common/imagelib/img_utils.c index e8e48141..775b041f 100644 --- a/engine/common/imagelib/img_utils.c +++ b/engine/common/imagelib/img_utils.c @@ -81,36 +81,13 @@ static byte palette_hl[768] = 147,255,247,199,255,255,255,159,91,83 }; -static float FILTER[NUM_FILTERS][FILTER_SIZE][FILTER_SIZE] = -{ -{ // regular blur -{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }, -{ 0.0f, 1.0f, 1.0f, 1.0f, 0.0f }, -{ 0.0f, 1.0f, 1.0f, 1.0f, 0.0f }, -{ 0.0f, 1.0f, 1.0f, 1.0f, 0.0f }, -{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }, -}, -{ // light blur -{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }, -{ 0.0f, 1.0f, 1.0f, 1.0f, 0.0f }, -{ 0.0f, 1.0f, 4.0f, 1.0f, 0.0f }, -{ 0.0f, 1.0f, 1.0f, 1.0f, 0.0f }, -{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }, -}, -{ // find edges -{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }, -{ 0.0f, -1.0f, -1.0f, -1.0f, 0.0f }, -{ 0.0f, -1.0f, 8.0f, -1.0f, 0.0f }, -{ 0.0f, -1.0f, -1.0f, -1.0f, 0.0f }, -{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }, -}, -{ // emboss +static float img_emboss[FILTER_SIZE][FILTER_SIZE] = +{ {-0.7f, -0.7f, -0.7f, -0.7f, 0.0f }, {-0.7f, -0.7f, -0.7f, 0.0f, 0.7f }, {-0.7f, -0.7f, 0.0f, 0.7f, 0.7f }, {-0.7f, 0.0f, 0.7f, 0.7f, 0.7f }, { 0.0f, 0.7f, 0.7f, 0.7f, 0.7f }, -} }; /* @@ -1361,7 +1338,7 @@ Filtering algorithm from http://www.student.kuleuven.ac.be/~m0216922/CG/filterin All credit due ================== */ -qboolean Image_ApplyFilter( rgbdata_t *pic, int filter, float factor, float bias, flFlags_t flags, GLenum blendFunc ) +static void Image_ApplyFilter( rgbdata_t *pic, float factor ) { int i, x, y; uint *fin, *fout; @@ -1369,7 +1346,7 @@ qboolean Image_ApplyFilter( rgbdata_t *pic, int filter, float factor, float bias // first expand the image into 32-bit buffer pic = Image_DecompressInternal( pic ); - + factor = bound( 0.0f, factor, 1.0f ); size = image.width * image.height * 4; image.tempbuffer = Mem_Realloc( host.imagepool, image.tempbuffer, size ); fout = (uint *)image.tempbuffer; @@ -1381,6 +1358,7 @@ qboolean Image_ApplyFilter( rgbdata_t *pic, int filter, float factor, float bias { vec3_t vout = { 0.0f, 0.0f, 0.0f }; int pos_x, pos_y; + float avg; for( pos_x = 0; pos_x < FILTER_SIZE; pos_x++ ) { @@ -1391,9 +1369,9 @@ qboolean Image_ApplyFilter( rgbdata_t *pic, int filter, float factor, float bias // casting's a unary operation anyway, so the othermost set of brackets in the left part // of the rvalue should not be necessary... but i'm paranoid when it comes to C... - vout[0] += ((float)((byte *)&fin[img_y * image.width + img_x])[0]) * FILTER[filter][pos_x][pos_y]; - vout[1] += ((float)((byte *)&fin[img_y * image.width + img_x])[1]) * FILTER[filter][pos_x][pos_y]; - vout[2] += ((float)((byte *)&fin[img_y * image.width + img_x])[2]) * FILTER[filter][pos_x][pos_y]; + vout[0] += ((float)((byte *)&fin[img_y * image.width + img_x])[0]) * img_emboss[pos_x][pos_y]; + vout[1] += ((float)((byte *)&fin[img_y * image.width + img_x])[1]) * img_emboss[pos_x][pos_y]; + vout[2] += ((float)((byte *)&fin[img_y * image.width + img_x])[2]) * img_emboss[pos_x][pos_y]; } } @@ -1401,20 +1379,17 @@ qboolean Image_ApplyFilter( rgbdata_t *pic, int filter, float factor, float bias for( i = 0; i < 3; i++ ) { vout[i] *= factor; - vout[i] += bias; + vout[i] += 128.0f; // base vout[i] = bound( 0.0f, vout[i], 255.0f ); } - if( flags & FILTER_GRAYSCALE ) - { - // NTSC greyscale conversion standard - float avg = (vout[0] * 30.0f + vout[1] * 59.0f + vout[2] * 11.0f) / 100.0f; + // NTSC greyscale conversion standard + avg = (vout[0] * 30.0f + vout[1] * 59.0f + vout[2] * 11.0f) / 100.0f; - // divide by 255 so GL operations work as expected - vout[0] = avg / 255.0f; - vout[1] = avg / 255.0f; - vout[2] = avg / 255.0f; - } + // divide by 255 so GL operations work as expected + vout[0] = avg / 255.0f; + vout[1] = avg / 255.0f; + vout[2] = avg / 255.0f; // write to temp - first, write data in (to get the alpha channel quickly and // easily, which will be left well alone by this particular operation...!) @@ -1429,29 +1404,9 @@ qboolean Image_ApplyFilter( rgbdata_t *pic, int filter, float factor, float bias float src = ((float)((byte *)&fin[y * image.width + x])[i]) / 255.0f; float tmp; - switch( blendFunc ) - { - case GL_ADD: - tmp = vout[i] + src; - break; - case GL_BLEND: - // default is FUNC_ADD here - // CsS + CdD works out as Src * Dst * 2 - tmp = vout[i] * src * 2.0f; - break; - case GL_DECAL: - // same as GL_REPLACE unless there's alpha, which we ignore for this - case GL_REPLACE: - tmp = vout[i]; - break; - case GL_ADD_SIGNED: - tmp = (vout[i] + src) - 0.5f; - break; - case GL_MODULATE: - default: // same as default - tmp = vout[i] * src; - break; - } + // default is GL_BLEND here + // CsS + CdD works out as Src * Dst * 2 + tmp = vout[i] * src * 2.0f; // multiply back by 255 to get the proper byte scale tmp *= 255.0f; @@ -1466,11 +1421,9 @@ qboolean Image_ApplyFilter( rgbdata_t *pic, int filter, float factor, float bias // copy result back memcpy( fin, fout, size ); - - return true; } -qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, imgfilter_t *filter ) +qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, float bumpscale ) { rgbdata_t *pic = *pix; qboolean result = true; @@ -1483,7 +1436,7 @@ qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, imgf return false; } - if( !flags && !filter ) + if( !flags ) { // clear any force flags image.force_flags = 0; @@ -1497,7 +1450,7 @@ qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, imgf ClearBits( pic->flags, IMAGE_HAS_LUMA ); } - if( flags & IMAGE_REMAP ) + if( FBitSet( flags, IMAGE_REMAP )) { // NOTE: user should keep copy of indexed image manually for new changes if( Image_RemapInternal( pic, width, height )) @@ -1505,10 +1458,14 @@ qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, imgf } // update format to RGBA if any - if( flags & IMAGE_FORCE_RGBA ) pic = Image_DecompressInternal( pic ); - if( flags & IMAGE_LIGHTGAMMA ) pic = Image_LightGamma( pic ); + if( FBitSet( flags, IMAGE_FORCE_RGBA )) + pic = Image_DecompressInternal( pic ); + + if( FBitSet( flags, IMAGE_LIGHTGAMMA )) + pic = Image_LightGamma( pic ); - if( filter ) Image_ApplyFilter( pic, filter->filter, filter->factor, filter->bias, filter->flags, filter->blendFunc ); + if( FBitSet( flags, IMAGE_EMBOSS )) + Image_ApplyFilter( pic, bumpscale ); out = Image_FlipInternal( pic->buffer, &pic->width, &pic->height, pic->type, flags ); if( pic->buffer != out ) memcpy( pic->buffer, image.tempbuffer, pic->size ); diff --git a/engine/common/imagelib/img_wad.c b/engine/common/imagelib/img_wad.c index 83fae094..954e3c8c 100644 --- a/engine/common/imagelib/img_wad.c +++ b/engine/common/imagelib/img_wad.c @@ -31,7 +31,7 @@ qboolean Image_LoadPAL( const char *name, const byte *buffer, size_t filesize ) if( filesize != 768 ) { - MsgDev( D_ERROR, "Image_LoadPAL: (%s) have invalid size (%d should be %d)\n", name, filesize, 768 ); + Con_DPrintf( S_ERROR "Image_LoadPAL: (%s) have invalid size (%d should be %d)\n", name, filesize, 768 ); return false; } @@ -82,7 +82,7 @@ qboolean Image_LoadFNT( const char *name, const byte *buffer, size_t filesize ) int numcolors; if( image.hint == IL_HINT_Q1 ) - return false; // Quake1 doesn't have qfonts + return false; // Quake1 doesn't have qfonts if( filesize < sizeof( font )) return false; @@ -120,8 +120,6 @@ qboolean Image_LoadFNT( const char *name, const byte *buffer, size_t filesize ) } else { - if( image.hint == IL_HINT_NO ) - MsgDev( D_ERROR, "Image_LoadFNT: (%s) have invalid palette size %d\n", name, numcolors ); return false; } @@ -151,7 +149,8 @@ qboolean Image_LoadMDL( const char *name, const byte *buffer, size_t filesize ) pixels = image.width * image.height; fin = (byte *)pin->index; // setup buffer - if( !Image_ValidSize( name )) return false; + if( !Image_ValidSize( name )) + return false; if( image.hint == IL_HINT_HL ) { @@ -169,8 +168,6 @@ qboolean Image_LoadMDL( const char *name, const byte *buffer, size_t filesize ) } else { - if( image.hint == IL_HINT_NO ) - MsgDev( D_ERROR, "Image_LoadMDL: lump (%s) is corrupted\n", name ); return false; // unknown or unsupported mode rejected } @@ -193,10 +190,7 @@ qboolean Image_LoadSPR( const char *name, const byte *buffer, size_t filesize ) if( image.hint == IL_HINT_HL ) { if( !image.d_currentpal ) - { - MsgDev( D_ERROR, "Image_LoadSPR: (%s) palette not installed\n", name ); return false; - } } else if( image.hint == IL_HINT_Q1 ) { @@ -213,10 +207,7 @@ qboolean Image_LoadSPR( const char *name, const byte *buffer, size_t filesize ) image.height = pin->height; if( filesize < image.width * image.height ) - { - MsgDev( D_ERROR, "Image_LoadSPR: file (%s) have invalid size\n", name ); return false; - } if( filesize == ( image.width * image.height * 4 )) truecolor = true; @@ -263,10 +254,7 @@ qboolean Image_LoadLMP( const char *name, const byte *buffer, size_t filesize ) int i, pixels; if( filesize < sizeof( lmp )) - { - MsgDev( D_ERROR, "Image_LoadLMP: file (%s) have invalid size\n", name ); return false; - } // valve software trick (particle palette) if( Q_stristr( name, "palette.lmp" )) @@ -296,10 +284,7 @@ qboolean Image_LoadLMP( const char *name, const byte *buffer, size_t filesize ) pixels = image.width * image.height; if( filesize < sizeof( lmp ) + pixels ) - { - MsgDev( D_ERROR, "Image_LoadLMP: file (%s) have invalid size %d\n", name, filesize ); return false; - } if( !Image_ValidSize( name )) return false; @@ -352,10 +337,7 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, size_t filesize ) int reflectivity[3] = { 0, 0, 0 }; if( filesize < sizeof( mip )) - { - MsgDev( D_ERROR, "Image_LoadMIP: file (%s) have invalid size\n", name ); return false; - } memcpy( &mip, buffer, sizeof( mip )); image.width = mip.width; @@ -466,8 +448,6 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, size_t filesize ) } else { - if( image.hint == IL_HINT_NO ) - MsgDev( D_ERROR, "Image_LoadMIP: lump (%s) is corrupted\n", name ); return false; // unknown or unsupported mode rejected } diff --git a/engine/common/input.c b/engine/common/input.c index 7bddbf4c..786e8308 100644 --- a/engine/common/input.c +++ b/engine/common/input.c @@ -43,7 +43,7 @@ static byte scan_to_key[128] = K_SHIFT,'\\','z','x','c','v','b','n','m',',','.','/',K_SHIFT, '*',K_ALT,' ',K_CAPSLOCK, K_F1,K_F2,K_F3,K_F4,K_F5,K_F6,K_F7,K_F8,K_F9,K_F10, - K_PAUSE,0,K_HOME,K_UPARROW,K_PGUP,K_KP_MINUS,K_LEFTARROW,K_KP_5, + K_PAUSE,K_SCROLLOCK,K_HOME,K_UPARROW,K_PGUP,K_KP_MINUS,K_LEFTARROW,K_KP_5, K_RIGHTARROW,K_KP_PLUS,K_END,K_DOWNARROW,K_PGDN,K_INS,K_DEL, 0,0,0,K_F11,K_F12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 diff --git a/engine/common/keys.c b/engine/common/keys.c index 8ddcc66e..b2a6a481 100644 --- a/engine/common/keys.c +++ b/engine/common/keys.c @@ -49,6 +49,7 @@ keyname_t keynames[] = {"CTRL", K_CTRL, "+attack" }, {"SHIFT", K_SHIFT, "+speed" }, {"CAPSLOCK", K_CAPSLOCK, "" }, +{"SCROLLOCK", K_SCROLLOCK, "" }, {"F1", K_F1, "cmd help" }, {"F2", K_F2, "menu_savegame" }, {"F3", K_F3, "menu_loadgame" }, @@ -202,7 +203,7 @@ const char *Key_KeynumToString( int keynum ) if ( keynum < 0 || keynum > 255 ) return ""; // check for printable ascii (don't use quote) - if( keynum > 32 && keynum < 127 && keynum != '"' && keynum != ';' ) + if( keynum > 32 && keynum < 127 && keynum != '"' && keynum != ';' && keynum != K_SCROLLOCK ) { tinystr[0] = keynum; tinystr[1] = 0; @@ -419,8 +420,10 @@ void Key_WriteBindings( file_t *f ) for( i = 0; i < 256; i++ ) { - if( keys[i].binding && keys[i].binding[0] ) - FS_Printf( f, "bind %s \"%s\"\n", Key_KeynumToString( i ), keys[i].binding ); + if( !COM_CheckString( keys[i].binding )) + continue; + + FS_Printf( f, "bind %s \"%s\"\n", Key_KeynumToString( i ), keys[i].binding ); } } @@ -436,8 +439,10 @@ void Key_Bindlist_f( void ) for( i = 0; i < 256; i++ ) { - if( keys[i].binding && keys[i].binding[0] ) - Con_Printf( "%s \"%s\"\n", Key_KeynumToString( i ), keys[i].binding ); + if( !COM_CheckString( keys[i].binding )) + continue; + + Con_Printf( "%s \"%s\"\n", Key_KeynumToString( i ), keys[i].binding ); } } diff --git a/engine/common/mod_bmodel.c b/engine/common/mod_bmodel.c index c357f0bf..8a1ab247 100644 --- a/engine/common/mod_bmodel.c +++ b/engine/common/mod_bmodel.c @@ -1771,7 +1771,6 @@ static void Mod_LoadTextures( dbspmodel_t *bmod ) int num, max, altmax; qboolean custom_palette; char texname[64]; - imgfilter_t *filter; mip_t *mt; int i, j; @@ -1819,7 +1818,6 @@ static void Mod_LoadTextures( dbspmodel_t *bmod ) // convert to lowercase Q_strncpy( tx->name, mt->name, sizeof( tx->name )); Q_strnlwr( tx->name, tx->name, sizeof( tx->name )); - filter = R_FindTexFilter( tx->name ); // grab texture filter custom_palette = false; tx->width = mt->width; @@ -1872,7 +1870,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod ) if( FS_FileExists( texpath, false )) { - tx->gl_texturenum = GL_LoadTexture( texpath, NULL, 0, 0, filter ); + tx->gl_texturenum = GL_LoadTexture( texpath, NULL, 0, TF_ALLOW_EMBOSS ); bmod->wadlist.wadusage[j]++; // this wad are really used break; } @@ -1888,7 +1886,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod ) if( custom_palette ) size += sizeof( short ) + 768; Q_snprintf( texname, sizeof( texname ), "#%s:%s.mip", loadstat.name, mt->name ); - tx->gl_texturenum = GL_LoadTexture( texname, (byte *)mt, size, 0, filter ); + tx->gl_texturenum = GL_LoadTexture( texname, (byte *)mt, size, TF_ALLOW_EMBOSS ); } // if texture is completely missed @@ -1911,7 +1909,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod ) int size = (int)sizeof( mip_t ) + ((mt->width * mt->height * 85)>>6); if( custom_palette ) size += sizeof( short ) + 768; - tx->fb_texturenum = GL_LoadTexture( texname, (byte *)mt, size, TF_MAKELUMA, NULL ); + tx->fb_texturenum = GL_LoadTexture( texname, (byte *)mt, size, TF_MAKELUMA ); } else { @@ -1936,7 +1934,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod ) } // okay, loading it from wad or hi-res version - tx->fb_texturenum = GL_LoadTexture( texname, src, srcSize, TF_MAKELUMA, NULL ); + tx->fb_texturenum = GL_LoadTexture( texname, src, srcSize, TF_MAKELUMA ); if( src ) Mem_Free( src ); } } diff --git a/engine/common/model.c b/engine/common/model.c index 4f20f69f..7f6ccaaa 100644 --- a/engine/common/model.c +++ b/engine/common/model.c @@ -201,6 +201,7 @@ void Mod_Shutdown( void ) ================== Mod_FindName +never return NULL ================== */ model_t *Mod_FindName( const char *filename, qboolean trackCRC ) @@ -208,9 +209,6 @@ model_t *Mod_FindName( const char *filename, qboolean trackCRC ) char modname[MAX_QPATH]; model_t *mod; int i; - - if( !COM_CheckString( filename )) - return NULL; Q_strncpy( modname, filename, sizeof( modname )); @@ -388,7 +386,12 @@ Loads in a model for the given name */ model_t *Mod_ForName( const char *name, qboolean crash, qboolean trackCRC ) { - model_t *mod = Mod_FindName( name, trackCRC ); + model_t *mod; + + if( !COM_CheckString( name )) + return NULL; + + mod = Mod_FindName( name, trackCRC ); return Mod_LoadModel( mod, crash ); } diff --git a/engine/common/net_ws.c b/engine/common/net_ws.c index 6a05da3f..91d5dcba 100644 --- a/engine/common/net_ws.c +++ b/engine/common/net_ws.c @@ -451,7 +451,7 @@ qboolean NET_CompareAdr( const netadr_t a, const netadr_t b ) return false; } - MsgDev( D_ERROR, "NET_CompareAdr: bad address type\n" ); + Con_DPrintf( S_ERROR "NET_CompareAdr: bad address type\n" ); return false; } @@ -893,7 +893,7 @@ qboolean NET_QueuePacket( netsrc_t sock, netadr_t *from, byte *data, size_t *len } else { - MsgDev( D_REPORT, "NET_QueuePacket: oversize packet from %s\n", NET_AdrToString( *from )); + Con_Reportf( "NET_QueuePacket: oversize packet from %s\n", NET_AdrToString( *from )); } } else @@ -908,7 +908,7 @@ qboolean NET_QueuePacket( netsrc_t sock, netadr_t *from, byte *data, size_t *len case WSAEMSGSIZE: break; default: // let's continue even after errors - MsgDev( D_ERROR, "NET_QueuePacket: %s from %s\n", NET_ErrorString(), NET_AdrToString( *from )); + Con_DPrintf( S_ERROR "NET_QueuePacket: %s from %s\n", NET_ErrorString(), NET_AdrToString( *from )); break; } } @@ -1059,11 +1059,11 @@ void NET_SendPacket( netsrc_t sock, size_t length, const void *data, netadr_t to // let dedicated servers continue after errors if( host.type == HOST_DEDICATED ) { - MsgDev( D_ERROR, "NET_SendPacket: %s to %s\n", NET_ErrorString(), NET_AdrToString( to )); + Con_DPrintf( S_ERROR "NET_SendPacket: %s to %s\n", NET_ErrorString(), NET_AdrToString( to )); } else if( err == WSAEADDRNOTAVAIL || err == WSAENOBUFS ) { - MsgDev( D_ERROR, "NET_SendPacket: %s to %s\n", NET_ErrorString(), NET_AdrToString( to )); + Con_DPrintf( S_ERROR "NET_SendPacket: %s to %s\n", NET_ErrorString(), NET_AdrToString( to )); } else { @@ -1149,13 +1149,13 @@ static int NET_IPSocket( const char *net_interface, int port, qboolean multicast { err = pWSAGetLastError(); if( err != WSAEAFNOSUPPORT ) - MsgDev( D_WARN, "NET_UDPSocket: port: %d socket: %s\n", port, NET_ErrorString( )); + Con_DPrintf( S_WARN "NET_UDPSocket: port: %d socket: %s\n", port, NET_ErrorString( )); return INVALID_SOCKET; } if( pIoctlSocket( net_socket, FIONBIO, &optval ) == SOCKET_ERROR ) { - MsgDev( D_WARN, "NET_UDPSocket: port: %d ioctl FIONBIO: %s\n", port, NET_ErrorString( )); + Con_DPrintf( S_WARN "NET_UDPSocket: port: %d ioctl FIONBIO: %s\n", port, NET_ErrorString( )); pCloseSocket( net_socket ); return INVALID_SOCKET; } @@ -1163,7 +1163,7 @@ static int NET_IPSocket( const char *net_interface, int port, qboolean multicast // make it broadcast capable if( pSetSockopt( net_socket, SOL_SOCKET, SO_BROADCAST, (const char *)&optval, sizeof( optval )) == SOCKET_ERROR ) { - MsgDev( D_WARN, "NET_UDPSocket: port: %d setsockopt SO_BROADCAST: %s\n", port, NET_ErrorString( )); + Con_DPrintf( S_WARN "NET_UDPSocket: port: %d setsockopt SO_BROADCAST: %s\n", port, NET_ErrorString( )); pCloseSocket( net_socket ); return INVALID_SOCKET; } @@ -1172,7 +1172,7 @@ static int NET_IPSocket( const char *net_interface, int port, qboolean multicast { if( pSetSockopt( net_socket, SOL_SOCKET, SO_REUSEADDR, (const char *)&optval, sizeof( optval )) == SOCKET_ERROR ) { - MsgDev( D_WARN, "NET_UDPSocket: port: %d setsockopt SO_REUSEADDR: %s\n", port, NET_ErrorString( )); + Con_DPrintf( S_WARN "NET_UDPSocket: port: %d setsockopt SO_REUSEADDR: %s\n", port, NET_ErrorString( )); pCloseSocket( net_socket ); return INVALID_SOCKET; } @@ -1204,7 +1204,7 @@ static int NET_IPSocket( const char *net_interface, int port, qboolean multicast if( pBind( net_socket, (void *)&addr, sizeof( addr )) == SOCKET_ERROR ) { - MsgDev( D_WARN, "NET_UDPSocket: port: %d bind: %s\n", port, NET_ErrorString( )); + Con_DPrintf( S_WARN "NET_UDPSocket: port: %d bind: %s\n", port, NET_ErrorString( )); pCloseSocket( net_socket ); return INVALID_SOCKET; } @@ -1213,7 +1213,7 @@ static int NET_IPSocket( const char *net_interface, int port, qboolean multicast { optval = 1; if( pSetSockopt( net_socket, IPPROTO_IP, IP_MULTICAST_LOOP, (const char *)&optval, sizeof( optval )) == SOCKET_ERROR ) - MsgDev( D_WARN, "NET_UDPSocket: port %d setsockopt IP_MULTICAST_LOOP: %s\n", port, NET_ErrorString( )); + Con_DPrintf( S_WARN "NET_UDPSocket: port %d setsockopt IP_MULTICAST_LOOP: %s\n", port, NET_ErrorString( )); } return net_socket; @@ -1294,7 +1294,7 @@ void NET_GetLocalAddress( void ) if( pGetSockName( net.ip_sockets[NS_SERVER], (struct sockaddr *)&address, &namelen ) == SOCKET_ERROR ) { // this may happens if multiple clients running on single machine - MsgDev( D_ERROR, "Could not get TCP/IP address. Reason: %s\n", NET_ErrorString( )); + Con_DPrintf( S_ERROR "Could not get TCP/IP address. Reason: %s\n", NET_ErrorString( )); // net.allow_ip = false; } else @@ -1306,7 +1306,7 @@ void NET_GetLocalAddress( void ) } else { - MsgDev( D_ERROR, "Could not get TCP/IP address, Invalid hostname: '%s'\n", buff ); + Con_DPrintf( S_ERROR "Could not get TCP/IP address, Invalid hostname: '%s'\n", buff ); } } else @@ -1463,13 +1463,13 @@ void NET_Init( void ) if( !NET_OpenWinSock( )) // loading wsock32.dll { - MsgDev( D_ERROR, "network failed to load wsock32.dll.\n" ); + Con_DPrintf( S_ERROR "network failed to load wsock32.dll.\n" ); return; } if( pWSAStartup( MAKEWORD( 1, 1 ), &net.winsockdata )) { - MsgDev( D_ERROR, "network initialization failed.\n" ); + Con_DPrintf( S_ERROR "network initialization failed.\n" ); NET_FreeWinSock(); return; } @@ -1488,7 +1488,7 @@ void NET_Init( void ) net.sequence_number = 1; net.initialized = true; - MsgDev( D_REPORT, "Base networking initialized.\n" ); + Con_Reportf( "Base networking initialized.\n" ); } diff --git a/engine/common/soundlib/snd_main.c b/engine/common/soundlib/snd_main.c index 703905b4..ca3bac13 100644 --- a/engine/common/soundlib/snd_main.c +++ b/engine/common/soundlib/snd_main.c @@ -118,7 +118,7 @@ load_internal: } if( filename[0] != '#' ) - Con_Reportf( S_WARN "FS_LoadSound: couldn't load \"%s\"\n", loadname ); + Con_DPrintf( S_WARN "FS_LoadSound: couldn't load \"%s\"\n", loadname ); return NULL; } diff --git a/engine/common/soundlib/snd_mp3.c b/engine/common/soundlib/snd_mp3.c index bc2acbdc..b98454df 100644 --- a/engine/common/soundlib/snd_mp3.c +++ b/engine/common/soundlib/snd_mp3.c @@ -71,16 +71,16 @@ qboolean Sound_LoadMPG( const char *name, const byte *buffer, size_t filesize ) return false; #ifdef _DEBUG - if( ret ) MsgDev( D_ERROR, "%s\n", get_error( mpeg )); + if( ret ) Con_DPrintf( S_ERROR "%s\n", get_error( mpeg )); #endif // trying to read header if( !feed_mpeg_header( mpeg, buffer, FRAME_SIZE, filesize, &sc )) { #ifdef _DEBUG - MsgDev( D_ERROR, "Sound_LoadMPG: failed to load (%s): %s\n", name, get_error( mpeg )); + Con_DPrintf( S_ERROR "Sound_LoadMPG: failed to load (%s): %s\n", name, get_error( mpeg )); #else - MsgDev( D_ERROR, "Sound_LoadMPG: (%s) is probably corrupted\n", name ); + Con_DPrintf( S_ERROR "Sound_LoadMPG: (%s) is probably corrupted\n", name ); #endif close_decoder( mpeg ); return false; @@ -97,7 +97,7 @@ qboolean Sound_LoadMPG( const char *name, const byte *buffer, size_t filesize ) if( !sound.size ) { // bad mpeg file ? - MsgDev( D_ERROR, "Sound_LoadMPG: (%s) is probably corrupted\n", name ); + Con_DPrintf( S_ERROR "Sound_LoadMPG: (%s) is probably corrupted\n", name ); close_decoder( mpeg ); return false; } @@ -164,22 +164,22 @@ stream_t *Stream_OpenMPG( const char *filename ) // couldn't create decoder if(( mpeg = create_decoder( &ret )) == NULL ) { - MsgDev( D_ERROR, "Stream_OpenMPG: couldn't create decoder\n" ); + Con_DPrintf( S_ERROR "Stream_OpenMPG: couldn't create decoder\n" ); Mem_Free( stream ); FS_Close( file ); return NULL; } #ifdef _DEBUG - if( ret ) MsgDev( D_ERROR, "%s\n", get_error( mpeg )); + if( ret ) Con_DPrintf( S_ERROR "%s\n", get_error( mpeg )); #endif // trying to open stream and read header if( !open_mpeg_stream( mpeg, file, FS_Read, FS_Seek, &sc )) { #ifdef _DEBUG - MsgDev( D_ERROR, "Stream_OpenMPG: failed to load (%s): %s\n", filename, get_error( mpeg )); + Con_DPrintf( S_ERROR "Stream_OpenMPG: failed to load (%s): %s\n", filename, get_error( mpeg )); #else - MsgDev( D_ERROR, "Stream_OpenMPG: (%s) is probably corrupted\n", filename ); + Con_DPrintf( S_ERROR "Stream_OpenMPG: (%s) is probably corrupted\n", filename ); #endif close_decoder( mpeg ); Mem_Free( stream ); diff --git a/engine/common/soundlib/snd_wav.c b/engine/common/soundlib/snd_wav.c index 7757813b..80ca54b1 100644 --- a/engine/common/soundlib/snd_wav.c +++ b/engine/common/soundlib/snd_wav.c @@ -155,7 +155,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, size_t filesize ) if( !( iff_dataPtr && !Q_strncmp( iff_dataPtr + 8, "WAVE", 4 ))) { - MsgDev( D_ERROR, "Sound_LoadWAV: %s missing 'RIFF/WAVE' chunks\n", name ); + Con_DPrintf( S_ERROR "Sound_LoadWAV: %s missing 'RIFF/WAVE' chunks\n", name ); return false; } @@ -165,7 +165,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, size_t filesize ) if( !iff_dataPtr ) { - MsgDev( D_ERROR, "Sound_LoadWAV: %s missing 'fmt ' chunk\n", name ); + Con_DPrintf( S_ERROR "Sound_LoadWAV: %s missing 'fmt ' chunk\n", name ); return false; } @@ -176,7 +176,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, size_t filesize ) { if( fmt != 85 ) { - MsgDev( D_ERROR, "Sound_LoadWAV: %s not a microsoft PCM format\n", name ); + Con_DPrintf( S_ERROR "Sound_LoadWAV: %s not a microsoft PCM format\n", name ); return false; } else @@ -189,7 +189,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, size_t filesize ) sound.channels = GetLittleShort(); if( sound.channels != 1 && sound.channels != 2 ) { - MsgDev( D_ERROR, "Sound_LoadWAV: only mono and stereo WAV files supported (%s)\n", name ); + Con_DPrintf( S_ERROR "Sound_LoadWAV: only mono and stereo WAV files supported (%s)\n", name ); return false; } @@ -201,7 +201,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, size_t filesize ) if( sound.width != 1 && sound.width != 2 ) { - MsgDev( D_WARN, "Sound_LoadWAV: only 8 and 16 bit WAV files supported (%s)\n", name ); + Con_DPrintf( S_ERROR "Sound_LoadWAV: only 8 and 16 bit WAV files supported (%s)\n", name ); return false; } @@ -235,7 +235,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, size_t filesize ) if( !iff_dataPtr ) { - MsgDev( D_WARN, "Sound_LoadWAV: %s missing 'data' chunk\n", name ); + Con_DPrintf( S_ERROR "Sound_LoadWAV: %s missing 'data' chunk\n", name ); return false; } @@ -246,7 +246,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, size_t filesize ) { if( samples < sound.samples ) { - MsgDev( D_ERROR, "Sound_LoadWAV: %s has a bad loop length\n", name ); + Con_DPrintf( S_ERROR "Sound_LoadWAV: %s has a bad loop length\n", name ); return false; } } @@ -254,7 +254,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, size_t filesize ) if( sound.samples <= 0 ) { - MsgDev( D_ERROR, "Sound_LoadWAV: file with %i samples (%s)\n", sound.samples, name ); + Con_DPrintf( S_ERROR "Sound_LoadWAV: file with %i samples (%s)\n", sound.samples, name ); return false; } @@ -326,7 +326,7 @@ stream_t *Stream_OpenWAV( const char *filename ) // find "RIFF" chunk if( !StreamFindNextChunk( file, "RIFF", &last_chunk )) { - MsgDev( D_ERROR, "Stream_OpenWAV: %s missing RIFF chunk\n", filename ); + Con_DPrintf( S_ERROR "Stream_OpenWAV: %s missing RIFF chunk\n", filename ); FS_Close( file ); return NULL; } @@ -334,7 +334,7 @@ stream_t *Stream_OpenWAV( const char *filename ) FS_Read( file, chunkName, 4 ); if( !Q_strncmp( chunkName, "WAVE", 4 )) { - MsgDev( D_ERROR, "Stream_OpenWAV: %s missing WAVE chunk\n", filename ); + Con_DPrintf( S_ERROR "Stream_OpenWAV: %s missing WAVE chunk\n", filename ); FS_Close( file ); return NULL; } @@ -344,7 +344,7 @@ stream_t *Stream_OpenWAV( const char *filename ) last_chunk = iff_data; if( !StreamFindNextChunk( file, "fmt ", &last_chunk )) { - MsgDev( D_ERROR, "Stream_OpenWAV: %s missing 'fmt ' chunk\n", filename ); + Con_DPrintf( S_ERROR "Stream_OpenWAV: %s missing 'fmt ' chunk\n", filename ); FS_Close( file ); return NULL; } @@ -354,7 +354,7 @@ stream_t *Stream_OpenWAV( const char *filename ) FS_Read( file, &t, sizeof( t )); if( t != 1 ) { - MsgDev( D_ERROR, "Stream_OpenWAV: %s not a microsoft PCM format\n", filename ); + Con_DPrintf( S_ERROR "Stream_OpenWAV: %s not a microsoft PCM format\n", filename ); FS_Close( file ); return NULL; } @@ -375,7 +375,7 @@ stream_t *Stream_OpenWAV( const char *filename ) last_chunk = iff_data; if( !StreamFindNextChunk( file, "data", &last_chunk )) { - MsgDev( D_ERROR, "Stream_OpenWAV: %s missing 'data' chunk\n", filename ); + Con_DPrintf( S_ERROR "Stream_OpenWAV: %s missing 'data' chunk\n", filename ); FS_Close( file ); return NULL; } diff --git a/engine/common/sys_win.c b/engine/common/sys_win.c index c476ae6e..c2e76e89 100644 --- a/engine/common/sys_win.c +++ b/engine/common/sys_win.c @@ -623,39 +623,4 @@ void Sys_Print( const char *pMsg ) Sys_PrintLog( logbuf ); Con_WinPrint( buffer ); -} - -/* -================ -MsgDev - -formatted developer message -================ -*/ -void MsgDev( int type, const char *pMsg, ... ) -{ - static char text[MAX_PRINT_MSG]; - va_list argptr; - - if( type >= D_REPORT && host_developer.value < DEV_EXTENDED ) - return; - - va_start( argptr, pMsg ); - Q_vsnprintf( text, sizeof( text ) - 1, pMsg, argptr ); - va_end( argptr ); - - switch( type ) - { - case D_WARN: - Sys_Print( va( "^3Warning:^7 %s", text )); - break; - case D_ERROR: - Sys_Print( va( "^1Error:^7 %s", text )); - break; - case D_INFO: - case D_NOTE: - case D_REPORT: - Sys_Print( text ); - break; - } } \ No newline at end of file diff --git a/engine/common/system.h b/engine/common/system.h index 88b08446..d3384213 100644 --- a/engine/common/system.h +++ b/engine/common/system.h @@ -104,7 +104,6 @@ char *Con_Input( void ); // text messages #define Msg Con_Printf -void MsgDev( int level, const char *pMsg, ... ); #ifdef __cplusplus } diff --git a/engine/keydefs.h b/engine/keydefs.h index ea22139f..c789189c 100644 --- a/engine/keydefs.h +++ b/engine/keydefs.h @@ -23,6 +23,7 @@ #define K_ENTER 13 #define K_ESCAPE 27 #define K_SPACE 32 +#define K_SCROLLOCK 70 // normal keys should be passed as lowercased ascii diff --git a/engine/server/server.h b/engine/server/server.h index ac19976b..d4d7d2c6 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -584,6 +584,7 @@ void SV_PlaybackEventFull( int flags, const edict_t *pInvoker, word eventindex, void SV_PlaybackReliableEvent( sizebuf_t *msg, word eventindex, float delay, event_args_t *args ); int SV_BuildSoundMsg( sizebuf_t *msg, edict_t *ent, int chan, const char *sample, int vol, float attn, int flags, int pitch, const vec3_t pos ); qboolean SV_BoxInPVS( const vec3_t org, const vec3_t absmin, const vec3_t absmax ); +void SV_QueueChangeLevel( const char *level, const char *landname ); void SV_WriteEntityPatch( const char *filename ); float SV_AngleMod( float ideal, float current, float speed ); void SV_SpawnEntities( const char *mapname ); diff --git a/engine/server/sv_client.c b/engine/server/sv_client.c index 38861d85..6001ad96 100644 --- a/engine/server/sv_client.c +++ b/engine/server/sv_client.c @@ -1232,13 +1232,13 @@ void SV_PutClientInServer( sv_client_t *cl ) SetBits( ent->v.flags, FL_GODMODE|FL_NOTARGET ); cl->pViewEntity = NULL; // reset pViewEntity + } - if( svgame.globals->cdAudioTrack ) - { - MSG_BeginServerCmd( &msg, svc_stufftext ); - MSG_WriteString( &msg, va( "cd loop %3d\n", svgame.globals->cdAudioTrack )); - svgame.globals->cdAudioTrack = 0; - } + if( svgame.globals->cdAudioTrack ) + { + MSG_BeginServerCmd( &msg, svc_stufftext ); + MSG_WriteString( &msg, va( "cd loop %3d\n", svgame.globals->cdAudioTrack )); + svgame.globals->cdAudioTrack = 0; } #ifdef HACKS_RELATED_HLMODS @@ -1731,6 +1731,9 @@ static qboolean SV_Godmode_f( sv_client_t *cl ) return true; pEntity->v.flags = pEntity->v.flags ^ FL_GODMODE; + if( pEntity->v.takedamage == DAMAGE_AIM ) + pEntity->v.takedamage = DAMAGE_NO; + else pEntity->v.takedamage = DAMAGE_AIM; if( !FBitSet( pEntity->v.flags, FL_GODMODE )) SV_ClientPrintf( cl, "godmode OFF\n" ); diff --git a/engine/server/sv_cmds.c b/engine/server/sv_cmds.c index ea704538..72954f63 100644 --- a/engine/server/sv_cmds.c +++ b/engine/server/sv_cmds.c @@ -440,6 +440,42 @@ void SV_Reload_f( void ) COM_LoadLevel( sv_hostmap->string, false ); } +/* +================== +SV_ChangeLevel_f + +classic change level +================== +*/ +void SV_ChangeLevel_f( void ) +{ + if( Cmd_Argc() != 2 ) + { + Con_Printf( S_USAGE "changelevel \n" ); + return; + } + + SV_QueueChangeLevel( Cmd_Argv( 1 ), NULL ); +} + +/* +================== +SV_ChangeLevel2_f + +smooth change level +================== +*/ +void SV_ChangeLevel2_f( void ) +{ + if( Cmd_Argc() != 3 ) + { + Con_Printf( S_USAGE "changelevel2 \n" ); + return; + } + + SV_QueueChangeLevel( Cmd_Argv( 1 ), Cmd_Argv( 2 )); +} + /* ================== SV_Kick_f @@ -802,6 +838,7 @@ void SV_InitHostCommands( void ) Cmd_AddCommand( "load", SV_Load_f, "load a saved game file" ); Cmd_AddCommand( "loadquick", SV_QuickLoad_f, "load a quick-saved game file" ); Cmd_AddCommand( "reload", SV_Reload_f, "continue from latest save or restart level" ); + Cmd_AddCommand( "killsave", SV_DeleteSave_f, "delete a saved game file and saveshot" ); } } @@ -824,13 +861,14 @@ void SV_InitOperatorCommands( void ) Cmd_AddCommand( "edict_usage", SV_EdictUsage_f, "show info about edicts usage" ); Cmd_AddCommand( "entity_info", SV_EntityInfo_f, "show more info about edicts" ); Cmd_AddCommand( "shutdownserver", SV_KillServer_f, "shutdown current server" ); + Cmd_AddCommand( "changelevel", SV_ChangeLevel_f, "change level" ); + Cmd_AddCommand( "changelevel2", SV_ChangeLevel2_f, "smooth change level" ); if( host.type == HOST_NORMAL ) { Cmd_AddCommand( "save", SV_Save_f, "save the game to a file" ); Cmd_AddCommand( "savequick", SV_QuickSave_f, "save the game to the quicksave" ); Cmd_AddCommand( "autosave", SV_AutoSave_f, "save the game to 'autosave' file" ); - Cmd_AddCommand( "killsave", SV_DeleteSave_f, "delete a saved game file and saveshot" ); } else if( host.type == HOST_DEDICATED ) { @@ -857,12 +895,13 @@ void SV_KillOperatorCommands( void ) Cmd_RemoveCommand( "edict_usage" ); Cmd_RemoveCommand( "entity_info" ); Cmd_RemoveCommand( "shutdownserver" ); + Cmd_RemoveCommand( "changelevel" ); + Cmd_RemoveCommand( "changelevel2" ); if( host.type == HOST_NORMAL ) { Cmd_RemoveCommand( "save" ); Cmd_RemoveCommand( "savequick" ); - Cmd_RemoveCommand( "killsave" ); Cmd_RemoveCommand( "autosave" ); } else if( host.type == HOST_DEDICATED ) diff --git a/engine/server/sv_game.c b/engine/server/sv_game.c index d5fe83e6..34955bd2 100644 --- a/engine/server/sv_game.c +++ b/engine/server/sv_game.c @@ -658,6 +658,91 @@ qboolean SV_BoxInPVS( const vec3_t org, const vec3_t absmin, const vec3_t absmax return true; } +/* +============= +SV_ChangeLevel + +Issue changing level +============= +*/ +void SV_QueueChangeLevel( const char *level, const char *landname ) +{ + int flags, smooth = false; + char mapname[MAX_QPATH]; + char *spawn_entity; + + // hold mapname to other place + Q_strncpy( mapname, level, sizeof( mapname )); + COM_StripExtension( mapname ); + + if( COM_CheckString( landname )) + smooth = true; + + // determine spawn entity classname + if( svs.maxclients == 1 ) + spawn_entity = GI->sp_entity; + else spawn_entity = GI->mp_entity; + + flags = SV_MapIsValid( mapname, spawn_entity, landname ); + + if( FBitSet( flags, MAP_INVALID_VERSION )) + { + Con_Printf( S_ERROR "changelevel: %s is invalid or not supported\n", mapname ); + return; + } + + if( !FBitSet( flags, MAP_IS_EXIST )) + { + Con_Printf( S_ERROR "changelevel: map %s doesn't exist\n", mapname ); + return; + } + + if( smooth && !FBitSet( flags, MAP_HAS_LANDMARK )) + { + if( sv_validate_changelevel->value ) + { + // NOTE: we find valid map but specified landmark it's doesn't exist + // run simple changelevel like in q1, throw warning + Con_Printf( S_WARN "changelevel: %s doesn't contain landmark [%s]. smooth transition was disabled\n", mapname, landname ); + smooth = false; + } + } + + if( svs.maxclients > 1 ) + smooth = false; // multiplayer doesn't support smooth transition + + if( smooth && !Q_stricmp( sv.name, level )) + { + Con_Printf( S_ERROR "can't changelevel with same map. Ignored.\n" ); + return; + } + + if( !smooth && !FBitSet( flags, MAP_HAS_SPAWNPOINT )) + { + if( sv_validate_changelevel->value ) + { + Con_Printf( S_ERROR "changelevel: %s doesn't have a valid spawnpoint. Ignored.\n", mapname ); + return; + } + } + + // bad changelevel position invoke enables in one-way transition + if( sv.framecount < 15 ) + { + if( sv_validate_changelevel->value ) + { + Con_Printf( S_WARN "an infinite changelevel was detected and will be disabled until a next save\\restore\n" ); + return; // lock with svs.spawncount here + } + } + + SV_SkipUpdates (); + + // changelevel will be executed on a next frame + if( smooth ) COM_ChangeLevel( mapname, landname, sv.background ); // Smoothed Half-Life changelevel + else COM_ChangeLevel( mapname, NULL, sv.background ); // Classic Quake changlevel +} + /* ============== SV_WriteEntityPatch @@ -1312,11 +1397,8 @@ pfnChangeLevel */ void pfnChangeLevel( const char *level, const char *landmark ) { - int flags, smooth = false; static uint last_spawncount = 0; - char mapname[MAX_QPATH]; char landname[MAX_QPATH]; - char *spawn_entity; char *text; if( !COM_CheckString( level ) || sv.state != ss_active ) @@ -1326,10 +1408,6 @@ void pfnChangeLevel( const char *level, const char *landmark ) if( svs.spawncount == last_spawncount ) return; last_spawncount = svs.spawncount; - - // hold mapname to other place - Q_strncpy( mapname, level, sizeof( mapname )); - COM_StripExtension( mapname ); landname[0] ='\0'; #ifdef HACKS_RELATED_HLMODS @@ -1346,72 +1424,7 @@ void pfnChangeLevel( const char *level, const char *landmark ) #else Q_strncpy( landname, landmark, sizeof( landname )); #endif - if( COM_CheckString( landname )) - smooth = true; - - // determine spawn entity classname - if( svs.maxclients == 1 ) - spawn_entity = GI->sp_entity; - else spawn_entity = GI->mp_entity; - - flags = SV_MapIsValid( mapname, spawn_entity, landname ); - - if( FBitSet( flags, MAP_INVALID_VERSION )) - { - Con_Printf( S_ERROR "changelevel: %s is invalid or not supported\n", mapname ); - return; - } - - if( !FBitSet( flags, MAP_IS_EXIST )) - { - Con_Printf( S_ERROR "changelevel: map %s doesn't exist\n", mapname ); - return; - } - - if( smooth && !FBitSet( flags, MAP_HAS_LANDMARK )) - { - if( sv_validate_changelevel->value ) - { - // NOTE: we find valid map but specified landmark it's doesn't exist - // run simple changelevel like in q1, throw warning - Con_Printf( S_WARN "changelevel: %s doesn't contain landmark [%s]. smooth transition was disabled\n", mapname, landname ); - smooth = false; - } - } - - if( svs.maxclients > 1 ) - smooth = false; // multiplayer doesn't support smooth transition - - if( smooth && !Q_stricmp( sv.name, level )) - { - Con_Printf( S_ERROR "can't changelevel with same map. Ignored.\n" ); - return; - } - - if( !smooth && !FBitSet( flags, MAP_HAS_SPAWNPOINT )) - { - if( sv_validate_changelevel->value ) - { - Con_Printf( S_ERROR "changelevel: %s doesn't have a valid spawnpoint. Ignored.\n", mapname ); - return; - } - } - - // bad changelevel position invoke enables in one-way transition - if( sv.framecount < 15 ) - { - if( sv_validate_changelevel->value ) - { - Con_Printf( S_WARN "an infinite changelevel was detected and will be disabled until a next save\\restore\n" ); - return; // lock with svs.spawncount here - } - } - - SV_SkipUpdates (); - - // changelevel will be executed on a next frame - if( smooth ) COM_ChangeLevel( mapname, landname, sv.background ); // Smoothed Half-Life changelevel - else COM_ChangeLevel( mapname, NULL, sv.background ); // Classic Quake changlevel + SV_QueueChangeLevel( level, landname ); } /* @@ -2022,6 +2035,9 @@ int SV_BuildSoundMsg( sizebuf_t *msg, edict_t *ent, int chan, const char *sample } else { + // TESTTEST + if( *sample == '*' ) chan = CHAN_AUTO; + // precache_sound can be used twice: cache sounds when loading // and return sound index when server is active sound_idx = SV_SoundIndex( sample ); @@ -2090,7 +2106,7 @@ void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float msg_dest = MSG_ALL; else if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE )) msg_dest = MSG_ALL; - else msg_dest = MSG_PAS_R; + else msg_dest = (svs.maxclients <= 1 ) ? MSG_ALL : MSG_PAS_R; // always sending stop sound command if( FBitSet( flags, SND_STOP )) @@ -2111,7 +2127,7 @@ pfnEmitAmbientSound */ void pfnEmitAmbientSound( edict_t *ent, float *pos, const char *sample, float vol, float attn, int flags, int pitch ) { - int msg_dest = MSG_PAS_R; + int msg_dest; if( sv.state == ss_loading ) SetBits( flags, SND_SPAWNING ); @@ -4598,8 +4614,11 @@ qboolean SV_ParseEdict( char **pfile, edict_t *ent ) } // no reason to keep this data - Mem_Free( pkvd[i].szKeyName ); - Mem_Free( pkvd[i].szValue ); + if( Mem_IsAllocatedExt( host.mempool, pkvd[i].szKeyName )) + Mem_Free( pkvd[i].szKeyName ); + + if( Mem_IsAllocatedExt( host.mempool, pkvd[i].szValue )) + Mem_Free( pkvd[i].szValue ); } if( classname ) diff --git a/engine/server/sv_init.c b/engine/server/sv_init.c index 812960a9..137a4bed 100644 --- a/engine/server/sv_init.c +++ b/engine/server/sv_init.c @@ -671,6 +671,7 @@ void SV_ShutdownGame( void ) SV_FinalMessage( "", true ); S_StopBackgroundTrack(); + CL_StopPlayback(); // stop demo too if( GameState->newGame ) { diff --git a/engine/server/sv_phys.c b/engine/server/sv_phys.c index 1b4b2ca6..b2970c4a 100644 --- a/engine/server/sv_phys.c +++ b/engine/server/sv_phys.c @@ -780,6 +780,7 @@ Does not change the entities velocity at all trace_t SV_PushEntity( edict_t *ent, const vec3_t lpush, const vec3_t apush, int *blocked, float flDamage ) { trace_t trace; + qboolean monsterBlock; qboolean monsterClip; int type; vec3_t end; @@ -812,10 +813,14 @@ trace_t SV_PushEntity( edict_t *ent, const vec3_t lpush, const vec3_t apush, int SV_LinkEdict( ent, true ); + if( ent->v.movetype == MOVETYPE_WALK || ent->v.movetype == MOVETYPE_STEP || ent->v.movetype == MOVETYPE_PUSHSTEP ) + monsterBlock = true; + else monsterBlock = false; + if( blocked ) { // more accuracy blocking code - if( flDamage <= 0.0f && FBitSet( host.features, ENGINE_PHYSICS_PUSHER_EXT )) + if( monsterBlock ) *blocked = !VectorCompareEpsilon( ent->v.origin, end, ON_EPSILON ); // can't move full distance else *blocked = true; }