mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 11:35:05 +08:00
Compare commits
15 Commits
mac-bsd-id
...
continuous
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e06417db6 | ||
|
|
1901c8a91d | ||
|
|
2511c07a66 | ||
|
|
20b2332ca1 | ||
|
|
a244c4d453 | ||
|
|
0b14349cdb | ||
|
|
70272ca903 | ||
|
|
4fbdf5e8ee | ||
|
|
7e939b5cd7 | ||
|
|
264f69cd91 | ||
|
|
40af9f992e | ||
|
|
d8e3a78aba | ||
|
|
28ac39fd84 | ||
|
|
a742fa385d | ||
|
|
e47c675386 |
@@ -195,7 +195,6 @@ static int AVI_OpenCodecContext( AVCodecContext **dst_dec_ctx, AVFormatContext *
|
||||
AVI_SpewError( quiet, S_ERROR "Failed to allocate %s codec context", dec->name );
|
||||
return AVERROR( ENOMEM );
|
||||
}
|
||||
|
||||
if(( ret = pavcodec_parameters_to_context( dec_ctx, st->codecpar )) < 0 )
|
||||
{
|
||||
AVI_SpewAvError( quiet, "avcodec_parameters_to_context", ret );
|
||||
@@ -251,8 +250,7 @@ byte *AVI_GetVideoFrame( movie_state_t *Avi, int target )
|
||||
|
||||
static void AVI_StreamAudio( movie_state_t *Avi )
|
||||
{
|
||||
int buffer_samples, file_samples, file_bytes;
|
||||
rawchan_t *ch = NULL;
|
||||
rawchan_t *ch;
|
||||
|
||||
// keep the same semantics, when S_RAW_SOUND_SOUNDTRACK doesn't play if S_StartStreaming wasn't enabled
|
||||
qboolean disable_stream = Avi->entnum == S_RAW_SOUND_SOUNDTRACK ? !snd.streaming : false;
|
||||
@@ -273,11 +271,11 @@ static void AVI_StreamAudio( movie_state_t *Avi )
|
||||
|
||||
while( ch->s_rawend < snd.soundtime + ch->max_samples )
|
||||
{
|
||||
int buffer_samples = ch->max_samples - (ch->s_rawend - snd.soundtime);
|
||||
int file_samples = buffer_samples * ((float)Avi->rate / SOUND_DMA_SPEED);
|
||||
int file_bytes;
|
||||
size_t copy;
|
||||
|
||||
buffer_samples = ch->max_samples - (ch->s_rawend - snd.soundtime);
|
||||
|
||||
file_samples = buffer_samples * ((float)Avi->rate / SOUND_DMA_SPEED);
|
||||
if( file_samples <= 1 ) return; // no more samples need
|
||||
|
||||
file_bytes = file_samples * pav_get_bytes_per_sample( Avi->s_fmt ) * Avi->channels;
|
||||
@@ -308,8 +306,6 @@ static void AVI_HandleAudio( movie_state_t *Avi, const AVFrame *frame )
|
||||
{
|
||||
int samples = frame->nb_samples;
|
||||
size_t len = samples * pav_get_bytes_per_sample( Avi->s_fmt ) * Avi->channels;
|
||||
int outsamples;
|
||||
uint8_t *ptr;
|
||||
|
||||
// allocate data
|
||||
if( !Avi->cached_audio )
|
||||
@@ -337,8 +333,8 @@ static void AVI_HandleAudio( movie_state_t *Avi, const AVFrame *frame )
|
||||
}
|
||||
}
|
||||
|
||||
ptr = Avi->cached_audio + Avi->cached_audio_len;
|
||||
outsamples = pswr_convert( Avi->swr_ctx, &ptr, samples, (void *)frame->data, samples );
|
||||
uint8_t *ptr = Avi->cached_audio + Avi->cached_audio_len;
|
||||
int outsamples = pswr_convert( Avi->swr_ctx, &ptr, samples, (void *)frame->data, samples );
|
||||
Avi->cached_audio_len += outsamples * pav_get_bytes_per_sample( Avi->s_fmt ) * Avi->channels;
|
||||
|
||||
// Con_Printf( "%s: got audio chunk of size %d samples\n", __func__, outsamples );
|
||||
@@ -463,8 +459,6 @@ qboolean AVI_Think( movie_state_t *Avi )
|
||||
|
||||
void AVI_OpenVideo( movie_state_t *Avi, const char *filename, qboolean load_audio, int quiet )
|
||||
{
|
||||
byte *dst[4];
|
||||
int dst_linesize[4];
|
||||
int ret;
|
||||
|
||||
if( Avi->active )
|
||||
@@ -529,6 +523,8 @@ void AVI_OpenVideo( movie_state_t *Avi, const char *filename, qboolean load_audi
|
||||
return;
|
||||
}
|
||||
|
||||
byte *dst[4];
|
||||
int dst_linesize[4];
|
||||
if(( ret = pav_image_alloc( dst, dst_linesize, Avi->xres, Avi->yres, AV_PIX_FMT_BGR0, 1 )) < 0 )
|
||||
{
|
||||
AVI_SpewAvError( quiet, "av_image_alloc", ret );
|
||||
|
||||
@@ -61,16 +61,14 @@ Emulate audio-cd system
|
||||
*/
|
||||
void CL_PlayCDTrack_f( void )
|
||||
{
|
||||
const char *command;
|
||||
const char *pszTrack;
|
||||
static int track = 0;
|
||||
static qboolean paused = false;
|
||||
static qboolean looped = false;
|
||||
static qboolean enabled = true;
|
||||
|
||||
if( Cmd_Argc() < 2 ) return;
|
||||
command = Cmd_Argv( 1 );
|
||||
pszTrack = Cmd_Argv( 2 );
|
||||
const char *command = Cmd_Argv( 1 );
|
||||
const char *pszTrack = Cmd_Argv( 2 );
|
||||
|
||||
if( !enabled && Q_stricmp( command, "on" ))
|
||||
return; // CD-player is disabled
|
||||
@@ -238,9 +236,7 @@ static scrshot_t CL_GetScreenshotTypeFromString( const char *string )
|
||||
void CL_GenericShot_f( void )
|
||||
{
|
||||
const char *argv0 = Cmd_Argv( 0 );
|
||||
scrshot_t type;
|
||||
|
||||
type = CL_GetScreenshotTypeFromString( argv0 );
|
||||
scrshot_t type = CL_GetScreenshotTypeFromString( argv0 );
|
||||
|
||||
if( type == scrshot_normal || type == scrshot_snapshot )
|
||||
{
|
||||
@@ -272,7 +268,6 @@ void CL_GenericShot_f( void )
|
||||
case scrshot_snapshot:
|
||||
{
|
||||
string checkname;
|
||||
int i;
|
||||
|
||||
// allow overriding screenshot by users request
|
||||
if( Cmd_Argc() > 1 )
|
||||
@@ -284,7 +279,7 @@ void CL_GenericShot_f( void )
|
||||
if( type == scrshot_snapshot )
|
||||
FS_AllowDirectPaths( true );
|
||||
|
||||
for( i = 0; i < 9999; i++ )
|
||||
for( int i = 0; i < 9999; i++ )
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -383,17 +378,14 @@ CL_WavePlayLen_f
|
||||
*/
|
||||
void CL_WavePlayLen_f( void )
|
||||
{
|
||||
const char *name;
|
||||
uint msecs;
|
||||
|
||||
if( Cmd_Argc() != 2 )
|
||||
{
|
||||
Con_Printf( "waveplaylen <wave file name>: returns approximate number of milliseconds a wave file will take to play.\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
name = Cmd_Argv( 1 );
|
||||
msecs = Sound_GetApproxWavePlayLen( name );
|
||||
const char *name = Cmd_Argv( 1 );
|
||||
uint msecs = Sound_GetApproxWavePlayLen( name );
|
||||
|
||||
if( msecs == 0 )
|
||||
{
|
||||
|
||||
@@ -130,9 +130,7 @@ void CL_MoveToOnHandList( resource_t *pResource )
|
||||
|
||||
static void CL_ClearResourceList( resource_t *pList )
|
||||
{
|
||||
resource_t *p, *n;
|
||||
|
||||
for( p = pList->pNext; p != pList && p; p = n )
|
||||
for( resource_t *p = pList->pNext, *n; p != pList && p; p = n )
|
||||
{
|
||||
n = p->pNext;
|
||||
|
||||
|
||||
@@ -71,9 +71,7 @@ const char *CL_MsgInfo( int cmd )
|
||||
}
|
||||
else if( cmd > svc_lastmsg && cmd <= ( svc_lastmsg + MAX_USER_MESSAGES ))
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < MAX_USER_MESSAGES; i++ )
|
||||
for( int i = 0; i < MAX_USER_MESSAGES; i++ )
|
||||
{
|
||||
if( clgame.msg[i].number == cmd )
|
||||
{
|
||||
@@ -106,11 +104,9 @@ record new message params into debug buffer
|
||||
*/
|
||||
void CL_Parse_RecordCommand( int cmd, int startoffset )
|
||||
{
|
||||
int slot;
|
||||
|
||||
if( cmd == svc_nop ) return;
|
||||
|
||||
slot = ( cls_message_debug.currentcmd++ & MSG_MASK );
|
||||
int slot = ( cls_message_debug.currentcmd++ & MSG_MASK );
|
||||
cls_message_debug.oldcmd[slot].command = cmd;
|
||||
cls_message_debug.oldcmd[slot].starting_offset = startoffset;
|
||||
cls_message_debug.oldcmd[slot].frame_number = host.framecount;
|
||||
@@ -141,9 +137,7 @@ write net_message into buffer.dat for debugging
|
||||
static void CL_WriteErrorMessage( int current_count, sizebuf_t *msg )
|
||||
{
|
||||
const char *buffer_file = "buffer.dat";
|
||||
file_t *fp;
|
||||
|
||||
fp = FS_Open( buffer_file, "wb", false );
|
||||
file_t *fp = FS_Open( buffer_file, "wb", false );
|
||||
if( !fp )
|
||||
{
|
||||
Con_Printf( S_ERROR "%s: can't open %s for write\n", __func__, buffer_file );
|
||||
@@ -170,7 +164,7 @@ void CL_WriteMessageHistory( void )
|
||||
{
|
||||
oldcmd_t *old;
|
||||
sizebuf_t *msg = &net_message;
|
||||
int i, thecmd;
|
||||
int thecmd;
|
||||
|
||||
if( !cls.initialized || cls.state == ca_disconnected )
|
||||
return;
|
||||
@@ -184,7 +178,7 @@ void CL_WriteMessageHistory( void )
|
||||
thecmd = cls_message_debug.currentcmd - 1;
|
||||
thecmd -= ( MSG_COUNT - 1 ); // back up to here
|
||||
|
||||
for( i = 0; i < MSG_COUNT - 1; i++ )
|
||||
for( int i = 0; i < MSG_COUNT - 1; i++ )
|
||||
{
|
||||
thecmd &= MSG_MASK;
|
||||
old = &cls_message_debug.oldcmd[thecmd];
|
||||
|
||||
@@ -245,8 +245,6 @@ Writes the demo command header and time-delta
|
||||
*/
|
||||
static void CL_WriteDemoCmdHeader( byte cmd, file_t *file )
|
||||
{
|
||||
float dt;
|
||||
|
||||
Assert( cmd >= 1 && cmd <= dem_lastcmd );
|
||||
if( !file ) return;
|
||||
|
||||
@@ -254,7 +252,7 @@ static void CL_WriteDemoCmdHeader( byte cmd, file_t *file )
|
||||
FS_Write( file, &cmd, sizeof( byte ));
|
||||
|
||||
// time offset
|
||||
dt = (float)(CL_GetDemoRecordClock() - demo.starttime);
|
||||
float dt = (float)(CL_GetDemoRecordClock() - demo.starttime);
|
||||
FS_Write( file, &dt, sizeof( float ));
|
||||
}
|
||||
|
||||
@@ -395,11 +393,6 @@ Write demo header
|
||||
*/
|
||||
static void CL_WriteDemoHeader( const char *name )
|
||||
{
|
||||
double maxfps;
|
||||
int copysize;
|
||||
int savepos;
|
||||
int curpos;
|
||||
|
||||
Con_Printf( "recording to %s.\n", name );
|
||||
cls.demofile = FS_Open( name, "wb", false );
|
||||
cls.demotime = 0.0;
|
||||
@@ -413,7 +406,7 @@ static void CL_WriteDemoHeader( const char *name )
|
||||
cls.demorecording = true;
|
||||
cls.demowaiting = true; // don't start saving messages until a non-delta compressed message is received
|
||||
|
||||
maxfps = fps_override.value ? MAX_FPS_HARD : MAX_FPS_SOFT;
|
||||
double maxfps = fps_override.value ? MAX_FPS_HARD : MAX_FPS_SOFT;
|
||||
|
||||
memset( &demo.header, 0, sizeof( demo.header ));
|
||||
|
||||
@@ -442,6 +435,7 @@ static void CL_WriteDemoHeader( const char *name )
|
||||
FS_Flush( cls.demoheader );
|
||||
|
||||
// now copy the stuff we cached from the server.
|
||||
int copysize, savepos;
|
||||
copysize = savepos = FS_Tell( cls.demoheader );
|
||||
|
||||
FS_Seek( cls.demoheader, 0, SEEK_SET );
|
||||
@@ -458,7 +452,7 @@ static void CL_WriteDemoHeader( const char *name )
|
||||
cls.td_lastframe = -1; // get a new message this frame
|
||||
|
||||
// now move on to entry # 1, the first data chunk.
|
||||
curpos = FS_Tell( cls.demofile );
|
||||
int curpos = FS_Tell( cls.demofile );
|
||||
demo.entry->length = curpos - demo.entry->offset;
|
||||
|
||||
// now we are writing the first real lump.
|
||||
@@ -487,19 +481,15 @@ finish recording demo
|
||||
*/
|
||||
static void CL_StopRecord( void )
|
||||
{
|
||||
int i, curpos;
|
||||
float stoptime;
|
||||
int frames;
|
||||
|
||||
if( !cls.demorecording ) return;
|
||||
|
||||
// demo playback should read this as an incoming message.
|
||||
CL_WriteDemoCmdHeader( dem_stop, cls.demofile );
|
||||
|
||||
stoptime = CL_GetDemoRecordClock();
|
||||
float stoptime = CL_GetDemoRecordClock();
|
||||
if( clgame.hInstance ) clgame.dllFuncs.pfnReset();
|
||||
|
||||
curpos = FS_Tell( cls.demofile );
|
||||
int curpos = FS_Tell( cls.demofile );
|
||||
demo.entry->length = curpos - demo.entry->offset;
|
||||
demo.entry->playback_time = stoptime - demo.realstarttime;
|
||||
demo.entry->playback_frames = demo.framecount;
|
||||
@@ -507,7 +497,7 @@ static void CL_StopRecord( void )
|
||||
// Now write out the directory and free it and touch up the demo header.
|
||||
FS_Write( cls.demofile, &demo.directory.numentries, sizeof( int ));
|
||||
|
||||
for( i = 0; i < demo.directory.numentries; i++ )
|
||||
for( int i = 0; i < demo.directory.numentries; i++ )
|
||||
FS_Write( cls.demofile, &demo.directory.entries[i], sizeof( demoentry_t ));
|
||||
|
||||
Mem_Free( demo.directory.entries );
|
||||
@@ -525,7 +515,7 @@ static void CL_StopRecord( void )
|
||||
gameui.globals->demoname[0] = '\0';
|
||||
demo.header.host_fps = 0.0;
|
||||
|
||||
frames = cls.td_lastframe - cls.td_startframe;
|
||||
int frames = cls.td_lastframe - cls.td_startframe;
|
||||
Con_Printf( "Completed demo\nRecording time: %02d:%02d, frames %i\n", (int)(cls.demotime / 60.0f), (int)fmod(cls.demotime, 60.0f), frames );
|
||||
cls.demotime = 0.0;
|
||||
}
|
||||
@@ -539,13 +529,12 @@ void CL_DrawDemoRecording( void )
|
||||
{
|
||||
char string[64];
|
||||
rgba_t color = { 255, 255, 255, 255 };
|
||||
int pos;
|
||||
int len;
|
||||
|
||||
if(!( host_developer.value && cls.demorecording ))
|
||||
return;
|
||||
|
||||
pos = FS_Tell( cls.demofile );
|
||||
int pos = FS_Tell( cls.demofile );
|
||||
Q_snprintf( string, sizeof( string ), "^1RECORDING:^7 %s: %s time: %02d:%02d", cls.demoname,
|
||||
Q_memprint( pos ), (int)(cls.demotime / 60.0f ), (int)fmod( cls.demotime, 60.0f ));
|
||||
|
||||
@@ -847,7 +836,6 @@ static qboolean CL_DemoReadMessageQuake( byte *buffer, size_t *length )
|
||||
{
|
||||
vec3_t viewangles;
|
||||
int msglen = 0;
|
||||
demoangle_t *a;
|
||||
|
||||
*length = 0; // assume we fail
|
||||
|
||||
@@ -888,7 +876,7 @@ static qboolean CL_DemoReadMessageQuake( byte *buffer, size_t *length )
|
||||
{
|
||||
// select entry into circular buffer
|
||||
demo.angle_position = (demo.angle_position + 1) & ANGLE_MASK;
|
||||
a = &demo.cmds[demo.angle_position];
|
||||
demoangle_t *a = &demo.cmds[demo.angle_position];
|
||||
|
||||
// record update
|
||||
a->starttime = demo.timestamp;
|
||||
@@ -1060,8 +1048,7 @@ qboolean CL_DemoReadMessage( byte *buffer, size_t *length )
|
||||
|
||||
static void CL_DemoFindInterpolatedViewAngles( float t, float *frac, demoangle_t **prev, demoangle_t **next )
|
||||
{
|
||||
int i, i0, i1, imod;
|
||||
float at;
|
||||
int i0, i1, imod;
|
||||
|
||||
if( cls.timedemo ) return;
|
||||
|
||||
@@ -1071,9 +1058,9 @@ static void CL_DemoFindInterpolatedViewAngles( float t, float *frac, demoangle_t
|
||||
|
||||
if( demo.cmds[i0].starttime >= t )
|
||||
{
|
||||
for( i = 0; i < ANGLE_BACKUP - 2; i++ )
|
||||
for( int i = 0; i < ANGLE_BACKUP - 2; i++ )
|
||||
{
|
||||
at = demo.cmds[imod & ANGLE_MASK].starttime;
|
||||
float at = demo.cmds[imod & ANGLE_MASK].starttime;
|
||||
if( at == 0.0f ) break;
|
||||
|
||||
if( at < t )
|
||||
@@ -1114,7 +1101,6 @@ void CL_DemoInterpolateAngles( void )
|
||||
{
|
||||
demoangle_t *prev = NULL, *next = NULL;
|
||||
float frac = 0.0f;
|
||||
float curtime;
|
||||
|
||||
if( cls.demoplayback == DEMO_QUAKE1 )
|
||||
{
|
||||
@@ -1126,7 +1112,7 @@ void CL_DemoInterpolateAngles( void )
|
||||
}
|
||||
else
|
||||
{
|
||||
curtime = (CL_GetDemoPlaybackClock() - demo.starttime) - host.frametime;
|
||||
float curtime = (CL_GetDemoPlaybackClock() - demo.starttime) - host.frametime;
|
||||
if( curtime > demo.timestamp )
|
||||
curtime = demo.timestamp; // don't run too far
|
||||
|
||||
@@ -1239,7 +1225,6 @@ int GAME_EXPORT CL_GetDemoComment( const char *demoname, char *comment )
|
||||
demodirectory_t directory;
|
||||
demoentry_t entry;
|
||||
float playtime = 0.0f;
|
||||
int i;
|
||||
|
||||
if( !comment ) return false;
|
||||
|
||||
@@ -1279,7 +1264,7 @@ int GAME_EXPORT CL_GetDemoComment( const char *demoname, char *comment )
|
||||
return false;
|
||||
}
|
||||
|
||||
for( i = 0; i < directory.numentries; i++ )
|
||||
for( int i = 0; i < directory.numentries; i++ )
|
||||
{
|
||||
FS_Read( demfile, &entry, sizeof( demoentry_t ));
|
||||
playtime += entry.playback_time;
|
||||
@@ -1388,7 +1373,6 @@ void CL_Record_f( void )
|
||||
{
|
||||
string demoname, demopath;
|
||||
const char *name;
|
||||
int n;
|
||||
|
||||
if( Cmd_Argc() == 1 )
|
||||
{
|
||||
@@ -1425,6 +1409,7 @@ void CL_Record_f( void )
|
||||
if( !Q_stricmp( name, "new" ))
|
||||
{
|
||||
// scan for a free filename
|
||||
int n;
|
||||
for( n = 0; n < 10000; n++ )
|
||||
{
|
||||
CL_DemoGetName( n, demoname, sizeof( demoname ));
|
||||
@@ -1511,7 +1496,7 @@ void CL_PlayDemo_f( void )
|
||||
{
|
||||
char filename[MAX_QPATH];
|
||||
char demoname[MAX_QPATH];
|
||||
int i, ident;
|
||||
int ident;
|
||||
|
||||
if( Cmd_Argc() < 2 )
|
||||
{
|
||||
@@ -1584,7 +1569,7 @@ void CL_PlayDemo_f( void )
|
||||
// allocate demo entries
|
||||
demo.directory.entries = Mem_Malloc( cls.mempool, sizeof( *demo.directory.entries ) * demo.directory.numentries );
|
||||
|
||||
for( i = 0; i < demo.directory.numentries; i++ )
|
||||
for( int i = 0; i < demo.directory.numentries; i++ )
|
||||
{
|
||||
demoentry_t *entry = &demo.directory.entries[i];
|
||||
|
||||
@@ -1640,15 +1625,13 @@ CL_StartDemos_f
|
||||
*/
|
||||
void CL_StartDemos_f( void )
|
||||
{
|
||||
int i, c;
|
||||
|
||||
if( cls.key_dest != key_menu )
|
||||
{
|
||||
Con_Printf( "'startdemos' is not valid from the console\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
c = Cmd_Argc() - 1;
|
||||
int c = Cmd_Argc() - 1;
|
||||
if( c > MAX_DEMOS )
|
||||
{
|
||||
Con_DPrintf( S_WARN "%s: max %i demos in demoloop\n", __func__, MAX_DEMOS );
|
||||
@@ -1657,7 +1640,7 @@ void CL_StartDemos_f( void )
|
||||
|
||||
Con_Printf( "%i demo%s in loop\n", c, (c > 1) ? "s" : "" );
|
||||
|
||||
for( i = 1; i < c + 1; i++ )
|
||||
for( int i = 1; i < c + 1; i++ )
|
||||
Q_strncpy( cls.demos[i-1], Cmd_Argv( i ), sizeof( cls.demos[0] ));
|
||||
cls.demos_pending = true;
|
||||
}
|
||||
@@ -1717,7 +1700,6 @@ void CL_ListDemo_f( void )
|
||||
file_t *f;
|
||||
char filename[MAX_QPATH];
|
||||
char demoname[MAX_QPATH];
|
||||
int i;
|
||||
|
||||
if( Cmd_Argc() < 2 )
|
||||
{
|
||||
@@ -1751,7 +1733,7 @@ void CL_ListDemo_f( void )
|
||||
filename, hdr.net_protocol, hdr.dem_protocol, hdr.host_fps, hdr.mapname,
|
||||
hdr.comment, hdr.gamedir );
|
||||
|
||||
for( i = 0; i < num_entries; i++ )
|
||||
for( int i = 0; i < num_entries; i++ )
|
||||
{
|
||||
demoentry_t entry;
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ static efrag_t *cl_efrags;
|
||||
|
||||
static efrag_t *CL_AllocEfrags( int num )
|
||||
{
|
||||
int i;
|
||||
efrag_t *efrags;
|
||||
|
||||
if( !cl.worldmodel )
|
||||
@@ -55,7 +54,7 @@ static efrag_t *CL_AllocEfrags( int num )
|
||||
efrags = Mem_Calloc( cl.worldmodel->mempool, sizeof( *efrags ) * num );
|
||||
|
||||
// initialize linked list
|
||||
for( i = 0; i < num - 1; i++ )
|
||||
for( int i = 0; i < num - 1; i++ )
|
||||
efrags[i].entnext = &efrags[i + 1];
|
||||
|
||||
cl_efrags_num += num;
|
||||
@@ -81,8 +80,6 @@ R_SplitEntityOnNode
|
||||
*/
|
||||
static void R_SplitEntityOnNode( mnode_t *node )
|
||||
{
|
||||
efrag_t *ef;
|
||||
mleaf_t *leaf;
|
||||
int sides;
|
||||
|
||||
if( node->contents == CONTENTS_SOLID )
|
||||
@@ -91,6 +88,9 @@ static void R_SplitEntityOnNode( mnode_t *node )
|
||||
// add an efrag if the node is a leaf
|
||||
if( node->contents < 0 )
|
||||
{
|
||||
efrag_t *ef;
|
||||
mleaf_t *leaf;
|
||||
|
||||
if( !r_pefragtopnode )
|
||||
r_pefragtopnode = node;
|
||||
|
||||
@@ -142,7 +142,6 @@ void R_AddEfrags( cl_entity_t *ent )
|
||||
{
|
||||
matrix3x4 transform;
|
||||
vec3_t outmins, outmaxs;
|
||||
int i;
|
||||
|
||||
if( !ent->model )
|
||||
return;
|
||||
@@ -155,7 +154,7 @@ void R_AddEfrags( cl_entity_t *ent )
|
||||
Matrix3x4_CreateFromEntity( transform, ent->angles, vec3_origin, 1.0f );
|
||||
Matrix3x4_TransformAABB( transform, ent->model->mins, ent->model->maxs, outmins, outmaxs );
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
r_emins[i] = ent->origin[i] + outmins[i];
|
||||
r_emaxs[i] = ent->origin[i] + outmaxs[i];
|
||||
@@ -174,13 +173,11 @@ R_StoreEfrags
|
||||
void R_StoreEfrags( efrag_t **ppefrag, int framecount )
|
||||
{
|
||||
efrag_t *pefrag;
|
||||
cl_entity_t *pent;
|
||||
model_t *clmodel;
|
||||
|
||||
while(( pefrag = *ppefrag ) != NULL )
|
||||
{
|
||||
pent = pefrag->entity;
|
||||
clmodel = pent->model;
|
||||
cl_entity_t *pent = pefrag->entity;
|
||||
model_t *clmodel = pent->model;
|
||||
|
||||
// how this could happen?
|
||||
if( unlikely( clmodel->type < mod_brush || clmodel->type > mod_studio ))
|
||||
|
||||
@@ -44,21 +44,17 @@ find nearest color in particle palette
|
||||
*/
|
||||
short GAME_EXPORT R_LookupColor( byte r, byte g, byte b )
|
||||
{
|
||||
int i, best;
|
||||
float diff, bestdiff;
|
||||
float rf, gf, bf;
|
||||
float bestdiff = 999999;
|
||||
int best = -1;
|
||||
|
||||
bestdiff = 999999;
|
||||
best = -1;
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
for( int i = 0; i < 256; i++ )
|
||||
{
|
||||
rf = r - clgame.palette[i].r;
|
||||
gf = g - clgame.palette[i].g;
|
||||
bf = b - clgame.palette[i].b;
|
||||
float rf = r - clgame.palette[i].r;
|
||||
float gf = g - clgame.palette[i].g;
|
||||
float bf = b - clgame.palette[i].b;
|
||||
|
||||
// convert color to monochrome
|
||||
diff = rf * (rf * 0.2f) + gf * (gf * 0.5f) + bf * (bf * 0.3f);
|
||||
float diff = rf * (rf * 0.2f) + gf * (gf * 0.5f) + bf * (bf * 0.3f);
|
||||
|
||||
if ( diff < bestdiff )
|
||||
{
|
||||
@@ -90,13 +86,11 @@ CL_InitParticles
|
||||
*/
|
||||
void CL_InitParticles( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
cl_particles = Mem_Calloc( cls.mempool, sizeof( particle_t ) * GI->max_particles );
|
||||
CL_ClearParticles ();
|
||||
|
||||
// this is used for EF_BRIGHTFIELD
|
||||
for( i = 0; i < NUMVERTEXNORMALS; i++ )
|
||||
for( int i = 0; i < NUMVERTEXNORMALS; i++ )
|
||||
{
|
||||
cl_avelocities[i][0] = COM_RandomFloat( 0.0f, 2.55f );
|
||||
cl_avelocities[i][1] = COM_RandomFloat( 0.0f, 2.55f );
|
||||
@@ -116,15 +110,13 @@ CL_ClearParticles
|
||||
*/
|
||||
void CL_ClearParticles( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !cl_particles ) return;
|
||||
|
||||
cl_free_particles = cl_particles;
|
||||
cl_active_particles = NULL;
|
||||
cl_active_tracers = NULL;
|
||||
|
||||
for( i = 0; i < GI->max_particles - 1; i++ )
|
||||
for( int i = 0; i < GI->max_particles - 1; i++ )
|
||||
cl_particles[i].next = &cl_particles[i+1];
|
||||
|
||||
cl_particles[GI->max_particles-1].next = NULL;
|
||||
@@ -357,15 +349,13 @@ CL_ClearViewBeams
|
||||
*/
|
||||
void CL_ClearViewBeams( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !cl_viewbeams ) return;
|
||||
|
||||
// clear beams
|
||||
cl_free_beams = cl_viewbeams;
|
||||
cl_active_beams = NULL;
|
||||
|
||||
for( i = 0; i < GI->max_beams - 1; i++ )
|
||||
for( int i = 0; i < GI->max_beams - 1; i++ )
|
||||
cl_viewbeams[i].next = &cl_viewbeams[i+1];
|
||||
cl_viewbeams[GI->max_beams - 1].next = NULL;
|
||||
}
|
||||
@@ -470,16 +460,13 @@ Optimized version of pointfile - use beams instead of particles
|
||||
*/
|
||||
void CL_ReadLineFile_f( void )
|
||||
{
|
||||
byte *afile;
|
||||
char *pfile;
|
||||
vec3_t p1, p2;
|
||||
int count, modelIndex;
|
||||
int modelIndex;
|
||||
char filename[MAX_QPATH];
|
||||
model_t *model;
|
||||
string token;
|
||||
|
||||
Q_snprintf( filename, sizeof( filename ), "maps/%s.lin", clgame.mapname );
|
||||
afile = FS_LoadFile( filename, NULL, false );
|
||||
byte *afile = FS_LoadFile( filename, NULL, false );
|
||||
|
||||
if( !afile )
|
||||
{
|
||||
@@ -489,9 +476,9 @@ void CL_ReadLineFile_f( void )
|
||||
|
||||
Con_Printf( "Reading %s...\n", filename );
|
||||
|
||||
count = 0;
|
||||
pfile = (char *)afile;
|
||||
model = CL_LoadModel( DEFAULT_LASERBEAM_PATH, &modelIndex );
|
||||
int count = 0;
|
||||
char *pfile = (char *)afile;
|
||||
model_t *model = CL_LoadModel( DEFAULT_LASERBEAM_PATH, &modelIndex );
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
@@ -1063,25 +1050,20 @@ set EF_BRIGHTFIELD effect
|
||||
*/
|
||||
void GAME_EXPORT R_EntityParticles( cl_entity_t *ent )
|
||||
{
|
||||
float angle;
|
||||
float sr, sp, sy, cr, cp, cy;
|
||||
vec3_t forward;
|
||||
particle_t *p;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < NUMVERTEXNORMALS; i++ )
|
||||
for( int i = 0; i < NUMVERTEXNORMALS; i++ )
|
||||
{
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
angle = cl.time * cl_avelocities[i][0];
|
||||
float sr, sp, sy, cr, cp, cy;
|
||||
float angle = cl.time * cl_avelocities[i][0];
|
||||
SinCos( angle, &sy, &cy );
|
||||
angle = cl.time * cl_avelocities[i][1];
|
||||
SinCos( angle, &sp, &cp );
|
||||
angle = cl.time * cl_avelocities[i][2];
|
||||
SinCos( angle, &sr, &cr );
|
||||
|
||||
VectorSet( forward, cp * cy, cp * sy, -sp );
|
||||
vec3_t forward = { cp * cy, cp * sy, -sp };
|
||||
|
||||
p->die = cl.time + 0.001f;
|
||||
p->color = 111; // yellow
|
||||
@@ -1098,19 +1080,16 @@ R_ParticleExplosion
|
||||
*/
|
||||
void GAME_EXPORT R_ParticleExplosion( const vec3_t org )
|
||||
{
|
||||
particle_t *p;
|
||||
int i, j;
|
||||
|
||||
for( i = 0; i < 1024; i++ )
|
||||
for( int i = 0; i < 1024; i++ )
|
||||
{
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
p->die = cl.time + 5.0f;
|
||||
p->ramp = COM_RandomLong( 0, 3 );
|
||||
p->color = ramp1[0];
|
||||
|
||||
for( j = 0; j < 3; j++ )
|
||||
for( int j = 0; j < 3; j++ )
|
||||
{
|
||||
p->org[j] = org[j] + COM_RandomFloat( -16.0f, 16.0f );
|
||||
p->vel[j] = COM_RandomFloat( -256.0f, 256.0f );
|
||||
@@ -1129,15 +1108,12 @@ R_ParticleExplosion2
|
||||
*/
|
||||
void GAME_EXPORT R_ParticleExplosion2( const vec3_t org, int colorStart, int colorLength )
|
||||
{
|
||||
int i, j;
|
||||
int colorMod = 0, packedColor;
|
||||
particle_t *p;
|
||||
int colorMod = 0;
|
||||
int packedColor = Host_IsQuakeCompatible( ) ? 255 : 0; // use old code for blob particles
|
||||
|
||||
packedColor = Host_IsQuakeCompatible( ) ? 255 : 0; // use old code for blob particles
|
||||
|
||||
for( i = 0; i < 512; i++ )
|
||||
for( int i = 0; i < 512; i++ )
|
||||
{
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
p->die = cl.time + 0.3f;
|
||||
@@ -1147,7 +1123,7 @@ void GAME_EXPORT R_ParticleExplosion2( const vec3_t org, int colorStart, int col
|
||||
|
||||
p->type = pt_blob;
|
||||
|
||||
for( j = 0; j < 3; j++ )
|
||||
for( int j = 0; j < 3; j++ )
|
||||
{
|
||||
p->org[j] = org[j] + COM_RandomFloat( -16.0f, 16.0f );
|
||||
p->vel[j] = COM_RandomFloat( -256.0f, 256.0f );
|
||||
@@ -1163,14 +1139,11 @@ R_BlobExplosion
|
||||
*/
|
||||
void GAME_EXPORT R_BlobExplosion( const vec3_t org )
|
||||
{
|
||||
particle_t *p;
|
||||
int i, j, packedColor;
|
||||
int packedColor = Host_IsQuakeCompatible( ) ? 255 : 0; // use old code for blob particles
|
||||
|
||||
packedColor = Host_IsQuakeCompatible( ) ? 255 : 0; // use old code for blob particles
|
||||
|
||||
for( i = 0; i < 1024; i++ )
|
||||
for( int i = 0; i < 1024; i++ )
|
||||
{
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
p->die = cl.time + COM_RandomFloat( 1.0f, 1.4f );
|
||||
@@ -1187,7 +1160,7 @@ void GAME_EXPORT R_BlobExplosion( const vec3_t org )
|
||||
p->color = COM_RandomLong( 150, 155 );
|
||||
}
|
||||
|
||||
for( j = 0; j < 3; j++ )
|
||||
for( int j = 0; j < 3; j++ )
|
||||
{
|
||||
p->org[j] = org[j] + COM_RandomFloat( -16.0f, 16.0f );
|
||||
p->vel[j] = COM_RandomFloat( -256.0f, 256.0f );
|
||||
@@ -1204,9 +1177,6 @@ PARTICLE_EFFECT on server
|
||||
*/
|
||||
void GAME_EXPORT R_RunParticleEffect( const vec3_t org, const vec3_t dir, int color, int count )
|
||||
{
|
||||
particle_t *p;
|
||||
int i;
|
||||
|
||||
if( count == 1024 )
|
||||
{
|
||||
// rocket explosion
|
||||
@@ -1214,9 +1184,9 @@ void GAME_EXPORT R_RunParticleEffect( const vec3_t org, const vec3_t dir, int co
|
||||
return;
|
||||
}
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
p->color = (color & ~7) + COM_RandomLong( 0, 7 );
|
||||
@@ -1238,20 +1208,18 @@ particle spray
|
||||
void GAME_EXPORT R_Blood( const vec3_t org, const vec3_t ndir, int pcolor, int speed )
|
||||
{
|
||||
vec3_t pos, dir, vec;
|
||||
int i, j;
|
||||
int pspeed = speed * 3;
|
||||
particle_t *p;
|
||||
|
||||
VectorNormalize2( ndir, dir );
|
||||
|
||||
for( i = 0; i < (speed / 2); i++ )
|
||||
for( int i = 0; i < (speed / 2); i++ )
|
||||
{
|
||||
VectorAddScalar( org, COM_RandomFloat( -3.0f, 3.0f ), pos );
|
||||
VectorAddScalar( dir, COM_RandomFloat( -0.06f, 0.06f ), vec );
|
||||
|
||||
for( j = 0; j < 8; j++ )
|
||||
for( int j = 0; j < 8; j++ )
|
||||
{
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
p->die = cl.time + 1.5f;
|
||||
@@ -1275,17 +1243,15 @@ particle spray 2
|
||||
*/
|
||||
void GAME_EXPORT R_BloodStream( const vec3_t org, const vec3_t ndir, int pcolor, int speed )
|
||||
{
|
||||
particle_t *p;
|
||||
int i, j;
|
||||
float arc;
|
||||
int accel = speed; // must be integer due to bug in GoldSrc
|
||||
vec3_t dir;
|
||||
|
||||
VectorNormalize2( ndir, dir );
|
||||
|
||||
for( arc = 0.05f, i = 0; i < 100; i++ )
|
||||
float arc = 0.05f;
|
||||
for( int i = 0; i < 100; i++ )
|
||||
{
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
p->die = cl.time + 2.0f;
|
||||
@@ -1301,11 +1267,10 @@ void GAME_EXPORT R_BloodStream( const vec3_t org, const vec3_t ndir, int pcolor,
|
||||
accel -= 0.00001f; // so last few will drip
|
||||
}
|
||||
|
||||
for( arc = 0.075f, i = 0; i < ( speed / 5 ); i++ )
|
||||
arc = 0.075f;
|
||||
for( int i = 0; i < ( speed / 5 ); i++ )
|
||||
{
|
||||
float num;
|
||||
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
p->die = cl.time + 3.0f;
|
||||
@@ -1318,14 +1283,14 @@ void GAME_EXPORT R_BloodStream( const vec3_t org, const vec3_t ndir, int pcolor,
|
||||
p->vel[2] -= arc;
|
||||
arc -= 0.005f;
|
||||
|
||||
num = COM_RandomFloat( 0.0f, 1.0f );
|
||||
float num = COM_RandomFloat( 0.0f, 1.0f );
|
||||
accel = speed * num;
|
||||
num *= 1.7f;
|
||||
|
||||
VectorScale( p->vel, num, p->vel );
|
||||
VectorScale( p->vel, accel, p->vel );
|
||||
|
||||
for( j = 0; j < 2; j++ )
|
||||
for( int j = 0; j < 2; j++ )
|
||||
{
|
||||
p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
@@ -1352,18 +1317,15 @@ R_LavaSplash
|
||||
*/
|
||||
void GAME_EXPORT R_LavaSplash( const vec3_t org )
|
||||
{
|
||||
particle_t *p;
|
||||
float vel;
|
||||
vec3_t dir;
|
||||
int i, j, k;
|
||||
|
||||
for( i = -16; i < 16; i++ )
|
||||
for( int i = -16; i < 16; i++ )
|
||||
{
|
||||
for( j = -16; j <16; j++ )
|
||||
for( int j = -16; j <16; j++ )
|
||||
{
|
||||
for( k = 0; k < 1; k++ )
|
||||
for( int k = 0; k < 1; k++ )
|
||||
{
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
p->die = cl.time + COM_RandomFloat( 2.0f, 2.62f );
|
||||
@@ -1379,7 +1341,7 @@ void GAME_EXPORT R_LavaSplash( const vec3_t org )
|
||||
p->org[2] = org[2] + COM_RandomFloat( 0.0f, 63.0f );
|
||||
|
||||
VectorNormalize( dir );
|
||||
vel = COM_RandomFloat( 50.0f, 113.0f );
|
||||
float vel = COM_RandomFloat( 50.0f, 113.0f );
|
||||
VectorScale( dir, vel, p->vel );
|
||||
}
|
||||
}
|
||||
@@ -1394,16 +1356,13 @@ R_ParticleBurst
|
||||
*/
|
||||
void GAME_EXPORT R_ParticleBurst( const vec3_t org, int size, int color, float life )
|
||||
{
|
||||
particle_t *p;
|
||||
vec3_t dir, dest;
|
||||
int i, j;
|
||||
float dist;
|
||||
|
||||
for( i = 0; i < 32; i++ )
|
||||
for( int i = 0; i < 32; i++ )
|
||||
{
|
||||
for( j = 0; j < 32; j++ )
|
||||
for( int j = 0; j < 32; j++ )
|
||||
{
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
p->die = cl.time + life + COM_RandomFloat( -0.5f, 0.5f );
|
||||
@@ -1413,7 +1372,7 @@ void GAME_EXPORT R_ParticleBurst( const vec3_t org, int size, int color, float l
|
||||
VectorCopy( org, p->org );
|
||||
VectorAddScalar( org, COM_RandomFloat( -size, size ), dest );
|
||||
VectorSubtract( dest, p->org, dir );
|
||||
dist = VectorNormalizeLength( dir );
|
||||
float dist = VectorNormalizeLength( dir );
|
||||
VectorScale( dir, ( dist / life ), p->vel );
|
||||
}
|
||||
}
|
||||
@@ -1427,16 +1386,13 @@ R_LargeFunnel
|
||||
*/
|
||||
void GAME_EXPORT R_LargeFunnel( const vec3_t org, int reverse )
|
||||
{
|
||||
particle_t *p;
|
||||
float vel, dist;
|
||||
vec3_t dir, dest;
|
||||
int i, j;
|
||||
|
||||
for( i = -8; i < 8; i++ )
|
||||
for( int i = -8; i < 8; i++ )
|
||||
{
|
||||
for( j = -8; j < 8; j++ )
|
||||
for( int j = -8; j < 8; j++ )
|
||||
{
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
dest[0] = (i * 32.0f) + org[0];
|
||||
@@ -1454,10 +1410,10 @@ void GAME_EXPORT R_LargeFunnel( const vec3_t org, int reverse )
|
||||
VectorSubtract( org, p->org, dir );
|
||||
}
|
||||
|
||||
vel = dest[2] / 8.0f;
|
||||
float vel = dest[2] / 8.0f;
|
||||
if( vel < 64.0f ) vel = 64.0f;
|
||||
|
||||
dist = VectorNormalizeLength( dir );
|
||||
float dist = VectorNormalizeLength( dir );
|
||||
vel += COM_RandomFloat( 64.0f, 128.0f );
|
||||
VectorScale( dir, vel, p->vel );
|
||||
p->die = cl.time + (dist / vel );
|
||||
@@ -1474,18 +1430,15 @@ R_TeleportSplash
|
||||
*/
|
||||
void GAME_EXPORT R_TeleportSplash( const vec3_t org )
|
||||
{
|
||||
particle_t *p;
|
||||
vec3_t dir;
|
||||
float vel;
|
||||
int i, j, k;
|
||||
|
||||
for( i = -16; i < 16; i += 4 )
|
||||
for( int i = -16; i < 16; i += 4 )
|
||||
{
|
||||
for( j = -16; j < 16; j += 4 )
|
||||
for( int j = -16; j < 16; j += 4 )
|
||||
{
|
||||
for( k = -24; k < 32; k += 4 )
|
||||
for( int k = -24; k < 32; k += 4 )
|
||||
{
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
p->die = cl.time + COM_RandomFloat( 0.2f, 0.34f );
|
||||
@@ -1501,7 +1454,7 @@ void GAME_EXPORT R_TeleportSplash( const vec3_t org )
|
||||
p->org[2] = org[2] + k + COM_RandomFloat( 0.0f, 3.0f );
|
||||
|
||||
VectorNormalize( dir );
|
||||
vel = COM_RandomFloat( 50.0f, 113.0f );
|
||||
float vel = COM_RandomFloat( 50.0f, 113.0f );
|
||||
VectorScale( dir, vel, p->vel );
|
||||
}
|
||||
}
|
||||
@@ -1638,13 +1591,12 @@ draw line from particles
|
||||
*/
|
||||
static void PM_ParticleLine( const vec3_t start, const vec3_t end, int pcolor, float life, float zvel )
|
||||
{
|
||||
float len, curdist;
|
||||
vec3_t diff, pos;
|
||||
|
||||
// determine distance
|
||||
VectorSubtract( end, start, diff );
|
||||
len = VectorNormalizeLength( diff );
|
||||
curdist = 0;
|
||||
float len = VectorNormalizeLength( diff );
|
||||
float curdist = 0;
|
||||
|
||||
while( curdist <= len )
|
||||
{
|
||||
@@ -1678,9 +1630,8 @@ static void PM_DrawBBox( const vec3_t mins, const vec3_t maxs, const vec3_t orig
|
||||
{
|
||||
vec3_t p[8], tmp;
|
||||
float gap = BOX_GAP;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 8; i++ )
|
||||
for( int i = 0; i < 8; i++ )
|
||||
{
|
||||
tmp[0] = (i & 1) ? mins[0] - gap : maxs[0] + gap;
|
||||
tmp[1] = (i & 2) ? mins[1] - gap : maxs[1] + gap ;
|
||||
@@ -1690,7 +1641,7 @@ static void PM_DrawBBox( const vec3_t mins, const vec3_t maxs, const vec3_t orig
|
||||
VectorCopy( tmp, p[i] );
|
||||
}
|
||||
|
||||
for( i = 0; i < 6; i++ )
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
PM_DrawRectangle( p[boxpnt[i][1]], p[boxpnt[i][0]], p[boxpnt[i][2]], p[boxpnt[i][3]], pcolor, life );
|
||||
}
|
||||
@@ -1704,9 +1655,7 @@ R_ParticleLine
|
||||
*/
|
||||
void GAME_EXPORT R_ParticleLine( const vec3_t start, const vec3_t end, byte r, byte g, byte b, float life )
|
||||
{
|
||||
int pcolor;
|
||||
|
||||
pcolor = R_LookupColor( r, g, b );
|
||||
int pcolor = R_LookupColor( r, g, b );
|
||||
PM_ParticleLine( start, end, pcolor, life, 0 );
|
||||
}
|
||||
|
||||
@@ -1720,9 +1669,8 @@ void GAME_EXPORT R_ParticleBox( const vec3_t absmin, const vec3_t absmax, byte r
|
||||
{
|
||||
vec3_t mins, maxs;
|
||||
vec3_t origin;
|
||||
int pcolor;
|
||||
|
||||
pcolor = R_LookupColor( r, g, b );
|
||||
int pcolor = R_LookupColor( r, g, b );
|
||||
|
||||
VectorAverage( absmax, absmin, origin );
|
||||
VectorSubtract( absmax, origin, maxs );
|
||||
@@ -1739,20 +1687,18 @@ R_ShowLine
|
||||
*/
|
||||
void GAME_EXPORT R_ShowLine( const vec3_t start, const vec3_t end )
|
||||
{
|
||||
vec3_t dir, org;
|
||||
float len;
|
||||
particle_t *p;
|
||||
vec3_t dir;
|
||||
|
||||
VectorSubtract( end, start, dir );
|
||||
len = VectorNormalizeLength( dir );
|
||||
float len = VectorNormalizeLength( dir );
|
||||
VectorScale( dir, 5.0f, dir );
|
||||
VectorCopy( start, org );
|
||||
vec3_t org = Vec3( start );
|
||||
|
||||
while( len > 0 )
|
||||
{
|
||||
len -= 5.0f;
|
||||
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
p->die = cl.time + 30;
|
||||
@@ -1771,25 +1717,21 @@ R_BulletImpactParticles
|
||||
*/
|
||||
void GAME_EXPORT R_BulletImpactParticles( const vec3_t pos )
|
||||
{
|
||||
int i, quantity;
|
||||
int color;
|
||||
float dist;
|
||||
vec3_t dir;
|
||||
particle_t *p;
|
||||
|
||||
VectorSubtract( pos, refState.vieworg, dir );
|
||||
dist = VectorLength( dir );
|
||||
float dist = VectorLength( dir );
|
||||
if( dist > 1000.0f ) dist = 1000.0f;
|
||||
|
||||
quantity = (1000.0f - dist) / 100.0f;
|
||||
int quantity = (1000.0f - dist) / 100.0f;
|
||||
if( quantity == 0 ) quantity = 1;
|
||||
|
||||
color = 3 - ((30 * quantity) / 100 );
|
||||
int color = 3 - ((30 * quantity) / 100 );
|
||||
R_SparkStreaks( pos, 2, -200, 200 );
|
||||
|
||||
for( i = 0; i < quantity * 4; i++ )
|
||||
for( int i = 0; i < quantity * 4; i++ )
|
||||
{
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
VectorCopy( pos, p->org);
|
||||
@@ -1813,12 +1755,9 @@ R_FlickerParticles
|
||||
*/
|
||||
void GAME_EXPORT R_FlickerParticles( const vec3_t org )
|
||||
{
|
||||
particle_t *p;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 15; i++ )
|
||||
for( int i = 0; i < 15; i++ )
|
||||
{
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
VectorCopy( org, p->org );
|
||||
@@ -1842,15 +1781,13 @@ create a splash of streaks
|
||||
void GAME_EXPORT R_StreakSplash( const vec3_t pos, const vec3_t dir, int color, int count, float speed, int velocityMin, int velocityMax )
|
||||
{
|
||||
vec3_t vel, vel2;
|
||||
particle_t *p;
|
||||
int i;
|
||||
|
||||
VectorScale( dir, speed, vel );
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
VectorAddScalar( vel, COM_RandomFloat( velocityMin, velocityMax ), vel2 );
|
||||
p = R_AllocTracer( pos, vel2, COM_RandomFloat( 0.1f, 0.5f ));
|
||||
particle_t *p = R_AllocTracer( pos, vel2, COM_RandomFloat( 0.1f, 0.5f ));
|
||||
if( !p ) return;
|
||||
|
||||
p->type = pt_grav;
|
||||
@@ -1868,9 +1805,7 @@ pmove debugging particle
|
||||
*/
|
||||
void CL_Particle( const vec3_t org, int color, float life, int zpos, int zvel )
|
||||
{
|
||||
particle_t *p;
|
||||
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
if( org ) VectorCopy( org, p->org );
|
||||
@@ -1888,17 +1823,15 @@ R_TracerEffect
|
||||
void GAME_EXPORT R_TracerEffect( const vec3_t start, const vec3_t end )
|
||||
{
|
||||
vec3_t pos, vel, dir;
|
||||
float len, speed;
|
||||
float offset;
|
||||
|
||||
speed = Q_max( tracerspeed.value, 3.0f );
|
||||
float speed = Q_max( tracerspeed.value, 3.0f );
|
||||
|
||||
VectorSubtract( end, start, dir );
|
||||
len = VectorLength( dir );
|
||||
float len = VectorLength( dir );
|
||||
if( len == 0.0f ) return;
|
||||
|
||||
VectorScale( dir, 1.0f / len, dir ); // normalize
|
||||
offset = COM_RandomFloat( -10.0f, 9.0f ) + traceroffset.value;
|
||||
float offset = COM_RandomFloat( -10.0f, 9.0f ) + traceroffset.value;
|
||||
VectorScale( dir, offset, vel );
|
||||
VectorAdd( start, vel, pos );
|
||||
VectorScale( dir, speed, vel );
|
||||
@@ -1949,17 +1882,15 @@ create a streak tracers
|
||||
*/
|
||||
void GAME_EXPORT R_SparkStreaks( const vec3_t pos, int count, int velocityMin, int velocityMax )
|
||||
{
|
||||
particle_t *p;
|
||||
vec3_t vel;
|
||||
int i;
|
||||
|
||||
for( i = 0; i<count; i++ )
|
||||
for( int i = 0; i<count; i++ )
|
||||
{
|
||||
vel[0] = COM_RandomFloat( velocityMin, velocityMax );
|
||||
vel[1] = COM_RandomFloat( velocityMin, velocityMax );
|
||||
vel[2] = COM_RandomFloat( velocityMin, velocityMax );
|
||||
|
||||
p = R_AllocTracer( pos, vel, COM_RandomFloat( 0.1f, 0.5f ));
|
||||
particle_t *p = R_AllocTracer( pos, vel, COM_RandomFloat( 0.1f, 0.5f ));
|
||||
if( !p ) return;
|
||||
|
||||
p->color = 5;
|
||||
@@ -1979,14 +1910,11 @@ void GAME_EXPORT R_Implosion( const vec3_t end, float radius, int count, float l
|
||||
{
|
||||
float dist = ( radius / 100.0f );
|
||||
vec3_t start, temp, vel;
|
||||
float factor;
|
||||
particle_t *p;
|
||||
int i;
|
||||
|
||||
if( life <= 0.0f ) life = 0.1f; // to avoid divide by zero
|
||||
factor = -1.0 / life;
|
||||
float factor = -1.0 / life;
|
||||
|
||||
for ( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
temp[0] = dist * COM_RandomFloat( -100.0f, 100.0f );
|
||||
temp[1] = dist * COM_RandomFloat( -100.0f, 100.0f );
|
||||
@@ -1994,7 +1922,8 @@ void GAME_EXPORT R_Implosion( const vec3_t end, float radius, int count, float l
|
||||
VectorScale( temp, factor, vel );
|
||||
VectorAdd( temp, end, start );
|
||||
|
||||
if(( p = R_AllocTracer( start, vel, life )) == NULL )
|
||||
particle_t *p = R_AllocTracer( start, vel, life );
|
||||
if( p == NULL )
|
||||
return;
|
||||
|
||||
p->type = pt_explode;
|
||||
@@ -2059,16 +1988,12 @@ CL_ReadPointFile_f
|
||||
*/
|
||||
void CL_ReadPointFile_f( void )
|
||||
{
|
||||
byte *afile;
|
||||
char *pfile;
|
||||
vec3_t org;
|
||||
int count;
|
||||
particle_t *p;
|
||||
char filename[64];
|
||||
string token;
|
||||
|
||||
Q_snprintf( filename, sizeof( filename ), "maps/%s.pts", clgame.mapname );
|
||||
afile = FS_LoadFile( filename, NULL, false );
|
||||
byte *afile = FS_LoadFile( filename, NULL, false );
|
||||
|
||||
if( !afile )
|
||||
{
|
||||
@@ -2078,8 +2003,8 @@ void CL_ReadPointFile_f( void )
|
||||
|
||||
Con_Printf( "Reading %s...\n", filename );
|
||||
|
||||
count = 0;
|
||||
pfile = (char *)afile;
|
||||
int count = 0;
|
||||
char *pfile = (char *)afile;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
@@ -2105,7 +2030,7 @@ void CL_ReadPointFile_f( void )
|
||||
|
||||
// NOTE: can't use R_AllocParticle because this command
|
||||
// may be executed from the console, while frametime is 0
|
||||
p = cl_free_particles;
|
||||
particle_t *p = cl_free_particles;
|
||||
cl_free_particles = p->next;
|
||||
p->next = cl_active_particles;
|
||||
cl_active_particles = p;
|
||||
|
||||
@@ -42,10 +42,6 @@ compute velocity for a given client
|
||||
*/
|
||||
static void CL_CalcPlayerVelocity( int idx, vec3_t velocity )
|
||||
{
|
||||
clientdata_t *pcd;
|
||||
vec3_t delta;
|
||||
double dt;
|
||||
|
||||
VectorClear( velocity );
|
||||
|
||||
if( idx <= 0 || idx > cl.maxclients )
|
||||
@@ -53,15 +49,16 @@ static void CL_CalcPlayerVelocity( int idx, vec3_t velocity )
|
||||
|
||||
if( idx == cl.playernum + 1 )
|
||||
{
|
||||
pcd = &cl.frames[cl.parsecountmod].clientdata;
|
||||
clientdata_t *pcd = &cl.frames[cl.parsecountmod].clientdata;
|
||||
VectorCopy( pcd->velocity, velocity );
|
||||
}
|
||||
else
|
||||
{
|
||||
dt = clgame.entities[idx].curstate.animtime - clgame.entities[idx].prevstate.animtime;
|
||||
double dt = clgame.entities[idx].curstate.animtime - clgame.entities[idx].prevstate.animtime;
|
||||
|
||||
if( dt != 0.0 )
|
||||
{
|
||||
vec3_t delta;
|
||||
VectorSubtract( clgame.entities[idx].curstate.velocity, clgame.entities[idx].prevstate.velocity, delta );
|
||||
VectorScale( delta, 1.0f / dt, velocity );
|
||||
}
|
||||
@@ -130,16 +127,13 @@ CL_SetEventIndex
|
||||
*/
|
||||
void CL_SetEventIndex( const char *szEvName, int ev_index )
|
||||
{
|
||||
cl_user_event_t *ev;
|
||||
int i;
|
||||
|
||||
if( !szEvName || !*szEvName )
|
||||
return; // ignore blank names
|
||||
|
||||
// search event by name to link with
|
||||
for( i = 0; i < MAX_EVENTS; i++ )
|
||||
for( int i = 0; i < MAX_EVENTS; i++ )
|
||||
{
|
||||
ev = clgame.events[i];
|
||||
cl_user_event_t *ev = clgame.events[i];
|
||||
if( !ev ) break;
|
||||
|
||||
if( !Q_stricmp( ev->name, szEvName ))
|
||||
@@ -158,12 +152,10 @@ CL_EventIndex
|
||||
*/
|
||||
word CL_EventIndex( const char *name )
|
||||
{
|
||||
word i;
|
||||
|
||||
if( COM_StringEmptyOrNULL( name ))
|
||||
return 0;
|
||||
|
||||
for( i = 1; i < MAX_EVENTS && cl.event_precache[i][0]; i++ )
|
||||
for( word i = 1; i < MAX_EVENTS && cl.event_precache[i][0]; i++ )
|
||||
{
|
||||
if( !Q_stricmp( cl.event_precache[i], name ))
|
||||
return i;
|
||||
@@ -204,28 +196,24 @@ CL_FireEvent
|
||||
*/
|
||||
static qboolean CL_FireEvent( event_info_t *ei, int slot )
|
||||
{
|
||||
cl_user_event_t *ev;
|
||||
const char *name;
|
||||
int i, idx;
|
||||
|
||||
if( !ei || !ei->index )
|
||||
return false;
|
||||
|
||||
// get the func pointer
|
||||
for( i = 0; i < MAX_EVENTS; i++ )
|
||||
for( int i = 0; i < MAX_EVENTS; i++ )
|
||||
{
|
||||
ev = clgame.events[i];
|
||||
cl_user_event_t *ev = clgame.events[i];
|
||||
|
||||
if( !ev )
|
||||
{
|
||||
idx = bound( 1, ei->index, ( MAX_EVENTS - 1 ));
|
||||
int idx = bound( 1, ei->index, ( MAX_EVENTS - 1 ));
|
||||
Con_Reportf( S_ERROR "%s: %s not precached\n", __func__, cl.event_precache[idx] );
|
||||
break;
|
||||
}
|
||||
|
||||
if( ev->index == ei->index )
|
||||
{
|
||||
name = cl.event_precache[ei->index];
|
||||
const char *name = cl.event_precache[ei->index];
|
||||
|
||||
if( cl_trace_events.value )
|
||||
{
|
||||
@@ -261,15 +249,11 @@ called right before draw frame
|
||||
*/
|
||||
void CL_FireEvents( void )
|
||||
{
|
||||
event_state_t *es;
|
||||
event_info_t *ei;
|
||||
int i;
|
||||
event_state_t *es = &cl.events;
|
||||
|
||||
es = &cl.events;
|
||||
|
||||
for( i = 0; i < MAX_EVENT_QUEUE; i++ )
|
||||
for( int i = 0; i < MAX_EVENT_QUEUE; i++ )
|
||||
{
|
||||
ei = &es->ei[i];
|
||||
event_info_t *ei = &es->ei[i];
|
||||
|
||||
if( ei->index == 0 )
|
||||
continue;
|
||||
@@ -294,16 +278,12 @@ find first empty event
|
||||
*/
|
||||
static event_info_t *CL_FindEmptyEvent( void )
|
||||
{
|
||||
int i;
|
||||
event_state_t *es;
|
||||
event_info_t *ei;
|
||||
|
||||
es = &cl.events;
|
||||
event_state_t *es = &cl.events;
|
||||
|
||||
// look for first slot where index is != 0
|
||||
for( i = 0; i < MAX_EVENT_QUEUE; i++ )
|
||||
for( int i = 0; i < MAX_EVENT_QUEUE; i++ )
|
||||
{
|
||||
ei = &es->ei[i];
|
||||
event_info_t *ei = &es->ei[i];
|
||||
if( ei->index != 0 )
|
||||
continue;
|
||||
return ei;
|
||||
@@ -322,15 +302,11 @@ replace only unreliable events
|
||||
*/
|
||||
static event_info_t *CL_FindUnreliableEvent( void )
|
||||
{
|
||||
event_state_t *es;
|
||||
event_info_t *ei;
|
||||
int i;
|
||||
event_state_t *es = &cl.events;
|
||||
|
||||
es = &cl.events;
|
||||
|
||||
for ( i = 0; i < MAX_EVENT_QUEUE; i++ )
|
||||
for ( int i = 0; i < MAX_EVENT_QUEUE; i++ )
|
||||
{
|
||||
ei = &es->ei[i];
|
||||
event_info_t *ei = &es->ei[i];
|
||||
if( ei->index != 0 )
|
||||
{
|
||||
// it's reliable, so skip it
|
||||
@@ -423,16 +399,10 @@ CL_ParseEvent
|
||||
*/
|
||||
void CL_ParseEvent( sizebuf_t *msg, connprotocol_t proto )
|
||||
{
|
||||
int event_index;
|
||||
int i, num_events;
|
||||
int packet_index;
|
||||
const event_args_t nullargs = { 0 };
|
||||
event_args_t args = { 0 };
|
||||
entity_state_t *state;
|
||||
float delay;
|
||||
int entity_bits;
|
||||
|
||||
num_events = MSG_ReadUBitLong( msg, 5 );
|
||||
int num_events = MSG_ReadUBitLong( msg, 5 );
|
||||
|
||||
if( proto == PROTO_GOLDSRC )
|
||||
entity_bits = MAX_GOLDSRC_ENTITY_BITS;
|
||||
@@ -440,9 +410,11 @@ void CL_ParseEvent( sizebuf_t *msg, connprotocol_t proto )
|
||||
entity_bits = MAX_ENTITY_BITS;
|
||||
|
||||
// parse events queue
|
||||
for( i = 0 ; i < num_events; i++ )
|
||||
for( int i = 0 ; i < num_events; i++ )
|
||||
{
|
||||
event_index = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
|
||||
int packet_index;
|
||||
float delay;
|
||||
int event_index = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
|
||||
|
||||
if( MSG_ReadOneBit( msg ))
|
||||
{
|
||||
@@ -467,7 +439,7 @@ void CL_ParseEvent( sizebuf_t *msg, connprotocol_t proto )
|
||||
|
||||
if( packet_index < frame->num_entities )
|
||||
{
|
||||
state = &cls.packet_entities[(frame->first_entity+packet_index)%cls.num_client_entities];
|
||||
entity_state_t *state = &cls.packet_entities[(frame->first_entity+packet_index)%cls.num_client_entities];
|
||||
args.entindex = state->number;
|
||||
|
||||
if( VectorIsNull( args.origin ))
|
||||
@@ -515,8 +487,6 @@ CL_PlaybackEvent
|
||||
void GAME_EXPORT CL_PlaybackEvent( int flags, const edict_t *pInvoker, word eventindex, float delay, float *origin,
|
||||
float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 )
|
||||
{
|
||||
event_args_t args;
|
||||
|
||||
if( FBitSet( flags, FEV_SERVER ))
|
||||
return;
|
||||
|
||||
@@ -538,20 +508,20 @@ void GAME_EXPORT CL_PlaybackEvent( int flags, const edict_t *pInvoker, word even
|
||||
ClearBits( flags, FEV_NOTHOST|FEV_HOSTONLY|FEV_GLOBAL );
|
||||
if( delay < 0.0f ) delay = 0.0f; // fixup negative delays
|
||||
|
||||
memset( &args, 0, sizeof( args ));
|
||||
|
||||
VectorCopy( origin, args.origin );
|
||||
VectorCopy( angles, args.angles );
|
||||
VectorCopy( cl.simvel, args.velocity );
|
||||
args.entindex = cl.playernum + 1;
|
||||
args.ducking = ( cl.local.usehull == 1 );
|
||||
|
||||
args.fparam1 = fparam1;
|
||||
args.fparam2 = fparam2;
|
||||
args.iparam1 = iparam1;
|
||||
args.iparam2 = iparam2;
|
||||
args.bparam1 = bparam1;
|
||||
args.bparam2 = bparam2;
|
||||
event_args_t args =
|
||||
{
|
||||
.origin = Vec3( origin ),
|
||||
.angles = Vec3( angles ),
|
||||
.velocity = Vec3( cl.simvel ),
|
||||
.entindex = cl.playernum + 1,
|
||||
.ducking = ( cl.local.usehull == 1 ),
|
||||
.fparam1 = fparam1,
|
||||
.fparam2 = fparam2,
|
||||
.iparam1 = iparam1,
|
||||
.iparam2 = iparam2,
|
||||
.bparam1 = bparam1,
|
||||
.bparam2 = bparam2,
|
||||
};
|
||||
|
||||
CL_QueueEvent( flags, eventindex, delay, &args );
|
||||
}
|
||||
|
||||
@@ -39,17 +39,14 @@ qboolean CL_FixedFont( cl_font_t *font )
|
||||
|
||||
static int CL_LoadFontTexture( const char *fontname, uint texFlags, int *width )
|
||||
{
|
||||
int font_width;
|
||||
int tex;
|
||||
|
||||
if( !g_fsapi.FileExists( fontname, false ))
|
||||
return 0;
|
||||
|
||||
tex = ref.dllFuncs.GL_LoadTexture( fontname, NULL, 0, texFlags );
|
||||
int tex = ref.dllFuncs.GL_LoadTexture( fontname, NULL, 0, texFlags );
|
||||
if( !tex )
|
||||
return 0;
|
||||
|
||||
font_width = REF_GET_PARM( PARM_TEX_WIDTH, tex );
|
||||
int font_width = REF_GET_PARM( PARM_TEX_WIDTH, tex );
|
||||
if( !font_width )
|
||||
{
|
||||
ref.dllFuncs.GL_FreeTexture( tex );
|
||||
@@ -89,7 +86,7 @@ void CL_SetFontColor( cl_font_t *font, const rgba_t color )
|
||||
|
||||
qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags )
|
||||
{
|
||||
int font_width, i;
|
||||
int font_width;
|
||||
|
||||
if( !rendermode )
|
||||
return false;
|
||||
@@ -107,7 +104,7 @@ qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float sc
|
||||
font->rendermode = rendermode;
|
||||
font->charHeight = Q_rint( font_width / 16 * scale );
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( font->fontRc ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( font->fontRc ); i++ )
|
||||
{
|
||||
font->fontRc[i].left = ( i * font_width / 16 ) % font_width;
|
||||
font->fontRc[i].right = font->fontRc[i].left + font_width / 16;
|
||||
@@ -124,8 +121,7 @@ qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float
|
||||
{
|
||||
fs_offset_t length;
|
||||
qfont_t src;
|
||||
byte *pfile;
|
||||
int font_width, i;
|
||||
int font_width;
|
||||
|
||||
if( !rendermode )
|
||||
return false;
|
||||
@@ -133,7 +129,7 @@ qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float
|
||||
if( font->valid )
|
||||
return true;
|
||||
|
||||
pfile = g_fsapi.LoadFile( fontname, &length, false );
|
||||
byte *pfile = g_fsapi.LoadFile( fontname, &length, false );
|
||||
if( !pfile )
|
||||
return false;
|
||||
|
||||
@@ -157,7 +153,7 @@ qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float
|
||||
font->rendermode = rendermode;
|
||||
font->charHeight = Q_rint( src.rowheight * scale );
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( font->fontRc ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( font->fontRc ); i++ )
|
||||
{
|
||||
const charinfo *ci = &src.fontinfo[i];
|
||||
|
||||
@@ -195,11 +191,6 @@ static int CL_CalcTabStop( const cl_font_t *font, int x )
|
||||
|
||||
int CL_DrawCharacter( float x, float y, int number, const rgba_t color, cl_font_t *font, int flags )
|
||||
{
|
||||
wrect_t *rc;
|
||||
float w, h;
|
||||
float s1, t1, s2, t2, half = 0.5f;
|
||||
int texw, texh;
|
||||
|
||||
if( !font || !font->valid || y < -font->charHeight )
|
||||
return 0;
|
||||
|
||||
@@ -220,21 +211,23 @@ int CL_DrawCharacter( float x, float y, int number, const rgba_t color, cl_font_
|
||||
if( !number || !font->charWidths[number])
|
||||
return 0;
|
||||
|
||||
int texw, texh;
|
||||
R_GetTextureParms( &texw, &texh, font->hFontTexture );
|
||||
if( !texw || !texh )
|
||||
return font->charWidths[number];
|
||||
|
||||
rc = &font->fontRc[number];
|
||||
wrect_t *rc = &font->fontRc[number];
|
||||
float half = 0.5f;
|
||||
|
||||
if( font->scale <= 1.f || !REF_GET_PARM( PARM_TEX_FILTERING, font->hFontTexture ))
|
||||
half = 0;
|
||||
|
||||
s1 = ((float)rc->left + half ) / texw;
|
||||
t1 = ((float)rc->top + half ) / texh;
|
||||
s2 = ((float)rc->right - half ) / texw;
|
||||
t2 = ((float)rc->bottom - half ) / texh;
|
||||
w = ( rc->right - rc->left ) * font->scale;
|
||||
h = ( rc->bottom - rc->top ) * font->scale;
|
||||
float s1 = ((float)rc->left + half ) / texw;
|
||||
float t1 = ((float)rc->top + half ) / texh;
|
||||
float s2 = ((float)rc->right - half ) / texw;
|
||||
float t2 = ((float)rc->bottom - half ) / texh;
|
||||
float w = ( rc->right - rc->left ) * font->scale;
|
||||
float h = ( rc->bottom - rc->top ) * font->scale;
|
||||
|
||||
if( FBitSet( flags, FONT_DRAW_HUD ))
|
||||
SPR_AdjustSize( &x, &y, &w, &h );
|
||||
|
||||
@@ -41,12 +41,10 @@ Store another position into interpolation circular buffer
|
||||
*/
|
||||
static void CL_UpdatePositions( cl_entity_t *ent )
|
||||
{
|
||||
position_history_t *ph, *prev;
|
||||
|
||||
prev = &ent->ph[ent->current_position & HISTORY_MASK];
|
||||
position_history_t *prev = &ent->ph[ent->current_position & HISTORY_MASK];
|
||||
|
||||
ent->current_position = (ent->current_position + 1) & HISTORY_MASK;
|
||||
ph = &ent->ph[ent->current_position];
|
||||
position_history_t *ph = &ent->ph[ent->current_position];
|
||||
VectorCopy( ent->curstate.origin, ph->origin );
|
||||
VectorCopy( ent->curstate.angles, ph->angles );
|
||||
|
||||
@@ -94,14 +92,13 @@ we don't want interpolate this
|
||||
*/
|
||||
static qboolean CL_EntityTeleported( cl_entity_t *ent )
|
||||
{
|
||||
float len, maxlen;
|
||||
vec3_t delta;
|
||||
|
||||
VectorSubtract( ent->curstate.origin, ent->prevstate.origin, delta );
|
||||
|
||||
// compute potential max movement in units per frame and compare with entity movement
|
||||
maxlen = ( clgame.movevars.maxvelocity * ( 1.0f / GAME_FPS ));
|
||||
len = VectorLength( delta );
|
||||
float maxlen = ( clgame.movevars.maxvelocity * ( 1.0f / GAME_FPS ));
|
||||
float len = VectorLength( delta );
|
||||
|
||||
return (len > maxlen);
|
||||
}
|
||||
@@ -169,22 +166,23 @@ check for parametrical moved entities
|
||||
*/
|
||||
static qboolean CL_ParametricMove( cl_entity_t *ent )
|
||||
{
|
||||
float frac, dt, t;
|
||||
vec3_t delta;
|
||||
|
||||
if( ent->curstate.starttime == 0.0f || ent->curstate.impacttime == 0.0f )
|
||||
return false;
|
||||
|
||||
VectorSubtract( ent->curstate.endpos, ent->curstate.startpos, delta );
|
||||
dt = ent->curstate.impacttime - ent->curstate.starttime;
|
||||
float dt = ent->curstate.impacttime - ent->curstate.starttime;
|
||||
|
||||
if( dt != 0.0f )
|
||||
{
|
||||
float t;
|
||||
|
||||
if( ent->lastmove > cl.time )
|
||||
t = ent->lastmove;
|
||||
else t = cl.time;
|
||||
|
||||
frac = ( t - ent->curstate.starttime ) / dt;
|
||||
float frac = ( t - ent->curstate.starttime ) / dt;
|
||||
frac = bound( 0.0f, frac, 1.0f );
|
||||
VectorMA( ent->curstate.startpos, frac, delta, ent->curstate.origin );
|
||||
|
||||
@@ -239,18 +237,14 @@ CL_GetStudioEstimatedFrame
|
||||
*/
|
||||
static float CL_GetStudioEstimatedFrame( cl_entity_t *ent )
|
||||
{
|
||||
studiohdr_t *pstudiohdr;
|
||||
mstudioseqdesc_t *pseqdesc;
|
||||
int sequence;
|
||||
|
||||
if( ent->model != NULL && ent->model->type == mod_studio )
|
||||
{
|
||||
pstudiohdr = (studiohdr_t *)Mod_StudioExtradata( ent->model );
|
||||
studiohdr_t *pstudiohdr = (studiohdr_t *)Mod_StudioExtradata( ent->model );
|
||||
|
||||
if( pstudiohdr && pstudiohdr->numseq > 0 )
|
||||
{
|
||||
sequence = bound( 0, ent->curstate.sequence, pstudiohdr->numseq - 1 );
|
||||
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + sequence;
|
||||
int sequence = bound( 0, ent->curstate.sequence, pstudiohdr->numseq - 1 );
|
||||
mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + sequence;
|
||||
return ref.dllFuncs.R_StudioEstimateFrame( ent, pseqdesc, cl.time );
|
||||
}
|
||||
}
|
||||
@@ -301,8 +295,6 @@ apply changes since new frame received
|
||||
*/
|
||||
static void CL_ProcessEntityUpdate( cl_entity_t *ent )
|
||||
{
|
||||
qboolean parametric;
|
||||
|
||||
ent->model = CL_ModelHandle( ent->curstate.modelindex );
|
||||
ent->index = ent->curstate.number;
|
||||
|
||||
@@ -324,7 +316,7 @@ static void CL_ProcessEntityUpdate( cl_entity_t *ent )
|
||||
VectorCopy( aiment->origin, ent->curstate.origin );
|
||||
}
|
||||
|
||||
parametric = ent->curstate.starttime != 0.0f && ent->curstate.impacttime != 0.0f;
|
||||
qboolean parametric = ent->curstate.starttime != 0.0f && ent->curstate.impacttime != 0.0f;
|
||||
|
||||
// allow interpolation on bmodels too
|
||||
if( ent->model && ent->model->type == mod_brush )
|
||||
@@ -363,13 +355,11 @@ find two timestamps
|
||||
static qboolean CL_FindInterpolationUpdates( cl_entity_t *ent, double targettime, position_history_t **ph0, position_history_t **ph1 )
|
||||
{
|
||||
qboolean extrapolate = true;
|
||||
uint i, i0, i1, imod;
|
||||
uint imod = ent->current_position;
|
||||
uint i0 = (imod - 0) & HISTORY_MASK; // curpos (lerp end)
|
||||
uint i1 = (imod - 1) & HISTORY_MASK; // oldpos (lerp start)
|
||||
|
||||
imod = ent->current_position;
|
||||
i0 = (imod - 0) & HISTORY_MASK; // curpos (lerp end)
|
||||
i1 = (imod - 1) & HISTORY_MASK; // oldpos (lerp start)
|
||||
|
||||
for( i = 1; i < HISTORY_MAX - 1; i++ )
|
||||
for( uint i = 1; i < HISTORY_MAX - 1; i++ )
|
||||
{
|
||||
double at = ent->ph[( imod - i ) & HISTORY_MASK].animtime;
|
||||
|
||||
@@ -401,19 +391,19 @@ non-local players interpolation
|
||||
*/
|
||||
static void CL_PureOrigin( cl_entity_t *ent, double t, vec3_t outorigin, vec3_t outangles )
|
||||
{
|
||||
double t1, t0, frac;
|
||||
position_history_t *ph0, *ph1;
|
||||
vec3_t delta;
|
||||
|
||||
// NOTE: ph0 is next, ph1 is a prev
|
||||
CL_FindInterpolationUpdates( ent, t, &ph0, &ph1 );
|
||||
|
||||
t0 = ph0->animtime;
|
||||
t1 = ph1->animtime;
|
||||
double t0 = ph0->animtime;
|
||||
double t1 = ph1->animtime;
|
||||
|
||||
if( t0 != 0.0 )
|
||||
{
|
||||
vec4_t q, q1, q2;
|
||||
vec3_t delta;
|
||||
double frac;
|
||||
|
||||
VectorSubtract( ph0->origin, ph1->origin, delta );
|
||||
|
||||
@@ -449,7 +439,6 @@ static int CL_InterpolateModel( cl_entity_t *e )
|
||||
{
|
||||
position_history_t *ph0 = NULL, *ph1 = NULL;
|
||||
vec3_t origin, angles, delta;
|
||||
double t, t1, t2, frac;
|
||||
vec4_t q, q1, q2;
|
||||
|
||||
VectorCopy( e->curstate.origin, e->origin );
|
||||
@@ -478,11 +467,11 @@ static int CL_InterpolateModel( cl_entity_t *e )
|
||||
if( cl.local.moving && cl.local.onground == e->index )
|
||||
return 1;
|
||||
|
||||
t = cl.time - cl_interp.value;
|
||||
double t = cl.time - cl_interp.value;
|
||||
CL_FindInterpolationUpdates( e, t, &ph0, &ph1 );
|
||||
|
||||
t1 = ph1->animtime;
|
||||
t2 = ph0->animtime;
|
||||
double t1 = ph1->animtime;
|
||||
double t2 = ph0->animtime;
|
||||
|
||||
if( t - t1 < 0.0f )
|
||||
return 0;
|
||||
@@ -502,7 +491,7 @@ static int CL_InterpolateModel( cl_entity_t *e )
|
||||
}
|
||||
|
||||
VectorSubtract( ph0->origin, ph1->origin, delta );
|
||||
frac = (t - t1) / (t2 - t1);
|
||||
double frac = (t - t1) / (t2 - t1);
|
||||
|
||||
if( frac < 0.0f )
|
||||
return 0;
|
||||
@@ -532,8 +521,6 @@ interpolate non-local clients
|
||||
*/
|
||||
void CL_ComputePlayerOrigin( cl_entity_t *ent )
|
||||
{
|
||||
double targettime;
|
||||
vec4_t q, q1, q2;
|
||||
vec3_t origin;
|
||||
vec3_t angles;
|
||||
|
||||
@@ -549,6 +536,8 @@ void CL_ComputePlayerOrigin( cl_entity_t *ent )
|
||||
|
||||
if( cls.demoplayback == DEMO_QUAKE1 )
|
||||
{
|
||||
vec4_t q, q1, q2;
|
||||
|
||||
// quake lerping is easy
|
||||
VectorLerp( ent->prevstate.origin, cl.lerpFrac, ent->curstate.origin, ent->origin );
|
||||
AngleQuaternion( ent->prevstate.angles, q1, false );
|
||||
@@ -558,7 +547,7 @@ void CL_ComputePlayerOrigin( cl_entity_t *ent )
|
||||
return;
|
||||
}
|
||||
|
||||
targettime = cl.time - cl_interp.value;
|
||||
double targettime = cl.time - cl_interp.value;
|
||||
CL_PureOrigin( ent, targettime, origin, angles );
|
||||
|
||||
VectorCopy( angles, ent->angles );
|
||||
@@ -574,9 +563,7 @@ process player states after the new packet has received
|
||||
*/
|
||||
static void CL_ProcessPlayerState( int playerindex, entity_state_t *state )
|
||||
{
|
||||
entity_state_t *ps;
|
||||
|
||||
ps = &cl.frames[cl.parsecountmod].playerstate[playerindex];
|
||||
entity_state_t *ps = &cl.frames[cl.parsecountmod].playerstate[playerindex];
|
||||
ps->number = state->number;
|
||||
ps->messagenum = cl.parsecount;
|
||||
ps->msg_time = cl.mtime[0];
|
||||
@@ -617,19 +604,15 @@ process player states after the new packet has received
|
||||
*/
|
||||
void CL_ProcessPacket( frame_t *frame )
|
||||
{
|
||||
entity_state_t *state;
|
||||
cl_entity_t *ent;
|
||||
int pnum;
|
||||
|
||||
for( pnum = 0; pnum < frame->num_entities; pnum++ )
|
||||
for( int pnum = 0; pnum < frame->num_entities; pnum++ )
|
||||
{
|
||||
// request the entity state from circular buffer
|
||||
state = &cls.packet_entities[(frame->first_entity+pnum) % cls.num_client_entities];
|
||||
entity_state_t *state = &cls.packet_entities[(frame->first_entity+pnum) % cls.num_client_entities];
|
||||
state->messagenum = cl.parsecount;
|
||||
state->msg_time = cl.mtime[0];
|
||||
|
||||
// mark all the players
|
||||
ent = &clgame.entities[state->number];
|
||||
cl_entity_t *ent = &clgame.entities[state->number];
|
||||
ent->player = CL_IsPlayerIndex( state->number );
|
||||
|
||||
if( state->number == ( cl.playernum + 1 ))
|
||||
@@ -675,7 +658,6 @@ Read and ignore whole entity packet.
|
||||
*/
|
||||
static void CL_FlushEntityPacket( sizebuf_t *msg, connprotocol_t proto )
|
||||
{
|
||||
int newnum;
|
||||
entity_state_t from, to;
|
||||
|
||||
memset( &from, 0, sizeof( from ));
|
||||
@@ -686,6 +668,8 @@ static void CL_FlushEntityPacket( sizebuf_t *msg, connprotocol_t proto )
|
||||
// read it all, but ignore it
|
||||
while( 1 )
|
||||
{
|
||||
int newnum;
|
||||
|
||||
if( !CL_ParseEntityNumFromPacket( msg, &newnum, proto ))
|
||||
break; // done
|
||||
|
||||
@@ -815,22 +799,19 @@ rest of the data stream.
|
||||
*/
|
||||
int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta, connprotocol_t proto )
|
||||
{
|
||||
frame_t *newframe, *oldframe;
|
||||
frame_t *oldframe;
|
||||
int oldindex, newnum, oldnum;
|
||||
int playerbytes = 0;
|
||||
int bufStart;
|
||||
entity_state_t *oldent;
|
||||
qboolean player;
|
||||
int count;
|
||||
|
||||
// save first uncompressed packet as timestamp
|
||||
if( cls.changelevel && !delta && cls.demorecording )
|
||||
CL_WriteDemoJumpTime();
|
||||
|
||||
// sentinel count. save it for debug checking
|
||||
count = MSG_ReadUBitLong( msg, MAX_VISIBLE_PACKET_BITS ) + 1;
|
||||
int count = MSG_ReadUBitLong( msg, MAX_VISIBLE_PACKET_BITS ) + 1;
|
||||
|
||||
newframe = &cl.frames[cl.parsecountmod];
|
||||
frame_t *newframe = &cl.frames[cl.parsecountmod];
|
||||
|
||||
// allocate parse entities
|
||||
memset( newframe->flags, 0, sizeof( newframe->flags ));
|
||||
@@ -871,7 +852,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta, connprotocol_t proto
|
||||
if( MSG_CheckOverflow( msg ))
|
||||
Host_Error( "%s: overflow\n", __func__ );
|
||||
|
||||
player = CL_IsPlayerIndex( newnum );
|
||||
qboolean player = CL_IsPlayerIndex( newnum );
|
||||
|
||||
while( oldnum < newnum )
|
||||
{
|
||||
@@ -883,7 +864,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta, connprotocol_t proto
|
||||
if( oldnum == newnum )
|
||||
{
|
||||
// delta from previous state
|
||||
bufStart = MSG_GetNumBytesRead( msg );
|
||||
int bufStart = MSG_GetNumBytesRead( msg );
|
||||
CL_DeltaEntity( msg, newframe, newnum, oldent, true );
|
||||
if( player ) playerbytes += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||
oldnum = CL_UpdateOldEntNum( ++oldindex, oldframe, &oldent );
|
||||
@@ -893,7 +874,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta, connprotocol_t proto
|
||||
if( oldnum > newnum )
|
||||
{
|
||||
// delta from baseline ?
|
||||
bufStart = MSG_GetNumBytesRead( msg );
|
||||
int bufStart = MSG_GetNumBytesRead( msg );
|
||||
CL_DeltaEntity( msg, newframe, newnum, NULL, true );
|
||||
if( player ) playerbytes += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||
continue;
|
||||
@@ -1029,12 +1010,10 @@ for all current players
|
||||
*/
|
||||
static void CL_LinkPlayers( frame_t *frame )
|
||||
{
|
||||
cl_entity_t *ent = CL_GetLocalPlayer();
|
||||
entity_state_t *state;
|
||||
cl_entity_t *ent;
|
||||
int i;
|
||||
|
||||
ent = CL_GetLocalPlayer();
|
||||
|
||||
// apply muzzleflash to weaponmodel
|
||||
if( ent && FBitSet( ent->curstate.effects, EF_MUZZLEFLASH ))
|
||||
SetBits( clgame.viewent.curstate.effects, EF_MUZZLEFLASH );
|
||||
@@ -1112,15 +1091,9 @@ CL_LinkPacketEntities
|
||||
*/
|
||||
static void CL_LinkPacketEntities( frame_t *frame )
|
||||
{
|
||||
cl_entity_t *ent;
|
||||
entity_state_t *state;
|
||||
qboolean parametric;
|
||||
qboolean interpolate;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < frame->num_entities; i++ )
|
||||
for( int i = 0; i < frame->num_entities; i++ )
|
||||
{
|
||||
state = &cls.packet_entities[(frame->first_entity + i) % cls.num_client_entities];
|
||||
entity_state_t *state = &cls.packet_entities[(frame->first_entity + i) % cls.num_client_entities];
|
||||
|
||||
// clients are should be done in CL_LinkPlayers
|
||||
if( state->number >= 1 && state->number <= cl.maxclients )
|
||||
@@ -1130,7 +1103,7 @@ static void CL_LinkPacketEntities( frame_t *frame )
|
||||
if( !state->modelindex || FBitSet( state->effects, EF_NODRAW ))
|
||||
continue;
|
||||
|
||||
ent = CL_GetEntityByIndex( state->number );
|
||||
cl_entity_t *ent = CL_GetEntityByIndex( state->number );
|
||||
|
||||
if( !ent )
|
||||
{
|
||||
@@ -1141,7 +1114,7 @@ static void CL_LinkPacketEntities( frame_t *frame )
|
||||
// animtime must keep an actual
|
||||
ent->curstate.animtime = state->animtime;
|
||||
ent->curstate.frame = state->frame;
|
||||
interpolate = false;
|
||||
qboolean interpolate = false;
|
||||
|
||||
if( !ent->model ) continue;
|
||||
|
||||
@@ -1155,7 +1128,7 @@ static void CL_LinkPacketEntities( frame_t *frame )
|
||||
}
|
||||
}
|
||||
|
||||
parametric = ( ent->curstate.impacttime != 0.0f && ent->curstate.starttime != 0.0f );
|
||||
qboolean parametric = ( ent->curstate.impacttime != 0.0f && ent->curstate.starttime != 0.0f );
|
||||
|
||||
if( !parametric && ent->curstate.movetype != MOVETYPE_COMPOUND )
|
||||
{
|
||||
@@ -1368,9 +1341,6 @@ SOUND ENGINE IMPLEMENTATION
|
||||
*/
|
||||
qboolean CL_GetEntitySpatialization( channel_t *ch )
|
||||
{
|
||||
cl_entity_t *ent;
|
||||
qboolean valid_origin;
|
||||
|
||||
if( ch->entnum == 0 )
|
||||
{
|
||||
SetBits( ch->flags, FL_CHAN_STATIC_SOUND );
|
||||
@@ -1383,8 +1353,8 @@ qboolean CL_GetEntitySpatialization( channel_t *ch )
|
||||
return true;
|
||||
}
|
||||
|
||||
valid_origin = VectorIsNull( ch->origin ) ? false : true;
|
||||
ent = CL_GetEntityByIndex( ch->entnum );
|
||||
qboolean valid_origin = VectorIsNull( ch->origin ) ? false : true;
|
||||
cl_entity_t *ent = CL_GetEntityByIndex( ch->entnum );
|
||||
|
||||
// entity is not present on the client but has valid origin
|
||||
if( !ent || !ent->model || ent->curstate.messagenum != cl.parsecount )
|
||||
|
||||
@@ -315,7 +315,6 @@ should be put at.
|
||||
static float CL_LerpPoint( void )
|
||||
{
|
||||
double f = cl_serverframetime();
|
||||
double frac;
|
||||
|
||||
if( f == 0.0 || cls.timedemo )
|
||||
{
|
||||
@@ -332,7 +331,7 @@ static float CL_LerpPoint( void )
|
||||
if( cl_interp.value <= 0.001 )
|
||||
return 1.0f;
|
||||
|
||||
frac = ( cl.time - cl.mtime[0] ) / cl_interp.value;
|
||||
double frac = ( cl.time - cl.mtime[0] ) / cl_interp.value;
|
||||
|
||||
return frac;
|
||||
}
|
||||
@@ -346,20 +345,17 @@ Drift interpolation value (this is used for server unlag system)
|
||||
*/
|
||||
static int CL_DriftInterpolationAmount( int goal )
|
||||
{
|
||||
float fgoal, maxmove, diff;
|
||||
int msec;
|
||||
|
||||
fgoal = (float)goal / 1000.0f;
|
||||
float fgoal = (float)goal / 1000.0f;
|
||||
|
||||
if( fgoal != cl.local.interp_amount )
|
||||
{
|
||||
maxmove = host.frametime * 0.05;
|
||||
diff = fgoal - cl.local.interp_amount;
|
||||
float maxmove = host.frametime * 0.05;
|
||||
float diff = fgoal - cl.local.interp_amount;
|
||||
diff = bound( -maxmove, diff, maxmove );
|
||||
cl.local.interp_amount += diff;
|
||||
}
|
||||
|
||||
msec = cl.local.interp_amount * 1000.0f;
|
||||
int msec = cl.local.interp_amount * 1000.0f;
|
||||
msec = bound( 0, msec, 100 );
|
||||
|
||||
return msec;
|
||||
@@ -420,14 +416,14 @@ CL_ComputePacketLoss
|
||||
*/
|
||||
static void CL_ComputePacketLoss( void )
|
||||
{
|
||||
int i, lost = 0;
|
||||
int lost = 0;
|
||||
|
||||
if( host.realtime < cls.packet_loss_recalc_time )
|
||||
return;
|
||||
|
||||
cls.packet_loss_recalc_time = host.realtime + 1.0;
|
||||
|
||||
for( i = cls.netchan.incoming_sequence - CL_UPDATE_BACKUP + 1; i <= cls.netchan.incoming_sequence; i++ )
|
||||
for( int i = cls.netchan.incoming_sequence - CL_UPDATE_BACKUP + 1; i <= cls.netchan.incoming_sequence; i++ )
|
||||
{
|
||||
if( cl.frames[i & CL_UPDATE_MASK].receivedtime == -1.0 )
|
||||
lost++;
|
||||
@@ -455,18 +451,15 @@ void CL_UpdateFrameLerp( void )
|
||||
|
||||
static void CL_FindInterpolatedAddAngle( float t, float *frac, pred_viewangle_t **prev, pred_viewangle_t **next )
|
||||
{
|
||||
int i, i0, i1, imod;
|
||||
float at;
|
||||
|
||||
imod = cl.angle_position - 1;
|
||||
i0 = (imod + 1) & ANGLE_MASK;
|
||||
i1 = (imod + 0) & ANGLE_MASK;
|
||||
int imod = cl.angle_position - 1;
|
||||
int i0 = (imod + 1) & ANGLE_MASK;
|
||||
int i1 = (imod + 0) & ANGLE_MASK;
|
||||
|
||||
if( cl.predicted_angle[i0].starttime >= t )
|
||||
{
|
||||
for( i = 0; i < ANGLE_BACKUP - 2; i++ )
|
||||
for( int i = 0; i < ANGLE_BACKUP - 2; i++ )
|
||||
{
|
||||
at = cl.predicted_angle[imod & ANGLE_MASK].starttime;
|
||||
float at = cl.predicted_angle[imod & ANGLE_MASK].starttime;
|
||||
if( at == 0.0f ) break;
|
||||
|
||||
if( at < t )
|
||||
@@ -534,14 +527,12 @@ navigate around texture atlas
|
||||
static qboolean CL_ProcessShowTexturesCmds( usercmd_t *cmd )
|
||||
{
|
||||
static int oldbuttons;
|
||||
int changed;
|
||||
int released;
|
||||
|
||||
if( !r_showtextures.value || CL_IsDevOverviewMode( ))
|
||||
return false;
|
||||
|
||||
changed = (oldbuttons ^ cmd->buttons);
|
||||
released = changed & (~cmd->buttons);
|
||||
int changed = (oldbuttons ^ cmd->buttons);
|
||||
int released = changed & (~cmd->buttons);
|
||||
|
||||
if( released & ( IN_RIGHT|IN_MOVERIGHT ))
|
||||
Cvar_SetValue( "r_showtextures", r_showtextures.value + 1 );
|
||||
@@ -613,17 +604,16 @@ tell the client.dll about player origin, angles, fov, etc
|
||||
*/
|
||||
static void CL_UpdateClientData( void )
|
||||
{
|
||||
client_data_t cdat;
|
||||
|
||||
if( cls.state != ca_active )
|
||||
return;
|
||||
|
||||
memset( &cdat, 0, sizeof( cdat ) );
|
||||
|
||||
VectorCopy( cl.viewangles, cdat.viewangles );
|
||||
VectorCopy( clgame.entities[cl.viewentity].origin, cdat.origin );
|
||||
cdat.iWeaponBits = cl.local.weapons;
|
||||
cdat.fov = cl.local.scr_fov;
|
||||
client_data_t cdat =
|
||||
{
|
||||
.viewangles = Vec3( cl.viewangles ),
|
||||
.origin = Vec3( clgame.entities[cl.viewentity].origin ),
|
||||
.iWeaponBits = cl.local.weapons,
|
||||
.fov = cl.local.scr_fov,
|
||||
};
|
||||
|
||||
if( clgame.dllFuncs.pfnUpdateClientData( &cdat, cl.time ))
|
||||
{
|
||||
@@ -642,21 +632,18 @@ static void CL_CreateCmd( void )
|
||||
{
|
||||
usercmd_t nullcmd = { 0 }, *cmd;
|
||||
runcmd_t *pcmd;
|
||||
qboolean active;
|
||||
double accurate_ms;
|
||||
vec3_t angles;
|
||||
int input_override;
|
||||
int i, ms;
|
||||
int ms;
|
||||
|
||||
if( cls.state <= ca_connected || cls.state == ca_cinematic )
|
||||
return;
|
||||
|
||||
// store viewangles in case it's will be freeze
|
||||
VectorCopy( cl.viewangles, angles );
|
||||
vec3_t angles = Vec3( cl.viewangles );
|
||||
input_override = 0;
|
||||
|
||||
// fix rounding error and framerate depending player move
|
||||
accurate_ms = host.frametime * 1000;
|
||||
double accurate_ms = host.frametime * 1000;
|
||||
ms = (int)accurate_ms;
|
||||
cl.frametime_remainder += accurate_ms - ms; // accumulate rounding error each frame
|
||||
|
||||
@@ -677,7 +664,7 @@ static void CL_CreateCmd( void )
|
||||
CL_SetSolidPlayers( cl.playernum );
|
||||
|
||||
// message we are constructing.
|
||||
i = cls.netchan.outgoing_sequence & CL_UPDATE_MASK;
|
||||
int i = cls.netchan.outgoing_sequence & CL_UPDATE_MASK;
|
||||
pcmd = &cl.commands[i];
|
||||
|
||||
if( !cls.demoplayback )
|
||||
@@ -695,7 +682,7 @@ static void CL_CreateCmd( void )
|
||||
cmd = &nullcmd;
|
||||
}
|
||||
|
||||
active = (( cls.signon == SIGNONS ) && !cl.paused && !cls.demoplayback );
|
||||
qboolean active = (( cls.signon == SIGNONS ) && !cl.paused && !cls.demoplayback );
|
||||
Platform_PreCreateMove();
|
||||
clgame.dllFuncs.CL_CreateMove( host.frametime, cmd, active );
|
||||
IN_EngineAppendMove( host.frametime, cmd, active );
|
||||
@@ -946,13 +933,12 @@ CL_BeginUpload_f
|
||||
*/
|
||||
static void CL_BeginUpload_f( void )
|
||||
{
|
||||
const char *name;
|
||||
resource_t custResource;
|
||||
byte *buf = NULL;
|
||||
int size = 0;
|
||||
byte md5[16];
|
||||
|
||||
name = Cmd_Argv( 1 );
|
||||
const char *name = Cmd_Argv( 1 );
|
||||
|
||||
if( COM_StringEmptyOrNULL( name ))
|
||||
return;
|
||||
@@ -1038,9 +1024,8 @@ static void CL_GetCDKey( char *protinfo, size_t protinfosize )
|
||||
byte hash[16] = { 0 };
|
||||
MD5Context_t ctx = { 0 };
|
||||
char key[64];
|
||||
int keylength;
|
||||
|
||||
keylength = Q_snprintf( key, sizeof( key ), "%u", COM_RandomLong( 0, 0x7ffffffe ));
|
||||
int keylength = Q_snprintf( key, sizeof( key ), "%u", COM_RandomLong( 0, 0x7ffffffe ));
|
||||
|
||||
MD5Init( &ctx );
|
||||
MD5Update( &ctx, key, keylength );
|
||||
@@ -1079,7 +1064,6 @@ static void CL_WriteSteamTicket( sizebuf_t *send )
|
||||
|
||||
void CL_SendGoldSrcConnectPacket( netadr_t adr, int challenge, const void *ticket, size_t ticketlen )
|
||||
{
|
||||
const char *name;
|
||||
sizebuf_t send;
|
||||
byte send_buf[2048];
|
||||
char protinfo[MAX_INFO_STRING];
|
||||
@@ -1090,7 +1074,7 @@ void CL_SendGoldSrcConnectPacket( netadr_t adr, int challenge, const void *ticke
|
||||
Info_SetValueForKeyf( protinfo, "unique", sizeof( protinfo ), "%i", 0xffffffff );
|
||||
Info_SetValueForKey( protinfo, "raw", "steam", sizeof( protinfo ));
|
||||
CL_GetCDKey( protinfo, sizeof( protinfo ));
|
||||
name = Info_ValueForKey( cls.userinfo, "name" );
|
||||
const char *name = Info_ValueForKey( cls.userinfo, "name" );
|
||||
if( cl_advertise_engine_in_name.value && Q_strnicmp( name, "[Xash3D]", 8 ))
|
||||
Info_SetValueForKeyf( cls.userinfo, "name", sizeof( cls.userinfo ), "[Xash3D]%s", name );
|
||||
|
||||
@@ -1123,8 +1107,6 @@ static void CL_SendConnectPacket( connprotocol_t proto, int challenge )
|
||||
{
|
||||
char protinfo[MAX_INFO_STRING];
|
||||
netadr_t adr = { 0 };
|
||||
int input_devices;
|
||||
netadrtype_t adrtype;
|
||||
|
||||
protinfo[0] = 0;
|
||||
|
||||
@@ -1135,11 +1117,11 @@ static void CL_SendConnectPacket( connprotocol_t proto, int challenge )
|
||||
return;
|
||||
}
|
||||
|
||||
adrtype = NET_NetadrType( &adr );
|
||||
netadrtype_t adrtype = NET_NetadrType( &adr );
|
||||
|
||||
if( adr.port == 0 ) adr.port = MSG_BigShort( PORT_SERVER );
|
||||
|
||||
input_devices = IN_CollectInputDevices();
|
||||
int input_devices = IN_CollectInputDevices();
|
||||
IN_LockInputDevices( adrtype != NA_LOOPBACK ? true : false );
|
||||
|
||||
// GoldSrc doesn't need useragent string
|
||||
@@ -1252,8 +1234,6 @@ Resend a connect message if the last one has timed out
|
||||
static void CL_CheckForResend( void )
|
||||
{
|
||||
netadr_t adr;
|
||||
net_gai_state_t res;
|
||||
float resend_time;
|
||||
|
||||
if( cls.internetservers_wait )
|
||||
{
|
||||
@@ -1287,6 +1267,7 @@ static void CL_CheckForResend( void )
|
||||
else if( cl_resend.value > CL_MAX_RESEND_TIME )
|
||||
Cvar_DirectSetValue( &cl_resend, CL_MAX_RESEND_TIME );
|
||||
|
||||
float resend_time;
|
||||
if( cls.bandwidth_test.started && !cls.bandwidth_test.passed && !cls.bandwidth_test.failed )
|
||||
resend_time = 2.0f;
|
||||
else
|
||||
@@ -1295,7 +1276,7 @@ static void CL_CheckForResend( void )
|
||||
if(( host.realtime - cls.connect_time ) < resend_time )
|
||||
return;
|
||||
|
||||
res = NET_StringToAdrNB( cls.servername, &adr, false );
|
||||
net_gai_state_t res = NET_StringToAdrNB( cls.servername, &adr, false );
|
||||
|
||||
if( res == NET_EAI_NONAME )
|
||||
{
|
||||
@@ -1377,9 +1358,6 @@ static void CL_CreateResourceList( void )
|
||||
{
|
||||
char szFileName[MAX_OSPATH];
|
||||
byte rgucMD5_hash[16] = { 0 };
|
||||
resource_t *pNewResource;
|
||||
int nSize;
|
||||
file_t *fp;
|
||||
|
||||
HPAK_FlushHostQueue();
|
||||
cl.num_resources = 0;
|
||||
@@ -1399,16 +1377,16 @@ static void CL_CreateResourceList( void )
|
||||
CL_ConvertImageToWAD3( szFileName );
|
||||
Q_strncpy( szFileName, "tempdecal.wad", sizeof( szFileName ));
|
||||
}
|
||||
fp = FS_Open( szFileName, "rb", true );
|
||||
file_t *fp = FS_Open( szFileName, "rb", true );
|
||||
|
||||
if( !fp )
|
||||
return;
|
||||
|
||||
nSize = FS_FileLength( fp );
|
||||
int nSize = FS_FileLength( fp );
|
||||
|
||||
if( nSize != 0 )
|
||||
{
|
||||
pNewResource = CL_AddResource( t_decal, szFileName, nSize, false, 0 );
|
||||
resource_t *pNewResource = CL_AddResource( t_decal, szFileName, nSize, false, 0 );
|
||||
|
||||
if( pNewResource )
|
||||
{
|
||||
@@ -1430,9 +1408,6 @@ CL_CheckLogoChanged
|
||||
*/
|
||||
static void CL_CheckLogoChanged( void )
|
||||
{
|
||||
player_info_t *player;
|
||||
int i;
|
||||
|
||||
if( cls.state != ca_active )
|
||||
return;
|
||||
|
||||
@@ -1444,10 +1419,10 @@ static void CL_CheckLogoChanged( void )
|
||||
if( cl.num_resources == 0 )
|
||||
return;
|
||||
|
||||
player = &cl.players[cl.playernum];
|
||||
player_info_t *player = &cl.players[cl.playernum];
|
||||
COM_ClearCustomizationList( &player->customdata, true );
|
||||
|
||||
for( i = 0; i < cl.num_resources; i++ )
|
||||
for( int i = 0; i < cl.num_resources; i++ )
|
||||
{
|
||||
resource_t *pResource = &cl.resourcelist[i];
|
||||
|
||||
@@ -1533,7 +1508,6 @@ static void CL_Rcon_f( void )
|
||||
char message[1024];
|
||||
sizebuf_t msg;
|
||||
netadr_t to;
|
||||
int i;
|
||||
|
||||
if( COM_StringEmptyOrNULL( rcon_password.string ))
|
||||
{
|
||||
@@ -1565,7 +1539,7 @@ static void CL_Rcon_f( void )
|
||||
MSG_WriteStringf( &msg, C2S_RCON" %s ", rcon_password.string );
|
||||
MSG_SeekToBit( &msg, -8, SEEK_CUR );
|
||||
|
||||
for( i = 1; i < Cmd_Argc(); i++ )
|
||||
for( int i = 1; i < Cmd_Argc(); i++ )
|
||||
{
|
||||
string command;
|
||||
|
||||
@@ -1588,11 +1562,9 @@ CL_ClearState
|
||||
*/
|
||||
void CL_ClearState( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
CL_ClearResourceLists();
|
||||
|
||||
for( i = 0; i < MAX_CLIENTS; i++ )
|
||||
for( int i = 0; i < MAX_CLIENTS; i++ )
|
||||
COM_ClearCustomizationList( &cl.players[i].customdata, false );
|
||||
|
||||
S_StopAllSounds ( true );
|
||||
|
||||
@@ -118,8 +118,7 @@ static void NetGraph_InitColors( void )
|
||||
byte mincolor[2][3];
|
||||
byte maxcolor[2][3];
|
||||
float dc[2][3];
|
||||
int i, hfrac;
|
||||
float f;
|
||||
int hfrac;
|
||||
|
||||
mincolor[0][0] = 63;
|
||||
mincolor[0][1] = 0;
|
||||
@@ -137,7 +136,7 @@ static void NetGraph_InitColors( void )
|
||||
maxcolor[1][1] = 0;
|
||||
maxcolor[1][2] = 0;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
dc[0][i] = (float)(maxcolor[0][i] - mincolor[0][i]);
|
||||
dc[1][i] = (float)(maxcolor[1][i] - mincolor[1][i]);
|
||||
@@ -145,8 +144,10 @@ static void NetGraph_InitColors( void )
|
||||
|
||||
hfrac = NETGRAPH_LERP_HEIGHT / 3;
|
||||
|
||||
for( i = 0; i < NETGRAPH_LERP_HEIGHT; i++ )
|
||||
for( int i = 0; i < NETGRAPH_LERP_HEIGHT; i++ )
|
||||
{
|
||||
float f;
|
||||
|
||||
if( i < hfrac )
|
||||
{
|
||||
f = (float)i / (float)hfrac;
|
||||
@@ -170,10 +171,9 @@ get frame data info, like chokes, packet losses, also update graph, packet and c
|
||||
*/
|
||||
static void NetGraph_GetFrameData( float *latency, int *latency_count )
|
||||
{
|
||||
int i, choke_count = 0, loss_count = 0;
|
||||
int choke_count = 0, loss_count = 0;
|
||||
double newtime = Platform_DoubleTime();
|
||||
static double nexttime = 0;
|
||||
float loss, choke;
|
||||
|
||||
*latency_count = 0;
|
||||
*latency = 0.0f;
|
||||
@@ -185,7 +185,7 @@ static void NetGraph_GetFrameData( float *latency, int *latency_count )
|
||||
nexttime = newtime + 0.05;
|
||||
}
|
||||
|
||||
for( i = cls.netchan.incoming_sequence - CL_UPDATE_BACKUP + 1; i <= cls.netchan.incoming_sequence; i++ )
|
||||
for( int i = cls.netchan.incoming_sequence - CL_UPDATE_BACKUP + 1; i <= cls.netchan.incoming_sequence; i++ )
|
||||
{
|
||||
frame_t *f = cl.frames + ( i & CL_UPDATE_MASK );
|
||||
struct packet_latency_t *p = netstat_packet_latency + ( i & NET_TIMINGS_MASK );
|
||||
@@ -228,7 +228,7 @@ static void NetGraph_GetFrameData( float *latency, int *latency_count )
|
||||
if( maxmsgbytes > 1000 )
|
||||
maxmsgbytes = 1000;
|
||||
|
||||
for( i = cls.netchan.outgoing_sequence - CL_UPDATE_BACKUP + 1; i <= cls.netchan.outgoing_sequence; i++ )
|
||||
for( int i = cls.netchan.outgoing_sequence - CL_UPDATE_BACKUP + 1; i <= cls.netchan.outgoing_sequence; i++ )
|
||||
{
|
||||
netstat_cmdinfo[i & NET_TIMINGS_MASK].cmd_lerp = cl.commands[i & CL_UPDATE_MASK].frame_lerp;
|
||||
netstat_cmdinfo[i & NET_TIMINGS_MASK].sent = cl.commands[i & CL_UPDATE_MASK].heldback ? false : true;
|
||||
@@ -236,11 +236,11 @@ static void NetGraph_GetFrameData( float *latency, int *latency_count )
|
||||
}
|
||||
|
||||
// packet loss
|
||||
loss = 100.0f * (float)loss_count / CL_UPDATE_BACKUP;
|
||||
float loss = 100.0f * (float)loss_count / CL_UPDATE_BACKUP;
|
||||
packet_loss = PACKETLOSS_AVG_FRAC * packet_loss + ( 1.0f - PACKETLOSS_AVG_FRAC ) * loss;
|
||||
|
||||
// packet choke
|
||||
choke = 100.0f * (float)choke_count / CL_UPDATE_BACKUP;
|
||||
float choke = 100.0f * (float)choke_count / CL_UPDATE_BACKUP;
|
||||
packet_choke = PACKETCHOKE_AVG_FRAC * packet_choke + ( 1.0f - PACKETCHOKE_AVG_FRAC ) * choke;
|
||||
}
|
||||
|
||||
@@ -252,13 +252,13 @@ NetGraph_DrawTimes
|
||||
*/
|
||||
static void NetGraph_DrawTimes( wrect_t rect, int x, int w )
|
||||
{
|
||||
int i, j, extrap_point = NETGRAPH_LERP_HEIGHT / 3, a, h;
|
||||
int extrap_point = NETGRAPH_LERP_HEIGHT / 3;
|
||||
wrect_t fill;
|
||||
|
||||
for( a = 0; a < w; a++ )
|
||||
for( int a = 0; a < w; a++ )
|
||||
{
|
||||
i = ( cls.netchan.outgoing_sequence - a ) & NET_TIMINGS_MASK;
|
||||
h = Q_min(( netstat_cmdinfo[i].cmd_lerp / 3.0f ) * NETGRAPH_LERP_HEIGHT, net_graphheight.value * 0.7f);
|
||||
int i = ( cls.netchan.outgoing_sequence - a ) & NET_TIMINGS_MASK;
|
||||
int h = Q_min(( netstat_cmdinfo[i].cmd_lerp / 3.0f ) * NETGRAPH_LERP_HEIGHT, net_graphheight.value * 0.7f);
|
||||
|
||||
fill.left = x + w - a - 1;
|
||||
fill.right = fill.bottom = 1;
|
||||
@@ -277,7 +277,7 @@ static void NetGraph_DrawTimes( wrect_t rect, int x, int w )
|
||||
start = (h - 1);
|
||||
}
|
||||
|
||||
for( j = start; j < h; j++ )
|
||||
for( int j = start; j < h; j++ )
|
||||
{
|
||||
int color = NETGRAPH_NET_COLORS + j + extrap_point;
|
||||
color = Q_min( color, ARRAYSIZE( netcolors ) - 1 );
|
||||
@@ -296,7 +296,7 @@ static void NetGraph_DrawTimes( wrect_t rect, int x, int w )
|
||||
if( !net_graphsolid.value )
|
||||
h = 1;
|
||||
|
||||
for( j = 0; j < h; j++ )
|
||||
for( int j = 0; j < h; j++ )
|
||||
{
|
||||
int color = NETGRAPH_NET_COLORS + j + oldh;
|
||||
color = Q_min( color, ARRAYSIZE( netcolors ) - 1 );
|
||||
@@ -495,15 +495,16 @@ NetGraph_DrawDataUsage
|
||||
*/
|
||||
static void NetGraph_DrawDataUsage( int x, int y, int w, int graphtype )
|
||||
{
|
||||
int a, i, h, lastvalidh = 0, ping;
|
||||
int lastvalidh = 0;
|
||||
int pingheight = net_graphheight.value - NETGRAPH_LERP_HEIGHT - 2;
|
||||
wrect_t fill = { 0 };
|
||||
byte color[4];
|
||||
|
||||
for( a = 0; a < w; a++ )
|
||||
for( int a = 0; a < w; a++ )
|
||||
{
|
||||
i = (cls.netchan.incoming_sequence - a) & NET_TIMINGS_MASK;
|
||||
h = netstat_packet_latency[i].latency;
|
||||
int ping;
|
||||
int i = (cls.netchan.incoming_sequence - a) & NET_TIMINGS_MASK;
|
||||
int h = netstat_packet_latency[i].latency;
|
||||
|
||||
NetGraph_ColorForHeight( &netstat_packet_latency[i], color, &ping );
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ return true if equal
|
||||
*/
|
||||
static qboolean CL_CmpStudioTextures( int numtexs, mstudiotexture_t *p1, remap_info_t *remap )
|
||||
{
|
||||
int i;
|
||||
mstudiotexture_t *p2;
|
||||
|
||||
if( !p1 ) // no textures
|
||||
@@ -60,7 +59,7 @@ static qboolean CL_CmpStudioTextures( int numtexs, mstudiotexture_t *p1, remap_i
|
||||
|
||||
p2 = remap->ptexture;
|
||||
|
||||
for( i = 0; i < numtexs; i++, p1++, p2++ )
|
||||
for( int i = 0; i < numtexs; i++, p1++, p2++ )
|
||||
{
|
||||
if( p1->flags & STUDIO_NF_COLORMAP )
|
||||
continue; // colormaps always has different indexes
|
||||
@@ -116,18 +115,17 @@ static void CL_DuplicateTexture( cl_entity_t *entity, model_t *model, mstudiotex
|
||||
const char *name;
|
||||
texture_t *tx = NULL;
|
||||
char texname[128];
|
||||
int i, index;
|
||||
size_t size;
|
||||
byte paletteBackup[768];
|
||||
byte *raw, *pal;
|
||||
int index = ptexture->index;
|
||||
|
||||
// save off the real texture index
|
||||
index = ptexture->index;
|
||||
name = ref.dllFuncs.GL_TextureName( index );
|
||||
Q_snprintf( texname, sizeof( texname ), "#%i_%s", entity->curstate.number, name + 1 );
|
||||
|
||||
// search for pixels
|
||||
for( i = 0; i < model->numtextures; i++ )
|
||||
for( int i = 0; i < model->numtextures; i++ )
|
||||
{
|
||||
tx = model->textures[i];
|
||||
if( tx->gl_texturenum == index )
|
||||
@@ -161,7 +159,7 @@ static void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptext
|
||||
texture_t *tx = NULL;
|
||||
char texname[128], name[128], mdlname[128];
|
||||
const char *origtexname;
|
||||
int i, index;
|
||||
int index;
|
||||
size_t size;
|
||||
byte paletteBackup[768];
|
||||
byte *raw, *pal;
|
||||
@@ -180,7 +178,7 @@ static void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptext
|
||||
return; // couldn't find texture
|
||||
|
||||
// search for pixels
|
||||
for( i = 0; i < entity->model->numtextures; i++ )
|
||||
for( int i = 0; i < entity->model->numtextures; i++ )
|
||||
{
|
||||
tx = entity->model->textures[i];
|
||||
if( tx->gl_texturenum == index )
|
||||
@@ -259,12 +257,10 @@ Release remap info per entity
|
||||
*/
|
||||
static void CL_FreeRemapInfo( remap_info_t *info )
|
||||
{
|
||||
int i;
|
||||
|
||||
Assert( info != NULL );
|
||||
|
||||
// release all colormap texture copies
|
||||
for( i = 0; i < info->numtextures; i++ )
|
||||
for( int i = 0; i < info->numtextures; i++ )
|
||||
{
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
@@ -438,11 +434,9 @@ Release all remap infos
|
||||
*/
|
||||
void CL_ClearAllRemaps( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( clgame.remap_info )
|
||||
{
|
||||
for( i = 0; i < clgame.maxRemapInfos; i++ )
|
||||
for( int i = 0; i < clgame.maxRemapInfos; i++ )
|
||||
{
|
||||
if( clgame.remap_info[i] )
|
||||
CL_FreeRemapInfo( clgame.remap_info[i] );
|
||||
|
||||
@@ -50,9 +50,7 @@ SCR_DrawFPS
|
||||
*/
|
||||
void SCR_DrawFPS( int height )
|
||||
{
|
||||
float calc;
|
||||
rgba_t color;
|
||||
double newtime;
|
||||
static double nexttime = 0, lasttime = 0;
|
||||
static double framerate = 0;
|
||||
static int framecount = 0;
|
||||
@@ -73,7 +71,7 @@ void SCR_DrawFPS( int height )
|
||||
default: return;
|
||||
}
|
||||
|
||||
newtime = Platform_DoubleTime();
|
||||
double newtime = Platform_DoubleTime();
|
||||
if( newtime >= nexttime )
|
||||
{
|
||||
framerate = framecount / (newtime - lasttime);
|
||||
@@ -82,7 +80,7 @@ void SCR_DrawFPS( int height )
|
||||
framecount = 0;
|
||||
}
|
||||
|
||||
calc = framerate;
|
||||
float calc = framerate;
|
||||
framecount++;
|
||||
|
||||
if( calc < 1.0f )
|
||||
@@ -120,15 +118,13 @@ Draw local player position, angles and velocity
|
||||
void SCR_DrawPos( void )
|
||||
{
|
||||
static char msg[MAX_SYSPATH];
|
||||
float speed;
|
||||
cl_entity_t *ent;
|
||||
rgba_t color;
|
||||
|
||||
if( cls.state != ca_active || !cl_showpos.value || cl.background )
|
||||
return;
|
||||
|
||||
ent = CL_GetLocalPlayer();
|
||||
speed = VectorLength( cl.simvel );
|
||||
cl_entity_t *ent = CL_GetLocalPlayer();
|
||||
float speed = VectorLength( cl.simvel );
|
||||
|
||||
Q_snprintf( msg, MAX_SYSPATH,
|
||||
"pos: %.2f %.2f %.2f\n"
|
||||
@@ -153,23 +149,22 @@ SCR_DrawEnts
|
||||
void SCR_DrawEnts( void )
|
||||
{
|
||||
rgba_t color = { 255, 255, 255, 255 };
|
||||
int i;
|
||||
|
||||
if( cls.state != ca_active || !cl_showents.value || ( cl.maxclients > 1 && !cls.demoplayback ))
|
||||
return;
|
||||
|
||||
// this probably better hook CL_AddVisibleEntities
|
||||
// as entities might get added by client.dll
|
||||
for( i = 0; i < clgame.maxEntities; i++ )
|
||||
for( int i = 0; i < clgame.maxEntities; i++ )
|
||||
{
|
||||
const cl_entity_t *ent = &clgame.entities[i];
|
||||
string msg;
|
||||
vec3_t screen, pos;
|
||||
vec3_t screen;
|
||||
|
||||
if( ent->curstate.messagenum != cl.parsecount )
|
||||
continue;
|
||||
|
||||
VectorCopy( ent->origin, pos );
|
||||
vec3_t pos = Vec3( ent->origin );
|
||||
|
||||
if( ent->model != NULL )
|
||||
{
|
||||
@@ -241,12 +236,12 @@ void SCR_DrawUserCmd( void )
|
||||
};
|
||||
cl_font_t *font = Con_GetCurFont();
|
||||
string msg;
|
||||
int i, ypos = 100;
|
||||
int ypos = 100;
|
||||
|
||||
if( cls.state != ca_active || !cl_showcmd.value )
|
||||
return;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( buttons ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( buttons ); i++ )
|
||||
{
|
||||
rgba_t rgba;
|
||||
|
||||
@@ -280,7 +275,6 @@ same as r_speeds but for network channel
|
||||
void SCR_NetSpeeds( void )
|
||||
{
|
||||
static char msg[MAX_SYSPATH];
|
||||
int x, y;
|
||||
float time = cl.mtime[0];
|
||||
static int min_svfps = 100;
|
||||
static int max_svfps = 0;
|
||||
@@ -326,8 +320,8 @@ void SCR_NetSpeeds( void )
|
||||
Q_memprint( cls.netchan.total_sended )
|
||||
);
|
||||
|
||||
x = refState.width - 320 * font->scale;
|
||||
y = 384;
|
||||
int x = refState.width - 320 * font->scale;
|
||||
int y = 384;
|
||||
|
||||
MakeRGBA( color, 255, 255, 255, 255 );
|
||||
CL_DrawString( x, y, msg, color, font, FONT_DRAW_RESETCOLORONLF );
|
||||
@@ -347,12 +341,11 @@ void SCR_RSpeeds( void )
|
||||
|
||||
if( ref.dllFuncs.R_SpeedsMessage( msg, sizeof( msg )))
|
||||
{
|
||||
int x, y;
|
||||
rgba_t color;
|
||||
cl_font_t *font = Con_GetCurFont();
|
||||
|
||||
x = refState.width - 340 * font->scale;
|
||||
y = 64;
|
||||
int x = refState.width - 340 * font->scale;
|
||||
int y = 64;
|
||||
|
||||
MakeRGBA( color, 255, 255, 255, 255 );
|
||||
CL_DrawString( x, y, msg, color, font, FONT_DRAW_RESETCOLORONLF );
|
||||
@@ -386,11 +379,10 @@ static void VID_WriteOverviewScript( void )
|
||||
{
|
||||
ref_overview_t *ov = &clgame.overView;
|
||||
string filename;
|
||||
file_t *f;
|
||||
|
||||
Q_snprintf( filename, sizeof( filename ), "overviews/%s.txt", clgame.mapname );
|
||||
|
||||
f = FS_Open( filename, "w", false );
|
||||
file_t *f = FS_Open( filename, "w", false );
|
||||
if( !f )
|
||||
{
|
||||
Con_Printf( S_ERROR "%s: can't open %s for write\n", __func__, filename );
|
||||
@@ -586,7 +578,6 @@ void SCR_TileClear( void )
|
||||
{
|
||||
int i, top, bottom, left, right, texnum;
|
||||
dirty_t clear;
|
||||
float tw, th;
|
||||
|
||||
if( likely( scr_viewsize.value >= 120 ))
|
||||
return; // full screen rendering
|
||||
@@ -634,8 +625,8 @@ void SCR_TileClear( void )
|
||||
left = clgame.viewport[0];
|
||||
right = left + clgame.viewport[2] - 1;
|
||||
|
||||
tw = REF_GET_PARM( PARM_TEX_SRC_WIDTH, texnum );
|
||||
th = REF_GET_PARM( PARM_TEX_SRC_HEIGHT, texnum );
|
||||
float tw = REF_GET_PARM( PARM_TEX_SRC_WIDTH, texnum );
|
||||
float th = REF_GET_PARM( PARM_TEX_SRC_HEIGHT, texnum );
|
||||
|
||||
if( clear.y1 < top )
|
||||
{
|
||||
@@ -749,11 +740,9 @@ void SCR_LoadCreditsFont( void )
|
||||
// copy font size for client.dll
|
||||
if( success )
|
||||
{
|
||||
int i;
|
||||
|
||||
clgame.scrInfo.iCharHeight = cls.creditsFont.charHeight;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( cls.creditsFont.charWidths ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( cls.creditsFont.charWidths ); i++ )
|
||||
clgame.scrInfo.charWidths[i] = cls.creditsFont.charWidths[i];
|
||||
}
|
||||
else Con_DPrintf( S_ERROR "failed to load HUD font\n" );
|
||||
|
||||
@@ -27,10 +27,10 @@ GNU General Public License for more details.
|
||||
static void CL_AdjustSprayDimensions( int *width, int *height )
|
||||
{
|
||||
float aspect = (float)( *width ) / (float)( *height );
|
||||
int h, w;
|
||||
for( h = (( *height ) / 16 ) * 16; h >= 16; h -= 16 )
|
||||
|
||||
for( int h = (( *height ) / 16 ) * 16; h >= 16; h -= 16 )
|
||||
{
|
||||
w = ((int)( h * aspect ) / 16 ) * 16;
|
||||
int w = ((int)( h * aspect ) / 16 ) * 16;
|
||||
if( w < 16 || w > *width )
|
||||
continue;
|
||||
|
||||
@@ -107,7 +107,6 @@ qboolean CL_ConvertImageToWAD3( const char *filename )
|
||||
{
|
||||
qboolean is_indexed_img;
|
||||
int width = 0, height = 0;
|
||||
int i;
|
||||
byte palette[SPRAY_PALETTE_BYTES];
|
||||
byte *indexed = NULL;
|
||||
rgbdata_t *image = NULL;
|
||||
@@ -122,7 +121,7 @@ qboolean CL_ConvertImageToWAD3( const char *filename )
|
||||
if( is_indexed_img )
|
||||
{
|
||||
// copy bmp palette from rgba to rgb
|
||||
for( i = 0; i < 256; ++i )
|
||||
for( int i = 0; i < 256; ++i )
|
||||
{
|
||||
palette[i * 3 + 0] = image->palette[i * 4 + 0]; // R
|
||||
palette[i * 3 + 1] = image->palette[i * 4 + 1]; // G
|
||||
@@ -141,7 +140,7 @@ qboolean CL_ConvertImageToWAD3( const char *filename )
|
||||
// set index 255 for transparent pixels in rgba images
|
||||
if( image->type == PF_RGBA_32 )
|
||||
{
|
||||
for( i = 0; i < width * height; ++i )
|
||||
for( int i = 0; i < width * height; ++i )
|
||||
{
|
||||
if( image->buffer[i * 4 + 3] <= SPRAY_ALPHA_THRESHOLD )
|
||||
quant->buffer[i] = 255;
|
||||
|
||||
@@ -33,11 +33,7 @@ assume pModel is valid
|
||||
mspriteframe_t *R_GetSpriteFrame( const model_t *pModel, int frame, float yaw )
|
||||
{
|
||||
msprite_t *psprite;
|
||||
mspritegroup_t *pspritegroup;
|
||||
mspriteframe_t *pspriteframe = NULL;
|
||||
float *pintervals, fullinterval;
|
||||
int i, numframes;
|
||||
float targettime;
|
||||
|
||||
if( !pModel )
|
||||
return NULL;
|
||||
@@ -61,14 +57,15 @@ mspriteframe_t *R_GetSpriteFrame( const model_t *pModel, int frame, float yaw )
|
||||
}
|
||||
else if( psprite->frames[frame].type == SPR_GROUP )
|
||||
{
|
||||
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
|
||||
pintervals = pspritegroup->intervals;
|
||||
numframes = pspritegroup->numframes;
|
||||
fullinterval = pintervals[numframes - 1];
|
||||
mspritegroup_t *pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
|
||||
float *pintervals = pspritegroup->intervals;
|
||||
int numframes = pspritegroup->numframes;
|
||||
float fullinterval = pintervals[numframes - 1];
|
||||
|
||||
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
|
||||
// are positive, so we don't have to worry about division by zero
|
||||
targettime = cl.time - ((int)( cl.time / fullinterval )) * fullinterval;
|
||||
float targettime = cl.time - ((int)( cl.time / fullinterval )) * fullinterval;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < ( numframes - 1 ); i++ )
|
||||
{
|
||||
@@ -82,7 +79,7 @@ mspriteframe_t *R_GetSpriteFrame( const model_t *pModel, int frame, float yaw )
|
||||
int angleframe = (int)( Q_rint(( refState.viewangles[1] - yaw + 45.0f ) / 360 * 8 ) - 4 ) & 7;
|
||||
|
||||
// e.g. doom-style sprite monsters
|
||||
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
|
||||
mspritegroup_t *pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
|
||||
pspriteframe = pspritegroup->frames[angleframe];
|
||||
}
|
||||
|
||||
@@ -203,16 +200,13 @@ static const byte *Mod_SpriteLoadFrame( model_t *mod, const void *pin, mspritefr
|
||||
|
||||
static const byte *Mod_SpriteLoadGroup( model_t *mod, const void *pin, mspriteframe_t **ppframe, int framenum )
|
||||
{
|
||||
const dspritegroup_t *pingroup;
|
||||
const dspritegroup_t *pingroup = (const dspritegroup_t *)pin;
|
||||
mspritegroup_t *pspritegroup;
|
||||
const dspriteinterval_t *pin_intervals;
|
||||
float *poutintervals;
|
||||
int i, groupsize, numframes;
|
||||
int groupsize, numframes = pingroup->numframes;
|
||||
const void *ptemp;
|
||||
|
||||
pingroup = (const dspritegroup_t *)pin;
|
||||
numframes = pingroup->numframes;
|
||||
|
||||
groupsize = sizeof( mspritegroup_t ) + ( numframes - 1 ) * sizeof( pspritegroup->frames[0] );
|
||||
pspritegroup = Mem_Calloc( mod->mempool, groupsize );
|
||||
pspritegroup->numframes = numframes;
|
||||
@@ -222,7 +216,7 @@ static const byte *Mod_SpriteLoadGroup( model_t *mod, const void *pin, mspritefr
|
||||
poutintervals = Mem_Calloc( mod->mempool, numframes * sizeof( float ));
|
||||
pspritegroup->intervals = poutintervals;
|
||||
|
||||
for( i = 0; i < numframes; i++ )
|
||||
for( int i = 0; i < numframes; i++ )
|
||||
{
|
||||
*poutintervals = pin_intervals->interval;
|
||||
if( *poutintervals <= 0.0f )
|
||||
@@ -232,7 +226,7 @@ static const byte *Mod_SpriteLoadGroup( model_t *mod, const void *pin, mspritefr
|
||||
}
|
||||
|
||||
ptemp = (const void *)pin_intervals;
|
||||
for( i = 0; i < numframes; i++ )
|
||||
for( int i = 0; i < numframes; i++ )
|
||||
{
|
||||
ptemp = Mod_SpriteLoadFrame( mod, ptemp, &pspritegroup->frames[i], framenum * 10 + i );
|
||||
}
|
||||
@@ -330,13 +324,12 @@ void Mod_SpriteLoadTextures( model_t *mod, const void *buffer )
|
||||
void Mod_SpriteUnloadTextures( void *data )
|
||||
{
|
||||
msprite_t *psprite = data;
|
||||
int i;
|
||||
|
||||
if( !data )
|
||||
return;
|
||||
|
||||
// release all textures
|
||||
for( i = 0; i < psprite->numframes; i++ )
|
||||
for( int i = 0; i < psprite->numframes; i++ )
|
||||
{
|
||||
if( !psprite->frames[i].frameptr )
|
||||
continue;
|
||||
@@ -348,9 +341,8 @@ void Mod_SpriteUnloadTextures( void *data )
|
||||
else
|
||||
{
|
||||
mspritegroup_t *pspritegroup = (mspritegroup_t *)psprite->frames[i].frameptr;
|
||||
int j;
|
||||
|
||||
for( j = 0; j < pspritegroup->numframes; j++ )
|
||||
for( int j = 0; j < pspritegroup->numframes; j++ )
|
||||
{
|
||||
if( pspritegroup->frames[j] )
|
||||
ref.dllFuncs.GL_FreeTexture( pspritegroup->frames[j]->gl_texturenum );
|
||||
|
||||
@@ -395,9 +395,7 @@ static void SteamBroker_UpdateConnecting( void )
|
||||
FD_ZERO( &writefds );
|
||||
FD_SET( broker.socket, &writefds );
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 0;
|
||||
struct timeval tv = { 0 };
|
||||
|
||||
#if XASH_WIN32
|
||||
int select_result = select( 0, NULL, &writefds, NULL, &tv );
|
||||
|
||||
@@ -120,21 +120,20 @@ void CL_AddClientResources( void )
|
||||
{
|
||||
const char *snd;
|
||||
char filepath[MAX_QPATH];
|
||||
int i;
|
||||
|
||||
// don't request resources from localhost or in quake-compatibility mode
|
||||
if( cl.maxclients <= 1 || Host_IsQuakeCompatible( ))
|
||||
return;
|
||||
|
||||
// check sprites first
|
||||
for( i = 0; i < ARRAYSIZE( cl_default_sprites ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( cl_default_sprites ); i++ )
|
||||
{
|
||||
if( !FS_FileExists( cl_default_sprites[i], false ))
|
||||
CL_AddClientResource( cl_default_sprites[i], t_model );
|
||||
}
|
||||
|
||||
// then check sounds
|
||||
for( i = 0; ( snd = SoundList_Get( BouncePlayerShell, i )); i++ )
|
||||
for( int i = 0; ( snd = SoundList_Get( BouncePlayerShell, i )); i++ )
|
||||
{
|
||||
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", snd );
|
||||
|
||||
@@ -142,7 +141,7 @@ void CL_AddClientResources( void )
|
||||
CL_AddClientResource( snd, t_sound );
|
||||
}
|
||||
|
||||
for( i = 0; ( snd = SoundList_Get( BounceWeaponShell, i )); i++ )
|
||||
for( int i = 0; ( snd = SoundList_Get( BounceWeaponShell, i )); i++ )
|
||||
{
|
||||
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", snd );
|
||||
|
||||
@@ -150,7 +149,7 @@ void CL_AddClientResources( void )
|
||||
CL_AddClientResource( snd, t_sound );
|
||||
}
|
||||
|
||||
for( i = 0; ( snd = SoundList_Get( Explode, i )); i++ )
|
||||
for( int i = 0; ( snd = SoundList_Get( Explode, i )); i++ )
|
||||
{
|
||||
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", snd );
|
||||
|
||||
@@ -159,7 +158,7 @@ void CL_AddClientResources( void )
|
||||
}
|
||||
|
||||
#if 0 // ric sounds was precached by server-side
|
||||
for( i = 0; ( snd = SoundList_Get( Ricochet, i )); i++ )
|
||||
for( int i = 0; ( snd = SoundList_Get( Ricochet, i )); i++ )
|
||||
{
|
||||
Q_snprintf( filepath, sizeof( filepath ), DEFAULT_SOUNDPATH "%s", snd );
|
||||
|
||||
@@ -177,11 +176,9 @@ CL_ClearTempEnts
|
||||
*/
|
||||
static void CL_ClearTempEnts( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !cl_tempents ) return;
|
||||
|
||||
for( i = 0; i < GI->max_tents - 1; i++ )
|
||||
for( int i = 0; i < GI->max_tents - 1; i++ )
|
||||
{
|
||||
cl_tempents[i].next = &cl_tempents[i+1];
|
||||
cl_tempents[i].entity.trivial_accept = INVALID_HANDLE;
|
||||
@@ -270,14 +267,12 @@ play collide sound
|
||||
*/
|
||||
static void CL_TempEntPlaySound( TEMPENTITY *pTemp, float damp )
|
||||
{
|
||||
float fvol;
|
||||
const char *soundname = NULL;
|
||||
qboolean isshellcasing = false;
|
||||
int zvel;
|
||||
|
||||
Assert( pTemp != NULL );
|
||||
|
||||
fvol = 0.8f;
|
||||
float fvol = 0.8f;
|
||||
|
||||
switch( pTemp->hitSound )
|
||||
{
|
||||
@@ -315,7 +310,7 @@ static void CL_TempEntPlaySound( TEMPENTITY *pTemp, float damp )
|
||||
if( !soundname )
|
||||
return;
|
||||
|
||||
zvel = abs( pTemp->entity.baseline.origin[2] );
|
||||
int zvel = abs( pTemp->entity.baseline.origin[2] );
|
||||
|
||||
// only play one out of every n
|
||||
if( isshellcasing )
|
||||
@@ -333,7 +328,6 @@ static void CL_TempEntPlaySound( TEMPENTITY *pTemp, float damp )
|
||||
if( damp > 0.0f )
|
||||
{
|
||||
int pitch;
|
||||
sound_t handle;
|
||||
|
||||
if( isshellcasing )
|
||||
fvol *= Q_min( 1.0f, ((float)zvel) / 350.0f );
|
||||
@@ -343,7 +337,7 @@ static void CL_TempEntPlaySound( TEMPENTITY *pTemp, float damp )
|
||||
pitch = COM_RandomLong( 95, 105 );
|
||||
else pitch = PITCH_NORM;
|
||||
|
||||
handle = S_RegisterSound( soundname );
|
||||
sound_t handle = S_RegisterSound( soundname );
|
||||
S_StartSound( pTemp->entity.origin, -(pTemp - cl_tempents), CHAN_BODY, handle, fvol, ATTN_NORM, pitch, SND_STOP_LOOPING );
|
||||
}
|
||||
}
|
||||
@@ -571,15 +565,14 @@ void GAME_EXPORT R_FizzEffect( cl_entity_t *ent, int modelIndex, int density )
|
||||
{
|
||||
const float base_time = cl.time - 0.1f;
|
||||
model_t *mod = CL_ModelHandle( modelIndex );
|
||||
vec3_t volume, mins, maxs;
|
||||
vec3_t volume;
|
||||
vec2_t speed;
|
||||
int i;
|
||||
|
||||
if( !ent || !ent->model || !modelIndex || !mod )
|
||||
return;
|
||||
|
||||
VectorCopy( ent->model->mins, mins );
|
||||
VectorCopy( ent->model->maxs, maxs );
|
||||
vec3_t mins = Vec3( ent->model->mins );
|
||||
vec3_t maxs = Vec3( ent->model->maxs );
|
||||
|
||||
if( ent->angles[1] != 0.0f )
|
||||
{
|
||||
@@ -592,12 +585,11 @@ void GAME_EXPORT R_FizzEffect( cl_entity_t *ent, int modelIndex, int density )
|
||||
|
||||
VectorSubtract( maxs, mins, volume );
|
||||
|
||||
for( i = 0; i <= density; i++ )
|
||||
for( int i = 0; i <= density; i++ )
|
||||
{
|
||||
TEMPENTITY *tent;
|
||||
vec3_t origin;
|
||||
vec3_t origin = Vec3( mins );
|
||||
|
||||
VectorCopy( mins, origin );
|
||||
origin[0] += COM_RandomLong( 0, (int)volume[0] - 1 );
|
||||
origin[1] += COM_RandomLong( 0, (int)volume[1] - 1 );
|
||||
|
||||
@@ -628,16 +620,13 @@ Create bubbles
|
||||
void GAME_EXPORT R_Bubbles( const vec3_t mins, const vec3_t maxs, float height, int modelIndex, int count, float speed )
|
||||
{
|
||||
TEMPENTITY *pTemp;
|
||||
float sine, cosine;
|
||||
float angle, zspeed;
|
||||
vec3_t origin;
|
||||
model_t *mod;
|
||||
int i;
|
||||
|
||||
if(( mod = CL_ModelHandle( modelIndex )) == NULL )
|
||||
return;
|
||||
|
||||
for ( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
origin[0] = COM_RandomLong( mins[0], maxs[0] );
|
||||
origin[1] = COM_RandomLong( mins[1], maxs[1] );
|
||||
@@ -649,10 +638,11 @@ void GAME_EXPORT R_Bubbles( const vec3_t mins, const vec3_t maxs, float height,
|
||||
|
||||
pTemp->x = origin[0];
|
||||
pTemp->y = origin[1];
|
||||
angle = COM_RandomFloat( -M_PI, M_PI );
|
||||
float sine, cosine;
|
||||
float angle = COM_RandomFloat( -M_PI, M_PI );
|
||||
SinCos( angle, &sine, &cosine );
|
||||
|
||||
zspeed = COM_RandomLong( 80, 140 );
|
||||
float zspeed = COM_RandomLong( 80, 140 );
|
||||
VectorSet( pTemp->entity.baseline.origin, speed * cosine, speed * sine, zspeed );
|
||||
pTemp->die = cl.time + ((height - (origin[2] - mins[2])) / zspeed) - 0.1f;
|
||||
pTemp->entity.curstate.frame = COM_RandomLong( 0, pTemp->frameMax );
|
||||
@@ -674,18 +664,15 @@ Create bubble trail
|
||||
void GAME_EXPORT R_BubbleTrail( const vec3_t start, const vec3_t end, float height, int modelIndex, int count, float speed )
|
||||
{
|
||||
TEMPENTITY *pTemp;
|
||||
float sine, cosine, zspeed;
|
||||
float dist, angle;
|
||||
vec3_t origin;
|
||||
model_t *mod;
|
||||
int i;
|
||||
|
||||
if(( mod = CL_ModelHandle( modelIndex )) == NULL )
|
||||
return;
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
dist = COM_RandomFloat( 0, 1.0 );
|
||||
float dist = COM_RandomFloat( 0, 1.0 );
|
||||
VectorLerp( start, dist, end, origin );
|
||||
pTemp = CL_TempEntAlloc( origin, mod );
|
||||
if( !pTemp ) return;
|
||||
@@ -694,10 +681,11 @@ void GAME_EXPORT R_BubbleTrail( const vec3_t start, const vec3_t end, float heig
|
||||
|
||||
pTemp->x = origin[0];
|
||||
pTemp->y = origin[1];
|
||||
angle = COM_RandomFloat( -M_PI, M_PI );
|
||||
float sine, cosine;
|
||||
float angle = COM_RandomFloat( -M_PI, M_PI );
|
||||
SinCos( angle, &sine, &cosine );
|
||||
|
||||
zspeed = COM_RandomLong( 80, 140 );
|
||||
float zspeed = COM_RandomLong( 80, 140 );
|
||||
VectorSet( pTemp->entity.baseline.origin, speed * cosine, speed * sine, zspeed );
|
||||
pTemp->die = cl.time + ((height - (origin[2] - start[2])) / zspeed) - 0.1f;
|
||||
pTemp->entity.curstate.frame = COM_RandomLong( 0, pTemp->frameMax );
|
||||
@@ -719,7 +707,6 @@ Attaches entity to player
|
||||
void GAME_EXPORT R_AttachTentToPlayer( int client, int modelIndex, float zoffset, float life )
|
||||
{
|
||||
TEMPENTITY *pTemp;
|
||||
vec3_t position;
|
||||
cl_entity_t *pClient;
|
||||
model_t *pModel;
|
||||
|
||||
@@ -734,7 +721,7 @@ void GAME_EXPORT R_AttachTentToPlayer( int client, int modelIndex, float zoffset
|
||||
if(( pModel = CL_ModelHandle( modelIndex )) == NULL )
|
||||
return;
|
||||
|
||||
VectorCopy( pClient->origin, position );
|
||||
vec3_t position = Vec3( pClient->origin );
|
||||
position[2] += zoffset;
|
||||
|
||||
pTemp = CL_TempEntAllocHigh( position, pModel );
|
||||
@@ -848,11 +835,9 @@ Do muzzleflash
|
||||
void GAME_EXPORT R_MuzzleFlash( const vec3_t pos, int type )
|
||||
{
|
||||
TEMPENTITY *pTemp;
|
||||
int index;
|
||||
float scale;
|
||||
|
||||
index = ( type % 10 ) % MAX_MUZZLEFLASH;
|
||||
scale = ( type / 10 ) * 0.1f;
|
||||
int index = ( type % 10 ) % MAX_MUZZLEFLASH;
|
||||
float scale = ( type / 10 ) * 0.1f;
|
||||
if( scale == 0.0f ) scale = 0.5f;
|
||||
|
||||
if( !cl_sprite_muzzleflash[index] )
|
||||
@@ -887,20 +872,16 @@ and some blood drops. This is high-priority tent
|
||||
void GAME_EXPORT R_BloodSprite( const vec3_t org, int colorIndex, int modelIndex, int modelIndex2, float size )
|
||||
{
|
||||
model_t *pModel, *pModel2;
|
||||
int impactindex;
|
||||
int spatterindex;
|
||||
int i, splatter;
|
||||
TEMPENTITY *pTemp;
|
||||
vec3_t pos;
|
||||
|
||||
colorIndex += COM_RandomLong( 1, 3 );
|
||||
impactindex = colorIndex;
|
||||
spatterindex = colorIndex - 1;
|
||||
int impactindex = colorIndex;
|
||||
int spatterindex = colorIndex - 1;
|
||||
|
||||
// validate the model first
|
||||
if(( pModel = CL_ModelHandle( modelIndex )) != NULL )
|
||||
{
|
||||
VectorCopy( org, pos );
|
||||
vec3_t pos = Vec3( org );
|
||||
pos[2] += COM_RandomFloat( 2.0f, 4.0f ); // make offset from ground (snarks issues)
|
||||
|
||||
// large, single blood sprite is a high-priority tent
|
||||
@@ -926,9 +907,9 @@ void GAME_EXPORT R_BloodSprite( const vec3_t org, int colorIndex, int modelIndex
|
||||
// validate the model first
|
||||
if(( pModel2 = CL_ModelHandle( modelIndex2 )) != NULL )
|
||||
{
|
||||
splatter = size + ( COM_RandomLong( 1, 8 ) + COM_RandomLong( 1, 8 ));
|
||||
int splatter = size + ( COM_RandomLong( 1, 8 ) + COM_RandomLong( 1, 8 ));
|
||||
|
||||
for( i = 0; i < splatter; i++ )
|
||||
for( int i = 0; i < splatter; i++ )
|
||||
{
|
||||
// create blood drips
|
||||
if(( pTemp = CL_TempEntAlloc( org, pModel2 )) != NULL )
|
||||
@@ -973,13 +954,11 @@ void GAME_EXPORT R_BreakModel( const vec3_t pos, const vec3_t size, const vec3_t
|
||||
{
|
||||
TEMPENTITY *pTemp;
|
||||
model_t *pmodel;
|
||||
char type;
|
||||
int i, j;
|
||||
|
||||
if(( pmodel = CL_ModelHandle( modelIndex )) == NULL )
|
||||
return;
|
||||
|
||||
type = flags & BREAK_TYPEMASK;
|
||||
char type = flags & BREAK_TYPEMASK;
|
||||
|
||||
if( count == 0 )
|
||||
{
|
||||
@@ -990,9 +969,10 @@ void GAME_EXPORT R_BreakModel( const vec3_t pos, const vec3_t size, const vec3_t
|
||||
// limit to 100 pieces
|
||||
if( count > 100 ) count = 100;
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
vec3_t vecSpot;
|
||||
int j;
|
||||
|
||||
for( j = 0; j < 32; j++ )
|
||||
{
|
||||
@@ -1209,14 +1189,12 @@ apply params for exploding sprite
|
||||
*/
|
||||
void GAME_EXPORT R_Sprite_Explode( TEMPENTITY *pTemp, float scale, int flags )
|
||||
{
|
||||
qboolean noadditive, drawalpha, rotate;
|
||||
|
||||
if( !pTemp )
|
||||
return;
|
||||
|
||||
noadditive = FBitSet( flags, TE_EXPLFLAG_NOADDITIVE );
|
||||
drawalpha = FBitSet( flags, TE_EXPLFLAG_DRAWALPHA );
|
||||
rotate = FBitSet( flags, TE_EXPLFLAG_ROTATE );
|
||||
qboolean noadditive = FBitSet( flags, TE_EXPLFLAG_NOADDITIVE );
|
||||
qboolean drawalpha = FBitSet( flags, TE_EXPLFLAG_DRAWALPHA );
|
||||
qboolean rotate = FBitSet( flags, TE_EXPLFLAG_ROTATE );
|
||||
|
||||
pTemp->entity.curstate.scale = scale;
|
||||
pTemp->entity.baseline.origin[2] = 8.0f;
|
||||
@@ -1242,11 +1220,9 @@ apply params for smoke sprite
|
||||
*/
|
||||
void GAME_EXPORT R_Sprite_Smoke( TEMPENTITY *pTemp, float scale )
|
||||
{
|
||||
int iColor;
|
||||
|
||||
if( !pTemp ) return;
|
||||
|
||||
iColor = COM_RandomLong( 20, 35 );
|
||||
int iColor = COM_RandomLong( 20, 35 );
|
||||
pTemp->entity.curstate.rendermode = kRenderTransAlpha;
|
||||
pTemp->entity.curstate.renderfx = kRenderFxNone;
|
||||
pTemp->entity.baseline.origin[2] = 30;
|
||||
@@ -1262,7 +1238,6 @@ static void R_Spray_Generic( const char *func, const vec3_t pos, const vec3_t di
|
||||
model_t *mod = CL_ModelHandle( modelIndex );
|
||||
float noise = spread / 100.0f;
|
||||
float znoise = noise * 1.5f;
|
||||
int i;
|
||||
|
||||
znoise = Q_min( 1.0f, znoise );
|
||||
|
||||
@@ -1272,10 +1247,9 @@ static void R_Spray_Generic( const char *func, const vec3_t pos, const vec3_t di
|
||||
return;
|
||||
}
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
TEMPENTITY *tent = CL_TempEntAlloc( pos, mod );
|
||||
float rand_speed;
|
||||
vec3_t noise_vec, vout;
|
||||
|
||||
if( !tent )
|
||||
@@ -1290,7 +1264,7 @@ static void R_Spray_Generic( const char *func, const vec3_t pos, const vec3_t di
|
||||
noise_vec[0] = COM_RandomFloat( -noise, noise );
|
||||
noise_vec[1] = COM_RandomFloat( -noise, noise );
|
||||
noise_vec[2] = COM_RandomFloat( 0.0f, znoise );
|
||||
rand_speed = COM_RandomFloat( speed * 0.8f, speed * 1.2f );
|
||||
float rand_speed = COM_RandomFloat( speed * 0.8f, speed * 1.2f );
|
||||
|
||||
VectorAdd( dir, noise_vec, vout );
|
||||
VectorScale( vout, rand_speed, tent->entity.baseline.origin );
|
||||
@@ -1361,7 +1335,6 @@ void GAME_EXPORT R_Sprite_Trail( int type, vec3_t start, vec3_t end, int modelIn
|
||||
TEMPENTITY *pTemp;
|
||||
vec3_t delta, dir;
|
||||
model_t *pmodel;
|
||||
int i;
|
||||
|
||||
if(( pmodel = CL_ModelHandle( modelIndex )) == NULL )
|
||||
return;
|
||||
@@ -1371,7 +1344,7 @@ void GAME_EXPORT R_Sprite_Trail( int type, vec3_t start, vec3_t end, int modelIn
|
||||
|
||||
amp /= 256.0f;
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
vec3_t pos, vel;
|
||||
|
||||
@@ -1412,9 +1385,7 @@ void GAME_EXPORT R_FunnelSprite( const vec3_t org, int modelIndex, int reverse )
|
||||
{
|
||||
TEMPENTITY *pTemp;
|
||||
vec3_t dir, dest;
|
||||
float dist, vel;
|
||||
model_t *pmodel;
|
||||
int i, j;
|
||||
|
||||
if(( pmodel = CL_ModelHandle( modelIndex )) == NULL )
|
||||
{
|
||||
@@ -1422,9 +1393,9 @@ void GAME_EXPORT R_FunnelSprite( const vec3_t org, int modelIndex, int reverse )
|
||||
return;
|
||||
}
|
||||
|
||||
for( i = -8; i < 8; i++ )
|
||||
for( int i = -8; i < 8; i++ )
|
||||
{
|
||||
for( j = -8; j < 8; j++ )
|
||||
for( int j = -8; j < 8; j++ )
|
||||
{
|
||||
pTemp = CL_TempEntAlloc( org, pmodel );
|
||||
if( !pTemp ) return;
|
||||
@@ -1451,9 +1422,9 @@ void GAME_EXPORT R_FunnelSprite( const vec3_t org, int modelIndex, int reverse )
|
||||
pTemp->entity.curstate.framerate = COM_RandomFloat( 0.1f, 0.4f );
|
||||
pTemp->flags = FTENT_ROTATE|FTENT_FADEOUT;
|
||||
|
||||
vel = dest[2] / 8.0f;
|
||||
float vel = dest[2] / 8.0f;
|
||||
if( vel < 64.0f ) vel = 64.0f;
|
||||
dist = VectorNormalizeLength( dir );
|
||||
float dist = VectorNormalizeLength( dir );
|
||||
vel += COM_RandomFloat( 64.0f, 128.0f );
|
||||
VectorScale( dir, vel, pTemp->entity.baseline.origin );
|
||||
pTemp->die = cl.time + (dist / vel) - 0.5f;
|
||||
@@ -1484,8 +1455,7 @@ Make a random ricochet sound
|
||||
*/
|
||||
static void R_RicochetSoundByName( const vec3_t pos, const char *name )
|
||||
{
|
||||
sound_t handle;
|
||||
handle = S_RegisterSound( name );
|
||||
sound_t handle = S_RegisterSound( name );
|
||||
S_StartSound( pos, 0, CHAN_AUTO, handle, VOL_NORM, 1.0, 100, 0 );
|
||||
}
|
||||
|
||||
@@ -1562,10 +1532,9 @@ Spherical shower of models, picks from set
|
||||
void GAME_EXPORT R_TempSphereModel( const vec3_t pos, float speed, float life, int count, int modelIndex )
|
||||
{
|
||||
TEMPENTITY *pTemp;
|
||||
int i;
|
||||
|
||||
// create temp models
|
||||
for( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
pTemp = CL_TempEntAlloc( pos, CL_ModelHandle( modelIndex ));
|
||||
if( !pTemp ) return;
|
||||
@@ -1609,8 +1578,6 @@ Create an explosion (scale is magnitude)
|
||||
*/
|
||||
void GAME_EXPORT R_Explosion( vec3_t pos, int model, float scale, float framerate, int flags )
|
||||
{
|
||||
sound_t hSound;
|
||||
|
||||
if( scale != 0.0f )
|
||||
{
|
||||
// create explosion sprite
|
||||
@@ -1621,10 +1588,8 @@ void GAME_EXPORT R_Explosion( vec3_t pos, int model, float scale, float framerat
|
||||
|
||||
if( !FBitSet( flags, TE_EXPLFLAG_NODLIGHTS ))
|
||||
{
|
||||
dlight_t *dl;
|
||||
|
||||
// big flash
|
||||
dl = CL_AllocDlight( 0 );
|
||||
dlight_t *dl = CL_AllocDlight( 0 );
|
||||
VectorCopy( pos, dl->origin );
|
||||
dl->radius = 200;
|
||||
dl->color.r = 250;
|
||||
@@ -1650,7 +1615,7 @@ void GAME_EXPORT R_Explosion( vec3_t pos, int model, float scale, float framerat
|
||||
const char *name = SoundList_GetRandom( Explode );
|
||||
if( name )
|
||||
{
|
||||
hSound = S_RegisterSound( name );
|
||||
sound_t hSound = S_RegisterSound( name );
|
||||
S_StartSound( pos, 0, CHAN_STATIC, hSound, VOL_NORM, 0.3f, PITCH_NORM, 0 );
|
||||
}
|
||||
}
|
||||
@@ -1667,18 +1632,16 @@ void GAME_EXPORT R_PlayerSprites( int client, int modelIndex, int count, int siz
|
||||
{
|
||||
TEMPENTITY *pTemp;
|
||||
cl_entity_t *pEnt;
|
||||
vec3_t position;
|
||||
vec3_t dir;
|
||||
int i;
|
||||
|
||||
pEnt = CL_GetEntityByIndex( client );
|
||||
|
||||
if( !pEnt || !pEnt->player )
|
||||
return;
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
VectorCopy( pEnt->origin, position );
|
||||
vec3_t position = Vec3( pEnt->origin );
|
||||
position[0] += COM_RandomFloat( -10.0f, 10.0f );
|
||||
position[1] += COM_RandomFloat( -10.0f, 10.0f );
|
||||
position[2] += COM_RandomFloat( -20.0f, 36.0f );
|
||||
@@ -1729,16 +1692,13 @@ void GAME_EXPORT R_FireField( float *org, int radius, int modelIndex, int count,
|
||||
{
|
||||
TEMPENTITY *pTemp;
|
||||
model_t *pmodel;
|
||||
float time;
|
||||
vec3_t pos;
|
||||
int i;
|
||||
|
||||
if(( pmodel = CL_ModelHandle( modelIndex )) == NULL )
|
||||
return;
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
VectorCopy( org, pos );
|
||||
vec3_t pos = Vec3( org );
|
||||
pos[0] += COM_RandomFloat( -radius, radius );
|
||||
pos[1] += COM_RandomFloat( -radius, radius );
|
||||
|
||||
@@ -1767,7 +1727,7 @@ void GAME_EXPORT R_FireField( float *org, int radius, int modelIndex, int count,
|
||||
}
|
||||
|
||||
pTemp->entity.curstate.framerate = COM_RandomFloat( 0.75f, 1.25f );
|
||||
time = life + COM_RandomFloat( -0.25f, 0.5f );
|
||||
float time = life + COM_RandomFloat( -0.25f, 0.5f );
|
||||
pTemp->die = cl.time + time;
|
||||
|
||||
if( pTemp->frameMax > 1 )
|
||||
@@ -1804,13 +1764,12 @@ void GAME_EXPORT R_MultiGunshot( const vec3_t org, const vec3_t dir, const vec3_
|
||||
{
|
||||
pmtrace_t trace;
|
||||
vec3_t right, up;
|
||||
vec3_t vecSrc, vecDir, vecEnd;
|
||||
int i, j, decalIndex;
|
||||
vec3_t vecDir, vecEnd;
|
||||
|
||||
VectorVectors( dir, right, up );
|
||||
VectorCopy( org, vecSrc );
|
||||
vec3_t vecSrc = Vec3( org );
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
// get circular gaussian spread
|
||||
float x, y, z;
|
||||
@@ -1820,7 +1779,7 @@ void GAME_EXPORT R_MultiGunshot( const vec3_t org, const vec3_t dir, const vec3_
|
||||
z = x * x + y * y;
|
||||
} while( z > 1.0f );
|
||||
|
||||
for( j = 0; j < 3; j++ )
|
||||
for( int j = 0; j < 3; j++ )
|
||||
{
|
||||
vecDir[j] = dir[j] + x * noise[0] * right[j] + y * noise[1] * up[j];
|
||||
vecEnd[j] = vecSrc[j] + 4096.0f * vecDir[j];
|
||||
@@ -1842,7 +1801,7 @@ void GAME_EXPORT R_MultiGunshot( const vec3_t org, const vec3_t dir, const vec3_
|
||||
if( pe && ( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP ))
|
||||
{
|
||||
cl_entity_t *e = CL_GetEntityByIndex( pe->info );
|
||||
decalIndex = CL_DecalIndex( decalIndices[COM_RandomLong( 0, decalCount-1 )] );
|
||||
int decalIndex = CL_DecalIndex( decalIndices[COM_RandomLong( 0, decalCount-1 )] );
|
||||
CL_DecalShoot( decalIndex, e->index, 0, trace.endpos, 0 );
|
||||
}
|
||||
}
|
||||
@@ -1881,7 +1840,6 @@ void CL_ParseTempEntity( sizebuf_t *msg, connprotocol_t proto )
|
||||
{
|
||||
sizebuf_t buf, *pbuf;
|
||||
byte msg_data[2048];
|
||||
int iSize;
|
||||
int type, color, count, flags;
|
||||
int decalIndex = 0, modelIndex = 0, entityIndex = 0;
|
||||
float scale, life, frameRate, vel, random;
|
||||
@@ -1896,7 +1854,7 @@ void CL_ParseTempEntity( sizebuf_t *msg, connprotocol_t proto )
|
||||
|
||||
if( proto != PROTO_GOLDSRC )
|
||||
{
|
||||
iSize = MSG_ReadWord( msg );
|
||||
int iSize = MSG_ReadWord( msg );
|
||||
|
||||
// this will probably be fatal anyway
|
||||
if( iSize > sizeof( msg_data ))
|
||||
@@ -2430,28 +2388,25 @@ static void CL_ClearLightStyles( void )
|
||||
|
||||
void CL_SetLightstyle( int style, const char *s, float f )
|
||||
{
|
||||
int i;
|
||||
lightstyle_t *ls;
|
||||
|
||||
if( unlikely( style < 0 || style >= MAX_LIGHTSTYLES ))
|
||||
{
|
||||
Con_Printf( S_WARN "%s: ignored invalid lightstyle id %d\n", __func__, style );
|
||||
return;
|
||||
}
|
||||
|
||||
ls = &cl.lightstyles[style];
|
||||
lightstyle_t *ls = &cl.lightstyles[style];
|
||||
|
||||
ls->length = Q_strncpy( ls->pattern, s, sizeof( ls->pattern ));
|
||||
ls->time = f; // set local time
|
||||
|
||||
for( i = 0; i < ls->length; i++ )
|
||||
for( int i = 0; i < ls->length; i++ )
|
||||
ls->map[i] = (float)(s[i] - 'a');
|
||||
|
||||
ls->interp = (ls->length <= 1) ? false : true;
|
||||
|
||||
// check for allow interpolate
|
||||
// NOTE: fast flickering styles looks ugly when interpolation is running
|
||||
for( i = 0; i < ( ls->length - 1 ); i++ )
|
||||
for( int i = 0; i < ( ls->length - 1 ); i++ )
|
||||
{
|
||||
float val1 = ls->map[( i + 0 ) % ls->length];
|
||||
float val2 = ls->map[( i + 1 ) % ls->length];
|
||||
@@ -2588,9 +2543,8 @@ void CL_DecayLights( void )
|
||||
{
|
||||
const float time = cl.time;
|
||||
const float dt = cl.time - cl.oldtime;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < MAX_DLIGHTS; i++ )
|
||||
for( int i = 0; i < MAX_DLIGHTS; i++ )
|
||||
{
|
||||
dlight_t *dl = &cl_dlights[i];
|
||||
|
||||
@@ -2608,7 +2562,7 @@ void CL_DecayLights( void )
|
||||
memset( dl, 0, sizeof( *dl ));
|
||||
}
|
||||
|
||||
for( i = 0; i < MAX_ELIGHTS; i++ )
|
||||
for( int i = 0; i < MAX_ELIGHTS; i++ )
|
||||
{
|
||||
dlight_t *dl = &cl_elights[i];
|
||||
|
||||
@@ -2650,7 +2604,6 @@ static void CL_UpdateFlashlight( cl_entity_t *ent )
|
||||
{
|
||||
vec3_t forward, view_ofs;
|
||||
vec3_t vecSrc, vecEnd;
|
||||
float falloff;
|
||||
pmtrace_t trace;
|
||||
cl_entity_t *hit;
|
||||
dlight_t *dl;
|
||||
@@ -2695,7 +2648,7 @@ static void CL_UpdateFlashlight( cl_entity_t *ent )
|
||||
VectorCopy( trace->endpos, dl->origin );
|
||||
#endif
|
||||
// compute falloff
|
||||
falloff = trace.fraction * FLASHLIGHT_DISTANCE;
|
||||
float falloff = trace.fraction * FLASHLIGHT_DISTANCE;
|
||||
if( falloff < 500.0f ) falloff = 1.0f;
|
||||
else falloff = 500.0f / falloff;
|
||||
falloff *= falloff;
|
||||
@@ -2879,25 +2832,22 @@ if cl_testlights is set, create 32 lights models
|
||||
*/
|
||||
void CL_TestLights( void )
|
||||
{
|
||||
int i, j, numLights;
|
||||
vec3_t forward, right;
|
||||
float f, r;
|
||||
dlight_t *dl;
|
||||
|
||||
if( !cl_testlights.value )
|
||||
return;
|
||||
|
||||
numLights = bound( 1, cl_testlights.value, MAX_DLIGHTS );
|
||||
int numLights = bound( 1, cl_testlights.value, MAX_DLIGHTS );
|
||||
AngleVectors( cl.viewangles, forward, right, NULL );
|
||||
|
||||
for( i = 0; i < numLights; i++ )
|
||||
for( int i = 0; i < numLights; i++ )
|
||||
{
|
||||
dl = &cl_dlights[i];
|
||||
dlight_t *dl = &cl_dlights[i];
|
||||
|
||||
r = 64 * ((i % 4) - 1.5f );
|
||||
f = 64 * ( i / 4) + 128;
|
||||
float r = 64 * ((i % 4) - 1.5f );
|
||||
float f = 64 * ( i / 4) + 128;
|
||||
|
||||
for( j = 0; j < 3; j++ )
|
||||
for( int j = 0; j < 3; j++ )
|
||||
dl->origin[j] = cl.simorg[j] + forward[j] * f + right[j] * r;
|
||||
|
||||
dl->color.r = ((((i % 6) + 1) & 1)>>0) * 255;
|
||||
@@ -2997,13 +2947,11 @@ get decal global index from decalname
|
||||
*/
|
||||
int GAME_EXPORT CL_DecalIndexFromName( const char *name )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( COM_StringEmptyOrNULL( name ))
|
||||
return 0;
|
||||
|
||||
// look through the loaded sprite name list for SpriteName
|
||||
for( i = 1; i < MAX_DECALS && host.draw_decals[i][0]; i++ )
|
||||
for( int i = 1; i < MAX_DECALS && host.draw_decals[i][0]; i++ )
|
||||
{
|
||||
if( !Q_stricmp( name, host.draw_decals[i] ))
|
||||
return i;
|
||||
@@ -3100,13 +3048,11 @@ e.g. by demo request
|
||||
*/
|
||||
void CL_ClearStaticEntities( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( host.type == HOST_DEDICATED )
|
||||
return;
|
||||
|
||||
// clear out efrags in case the level hasn't been reloaded
|
||||
for( i = 0; i < cl.worldmodel->numleafs; i++ )
|
||||
for( int i = 0; i < cl.worldmodel->numleafs; i++ )
|
||||
cl.worldmodel->leafs[i+1].efrags = NULL;
|
||||
|
||||
clgame.numStatics = 0;
|
||||
|
||||
@@ -192,11 +192,9 @@ SCR_PlayCinematic
|
||||
qboolean SCR_PlayCinematic( const char *arg )
|
||||
{
|
||||
int x, y, w, h;
|
||||
const char *fullpath;
|
||||
const char *fullpath = FS_GetDiskPath( arg, false );
|
||||
double video_ratio, screen_ratio, scale;
|
||||
|
||||
fullpath = FS_GetDiskPath( arg, false );
|
||||
|
||||
if( FS_FileExists( arg, false ) && !fullpath )
|
||||
{
|
||||
Con_Printf( S_ERROR "Couldn't load %s from packfile. Please extract it\n", arg );
|
||||
|
||||
@@ -187,18 +187,15 @@ merge refdef with overview settings
|
||||
static void V_RefApplyOverview( ref_viewpass_t *rvp )
|
||||
{
|
||||
ref_overview_t *ov = &clgame.overView;
|
||||
float aspect;
|
||||
float size_x, size_y;
|
||||
vec2_t mins, maxs;
|
||||
|
||||
if( !CL_IsDevOverviewMode( ))
|
||||
return;
|
||||
|
||||
// NOTE: Xash3D may use 16:9 or 16:10 aspects
|
||||
aspect = (float)refState.width / (float)refState.height;
|
||||
float aspect = (float)refState.width / (float)refState.height;
|
||||
|
||||
size_x = fabs( 8192.0f / ov->flZoom );
|
||||
size_y = fabs( 8192.0f / (ov->flZoom * aspect ));
|
||||
float size_x = fabs( 8192.0f / ov->flZoom );
|
||||
float size_y = fabs( 8192.0f / (ov->flZoom * aspect ));
|
||||
|
||||
// compute rectangle
|
||||
ov->xLeft = -(size_x / 2);
|
||||
@@ -214,8 +211,8 @@ static void V_RefApplyOverview( ref_viewpass_t *rvp )
|
||||
|
||||
VectorCopy( ov->origin, rvp->vieworigin );
|
||||
rvp->vieworigin[2] = ov->zFar + ov->zNear;
|
||||
Vector2Copy( rvp->vieworigin, mins );
|
||||
Vector2Copy( rvp->vieworigin, maxs );
|
||||
vec2_t mins = Vec2( rvp->vieworigin );
|
||||
vec2_t maxs = Vec2( rvp->vieworigin );
|
||||
|
||||
mins[!ov->rotated] += ov->xLeft;
|
||||
maxs[!ov->rotated] += ov->xRight;
|
||||
@@ -238,13 +235,11 @@ V_CalcFov
|
||||
*/
|
||||
static float V_CalcFov( float *fov_x, float width, float height )
|
||||
{
|
||||
float x, half_fov_y;
|
||||
|
||||
if( *fov_x < 1.0f || *fov_x > 179.0f )
|
||||
*fov_x = 90.0f; // default value
|
||||
|
||||
x = width / tan( DEG2RAD( *fov_x ) * 0.5f );
|
||||
half_fov_y = atan( height / x );
|
||||
float x = width / tan( DEG2RAD( *fov_x ) * 0.5f );
|
||||
float half_fov_y = atan( height / x );
|
||||
|
||||
return RAD2DEG( half_fov_y ) * 2;
|
||||
}
|
||||
@@ -500,13 +495,12 @@ static void R_ShowTree( void )
|
||||
{
|
||||
float x = (float)((refState.width - (int)POINT_SIZE) >> 1);
|
||||
float y = NODE_INTERVAL_Y(1.0f);
|
||||
mleaf_t *viewleaf;
|
||||
|
||||
if( !cl.worldmodel || !r_showtree.value )
|
||||
return;
|
||||
|
||||
world.recursion_level = 0;
|
||||
viewleaf = Mod_PointInLeaf( refState.vieworg, cl.worldmodel->nodes, cl.worldmodel );
|
||||
mleaf_t *viewleaf = Mod_PointInLeaf( refState.vieworg, cl.worldmodel->nodes, cl.worldmodel );
|
||||
|
||||
ref.dllFuncs.TriRenderMode( kRenderTransTexture );
|
||||
|
||||
|
||||
@@ -182,13 +182,11 @@ Con_SetColor
|
||||
*/
|
||||
static void Con_SetColor( void )
|
||||
{
|
||||
int r, g, b;
|
||||
int num;
|
||||
|
||||
if( !FBitSet( con_color.flags, FCVAR_CHANGED ))
|
||||
return;
|
||||
|
||||
num = sscanf( con_color.string, "%i %i %i", &r, &g, &b );
|
||||
int r, g, b;
|
||||
int num = sscanf( con_color.string, "%i %i %i", &r, &g, &b );
|
||||
|
||||
switch( num )
|
||||
{
|
||||
@@ -213,9 +211,7 @@ Con_ClearNotify
|
||||
*/
|
||||
void Con_ClearNotify( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < CON_LINES_COUNT; i++ )
|
||||
for( int i = 0; i < CON_LINES_COUNT; i++ )
|
||||
CON_LINES( i ).addtime = 0.0;
|
||||
}
|
||||
|
||||
@@ -310,15 +306,13 @@ Con_SetTimes_f
|
||||
*/
|
||||
static void Con_SetTimes_f( void )
|
||||
{
|
||||
int newtimes;
|
||||
|
||||
if( Cmd_Argc() != 2 )
|
||||
{
|
||||
Con_Printf( S_USAGE "contimes <n lines>\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
newtimes = Q_atoi( Cmd_Argv( 1 ) );
|
||||
int newtimes = Q_atoi( Cmd_Argv( 1 ) );
|
||||
con.num_times = bound( CON_TIMES, newtimes, CON_MAX_TIMES );
|
||||
}
|
||||
|
||||
@@ -333,15 +327,12 @@ went backwards)
|
||||
*/
|
||||
static void Con_FixTimes( void )
|
||||
{
|
||||
double diff;
|
||||
int i;
|
||||
|
||||
if( con.lines_count <= 0 ) return;
|
||||
|
||||
diff = cl.time - CON_LINES_LAST().addtime;
|
||||
double diff = cl.time - CON_LINES_LAST().addtime;
|
||||
if( diff >= 0.0 ) return; // nothing to fix
|
||||
|
||||
for( i = 0; i < con.lines_count; i++ )
|
||||
for( int i = 0; i < con.lines_count; i++ )
|
||||
CON_LINES( i ).addtime += diff;
|
||||
}
|
||||
|
||||
@@ -428,8 +419,7 @@ Appends a given string as a new line to the console.
|
||||
*/
|
||||
static void Con_AddLine( const char *line, int length, qboolean newline )
|
||||
{
|
||||
char *putpos;
|
||||
con_lineinfo_t *p;
|
||||
char *putpos;
|
||||
|
||||
if( !con.initialized || !con.buffer )
|
||||
return;
|
||||
@@ -442,6 +432,7 @@ static void Con_AddLine( const char *line, int length, qboolean newline )
|
||||
while( !( putpos = Con_BytesLeft( length )) || con.lines_count >= con.maxlines )
|
||||
Con_DeleteLine();
|
||||
|
||||
con_lineinfo_t *p;
|
||||
if( newline )
|
||||
{
|
||||
memcpy( putpos, line, length );
|
||||
@@ -475,12 +466,11 @@ If the line width has changed, reformat the buffer.
|
||||
static void Con_CheckResize( void )
|
||||
{
|
||||
int charWidth = 8;
|
||||
int width;
|
||||
|
||||
if( con.curFont && con.curFont->hFontTexture )
|
||||
charWidth = con.curFont->charWidths['O'] - 1;
|
||||
|
||||
width = ( refState.width / charWidth ) - 2;
|
||||
int width = ( refState.width / charWidth ) - 2;
|
||||
if( !ref.initialized ) width = (640 / 5);
|
||||
|
||||
if( width == con.linewidth )
|
||||
@@ -611,13 +601,12 @@ Con_LoadConchars
|
||||
*/
|
||||
static void Con_LoadConchars( void )
|
||||
{
|
||||
int i, fontSize;
|
||||
|
||||
// load all the console fonts
|
||||
for( i = 0; i < CON_NUMFONTS; i++ )
|
||||
for( int i = 0; i < CON_NUMFONTS; i++ )
|
||||
Con_LoadConsoleFont( i, con.chars + i );
|
||||
|
||||
// select properly fontsize
|
||||
int fontSize;
|
||||
if( con_fontnum.value >= 0 && con_fontnum.value <= CON_NUMFONTS - 1 )
|
||||
fontSize = con_fontnum.value;
|
||||
else if( refState.width <= 640 )
|
||||
@@ -675,7 +664,6 @@ int Con_UtfMoveLeft( char *str, int pos )
|
||||
{
|
||||
utfstate_t state = { 0 };
|
||||
int k = 0;
|
||||
int i;
|
||||
|
||||
if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
|
||||
return pos - 1;
|
||||
@@ -683,7 +671,7 @@ int Con_UtfMoveLeft( char *str, int pos )
|
||||
if( pos == 1 )
|
||||
return 0;
|
||||
|
||||
for( i = 0; i < pos - 1; i++ )
|
||||
for( int i = 0; i < pos - 1; i++ )
|
||||
{
|
||||
if( Q_DecodeUTF8( &state, (byte)str[i] ))
|
||||
k = i + 1;
|
||||
@@ -702,12 +690,11 @@ get next of previous printful char
|
||||
int Con_UtfMoveRight( char *str, int pos, int length )
|
||||
{
|
||||
utfstate_t state = { 0 };
|
||||
int i;
|
||||
|
||||
if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
|
||||
return pos + 1;
|
||||
|
||||
for( i = pos; i <= length; i++ )
|
||||
for( int i = pos; i <= length; i++ )
|
||||
{
|
||||
if( Q_DecodeUTF8( &state, (byte)str[i] ))
|
||||
return i + 1;
|
||||
@@ -718,20 +705,15 @@ int Con_UtfMoveRight( char *str, int pos, int length )
|
||||
|
||||
static void Con_DrawCharToConback( int num, const byte *conchars, byte *dest )
|
||||
{
|
||||
int row, col;
|
||||
const byte *source;
|
||||
int drawline;
|
||||
int x;
|
||||
int row = num >> 4;
|
||||
int col = num & 15;
|
||||
const byte *source = conchars + (row << 10) + (col << 3);
|
||||
|
||||
row = num >> 4;
|
||||
col = num & 15;
|
||||
source = conchars + (row << 10) + (col << 3);
|
||||
|
||||
drawline = 8;
|
||||
int drawline = 8;
|
||||
|
||||
while( drawline-- )
|
||||
{
|
||||
for( x = 0; x < 8; x++ )
|
||||
for( int x = 0; x < 8; x++ )
|
||||
if( source[x] != 255 )
|
||||
dest[x] = 0x60 + source[x];
|
||||
source += 128;
|
||||
@@ -1118,15 +1100,12 @@ Field_Paste
|
||||
*/
|
||||
static void Field_Paste( field_t *edit )
|
||||
{
|
||||
char *cbd;
|
||||
int i, pasteLen;
|
||||
|
||||
cbd = Sys_GetClipboardData();
|
||||
char *cbd = Sys_GetClipboardData();
|
||||
if( !cbd ) return;
|
||||
|
||||
// send as if typed, so insert / overstrike works properly
|
||||
pasteLen = Q_strlen( cbd );
|
||||
for( i = 0; i < pasteLen; i++ )
|
||||
int pasteLen = Q_strlen( cbd );
|
||||
for( int i = 0; i < pasteLen; i++ )
|
||||
Field_CharEvent( edit, cbd[i] );
|
||||
}
|
||||
|
||||
@@ -1154,8 +1133,6 @@ Key events are used for non-printable characters, others are gotten from char ev
|
||||
*/
|
||||
static void Field_KeyDownEvent( field_t *edit, int key )
|
||||
{
|
||||
int len;
|
||||
|
||||
// shift-insert is paste
|
||||
if((( key == K_INS ) || ( key == K_KP_INS )) && Key_IsDown( K_SHIFT ))
|
||||
{
|
||||
@@ -1163,7 +1140,7 @@ static void Field_KeyDownEvent( field_t *edit, int key )
|
||||
return;
|
||||
}
|
||||
|
||||
len = Q_strlen( edit->buffer );
|
||||
int len = Q_strlen( edit->buffer );
|
||||
|
||||
if( key == K_DEL )
|
||||
{
|
||||
@@ -1225,8 +1202,6 @@ Field_CharEvent
|
||||
*/
|
||||
static void Field_CharEvent( field_t *edit, int ch )
|
||||
{
|
||||
int len;
|
||||
|
||||
if( ch == 'v' - 'a' + 1 )
|
||||
{
|
||||
// ctrl-v is paste
|
||||
@@ -1241,7 +1216,7 @@ static void Field_CharEvent( field_t *edit, int ch )
|
||||
return;
|
||||
}
|
||||
|
||||
len = Q_strlen( edit->buffer );
|
||||
int len = Q_strlen( edit->buffer );
|
||||
|
||||
if( ch == 'a' - 'a' + 1 )
|
||||
{
|
||||
@@ -1286,7 +1261,6 @@ Field_DrawInputLine
|
||||
*/
|
||||
static int Field_DrawInputLine( int x, int y, const field_t *edit, byte alpha, qboolean cursor )
|
||||
{
|
||||
int curPos;
|
||||
char str[MAX_SYSPATH];
|
||||
rgba_t colorDefault;
|
||||
const int prestep = bound( 0, edit->scroll, sizeof( edit->buffer ) - 1 );
|
||||
@@ -1303,6 +1277,7 @@ static int Field_DrawInputLine( int x, int y, const field_t *edit, byte alpha, q
|
||||
|
||||
// calc cursor position
|
||||
str[cursorCharPos] = 0;
|
||||
int curPos;
|
||||
CL_DrawStringLen( con.curFont, str, &curPos, NULL, FONT_DRAW_UTF8 );
|
||||
|
||||
// draw the cursor
|
||||
@@ -1415,10 +1390,7 @@ static void Con_HistoryAppend( con_history_t *self, const field_t *from )
|
||||
|
||||
static void Con_LoadHistory( con_history_t *self )
|
||||
{
|
||||
file_t *fd;
|
||||
int i;
|
||||
|
||||
fd = FS_Open( "console_history.txt", "rb", true );
|
||||
file_t *fd = FS_Open( "console_history.txt", "rb", true );
|
||||
|
||||
if( !fd )
|
||||
return;
|
||||
@@ -1448,7 +1420,7 @@ static void Con_LoadHistory( con_history_t *self )
|
||||
|
||||
FS_Close( fd );
|
||||
|
||||
for( i = self->next; i < CON_HISTORY; i++ )
|
||||
for( int i = self->next; i < CON_HISTORY; i++ )
|
||||
{
|
||||
history_line_t *f = &self->lines[i];
|
||||
|
||||
@@ -1460,17 +1432,15 @@ static void Con_LoadHistory( con_history_t *self )
|
||||
|
||||
static void Con_SaveHistory( con_history_t *self )
|
||||
{
|
||||
int historyStart = self->next - CON_HISTORY, i;
|
||||
file_t *f;
|
||||
|
||||
// do not save history if nothing was executed
|
||||
if( self->next == 0 )
|
||||
return;
|
||||
|
||||
int historyStart = self->next - CON_HISTORY;
|
||||
if( historyStart < 0 )
|
||||
historyStart = 0;
|
||||
|
||||
f = FS_Open( "console_history.txt", "wb", true );
|
||||
file_t *f = FS_Open( "console_history.txt", "wb", true );
|
||||
|
||||
if( !f )
|
||||
{
|
||||
@@ -1478,7 +1448,7 @@ static void Con_SaveHistory( con_history_t *self )
|
||||
return;
|
||||
}
|
||||
|
||||
for( i = historyStart; i < self->next; i++ )
|
||||
for( int i = historyStart; i < self->next; i++ )
|
||||
{
|
||||
const char *s = self->lines[i % CON_HISTORY].buffer;
|
||||
|
||||
@@ -1704,15 +1674,13 @@ The input line scrolls horizontally if typing goes beyond the right edge
|
||||
*/
|
||||
static void Con_DrawInput( int lines )
|
||||
{
|
||||
int x, y;
|
||||
|
||||
// don't draw anything (always draw if not active)
|
||||
if( cls.key_dest != key_console || !con.curFont )
|
||||
return;
|
||||
|
||||
y = lines - ( con.curFont->charHeight * 2 );
|
||||
int y = lines - ( con.curFont->charHeight * 2 );
|
||||
CL_DrawCharacter( con.curFont->charWidths[' '], y, ']', g_color_table[7], con.curFont, 0 );
|
||||
x = Field_DrawInputLine( con.curFont->charWidths[' ']*2, y, &con.input, 255, true );
|
||||
int x = Field_DrawInputLine( con.curFont->charWidths[' ']*2, y, &con.input, 255, true );
|
||||
|
||||
// HACKHACK: avoid rendering issues when scroll != 0
|
||||
if( con_showcompletion.value && con.input.scroll == 0 )
|
||||
@@ -1744,18 +1712,16 @@ Custom debug messages
|
||||
static int Con_DrawDebugLines( void )
|
||||
{
|
||||
notify_t *notify = con.notify;
|
||||
int i, count = 0;
|
||||
int defaultX;
|
||||
int count = 0;
|
||||
int y = 20;
|
||||
int fontTall;
|
||||
|
||||
if( !con.curFont || !con.curFont->valid )
|
||||
return 0;
|
||||
|
||||
defaultX = refState.width / 4;
|
||||
fontTall = con.curFont->charHeight + 1;
|
||||
int defaultX = refState.width / 4;
|
||||
int fontTall = con.curFont->charHeight + 1;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( con.notify ); i++, notify++ )
|
||||
for( int i = 0; i < ARRAYSIZE( con.notify ); i++, notify++ )
|
||||
{
|
||||
int x, len;
|
||||
|
||||
@@ -1789,19 +1755,18 @@ Draws the debug messages (not passed to console history)
|
||||
void Con_DrawDebug( void )
|
||||
{
|
||||
static double timeStart;
|
||||
string dlstring;
|
||||
int x, y;
|
||||
|
||||
if( scr_download.value != -1.0f )
|
||||
{
|
||||
string dlstring;
|
||||
int length;
|
||||
Q_snprintf( dlstring, sizeof( dlstring ), "Downloading [%d remaining]: ^2%s^7 %5.1f%% time %.f secs",
|
||||
host.downloadcount, host.downloadfile, scr_download.value, Platform_DoubleTime() - timeStart );
|
||||
|
||||
Con_DrawStringLen( dlstring, &length, NULL );
|
||||
length = Q_max( length, 300 );
|
||||
x = refState.width - length * 1.05f;
|
||||
y = con.curFont->charHeight * 1.05f;
|
||||
int x = refState.width - length * 1.05f;
|
||||
int y = con.curFont->charHeight * 1.05f;
|
||||
Con_DrawString( x, y, dlstring, g_color_table[7] );
|
||||
}
|
||||
else
|
||||
@@ -1829,15 +1794,15 @@ Draws the last few lines of output transparently over the game top
|
||||
static void Con_DrawNotify( void )
|
||||
{
|
||||
double time = cl.time;
|
||||
int i, x, y = 0;
|
||||
int y = 0;
|
||||
|
||||
if( !con.curFont ) return;
|
||||
|
||||
x = con.curFont->charWidths[' ']; // offset one space at left screen side
|
||||
int x = con.curFont->charWidths[' ']; // offset one space at left screen side
|
||||
|
||||
if( host.allow_console && !Con_BackgroundMapActive( ))
|
||||
{
|
||||
for( i = Q_max( 0, CON_LINES_COUNT - con.num_times ); i < CON_LINES_COUNT; i++ )
|
||||
for( int i = Q_max( 0, CON_LINES_COUNT - con.num_times ); i < CON_LINES_COUNT; i++ )
|
||||
{
|
||||
con_lineinfo_t *l = &CON_LINES( i );
|
||||
|
||||
@@ -1905,13 +1870,13 @@ of it based on con.backscroll.
|
||||
*/
|
||||
static void Con_LastVisibleLine( int *lastline )
|
||||
{
|
||||
int i, lines_seen = 0;
|
||||
int lines_seen = 0;
|
||||
|
||||
con.backscroll = Q_max( 0, con.backscroll );
|
||||
*lastline = 0;
|
||||
|
||||
// now count until we saw con_backscroll actual lines
|
||||
for( i = CON_LINES_COUNT - 1; i >= 0; i-- )
|
||||
for( int i = CON_LINES_COUNT - 1; i >= 0; i-- )
|
||||
{
|
||||
// line is the last visible line?
|
||||
*lastline = i;
|
||||
@@ -2086,8 +2051,6 @@ void Con_DrawVersion( void )
|
||||
{
|
||||
// draws the current build
|
||||
byte *color = g_color_table[7];
|
||||
int stringLen, charH = 0;
|
||||
int start, height = refState.height;
|
||||
string curbuild;
|
||||
|
||||
if( !scr_drawversion.value )
|
||||
@@ -2116,9 +2079,10 @@ void Con_DrawVersion( void )
|
||||
XASH_ENGINE_NAME " v%i/" XASH_VERSION " (%s-%s build %i)", PROTOCOL_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
|
||||
}
|
||||
|
||||
int stringLen, charH = 0;
|
||||
Con_DrawStringLen( curbuild, &stringLen, &charH );
|
||||
start = refState.width - stringLen * 1.05f;
|
||||
height -= charH * 1.05f;
|
||||
int start = refState.width - stringLen * 1.05f;
|
||||
int height = refState.height - charH * 1.05f;
|
||||
|
||||
Con_DrawString( start, height, curbuild, color );
|
||||
}
|
||||
@@ -2132,8 +2096,6 @@ Scroll it up or down
|
||||
*/
|
||||
void Con_RunConsole( void )
|
||||
{
|
||||
float lines_per_frame;
|
||||
|
||||
Con_SetColor( );
|
||||
|
||||
// decide on the destination height of the console
|
||||
@@ -2149,7 +2111,7 @@ void Con_RunConsole( void )
|
||||
}
|
||||
else con.showlines = 0; // none visible
|
||||
|
||||
lines_per_frame = fabs( scr_conspeed.value ) * host.realframetime;
|
||||
float lines_per_frame = fabs( scr_conspeed.value ) * host.realframetime;
|
||||
|
||||
if( con.showlines < con.vislines )
|
||||
{
|
||||
@@ -2224,9 +2186,7 @@ void Con_CharEvent( int key )
|
||||
|
||||
static int Con_LoadSimpleConback( const char *name, int flags )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 5; i++ )
|
||||
for( int i = 0; i < 5; i++ )
|
||||
{
|
||||
string path;
|
||||
|
||||
@@ -2311,15 +2271,13 @@ void Con_VidInit( void )
|
||||
{
|
||||
lmp_t *cb = (lmp_t *)FS_LoadFile( "gfx/conback.lmp", &length, false );
|
||||
char ver[64];
|
||||
byte *dest;
|
||||
int x, y, len;
|
||||
|
||||
if( cb && cb->width == 320 && cb->height == 200 )
|
||||
{
|
||||
len = Q_snprintf( ver, 64, "%i", Q_buildnum( )); // can store only buildnum
|
||||
dest = (byte *)(cb + 1) + 320 * 186 + 320 - 11 - 8 * len;
|
||||
y = len;
|
||||
for( x = 0; x < y; x++ )
|
||||
int len = Q_snprintf( ver, 64, "%i", Q_buildnum( )); // can store only buildnum
|
||||
byte *dest = (byte *)(cb + 1) + 320 * 186 + 320 - 11 - 8 * len;
|
||||
int y = len;
|
||||
for( int x = 0; x < y; x++ )
|
||||
Con_DrawCharToConback( ver[x], buf, dest + (x << 3));
|
||||
con.background = ref.dllFuncs.GL_LoadTexture( "#gfx/conback.lmp", (byte *)cb, length, TF_IMAGE );
|
||||
}
|
||||
@@ -2344,8 +2302,7 @@ Con_InvalidateFonts
|
||||
*/
|
||||
void Con_InvalidateFonts( void )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < ARRAYSIZE( con.chars ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( con.chars ); i++ )
|
||||
CL_FreeFont( &con.chars[i] );
|
||||
con.curFont = NULL;
|
||||
}
|
||||
@@ -2399,9 +2356,8 @@ static void Test_RunConHistory( void )
|
||||
const char *strs1[] = { "map t0a0", "quit", "wtf", "wtf", "", "nyan" };
|
||||
const char *strs2[] = { "nyan", "wtf", "quit", "map t0a0" };
|
||||
const char *testbackup = "unfinished_edit";
|
||||
int i;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( strs1 ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( strs1 ); i++ )
|
||||
{
|
||||
Field_Set( &input, strs1[i] );
|
||||
Con_HistoryAppend( &hist, &input );
|
||||
@@ -2409,7 +2365,7 @@ static void Test_RunConHistory( void )
|
||||
|
||||
Field_Set( &input, testbackup );
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( strs2 ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( strs2 ); i++ )
|
||||
{
|
||||
Con_HistoryUp( &hist, &input );
|
||||
TASSERT_STR( input.buffer, strs2[i] );
|
||||
@@ -2418,7 +2374,7 @@ static void Test_RunConHistory( void )
|
||||
// check for overrun
|
||||
Con_HistoryUp( &hist, &input );
|
||||
|
||||
for( i = ARRAYSIZE( strs2 ) - 1; i >= 0; i-- )
|
||||
for( int i = ARRAYSIZE( strs2 ) - 1; i >= 0; i-- )
|
||||
{
|
||||
TASSERT_STR( input.buffer, strs2[i] );
|
||||
Con_HistoryDown( &hist, &input );
|
||||
|
||||
@@ -172,8 +172,6 @@ Initialize CD playlist
|
||||
*/
|
||||
static void CL_InitCDAudio( const char *filename )
|
||||
{
|
||||
byte *afile;
|
||||
char *pfile;
|
||||
string token;
|
||||
int c = 0;
|
||||
|
||||
@@ -183,10 +181,10 @@ static void CL_InitCDAudio( const char *filename )
|
||||
CL_CreatePlaylist( filename );
|
||||
}
|
||||
|
||||
afile = FS_LoadFile( filename, NULL, false );
|
||||
byte *afile = FS_LoadFile( filename, NULL, false );
|
||||
if( !afile ) return;
|
||||
|
||||
pfile = (char *)afile;
|
||||
char *pfile = (char *)afile;
|
||||
|
||||
// format: trackname\n [num]
|
||||
while(( pfile = COM_ParseFile( pfile, token, sizeof( token ))) != NULL )
|
||||
@@ -318,14 +316,12 @@ draw hudsprite routine
|
||||
*/
|
||||
void SPR_AdjustSize( float *x, float *y, float *w, float *h )
|
||||
{
|
||||
float xscale, yscale;
|
||||
|
||||
if( refState.width == clgame.scrInfo.iWidth && refState.height == clgame.scrInfo.iHeight )
|
||||
return;
|
||||
|
||||
// scale for screen sizes
|
||||
xscale = refState.width / (float)clgame.scrInfo.iWidth;
|
||||
yscale = refState.height / (float)clgame.scrInfo.iHeight;
|
||||
float xscale = refState.width / (float)clgame.scrInfo.iWidth;
|
||||
float yscale = refState.height / (float)clgame.scrInfo.iHeight;
|
||||
|
||||
*x *= xscale;
|
||||
*y *= yscale;
|
||||
@@ -369,7 +365,6 @@ draw hudsprite routine
|
||||
static void SPR_DrawGeneric( int frame, float x, float y, float width, float height, const wrect_t *prc )
|
||||
{
|
||||
float s1, s2, t1, t2;
|
||||
int texnum;
|
||||
|
||||
if( width == -1 && height == -1 )
|
||||
{
|
||||
@@ -382,7 +377,7 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei
|
||||
height = h;
|
||||
}
|
||||
|
||||
texnum = R_GetSpriteTexture( clgame.ds.pSprite, frame );
|
||||
int texnum = R_GetSpriteTexture( clgame.ds.pSprite, frame );
|
||||
|
||||
if( prc )
|
||||
{
|
||||
@@ -430,11 +425,8 @@ called each frame
|
||||
void CL_DrawCenterPrint( void )
|
||||
{
|
||||
cl_font_t *font = Con_GetCurFont();
|
||||
char *pText;
|
||||
int i, j, x, y;
|
||||
int width, lineLength;
|
||||
byte *colorDefault, line[MAX_LINELENGTH];
|
||||
int charWidth, charHeight;
|
||||
byte line[MAX_LINELENGTH];
|
||||
int charHeight;
|
||||
|
||||
if( !clgame.centerPrint.time )
|
||||
return;
|
||||
@@ -446,17 +438,17 @@ void CL_DrawCenterPrint( void )
|
||||
return;
|
||||
}
|
||||
|
||||
y = clgame.centerPrint.y; // start y
|
||||
colorDefault = g_color_table[7];
|
||||
pText = clgame.centerPrint.message;
|
||||
int y = clgame.centerPrint.y; // start y
|
||||
byte *colorDefault = g_color_table[7];
|
||||
char *pText = clgame.centerPrint.message;
|
||||
|
||||
CL_DrawCharacterLen( font, 0, NULL, &charHeight );
|
||||
CL_SetFontRendermode( font );
|
||||
CL_SetFontColor( font, colorDefault );
|
||||
for( i = 0; i < clgame.centerPrint.lines; i++ )
|
||||
for( int i = 0; i < clgame.centerPrint.lines; i++ )
|
||||
{
|
||||
lineLength = 0;
|
||||
width = 0;
|
||||
int lineLength = 0;
|
||||
int width = 0;
|
||||
|
||||
while( *pText && *pText != '\n' && lineLength < MAX_LINELENGTH )
|
||||
{
|
||||
@@ -466,6 +458,7 @@ void CL_DrawCenterPrint( void )
|
||||
continue;
|
||||
|
||||
line[lineLength] = number;
|
||||
int charWidth;
|
||||
CL_DrawCharacterLen( font, number, &charWidth, NULL );
|
||||
width += charWidth;
|
||||
lineLength++;
|
||||
@@ -477,9 +470,9 @@ void CL_DrawCenterPrint( void )
|
||||
pText++; // Skip LineFeed
|
||||
line[lineLength] = 0;
|
||||
|
||||
x = CL_AdjustXPos( -1, width, clgame.centerPrint.totalWidth );
|
||||
int x = CL_AdjustXPos( -1, width, clgame.centerPrint.totalWidth );
|
||||
|
||||
for( j = 0; j < lineLength; j++ )
|
||||
for( int j = 0; j < lineLength; j++ )
|
||||
{
|
||||
if( x >= 0 && y >= 0 && x <= refState.width )
|
||||
x += CL_DrawCharacter( x, y, line[j], NULL, font, FONT_DRAW_HUD | FONT_DRAW_NORENDERMODE | FONT_DRAW_NOCOLOR );
|
||||
@@ -534,9 +527,7 @@ can be modulated
|
||||
static void CL_DrawScreenFade( void )
|
||||
{
|
||||
screenfade_t *sf = &clgame.fade;
|
||||
int alpha;
|
||||
|
||||
alpha = V_FadeAlpha( sf );
|
||||
int alpha = V_FadeAlpha( sf );
|
||||
|
||||
if( !alpha )
|
||||
return;
|
||||
@@ -619,11 +610,9 @@ Parse TE_TEXTMESSAGE
|
||||
void CL_ParseTextMessage( sizebuf_t *msg )
|
||||
{
|
||||
static int msgindex = 0;
|
||||
client_textmessage_t *text;
|
||||
int channel;
|
||||
|
||||
// read channel ( 0 - auto)
|
||||
channel = MSG_ReadByte( msg );
|
||||
int channel = MSG_ReadByte( msg );
|
||||
|
||||
if( channel <= 0 || channel > ( MAX_TEXTCHANNELS - 1 ))
|
||||
{
|
||||
@@ -632,7 +621,7 @@ void CL_ParseTextMessage( sizebuf_t *msg )
|
||||
}
|
||||
|
||||
// grab message channel
|
||||
text = &cl_textmessage[channel];
|
||||
client_textmessage_t *text = &cl_textmessage[channel];
|
||||
|
||||
text->x = (float)(MSG_ReadShort( msg ) / 8192.0f);
|
||||
text->y = (float)(MSG_ReadShort( msg ) / 8192.0f);
|
||||
@@ -680,12 +669,9 @@ return soundname from index
|
||||
*/
|
||||
static const char *CL_SoundFromIndex( int index )
|
||||
{
|
||||
sfx_t *sfx = NULL;
|
||||
int hSound;
|
||||
|
||||
// make sure what we in-bounds
|
||||
index = bound( 0, index, MAX_SOUNDS );
|
||||
hSound = cl.sound_index[index];
|
||||
int hSound = cl.sound_index[index];
|
||||
|
||||
if( !hSound )
|
||||
{
|
||||
@@ -693,7 +679,7 @@ static const char *CL_SoundFromIndex( int index )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sfx = S_GetSfxByHandle( hSound );
|
||||
sfx_t *sfx = S_GetSfxByHandle( hSound );
|
||||
if( !sfx )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: bad sfx for index %i\n", __func__, index );
|
||||
@@ -740,8 +726,6 @@ perform common scissor test
|
||||
*/
|
||||
qboolean CL_Scissor( const scissor_state_t *scissor, float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 )
|
||||
{
|
||||
float dudx, dvdy;
|
||||
|
||||
if( !scissor->test )
|
||||
return true;
|
||||
|
||||
@@ -758,8 +742,8 @@ qboolean CL_Scissor( const scissor_state_t *scissor, float *x, float *y, float *
|
||||
if( *y >= scissor->y + scissor->height )
|
||||
return false;
|
||||
|
||||
dudx = (*u1 - *u0) / *width;
|
||||
dvdy = (*v1 - *v0) / *height;
|
||||
float dudx = (*u1 - *u0) / *width;
|
||||
float dvdy = (*v1 - *v0) / *height;
|
||||
|
||||
if( *x < scissor->x )
|
||||
{
|
||||
@@ -946,9 +930,7 @@ void CL_DrawHUD( int state )
|
||||
|
||||
static void CL_ClearUserMessage( char *pszName, int svc_num )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < MAX_USER_MESSAGES && clgame.msg[i].name[0]; i++ )
|
||||
for( int i = 0; i < MAX_USER_MESSAGES && clgame.msg[i].name[0]; i++ )
|
||||
if( ( clgame.msg[i].number == svc_num ) && Q_stricmp( clgame.msg[i].name, pszName ) )
|
||||
clgame.msg[i].number = 0;
|
||||
}
|
||||
@@ -1072,9 +1054,7 @@ free studio cache on change level
|
||||
*/
|
||||
void CL_ClearSpriteTextures( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 1; i < MAX_CLIENT_SPRITES; i++ )
|
||||
for( int i = 1; i < MAX_CLIENT_SPRITES; i++ )
|
||||
{
|
||||
if( clgame.sprites[i].needload == NL_UNREFERENCED )
|
||||
continue;
|
||||
@@ -1212,8 +1192,6 @@ upload sprite frames
|
||||
*/
|
||||
static qboolean CL_LoadHudSprite( const char *szSpriteName, model_t *m_pSprite, uint type, uint texFlags )
|
||||
{
|
||||
byte *buf;
|
||||
fs_offset_t size;
|
||||
qboolean loaded;
|
||||
|
||||
Assert( m_pSprite != NULL );
|
||||
@@ -1243,7 +1221,8 @@ static qboolean CL_LoadHudSprite( const char *szSpriteName, model_t *m_pSprite,
|
||||
}
|
||||
}
|
||||
|
||||
buf = FS_LoadFile( szSpriteName, &size, false );
|
||||
fs_offset_t size;
|
||||
byte *buf = FS_LoadFile( szSpriteName, &size, false );
|
||||
if( buf == NULL )
|
||||
return false;
|
||||
|
||||
@@ -1280,7 +1259,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
|
||||
{
|
||||
char name[MAX_QPATH];
|
||||
model_t *mod;
|
||||
int i, start;
|
||||
int i;
|
||||
|
||||
if( COM_StringEmptyOrNULL( filename ))
|
||||
{
|
||||
@@ -1310,7 +1289,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
|
||||
// find a free model slot spot
|
||||
// use low indices only for HUD sprites
|
||||
// for GoldSrc bug compatibility
|
||||
start = type == SPR_HUDSPRITE ? 0 : MAX_CLIENT_SPRITES / 2;
|
||||
int start = type == SPR_HUDSPRITE ? 0 : MAX_CLIENT_SPRITES / 2;
|
||||
|
||||
for( i = 0, mod = &clgame.sprites[start]; i < MAX_CLIENT_SPRITES / 2; i++, mod++ )
|
||||
{
|
||||
@@ -1356,9 +1335,9 @@ pfnSPR_LoadExt
|
||||
*/
|
||||
HSPRITE pfnSPR_LoadExt( const char *szPicName, uint texFlags )
|
||||
{
|
||||
model_t *spr;
|
||||
model_t *spr = CL_LoadSpriteModel( szPicName, SPR_CLIENT, texFlags );
|
||||
|
||||
if(( spr = CL_LoadSpriteModel( szPicName, SPR_CLIENT, texFlags )) == NULL )
|
||||
if( spr == NULL )
|
||||
return 0;
|
||||
|
||||
return (spr - clgame.sprites) + 1; // return index
|
||||
@@ -1374,9 +1353,9 @@ function exported for support GoldSrc Monitor utility
|
||||
HSPRITE EXPORT pfnSPR_Load( const char *szPicName );
|
||||
HSPRITE EXPORT pfnSPR_Load( const char *szPicName )
|
||||
{
|
||||
model_t *spr;
|
||||
model_t *spr = CL_LoadSpriteModel( szPicName, SPR_HUDSPRITE, 0 );
|
||||
|
||||
if(( spr = CL_LoadSpriteModel( szPicName, SPR_HUDSPRITE, 0 )) == NULL )
|
||||
if( spr == NULL )
|
||||
return 0;
|
||||
|
||||
return (spr - clgame.sprites) + 1; // return index
|
||||
@@ -1390,16 +1369,16 @@ CL_GetSpritePointer
|
||||
*/
|
||||
static const model_t *CL_GetSpritePointer( HSPRITE hSprite )
|
||||
{
|
||||
model_t *mod;
|
||||
int index = hSprite - 1;
|
||||
|
||||
if( index < 0 || index >= MAX_CLIENT_SPRITES )
|
||||
return NULL; // bad image
|
||||
mod = &clgame.sprites[index];
|
||||
|
||||
model_t *mod = &clgame.sprites[index];
|
||||
|
||||
if( mod->needload == NL_NEEDS_LOADED )
|
||||
{
|
||||
int type = FBitSet( mod->flags, MODEL_CLIENT ) ? SPR_HUDSPRITE : SPR_MAPSPRITE;
|
||||
int type = FBitSet( mod->flags, MODEL_CLIENT ) ? SPR_HUDSPRITE : SPR_MAPSPRITE;
|
||||
|
||||
if( CL_LoadHudSprite( mod->name, mod, type, mod->numtexinfo ))
|
||||
return mod;
|
||||
@@ -1868,8 +1847,6 @@ pfnGetPlayerInfo
|
||||
*/
|
||||
static void GAME_EXPORT pfnGetPlayerInfo( int ent_num, hud_player_info_t *pinfo )
|
||||
{
|
||||
player_info_t *player;
|
||||
|
||||
ent_num -= 1; // player list if offset by 1 from ents
|
||||
|
||||
if( ent_num >= cl.maxclients || ent_num < 0 || !cl.players[ent_num].name[0] )
|
||||
@@ -1879,7 +1856,7 @@ static void GAME_EXPORT pfnGetPlayerInfo( int ent_num, hud_player_info_t *pinfo
|
||||
return;
|
||||
}
|
||||
|
||||
player = &cl.players[ent_num];
|
||||
player_info_t *player = &cl.players[ent_num];
|
||||
pinfo->thisplayer = ( ent_num == cl.playernum ) ? true : false;
|
||||
pinfo->name = player->name;
|
||||
pinfo->model = player->model;
|
||||
@@ -1910,11 +1887,9 @@ pfnPlaySoundByIndex
|
||||
*/
|
||||
static void GAME_EXPORT pfnPlaySoundByIndex( int iSound, float volume )
|
||||
{
|
||||
int hSound;
|
||||
|
||||
// make sure what we in-bounds
|
||||
iSound = bound( 0, iSound, MAX_SOUNDS );
|
||||
hSound = cl.sound_index[iSound];
|
||||
int hSound = cl.sound_index[iSound];
|
||||
if( !hSound ) return;
|
||||
|
||||
S_StartSound( NULL, cl.viewentity, CHAN_ITEM, hSound, volume, ATTN_NORM, PITCH_NORM, SND_STOP_LOOPING );
|
||||
@@ -2200,8 +2175,6 @@ pfnCalcShake
|
||||
static void GAME_EXPORT pfnCalcShake( void )
|
||||
{
|
||||
screen_shake_t *const shake = &clgame.shake;
|
||||
float frametime, fraction, freq;
|
||||
int i;
|
||||
|
||||
if( cl.time > shake->time || shake->amplitude <= 0 || shake->frequency <= 0 || shake->duration <= 0 )
|
||||
{
|
||||
@@ -2216,7 +2189,7 @@ static void GAME_EXPORT pfnCalcShake( void )
|
||||
return;
|
||||
}
|
||||
|
||||
frametime = cl_clientframetime();
|
||||
float frametime = cl_clientframetime();
|
||||
|
||||
if( cl.time > shake->next_shake )
|
||||
{
|
||||
@@ -2224,20 +2197,20 @@ static void GAME_EXPORT pfnCalcShake( void )
|
||||
shake->next_shake = (float)cl.time + shake->frequency / shake->duration;
|
||||
|
||||
// randomize each shake
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( int i = 0; i < 3; i++ )
|
||||
shake->offset[i] = COM_RandomFloat( -shake->amplitude, shake->amplitude );
|
||||
shake->angle = COM_RandomFloat( -shake->amplitude * 0.25f, shake->amplitude * 0.25f );
|
||||
}
|
||||
|
||||
// get initial fraction and frequency values over the duration
|
||||
fraction = ((float)cl.time - shake->time ) / shake->duration;
|
||||
freq = fraction != 0.0f ? ( shake->frequency / fraction ) * shake->frequency : 0.0f;
|
||||
float fraction = ((float)cl.time - shake->time ) / shake->duration;
|
||||
float freq = fraction != 0.0f ? ( shake->frequency / fraction ) * shake->frequency : 0.0f;
|
||||
|
||||
// quickly approach zero but apply time over sine wave
|
||||
fraction *= fraction * sin( cl.time * freq );
|
||||
|
||||
// apply shake offset
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( int i = 0; i < 3; i++ )
|
||||
shake->applied_offset[i] = shake->offset[i] * fraction;
|
||||
|
||||
// apply roll angle
|
||||
@@ -2349,10 +2322,7 @@ pfnKillEvent
|
||||
*/
|
||||
static void GAME_EXPORT pfnKillEvents( int entnum, const char *eventname )
|
||||
{
|
||||
int i;
|
||||
event_state_t *es;
|
||||
event_info_t *ei;
|
||||
word eventIndex = CL_EventIndex( eventname );
|
||||
word eventIndex = CL_EventIndex( eventname );
|
||||
|
||||
if( eventIndex >= MAX_EVENTS )
|
||||
return;
|
||||
@@ -2360,12 +2330,12 @@ static void GAME_EXPORT pfnKillEvents( int entnum, const char *eventname )
|
||||
if( entnum < 0 || entnum >= clgame.maxEntities )
|
||||
return;
|
||||
|
||||
es = &cl.events;
|
||||
event_state_t *es = &cl.events;
|
||||
|
||||
// find all events with specified index and kill it
|
||||
for( i = 0; i < MAX_EVENT_QUEUE; i++ )
|
||||
for( int i = 0; i < MAX_EVENT_QUEUE; i++ )
|
||||
{
|
||||
ei = &es->ei[i];
|
||||
event_info_t *ei = &es->ei[i];
|
||||
|
||||
if( ei->index == eventIndex && ei->entity_index == entnum )
|
||||
{
|
||||
@@ -2395,7 +2365,6 @@ CL_FindModelIndex
|
||||
static int GAME_EXPORT CL_FindModelIndex( const char *m )
|
||||
{
|
||||
char filepath[MAX_QPATH];
|
||||
int i;
|
||||
|
||||
if( COM_StringEmptyOrNULL( m ))
|
||||
return 0;
|
||||
@@ -2403,7 +2372,7 @@ static int GAME_EXPORT CL_FindModelIndex( const char *m )
|
||||
Q_strncpy( filepath, m, sizeof( filepath ));
|
||||
COM_FixSlashes( filepath );
|
||||
|
||||
for( i = 0; i < cl.nummodels; i++ )
|
||||
for( int i = 0; i < cl.nummodels; i++ )
|
||||
{
|
||||
if( !cl.models[i+1] )
|
||||
continue;
|
||||
@@ -2735,9 +2704,7 @@ pfnLoadMapSprite
|
||||
*/
|
||||
static model_t *pfnLoadMapSprite( const char *filename )
|
||||
{
|
||||
model_t *mod;
|
||||
|
||||
mod = Mod_FindName( filename, false );
|
||||
model_t *mod = Mod_FindName( filename, false );
|
||||
|
||||
if( CL_LoadHudSprite( filename, mod, SPR_MAPSPRITE, 0 ))
|
||||
return mod;
|
||||
@@ -2813,12 +2780,10 @@ PlayerInfo_SetValueForKey
|
||||
*/
|
||||
static void GAME_EXPORT PlayerInfo_SetValueForKey( const char *key, const char *value )
|
||||
{
|
||||
convar_t *var;
|
||||
|
||||
if( !Q_strcmp( Info_ValueForKey( cls.userinfo, key ), value ))
|
||||
return; // no changes ?
|
||||
|
||||
var = Cvar_FindVar( key );
|
||||
convar_t *var = Cvar_FindVar( key );
|
||||
|
||||
if( var && FBitSet( var->flags, FCVAR_USERINFO ))
|
||||
{
|
||||
@@ -2899,11 +2864,10 @@ pfnGetMousePos
|
||||
*/
|
||||
static void GAME_EXPORT pfnGetMousePos( struct tagPOINT *ppt )
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if( !ppt )
|
||||
return;
|
||||
|
||||
int x, y;
|
||||
Platform_GetMousePos( &x, &y );
|
||||
|
||||
ppt->x = x;
|
||||
@@ -3052,11 +3016,11 @@ static int GAME_EXPORT pfnDrawStringReverse( int x, int y, const char *str, int
|
||||
{
|
||||
rgba_t color = { r, g, b, 255 };
|
||||
int flags = FONT_DRAW_HUD | FONT_DRAW_NOLF;
|
||||
int width;
|
||||
|
||||
if( hud_utf8.value )
|
||||
SetBits( flags, FONT_DRAW_UTF8 );
|
||||
|
||||
int width;
|
||||
CL_DrawStringLen( &cls.creditsFont, str, &width, NULL, flags );
|
||||
|
||||
x -= width;
|
||||
@@ -3236,11 +3200,9 @@ TriBrightness
|
||||
*/
|
||||
void TriBrightness( float brightness )
|
||||
{
|
||||
float r, g, b;
|
||||
|
||||
r = clgame.ds.triRGBA[0] * clgame.ds.triRGBA[3] * brightness;
|
||||
g = clgame.ds.triRGBA[1] * clgame.ds.triRGBA[3] * brightness;
|
||||
b = clgame.ds.triRGBA[2] * clgame.ds.triRGBA[3] * brightness;
|
||||
float r = clgame.ds.triRGBA[0] * clgame.ds.triRGBA[3] * brightness;
|
||||
float g = clgame.ds.triRGBA[1] * clgame.ds.triRGBA[3] * brightness;
|
||||
float b = clgame.ds.triRGBA[2] * clgame.ds.triRGBA[3] * brightness;
|
||||
|
||||
ref.dllFuncs.Color4f( r, g, b, 1.0f );
|
||||
}
|
||||
@@ -3287,11 +3249,9 @@ NOTE: dlights are ignored
|
||||
*/
|
||||
void TriLightAtPoint( float *pos, float *value )
|
||||
{
|
||||
colorVec vLightColor;
|
||||
|
||||
if( !pos || !value ) return;
|
||||
|
||||
vLightColor = ref.dllFuncs.R_LightPoint( pos );
|
||||
colorVec vLightColor = ref.dllFuncs.R_LightPoint( pos );
|
||||
|
||||
value[0] = vLightColor.r;
|
||||
value[1] = vLightColor.g;
|
||||
@@ -3324,9 +3284,9 @@ bind current texture
|
||||
*/
|
||||
int TriSpriteTexture( model_t *pSpriteModel, int frame )
|
||||
{
|
||||
int gl_texturenum;
|
||||
int gl_texturenum = R_GetSpriteTexture( pSpriteModel, frame );
|
||||
|
||||
if(( gl_texturenum = R_GetSpriteTexture( pSpriteModel, frame )) <= 0 )
|
||||
if( gl_texturenum <= 0 )
|
||||
return 0;
|
||||
|
||||
ref.dllFuncs.GL_Bind( XASH_TEXTURE0, gl_texturenum );
|
||||
@@ -3467,13 +3427,10 @@ NetAPI_CancelRequest
|
||||
*/
|
||||
static void GAME_EXPORT NetAPI_CancelRequest( int context )
|
||||
{
|
||||
net_request_t *nr;
|
||||
int i;
|
||||
;
|
||||
// find a specified request
|
||||
for( i = 0; i < MAX_REQUESTS; i++ )
|
||||
for( int i = 0; i < MAX_REQUESTS; i++ )
|
||||
{
|
||||
nr = &clgame.net_requests[i];
|
||||
net_request_t *nr = &clgame.net_requests[i];
|
||||
|
||||
if( clgame.net_requests[i].resp.context == context )
|
||||
{
|
||||
@@ -3498,13 +3455,10 @@ NetAPI_CancelAllRequests
|
||||
*/
|
||||
void GAME_EXPORT NetAPI_CancelAllRequests( void )
|
||||
{
|
||||
net_request_t *nr;
|
||||
int i;
|
||||
|
||||
// tell the user about cancel
|
||||
for( i = 0; i < MAX_REQUESTS; i++ )
|
||||
for( int i = 0; i < MAX_REQUESTS; i++ )
|
||||
{
|
||||
nr = &clgame.net_requests[i];
|
||||
net_request_t *nr = &clgame.net_requests[i];
|
||||
if( !nr->pfnFunc ) continue; // not used
|
||||
SetBits( nr->resp.error, NET_ERROR_TIMEOUT );
|
||||
nr->resp.ping = host.realtime - nr->timesend;
|
||||
@@ -3981,12 +3935,11 @@ static engine_studio_api_t gStudioAPI =
|
||||
static void CL_InitStudioAPI( void )
|
||||
{
|
||||
static r_studio_interface_t gDefaultStudioDraw;
|
||||
r_studio_interface_t *pStudioDraw;
|
||||
|
||||
if( !ref.dllFuncs.R_StudioFillAPI( &gStudioAPI, &gDefaultStudioDraw ))
|
||||
return;
|
||||
|
||||
pStudioDraw = &gDefaultStudioDraw;
|
||||
r_studio_interface_t *pStudioDraw = &gDefaultStudioDraw;
|
||||
|
||||
if( clgame.dllFuncs.pfnGetStudioModelInterface )
|
||||
clgame.dllFuncs.pfnGetStudioModelInterface( STUDIO_INTERFACE_VERSION, &pStudioDraw, &gStudioAPI );
|
||||
@@ -4001,7 +3954,6 @@ qboolean CL_LoadProgs( const char *name )
|
||||
qboolean valid_single_export = false;
|
||||
qboolean missed_exports = false;
|
||||
qboolean try_internal_vgui_support = GI->internal_vgui_support;
|
||||
int i;
|
||||
|
||||
if( clgame.hInstance ) CL_UnloadProgs();
|
||||
|
||||
@@ -4057,7 +4009,7 @@ qboolean CL_LoadProgs( const char *name )
|
||||
if( GetClientAPI != NULL ) // check critical functions again
|
||||
valid_single_export = ValidateExports( cdll_exports, ARRAYSIZE( cdll_exports ));
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( cdll_exports ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( cdll_exports ); i++ )
|
||||
{
|
||||
if( *(cdll_exports[i].func) != NULL )
|
||||
continue; // already got through 'F' or 'GetClientAPI'
|
||||
@@ -4088,7 +4040,7 @@ qboolean CL_LoadProgs( const char *name )
|
||||
if( !valid_single_export )
|
||||
ClearExports( cdll_new_exports, ARRAYSIZE( cdll_new_exports ));
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( cdll_new_exports ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( cdll_new_exports ); i++ )
|
||||
{
|
||||
if( *(cdll_new_exports[i].func) != NULL )
|
||||
continue; // already gott through 'F' or 'GetClientAPI'
|
||||
|
||||
@@ -78,8 +78,6 @@ void UI_MouseMove( int x, int y )
|
||||
|
||||
void UI_SetActiveMenu( qboolean fActive )
|
||||
{
|
||||
movie_state_t *cin_state;
|
||||
|
||||
if( !gameui.hInstance )
|
||||
{
|
||||
if( !fActive )
|
||||
@@ -93,7 +91,7 @@ void UI_SetActiveMenu( qboolean fActive )
|
||||
if( !fActive )
|
||||
{
|
||||
// close logo when menu is shutdown
|
||||
cin_state = AVI_GetState( CIN_LOGO );
|
||||
movie_state_t *cin_state = AVI_GetState( CIN_LOGO );
|
||||
AVI_CloseVideo( cin_state );
|
||||
}
|
||||
}
|
||||
@@ -356,12 +354,10 @@ static float GAME_EXPORT UI_GetLogoLength( void )
|
||||
|
||||
static void UI_UpdateUserinfo( void )
|
||||
{
|
||||
player_info_t *player;
|
||||
|
||||
if( !host.userinfo_changed )
|
||||
return;
|
||||
|
||||
player = &gameui.playerinfo;
|
||||
player_info_t *player = &gameui.playerinfo;
|
||||
|
||||
Q_strncpy( player->userinfo, cls.userinfo, sizeof( player->userinfo ));
|
||||
Q_strncpy( player->name, Info_ValueForKey( player->userinfo, "name" ), sizeof( player->name ));
|
||||
@@ -427,10 +423,8 @@ static void UI_ToOldGameInfo( GAMEINFO *out, const gameinfo2_t *in )
|
||||
|
||||
static void UI_GetModsInfo( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
gameui.modsInfo = Mem_Calloc( gameui.mempool, sizeof( *gameui.modsInfo ) * FI->numgames );
|
||||
for( i = 0; i < FI->numgames; i++ )
|
||||
for( int i = 0; i < FI->numgames; i++ )
|
||||
UI_ConvertGameInfo( &gameui.modsInfo[i], FI->games[i] );
|
||||
}
|
||||
|
||||
@@ -755,10 +749,9 @@ drawing string like a console string
|
||||
*/
|
||||
static int GAME_EXPORT UI_DrawConsoleString( int x, int y, const char *string )
|
||||
{
|
||||
int drawLen;
|
||||
|
||||
if( !string || !*string ) return 0; // silent ignore
|
||||
drawLen = Con_DrawString( x, y, string, gameui.ds.textColor );
|
||||
|
||||
int drawLen = Con_DrawString( x, y, string, gameui.ds.textColor );
|
||||
MakeRGBA( gameui.ds.textColor, 255, 255, 255, 255 );
|
||||
|
||||
return (x + drawLen); // exclude color prexfixes
|
||||
@@ -958,14 +951,12 @@ static GAMEINFO ** GAME_EXPORT pfnGetGamesList( int *numGames )
|
||||
|
||||
if( !gameui.oldModsInfo )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !gameui.modsInfo )
|
||||
UI_GetModsInfo();
|
||||
|
||||
// first allocate array of pointers
|
||||
gameui.oldModsInfo = Mem_Calloc( gameui.mempool, sizeof( *gameui.oldModsInfo ) * FI->numgames );
|
||||
for( i = 0; i < FI->numgames; i++ )
|
||||
for( int i = 0; i < FI->numgames; i++ )
|
||||
{
|
||||
gameui.oldModsInfo[i] = Mem_Calloc( gameui.mempool, sizeof( *gameui.oldModsInfo[i] ));
|
||||
UI_ToOldGameInfo( gameui.oldModsInfo[i], &gameui.modsInfo[i] );
|
||||
@@ -1135,12 +1126,10 @@ static void GAME_EXPORT pfnCon_DefaultColor( int r, int g, int b )
|
||||
|
||||
static void GAME_EXPORT pfnSetCursor( void *hCursor )
|
||||
{
|
||||
uintptr_t cursor;
|
||||
|
||||
if( !gameui.use_extended_api )
|
||||
return; // ignore original Xash menus
|
||||
|
||||
cursor = (uintptr_t)hCursor;
|
||||
uintptr_t cursor = (uintptr_t)hCursor;
|
||||
if( cursor < dc_user || cursor > dc_last )
|
||||
return;
|
||||
|
||||
|
||||
@@ -63,12 +63,10 @@ static int pfnDrawScaledCharacter( int x, int y, int number, int r, int g, int b
|
||||
if( fabs( g_font_scale - scale ) > 0.1f ||
|
||||
g_scaled_font.hFontTexture != cls.creditsFont.hFontTexture )
|
||||
{
|
||||
int i;
|
||||
|
||||
g_scaled_font = cls.creditsFont;
|
||||
g_scaled_font.scale *= scale;
|
||||
g_scaled_font.charHeight *= scale;
|
||||
for( i = 0; i < ARRAYSIZE( g_scaled_font.charWidths ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( g_scaled_font.charWidths ); i++ )
|
||||
g_scaled_font.charWidths[i] *= scale;
|
||||
|
||||
g_font_scale = scale;
|
||||
|
||||
@@ -101,10 +101,9 @@ CL_SetIdealPitch
|
||||
void CL_SetIdealPitch( void )
|
||||
{
|
||||
float angleval, sinval, cosval;
|
||||
int i, j, step, dir, steps;
|
||||
int i, dir, steps;
|
||||
float z[MAX_FORWARD];
|
||||
vec3_t top, bottom;
|
||||
pmtrace_t tr;
|
||||
|
||||
if( cl.local.onground == -1 )
|
||||
return;
|
||||
@@ -116,6 +115,8 @@ void CL_SetIdealPitch( void )
|
||||
// 160 or so units to see what's below
|
||||
for( i = 0; i < MAX_FORWARD; i++ )
|
||||
{
|
||||
pmtrace_t tr;
|
||||
|
||||
top[0] = cl.simorg[0] + cosval * (i + 3.0f) * 12.0f;
|
||||
top[1] = cl.simorg[1] + sinval * (i + 3.0f) * 12.0f;
|
||||
top[2] = cl.simorg[2] + cl.viewheight[2];
|
||||
@@ -137,9 +138,10 @@ void CL_SetIdealPitch( void )
|
||||
dir = 0;
|
||||
steps = 0;
|
||||
|
||||
for( j = 1; j < i; j++ )
|
||||
for( int j = 1; j < i; j++ )
|
||||
{
|
||||
step = z[j] - z[j-1];
|
||||
int step = z[j] - z[j-1];
|
||||
|
||||
if( step > -ON_EPSILON && step < ON_EPSILON )
|
||||
continue;
|
||||
|
||||
@@ -244,15 +246,10 @@ This sets up the first phase.
|
||||
*/
|
||||
void GAME_EXPORT CL_SetUpPlayerPrediction( int dopred, int bIncludeLocalClient )
|
||||
{
|
||||
entity_state_t *state;
|
||||
predicted_player_t *player;
|
||||
cl_entity_t *ent;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < MAX_CLIENTS; i++ )
|
||||
for( int i = 0; i < MAX_CLIENTS; i++ )
|
||||
{
|
||||
state = &cl.frames[cl.parsecountmod].playerstate[i];
|
||||
player = &cls.predicted_players[i];
|
||||
entity_state_t *state = &cl.frames[cl.parsecountmod].playerstate[i];
|
||||
predicted_player_t *player = &cls.predicted_players[i];
|
||||
|
||||
player->active = false;
|
||||
|
||||
@@ -279,7 +276,7 @@ void GAME_EXPORT CL_SetUpPlayerPrediction( int dopred, int bIncludeLocalClient )
|
||||
}
|
||||
else
|
||||
{
|
||||
ent = CL_GetEntityByIndex( i + 1 );
|
||||
cl_entity_t *ent = CL_GetEntityByIndex( i + 1 );
|
||||
|
||||
CL_ComputePlayerOrigin( ent );
|
||||
|
||||
@@ -397,16 +394,13 @@ collect solid entities
|
||||
*/
|
||||
static void CL_AddLinksToPmove( frame_t *frame )
|
||||
{
|
||||
entity_state_t *state;
|
||||
model_t *model;
|
||||
physent_t *pe;
|
||||
int i;
|
||||
|
||||
if( !frame->valid ) return;
|
||||
|
||||
for( i = 0; i < frame->num_entities; i++ )
|
||||
for( int i = 0; i < frame->num_entities; i++ )
|
||||
{
|
||||
state = &cls.packet_entities[(frame->first_entity + i) % cls.num_client_entities];
|
||||
entity_state_t *state = &cls.packet_entities[(frame->first_entity + i) % cls.num_client_entities];
|
||||
model_t *model;
|
||||
physent_t *pe;
|
||||
|
||||
if( state->number >= 1 && state->number <= cl.maxclients )
|
||||
continue;
|
||||
@@ -506,18 +500,14 @@ pmove must be setup with world and solid entity hulls before calling
|
||||
*/
|
||||
void GAME_EXPORT CL_SetSolidPlayers( int playernum )
|
||||
{
|
||||
entity_state_t *state;
|
||||
predicted_player_t *player;
|
||||
physent_t *pe;
|
||||
int i;
|
||||
|
||||
if( !cl_solid_players.value )
|
||||
return;
|
||||
|
||||
for( i = 0; i < MAX_CLIENTS; i++ )
|
||||
for( int i = 0; i < MAX_CLIENTS; i++ )
|
||||
{
|
||||
state = &cl.frames[cl.parsecountmod].playerstate[i];
|
||||
player = &cls.predicted_players[i];
|
||||
entity_state_t *state = &cl.frames[cl.parsecountmod].playerstate[i];
|
||||
predicted_player_t *player = &cls.predicted_players[i];
|
||||
physent_t *pe;
|
||||
|
||||
if( playernum == -1 )
|
||||
{
|
||||
@@ -562,18 +552,17 @@ CL_WaterEntity
|
||||
*/
|
||||
int GAME_EXPORT CL_WaterEntity( const float *rgflPos )
|
||||
{
|
||||
physent_t *pe;
|
||||
hull_t *hull;
|
||||
vec3_t test, offset;
|
||||
int i, oldhull;
|
||||
int oldhull;
|
||||
|
||||
if( !rgflPos ) return -1;
|
||||
|
||||
oldhull = clgame.pmove->usehull;
|
||||
|
||||
for( i = 0; i < clgame.pmove->numphysent; i++ )
|
||||
for( int i = 0; i < clgame.pmove->numphysent; i++ )
|
||||
{
|
||||
pe = &clgame.pmove->physents[i];
|
||||
physent_t *pe = &clgame.pmove->physents[i];
|
||||
hull_t *hull;
|
||||
vec3_t test, offset;
|
||||
|
||||
if( pe->solid != SOLID_NOT ) // disabled ?
|
||||
continue;
|
||||
@@ -657,9 +646,8 @@ returns water brush where inside pos
|
||||
*/
|
||||
cl_entity_t *CL_GetWaterEntity( const float *rgflPos )
|
||||
{
|
||||
int entnum;
|
||||
int entnum = CL_WaterEntity( rgflPos );
|
||||
|
||||
entnum = CL_WaterEntity( rgflPos );
|
||||
if( entnum <= 0 ) return NULL; // world or not water
|
||||
|
||||
return CL_GetEntityByIndex( entnum );
|
||||
@@ -732,8 +720,6 @@ CL_InitClientMove
|
||||
*/
|
||||
void CL_InitClientMove( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
Pmove_Init ();
|
||||
|
||||
clgame.pmove->server = false; // running at client
|
||||
@@ -741,7 +727,7 @@ void CL_InitClientMove( void )
|
||||
clgame.pmove->runfuncs = false;
|
||||
|
||||
// enumerate client hulls
|
||||
for( i = 0; i < MAX_MAP_HULLS; i++ )
|
||||
for( int i = 0; i < MAX_MAP_HULLS; i++ )
|
||||
{
|
||||
if( clgame.dllFuncs.pfnGetHullBounds( i, host.player_mins[i], host.player_maxs[i] ))
|
||||
Con_Reportf( "CL: hull%i, player_mins: %g %g %g, player_maxs: %g %g %g\n", i,
|
||||
|
||||
@@ -72,18 +72,15 @@ static qboolean CheckSkybox( const char *name, char out[SKYBOX_MAX_SIDES][MAX_ST
|
||||
{
|
||||
static const char *skybox_ext[3] = { "dds", "tga", "bmp" };
|
||||
static const char *skybox_delim[2] = { "", "_" }; // no space for HL style, underscore for Q1 style
|
||||
int i;
|
||||
|
||||
// search for skybox images
|
||||
for( i = 0; i < ARRAYSIZE( skybox_ext ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( skybox_ext ); i++ )
|
||||
{
|
||||
int j;
|
||||
|
||||
for( j = 0; j < ARRAYSIZE( skybox_delim ); j++ )
|
||||
for( int j = 0; j < ARRAYSIZE( skybox_delim ); j++ )
|
||||
{
|
||||
int k, num_checked_sides = 0;
|
||||
int num_checked_sides = 0;
|
||||
|
||||
for( k = 0; k < SKYBOX_MAX_SIDES; k++ )
|
||||
for( int k = 0; k < SKYBOX_MAX_SIDES; k++ )
|
||||
{
|
||||
char sidename[MAX_VA_STRING];
|
||||
|
||||
@@ -109,7 +106,6 @@ void R_SetupSky( const char *name )
|
||||
char sidenames[SKYBOX_MAX_SIDES][MAX_STRING];
|
||||
int skyboxTextures[SKYBOX_MAX_SIDES] = { 0 };
|
||||
int i, len;
|
||||
qboolean result;
|
||||
|
||||
if( COM_StringEmptyOrNULL( name ))
|
||||
{
|
||||
@@ -125,10 +121,9 @@ void R_SetupSky( const char *name )
|
||||
|
||||
if( loadname[len - 1] == '_' )
|
||||
loadname[len - 1] = '\0';
|
||||
result = CheckSkybox( loadname, sidenames );
|
||||
|
||||
// to prevent infinite recursion if default skybox was missed
|
||||
if( !result && Q_stricmp( name, DEFAULT_SKYBOX_NAME ))
|
||||
if( !CheckSkybox( loadname, sidenames ) && Q_stricmp( name, DEFAULT_SKYBOX_NAME ))
|
||||
{
|
||||
Con_Reportf( S_WARN "missed or incomplete skybox '%s'\n", name );
|
||||
R_SetupSky( DEFAULT_SKYBOX_NAME ); // force to default
|
||||
|
||||
@@ -35,7 +35,6 @@ static CVAR_DEFINE( v_gamma, "gamma", "2.5", FCVAR_ARCHIVE, "gamma amount" );
|
||||
static void BuildGammaTable( const float gamma, const float brightness, const float texgamma, const float lightgamma )
|
||||
{
|
||||
float g1, g2, g3;
|
||||
int i;
|
||||
|
||||
if( gamma != 0.0 )
|
||||
g1 = 1.0 / gamma;
|
||||
@@ -50,7 +49,7 @@ static void BuildGammaTable( const float gamma, const float brightness, const fl
|
||||
else
|
||||
g3 = 0.05;
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
for( int i = 0; i < 256; i++ )
|
||||
{
|
||||
// keep it float or texgamma test will fail with -ffast-math
|
||||
float d = pow( i / 255.0, (double)g2 );
|
||||
@@ -58,11 +57,9 @@ static void BuildGammaTable( const float gamma, const float brightness, const fl
|
||||
texgammatable[i] = bound( 0, inf, 255 );
|
||||
}
|
||||
|
||||
for( i = 0; i < 1024; i++ )
|
||||
for( int i = 0; i < 1024; i++ )
|
||||
{
|
||||
double d;
|
||||
float f = pow( i / 1023.0, (double)lightgamma );
|
||||
int inf;
|
||||
|
||||
if( brightness > 1.0 )
|
||||
f *= brightness;
|
||||
@@ -72,8 +69,8 @@ static void BuildGammaTable( const float gamma, const float brightness, const fl
|
||||
else
|
||||
f = (( f - g3 ) / ( 1.0 - g3 )) * 0.875 + 0.125;
|
||||
|
||||
d = pow( (double)f, (double)g1 ); // do not remove the cast, or tests fail
|
||||
inf = d * 1023.0;
|
||||
double d = pow( (double)f, (double)g1 ); // do not remove the cast, or tests fail
|
||||
int inf = d * 1023.0;
|
||||
lightgammatable[i] = bound( 0, inf, 1023 );
|
||||
|
||||
// do these calculations in the same loop...
|
||||
@@ -255,11 +252,9 @@ static void Test_PrecomputedGammaTables( void )
|
||||
|
||||
while(( data = Test_GetGammaTables( i )))
|
||||
{
|
||||
int j;
|
||||
|
||||
BuildGammaTable( data->gamma, data->brightness, data->texgamma, data->lightgamma );
|
||||
|
||||
for( j = 0; j < 1024; j++ )
|
||||
for( int j = 0; j < 1024; j++ )
|
||||
{
|
||||
if( j < 256 )
|
||||
{
|
||||
|
||||
@@ -102,9 +102,8 @@ static qboolean ID_ProcessFile( bloomfilter_t *value, const char *path );
|
||||
static void ID_BloomFilter_f( void )
|
||||
{
|
||||
bloomfilter_t value = 0;
|
||||
int i;
|
||||
|
||||
for( i = 1; i < Cmd_Argc(); i++ )
|
||||
for( int i = 1; i < Cmd_Argc(); i++ )
|
||||
value |= BloomFilter_ProcessStr( Cmd_Argv( i ) );
|
||||
|
||||
Msg( "%d %016"PRIX64"\n", BloomFilter_Weight( value ), value );
|
||||
@@ -119,7 +118,6 @@ static qboolean ID_VerifyHEX( const char *hex )
|
||||
uint chars = 0;
|
||||
char prev = 0;
|
||||
qboolean monotonic = true; // detect 11:22...
|
||||
int weight = 0;
|
||||
|
||||
while( *hex++ )
|
||||
{
|
||||
@@ -142,6 +140,7 @@ static qboolean ID_VerifyHEX( const char *hex )
|
||||
if( monotonic )
|
||||
return false;
|
||||
|
||||
int weight = 0;
|
||||
while( chars )
|
||||
{
|
||||
if( chars & 1 )
|
||||
@@ -170,7 +169,7 @@ static void ID_VerifyHEX_f( void )
|
||||
static qboolean ID_ProcessCPUInfo( bloomfilter_t *value )
|
||||
{
|
||||
int cpuinfofd = open( "/proc/cpuinfo", O_RDONLY );
|
||||
char buffer[1024], *pbuf, *pbuf2;
|
||||
char buffer[1024];
|
||||
int ret;
|
||||
|
||||
if( cpuinfofd < 0 )
|
||||
@@ -189,12 +188,12 @@ static qboolean ID_ProcessCPUInfo( bloomfilter_t *value )
|
||||
if( !ret )
|
||||
return false;
|
||||
|
||||
pbuf = Q_stristr( buffer, "Serial" );
|
||||
char *pbuf = Q_stristr( buffer, "Serial" );
|
||||
if( !pbuf )
|
||||
return false;
|
||||
pbuf += 6;
|
||||
|
||||
pbuf2 = Q_strchrnul( pbuf, '\n' );
|
||||
char *pbuf2 = Q_strchrnul( pbuf, '\n' );
|
||||
*pbuf2 = 0;
|
||||
|
||||
if( !ID_VerifyHEX( pbuf ) )
|
||||
@@ -207,20 +206,18 @@ static qboolean ID_ProcessCPUInfo( bloomfilter_t *value )
|
||||
static qboolean ID_ValidateNetDevice( const char *dev )
|
||||
{
|
||||
const char *prefix = "/sys/class/net";
|
||||
byte *pfile;
|
||||
int assignType;
|
||||
|
||||
// These devices are fake, their mac address is generated each boot, while assign_type is 0
|
||||
if( !Q_strnicmp( dev, "ccmni", sizeof( "ccmni" ) ) ||
|
||||
!Q_strnicmp( dev, "ifb", sizeof( "ifb" ) ) )
|
||||
return false;
|
||||
|
||||
pfile = FS_LoadDirectFile( va( "%s/%s/addr_assign_type", prefix, dev ), NULL );
|
||||
byte *pfile = FS_LoadDirectFile( va( "%s/%s/addr_assign_type", prefix, dev ), NULL );
|
||||
|
||||
// if NULL, it may be old kernel
|
||||
if( pfile )
|
||||
{
|
||||
assignType = Q_atoi( (char*)pfile );
|
||||
int assignType = Q_atoi( (char*)pfile );
|
||||
|
||||
Mem_Free( pfile );
|
||||
|
||||
@@ -500,12 +497,10 @@ static int ID_CheckWMIC( bloomfilter_t value, const wchar_t *cmdline )
|
||||
pbuf = COM_ParseFile( buffer, token, sizeof( token )); // Header
|
||||
while(( pbuf = COM_ParseFile( pbuf, token, sizeof( token ))))
|
||||
{
|
||||
bloomfilter_t filter;
|
||||
|
||||
if( !ID_VerifyHEX( token ))
|
||||
continue;
|
||||
|
||||
filter = BloomFilter_ProcessStr( token );
|
||||
bloomfilter_t filter = BloomFilter_ProcessStr( token );
|
||||
count += ( filter & value ) == filter;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,13 +88,12 @@ Apply gyro movement to view angles
|
||||
*/
|
||||
void IN_GyroFinalizeMove( float *fw, float *side, float *dpitch, float *dyaw )
|
||||
{
|
||||
platform_orientation_t orient;
|
||||
float orient_scale = 1.0f;
|
||||
|
||||
if( !gyro_enable.value || !gyro_available.value )
|
||||
return;
|
||||
|
||||
orient = Platform_GetDisplayOrientation();
|
||||
platform_orientation_t orient = Platform_GetDisplayOrientation();
|
||||
if( orient == ORIENTATION_LANDSCAPE_FLIPPED )
|
||||
orient_scale = -1.0f;
|
||||
|
||||
|
||||
@@ -129,9 +129,8 @@ static void Joy_HatMotionEvent( int value )
|
||||
{ JOY_HAT_LEFT, K_LEFTARROW },
|
||||
{ JOY_HAT_RIGHT, K_RIGHTARROW },
|
||||
};
|
||||
int i;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( keys ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( keys ); i++ )
|
||||
{
|
||||
if( value & keys[i].mask )
|
||||
{
|
||||
@@ -317,9 +316,8 @@ void Joy_FinalizeMove( float *fw, float *side, float *dpitch, float *dyaw )
|
||||
if( FBitSet( joy_axis_binding.flags, FCVAR_CHANGED ) )
|
||||
{
|
||||
const char *bind = joy_axis_binding.string;
|
||||
size_t i;
|
||||
|
||||
for( i = 0; bind[i] && i < MAX_AXES; i++ )
|
||||
for( size_t i = 0; bind[i] && i < MAX_AXES; i++ )
|
||||
{
|
||||
switch( bind[i] )
|
||||
{
|
||||
@@ -535,8 +533,6 @@ void Joy_DrawDebug( void )
|
||||
}
|
||||
|
||||
qboolean pressed = Key_IsDown( buttons[i] );
|
||||
int btn_w = 0;
|
||||
rgba_t color;
|
||||
string name;
|
||||
|
||||
Q_strncpy( name, Key_KeynumToString( buttons[i] ), sizeof( name ));
|
||||
@@ -545,8 +541,11 @@ void Joy_DrawDebug( void )
|
||||
if( p )
|
||||
*p = 0;
|
||||
|
||||
rgba_t color;
|
||||
MakeRGBA( color, pressed ? 0 : 255, pressed ? 255 : 0, 0, 255 );
|
||||
CL_DrawString( x, y, name, color, font, 0 );
|
||||
|
||||
int btn_w = 0;
|
||||
CL_DrawStringLen( font, name, &btn_w, NULL, 0 );
|
||||
x += btn_w + 6;
|
||||
}
|
||||
|
||||
@@ -187,8 +187,6 @@ to be configured even if they don't have defined names.
|
||||
*/
|
||||
static int Key_StringToKeynum( const char *str )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !str || !str[0] )
|
||||
return -1;
|
||||
|
||||
@@ -207,7 +205,7 @@ static int Key_StringToKeynum( const char *str )
|
||||
}
|
||||
|
||||
// scan for a text match
|
||||
for( i = 0; i < ARRAYSIZE( keynames ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( keynames ); i++ )
|
||||
{
|
||||
if( !Q_stricmp( str, keynames[i].name ))
|
||||
return keynames[i].keynum;
|
||||
@@ -293,19 +291,16 @@ Key_GetKey
|
||||
*/
|
||||
static int Key_GetKey( const char *pBinding )
|
||||
{
|
||||
int i, len;
|
||||
const char *p;
|
||||
|
||||
if( !pBinding ) return -1;
|
||||
|
||||
len = Q_strlen( pBinding );
|
||||
int len = Q_strlen( pBinding );
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( keys ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( keys ); i++ )
|
||||
{
|
||||
if( !keys[i].binding )
|
||||
continue;
|
||||
|
||||
p = keys[i].binding;
|
||||
const char *p = keys[i].binding;
|
||||
|
||||
if( *p == '+' )
|
||||
p++;
|
||||
@@ -340,15 +335,13 @@ Key_Unbind_f
|
||||
*/
|
||||
static void Key_Unbind_f( void )
|
||||
{
|
||||
int b;
|
||||
|
||||
if( Cmd_Argc() != 2 )
|
||||
{
|
||||
Con_Printf( S_USAGE "unbind <key> : remove commands from a key\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
b = Key_StringToKeynum( Cmd_Argv( 1 ));
|
||||
int b = Key_StringToKeynum( Cmd_Argv( 1 ));
|
||||
|
||||
if( b == -1 )
|
||||
{
|
||||
@@ -372,9 +365,7 @@ Key_Unbindall_f
|
||||
*/
|
||||
static void Key_Unbindall_f( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( keys ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( keys ); i++ )
|
||||
{
|
||||
if( keys[i].binding )
|
||||
Key_SetBinding( i, "" );
|
||||
@@ -392,17 +383,15 @@ Key_Reset_f
|
||||
*/
|
||||
static void Key_Reset_f( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
// clear all keys first
|
||||
for( i = 0; i < ARRAYSIZE( keys ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( keys ); i++ )
|
||||
{
|
||||
if( keys[i].binding )
|
||||
Key_SetBinding( i, "" );
|
||||
}
|
||||
|
||||
// apply default values
|
||||
for( i = 0; i < ARRAYSIZE( keynames ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( keynames ); i++ )
|
||||
Key_SetBinding( keynames[i].keynum, keynames[i].binding );
|
||||
}
|
||||
|
||||
@@ -413,10 +402,7 @@ Key_Bind_f
|
||||
*/
|
||||
static void Key_Bind_f( void )
|
||||
{
|
||||
char cmd[1024];
|
||||
int i, c, b;
|
||||
|
||||
c = Cmd_Argc();
|
||||
int c = Cmd_Argc();
|
||||
|
||||
if( c < 2 )
|
||||
{
|
||||
@@ -424,7 +410,7 @@ static void Key_Bind_f( void )
|
||||
return;
|
||||
}
|
||||
|
||||
b = Key_StringToKeynum( Cmd_Argv( 1 ));
|
||||
int b = Key_StringToKeynum( Cmd_Argv( 1 ));
|
||||
|
||||
if( b == -1 )
|
||||
{
|
||||
@@ -441,9 +427,10 @@ static void Key_Bind_f( void )
|
||||
}
|
||||
|
||||
// copy the rest of the command line
|
||||
char cmd[1024];
|
||||
cmd[0] = 0; // start out with a null string
|
||||
|
||||
for( i = 2; i < c; i++ )
|
||||
for( int i = 2; i < c; i++ )
|
||||
{
|
||||
Q_strncat( cmd, Cmd_Argv( i ), sizeof( cmd ));
|
||||
if( i != ( c - 1 )) Q_strncat( cmd, " ", sizeof( cmd ));
|
||||
@@ -461,18 +448,16 @@ Writes lines containing "bind key value"
|
||||
*/
|
||||
void Key_WriteBindings( file_t *f )
|
||||
{
|
||||
int i;
|
||||
string newCommand;
|
||||
|
||||
if( !f ) return;
|
||||
|
||||
FS_Printf( f, "unbindall\n" );
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( keys ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( keys ); i++ )
|
||||
{
|
||||
if( COM_StringEmptyOrNULL( keys[i].binding ))
|
||||
continue;
|
||||
|
||||
string newCommand;
|
||||
Cmd_Escape( newCommand, keys[i].binding, sizeof( newCommand ));
|
||||
|
||||
// NOTE: as TheKingFireS figured out, some particular mods (like CoF) do not
|
||||
@@ -491,9 +476,7 @@ Key_Bindlist_f
|
||||
*/
|
||||
static void Key_Bindlist_f( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( keys ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( keys ); i++ )
|
||||
{
|
||||
if( COM_StringEmptyOrNULL( keys[i].binding ))
|
||||
continue;
|
||||
@@ -514,10 +497,9 @@ qboolean Cmd_GetKeysList( const char *s, char *completedname, int length, qboole
|
||||
size_t i, numkeys;
|
||||
string keys_strings[ARRAYSIZE( keys )];
|
||||
string matchbuf;
|
||||
int len;
|
||||
|
||||
// compare keys list with current keyword
|
||||
len = Q_strlen( s );
|
||||
int len = Q_strlen( s );
|
||||
|
||||
for( i = 0, numkeys = 0; i < ARRAYSIZE( keys ); i++ )
|
||||
{
|
||||
@@ -569,8 +551,6 @@ Key_Init
|
||||
*/
|
||||
void Key_Init( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
// register our functions
|
||||
Cmd_AddRestrictedCommand( "bind", Key_Bind_f, "binds a command to the specified key in bindmap" );
|
||||
Cmd_AddRestrictedCommand( "unbind", Key_Unbind_f, "removes a command on the specified key in bindmap" );
|
||||
@@ -580,7 +560,7 @@ void Key_Init( void )
|
||||
Cmd_AddCommand( "makehelp", Key_EnumCmds_f, "write help.txt that contains all console cvars and cmds" );
|
||||
|
||||
// setup default binding. "unbindall" from config.cfg will be reset it
|
||||
for( i = 0; i < ARRAYSIZE( keynames ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( keynames ); i++ )
|
||||
Key_SetBinding( keynames[i].keynum, keynames[i].binding );
|
||||
|
||||
Cvar_RegisterVariable( &key_rotate );
|
||||
@@ -594,21 +574,20 @@ Key_AddKeyCommands
|
||||
*/
|
||||
static void Key_AddKeyCommands( int key, const char *kb, qboolean down )
|
||||
{
|
||||
char button[1024];
|
||||
char *buttonPtr;
|
||||
char cmd[1024];
|
||||
int i;
|
||||
|
||||
if( !kb ) return;
|
||||
buttonPtr = button;
|
||||
|
||||
for( i = 0; ; i++ )
|
||||
char button[1024];
|
||||
char *buttonPtr = button;
|
||||
|
||||
for( int i = 0; ; i++ )
|
||||
{
|
||||
if( kb[i] == ';' || !kb[i] )
|
||||
{
|
||||
*buttonPtr = '\0';
|
||||
if( button[0] == '+' )
|
||||
{
|
||||
char cmd[1024];
|
||||
|
||||
// button commands add keynum as a parm
|
||||
if( down ) Q_snprintf( cmd, sizeof( cmd ), "%s %i\n", button, key );
|
||||
else Q_snprintf( cmd, sizeof( cmd ), "-%s %i\n", button + 1, key );
|
||||
@@ -708,8 +687,6 @@ Called by the system for both key up and key down events
|
||||
*/
|
||||
void GAME_EXPORT Key_Event( int key, int down )
|
||||
{
|
||||
const char *kb;
|
||||
|
||||
key = Key_Rotate( key );
|
||||
|
||||
if( OSK_KeyEvent( key, down ) )
|
||||
@@ -719,7 +696,7 @@ void GAME_EXPORT Key_Event( int key, int down )
|
||||
if( !keys[key].down && !down )
|
||||
return;
|
||||
|
||||
kb = keys[key].binding;
|
||||
const char *kb = keys[key].binding;
|
||||
keys[key].down = down ? true : false;
|
||||
|
||||
#ifdef HACKS_RELATED_HLMODS
|
||||
@@ -917,13 +894,11 @@ Key_ClearStates
|
||||
*/
|
||||
void GAME_EXPORT Key_ClearStates( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
// don't clear keys during changelevel
|
||||
if( cls.changelevel )
|
||||
return;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( keys ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( keys ); i++ )
|
||||
{
|
||||
if( i >= K_MOUSE1 && i <= K_MOUSE5 )
|
||||
IN_MouseEvent( i - K_MOUSE1, false );
|
||||
|
||||
@@ -144,8 +144,6 @@ qboolean OSK_KeyEvent( int key, int down )
|
||||
break;
|
||||
default:
|
||||
{
|
||||
int ch;
|
||||
|
||||
if( !down )
|
||||
{
|
||||
if( osk.shift && osk.curlayout & 1 )
|
||||
@@ -156,7 +154,7 @@ qboolean OSK_KeyEvent( int key, int down )
|
||||
break;
|
||||
}
|
||||
|
||||
ch = (byte)osk.curbutton.val;
|
||||
int ch = (byte)osk.curbutton.val;
|
||||
|
||||
// do not pass UTF-8 sequence into the engine, convert it here
|
||||
if( !cls.accept_utf8 )
|
||||
|
||||
@@ -249,10 +249,7 @@ Dump config to file
|
||||
*/
|
||||
static qboolean Touch_DumpConfig( const char *name, const char *profilename )
|
||||
{
|
||||
file_t *f;
|
||||
const touch_button_t *button;
|
||||
|
||||
f = FS_Open( name, "w", true );
|
||||
file_t *f = FS_Open( name, "w", true );
|
||||
|
||||
if( !f )
|
||||
{
|
||||
@@ -299,7 +296,7 @@ static qboolean Touch_DumpConfig( const char *name, const char *profilename )
|
||||
FS_Printf( f, "touch_removeall\n" );
|
||||
FS_Printf( f, "touch_aspectratio %g\n", Touch_AspectRatio());
|
||||
|
||||
for( button = touch.list_user.first; button; button = button->next )
|
||||
for( const touch_button_t *button = touch.list_user.first; button; button = button->next )
|
||||
Touch_ExportButtonToConfig( f, button, false );
|
||||
|
||||
FS_Close( f );
|
||||
@@ -347,9 +344,6 @@ export current touch configuration into profile
|
||||
*/
|
||||
static void Touch_ExportConfig_f( void )
|
||||
{
|
||||
const char *name;
|
||||
string profilename;
|
||||
|
||||
if( Cmd_Argc() != 2 )
|
||||
{
|
||||
Con_Printf( S_USAGE "touch_exportconfig <name>\n" );
|
||||
@@ -362,7 +356,8 @@ static void Touch_ExportConfig_f( void )
|
||||
return;
|
||||
}
|
||||
|
||||
name = Cmd_Argv( 1 );
|
||||
const char *name = Cmd_Argv( 1 );
|
||||
string profilename;
|
||||
|
||||
if( Q_strstr( name, "touch_presets/" ))
|
||||
{
|
||||
@@ -386,7 +381,6 @@ export current touch configuration into C code
|
||||
*/
|
||||
static void Touch_GenerateCode_f( void )
|
||||
{
|
||||
const touch_button_t *button;
|
||||
rgba_t c = { 0 };
|
||||
|
||||
if( !touch.list_user.first )
|
||||
@@ -395,11 +389,9 @@ static void Touch_GenerateCode_f( void )
|
||||
return;
|
||||
}
|
||||
|
||||
for( button = touch.list_user.first; button; button = button->next )
|
||||
for( const touch_button_t *button = touch.list_user.first; button; button = button->next )
|
||||
{
|
||||
float aspect;
|
||||
int flags = button->flags;
|
||||
int round;
|
||||
|
||||
if( FBitSet( flags, TOUCH_FL_CLIENT ))
|
||||
continue; // skip temporary buttons
|
||||
@@ -410,7 +402,7 @@ static void Touch_GenerateCode_f( void )
|
||||
if( FBitSet( flags, TOUCH_FL_DEF_HIDE ))
|
||||
SetBits( flags, TOUCH_FL_HIDE );
|
||||
|
||||
aspect = ( button->y2 - button->y1 ) / (( button->x2 - button->x1 ) / Touch_AspectRatio( ));
|
||||
float aspect = ( button->y2 - button->y1 ) / (( button->x2 - button->x1 ) / Touch_AspectRatio( ));
|
||||
|
||||
if( memcmp( c, button->color, sizeof( c )))
|
||||
{
|
||||
@@ -419,6 +411,7 @@ static void Touch_GenerateCode_f( void )
|
||||
memcpy( c, button->color, sizeof( c ));
|
||||
}
|
||||
|
||||
int round;
|
||||
if( button->type == touch_command )
|
||||
{
|
||||
if( fabs( aspect - 1.0f ) < 0.001 )
|
||||
@@ -438,22 +431,18 @@ static void Touch_GenerateCode_f( void )
|
||||
|
||||
static void Touch_RoundAll_f( void )
|
||||
{
|
||||
touch_button_t *button;
|
||||
|
||||
if( !touch_grid_enable.value )
|
||||
return;
|
||||
|
||||
for( button = touch.list_user.first; button; button = button->next )
|
||||
for( touch_button_t *button = touch.list_user.first; button; button = button->next )
|
||||
IN_TouchCheckCoords( &button->x1, &button->y1, &button->x2, &button->y2 );
|
||||
}
|
||||
|
||||
static void Touch_ListButtons_f( void )
|
||||
{
|
||||
touch_button_t *button;
|
||||
|
||||
Touch_InitConfig();
|
||||
|
||||
for( button = touch.list_user.first; button; button = button->next )
|
||||
for( touch_button_t *button = touch.list_user.first; button; button = button->next )
|
||||
{
|
||||
Con_Printf( "%s %s %s %g %g %g %g %d %d %d %d %d\n",
|
||||
button->name, button->texture, button->command,
|
||||
@@ -483,9 +472,7 @@ static void Touch_Stroke_f( void )
|
||||
|
||||
static touch_button_t *Touch_FindNextNoPattern( touch_button_t *buttons, const char *name, qboolean privileged )
|
||||
{
|
||||
touch_button_t *b;
|
||||
|
||||
for( b = buttons; b; b = b->next )
|
||||
for( touch_button_t *b = buttons; b; b = b->next )
|
||||
{
|
||||
if( !privileged && !FBitSet( b->flags, TOUCH_FL_UNPRIVILEGED ))
|
||||
continue;
|
||||
@@ -504,13 +491,12 @@ static touch_button_t *Touch_FindButtonNoPattern( touchbuttonlist_t *list, const
|
||||
|
||||
static touch_button_t *Touch_FindNext( touch_button_t *buttons, const char *name, qboolean privileged )
|
||||
{
|
||||
touch_button_t *b;
|
||||
qboolean has_pattern = Q_strchr( name, '*' ) != NULL;
|
||||
|
||||
if( !has_pattern )
|
||||
return Touch_FindNextNoPattern( buttons, name, privileged );
|
||||
|
||||
for( b = buttons; b; b = b->next )
|
||||
for( touch_button_t *b = buttons; b; b = b->next )
|
||||
{
|
||||
if( !privileged && !FBitSet( b->flags, TOUCH_FL_UNPRIVILEGED ))
|
||||
continue;
|
||||
@@ -584,10 +570,9 @@ static void Touch_SetClientOnly_f( void )
|
||||
|
||||
static void Touch_RemoveButtonFromList( touchbuttonlist_t *list, const char *name, qboolean privileged )
|
||||
{
|
||||
touch_button_t *button;
|
||||
|
||||
IN_TouchEditClear();
|
||||
|
||||
touch_button_t *button;
|
||||
while(( button = Touch_FindFirst( list, name, privileged )))
|
||||
{
|
||||
if( button->prev )
|
||||
@@ -640,9 +625,7 @@ static void Touch_RemoveAll_f( void )
|
||||
|
||||
static void Touch_SetColor( touchbuttonlist_t *list, const char *name, byte *color, qboolean privileged )
|
||||
{
|
||||
touch_button_t *b;
|
||||
|
||||
for( b = Touch_FindFirst( list, name, privileged ); b != NULL; b = Touch_FindNext( b->next, name, privileged ))
|
||||
for( touch_button_t *b = Touch_FindFirst( list, name, privileged ); b != NULL; b = Touch_FindNext( b->next, name, privileged ))
|
||||
Vector4Copy( color, b->color );
|
||||
}
|
||||
|
||||
@@ -677,9 +660,7 @@ static void Touch_SetCommand( touch_button_t *button, const char *command )
|
||||
|
||||
void Touch_HideButtons( const char *name, byte hide, qboolean privileged )
|
||||
{
|
||||
touch_button_t *b;
|
||||
|
||||
for( b = Touch_FindFirst( &touch.list_user, name, privileged ); b != NULL; b = Touch_FindNext( b->next, name, privileged ))
|
||||
for( touch_button_t *b = Touch_FindFirst( &touch.list_user, name, privileged ); b != NULL; b = Touch_FindNext( b->next, name, privileged ))
|
||||
{
|
||||
if( hide )
|
||||
SetBits( b->flags, TOUCH_FL_HIDE );
|
||||
@@ -718,9 +699,7 @@ static void Touch_Show_f( void )
|
||||
|
||||
static void Touch_FadeButtons( touchbuttonlist_t *list, const char *name, float speed, float end, float start, qboolean privileged )
|
||||
{
|
||||
touch_button_t *b;
|
||||
|
||||
for( b = Touch_FindFirst( list, name, privileged ); b != NULL; b = Touch_FindNext( b->next, name, privileged ))
|
||||
for( touch_button_t *b = Touch_FindFirst( list, name, privileged ); b != NULL; b = Touch_FindNext( b->next, name, privileged ))
|
||||
{
|
||||
if( start >= 0 )
|
||||
b->fade = start;
|
||||
@@ -855,8 +834,6 @@ static touch_button_t *Touch_AddButton( touchbuttonlist_t *list, const char *nam
|
||||
|
||||
void Touch_AddClientButton( const char *name, const char *texture, const char *command, float x1, float y1, float x2, float y2, byte *color, int round, float aspect, int flags )
|
||||
{
|
||||
touch_button_t *button;
|
||||
|
||||
if( !touch.initialized )
|
||||
return;
|
||||
|
||||
@@ -865,15 +842,14 @@ void Touch_AddClientButton( const char *name, const char *texture, const char *c
|
||||
if( round == round_aspect )
|
||||
y2 = y1 + ( x2 - x1 ) / (Touch_AspectRatio()) * aspect;
|
||||
|
||||
button = Touch_AddButton( &touch.list_user, name, texture, command, x1, y1, x2, y2, color, true );
|
||||
touch_button_t *button = Touch_AddButton( &touch.list_user, name, texture, command, x1, y1, x2, y2, color, true );
|
||||
SetBits( button->flags, TOUCH_FL_CLIENT | TOUCH_FL_NOEDIT );
|
||||
button->aspect = aspect;
|
||||
}
|
||||
|
||||
static void Touch_LoadDefaults_f( void )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < g_DefaultButtonsLength; i++ )
|
||||
for( int i = 0; i < g_DefaultButtonsLength; i++ )
|
||||
{
|
||||
touch_button_t *button;
|
||||
float x1 = g_DefaultButtons[i].x1,
|
||||
@@ -903,11 +879,9 @@ static void Touch_LoadDefaults_f( void )
|
||||
// Add default button from client
|
||||
void Touch_AddDefaultButton( const char *name, const char *texture, const char *command, float x1, float y1, float x2, float y2, byte *color, int round, float aspect, int flags )
|
||||
{
|
||||
touchdefaultbutton_t *b;
|
||||
|
||||
g_DefaultButtons = Mem_Realloc( touch.mempool, g_DefaultButtons, sizeof( *g_DefaultButtons ) * ( g_DefaultButtonsLength + 1 ));
|
||||
|
||||
b = &g_DefaultButtons[g_DefaultButtonsLength];
|
||||
touchdefaultbutton_t *b = &g_DefaultButtons[g_DefaultButtonsLength];
|
||||
|
||||
Q_strncpy( b->name, name, sizeof( b->name ));
|
||||
Q_strncpy( b->texture, texture, sizeof( b->texture ));
|
||||
@@ -938,22 +912,18 @@ void Touch_ResetDefaultButtons( void )
|
||||
|
||||
static void Touch_AddButton_f( void )
|
||||
{
|
||||
rgba_t color = { 255, 255, 255, 255 };
|
||||
touch_button_t *button = NULL;
|
||||
const char *name, *command;
|
||||
float x1 = 0.4f, y1 = 0.4f, x2 = 0.6f, y2 = 0.6f;
|
||||
qboolean privileged = Cmd_CurrentCommandIsPrivileged();
|
||||
string texture;
|
||||
|
||||
if( Cmd_Argc( ) < 4 )
|
||||
{
|
||||
Con_Printf( S_USAGE "touch_addbutton <name> <texture> <command> [<x1> <y1> <x2> <y2> [ r g b a ] ]\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
name = Cmd_Argv( 1 );
|
||||
const char *name = Cmd_Argv( 1 );
|
||||
string texture;
|
||||
Q_strncpy( texture, Cmd_Argv( 2 ), sizeof( texture ));
|
||||
command = Cmd_Argv( 3 );
|
||||
const char *command = Cmd_Argv( 3 );
|
||||
float x1 = 0.4f, y1 = 0.4f, x2 = 0.6f, y2 = 0.6f;
|
||||
rgba_t color = { 255, 255, 255, 255 };
|
||||
|
||||
// HACKHACK: old engine specifically used .tga for touch buttons
|
||||
// and because new engine extras.pk3 don't have .tga textures
|
||||
@@ -980,7 +950,8 @@ static void Touch_AddButton_f( void )
|
||||
color[3] = Q_atoi( Cmd_Argv( 11 ));
|
||||
}
|
||||
|
||||
button = Touch_AddButton( &touch.list_user, name, texture, command, x1, y1, x2, y2, color, privileged );
|
||||
qboolean privileged = Cmd_CurrentCommandIsPrivileged();
|
||||
touch_button_t *button = Touch_AddButton( &touch.list_user, name, texture, command, x1, y1, x2, y2, color, privileged );
|
||||
|
||||
if( Cmd_Argc( ) >= 13 )
|
||||
SetBits( button->flags, Q_atoi( Cmd_Argv( 12 )));
|
||||
@@ -1023,9 +994,7 @@ static void Touch_EnableEdit_f( void )
|
||||
// convert coordinates to actual aspect ratio after it was updated
|
||||
if( touch.config_aspect_ratio != touch.actual_aspect_ratio )
|
||||
{
|
||||
touch_button_t *button;
|
||||
|
||||
for( button = touch.list_user.first; button; button = button->next )
|
||||
for( touch_button_t *button = touch.list_user.first; button; button = button->next )
|
||||
{
|
||||
button->y1 /= touch.actual_aspect_ratio / touch.config_aspect_ratio;
|
||||
button->y2 /= touch.actual_aspect_ratio / touch.config_aspect_ratio;
|
||||
@@ -1315,10 +1284,6 @@ static void IN_TouchCheckCoords( float *x1, float *y1, float *x2, float *y2 )
|
||||
|
||||
static float Touch_DrawCharacter( float x, float y, int number, float size )
|
||||
{
|
||||
float s1, s2, t1, t2, width, height;
|
||||
int w, h;
|
||||
wrect_t *prc;
|
||||
|
||||
if( !cls.creditsFont.valid )
|
||||
return 0;
|
||||
|
||||
@@ -1328,16 +1293,17 @@ static float Touch_DrawCharacter( float x, float y, int number, float size )
|
||||
if( !number )
|
||||
return 0;
|
||||
|
||||
int w, h;
|
||||
R_GetTextureParms( &w, &h, cls.creditsFont.hFontTexture );
|
||||
prc = &cls.creditsFont.fontRc[number];
|
||||
wrect_t *prc = &cls.creditsFont.fontRc[number];
|
||||
|
||||
s1 = prc->left / (float)w;
|
||||
t1 = prc->top / (float)h;
|
||||
s2 = prc->right / (float)w;
|
||||
t2 = prc->bottom / (float)h;
|
||||
float s1 = prc->left / (float)w;
|
||||
float t1 = prc->top / (float)h;
|
||||
float s2 = prc->right / (float)w;
|
||||
float t2 = prc->bottom / (float)h;
|
||||
|
||||
width = ( prc->right - prc->left ) / 1024.0f * size;
|
||||
height = ( prc->bottom - prc->top ) / 1024.0f * size;
|
||||
float width = ( prc->right - prc->left ) / 1024.0f * size;
|
||||
float height = ( prc->bottom - prc->top ) / 1024.0f * size;
|
||||
|
||||
ref.dllFuncs.R_DrawStretchPic( TO_SCRN_X( x ), TO_SCRN_Y( y ), TO_SCRN_X( width ), TO_SCRN_X( height ),
|
||||
s1, t1, s2, t2, cls.creditsFont.hFontTexture );
|
||||
@@ -1384,9 +1350,7 @@ static float Touch_DrawText( float x1, float y1, float x2, float y2, const char
|
||||
|
||||
static void Touch_DrawButtons( touchbuttonlist_t *list )
|
||||
{
|
||||
touch_button_t *b;
|
||||
|
||||
for( b = list->first; b; b = b->next )
|
||||
for( touch_button_t *b = list->first; b; b = b->next )
|
||||
{
|
||||
if( Touch_IsVisible( b ))
|
||||
{
|
||||
@@ -1506,17 +1470,15 @@ void Touch_Draw( void )
|
||||
|
||||
if( touch.state >= state_edit && touch_grid_enable.value )
|
||||
{
|
||||
float x;
|
||||
|
||||
if( touch_in_menu.value )
|
||||
ref.dllFuncs.FillRGBA( kRenderTransTexture, 0, 0, 1, 1, 32, 32, 32, 255 );
|
||||
else
|
||||
ref.dllFuncs.FillRGBA( kRenderTransTexture, 0, 0, 1, 1, 0, 0, 0, 112 );
|
||||
|
||||
for( x = 0.0f; x < 1.0f; x += GRID_X )
|
||||
for( float x = 0.0f; x < 1.0f; x += GRID_X )
|
||||
ref.dllFuncs.FillRGBA( kRenderTransTexture, TO_SCRN_X( x ), 0, 1, TO_SCRN_Y( 1 ), 0, 224, 224, 112 );
|
||||
|
||||
for( x = 0.0f; x < 1.0f; x += GRID_Y )
|
||||
for( float x = 0.0f; x < 1.0f; x += GRID_Y )
|
||||
ref.dllFuncs.FillRGBA( kRenderTransTexture, 0, TO_SCRN_Y( x ), TO_SCRN_X( 1 ), 1, 0, 224, 224, 112 );
|
||||
}
|
||||
|
||||
@@ -1738,16 +1700,14 @@ static void Touch_Motion( int fingerID, float x, float y, float dx, float dy )
|
||||
|
||||
if( touch_nonlinear_look.value )
|
||||
{
|
||||
float dabs, dcos, dsin;
|
||||
|
||||
// save angle, modify only velocity
|
||||
dabs = sqrt( dx * dx + dy * dy );
|
||||
float dabs = sqrt( dx * dx + dy * dy );
|
||||
|
||||
if( dabs < 0.000001f )
|
||||
return; // no motion, avoid division by zero
|
||||
|
||||
dcos = dx / dabs;
|
||||
dsin = dy / dabs;
|
||||
float dcos = dx / dabs;
|
||||
float dsin = dy / dabs;
|
||||
|
||||
if( touch_exp_mult.value > 1 )
|
||||
dabs = ( exp( dabs * touch_exp_mult.value ) - 1 ) / touch_exp_mult.value;
|
||||
@@ -1771,14 +1731,13 @@ static void Touch_Motion( int fingerID, float x, float y, float dx, float dy )
|
||||
|
||||
static qboolean Touch_ButtonPress( touchbuttonlist_t *list, touchEventType type, int fingerID, float x, float y )
|
||||
{
|
||||
touch_button_t *button;
|
||||
qboolean result = false;
|
||||
|
||||
if( type != event_down && type != event_up )
|
||||
return false;
|
||||
|
||||
// run from end(front) to start(back)
|
||||
for( button = list->last; button; button = button->prev )
|
||||
for( touch_button_t *button = list->last; button; button = button->prev )
|
||||
{
|
||||
// skip invisible buttons
|
||||
if( !Touch_IsVisible( button ))
|
||||
@@ -1850,14 +1809,12 @@ static qboolean Touch_ButtonPress( touchbuttonlist_t *list, touchEventType type,
|
||||
|
||||
if( touch.look_finger == fingerID )
|
||||
{
|
||||
touch_button_t *newbutton;
|
||||
|
||||
// this is an error, try recover
|
||||
touch.move_finger = touch.look_finger = -1;
|
||||
|
||||
// player touched touch_move with enabled look mode
|
||||
// and same finger id. release all move triggers
|
||||
for( newbutton = list->first; newbutton; newbutton = newbutton->next )
|
||||
for( touch_button_t *newbutton = list->first; newbutton; newbutton = newbutton->next )
|
||||
{
|
||||
if( newbutton->type == touch_move || newbutton->type == touch_look )
|
||||
newbutton->finger = -1;
|
||||
@@ -1910,14 +1867,12 @@ static qboolean Touch_ButtonPress( touchbuttonlist_t *list, touchEventType type,
|
||||
|
||||
if( touch.move_finger == fingerID )
|
||||
{
|
||||
touch_button_t *newbutton;
|
||||
|
||||
// this is an error, try recover
|
||||
touch.move_finger = touch.look_finger = -1;
|
||||
|
||||
// player touched touch_move with enabled look mode
|
||||
// and same finger id. release all move triggers
|
||||
for( newbutton = list->first; newbutton; newbutton = newbutton->next )
|
||||
for( touch_button_t *newbutton = list->first; newbutton; newbutton = newbutton->next )
|
||||
{
|
||||
if( newbutton->type == touch_move || newbutton->type == touch_look )
|
||||
newbutton->finger = -1;
|
||||
@@ -1994,8 +1949,6 @@ static qboolean Touch_ButtonPress( touchbuttonlist_t *list, touchEventType type,
|
||||
|
||||
static qboolean Touch_ButtonEdit( touchEventType type, int fingerID, float x, float y )
|
||||
{
|
||||
touch_button_t *button;
|
||||
|
||||
// edit buttons are on y1
|
||||
if( type == event_down )
|
||||
{
|
||||
@@ -2010,7 +1963,7 @@ static qboolean Touch_ButtonEdit( touchEventType type, int fingerID, float x, fl
|
||||
}
|
||||
|
||||
// run from end(front) to start(back)
|
||||
for( button = touch.list_user.last; button; button = button->prev )
|
||||
for( touch_button_t *button = touch.list_user.last; button; button = button->prev )
|
||||
{
|
||||
if( type == event_down )
|
||||
{
|
||||
|
||||
@@ -337,8 +337,6 @@ IN_MouseMove
|
||||
*/
|
||||
static void IN_MouseMove( void )
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if( !in_mouseinitialized )
|
||||
return;
|
||||
|
||||
@@ -350,6 +348,7 @@ static void IN_MouseMove( void )
|
||||
}
|
||||
|
||||
// find mouse movement
|
||||
int x, y;
|
||||
Platform_GetMousePos( &x, &y );
|
||||
|
||||
VGui_MouseMove( x, y );
|
||||
@@ -586,18 +585,15 @@ Called from cl_main.c after generating command in client
|
||||
*/
|
||||
void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active )
|
||||
{
|
||||
float forward, side, pitch, yaw;
|
||||
|
||||
if( clgame.dllFuncs.pfnLookEvent )
|
||||
return;
|
||||
|
||||
if( cls.key_dest != key_game || cl.paused || cl.intermission )
|
||||
return;
|
||||
|
||||
forward = side = pitch = yaw = 0;
|
||||
|
||||
if( active )
|
||||
{
|
||||
float forward = 0, side = 0, pitch = 0, yaw = 0;
|
||||
float sensitivity = 1;//( (float)cl.local.scr_fov / (float)90.0f );
|
||||
|
||||
IN_CollectInput( &forward, &side, &pitch, &yaw, false );
|
||||
|
||||
@@ -73,9 +73,7 @@ static void free_winding( winding_t *w )
|
||||
|
||||
static winding_t *winding_copy( winding_t *w )
|
||||
{
|
||||
winding_t *neww;
|
||||
|
||||
neww = winding_alloc( w->numpoints );
|
||||
winding_t *neww = winding_alloc( w->numpoints );
|
||||
memcpy( neww, w, offsetof( winding_t, p[w->numpoints] ) );
|
||||
|
||||
return neww;
|
||||
@@ -83,12 +81,9 @@ static winding_t *winding_copy( winding_t *w )
|
||||
|
||||
static void winding_reverse( winding_t *w )
|
||||
{
|
||||
vec3_t point;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < w->numpoints / 2; i++ )
|
||||
for( int i = 0; i < w->numpoints / 2; i++ )
|
||||
{
|
||||
VectorCopy( w->p[i], point );
|
||||
vec3_t point = Vec3( w->p[i] );
|
||||
VectorCopy( w->p[w->numpoints - i - 1], w->p[i] );
|
||||
VectorCopy( point, w->p[w->numpoints - i - 1] );
|
||||
}
|
||||
@@ -117,15 +112,13 @@ winding_for_plane
|
||||
static winding_t *winding_for_plane( const mplane_t *p )
|
||||
{
|
||||
vec3_t org, vright, vup;
|
||||
int i, axis;
|
||||
vec_t max, v;
|
||||
winding_t *w;
|
||||
vec_t v;
|
||||
|
||||
// find the major axis
|
||||
max = -BOGUS_RANGE;
|
||||
axis = -1;
|
||||
vec_t max = -BOGUS_RANGE;
|
||||
int axis = -1;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
v = fabs( p->normal[i] );
|
||||
if( v > max )
|
||||
@@ -159,7 +152,7 @@ static winding_t *winding_for_plane( const mplane_t *p )
|
||||
VectorScale( vright, BOGUS_RANGE, vright );
|
||||
|
||||
// project a really big axis aligned box onto the plane
|
||||
w = winding_alloc( 4 );
|
||||
winding_t *w = winding_alloc( 4 );
|
||||
memset( w->p, 0, sizeof( vec3_t ) * 4 );
|
||||
w->numpoints = 4;
|
||||
w->plane = p;
|
||||
@@ -248,46 +241,42 @@ If keepon is true, an exactly on-plane winding will be saved, otherwise
|
||||
*/
|
||||
static winding_t *winding_clip( winding_t *in, const mplane_t *split, qboolean keepon, int side, vec_t epsilon )
|
||||
{
|
||||
vec_t *dists;
|
||||
int *sides;
|
||||
int counts[3];
|
||||
vec_t dot;
|
||||
int i, j;
|
||||
winding_t *neww;
|
||||
vec_t *p1, *p2, *mid;
|
||||
int maxpts;
|
||||
|
||||
dists = (vec_t *)malloc(( in->numpoints + 1 ) * sizeof( vec_t ));
|
||||
sides = (int *)malloc(( in->numpoints + 1 ) * sizeof( int ));
|
||||
vec_t *dists = (vec_t *)malloc(( in->numpoints + 1 ) * sizeof( vec_t ));
|
||||
int *sides = (int *)malloc(( in->numpoints + 1 ) * sizeof( int ));
|
||||
CalcSides( in, split, sides, dists, counts, epsilon );
|
||||
|
||||
if( keepon && !counts[SIDE_FRONT] && !counts[SIDE_BACK] )
|
||||
{
|
||||
neww = in;
|
||||
goto out_free;
|
||||
free( dists );
|
||||
free( sides );
|
||||
return in;
|
||||
}
|
||||
|
||||
if( !counts[side] )
|
||||
{
|
||||
free_winding( in );
|
||||
neww = NULL;
|
||||
goto out_free;
|
||||
free( dists );
|
||||
free( sides );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( !counts[side ^ 1] )
|
||||
{
|
||||
neww = in;
|
||||
goto out_free;
|
||||
free( dists );
|
||||
free( sides );
|
||||
return in;
|
||||
}
|
||||
|
||||
maxpts = in->numpoints + 4;
|
||||
neww = winding_alloc( maxpts );
|
||||
int maxpts = in->numpoints + 4;
|
||||
winding_t *neww = winding_alloc( maxpts );
|
||||
neww->numpoints = 0;
|
||||
neww->plane = in->plane;
|
||||
|
||||
for( i = 0; i < in->numpoints; i++ )
|
||||
for( int i = 0; i < in->numpoints; i++ )
|
||||
{
|
||||
p1 = in->p[i];
|
||||
vec_t *p1 = in->p[i];
|
||||
|
||||
if( sides[i] == SIDE_ON )
|
||||
{
|
||||
@@ -306,11 +295,11 @@ static winding_t *winding_clip( winding_t *in, const mplane_t *split, qboolean k
|
||||
continue;
|
||||
|
||||
// generate a split point
|
||||
p2 = in->p[(i + 1) % in->numpoints];
|
||||
mid = neww->p[neww->numpoints++];
|
||||
vec_t *p2 = in->p[(i + 1) % in->numpoints];
|
||||
vec_t *mid = neww->p[neww->numpoints++];
|
||||
|
||||
dot = dists[i] / (dists[i] - dists[i + 1]);
|
||||
for( j = 0; j < 3; j++ )
|
||||
vec_t dot = dists[i] / (dists[i] - dists[i + 1]);
|
||||
for( int j = 0; j < 3; j++ )
|
||||
{
|
||||
// avoid round off error when possible
|
||||
if( in->plane->normal[j] == 1.0f )
|
||||
@@ -333,7 +322,6 @@ static winding_t *winding_clip( winding_t *in, const mplane_t *split, qboolean k
|
||||
|
||||
// Shrink the winding back to just what it needs...
|
||||
neww = winding_shrink(neww);
|
||||
out_free:
|
||||
free( dists );
|
||||
free( sides );
|
||||
|
||||
@@ -352,17 +340,10 @@ new windings will be created.
|
||||
*/
|
||||
static void winding_split( winding_t *in, const mplane_t *split, winding_t **pfront, winding_t **pback )
|
||||
{
|
||||
vec_t *dists;
|
||||
int *sides;
|
||||
int counts[3];
|
||||
vec_t dot;
|
||||
int i, j;
|
||||
winding_t *front, *back;
|
||||
vec_t *p1, *p2, *mid;
|
||||
int maxpts;
|
||||
|
||||
dists = (vec_t *)malloc(( in->numpoints + 1 ) * sizeof( vec_t ));
|
||||
sides = (int *)malloc(( in->numpoints + 1 ) * sizeof( int ));
|
||||
vec_t *dists = (vec_t *)malloc(( in->numpoints + 1 ) * sizeof( vec_t ));
|
||||
int *sides = (int *)malloc(( in->numpoints + 1 ) * sizeof( int ));
|
||||
CalcSides(in, split, sides, dists, counts, 0.04f );
|
||||
|
||||
if( !counts[0] && !counts[1] )
|
||||
@@ -370,34 +351,40 @@ static void winding_split( winding_t *in, const mplane_t *split, winding_t **pfr
|
||||
// winding on the split plane - return copies on both sides
|
||||
*pfront = winding_copy( in );
|
||||
*pback = winding_copy( in );
|
||||
goto out_free;
|
||||
free( dists );
|
||||
free( sides );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !counts[0] )
|
||||
{
|
||||
*pfront = NULL;
|
||||
*pback = in;
|
||||
goto out_free;
|
||||
free( dists );
|
||||
free( sides );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !counts[1] )
|
||||
{
|
||||
*pfront = in;
|
||||
*pback = NULL;
|
||||
goto out_free;
|
||||
free( dists );
|
||||
free( sides );
|
||||
return;
|
||||
}
|
||||
|
||||
maxpts = in->numpoints + 4;
|
||||
front = winding_alloc( maxpts );
|
||||
int maxpts = in->numpoints + 4;
|
||||
winding_t *front = winding_alloc( maxpts );
|
||||
front->numpoints = 0;
|
||||
front->plane = in->plane;
|
||||
back = winding_alloc( maxpts );
|
||||
winding_t *back = winding_alloc( maxpts );
|
||||
back->numpoints = 0;
|
||||
back->plane = in->plane;
|
||||
|
||||
for( i = 0; i < in->numpoints; i++ )
|
||||
for( int i = 0; i < in->numpoints; i++ )
|
||||
{
|
||||
p1 = in->p[i];
|
||||
vec_t *p1 = in->p[i];
|
||||
|
||||
if( sides[i] == SIDE_ON )
|
||||
{
|
||||
@@ -423,11 +410,11 @@ static void winding_split( winding_t *in, const mplane_t *split, winding_t **pfr
|
||||
continue;
|
||||
|
||||
// generate a split point
|
||||
p2 = in->p[(i + 1) % in->numpoints];
|
||||
mid = front->p[front->numpoints++];
|
||||
vec_t *p2 = in->p[(i + 1) % in->numpoints];
|
||||
vec_t *mid = front->p[front->numpoints++];
|
||||
|
||||
dot = dists[i] / (dists[i] - dists[i + 1]);
|
||||
for( j = 0; j < 3; j++ )
|
||||
vec_t dot = dists[i] / (dists[i] - dists[i + 1]);
|
||||
for( int j = 0; j < 3; j++ )
|
||||
{
|
||||
// avoid round off error when possible
|
||||
if( in->plane->normal[j] == 1.0f )
|
||||
@@ -449,7 +436,6 @@ static void winding_split( winding_t *in, const mplane_t *split, winding_t **pfr
|
||||
|
||||
*pfront = winding_shrink( front );
|
||||
*pback = winding_shrink( back );
|
||||
out_free:
|
||||
free( dists );
|
||||
free( sides );
|
||||
}
|
||||
|
||||
@@ -60,33 +60,34 @@ CL_ParseSoundPacket
|
||||
*/
|
||||
static void CL_ParseSoundPacket( sizebuf_t *msg, qboolean restore )
|
||||
{
|
||||
vec3_t pos;
|
||||
int chan, sound;
|
||||
float volume, attn;
|
||||
int flags, pitch, entnum, wordIndex = 0;
|
||||
int wordIndex = 0;
|
||||
sound_t handle = 0;
|
||||
double samplePos = 0, forcedEnd = 0;
|
||||
|
||||
flags = MSG_ReadUBitLong( msg, MAX_SND_FLAGS_BITS );
|
||||
sound = MSG_ReadUBitLong( msg, MAX_SOUND_BITS );
|
||||
chan = MSG_ReadUBitLong( msg, MAX_SND_CHAN_BITS );
|
||||
int flags = MSG_ReadUBitLong( msg, MAX_SND_FLAGS_BITS );
|
||||
int sound = MSG_ReadUBitLong( msg, MAX_SOUND_BITS );
|
||||
int chan = MSG_ReadUBitLong( msg, MAX_SND_CHAN_BITS );
|
||||
|
||||
float volume;
|
||||
if( FBitSet( flags, SND_VOLUME ))
|
||||
volume = (float)MSG_ReadByte( msg ) / 255.0f;
|
||||
else volume = VOL_NORM;
|
||||
|
||||
float attn;
|
||||
if( FBitSet( flags, SND_ATTENUATION ))
|
||||
attn = (float)MSG_ReadByte( msg ) / 64.0f;
|
||||
else attn = ATTN_NONE;
|
||||
|
||||
int pitch;
|
||||
if( FBitSet( flags, SND_PITCH ))
|
||||
pitch = MSG_ReadByte( msg );
|
||||
else pitch = PITCH_NORM;
|
||||
|
||||
// entity reletive
|
||||
entnum = MSG_ReadUBitLong( msg, MAX_ENTITY_BITS );
|
||||
int entnum = MSG_ReadUBitLong( msg, MAX_ENTITY_BITS );
|
||||
|
||||
// positioned in space
|
||||
vec3_t pos;
|
||||
MSG_ReadVec3Coord( msg, pos );
|
||||
|
||||
if( FBitSet( flags, SND_SENTENCE ))
|
||||
@@ -129,8 +130,6 @@ CL_ParseServerTime
|
||||
*/
|
||||
void CL_ParseServerTime( sizebuf_t *msg, connprotocol_t proto )
|
||||
{
|
||||
double dt;
|
||||
|
||||
cl.mtime[1] = cl.mtime[0];
|
||||
cl.mtime[0] = MSG_ReadFloat( msg );
|
||||
|
||||
@@ -140,7 +139,7 @@ void CL_ParseServerTime( sizebuf_t *msg, connprotocol_t proto )
|
||||
if( cl.maxclients == 1 )
|
||||
cl.time = cl.mtime[0];
|
||||
|
||||
dt = cl.time - cl.mtime[0];
|
||||
double dt = cl.time - cl.mtime[0];
|
||||
|
||||
if( fabs( dt ) > cl_clockreset.value ) // 0.1 by default
|
||||
{
|
||||
@@ -212,29 +211,26 @@ CL_ParseParticles
|
||||
*/
|
||||
static void CL_ParseParticles( sizebuf_t *msg, connprotocol_t proto )
|
||||
{
|
||||
vec3_t org, dir;
|
||||
int i, count, color;
|
||||
float life;
|
||||
vec3_t org, dir;
|
||||
|
||||
MSG_ReadVec3Coord( msg, org );
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( int i = 0; i < 3; i++ )
|
||||
dir[i] = MSG_ReadChar( msg ) * 0.0625f;
|
||||
|
||||
count = MSG_ReadByte( msg );
|
||||
color = MSG_ReadByte( msg );
|
||||
int count = MSG_ReadByte( msg );
|
||||
int color = MSG_ReadByte( msg );
|
||||
if( count == 255 )
|
||||
count = 1024;
|
||||
|
||||
float life;
|
||||
if( proto == PROTO_GOLDSRC )
|
||||
life = 0.0f;
|
||||
else life = MSG_ReadByte( msg ) * 0.125f;
|
||||
|
||||
if( life != 0.0f && count == 1 )
|
||||
{
|
||||
particle_t *p;
|
||||
|
||||
p = R_AllocParticle( NULL );
|
||||
particle_t *p = R_AllocParticle( NULL );
|
||||
if( !p ) return;
|
||||
|
||||
p->die += life;
|
||||
@@ -256,10 +252,8 @@ static client entity
|
||||
*/
|
||||
static void CL_ParseStaticEntity( sizebuf_t *msg )
|
||||
{
|
||||
int i;
|
||||
const entity_state_t from = { 0 };
|
||||
entity_state_t to;
|
||||
cl_entity_t *ent;
|
||||
|
||||
if( !clgame.static_entities )
|
||||
clgame.static_entities = Mem_Calloc( clgame.mempool, sizeof( cl_entity_t ) * MAX_STATIC_ENTITIES );
|
||||
@@ -267,14 +261,14 @@ static void CL_ParseStaticEntity( sizebuf_t *msg )
|
||||
MSG_ReadUBitLong( msg, MAX_ENTITY_BITS );
|
||||
MSG_ReadDeltaEntity( msg, &from, &to, 0, DELTA_STATIC, cl.mtime[0] );
|
||||
|
||||
i = clgame.numStatics;
|
||||
int i = clgame.numStatics;
|
||||
if( i >= MAX_STATIC_ENTITIES )
|
||||
{
|
||||
Con_Printf( S_ERROR "MAX_STATIC_ENTITIES limit exceeded!\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
ent = &clgame.static_entities[i];
|
||||
cl_entity_t *ent = &clgame.static_entities[i];
|
||||
clgame.numStatics++;
|
||||
|
||||
// all states are same
|
||||
@@ -315,7 +309,7 @@ Set new weapon animation
|
||||
*/
|
||||
void GAME_EXPORT CL_WeaponAnim( int iAnim, int body )
|
||||
{
|
||||
cl_entity_t *view = &clgame.viewent;
|
||||
cl_entity_t *view = &clgame.viewent;
|
||||
|
||||
cl.local.weaponstarttime = 0.0f;
|
||||
cl.local.weaponsequence = iAnim;
|
||||
@@ -339,20 +333,18 @@ CL_ParseStaticDecal
|
||||
*/
|
||||
void CL_ParseStaticDecal( sizebuf_t *msg )
|
||||
{
|
||||
vec3_t origin;
|
||||
int decalIndex, entityIndex, modelIndex;
|
||||
float scale;
|
||||
int flags;
|
||||
vec3_t origin;
|
||||
|
||||
MSG_ReadVec3Coord( msg, origin );
|
||||
decalIndex = MSG_ReadWord( msg );
|
||||
entityIndex = MSG_ReadShort( msg );
|
||||
int decalIndex = MSG_ReadWord( msg );
|
||||
int entityIndex = MSG_ReadShort( msg );
|
||||
|
||||
int modelIndex;
|
||||
if( entityIndex > 0 )
|
||||
modelIndex = MSG_ReadWord( msg );
|
||||
else modelIndex = 0;
|
||||
flags = MSG_ReadByte( msg );
|
||||
scale = (float)MSG_ReadWord( msg ) / 4096.0f;
|
||||
int flags = MSG_ReadByte( msg );
|
||||
float scale = (float)MSG_ReadWord( msg ) / 4096.0f;
|
||||
|
||||
CL_FireCustomDecal( CL_DecalIndex( decalIndex ), entityIndex, modelIndex, origin, flags, scale );
|
||||
}
|
||||
@@ -381,11 +373,9 @@ CL_RequestMissingResources
|
||||
*/
|
||||
qboolean CL_RequestMissingResources( void )
|
||||
{
|
||||
resource_t *p;
|
||||
|
||||
if( !cls.dl.doneregistering && ( cls.dl.custom || cls.state == ca_validate ))
|
||||
{
|
||||
p = cl.resourcesneeded.pNext;
|
||||
resource_t *p = cl.resourcesneeded.pNext;
|
||||
|
||||
if( p == &cl.resourcesneeded )
|
||||
{
|
||||
@@ -404,17 +394,16 @@ qboolean CL_RequestMissingResources( void )
|
||||
|
||||
void CL_BatchResourceRequest( qboolean initialize )
|
||||
{
|
||||
byte data[MAX_INIT_MSG];
|
||||
resource_t *p, *n;
|
||||
sizebuf_t msg;
|
||||
qboolean done_downloading = true;
|
||||
byte data[MAX_INIT_MSG];
|
||||
sizebuf_t msg;
|
||||
qboolean done_downloading = true;
|
||||
|
||||
MSG_Init( &msg, "Resource Batch", data, sizeof( data ));
|
||||
|
||||
// client resources is not precached by server
|
||||
if( initialize ) CL_AddClientResources();
|
||||
|
||||
for( p = cl.resourcesneeded.pNext; p && p != &cl.resourcesneeded; p = n )
|
||||
for( resource_t *p = cl.resourcesneeded.pNext, *n; p && p != &cl.resourcesneeded; p = n )
|
||||
{
|
||||
n = p->pNext;
|
||||
|
||||
@@ -491,10 +480,9 @@ void CL_BatchResourceRequest( qboolean initialize )
|
||||
|
||||
int CL_EstimateNeededResources( void )
|
||||
{
|
||||
resource_t *p;
|
||||
int nTotalSize = 0;
|
||||
int nTotalSize = 0;
|
||||
|
||||
for( p = cl.resourcesneeded.pNext; p != &cl.resourcesneeded; p = p->pNext )
|
||||
for( resource_t *p = cl.resourcesneeded.pNext; p != &cl.resourcesneeded; p = p->pNext )
|
||||
{
|
||||
switch( p->type )
|
||||
{
|
||||
@@ -570,9 +558,7 @@ static void CL_StartResourceDownloading( const char *pszMessage, qboolean bCusto
|
||||
|
||||
static customization_t *CL_PlayerHasCustomization( int nPlayerNum, resourcetype_t type )
|
||||
{
|
||||
customization_t *pList;
|
||||
|
||||
for( pList = cl.players[nPlayerNum].customdata.pNext; pList; pList = pList->pNext )
|
||||
for( customization_t *pList = cl.players[nPlayerNum].customdata.pNext; pList; pList = pList->pNext )
|
||||
{
|
||||
if( pList->resource.type == type )
|
||||
return pList;
|
||||
@@ -582,10 +568,8 @@ static customization_t *CL_PlayerHasCustomization( int nPlayerNum, resourcetype_
|
||||
|
||||
static void CL_RemoveCustomization( int nPlayerNum, customization_t *pRemove )
|
||||
{
|
||||
customization_t *pList;
|
||||
customization_t *pNext;
|
||||
|
||||
for( pList = cl.players[nPlayerNum].customdata.pNext; pList; pList = pNext )
|
||||
customization_t *pNext;
|
||||
for( customization_t *pList = cl.players[nPlayerNum].customdata.pNext; pList; pList = pNext )
|
||||
{
|
||||
pNext = pList->pNext;
|
||||
|
||||
@@ -619,17 +603,11 @@ CL_ParseCustomization
|
||||
*/
|
||||
static void CL_ParseCustomization( sizebuf_t *msg )
|
||||
{
|
||||
customization_t *pExistingCustomization;
|
||||
customization_t *pList;
|
||||
qboolean bFound;
|
||||
resource_t *pRes;
|
||||
int i;
|
||||
|
||||
i = MSG_ReadByte( msg );
|
||||
int i = MSG_ReadByte( msg );
|
||||
if( i >= MAX_CLIENTS )
|
||||
Host_Error( "Bogus player index during customization parsing.\n" );
|
||||
|
||||
pRes = Mem_Calloc( cls.mempool, sizeof( resource_t ));
|
||||
resource_t *pRes = Mem_Calloc( cls.mempool, sizeof( resource_t ));
|
||||
pRes->type = MSG_ReadByte( msg );
|
||||
|
||||
Q_strncpy( pRes->szFileName, MSG_ReadString( msg ), sizeof( pRes->szFileName ));
|
||||
@@ -656,13 +634,13 @@ static void CL_ParseCustomization( sizebuf_t *msg )
|
||||
return;
|
||||
}
|
||||
|
||||
pExistingCustomization = CL_PlayerHasCustomization( i, pRes->type );
|
||||
customization_t *pExistingCustomization = CL_PlayerHasCustomization( i, pRes->type );
|
||||
|
||||
if( pExistingCustomization )
|
||||
CL_RemoveCustomization( i, pExistingCustomization );
|
||||
bFound = false;
|
||||
|
||||
for( pList = cl.players[pRes->playernum].customdata.pNext; pList; pList = pList->pNext )
|
||||
qboolean bFound = false;
|
||||
for( customization_t *pList = cl.players[pRes->playernum].customdata.pNext; pList; pList = pList->pNext )
|
||||
{
|
||||
if( !memcmp( pList->resource.rgucMD5_hash, pRes->rgucMD5_hash, 16 ))
|
||||
{
|
||||
@@ -673,11 +651,11 @@ static void CL_ParseCustomization( sizebuf_t *msg )
|
||||
|
||||
if( HPAK_GetDataPointer( hpk_custom_file.string, pRes, NULL, NULL ))
|
||||
{
|
||||
qboolean bError = false;
|
||||
qboolean bError = false;
|
||||
|
||||
if( !bFound )
|
||||
{
|
||||
pList = &cl.players[pRes->playernum].customdata;
|
||||
customization_t *pList = &cl.players[pRes->playernum].customdata;
|
||||
|
||||
if( !COM_CreateCustomization( pList, pRes, pRes->playernum, FCUST_FROMHPAK, NULL, NULL ))
|
||||
bError = true;
|
||||
@@ -707,15 +685,14 @@ CL_ParseResourceRequest
|
||||
*/
|
||||
void CL_SendResourceList( const resource_t *list, int count )
|
||||
{
|
||||
byte buffer[MAX_INIT_MSG];
|
||||
sizebuf_t sbuf;
|
||||
int i;
|
||||
byte buffer[MAX_INIT_MSG];
|
||||
sizebuf_t sbuf;
|
||||
|
||||
MSG_Init( &sbuf, "ResourceBlock", buffer, sizeof( buffer ));
|
||||
MSG_BeginClientCmd( &sbuf, clc_resourcelist );
|
||||
MSG_WriteShort( &sbuf, count );
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
MSG_WriteString( &sbuf, list[i].szFileName );
|
||||
MSG_WriteByte( &sbuf, list[i].type );
|
||||
@@ -733,10 +710,8 @@ void CL_SendResourceList( const resource_t *list, int count )
|
||||
|
||||
static void CL_ParseResourceRequest( sizebuf_t *msg )
|
||||
{
|
||||
int arg, nStartIndex;
|
||||
|
||||
arg = MSG_ReadLong( msg );
|
||||
nStartIndex = MSG_ReadLong( msg );
|
||||
int arg = MSG_ReadLong( msg );
|
||||
int nStartIndex = MSG_ReadLong( msg );
|
||||
|
||||
if( cl.servercount != arg )
|
||||
return;
|
||||
@@ -756,16 +731,12 @@ loading custom decal for self
|
||||
*/
|
||||
static void CL_CreateCustomizationList( void )
|
||||
{
|
||||
resource_t *pResource;
|
||||
player_info_t *pPlayer;
|
||||
int i;
|
||||
|
||||
pPlayer = &cl.players[cl.playernum];
|
||||
player_info_t *pPlayer = &cl.players[cl.playernum];
|
||||
pPlayer->customdata.pNext = NULL;
|
||||
|
||||
for( i = 0; i < cl.num_resources; i++ )
|
||||
for( int i = 0; i < cl.num_resources; i++ )
|
||||
{
|
||||
pResource = &cl.resourcelist[i];
|
||||
resource_t *pResource = &cl.resourcelist[i];
|
||||
|
||||
if( !COM_CreateCustomization( &pPlayer->customdata, pResource, cl.playernum, 0, NULL, NULL ))
|
||||
Con_Printf( "problem with client customization %s, ignoring...", pResource->szFileName );
|
||||
@@ -1247,12 +1218,10 @@ CL_ParseLightStyle
|
||||
*/
|
||||
static void CL_ParseLightStyle( sizebuf_t *msg, connprotocol_t proto )
|
||||
{
|
||||
int style;
|
||||
const char *s;
|
||||
float f = cl.mtime[0];
|
||||
float f = cl.mtime[0];
|
||||
|
||||
style = MSG_ReadByte( msg );
|
||||
s = MSG_ReadString( msg );
|
||||
int style = MSG_ReadByte( msg );
|
||||
const char *s = MSG_ReadString( msg );
|
||||
if( proto != PROTO_GOLDSRC && proto != PROTO_QUAKE )
|
||||
f = MSG_ReadFloat( msg );
|
||||
|
||||
@@ -1280,10 +1249,7 @@ add the view angle yaw
|
||||
*/
|
||||
static void CL_ParseAddAngle( sizebuf_t *msg )
|
||||
{
|
||||
pred_viewangle_t *a;
|
||||
float delta_yaw;
|
||||
|
||||
delta_yaw = MSG_ReadBitAngle( msg, 16 );
|
||||
float delta_yaw = MSG_ReadBitAngle( msg, 16 );
|
||||
#if 0
|
||||
cl.viewangles[YAW] += delta_yaw;
|
||||
return;
|
||||
@@ -1293,7 +1259,7 @@ static void CL_ParseAddAngle( sizebuf_t *msg )
|
||||
|
||||
// select entry into circular buffer
|
||||
cl.angle_position = (cl.angle_position + 1) & ANGLE_MASK;
|
||||
a = &cl.predicted_angle[cl.angle_position];
|
||||
pred_viewangle_t *a = &cl.predicted_angle[cl.angle_position];
|
||||
|
||||
// record update
|
||||
a->starttime = cl.mtime[0];
|
||||
@@ -1323,20 +1289,18 @@ reading decals, etc.
|
||||
*/
|
||||
static void CL_ParseRestore( sizebuf_t *msg )
|
||||
{
|
||||
string filename;
|
||||
int i, mapCount;
|
||||
char *pMapName;
|
||||
string filename;
|
||||
|
||||
// mapname.HL2
|
||||
Q_strncpy( filename, MSG_ReadString( msg ), sizeof( filename ));
|
||||
mapCount = MSG_ReadByte( msg );
|
||||
int mapCount = MSG_ReadByte( msg );
|
||||
|
||||
// g-cont. acutally in Xash3D this does nothing.
|
||||
// decals already restored on a server, and correctly transferred through levels
|
||||
// but i'm leave this message for backward compatibility
|
||||
for( i = 0; i < mapCount; i++ )
|
||||
for( int i = 0; i < mapCount; i++ )
|
||||
{
|
||||
pMapName = MSG_ReadString( msg );
|
||||
char *pMapName = MSG_ReadString( msg );
|
||||
Con_Printf( "Loading decals from %s\n", pMapName );
|
||||
}
|
||||
}
|
||||
@@ -1350,10 +1314,9 @@ register new user message or update existing
|
||||
*/
|
||||
static void CL_RegisterUserMessage( sizebuf_t *msg, connprotocol_t proto )
|
||||
{
|
||||
char *pszName;
|
||||
char szName[17];
|
||||
int size;
|
||||
int svc_num = MSG_ReadByte( msg );
|
||||
int size;
|
||||
|
||||
if( proto == PROTO_GOLDSRC )
|
||||
{
|
||||
@@ -1368,6 +1331,7 @@ static void CL_RegisterUserMessage( sizebuf_t *msg, connprotocol_t proto )
|
||||
size = -1;
|
||||
}
|
||||
|
||||
char *pszName;
|
||||
if( proto == PROTO_GOLDSRC )
|
||||
{
|
||||
MSG_ReadBytes( msg, szName, sizeof( szName ) - 1 );
|
||||
@@ -1388,9 +1352,8 @@ collect userinfo from all players
|
||||
*/
|
||||
static void CL_UpdateUserinfo( sizebuf_t *msg, connprotocol_t proto )
|
||||
{
|
||||
int slot, id;
|
||||
qboolean active;
|
||||
player_info_t *player;
|
||||
int slot, id;
|
||||
qboolean active;
|
||||
|
||||
if( proto == PROTO_GOLDSRC )
|
||||
{
|
||||
@@ -1408,7 +1371,7 @@ static void CL_UpdateUserinfo( sizebuf_t *msg, connprotocol_t proto )
|
||||
if( slot >= MAX_CLIENTS )
|
||||
Host_Error( "%s: svc_updateuserinfo >= MAX_CLIENTS\n", __func__ );
|
||||
|
||||
player = &cl.players[slot];
|
||||
player_info_t *player = &cl.players[slot];
|
||||
|
||||
if( active )
|
||||
{
|
||||
@@ -1449,9 +1412,7 @@ downloading and precache resource in-game
|
||||
*/
|
||||
void CL_ParseResource( sizebuf_t *msg )
|
||||
{
|
||||
resource_t *pResource;
|
||||
|
||||
pResource = Mem_Calloc( cls.mempool, sizeof( resource_t ));
|
||||
resource_t *pResource = Mem_Calloc( cls.mempool, sizeof( resource_t ));
|
||||
pResource->type = MSG_ReadUBitLong( msg, 4 );
|
||||
|
||||
Q_strncpy( pResource->szFileName, MSG_ReadString( msg ), sizeof( pResource->szFileName ));
|
||||
@@ -1511,13 +1472,10 @@ void CL_UpdateUserPings( sizebuf_t *msg )
|
||||
// because pings message always ends by null bit
|
||||
while( 1 )
|
||||
{
|
||||
int slot;
|
||||
player_info_t *player;
|
||||
|
||||
if( !MSG_ReadOneBit( msg ))
|
||||
break; // end of message
|
||||
|
||||
slot = MSG_ReadUBitLong( msg, MAX_CLIENT_BITS );
|
||||
int slot = MSG_ReadUBitLong( msg, MAX_CLIENT_BITS );
|
||||
|
||||
if( unlikely( slot >= MAX_CLIENTS ))
|
||||
{
|
||||
@@ -1525,7 +1483,7 @@ void CL_UpdateUserPings( sizebuf_t *msg )
|
||||
return;
|
||||
}
|
||||
|
||||
player = &cl.players[slot];
|
||||
player_info_t *player = &cl.players[slot];
|
||||
player->ping = MSG_ReadUBitLong( msg, 12 );
|
||||
player->packet_loss = MSG_ReadUBitLong( msg, 7 );
|
||||
}
|
||||
@@ -1550,18 +1508,14 @@ static const char *CL_CheckTypeToString( int check_type )
|
||||
|
||||
static void CL_SendConsistencyInfo( sizebuf_t *msg, connprotocol_t proto )
|
||||
{
|
||||
qboolean user_changed_diskfile;
|
||||
vec3_t mins, maxs;
|
||||
string filename;
|
||||
byte md5[16] = { 0 };
|
||||
int pos;
|
||||
byte md5[16] = { 0 };
|
||||
|
||||
if( !cl.need_force_consistency_response )
|
||||
return;
|
||||
cl.need_force_consistency_response = false;
|
||||
|
||||
MSG_BeginClientCmd( msg, clc_fileconsistency );
|
||||
pos = MSG_GetNumBytesWritten( msg );
|
||||
int pos = MSG_GetNumBytesWritten( msg );
|
||||
if( proto == PROTO_GOLDSRC )
|
||||
{
|
||||
MSG_WriteShort( msg, 0 );
|
||||
@@ -1573,9 +1527,11 @@ static void CL_SendConsistencyInfo( sizebuf_t *msg, connprotocol_t proto )
|
||||
for( int i = 0; i < cl.num_consistency; i++ )
|
||||
{
|
||||
qboolean have_file = true;
|
||||
qboolean user_changed_diskfile = false;
|
||||
vec3_t mins, maxs;
|
||||
string filename;
|
||||
consistency_t *pc = &cl.consistency_list[i];
|
||||
|
||||
user_changed_diskfile = false;
|
||||
MSG_WriteOneBit( msg, 1 );
|
||||
MSG_WriteUBitLong( msg, pc->orig_index, MAX_MODEL_BITS );
|
||||
|
||||
@@ -1654,10 +1610,9 @@ static void CL_SendConsistencyInfo( sizebuf_t *msg, connprotocol_t proto )
|
||||
|
||||
if( proto == PROTO_GOLDSRC )
|
||||
{
|
||||
int len;
|
||||
MSG_EndBitWriting( msg );
|
||||
|
||||
len = MSG_GetNumBytesWritten( msg ) - pos - 2;
|
||||
int len = MSG_GetNumBytesWritten( msg ) - pos - 2;
|
||||
*(short *)&msg->pData[pos] = len;
|
||||
|
||||
COM_Munge( &msg->pData[pos + 2], len, cl.servercount );
|
||||
@@ -1673,11 +1628,10 @@ static void CL_StartDark( void )
|
||||
{
|
||||
if( v_dark.value )
|
||||
{
|
||||
screenfade_t *sf = &clgame.fade;
|
||||
float fadetime = 5.0f;
|
||||
client_textmessage_t *title;
|
||||
screenfade_t *sf = &clgame.fade;
|
||||
float fadetime = 5.0f;
|
||||
|
||||
title = CL_TextMessageGet( "GAMETITLE" );
|
||||
client_textmessage_t *title = CL_TextMessageGet( "GAMETITLE" );
|
||||
if( Host_IsQuakeCompatible( ))
|
||||
fadetime = 1.0f;
|
||||
|
||||
@@ -1789,20 +1743,12 @@ void CL_RegisterResources( sizebuf_t *msg, connprotocol_t proto )
|
||||
|
||||
static void CL_ParseConsistencyInfo( sizebuf_t *msg, connprotocol_t proto )
|
||||
{
|
||||
int lastcheck;
|
||||
int delta;
|
||||
int i;
|
||||
int isdelta;
|
||||
resource_t *pResource;
|
||||
resource_t *skip_crc_change;
|
||||
int skip;
|
||||
consistency_t *pc;
|
||||
byte nullbuffer[32];
|
||||
byte nullbuffer[32];
|
||||
|
||||
memset( nullbuffer, 0, 32 );
|
||||
|
||||
cl.need_force_consistency_response = MSG_ReadOneBit( msg );
|
||||
pResource = cl.resourcesneeded.pNext;
|
||||
resource_t *pResource = cl.resourcesneeded.pNext;
|
||||
|
||||
if( !cl.need_force_consistency_response )
|
||||
return;
|
||||
@@ -1816,19 +1762,20 @@ static void CL_ParseConsistencyInfo( sizebuf_t *msg, connprotocol_t proto )
|
||||
if( cl_trace_consistency.value )
|
||||
Con_Printf( "Server wants consistency of the following resources:\n" );
|
||||
|
||||
skip_crc_change = NULL;
|
||||
lastcheck = 0;
|
||||
resource_t *skip_crc_change = NULL;
|
||||
int lastcheck = 0;
|
||||
|
||||
while( MSG_ReadOneBit( msg ))
|
||||
{
|
||||
isdelta = MSG_ReadOneBit( msg );
|
||||
int isdelta = MSG_ReadOneBit( msg );
|
||||
int delta;
|
||||
|
||||
if( isdelta ) delta = MSG_ReadUBitLong( msg, 5 ) + lastcheck;
|
||||
else delta = MSG_ReadUBitLong( msg, proto == PROTO_GOLDSRC ? MAX_GOLDSRC_MODEL_BITS : MAX_MODEL_BITS );
|
||||
|
||||
skip = delta - lastcheck;
|
||||
int skip = delta - lastcheck;
|
||||
|
||||
for( i = 0; i < skip; i++ )
|
||||
for( int i = 0; i < skip; i++ )
|
||||
{
|
||||
if( pResource != skip_crc_change && Q_strstr( pResource->szFileName, "models/" ))
|
||||
Mod_NeedCRC( pResource->szFileName, false );
|
||||
@@ -1844,7 +1791,7 @@ static void CL_ParseConsistencyInfo( sizebuf_t *msg, connprotocol_t proto )
|
||||
if( cl.num_consistency >= MAX_MODELS )
|
||||
Host_Error( "%s: MAX_MODELS limit exceeded (%d)\n", __func__, MAX_MODELS );
|
||||
|
||||
pc = &cl.consistency_list[cl.num_consistency];
|
||||
consistency_t *pc = &cl.consistency_list[cl.num_consistency];
|
||||
cl.num_consistency++;
|
||||
|
||||
memset( pc, 0, sizeof( *pc ));
|
||||
@@ -1876,14 +1823,11 @@ CL_ParseResourceList
|
||||
*/
|
||||
void CL_ParseResourceList( sizebuf_t *msg, connprotocol_t proto )
|
||||
{
|
||||
resource_t *pResource;
|
||||
int i, total;
|
||||
int total = MSG_ReadUBitLong( msg, proto == PROTO_GOLDSRC ? MAX_GOLDSRC_RESOURCE_BITS : MAX_RESOURCE_BITS );
|
||||
|
||||
total = MSG_ReadUBitLong( msg, proto == PROTO_GOLDSRC ? MAX_GOLDSRC_RESOURCE_BITS : MAX_RESOURCE_BITS );
|
||||
|
||||
for( i = 0; i < total; i++ )
|
||||
for( int i = 0; i < total; i++ )
|
||||
{
|
||||
pResource = Mem_Calloc( cls.mempool, sizeof( resource_t ));
|
||||
resource_t *pResource = Mem_Calloc( cls.mempool, sizeof( resource_t ));
|
||||
pResource->type = MSG_ReadUBitLong( msg, 4 );
|
||||
|
||||
Q_strncpy( pResource->szFileName, MSG_ReadString( msg ), sizeof( pResource->szFileName ));
|
||||
@@ -2080,14 +2024,12 @@ Set screen fade
|
||||
*/
|
||||
static void CL_ParseScreenFade( sizebuf_t *msg )
|
||||
{
|
||||
float duration, holdTime;
|
||||
screenfade_t *sf = &clgame.fade;
|
||||
float flScale;
|
||||
screenfade_t *sf = &clgame.fade;
|
||||
|
||||
duration = (float)MSG_ReadWord( msg );
|
||||
holdTime = (float)MSG_ReadWord( msg );
|
||||
float duration = (float)MSG_ReadWord( msg );
|
||||
float holdTime = (float)MSG_ReadWord( msg );
|
||||
sf->fadeFlags = MSG_ReadShort( msg );
|
||||
flScale = FBitSet( sf->fadeFlags, FFADE_LONGFADE ) ? (1.0f / 256.0f) : (1.0f / 4096.0f);
|
||||
float flScale = FBitSet( sf->fadeFlags, FFADE_LONGFADE ) ? (1.0f / 256.0f) : (1.0f / 4096.0f);
|
||||
|
||||
sf->fader = MSG_ReadByte( msg );
|
||||
sf->fadeg = MSG_ReadByte( msg );
|
||||
@@ -2196,9 +2138,6 @@ Exec map/class specific configs
|
||||
*/
|
||||
static void CL_ParseExec( sizebuf_t *msg )
|
||||
{
|
||||
qboolean is_class;
|
||||
int class_idx;
|
||||
string mapname;
|
||||
const char *class_cfgs[] = {
|
||||
"",
|
||||
"exec scout.cfg\n",
|
||||
@@ -2214,17 +2153,18 @@ static void CL_ParseExec( sizebuf_t *msg )
|
||||
"exec civilian.cfg\n"
|
||||
};
|
||||
|
||||
is_class = MSG_ReadByte( msg );
|
||||
qboolean is_class = MSG_ReadByte( msg );
|
||||
|
||||
if( is_class )
|
||||
{
|
||||
class_idx = MSG_ReadByte( msg );
|
||||
int class_idx = MSG_ReadByte( msg );
|
||||
|
||||
if( class_idx >= 0 && class_idx <= 11 && !Q_stricmp( GI->gamefolder, "tfc" ) )
|
||||
Cbuf_AddText( class_cfgs[class_idx] );
|
||||
}
|
||||
else if( !Q_stricmp( GI->gamefolder, "tfc" ) )
|
||||
{
|
||||
string mapname;
|
||||
Cbuf_AddText( "exec mapdefault.cfg\n" );
|
||||
|
||||
COM_FileBase( clgame.mapname, mapname, sizeof( mapname ));
|
||||
@@ -2378,17 +2318,15 @@ show display finale or cutscene message
|
||||
*/
|
||||
static void CL_ParseFinaleCutscene( sizebuf_t *msg, int level )
|
||||
{
|
||||
static int msgindex = 0;
|
||||
client_textmessage_t *text;
|
||||
int channel;
|
||||
static int msgindex = 0;
|
||||
|
||||
cl.intermission = level;
|
||||
|
||||
channel = msgindex;
|
||||
int channel = msgindex;
|
||||
msgindex = (msgindex + 1) & (MAX_TEXTCHANNELS - 1);
|
||||
|
||||
// grab message channel
|
||||
text = &cl_textmessage[channel];
|
||||
client_textmessage_t *text = &cl_textmessage[channel];
|
||||
|
||||
// NOTE: svc_finale and svc_cutscene has a
|
||||
// predefined settings like Quake-style
|
||||
@@ -2600,9 +2538,9 @@ dispatch messages
|
||||
*/
|
||||
void CL_ParseServerMessage( sizebuf_t *msg )
|
||||
{
|
||||
size_t bufStart, playerbytes;
|
||||
int cmd;
|
||||
int old_background;
|
||||
size_t bufStart, playerbytes;
|
||||
int cmd;
|
||||
int old_background;
|
||||
|
||||
// parse the message
|
||||
while( 1 )
|
||||
|
||||
@@ -285,19 +285,17 @@ static void CL_CopyPacketEntity( frame_t *frame, int num, const entity_state_t *
|
||||
|
||||
static int CL_ParsePacketEntitiesGS( sizebuf_t *msg, qboolean delta )
|
||||
{
|
||||
frame_t *frame, *oldframe;
|
||||
int oldindex, oldnum, numbase = 0;
|
||||
entity_state_t *oldent;
|
||||
int count;
|
||||
frame_t *oldframe;
|
||||
int numbase = 0;
|
||||
int playerbytes = 0;
|
||||
|
||||
// save first uncompressed packet as timestamp
|
||||
if( cls.changelevel && !delta && cls.demorecording )
|
||||
CL_WriteDemoJumpTime();
|
||||
|
||||
count = MSG_ReadWord( msg );
|
||||
int count = MSG_ReadWord( msg );
|
||||
|
||||
frame = &cl.frames[cl.parsecountmod];
|
||||
frame_t *frame = &cl.frames[cl.parsecountmod];
|
||||
memset( frame->flags, 0, sizeof( frame->flags ));
|
||||
frame->first_entity = cls.next_client_entities;
|
||||
frame->num_entities = 0;
|
||||
@@ -326,9 +324,9 @@ static int CL_ParsePacketEntitiesGS( sizebuf_t *msg, qboolean delta )
|
||||
|
||||
MSG_StartBitWriting( msg );
|
||||
|
||||
oldent = NULL;
|
||||
oldindex = 0;
|
||||
oldnum = CL_UpdateOldEntNum( oldindex, oldframe, &oldent );
|
||||
entity_state_t *oldent = NULL;
|
||||
int oldindex = 0;
|
||||
int oldnum = CL_UpdateOldEntNum( oldindex, oldframe, &oldent );
|
||||
|
||||
// read it all but ignore it
|
||||
while( 1 )
|
||||
@@ -415,10 +413,9 @@ static int CL_ParsePacketEntitiesGS( sizebuf_t *msg, qboolean delta )
|
||||
static float MSG_ReadGSBitCoord( sizebuf_t *sb )
|
||||
{
|
||||
float value = 0;
|
||||
int ival, fval;
|
||||
|
||||
ival = MSG_ReadOneBit( sb );
|
||||
fval = MSG_ReadOneBit( sb );
|
||||
int ival = MSG_ReadOneBit( sb );
|
||||
int fval = MSG_ReadOneBit( sb );
|
||||
|
||||
if( ival || fval )
|
||||
{
|
||||
@@ -439,13 +436,11 @@ static float MSG_ReadGSBitCoord( sizebuf_t *sb )
|
||||
|
||||
static void MSG_ReadGSBitVec3Coord( sizebuf_t *sb, vec3_t fa )
|
||||
{
|
||||
qboolean x, y, z;
|
||||
|
||||
VectorClear( fa );
|
||||
|
||||
x = MSG_ReadOneBit( sb );
|
||||
y = MSG_ReadOneBit( sb );
|
||||
z = MSG_ReadOneBit( sb );
|
||||
qboolean x = MSG_ReadOneBit( sb );
|
||||
qboolean y = MSG_ReadOneBit( sb );
|
||||
qboolean z = MSG_ReadOneBit( sb );
|
||||
if( x )
|
||||
fa[0] = MSG_ReadGSBitCoord( sb );
|
||||
if( y )
|
||||
@@ -456,31 +451,32 @@ static void MSG_ReadGSBitVec3Coord( sizebuf_t *sb, vec3_t fa )
|
||||
|
||||
static void CL_ParseSoundPacketGS( sizebuf_t *msg )
|
||||
{
|
||||
vec3_t pos;
|
||||
int chan, sound;
|
||||
float volume, attn;
|
||||
int flags, pitch, entnum;
|
||||
sound_t handle = 0;
|
||||
|
||||
MSG_StartBitWriting( msg );
|
||||
|
||||
flags = MSG_ReadUBitLong( msg, 9 );
|
||||
int flags = MSG_ReadUBitLong( msg, 9 );
|
||||
|
||||
float volume;
|
||||
if( FBitSet( flags, SND_VOLUME ))
|
||||
volume = (float)MSG_ReadByte( msg ) / 255.0f;
|
||||
else volume = VOL_NORM;
|
||||
|
||||
float attn;
|
||||
if( FBitSet( flags, SND_ATTENUATION ))
|
||||
attn = (float)MSG_ReadByte( msg ) / 64.0f;
|
||||
else attn = ATTN_NONE;
|
||||
|
||||
chan = MSG_ReadUBitLong( msg, 3 );
|
||||
entnum = MSG_ReadUBitLong( msg, MAX_GOLDSRC_ENTITY_BITS );
|
||||
int chan = MSG_ReadUBitLong( msg, 3 );
|
||||
int entnum = MSG_ReadUBitLong( msg, MAX_GOLDSRC_ENTITY_BITS );
|
||||
int sound;
|
||||
if( FBitSet( flags, SND_GOLDSRC_LARGE_INDEX ))
|
||||
sound = MSG_ReadWord( msg );
|
||||
else sound = MSG_ReadByte( msg );
|
||||
vec3_t pos;
|
||||
MSG_ReadGSBitVec3Coord( msg, pos );
|
||||
|
||||
int pitch;
|
||||
if( FBitSet( flags, SND_PITCH ))
|
||||
pitch = MSG_ReadByte( msg );
|
||||
else pitch = PITCH_NORM;
|
||||
@@ -514,17 +510,15 @@ static void CL_ParseSoundPacketGS( sizebuf_t *msg )
|
||||
static void CL_ParseSpawnStaticSound( sizebuf_t *msg )
|
||||
{
|
||||
vec3_t pos;
|
||||
int sound, entnum, pitch, flags;
|
||||
float volume, attn;
|
||||
sound_t handle = 0;
|
||||
|
||||
MSG_ReadVec3Coord( msg, pos );
|
||||
sound = MSG_ReadShort( msg );
|
||||
volume = MSG_ReadByte( msg ) * ( 1.0f / 255.0f );
|
||||
attn = MSG_ReadByte( msg ) * ( 1.0f / 64.0f );
|
||||
entnum = MSG_ReadShort( msg );
|
||||
pitch = MSG_ReadByte( msg );
|
||||
flags = MSG_ReadByte( msg );
|
||||
int sound = MSG_ReadShort( msg );
|
||||
float volume = MSG_ReadByte( msg ) * ( 1.0f / 255.0f );
|
||||
float attn = MSG_ReadByte( msg ) * ( 1.0f / 64.0f );
|
||||
int entnum = MSG_ReadShort( msg );
|
||||
int pitch = MSG_ReadByte( msg );
|
||||
int flags = MSG_ReadByte( msg );
|
||||
|
||||
if( FBitSet( flags, SND_SENTENCE ))
|
||||
{
|
||||
|
||||
@@ -80,14 +80,13 @@ we don't want interpolate this
|
||||
*/
|
||||
static qboolean CL_QuakeEntityTeleported( cl_entity_t *ent, entity_state_t *newstate )
|
||||
{
|
||||
float len, maxlen;
|
||||
vec3_t delta;
|
||||
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.0f / GAME_FPS ));
|
||||
len = VectorLength( delta );
|
||||
float maxlen = ( clgame.movevars.maxvelocity * ( 1.0f / GAME_FPS ));
|
||||
float len = VectorLength( delta );
|
||||
|
||||
return (len > maxlen);
|
||||
}
|
||||
@@ -139,33 +138,30 @@ CL_ParseQuakeSound
|
||||
*/
|
||||
static void CL_ParseQuakeSound( sizebuf_t *msg )
|
||||
{
|
||||
int channel, sound;
|
||||
int flags, entnum;
|
||||
float volume, attn;
|
||||
sound_t handle;
|
||||
vec3_t pos;
|
||||
|
||||
flags = MSG_ReadByte( msg );
|
||||
int flags = MSG_ReadByte( msg );
|
||||
|
||||
float volume;
|
||||
if( FBitSet( flags, SND_VOLUME ))
|
||||
volume = (float)MSG_ReadByte( msg ) / 255.0f;
|
||||
else volume = VOL_NORM;
|
||||
|
||||
float attn;
|
||||
if( FBitSet( flags, SND_ATTENUATION ))
|
||||
attn = (float)MSG_ReadByte( msg ) / 64.0f;
|
||||
else attn = ATTN_NONE;
|
||||
|
||||
channel = MSG_ReadWord( msg );
|
||||
sound = MSG_ReadByte( msg ); // Quake1 have max 255 precached sounds. erm
|
||||
int channel = MSG_ReadWord( msg );
|
||||
int sound = MSG_ReadByte( msg ); // Quake1 have max 255 precached sounds. erm
|
||||
|
||||
// positioned in space
|
||||
vec3_t pos;
|
||||
MSG_ReadVec3Coord( msg, pos );
|
||||
|
||||
entnum = channel >> 3; // entity reletive
|
||||
int entnum = channel >> 3; // entity reletive
|
||||
channel &= 7;
|
||||
|
||||
// see precached sound
|
||||
handle = cl.sound_index[sound];
|
||||
sound_t handle = cl.sound_index[sound];
|
||||
|
||||
if( !cl.audio_prepped )
|
||||
return; // too early
|
||||
@@ -181,11 +177,6 @@ CL_ParseQuakeServerInfo
|
||||
*/
|
||||
static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
|
||||
{
|
||||
resource_t *pResource;
|
||||
const char *pResName;
|
||||
int gametype;
|
||||
int i;
|
||||
|
||||
Con_Reportf( "Serverdata packet received.\n" );
|
||||
cls.timestart = Platform_DoubleTime();
|
||||
|
||||
@@ -198,7 +189,7 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
|
||||
cls.state = ca_connected;
|
||||
|
||||
// parse protocol version number
|
||||
i = MSG_ReadLong( msg );
|
||||
int i = MSG_ReadLong( msg );
|
||||
|
||||
if( i != PROTOCOL_VERSION_QUAKE )
|
||||
{
|
||||
@@ -208,7 +199,7 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
|
||||
}
|
||||
|
||||
cl.maxclients = MSG_ReadByte( msg );
|
||||
gametype = MSG_ReadByte( msg );
|
||||
int gametype = MSG_ReadByte( msg );
|
||||
clgame.maxEntities = GI->max_edicts;
|
||||
clgame.maxEntities = bound( 600, clgame.maxEntities, MAX_EDICTS );
|
||||
clgame.maxModels = MAX_MODELS;
|
||||
@@ -264,12 +255,12 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
|
||||
// Quake just have a large packet of initialization data
|
||||
for( i = 1; i < MAX_MODELS; i++ )
|
||||
{
|
||||
pResName = MSG_ReadString( msg );
|
||||
const char *pResName = MSG_ReadString( msg );
|
||||
|
||||
if( COM_StringEmptyOrNULL( pResName ))
|
||||
break; // end of list
|
||||
|
||||
pResource = Mem_Calloc( cls.mempool, sizeof( resource_t ));
|
||||
resource_t *pResource = Mem_Calloc( cls.mempool, sizeof( resource_t ));
|
||||
pResource->type = t_model;
|
||||
|
||||
Q_strncpy( pResource->szFileName, pResName, sizeof( pResource->szFileName ));
|
||||
@@ -282,12 +273,12 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
|
||||
|
||||
for( i = 1; i < MAX_SOUNDS; i++ )
|
||||
{
|
||||
pResName = MSG_ReadString( msg );
|
||||
const char *pResName = MSG_ReadString( msg );
|
||||
|
||||
if( COM_StringEmptyOrNULL( pResName ))
|
||||
break; // end of list
|
||||
|
||||
pResource = Mem_Calloc( cls.mempool, sizeof( resource_t ));
|
||||
resource_t *pResource = Mem_Calloc( cls.mempool, sizeof( resource_t ));
|
||||
pResource->type = t_sound;
|
||||
|
||||
Q_strncpy( pResource->szFileName, pResName, sizeof( pResource->szFileName ));
|
||||
@@ -340,15 +331,12 @@ CL_ParseQuakeClientData
|
||||
*/
|
||||
static void CL_ParseQuakeClientData( sizebuf_t *msg )
|
||||
{
|
||||
int i, bits = MSG_ReadWord( msg );
|
||||
frame_t *frame;
|
||||
int bits = MSG_ReadWord( msg );
|
||||
|
||||
// this is the frame update that this message corresponds to
|
||||
i = cls.netchan.incoming_sequence;
|
||||
|
||||
cl.parsecount = i; // ack'd incoming messages.
|
||||
cl.parsecount = cls.netchan.incoming_sequence; // ack'd incoming messages.
|
||||
cl.parsecountmod = cl.parsecount & CL_UPDATE_MASK; // index into window.
|
||||
frame = &cl.frames[cl.parsecountmod]; // frame at index.
|
||||
frame_t *frame = &cl.frames[cl.parsecountmod]; // frame at index.
|
||||
frame->time = cl.mtime[0]; // mark network received time
|
||||
frame->receivedtime = host.realtime; // time now that we are parsing.
|
||||
memset( &frame->graphdata, 0, sizeof( netbandwidthgraph_t ));
|
||||
@@ -365,7 +353,7 @@ static void CL_ParseQuakeClientData( sizebuf_t *msg )
|
||||
cl.local.idealpitch = MSG_ReadChar( msg );
|
||||
else cl.local.idealpitch = 0;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
if( FBitSet( bits, SU_PUNCH1 << i ))
|
||||
frame->clientdata.punchangle[i] = (float)MSG_ReadChar( msg );
|
||||
@@ -568,15 +556,14 @@ CL_ParseQuakeParticles
|
||||
*/
|
||||
static void CL_ParseQuakeParticle( sizebuf_t *msg )
|
||||
{
|
||||
int count, color;
|
||||
vec3_t org, dir;
|
||||
vec3_t org, dir;
|
||||
|
||||
MSG_ReadVec3Coord( msg, org );
|
||||
dir[0] = MSG_ReadChar( msg ) * 0.0625f;
|
||||
dir[1] = MSG_ReadChar( msg ) * 0.0625f;
|
||||
dir[2] = MSG_ReadChar( msg ) * 0.0625f;
|
||||
count = MSG_ReadByte( msg );
|
||||
color = MSG_ReadByte( msg );
|
||||
int count = MSG_ReadByte( msg );
|
||||
int color = MSG_ReadByte( msg );
|
||||
if( count == 255 ) count = 1024;
|
||||
|
||||
R_RunParticleEffect( org, dir, color, count );
|
||||
@@ -590,14 +577,12 @@ CL_ParseQuakeStaticSound
|
||||
*/
|
||||
static void CL_ParseQuakeStaticSound( sizebuf_t *msg )
|
||||
{
|
||||
int sound_num;
|
||||
float vol, attn;
|
||||
vec3_t org;
|
||||
vec3_t org;
|
||||
|
||||
MSG_ReadVec3Coord( msg, org );
|
||||
sound_num = MSG_ReadByte( msg );
|
||||
vol = (float)MSG_ReadByte( msg ) / 255.0f;
|
||||
attn = (float)MSG_ReadByte( msg ) / 64.0f;
|
||||
int sound_num = MSG_ReadByte( msg );
|
||||
float vol = (float)MSG_ReadByte( msg ) / 255.0f;
|
||||
float attn = (float)MSG_ReadByte( msg ) / 64.0f;
|
||||
|
||||
S_StartSound( org, 0, CHAN_STATIC, cl.sound_index[sound_num], vol, attn, PITCH_NORM, 0 );
|
||||
}
|
||||
@@ -628,8 +613,6 @@ CL_ParseStaticEntity
|
||||
static void CL_ParseQuakeStaticEntity( sizebuf_t *msg )
|
||||
{
|
||||
entity_state_t state = { 0 };
|
||||
cl_entity_t *ent;
|
||||
int i;
|
||||
|
||||
if( !clgame.static_entities )
|
||||
clgame.static_entities = Mem_Calloc( clgame.mempool, sizeof( cl_entity_t ) * MAX_STATIC_ENTITIES );
|
||||
@@ -645,14 +628,14 @@ static void CL_ParseQuakeStaticEntity( sizebuf_t *msg )
|
||||
state.origin[2] = MSG_ReadCoord( msg );
|
||||
state.angles[2] = MSG_ReadAngle( msg );
|
||||
|
||||
i = clgame.numStatics;
|
||||
int i = clgame.numStatics;
|
||||
if( i >= MAX_STATIC_ENTITIES )
|
||||
{
|
||||
Con_Printf( S_ERROR "%s: static entities limit exceeded!\n", __func__ );
|
||||
return;
|
||||
}
|
||||
|
||||
ent = &clgame.static_entities[i];
|
||||
cl_entity_t *ent = &clgame.static_entities[i];
|
||||
clgame.numStatics++;
|
||||
|
||||
ent->index = 0; // ???
|
||||
@@ -692,16 +675,13 @@ CL_ParseQuakeBaseline
|
||||
*/
|
||||
static void CL_ParseQuakeBaseline( sizebuf_t *msg )
|
||||
{
|
||||
entity_state_t state;
|
||||
cl_entity_t *ent;
|
||||
int newnum;
|
||||
|
||||
newnum = MSG_ReadWord( msg ); // entnum
|
||||
int newnum = MSG_ReadWord( msg ); // entnum
|
||||
|
||||
if( newnum >= clgame.maxEntities )
|
||||
Host_Error( "%s: no free edicts\n", __func__ );
|
||||
|
||||
// parse baseline
|
||||
entity_state_t state;
|
||||
memset( &state, 0, sizeof( state ));
|
||||
state.modelindex = MSG_ReadByte( msg );
|
||||
state.frame = MSG_ReadByte( msg );
|
||||
@@ -714,7 +694,7 @@ static void CL_ParseQuakeBaseline( sizebuf_t *msg )
|
||||
state.origin[2] = MSG_ReadCoord( msg );
|
||||
state.angles[2] = MSG_ReadAngle( msg );
|
||||
|
||||
ent = CL_EDICT_NUM( newnum );
|
||||
cl_entity_t *ent = CL_EDICT_NUM( newnum );
|
||||
ent->index = newnum;
|
||||
ent->player = CL_IsPlayerIndex( newnum );
|
||||
ent->prevstate = ent->baseline = state;
|
||||
|
||||
@@ -386,13 +386,14 @@ Do stereo processing
|
||||
static void DLY_DoStereoDelay( portable_samplepair_t *paint, int count )
|
||||
{
|
||||
dly_t *dly = &stereodly;
|
||||
int delay, samplexf;
|
||||
|
||||
if( !dly->lpdelayline )
|
||||
return; // inactive
|
||||
|
||||
for( ; count; count--, paint++ )
|
||||
{
|
||||
int delay;
|
||||
|
||||
if( dly->mod && --dly->modcur < 0 )
|
||||
dly->modcur = dly->mod;
|
||||
|
||||
@@ -414,7 +415,7 @@ static void DLY_DoStereoDelay( portable_samplepair_t *paint, int count )
|
||||
// modify delay, if crossfading
|
||||
if( dly->xfade )
|
||||
{
|
||||
samplexf = dly->lpdelayline[dly->idelayoutputxf] * (128 - dly->xfade) >> 7;
|
||||
int samplexf = dly->lpdelayline[dly->idelayoutputxf] * (128 - dly->xfade) >> 7;
|
||||
delay = samplexf + ((delay * dly->xfade) >> 7);
|
||||
|
||||
if( ++dly->idelayoutputxf >= dly->cdelaysamplesmax )
|
||||
@@ -496,14 +497,13 @@ Do delay processing
|
||||
static void DLY_DoDelay( portable_samplepair_t *paint, int count )
|
||||
{
|
||||
dly_t *dly = &monodly;
|
||||
int delay;
|
||||
|
||||
if( !dly->lpdelayline || !count )
|
||||
return; // inactive
|
||||
|
||||
for( ; count; count--, paint++ )
|
||||
{
|
||||
delay = dly->lpdelayline[dly->idelayoutput];
|
||||
int delay = dly->lpdelayline[dly->idelayoutput];
|
||||
|
||||
// don't process if delay line and left/right samples are zero
|
||||
if( delay || paint->left || paint->right )
|
||||
@@ -613,8 +613,6 @@ Do reverberation for one dly
|
||||
static int RVB_DoReverbForOneDly( dly_t *dly, const int vlr, const portable_samplepair_t *samplepair )
|
||||
{
|
||||
int delay;
|
||||
int samplexf;
|
||||
int val, valt;
|
||||
int voutm = 0;
|
||||
|
||||
if( --dly->modcur < 0 )
|
||||
@@ -624,6 +622,8 @@ static int RVB_DoReverbForOneDly( dly_t *dly, const int vlr, const portable_samp
|
||||
|
||||
if( dly->xfade || delay || samplepair->left || samplepair->right )
|
||||
{
|
||||
int val, valt;
|
||||
|
||||
// modulate delay rate
|
||||
if( !dly->mod )
|
||||
{
|
||||
@@ -636,7 +636,7 @@ static int RVB_DoReverbForOneDly( dly_t *dly, const int vlr, const portable_samp
|
||||
|
||||
if( dly->xfade )
|
||||
{
|
||||
samplexf = (dly->lpdelayline[dly->idelayoutputxf] * (REVERB_XFADE - dly->xfade)) / REVERB_XFADE;
|
||||
int samplexf = (dly->lpdelayline[dly->idelayoutputxf] * (REVERB_XFADE - dly->xfade)) / REVERB_XFADE;
|
||||
delay = ((delay * dly->xfade) / REVERB_XFADE) + samplexf;
|
||||
|
||||
if( ++dly->idelayoutputxf >= dly->cdelaysamplesmax )
|
||||
@@ -688,14 +688,14 @@ static void RVB_DoReverb( portable_samplepair_t *paint, int count )
|
||||
{
|
||||
dly_t *dly1 = &reverbdly[0];
|
||||
dly_t *dly2 = &reverbdly[1];
|
||||
int vlr, voutm;
|
||||
|
||||
if( !dly1->lpdelayline )
|
||||
return;
|
||||
|
||||
for( ; count; count--, paint++ )
|
||||
{
|
||||
vlr = ( paint->left + paint->right ) >> 1;
|
||||
int vlr = ( paint->left + paint->right ) >> 1;
|
||||
int voutm;
|
||||
|
||||
voutm = RVB_DoReverbForOneDly( dly1, vlr, paint );
|
||||
voutm += RVB_DoReverbForOneDly( dly2, vlr, paint );
|
||||
@@ -881,9 +881,8 @@ static void SX_Profiling_f( void )
|
||||
portable_samplepair_t testbuffer[512];
|
||||
float oldroom = room_type.value;
|
||||
double start, end;
|
||||
int i, calls;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( testbuffer ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( testbuffer ); i++ )
|
||||
{
|
||||
testbuffer[i].left = COM_RandomLong( 0, 3000 );
|
||||
testbuffer[i].right = COM_RandomLong( 0, 3000 );
|
||||
@@ -899,7 +898,7 @@ static void SX_Profiling_f( void )
|
||||
Con_Printf( "Profiling 10000 calls to DSP. Sample count is 512, room_type is %i\n", idsp_room );
|
||||
|
||||
start = Platform_DoubleTime();
|
||||
for( calls = 10000; calls; calls-- )
|
||||
for( int calls = 10000; calls; calls-- )
|
||||
{
|
||||
SX_RoomFX( testbuffer, 512 );
|
||||
}
|
||||
|
||||
@@ -39,17 +39,16 @@ S_SoundList_f
|
||||
*/
|
||||
void S_SoundList_f( void )
|
||||
{
|
||||
sfx_t *sfx;
|
||||
wavdata_t *sc;
|
||||
int i, totalSfx = 0;
|
||||
int totalSize = 0;
|
||||
sfx_t *sfx;
|
||||
int i, totalSfx = 0;
|
||||
int totalSize = 0;
|
||||
|
||||
for( i = 0, sfx = s_knownSfx; i < s_numSfx; i++, sfx++ )
|
||||
{
|
||||
if( !sfx->name[0] )
|
||||
continue;
|
||||
|
||||
sc = sfx->cache;
|
||||
wavdata_t *sc = sfx->cache;
|
||||
if( sc )
|
||||
{
|
||||
totalSize += sc->size;
|
||||
@@ -149,7 +148,7 @@ S_FindName
|
||||
sfx_t *S_FindName( const char *pname, qboolean *pfInCache )
|
||||
{
|
||||
sfx_t *sfx;
|
||||
uint i, hash;
|
||||
uint i;
|
||||
string name;
|
||||
|
||||
if( COM_StringEmptyOrNULL( pname ) || !snd.initialized )
|
||||
@@ -162,7 +161,7 @@ sfx_t *S_FindName( const char *pname, qboolean *pfInCache )
|
||||
COM_FixSlashes( name );
|
||||
|
||||
// see if already loaded
|
||||
hash = COM_HashKey( name, MAX_SFX_HASH );
|
||||
uint hash = COM_HashKey( name, MAX_SFX_HASH );
|
||||
for( sfx = s_sfxHashList[hash]; sfx; sfx = sfx->hashNext )
|
||||
{
|
||||
if( !Q_strcmp( sfx->name, name ))
|
||||
@@ -210,17 +209,14 @@ S_FreeSound
|
||||
*/
|
||||
void S_FreeSound( sfx_t *sfx )
|
||||
{
|
||||
sfx_t *hashSfx;
|
||||
sfx_t **prev;
|
||||
|
||||
if( !sfx || !sfx->name[0] )
|
||||
return;
|
||||
|
||||
// de-link it from the hash tree
|
||||
prev = &s_sfxHashList[sfx->hashValue];
|
||||
sfx_t **prev = &s_sfxHashList[sfx->hashValue];
|
||||
while( 1 )
|
||||
{
|
||||
hashSfx = *prev;
|
||||
sfx_t *hashSfx = *prev;
|
||||
if( !hashSfx )
|
||||
break;
|
||||
|
||||
@@ -251,12 +247,10 @@ S_BeginRegistration
|
||||
*/
|
||||
void S_BeginRegistration( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
snd.have_ambient_sfx = false;
|
||||
|
||||
// check for automatic ambient sounds
|
||||
for( i = 0; i < NUM_AMBIENTS; i++ )
|
||||
for( int i = 0; i < NUM_AMBIENTS; i++ )
|
||||
{
|
||||
if( !GI->ambientsound[i][0] )
|
||||
continue; // empty slot
|
||||
@@ -386,6 +380,7 @@ void S_FreeSounds( void )
|
||||
for( i = 0, sfx = s_knownSfx; i < s_numSfx; i++, sfx++ )
|
||||
S_FreeSound( sfx );
|
||||
|
||||
|
||||
memset( s_knownSfx, 0, sizeof( s_knownSfx ));
|
||||
memset( s_sfxHashList, 0, sizeof( s_sfxHashList ));
|
||||
|
||||
|
||||
@@ -290,8 +290,6 @@ static int SND_GetChannelTimeLeft( const channel_t *ch )
|
||||
|
||||
if( ch->words ) // sentences are special, count all remaining words
|
||||
{
|
||||
int i;
|
||||
|
||||
if( FBitSet( ch->flags, FL_CHAN_SENTENCE_FINISHED ) )
|
||||
return 0;
|
||||
|
||||
@@ -300,7 +298,7 @@ static int SND_GetChannelTimeLeft( const channel_t *ch )
|
||||
|
||||
// here we count all remaining words, stopping if no sfx or sound file is available
|
||||
// see VOX_LoadWord
|
||||
for( i = ch->word_index + 1; i < CVOXWORDMAX; i++ )
|
||||
for( int i = ch->word_index + 1; i < CVOXWORDMAX; i++ )
|
||||
{
|
||||
wavdata_t *sc;
|
||||
int end;
|
||||
@@ -341,14 +339,9 @@ exceptions).
|
||||
*/
|
||||
channel_t *SND_PickDynamicChannel( int entnum, int channel, sfx_t *sfx, qboolean *ignore )
|
||||
{
|
||||
int ch_idx;
|
||||
int first_to_die;
|
||||
int life_left;
|
||||
int timeleft;
|
||||
int first_to_die = -1;
|
||||
int life_left = 0x7fffffff;
|
||||
|
||||
// check for replacement sound, or find the best one to replace
|
||||
first_to_die = -1;
|
||||
life_left = 0x7fffffff;
|
||||
if( ignore ) *ignore = false;
|
||||
|
||||
if( channel == CHAN_STREAM && SND_FStreamIsPlaying( sfx ))
|
||||
@@ -358,9 +351,10 @@ channel_t *SND_PickDynamicChannel( int entnum, int channel, sfx_t *sfx, qboolean
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for( ch_idx = NUM_AMBIENTS; ch_idx < MAX_DYNAMIC_CHANNELS; ch_idx++ )
|
||||
for( int ch_idx = NUM_AMBIENTS; ch_idx < MAX_DYNAMIC_CHANNELS; ch_idx++ )
|
||||
{
|
||||
channel_t *ch = &snd.channels[ch_idx];
|
||||
int timeleft;
|
||||
|
||||
// Never override a streaming sound that is currently playing or
|
||||
// voice over IP data that is playing or any sound on CHAN_VOICE( acting )
|
||||
@@ -1019,14 +1013,14 @@ grab all static sounds playing at current channel
|
||||
int S_GetCurrentDynamicSounds( soundlist_t *pout, int size )
|
||||
{
|
||||
int sounds_left = size;
|
||||
int i, looped;
|
||||
|
||||
if( !snd.initialized )
|
||||
return 0;
|
||||
|
||||
for( i = 0; i < snd.max_channels && sounds_left; i++ )
|
||||
for( int i = 0; i < snd.max_channels && sounds_left; i++ )
|
||||
{
|
||||
const channel_t *ch = &snd.channels[i];
|
||||
int looped;
|
||||
|
||||
if( !ch->sfx || !ch->sfx->name[0] || !Q_stricmp( ch->sfx->name, "*default" ))
|
||||
continue; // don't serialize default sounds
|
||||
@@ -1220,14 +1214,13 @@ S_RawSamplesStereo
|
||||
*/
|
||||
uint S_RawSamplesStereo( portable_samplepair_t *rawsamples, uint rawend, uint max_samples, uint samples, uint rate, word width, word channels, const byte *data )
|
||||
{
|
||||
uint fracstep, samplefrac;
|
||||
uint src, dst;
|
||||
uint src;
|
||||
|
||||
if( rawend < snd.paintedtime )
|
||||
rawend = snd.paintedtime;
|
||||
|
||||
fracstep = ((double) rate / (double)SOUND_DMA_SPEED) * (double)(1 << S_RAW_SAMPLES_PRECISION_BITS);
|
||||
samplefrac = 0;
|
||||
uint fracstep = ((double) rate / (double)SOUND_DMA_SPEED) * (double)(1 << S_RAW_SAMPLES_PRECISION_BITS);
|
||||
uint samplefrac = 0;
|
||||
|
||||
if( width == 2 )
|
||||
{
|
||||
@@ -1237,7 +1230,7 @@ uint S_RawSamplesStereo( portable_samplepair_t *rawsamples, uint rawend, uint ma
|
||||
{
|
||||
for( src = 0; src < samples; samplefrac += fracstep, src = ( samplefrac >> S_RAW_SAMPLES_PRECISION_BITS ))
|
||||
{
|
||||
dst = rawend++ & ( max_samples - 1 );
|
||||
uint dst = rawend++ & ( max_samples - 1 );
|
||||
rawsamples[dst].left = in[src*2+0];
|
||||
rawsamples[dst].right = in[src*2+1];
|
||||
}
|
||||
@@ -1246,7 +1239,7 @@ uint S_RawSamplesStereo( portable_samplepair_t *rawsamples, uint rawend, uint ma
|
||||
{
|
||||
for( src = 0; src < samples; samplefrac += fracstep, src = ( samplefrac >> S_RAW_SAMPLES_PRECISION_BITS ))
|
||||
{
|
||||
dst = rawend++ & ( max_samples - 1 );
|
||||
uint dst = rawend++ & ( max_samples - 1 );
|
||||
rawsamples[dst].left = in[src];
|
||||
rawsamples[dst].right = in[src];
|
||||
}
|
||||
@@ -1260,7 +1253,7 @@ uint S_RawSamplesStereo( portable_samplepair_t *rawsamples, uint rawend, uint ma
|
||||
|
||||
for( src = 0; src < samples; samplefrac += fracstep, src = ( samplefrac >> S_RAW_SAMPLES_PRECISION_BITS ))
|
||||
{
|
||||
dst = rawend++ & ( max_samples - 1 );
|
||||
uint dst = rawend++ & ( max_samples - 1 );
|
||||
rawsamples[dst].left = in[src*2+0] << 8;
|
||||
rawsamples[dst].right = in[src*2+1] << 8;
|
||||
}
|
||||
@@ -1269,7 +1262,7 @@ uint S_RawSamplesStereo( portable_samplepair_t *rawsamples, uint rawend, uint ma
|
||||
{
|
||||
for( src = 0; src < samples; samplefrac += fracstep, src = ( samplefrac >> S_RAW_SAMPLES_PRECISION_BITS ))
|
||||
{
|
||||
dst = rawend++ & ( max_samples - 1 );
|
||||
uint dst = rawend++ & ( max_samples - 1 );
|
||||
rawsamples[dst].left = ( data[src] - 128 ) << 8;
|
||||
rawsamples[dst].right = ( data[src] - 128 ) << 8;
|
||||
}
|
||||
@@ -1309,9 +1302,7 @@ Free raw channel that have been idling for too long.
|
||||
*/
|
||||
static void S_FreeIdleRawChannels( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < snd.max_raw_channels; i++ )
|
||||
for( int i = 0; i < snd.max_raw_channels; i++ )
|
||||
{
|
||||
rawchan_t *ch = snd.raw_channels[i];
|
||||
|
||||
@@ -1344,9 +1335,7 @@ S_ClearRawChannels
|
||||
*/
|
||||
static void S_ClearRawChannels( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < snd.max_raw_channels; i++ )
|
||||
for( int i = 0; i < snd.max_raw_channels; i++ )
|
||||
{
|
||||
rawchan_t *ch = snd.raw_channels[i];
|
||||
|
||||
@@ -1464,12 +1453,10 @@ S_StopAllSounds
|
||||
*/
|
||||
void S_StopAllSounds( qboolean ambient )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !snd.initialized ) return;
|
||||
snd.total_channels = MAX_DYNAMIC_CHANNELS; // no statics
|
||||
|
||||
for( i = 0; i < snd.max_channels; i++ )
|
||||
for( int i = 0; i < snd.max_channels; i++ )
|
||||
{
|
||||
if( !snd.channels[i].sfx )
|
||||
continue;
|
||||
@@ -1503,14 +1490,13 @@ update global soundtime
|
||||
static int S_GetSoundtime( void )
|
||||
{
|
||||
static int buffers, oldsamplepos;
|
||||
int samplepos, fullsamples;
|
||||
|
||||
fullsamples = snd.samples / 2;
|
||||
int fullsamples = snd.samples / 2;
|
||||
|
||||
// it is possible to miscount buffers
|
||||
// if it has wrapped twice between
|
||||
// calls to S_Update. Oh well.
|
||||
samplepos = snd.samplepos;
|
||||
int samplepos = snd.samplepos;
|
||||
|
||||
if( samplepos < oldsamplepos )
|
||||
{
|
||||
@@ -1776,13 +1762,12 @@ static void S_Music_f( void )
|
||||
{
|
||||
string intro, main, track;
|
||||
const char *ext[] = { "mp3", "wav" };
|
||||
int i;
|
||||
|
||||
Q_strncpy( track, Cmd_Argv( 1 ), sizeof( track ));
|
||||
Q_snprintf( intro, sizeof( intro ), "%s_intro", Cmd_Argv( 1 ));
|
||||
Q_snprintf( main, sizeof( main ), "%s_main", Cmd_Argv( 1 ));
|
||||
|
||||
for( i = 0; i < 2; i++ )
|
||||
for( int i = 0; i < 2; i++ )
|
||||
{
|
||||
char intro_path[MAX_VA_STRING];
|
||||
char main_path[MAX_VA_STRING];
|
||||
|
||||
@@ -36,20 +36,17 @@ static void SND_CommitMouthValue( mouth_t *mouth, int savg, int scount )
|
||||
void SND_MoveMouth8( mouth_t *mouth, int pos, const wavdata_t *sc, int count, qboolean use_loop )
|
||||
{
|
||||
const int8_t *pdata = NULL;
|
||||
int scount;
|
||||
int savg, data;
|
||||
uint i;
|
||||
|
||||
count = S_RetrieveAudioSamples( sc, (const void **)&pdata, pos, count, use_loop );
|
||||
if( pdata == NULL ) return;
|
||||
|
||||
i = 0;
|
||||
scount = mouth->sndcount;
|
||||
savg = 0;
|
||||
uint i = 0;
|
||||
int scount = mouth->sndcount;
|
||||
int savg = 0;
|
||||
|
||||
while( i < count && scount < CAVGSAMPLES )
|
||||
{
|
||||
data = pdata[i];
|
||||
int data = pdata[i];
|
||||
savg += abs( data );
|
||||
|
||||
i += 80 + ((byte)data & 0x1F);
|
||||
@@ -62,20 +59,17 @@ void SND_MoveMouth8( mouth_t *mouth, int pos, const wavdata_t *sc, int count, qb
|
||||
void SND_MoveMouth16( mouth_t *mouth, int pos, const wavdata_t *sc, int count, qboolean use_loop )
|
||||
{
|
||||
const int16_t *pdata = NULL;
|
||||
int savg, data;
|
||||
int scount;
|
||||
uint i;
|
||||
|
||||
count = S_RetrieveAudioSamples( sc, (const void **)&pdata, pos, count, use_loop );
|
||||
if( pdata == NULL ) return;
|
||||
|
||||
i = 0;
|
||||
scount = mouth->sndcount;
|
||||
savg = 0;
|
||||
uint i = 0;
|
||||
int scount = mouth->sndcount;
|
||||
int savg = 0;
|
||||
|
||||
while( i < count && scount < CAVGSAMPLES )
|
||||
{
|
||||
data = pdata[i];
|
||||
int data = pdata[i];
|
||||
data = (bound( -32767, data, 0x7ffe ) >> 8);
|
||||
savg += abs( data );
|
||||
|
||||
@@ -88,9 +82,7 @@ void SND_MoveMouth16( mouth_t *mouth, int pos, const wavdata_t *sc, int count, q
|
||||
|
||||
void SND_ForceInitMouth( int entnum )
|
||||
{
|
||||
cl_entity_t *clientEntity;
|
||||
|
||||
clientEntity = CL_GetEntityByIndex( entnum );
|
||||
cl_entity_t *clientEntity = CL_GetEntityByIndex( entnum );
|
||||
|
||||
if( clientEntity )
|
||||
{
|
||||
@@ -102,9 +94,7 @@ void SND_ForceInitMouth( int entnum )
|
||||
|
||||
void SND_ForceCloseMouth( int entnum )
|
||||
{
|
||||
cl_entity_t *clientEntity;
|
||||
|
||||
clientEntity = CL_GetEntityByIndex( entnum );
|
||||
cl_entity_t *clientEntity = CL_GetEntityByIndex( entnum );
|
||||
|
||||
if( clientEntity )
|
||||
clientEntity->mouth.mouthopen = 0;
|
||||
@@ -112,17 +102,13 @@ void SND_ForceCloseMouth( int entnum )
|
||||
|
||||
void SND_MoveMouthRaw( mouth_t *mouth, const portable_samplepair_t *buf, int count )
|
||||
{
|
||||
int savg, data;
|
||||
int scount = 0;
|
||||
uint i;
|
||||
|
||||
i = 0;
|
||||
scount = mouth->sndcount;
|
||||
savg = 0;
|
||||
uint i = 0;
|
||||
int scount = mouth->sndcount;
|
||||
int savg = 0;
|
||||
|
||||
while ( i < count && scount < CAVGSAMPLES )
|
||||
{
|
||||
data = buf[i].left; // mono sound anyway
|
||||
int data = buf[i].left; // mono sound anyway
|
||||
data = ( bound( -32767, data, 0x7ffe ) >> 8 );
|
||||
savg += abs( data );
|
||||
|
||||
|
||||
@@ -66,14 +66,14 @@ S_GetMusicVolume
|
||||
*/
|
||||
float S_GetMusicVolume( void )
|
||||
{
|
||||
float scale = 1.0f;
|
||||
|
||||
if( host.status == HOST_NOFOCUS && snd_mute_losefocus.value != 0.0f )
|
||||
{
|
||||
// we return zero volume to keep sounds running
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
float scale = 1.0f;
|
||||
|
||||
if( cls.key_dest != key_menu && musicfade.percent != 0 )
|
||||
{
|
||||
scale = bound( 0.0f, musicfade.percent / 100.0f, 1.0f );
|
||||
@@ -191,11 +191,7 @@ S_StreamBackgroundTrack
|
||||
*/
|
||||
void S_StreamBackgroundTrack( void )
|
||||
{
|
||||
int bufferSamples;
|
||||
int fileSamples;
|
||||
byte raw[MAX_RAW_SAMPLES];
|
||||
int r, fileBytes;
|
||||
rawchan_t *ch = NULL;
|
||||
|
||||
if( !snd.initialized || !s_bgTrack.stream || snd.streaming )
|
||||
return;
|
||||
@@ -213,7 +209,7 @@ void S_StreamBackgroundTrack( void )
|
||||
else if( cls.key_dest == key_console )
|
||||
return;
|
||||
|
||||
ch = S_FindRawChannel( S_RAW_SOUND_BACKGROUNDTRACK, true );
|
||||
rawchan_t *ch = S_FindRawChannel( S_RAW_SOUND_BACKGROUNDTRACK, true );
|
||||
|
||||
Assert( ch != NULL );
|
||||
|
||||
@@ -225,14 +221,14 @@ void S_StreamBackgroundTrack( void )
|
||||
{
|
||||
const stream_t *info = s_bgTrack.stream;
|
||||
|
||||
bufferSamples = ch->max_samples - (ch->s_rawend - snd.soundtime);
|
||||
int bufferSamples = ch->max_samples - (ch->s_rawend - snd.soundtime);
|
||||
|
||||
// decide how much data needs to be read from the file
|
||||
fileSamples = bufferSamples * ((float)info->rate / SOUND_DMA_SPEED );
|
||||
int 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 );
|
||||
int fileBytes = fileSamples * ( info->width * info->channels );
|
||||
|
||||
if( fileBytes > sizeof( raw ))
|
||||
{
|
||||
@@ -241,7 +237,7 @@ void S_StreamBackgroundTrack( void )
|
||||
}
|
||||
|
||||
// read
|
||||
r = FS_ReadStream( s_bgTrack.stream, fileBytes, raw );
|
||||
int r = FS_ReadStream( s_bgTrack.stream, fileBytes, raw );
|
||||
|
||||
if( r < fileBytes )
|
||||
{
|
||||
|
||||
@@ -52,7 +52,7 @@ static qboolean S_ShouldTrimSample16( const int16_t *buf, int channels )
|
||||
|
||||
static int S_TrimStart( const wavdata_t *wav, int start )
|
||||
{
|
||||
size_t channels = wav->channels, width = wav->width, i;
|
||||
size_t channels = wav->channels, width = wav->width;
|
||||
|
||||
if( wav->type != WF_PCMDATA )
|
||||
return start;
|
||||
@@ -61,7 +61,7 @@ static int S_TrimStart( const wavdata_t *wav, int start )
|
||||
{
|
||||
const int8_t *data = (const int8_t *)&wav->buffer[channels * width * start];
|
||||
|
||||
for( i = 0; i < TRIM_SCAN_MAX && start < wav->samples; i++ )
|
||||
for( size_t i = 0; i < TRIM_SCAN_MAX && start < wav->samples; i++ )
|
||||
{
|
||||
if( !S_ShouldTrimSample8( data, wav->channels ))
|
||||
break;
|
||||
@@ -74,7 +74,7 @@ static int S_TrimStart( const wavdata_t *wav, int start )
|
||||
{
|
||||
const int16_t *data = (const int16_t *)&wav->buffer[channels * width * start];
|
||||
|
||||
for( i = 0; i < TRIM_SCAN_MAX && start < wav->samples; i++ )
|
||||
for( size_t i = 0; i < TRIM_SCAN_MAX && start < wav->samples; i++ )
|
||||
{
|
||||
if( !S_ShouldTrimSample16( data, wav->channels ))
|
||||
break;
|
||||
@@ -89,7 +89,7 @@ static int S_TrimStart( const wavdata_t *wav, int start )
|
||||
|
||||
static int S_TrimEnd( const wavdata_t *wav, int end )
|
||||
{
|
||||
size_t channels = wav->channels, width = wav->width, i;
|
||||
size_t channels = wav->channels, width = wav->width;
|
||||
|
||||
if( wav->type != WF_PCMDATA )
|
||||
return end;
|
||||
@@ -98,7 +98,7 @@ static int S_TrimEnd( const wavdata_t *wav, int end )
|
||||
{
|
||||
const int8_t *data = (const int8_t *)&wav->buffer[channels * width * ( end - 1 )];
|
||||
|
||||
for( i = 0; i < TRIM_SCAN_MAX && end > 0; i++ )
|
||||
for( size_t i = 0; i < TRIM_SCAN_MAX && end > 0; i++ )
|
||||
{
|
||||
if( !S_ShouldTrimSample8( data, wav->channels ))
|
||||
break;
|
||||
@@ -111,7 +111,7 @@ static int S_TrimEnd( const wavdata_t *wav, int end )
|
||||
{
|
||||
const int16_t *data = (const int16_t *)&wav->buffer[channels * width * ( end - 1 )];
|
||||
|
||||
for( i = 0; i < TRIM_SCAN_MAX && end > 0; i++ )
|
||||
for( size_t i = 0; i < TRIM_SCAN_MAX && end > 0; i++ )
|
||||
{
|
||||
if( !S_ShouldTrimSample16( data, wav->channels ))
|
||||
break;
|
||||
@@ -222,9 +222,6 @@ float VOX_ModifyPitch( channel_t *ch, float pitch )
|
||||
|
||||
static const char *VOX_GetDirectory( char *szpath, const char *psz, int nsize )
|
||||
{
|
||||
const char *p;
|
||||
int len;
|
||||
|
||||
// HACKHACK: some modders send strings like "/fvox/_period four"
|
||||
// which should get parsed as "_period four" said by fvox
|
||||
// it might be incorrect but ignore first slash here for now
|
||||
@@ -232,7 +229,7 @@ static const char *VOX_GetDirectory( char *szpath, const char *psz, int nsize )
|
||||
psz++;
|
||||
|
||||
// search / backwards
|
||||
p = Q_strrchr( psz, '/' );
|
||||
const char *p = Q_strrchr( psz, '/' );
|
||||
|
||||
if( !p )
|
||||
{
|
||||
@@ -240,7 +237,7 @@ static const char *VOX_GetDirectory( char *szpath, const char *psz, int nsize )
|
||||
return psz;
|
||||
}
|
||||
|
||||
len = p - psz + 1;
|
||||
int len = p - psz + 1;
|
||||
|
||||
if( len > nsize )
|
||||
{
|
||||
@@ -256,8 +253,7 @@ static const char *VOX_GetDirectory( char *szpath, const char *psz, int nsize )
|
||||
|
||||
static const char *VOX_LookupString( const char *pszin )
|
||||
{
|
||||
int i = -1, len;
|
||||
const char *c;
|
||||
int i = -1;
|
||||
|
||||
// check if we are an immediate sentence
|
||||
if( *pszin == '#' )
|
||||
@@ -289,9 +285,9 @@ static const char *VOX_LookupString( const char *pszin )
|
||||
if( i == cszrawsentences )
|
||||
return NULL;
|
||||
|
||||
len = Q_strlen( rgpszrawsentence[i] );
|
||||
int len = Q_strlen( rgpszrawsentence[i] );
|
||||
|
||||
c = &rgpszrawsentence[i][len + 1];
|
||||
const char *c = &rgpszrawsentence[i][len + 1];
|
||||
for( ; *c == ' ' || *c == '\t'; c++ );
|
||||
|
||||
return c;
|
||||
@@ -362,12 +358,11 @@ static void VOX_MakeDefaultWordParams( voxword_t *voxword )
|
||||
|
||||
static qboolean VOX_ParseWordParams( char *psz, voxword_t *pvoxword, voxword_t *default_voxword )
|
||||
{
|
||||
int len, i;
|
||||
char sznum[8], *pszsave = psz;
|
||||
|
||||
*pvoxword = *default_voxword;
|
||||
|
||||
len = Q_strlen( psz );
|
||||
int len = Q_strlen( psz );
|
||||
|
||||
if( len == 0 )
|
||||
return false;
|
||||
@@ -388,6 +383,7 @@ static qboolean VOX_ParseWordParams( char *psz, voxword_t *pvoxword, voxword_t *
|
||||
for( ;; )
|
||||
{
|
||||
char command;
|
||||
int i;
|
||||
|
||||
// find command
|
||||
for( ; *psz &&
|
||||
@@ -446,7 +442,7 @@ void VOX_LoadSound( channel_t *ch, const char *pszin )
|
||||
char buffer[512] = { 0 }, szpath[32] = { 0 };
|
||||
char *rgpparseword[CVOXWORDMAX] = { 0 };
|
||||
const char *psz;
|
||||
int i, j;
|
||||
int j;
|
||||
int num_words;
|
||||
voxword_t default_voxword;
|
||||
voxword_t words_buf[CVOXWORDMAX + 1]; // local scratch: parsed words + null terminator
|
||||
@@ -490,7 +486,8 @@ void VOX_LoadSound( channel_t *ch, const char *pszin )
|
||||
VOX_MakeDefaultWordParams( &default_voxword );
|
||||
memset( words_buf, 0, sizeof( words_buf ));
|
||||
|
||||
for( i = 0, j = 0; i < num_words; i++ )
|
||||
j = 0;
|
||||
for( int i = 0; i < num_words; i++ )
|
||||
{
|
||||
char pathbuffer[MAX_SYSPATH];
|
||||
|
||||
@@ -589,9 +586,7 @@ void VOX_Init( void )
|
||||
|
||||
void VOX_Shutdown( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < cszrawsentences; i++ )
|
||||
for( int i = 0; i < cszrawsentences; i++ )
|
||||
Mem_Free( rgpszrawsentence[i] );
|
||||
|
||||
cszrawsentences = 0;
|
||||
@@ -609,9 +604,8 @@ static void Test_VOX_GetDirectory( void )
|
||||
"barney/meow", "meow", "barney/",
|
||||
"/fvox/_period", "_period", "fvox/",
|
||||
};
|
||||
int i;
|
||||
|
||||
for( i = 0; i < sizeof( data ) / sizeof( data[0] ); i += 3 )
|
||||
for( int i = 0; i < sizeof( data ) / sizeof( data[0] ); i += 3 )
|
||||
{
|
||||
string szpath;
|
||||
const char *p = VOX_GetDirectory( szpath, data[i+0], sizeof( szpath ));
|
||||
@@ -623,7 +617,6 @@ static void Test_VOX_GetDirectory( void )
|
||||
|
||||
static void Test_VOX_LookupString( void )
|
||||
{
|
||||
int i;
|
||||
const char *p, *data[] =
|
||||
{
|
||||
"0", "123",
|
||||
@@ -645,7 +638,7 @@ static void Test_VOX_LookupString( void )
|
||||
rgpszrawsentence[cszrawsentences++] = (char*)"SentenceWithSpaces\0 SPAAACE";
|
||||
rgpszrawsentence[cszrawsentences++] = (char*)"SentenceWithTabsAndSpaces\0\t \t\t MEOW";
|
||||
|
||||
for( i = 0; i < sizeof( data ) / sizeof( data[0] ); i += 2 )
|
||||
for( int i = 0; i < sizeof( data ) / sizeof( data[0] ); i += 2 )
|
||||
{
|
||||
p = VOX_LookupString( data[i] );
|
||||
|
||||
|
||||
@@ -381,18 +381,17 @@ Apply automatic gain control to voice samples
|
||||
*/
|
||||
static void Voice_ApplyGainAdjust( int16_t *samples, int count, float scale )
|
||||
{
|
||||
float gain, modifiedMax;
|
||||
int average, blockOffset = 0;
|
||||
int blockOffset = 0;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
int i, localMax = 0, localSum = 0;
|
||||
int localMax = 0, localSum = 0;
|
||||
int blockSize = Q_min( count - blockOffset, voice.autogain.block_size );
|
||||
|
||||
if( blockSize < 1 )
|
||||
break;
|
||||
|
||||
for( i = 0; i < blockSize; ++i )
|
||||
for( int i = 0; i < blockSize; ++i )
|
||||
{
|
||||
int sample = samples[blockOffset + i];
|
||||
int absSample = abs( sample );
|
||||
@@ -401,14 +400,14 @@ static void Voice_ApplyGainAdjust( int16_t *samples, int count, float scale )
|
||||
localMax = absSample;
|
||||
|
||||
localSum += absSample;
|
||||
gain = voice.autogain.current_gain + i * voice.autogain.gain_multiplier;
|
||||
float gain = voice.autogain.current_gain + i * voice.autogain.gain_multiplier;
|
||||
samples[blockOffset + i] = bound( SHRT_MIN, (int)( sample * gain ), SHRT_MAX );
|
||||
}
|
||||
|
||||
if( blockOffset % voice.autogain.block_size == 0 )
|
||||
{
|
||||
average = localSum / blockSize;
|
||||
modifiedMax = average + ( localMax - average ) * voice_avggain.value;
|
||||
int average = localSum / blockSize;
|
||||
float modifiedMax = average + ( localMax - average ) * voice_avggain.value;
|
||||
|
||||
voice.autogain.current_gain = voice.autogain.next_gain * scale;
|
||||
voice.autogain.next_gain = Q_min((float)SHRT_MAX / ( modifiedMax > 1 ? modifiedMax : 1 ), voice_maxgain.value ) * scale;
|
||||
@@ -435,13 +434,11 @@ static uint Voice_GetOpusCompressedData( byte *out, uint maxsize, uint *frames )
|
||||
|
||||
if( voice.input_file )
|
||||
{
|
||||
uint numbytes;
|
||||
double updateInterval, curtime = Platform_DoubleTime();
|
||||
|
||||
updateInterval = curtime - voice.start_time;
|
||||
double curtime = Platform_DoubleTime();
|
||||
double updateInterval = curtime - voice.start_time;
|
||||
voice.start_time = curtime;
|
||||
|
||||
numbytes = updateInterval * voice.samplerate * voice.width * VOICE_PCM_CHANNELS;
|
||||
uint numbytes = updateInterval * voice.samplerate * voice.width * VOICE_PCM_CHANNELS;
|
||||
numbytes = Q_min( numbytes, voice.input_file->size - voice.input_file_pos );
|
||||
numbytes = Q_min( numbytes, sizeof( voice.input_buffer ) - voice.input_buffer_pos );
|
||||
|
||||
@@ -510,13 +507,11 @@ static uint Voice_GetGSCompressedData( byte *out, uint maxsize, uint *frames )
|
||||
|
||||
if( voice.input_file )
|
||||
{
|
||||
uint numbytes;
|
||||
double updateInterval, curtime = Platform_DoubleTime();
|
||||
|
||||
updateInterval = curtime - voice.start_time;
|
||||
double curtime = Platform_DoubleTime();
|
||||
double updateInterval = curtime - voice.start_time;
|
||||
voice.start_time = curtime;
|
||||
|
||||
numbytes = updateInterval * voice.samplerate * voice.width * VOICE_PCM_CHANNELS;
|
||||
uint numbytes = updateInterval * voice.samplerate * voice.width * VOICE_PCM_CHANNELS;
|
||||
numbytes = Q_min( numbytes, voice.input_file->size - voice.input_file_pos );
|
||||
numbytes = Q_min( numbytes, sizeof( voice.input_buffer ) - voice.input_buffer_pos );
|
||||
|
||||
@@ -597,23 +592,15 @@ Process GoldSrc voice data and return number of samples
|
||||
*/
|
||||
static int Voice_ProcessGSData( int ent, const uint8_t *data, uint32_t size )
|
||||
{
|
||||
uint32_t crc_in_packet;
|
||||
uint32_t crc;
|
||||
size_t offset;
|
||||
size_t samples;
|
||||
uint8_t vpc_type;
|
||||
uint16_t data_len;
|
||||
OpusDecoder *decoder;
|
||||
size_t opus_offset;
|
||||
int decoded;
|
||||
size_t silence_samples;
|
||||
uint16_t frame_size;
|
||||
|
||||
if( !data || ent <= 0 || ent > cl.maxclients )
|
||||
return 0;
|
||||
|
||||
crc_in_packet = LittleLong( *(uint32_t *)( data + size - sizeof( uint32_t )));
|
||||
crc = CRC32_INIT_VALUE;
|
||||
uint32_t crc_in_packet = LittleLong( *(uint32_t *)( data + size - sizeof( uint32_t )));
|
||||
uint32_t crc = CRC32_INIT_VALUE;
|
||||
CRC32_ProcessBuffer( &crc, data, size - sizeof( uint32_t ));
|
||||
crc = CRC32_Final( crc );
|
||||
|
||||
@@ -623,7 +610,7 @@ static int Voice_ProcessGSData( int ent, const uint8_t *data, uint32_t size )
|
||||
return 0;
|
||||
}
|
||||
|
||||
offset = sizeof( uint64_t );
|
||||
size_t offset = sizeof( uint64_t );
|
||||
samples = 0;
|
||||
|
||||
if( offset >= size - sizeof( uint32_t ) || data[offset] != GS_VPC_SETSAMPLERATE )
|
||||
@@ -644,7 +631,9 @@ static int Voice_ProcessGSData( int ent, const uint8_t *data, uint32_t size )
|
||||
|
||||
if( vpc_type == GS_VPC_VDATA_OPUS_PLC )
|
||||
{
|
||||
decoder = voice.gs_decoders[ent - 1];
|
||||
OpusDecoder *decoder = voice.gs_decoders[ent - 1];
|
||||
size_t opus_offset;
|
||||
|
||||
if( !decoder )
|
||||
{
|
||||
Con_Printf( S_WARN "No decoder available for entity %d\n", ent );
|
||||
@@ -653,7 +642,7 @@ static int Voice_ProcessGSData( int ent, const uint8_t *data, uint32_t size )
|
||||
opus_offset = 0;
|
||||
while( opus_offset + sizeof( uint32_t ) <= data_len )
|
||||
{
|
||||
frame_size = LittleShort( *(uint16_t *)( data + offset + opus_offset ));
|
||||
uint16_t frame_size = LittleShort( *(uint16_t *)( data + offset + opus_offset ));
|
||||
opus_offset += sizeof( uint32_t );
|
||||
// if frame size is 0, it means silence
|
||||
if( frame_size == 0 )
|
||||
@@ -677,7 +666,7 @@ static int Voice_ProcessGSData( int ent, const uint8_t *data, uint32_t size )
|
||||
Con_Printf( S_WARN "Opus frame size exceeds data length\n" );
|
||||
return 0;
|
||||
}
|
||||
decoded = opus_decode( decoder, data + offset + opus_offset, frame_size,
|
||||
int decoded = opus_decode( decoder, data + offset + opus_offset, frame_size,
|
||||
( (int16_t *)voice.decompress_buffer ) + samples, voice.frame_size, 0 );
|
||||
if( decoded < 0 )
|
||||
{
|
||||
@@ -690,7 +679,7 @@ static int Voice_ProcessGSData( int ent, const uint8_t *data, uint32_t size )
|
||||
}
|
||||
else if( vpc_type == GS_VPC_VDATA_SILENCE )
|
||||
{
|
||||
silence_samples = data_len / 2;
|
||||
size_t silence_samples = data_len / 2;
|
||||
if( silence_samples > GS_MAX_DECOMPRESSED_SAMPLES )
|
||||
{
|
||||
Con_Printf( S_WARN "Silence data too large\n" );
|
||||
@@ -906,8 +895,6 @@ stop recording and notify user dlls
|
||||
*/
|
||||
void Voice_Disconnect( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
Voice_RecordStop();
|
||||
|
||||
if( voice.local.talking_ack )
|
||||
@@ -916,7 +903,7 @@ void Voice_Disconnect( void )
|
||||
voice.local.talking_ack = false;
|
||||
}
|
||||
|
||||
for( i = 1; i <= MAX_CLIENTS; i++ )
|
||||
for( int i = 1; i <= MAX_CLIENTS; i++ )
|
||||
Voice_Status( i, false );
|
||||
|
||||
VoiceCapture_Shutdown();
|
||||
@@ -1198,10 +1185,12 @@ qboolean Voice_Init( const char *pszCodecName, int quality, qboolean preinit )
|
||||
|
||||
voice_audio_info_t Voice_GetAudioInfo( void )
|
||||
{
|
||||
voice_audio_info_t info;
|
||||
voice_audio_info_t info =
|
||||
{
|
||||
.width = voice.width,
|
||||
.samplerate = voice.samplerate,
|
||||
.frame_size = voice.frame_size,
|
||||
};
|
||||
|
||||
info.width = voice.width;
|
||||
info.samplerate = voice.samplerate;
|
||||
info.frame_size = voice.frame_size;
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ wavdata_t *FS_LoadSound( const char *filename, const byte *buffer, size_t size )
|
||||
const char *ext = COM_FileExtension( filename );
|
||||
string loadname;
|
||||
qboolean anyformat = true;
|
||||
const loadwavfmt_t *format;
|
||||
|
||||
Sound_Reset(); // clear old sounddata
|
||||
Q_strncpy( loadname, filename, sizeof( loadname ));
|
||||
@@ -68,7 +67,7 @@ wavdata_t *FS_LoadSound( const char *filename, const byte *buffer, size_t size )
|
||||
{
|
||||
// we needs to compare file extension with list of supported formats
|
||||
// and be sure what is real extension, not a filename with dot
|
||||
for( format = sound.loadformats; format && format->ext; format++ )
|
||||
for( const loadwavfmt_t *format = sound.loadformats; format && format->ext; format++ )
|
||||
{
|
||||
if( !Q_stricmp( format->ext, ext ))
|
||||
{
|
||||
@@ -84,18 +83,17 @@ wavdata_t *FS_LoadSound( const char *filename, const byte *buffer, size_t size )
|
||||
goto load_internal;
|
||||
|
||||
// now try all the formats in the selected list
|
||||
for( format = sound.loadformats; format && format->ext; format++)
|
||||
for( const loadwavfmt_t *format = sound.loadformats; format && format->ext; format++)
|
||||
{
|
||||
if( anyformat || !Q_stricmp( ext, format->ext ))
|
||||
{
|
||||
qboolean success = false;
|
||||
fs_offset_t filesize = 0;
|
||||
byte *f;
|
||||
string path;
|
||||
|
||||
Q_snprintf( path, sizeof( path ), DEFAULT_SOUNDPATH "%s.%s", loadname, format->ext );
|
||||
|
||||
f = FS_LoadFile( path, &filesize, false );
|
||||
byte *f = FS_LoadFile( path, &filesize, false );
|
||||
if( f && filesize > 0 )
|
||||
{
|
||||
success = format->loadfunc( path, f, filesize );
|
||||
@@ -119,7 +117,7 @@ wavdata_t *FS_LoadSound( const char *filename, const byte *buffer, size_t size )
|
||||
}
|
||||
|
||||
load_internal:
|
||||
for( format = sound.loadformats; format && format->ext; format++ )
|
||||
for( const loadwavfmt_t *format = sound.loadformats; format && format->ext; format++ )
|
||||
{
|
||||
if( anyformat || !Q_stricmp( ext, format->ext ))
|
||||
{
|
||||
@@ -162,7 +160,6 @@ stream_t *FS_OpenStream( const char *filename )
|
||||
const char *ext = COM_FileExtension( filename );
|
||||
string loadname;
|
||||
qboolean anyformat = true;
|
||||
const streamfmt_t *format;
|
||||
stream_t *stream = NULL;
|
||||
|
||||
Sound_Reset(); // clear old streaminfo
|
||||
@@ -172,7 +169,7 @@ stream_t *FS_OpenStream( const char *filename )
|
||||
{
|
||||
// we needs to compare file extension with list of supported formats
|
||||
// and be sure what is real extension, not a filename with dot
|
||||
for( format = sound.streamformat; format && format->ext; format++ )
|
||||
for( const streamfmt_t *format = sound.streamformat; format && format->ext; format++ )
|
||||
{
|
||||
if( !Q_stricmp( format->ext, ext ))
|
||||
{
|
||||
@@ -184,7 +181,7 @@ stream_t *FS_OpenStream( const char *filename )
|
||||
}
|
||||
|
||||
// now try all the formats in the selected list
|
||||
for( format = sound.streamformat; format && format->ext; format++)
|
||||
for( const streamfmt_t *format = sound.streamformat; format && format->ext; format++)
|
||||
{
|
||||
if( anyformat || !Q_stricmp( ext, format->ext ))
|
||||
{
|
||||
|
||||
@@ -362,9 +362,7 @@ int Stream_ReadMPG( stream_t *stream, int needBytes, void *buffer )
|
||||
{
|
||||
// buffer handling
|
||||
int bytesWritten = 0;
|
||||
void *mpg;
|
||||
|
||||
mpg = stream->ptr;
|
||||
void *mpg = stream->ptr;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
|
||||
@@ -258,13 +258,12 @@ int Stream_ReadOggOpus( stream_t *stream, int needBytes, void *buffer )
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
int ret;
|
||||
byte *data;
|
||||
int outsize;
|
||||
|
||||
if( !stream->buffsize )
|
||||
{
|
||||
ret = op_read( ctx->of, (opus_int16 *)stream->temp, OUTBUF_SIZE / stream->width, NULL );
|
||||
int ret = op_read( ctx->of, (opus_int16 *)stream->temp, OUTBUF_SIZE / stream->width, NULL );
|
||||
if( ret == 0 )
|
||||
break; // end of file
|
||||
else if( ret < 0 )
|
||||
@@ -298,9 +297,9 @@ int Stream_ReadOggOpus( stream_t *stream, int needBytes, void *buffer )
|
||||
|
||||
int Stream_SetPosOggOpus( stream_t *stream, int newpos )
|
||||
{
|
||||
int ret;
|
||||
opus_streaming_ctx_t *ctx = (opus_streaming_ctx_t *)stream->ptr;
|
||||
if(( ret = op_raw_seek( ctx->of, newpos )) == 0 )
|
||||
int ret = op_raw_seek( ctx->of, newpos );
|
||||
if( ret == 0 )
|
||||
{
|
||||
stream->buffsize = 0; // flush any previous data
|
||||
return true;
|
||||
|
||||
@@ -268,9 +268,9 @@ int Stream_ReadOggVorbis( stream_t *stream, int needBytes, void *buffer )
|
||||
|
||||
int Stream_SetPosOggVorbis( stream_t *stream, int newpos )
|
||||
{
|
||||
int ret;
|
||||
vorbis_streaming_ctx_t *ctx = (vorbis_streaming_ctx_t *)stream->ptr;
|
||||
if(( ret = ov_raw_seek_lap( &ctx->vf, newpos )) == 0 )
|
||||
int ret = ov_raw_seek_lap( &ctx->vf, newpos );
|
||||
if( ret == 0 )
|
||||
{
|
||||
stream->buffsize = 0; // flush any previous data
|
||||
return true;
|
||||
|
||||
@@ -176,7 +176,6 @@ Sound_LoadWAV
|
||||
*/
|
||||
qboolean Sound_LoadWAV( const char *name, const byte *buffer, fs_offset_t filesize )
|
||||
{
|
||||
int samples, fmt;
|
||||
qboolean mpeg_stream = false;
|
||||
|
||||
if( !buffer || filesize <= 0 )
|
||||
@@ -205,7 +204,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
}
|
||||
|
||||
iff_dataPtr += 8;
|
||||
fmt = GetLittleShort();
|
||||
int fmt = GetLittleShort();
|
||||
|
||||
if( fmt != 1 )
|
||||
{
|
||||
@@ -276,7 +275,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
}
|
||||
|
||||
iff_dataPtr += 4;
|
||||
samples = GetLittleLong() / sound.width;
|
||||
int samples = GetLittleLong() / sound.width;
|
||||
|
||||
if( sound.samples )
|
||||
{
|
||||
@@ -331,12 +330,11 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
// now convert 8-bit sounds to signed
|
||||
if( sound.width == 1 )
|
||||
{
|
||||
int i, j;
|
||||
signed char *pData = (signed char *)sound.wav;
|
||||
|
||||
for( i = 0; i < sound.samples; i++ )
|
||||
for( int i = 0; i < sound.samples; i++ )
|
||||
{
|
||||
for( j = 0; j < sound.channels; j++ )
|
||||
for( int j = 0; j < sound.channels; j++ )
|
||||
{
|
||||
*pData = (byte)((int)((byte)*pData) - 128 );
|
||||
pData++;
|
||||
@@ -382,7 +380,6 @@ stream_t *Stream_OpenWAV( const char *filename )
|
||||
stream_t *stream;
|
||||
int last_chunk = 0;
|
||||
char chunkName[4];
|
||||
int iff_data;
|
||||
file_t *file;
|
||||
short t;
|
||||
|
||||
@@ -418,7 +415,7 @@ stream_t *Stream_OpenWAV( const char *filename )
|
||||
}
|
||||
|
||||
// get "fmt " chunk
|
||||
iff_data = FS_Tell( file );
|
||||
int iff_data = FS_Tell( file );
|
||||
last_chunk = iff_data;
|
||||
if( !StreamFindNextChunk( file, "fmt ", &last_chunk ))
|
||||
{
|
||||
@@ -485,11 +482,9 @@ assume stream is valid
|
||||
*/
|
||||
int Stream_ReadWAV( stream_t *stream, int bytes, void *buffer )
|
||||
{
|
||||
int remaining;
|
||||
|
||||
if( !stream->file ) return 0; // invalid file
|
||||
|
||||
remaining = stream->size - stream->pos;
|
||||
int remaining = stream->size - stream->pos;
|
||||
if( remaining <= 0 ) return 0;
|
||||
if( bytes > remaining ) bytes = remaining;
|
||||
|
||||
|
||||
@@ -219,8 +219,6 @@ client_textmessage_t *CL_TextMessageParse( poolhandle_t mempool, char *pfile, in
|
||||
void Test_RunTitles( void )
|
||||
{
|
||||
poolhandle_t mempool = Mem_AllocPool( __func__ );
|
||||
client_textmessage_t *tmessages;
|
||||
client_textmessage_t *null;
|
||||
int num_titles = 0, num_null_titles = 0;
|
||||
char titles[] =
|
||||
"// this is a comment\n"
|
||||
@@ -258,7 +256,7 @@ void Test_RunTitles( void )
|
||||
char broken_titles[] = "}\n";
|
||||
char broken_titles2[] = "{\n{\n";
|
||||
|
||||
null = CL_TextMessageParse( mempool, broken_titles, Q_strlen( broken_titles ), &num_null_titles );
|
||||
client_textmessage_t *null = CL_TextMessageParse( mempool, broken_titles, Q_strlen( broken_titles ), &num_null_titles );
|
||||
TASSERT_EQi( num_null_titles, 0 );
|
||||
TASSERT_EQp( null, NULL );
|
||||
|
||||
@@ -266,7 +264,7 @@ void Test_RunTitles( void )
|
||||
TASSERT_EQi( num_null_titles, 0 );
|
||||
TASSERT_EQp( null, NULL );
|
||||
|
||||
tmessages = CL_TextMessageParse( mempool, titles, Q_strlen( titles ), &num_titles );
|
||||
client_textmessage_t *tmessages = CL_TextMessageParse( mempool, titles, Q_strlen( titles ), &num_titles );
|
||||
TASSERT_EQi( num_titles, 4 );
|
||||
TASSERT_NEQp( tmessages, NULL );
|
||||
|
||||
|
||||
@@ -73,9 +73,7 @@ static void GAME_EXPORT VGUI_DrawInit( void )
|
||||
|
||||
static void GAME_EXPORT VGUI_DrawShutdown( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 1; i < vgui.texture_id; i++ )
|
||||
for( int i = 1; i < vgui.texture_id; i++ )
|
||||
ref.dllFuncs.GL_FreeTexture( vgui.textures[i].gl_texturenum );
|
||||
|
||||
Mem_FreePool( &vgui.mempool );
|
||||
@@ -136,9 +134,7 @@ static void GAME_EXPORT VGUI_UploadTexture( int id, const char *buffer, int widt
|
||||
// it's a new texture, try to find a copy
|
||||
if( vgui.textures[id].gl_texturenum == 0 )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 1; i < vgui.texture_id; i++ )
|
||||
for( int i = 1; i < vgui.texture_id; i++ )
|
||||
{
|
||||
if( vgui.textures[i].gl_texturenum != 0 && !memcmp( vgui.textures[i].hash, hash, sizeof( hash )))
|
||||
{
|
||||
@@ -210,26 +206,22 @@ static void GAME_EXPORT VGUI_SetupDrawingText( int *pColor )
|
||||
|
||||
static void GAME_EXPORT VGUI_DrawQuad( const vpoint_t *ul, const vpoint_t *lr )
|
||||
{
|
||||
float x, y, w, h;
|
||||
|
||||
if( !ul || !lr )
|
||||
return;
|
||||
|
||||
x = ul->point[0];
|
||||
y = ul->point[1];
|
||||
w = lr->point[0] - x;
|
||||
h = lr->point[1] - y;
|
||||
float x = ul->point[0];
|
||||
float y = ul->point[1];
|
||||
float w = lr->point[0] - x;
|
||||
float h = lr->point[1] - y;
|
||||
|
||||
SPR_AdjustSize( &x, &y, &w, &h );
|
||||
|
||||
if( vgui.enable_texture )
|
||||
{
|
||||
float s1, s2, t1, t2;
|
||||
|
||||
s1 = ul->coord[0];
|
||||
t1 = ul->coord[1];
|
||||
s2 = lr->coord[0];
|
||||
t2 = lr->coord[1];
|
||||
float s1 = ul->coord[0];
|
||||
float t1 = ul->coord[1];
|
||||
float s2 = lr->coord[0];
|
||||
float t2 = lr->coord[1];
|
||||
|
||||
ref.dllFuncs.Color4ub( vgui.color[0], vgui.color[1], vgui.color[2], vgui.color[3] );
|
||||
ref.dllFuncs.R_DrawStretchPic( x, y, w, h, s1, t1, s2, t2, vgui.textures[vgui.bound_texture].gl_texturenum );
|
||||
|
||||
@@ -91,11 +91,11 @@ VID_GetModeString
|
||||
*/
|
||||
const char *VID_GetModeString( int vid_mode )
|
||||
{
|
||||
vidmode_t *vidmode;
|
||||
if( vid_mode < 0 || vid_mode >= R_MaxVideoModes() )
|
||||
return NULL;
|
||||
|
||||
if( !( vidmode = R_GetVideoMode( vid_mode ) ) )
|
||||
vidmode_t *vidmode = R_GetVideoMode( vid_mode );
|
||||
if( !vidmode )
|
||||
return NULL;
|
||||
|
||||
return vidmode->desc;
|
||||
@@ -176,9 +176,7 @@ static void VID_Mode_f( void )
|
||||
{
|
||||
case 2:
|
||||
{
|
||||
vidmode_t *vidmode;
|
||||
|
||||
vidmode = R_GetVideoMode( Q_atoi( Cmd_Argv( 1 )) );
|
||||
vidmode_t *vidmode = R_GetVideoMode( Q_atoi( Cmd_Argv( 1 )) );
|
||||
if( !vidmode )
|
||||
{
|
||||
Con_Printf( S_ERROR "unable to set mode, backend returned null\n" );
|
||||
|
||||
@@ -43,16 +43,12 @@ Find base command in bucket
|
||||
*/
|
||||
static base_command_hashmap_t *BaseCmd_FindInBucket( base_command_hashmap_t *bucket, base_command_type_e type, const char *name )
|
||||
{
|
||||
base_command_hashmap_t *i;
|
||||
|
||||
for( i = bucket; i != NULL; i = i->next )
|
||||
for( base_command_hashmap_t *i = bucket; i != NULL; i = i->next )
|
||||
{
|
||||
int cmp;
|
||||
|
||||
if( i->type != type )
|
||||
continue;
|
||||
|
||||
cmp = Q_stricmp( i->name, name );
|
||||
int cmp = Q_stricmp( i->name, name );
|
||||
|
||||
if( cmp < 0 )
|
||||
continue;
|
||||
@@ -147,16 +143,16 @@ Add new typed base command to hashmap
|
||||
*/
|
||||
void BaseCmd_Insert( base_command_type_e type, base_command_t *basecmd, const char *name )
|
||||
{
|
||||
base_command_hashmap_t *elem, *cur, *find;
|
||||
uint hash = BaseCmd_HashKey( name );
|
||||
size_t len = Q_strlen( name );
|
||||
base_command_hashmap_t *elem = Mem_Malloc( basecmd_pool, sizeof( base_command_hashmap_t ) + len + 1 );
|
||||
|
||||
elem = Mem_Malloc( basecmd_pool, sizeof( base_command_hashmap_t ) + len + 1 );
|
||||
elem->basecmd = basecmd;
|
||||
elem->type = type;
|
||||
Q_strncpy( elem->name, name, len + 1 );
|
||||
|
||||
// link the variable in alphanumerical order
|
||||
base_command_hashmap_t *cur, *find;
|
||||
for( cur = NULL, find = hashed_cmds[hash];
|
||||
find && Q_stricmp( find->name, elem->name ) < 0;
|
||||
cur = find, find = find->next );
|
||||
@@ -181,12 +177,10 @@ void BaseCmd_Remove( base_command_type_e type, const char *name )
|
||||
|
||||
for( prev = NULL, i = hashed_cmds[hash]; i != NULL; prev = i, i = i->next )
|
||||
{
|
||||
int cmp;
|
||||
|
||||
if( i->type != type )
|
||||
continue;
|
||||
|
||||
cmp = Q_stricmp( i->name, name );
|
||||
int cmp = Q_stricmp( i->name, name );
|
||||
|
||||
if( cmp < 0 )
|
||||
continue;
|
||||
@@ -241,11 +235,10 @@ void BaseCmd_Stats_f( void )
|
||||
|
||||
for( int i = 0; i < HASH_SIZE; i++ )
|
||||
{
|
||||
base_command_hashmap_t *hm;
|
||||
int len = 0;
|
||||
|
||||
// count bucket length
|
||||
for( hm = hashed_cmds[i]; hm; hm = hm->next, len++ );
|
||||
for( base_command_hashmap_t *hm = hashed_cmds[i]; hm; hm = hm->next, len++ );
|
||||
|
||||
if( len == 0 )
|
||||
{
|
||||
@@ -300,11 +293,8 @@ void BaseCmd_Test_f( void )
|
||||
|
||||
for( int i = 0; i < 1000; i++ )
|
||||
{
|
||||
cmdalias_t *a;
|
||||
void *cmd;
|
||||
|
||||
// Cmd_LookupCmds don't allows to check alias, so just iterate
|
||||
for( a = Cmd_AliasGetList(); a; a = a->next, stats.lookups++ )
|
||||
for( cmdalias_t *a = Cmd_AliasGetList(); a; a = a->next, stats.lookups++ )
|
||||
{
|
||||
if( !BaseCmd_Find( HM_CMDALIAS, a->name ))
|
||||
{
|
||||
@@ -313,7 +303,7 @@ void BaseCmd_Test_f( void )
|
||||
}
|
||||
}
|
||||
|
||||
for( cmd = Cmd_GetFirstFunctionHandle(); cmd;
|
||||
for( void *cmd = Cmd_GetFirstFunctionHandle(); cmd;
|
||||
cmd = Cmd_GetNextFunctionHandle( cmd ), stats.lookups++ )
|
||||
{
|
||||
if( !BaseCmd_Find( HM_CMD, Cmd_GetName( cmd )))
|
||||
|
||||
@@ -77,9 +77,7 @@ Determine script variable type
|
||||
*/
|
||||
static cvartype_t CSCR_ParseType( parserstate_t *ps )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 1; i < T_COUNT; i++ )
|
||||
for( int i = 1; i < T_COUNT; i++ )
|
||||
{
|
||||
if( CSCR_ExpectString( ps, cvartypes[i], false, false ))
|
||||
return i;
|
||||
@@ -213,11 +211,11 @@ will callback on each scrvardef_t
|
||||
static int CSCR_ParseFile( const char *scriptfilename,
|
||||
void (*callback)( scrvardef_t *var, void * ), void *userdata )
|
||||
{
|
||||
parserstate_t state = { 0 };
|
||||
qboolean success = false;
|
||||
int count = 0;
|
||||
fs_offset_t length = 0;
|
||||
char *start;
|
||||
parserstate_t state = { 0 };
|
||||
qboolean success = false;
|
||||
int count = 0;
|
||||
fs_offset_t length = 0;
|
||||
char *start;
|
||||
|
||||
state.filename = scriptfilename;
|
||||
state.buf = start = (char *)FS_LoadFile( scriptfilename, &length, true );
|
||||
|
||||
@@ -66,15 +66,13 @@ Cbuf_GetSpace
|
||||
*/
|
||||
static void *Cbuf_GetSpace( cmdbuf_t *buf, int length )
|
||||
{
|
||||
void *data;
|
||||
|
||||
if(( buf->cursize + length ) >= sizeof( buf->data ))
|
||||
{
|
||||
buf->cursize = 0;
|
||||
Host_Error( "%s: overflow\n", __func__ );
|
||||
}
|
||||
|
||||
data = buf->data + buf->cursize;
|
||||
void *data = buf->data + buf->cursize;
|
||||
buf->cursize += length;
|
||||
|
||||
return data;
|
||||
@@ -168,10 +166,8 @@ Cbuf_Execute
|
||||
*/
|
||||
static void Cbuf_ExecuteCommandsFromBuffer( cmdbuf_t *buf, qboolean isPrivileged, int cmdsToExecute )
|
||||
{
|
||||
char *text;
|
||||
char line[MAX_CMD_LINE];
|
||||
int i, quotes;
|
||||
char *comment;
|
||||
int i;
|
||||
|
||||
while( buf->cursize )
|
||||
{
|
||||
@@ -189,10 +185,10 @@ static void Cbuf_ExecuteCommandsFromBuffer( cmdbuf_t *buf, qboolean isPrivileged
|
||||
}
|
||||
|
||||
// find a \n or ; line break
|
||||
text = (char *)buf->data;
|
||||
char *text = (char *)buf->data;
|
||||
|
||||
quotes = false;
|
||||
comment = NULL;
|
||||
int quotes = false;
|
||||
char *comment = NULL;
|
||||
|
||||
for( i = 0; i < buf->cursize; i++ )
|
||||
{
|
||||
@@ -384,9 +380,7 @@ Just prints the rest of the line to the console
|
||||
*/
|
||||
static void Cmd_Echo_f( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 1; i < Cmd_Argc(); i++ )
|
||||
for( int i = 1; i < Cmd_Argc(); i++ )
|
||||
Con_Printf( "%s ", Cmd_Argv( i ));
|
||||
Con_Printf( "\n" );
|
||||
}
|
||||
@@ -402,8 +396,6 @@ static void Cmd_Alias_f( void )
|
||||
{
|
||||
cmdalias_t *a;
|
||||
char cmd[MAX_CMD_LINE];
|
||||
int i, c;
|
||||
const char *s;
|
||||
|
||||
if( Cmd_Argc() == 1 )
|
||||
{
|
||||
@@ -413,7 +405,7 @@ static void Cmd_Alias_f( void )
|
||||
return;
|
||||
}
|
||||
|
||||
s = Cmd_Argv( 1 );
|
||||
const char *s = Cmd_Argv( 1 );
|
||||
|
||||
if( Q_strlen( s ) >= MAX_ALIAS_NAME )
|
||||
{
|
||||
@@ -452,9 +444,9 @@ static void Cmd_Alias_f( void )
|
||||
// copy the rest of the command line
|
||||
cmd[0] = 0; // start out with a null string
|
||||
|
||||
c = Cmd_Argc();
|
||||
int c = Cmd_Argc();
|
||||
|
||||
for( i = 2; i < c; i++ )
|
||||
for( int i = 2; i < c; i++ )
|
||||
{
|
||||
if( i != 2 ) Q_strncat( cmd, " ", sizeof( cmd ));
|
||||
Q_strncat( cmd, Cmd_Argv( i ), sizeof( cmd ));
|
||||
@@ -473,20 +465,16 @@ Remove existing aliases.
|
||||
*/
|
||||
static void Cmd_UnAlias_f ( void )
|
||||
{
|
||||
cmdalias_t *a, *p;
|
||||
const char *s;
|
||||
int i;
|
||||
|
||||
if( Cmd_Argc() == 1 )
|
||||
{
|
||||
Con_Printf( S_USAGE "unalias alias1 [alias2 ...]\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
for( i = 1; i < Cmd_Argc(); i++ )
|
||||
for( int i = 1; i < Cmd_Argc(); i++ )
|
||||
{
|
||||
s = Cmd_Argv( i );
|
||||
p = NULL;
|
||||
const char *s = Cmd_Argv( i );
|
||||
cmdalias_t *a, *p = NULL;
|
||||
|
||||
for( a = cmd_alias; a; p = a, a = a->next )
|
||||
{
|
||||
@@ -586,10 +574,9 @@ will point into this temporary buffer.
|
||||
void Cmd_TokenizeString( const char *text )
|
||||
{
|
||||
char cmd_token[MAX_CMD_BUFFER];
|
||||
int i;
|
||||
|
||||
// clear the args from the last string
|
||||
for( i = 0; i < cmd_argc; i++ )
|
||||
for( int i = 0; i < cmd_argc; i++ )
|
||||
Mem_Free( cmd_argv[i] );
|
||||
|
||||
cmd_argc = 0; // clear previous args
|
||||
@@ -709,15 +696,13 @@ Cmd_RemoveCommand
|
||||
*/
|
||||
void GAME_EXPORT Cmd_RemoveCommand( const char *cmd_name )
|
||||
{
|
||||
cmd_t *cmd, **back;
|
||||
|
||||
if( !cmd_name || !*cmd_name )
|
||||
return;
|
||||
|
||||
back = &cmd_functions;
|
||||
cmd_t **back = &cmd_functions;
|
||||
while( 1 )
|
||||
{
|
||||
cmd = *back;
|
||||
cmd_t *cmd = *back;
|
||||
if( !cmd ) return;
|
||||
|
||||
if( !Q_strcmp( cmd_name, cmd->name ))
|
||||
@@ -743,20 +728,17 @@ Cmd_LookupCmds
|
||||
*/
|
||||
void Cmd_LookupCmds( void *buffer, void *ptr, setpair_t callback )
|
||||
{
|
||||
cmd_t *cmd;
|
||||
cmdalias_t *alias;
|
||||
|
||||
// nothing to process ?
|
||||
if( !callback ) return;
|
||||
|
||||
for( cmd = cmd_functions; cmd; cmd = cmd->next )
|
||||
for( cmd_t *cmd = cmd_functions; cmd; cmd = cmd->next )
|
||||
{
|
||||
if( !buffer ) callback( cmd->name, (char *)cmd->function, cmd->desc, ptr );
|
||||
else callback( cmd->name, (char *)cmd->function, buffer, ptr );
|
||||
}
|
||||
|
||||
// lookup an aliases too
|
||||
for( alias = cmd_alias; alias; alias = alias->next )
|
||||
for( cmdalias_t *alias = cmd_alias; alias; alias = alias->next )
|
||||
callback( alias->name, alias->value, buffer, ptr );
|
||||
}
|
||||
|
||||
@@ -846,7 +828,6 @@ static void Cmd_Else_f( void )
|
||||
static qboolean Cmd_ShouldAllowCommand( cmd_t *cmd, qboolean isPrivileged )
|
||||
{
|
||||
const char *prefixes[] = { "cl_", "gl_", "r_", "m_", "hud_", "joy_", "con_", "scr_" };
|
||||
int i;
|
||||
|
||||
// always allow local commands
|
||||
if( isPrivileged )
|
||||
@@ -863,7 +844,7 @@ static qboolean Cmd_ShouldAllowCommand( cmd_t *cmd, qboolean isPrivileged )
|
||||
if( FBitSet( cmd->flags, CMD_FILTERABLE ))
|
||||
return false;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( prefixes ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( prefixes ); i++ )
|
||||
{
|
||||
if( !Q_strnicmp( cmd->name, prefixes[i], Q_strlen( prefixes[i] )))
|
||||
return false;
|
||||
@@ -1038,7 +1019,6 @@ Cmd_List_f
|
||||
*/
|
||||
static void Cmd_List_f( void )
|
||||
{
|
||||
cmd_t *cmd;
|
||||
int i = 0;
|
||||
size_t matchlen = 0;
|
||||
const char *match = NULL;
|
||||
@@ -1049,7 +1029,7 @@ static void Cmd_List_f( void )
|
||||
matchlen = Q_strlen( match );
|
||||
}
|
||||
|
||||
for( cmd = cmd_functions; cmd; cmd = cmd->next )
|
||||
for( cmd_t *cmd = cmd_functions; cmd; cmd = cmd->next )
|
||||
{
|
||||
if( cmd->name[0] == '@' )
|
||||
continue; // never show system cmds
|
||||
@@ -1073,8 +1053,6 @@ unlink all commands with specified flag
|
||||
*/
|
||||
void Cmd_Unlink( int group )
|
||||
{
|
||||
cmd_t *cmd;
|
||||
cmd_t **prev;
|
||||
int count = 0;
|
||||
|
||||
if( FBitSet( group, CMD_SERVERDLL ) && Cvar_VariableInteger( "host_gameloaded" ))
|
||||
@@ -1086,11 +1064,11 @@ void Cmd_Unlink( int group )
|
||||
if( FBitSet( group, CMD_GAMEUIDLL ) && Cvar_VariableInteger( "host_gameuiloaded" ))
|
||||
return;
|
||||
|
||||
prev = &cmd_functions;
|
||||
cmd_t **prev = &cmd_functions;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
cmd = *prev;
|
||||
cmd_t *cmd = *prev;
|
||||
if( !cmd ) break;
|
||||
|
||||
// do filter by specified group
|
||||
@@ -1115,10 +1093,6 @@ void Cmd_Unlink( int group )
|
||||
|
||||
static void Cmd_Apropos_f( void )
|
||||
{
|
||||
cmd_t *cmd;
|
||||
convar_t *var;
|
||||
cmdalias_t *alias;
|
||||
const char *partial;
|
||||
int count = 0;
|
||||
char buf[MAX_VA_STRING];
|
||||
|
||||
@@ -1128,7 +1102,7 @@ static void Cmd_Apropos_f( void )
|
||||
return;
|
||||
}
|
||||
|
||||
partial = Cmd_Args();
|
||||
const char *partial = Cmd_Args();
|
||||
|
||||
if( !Q_strpbrk( partial, "*?" ))
|
||||
{
|
||||
@@ -1136,7 +1110,7 @@ static void Cmd_Apropos_f( void )
|
||||
partial = buf;
|
||||
}
|
||||
|
||||
for( var = (convar_t*)Cvar_GetList(); var; var = var->next )
|
||||
for( convar_t *var = (convar_t*)Cvar_GetList(); var; var = var->next )
|
||||
{
|
||||
if( !matchpattern_with_separator( var->name, partial, true, "", false ) )
|
||||
{
|
||||
@@ -1162,7 +1136,7 @@ static void Cmd_Apropos_f( void )
|
||||
count++;
|
||||
}
|
||||
|
||||
for( cmd = Cmd_GetFirstFunctionHandle(); cmd; cmd = Cmd_GetNextFunctionHandle( cmd ) )
|
||||
for( cmd_t *cmd = Cmd_GetFirstFunctionHandle(); cmd; cmd = Cmd_GetNextFunctionHandle( cmd ) )
|
||||
{
|
||||
if( cmd->name[0] == '@' )
|
||||
continue; // never show system cmds
|
||||
@@ -1175,7 +1149,7 @@ static void Cmd_Apropos_f( void )
|
||||
count++;
|
||||
}
|
||||
|
||||
for( alias = Cmd_AliasGetList(); alias; alias = alias->next )
|
||||
for( cmdalias_t *alias = Cmd_AliasGetList(); alias; alias = alias->next )
|
||||
{
|
||||
// proceed a bit differently here as an alias value always got a final \n
|
||||
if( !matchpattern_with_separator( alias->name, partial, true, "", false ) &&
|
||||
@@ -1247,10 +1221,9 @@ Cmd_ExecScript
|
||||
*/
|
||||
static void Cmd_ExecScript( const char *filename )
|
||||
{
|
||||
byte *f;
|
||||
fs_offset_t len;
|
||||
byte *f = FS_LoadFile( filename, &len, false );
|
||||
|
||||
f = FS_LoadFile( filename, &len, false );
|
||||
if( !f )
|
||||
{
|
||||
Con_Reportf( "couldn't exec %s\n", filename );
|
||||
|
||||
@@ -68,19 +68,17 @@ static int idum = 0;
|
||||
|
||||
static int lran1( void )
|
||||
{
|
||||
static int iy = 0;
|
||||
static int iv[NTAB];
|
||||
int j;
|
||||
int k;
|
||||
static int iy = 0;
|
||||
static int iv[NTAB];
|
||||
|
||||
if( idum <= 0 || !iy )
|
||||
{
|
||||
if( -(idum) < 1 ) idum = 1;
|
||||
else idum = -(idum);
|
||||
|
||||
for( j = NTAB + 7; j >= 0; j-- )
|
||||
for( int j = NTAB + 7; j >= 0; j-- )
|
||||
{
|
||||
k = (idum) / IQ;
|
||||
int k = (idum) / IQ;
|
||||
idum = IA * (idum - k * IQ) - IR * k;
|
||||
if( idum < 0 ) idum += IM;
|
||||
if( j < NTAB ) iv[j] = idum;
|
||||
@@ -89,10 +87,10 @@ static int lran1( void )
|
||||
iy = iv[0];
|
||||
}
|
||||
|
||||
k = (idum) / IQ;
|
||||
int k = (idum) / IQ;
|
||||
idum = IA * (idum - k * IQ) - IR * k;
|
||||
if( idum < 0 ) idum += IM;
|
||||
j = iy / NDIV;
|
||||
int j = iy / NDIV;
|
||||
iy = iv[j];
|
||||
iv[j] = idum;
|
||||
|
||||
@@ -121,18 +119,15 @@ void GAME_EXPORT COM_SetRandomSeed( int lSeed )
|
||||
|
||||
float GAME_EXPORT COM_RandomFloat( float flLow, float flHigh )
|
||||
{
|
||||
float fl;
|
||||
|
||||
if( idum == 0 ) COM_SetRandomSeed( 0 );
|
||||
|
||||
fl = fran1(); // float in [0,1]
|
||||
float fl = fran1(); // float in [0,1]
|
||||
return (fl * (flHigh - flLow)) + flLow; // float in [low, high)
|
||||
}
|
||||
|
||||
int GAME_EXPORT COM_RandomLong( int lLow, int lHigh )
|
||||
{
|
||||
dword maxAcceptable;
|
||||
dword n, x = lHigh - lLow + 1;
|
||||
dword x = lHigh - lLow + 1;
|
||||
|
||||
if( idum == 0 ) COM_SetRandomSeed( 0 );
|
||||
|
||||
@@ -146,7 +141,8 @@ int GAME_EXPORT COM_RandomLong( int lLow, int lHigh )
|
||||
// the average number of times through the loop is 2. For cases where x is
|
||||
// much smaller than MAX_RANDOM_RANGE, the average number of times through the
|
||||
// loop is very close to 1.
|
||||
maxAcceptable = MAX_RANDOM_RANGE - ((MAX_RANDOM_RANGE + 1) % x );
|
||||
dword maxAcceptable = MAX_RANDOM_RANGE - ((MAX_RANDOM_RANGE + 1) % x );
|
||||
dword n;
|
||||
do
|
||||
{
|
||||
n = lran1();
|
||||
@@ -166,12 +162,13 @@ of all text functions.
|
||||
*/
|
||||
char *va( const char *format, ... )
|
||||
{
|
||||
va_list argptr;
|
||||
static char string[16][MAX_VA_STRING], *s;
|
||||
static int stringindex = 0;
|
||||
static char string[16][MAX_VA_STRING], *s;
|
||||
static int stringindex = 0;
|
||||
|
||||
s = string[stringindex];
|
||||
stringindex = (stringindex + 1) & 15;
|
||||
|
||||
va_list argptr;
|
||||
va_start( argptr, format );
|
||||
Q_vsnprintf( s, sizeof( string[0] ), format, argptr );
|
||||
va_end( argptr );
|
||||
@@ -222,12 +219,10 @@ typedef struct
|
||||
|
||||
qboolean LZSS_IsCompressed( const byte *source, size_t input_len )
|
||||
{
|
||||
const lzss_header_t *phdr;
|
||||
|
||||
if( input_len <= sizeof( lzss_header_t ))
|
||||
return 0;
|
||||
|
||||
phdr = (const lzss_header_t *)source;
|
||||
const lzss_header_t *phdr = (const lzss_header_t *)source;
|
||||
|
||||
if( phdr && phdr->id == LittleLong( LZSS_ID ))
|
||||
return true;
|
||||
@@ -236,12 +231,10 @@ qboolean LZSS_IsCompressed( const byte *source, size_t input_len )
|
||||
|
||||
uint LZSS_GetActualSize( const byte *source, size_t input_len )
|
||||
{
|
||||
const lzss_header_t *phdr;
|
||||
|
||||
if( input_len <= sizeof( lzss_header_t ))
|
||||
return 0;
|
||||
|
||||
phdr = (const lzss_header_t *)source;
|
||||
const lzss_header_t *phdr = (const lzss_header_t *)source;
|
||||
|
||||
if( phdr && phdr->id == LittleLong( LZSS_ID ))
|
||||
return LittleLong( phdr->size );
|
||||
@@ -251,15 +244,12 @@ uint LZSS_GetActualSize( const byte *source, size_t input_len )
|
||||
|
||||
static void LZSS_BuildHash( lzss_state_t *state, const byte *source )
|
||||
{
|
||||
lzss_list_t *list;
|
||||
lzss_node_t *node;
|
||||
unsigned int targetindex = (uintptr_t)source & ( state->window_size - 1 );
|
||||
|
||||
node = &state->hash_node[targetindex];
|
||||
unsigned int targetindex = (uintptr_t)source & ( state->window_size - 1 );
|
||||
lzss_node_t *node = &state->hash_node[targetindex];
|
||||
|
||||
if( node->data )
|
||||
{
|
||||
list = &state->hash_table[*node->data];
|
||||
lzss_list_t *list = &state->hash_table[*node->data];
|
||||
if( node->prev )
|
||||
{
|
||||
list->end = node->prev;
|
||||
@@ -272,7 +262,7 @@ static void LZSS_BuildHash( lzss_state_t *state, const byte *source )
|
||||
}
|
||||
}
|
||||
|
||||
list = &state->hash_table[*source];
|
||||
lzss_list_t *list = &state->hash_table[*source];
|
||||
node->data = source;
|
||||
node->prev = NULL;
|
||||
node->next = list->start;
|
||||
@@ -284,19 +274,19 @@ static void LZSS_BuildHash( lzss_state_t *state, const byte *source )
|
||||
|
||||
static byte *LZSS_CompressNoAlloc( lzss_state_t *state, byte *pInput, int input_length, byte *pOutputBuf, uint *pOutputSize )
|
||||
{
|
||||
byte *pStart = pOutputBuf; // allocate the output buffer, compressed buffer is expected to be less, caller will free
|
||||
byte *pEnd = pStart + input_length - sizeof( lzss_header_t ) - 8; // prevent compression failure
|
||||
lzss_header_t *header = (lzss_header_t *)pStart;
|
||||
byte *pOutput = pStart + sizeof( lzss_header_t );
|
||||
const byte *pEncodedPosition = NULL;
|
||||
byte *pLookAhead = pInput;
|
||||
byte *pWindow = pInput;
|
||||
int i, putCmdByte = 0;
|
||||
byte *pCmdByte = NULL;
|
||||
|
||||
if( input_length <= sizeof( lzss_header_t ) + 8 )
|
||||
return NULL;
|
||||
|
||||
byte *pStart = pOutputBuf; // allocate the output buffer, compressed buffer is expected to be less, caller will free
|
||||
byte *pEnd = pStart + input_length - sizeof( lzss_header_t ) - 8; // prevent compression failure
|
||||
lzss_header_t *header = (lzss_header_t *)pStart;
|
||||
byte *pOutput = pStart + sizeof( lzss_header_t );
|
||||
const byte *pEncodedPosition = NULL;
|
||||
byte *pLookAhead = pInput;
|
||||
byte *pWindow = pInput;
|
||||
int putCmdByte = 0;
|
||||
byte *pCmdByte = NULL;
|
||||
|
||||
// set LZSS header
|
||||
header->id = LittleLong( LZSS_ID );
|
||||
header->size = LittleLong( input_length );
|
||||
@@ -359,7 +349,7 @@ static byte *LZSS_CompressNoAlloc( lzss_state_t *state, byte *pInput, int input_
|
||||
encoded_length = 1;
|
||||
}
|
||||
|
||||
for( i = 0; i < encoded_length; i++ )
|
||||
for( int i = 0; i < encoded_length; i++ )
|
||||
{
|
||||
LZSS_BuildHash( state, pLookAhead++ );
|
||||
}
|
||||
@@ -407,13 +397,12 @@ static byte *LZSS_CompressNoAlloc( lzss_state_t *state, byte *pInput, int input_
|
||||
byte *LZSS_Compress( byte *pInput, int inputLength, uint *pOutputSize )
|
||||
{
|
||||
byte *pStart = (byte *)malloc( inputLength );
|
||||
byte *pFinal = NULL;
|
||||
lzss_state_t state = { .window_size = LZSS_WINDOW_SIZE };
|
||||
|
||||
if( !pStart )
|
||||
return NULL;
|
||||
|
||||
pFinal = LZSS_CompressNoAlloc( &state, pInput, inputLength, pStart, pOutputSize );
|
||||
lzss_state_t state = { .window_size = LZSS_WINDOW_SIZE };
|
||||
byte *pFinal = LZSS_CompressNoAlloc( &state, pInput, inputLength, pStart, pOutputSize );
|
||||
|
||||
if( !pFinal )
|
||||
{
|
||||
@@ -426,21 +415,20 @@ byte *LZSS_Compress( byte *pInput, int inputLength, uint *pOutputSize )
|
||||
|
||||
uint LZSS_Decompress( const byte *pInput, byte *pOutput, size_t input_len, size_t output_len )
|
||||
{
|
||||
uint totalBytes = 0;
|
||||
int getCmdByte = 0;
|
||||
int cmdByte = 0;
|
||||
uint actualSize;
|
||||
const byte *pInputEnd = pInput + input_len - 1; // thanks to nillerusr for the fix!
|
||||
byte *pOrigOutput = pOutput;
|
||||
|
||||
if( input_len <= sizeof( lzss_header_t ))
|
||||
return 0;
|
||||
|
||||
actualSize = LZSS_GetActualSize( pInput, input_len );
|
||||
uint actualSize = LZSS_GetActualSize( pInput, input_len );
|
||||
|
||||
if( !actualSize || actualSize > output_len )
|
||||
return 0;
|
||||
|
||||
uint totalBytes = 0;
|
||||
int getCmdByte = 0;
|
||||
int cmdByte = 0;
|
||||
const byte *pInputEnd = pInput + input_len - 1; // thanks to nillerusr for the fix!
|
||||
byte *pOrigOutput = pOutput;
|
||||
|
||||
pInput += sizeof( lzss_header_t );
|
||||
|
||||
while( 1 )
|
||||
@@ -456,26 +444,22 @@ uint LZSS_Decompress( const byte *pInput, byte *pOutput, size_t input_len, size_
|
||||
|
||||
if( cmdByte & 0x01 )
|
||||
{
|
||||
int position;
|
||||
int i, count;
|
||||
byte *pSource;
|
||||
|
||||
if( pInput > pInputEnd )
|
||||
return 0;
|
||||
|
||||
position = *pInput++ << LZSS_LOOKSHIFT;
|
||||
int position = *pInput++ << LZSS_LOOKSHIFT;
|
||||
position |= ( *pInput >> LZSS_LOOKSHIFT );
|
||||
count = ( *pInput++ & 0x0F ) + 1;
|
||||
int count = ( *pInput++ & 0x0F ) + 1;
|
||||
|
||||
if( count == 1 )
|
||||
break;
|
||||
|
||||
pSource = pOutput - position - 1;
|
||||
byte *pSource = pOutput - position - 1;
|
||||
|
||||
if( totalBytes + count > output_len || pSource < pOrigOutput )
|
||||
return 0;
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
*pOutput++ = *pSource++;
|
||||
totalBytes += count;
|
||||
}
|
||||
@@ -506,16 +490,12 @@ COM_ParseVector
|
||||
*/
|
||||
qboolean COM_ParseVector( char **pfile, float *v, size_t size )
|
||||
{
|
||||
string token;
|
||||
qboolean bracket = false;
|
||||
char *saved;
|
||||
uint i;
|
||||
|
||||
if( v == NULL || size == 0 )
|
||||
return false;
|
||||
|
||||
memset( v, 0, sizeof( *v ) * size );
|
||||
|
||||
string token;
|
||||
if( size == 1 )
|
||||
{
|
||||
*pfile = COM_ParseFile( *pfile, token, sizeof( token ));
|
||||
@@ -523,16 +503,17 @@ qboolean COM_ParseVector( char **pfile, float *v, size_t size )
|
||||
return true;
|
||||
}
|
||||
|
||||
saved = *pfile;
|
||||
char *saved = *pfile;
|
||||
|
||||
if(( *pfile = COM_ParseFile( *pfile, token, sizeof( token ))) == NULL )
|
||||
return false;
|
||||
|
||||
qboolean bracket = false;
|
||||
if( token[0] == '(' )
|
||||
bracket = true;
|
||||
else *pfile = saved; // restore token to right get it again
|
||||
|
||||
for( i = 0; i < size; i++ )
|
||||
for( uint i = 0; i < size; i++ )
|
||||
{
|
||||
*pfile = COM_ParseFile( *pfile, token, sizeof( token ));
|
||||
v[i] = Q_atof( token );
|
||||
@@ -595,13 +576,11 @@ Converts pszInput Hex string to nInputLength/2 binary
|
||||
*/
|
||||
void COM_HexConvert( const char *pszInput, int nInputLength, byte *pOutput )
|
||||
{
|
||||
const char *pIn;
|
||||
byte *p = pOutput;
|
||||
int i;
|
||||
byte *p = pOutput;
|
||||
|
||||
for( i = 0; i < nInputLength; i += 2 )
|
||||
for( int i = 0; i < nInputLength; i += 2 )
|
||||
{
|
||||
pIn = &pszInput[i];
|
||||
const char *pIn = &pszInput[i];
|
||||
*p = COM_Nibble( pIn[0] ) << 4 | COM_Nibble( pIn[1] );
|
||||
p++;
|
||||
}
|
||||
@@ -615,10 +594,6 @@ COM_LoadFileForMe
|
||||
*/
|
||||
byte *GAME_EXPORT COM_LoadFileForMe( const char *filename, int *pLength )
|
||||
{
|
||||
string name;
|
||||
byte *pfile;
|
||||
fs_offset_t iLength;
|
||||
|
||||
if( COM_StringEmptyOrNULL( filename ))
|
||||
{
|
||||
if( pLength )
|
||||
@@ -626,10 +601,12 @@ byte *GAME_EXPORT COM_LoadFileForMe( const char *filename, int *pLength )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
string name;
|
||||
Q_strncpy( name, filename, sizeof( name ));
|
||||
COM_FixSlashes( name );
|
||||
|
||||
pfile = g_fsapi.LoadFileMalloc( name, &iLength, false );
|
||||
fs_offset_t iLength;
|
||||
byte *pfile = g_fsapi.LoadFileMalloc( name, &iLength, false );
|
||||
if( pLength ) *pLength = (int)iLength;
|
||||
|
||||
return pfile;
|
||||
@@ -728,16 +705,17 @@ pfnCompareFileTime
|
||||
*/
|
||||
int GAME_EXPORT pfnCompareFileTime( const char *path1, const char *path2, int *retval )
|
||||
{
|
||||
int t1, t2;
|
||||
*retval = 0;
|
||||
|
||||
if( !path1 || !path2 )
|
||||
return 0;
|
||||
|
||||
if(( t1 = g_fsapi.FileTime( path1, false )) == -1 )
|
||||
int t1 = g_fsapi.FileTime( path1, false );
|
||||
if( t1 == -1 )
|
||||
return 0;
|
||||
|
||||
if(( t2 = g_fsapi.FileTime( path2, false )) == -1 )
|
||||
int t2 = g_fsapi.FileTime( path2, false );
|
||||
if( t2 == -1 )
|
||||
return 0;
|
||||
|
||||
if( t1 < t2 )
|
||||
@@ -770,17 +748,11 @@ int GAME_EXPORT COM_CheckParm( char *parm, char **ppnext )
|
||||
|
||||
qboolean COM_IsSafeFileToDownload( const char *filename )
|
||||
{
|
||||
char lwrfilename[4096];
|
||||
const char *last;
|
||||
const char *ext;
|
||||
size_t len;
|
||||
int i;
|
||||
|
||||
if( COM_StringEmptyOrNULL( filename ))
|
||||
return false;
|
||||
|
||||
ext = COM_FileExtension( filename );
|
||||
len = Q_strlen( filename );
|
||||
const char *ext = COM_FileExtension( filename );
|
||||
size_t len = Q_strlen( filename );
|
||||
|
||||
// only allow extensionless files that start with !MD5
|
||||
if( !Q_strncmp( filename, "!MD5", 4 ))
|
||||
@@ -793,7 +765,7 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
|
||||
if( len != 36 )
|
||||
return false;
|
||||
|
||||
for( i = 4; i < len; i++ )
|
||||
for( int i = 4; i < len; i++ )
|
||||
{
|
||||
if(( filename[i] >= '0' && filename[i] <= '9' ) ||
|
||||
( filename[i] >= 'A' && filename[i] <= 'F' ))
|
||||
@@ -805,12 +777,13 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
|
||||
return true;
|
||||
}
|
||||
|
||||
for( i = 0; i < len; i++ )
|
||||
for( int i = 0; i < len; i++ )
|
||||
{
|
||||
if( !isprint( filename[i] ))
|
||||
return false;
|
||||
}
|
||||
|
||||
char lwrfilename[4096];
|
||||
Q_strnlwr( filename, lwrfilename, sizeof( lwrfilename ));
|
||||
ext = COM_FileExtension( lwrfilename );
|
||||
|
||||
@@ -820,7 +793,7 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
|
||||
if( lwrfilename[0] == '/' )
|
||||
return false;
|
||||
|
||||
last = Q_strrchr( lwrfilename, '.' );
|
||||
const char *last = Q_strrchr( lwrfilename, '.' );
|
||||
|
||||
if( last == NULL )
|
||||
return false;
|
||||
@@ -828,7 +801,7 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
|
||||
if( Q_strlen( last ) != 4 )
|
||||
return false;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( file_exts ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( file_exts ); i++ )
|
||||
{
|
||||
if( !Q_stricmp( ext, file_exts[i] ))
|
||||
return false;
|
||||
@@ -839,14 +812,11 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
|
||||
|
||||
char *_copystring( poolhandle_t mempool, const char *s, const char *filename, int fileline )
|
||||
{
|
||||
size_t size;
|
||||
char *b;
|
||||
|
||||
if( !s ) return NULL;
|
||||
if( !mempool ) mempool = host.mempool;
|
||||
|
||||
size = Q_strlen( s ) + 1;
|
||||
b = _Mem_Alloc( mempool, size, false, filename, fileline );
|
||||
size_t size = Q_strlen( s ) + 1;
|
||||
char *b = _Mem_Alloc( mempool, size, false, filename, fileline );
|
||||
Q_strncpy( b, s, size );
|
||||
|
||||
return b;
|
||||
|
||||
@@ -54,11 +54,10 @@ Cmd_ListMaps
|
||||
*/
|
||||
int Cmd_ListMaps( search_t *t, char *lastmapname, size_t len, qboolean silent )
|
||||
{
|
||||
file_t *f;
|
||||
int i, nummaps;
|
||||
int nummaps = 0;
|
||||
string mapname, message, compiler, generator;
|
||||
|
||||
for( i = 0, nummaps = 0; i < t->numfilenames; i++ )
|
||||
for( int i = 0; i < t->numfilenames; i++ )
|
||||
{
|
||||
char entfilename[MAX_QPATH];
|
||||
const char *ext = COM_FileExtension( t->filenames[i] );
|
||||
@@ -72,17 +71,14 @@ int Cmd_ListMaps( search_t *t, char *lastmapname, size_t len, qboolean silent )
|
||||
compiler[0] = '\0';
|
||||
generator[0] = '\0';
|
||||
|
||||
f = FS_Open( t->filenames[i], "rb", con_gamemaps.value );
|
||||
file_t *f = FS_Open( t->filenames[i], "rb", con_gamemaps.value );
|
||||
|
||||
if( f )
|
||||
{
|
||||
dheader_t *header;
|
||||
dextrahdr_t *hdrext;
|
||||
dlump_t entities;
|
||||
fs_offset_t filelen;
|
||||
byte buf[MAX_SYSPATH] = { 0 }; // 1 kb
|
||||
|
||||
filelen = FS_Read( f, buf, sizeof( buf ));
|
||||
fs_offset_t filelen = FS_Read( f, buf, sizeof( buf ));
|
||||
|
||||
// check all the lumps and some other errors
|
||||
if( !Mod_TestBmodelLumps( f, t->filenames[i], buf, filelen, silent, &entities ))
|
||||
@@ -94,8 +90,8 @@ int Cmd_ListMaps( search_t *t, char *lastmapname, size_t len, qboolean silent )
|
||||
lumpofs = entities.fileofs;
|
||||
lumplen = entities.filelen;
|
||||
|
||||
header = (dheader_t *)buf;
|
||||
hdrext = (dextrahdr_t *)((byte *)buf + sizeof( dheader_t ));
|
||||
dheader_t *header = (dheader_t *)buf;
|
||||
dextrahdr_t *hdrext = (dextrahdr_t *)((byte *)buf + sizeof( dheader_t ));
|
||||
|
||||
ver = header->version;
|
||||
if( hdrext->id == IDEXTRAHEADER ) version = hdrext->version;
|
||||
@@ -187,11 +183,9 @@ Prints or complete map filename
|
||||
*/
|
||||
static qboolean Cmd_GetMapList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
int i, nummaps;
|
||||
string matchbuf;
|
||||
|
||||
t = FS_Search( va( "maps/%s*.bsp", s ), true, con_gamemaps.value );
|
||||
search_t *t = FS_Search( va( "maps/%s*.bsp", s ), true, con_gamemaps.value );
|
||||
if( !t ) return false;
|
||||
|
||||
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
|
||||
@@ -199,7 +193,7 @@ static qboolean Cmd_GetMapList( const char *s, char *completedname, int length,
|
||||
Q_strncpy( completedname, matchbuf, length );
|
||||
if( t->numfilenames == 1 ) return true;
|
||||
|
||||
nummaps = Cmd_ListMaps( t, matchbuf, sizeof( matchbuf ), !print_suggestions );
|
||||
int nummaps = Cmd_ListMaps( t, matchbuf, sizeof( matchbuf ), !print_suggestions );
|
||||
|
||||
if( print_suggestions )
|
||||
Con_Printf( "\n^3 %d maps found.\n", nummaps );
|
||||
@@ -207,7 +201,7 @@ static qboolean Cmd_GetMapList( const char *s, char *completedname, int length,
|
||||
Mem_Free( t );
|
||||
|
||||
// cut shortestMatch to the amount common with s
|
||||
for( i = 0; matchbuf[i]; i++ )
|
||||
for( int i = 0; matchbuf[i]; i++ )
|
||||
{
|
||||
if( Q_tolower( completedname[i] ) != Q_tolower( matchbuf[i] ))
|
||||
completedname[i] = 0;
|
||||
@@ -224,12 +218,10 @@ Prints or complete demo filename
|
||||
*/
|
||||
static qboolean Cmd_GetDemoList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
int i, numdems;
|
||||
string matchbuf;
|
||||
|
||||
// lookup only in gamedir
|
||||
t = FS_Search( va( "%s*.dem", s ), true, true );
|
||||
search_t *t = FS_Search( va( "%s*.dem", s ), true, true );
|
||||
if( !t ) return false;
|
||||
|
||||
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
|
||||
@@ -237,7 +229,8 @@ static qboolean Cmd_GetDemoList( const char *s, char *completedname, int length,
|
||||
Q_strncpy( completedname, matchbuf, length );
|
||||
if( t->numfilenames == 1 ) return true;
|
||||
|
||||
for( i = 0, numdems = 0; i < t->numfilenames; i++ )
|
||||
int numdems = 0;
|
||||
for( int i = 0; i < t->numfilenames; i++ )
|
||||
{
|
||||
if( Q_stricmp( COM_FileExtension( t->filenames[i] ), "dem" ))
|
||||
continue;
|
||||
@@ -256,7 +249,7 @@ static qboolean Cmd_GetDemoList( const char *s, char *completedname, int length,
|
||||
// cut shortestMatch to the amount common with s
|
||||
if( completedname && length )
|
||||
{
|
||||
for( i = 0; matchbuf[i]; i++ )
|
||||
for( int i = 0; matchbuf[i]; i++ )
|
||||
{
|
||||
if( Q_tolower( completedname[i] ) != Q_tolower( matchbuf[i] ))
|
||||
completedname[i] = 0;
|
||||
@@ -274,11 +267,9 @@ Prints or complete movie filename
|
||||
*/
|
||||
static qboolean Cmd_GetMovieList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
int i, nummovies;
|
||||
string matchbuf;
|
||||
|
||||
t = FS_Search( va( "media/%s*.avi", s ), true, false );
|
||||
search_t *t = FS_Search( va( "media/%s*.avi", s ), true, false );
|
||||
if( !t ) return false;
|
||||
|
||||
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
|
||||
@@ -286,7 +277,8 @@ static qboolean Cmd_GetMovieList( const char *s, char *completedname, int length
|
||||
Q_strncpy( completedname, matchbuf, length );
|
||||
if( t->numfilenames == 1 ) return true;
|
||||
|
||||
for(i = 0, nummovies = 0; i < t->numfilenames; i++)
|
||||
int nummovies = 0;
|
||||
for( int i = 0; i < t->numfilenames; i++ )
|
||||
{
|
||||
if( Q_stricmp( COM_FileExtension( t->filenames[i] ), "avi" ))
|
||||
continue;
|
||||
@@ -304,7 +296,7 @@ static qboolean Cmd_GetMovieList( const char *s, char *completedname, int length
|
||||
// cut shortestMatch to the amount common with s
|
||||
if( completedname && length )
|
||||
{
|
||||
for( i = 0; matchbuf[i]; i++ )
|
||||
for( int i = 0; matchbuf[i]; i++ )
|
||||
{
|
||||
if( Q_tolower( completedname[i] ) != Q_tolower( matchbuf[i] ))
|
||||
completedname[i] = 0;
|
||||
@@ -323,11 +315,9 @@ Prints or complete background track filename
|
||||
*/
|
||||
static qboolean Cmd_GetMusicList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
int i, numtracks;
|
||||
string matchbuf;
|
||||
|
||||
t = FS_Search( va( "media/%s*.*", s ), true, false );
|
||||
search_t *t = FS_Search( va( "media/%s*.*", s ), true, false );
|
||||
if( !t ) return false;
|
||||
|
||||
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
|
||||
@@ -335,7 +325,8 @@ static qboolean Cmd_GetMusicList( const char *s, char *completedname, int length
|
||||
Q_strncpy( completedname, matchbuf, length );
|
||||
if( t->numfilenames == 1 ) return true;
|
||||
|
||||
for(i = 0, numtracks = 0; i < t->numfilenames; i++)
|
||||
int numtracks = 0;
|
||||
for( int i = 0; i < t->numfilenames; i++ )
|
||||
{
|
||||
const char *ext = COM_FileExtension( t->filenames[i] );
|
||||
|
||||
@@ -355,7 +346,7 @@ static qboolean Cmd_GetMusicList( const char *s, char *completedname, int length
|
||||
// cut shortestMatch to the amount common with s
|
||||
if( completedname && length )
|
||||
{
|
||||
for( i = 0; matchbuf[i]; i++ )
|
||||
for( int i = 0; matchbuf[i]; i++ )
|
||||
{
|
||||
if( Q_tolower( completedname[i] ) != Q_tolower( matchbuf[i] ))
|
||||
completedname[i] = 0;
|
||||
@@ -373,11 +364,9 @@ Prints or complete savegame filename
|
||||
*/
|
||||
static qboolean Cmd_GetSavesList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
int i, numsaves;
|
||||
string matchbuf;
|
||||
|
||||
t = FS_Search( va( DEFAULT_SAVE_DIRECTORY "%s*.sav", s ), true, true ); // lookup only in gamedir
|
||||
search_t *t = FS_Search( va( DEFAULT_SAVE_DIRECTORY "%s*.sav", s ), true, true ); // lookup only in gamedir
|
||||
if( !t ) return false;
|
||||
|
||||
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
|
||||
@@ -385,7 +374,8 @@ static qboolean Cmd_GetSavesList( const char *s, char *completedname, int length
|
||||
Q_strncpy( completedname, matchbuf, length );
|
||||
if( t->numfilenames == 1 ) return true;
|
||||
|
||||
for( i = 0, numsaves = 0; i < t->numfilenames; i++ )
|
||||
int numsaves = 0;
|
||||
for( int i = 0; i < t->numfilenames; i++ )
|
||||
{
|
||||
if( Q_stricmp( COM_FileExtension( t->filenames[i] ), "sav" ))
|
||||
continue;
|
||||
@@ -403,7 +393,7 @@ static qboolean Cmd_GetSavesList( const char *s, char *completedname, int length
|
||||
// cut shortestMatch to the amount common with s
|
||||
if( completedname && length )
|
||||
{
|
||||
for( i = 0; matchbuf[i]; i++ )
|
||||
for( int i = 0; matchbuf[i]; i++ )
|
||||
{
|
||||
if( Q_tolower( completedname[i] ) != Q_tolower( matchbuf[i] ))
|
||||
completedname[i] = 0;
|
||||
@@ -422,11 +412,9 @@ Prints or complete .cfg filename
|
||||
*/
|
||||
static qboolean Cmd_GetConfigList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
int i, numconfigs;
|
||||
string matchbuf;
|
||||
|
||||
t = FS_Search( va( "%s*.cfg", s ), true, false );
|
||||
search_t *t = FS_Search( va( "%s*.cfg", s ), true, false );
|
||||
if( !t ) return false;
|
||||
|
||||
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
|
||||
@@ -434,7 +422,8 @@ static qboolean Cmd_GetConfigList( const char *s, char *completedname, int lengt
|
||||
Q_strncpy( completedname, matchbuf, length );
|
||||
if( t->numfilenames == 1 ) return true;
|
||||
|
||||
for( i = 0, numconfigs = 0; i < t->numfilenames; i++ )
|
||||
int numconfigs = 0;
|
||||
for( int i = 0; i < t->numfilenames; i++ )
|
||||
{
|
||||
if( Q_stricmp( COM_FileExtension( t->filenames[i] ), "cfg" ))
|
||||
continue;
|
||||
@@ -452,7 +441,7 @@ static qboolean Cmd_GetConfigList( const char *s, char *completedname, int lengt
|
||||
// cut shortestMatch to the amount common with s
|
||||
if( completedname && length )
|
||||
{
|
||||
for( i = 0; matchbuf[i]; i++ )
|
||||
for( int i = 0; matchbuf[i]; i++ )
|
||||
{
|
||||
if( Q_tolower( completedname[i] ) != Q_tolower( matchbuf[i] ))
|
||||
completedname[i] = 0;
|
||||
@@ -471,11 +460,9 @@ Prints or complete sound filename
|
||||
*/
|
||||
static qboolean Cmd_GetSoundList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
int i, numsounds;
|
||||
string matchbuf;
|
||||
|
||||
t = FS_Search( va( "%s%s*.*", DEFAULT_SOUNDPATH, s ), true, false );
|
||||
search_t *t = FS_Search( va( "%s%s*.*", DEFAULT_SOUNDPATH, s ), true, false );
|
||||
if( !t ) return false;
|
||||
|
||||
Q_strncpy( matchbuf, t->filenames[0] + sizeof( DEFAULT_SOUNDPATH ) - 1, sizeof( matchbuf ));
|
||||
@@ -484,7 +471,8 @@ static qboolean Cmd_GetSoundList( const char *s, char *completedname, int length
|
||||
Q_strncpy( completedname, matchbuf, length );
|
||||
if( t->numfilenames == 1 ) return true;
|
||||
|
||||
for(i = 0, numsounds = 0; i < t->numfilenames; i++)
|
||||
int numsounds = 0;
|
||||
for( int i = 0; i < t->numfilenames; i++ )
|
||||
{
|
||||
const char *ext = COM_FileExtension( t->filenames[i] );
|
||||
|
||||
@@ -505,7 +493,7 @@ static qboolean Cmd_GetSoundList( const char *s, char *completedname, int length
|
||||
// cut shortestMatch to the amount common with s
|
||||
if( completedname && length )
|
||||
{
|
||||
for( i = 0; matchbuf[i]; i++ )
|
||||
for( int i = 0; matchbuf[i]; i++ )
|
||||
{
|
||||
if( Q_tolower( completedname[i] ) != Q_tolower( matchbuf[i] ))
|
||||
completedname[i] = 0;
|
||||
@@ -525,12 +513,10 @@ Prints or complete item classname (weapons only)
|
||||
static qboolean Cmd_GetItemsList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||
{
|
||||
#if !XASH_DEDICATED
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
int i, numitems;
|
||||
string matchbuf;
|
||||
|
||||
if( !clgame.itemspath[0] ) return false; // not in game yet
|
||||
t = FS_Search( va( "%s/%s*.txt", clgame.itemspath, s ), true, false );
|
||||
search_t *t = FS_Search( va( "%s/%s*.txt", clgame.itemspath, s ), true, false );
|
||||
if( !t ) return false;
|
||||
|
||||
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
|
||||
@@ -538,7 +524,8 @@ static qboolean Cmd_GetItemsList( const char *s, char *completedname, int length
|
||||
Q_strncpy( completedname, matchbuf, length );
|
||||
if( t->numfilenames == 1 ) return true;
|
||||
|
||||
for( i = 0, numitems = 0; i < t->numfilenames; i++ )
|
||||
int numitems = 0;
|
||||
for( int i = 0; i < t->numfilenames; i++ )
|
||||
{
|
||||
if( Q_stricmp( COM_FileExtension( t->filenames[i] ), "txt" ))
|
||||
continue;
|
||||
@@ -556,7 +543,7 @@ static qboolean Cmd_GetItemsList( const char *s, char *completedname, int length
|
||||
// cut shortestMatch to the amount common with s
|
||||
if( completedname && length )
|
||||
{
|
||||
for( i = 0; matchbuf[i]; i++ )
|
||||
for( int i = 0; matchbuf[i]; i++ )
|
||||
{
|
||||
if( Q_tolower( completedname[i] ) != Q_tolower( matchbuf[i] ))
|
||||
completedname[i] = 0;
|
||||
@@ -612,7 +599,6 @@ Autocomplete for bind command
|
||||
*/
|
||||
static qboolean Cmd_GetCommandsAndCvarsList( const char *s, char *completedname, int length, qboolean cmds, qboolean cvars, qboolean toggle, qboolean print_suggestions )
|
||||
{
|
||||
size_t i;
|
||||
string matchbuf;
|
||||
con_autocomplete_t list = { 0 }; // local autocomplete list
|
||||
|
||||
@@ -645,7 +631,7 @@ static qboolean Cmd_GetCommandsAndCvarsList( const char *s, char *completedname,
|
||||
|
||||
qsort( list.cmds, list.matchCount, sizeof( char* ), Con_SortCmds );
|
||||
|
||||
for( i = 0; i < list.matchCount; i++ )
|
||||
for( size_t i = 0; i < list.matchCount; i++ )
|
||||
{
|
||||
Q_strncpy( matchbuf, list.cmds[i], sizeof( matchbuf ));
|
||||
if( print_suggestions )
|
||||
@@ -657,14 +643,14 @@ static qboolean Cmd_GetCommandsAndCvarsList( const char *s, char *completedname,
|
||||
|
||||
if( completedname && length )
|
||||
{
|
||||
for( i = 0; matchbuf[i]; i++ )
|
||||
for( size_t i = 0; matchbuf[i]; i++ )
|
||||
{
|
||||
if( Q_tolower( completedname[i] ) != Q_tolower( matchbuf[i] ))
|
||||
completedname[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for( i = 0; i < list.matchCount; i++ )
|
||||
for( size_t i = 0; i < list.matchCount; i++ )
|
||||
{
|
||||
if( list.cmds[i] != NULL )
|
||||
{
|
||||
@@ -709,11 +695,9 @@ Prints or complete .HPK filenames
|
||||
*/
|
||||
static qboolean Cmd_GetCustomList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||
{
|
||||
search_t *t;
|
||||
string matchbuf;
|
||||
int i, numitems;
|
||||
string matchbuf;
|
||||
|
||||
t = FS_Search( va( "%s*.hpk", s ), true, false );
|
||||
search_t *t = FS_Search( va( "%s*.hpk", s ), true, false );
|
||||
if( !t ) return false;
|
||||
|
||||
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
|
||||
@@ -721,7 +705,8 @@ static qboolean Cmd_GetCustomList( const char *s, char *completedname, int lengt
|
||||
Q_strncpy( completedname, matchbuf, length );
|
||||
if( t->numfilenames == 1 ) return true;
|
||||
|
||||
for(i = 0, numitems = 0; i < t->numfilenames; i++)
|
||||
int numitems = 0;
|
||||
for( int i = 0; i < t->numfilenames; i++ )
|
||||
{
|
||||
if( Q_stricmp( COM_FileExtension( t->filenames[i] ), "hpk" ))
|
||||
continue;
|
||||
@@ -739,7 +724,7 @@ static qboolean Cmd_GetCustomList( const char *s, char *completedname, int lengt
|
||||
// cut shortestMatch to the amount common with s
|
||||
if( completedname && length )
|
||||
{
|
||||
for( i = 0; matchbuf[i]; i++ )
|
||||
for( int i = 0; matchbuf[i]; i++ )
|
||||
{
|
||||
if( Q_tolower( completedname[i] ) != Q_tolower( matchbuf[i] ))
|
||||
completedname[i] = 0;
|
||||
@@ -757,15 +742,14 @@ Prints or complete gamedir name
|
||||
*/
|
||||
static qboolean Cmd_GetGamesList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||
{
|
||||
int i, numgamedirs;
|
||||
string gamedirs[MAX_MODS];
|
||||
string matchbuf;
|
||||
int len;
|
||||
string gamedirs[MAX_MODS];
|
||||
string matchbuf;
|
||||
|
||||
// compare gamelist with current keyword
|
||||
len = Q_strlen( s );
|
||||
int len = Q_strlen( s );
|
||||
|
||||
for( i = 0, numgamedirs = 0; i < FI->numgames; i++ )
|
||||
int numgamedirs = 0;
|
||||
for( int i = 0; i < FI->numgames; i++ )
|
||||
{
|
||||
if(( *s == '*' ) || !Q_strnicmp( FI->games[i]->gamefolder, s, len))
|
||||
Q_strncpy( gamedirs[numgamedirs++], FI->games[i]->gamefolder, sizeof( gamedirs[0] ));
|
||||
@@ -777,7 +761,7 @@ static qboolean Cmd_GetGamesList( const char *s, char *completedname, int length
|
||||
Q_strncpy( completedname, matchbuf, length );
|
||||
if( numgamedirs == 1 ) return true;
|
||||
|
||||
for( i = 0; i < numgamedirs; i++ )
|
||||
for( int i = 0; i < numgamedirs; i++ )
|
||||
{
|
||||
Q_strncpy( matchbuf, gamedirs[i], sizeof( matchbuf ));
|
||||
if( print_suggestions )
|
||||
@@ -790,7 +774,7 @@ static qboolean Cmd_GetGamesList( const char *s, char *completedname, int length
|
||||
// cut shortestMatch to the amount common with s
|
||||
if( completedname && length )
|
||||
{
|
||||
for( i = 0; matchbuf[i]; i++ )
|
||||
for( int i = 0; matchbuf[i]; i++ )
|
||||
{
|
||||
if( Q_tolower( completedname[i] ) != Q_tolower( matchbuf[i] ))
|
||||
completedname[i] = 0;
|
||||
@@ -808,10 +792,8 @@ Prints or complete CD command name
|
||||
*/
|
||||
static qboolean Cmd_GetCDList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||
{
|
||||
int i, numcdcommands;
|
||||
string cdcommands[8];
|
||||
string matchbuf;
|
||||
int len;
|
||||
string cdcommands[8];
|
||||
string matchbuf;
|
||||
|
||||
const char *cd_command[] =
|
||||
{
|
||||
@@ -826,9 +808,10 @@ static qboolean Cmd_GetCDList( const char *s, char *completedname, int length, q
|
||||
};
|
||||
|
||||
// compare CD command list with current keyword
|
||||
len = Q_strlen( s );
|
||||
int len = Q_strlen( s );
|
||||
|
||||
for( i = 0, numcdcommands = 0; i < 8; i++ )
|
||||
int numcdcommands = 0;
|
||||
for( int i = 0; i < 8; i++ )
|
||||
{
|
||||
if(( *s == '*' ) || !Q_strnicmp( cd_command[i], s, len))
|
||||
Q_strncpy( cdcommands[numcdcommands++], cd_command[i], sizeof( cdcommands[0] ));
|
||||
@@ -840,7 +823,7 @@ static qboolean Cmd_GetCDList( const char *s, char *completedname, int length, q
|
||||
Q_strncpy( completedname, matchbuf, length );
|
||||
if( numcdcommands == 1 ) return true;
|
||||
|
||||
for( i = 0; i < numcdcommands; i++ )
|
||||
for( int i = 0; i < numcdcommands; i++ )
|
||||
{
|
||||
Q_strncpy( matchbuf, cdcommands[i], sizeof( matchbuf ));
|
||||
if( print_suggestions )
|
||||
@@ -853,7 +836,7 @@ static qboolean Cmd_GetCDList( const char *s, char *completedname, int length, q
|
||||
// cut shortestMatch to the amount common with s
|
||||
if( completedname && length )
|
||||
{
|
||||
for( i = 0; matchbuf[i]; i++ )
|
||||
for( int i = 0; matchbuf[i]; i++ )
|
||||
{
|
||||
if( Q_tolower( completedname[i] ) != Q_tolower( matchbuf[i] ))
|
||||
completedname[i] = 0;
|
||||
@@ -864,21 +847,15 @@ static qboolean Cmd_GetCDList( const char *s, char *completedname, int length, q
|
||||
|
||||
static qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
|
||||
{
|
||||
qboolean use_filter = false;
|
||||
string mpfilter;
|
||||
char *buffer;
|
||||
size_t buffersize;
|
||||
string result;
|
||||
int i, size;
|
||||
search_t *t;
|
||||
file_t *f;
|
||||
string mpfilter;
|
||||
string result;
|
||||
|
||||
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 );
|
||||
search_t *t = FS_Search( "maps/*.bsp", false, onlyingamedir );
|
||||
|
||||
if( !t )
|
||||
{
|
||||
@@ -890,11 +867,11 @@ static qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
|
||||
return false;
|
||||
}
|
||||
|
||||
buffersize = t->numfilenames * 2 * sizeof( result );
|
||||
buffer = Mem_Calloc( host.mempool, buffersize );
|
||||
use_filter = !COM_StringEmpty( GI->mp_filter );
|
||||
size_t buffersize = t->numfilenames * 2 * sizeof( result );
|
||||
char *buffer = Mem_Calloc( host.mempool, buffersize );
|
||||
qboolean use_filter = !COM_StringEmpty( GI->mp_filter );
|
||||
|
||||
for( i = 0; i < t->numfilenames; i++ )
|
||||
for( int i = 0; i < t->numfilenames; i++ )
|
||||
{
|
||||
char *ents = NULL, *pfile;
|
||||
int lumpofs = 0, lumplen = 0;
|
||||
@@ -906,17 +883,16 @@ static qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
|
||||
if( use_filter && Q_stristr( t->filenames[i], mpfilter ))
|
||||
continue;
|
||||
|
||||
f = FS_Open( t->filenames[i], "rb", onlyingamedir );
|
||||
file_t *f = FS_Open( t->filenames[i], "rb", onlyingamedir );
|
||||
COM_FileBase( t->filenames[i], mapname, sizeof( mapname ));
|
||||
|
||||
if( f )
|
||||
{
|
||||
qboolean have_spawnpoints = false;
|
||||
dlump_t entities;
|
||||
fs_offset_t filelen;
|
||||
byte buf[MAX_SYSPATH] = { 0 };
|
||||
|
||||
filelen = FS_Read( f, buf, MAX_SYSPATH );
|
||||
fs_offset_t filelen = FS_Read( f, buf, MAX_SYSPATH );
|
||||
|
||||
// check all the lumps and some other errors
|
||||
if( !Mod_TestBmodelLumps( f, t->filenames[i], buf, filelen, true, &entities ))
|
||||
@@ -999,7 +975,7 @@ static qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
|
||||
}
|
||||
|
||||
if( t ) Mem_Free( t ); // free search result
|
||||
size = Q_strlen( buffer );
|
||||
int size = Q_strlen( buffer );
|
||||
|
||||
if( !size )
|
||||
{
|
||||
@@ -1102,9 +1078,7 @@ for various cmds
|
||||
*/
|
||||
static qboolean Cmd_AutocompleteName( const char *source, int arg, char *buffer, size_t bufsize, qboolean print_suggestions )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( cmd_list ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( cmd_list ); i++ )
|
||||
{
|
||||
if( cmd_list[i].arg == arg && Cmd_CheckName( cmd_list[i].name ))
|
||||
return cmd_list[i].func( source, buffer, bufsize, print_suggestions );
|
||||
@@ -1150,14 +1124,11 @@ Con_ConcatRemaining
|
||||
*/
|
||||
static void Con_ConcatRemaining( const char *src, const char *start )
|
||||
{
|
||||
const char *arg;
|
||||
int i;
|
||||
|
||||
arg = Q_strstr( src, start );
|
||||
const char *arg = Q_strstr( src, start );
|
||||
|
||||
if( !arg )
|
||||
{
|
||||
for( i = 1; i < Cmd_Argc(); i++ )
|
||||
for( int i = 1; i < Cmd_Argc(); i++ )
|
||||
{
|
||||
Q_strncat( con.completionField->buffer, " ", sizeof( con.completionField->buffer ) );
|
||||
arg = Cmd_Argv( i );
|
||||
@@ -1190,11 +1161,7 @@ perform Tab expansion
|
||||
*/
|
||||
void Con_CompleteCommand( field_t *field, qboolean print_suggestions )
|
||||
{
|
||||
field_t temp;
|
||||
string filename;
|
||||
qboolean toggle = false;
|
||||
qboolean nextcmd;
|
||||
int i;
|
||||
|
||||
// setup the completion field
|
||||
con.completionField = field;
|
||||
@@ -1205,7 +1172,7 @@ void Con_CompleteCommand( field_t *field, qboolean print_suggestions )
|
||||
// only look at the first token for completion purposes
|
||||
Cmd_TokenizeString( con.completionField->buffer );
|
||||
|
||||
nextcmd = (con.completionField->buffer[Q_strlen( con.completionField->buffer ) - 1] == ' ') ? true : false;
|
||||
qboolean nextcmd = (con.completionField->buffer[Q_strlen( con.completionField->buffer ) - 1] == ' ') ? true : false;
|
||||
|
||||
con.completionString = Cmd_Argv( 0 );
|
||||
|
||||
@@ -1217,7 +1184,7 @@ void Con_CompleteCommand( field_t *field, qboolean print_suggestions )
|
||||
return;
|
||||
|
||||
// free the old autocomplete list
|
||||
for( i = 0; i < con.matchCount; i++ )
|
||||
for( int i = 0; i < con.matchCount; i++ )
|
||||
{
|
||||
if( con.cmds[i] != NULL )
|
||||
{
|
||||
@@ -1235,7 +1202,7 @@ void Con_CompleteCommand( field_t *field, qboolean print_suggestions )
|
||||
|
||||
if( !con.matchCount ) return; // no matches
|
||||
|
||||
temp = *con.completionField;
|
||||
field_t temp = *con.completionField;
|
||||
|
||||
// autocomplete second arg
|
||||
if(( Cmd_Argc() >= 2 ) || ( Cmd_Argc() == 1 && nextcmd ))
|
||||
@@ -1249,11 +1216,12 @@ void Con_CompleteCommand( field_t *field, qboolean print_suggestions )
|
||||
if( COM_StringEmpty( con.completionBuffer ) )
|
||||
return;
|
||||
|
||||
string filename;
|
||||
if( Cmd_AutocompleteName( con.completionBuffer, Cmd_Argc() - 1, filename, sizeof( filename ), print_suggestions ))
|
||||
{
|
||||
con.completionField->buffer[0] = 0;
|
||||
|
||||
for( i = 0; i < Cmd_Argc() - 1; i++ )
|
||||
for( int i = 0; i < Cmd_Argc() - 1; i++ )
|
||||
{
|
||||
Q_strncat( con.completionField->buffer, Cmd_Argv( i ), sizeof( con.completionField->buffer ));
|
||||
Q_strncat( con.completionField->buffer, " ", sizeof( con.completionField->buffer ));
|
||||
@@ -1320,12 +1288,11 @@ NOTE: input string must be equal or longer than MAX_STRING
|
||||
*/
|
||||
void Cmd_AutoComplete( char *complete_string )
|
||||
{
|
||||
field_t input;
|
||||
|
||||
if( !complete_string || !*complete_string )
|
||||
return;
|
||||
|
||||
// setup input
|
||||
field_t input;
|
||||
Q_strncpy( input.buffer, complete_string, sizeof( input.buffer ) );
|
||||
input.cursor = input.scroll = 0;
|
||||
|
||||
@@ -1345,10 +1312,8 @@ Cmd_AutoCompleteClear
|
||||
*/
|
||||
void Cmd_AutoCompleteClear( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
// free the old autocomplete list
|
||||
for( i = 0; i < con.matchCount; i++ )
|
||||
for( int i = 0; i < con.matchCount; i++ )
|
||||
{
|
||||
if( con.cmds[i] != NULL )
|
||||
{
|
||||
@@ -1377,15 +1342,13 @@ static void Cmd_WriteOpenGLCvar( const char *name, const char *string, const cha
|
||||
|
||||
static void Cmd_WriteHelp(const char *name, const char *unused, const char *desc, void *f )
|
||||
{
|
||||
int length;
|
||||
|
||||
if( COM_StringEmptyOrNULL( desc ))
|
||||
return; // ignore fantom cmds
|
||||
|
||||
if( name[0] == '+' || name[0] == '-' )
|
||||
return; // key bindings
|
||||
|
||||
length = 3 - (Q_strlen( name ) / 10); // Asm_Ed default tab stop is 10
|
||||
int length = 3 - (Q_strlen( name ) / 10); // Asm_Ed default tab stop is 10
|
||||
|
||||
if( length == 3 ) FS_Printf( f, "%s\t\t\t\"%s\"\n", name, desc );
|
||||
if( length == 2 ) FS_Printf( f, "%s\t\t\"%s\"\n", name, desc );
|
||||
@@ -1431,14 +1394,13 @@ Writes key bindings and archived cvars to config.cfg
|
||||
*/
|
||||
void Host_WriteConfig( void )
|
||||
{
|
||||
kbutton_t *mlook = NULL;
|
||||
kbutton_t *jlook = NULL;
|
||||
file_t *f;
|
||||
kbutton_t *mlook = NULL;
|
||||
kbutton_t *jlook = NULL;
|
||||
|
||||
if( !clgame.hInstance || Sys_CheckParm( "-nowriteconfig" ) ) return;
|
||||
|
||||
|
||||
f = FS_Open( "config.cfg.new", "w", false );
|
||||
file_t *f = FS_Open( "config.cfg.new", "w", false );
|
||||
if( f )
|
||||
{
|
||||
Con_Reportf( "%s()\n", __func__ );
|
||||
@@ -1479,11 +1441,11 @@ save serverinfo variables into server.cfg (using for dedicated server too)
|
||||
*/
|
||||
void GAME_EXPORT Host_WriteServerConfig( const char *name )
|
||||
{
|
||||
file_t *f;
|
||||
string newconfigfile;
|
||||
|
||||
Q_snprintf( newconfigfile, MAX_STRING, "%s.new", name );
|
||||
|
||||
file_t *f;
|
||||
if(( f = FS_Open( newconfigfile, "w", false )) != NULL )
|
||||
{
|
||||
Host_InitializeConfig( f, "game.cfg", "multiplayer server temporary config" );
|
||||
@@ -1504,21 +1466,18 @@ save opengl variables into opengl.cfg
|
||||
*/
|
||||
void Host_WriteOpenGLConfig( void )
|
||||
{
|
||||
const char *config_name;
|
||||
string name;
|
||||
file_t *f;
|
||||
|
||||
if( Sys_CheckParm( "-nowriteconfig" ) || !ref.dllFuncs.R_GetConfigName )
|
||||
return;
|
||||
|
||||
config_name = ref.dllFuncs.R_GetConfigName();
|
||||
const char *config_name = ref.dllFuncs.R_GetConfigName();
|
||||
|
||||
if( !config_name )
|
||||
return;
|
||||
|
||||
string name;
|
||||
Q_snprintf( name, sizeof( name ), "%s.cfg", config_name );
|
||||
|
||||
f = FS_Open( va( "%s.new", name ), "w", false );
|
||||
file_t *f = FS_Open( va( "%s.new", name ), "w", false );
|
||||
if( f )
|
||||
{
|
||||
Con_Reportf( "%s()\n", __func__ );
|
||||
@@ -1539,12 +1498,10 @@ save render variables into video.cfg
|
||||
*/
|
||||
void Host_WriteVideoConfig( void )
|
||||
{
|
||||
file_t *f;
|
||||
|
||||
if( Sys_CheckParm( "-nowriteconfig" ) )
|
||||
return;
|
||||
|
||||
f = FS_Open( "video.cfg.new", "w", false );
|
||||
file_t *f = FS_Open( "video.cfg.new", "w", false );
|
||||
if( f )
|
||||
{
|
||||
Con_Reportf( "%s()\n", __func__ );
|
||||
@@ -1558,8 +1515,6 @@ void Host_WriteVideoConfig( void )
|
||||
|
||||
void Key_EnumCmds_f( void )
|
||||
{
|
||||
file_t *f;
|
||||
|
||||
FS_AllowDirectPaths( true );
|
||||
if( FS_FileExists( "../help.txt", false ))
|
||||
{
|
||||
@@ -1568,7 +1523,7 @@ void Key_EnumCmds_f( void )
|
||||
return;
|
||||
}
|
||||
|
||||
f = FS_Open( "../help.txt", "w", false );
|
||||
file_t *f = FS_Open( "../help.txt", "w", false );
|
||||
if( f )
|
||||
{
|
||||
Host_InitializeConfig( f, "help.txt", "xash commands and console variables" );
|
||||
|
||||
@@ -51,10 +51,9 @@ static qboolean CustomDecal_Validate( const char *path, void *raw, int nFileSize
|
||||
|
||||
void COM_ClearCustomizationList( customization_t *pHead, qboolean bCleanDecals )
|
||||
{
|
||||
customization_t *pCurrent;
|
||||
customization_t *pNext;
|
||||
|
||||
for( pCurrent = pHead->pNext; pCurrent != NULL; pCurrent = pNext )
|
||||
for( customization_t *pCurrent = pHead->pNext; pCurrent != NULL; pCurrent = pNext )
|
||||
{
|
||||
pNext = pCurrent->pNext;
|
||||
|
||||
@@ -82,12 +81,10 @@ void COM_ClearCustomizationList( customization_t *pHead, qboolean bCleanDecals )
|
||||
qboolean COM_CreateCustomization( customization_t *pListHead, resource_t *pResource, int playernumber, int flags, customization_t **pOut, int *nLumps )
|
||||
{
|
||||
qboolean bError = false;
|
||||
fs_offset_t checksize = 0;
|
||||
customization_t *pCust;
|
||||
|
||||
if( pOut ) *pOut = NULL;
|
||||
|
||||
pCust = Z_Calloc( sizeof( customization_t ));
|
||||
customization_t *pCust = Z_Calloc( sizeof( customization_t ));
|
||||
pCust->resource = *pResource;
|
||||
|
||||
if( pResource->nDownloadSize <= 0 )
|
||||
@@ -102,7 +99,7 @@ qboolean COM_CreateCustomization( customization_t *pListHead, resource_t *pResou
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
fs_offset_t checksize = 0;
|
||||
pCust->pBuffer = FS_LoadFile( pResource->szFileName, &checksize, true );
|
||||
if( (int)checksize != pCust->resource.nDownloadSize )
|
||||
bError = true;
|
||||
@@ -158,11 +155,10 @@ CustomizationError:
|
||||
int COM_SizeofResourceList( resource_t *pList, resourceinfo_t *ri )
|
||||
{
|
||||
int nSize = 0;
|
||||
resource_t *p;
|
||||
|
||||
memset( ri, 0, sizeof( *ri ));
|
||||
|
||||
for( p = pList->pNext; p != pList; p = p->pNext )
|
||||
for( resource_t *p = pList->pNext; p != pList; p = p->pNext )
|
||||
{
|
||||
nSize += p->nDownloadSize;
|
||||
|
||||
|
||||
@@ -70,12 +70,10 @@ find the specified variable by name
|
||||
*/
|
||||
convar_t *Cvar_FindVar( const char *var_name )
|
||||
{
|
||||
convar_t *var;
|
||||
|
||||
if( !var_name )
|
||||
return NULL;
|
||||
|
||||
var = BaseCmd_Find( HM_CVAR, var_name );
|
||||
convar_t *var = BaseCmd_Find( HM_CVAR, var_name );
|
||||
|
||||
// HACKHACK: HL25 compatibility
|
||||
if( !var && !Q_stricmp( var_name, "gl_widescreen_yfov" ))
|
||||
@@ -190,10 +188,9 @@ deal with userinfo etc
|
||||
*/
|
||||
static const char *Cvar_ValidateString( convar_t *var, const char *value )
|
||||
{
|
||||
const char *pszValue;
|
||||
static char szNew[MAX_STRING];
|
||||
const char *pszValue = value;
|
||||
|
||||
pszValue = value;
|
||||
szNew[0] = 0;
|
||||
|
||||
// this cvar's string must only contain printable characters.
|
||||
@@ -283,14 +280,11 @@ unlink the variable
|
||||
static int Cvar_UnlinkVar( const char *var_name, uint32_t group )
|
||||
{
|
||||
int count = 0;
|
||||
convar_t **prev;
|
||||
convar_t *var;
|
||||
|
||||
prev = &cvar_vars;
|
||||
convar_t **prev = &cvar_vars;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
var = *prev;
|
||||
convar_t *var = *prev;
|
||||
if( !var ) break;
|
||||
|
||||
// do filter by name
|
||||
@@ -358,13 +352,11 @@ Cvar_LookupVars
|
||||
*/
|
||||
void Cvar_LookupVars( int checkbit, void *buffer, void *ptr, setpair_t callback )
|
||||
{
|
||||
convar_t *var;
|
||||
|
||||
// nothing to process ?
|
||||
if( !callback ) return;
|
||||
|
||||
// force checkbit to 0 for lookup all cvars
|
||||
for( var = cvar_vars; var; var = var->next )
|
||||
for( convar_t *var = cvar_vars; var; var = var->next )
|
||||
{
|
||||
if( checkbit && !FBitSet( var->flags, checkbit ))
|
||||
continue;
|
||||
@@ -627,8 +619,6 @@ Cvar_Set2
|
||||
*/
|
||||
static convar_t *Cvar_Set2( const char *var_name, const char *value )
|
||||
{
|
||||
convar_t *var;
|
||||
qboolean dll_variable = false;
|
||||
qboolean force = false;
|
||||
|
||||
if( !Cvar_ValidateVarName( var_name, false ))
|
||||
@@ -637,7 +627,7 @@ static convar_t *Cvar_Set2( const char *var_name, const char *value )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
var = Cvar_FindVar( var_name );
|
||||
convar_t *var = Cvar_FindVar( var_name );
|
||||
if( !var )
|
||||
{
|
||||
// if cvar not found, create it
|
||||
@@ -663,7 +653,7 @@ static convar_t *Cvar_Set2( const char *var_name, const char *value )
|
||||
|
||||
// use this check to prevent acessing for unexisting fields
|
||||
// for cvar_t: latched_string, description, etc
|
||||
dll_variable = FBitSet( var->flags, FCVAR_EXTDLL );
|
||||
qboolean dll_variable = FBitSet( var->flags, FCVAR_EXTDLL );
|
||||
|
||||
// check value
|
||||
if( !value )
|
||||
@@ -782,8 +772,6 @@ Cvar_Set
|
||||
*/
|
||||
void GAME_EXPORT Cvar_Set( const char *var_name, const char *value )
|
||||
{
|
||||
convar_t *var;
|
||||
|
||||
if( !var_name )
|
||||
{
|
||||
// there is an error in C code if this happens
|
||||
@@ -791,7 +779,7 @@ void GAME_EXPORT Cvar_Set( const char *var_name, const char *value )
|
||||
return;
|
||||
}
|
||||
|
||||
var = Cvar_FindVar( var_name );
|
||||
convar_t *var = Cvar_FindVar( var_name );
|
||||
|
||||
if( !var )
|
||||
{
|
||||
@@ -836,8 +824,6 @@ Cvar_VariableValue
|
||||
*/
|
||||
float GAME_EXPORT Cvar_VariableValue( const char *var_name )
|
||||
{
|
||||
convar_t *var;
|
||||
|
||||
if( !var_name )
|
||||
{
|
||||
// there is an error in C code if this happens
|
||||
@@ -845,7 +831,7 @@ float GAME_EXPORT Cvar_VariableValue( const char *var_name )
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
var = Cvar_FindVar( var_name );
|
||||
convar_t *var = Cvar_FindVar( var_name );
|
||||
if( !var ) return 0.0f;
|
||||
|
||||
return Q_atof( var->string );
|
||||
@@ -858,9 +844,7 @@ Cvar_VariableInteger
|
||||
*/
|
||||
int Cvar_VariableInteger( const char *var_name )
|
||||
{
|
||||
convar_t *var;
|
||||
|
||||
var = Cvar_FindVar( var_name );
|
||||
convar_t *var = Cvar_FindVar( var_name );
|
||||
if( !var ) return 0;
|
||||
|
||||
return Q_atoi( var->string );
|
||||
@@ -873,8 +857,6 @@ Cvar_VariableString
|
||||
*/
|
||||
const char *Cvar_VariableString( const char *var_name )
|
||||
{
|
||||
convar_t *var;
|
||||
|
||||
if( !var_name )
|
||||
{
|
||||
// there is an error in C code if this happens
|
||||
@@ -882,7 +864,7 @@ const char *Cvar_VariableString( const char *var_name )
|
||||
return "";
|
||||
}
|
||||
|
||||
var = Cvar_FindVar( var_name );
|
||||
convar_t *var = Cvar_FindVar( var_name );
|
||||
if( !var ) return "";
|
||||
|
||||
return var->string;
|
||||
@@ -909,10 +891,8 @@ Any testing variables will be reset to the safe values
|
||||
*/
|
||||
void Cvar_SetCheatState( void )
|
||||
{
|
||||
convar_t *var;
|
||||
|
||||
// set all default vars to the safe value
|
||||
for( var = cvar_vars; var; var = var->next )
|
||||
for( convar_t *var = cvar_vars; var; var = var->next )
|
||||
{
|
||||
// can't process dll cvars - missed def_string
|
||||
if( !FBitSet( var->flags, FCVAR_ALLOCATED|FCVAR_EXTENDED ))
|
||||
@@ -959,7 +939,6 @@ static int ShouldSetCvar_splitstr_handler( char *prev, char *next, void *userdat
|
||||
static qboolean Cvar_ShouldSetCvar( convar_t *v, qboolean isPrivileged )
|
||||
{
|
||||
const char *prefixes[] = { "cl_", "gl_", "m_", "r_", "hud_", "joy_", "con_", "scr_" };
|
||||
int i;
|
||||
|
||||
if( isPrivileged )
|
||||
return true;
|
||||
@@ -981,7 +960,7 @@ static qboolean Cvar_ShouldSetCvar( convar_t *v, qboolean isPrivileged )
|
||||
if( FBitSet( v->flags, FCVAR_FILTERABLE ))
|
||||
return false;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( prefixes ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( prefixes ); i++ )
|
||||
{
|
||||
if( !Q_strnicmp( v->name, prefixes[i], Q_strlen( prefixes[i] )))
|
||||
return false;
|
||||
@@ -1046,9 +1025,7 @@ with the specified flag set to true.
|
||||
*/
|
||||
void Cvar_WriteVariables( file_t *f, int group )
|
||||
{
|
||||
convar_t *var;
|
||||
|
||||
for( var = cvar_vars; var; var = var->next )
|
||||
for( convar_t *var = cvar_vars; var; var = var->next )
|
||||
{
|
||||
if( FBitSet( var->flags, group ))
|
||||
FS_Printf( f, "%s \"%s\"\n", var->name, var->string );
|
||||
@@ -1064,15 +1041,13 @@ Toggles a cvar for easy single key binding
|
||||
*/
|
||||
static void Cvar_Toggle_f( void )
|
||||
{
|
||||
int v;
|
||||
|
||||
if( Cmd_Argc() != 2 )
|
||||
{
|
||||
Con_Printf( S_USAGE "toggle <variable>\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
v = !Cvar_VariableInteger( Cmd_Argv( 1 ));
|
||||
int v = !Cvar_VariableInteger( Cmd_Argv( 1 ));
|
||||
|
||||
Cvar_Set( Cmd_Argv( 1 ), v ? "1" : "0" );
|
||||
}
|
||||
@@ -1087,10 +1062,10 @@ weren't declared in C code.
|
||||
*/
|
||||
static void Cvar_Set_f( void )
|
||||
{
|
||||
int i, c, l = 0, len;
|
||||
char combined[MAX_CMD_TOKENS];
|
||||
int l = 0;
|
||||
|
||||
c = Cmd_Argc();
|
||||
int c = Cmd_Argc();
|
||||
if( c < 3 )
|
||||
{
|
||||
Msg( S_USAGE "set <variable> <value>\n" );
|
||||
@@ -1098,9 +1073,9 @@ static void Cvar_Set_f( void )
|
||||
}
|
||||
combined[0] = 0;
|
||||
|
||||
for( i = 2; i < c; i++ )
|
||||
for( int i = 2; i < c; i++ )
|
||||
{
|
||||
len = Q_strlen( Cmd_Argv(i) + 1 );
|
||||
int len = Q_strlen( Cmd_Argv(i) + 1 );
|
||||
if( l + len >= MAX_CMD_TOKENS - 2 )
|
||||
break;
|
||||
Q_strncat( combined, Cmd_Argv( i ), sizeof( combined ));
|
||||
@@ -1134,7 +1109,6 @@ Cvar_List_f
|
||||
*/
|
||||
static void Cvar_List_f( void )
|
||||
{
|
||||
convar_t *var;
|
||||
const char *match = NULL;
|
||||
int count = 0;
|
||||
size_t matchlen = 0;
|
||||
@@ -1145,10 +1119,9 @@ static void Cvar_List_f( void )
|
||||
matchlen = Q_strlen( match );
|
||||
}
|
||||
|
||||
for( var = cvar_vars; var; var = var->next )
|
||||
for( convar_t *var = cvar_vars; var; var = var->next )
|
||||
{
|
||||
char value[MAX_VA_STRING];
|
||||
char *p;
|
||||
|
||||
if( var->name[0] == '@' )
|
||||
continue; // never shows system cvars
|
||||
@@ -1156,7 +1129,7 @@ static void Cvar_List_f( void )
|
||||
if( match && !Q_strnicmpext( match, var->name, matchlen ))
|
||||
continue;
|
||||
|
||||
p = Q_strchr( var->string, '^' );
|
||||
char *p = Q_strchr( var->string, '^' );
|
||||
|
||||
if( IsColorString( p ))
|
||||
Q_snprintf( value, sizeof( value ), "\"%s\"", var->string );
|
||||
@@ -1195,12 +1168,10 @@ unlink all cvars with specified flag
|
||||
*/
|
||||
void Cvar_Unlink( uint32_t group )
|
||||
{
|
||||
int count;
|
||||
|
||||
if( !Cvar_ValidateUnlinkGroup( group ))
|
||||
return;
|
||||
|
||||
count = Cvar_UnlinkVar( NULL, group );
|
||||
int count = Cvar_UnlinkVar( NULL, group );
|
||||
Con_Reportf( "unlink %i cvars\n", count );
|
||||
}
|
||||
|
||||
@@ -1208,18 +1179,14 @@ pending_cvar_t *Cvar_PrepareToUnlink( uint32_t group )
|
||||
{
|
||||
pending_cvar_t *list = NULL;
|
||||
pending_cvar_t *tail = NULL;
|
||||
convar_t *cv;
|
||||
|
||||
for( cv = cvar_vars; cv != NULL; cv = cv->next )
|
||||
for( convar_t *cv = cvar_vars; cv != NULL; cv = cv->next )
|
||||
{
|
||||
size_t namelen;
|
||||
pending_cvar_t *p;
|
||||
|
||||
if( !FBitSet( cv->flags, group ))
|
||||
continue;
|
||||
|
||||
namelen = Q_strlen( cv->name ) + 1;
|
||||
p = Mem_Malloc( cvar_pool, sizeof( *list ) + namelen );
|
||||
size_t namelen = Q_strlen( cv->name ) + 1;
|
||||
pending_cvar_t *p = Mem_Malloc( cvar_pool, sizeof( *list ) + namelen );
|
||||
p->next = NULL;
|
||||
p->cv_cur = cv;
|
||||
p->cv_next = cv->next;
|
||||
@@ -1320,9 +1287,7 @@ Cvar_PostFSInit
|
||||
*/
|
||||
void Cvar_PostFSInit( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( cvar_filter_quirks ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( cvar_filter_quirks ); i++ )
|
||||
{
|
||||
if( !Q_stricmp( cvar_filter_quirks[i].gamedir, GI->gamefolder ))
|
||||
{
|
||||
|
||||
@@ -35,9 +35,7 @@ const char *CL_MsgInfo( int cmd )
|
||||
}
|
||||
else if( cmd > svc_lastmsg && cmd <= ( svc_lastmsg + MAX_USER_MESSAGES ))
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < MAX_USER_MESSAGES; i++ )
|
||||
for( int i = 0; i < MAX_USER_MESSAGES; i++ )
|
||||
{
|
||||
if( svgame.msg[i].number == cmd )
|
||||
{
|
||||
|
||||
@@ -70,9 +70,7 @@ byte *FS_LoadDirectFile( const char *path, fs_offset_t *filesizeptr )
|
||||
|
||||
static void COM_StripDirectorySlash( char *pname )
|
||||
{
|
||||
size_t len;
|
||||
|
||||
len = Q_strlen( pname );
|
||||
size_t len = Q_strlen( pname );
|
||||
if( len > 0 && pname[len - 1] == '/' )
|
||||
pname[len - 1] = 0;
|
||||
}
|
||||
@@ -128,7 +126,6 @@ static void FS_LoadVFSConfig( const char *gamedir )
|
||||
|
||||
void FS_SaveVFSConfig( void )
|
||||
{
|
||||
file_t *f;
|
||||
const qboolean force_save = !FS_FileExists( "vfs.cfg", true );
|
||||
|
||||
if( !force_save && !FBitSet( fs_mount_hd.flags|fs_mount_lv.flags|fs_mount_l10n.flags|fs_mount_addon.flags|ui_language.flags, FCVAR_CHANGED ))
|
||||
@@ -139,7 +136,7 @@ void FS_SaveVFSConfig( void )
|
||||
|
||||
Con_Printf( "%s()\n", __func__ );
|
||||
|
||||
f = FS_Open( "vfs.cfg.new", "w", true );
|
||||
file_t *f = FS_Open( "vfs.cfg.new", "w", true );
|
||||
if( !f )
|
||||
{
|
||||
Con_Printf( S_ERROR "%s: can't open %s for write\n", __func__, "vfs.cfg.new" );
|
||||
@@ -219,7 +216,6 @@ static void FS_UnloadProgs( void )
|
||||
static qboolean FS_LoadProgs( void )
|
||||
{
|
||||
const char *name = FILESYSTEM_STDIO_DLL;
|
||||
FSAPI GetFSAPI;
|
||||
|
||||
fs_hInstance = COM_LoadLibrary( name, false, true );
|
||||
|
||||
@@ -229,6 +225,7 @@ static qboolean FS_LoadProgs( void )
|
||||
return false;
|
||||
}
|
||||
|
||||
FSAPI GetFSAPI;
|
||||
if( !( GetFSAPI = (FSAPI)COM_GetProcAddress( fs_hInstance, GET_FS_API )))
|
||||
{
|
||||
FS_UnloadProgs();
|
||||
|
||||
@@ -121,7 +121,6 @@ static void Host_MakeVersionString( char *out, size_t len )
|
||||
static void Host_PrintUsage( const char *exename )
|
||||
{
|
||||
string version_str;
|
||||
const char *usage_str;
|
||||
|
||||
Host_MakeVersionString( version_str, sizeof( version_str ));
|
||||
|
||||
@@ -136,7 +135,7 @@ static void Host_PrintUsage( const char *exename )
|
||||
#endif
|
||||
#define O( x, y ) " "x" "y"\n"
|
||||
|
||||
usage_str = S_USAGE XASH_EXE " [options] [+command] [+command2 arg] ...\n"
|
||||
const char *usage_str = S_USAGE XASH_EXE " [options] [+command] [+command2 arg] ...\n"
|
||||
|
||||
"\nCommon options:\n"
|
||||
O("-dev [level] ", "set log verbosity 0-2")
|
||||
@@ -235,12 +234,11 @@ static void Host_PrintBugcompUsage( const char *exename )
|
||||
string version_str;
|
||||
char usage_str[4096];
|
||||
char *p = usage_str;
|
||||
int i;
|
||||
|
||||
Host_MakeVersionString( version_str, sizeof( version_str ));
|
||||
|
||||
p += Q_snprintf( p, sizeof( usage_str ) - ( usage_str - p ), "Known bugcomp flags are:\n" );
|
||||
for( i = 0; i < ARRAYSIZE( bugcomp_features ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( bugcomp_features ); i++ )
|
||||
p += Q_snprintf( p, sizeof( usage_str ) - ( usage_str - p ), " %s: %s\n", bugcomp_features[i].arg, bugcomp_features[i].msg );
|
||||
p += Q_snprintf( p, sizeof( usage_str ) - ( usage_str - p ), "\nIt is possible to combine multiple flags with '+' characters.\nExample: -bugcomp flag1+flag2+flag3...\n" );
|
||||
|
||||
@@ -262,9 +260,7 @@ Host_PrintEngineFeatures
|
||||
*/
|
||||
static void Host_PrintFeatures( uint32_t flags, const char *s, const feature_message_t *features, size_t size )
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for( i = 0; i < size; i++ )
|
||||
for( size_t i = 0; i < size; i++ )
|
||||
{
|
||||
if( FBitSet( flags, features[i].mask ))
|
||||
Con_Printf( "^3%s:^7 %s is enabled\n", s, features[i].msg );
|
||||
@@ -340,7 +336,6 @@ static int Host_CalcSleep( void )
|
||||
if( sv_hibernate_when_empty.value )
|
||||
{
|
||||
int players, bots;
|
||||
|
||||
SV_GetPlayerCount( &players, &bots );
|
||||
|
||||
if( sv_hibernate_when_empty_include_bots.value )
|
||||
@@ -423,14 +418,13 @@ Host_RegisterDecal
|
||||
*/
|
||||
static qboolean Host_RegisterDecal( const char *name, int *count )
|
||||
{
|
||||
char shortname[MAX_QPATH];
|
||||
int i;
|
||||
|
||||
if( COM_StringEmptyOrNULL( name ))
|
||||
return 0;
|
||||
|
||||
char shortname[MAX_QPATH];
|
||||
COM_FileBase( name, shortname, sizeof( shortname ));
|
||||
|
||||
int i;
|
||||
for( i = 1; i < MAX_DECALS && host.draw_decals[i][0]; i++ )
|
||||
{
|
||||
if( !Q_stricmp( host.draw_decals[i], shortname ))
|
||||
@@ -457,15 +451,14 @@ Host_InitDecals
|
||||
*/
|
||||
static void Host_InitDecals( void )
|
||||
{
|
||||
int i, num_decals = 0;
|
||||
search_t *t;
|
||||
int num_decals = 0;
|
||||
|
||||
memset( host.draw_decals, 0, sizeof( host.draw_decals ));
|
||||
|
||||
// lookup all the decals in decals.wad (basedir, gamedir, falldir)
|
||||
t = FS_Search( "decals.wad/*.*", true, false );
|
||||
search_t *t = FS_Search( "decals.wad/*.*", true, false );
|
||||
|
||||
for( i = 0; t && i < t->numfilenames; i++ )
|
||||
for( int i = 0; t && i < t->numfilenames; i++ )
|
||||
{
|
||||
if( !Host_RegisterDecal( t->filenames[i], &num_decals ))
|
||||
break;
|
||||
@@ -484,8 +477,7 @@ Add them exactly as if they had been typed at the console
|
||||
*/
|
||||
static void Host_GetCommands( void )
|
||||
{
|
||||
char *cmd;
|
||||
|
||||
char *cmd;
|
||||
while( ( cmd = Platform_Input() ) )
|
||||
{
|
||||
Cbuf_AddText( cmd );
|
||||
@@ -541,7 +533,6 @@ static double Host_CalcFPS( void )
|
||||
static qboolean Host_Autosleep( double dt, double scale )
|
||||
{
|
||||
double targetframetime;
|
||||
int sleep;
|
||||
double fps = Host_CalcFPS();
|
||||
|
||||
if( fps <= 0 )
|
||||
@@ -555,7 +546,7 @@ static qboolean Host_Autosleep( double dt, double scale )
|
||||
else
|
||||
targetframetime = ( 1.0 / fps );
|
||||
|
||||
sleep = Host_CalcSleep();
|
||||
int sleep = Host_CalcSleep();
|
||||
if( sleep <= 0 ) // no sleeps between frames, much simpler code
|
||||
{
|
||||
if( dt < targetframetime * scale )
|
||||
@@ -627,11 +618,10 @@ Returns false if the time is too short to run a frame
|
||||
static qboolean Host_FilterTime( double time )
|
||||
{
|
||||
static double oldtime;
|
||||
double dt;
|
||||
double scale = sys_timescale.value;
|
||||
|
||||
host.realtime += time * scale;
|
||||
dt = host.realtime - oldtime;
|
||||
double dt = host.realtime - oldtime;
|
||||
|
||||
// clamp the fps in multiplayer games
|
||||
if( !Host_Autosleep( dt, scale ))
|
||||
@@ -657,13 +647,11 @@ Host_Frame
|
||||
*/
|
||||
void Host_Frame( double time )
|
||||
{
|
||||
double t1;
|
||||
|
||||
// decide the simulation time
|
||||
if( !Host_FilterTime( time ))
|
||||
return;
|
||||
|
||||
t1 = Platform_DoubleTime();
|
||||
double t1 = Platform_DoubleTime();
|
||||
|
||||
if( host.framecount == 0 )
|
||||
Con_DPrintf( "Time to first frame: %.3f seconds\n", t1 - host.starttime );
|
||||
@@ -990,7 +978,7 @@ Host_InitCommon
|
||||
static void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bChangeGame, char *exename, size_t exename_size )
|
||||
{
|
||||
const char *basedir = progname[0] == '#' ? progname + 1 : progname;
|
||||
int ticrate, developer = DEFAULT_DEV;
|
||||
int developer = DEFAULT_DEV;
|
||||
|
||||
// some commands may turn engine into infinite loop,
|
||||
// e.g. xash.exe +game xash -game xash
|
||||
@@ -1069,6 +1057,7 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
|
||||
Cvar_DirectSetValue( &host_developer, developer );
|
||||
Cvar_RegisterVariable( &sys_ticrate );
|
||||
|
||||
int ticrate;
|
||||
if( Sys_GetIntFromCmdLine( "-sys_ticrate", &ticrate ))
|
||||
Cvar_DirectSetValue( &sys_ticrate, bound( MIN_FPS, ticrate, MAX_FPS_HARD ));
|
||||
|
||||
@@ -1092,10 +1081,8 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole
|
||||
// print current developer level to simplify processing users feedback
|
||||
if( developer > 0 )
|
||||
{
|
||||
int i;
|
||||
|
||||
Con_Printf( "Program args: " S_YELLOW );
|
||||
for( i = 0; i < host.argc; i++ )
|
||||
for( int i = 0; i < host.argc; i++ )
|
||||
Con_Printf( "%s ", host.argv[i] );
|
||||
Con_Printf( S_DEFAULT "\n" );
|
||||
|
||||
@@ -1158,7 +1145,7 @@ Host_Main
|
||||
int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame pChangeGame )
|
||||
{
|
||||
static double oldtime;
|
||||
string demoname, exename;
|
||||
string exename;
|
||||
|
||||
if( setjmp( return_from_main_buf ))
|
||||
return error_on_exit;
|
||||
@@ -1287,6 +1274,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
|
||||
IN_GyroCheckAvailability();
|
||||
#endif
|
||||
|
||||
string demoname;
|
||||
if( Sys_GetParmFromCmdLine( "-timedemo", demoname ))
|
||||
Cbuf_AddTextf( "timedemo %s\n", demoname );
|
||||
|
||||
|
||||
@@ -193,14 +193,13 @@ void Host_AbortCurrentFrame( void )
|
||||
|
||||
void COM_Frame( double time )
|
||||
{
|
||||
int loopCount = 0;
|
||||
|
||||
if( setjmp( g_abortframe ))
|
||||
return;
|
||||
|
||||
int loopCount = 0;
|
||||
while( 1 )
|
||||
{
|
||||
int oldState = GameState->curstate;
|
||||
int oldState = GameState->curstate;
|
||||
|
||||
// execute the current state (and transition to the next state if not in STATE_RUNFRAME)
|
||||
switch( GameState->curstate )
|
||||
|
||||
@@ -67,9 +67,8 @@ static inline void HPAK_ResourceFromCompat( resource_t *dest, dresource_t *src )
|
||||
|
||||
static void HPAK_AddToQueue( const char *name, resource_t *pResource, void *data, file_t *f )
|
||||
{
|
||||
hash_pack_queue_t *p;
|
||||
hash_pack_queue_t *p = Z_Malloc( sizeof( hash_pack_queue_t ));
|
||||
|
||||
p = Z_Malloc( sizeof( hash_pack_queue_t ));
|
||||
p->name = copystring( name );
|
||||
p->resource = *pResource;
|
||||
p->size = pResource->nDownloadSize;
|
||||
@@ -85,9 +84,7 @@ static void HPAK_AddToQueue( const char *name, resource_t *pResource, void *data
|
||||
|
||||
void HPAK_FlushHostQueue( void )
|
||||
{
|
||||
hash_pack_queue_t *p;
|
||||
|
||||
for( p = gp_hpak_queue; p != NULL; p = gp_hpak_queue )
|
||||
for( hash_pack_queue_t *p = gp_hpak_queue; p != NULL; p = gp_hpak_queue )
|
||||
{
|
||||
gp_hpak_queue = p->next;
|
||||
HPAK_AddLump( false, p->name, &p->resource, p->data, NULL );
|
||||
@@ -100,10 +97,8 @@ void HPAK_FlushHostQueue( void )
|
||||
|
||||
static void HPAK_CreatePak( const char *filename, resource_t *pResource, byte *pData, file_t *fin )
|
||||
{
|
||||
int filelocation;
|
||||
string pakname;
|
||||
byte md5[16];
|
||||
file_t *fout;
|
||||
MD5Context_t ctx = { 0 };
|
||||
|
||||
if( COM_StringEmptyOrNULL( filename ))
|
||||
@@ -117,7 +112,7 @@ static void HPAK_CreatePak( const char *filename, resource_t *pResource, byte *p
|
||||
|
||||
Con_Printf( "creating HPAK %s.\n", pakname );
|
||||
|
||||
fout = FS_Open( pakname, "wb", true );
|
||||
file_t *fout = FS_Open( pakname, "wb", true );
|
||||
if( !fout )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: can't write %s.\n", __func__, pakname );
|
||||
@@ -129,11 +124,9 @@ static void HPAK_CreatePak( const char *filename, resource_t *pResource, byte *p
|
||||
|
||||
if( pData == NULL )
|
||||
{
|
||||
byte *temp;
|
||||
int filelocation = FS_Tell( fin );
|
||||
byte *temp = Z_Malloc( pResource->nDownloadSize );
|
||||
|
||||
// there are better ways
|
||||
filelocation = FS_Tell( fin );
|
||||
temp = Z_Malloc( pResource->nDownloadSize );
|
||||
FS_Read( fin, temp, pResource->nDownloadSize );
|
||||
FS_Seek( fin, filelocation, SEEK_SET );
|
||||
MD5Update( &ctx, temp, pResource->nDownloadSize );
|
||||
@@ -173,7 +166,7 @@ static void HPAK_CreatePak( const char *filename, resource_t *pResource, byte *p
|
||||
FS_Write( fout, pData, hash_pack_info.entries[0].disksize );
|
||||
}
|
||||
|
||||
filelocation = FS_Tell( fout );
|
||||
int filelocation = FS_Tell( fout );
|
||||
FS_Write( fout, &hash_pack_info.count, sizeof( hash_pack_info.count ));
|
||||
FS_Write( fout, &hash_pack_info.entries[0], sizeof( hpak_lump_t ));
|
||||
|
||||
@@ -189,9 +182,7 @@ static void HPAK_CreatePak( const char *filename, resource_t *pResource, byte *p
|
||||
|
||||
static qboolean HPAK_FindResource( hpak_info_t *hpk, byte *hash, resource_t *pResource )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < hpk->count; i++ )
|
||||
for( int i = 0; i < hpk->count; i++ )
|
||||
{
|
||||
if( !memcmp( hpk->entries[i].resource.rgucMD5_hash, hash, 16 ))
|
||||
{
|
||||
@@ -206,12 +197,9 @@ static qboolean HPAK_FindResource( hpak_info_t *hpk, byte *hash, resource_t *pRe
|
||||
|
||||
void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource, byte *pData, file_t *pFile )
|
||||
{
|
||||
int i, j, position, length;
|
||||
hpak_lump_t *pCurrentEntry = NULL;
|
||||
string srcname, dstname;
|
||||
hpak_info_t srcpak, dstpak;
|
||||
file_t *file_src;
|
||||
file_t *file_dst;
|
||||
byte md5[16];
|
||||
MD5Context_t ctx = { 0 };
|
||||
|
||||
@@ -229,11 +217,9 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
|
||||
|
||||
if( !pData )
|
||||
{
|
||||
byte *temp;
|
||||
int position = FS_Tell( pFile );
|
||||
byte *temp = Z_Malloc( pResource->nDownloadSize );
|
||||
|
||||
// there are better ways
|
||||
position = FS_Tell( pFile );
|
||||
temp = Z_Malloc( pResource->nDownloadSize );
|
||||
FS_Read( pFile, temp, pResource->nDownloadSize );
|
||||
FS_Seek( pFile, position, SEEK_SET );
|
||||
MD5Update( &ctx, temp, pResource->nDownloadSize );
|
||||
@@ -261,7 +247,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
|
||||
Q_strncpy( srcname, name, sizeof( srcname ));
|
||||
COM_ReplaceExtension( srcname, ".hpk", sizeof( srcname ));
|
||||
|
||||
file_src = FS_Open( srcname, "rb", true );
|
||||
file_t *file_src = FS_Open( srcname, "rb", true );
|
||||
|
||||
if( !file_src )
|
||||
{
|
||||
@@ -273,7 +259,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
|
||||
Q_strncpy( dstname, srcname, sizeof( dstname ));
|
||||
COM_ReplaceExtension( dstname, ".hp2", sizeof( dstname ));
|
||||
|
||||
file_dst = FS_Open( dstname, "wb", true );
|
||||
file_t *file_dst = FS_Open( dstname, "wb", true );
|
||||
|
||||
if( !file_dst )
|
||||
{
|
||||
@@ -294,7 +280,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
|
||||
return;
|
||||
}
|
||||
|
||||
length = FS_FileLength( file_src );
|
||||
int length = FS_FileLength( file_src );
|
||||
FS_Seek( file_src, 0, SEEK_SET ); // rewind to start of file
|
||||
FS_FileCopy( file_dst, file_src, length );
|
||||
|
||||
@@ -329,13 +315,13 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
|
||||
memcpy( dstpak.entries, srcpak.entries, sizeof( hpak_lump_t ) * srcpak.count );
|
||||
|
||||
// check is there are entry with same hash
|
||||
for( i = 0; i < srcpak.count; i++ )
|
||||
for( int i = 0; i < srcpak.count; i++ )
|
||||
{
|
||||
if( memcmp( md5, srcpak.entries[i].resource.rgucMD5_hash, 16 ) == 0 )
|
||||
{
|
||||
pCurrentEntry = &dstpak.entries[i];
|
||||
|
||||
for( j = i; j < srcpak.count; j++ )
|
||||
for( int j = i; j < srcpak.count; j++ )
|
||||
dstpak.entries[j + 1] = srcpak.entries[j];
|
||||
}
|
||||
}
|
||||
@@ -357,7 +343,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
|
||||
hash_pack_header.infotableofs = FS_Tell( file_dst );
|
||||
FS_Write( file_dst, &dstpak.count, sizeof( dstpak.count ));
|
||||
|
||||
for( i = 0; i < dstpak.count; i++ )
|
||||
for( int i = 0; i < dstpak.count; i++ )
|
||||
{
|
||||
FS_Write( file_dst, &dstpak.entries[i], sizeof( hpak_lump_t ));
|
||||
}
|
||||
@@ -380,14 +366,9 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
|
||||
|
||||
static qboolean HPAK_Validate( const char *filename, qboolean quiet, qboolean delete )
|
||||
{
|
||||
file_t *f;
|
||||
hpak_lump_t *dataDir;
|
||||
hpak_header_t hdr;
|
||||
byte *dataPak;
|
||||
int i, num_lumps;
|
||||
MD5Context_t MD5_Hash;
|
||||
string pakname;
|
||||
dresource_t *pRes;
|
||||
byte md5[16];
|
||||
|
||||
if( quiet ) HPAK_FlushHostQueue();
|
||||
@@ -399,7 +380,7 @@ static qboolean HPAK_Validate( const char *filename, qboolean quiet, qboolean de
|
||||
Q_strncpy( pakname, filename, sizeof( pakname ));
|
||||
COM_ReplaceExtension( pakname, ".hpk", sizeof( pakname ));
|
||||
|
||||
f = FS_Open( pakname, "rb", true );
|
||||
file_t *f = FS_Open( pakname, "rb", true );
|
||||
if( !f )
|
||||
{
|
||||
if( !quiet )
|
||||
@@ -419,6 +400,8 @@ static qboolean HPAK_Validate( const char *filename, qboolean quiet, qboolean de
|
||||
}
|
||||
|
||||
FS_Seek( f, hdr.infotableofs, SEEK_SET );
|
||||
|
||||
int num_lumps;
|
||||
FS_Read( f, &num_lumps, sizeof( num_lumps ));
|
||||
|
||||
if( num_lumps < 1 || num_lumps > HPAK_MAX_ENTRIES )
|
||||
@@ -431,12 +414,12 @@ static qboolean HPAK_Validate( const char *filename, qboolean quiet, qboolean de
|
||||
|
||||
if( !quiet ) Con_Printf( "# of Entries: %i\n", num_lumps );
|
||||
|
||||
dataDir = Z_Malloc( sizeof( hpak_lump_t ) * num_lumps );
|
||||
hpak_lump_t *dataDir = Z_Malloc( sizeof( hpak_lump_t ) * num_lumps );
|
||||
FS_Read( f, dataDir, sizeof( hpak_lump_t ) * num_lumps );
|
||||
|
||||
if( !quiet ) Con_Printf( "# Type Size FileName : MD5 Hash\n" );
|
||||
|
||||
for( i = 0; i < num_lumps; i++ )
|
||||
for( int i = 0; i < num_lumps; i++ )
|
||||
{
|
||||
if( dataDir[i].disksize < HPAK_ENTRY_MIN_SIZE || dataDir[i].disksize > HPAK_ENTRY_MAX_SIZE )
|
||||
{
|
||||
@@ -448,7 +431,7 @@ static qboolean HPAK_Validate( const char *filename, qboolean quiet, qboolean de
|
||||
return false;
|
||||
}
|
||||
|
||||
dataPak = Z_Malloc( dataDir[i].disksize );
|
||||
byte *dataPak = Z_Malloc( dataDir[i].disksize );
|
||||
FS_Seek( f, dataDir[i].filepos, SEEK_SET );
|
||||
FS_Read( f, dataPak, dataDir[i].disksize );
|
||||
|
||||
@@ -457,7 +440,7 @@ static qboolean HPAK_Validate( const char *filename, qboolean quiet, qboolean de
|
||||
MD5Update( &MD5_Hash, dataPak, dataDir[i].disksize );
|
||||
MD5Final( md5, &MD5_Hash );
|
||||
|
||||
pRes = &dataDir[i].resource;
|
||||
dresource_t *pRes = &dataDir[i].resource;
|
||||
|
||||
if( !quiet )
|
||||
{
|
||||
@@ -508,9 +491,8 @@ void HPAK_CheckIntegrity( const char *filename )
|
||||
void HPAK_CheckSize( const char *filename )
|
||||
{
|
||||
string pakname;
|
||||
int maxsize;
|
||||
int maxsize = hpk_maxsize.value;
|
||||
|
||||
maxsize = hpk_maxsize.value;
|
||||
if( maxsize <= 0 ) return;
|
||||
|
||||
if( COM_StringEmptyOrNULL( filename ) )
|
||||
@@ -532,14 +514,11 @@ qboolean HPAK_ResourceForHash( const char *filename, byte *hash, resource_t *pRe
|
||||
hpak_info_t directory;
|
||||
hpak_header_t header;
|
||||
string pakname;
|
||||
qboolean bFound;
|
||||
file_t *f;
|
||||
hash_pack_queue_t *p;
|
||||
|
||||
if( COM_StringEmptyOrNULL( filename ))
|
||||
return false;
|
||||
|
||||
for( p = gp_hpak_queue; p != NULL; p = p->next )
|
||||
for( hash_pack_queue_t *p = gp_hpak_queue; p != NULL; p = p->next )
|
||||
{
|
||||
if( !Q_stricmp( p->name, filename ) && !memcmp( p->resource.rgucMD5_hash, hash, 16 ))
|
||||
{
|
||||
@@ -552,7 +531,7 @@ qboolean HPAK_ResourceForHash( const char *filename, byte *hash, resource_t *pRe
|
||||
Q_strncpy( pakname, filename, sizeof( pakname ));
|
||||
COM_ReplaceExtension( pakname, ".hpk", sizeof( pakname ));
|
||||
|
||||
f = FS_Open( pakname, "rb", true );
|
||||
file_t *f = FS_Open( pakname, "rb", true );
|
||||
if( !f ) return false;
|
||||
|
||||
FS_Read( f, &header, sizeof( header ));
|
||||
@@ -580,7 +559,7 @@ qboolean HPAK_ResourceForHash( const char *filename, byte *hash, resource_t *pRe
|
||||
|
||||
directory.entries = Z_Malloc( sizeof( hpak_lump_t ) * directory.count );
|
||||
FS_Read( f, directory.entries, sizeof( hpak_lump_t ) * directory.count );
|
||||
bFound = HPAK_FindResource( &directory, hash, pResource );
|
||||
qboolean bFound = HPAK_FindResource( &directory, hash, pResource );
|
||||
Mem_Free( directory.entries );
|
||||
FS_Close( f );
|
||||
|
||||
@@ -592,7 +571,6 @@ static qboolean HPAK_ResourceForIndex( const char *filename, int index, resource
|
||||
hpak_header_t header;
|
||||
hpak_info_t directory;
|
||||
string pakname;
|
||||
file_t *f;
|
||||
|
||||
if( COM_StringEmptyOrNULL( filename ) )
|
||||
return false;
|
||||
@@ -600,7 +578,7 @@ static qboolean HPAK_ResourceForIndex( const char *filename, int index, resource
|
||||
Q_strncpy( pakname, filename, sizeof( pakname ));
|
||||
COM_ReplaceExtension( pakname, ".hpk", sizeof( pakname ));
|
||||
|
||||
f = FS_Open( pakname, "rb", true );
|
||||
file_t *f = FS_Open( pakname, "rb", true );
|
||||
if( !f )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "couldn't open %s.\n", pakname );
|
||||
@@ -650,14 +628,9 @@ static qboolean HPAK_ResourceForIndex( const char *filename, int index, resource
|
||||
|
||||
qboolean HPAK_GetDataPointer( const char *filename, resource_t *pResource, byte **buffer, int *bufsize )
|
||||
{
|
||||
byte *tmpbuf;
|
||||
string pakname;
|
||||
hpak_header_t header;
|
||||
hpak_info_t directory;
|
||||
hpak_lump_t *entry;
|
||||
hash_pack_queue_t *p;
|
||||
file_t *f;
|
||||
int i;
|
||||
|
||||
if( COM_StringEmptyOrNULL( filename ))
|
||||
return false;
|
||||
@@ -665,13 +638,13 @@ qboolean HPAK_GetDataPointer( const char *filename, resource_t *pResource, byte
|
||||
if( buffer ) *buffer = NULL;
|
||||
if( bufsize ) *bufsize = 0;
|
||||
|
||||
for( p = gp_hpak_queue; p != NULL; p = p->next )
|
||||
for( hash_pack_queue_t *p = gp_hpak_queue; p != NULL; p = p->next )
|
||||
{
|
||||
if( !Q_stricmp( p->name, filename ) && !memcmp( p->resource.rgucMD5_hash, pResource->rgucMD5_hash, 16 ))
|
||||
{
|
||||
if( buffer )
|
||||
{
|
||||
tmpbuf = Z_Malloc( p->size );
|
||||
byte *tmpbuf = Z_Malloc( p->size );
|
||||
memcpy( tmpbuf, p->data, p->size );
|
||||
*buffer = tmpbuf;
|
||||
}
|
||||
@@ -686,7 +659,7 @@ qboolean HPAK_GetDataPointer( const char *filename, resource_t *pResource, byte
|
||||
Q_strncpy( pakname, filename, sizeof( pakname ));
|
||||
COM_ReplaceExtension( pakname, ".hpk", sizeof( pakname ));
|
||||
|
||||
f = FS_Open( pakname, "rb", true );
|
||||
file_t *f = FS_Open( pakname, "rb", true );
|
||||
if( !f ) return false;
|
||||
|
||||
FS_Read( f, &header, sizeof( header ));
|
||||
@@ -718,9 +691,9 @@ qboolean HPAK_GetDataPointer( const char *filename, resource_t *pResource, byte
|
||||
directory.entries = Z_Malloc( sizeof( hpak_lump_t ) * directory.count );
|
||||
FS_Read( f, directory.entries, sizeof( hpak_lump_t ) * directory.count );
|
||||
|
||||
for( i = 0; i < directory.count; i++ )
|
||||
for( int i = 0; i < directory.count; i++ )
|
||||
{
|
||||
entry = &directory.entries[i];
|
||||
hpak_lump_t *entry = &directory.entries[i];
|
||||
|
||||
if( entry->filepos > 0 &&
|
||||
entry->disksize > 0 &&
|
||||
@@ -730,7 +703,7 @@ qboolean HPAK_GetDataPointer( const char *filename, resource_t *pResource, byte
|
||||
|
||||
if( buffer )
|
||||
{
|
||||
tmpbuf = Z_Malloc( entry->disksize );
|
||||
byte *tmpbuf = Z_Malloc( entry->disksize );
|
||||
FS_Read( f, tmpbuf, entry->disksize );
|
||||
*buffer = tmpbuf;
|
||||
}
|
||||
@@ -755,11 +728,8 @@ void HPAK_RemoveLump( const char *name, resource_t *pResource )
|
||||
{
|
||||
string read_path;
|
||||
string save_path;
|
||||
file_t *file_src;
|
||||
file_t *file_dst;
|
||||
hpak_info_t hpak_read;
|
||||
hpak_info_t hpak_save;
|
||||
int i, j;
|
||||
|
||||
if( COM_StringEmptyOrNULL( name ) || !pResource )
|
||||
return;
|
||||
@@ -769,7 +739,7 @@ void HPAK_RemoveLump( const char *name, resource_t *pResource )
|
||||
Q_strncpy( read_path, name, sizeof( read_path ));
|
||||
COM_ReplaceExtension( read_path, ".hpk", sizeof( read_path ));
|
||||
|
||||
file_src = FS_Open( read_path, "rb", true );
|
||||
file_t *file_src = FS_Open( read_path, "rb", true );
|
||||
if( !file_src )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s couldn't open.\n", read_path );
|
||||
@@ -778,7 +748,7 @@ void HPAK_RemoveLump( const char *name, resource_t *pResource )
|
||||
|
||||
Q_strncpy( save_path, read_path, sizeof( save_path ));
|
||||
COM_ReplaceExtension( save_path, ".hp2", sizeof( save_path ));
|
||||
file_dst = FS_Open( save_path, "wb", true );
|
||||
file_t *file_dst = FS_Open( save_path, "wb", true );
|
||||
|
||||
if( !file_dst )
|
||||
{
|
||||
@@ -845,7 +815,7 @@ void HPAK_RemoveLump( const char *name, resource_t *pResource )
|
||||
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++ )
|
||||
for( int i = 0, j = 0; i < hpak_read.count; i++ )
|
||||
{
|
||||
if( !memcmp( hpak_read.entries[i].resource.rgucMD5_hash, pResource->rgucMD5_hash, 16 ))
|
||||
continue;
|
||||
@@ -860,7 +830,7 @@ void HPAK_RemoveLump( const char *name, resource_t *pResource )
|
||||
hash_pack_header.infotableofs = FS_Tell( file_dst );
|
||||
FS_Write( file_dst, &hpak_save.count, sizeof( hpak_save.count ));
|
||||
|
||||
for( i = 0; i < hpak_save.count; i++ )
|
||||
for( int i = 0; i < hpak_save.count; i++ )
|
||||
FS_Write( file_dst, &hpak_save.entries[i], sizeof( hpak_lump_t ));
|
||||
|
||||
FS_Seek( file_dst, 0, SEEK_SET );
|
||||
@@ -877,15 +847,10 @@ void HPAK_RemoveLump( const char *name, resource_t *pResource )
|
||||
|
||||
static void HPAK_List_f( void )
|
||||
{
|
||||
int nCurrent;
|
||||
hpak_header_t header;
|
||||
hpak_info_t directory;
|
||||
hpak_lump_t *entry;
|
||||
string lumpname;
|
||||
string pakname;
|
||||
const char *type;
|
||||
const char *size;
|
||||
file_t *f;
|
||||
|
||||
if( Cmd_Argc() != 2 )
|
||||
{
|
||||
@@ -899,7 +864,7 @@ static void HPAK_List_f( void )
|
||||
COM_ReplaceExtension( pakname, ".hpk", sizeof( pakname ));
|
||||
Con_Printf( "Contents for %s.\n", pakname );
|
||||
|
||||
f = FS_Open( pakname, "rb", true );
|
||||
file_t *f = FS_Open( pakname, "rb", true );
|
||||
if( !f )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "couldn't open %s.\n", pakname );
|
||||
@@ -938,12 +903,13 @@ static void HPAK_List_f( void )
|
||||
directory.entries = Z_Malloc( directory.count * sizeof( hpak_lump_t ));
|
||||
FS_Read( f, directory.entries, directory.count * sizeof( hpak_lump_t ));
|
||||
|
||||
for( nCurrent = 0; nCurrent < directory.count; nCurrent++ )
|
||||
for( int nCurrent = 0; nCurrent < directory.count; nCurrent++ )
|
||||
{
|
||||
entry = &directory.entries[nCurrent];
|
||||
hpak_lump_t *entry = &directory.entries[nCurrent];
|
||||
const char *type = COM_ResourceTypeFromIndex( entry->resource.type );
|
||||
const char *size = Q_memprint( entry->resource.nDownloadSize );
|
||||
|
||||
COM_FileBase( entry->resource.szFileName, lumpname, sizeof( lumpname ));
|
||||
type = COM_ResourceTypeFromIndex( entry->resource.type );
|
||||
size = Q_memprint( entry->resource.nDownloadSize );
|
||||
|
||||
Con_Printf( "%i: %10s %s %s\n : %s\n", nCurrent + 1, type, size, lumpname, MD5_Print( entry->resource.rgucMD5_hash ));
|
||||
}
|
||||
@@ -955,19 +921,12 @@ static void HPAK_List_f( void )
|
||||
|
||||
static void HPAK_Extract_f( void )
|
||||
{
|
||||
int nCurrent;
|
||||
hpak_header_t header;
|
||||
hpak_info_t directory;
|
||||
hpak_lump_t *entry;
|
||||
string lumpname;
|
||||
string pakname;
|
||||
string szFileOut;
|
||||
int nIndex;
|
||||
byte *pData;
|
||||
int nDataSize;
|
||||
const char *type;
|
||||
const char *size;
|
||||
file_t *f;
|
||||
|
||||
if( Cmd_Argc() != 3 )
|
||||
{
|
||||
@@ -990,7 +949,7 @@ static void HPAK_Extract_f( void )
|
||||
COM_ReplaceExtension( pakname, ".hpk", sizeof( pakname ));
|
||||
Con_Printf( "Contents for %s.\n", pakname );
|
||||
|
||||
f = FS_Open( pakname, "rb", true );
|
||||
file_t *f = FS_Open( pakname, "rb", true );
|
||||
if( !f )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "couldn't open %s.\n", pakname );
|
||||
@@ -1029,16 +988,17 @@ static void HPAK_Extract_f( void )
|
||||
directory.entries = Z_Malloc( directory.count * sizeof( hpak_lump_t ));
|
||||
FS_Read( f, directory.entries, directory.count * sizeof( hpak_lump_t ));
|
||||
|
||||
for( nCurrent = 0; nCurrent < directory.count; nCurrent++ )
|
||||
for( int nCurrent = 0; nCurrent < directory.count; nCurrent++ )
|
||||
{
|
||||
entry = &directory.entries[nCurrent];
|
||||
hpak_lump_t *entry = &directory.entries[nCurrent];
|
||||
|
||||
if( nIndex != -1 && nIndex != nCurrent )
|
||||
continue;
|
||||
|
||||
const char *type = COM_ResourceTypeFromIndex( entry->resource.type );
|
||||
const char *size = Q_memprint( entry->resource.nDownloadSize );
|
||||
|
||||
COM_FileBase( entry->resource.szFileName, lumpname, sizeof( lumpname ) );
|
||||
type = COM_ResourceTypeFromIndex( entry->resource.type );
|
||||
size = Q_memprint( entry->resource.nDownloadSize );
|
||||
|
||||
Con_Printf( "Extracting %i: %10s %s %s\n", nCurrent + 1, type, size, lumpname );
|
||||
|
||||
@@ -1048,8 +1008,9 @@ static void HPAK_Extract_f( void )
|
||||
continue;
|
||||
}
|
||||
|
||||
nDataSize = entry->disksize;
|
||||
pData = Z_Malloc( nDataSize + 1 );
|
||||
int nDataSize = entry->disksize;
|
||||
byte *pData = Z_Malloc( nDataSize + 1 );
|
||||
|
||||
FS_Seek( f, entry->filepos, SEEK_SET );
|
||||
FS_Read( f, pData, nDataSize );
|
||||
|
||||
|
||||
@@ -228,14 +228,12 @@ static int HTTP_FileQueue( httpfile_t *file )
|
||||
|
||||
static int HTTP_FileResolveNS( httpfile_t *file )
|
||||
{
|
||||
net_gai_state_t res;
|
||||
|
||||
if( http.resolving )
|
||||
return 0;
|
||||
|
||||
memset( &file->addr, 0, sizeof( file->addr ));
|
||||
|
||||
res = NET_StringToSockaddr( file->server->host, &file->addr, true, AF_UNSPEC );
|
||||
net_gai_state_t res = NET_StringToSockaddr( file->server->host, &file->addr, true, AF_UNSPEC );
|
||||
|
||||
switch( file->addr.ss_family )
|
||||
{
|
||||
@@ -343,9 +341,7 @@ static int HTTP_FileConnect( httpfile_t *file )
|
||||
|
||||
static int HTTP_FileSendRequest( httpfile_t *file )
|
||||
{
|
||||
int res = -1;
|
||||
|
||||
res = send( file->socket, file->buf + file->bytes_sent, file->query_length - file->bytes_sent, 0 );
|
||||
int res = send( file->socket, file->buf + file->bytes_sent, file->query_length - file->bytes_sent, 0 );
|
||||
|
||||
if( res >= 0 )
|
||||
{
|
||||
@@ -382,7 +378,6 @@ static int HTTP_FileSendRequest( httpfile_t *file )
|
||||
|
||||
static int HTTP_FileDecompress( httpfile_t *file )
|
||||
{
|
||||
fs_offset_t len;
|
||||
#pragma pack( push, 1 )
|
||||
struct
|
||||
{
|
||||
@@ -404,15 +399,10 @@ static int HTTP_FileDecompress( httpfile_t *file )
|
||||
GZFLG_FCOMMENT = BIT( 4 )
|
||||
};
|
||||
|
||||
z_stream decompress_stream;
|
||||
char name[MAX_SYSPATH];
|
||||
fs_offset_t deflate_pos;
|
||||
size_t compressed_len, decompressed_len;
|
||||
byte *data_in, *data_out;
|
||||
int zlib_result;
|
||||
|
||||
g_fsapi.Seek( file->file, 0, SEEK_END );
|
||||
len = g_fsapi.Tell( file->file );
|
||||
fs_offset_t len = g_fsapi.Tell( file->file );
|
||||
|
||||
g_fsapi.Seek( file->file, 0, SEEK_SET );
|
||||
if( g_fsapi.Read( file->file, &hdr, sizeof( hdr )) != sizeof( hdr ))
|
||||
@@ -430,10 +420,9 @@ static int HTTP_FileDecompress( httpfile_t *file )
|
||||
if( FBitSet( hdr.flags, GZFLG_FEXTRA ))
|
||||
{
|
||||
byte res[2];
|
||||
uint16_t xlen;
|
||||
|
||||
g_fsapi.Read( file->file, res, sizeof( res ));
|
||||
xlen = res[0] | res[1] << 16;
|
||||
uint16_t xlen = res[0] | res[1] << 16;
|
||||
g_fsapi.Seek( file->file, xlen, SEEK_CUR );
|
||||
}
|
||||
|
||||
@@ -458,8 +447,9 @@ static int HTTP_FileDecompress( httpfile_t *file )
|
||||
if( FBitSet( hdr.flags, GZFLG_FHCRC ))
|
||||
g_fsapi.Seek( file->file, 2, SEEK_CUR );
|
||||
|
||||
deflate_pos = g_fsapi.Tell( file->file );
|
||||
compressed_len = len - deflate_pos;
|
||||
fs_offset_t deflate_pos = g_fsapi.Tell( file->file );
|
||||
size_t compressed_len = len - deflate_pos;
|
||||
size_t decompressed_len;
|
||||
|
||||
{
|
||||
byte data[4];
|
||||
@@ -479,16 +469,20 @@ static int HTTP_FileDecompress( httpfile_t *file )
|
||||
return 0;
|
||||
}
|
||||
|
||||
data_in = Mem_Malloc( host.mempool, compressed_len + 1 );
|
||||
data_out = Mem_Malloc( host.mempool, decompressed_len + 1 );
|
||||
byte *data_in = Mem_Malloc( host.mempool, compressed_len + 1 );
|
||||
byte *data_out = Mem_Malloc( host.mempool, decompressed_len + 1 );
|
||||
|
||||
HTTP_DownloadPath( name, sizeof( name ), file->path, false );
|
||||
|
||||
memset( &decompress_stream, 0, sizeof( decompress_stream ));
|
||||
decompress_stream.total_in = decompress_stream.avail_in = compressed_len;
|
||||
decompress_stream.next_in = data_in;
|
||||
decompress_stream.total_out = decompress_stream.avail_out = decompressed_len;
|
||||
decompress_stream.next_out = data_out;
|
||||
z_stream decompress_stream =
|
||||
{
|
||||
.total_in = compressed_len,
|
||||
.avail_in = compressed_len,
|
||||
.next_in = data_in,
|
||||
.total_out = decompressed_len,
|
||||
.avail_out = decompressed_len,
|
||||
.next_out = data_out,
|
||||
};
|
||||
|
||||
g_fsapi.Seek( file->file, deflate_pos, SEEK_SET );
|
||||
g_fsapi.Read( file->file, data_in, compressed_len );
|
||||
@@ -502,7 +496,7 @@ static int HTTP_FileDecompress( httpfile_t *file )
|
||||
return 0;
|
||||
}
|
||||
|
||||
zlib_result = inflate( &decompress_stream, Z_NO_FLUSH );
|
||||
int zlib_result = inflate( &decompress_stream, Z_NO_FLUSH );
|
||||
inflateEnd( &decompress_stream );
|
||||
|
||||
if( zlib_result == Z_OK || zlib_result == Z_STREAM_END )
|
||||
@@ -550,7 +544,7 @@ remove files with HTTP_FREE state from list
|
||||
static void HTTP_AutoClean( void )
|
||||
{
|
||||
char buf[1024];
|
||||
httpfile_t *cur, **prev = &http.first_file;
|
||||
httpfile_t **prev = &http.first_file;
|
||||
sizebuf_t msg;
|
||||
|
||||
MSG_Init( &msg, "DlFile", buf, sizeof( buf ));
|
||||
@@ -558,7 +552,7 @@ static void HTTP_AutoClean( void )
|
||||
// clean all files marked to free
|
||||
while( 1 )
|
||||
{
|
||||
cur = *prev;
|
||||
httpfile_t *cur = *prev;
|
||||
|
||||
if( !cur )
|
||||
break;
|
||||
@@ -605,7 +599,6 @@ static int HTTP_FileSaveReceivedData( httpfile_t *file, int pos, int length )
|
||||
while( length > 0 )
|
||||
{
|
||||
int oldpos = pos;
|
||||
int ret;
|
||||
int len_to_write;
|
||||
|
||||
if( file->chunked && file->chunksize <= 0 )
|
||||
@@ -670,7 +663,7 @@ static int HTTP_FileSaveReceivedData( httpfile_t *file, int pos, int length )
|
||||
len_to_write = Q_min( length, file->chunksize );
|
||||
else len_to_write = length;
|
||||
|
||||
ret = FS_Write( file->file, &file->buf[pos], len_to_write );
|
||||
int ret = FS_Write( file->file, &file->buf[pos], len_to_write );
|
||||
if( ret != len_to_write )
|
||||
{
|
||||
// close it and go to next
|
||||
@@ -724,18 +717,15 @@ static int HTTP_FileProcessStream( httpfile_t *curfile )
|
||||
if( begin ) // Got full header
|
||||
{
|
||||
char *content_length;
|
||||
char *content_encoding;
|
||||
char *transfer_encoding;
|
||||
|
||||
*begin = 0; // cut string to print out response
|
||||
|
||||
if( !Q_strstr( curfile->buf, "200 OK" ))
|
||||
{
|
||||
char *p;
|
||||
|
||||
int num = -1;
|
||||
|
||||
p = Q_strchr( curfile->buf, '\r' );
|
||||
char *p = Q_strchr( curfile->buf, '\r' );
|
||||
if( !p ) p = Q_strchr( curfile->buf, '\n' );
|
||||
if( p ) *p = 0;
|
||||
|
||||
@@ -766,7 +756,7 @@ static int HTTP_FileProcessStream( httpfile_t *curfile )
|
||||
return 0;
|
||||
}
|
||||
|
||||
content_encoding = Q_stristr( curfile->buf, "Content-Encoding" );
|
||||
char *content_encoding = Q_stristr( curfile->buf, "Content-Encoding" );
|
||||
if( content_encoding ) // fetch compressed status
|
||||
{
|
||||
content_encoding += sizeof( "Content-Encoding: " ) - 1;
|
||||
@@ -792,10 +782,8 @@ static int HTTP_FileProcessStream( httpfile_t *curfile )
|
||||
}
|
||||
else if(( content_length = Q_stristr( curfile->buf, "Content-Length: " ) ))
|
||||
{
|
||||
int size;
|
||||
|
||||
content_length += sizeof( "Content-Length: " ) - 1;
|
||||
size = Q_atoi( content_length );
|
||||
int size = Q_atoi( content_length );
|
||||
|
||||
Con_Reportf( "HTTP: Got 200 OK! File size is %d%s\n", curfile->size, curfile->compressed ? ", compressed" : "" );
|
||||
|
||||
@@ -912,13 +900,11 @@ Call every frame
|
||||
*/
|
||||
void HTTP_Run( void )
|
||||
{
|
||||
httpfile_t *curfile;
|
||||
|
||||
http.resolving = false;
|
||||
http.progress_count = 0;
|
||||
http.progress = 0;
|
||||
|
||||
for( curfile = http.first_file; curfile; curfile = curfile->next )
|
||||
for( httpfile_t *curfile = http.first_file; curfile; curfile = curfile->next )
|
||||
{
|
||||
int move_next = 1;
|
||||
|
||||
@@ -948,8 +934,6 @@ Add new download to end of queue
|
||||
*/
|
||||
void HTTP_AddDownload( const char *path, int size, qboolean process, resource_t *res )
|
||||
{
|
||||
httpfile_t *httpfile;
|
||||
|
||||
if( COM_CheckNastyPath( path ))
|
||||
{
|
||||
Con_Printf( S_ERROR "%s: refused to download %s, nasty path\n", __func__, path );
|
||||
@@ -962,7 +946,7 @@ void HTTP_AddDownload( const char *path, int size, qboolean process, resource_t
|
||||
return;
|
||||
}
|
||||
|
||||
httpfile = Z_Calloc( sizeof( *httpfile ));
|
||||
httpfile_t *httpfile = Z_Calloc( sizeof( *httpfile ));
|
||||
|
||||
Con_Reportf( "File %s queued to download\n", path );
|
||||
|
||||
@@ -1005,11 +989,7 @@ HTTP_ParseURL
|
||||
*/
|
||||
static httpserver_t *HTTP_ParseURL( const char *url_ )
|
||||
{
|
||||
httpserver_t *server;
|
||||
int i;
|
||||
const char *url = NULL;
|
||||
|
||||
url = Q_strstr( url_, "http://" );
|
||||
const char *url = Q_strstr( url_, "http://" );
|
||||
|
||||
if( url )
|
||||
url += 7;
|
||||
@@ -1023,8 +1003,8 @@ static httpserver_t *HTTP_ParseURL( const char *url_ )
|
||||
if( !url )
|
||||
return NULL;
|
||||
|
||||
server = Z_Calloc( sizeof( httpserver_t ));
|
||||
i = 0;
|
||||
httpserver_t *server = Z_Calloc( sizeof( httpserver_t ));
|
||||
int i = 0;
|
||||
|
||||
while( *url && ( *url != ':' ) && ( *url != '/' ) && ( *url != '\r' ) && ( *url != '\n' ))
|
||||
{
|
||||
@@ -1164,19 +1144,17 @@ Print all pending downloads to console
|
||||
static void HTTP_List_f( void )
|
||||
{
|
||||
int i = 0;
|
||||
httpfile_t *file;
|
||||
|
||||
if( !http.first_file )
|
||||
Con_Printf( "no downloads queued\n" );
|
||||
|
||||
for( file = http.first_file; file; file = file->next )
|
||||
for( httpfile_t *file = http.first_file; file; file = file->next )
|
||||
{
|
||||
Con_Printf( "%d. %s (%d of %d)\n", i++, file->path, file->downloaded, file->size );
|
||||
|
||||
if( file->server )
|
||||
{
|
||||
httpserver_t *server;
|
||||
for( server = file->server; server; server = server->next )
|
||||
for( httpserver_t *server = file->server; server; server = server->next )
|
||||
{
|
||||
Con_Printf( "\thttp://%s:%d/%s%s\n", file->server->host, file->server->port,
|
||||
file->server->path, file->path );
|
||||
@@ -1194,9 +1172,7 @@ When connected to new server, all old files should not increase counter
|
||||
*/
|
||||
void HTTP_ResetProcessState( void )
|
||||
{
|
||||
httpfile_t *file;
|
||||
|
||||
for( file = http.first_file; file; file = file->next )
|
||||
for( httpfile_t *file = http.first_file; file; file = file->next )
|
||||
file->process = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,14 +42,13 @@ Image_LoadBMP
|
||||
*/
|
||||
qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesize )
|
||||
{
|
||||
byte *buf_p, *pixbuf;
|
||||
byte *pixbuf;
|
||||
rgba_t palette[256] = { 0 };
|
||||
int i, columns, column, rows, row, bpp = 1;
|
||||
int cbPalBytes = 0, padSize = 0, bps = 0;
|
||||
int columns, column, rows, row, bpp = 1;
|
||||
int cbPalBytes = 0, padSize = 0;
|
||||
uint reflectivity[3] = { 0, 0, 0 };
|
||||
qboolean load_qfont = false;
|
||||
bmp_t bhdr;
|
||||
fs_offset_t estimatedSize;
|
||||
|
||||
if( filesize < sizeof( bhdr ))
|
||||
{
|
||||
@@ -57,7 +56,7 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
return false;
|
||||
}
|
||||
|
||||
buf_p = (byte *)buffer;
|
||||
byte *buf_p = (byte *)buffer;
|
||||
memcpy( &bhdr, buf_p, sizeof( bmp_t ));
|
||||
le_struct_swap( bmp_swap, &bhdr );
|
||||
buf_p += BI_FILE_HEADER_SIZE + bhdr.bitmapHeaderSize;
|
||||
@@ -132,7 +131,7 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
}
|
||||
}
|
||||
|
||||
estimatedSize = ( buf_p - buffer ) + cbPalBytes;
|
||||
fs_offset_t estimatedSize = ( buf_p - buffer ) + cbPalBytes;
|
||||
if( filesize < estimatedSize )
|
||||
{
|
||||
Con_Reportf( S_ERROR "%s: %s have incorrect file size %li should be greater than %li (palette)\n", __func__, name, (long)filesize, (long)estimatedSize );
|
||||
@@ -144,7 +143,7 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
// setup gradient alpha for player decal
|
||||
if( !Q_strncmp( name, "#logo", 5 ))
|
||||
{
|
||||
for( i = 0; i < bhdr.colors; i++ )
|
||||
for( int i = 0; i < bhdr.colors; i++ )
|
||||
palette[i][3] = i;
|
||||
image.flags |= IMAGE_HAS_ALPHA;
|
||||
}
|
||||
@@ -152,7 +151,7 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
if( Image_CheckFlag( IL_OVERVIEW ) && bhdr.bitsPerPixel == 8 )
|
||||
{
|
||||
// convert green background into alpha-layer, make opacity for all other entries
|
||||
for( i = 0; i < bhdr.colors; i++ )
|
||||
for( int i = 0; i < bhdr.colors; i++ )
|
||||
{
|
||||
if( palette[i][0] == 0 && palette[i][1] == 255 && palette[i][2] == 0 )
|
||||
{
|
||||
@@ -168,7 +167,7 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
pixbuf = image.palette = Mem_Malloc( host.imagepool, 1024 );
|
||||
|
||||
// bmp have a reversed palette colors
|
||||
for( i = 0; i < bhdr.colors; i++ )
|
||||
for( int i = 0; i < bhdr.colors; i++ )
|
||||
{
|
||||
*pixbuf++ = palette[i][2];
|
||||
*pixbuf++ = palette[i][1];
|
||||
@@ -185,7 +184,7 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
}
|
||||
|
||||
buf_p += cbPalBytes;
|
||||
bps = image.width * (bhdr.bitsPerPixel >> 3);
|
||||
int bps = image.width * (bhdr.bitsPerPixel >> 3);
|
||||
|
||||
switch( bhdr.bitsPerPixel )
|
||||
{
|
||||
@@ -353,15 +352,9 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
|
||||
qboolean Image_SaveBMP( const char *name, rgbdata_t *pix )
|
||||
{
|
||||
file_t *pfile = NULL;
|
||||
rgba_t rgrgbPalette[256];
|
||||
dword cbBmpBits;
|
||||
byte *pb, *pbBmpBits;
|
||||
dword cbPalBytes;
|
||||
dword biTrueWidth;
|
||||
byte *pb;
|
||||
int pixel_size;
|
||||
int i, x, y;
|
||||
bmp_t hdr;
|
||||
|
||||
if( FS_FileExists( name, false ) && !Image_CheckFlag( IL_ALLOW_OVERWRITE ) )
|
||||
return false; // already existed
|
||||
@@ -389,45 +382,44 @@ qboolean Image_SaveBMP( const char *name, rgbdata_t *pix )
|
||||
return false;
|
||||
}
|
||||
|
||||
pfile = FS_Open( name, "wb", false );
|
||||
if( !pfile ) return false;
|
||||
file_t *pfile = FS_Open( name, "wb", false );
|
||||
if( !pfile )
|
||||
return false;
|
||||
|
||||
// NOTE: align transparency column will sucessfully removed
|
||||
// after create sprite or lump image, it's just standard requiriments
|
||||
biTrueWidth = ((pix->width + 3) & ~3);
|
||||
cbBmpBits = biTrueWidth * pix->height * pixel_size;
|
||||
cbPalBytes = ( pixel_size == 1 ) ? 256 * sizeof( rgba_t ) : 0;
|
||||
dword biTrueWidth = ((pix->width + 3) & ~3);
|
||||
dword cbBmpBits = biTrueWidth * pix->height * pixel_size;
|
||||
dword cbPalBytes = ( pixel_size == 1 ) ? 256 * sizeof( rgba_t ) : 0;
|
||||
|
||||
// Bogus file header check
|
||||
hdr.id[0] = 'B';
|
||||
hdr.id[1] = 'M';
|
||||
hdr.fileSize = sizeof( hdr ) + cbBmpBits + cbPalBytes;
|
||||
hdr.reserved0 = 0;
|
||||
hdr.bitmapDataOffset = sizeof( hdr ) + cbPalBytes;
|
||||
hdr.bitmapHeaderSize = BI_SIZE;
|
||||
hdr.width = biTrueWidth;
|
||||
hdr.height = pix->height;
|
||||
hdr.planes = 1;
|
||||
hdr.bitsPerPixel = pixel_size * 8;
|
||||
hdr.compression = BI_RGB;
|
||||
hdr.bitmapDataSize = cbBmpBits;
|
||||
hdr.hRes = 0;
|
||||
hdr.vRes = 0;
|
||||
hdr.colors = ( pixel_size == 1 ) ? 256 : 0;
|
||||
hdr.importantColors = 0;
|
||||
bmp_t hdr =
|
||||
{
|
||||
.id = { 'B', 'M' },
|
||||
.fileSize = sizeof( hdr ) + cbBmpBits + cbPalBytes,
|
||||
.bitmapDataOffset = sizeof( hdr ) + cbPalBytes,
|
||||
.bitmapHeaderSize = BI_SIZE,
|
||||
.width = biTrueWidth,
|
||||
.height = pix->height,
|
||||
.planes = 1,
|
||||
.bitsPerPixel = pixel_size * 8,
|
||||
.compression = BI_RGB,
|
||||
.bitmapDataSize = cbBmpBits,
|
||||
.colors = ( pixel_size == 1 ) ? 256 : 0,
|
||||
};
|
||||
|
||||
le_struct_swap( bmp_swap, &hdr );
|
||||
FS_Write( pfile, &hdr, sizeof( bmp_t ));
|
||||
le_struct_swap( bmp_swap, &hdr );
|
||||
|
||||
pbBmpBits = Mem_Malloc( host.imagepool, cbBmpBits );
|
||||
byte *pbBmpBits = Mem_Malloc( host.imagepool, cbBmpBits );
|
||||
|
||||
if( pixel_size == 1 )
|
||||
{
|
||||
pb = pix->palette;
|
||||
|
||||
// copy over used entries
|
||||
for( i = 0; i < (int)hdr.colors; i++ )
|
||||
for( int i = 0; i < (int)hdr.colors; i++ )
|
||||
{
|
||||
rgrgbPalette[i][2] = *pb++;
|
||||
rgrgbPalette[i][1] = *pb++;
|
||||
@@ -447,9 +439,9 @@ qboolean Image_SaveBMP( const char *name, rgbdata_t *pix )
|
||||
|
||||
pb = pix->buffer;
|
||||
|
||||
for( y = 0; y < hdr.height; y++ )
|
||||
for( int y = 0; y < hdr.height; y++ )
|
||||
{
|
||||
i = (hdr.height - 1 - y ) * (hdr.width);
|
||||
int i = (hdr.height - 1 - y ) * (hdr.width);
|
||||
|
||||
if( pixel_size == 1 )
|
||||
{
|
||||
@@ -457,7 +449,7 @@ qboolean Image_SaveBMP( const char *name, rgbdata_t *pix )
|
||||
}
|
||||
else
|
||||
{
|
||||
for( x = 0; x < pix->width; x++ )
|
||||
for( int x = 0; x < pix->width; x++ )
|
||||
{
|
||||
// 24 bit
|
||||
qboolean be = ImageBigEndian( pix->type );
|
||||
|
||||
@@ -62,22 +62,18 @@ le_struct_end();
|
||||
|
||||
static qboolean Image_CheckDXT3Alpha( dds_t *hdr, byte *fin )
|
||||
{
|
||||
word sAlpha;
|
||||
byte *alpha;
|
||||
int x, y, i, j;
|
||||
|
||||
for( y = 0; y < hdr->dwHeight; y += 4 )
|
||||
for( int y = 0; y < hdr->dwHeight; y += 4 )
|
||||
{
|
||||
for( x = 0; x < hdr->dwWidth; x += 4 )
|
||||
for( int x = 0; x < hdr->dwWidth; x += 4 )
|
||||
{
|
||||
alpha = fin + 8;
|
||||
byte *alpha = fin + 8;
|
||||
fin += 16;
|
||||
|
||||
for( j = 0; j < 4; j++ )
|
||||
for( int j = 0; j < 4; j++ )
|
||||
{
|
||||
sAlpha = alpha[2*j] + 256 * alpha[2*j+1];
|
||||
word sAlpha = alpha[2*j] + 256 * alpha[2*j+1];
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
if((( x + i ) < hdr->dwWidth ) && (( y + j ) < hdr->dwHeight ))
|
||||
{
|
||||
@@ -95,27 +91,23 @@ static qboolean Image_CheckDXT3Alpha( dds_t *hdr, byte *fin )
|
||||
|
||||
static qboolean Image_CheckDXT5Alpha( dds_t *hdr, byte *fin )
|
||||
{
|
||||
uint bits;
|
||||
byte *alphamask;
|
||||
int x, y, i, j;
|
||||
|
||||
for( y = 0; y < hdr->dwHeight; y += 4 )
|
||||
for( int y = 0; y < hdr->dwHeight; y += 4 )
|
||||
{
|
||||
for( x = 0; x < hdr->dwWidth; x += 4 )
|
||||
for( int x = 0; x < hdr->dwWidth; x += 4 )
|
||||
{
|
||||
if( y >= hdr->dwHeight || x >= hdr->dwWidth )
|
||||
break;
|
||||
|
||||
alphamask = fin + 2;
|
||||
byte *alphamask = fin + 2;
|
||||
fin += 8;
|
||||
fin += 8;
|
||||
|
||||
// last three bytes
|
||||
bits = (alphamask[3]) | (alphamask[4] << 8) | (alphamask[5] << 16);
|
||||
uint bits = (alphamask[3]) | (alphamask[4] << 8) | (alphamask[5] << 16);
|
||||
|
||||
for( j = 2; j < 4; j++ )
|
||||
for( int j = 2; j < 4; j++ )
|
||||
{
|
||||
for( i = 0; i < 4; i++ )
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
// only put pixels out < width or height
|
||||
if((( x + i ) < hdr->dwWidth ) && (( y + j ) < hdr->dwHeight ))
|
||||
@@ -259,14 +251,13 @@ static void Image_DXTGetPixelFormat( dds_t *hdr, dds_header_dxt10_t *headerExt )
|
||||
static size_t Image_DXTCalcMipmapSize( dds_t *hdr )
|
||||
{
|
||||
size_t buffsize = 0;
|
||||
int i, width, height, depth;
|
||||
|
||||
// now correct buffer size
|
||||
for( i = 0; i < Q_max( 1, ( hdr->dwMipMapCount )); i++ )
|
||||
for( int i = 0; i < Q_max( 1, ( hdr->dwMipMapCount )); i++ )
|
||||
{
|
||||
width = Q_max( 1, ( hdr->dwWidth >> i ));
|
||||
height = Q_max( 1, ( hdr->dwHeight >> i ));
|
||||
depth = Q_max( 1, ( image.depth >> i ));
|
||||
int width = Q_max( 1, ( hdr->dwWidth >> i ));
|
||||
int height = Q_max( 1, ( hdr->dwHeight >> i ));
|
||||
int depth = Q_max( 1, ( image.depth >> i ));
|
||||
buffsize += Image_ComputeSize( image.type, width, height, depth );
|
||||
}
|
||||
|
||||
@@ -325,8 +316,6 @@ Image_LoadDDS
|
||||
qboolean Image_LoadDDS( const char *name, const byte *buffer, fs_offset_t filesize )
|
||||
{
|
||||
dds_t header;
|
||||
byte *fin;
|
||||
int headersOffset;
|
||||
dds_header_dxt10_t header2;
|
||||
|
||||
if( filesize < sizeof( header ))
|
||||
@@ -350,7 +339,7 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
return false;
|
||||
}
|
||||
|
||||
headersOffset = sizeof( header );
|
||||
int headersOffset = sizeof( header );
|
||||
if( header.dsPixelFormat.dwFourCC == TYPE_DX10 )
|
||||
{
|
||||
memcpy( &header2, buffer + sizeof( header ), sizeof( header2 ));
|
||||
@@ -381,7 +370,7 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
|
||||
image.size = Image_DXTCalcSize( name, &header, filesize - headersOffset );
|
||||
if( image.size == 0 ) return false; // just in case
|
||||
fin = (byte *)( buffer + headersOffset );
|
||||
byte *fin = (byte *)( buffer + headersOffset );
|
||||
|
||||
// copy an encode method
|
||||
image.encode = (word)header.dwReserved1[0];
|
||||
|
||||
@@ -98,7 +98,6 @@ static qboolean Image_KTX2Parse( const ktx2_header_t *header, const byte *buffer
|
||||
ktx2_index_t index;
|
||||
size_t total_size = 0;
|
||||
size_t max_offset = 0;
|
||||
int mip, cursor;
|
||||
const byte *const levels_begin = buffer + KTX2_LEVELS_OFFSET;
|
||||
|
||||
// Sets image.type and image.flags
|
||||
@@ -155,7 +154,7 @@ static qboolean Image_KTX2Parse( const ktx2_header_t *header, const byte *buffer
|
||||
memcpy( &index, buffer + KTX2_IDENTIFIER_SIZE + sizeof( ktx2_header_t ), sizeof( index ));
|
||||
le_struct_swap( ktx2_index_swap, &index );
|
||||
|
||||
for( mip = 0; mip < header->levelCount; ++mip )
|
||||
for( int mip = 0; mip < header->levelCount; ++mip )
|
||||
{
|
||||
const uint32_t width = Q_max( 1, ( header->pixelWidth >> mip ));
|
||||
const uint32_t height = Q_max( 1, ( header->pixelHeight >> mip ));
|
||||
@@ -185,7 +184,7 @@ static qboolean Image_KTX2Parse( const ktx2_header_t *header, const byte *buffer
|
||||
image.rgba = Mem_Malloc( host.imagepool, image.size );
|
||||
memcpy( image.rgba, buffer, image.size );
|
||||
|
||||
for( mip = 0, cursor = 0; mip < header->levelCount; ++mip )
|
||||
for( int mip = 0, cursor = 0; mip < header->levelCount; ++mip )
|
||||
{
|
||||
ktx2_level_t level;
|
||||
memcpy( &level, levels_begin + mip * sizeof( level ), sizeof( level ));
|
||||
|
||||
@@ -169,8 +169,6 @@ void Image_Reset( void )
|
||||
|
||||
static MALLOC_LIKE( FS_FreeImage, 1 ) rgbdata_t *ImagePack( const char *name )
|
||||
{
|
||||
rgbdata_t *pack;
|
||||
|
||||
Image_ReportLookupsCount( name );
|
||||
|
||||
if( Image_CheckFlag( IL_LOAD_PLAYER_DECAL ))
|
||||
@@ -185,7 +183,7 @@ static MALLOC_LIKE( FS_FreeImage, 1 ) rgbdata_t *ImagePack( const char *name )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pack = Mem_Calloc( host.imagepool, sizeof( *pack ));
|
||||
rgbdata_t *pack = Mem_Calloc( host.imagepool, sizeof( *pack ));
|
||||
|
||||
if( image.cubemap )
|
||||
{
|
||||
@@ -228,7 +226,6 @@ FS_AddSideToPack
|
||||
*/
|
||||
static qboolean FS_AddSideToPack( int adjust_flags )
|
||||
{
|
||||
byte *out, *flipped;
|
||||
qboolean resampled = false;
|
||||
|
||||
// first side set average size for all cubemap sides!
|
||||
@@ -247,12 +244,12 @@ static qboolean FS_AddSideToPack( int adjust_flags )
|
||||
return false;
|
||||
|
||||
// flip image if needed
|
||||
flipped = Image_FlipInternal( image.rgba, &image.width, &image.height, image.source_type, adjust_flags );
|
||||
byte *flipped = Image_FlipInternal( image.rgba, &image.width, &image.height, image.source_type, adjust_flags );
|
||||
if( !flipped ) return false; // try to reasmple dxt?
|
||||
if( flipped != image.rgba ) image.rgba = Image_Copy( image.size );
|
||||
|
||||
// resampling image if needed
|
||||
out = Image_ResampleInternal((uint *)image.rgba, image.width, image.height, image.source_width, image.source_height, image.source_type, &resampled );
|
||||
byte *out = Image_ResampleInternal((uint *)image.rgba, image.width, image.height, image.source_width, image.source_height, image.source_type, &resampled );
|
||||
if( !out ) return false; // try to reasmple dxt?
|
||||
if( resampled ) image.rgba = Image_Copy( image.size );
|
||||
|
||||
@@ -268,12 +265,10 @@ static qboolean FS_AddSideToPack( int adjust_flags )
|
||||
|
||||
static const loadpixformat_t *Image_GetLoadFormatForExtension( const char *ext )
|
||||
{
|
||||
const loadpixformat_t *format;
|
||||
|
||||
if( COM_StringEmpty( ext ))
|
||||
return NULL;
|
||||
|
||||
for( format = image.loadformats; format->ext; format++ )
|
||||
for( const loadpixformat_t *format = image.loadformats; format->ext; format++ )
|
||||
{
|
||||
if( !Q_stricmp( ext, format->ext ))
|
||||
return format;
|
||||
@@ -316,10 +311,9 @@ static qboolean Image_ProbeLoad_( const loadpixformat_t *fmt, const char *name,
|
||||
qboolean success = false;
|
||||
fs_offset_t filesize;
|
||||
string path;
|
||||
byte *f;
|
||||
|
||||
Q_snprintf( path, sizeof( path ), "%s%s.%s", name, suffix, fmt->ext );
|
||||
f = FS_LoadFile( path, &filesize, false );
|
||||
byte *f = FS_LoadFile( path, &filesize, false );
|
||||
|
||||
Image_IncrementLookupTime();
|
||||
|
||||
@@ -335,24 +329,21 @@ static qboolean Image_ProbeLoad_( const loadpixformat_t *fmt, const char *name,
|
||||
|
||||
static qboolean Image_ProbeLoad2( const char *name, const char *suffix, int override_hint )
|
||||
{
|
||||
const loadpixformat_t *fmt;
|
||||
search_t *t;
|
||||
string pattern;
|
||||
int i;
|
||||
|
||||
Q_snprintf( pattern, sizeof( pattern ), "%s%s.*", name, suffix );
|
||||
|
||||
t = FS_Search( pattern, true, false );
|
||||
search_t *t = FS_Search( pattern, true, false );
|
||||
|
||||
if( !t )
|
||||
return false;
|
||||
|
||||
// we now have to check every extension
|
||||
// to keep the loading order
|
||||
for( fmt = image.loadformats; fmt->ext; fmt++ )
|
||||
for( const loadpixformat_t *fmt = image.loadformats; fmt->ext; fmt++ )
|
||||
{
|
||||
fs_offset_t filesize;
|
||||
byte *data;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < t->numfilenames; i++ )
|
||||
{
|
||||
@@ -366,7 +357,7 @@ static qboolean Image_ProbeLoad2( const char *name, const char *suffix, int over
|
||||
if( i == t->numfilenames )
|
||||
continue;
|
||||
|
||||
data = FS_LoadFile( t->filenames[i], &filesize, false );
|
||||
byte *data = FS_LoadFile( t->filenames[i], &filesize, false );
|
||||
Image_IncrementLookupTime();
|
||||
|
||||
// can't load file, ignore
|
||||
@@ -417,14 +408,13 @@ rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size )
|
||||
{
|
||||
const char *ext = COM_FileExtension( filename );
|
||||
string loadname;
|
||||
int i, j;
|
||||
const loadpixformat_t *extfmt;
|
||||
|
||||
Q_strncpy( loadname, filename, sizeof( loadname ));
|
||||
|
||||
// we needs to compare file extension with list of supported formats
|
||||
// and be sure what is real extension, not a filename with dot
|
||||
if(( extfmt = Image_GetLoadFormatForExtension( ext )))
|
||||
const loadpixformat_t *extfmt = Image_GetLoadFormatForExtension( ext );
|
||||
if( extfmt )
|
||||
COM_StripExtension( loadname );
|
||||
|
||||
Image_Reset(); // clear old image
|
||||
@@ -437,11 +427,11 @@ rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size )
|
||||
return ImagePack( filename );
|
||||
|
||||
// check all cubemap sides with package suffix
|
||||
for( j = 0; j < ARRAYSIZE( load_cubemap ); j++ )
|
||||
for( int j = 0; j < ARRAYSIZE( load_cubemap ); j++ )
|
||||
{
|
||||
const cubepack_t *cmap = &load_cubemap[j];
|
||||
|
||||
for( i = 0; i < 6; i++ )
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
if( Image_ProbeLoad( extfmt, loadname, cmap->type[i].suf, cmap->type[i].hint ))
|
||||
{
|
||||
@@ -507,7 +497,6 @@ qboolean FS_SaveImage( const char *filename, rgbdata_t *pix )
|
||||
const char *ext = COM_FileExtension( filename );
|
||||
qboolean anyformat = COM_StringEmpty( ext );
|
||||
string path, savename;
|
||||
const savepixformat_t *format;
|
||||
|
||||
if( !pix || !pix->buffer || anyformat )
|
||||
{
|
||||
@@ -522,7 +511,6 @@ qboolean FS_SaveImage( const char *filename, rgbdata_t *pix )
|
||||
if( pix->flags & (IMAGE_CUBEMAP|IMAGE_SKYBOX))
|
||||
{
|
||||
size_t realSize = pix->size; // keep real pic size
|
||||
byte *picBuffer; // to avoid corrupt memory on free data
|
||||
const suffix_t *box;
|
||||
int i;
|
||||
|
||||
@@ -538,10 +526,10 @@ qboolean FS_SaveImage( const char *filename, rgbdata_t *pix )
|
||||
}
|
||||
|
||||
pix->size /= 6; // now set as side size
|
||||
picBuffer = pix->buffer;
|
||||
byte *picBuffer = pix->buffer;
|
||||
|
||||
// save all sides seperately
|
||||
for( format = image.saveformats; format && format->ext; format++ )
|
||||
for( const savepixformat_t *format = image.saveformats; format && format->ext; format++ )
|
||||
{
|
||||
if( !Q_stricmp( ext, format->ext ))
|
||||
{
|
||||
@@ -565,7 +553,7 @@ qboolean FS_SaveImage( const char *filename, rgbdata_t *pix )
|
||||
}
|
||||
else
|
||||
{
|
||||
for( format = image.saveformats; format && format->ext; format++ )
|
||||
for( const savepixformat_t *format = image.saveformats; format && format->ext; format++ )
|
||||
{
|
||||
if( !Q_stricmp( ext, format->ext ))
|
||||
{
|
||||
@@ -610,13 +598,12 @@ make an image copy
|
||||
*/
|
||||
rgbdata_t *FS_CopyImage( const rgbdata_t *in )
|
||||
{
|
||||
rgbdata_t *out;
|
||||
int palSize = 0;
|
||||
|
||||
if( !in )
|
||||
return NULL;
|
||||
|
||||
out = Mem_Malloc( host.imagepool, sizeof( *out ));
|
||||
rgbdata_t *out = Mem_Malloc( host.imagepool, sizeof( *out ));
|
||||
*out = *in;
|
||||
|
||||
switch( in->type )
|
||||
@@ -660,10 +647,8 @@ static void GeneratePixel( byte *pix, uint i, uint j, uint w, uint h, qboolean g
|
||||
|
||||
static void Test_CheckImage( const char *name, rgbdata_t *rgb )
|
||||
{
|
||||
rgbdata_t *load;
|
||||
|
||||
// test reading
|
||||
load = FS_LoadImage( name, NULL, 0 );
|
||||
rgbdata_t *load = FS_LoadImage( name, NULL, 0 );
|
||||
TASSERT( load->width == rgb->width )
|
||||
TASSERT( load->height == rgb->height )
|
||||
TASSERT( load->type == rgb->type )
|
||||
@@ -677,9 +662,7 @@ static void Test_CheckImage( const char *name, rgbdata_t *rgb )
|
||||
void Test_RunImagelib( void )
|
||||
{
|
||||
rgbdata_t rgb = { 0 };
|
||||
byte *buf;
|
||||
const char *extensions[] = { "tga", "png", "bmp" };
|
||||
uint i, j;
|
||||
|
||||
Image_Setup();
|
||||
|
||||
@@ -689,26 +672,25 @@ void Test_RunImagelib( void )
|
||||
rgb.type = PF_RGBA_32;
|
||||
rgb.flags = IMAGE_HAS_ALPHA;
|
||||
rgb.size = rgb.width * rgb.height * 4;
|
||||
buf = rgb.buffer = Z_Malloc( rgb.size );
|
||||
byte *buf = rgb.buffer = Z_Malloc( rgb.size );
|
||||
|
||||
for( i = 0; i < rgb.height; i++ )
|
||||
for( uint i = 0; i < rgb.height; i++ )
|
||||
{
|
||||
for( j = 0; j < rgb.width; j++ )
|
||||
for( uint j = 0; j < rgb.width; j++ )
|
||||
{
|
||||
GeneratePixel( buf, i, j, rgb.width, rgb.height, true );
|
||||
buf += 4;
|
||||
}
|
||||
}
|
||||
|
||||
for( i = 0; i < sizeof(extensions) / sizeof(extensions[0]); i++ )
|
||||
for( uint i = 0; i < sizeof(extensions) / sizeof(extensions[0]); i++ )
|
||||
{
|
||||
qboolean ret;
|
||||
char name[MAX_VA_STRING];
|
||||
|
||||
Q_snprintf( name, sizeof( name ), "test_gen.%s", extensions[i] );
|
||||
|
||||
// test saving
|
||||
ret = FS_SaveImage( name, &rgb );
|
||||
qboolean ret = FS_SaveImage( name, &rgb );
|
||||
Con_Printf( "Checking if we can save images in '%s' format...\n", extensions[i] );
|
||||
ASSERT(ret == true);
|
||||
|
||||
|
||||
@@ -33,12 +33,11 @@ Image_LoadPNG
|
||||
*/
|
||||
qboolean Image_LoadPNG( const char *name, const byte *buffer, fs_offset_t filesize )
|
||||
{
|
||||
int ret;
|
||||
short p, a, b, c, pa, pb, pc;
|
||||
byte *buf_p, *pixbuf, *raw, *prior, *idat_buf = NULL, *uncompressed_buffer = NULL;
|
||||
byte *pixbuf, *raw, *prior, *idat_buf = NULL, *uncompressed_buffer = NULL;
|
||||
byte *pallete = NULL, *trns = NULL;
|
||||
uint chunk_len, trns_len = 0, plte_len = 0, crc32, crc32_check, oldsize = 0, newsize = 0, rowsize;
|
||||
uint uncompressed_size, pixel_size, pixel_count, i, y, filter_type, chunk_sign, r_alpha, g_alpha, b_alpha;
|
||||
uint chunk_len, trns_len = 0, plte_len = 0, crc32, crc32_check, oldsize = 0, newsize = 0;
|
||||
uint pixel_size, i, y, filter_type, chunk_sign, r_alpha, g_alpha, b_alpha;
|
||||
qboolean has_iend_chunk = false;
|
||||
z_stream stream = {0};
|
||||
png_t png_hdr;
|
||||
@@ -46,7 +45,7 @@ qboolean Image_LoadPNG( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
if( filesize < sizeof( png_hdr ))
|
||||
return false;
|
||||
|
||||
buf_p = (byte *)buffer;
|
||||
byte *buf_p = (byte *)buffer;
|
||||
|
||||
// get png header
|
||||
memcpy( &png_hdr, buffer, sizeof( png_t ));
|
||||
@@ -265,7 +264,7 @@ qboolean Image_LoadPNG( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
}
|
||||
|
||||
image.type = PF_RGBA_32; // always exctracted to 32-bit buffer
|
||||
pixel_count = image.height * image.width;
|
||||
uint pixel_count = image.height * image.width;
|
||||
image.size = pixel_count * 4;
|
||||
|
||||
if( png_hdr.ihdr_chunk.colortype & PNG_CT_RGB )
|
||||
@@ -276,9 +275,9 @@ qboolean Image_LoadPNG( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
|
||||
image.depth = 1;
|
||||
|
||||
rowsize = pixel_size * image.width;
|
||||
uint rowsize = pixel_size * image.width;
|
||||
|
||||
uncompressed_size = image.height * ( rowsize + 1 ); // +1 for filter
|
||||
uint uncompressed_size = image.height * ( rowsize + 1 ); // +1 for filter
|
||||
uncompressed_buffer = Mem_Malloc( host.imagepool, uncompressed_size );
|
||||
|
||||
stream.next_in = idat_buf;
|
||||
@@ -295,7 +294,7 @@ qboolean Image_LoadPNG( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = inflate( &stream, Z_NO_FLUSH );
|
||||
int ret = inflate( &stream, Z_NO_FLUSH );
|
||||
inflateEnd( &stream );
|
||||
|
||||
Mem_Free( idat_buf );
|
||||
@@ -506,10 +505,9 @@ Image_SavePNG
|
||||
*/
|
||||
qboolean Image_SavePNG( const char *name, rgbdata_t *pix )
|
||||
{
|
||||
int ret;
|
||||
uint y, outsize, pixel_size, filtered_size, idat_len;
|
||||
uint ihdr_len, crc32, rowsize, big_idat_len;
|
||||
byte *in, *buffer, *out, *filtered_buffer, *rowend;
|
||||
uint pixel_size;
|
||||
uint crc32;
|
||||
byte *out;
|
||||
z_stream stream = {0};
|
||||
png_t png_hdr;
|
||||
png_footer_t png_ftr;
|
||||
@@ -537,19 +535,20 @@ qboolean Image_SavePNG( const char *name, rgbdata_t *pix )
|
||||
return false;
|
||||
}
|
||||
|
||||
rowsize = pix->width * pixel_size;
|
||||
uint rowsize = pix->width * pixel_size;
|
||||
|
||||
// get filtered image size
|
||||
filtered_size = ( rowsize + 1 ) * pix->height;
|
||||
uint filtered_size = ( rowsize + 1 ) * pix->height;
|
||||
|
||||
byte *filtered_buffer;
|
||||
out = filtered_buffer = Mem_Malloc( host.imagepool, filtered_size );
|
||||
|
||||
// apply adaptive filter to image
|
||||
for( y = 0; y < pix->height; y++ )
|
||||
for( uint y = 0; y < pix->height; y++ )
|
||||
{
|
||||
in = pix->buffer + y * pix->width * pixel_size;
|
||||
byte *in = pix->buffer + y * pix->width * pixel_size;
|
||||
*out++ = PNG_F_NONE;
|
||||
rowend = in + rowsize;
|
||||
byte *rowend = in + rowsize;
|
||||
for( ; in < rowend; in += pixel_size )
|
||||
{
|
||||
*out++ = be ? in[2] : in[0];
|
||||
@@ -562,13 +561,13 @@ qboolean Image_SavePNG( const char *name, rgbdata_t *pix )
|
||||
}
|
||||
|
||||
// get IHDR chunk length
|
||||
ihdr_len = sizeof( png_ihdr_t );
|
||||
uint ihdr_len = sizeof( png_ihdr_t );
|
||||
|
||||
// predict IDAT chunk length
|
||||
idat_len = deflateBound( NULL, filtered_size );
|
||||
uint idat_len = deflateBound( NULL, filtered_size );
|
||||
|
||||
// calculate PNG filesize
|
||||
outsize = sizeof( png_t );
|
||||
uint outsize = sizeof( png_t );
|
||||
outsize += sizeof( idat_len );
|
||||
outsize += sizeof( idat_sign );
|
||||
outsize += idat_len;
|
||||
@@ -612,6 +611,7 @@ qboolean Image_SavePNG( const char *name, rgbdata_t *pix )
|
||||
// write IHDR chunk CRC
|
||||
png_hdr.ihdr_crc32 = BigLong( crc32 );
|
||||
|
||||
byte *buffer;
|
||||
out = buffer = (byte *)Mem_Malloc( host.imagepool, outsize );
|
||||
|
||||
stream.next_in = filtered_buffer;
|
||||
@@ -628,7 +628,7 @@ qboolean Image_SavePNG( const char *name, rgbdata_t *pix )
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = deflate( &stream, Z_FINISH );
|
||||
int ret = deflate( &stream, Z_FINISH );
|
||||
deflateEnd( &stream );
|
||||
|
||||
Mem_Free( filtered_buffer );
|
||||
@@ -650,7 +650,7 @@ qboolean Image_SavePNG( const char *name, rgbdata_t *pix )
|
||||
out += sizeof( png_t );
|
||||
|
||||
// convert IDAT chunk length to big endian
|
||||
big_idat_len = BigLong( idat_len );
|
||||
uint big_idat_len = BigLong( idat_len );
|
||||
|
||||
// write IDAT chunk length
|
||||
memcpy( out, &big_idat_len, sizeof( idat_len ));
|
||||
|
||||
@@ -68,15 +68,13 @@ static int radpower[initrad]; // radpower for precomputation
|
||||
|
||||
static void initnet( byte *thepic, int len, int sample )
|
||||
{
|
||||
register int i, *p;
|
||||
|
||||
thepicture = thepic;
|
||||
lengthcount = len;
|
||||
samplefac = sample;
|
||||
|
||||
for( i = 0; i < netsize; i++ )
|
||||
for( register int i = 0; i < netsize; i++ )
|
||||
{
|
||||
p = network[i];
|
||||
register int *p = network[i];
|
||||
p[0] = p[1] = p[2] = (i << (netbiasshift + 8)) / netsize;
|
||||
freq[i] = intbias / netsize; // 1 / netsize
|
||||
bias[i] = 0;
|
||||
@@ -86,15 +84,13 @@ static void initnet( byte *thepic, int len, int sample )
|
||||
// Unbias network to give byte values 0..255 and record position i to prepare for sort
|
||||
static void unbiasnet( void )
|
||||
{
|
||||
int i, j, temp;
|
||||
|
||||
for( i = 0; i < netsize; i++ )
|
||||
for( int i = 0; i < netsize; i++ )
|
||||
{
|
||||
for( j = 0; j < 3; j++ )
|
||||
for( int j = 0; j < 3; j++ )
|
||||
{
|
||||
// OLD CODE: network[i][j] >>= netbiasshift;
|
||||
// Fix based on bug report by Juergen Weigert jw@suse.de
|
||||
temp = (network[i][j] + (1 << (netbiasshift - 1))) >> netbiasshift;
|
||||
int temp = (network[i][j] + (1 << (netbiasshift - 1))) >> netbiasshift;
|
||||
if( temp > 255 ) temp = 255;
|
||||
network[i][j] = temp;
|
||||
}
|
||||
@@ -106,21 +102,18 @@ static void unbiasnet( void )
|
||||
// Insertion sort of network and building of netindex[0..255] (to do after unbias)
|
||||
static void inxbuild( void )
|
||||
{
|
||||
register int *p, *q;
|
||||
register int i, j, smallpos, smallval;
|
||||
int previouscol, startpos;
|
||||
int previouscol = 0;
|
||||
int startpos = 0;
|
||||
|
||||
previouscol = 0;
|
||||
startpos = 0;
|
||||
|
||||
for( i = 0; i < netsize; i++ )
|
||||
for( register int i = 0; i < netsize; i++ )
|
||||
{
|
||||
p = network[i];
|
||||
smallpos = i;
|
||||
smallval = p[1]; // index on g
|
||||
register int *p = network[i];
|
||||
register int smallpos = i;
|
||||
register int smallval = p[1]; // index on g
|
||||
|
||||
// find smallest in i..netsize-1
|
||||
for( j = i + 1; j < netsize; j++ )
|
||||
register int *q;
|
||||
for( register int j = i + 1; j < netsize; j++ )
|
||||
{
|
||||
q = network[j];
|
||||
if( q[1] < smallval )
|
||||
@@ -136,6 +129,7 @@ static void inxbuild( void )
|
||||
// swap p (i) and q (smallpos) entries
|
||||
if( i != smallpos )
|
||||
{
|
||||
register int j;
|
||||
j = q[0]; q[0] = p[0]; p[0] = j;
|
||||
j = q[1]; q[1] = p[1]; p[1] = j;
|
||||
j = q[2]; q[2] = p[2]; p[2] = j;
|
||||
@@ -147,7 +141,7 @@ static void inxbuild( void )
|
||||
{
|
||||
netindex[previouscol] = (startpos+i) >> 1;
|
||||
|
||||
for( j = previouscol + 1; j < smallval; j++ )
|
||||
for( register int j = previouscol + 1; j < smallval; j++ )
|
||||
netindex[j] = i;
|
||||
|
||||
previouscol = smallval;
|
||||
@@ -157,7 +151,7 @@ static void inxbuild( void )
|
||||
|
||||
netindex[previouscol] = (startpos + maxnetpos)>>1;
|
||||
|
||||
for( j = previouscol + 1; j < 256; j++ )
|
||||
for( int j = previouscol + 1; j < 256; j++ )
|
||||
netindex[j] = maxnetpos; // really 256
|
||||
}
|
||||
|
||||
@@ -165,14 +159,13 @@ static void inxbuild( void )
|
||||
// Search for BGR values 0..255 (after net is unbiased) and return colour index
|
||||
static int inxsearch( int r, int g, int b )
|
||||
{
|
||||
register int i, j, dist, a, bestd;
|
||||
register int dist, a;
|
||||
register int *p;
|
||||
int best;
|
||||
|
||||
bestd = 1000; // biggest possible dist is 256 * 3
|
||||
best = -1;
|
||||
i = netindex[g]; // index on g
|
||||
j = i - 1; // start at netindex[g] and work outwards
|
||||
register int bestd = 1000; // biggest possible dist is 256 * 3
|
||||
int best = -1;
|
||||
register int i = netindex[g]; // index on g
|
||||
register int j = i - 1; // start at netindex[g] and work outwards
|
||||
|
||||
while(( i < netsize ) || ( j >= 0 ))
|
||||
{
|
||||
@@ -246,25 +239,22 @@ static int inxsearch( int r, int g, int b )
|
||||
// Search for biased BGR values
|
||||
static int contest( int r, int g, int b )
|
||||
{
|
||||
register int *p, *f, *n;
|
||||
register int i, dist, a, biasdist, betafreq;
|
||||
int bestpos, bestbiaspos, bestd, bestbiasd;
|
||||
|
||||
// finds closest neuron (min dist) and updates freq
|
||||
// finds best neuron (min dist-bias) and returns position
|
||||
// for frequently chosen neurons, freq[i] is high and bias[i] is negative
|
||||
// bias[i] = gamma * ((1 / netsize) - freq[i])
|
||||
bestd = INT_MAX;
|
||||
bestbiasd = bestd;
|
||||
bestpos = -1;
|
||||
bestbiaspos = bestpos;
|
||||
p = bias;
|
||||
f = freq;
|
||||
int bestd = INT_MAX;
|
||||
int bestbiasd = bestd;
|
||||
int bestpos = -1;
|
||||
int bestbiaspos = bestpos;
|
||||
register int *p = bias;
|
||||
register int *f = freq;
|
||||
|
||||
for( i = 0; i < netsize; i++ )
|
||||
for( register int i = 0; i < netsize; i++ )
|
||||
{
|
||||
n = network[i];
|
||||
dist = n[2] - b;
|
||||
register int *n = network[i];
|
||||
register int dist = n[2] - b;
|
||||
register int a;
|
||||
if( dist < 0 ) dist = -dist;
|
||||
a = n[1] - g;
|
||||
if( a < 0 ) a = -a;
|
||||
@@ -279,7 +269,7 @@ static int contest( int r, int g, int b )
|
||||
bestpos = i;
|
||||
}
|
||||
|
||||
biasdist = dist - ((*p) >> (intbiasshift - netbiasshift));
|
||||
register int biasdist = dist - ((*p) >> (intbiasshift - netbiasshift));
|
||||
|
||||
if( biasdist < bestbiasd )
|
||||
{
|
||||
@@ -287,7 +277,7 @@ static int contest( int r, int g, int b )
|
||||
bestbiaspos = i;
|
||||
}
|
||||
|
||||
betafreq = (*f >> betashift);
|
||||
register int betafreq = (*f >> betashift);
|
||||
*f++ -= betafreq;
|
||||
*p++ += (betafreq << gammashift);
|
||||
}
|
||||
@@ -301,9 +291,7 @@ static int contest( int r, int g, int b )
|
||||
// Move neuron i towards biased (b,g,r) by factor alpha
|
||||
static void altersingle( int alpha, int i, int r, int g, int b )
|
||||
{
|
||||
register int *n;
|
||||
|
||||
n = network[i]; // alter hit neuron
|
||||
register int *n = network[i]; // alter hit neuron
|
||||
*n -= (alpha * (*n - r)) / initalpha;
|
||||
n++;
|
||||
*n -= (alpha * (*n - g)) / initalpha;
|
||||
@@ -314,21 +302,19 @@ static void altersingle( int alpha, int i, int r, int g, int b )
|
||||
// Move adjacent neurons by precomputed alpha*(1-((i-j)^2/[r]^2)) in radpower[|i-j|]
|
||||
static void alterneigh( int rad, int i, int r, int g, int b )
|
||||
{
|
||||
register int j, k, lo, hi, a;
|
||||
register int *p, *q;
|
||||
|
||||
lo = i - rad;
|
||||
register int lo = i - rad;
|
||||
if( lo < -1 ) lo = -1;
|
||||
hi = i + rad;
|
||||
register int hi = i + rad;
|
||||
if( hi > netsize ) hi = netsize;
|
||||
|
||||
j = i + 1;
|
||||
k = i - 1;
|
||||
q = radpower;
|
||||
register int j = i + 1;
|
||||
register int k = i - 1;
|
||||
register int *q = radpower;
|
||||
|
||||
while(( j < hi ) || ( k > lo ))
|
||||
{
|
||||
a = (*(++q));
|
||||
register int a = (*(++q));
|
||||
register int *p;
|
||||
|
||||
if( j < hi )
|
||||
{
|
||||
@@ -357,24 +343,20 @@ static void alterneigh( int rad, int i, int r, int g, int b )
|
||||
// Main Learning Loop
|
||||
static void learn( void )
|
||||
{
|
||||
register byte *p;
|
||||
register int i, j, r, g, b;
|
||||
int radius, rad, alpha, step;
|
||||
int delta, samplepixels;
|
||||
byte *lim;
|
||||
int step;
|
||||
|
||||
alphadec = 30 + ((samplefac - 1) / 3);
|
||||
p = thepicture;
|
||||
lim = thepicture + lengthcount;
|
||||
samplepixels = lengthcount / (image.bpp * samplefac);
|
||||
delta = samplepixels / ncycles;
|
||||
alpha = initalpha;
|
||||
radius = initradius;
|
||||
register byte *p = thepicture;
|
||||
byte *lim = thepicture + lengthcount;
|
||||
int samplepixels = lengthcount / (image.bpp * samplefac);
|
||||
int delta = samplepixels / ncycles;
|
||||
int alpha = initalpha;
|
||||
int radius = initradius;
|
||||
|
||||
rad = radius >> radiusbiasshift;
|
||||
int rad = radius >> radiusbiasshift;
|
||||
if( rad <= 1 ) rad = 0;
|
||||
|
||||
for( i = 0; i < rad; i++ )
|
||||
for( int i = 0; i < rad; i++ )
|
||||
radpower[i] = alpha * ((( rad * rad - i * i ) * radbias ) / ( rad * rad ));
|
||||
|
||||
if( delta <= 0 ) return;
|
||||
@@ -396,14 +378,14 @@ static void learn( void )
|
||||
step = prime4 * image.bpp;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
register int i = 0;
|
||||
|
||||
while( i < samplepixels )
|
||||
{
|
||||
r = p[0] << netbiasshift;
|
||||
g = p[1] << netbiasshift;
|
||||
b = p[2] << netbiasshift;
|
||||
j = contest( r, g, b );
|
||||
register int r = p[0] << netbiasshift;
|
||||
register int g = p[1] << netbiasshift;
|
||||
register int b = p[2] << netbiasshift;
|
||||
register int j = contest( r, g, b );
|
||||
|
||||
altersingle( alpha, j, r, g, b );
|
||||
if( rad ) alterneigh( rad, j, r, g, b ); // alter neighbours
|
||||
@@ -420,7 +402,7 @@ static void learn( void )
|
||||
rad = radius >> radiusbiasshift;
|
||||
if( rad <= 1 ) rad = 0;
|
||||
|
||||
for( j = 0; j < rad; j++ )
|
||||
for( int j = 0; j < rad; j++ )
|
||||
radpower[j] = alpha * ((( rad * rad - j * j ) * radbias ) / ( rad * rad ));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,19 +34,17 @@ Image_LoadTGA
|
||||
*/
|
||||
qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesize )
|
||||
{
|
||||
int i, columns, rows, row_inc, row, col;
|
||||
byte *buf_p, *pixbuf, *targa_rgba;
|
||||
int columns, rows, row_inc, row, col;
|
||||
byte *pixbuf;
|
||||
rgba_t palette[256];
|
||||
byte red = 0, green = 0, blue = 0, alpha = 0;
|
||||
int readpixelcount, pixelcount;
|
||||
uint reflectivity[3] = { 0, 0, 0 };
|
||||
qboolean compressed;
|
||||
tga_t targa_header;
|
||||
|
||||
if( filesize < sizeof( tga_t ))
|
||||
return false;
|
||||
|
||||
buf_p = (byte *)buffer;
|
||||
byte *buf_p = (byte *)buffer;
|
||||
targa_header.id_length = *buf_p++;
|
||||
targa_header.colormap_type = *buf_p++;
|
||||
targa_header.image_type = *buf_p++;
|
||||
@@ -87,7 +85,7 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
}
|
||||
if( targa_header.colormap_size == 24 )
|
||||
{
|
||||
for( i = 0; i < targa_header.colormap_length; i++ )
|
||||
for( int i = 0; i < targa_header.colormap_length; i++ )
|
||||
{
|
||||
palette[i][2] = *buf_p++;
|
||||
palette[i][1] = *buf_p++;
|
||||
@@ -97,7 +95,7 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
}
|
||||
else if( targa_header.colormap_size == 32 )
|
||||
{
|
||||
for( i = 0; i < targa_header.colormap_length; i++ )
|
||||
for( int i = 0; i < targa_header.colormap_length; i++ )
|
||||
{
|
||||
palette[i][2] = *buf_p++;
|
||||
palette[i][1] = *buf_p++;
|
||||
@@ -134,7 +132,7 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
rows = targa_header.height;
|
||||
|
||||
image.size = image.width * image.height * 4;
|
||||
targa_rgba = image.rgba = Mem_Malloc( host.imagepool, image.size );
|
||||
byte *targa_rgba = image.rgba = Mem_Malloc( host.imagepool, image.size );
|
||||
|
||||
// if bit 5 of attributes isn't set, the image has been stored from bottom to top
|
||||
if( !Image_CheckFlag( IL_DONTFLIP_TGA ) && targa_header.attributes & 0x20 )
|
||||
@@ -148,11 +146,11 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
row_inc = -columns * 4 * 2;
|
||||
}
|
||||
|
||||
compressed = ( targa_header.image_type == 9 || targa_header.image_type == 10 || targa_header.image_type == 11 );
|
||||
qboolean compressed = ( targa_header.image_type == 9 || targa_header.image_type == 10 || targa_header.image_type == 11 );
|
||||
for( row = col = 0; row < rows; )
|
||||
{
|
||||
pixelcount = 0x10000;
|
||||
readpixelcount = 0x10000;
|
||||
int pixelcount = 0x10000;
|
||||
int readpixelcount = 0x10000;
|
||||
|
||||
if( compressed )
|
||||
{
|
||||
@@ -245,9 +243,7 @@ Image_SaveTGA
|
||||
*/
|
||||
qboolean Image_SaveTGA( const char *name, rgbdata_t *pix )
|
||||
{
|
||||
int y, outsize, pixel_size;
|
||||
const uint8_t *bufend, *in;
|
||||
uint8_t *buffer, *out;
|
||||
int pixel_size;
|
||||
tga_t targa_header = {0};
|
||||
const char comment[] = "Generated by Xash ImageLib";
|
||||
|
||||
@@ -269,11 +265,11 @@ qboolean Image_SaveTGA( const char *name, rgbdata_t *pix )
|
||||
return false;
|
||||
}
|
||||
|
||||
outsize = pix->width * pix->height * pixel_size;
|
||||
int outsize = pix->width * pix->height * pixel_size;
|
||||
outsize += sizeof( tga_t );
|
||||
outsize += sizeof( comment ) - 1;
|
||||
|
||||
buffer = (uint8_t *)Mem_Malloc( host.imagepool, outsize );
|
||||
uint8_t *buffer = (uint8_t *)Mem_Malloc( host.imagepool, outsize );
|
||||
|
||||
// prepare header
|
||||
targa_header.id_length = sizeof( comment ) - 1; // tga comment length
|
||||
@@ -292,7 +288,7 @@ qboolean Image_SaveTGA( const char *name, rgbdata_t *pix )
|
||||
targa_header.attributes = 0;
|
||||
}
|
||||
|
||||
out = buffer;
|
||||
uint8_t *out = buffer;
|
||||
|
||||
le_struct_swap( tga_swap, &targa_header );
|
||||
memcpy( out, &targa_header, sizeof( tga_t ) );
|
||||
@@ -306,10 +302,10 @@ qboolean Image_SaveTGA( const char *name, rgbdata_t *pix )
|
||||
case PF_RGB_24:
|
||||
case PF_RGBA_32:
|
||||
// swap rgba to bgra and flip upside down
|
||||
for( y = pix->height - 1; y >= 0; y-- )
|
||||
for( int y = pix->height - 1; y >= 0; y-- )
|
||||
{
|
||||
in = pix->buffer + y * pix->width * pixel_size;
|
||||
bufend = in + pix->width * pixel_size;
|
||||
const uint8_t *in = pix->buffer + y * pix->width * pixel_size;
|
||||
const uint8_t *bufend = in + pix->width * pixel_size;
|
||||
for( ; in < bufend; in += pixel_size )
|
||||
{
|
||||
*out++ = in[2];
|
||||
@@ -323,10 +319,10 @@ qboolean Image_SaveTGA( const char *name, rgbdata_t *pix )
|
||||
case PF_BGR_24:
|
||||
case PF_BGRA_32:
|
||||
// flip upside down
|
||||
for( y = pix->height - 1; y >= 0; y-- )
|
||||
for( int y = pix->height - 1; y >= 0; y-- )
|
||||
{
|
||||
in = pix->buffer + y * pix->width * pixel_size;
|
||||
bufend = in + pix->width * pixel_size;
|
||||
const uint8_t *in = pix->buffer + y * pix->width * pixel_size;
|
||||
const uint8_t *bufend = in + pix->width * pixel_size;
|
||||
for( ; in < bufend; in += pixel_size )
|
||||
{
|
||||
*out++ = in[0];
|
||||
|
||||
@@ -174,9 +174,7 @@ void Image_Shutdown( void )
|
||||
|
||||
byte *Image_Copy( size_t size )
|
||||
{
|
||||
byte *out;
|
||||
|
||||
out = Mem_Realloc( host.imagepool, image.tempbuffer, size );
|
||||
byte *out = Mem_Realloc( host.imagepool, image.tempbuffer, size );
|
||||
image.tempbuffer = NULL;
|
||||
|
||||
return out;
|
||||
@@ -319,17 +317,16 @@ static void Image_SetPalette( const byte *pal, uint *d_table )
|
||||
|
||||
static void Image_ConvertPalTo24bit( rgbdata_t *pic )
|
||||
{
|
||||
byte *pal32, *pal24;
|
||||
byte *converted;
|
||||
int i;
|
||||
byte *pal24;
|
||||
|
||||
if( pic->type == PF_INDEXED_24 )
|
||||
return; // does nothing
|
||||
|
||||
byte *converted;
|
||||
pal24 = converted = Mem_Malloc( host.imagepool, 768 );
|
||||
pal32 = pic->palette;
|
||||
byte *pal32 = pic->palette;
|
||||
|
||||
for( i = 0; i < 256; i++, pal24 += 3, pal32 += 4 )
|
||||
for( int i = 0; i < 256; i++, pal24 += 3, pal32 += 4 )
|
||||
{
|
||||
pal24[0] = pal32[0];
|
||||
pal24[1] = pal32[1];
|
||||
@@ -436,27 +433,22 @@ void Image_GetPaletteLMP( const byte *pal, int rendermode )
|
||||
|
||||
void Image_PaletteHueReplace( byte *palSrc, int newHue, int start, int end, int pal_size )
|
||||
{
|
||||
float r, g, b;
|
||||
float maxcol, mincol;
|
||||
float hue, val, sat;
|
||||
int i;
|
||||
|
||||
hue = (float)(newHue * ( 360.0f / 255 ));
|
||||
float hue = (float)(newHue * ( 360.0f / 255 ));
|
||||
pal_size = bound( 3, pal_size, 4 );
|
||||
|
||||
for( i = start; i <= end; i++ )
|
||||
for( int i = start; i <= end; i++ )
|
||||
{
|
||||
r = palSrc[i*pal_size+0];
|
||||
g = palSrc[i*pal_size+1];
|
||||
b = palSrc[i*pal_size+2];
|
||||
float r = palSrc[i*pal_size+0];
|
||||
float g = palSrc[i*pal_size+1];
|
||||
float b = palSrc[i*pal_size+2];
|
||||
|
||||
maxcol = Q_max( Q_max( r, g ), b ) / 255.0f;
|
||||
mincol = Q_min( Q_min( r, g ), b ) / 255.0f;
|
||||
float maxcol = Q_max( Q_max( r, g ), b ) / 255.0f;
|
||||
float mincol = Q_min( Q_min( r, g ), b ) / 255.0f;
|
||||
|
||||
if( maxcol == 0 ) continue;
|
||||
|
||||
val = maxcol;
|
||||
sat = (maxcol - mincol) / maxcol;
|
||||
float val = maxcol;
|
||||
float sat = (maxcol - mincol) / maxcol;
|
||||
|
||||
mincol = val * (1.0f - sat);
|
||||
|
||||
@@ -512,10 +504,9 @@ void Image_PaletteHueReplace( byte *palSrc, int newHue, int start, int end, int
|
||||
static void Image_PaletteTranslate( byte *palSrc, int top, int bottom, int pal_size )
|
||||
{
|
||||
byte dst[256], src[256];
|
||||
int i;
|
||||
|
||||
pal_size = bound( 3, pal_size, 4 );
|
||||
for( i = 0; i < 256; i++ )
|
||||
for( int i = 0; i < 256; i++ )
|
||||
src[i] = i;
|
||||
memcpy( dst, src, 256 );
|
||||
|
||||
@@ -526,7 +517,7 @@ static void Image_PaletteTranslate( byte *palSrc, int top, int bottom, int pal_s
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i < 16; i++ )
|
||||
for( int i = 0; i < 16; i++ )
|
||||
dst[SHIRT_HUE_START+i] = src[top + 15 - i];
|
||||
}
|
||||
|
||||
@@ -536,12 +527,12 @@ static void Image_PaletteTranslate( byte *palSrc, int top, int bottom, int pal_s
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i < 16; i++ )
|
||||
for( int i = 0; i < 16; i++ )
|
||||
dst[PANTS_HUE_START + i] = src[bottom + 15 - i];
|
||||
}
|
||||
|
||||
// last color isn't changed
|
||||
for( i = 0; i < 255; i++ )
|
||||
for( int i = 0; i < 255; i++ )
|
||||
{
|
||||
palSrc[i*pal_size+0] = palette_q1[dst[i]*3+0];
|
||||
palSrc[i*pal_size+1] = palette_q1[dst[i]*3+1];
|
||||
@@ -574,8 +565,6 @@ qboolean Image_Copy8bitRGBA( const byte *in, byte *out, int pixels )
|
||||
{
|
||||
int *iout = (int *)out;
|
||||
byte *fin = (byte *)in;
|
||||
byte *col;
|
||||
int i;
|
||||
|
||||
if( !in || !image.d_currentpal )
|
||||
return false;
|
||||
@@ -583,14 +572,14 @@ qboolean Image_Copy8bitRGBA( const byte *in, byte *out, int pixels )
|
||||
// this is a base image with luma - clear luma pixels
|
||||
if( image.flags & IMAGE_HAS_LUMA )
|
||||
{
|
||||
for( i = 0; i < image.width * image.height; i++ )
|
||||
for( int i = 0; i < image.width * image.height; i++ )
|
||||
fin[i] = fin[i] < 224 ? fin[i] : image.black_pixel;
|
||||
}
|
||||
|
||||
// check for color
|
||||
for( i = 0; i < 256; i++ )
|
||||
for( int i = 0; i < 256; i++ )
|
||||
{
|
||||
col = (byte *)&image.d_currentpal[i];
|
||||
byte *col = (byte *)&image.d_currentpal[i];
|
||||
if( col[0] != col[1] || col[1] != col[2] )
|
||||
{
|
||||
image.flags |= IMAGE_HAS_COLOR;
|
||||
@@ -641,14 +630,15 @@ qboolean Image_Copy8bitRGBA( const byte *in, byte *out, int pixels )
|
||||
|
||||
static void Image_Resample32LerpLine( const byte *in, byte *out, int inwidth, int outwidth )
|
||||
{
|
||||
int j, xi, oldx = 0, f, fstep, endx, lerp;
|
||||
int oldx = 0;
|
||||
|
||||
fstep = (int)(inwidth * 65536.0f / outwidth);
|
||||
endx = (inwidth-1);
|
||||
int fstep = (int)(inwidth * 65536.0f / outwidth);
|
||||
int endx = (inwidth-1);
|
||||
|
||||
int j, f;
|
||||
for( j = 0, f = 0; j < outwidth; j++, f += fstep )
|
||||
{
|
||||
xi = f>>16;
|
||||
int xi = f>>16;
|
||||
if( xi != oldx )
|
||||
{
|
||||
in += (xi - oldx) * 4;
|
||||
@@ -656,7 +646,7 @@ static void Image_Resample32LerpLine( const byte *in, byte *out, int inwidth, in
|
||||
}
|
||||
if( xi < endx )
|
||||
{
|
||||
lerp = f & 0xFFFF;
|
||||
int lerp = f & 0xFFFF;
|
||||
*out++ = (byte)((((in[4] - in[0]) * lerp)>>16) + in[0]);
|
||||
*out++ = (byte)((((in[5] - in[1]) * lerp)>>16) + in[1]);
|
||||
*out++ = (byte)((((in[6] - in[2]) * lerp)>>16) + in[2]);
|
||||
@@ -674,14 +664,15 @@ static void Image_Resample32LerpLine( const byte *in, byte *out, int inwidth, in
|
||||
|
||||
static void Image_Resample24LerpLine( const byte *in, byte *out, int inwidth, int outwidth )
|
||||
{
|
||||
int j, xi, oldx = 0, f, fstep, endx, lerp;
|
||||
int oldx = 0;
|
||||
|
||||
fstep = (int)(inwidth * 65536.0f / outwidth);
|
||||
endx = (inwidth-1);
|
||||
int fstep = (int)(inwidth * 65536.0f / outwidth);
|
||||
int endx = (inwidth-1);
|
||||
|
||||
int j, f;
|
||||
for( j = 0, f = 0; j < outwidth; j++, f += fstep )
|
||||
{
|
||||
xi = f>>16;
|
||||
int xi = f>>16;
|
||||
|
||||
if( xi != oldx )
|
||||
{
|
||||
@@ -691,7 +682,7 @@ static void Image_Resample24LerpLine( const byte *in, byte *out, int inwidth, in
|
||||
|
||||
if( xi < endx )
|
||||
{
|
||||
lerp = f & 0xFFFF;
|
||||
int lerp = f & 0xFFFF;
|
||||
*out++ = (byte)((((in[3] - in[0]) * lerp)>>16) + in[0]);
|
||||
*out++ = (byte)((((in[4] - in[1]) * lerp)>>16) + in[1]);
|
||||
*out++ = (byte)((((in[5] - in[2]) * lerp)>>16) + in[2]);
|
||||
@@ -707,20 +698,17 @@ static void Image_Resample24LerpLine( const byte *in, byte *out, int inwidth, in
|
||||
|
||||
static void Image_Resample32Lerp( const void *indata, int inwidth, int inheight, void *outdata, int outwidth, int outheight )
|
||||
{
|
||||
const byte *inrow;
|
||||
int i, j, r, yi, oldy = 0, f, fstep, lerp, endy = (inheight - 1);
|
||||
int i, j, r, yi, oldy = 0, f, lerp, endy = (inheight - 1);
|
||||
int inwidth4 = inwidth * 4;
|
||||
int outwidth4 = outwidth * 4;
|
||||
byte *out = (byte *)outdata;
|
||||
byte *resamplerow1;
|
||||
byte *resamplerow2;
|
||||
|
||||
fstep = (int)(inheight * 65536.0f / outheight);
|
||||
int fstep = (int)(inheight * 65536.0f / outheight);
|
||||
|
||||
resamplerow1 = (byte *)Mem_Malloc( host.imagepool, outwidth * 4 * 2);
|
||||
resamplerow2 = resamplerow1 + outwidth * 4;
|
||||
byte *resamplerow1 = (byte *)Mem_Malloc( host.imagepool, outwidth * 4 * 2);
|
||||
byte *resamplerow2 = resamplerow1 + outwidth * 4;
|
||||
|
||||
inrow = (const byte *)indata;
|
||||
const byte *inrow = (const byte *)indata;
|
||||
|
||||
Image_Resample32LerpLine( inrow, resamplerow1, inwidth, outwidth );
|
||||
Image_Resample32LerpLine( inrow + inwidth4, resamplerow2, inwidth, outwidth );
|
||||
@@ -815,17 +803,15 @@ static void Image_Resample32Lerp( const void *indata, int inwidth, int inheight,
|
||||
|
||||
static void Image_Resample32Nolerp( const void *indata, int inwidth, int inheight, void *outdata, int outwidth, int outheight )
|
||||
{
|
||||
int i, j;
|
||||
uint frac, fracstep;
|
||||
int *inrow, *out = (int *)outdata; // relies on int being 4 bytes
|
||||
int *out = (int *)outdata; // relies on int being 4 bytes
|
||||
|
||||
fracstep = inwidth * 0x10000 / outwidth;
|
||||
uint fracstep = inwidth * 0x10000 / outwidth;
|
||||
|
||||
for( i = 0; i < outheight; i++)
|
||||
for( int i = 0; i < outheight; i++)
|
||||
{
|
||||
inrow = (int *)indata + inwidth * (i * inheight / outheight);
|
||||
frac = fracstep>>1;
|
||||
j = outwidth - 4;
|
||||
int *inrow = (int *)indata + inwidth * (i * inheight / outheight);
|
||||
uint frac = fracstep>>1;
|
||||
int j = outwidth - 4;
|
||||
|
||||
while( j >= 0 )
|
||||
{
|
||||
@@ -854,21 +840,18 @@ static void Image_Resample32Nolerp( const void *indata, int inwidth, int inheigh
|
||||
|
||||
static void Image_Resample24Lerp( const void *indata, int inwidth, int inheight, void *outdata, int outwidth, int outheight )
|
||||
{
|
||||
const byte *inrow;
|
||||
int i, j, r, yi, oldy, f, fstep, lerp, endy = (inheight - 1);
|
||||
int i, j, r, yi, f, lerp, endy = (inheight - 1);
|
||||
int inwidth3 = inwidth * 3;
|
||||
int outwidth3 = outwidth * 3;
|
||||
byte *out = (byte *)outdata;
|
||||
byte *resamplerow1;
|
||||
byte *resamplerow2;
|
||||
|
||||
fstep = (int)(inheight * 65536.0f / outheight);
|
||||
int fstep = (int)(inheight * 65536.0f / outheight);
|
||||
|
||||
resamplerow1 = (byte *)Mem_Malloc( host.imagepool, outwidth * 3 * 2 );
|
||||
resamplerow2 = resamplerow1 + outwidth*3;
|
||||
byte *resamplerow1 = (byte *)Mem_Malloc( host.imagepool, outwidth * 3 * 2 );
|
||||
byte *resamplerow2 = resamplerow1 + outwidth*3;
|
||||
|
||||
inrow = (const byte *)indata;
|
||||
oldy = 0;
|
||||
const byte *inrow = (const byte *)indata;
|
||||
int oldy = 0;
|
||||
Image_Resample24LerpLine( inrow, resamplerow1, inwidth, outwidth );
|
||||
Image_Resample24LerpLine( inrow + inwidth3, resamplerow2, inwidth, outwidth );
|
||||
|
||||
@@ -955,17 +938,17 @@ static void Image_Resample24Lerp( const void *indata, int inwidth, int inheight,
|
||||
|
||||
static void Image_Resample24Nolerp( const void *indata, int inwidth, int inheight, void *outdata, int outwidth, int outheight )
|
||||
{
|
||||
uint frac, fracstep;
|
||||
int i, j, f, inwidth3 = inwidth * 3;
|
||||
byte *inrow, *out = (byte *)outdata;
|
||||
int inwidth3 = inwidth * 3;
|
||||
byte *out = (byte *)outdata;
|
||||
|
||||
fracstep = inwidth * 0x10000 / outwidth;
|
||||
uint fracstep = inwidth * 0x10000 / outwidth;
|
||||
|
||||
for( i = 0; i < outheight; i++)
|
||||
for( int i = 0; i < outheight; i++)
|
||||
{
|
||||
inrow = (byte *)indata + inwidth3 * (i * inheight / outheight);
|
||||
frac = fracstep>>1;
|
||||
j = outwidth - 4;
|
||||
byte *inrow = (byte *)indata + inwidth3 * (i * inheight / outheight);
|
||||
uint frac = fracstep>>1;
|
||||
int j = outwidth - 4;
|
||||
int f;
|
||||
|
||||
while( j >= 0 )
|
||||
{
|
||||
@@ -1021,20 +1004,17 @@ static void Image_Resample24Nolerp( const void *indata, int inwidth, int inheigh
|
||||
|
||||
static void Image_Resample8Nolerp( const void *indata, int inwidth, int inheight, void *outdata, int outwidth, int outheight )
|
||||
{
|
||||
int i, j;
|
||||
byte *in, *inrow;
|
||||
uint frac, fracstep;
|
||||
byte *out = (byte *)outdata;
|
||||
|
||||
in = (byte *)indata;
|
||||
fracstep = inwidth * 0x10000 / outwidth;
|
||||
byte *in = (byte *)indata;
|
||||
uint fracstep = inwidth * 0x10000 / outwidth;
|
||||
|
||||
for( i = 0; i < outheight; i++, out += outwidth )
|
||||
for( int i = 0; i < outheight; i++, out += outwidth )
|
||||
{
|
||||
inrow = in + inwidth*(i*inheight/outheight);
|
||||
frac = fracstep>>1;
|
||||
byte *inrow = in + inwidth*(i*inheight/outheight);
|
||||
uint frac = fracstep>>1;
|
||||
|
||||
for( j = 0; j < outwidth; j++ )
|
||||
for( int j = 0; j < outwidth; j++ )
|
||||
{
|
||||
out[j] = inrow[frac>>16];
|
||||
frac += fracstep;
|
||||
@@ -1094,7 +1074,7 @@ Image_Flip
|
||||
*/
|
||||
byte *Image_FlipInternal( const byte *in, word *srcwidth, word *srcheight, int type, int flags )
|
||||
{
|
||||
int i, x, y;
|
||||
int x, y;
|
||||
word width = *srcwidth;
|
||||
word height = *srcheight;
|
||||
int samples = PFDesc[type].bpp;
|
||||
@@ -1106,7 +1086,6 @@ byte *Image_FlipInternal( const byte *in, word *srcwidth, word *srcheight, int t
|
||||
int row_ofs = ( flip_y ? ( height - 1 ) * width * samples : 0 );
|
||||
int col_ofs = ( flip_x ? ( width - 1 ) * samples : 0 );
|
||||
const byte *p, *line;
|
||||
byte *out;
|
||||
|
||||
// nothing to process
|
||||
if( !FBitSet( flags, IMAGE_FLIP_X|IMAGE_FLIP_Y|IMAGE_ROT_90 ))
|
||||
@@ -1126,20 +1105,20 @@ byte *Image_FlipInternal( const byte *in, word *srcwidth, word *srcheight, int t
|
||||
return (byte *)in;
|
||||
}
|
||||
|
||||
out = image.tempbuffer;
|
||||
byte *out = image.tempbuffer;
|
||||
|
||||
if( flip_i )
|
||||
{
|
||||
for( x = 0, line = in + col_ofs; x < width; x++, line += col_inc )
|
||||
for( y = 0, p = line + row_ofs; y < height; y++, p += row_inc, out += samples )
|
||||
for( i = 0; i < samples; i++ )
|
||||
for( int i = 0; i < samples; i++ )
|
||||
out[i] = p[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
for( y = 0, line = in + row_ofs; y < height; y++, line += row_inc )
|
||||
for( x = 0, p = line + col_ofs; x < width; x++, p += col_inc, out += samples )
|
||||
for( i = 0; i < samples; i++ )
|
||||
for( int i = 0; i < samples; i++ )
|
||||
out[i] = p[i];
|
||||
}
|
||||
|
||||
@@ -1161,7 +1140,6 @@ byte *Image_FlipInternal( const byte *in, word *srcwidth, word *srcheight, int t
|
||||
static byte *Image_MakeLuma( byte *fin, int width, int height, int type, int flags )
|
||||
{
|
||||
byte *out;
|
||||
int i;
|
||||
|
||||
if( !FBitSet( flags, IMAGE_HAS_LUMA ))
|
||||
return (byte *)fin;
|
||||
@@ -1171,7 +1149,7 @@ static byte *Image_MakeLuma( byte *fin, int width, int height, int type, int fla
|
||||
case PF_INDEXED_24:
|
||||
case PF_INDEXED_32:
|
||||
out = image.tempbuffer = Mem_Realloc( host.imagepool, image.tempbuffer, width * height );
|
||||
for( i = 0; i < width * height; i++ )
|
||||
for( int i = 0; i < width * height; i++ )
|
||||
*out++ = fin[i] >= 224 ? fin[i] : image.black_pixel;
|
||||
break;
|
||||
default:
|
||||
@@ -1216,15 +1194,12 @@ force to unpack any image to 32-bit buffer
|
||||
*/
|
||||
static qboolean Image_Decompress( const byte *data )
|
||||
{
|
||||
byte *fin, *fout;
|
||||
int i, size;
|
||||
|
||||
if( !data ) return false;
|
||||
fin = (byte *)data;
|
||||
byte *fin = (byte *)data;
|
||||
|
||||
size = image.width * image.height * 4;
|
||||
int size = image.width * image.height * 4;
|
||||
image.tempbuffer = Mem_Realloc( host.imagepool, image.tempbuffer, size );
|
||||
fout = image.tempbuffer;
|
||||
byte *fout = image.tempbuffer;
|
||||
|
||||
switch( PFDesc[image.type].format )
|
||||
{
|
||||
@@ -1243,7 +1218,7 @@ static qboolean Image_Decompress( const byte *data )
|
||||
return false;
|
||||
break;
|
||||
case PF_BGR_24:
|
||||
for (i = 0; i < image.width * image.height; i++ )
|
||||
for( int i = 0; i < image.width * image.height; i++ )
|
||||
{
|
||||
fout[(i<<2)+0] = fin[i*3+2];
|
||||
fout[(i<<2)+1] = fin[i*3+1];
|
||||
@@ -1252,7 +1227,7 @@ static qboolean Image_Decompress( const byte *data )
|
||||
}
|
||||
break;
|
||||
case PF_RGB_24:
|
||||
for (i = 0; i < image.width * image.height; i++ )
|
||||
for( int i = 0; i < image.width * image.height; i++ )
|
||||
{
|
||||
fout[(i<<2)+0] = fin[i*3+0];
|
||||
fout[(i<<2)+1] = fin[i*3+1];
|
||||
@@ -1261,7 +1236,7 @@ static qboolean Image_Decompress( const byte *data )
|
||||
}
|
||||
break;
|
||||
case PF_BGRA_32:
|
||||
for( i = 0; i < image.width * image.height; i++ )
|
||||
for( int i = 0; i < image.width * image.height; i++ )
|
||||
{
|
||||
fout[i*4+0] = fin[i*4+2];
|
||||
fout[i*4+1] = fin[i*4+1];
|
||||
@@ -1308,12 +1283,11 @@ static rgbdata_t *Image_DecompressInternal( rgbdata_t *pic )
|
||||
static rgbdata_t *Image_LightGamma( rgbdata_t *pic )
|
||||
{
|
||||
byte *in = (byte *)pic->buffer;
|
||||
int i;
|
||||
|
||||
if( pic->type != PF_RGBA_32 )
|
||||
return pic;
|
||||
|
||||
for( i = 0; i < pic->width * pic->height; i++, in += 4 )
|
||||
for( int i = 0; i < pic->width * pic->height; i++, in += 4 )
|
||||
{
|
||||
in[0] = LightToTexGamma( in[0] );
|
||||
in[1] = LightToTexGamma( in[1] );
|
||||
@@ -1483,22 +1457,17 @@ void Image_GenerateMipmaps( const byte *source, int width, int height, byte *mip
|
||||
{ width / 8, height / 8 }
|
||||
};
|
||||
byte *mipmaps[3] = { mip1, mip2, mip3 };
|
||||
int m;
|
||||
|
||||
for( m = 0; m < 3; ++m )
|
||||
for( int m = 0; m < 3; ++m )
|
||||
{
|
||||
int mw, mh, step, y;
|
||||
|
||||
if( !mipmaps[m] )
|
||||
continue;
|
||||
mw = sizes[m][0];
|
||||
mh = sizes[m][1];
|
||||
step = 1 << ( m + 1 );
|
||||
for( y = 0; y < mh; ++y )
|
||||
int mw = sizes[m][0];
|
||||
int mh = sizes[m][1];
|
||||
int step = 1 << ( m + 1 );
|
||||
for( int y = 0; y < mh; ++y )
|
||||
{
|
||||
int x;
|
||||
|
||||
for( x = 0; x < mw; ++x )
|
||||
for( int x = 0; x < mw; ++x )
|
||||
{
|
||||
mipmaps[m][y * mw + x] = source[( y * step ) * width + ( x * step )];
|
||||
}
|
||||
|
||||
@@ -124,9 +124,6 @@ Image_LoadFNT
|
||||
qboolean Image_LoadFNT( const char *name, const byte *buffer, fs_offset_t filesize )
|
||||
{
|
||||
qfont_t font;
|
||||
const byte *pal, *fin;
|
||||
size_t size;
|
||||
int numcolors;
|
||||
|
||||
if( image.hint == IL_HINT_Q1 )
|
||||
return false; // Quake1 doesn't have qfonts
|
||||
@@ -138,7 +135,7 @@ qboolean Image_LoadFNT( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
le_struct_swap( qfont_swap, &font );
|
||||
|
||||
// last sixty four bytes - what the hell ????
|
||||
size = sizeof( qfont_t ) - 4 + ( font.height * font.width * QCHAR_WIDTH ) + sizeof( short ) + 768 + 64;
|
||||
size_t size = sizeof( qfont_t ) - 4 + ( font.height * font.width * QCHAR_WIDTH ) + sizeof( short ) + 768 + 64;
|
||||
|
||||
if( size != filesize )
|
||||
{
|
||||
@@ -156,9 +153,9 @@ qboolean Image_LoadFNT( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
if( !Image_LumpValidSize( name ))
|
||||
return false;
|
||||
|
||||
fin = buffer + sizeof( font ) - 4;
|
||||
pal = fin + (image.width * image.height);
|
||||
numcolors = pal[0] | (pal[1] << 8);
|
||||
const byte *fin = buffer + sizeof( font ) - 4;
|
||||
const byte *pal = fin + (image.width * image.height);
|
||||
int numcolors = pal[0] | (pal[1] << 8);
|
||||
pal += sizeof( short );
|
||||
|
||||
if( numcolors == 768 || numcolors == 256 )
|
||||
@@ -198,18 +195,13 @@ Image_LoadMDL
|
||||
*/
|
||||
qboolean Image_LoadMDL( const char *name, const byte *buffer, fs_offset_t filesize )
|
||||
{
|
||||
byte *fin;
|
||||
size_t pixels;
|
||||
mstudiotexture_t *pin;
|
||||
int flags;
|
||||
|
||||
pin = (mstudiotexture_t *)buffer;
|
||||
flags = pin->flags;
|
||||
mstudiotexture_t *pin = (mstudiotexture_t *)buffer;
|
||||
int flags = pin->flags;
|
||||
|
||||
image.width = pin->width;
|
||||
image.height = pin->height;
|
||||
pixels = image.width * image.height;
|
||||
fin = (byte *)g_mdltexdata;
|
||||
size_t pixels = image.width * image.height;
|
||||
byte *fin = (byte *)g_mdltexdata;
|
||||
ASSERT(fin);
|
||||
g_mdltexdata = NULL;
|
||||
|
||||
@@ -250,7 +242,6 @@ qboolean Image_LoadSPR( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
{
|
||||
dspriteframe_t pin; // identical for q1\hl sprites
|
||||
qboolean truecolor = false;
|
||||
byte *fin;
|
||||
|
||||
if( image.hint == IL_HINT_HL )
|
||||
{
|
||||
@@ -296,7 +287,7 @@ qboolean Image_LoadSPR( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
break;
|
||||
}
|
||||
|
||||
fin = (byte *)(buffer + sizeof(dspriteframe_t));
|
||||
byte *fin = (byte *)(buffer + sizeof(dspriteframe_t));
|
||||
|
||||
if( truecolor )
|
||||
{
|
||||
@@ -320,7 +311,6 @@ qboolean Image_LoadLMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
lmp_t lmp;
|
||||
byte *fin, *pal;
|
||||
int rendermode;
|
||||
int i, pixels;
|
||||
|
||||
if( filesize < sizeof( lmp ))
|
||||
return false;
|
||||
@@ -338,7 +328,7 @@ qboolean Image_LoadLMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
fin = (byte *)buffer;
|
||||
|
||||
// need to remap transparent color from first to last entry
|
||||
for( i = 0; i < 16384; i++ ) if( !fin[i] ) fin[i] = 0xFF;
|
||||
for( int i = 0; i < 16384; i++ ) if( !fin[i] ) fin[i] = 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -351,7 +341,7 @@ qboolean Image_LoadLMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
fin += sizeof( lmp );
|
||||
}
|
||||
|
||||
pixels = image.width * image.height;
|
||||
int pixels = image.width * image.height;
|
||||
|
||||
if( filesize < sizeof( lmp ) + pixels )
|
||||
return false;
|
||||
@@ -366,7 +356,7 @@ qboolean Image_LoadLMP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
// HACKHACK: console background image shouldn't be transparent
|
||||
if( !Q_stristr( name, "conback" ))
|
||||
{
|
||||
for( i = 0; i < pixels; i++ )
|
||||
for( int i = 0; i < pixels; i++ )
|
||||
{
|
||||
if( fin[i] == 255 )
|
||||
{
|
||||
@@ -430,7 +420,7 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
qboolean hl_texture;
|
||||
byte *fin, *pal;
|
||||
int ofs[4], rendermode;
|
||||
int i, pixels, numcolors;
|
||||
int numcolors;
|
||||
uint reflectivity[3] = { 0, 0, 0 };
|
||||
|
||||
if( filesize < sizeof( mip ))
|
||||
@@ -446,7 +436,7 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
return false;
|
||||
|
||||
memcpy( ofs, mip.offsets, sizeof( ofs ));
|
||||
pixels = image.width * image.height;
|
||||
int pixels = image.width * image.height;
|
||||
|
||||
if( image.hint != IL_HINT_Q1 && filesize >= (int)sizeof(mip) + ((pixels * 85)>>6) + sizeof(short) + 768)
|
||||
{
|
||||
@@ -489,7 +479,7 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
// check for luma pixels (but ignore liquid textures because they have no lightmap)
|
||||
if( mip.name[0] != '*' && mip.name[0] != '!' )
|
||||
{
|
||||
for( i = 0; i < image.width * image.height; i++ )
|
||||
for( int i = 0; i < image.width * image.height; i++ )
|
||||
{
|
||||
if( fin[i] > 224 )
|
||||
{
|
||||
@@ -548,7 +538,7 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
// don't apply luma to water surfaces because they have no lightmap
|
||||
if( !image.custom_palette && mip.name[0] != '*' && mip.name[0] != '!' )
|
||||
{
|
||||
for( i = 0; i < image.width * image.height; i++ )
|
||||
for( int i = 0; i < image.width * image.height; i++ )
|
||||
{
|
||||
if( fin[i] > 224 && fin[i] != 255 )
|
||||
{
|
||||
@@ -562,7 +552,7 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
// Arcane Dimensions has the transparent textures
|
||||
if( Q_strrchr( name, '{' ))
|
||||
{
|
||||
for( i = 0; i < image.width * image.height; i++ )
|
||||
for( int i = 0; i < image.width * image.height; i++ )
|
||||
{
|
||||
if( fin[i] == 255 )
|
||||
{
|
||||
@@ -614,7 +604,7 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
else
|
||||
{
|
||||
// calc texture reflectivity
|
||||
for( i = 0; i < 256; i++ )
|
||||
for( int i = 0; i < 256; i++ )
|
||||
{
|
||||
reflectivity[0] += pal[i*3+0];
|
||||
reflectivity[1] += pal[i*3+1];
|
||||
@@ -639,8 +629,6 @@ Image_LoadWAD
|
||||
qboolean Image_LoadWAD( const char *name, const byte *buffer, fs_offset_t filesize )
|
||||
{
|
||||
dwadinfo_t whdr;
|
||||
const unsigned char *mipdata;
|
||||
int i, j;
|
||||
|
||||
if( !buffer || filesize < sizeof( dwadinfo_t ))
|
||||
return false;
|
||||
@@ -650,19 +638,13 @@ qboolean Image_LoadWAD( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
if( whdr.numlumps <= 0 || whdr.infotableofs <= 0 || whdr.infotableofs >= (int)filesize )
|
||||
return false;
|
||||
|
||||
for( i = 0; i < whdr.numlumps; ++i )
|
||||
for( int i = 0; i < whdr.numlumps; ++i )
|
||||
{
|
||||
const unsigned char *pixels, *palette, *use_palette;
|
||||
unsigned char grad_palette[256 * 3];
|
||||
dlumpinfo_t lump;
|
||||
int mip_size;
|
||||
mip_t mip;
|
||||
uint32_t width, height, offset0;
|
||||
uint32_t m0size, m1size, m2size, m3size;
|
||||
qboolean alpha_mode = false;
|
||||
unsigned char frontR = 0, frontG = 0, frontB = 0;
|
||||
float t;
|
||||
byte idx;
|
||||
|
||||
memcpy( &lump, buffer + whdr.infotableofs + i * sizeof( dlumpinfo_t ), sizeof( lump ));
|
||||
le_struct_swap( dlumpinfo_swap, &lump );
|
||||
@@ -671,30 +653,30 @@ qboolean Image_LoadWAD( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
continue;
|
||||
|
||||
// get lump data and validate
|
||||
mipdata = (const unsigned char *)buffer + lump.filepos;
|
||||
mip_size = lump.disksize;
|
||||
const unsigned char *mipdata = (const unsigned char *)buffer + lump.filepos;
|
||||
int mip_size = lump.disksize;
|
||||
if( lump.filepos < 0 || lump.filepos + mip_size > (int)filesize )
|
||||
continue;
|
||||
|
||||
memcpy( &mip, mipdata, sizeof( mip ));
|
||||
le_struct_swap( mip_swap, &mip );
|
||||
width = mip.width;
|
||||
height = mip.height;
|
||||
uint32_t width = mip.width;
|
||||
uint32_t height = mip.height;
|
||||
|
||||
if( width <= 0 || height <= 0 || width > 256 || height > 256 )
|
||||
continue;
|
||||
|
||||
offset0 = mip.offsets[0];
|
||||
uint32_t offset0 = mip.offsets[0];
|
||||
if( offset0 == 0 || offset0 + width * height > (uint32_t)mip_size )
|
||||
continue;
|
||||
|
||||
pixels = mipdata + offset0;
|
||||
m0size = width * height;
|
||||
m1size = m0size / 4;
|
||||
m2size = m0size / 16;
|
||||
m3size = m0size / 64;
|
||||
palette = mipdata + 0x28 + m0size + m1size + m2size + m3size + 2;
|
||||
use_palette = palette;
|
||||
const unsigned char *pixels = mipdata + offset0;
|
||||
uint32_t m0size = width * height;
|
||||
uint32_t m1size = m0size / 4;
|
||||
uint32_t m2size = m0size / 16;
|
||||
uint32_t m3size = m0size / 64;
|
||||
const unsigned char *palette = mipdata + 0x28 + m0size + m1size + m2size + m3size + 2;
|
||||
const unsigned char *use_palette = palette;
|
||||
|
||||
// handle gradient palette
|
||||
if( lump.type == TYP_PALETTE )
|
||||
@@ -704,9 +686,9 @@ qboolean Image_LoadWAD( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
frontR = frontColorPtr[0];
|
||||
frontG = frontColorPtr[1];
|
||||
frontB = frontColorPtr[2];
|
||||
for( j = 0; j < 256; ++j )
|
||||
for( int j = 0; j < 256; ++j )
|
||||
{
|
||||
t = j / 255.0f;
|
||||
float t = j / 255.0f;
|
||||
grad_palette[j * 3 + 0] = (unsigned char)( frontR * t );
|
||||
grad_palette[j * 3 + 1] = (unsigned char)( frontG * t );
|
||||
grad_palette[j * 3 + 2] = (unsigned char)( frontB * t );
|
||||
@@ -726,9 +708,9 @@ qboolean Image_LoadWAD( const char *name, const byte *buffer, fs_offset_t filesi
|
||||
image.palette = NULL;
|
||||
|
||||
// convert indexed pixels to RGBA
|
||||
for( j = 0; j < (int)( width * height ); ++j )
|
||||
for( int j = 0; j < (int)( width * height ); ++j )
|
||||
{
|
||||
idx = pixels[j];
|
||||
byte idx = pixels[j];
|
||||
image.rgba[j * 4 + 0] = use_palette[idx * 3 + 0];
|
||||
image.rgba[j * 4 + 1] = use_palette[idx * 3 + 1];
|
||||
image.rgba[j * 4 + 2] = use_palette[idx * 3 + 2];
|
||||
@@ -749,17 +731,18 @@ Image_SaveWAD
|
||||
*/
|
||||
qboolean Image_SaveWAD( const char *name, rgbdata_t *pix )
|
||||
{
|
||||
int m0size, m1size, m2size, m3size;
|
||||
byte *mip1_data = NULL, *mip2_data = NULL, *mip3_data = NULL;
|
||||
const byte *palette;
|
||||
byte grad_palette[256 * 3];
|
||||
file_t *f;
|
||||
dwadinfo_t header;
|
||||
dwadinfo_t header =
|
||||
{
|
||||
.ident = IDWAD3HEADER,
|
||||
.numlumps = 1,
|
||||
};
|
||||
mip_t miptex;
|
||||
long infotableofs;
|
||||
dlumpinfo_t lump;
|
||||
fs_offset_t pad;
|
||||
int i;
|
||||
qboolean result = false;
|
||||
int lump_type = ( pix->flags & IMAGE_GRADIENT_DECAL ) ? TYP_PALETTE : TYP_MIPTEX;
|
||||
short palette_size = 256;
|
||||
@@ -768,12 +751,12 @@ qboolean Image_SaveWAD( const char *name, rgbdata_t *pix )
|
||||
if( !pix || !pix->buffer )
|
||||
return false;
|
||||
|
||||
palette = pix->palette ? pix->palette : (const byte *)image.palette;
|
||||
const byte *palette = pix->palette ? pix->palette : (const byte *)image.palette;
|
||||
|
||||
m0size = pix->width * pix->height;
|
||||
m1size = m0size / 4;
|
||||
m2size = m0size / 16;
|
||||
m3size = m0size / 64;
|
||||
int m0size = pix->width * pix->height;
|
||||
int m1size = m0size / 4;
|
||||
int m2size = m0size / 16;
|
||||
int m3size = m0size / 64;
|
||||
|
||||
mip1_data = (byte *)Mem_Malloc( host.imagepool, m1size );
|
||||
mip2_data = (byte *)Mem_Malloc( host.imagepool, m2size );
|
||||
@@ -796,10 +779,6 @@ qboolean Image_SaveWAD( const char *name, rgbdata_t *pix )
|
||||
if( !f )
|
||||
goto cleanup;
|
||||
|
||||
memset( &header, 0, sizeof( header ));
|
||||
header.ident = IDWAD3HEADER;
|
||||
header.numlumps = 1;
|
||||
|
||||
le_struct_swap( dwadinfo_swap, &header );
|
||||
FS_Write( f, &header, sizeof( header ));
|
||||
le_struct_swap( mip_swap, &miptex );
|
||||
@@ -815,7 +794,7 @@ qboolean Image_SaveWAD( const char *name, rgbdata_t *pix )
|
||||
if( lump_type == TYP_PALETTE )
|
||||
{
|
||||
const byte *frontColorPtr = palette + 255 * 3;
|
||||
for( i = 0; i < 256; ++i )
|
||||
for( int i = 0; i < 256; ++i )
|
||||
{
|
||||
float t = i / 255.0f;
|
||||
grad_palette[i * 3 + 0] = (byte)( frontColorPtr[0] * t );
|
||||
@@ -831,7 +810,7 @@ qboolean Image_SaveWAD( const char *name, rgbdata_t *pix )
|
||||
|
||||
// padding up to a multiple of 4
|
||||
pad = (( FS_Tell( f ) + 3 ) & ~3 ) - FS_Tell( f );
|
||||
for( i = 0; i < pad; ++i )
|
||||
for( int i = 0; i < pad; ++i )
|
||||
FS_Write( f, (const void *)&(char){0}, 1 );
|
||||
|
||||
infotableofs = FS_Tell( f );
|
||||
|
||||
@@ -35,15 +35,13 @@ void Info_Print( const char *s )
|
||||
{
|
||||
char key[MAX_KV_SIZE];
|
||||
char value[MAX_KV_SIZE];
|
||||
int l, count;
|
||||
char *o;
|
||||
|
||||
if( *s == '\\' ) s++;
|
||||
|
||||
while( *s )
|
||||
{
|
||||
count = 0;
|
||||
o = key;
|
||||
int count = 0;
|
||||
char *o = key;
|
||||
|
||||
while( count < (MAX_KV_SIZE - 1) && *s && *s != '\\' )
|
||||
{
|
||||
@@ -51,7 +49,7 @@ void Info_Print( const char *s )
|
||||
count++;
|
||||
}
|
||||
|
||||
l = o - key;
|
||||
int l = o - key;
|
||||
if( l < 20 )
|
||||
{
|
||||
memset( o, ' ', 20 - l );
|
||||
@@ -93,15 +91,13 @@ qboolean Info_IsValid( const char *s )
|
||||
{
|
||||
char key[MAX_KV_SIZE];
|
||||
char value[MAX_KV_SIZE];
|
||||
int count;
|
||||
char *o;
|
||||
|
||||
if( *s == '\\' ) s++;
|
||||
|
||||
while( *s )
|
||||
{
|
||||
count = 0;
|
||||
o = key;
|
||||
int count = 0;
|
||||
char *o = key;
|
||||
|
||||
while( count < (MAX_KV_SIZE - 1) && *s && *s != '\\' )
|
||||
{
|
||||
@@ -144,15 +140,13 @@ void Info_WriteVars( file_t *f )
|
||||
char pkey[MAX_SERVERINFO_STRING];
|
||||
static char value[4][MAX_SERVERINFO_STRING]; // use two buffers so compares work without stomping on each other
|
||||
static int valueindex;
|
||||
convar_t *pcvar;
|
||||
char *o;
|
||||
|
||||
valueindex = (valueindex + 1) % 4;
|
||||
if( *s == '\\' ) s++;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
o = pkey;
|
||||
char *o = pkey;
|
||||
while( *s != '\\' )
|
||||
{
|
||||
if( !*s ) return;
|
||||
@@ -170,7 +164,7 @@ void Info_WriteVars( file_t *f )
|
||||
}
|
||||
*o = 0;
|
||||
|
||||
pcvar = Cvar_FindVar( pkey );
|
||||
convar_t *pcvar = Cvar_FindVar( pkey );
|
||||
|
||||
if( !pcvar && pkey[0] != '*' ) // don't store out star keys
|
||||
FS_Printf( f, "setinfo \"%s\" \"%s\"\n", pkey, value[valueindex] );
|
||||
|
||||
@@ -15,11 +15,9 @@ void IPv6IPToString( char *pszOutText, const unsigned char *ip )
|
||||
// If there's a tie, we want the leftmost one.
|
||||
int idxLongestRunStart = -1;
|
||||
int nLongestRun = 1; // It must be at least 2 quads in a row, a single 0 must not be compressed
|
||||
int nCurrentRun = 0, idxQuad;
|
||||
char *p;
|
||||
qboolean bNeedColon;
|
||||
int nCurrentRun = 0;
|
||||
|
||||
for ( idxQuad = 0 ; idxQuad < 8 ; ++idxQuad )
|
||||
for ( int idxQuad = 0 ; idxQuad < 8 ; ++idxQuad )
|
||||
{
|
||||
// Zero
|
||||
if ( ip[idxQuad*2] || ip[idxQuad*2 + 1] )
|
||||
@@ -42,9 +40,9 @@ void IPv6IPToString( char *pszOutText, const unsigned char *ip )
|
||||
}
|
||||
|
||||
// Print the quads
|
||||
p = pszOutText;
|
||||
idxQuad = 0;
|
||||
bNeedColon = false;
|
||||
char *p = pszOutText;
|
||||
int idxQuad = 0;
|
||||
qboolean bNeedColon = false;
|
||||
while ( idxQuad < 8 )
|
||||
{
|
||||
// Run of compressed zeros?
|
||||
@@ -59,7 +57,6 @@ void IPv6IPToString( char *pszOutText, const unsigned char *ip )
|
||||
{
|
||||
// Lowercase hex digits, with leading zeros omitted
|
||||
static const char hexdigits[] = "0123456789abcdef";
|
||||
unsigned quad;
|
||||
|
||||
// Colon to separate from previous, unless
|
||||
// we are first or immediately follow compressed zero "::"
|
||||
@@ -70,7 +67,7 @@ void IPv6IPToString( char *pszOutText, const unsigned char *ip )
|
||||
bNeedColon = true;
|
||||
|
||||
// Assemble 16-bit quad value from the two bytes
|
||||
quad = ( (unsigned)ip[idxQuad*2] << 8U ) | ip[idxQuad*2 + 1];
|
||||
unsigned quad = ( (unsigned)ip[idxQuad*2] << 8U ) | ip[idxQuad*2 + 1];
|
||||
|
||||
// Manually do the hex number formatting.
|
||||
if ( quad >= 0x0010 )
|
||||
@@ -143,14 +140,9 @@ static bool ParseIPv6Addr_IsSpace( char c )
|
||||
}
|
||||
bool ParseIPv6Addr( const char *pszText, unsigned char *pOutIP, int *pOutPort, uint32_t *pOutScope )
|
||||
{
|
||||
unsigned char *d, *pZeroFill, *pEndIP;
|
||||
const char *s;
|
||||
qboolean bQuadMustFollow;
|
||||
int nPort;
|
||||
|
||||
while ( ParseIPv6Addr_IsSpace( *pszText ) )
|
||||
++pszText;
|
||||
s = pszText;
|
||||
const char *s = pszText;
|
||||
|
||||
// Skip opening bracket, if present
|
||||
if ( *s == '[' )
|
||||
@@ -161,10 +153,10 @@ bool ParseIPv6Addr( const char *pszText, unsigned char *pOutIP, int *pOutPort, u
|
||||
}
|
||||
|
||||
// Special case for leading "::"
|
||||
bQuadMustFollow = true;
|
||||
d = pOutIP;
|
||||
pZeroFill = NULL;
|
||||
pEndIP = pOutIP + 16;
|
||||
qboolean bQuadMustFollow = true;
|
||||
unsigned char *d = pOutIP;
|
||||
unsigned char *pZeroFill = NULL;
|
||||
unsigned char *pEndIP = pOutIP + 16;
|
||||
if ( s[0] == ':' && s[1] == ':' )
|
||||
{
|
||||
pZeroFill = d;
|
||||
@@ -177,8 +169,6 @@ bool ParseIPv6Addr( const char *pszText, unsigned char *pOutIP, int *pOutPort, u
|
||||
{
|
||||
// Next thing must be a quad, or end of input. Is it a quad?
|
||||
int quadDigit = ParseIPv6Addr_HexDigitVal( *s );
|
||||
const char *pszStartQuad;
|
||||
int quad;
|
||||
|
||||
if ( quadDigit < 0 )
|
||||
{
|
||||
@@ -191,9 +181,9 @@ bool ParseIPv6Addr( const char *pszText, unsigned char *pOutIP, int *pOutPort, u
|
||||
if ( d >= pEndIP )
|
||||
return false;
|
||||
|
||||
pszStartQuad = s;
|
||||
const char *pszStartQuad = s;
|
||||
++s;
|
||||
quad = quadDigit;
|
||||
int quad = quadDigit;
|
||||
|
||||
// Now parse up to three additional characters
|
||||
quadDigit = ParseIPv6Addr_HexDigitVal( *s );
|
||||
@@ -233,12 +223,11 @@ bool ParseIPv6Addr( const char *pszText, unsigned char *pOutIP, int *pOutPort, u
|
||||
|
||||
// Parse 1-3 decimal digits
|
||||
int octet = ParseIPv6Addr_DecimalDigitVal( *s );
|
||||
int dig;
|
||||
|
||||
if ( octet < 0 )
|
||||
return false;
|
||||
++s;
|
||||
dig = ParseIPv6Addr_DecimalDigitVal( *s );
|
||||
int dig = ParseIPv6Addr_DecimalDigitVal( *s );
|
||||
if ( dig >= 0 )
|
||||
{
|
||||
++s;
|
||||
@@ -340,16 +329,13 @@ bool ParseIPv6Addr( const char *pszText, unsigned char *pOutIP, int *pOutPort, u
|
||||
|
||||
if ( *s == '%' )
|
||||
{
|
||||
// Parse scope number
|
||||
uint32_t unScope = 0;
|
||||
int nScopeDigit;
|
||||
|
||||
++s;
|
||||
|
||||
nScopeDigit = ParseIPv6Addr_DecimalDigitVal( *s );
|
||||
// Parse scope number
|
||||
int nScopeDigit = ParseIPv6Addr_DecimalDigitVal( *s );
|
||||
if ( nScopeDigit < 0 )
|
||||
return false;
|
||||
unScope = (uint32_t)nScopeDigit;
|
||||
uint32_t unScope = (uint32_t)nScopeDigit;
|
||||
for (;;)
|
||||
{
|
||||
++s;
|
||||
@@ -418,17 +404,15 @@ bool ParseIPv6Addr( const char *pszText, unsigned char *pOutIP, int *pOutPort, u
|
||||
return false;
|
||||
|
||||
// Parse port number
|
||||
nPort = ParseIPv6Addr_DecimalDigitVal( *s );
|
||||
int nPort = ParseIPv6Addr_DecimalDigitVal( *s );
|
||||
if ( nPort < 0 )
|
||||
return false;
|
||||
for (;;)
|
||||
{
|
||||
int portDigit;
|
||||
|
||||
++s;
|
||||
if ( *s == '\0' || ParseIPv6Addr_IsSpace( *s ) )
|
||||
break;
|
||||
portDigit = ParseIPv6Addr_DecimalDigitVal( *s );
|
||||
int portDigit = ParseIPv6Addr_DecimalDigitVal( *s );
|
||||
if ( portDigit < 0 )
|
||||
return false;
|
||||
nPort = nPort * 10 + portDigit;
|
||||
|
||||
@@ -46,13 +46,13 @@ void *COM_FunctionFromName_SR( void *hInstance, const char *pName )
|
||||
#endif
|
||||
|
||||
#if XASH_POSIX
|
||||
size_t numfuncs, i;
|
||||
void *f = NULL;
|
||||
size_t numfuncs;
|
||||
char **funcs = COM_ConvertToLocalPlatform( MANGLE_ITANIUM, pName, &numfuncs );
|
||||
|
||||
if( funcs )
|
||||
{
|
||||
for( i = 0; i < numfuncs; i++ )
|
||||
void *f = NULL;
|
||||
for( size_t i = 0; i < numfuncs; i++ )
|
||||
{
|
||||
if( !f )
|
||||
f = COM_FunctionFromName( hInstance, funcs[i] );
|
||||
@@ -85,13 +85,10 @@ const char *COM_OffsetNameForFunction( void *function )
|
||||
|
||||
dll_user_t *FS_FindLibrary( const char *dllname, qboolean directpath )
|
||||
{
|
||||
dll_user_t *p;
|
||||
fs_dllinfo_t dllInfo;
|
||||
|
||||
// no fs loaded yet, but let engine find fs
|
||||
if( !g_fsapi.FindLibrary )
|
||||
{
|
||||
p = Mem_Calloc( host.mempool, sizeof( dll_user_t ));
|
||||
dll_user_t *p = Mem_Calloc( host.mempool, sizeof( dll_user_t ));
|
||||
Q_strncpy( p->shortPath, dllname, sizeof( p->shortPath ));
|
||||
Q_strncpy( p->fullPath, dllname, sizeof( p->fullPath ));
|
||||
Q_strncpy( p->dllName, dllname, sizeof( p->dllName ));
|
||||
@@ -99,13 +96,15 @@ dll_user_t *FS_FindLibrary( const char *dllname, qboolean directpath )
|
||||
return p;
|
||||
}
|
||||
|
||||
fs_dllinfo_t dllInfo;
|
||||
|
||||
// fs can't find library
|
||||
if( !g_fsapi.FindLibrary( dllname, directpath, &dllInfo ))
|
||||
return NULL;
|
||||
|
||||
// NOTE: for libraries we not fail even if search is NULL
|
||||
// let the OS find library himself
|
||||
p = Mem_Calloc( host.mempool, sizeof( dll_user_t ));
|
||||
dll_user_t *p = Mem_Calloc( host.mempool, sizeof( dll_user_t ));
|
||||
Q_strncpy( p->shortPath, dllInfo.shortPath, sizeof( p->shortPath ));
|
||||
Q_strncpy( p->fullPath, dllInfo.fullPath, sizeof( p->fullPath ));
|
||||
Q_strncpy( p->dllName, dllname, sizeof( p->dllName ));
|
||||
@@ -279,12 +278,12 @@ static EFunctionMangleType COM_DetectMangleType( const char *str )
|
||||
|
||||
char *COM_GetMSVCName( const char *in_name )
|
||||
{
|
||||
static string out_name;
|
||||
char *pos;
|
||||
static string out_name;
|
||||
|
||||
if( in_name[0] == '?' ) // is this a MSVC C++ mangled name?
|
||||
{
|
||||
if(( pos = Q_strstr( in_name, "@@" )) != NULL )
|
||||
char *pos = Q_strstr( in_name, "@@" );
|
||||
if( pos != NULL )
|
||||
{
|
||||
ptrdiff_t len = pos - in_name;
|
||||
|
||||
@@ -367,16 +366,12 @@ invalid_format:
|
||||
|
||||
char **COM_ConvertToLocalPlatform( EFunctionMangleType to, const char *from, size_t *numfuncs )
|
||||
{
|
||||
string symbols[MAX_NESTED_NAMESPACES], temp, temp2;
|
||||
const char *prev;
|
||||
const char *postfix[3];
|
||||
int i = 0;
|
||||
char **ret;
|
||||
|
||||
// TODO:
|
||||
if( to == MANGLE_MSVC )
|
||||
return NULL;
|
||||
|
||||
const char *postfix[3];
|
||||
|
||||
switch( to )
|
||||
{
|
||||
case MANGLE_ITANIUM:
|
||||
@@ -389,7 +384,9 @@ char **COM_ConvertToLocalPlatform( EFunctionMangleType to, const char *from, siz
|
||||
return NULL;
|
||||
}
|
||||
|
||||
prev = from;
|
||||
string symbols[MAX_NESTED_NAMESPACES];
|
||||
const char *prev = from;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < MAX_NESTED_NAMESPACES; i++ )
|
||||
{
|
||||
@@ -415,8 +412,9 @@ char **COM_ConvertToLocalPlatform( EFunctionMangleType to, const char *from, siz
|
||||
|
||||
// only three possible variations
|
||||
*numfuncs = ARRAYSIZE( postfix );
|
||||
ret = Z_Malloc( sizeof( char * ) * ARRAYSIZE( postfix ) );
|
||||
char **ret = Z_Malloc( sizeof( char * ) * ARRAYSIZE( postfix ) );
|
||||
|
||||
string temp, temp2;
|
||||
Q_strncpy( temp, "_ZN", sizeof( temp ));
|
||||
|
||||
for( ; i >= 0; i-- )
|
||||
@@ -492,9 +490,8 @@ static void Test_GetMSVCName( void )
|
||||
"?foo@@", "foo", // not an error?
|
||||
"?foo@bar@baz@@gotstrippedanyway","foo@bar@baz"
|
||||
};
|
||||
int i;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( symbols ); i += 2 )
|
||||
for( int i = 0; i < ARRAYSIZE( symbols ); i += 2 )
|
||||
{
|
||||
Msg( "Checking if MSVC '%s' converts to '%s'...\n", symbols[i], symbols[i+1] );
|
||||
|
||||
@@ -519,9 +516,8 @@ static void Test_GetItaniumName( void )
|
||||
"_ZN3fooEv", "foo", // not possible?
|
||||
"_ZN3baz3bar3fooEdontcare", "foo@bar@baz",
|
||||
};
|
||||
int i;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( symbols ); i += 2 )
|
||||
for( int i = 0; i < ARRAYSIZE( symbols ); i += 2 )
|
||||
{
|
||||
Msg( "Checking if Itanium '%s' converts to '%s'...\n", symbols[i], symbols[i+1] );
|
||||
|
||||
@@ -538,17 +534,15 @@ static void Test_ConvertFromValveToLocal( void )
|
||||
"xash3d@fwgs", "_ZN4fwgs6xash3d",
|
||||
"foo@bar@bazz", "_ZN4bazz3bar3foo"
|
||||
};
|
||||
int i;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( symbols ); i += 2 )
|
||||
for( int i = 0; i < ARRAYSIZE( symbols ); i += 2 )
|
||||
{
|
||||
char **ret;
|
||||
size_t numfuncs;
|
||||
size_t symlen = Q_strlen( symbols[i + 1] );
|
||||
|
||||
Msg( "Checking if Valve '%s' converts to Itanium '%s'...\n", symbols[i], symbols[i+1] );
|
||||
|
||||
ret = COM_ConvertToLocalPlatform( MANGLE_ITANIUM, symbols[i], &numfuncs );
|
||||
char **ret = COM_ConvertToLocalPlatform( MANGLE_ITANIUM, symbols[i], &numfuncs );
|
||||
|
||||
TASSERT( numfuncs == 3 );
|
||||
TASSERT( !Q_strncmp( ret[0], symbols[i+1], symlen ));
|
||||
|
||||
@@ -45,14 +45,11 @@ static CVAR_DEFINE_AUTO( sv_verbose_heartbeats, "0", 0, "print every heartbeat t
|
||||
|
||||
static size_t NET_BuildMasterServerScanRequest( char *buf, size_t size, uint32_t key, qboolean nat, const char *filter, connprotocol_t proto )
|
||||
{
|
||||
size_t remaining;
|
||||
char *info, temp[32];
|
||||
|
||||
// TODO: pagination and region
|
||||
Q_strncpy( buf, A2M_SCAN_REQUEST, size );
|
||||
|
||||
info = buf + sizeof( A2M_SCAN_REQUEST ) - 1;
|
||||
remaining = size - sizeof( A2M_SCAN_REQUEST );
|
||||
char *info = buf + sizeof( A2M_SCAN_REQUEST ) - 1;
|
||||
size_t remaining = size - sizeof( A2M_SCAN_REQUEST );
|
||||
|
||||
Q_strncpy( info, filter, remaining );
|
||||
|
||||
@@ -62,6 +59,8 @@ static size_t NET_BuildMasterServerScanRequest( char *buf, size_t size, uint32_t
|
||||
|
||||
if( proto != PROTO_GOLDSRC )
|
||||
{
|
||||
char temp[32];
|
||||
|
||||
// let master know about client version
|
||||
Info_SetValueForKey( info, "clver", XASH_VERSION, remaining );
|
||||
Info_SetValueForKey( info, "nat", nat ? "1" : "0", remaining );
|
||||
@@ -87,15 +86,13 @@ NET_GetMasterHostByName
|
||||
*/
|
||||
static net_gai_state_t NET_GetMasterHostByName( master_t *m )
|
||||
{
|
||||
net_gai_state_t res;
|
||||
|
||||
if( host.realtime > m->resolve_time )
|
||||
m->adr.type = 0;
|
||||
|
||||
if( m->adr.type )
|
||||
return NET_EAI_OK;
|
||||
|
||||
res = NET_StringToAdrNB( m->address, &m->adr, m->v6only );
|
||||
net_gai_state_t res = NET_StringToAdrNB( m->address, &m->adr, m->v6only );
|
||||
|
||||
if( res == NET_EAI_OK )
|
||||
{
|
||||
@@ -127,10 +124,9 @@ return true if would block
|
||||
*/
|
||||
static qboolean NET_SendToMasters( netsrc_t sock, size_t len, const void *data, connprotocol_t proto )
|
||||
{
|
||||
master_t *master;
|
||||
qboolean wait = false;
|
||||
|
||||
for( master = ml.head; master; master = master->next )
|
||||
for( master_t *master = ml.head; master; master = master->next )
|
||||
{
|
||||
if( master->gs )
|
||||
{
|
||||
@@ -199,9 +195,7 @@ NET_AnnounceToMaster
|
||||
*/
|
||||
void NET_MasterClear( void )
|
||||
{
|
||||
master_t *m;
|
||||
|
||||
for( m = ml.head; m; m = m->next )
|
||||
for( master_t *m = ml.head; m; m = m->next )
|
||||
m->last_heartbeat = MAX_HEARTBEAT;
|
||||
}
|
||||
|
||||
@@ -213,11 +207,8 @@ NET_MasterQuery
|
||||
qboolean NET_MasterQuery( uint32_t key, qboolean nat, const char *filter )
|
||||
{
|
||||
char buf[512];
|
||||
size_t len;
|
||||
qboolean wait = false;
|
||||
|
||||
len = NET_BuildMasterServerScanRequest( buf, sizeof( buf ), key, nat, filter, PROTO_CURRENT );
|
||||
wait = NET_SendToMasters( NS_CLIENT, len, buf, PROTO_CURRENT );
|
||||
size_t len = NET_BuildMasterServerScanRequest( buf, sizeof( buf ), key, nat, filter, PROTO_CURRENT );
|
||||
qboolean wait = NET_SendToMasters( NS_CLIENT, len, buf, PROTO_CURRENT );
|
||||
|
||||
// goldsrc don't have nat traversal extensions
|
||||
if( !nat )
|
||||
@@ -240,12 +231,10 @@ NET_MasterHeartbeat
|
||||
*/
|
||||
void NET_MasterHeartbeat( void )
|
||||
{
|
||||
master_t *m;
|
||||
|
||||
if(( !public_server.value && !sv_nat.value ) || svs.maxclients == 1 )
|
||||
return; // only public servers send heartbeats
|
||||
|
||||
for( m = ml.head; m; m = m->next )
|
||||
for( master_t *m = ml.head; m; m = m->next )
|
||||
{
|
||||
if( host.realtime - m->last_heartbeat < HEARTBEAT_SECONDS )
|
||||
continue;
|
||||
@@ -296,9 +285,7 @@ NET_GetMasterFromAdr
|
||||
*/
|
||||
static master_t *NET_GetMasterFromAdr( netadr_t adr )
|
||||
{
|
||||
master_t *master;
|
||||
|
||||
for( master = ml.head; master; master = master->next )
|
||||
for( master_t *master = ml.head; master; master = master->next )
|
||||
{
|
||||
if( NET_CompareAdr( adr, master->adr ))
|
||||
return master;
|
||||
@@ -315,9 +302,7 @@ NET_GetMaster
|
||||
*/
|
||||
qboolean NET_GetMaster( netadr_t from, uint *challenge, double *last_heartbeat )
|
||||
{
|
||||
master_t *m;
|
||||
|
||||
m = NET_GetMasterFromAdr( from );
|
||||
master_t *m = NET_GetMasterFromAdr( from );
|
||||
|
||||
if( m )
|
||||
{
|
||||
@@ -356,15 +341,13 @@ Add master to the list
|
||||
*/
|
||||
static master_t *NET_AddMaster( const char *addr )
|
||||
{
|
||||
master_t *master;
|
||||
|
||||
for( master = ml.head; master; master = master->next )
|
||||
for( master_t *master = ml.head; master; master = master->next )
|
||||
{
|
||||
if( !Q_stricmp( master->address, addr )) // already exists
|
||||
return master;
|
||||
}
|
||||
|
||||
master = Mem_Calloc( host.mempool, sizeof( *master ));
|
||||
master_t *master = Mem_Calloc( host.mempool, sizeof( *master ));
|
||||
Q_strncpy( master->address, addr, sizeof( master->address ));
|
||||
|
||||
if( ml.tail )
|
||||
@@ -382,15 +365,13 @@ static master_t *NET_AddMaster( const char *addr )
|
||||
|
||||
static void NET_AddMaster_f( void )
|
||||
{
|
||||
master_t *master;
|
||||
|
||||
if( Cmd_Argc() != 2 )
|
||||
{
|
||||
Msg( S_USAGE "addmaster <address> [gs]\n");
|
||||
return;
|
||||
}
|
||||
|
||||
master = NET_AddMaster( Cmd_Argv( 1 ));
|
||||
master_t *master = NET_AddMaster( Cmd_Argv( 1 ));
|
||||
master->save = true;
|
||||
|
||||
if( !Q_stricmp( Cmd_Argv( 2 ), "gs" ))
|
||||
@@ -427,12 +408,10 @@ Display current master linked list
|
||||
*/
|
||||
static void NET_ListMasters_f( void )
|
||||
{
|
||||
master_t *master;
|
||||
int i;
|
||||
|
||||
Con_Printf( "Master servers:\n" );
|
||||
|
||||
for( i = 1, master = ml.head; master; i++, master = master->next )
|
||||
int i = 1;
|
||||
for( master_t *master = ml.head; master; i++, master = master->next )
|
||||
{
|
||||
Con_Printf( "%d\t%s", i, master->address );
|
||||
if( master->adr.type != 0 )
|
||||
@@ -457,11 +436,8 @@ Load master server list from xashcomm.lst
|
||||
*/
|
||||
static void NET_LoadMasters( void )
|
||||
{
|
||||
byte *afile;
|
||||
char *pfile;
|
||||
char token[MAX_TOKEN];
|
||||
|
||||
afile = FS_LoadFile( "xashcomm.lst", NULL, false );
|
||||
byte *afile = FS_LoadFile( "xashcomm.lst", NULL, false );
|
||||
|
||||
if( !afile ) // file doesn't exist yet
|
||||
{
|
||||
@@ -469,7 +445,7 @@ static void NET_LoadMasters( void )
|
||||
return;
|
||||
}
|
||||
|
||||
pfile = (char*)afile;
|
||||
char *pfile = (char*)afile;
|
||||
|
||||
// format: master <addr>\n
|
||||
while(( pfile = COM_ParseFile( pfile, token, sizeof( token ))))
|
||||
@@ -515,13 +491,10 @@ Save master server list to xashcomm.lst, except for default
|
||||
*/
|
||||
void NET_SaveMasters( void )
|
||||
{
|
||||
file_t *f;
|
||||
master_t *m;
|
||||
|
||||
if( !ml.modified )
|
||||
return;
|
||||
|
||||
f = FS_Open( "xashcomm.lst", "w", true );
|
||||
file_t *f = FS_Open( "xashcomm.lst", "w", true );
|
||||
|
||||
if( !f )
|
||||
{
|
||||
@@ -529,7 +502,7 @@ void NET_SaveMasters( void )
|
||||
return;
|
||||
}
|
||||
|
||||
for( m = ml.head; m; m = m->next )
|
||||
for( master_t *m = ml.head; m; m = m->next )
|
||||
{
|
||||
const char *key;
|
||||
|
||||
|
||||
@@ -27,20 +27,17 @@ static const trivertex_t *g_poseverts[MAXALIASFRAMES];
|
||||
|
||||
static const void *Mod_LoadAliasFrame( const daliasframe_t *pdaliasframe, maliasframedesc_t *frame, const aliashdr_t *aliashdr )
|
||||
{
|
||||
const trivertex_t *pinframe;
|
||||
int i;
|
||||
|
||||
Q_strncpy( frame->name, pdaliasframe->name, sizeof( frame->name ));
|
||||
frame->firstpose = g_posenum;
|
||||
frame->numposes = 1;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
frame->bboxmin.v[i] = pdaliasframe->bboxmin.v[i];
|
||||
frame->bboxmax.v[i] = pdaliasframe->bboxmax.v[i];
|
||||
}
|
||||
|
||||
pinframe = (const trivertex_t *)(pdaliasframe + 1);
|
||||
const trivertex_t *pinframe = (const trivertex_t *)(pdaliasframe + 1);
|
||||
|
||||
g_poseverts[g_posenum] = pinframe;
|
||||
g_posenum++;
|
||||
@@ -52,27 +49,25 @@ static const void *Mod_LoadAliasFrame( const daliasframe_t *pdaliasframe, malias
|
||||
|
||||
static const void *Mod_LoadAliasGroup( const daliasgroup_t *pingroup, maliasframedesc_t *frame, const aliashdr_t *aliashdr )
|
||||
{
|
||||
const daliasinterval_t *pin_intervals;
|
||||
const void *ptemp;
|
||||
int i, numframes;
|
||||
int numframes;
|
||||
|
||||
frame->firstpose = g_posenum;
|
||||
frame->numposes = numframes = pingroup->numframes;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
frame->bboxmin.v[i] = pingroup->bboxmin.v[i];
|
||||
frame->bboxmax.v[i] = pingroup->bboxmax.v[i];
|
||||
}
|
||||
|
||||
pin_intervals = (const daliasinterval_t *)(pingroup + 1);
|
||||
const daliasinterval_t *pin_intervals = (const daliasinterval_t *)(pingroup + 1);
|
||||
|
||||
// all the intervals are always equal 0.1 so we don't care about them
|
||||
frame->interval = pin_intervals->interval;
|
||||
pin_intervals += numframes;
|
||||
ptemp = (void *)pin_intervals;
|
||||
const void *ptemp = (void *)pin_intervals;
|
||||
|
||||
for( i = 0; i < numframes; i++ )
|
||||
for( int i = 0; i < numframes; i++ )
|
||||
{
|
||||
g_poseverts[g_posenum] = (const trivertex_t *)((const daliasframe_t *)ptemp + 1);
|
||||
ptemp = g_poseverts[g_posenum] + aliashdr->numverts;
|
||||
@@ -84,24 +79,20 @@ static const void *Mod_LoadAliasGroup( const daliasgroup_t *pingroup, maliasfram
|
||||
|
||||
static void Mod_CalcAliasBounds( model_t *mod, const aliashdr_t *aliashdr )
|
||||
{
|
||||
int i, j, k;
|
||||
float radius;
|
||||
float dist;
|
||||
vec3_t v;
|
||||
|
||||
ClearBounds( mod->mins, mod->maxs );
|
||||
radius = 0.0f;
|
||||
float radius = 0.0f;
|
||||
|
||||
// process verts
|
||||
for( i = 0; i < aliashdr->numposes; i++ )
|
||||
for( int i = 0; i < aliashdr->numposes; i++ )
|
||||
{
|
||||
for( j = 0; j < aliashdr->numverts; j++ )
|
||||
for( int j = 0; j < aliashdr->numverts; j++ )
|
||||
{
|
||||
for( k = 0; k < 3; k++ )
|
||||
vec3_t v;
|
||||
for( int k = 0; k < 3; k++ )
|
||||
v[k] = g_poseverts[i][j].v[k] * aliashdr->scale[k] + aliashdr->scale_origin[k];
|
||||
|
||||
AddPointToBounds( v, mod->mins, mod->maxs );
|
||||
dist = DotProduct( v, v );
|
||||
float dist = DotProduct( v, v );
|
||||
|
||||
if( radius < dist )
|
||||
radius = dist;
|
||||
@@ -113,15 +104,13 @@ static void Mod_CalcAliasBounds( model_t *mod, const aliashdr_t *aliashdr )
|
||||
|
||||
static const void *Mod_LoadAllSkins( model_t *mod, int numskins, const daliasskintype_t *pskintype, const aliashdr_t *aliashdr )
|
||||
{
|
||||
int i, size;
|
||||
|
||||
if(( numskins < 1 ) || ( numskins > MAX_SKINS ))
|
||||
Host_Error( "%s: Invalid # of skins: %d\n", __func__, numskins );
|
||||
|
||||
size = aliashdr->skinwidth * aliashdr->skinheight;
|
||||
int size = aliashdr->skinwidth * aliashdr->skinheight;
|
||||
|
||||
// just skipping textures, renderer will take care of them later
|
||||
for( i = 0; i < numskins; i++ )
|
||||
for( int i = 0; i < numskins; i++ )
|
||||
{
|
||||
if( pskintype->type == ALIAS_SKIN_SINGLE )
|
||||
{
|
||||
@@ -152,33 +141,24 @@ load alias model
|
||||
*/
|
||||
void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded )
|
||||
{
|
||||
const daliasframetype_t *pframetype;
|
||||
const daliasskintype_t *pskintype;
|
||||
const dtriangle_t *pintriangles;
|
||||
const daliashdr_t *pinmodel;
|
||||
const stvert_t *pinstverts;
|
||||
aliashdr_t *m_pAliasHeader;
|
||||
size_t size;
|
||||
char poolname[MAX_VA_STRING];
|
||||
int i;
|
||||
|
||||
if( loaded ) *loaded = false;
|
||||
pinmodel = (const daliashdr_t *)buffer;
|
||||
i = pinmodel->version;
|
||||
const daliashdr_t *pinmodel = (const daliashdr_t *)buffer;
|
||||
|
||||
if( i != ALIAS_VERSION )
|
||||
if( pinmodel->version != ALIAS_VERSION )
|
||||
{
|
||||
Con_DPrintf( S_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, pinmodel->version, ALIAS_VERSION );
|
||||
return;
|
||||
}
|
||||
|
||||
if( pinmodel->numverts <= 0 || pinmodel->numtris <= 0 || pinmodel->numframes <= 0 )
|
||||
return; // how is it possible to make that?
|
||||
|
||||
char poolname[MAX_VA_STRING];
|
||||
Q_snprintf( poolname, sizeof( poolname ), "^2%s^7", mod->name );
|
||||
mod->mempool = Mem_AllocPool( poolname );
|
||||
|
||||
size = sizeof( aliashdr_t ) + (pinmodel->numframes - 1) * sizeof( maliasframedesc_t );
|
||||
size_t size = sizeof( aliashdr_t ) + (pinmodel->numframes - 1) * sizeof( maliasframedesc_t );
|
||||
aliashdr_t *m_pAliasHeader;
|
||||
mod->cache.data = m_pAliasHeader = Mem_Calloc( mod->mempool, size );
|
||||
|
||||
// endian-adjust and copy the data, starting with the alias model header
|
||||
@@ -199,7 +179,7 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded )
|
||||
mod->numframes = m_pAliasHeader->numframes = pinmodel->numframes;
|
||||
m_pAliasHeader->size = pinmodel->size;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
m_pAliasHeader->scale[i] = pinmodel->scale[i];
|
||||
m_pAliasHeader->scale_origin[i] = pinmodel->scale_origin[i];
|
||||
@@ -207,24 +187,24 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded )
|
||||
}
|
||||
|
||||
// load the skins
|
||||
pskintype = (const daliasskintype_t *)&pinmodel[1];
|
||||
const daliasskintype_t *pskintype = (const daliasskintype_t *)&pinmodel[1];
|
||||
pskintype = Mod_LoadAllSkins( mod, m_pAliasHeader->numskins, pskintype, m_pAliasHeader );
|
||||
// will be done at renderer side...
|
||||
|
||||
// load base s and t vertices
|
||||
pinstverts = (const stvert_t *)pskintype;
|
||||
const stvert_t *pinstverts = (const stvert_t *)pskintype;
|
||||
// will be done at renderer side...
|
||||
|
||||
// load triangle lists
|
||||
pintriangles = (const dtriangle_t *)&pinstverts[m_pAliasHeader->numverts];
|
||||
const dtriangle_t *pintriangles = (const dtriangle_t *)&pinstverts[m_pAliasHeader->numverts];
|
||||
// will be done at renderer side
|
||||
|
||||
// load the frames
|
||||
pframetype = (const daliasframetype_t *)&pintriangles[m_pAliasHeader->numtris];
|
||||
const daliasframetype_t *pframetype = (const daliasframetype_t *)&pintriangles[m_pAliasHeader->numtris];
|
||||
m_pAliasHeader->pposeverts = g_poseverts; // store the pointer to be accessed by renderer
|
||||
g_posenum = 0;
|
||||
|
||||
for( i = 0; i < m_pAliasHeader->numframes; i++ )
|
||||
for( int i = 0; i < m_pAliasHeader->numframes; i++ )
|
||||
{
|
||||
aliasframetype_t frametype = pframetype->type;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -111,14 +111,14 @@ static byte *Mod_SwapSpriteGroup( byte *p, byte *end, int bytes )
|
||||
static qboolean Mod_SwapSprite( void *buffer, size_t buffersize, int *out_version )
|
||||
{
|
||||
byte *end = (byte *)buffer + buffersize;
|
||||
int version, numframes, bytes;
|
||||
int numframes;
|
||||
byte *p;
|
||||
|
||||
if( buffersize < sizeof( dsprite_t ))
|
||||
return false;
|
||||
|
||||
// peek at ident + version before full swap
|
||||
version = LittleLong(((dsprite_t *)buffer)->version );
|
||||
int version = LittleLong(((dsprite_t *)buffer)->version );
|
||||
|
||||
switch( version )
|
||||
{
|
||||
@@ -152,7 +152,7 @@ static qboolean Mod_SwapSprite( void *buffer, size_t buffersize, int *out_versio
|
||||
}
|
||||
|
||||
*out_version = version;
|
||||
bytes = ( version == SPRITE_VERSION_32 ) ? 4 : 1;
|
||||
int bytes = ( version == SPRITE_VERSION_32 ) ? 4 : 1;
|
||||
|
||||
// swap all frames
|
||||
for( int i = 0; i < numframes && p && p < end; i++ )
|
||||
@@ -194,12 +194,11 @@ load sprite model
|
||||
void Mod_LoadSpriteModel( model_t *mod, void *buffer, size_t buffersize, qboolean *loaded )
|
||||
{
|
||||
msprite_t *psprite;
|
||||
char poolname[MAX_VA_STRING];
|
||||
int version;
|
||||
|
||||
if( loaded )
|
||||
*loaded = false;
|
||||
|
||||
int version;
|
||||
if( !Mod_SwapSprite( buffer, buffersize, &version ))
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: %s is not a valid sprite\n", __func__, mod->name );
|
||||
@@ -207,13 +206,13 @@ void Mod_LoadSpriteModel( model_t *mod, void *buffer, size_t buffersize, qboolea
|
||||
}
|
||||
|
||||
mod->type = mod_sprite;
|
||||
char poolname[MAX_VA_STRING];
|
||||
Q_snprintf( poolname, sizeof( poolname ), "^2%s^7", mod->name );
|
||||
mod->mempool = Mem_AllocPool( poolname );
|
||||
|
||||
if( version == SPRITE_VERSION_Q1 || version == SPRITE_VERSION_32 )
|
||||
{
|
||||
dsprite_q1_t *pinq1 = buffer;
|
||||
size_t size;
|
||||
|
||||
if( pinq1->numframes == 0 )
|
||||
{
|
||||
@@ -221,7 +220,7 @@ void Mod_LoadSpriteModel( model_t *mod, void *buffer, size_t buffersize, qboolea
|
||||
return;
|
||||
}
|
||||
|
||||
size = sizeof( msprite_t ) + ( pinq1->numframes - 1 ) * sizeof( psprite->frames );
|
||||
size_t size = sizeof( msprite_t ) + ( pinq1->numframes - 1 ) * sizeof( psprite->frames );
|
||||
|
||||
psprite = Mem_Calloc( mod->mempool, size );
|
||||
mod->cache.data = psprite; // make link to extradata
|
||||
@@ -245,7 +244,6 @@ void Mod_LoadSpriteModel( model_t *mod, void *buffer, size_t buffersize, qboolea
|
||||
else // if( version == SPRITE_VERSION_HL )
|
||||
{
|
||||
dsprite_hl_t *pinhl = buffer;
|
||||
size_t size;
|
||||
|
||||
if( pinhl->numframes == 0 )
|
||||
{
|
||||
@@ -253,7 +251,7 @@ void Mod_LoadSpriteModel( model_t *mod, void *buffer, size_t buffersize, qboolea
|
||||
return;
|
||||
}
|
||||
|
||||
size = sizeof( msprite_t ) + ( pinhl->numframes - 1 ) * sizeof( psprite->frames );
|
||||
size_t size = sizeof( msprite_t ) + ( pinhl->numframes - 1 ) * sizeof( psprite->frames );
|
||||
|
||||
psprite = Mem_Calloc( mod->mempool, size );
|
||||
mod->cache.data = psprite; // make link to extradata
|
||||
|
||||
@@ -211,12 +211,10 @@ Mod_InitStudioHull
|
||||
*/
|
||||
void Mod_InitStudioHull( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( studio_hull[0].planes != NULL )
|
||||
return; // already initailized
|
||||
|
||||
for( i = 0; i < MAXSTUDIOBONES; i++ )
|
||||
for( int i = 0; i < MAXSTUDIOBONES; i++ )
|
||||
{
|
||||
studio_hull[i].clipnodes16 = (mclipnode16_t *)box_clipnodes16;
|
||||
studio_hull[i].planes = &studio_planes[i*6];
|
||||
@@ -265,13 +263,11 @@ AddToStudioCache
|
||||
*/
|
||||
static void Mod_AddToStudioCache( float frame, int sequence, vec3_t angles, vec3_t origin, vec3_t size, byte *pcontroller, byte *pblending, model_t *model, hull_t *hull, int numhitboxes )
|
||||
{
|
||||
mstudiocache_t *pCache;
|
||||
|
||||
if( numhitboxes + cache_current_hull >= MAXSTUDIOBONES )
|
||||
Mod_ClearStudioCache();
|
||||
|
||||
cache_current++;
|
||||
pCache = &cache_studio[cache_current & STUDIO_CACHEMASK];
|
||||
mstudiocache_t *pCache = &cache_studio[cache_current & STUDIO_CACHEMASK];
|
||||
|
||||
pCache->frame = frame;
|
||||
pCache->sequence = sequence;
|
||||
@@ -302,12 +298,9 @@ CheckStudioCache
|
||||
*/
|
||||
static mstudiocache_t *Mod_CheckStudioCache( model_t *model, float frame, int sequence, vec3_t angles, vec3_t origin, vec3_t size, byte *controller, byte *blending )
|
||||
{
|
||||
mstudiocache_t *pCached;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < STUDIO_CACHESIZE; i++ )
|
||||
for( int i = 0; i < STUDIO_CACHESIZE; i++ )
|
||||
{
|
||||
pCached = &cache_studio[(cache_current - i) & STUDIO_CACHEMASK];
|
||||
mstudiocache_t *pCached = &cache_studio[(cache_current - i) & STUDIO_CACHEMASK];
|
||||
|
||||
if( pCached->model != model )
|
||||
continue;
|
||||
@@ -377,18 +370,13 @@ NOTE: pEdict may be NULL
|
||||
*/
|
||||
hull_t *Mod_HullForStudio( model_t *model, float frame, int sequence, vec3_t angles, vec3_t origin, vec3_t size, byte *pcontroller, byte *pblending, int *numhitboxes, edict_t *pEdict )
|
||||
{
|
||||
vec3_t angles2;
|
||||
mstudiocache_t *bonecache;
|
||||
mstudiobbox_t *phitbox;
|
||||
qboolean bSkipShield;
|
||||
int i, j;
|
||||
qboolean bSkipShield = false;
|
||||
|
||||
bSkipShield = false;
|
||||
*numhitboxes = 0; // assume error
|
||||
|
||||
if( mod_studiocache.value )
|
||||
{
|
||||
bonecache = Mod_CheckStudioCache( model, frame, sequence, angles, origin, size, pcontroller, pblending );
|
||||
mstudiocache_t *bonecache = Mod_CheckStudioCache( model, frame, sequence, angles, origin, size, pcontroller, pblending );
|
||||
|
||||
if( bonecache != NULL )
|
||||
{
|
||||
@@ -404,18 +392,18 @@ hull_t *Mod_HullForStudio( model_t *model, float frame, int sequence, vec3_t ang
|
||||
mod_studiohdr = Mod_StudioExtradata( model );
|
||||
if( !mod_studiohdr ) return NULL; // probably not a studiomodel
|
||||
|
||||
VectorCopy( angles, angles2 );
|
||||
vec3_t angles2 = Vec3( angles );
|
||||
|
||||
if( !FBitSet( host.features, ENGINE_COMPENSATE_QUAKE_BUG ))
|
||||
angles2[PITCH] = -angles2[PITCH]; // stupid quake bug
|
||||
|
||||
pBlendAPI->SV_StudioSetupBones( model, frame, sequence, angles2, origin, pcontroller, pblending, -1, pEdict );
|
||||
phitbox = (mstudiobbox_t *)((byte *)mod_studiohdr + mod_studiohdr->hitboxindex);
|
||||
mstudiobbox_t *phitbox = (mstudiobbox_t *)((byte *)mod_studiohdr + mod_studiohdr->hitboxindex);
|
||||
|
||||
if( SV_IsValidEdict( pEdict ) && pEdict->v.gamestate == 1 )
|
||||
bSkipShield = 1;
|
||||
|
||||
for( i = j = 0; i < mod_studiohdr->numhitboxes; i++, j += 6 )
|
||||
for( int i = 0, j = 0; i < mod_studiohdr->numhitboxes; i++, j += 6 )
|
||||
{
|
||||
if( world.version == QBSP2_VERSION )
|
||||
studio_hull[i].clipnodes32 = (mclipnode32_t *)box_clipnodes32;
|
||||
@@ -743,7 +731,6 @@ StudioGetAttachment
|
||||
void Mod_StudioGetAttachment( const edict_t *e, int iAtt, float *origin, float *angles )
|
||||
{
|
||||
mstudioattachment_t *pAtt;
|
||||
vec3_t angles2;
|
||||
matrix3x4 localPose;
|
||||
matrix3x4 worldPose;
|
||||
model_t *mod;
|
||||
@@ -766,7 +753,7 @@ void Mod_StudioGetAttachment( const edict_t *e, int iAtt, float *origin, float *
|
||||
// calculate attachment origin and angles
|
||||
pAtt = (mstudioattachment_t *)((byte *)mod_studiohdr + mod_studiohdr->attachmentindex) + iAtt;
|
||||
|
||||
VectorCopy( e->v.angles, angles2 );
|
||||
vec3_t angles2 = Vec3( e->v.angles );
|
||||
|
||||
if( !FBitSet( host.features, ENGINE_COMPENSATE_QUAKE_BUG ))
|
||||
angles2[PITCH] = -angles2[PITCH];
|
||||
|
||||
@@ -195,12 +195,10 @@ Mod_FreeAll
|
||||
*/
|
||||
void Mod_FreeAll( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
#if !XASH_DEDICATED
|
||||
Mod_ReleaseHullPolygons();
|
||||
#endif
|
||||
for( i = 0; i < mod_numknown; i++ )
|
||||
for( int i = 0; i < mod_numknown; i++ )
|
||||
Mod_FreeModel( &mod_known[i] );
|
||||
mod_numknown = 0;
|
||||
}
|
||||
@@ -212,9 +210,7 @@ Mod_ClearUserData
|
||||
*/
|
||||
void Mod_ClearUserData( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < mod_numknown; i++ )
|
||||
for( int i = 0; i < mod_numknown; i++ )
|
||||
Mod_FreeUserData( &mod_known[i] );
|
||||
}
|
||||
|
||||
@@ -301,8 +297,6 @@ model_t *Mod_LoadModel( model_t *mod, qboolean crash )
|
||||
char tempname[MAX_QPATH];
|
||||
fs_offset_t length = 0;
|
||||
qboolean loaded, loaded2 = false;
|
||||
byte *buf;
|
||||
model_info_t *p;
|
||||
|
||||
if( !mod )
|
||||
{
|
||||
@@ -327,7 +321,7 @@ model_t *Mod_LoadModel( model_t *mod, qboolean crash )
|
||||
Q_strncpy( tempname, mod->name, sizeof( tempname ));
|
||||
COM_FixSlashes( tempname );
|
||||
|
||||
buf = FS_LoadFile( tempname, &length, false );
|
||||
byte *buf = FS_LoadFile( tempname, &length, false );
|
||||
|
||||
if( !buf || length < sizeof( uint ))
|
||||
{
|
||||
@@ -407,7 +401,7 @@ model_t *Mod_LoadModel( model_t *mod, qboolean crash )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p = &mod_crcinfo[mod - mod_known];
|
||||
model_info_t *p = &mod_crcinfo[mod - mod_known];
|
||||
mod->needload = NL_PRESENT;
|
||||
|
||||
if( FBitSet( p->flags, FCRC_SHOULD_CHECKSUM ))
|
||||
@@ -443,12 +437,10 @@ Loads in a model for the given name
|
||||
*/
|
||||
model_t *Mod_ForName( const char *name, qboolean crash, qboolean trackCRC )
|
||||
{
|
||||
model_t *mod;
|
||||
|
||||
if( COM_StringEmptyOrNULL( name ))
|
||||
return NULL;
|
||||
|
||||
mod = Mod_FindName( name, trackCRC );
|
||||
model_t *mod = Mod_FindName( name, trackCRC );
|
||||
return Mod_LoadModel( mod, crash );
|
||||
}
|
||||
|
||||
@@ -461,8 +453,6 @@ free studio cache on change level
|
||||
*/
|
||||
static void Mod_PurgeStudioCache( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
// refresh hull data
|
||||
SetBits( r_showhull.flags, FCVAR_CHANGED );
|
||||
#if !XASH_DEDICATED
|
||||
@@ -473,7 +463,7 @@ static void Mod_PurgeStudioCache( void )
|
||||
|
||||
// we should release all the world submodels
|
||||
// and clear studio sequences
|
||||
for( i = 1; i < mod_numknown; i++ )
|
||||
for( int i = 1; i < mod_numknown; i++ )
|
||||
{
|
||||
if( mod_known[i].needload == NL_UNREFERENCED )
|
||||
continue;
|
||||
@@ -500,8 +490,6 @@ Loads in the map and all submodels
|
||||
*/
|
||||
model_t *Mod_LoadWorld( const char *name, qboolean preload )
|
||||
{
|
||||
model_t *pworld;
|
||||
|
||||
// already loaded?
|
||||
if( !Q_stricmp( mod_known->name, name ))
|
||||
return mod_known;
|
||||
@@ -511,7 +499,7 @@ model_t *Mod_LoadWorld( const char *name, qboolean preload )
|
||||
|
||||
// load the newmap
|
||||
world.loading = true;
|
||||
pworld = Mod_FindName( name, false );
|
||||
model_t *pworld = Mod_FindName( name, false );
|
||||
if( preload ) Mod_LoadModel( pworld, true );
|
||||
world.loading = false;
|
||||
|
||||
@@ -555,12 +543,10 @@ Mod_Calloc
|
||||
*/
|
||||
void *GAME_EXPORT Mod_Calloc( int number, size_t size )
|
||||
{
|
||||
cache_user_t *cu;
|
||||
|
||||
if( number <= 0 || size <= 0 )
|
||||
return NULL;
|
||||
|
||||
cu = (cache_user_t *)Mem_Calloc( com_studiocache, sizeof( cache_user_t ) + number * size );
|
||||
cache_user_t *cu = (cache_user_t *)Mem_Calloc( com_studiocache, sizeof( cache_user_t ) + number * size );
|
||||
cu->data = (void *)cu; // make sure that cu->data is not NULL
|
||||
|
||||
return cu;
|
||||
@@ -593,7 +579,6 @@ void GAME_EXPORT Mod_LoadCacheFile( const char *filename, cache_user_t *cu )
|
||||
{
|
||||
char modname[MAX_QPATH];
|
||||
fs_offset_t size;
|
||||
byte *buf;
|
||||
|
||||
Assert( cu != NULL );
|
||||
|
||||
@@ -603,7 +588,7 @@ void GAME_EXPORT Mod_LoadCacheFile( const char *filename, cache_user_t *cu )
|
||||
Q_strncpy( modname, filename, sizeof( modname ));
|
||||
COM_FixSlashes( modname );
|
||||
|
||||
buf = FS_LoadFile( modname, &size, false );
|
||||
byte *buf = FS_LoadFile( modname, &size, false );
|
||||
if( !buf || !size ) Host_Error( "LoadCacheFile: ^1can't load %s^7\n", filename );
|
||||
cu->data = Mem_Malloc( com_studiocache, size );
|
||||
memcpy( cu->data, buf, size );
|
||||
@@ -643,11 +628,8 @@ Mod_ValidateCRC
|
||||
*/
|
||||
qboolean Mod_ValidateCRC( const char *name, uint32_t crc )
|
||||
{
|
||||
model_info_t *p;
|
||||
model_t *mod;
|
||||
|
||||
mod = Mod_FindName( name, true );
|
||||
p = &mod_crcinfo[mod - mod_known];
|
||||
model_t *mod = Mod_FindName( name, true );
|
||||
model_info_t *p = &mod_crcinfo[mod - mod_known];
|
||||
|
||||
if( !FBitSet( p->flags, FCRC_CHECKSUM_DONE ))
|
||||
return true;
|
||||
@@ -664,11 +646,8 @@ Mod_NeedCRC
|
||||
*/
|
||||
void Mod_NeedCRC( const char *name, qboolean needCRC )
|
||||
{
|
||||
model_t *mod;
|
||||
model_info_t *p;
|
||||
|
||||
mod = Mod_FindName( name, true );
|
||||
p = &mod_crcinfo[mod - mod_known];
|
||||
model_t *mod = Mod_FindName( name, true );
|
||||
model_info_t *p = &mod_crcinfo[mod - mod_known];
|
||||
|
||||
if( needCRC ) SetBits( p->flags, FCRC_SHOULD_CHECKSUM );
|
||||
else ClearBits( p->flags, FCRC_SHOULD_CHECKSUM );
|
||||
|
||||
@@ -44,22 +44,19 @@ static uint COM_SwapLong( uint c )
|
||||
static void COM_GenericMunge( byte *data, const size_t len, const int seq, const byte *table, const qboolean reverse )
|
||||
{
|
||||
const size_t mungelen = len / 4;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < mungelen; i++ )
|
||||
for( int i = 0; i < mungelen; i++ )
|
||||
{
|
||||
uint32_t c;
|
||||
void *pc = &data[i * 4];
|
||||
byte *p;
|
||||
int j;
|
||||
|
||||
memcpy( &c, pc, sizeof( c ));
|
||||
c ^= seq;
|
||||
if( !reverse )
|
||||
c = COM_SwapLong( c );
|
||||
|
||||
p = (byte *)&c;
|
||||
for( j = 0; j < 4; j++ )
|
||||
byte *p = (byte *)&c;
|
||||
for( int j = 0; j < 4; j++ )
|
||||
*p++ ^= (0xa5 | (j << j) | j | table[(i + j) & 0x0f]);
|
||||
|
||||
if( reverse )
|
||||
@@ -123,11 +120,10 @@ void Test_RunMunge( void )
|
||||
};
|
||||
string buf;
|
||||
size_t msglen = Q_strlen( msg ) + 1;
|
||||
int i;
|
||||
|
||||
Q_strncpy( buf, msg, msglen );
|
||||
|
||||
for( i = 0; i < 0xFF; i++ )
|
||||
for( int i = 0; i < 0xFF; i++ )
|
||||
{
|
||||
COM_Munge( buf, msglen, i );
|
||||
if( i < sizeof( expected ) / sizeof( expected[0] ))
|
||||
|
||||
@@ -308,8 +308,6 @@ void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits )
|
||||
int nBitsLeft = numbits;
|
||||
int iCurBit = sb->iCurBit;
|
||||
uint iDWord = iCurBit >> 5; // Mask in a dword.
|
||||
uint32_t iCurBitMasked;
|
||||
int nBitsWritten;
|
||||
|
||||
Assert( numbits >= 1 && numbits <= 32 );
|
||||
|
||||
@@ -320,14 +318,14 @@ void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits )
|
||||
return;
|
||||
}
|
||||
|
||||
iCurBitMasked = iCurBit & 31;
|
||||
uint32_t iCurBitMasked = iCurBit & 31;
|
||||
uint32_t dword = LittleLong(((uint32_t *)sb->pData)[iDWord] );
|
||||
dword &= BitWriteMasks[iCurBitMasked][nBitsLeft-1];
|
||||
dword |= curData << iCurBitMasked;
|
||||
((uint32_t *)sb->pData)[iDWord] = LittleLong( dword );
|
||||
|
||||
// did it span a dword?
|
||||
nBitsWritten = 32 - iCurBitMasked;
|
||||
int nBitsWritten = 32 - iCurBitMasked;
|
||||
|
||||
if( nBitsWritten < nBitsLeft )
|
||||
{
|
||||
@@ -429,13 +427,12 @@ void MSG_WriteBitAngle( sizebuf_t *sb, float fAngle, int numbits )
|
||||
{
|
||||
const uint shift = ( 1 << numbits );
|
||||
const uint mask = shift - 1;
|
||||
int d;
|
||||
|
||||
// clamp the angle before receiving
|
||||
fAngle = fmod( fAngle, 360.0f );
|
||||
if( fAngle < 0 ) fAngle += 360.0f;
|
||||
|
||||
d = (int)(( fAngle * shift ) / 360.0f );
|
||||
int d = (int)(( fAngle * shift ) / 360.0f );
|
||||
d &= mask;
|
||||
|
||||
MSG_WriteUBitLong( sb, (uint)d, numbits );
|
||||
@@ -546,11 +543,10 @@ qboolean MSG_WriteString( sizebuf_t *sb, const char *pStr )
|
||||
qboolean MSG_WriteStringf( sizebuf_t *sb, const char *format, ... )
|
||||
{
|
||||
va_list va;
|
||||
int len;
|
||||
char buf[MAX_VA_STRING];
|
||||
|
||||
va_start( va, format );
|
||||
len = Q_vsnprintf( buf, sizeof( buf ), format, va );
|
||||
int len = Q_vsnprintf( buf, sizeof( buf ), format, va );
|
||||
va_end( va );
|
||||
|
||||
if( len < 0 )
|
||||
@@ -577,9 +573,6 @@ int MSG_ReadOneBit( sizebuf_t *sb )
|
||||
|
||||
uint MSG_ReadUBitLong( sizebuf_t *sb, int numbits )
|
||||
{
|
||||
int idword1;
|
||||
uint dword1, ret;
|
||||
|
||||
if( numbits == 8 )
|
||||
{
|
||||
int leftBits = MSG_GetNumBitsLeft( sb );
|
||||
@@ -597,12 +590,12 @@ uint MSG_ReadUBitLong( sizebuf_t *sb, int numbits )
|
||||
Assert( numbits > 0 && numbits <= 32 );
|
||||
|
||||
// Read the current dword.
|
||||
idword1 = sb->iCurBit >> 5;
|
||||
dword1 = LittleLong(((uint *)sb->pData)[idword1] );
|
||||
int idword1 = sb->iCurBit >> 5;
|
||||
uint dword1 = LittleLong(((uint *)sb->pData)[idword1] );
|
||||
dword1 >>= ( sb->iCurBit & 31 ); // get the bits we're interested in.
|
||||
|
||||
sb->iCurBit += numbits;
|
||||
ret = dword1;
|
||||
uint ret = dword1;
|
||||
|
||||
// Does it span this dword?
|
||||
if(( sb->iCurBit - 1 ) >> 5 == idword1 )
|
||||
@@ -726,10 +719,10 @@ int MSG_ReadCmd( sizebuf_t *sb, netsrc_t type )
|
||||
|
||||
int MSG_ReadChar( sizebuf_t *sb )
|
||||
{
|
||||
int alt = sb->iAlternateSign, ret;
|
||||
int alt = sb->iAlternateSign;
|
||||
|
||||
sb->iAlternateSign = 0;
|
||||
ret = MSG_ReadSBitLong( sb, sizeof( int8_t ) << 3 );
|
||||
int ret = MSG_ReadSBitLong( sb, sizeof( int8_t ) << 3 );
|
||||
sb->iAlternateSign = alt;
|
||||
|
||||
return ret;
|
||||
@@ -742,10 +735,10 @@ int MSG_ReadByte( sizebuf_t *sb )
|
||||
|
||||
int MSG_ReadShort( sizebuf_t *sb )
|
||||
{
|
||||
int alt = sb->iAlternateSign, ret;
|
||||
int alt = sb->iAlternateSign;
|
||||
|
||||
sb->iAlternateSign = 0;
|
||||
ret = MSG_ReadSBitLong( sb, sizeof( int16_t ) << 3 );
|
||||
int ret = MSG_ReadSBitLong( sb, sizeof( int16_t ) << 3 );
|
||||
sb->iAlternateSign = alt;
|
||||
|
||||
return ret;
|
||||
@@ -780,10 +773,10 @@ void MSG_ReadVec3Angles( sizebuf_t *sb, vec3_t fa )
|
||||
|
||||
int MSG_ReadLong( sizebuf_t *sb )
|
||||
{
|
||||
int alt = sb->iAlternateSign, ret;
|
||||
int alt = sb->iAlternateSign;
|
||||
|
||||
sb->iAlternateSign = 0;
|
||||
ret = MSG_ReadSBitLong( sb, sizeof( int32_t ) << 3 );
|
||||
int ret = MSG_ReadSBitLong( sb, sizeof( int32_t ) << 3 );
|
||||
sb->iAlternateSign = alt;
|
||||
|
||||
return ret;
|
||||
@@ -842,14 +835,14 @@ char *MSG_ReadStringLine( sizebuf_t *sb )
|
||||
|
||||
void MSG_ExciseBits( sizebuf_t *sb, int startbit, int bitstoremove )
|
||||
{
|
||||
int i, endbit = startbit + bitstoremove;
|
||||
int endbit = startbit + bitstoremove;
|
||||
int remaining_to_end = sb->nDataBits - endbit;
|
||||
sizebuf_t temp;
|
||||
|
||||
MSG_StartWriting( &temp, sb->pData, MSG_GetMaxBytes( sb ), startbit, -1 );
|
||||
MSG_SeekToBit( sb, endbit, SEEK_SET );
|
||||
|
||||
for( i = 0; i < remaining_to_end; i++ )
|
||||
for( int i = 0; i < remaining_to_end; i++ )
|
||||
{
|
||||
MSG_WriteOneBit( &temp, MSG_ReadOneBit( sb ));
|
||||
}
|
||||
|
||||
@@ -164,10 +164,9 @@ Netchan_Init
|
||||
void Netchan_Init( void )
|
||||
{
|
||||
char buf[32];
|
||||
int port;
|
||||
|
||||
// pick a port value that should be nice and random
|
||||
port = COM_RandomLong( 1, 65535 );
|
||||
int port = COM_RandomLong( 1, 65535 );
|
||||
Q_snprintf( buf, sizeof( buf ), "%i", port );
|
||||
|
||||
Cvar_RegisterVariable( &net_showpackets );
|
||||
@@ -261,9 +260,7 @@ Netchan_IncomingReady
|
||||
*/
|
||||
qboolean Netchan_IncomingReady( netchan_t *chan )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < MAX_STREAMS; i++ )
|
||||
for( int i = 0; i < MAX_STREAMS; i++ )
|
||||
{
|
||||
if( chan->incomingready[i] )
|
||||
return true;
|
||||
@@ -299,8 +296,6 @@ Netchan_UnlinkFragment
|
||||
*/
|
||||
static void Netchan_UnlinkFragment( fragbuf_t *buf, fragbuf_t **list )
|
||||
{
|
||||
fragbuf_t *search;
|
||||
|
||||
if( !list ) return;
|
||||
|
||||
// at head of list
|
||||
@@ -314,7 +309,7 @@ static void Netchan_UnlinkFragment( fragbuf_t *buf, fragbuf_t **list )
|
||||
return;
|
||||
}
|
||||
|
||||
search = *list;
|
||||
fragbuf_t *search = *list;
|
||||
while( search->next )
|
||||
{
|
||||
if( search->next == buf )
|
||||
@@ -337,16 +332,14 @@ Netchan_ClearFragbufs
|
||||
*/
|
||||
static void Netchan_ClearFragbufs( fragbuf_t **ppbuf )
|
||||
{
|
||||
fragbuf_t *buf, *n;
|
||||
|
||||
if( !ppbuf ) return;
|
||||
|
||||
// Throw away any that are sitting around
|
||||
buf = *ppbuf;
|
||||
fragbuf_t *buf = *ppbuf;
|
||||
|
||||
while( buf )
|
||||
{
|
||||
n = buf->next;
|
||||
fragbuf_t *n = buf->next;
|
||||
Mem_Free( buf );
|
||||
buf = n;
|
||||
}
|
||||
@@ -362,16 +355,13 @@ Netchan_ClearFragments
|
||||
*/
|
||||
static void Netchan_ClearFragments( netchan_t *chan )
|
||||
{
|
||||
fragbufwaiting_t *wait, *next;
|
||||
int i;
|
||||
|
||||
for( i = 0; i < MAX_STREAMS; i++ )
|
||||
for( int i = 0; i < MAX_STREAMS; i++ )
|
||||
{
|
||||
wait = chan->waitlist[i];
|
||||
fragbufwaiting_t *wait = chan->waitlist[i];
|
||||
|
||||
while( wait )
|
||||
{
|
||||
next = wait->next;
|
||||
fragbufwaiting_t *next = wait->next;
|
||||
Netchan_ClearFragbufs( &wait->fragbufs );
|
||||
Mem_Free( wait );
|
||||
wait = next;
|
||||
@@ -391,14 +381,12 @@ Netchan_Clear
|
||||
*/
|
||||
void Netchan_Clear( netchan_t *chan )
|
||||
{
|
||||
int i;
|
||||
|
||||
Netchan_ClearFragments( chan );
|
||||
|
||||
chan->cleartime = 0.0;
|
||||
chan->reliable_length = 0;
|
||||
|
||||
for( i = 0; i < MAX_STREAMS; i++ )
|
||||
for( int i = 0; i < MAX_STREAMS; i++ )
|
||||
{
|
||||
chan->reliable_fragid[i] = 0;
|
||||
chan->reliable_fragment[i] = 0;
|
||||
@@ -453,13 +441,12 @@ void Netchan_OutOfBandPrint( int net_socket, netadr_t adr, const char *fmt, ...
|
||||
{
|
||||
va_list va;
|
||||
byte buf[MAX_PRINT_MSG + 4] = { 0xff, 0xff, 0xff, 0xff };
|
||||
int len;
|
||||
|
||||
if( CL_IsPlaybackDemo( ))
|
||||
return;
|
||||
|
||||
va_start( va, fmt );
|
||||
len = Q_vsnprintf( &buf[4], sizeof( buf ) - 4, fmt, va );
|
||||
int len = Q_vsnprintf( &buf[4], sizeof( buf ) - 4, fmt, va );
|
||||
va_end( va );
|
||||
|
||||
if( len < 0 )
|
||||
@@ -479,9 +466,7 @@ Netchan_AllocFragbuf
|
||||
*/
|
||||
static fragbuf_t *Netchan_AllocFragbuf( int fragment_size )
|
||||
{
|
||||
fragbuf_t *buf;
|
||||
|
||||
buf = (fragbuf_t *)Mem_Calloc( net_mempool, sizeof( fragbuf_t ) + fragment_size );
|
||||
fragbuf_t *buf = (fragbuf_t *)Mem_Calloc( net_mempool, sizeof( fragbuf_t ) + fragment_size );
|
||||
MSG_Init( &buf->frag_message, "Frag Message", buf->frag_message_buf, fragment_size );
|
||||
|
||||
return buf;
|
||||
@@ -495,11 +480,9 @@ Netchan_AddFragbufToTail
|
||||
*/
|
||||
static void Netchan_AddFragbufToTail( fragbufwaiting_t *wait, fragbuf_t *buf )
|
||||
{
|
||||
fragbuf_t *p;
|
||||
|
||||
buf->next = NULL;
|
||||
wait->fragbufcount++;
|
||||
p = wait->fragbufs;
|
||||
fragbuf_t *p = wait->fragbufs;
|
||||
|
||||
if( p )
|
||||
{
|
||||
@@ -519,12 +502,11 @@ Netchan_UpdateFlow
|
||||
static void Netchan_UpdateFlow( netchan_t *chan )
|
||||
{
|
||||
float faccumulatedtime = 0.0;
|
||||
int i, bytes = 0;
|
||||
int flow, start;
|
||||
int bytes = 0;
|
||||
|
||||
if( !chan ) return;
|
||||
|
||||
for( flow = 0; flow < 2; flow++ )
|
||||
for( int flow = 0; flow < 2; flow++ )
|
||||
{
|
||||
flow_t *pflow = &chan->flow[flow];
|
||||
|
||||
@@ -532,10 +514,10 @@ static void Netchan_UpdateFlow( netchan_t *chan )
|
||||
continue;
|
||||
|
||||
pflow->nextcompute = host.realtime + FLOW_INTERVAL;
|
||||
start = pflow->current - 1;
|
||||
int start = pflow->current - 1;
|
||||
|
||||
// compute data flow rate
|
||||
for( i = 0; i < MASK_LATENT; i++ )
|
||||
for( int i = 0; i < MASK_LATENT; i++ )
|
||||
{
|
||||
flowstats_t *pprev = &pflow->stats[(start - i) & MASK_LATENT];
|
||||
flowstats_t *pstat = &pflow->stats[(start - i - 1) & MASK_LATENT];
|
||||
@@ -558,17 +540,14 @@ Fragmentation buffer is full and user is prepared to send
|
||||
*/
|
||||
void Netchan_FragSend( netchan_t *chan )
|
||||
{
|
||||
fragbufwaiting_t *wait;
|
||||
int i;
|
||||
|
||||
if( !chan ) return;
|
||||
|
||||
for( i = 0; i < MAX_STREAMS; i++ )
|
||||
for( int i = 0; i < MAX_STREAMS; i++ )
|
||||
{
|
||||
// already something queued up, just leave in waitlist
|
||||
if( chan->fragbufs[i] ) continue;
|
||||
|
||||
wait = chan->waitlist[i];
|
||||
fragbufwaiting_t *wait = chan->waitlist[i];
|
||||
|
||||
// nothing to queue?
|
||||
if( !wait ) continue;
|
||||
@@ -594,10 +573,6 @@ Netchan_AddBufferToList
|
||||
*/
|
||||
void Netchan_AddBufferToList( fragbuf_t **pplist, fragbuf_t *pbuf )
|
||||
{
|
||||
// Find best slot
|
||||
fragbuf_t *pprev, *n;
|
||||
int id1, id2;
|
||||
|
||||
pbuf->next = NULL;
|
||||
|
||||
if( !pplist )
|
||||
@@ -610,12 +585,13 @@ void Netchan_AddBufferToList( fragbuf_t **pplist, fragbuf_t *pbuf )
|
||||
return;
|
||||
}
|
||||
|
||||
pprev = *pplist;
|
||||
// Find best slot
|
||||
fragbuf_t *pprev = *pplist;
|
||||
while( pprev->next )
|
||||
{
|
||||
n = pprev->next; // next item in list
|
||||
id1 = FRAG_GETID( n->bufferid );
|
||||
id2 = FRAG_GETID( pbuf->bufferid );
|
||||
fragbuf_t *n = pprev->next; // next item in list
|
||||
int id1 = FRAG_GETID( n->bufferid );
|
||||
int id2 = FRAG_GETID( pbuf->bufferid );
|
||||
|
||||
if( id1 > id2 )
|
||||
{
|
||||
@@ -642,19 +618,14 @@ Netchan_CreateFragments_
|
||||
*/
|
||||
static void Netchan_CreateFragments_( netchan_t *chan, sizebuf_t *msg )
|
||||
{
|
||||
fragbuf_t *buf;
|
||||
int chunksize;
|
||||
int remaining;
|
||||
int bytes, pos;
|
||||
int bufferid = 1;
|
||||
fragbufwaiting_t *wait, *p;
|
||||
|
||||
if( MSG_GetNumBytesWritten( msg ) == 0 )
|
||||
return;
|
||||
|
||||
chunksize = chan->pfnBlockSize( chan->client, FRAGSIZE_FRAG );
|
||||
int chunksize = chan->pfnBlockSize( chan->client, FRAGSIZE_FRAG );
|
||||
|
||||
wait = (fragbufwaiting_t *)Mem_Calloc( net_mempool, sizeof( fragbufwaiting_t ));
|
||||
fragbufwaiting_t *wait = (fragbufwaiting_t *)Mem_Calloc( net_mempool, sizeof( fragbufwaiting_t ));
|
||||
|
||||
if( chan->use_bz2 && memcmp( MSG_GetData( msg ), "BZ2", 4 ))
|
||||
{
|
||||
@@ -691,15 +662,15 @@ static void Netchan_CreateFragments_( netchan_t *chan, sizebuf_t *msg )
|
||||
if( pbOut ) free( pbOut );
|
||||
}
|
||||
|
||||
remaining = MSG_GetNumBytesWritten( msg );
|
||||
pos = 0; // current position in bytes
|
||||
int remaining = MSG_GetNumBytesWritten( msg );
|
||||
int pos = 0; // current position in bytes
|
||||
|
||||
while( remaining > 0 )
|
||||
{
|
||||
bytes = Q_min( remaining, chunksize );
|
||||
int bytes = Q_min( remaining, chunksize );
|
||||
remaining -= bytes;
|
||||
|
||||
buf = Netchan_AllocFragbuf( bytes );
|
||||
fragbuf_t *buf = Netchan_AllocFragbuf( bytes );
|
||||
buf->bufferid = bufferid++;
|
||||
|
||||
// Copy in data
|
||||
@@ -717,7 +688,7 @@ static void Netchan_CreateFragments_( netchan_t *chan, sizebuf_t *msg )
|
||||
}
|
||||
else
|
||||
{
|
||||
p = chan->waitlist[FRAG_NORMAL_STREAM];
|
||||
fragbufwaiting_t *p = chan->waitlist[FRAG_NORMAL_STREAM];
|
||||
|
||||
while( p->next )
|
||||
p = p->next;
|
||||
@@ -752,7 +723,6 @@ Netchan_FindBufferById
|
||||
static fragbuf_t *Netchan_FindBufferById( fragbuf_t **pplist, int id, qboolean allocate )
|
||||
{
|
||||
fragbuf_t *list = *pplist;
|
||||
fragbuf_t *pnewbuf;
|
||||
int count = 0;
|
||||
|
||||
while( list )
|
||||
@@ -774,7 +744,7 @@ static fragbuf_t *Netchan_FindBufferById( fragbuf_t **pplist, int id, qboolean a
|
||||
}
|
||||
|
||||
// create new entry
|
||||
pnewbuf = Netchan_AllocFragbuf( NET_MAX_FRAGMENT );
|
||||
fragbuf_t *pnewbuf = Netchan_AllocFragbuf( NET_MAX_FRAGMENT );
|
||||
pnewbuf->bufferid = id;
|
||||
Netchan_AddBufferToList( pplist, pnewbuf );
|
||||
|
||||
@@ -789,14 +759,10 @@ Netchan_CheckForCompletion
|
||||
*/
|
||||
static void Netchan_CheckForCompletion( netchan_t *chan, int stream, int intotalbuffers )
|
||||
{
|
||||
int c, id;
|
||||
int size;
|
||||
fragbuf_t *p;
|
||||
int size = 0;
|
||||
int c = 0;
|
||||
|
||||
size = 0;
|
||||
c = 0;
|
||||
|
||||
p = chan->incomingbufs[stream];
|
||||
fragbuf_t *p = chan->incomingbufs[stream];
|
||||
if( !p ) return;
|
||||
|
||||
while( p )
|
||||
@@ -804,7 +770,7 @@ static void Netchan_CheckForCompletion( netchan_t *chan, int stream, int intotal
|
||||
size += MSG_GetNumBytesWritten( &p->frag_message );
|
||||
c++;
|
||||
|
||||
id = FRAG_GETID( p->bufferid );
|
||||
int id = FRAG_GETID( p->bufferid );
|
||||
if( id != c )
|
||||
{
|
||||
if( chan->sock == NS_CLIENT )
|
||||
@@ -829,20 +795,15 @@ Netchan_CreateFileFragmentsFromBuffer
|
||||
*/
|
||||
void Netchan_CreateFileFragmentsFromBuffer( netchan_t *chan, const char *filename, byte *pbuf, int size )
|
||||
{
|
||||
int chunksize;
|
||||
int send, pos;
|
||||
int remaining;
|
||||
int bufferid = 1;
|
||||
qboolean firstfragment = true;
|
||||
fragbufwaiting_t *wait, *p;
|
||||
fragbuf_t *buf;
|
||||
uint originalSize = size;
|
||||
const char *compressor = "";
|
||||
|
||||
if( !size )
|
||||
return;
|
||||
|
||||
chunksize = chan->pfnBlockSize( chan->client, FRAGSIZE_FRAG );
|
||||
int chunksize = chan->pfnBlockSize( chan->client, FRAGSIZE_FRAG );
|
||||
|
||||
if( chan->gs_netchan )
|
||||
{
|
||||
@@ -876,15 +837,15 @@ void Netchan_CreateFileFragmentsFromBuffer( netchan_t *chan, const char *filenam
|
||||
free( pbOut );
|
||||
}
|
||||
|
||||
wait = (fragbufwaiting_t *)Mem_Calloc( net_mempool, sizeof( fragbufwaiting_t ));
|
||||
remaining = size;
|
||||
pos = 0;
|
||||
fragbufwaiting_t *wait = (fragbufwaiting_t *)Mem_Calloc( net_mempool, sizeof( fragbufwaiting_t ));
|
||||
int remaining = size;
|
||||
int pos = 0;
|
||||
|
||||
while( remaining > 0 )
|
||||
{
|
||||
send = Q_min( remaining, chunksize );
|
||||
int send = Q_min( remaining, chunksize );
|
||||
|
||||
buf = Netchan_AllocFragbuf( send );
|
||||
fragbuf_t *buf = Netchan_AllocFragbuf( send );
|
||||
buf->bufferid = bufferid++;
|
||||
|
||||
// copy in data
|
||||
@@ -894,7 +855,7 @@ void Netchan_CreateFileFragmentsFromBuffer( netchan_t *chan, const char *filenam
|
||||
{
|
||||
// write filename
|
||||
MSG_WriteString( &buf->frag_message, filename );
|
||||
|
||||
|
||||
// write compressor name and uncompressed size
|
||||
if( chan->gs_netchan )
|
||||
{
|
||||
@@ -928,7 +889,7 @@ void Netchan_CreateFileFragmentsFromBuffer( netchan_t *chan, const char *filenam
|
||||
}
|
||||
else
|
||||
{
|
||||
p = chan->waitlist[FRAG_FILE_STREAM];
|
||||
fragbufwaiting_t *p = chan->waitlist[FRAG_FILE_STREAM];
|
||||
|
||||
while( p->next )
|
||||
p = p->next;
|
||||
@@ -944,17 +905,9 @@ Netchan_CreateFileFragments
|
||||
*/
|
||||
int Netchan_CreateFileFragments( netchan_t *chan, const char *filename )
|
||||
{
|
||||
int chunksize;
|
||||
int send, pos;
|
||||
int remaining;
|
||||
int bufferid = 1;
|
||||
fs_offset_t filesize = 0;
|
||||
fs_offset_t originalSize = 0;
|
||||
int compressedFileTime;
|
||||
int fileTime;
|
||||
qboolean firstfragment = true;
|
||||
qboolean bCompressed = false;
|
||||
fragbufwaiting_t *wait, *p;
|
||||
fragbuf_t *buf;
|
||||
char compressedfilename[sizeof( buf->filename ) + 5];
|
||||
const char *compressor = "";
|
||||
@@ -969,18 +922,20 @@ int Netchan_CreateFileFragments( netchan_t *chan, const char *filename )
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(( filesize = FS_FileSize( filename, false )) <= 0 )
|
||||
fs_offset_t filesize = FS_FileSize( filename, false );
|
||||
|
||||
if( filesize <= 0 )
|
||||
{
|
||||
Con_Printf( S_WARN "Unable to open %s for transfer\n", filename );
|
||||
return 0;
|
||||
}
|
||||
|
||||
originalSize = filesize;
|
||||
chunksize = chan->pfnBlockSize( chan->client, FRAGSIZE_FRAG );
|
||||
fs_offset_t originalSize = filesize;
|
||||
int chunksize = chan->pfnBlockSize( chan->client, FRAGSIZE_FRAG );
|
||||
|
||||
Q_snprintf( compressedfilename, sizeof( compressedfilename ), "%s.ztmp", filename );
|
||||
compressedFileTime = FS_FileTime( compressedfilename, false );
|
||||
fileTime = FS_FileTime( filename, false );
|
||||
int compressedFileTime = FS_FileTime( compressedfilename, false );
|
||||
int fileTime = FS_FileTime( filename, false );
|
||||
|
||||
if( compressedFileTime >= fileTime )
|
||||
{
|
||||
@@ -1029,13 +984,13 @@ int Netchan_CreateFileFragments( netchan_t *chan, const char *filename )
|
||||
Mem_Free( uncompressed );
|
||||
}
|
||||
|
||||
wait = (fragbufwaiting_t *)Mem_Calloc( net_mempool, sizeof( fragbufwaiting_t ));
|
||||
remaining = filesize;
|
||||
pos = 0;
|
||||
fragbufwaiting_t *wait = (fragbufwaiting_t *)Mem_Calloc( net_mempool, sizeof( fragbufwaiting_t ));
|
||||
int remaining = filesize;
|
||||
int pos = 0;
|
||||
|
||||
while( remaining > 0 )
|
||||
{
|
||||
send = Q_min( remaining, chunksize );
|
||||
int send = Q_min( remaining, chunksize );
|
||||
|
||||
buf = Netchan_AllocFragbuf( send );
|
||||
buf->bufferid = bufferid++;
|
||||
@@ -1080,7 +1035,7 @@ int Netchan_CreateFileFragments( netchan_t *chan, const char *filename )
|
||||
}
|
||||
else
|
||||
{
|
||||
p = chan->waitlist[FRAG_FILE_STREAM];
|
||||
fragbufwaiting_t *p = chan->waitlist[FRAG_FILE_STREAM];
|
||||
while( p->next )
|
||||
p = p->next;
|
||||
p->next = wait;
|
||||
@@ -1097,15 +1052,13 @@ Netchan_FlushIncoming
|
||||
*/
|
||||
void Netchan_FlushIncoming( netchan_t *chan, int stream )
|
||||
{
|
||||
fragbuf_t *p, *n;
|
||||
|
||||
MSG_Clear( &net_message );
|
||||
|
||||
p = chan->incomingbufs[ stream ];
|
||||
fragbuf_t *p = chan->incomingbufs[ stream ];
|
||||
|
||||
while( p )
|
||||
{
|
||||
n = p->next;
|
||||
fragbuf_t *n = p->next;
|
||||
Mem_Free( p );
|
||||
p = n;
|
||||
}
|
||||
@@ -1122,7 +1075,6 @@ Netchan_CopyNormalFragments
|
||||
qboolean Netchan_CopyNormalFragments( netchan_t *chan, sizebuf_t *msg, size_t *length )
|
||||
{
|
||||
size_t size = 0;
|
||||
fragbuf_t *p, *n;
|
||||
|
||||
if( !chan->incomingready[FRAG_NORMAL_STREAM] )
|
||||
return false;
|
||||
@@ -1133,13 +1085,13 @@ qboolean Netchan_CopyNormalFragments( netchan_t *chan, sizebuf_t *msg, size_t *l
|
||||
return false;
|
||||
}
|
||||
|
||||
p = chan->incomingbufs[FRAG_NORMAL_STREAM];
|
||||
fragbuf_t *p = chan->incomingbufs[FRAG_NORMAL_STREAM];
|
||||
|
||||
MSG_Init( msg, "NetMessage", net_message_buffer, sizeof( net_message_buffer ));
|
||||
|
||||
while( p )
|
||||
{
|
||||
n = p->next;
|
||||
fragbuf_t *n = p->next;
|
||||
|
||||
// copy it in
|
||||
MSG_WriteBytes( msg, MSG_GetData( &p->frag_message ), MSG_GetNumBytesWritten( &p->frag_message ));
|
||||
@@ -1209,9 +1161,6 @@ qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg )
|
||||
{
|
||||
char filename[MAX_OSPATH], compressor[32];
|
||||
uint uncompressedSize;
|
||||
int nsize, pos;
|
||||
byte *buffer;
|
||||
fragbuf_t *p, *n;
|
||||
|
||||
if( !chan->incomingready[FRAG_FILE_STREAM] )
|
||||
return false;
|
||||
@@ -1222,7 +1171,7 @@ qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg )
|
||||
return false;
|
||||
}
|
||||
|
||||
p = chan->incomingbufs[FRAG_FILE_STREAM];
|
||||
fragbuf_t *p = chan->incomingbufs[FRAG_FILE_STREAM];
|
||||
|
||||
MSG_Init( msg, "NetMessage", net_message_buffer, sizeof( net_message_buffer ));
|
||||
|
||||
@@ -1272,7 +1221,7 @@ qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg )
|
||||
}
|
||||
|
||||
// create file from buffers
|
||||
nsize = 0;
|
||||
int nsize = 0;
|
||||
while ( p )
|
||||
{
|
||||
nsize += MSG_GetNumBytesWritten( &p->frag_message ); // Size will include a bit of slop, oh well
|
||||
@@ -1281,17 +1230,15 @@ qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg )
|
||||
p = p->next;
|
||||
}
|
||||
|
||||
buffer = Mem_Calloc( net_mempool, nsize + 1 );
|
||||
byte *buffer = Mem_Calloc( net_mempool, nsize + 1 );
|
||||
p = chan->incomingbufs[FRAG_FILE_STREAM];
|
||||
pos = 0;
|
||||
int pos = 0;
|
||||
|
||||
while( p )
|
||||
{
|
||||
int cursize;
|
||||
fragbuf_t *n = p->next;
|
||||
|
||||
n = p->next;
|
||||
|
||||
cursize = MSG_GetNumBytesWritten( &p->frag_message );
|
||||
int cursize = MSG_GetNumBytesWritten( &p->frag_message );
|
||||
|
||||
// first message has the file name, don't write that into the data stream,
|
||||
// just write the rest of the actual data
|
||||
@@ -1314,8 +1261,6 @@ qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg )
|
||||
if( chan->gs_netchan && chan->use_bz2 && !Q_stricmp( compressor, "bz2" ))
|
||||
{
|
||||
#if !XASH_DEDICATED
|
||||
byte *uncompressedBuffer;
|
||||
|
||||
if( uncompressedSize == 0 || uncompressedSize > MAX_NETCHAN_DECOMPRESSED_SIZE )
|
||||
{
|
||||
Con_Printf( S_ERROR "BZ2 fragment uncompressed size out of range: %u for %s\n", uncompressedSize, filename );
|
||||
@@ -1324,7 +1269,7 @@ qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg )
|
||||
return false;
|
||||
}
|
||||
|
||||
uncompressedBuffer = Mem_Calloc( net_mempool, uncompressedSize );
|
||||
byte *uncompressedBuffer = Mem_Calloc( net_mempool, uncompressedSize );
|
||||
|
||||
Con_DPrintf( "Decompressing file %s (%d -> %d bytes)\n", filename, nsize, uncompressedSize );
|
||||
if( BZ2_bzBuffToBuffDecompress( uncompressedBuffer, &uncompressedSize, buffer, nsize, 1, 0 ) != BZ_OK )
|
||||
@@ -1344,8 +1289,6 @@ qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg )
|
||||
}
|
||||
else if( chan->use_lzss && LZSS_IsCompressed( buffer, nsize ))
|
||||
{
|
||||
byte *uncompressedBuffer;
|
||||
|
||||
uncompressedSize = LZSS_GetActualSize( buffer, nsize );
|
||||
|
||||
if( uncompressedSize == 0 || uncompressedSize > MAX_NETCHAN_DECOMPRESSED_SIZE )
|
||||
@@ -1356,7 +1299,7 @@ qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg )
|
||||
return false;
|
||||
}
|
||||
|
||||
uncompressedBuffer = Mem_Calloc( net_mempool, uncompressedSize );
|
||||
byte *uncompressedBuffer = Mem_Calloc( net_mempool, uncompressedSize );
|
||||
|
||||
nsize = LZSS_Decompress( buffer, uncompressedBuffer, nsize, uncompressedSize );
|
||||
Mem_Free( buffer );
|
||||
@@ -1390,18 +1333,15 @@ qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg )
|
||||
|
||||
static qboolean Netchan_Validate( netchan_t *chan, sizebuf_t *sb, qboolean *frag_message, uint *fragid, int *frag_offset, int *frag_length )
|
||||
{
|
||||
int i, buffer, offset;
|
||||
int count, length;
|
||||
|
||||
for( i = 0; i < MAX_STREAMS; i++ )
|
||||
for( int i = 0; i < MAX_STREAMS; i++ )
|
||||
{
|
||||
if( !frag_message[i] )
|
||||
continue;
|
||||
|
||||
buffer = FRAG_GETID( fragid[i] );
|
||||
count = FRAG_GETCOUNT( fragid[i] );
|
||||
offset = BitByte( frag_offset[i] );
|
||||
length = BitByte( frag_length[i] );
|
||||
int buffer = FRAG_GETID( fragid[i] );
|
||||
int count = FRAG_GETCOUNT( fragid[i] );
|
||||
int offset = BitByte( frag_offset[i] );
|
||||
int length = BitByte( frag_length[i] );
|
||||
|
||||
if( buffer < 0 || buffer > NET_MAX_BUFFER_ID )
|
||||
return false;
|
||||
@@ -1428,8 +1368,7 @@ Netchan_UpdateProgress
|
||||
void Netchan_UpdateProgress( netchan_t *chan )
|
||||
{
|
||||
#if !XASH_DEDICATED
|
||||
fragbuf_t *p;
|
||||
int i, c = 0;
|
||||
int c = 0;
|
||||
int total = 0;
|
||||
float bestpercent = 0.0;
|
||||
|
||||
@@ -1443,12 +1382,12 @@ void Netchan_UpdateProgress( netchan_t *chan )
|
||||
if( !chan->incomingbufs[FRAG_FILE_STREAM] )
|
||||
return;
|
||||
|
||||
for( i = MAX_STREAMS - 1; i >= 0; i-- )
|
||||
for( int i = MAX_STREAMS - 1; i >= 0; i-- )
|
||||
{
|
||||
// receiving data
|
||||
if( chan->incomingbufs[i] )
|
||||
{
|
||||
p = chan->incomingbufs[i];
|
||||
fragbuf_t *p = chan->incomingbufs[i];
|
||||
|
||||
total = FRAG_GETCOUNT( p->bufferid );
|
||||
|
||||
@@ -1471,11 +1410,10 @@ void Netchan_UpdateProgress( netchan_t *chan )
|
||||
if( i == FRAG_FILE_STREAM )
|
||||
{
|
||||
char sz[MAX_SYSPATH];
|
||||
char *in, *out;
|
||||
int len = 0;
|
||||
|
||||
in = (char *)MSG_GetData( &p->frag_message );
|
||||
out = sz;
|
||||
char *in = (char *)MSG_GetData( &p->frag_message );
|
||||
char *out = sz;
|
||||
|
||||
while( *in )
|
||||
{
|
||||
@@ -1521,10 +1459,9 @@ void Netchan_TransmitBits( netchan_t *chan, int length, const byte *data )
|
||||
{
|
||||
byte send_buf[NET_MAX_MESSAGE];
|
||||
qboolean send_reliable_fragment;
|
||||
uint w1, w2, statId;
|
||||
qboolean send_reliable;
|
||||
sizebuf_t send;
|
||||
int i, j;
|
||||
int i;
|
||||
float fRate;
|
||||
|
||||
// check for message overflow
|
||||
@@ -1686,7 +1623,7 @@ void Netchan_TransmitBits( netchan_t *chan, int length, const byte *data )
|
||||
chan->reliable_fragment[i] = 1;
|
||||
|
||||
// offset the rest of the starting positions
|
||||
for( j = i + 1; j < MAX_STREAMS; j++ )
|
||||
for( int j = i + 1; j < MAX_STREAMS; j++ )
|
||||
chan->frag_startpos[j] += chan->frag_length[i];
|
||||
}
|
||||
}
|
||||
@@ -1696,8 +1633,8 @@ void Netchan_TransmitBits( netchan_t *chan, int length, const byte *data )
|
||||
MSG_Init( &send, "NetSend", send_buf, sizeof( send_buf ));
|
||||
|
||||
// prepare the packet header
|
||||
w1 = chan->outgoing_sequence | (((uint)send_reliable ) << 31);
|
||||
w2 = chan->incoming_sequence | (chan->incoming_reliable_sequence << 31);
|
||||
uint w1 = chan->outgoing_sequence | (((uint)send_reliable ) << 31);
|
||||
uint w2 = chan->incoming_sequence | (chan->incoming_reliable_sequence << 31);
|
||||
|
||||
send_reliable_fragment = false;
|
||||
|
||||
@@ -1780,7 +1717,7 @@ void Netchan_TransmitBits( netchan_t *chan, int length, const byte *data )
|
||||
}
|
||||
}
|
||||
|
||||
statId = chan->flow[FLOW_OUTGOING].current & MASK_LATENT;
|
||||
uint statId = chan->flow[FLOW_OUTGOING].current & MASK_LATENT;
|
||||
chan->flow[FLOW_OUTGOING].stats[statId].size = MSG_GetNumBytesWritten( &send ) + UDP_HEADER_SIZE;
|
||||
chan->flow[FLOW_OUTGOING].stats[statId].time = host.realtime;
|
||||
chan->flow[FLOW_OUTGOING].totalbytes += chan->flow[FLOW_OUTGOING].stats[statId].size;
|
||||
@@ -1832,19 +1769,15 @@ modifies net_message so that it points to the packet payload
|
||||
*/
|
||||
qboolean Netchan_Process( netchan_t *chan, sizebuf_t *msg )
|
||||
{
|
||||
uint sequence, sequence_ack;
|
||||
uint reliable_ack, reliable_message;
|
||||
uint fragid[MAX_STREAMS] = { 0, 0 };
|
||||
qboolean frag_message[MAX_STREAMS] = { false, false };
|
||||
int frag_offset[MAX_STREAMS] = { 0, 0 };
|
||||
int frag_length[MAX_STREAMS] = { 0, 0 };
|
||||
qboolean message_contains_fragments;
|
||||
int i, statId;
|
||||
|
||||
// get sequence numbers
|
||||
MSG_Clear( msg );
|
||||
sequence = MSG_ReadLong( msg );
|
||||
sequence_ack = MSG_ReadLong( msg );
|
||||
uint sequence = MSG_ReadLong( msg );
|
||||
uint sequence_ack = MSG_ReadLong( msg );
|
||||
|
||||
if( chan->use_munge )
|
||||
COM_UnMunge2( msg->pData + 8, ( msg->nDataBits >> 3 ) - 8, sequence & 0xFF );
|
||||
@@ -1853,14 +1786,14 @@ qboolean Netchan_Process( netchan_t *chan, sizebuf_t *msg )
|
||||
if( chan->sock == NS_SERVER )
|
||||
MSG_ReadShort( msg );
|
||||
|
||||
reliable_message = sequence >> 31;
|
||||
reliable_ack = sequence_ack >> 31;
|
||||
uint reliable_message = sequence >> 31;
|
||||
uint reliable_ack = sequence_ack >> 31;
|
||||
|
||||
message_contains_fragments = FBitSet( sequence, BIT( 30 )) ? true : false;
|
||||
qboolean message_contains_fragments = FBitSet( sequence, BIT( 30 )) ? true : false;
|
||||
|
||||
if( message_contains_fragments )
|
||||
{
|
||||
for( i = 0; i < MAX_STREAMS; i++ )
|
||||
for( int i = 0; i < MAX_STREAMS; i++ )
|
||||
{
|
||||
if( MSG_ReadByte( msg ))
|
||||
{
|
||||
@@ -1941,7 +1874,7 @@ qboolean Netchan_Process( netchan_t *chan, sizebuf_t *msg )
|
||||
chan->last_received = host.realtime;
|
||||
|
||||
// Update data flow stats
|
||||
statId = chan->flow[FLOW_INCOMING].current & MASK_LATENT;
|
||||
uint statId = chan->flow[FLOW_INCOMING].current & MASK_LATENT;
|
||||
chan->flow[FLOW_INCOMING].stats[statId].size = MSG_GetMaxBytes( msg ) + UDP_HEADER_SIZE;
|
||||
chan->flow[FLOW_INCOMING].stats[statId].time = host.realtime;
|
||||
chan->flow[FLOW_INCOMING].totalbytes += chan->flow[FLOW_INCOMING].stats[statId].size;
|
||||
@@ -1953,31 +1886,24 @@ qboolean Netchan_Process( netchan_t *chan, sizebuf_t *msg )
|
||||
|
||||
if( message_contains_fragments )
|
||||
{
|
||||
for( i = 0; i < MAX_STREAMS; i++ )
|
||||
for( int i = 0; i < MAX_STREAMS; i++ )
|
||||
{
|
||||
int j;
|
||||
int intotalbuffers;
|
||||
int oldpos, curbit;
|
||||
int numbitstoremove;
|
||||
fragbuf_t *pbuf;
|
||||
|
||||
if( !frag_message[i] )
|
||||
continue;
|
||||
|
||||
intotalbuffers = FRAG_GETCOUNT( fragid[i] );
|
||||
int intotalbuffers = FRAG_GETCOUNT( fragid[i] );
|
||||
|
||||
if( fragid[i] != 0 )
|
||||
{
|
||||
pbuf = Netchan_FindBufferById( &chan->incomingbufs[i], fragid[i], true );
|
||||
fragbuf_t *pbuf = Netchan_FindBufferById( &chan->incomingbufs[i], fragid[i], true );
|
||||
|
||||
if( pbuf )
|
||||
{
|
||||
byte buffer[NET_MAX_FRAGMENT];
|
||||
int bits, size;
|
||||
sizebuf_t temp;
|
||||
|
||||
size = MSG_GetNumBitsRead( msg ) + frag_offset[i];
|
||||
bits = frag_length[i];
|
||||
int size = MSG_GetNumBitsRead( msg ) + frag_offset[i];
|
||||
int bits = frag_length[i];
|
||||
|
||||
// copy in data
|
||||
MSG_Clear( &pbuf->frag_message );
|
||||
@@ -1992,14 +1918,14 @@ qboolean Netchan_Process( netchan_t *chan, sizebuf_t *msg )
|
||||
}
|
||||
|
||||
// rearrange incoming data to not have the frag stuff in the middle of it
|
||||
oldpos = MSG_GetNumBitsRead( msg );
|
||||
curbit = MSG_GetNumBitsRead( msg ) + frag_offset[i];
|
||||
numbitstoremove = frag_length[i];
|
||||
int oldpos = MSG_GetNumBitsRead( msg );
|
||||
int curbit = MSG_GetNumBitsRead( msg ) + frag_offset[i];
|
||||
int numbitstoremove = frag_length[i];
|
||||
|
||||
MSG_ExciseBits( msg, curbit, numbitstoremove );
|
||||
MSG_SeekToBit( msg, oldpos, SEEK_SET );
|
||||
|
||||
for( j = i + 1; j < MAX_STREAMS; j++ )
|
||||
for( int j = i + 1; j < MAX_STREAMS; j++ )
|
||||
frag_offset[j] -= frag_length[i];
|
||||
}
|
||||
|
||||
|
||||
@@ -436,12 +436,10 @@ static const delta_info_t dt_goldsrc_meta =
|
||||
|
||||
static delta_info_t *Delta_FindStruct( const char *name )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( COM_StringEmptyOrNULL( name ))
|
||||
return NULL;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( dt_info ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( dt_info ); i++ )
|
||||
{
|
||||
if( !Q_stricmp( dt_info[i].pName, name ))
|
||||
return &dt_info[i];
|
||||
@@ -467,12 +465,10 @@ static delta_info_t *Delta_FindStructByIndex( int index )
|
||||
|
||||
static delta_info_t *Delta_FindStructByEncoder( const char *encoderName )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( COM_StringEmptyOrNULL( encoderName ) )
|
||||
return NULL;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( dt_info ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( dt_info ); i++ )
|
||||
{
|
||||
if( !Q_stricmp( dt_info[i].funcName, encoderName ))
|
||||
return &dt_info[i];
|
||||
@@ -483,11 +479,9 @@ static delta_info_t *Delta_FindStructByEncoder( const char *encoderName )
|
||||
|
||||
static delta_info_t *Delta_FindStructByDelta( const delta_t *pFields )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !pFields ) return NULL;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( dt_info ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( dt_info ); i++ )
|
||||
{
|
||||
if( dt_info[i].pFields == pFields )
|
||||
return &dt_info[i];
|
||||
@@ -498,12 +492,10 @@ static delta_info_t *Delta_FindStructByDelta( const delta_t *pFields )
|
||||
|
||||
static void Delta_CustomEncode( delta_info_t *dt, const void *from, const void *to )
|
||||
{
|
||||
int i;
|
||||
|
||||
Assert( dt != NULL );
|
||||
|
||||
// set all fields is active by default
|
||||
for( i = 0; i < dt->numFields; i++ )
|
||||
for( int i = 0; i < dt->numFields; i++ )
|
||||
dt->pFields[i].bInactive = false;
|
||||
|
||||
if( dt->userCallback )
|
||||
@@ -512,12 +504,10 @@ static void Delta_CustomEncode( delta_info_t *dt, const void *from, const void *
|
||||
|
||||
static const delta_field_t *Delta_FindFieldInfo( const delta_field_t *pInfo, const char *fieldName, int maxFields )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !fieldName || !*fieldName )
|
||||
return NULL;
|
||||
|
||||
for( i = 0; i < maxFields; i++ )
|
||||
for( int i = 0; i < maxFields; i++ )
|
||||
{
|
||||
if( !Q_strcmp( pInfo[i].name, fieldName ))
|
||||
return &pInfo[i];
|
||||
@@ -528,12 +518,10 @@ static const delta_field_t *Delta_FindFieldInfo( const delta_field_t *pInfo, con
|
||||
|
||||
static int Delta_IndexForFieldInfo( const delta_field_t *pInfo, const char *fieldName, int maxFields )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !fieldName || !*fieldName )
|
||||
return -1;
|
||||
|
||||
for( i = 0; i < maxFields; i++ )
|
||||
for( int i = 0; i < maxFields; i++ )
|
||||
{
|
||||
if( !Q_strcmp( pInfo[i].name, fieldName ))
|
||||
return i;
|
||||
@@ -543,9 +531,8 @@ static int Delta_IndexForFieldInfo( const delta_field_t *pInfo, const char *fiel
|
||||
|
||||
static qboolean Delta_AddField( delta_info_t *dt, const char *pName, int flags, int bits, float mul, float post_mul )
|
||||
{
|
||||
const delta_field_t *pFieldInfo;
|
||||
delta_t *pField;
|
||||
int i;
|
||||
delta_t *pField;
|
||||
int i;
|
||||
|
||||
// check for coexisting field
|
||||
for( i = 0, pField = dt->pFields; i < dt->numFields && pField; i++, pField++ )
|
||||
@@ -562,7 +549,7 @@ static qboolean Delta_AddField( delta_info_t *dt, const char *pName, int flags,
|
||||
}
|
||||
|
||||
// find field description
|
||||
pFieldInfo = Delta_FindFieldInfo( dt->pInfo, pName, dt->maxFields );
|
||||
const delta_field_t *pFieldInfo = Delta_FindFieldInfo( dt->pInfo, pName, dt->maxFields );
|
||||
if( !pFieldInfo )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: couldn't find description for %s->%s\n", __func__, dt->pName, pName );
|
||||
@@ -594,18 +581,15 @@ static qboolean Delta_AddField( delta_info_t *dt, const char *pName, int flags,
|
||||
|
||||
static void Delta_WriteTableField( sizebuf_t *msg, int tableIndex, const delta_t *pField )
|
||||
{
|
||||
int nameIndex;
|
||||
delta_info_t *dt;
|
||||
|
||||
Assert( pField != NULL );
|
||||
|
||||
if( COM_StringEmptyOrNULL( pField->name ))
|
||||
return;// not initialized ?
|
||||
|
||||
dt = Delta_FindStructByIndex( tableIndex );
|
||||
delta_info_t *dt = Delta_FindStructByIndex( tableIndex );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
nameIndex = Delta_IndexForFieldInfo( dt->pInfo, pField->name, dt->maxFields );
|
||||
int nameIndex = Delta_IndexForFieldInfo( dt->pInfo, pField->name, dt->maxFields );
|
||||
Assert( nameIndex >= 0 && nameIndex < dt->maxFields );
|
||||
|
||||
MSG_BeginServerCmd( msg, svc_deltatable );
|
||||
@@ -632,19 +616,16 @@ static void Delta_WriteTableField( sizebuf_t *msg, int tableIndex, const delta_t
|
||||
|
||||
void Delta_ParseTableField( sizebuf_t *msg )
|
||||
{
|
||||
int tableIndex, nameIndex;
|
||||
float mul = 1.0f, post_mul = 1.0f;
|
||||
int flags, bits;
|
||||
const char *pName;
|
||||
float mul = 1.0f, post_mul = 1.0f;
|
||||
const char *pName;
|
||||
qboolean ignore = false;
|
||||
delta_info_t *dt;
|
||||
|
||||
tableIndex = MSG_ReadUBitLong( msg, 4 );
|
||||
dt = Delta_FindStructByIndex( tableIndex );
|
||||
int tableIndex = MSG_ReadUBitLong( msg, 4 );
|
||||
delta_info_t *dt = Delta_FindStructByIndex( tableIndex );
|
||||
if( !dt )
|
||||
Host_Error( "%s: not initialized", __func__ );
|
||||
|
||||
nameIndex = MSG_ReadUBitLong( msg, 8 ); // read field name index
|
||||
int nameIndex = MSG_ReadUBitLong( msg, 8 ); // read field name index
|
||||
if( ( nameIndex >= 0 && nameIndex < dt->maxFields ) )
|
||||
{
|
||||
pName = dt->pInfo[nameIndex].name;
|
||||
@@ -655,8 +636,8 @@ void Delta_ParseTableField( sizebuf_t *msg )
|
||||
Con_Reportf( "%s: wrong nameIndex %d for table %s, ignoring\n", __func__, nameIndex, dt->pName );
|
||||
}
|
||||
|
||||
flags = MSG_ReadUBitLong( msg, 10 );
|
||||
bits = MSG_ReadUBitLong( msg, 5 ) + 1;
|
||||
int flags = MSG_ReadUBitLong( msg, 10 );
|
||||
int bits = MSG_ReadUBitLong( msg, 5 ) + 1;
|
||||
|
||||
// read the multipliers
|
||||
if( MSG_ReadOneBit( msg ))
|
||||
@@ -678,9 +659,7 @@ void Delta_ParseTableField( sizebuf_t *msg )
|
||||
|
||||
static qboolean Delta_ParseField( char **delta_script, const delta_info_t *dt, delta_t *pField, qboolean bPost )
|
||||
{
|
||||
const delta_field_t *pFieldInfo;
|
||||
string token;
|
||||
char *oldpos;
|
||||
string token;
|
||||
|
||||
*delta_script = COM_ParseFile( *delta_script, token, sizeof( token ));
|
||||
if( Q_strcmp( token, "(" ))
|
||||
@@ -696,7 +675,7 @@ static qboolean Delta_ParseField( char **delta_script, const delta_info_t *dt, d
|
||||
return false;
|
||||
}
|
||||
|
||||
pFieldInfo = Delta_FindFieldInfo( dt->pInfo, token, dt->maxFields );
|
||||
const delta_field_t *pFieldInfo = Delta_FindFieldInfo( dt->pInfo, token, dt->maxFields );
|
||||
if( !pFieldInfo )
|
||||
{
|
||||
Con_DPrintf( S_ERROR "%s: unable to find field %s\n", __func__, token );
|
||||
@@ -809,7 +788,7 @@ static qboolean Delta_ParseField( char **delta_script, const delta_info_t *dt, d
|
||||
}
|
||||
|
||||
// ... and trying to parse optional ',' post-symbol
|
||||
oldpos = *delta_script;
|
||||
char *oldpos = *delta_script;
|
||||
*delta_script = COM_ParseFile( *delta_script, token, sizeof( token ));
|
||||
if( token[0] != ',' ) *delta_script = oldpos; // not a ','
|
||||
|
||||
@@ -818,13 +797,12 @@ static qboolean Delta_ParseField( char **delta_script, const delta_info_t *dt, d
|
||||
|
||||
static void Delta_ParseTable( char **delta_script, delta_info_t *dt, const char *encodeDll, const char *encodeFunc )
|
||||
{
|
||||
string token;
|
||||
delta_t *pField;
|
||||
string token;
|
||||
|
||||
// allocate the delta-structures
|
||||
if( !dt->pFields ) dt->pFields = (delta_t *)Z_Calloc( dt->maxFields * sizeof( delta_t ));
|
||||
|
||||
pField = dt->pFields;
|
||||
delta_t *pField = dt->pFields;
|
||||
dt->numFields = 0;
|
||||
|
||||
// assume we have handled '{'
|
||||
@@ -870,19 +848,16 @@ static void Delta_ParseTable( char **delta_script, delta_info_t *dt, const char
|
||||
|
||||
static void Delta_InitFields( void )
|
||||
{
|
||||
byte *afile;
|
||||
char *pfile;
|
||||
string encodeDll, encodeFunc, token;
|
||||
delta_info_t *dt;
|
||||
string encodeDll, encodeFunc, token;
|
||||
|
||||
afile = FS_LoadFile( DELTA_PATH, NULL, false );
|
||||
byte *afile = FS_LoadFile( DELTA_PATH, NULL, false );
|
||||
if( !afile ) Sys_Error( "%s: couldn't load file %s\n", __func__, DELTA_PATH );
|
||||
|
||||
pfile = (char *)afile;
|
||||
char *pfile = (char *)afile;
|
||||
|
||||
while(( pfile = COM_ParseFile( pfile, token, sizeof( token ))) != NULL )
|
||||
{
|
||||
dt = Delta_FindStruct( token );
|
||||
delta_info_t *dt = Delta_FindStruct( token );
|
||||
|
||||
if( dt == NULL )
|
||||
{
|
||||
@@ -911,15 +886,13 @@ static void Delta_InitFields( void )
|
||||
|
||||
void Delta_Init( void )
|
||||
{
|
||||
delta_info_t *dt;
|
||||
|
||||
// shutdown it first
|
||||
if( delta_init ) Delta_Shutdown ();
|
||||
|
||||
Delta_InitFields (); // initialize fields
|
||||
delta_init = true;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_MOVEVARS_T );
|
||||
delta_info_t *dt = Delta_FindStructByIndex( DT_MOVEVARS_T );
|
||||
|
||||
Assert( dt != NULL );
|
||||
|
||||
@@ -972,12 +945,12 @@ void Delta_Init( void )
|
||||
|
||||
void Delta_InitClient( void )
|
||||
{
|
||||
int i, numActive = 0;
|
||||
int numActive = 0;
|
||||
|
||||
// already initalized
|
||||
if( delta_init ) return;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( dt_info ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( dt_info ); i++ )
|
||||
{
|
||||
if( dt_info[i].numFields > 0 )
|
||||
{
|
||||
@@ -991,11 +964,9 @@ void Delta_InitClient( void )
|
||||
|
||||
void Delta_Shutdown( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !delta_init ) return;
|
||||
|
||||
for( i = 0; i < ARRAYSIZE( dt_info ); i++ )
|
||||
for( int i = 0; i < ARRAYSIZE( dt_info ); i++ )
|
||||
{
|
||||
dt_info[i].numFields = 0;
|
||||
dt_info[i].customEncode = CUSTOM_NONE;
|
||||
@@ -1172,11 +1143,8 @@ compare baselines to find optimal
|
||||
*/
|
||||
int Delta_TestBaseline( const entity_state_t *from, const entity_state_t *to, qboolean player, double timebase )
|
||||
{
|
||||
delta_info_t *dt = NULL;
|
||||
delta_t *pField;
|
||||
int i, countBits;
|
||||
|
||||
countBits = MAX_ENTITY_BITS + 2;
|
||||
delta_info_t *dt = NULL;
|
||||
int countBits = MAX_ENTITY_BITS + 2;
|
||||
|
||||
if( to == NULL )
|
||||
{
|
||||
@@ -1194,14 +1162,14 @@ int Delta_TestBaseline( const entity_state_t *from, const entity_state_t *to, qb
|
||||
|
||||
countBits++; // entityType flag
|
||||
|
||||
pField = dt->pFields;
|
||||
delta_t *pField = dt->pFields;
|
||||
Assert( pField != NULL );
|
||||
|
||||
// activate fields and call custom encode func
|
||||
Delta_CustomEncode( dt, from, to );
|
||||
|
||||
// process fields
|
||||
for( i = 0; i < dt->numFields; i++, pField++ )
|
||||
for( int i = 0; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
// flag about field change (sets always)
|
||||
countBits++;
|
||||
@@ -1489,10 +1457,9 @@ static void Delta_ParseGSFields( sizebuf_t *msg, const delta_info_t *dt, const v
|
||||
{
|
||||
uint8_t bits[8] = { 0 };
|
||||
delta_t *pField;
|
||||
byte c;
|
||||
int i;
|
||||
|
||||
c = MSG_ReadUBitLong( msg, 3 );
|
||||
byte c = MSG_ReadUBitLong( msg, 3 );
|
||||
|
||||
for( i = 0; i < c; i++ )
|
||||
bits[i] = MSG_ReadByte( msg );
|
||||
@@ -1564,21 +1531,17 @@ MSG_WriteDeltaUsercmd
|
||||
*/
|
||||
void MSG_WriteDeltaUsercmd( sizebuf_t *msg, const usercmd_t *from, const usercmd_t *to )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
int i;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_USERCMD_T );
|
||||
delta_info_t *dt = Delta_FindStructByIndex( DT_USERCMD_T );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
delta_t *pField = dt->pFields;
|
||||
Assert( pField != NULL );
|
||||
|
||||
// activate fields and call custom encode func
|
||||
Delta_CustomEncode( dt, from, to );
|
||||
|
||||
// process fields
|
||||
for( i = 0; i < dt->numFields; i++, pField++ )
|
||||
for( int i = 0; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
Delta_WriteField( msg, pField, from, to, 0.0f );
|
||||
}
|
||||
@@ -1591,20 +1554,16 @@ MSG_ReadDeltaUsercmd
|
||||
*/
|
||||
void MSG_ReadDeltaUsercmd( sizebuf_t *msg, const usercmd_t *from, usercmd_t *to )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
int i;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_USERCMD_T );
|
||||
delta_info_t *dt = Delta_FindStructByIndex( DT_USERCMD_T );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
delta_t *pField = dt->pFields;
|
||||
Assert( pField != NULL );
|
||||
|
||||
*to = *from;
|
||||
|
||||
// process fields
|
||||
for( i = 0; i < dt->numFields; i++, pField++ )
|
||||
for( int i = 0; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
Delta_ReadField( msg, pField, from, to, 0.0f );
|
||||
}
|
||||
@@ -1626,21 +1585,17 @@ MSG_WriteDeltaEvent
|
||||
*/
|
||||
void MSG_WriteDeltaEvent( sizebuf_t *msg, const event_args_t *from, const event_args_t *to )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
int i;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_EVENT_T );
|
||||
delta_info_t *dt = Delta_FindStructByIndex( DT_EVENT_T );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
delta_t *pField = dt->pFields;
|
||||
Assert( pField != NULL );
|
||||
|
||||
// activate fields and call custom encode func
|
||||
Delta_CustomEncode( dt, from, to );
|
||||
|
||||
// process fields
|
||||
for( i = 0; i < dt->numFields; i++, pField++ )
|
||||
for( int i = 0; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
Delta_WriteField( msg, pField, from, to, 0.0f );
|
||||
}
|
||||
@@ -1653,20 +1608,16 @@ MSG_ReadDeltaEvent
|
||||
*/
|
||||
void MSG_ReadDeltaEvent( sizebuf_t *msg, const event_args_t *from, event_args_t *to )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
int i;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_EVENT_T );
|
||||
delta_info_t *dt = Delta_FindStructByIndex( DT_EVENT_T );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
delta_t *pField = dt->pFields;
|
||||
Assert( pField != NULL );
|
||||
|
||||
*to = *from;
|
||||
|
||||
// process fields
|
||||
for( i = 0; i < dt->numFields; i++, pField++ )
|
||||
for( int i = 0; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
Delta_ReadField( msg, pField, from, to, 0.0f );
|
||||
}
|
||||
@@ -1681,18 +1632,15 @@ movevars_t communication
|
||||
*/
|
||||
qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, const movevars_t *from, const movevars_t *to )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
int i, startBit;
|
||||
int numChanges = 0;
|
||||
int numChanges = 0;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_MOVEVARS_T );
|
||||
delta_info_t *dt = Delta_FindStructByIndex( DT_MOVEVARS_T );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
delta_t *pField = dt->pFields;
|
||||
Assert( pField != NULL );
|
||||
|
||||
startBit = msg->iCurBit;
|
||||
int startBit = msg->iCurBit;
|
||||
|
||||
// activate fields and call custom encode func
|
||||
Delta_CustomEncode( dt, from, to );
|
||||
@@ -1700,7 +1648,7 @@ qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, const movevars_t *from, const m
|
||||
MSG_BeginServerCmd( msg, svc_deltamovevars );
|
||||
|
||||
// process fields
|
||||
for( i = 0; i < dt->numFields; i++, pField++ )
|
||||
for( int i = 0; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
if( Delta_WriteField( msg, pField, from, to, 0.0f ))
|
||||
numChanges++;
|
||||
@@ -1717,20 +1665,16 @@ qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, const movevars_t *from, const m
|
||||
|
||||
void MSG_ReadDeltaMovevars( sizebuf_t *msg, const movevars_t *from, movevars_t *to )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
int i;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_MOVEVARS_T );
|
||||
delta_info_t *dt = Delta_FindStructByIndex( DT_MOVEVARS_T );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
delta_t *pField = dt->pFields;
|
||||
Assert( pField != NULL );
|
||||
|
||||
*to = *from;
|
||||
|
||||
// process fields
|
||||
for( i = 0; i < dt->numFields; i++, pField++ )
|
||||
for( int i = 0; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
Delta_ReadField( msg, pField, from, to, 0.0f );
|
||||
}
|
||||
@@ -1753,18 +1697,15 @@ Other clients can grab the client state from entity_state_t
|
||||
*/
|
||||
void MSG_WriteClientData( sizebuf_t *msg, const clientdata_t *from, const clientdata_t *to, double timebase )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
int i, startBit;
|
||||
int numChanges = 0;
|
||||
int numChanges = 0;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_CLIENTDATA_T );
|
||||
delta_info_t *dt = Delta_FindStructByIndex( DT_CLIENTDATA_T );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
delta_t *pField = dt->pFields;
|
||||
Assert( pField != NULL );
|
||||
|
||||
startBit = msg->iCurBit;
|
||||
int startBit = msg->iCurBit;
|
||||
|
||||
MSG_WriteOneBit( msg, 1 ); // have clientdata
|
||||
|
||||
@@ -1772,7 +1713,7 @@ void MSG_WriteClientData( sizebuf_t *msg, const clientdata_t *from, const client
|
||||
Delta_CustomEncode( dt, from, to );
|
||||
|
||||
// process fields
|
||||
for( i = 0; i < dt->numFields; i++, pField++ )
|
||||
for( int i = 0; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
if( Delta_WriteField( msg, pField, from, to, timebase ))
|
||||
numChanges++;
|
||||
@@ -1794,21 +1735,16 @@ Read the clientdata
|
||||
void MSG_ReadClientData( sizebuf_t *msg, const clientdata_t *from, clientdata_t *to, double timebase )
|
||||
{
|
||||
#if !XASH_DEDICATED
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
int i;
|
||||
qboolean noChanges;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_CLIENTDATA_T );
|
||||
delta_info_t *dt = Delta_FindStructByIndex( DT_CLIENTDATA_T );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
delta_t *pField = dt->pFields;
|
||||
Assert( pField != NULL );
|
||||
|
||||
noChanges = !MSG_ReadOneBit( msg );
|
||||
qboolean noChanges = !MSG_ReadOneBit( msg );
|
||||
|
||||
// process fields
|
||||
for( i = 0; i < dt->numFields; i++, pField++ )
|
||||
for( int i = 0; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
if( noChanges )
|
||||
Delta_CopyField( pField, from, to, timebase );
|
||||
@@ -1834,27 +1770,24 @@ Other clients can grab the client state from entity_state_t
|
||||
*/
|
||||
void MSG_WriteWeaponData( sizebuf_t *msg, const weapon_data_t *from, const weapon_data_t *to, double timebase, int index )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
int i, startBit;
|
||||
int numChanges = 0;
|
||||
int numChanges = 0;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_WEAPONDATA_T );
|
||||
delta_info_t *dt = Delta_FindStructByIndex( DT_WEAPONDATA_T );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
delta_t *pField = dt->pFields;
|
||||
Assert( pField != NULL );
|
||||
|
||||
// activate fields and call custom encode func
|
||||
Delta_CustomEncode( dt, from, to );
|
||||
|
||||
startBit = msg->iCurBit;
|
||||
int startBit = msg->iCurBit;
|
||||
|
||||
MSG_WriteOneBit( msg, 1 );
|
||||
MSG_WriteUBitLong( msg, index, MAX_WEAPON_BITS );
|
||||
|
||||
// process fields
|
||||
for( i = 0; i < dt->numFields; i++, pField++ )
|
||||
for( int i = 0; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
if( Delta_WriteField( msg, pField, from, to, timebase ))
|
||||
numChanges++;
|
||||
@@ -1873,18 +1806,14 @@ Read the clientdata
|
||||
*/
|
||||
void MSG_ReadWeaponData( sizebuf_t *msg, const weapon_data_t *from, weapon_data_t *to, double timebase )
|
||||
{
|
||||
delta_t *pField;
|
||||
delta_info_t *dt;
|
||||
int i;
|
||||
|
||||
dt = Delta_FindStructByIndex( DT_WEAPONDATA_T );
|
||||
delta_info_t *dt = Delta_FindStructByIndex( DT_WEAPONDATA_T );
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
delta_t *pField = dt->pFields;
|
||||
Assert( pField != NULL );
|
||||
|
||||
// process fields
|
||||
for( i = 0; i < dt->numFields; i++, pField++ )
|
||||
for( int i = 0; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
Delta_ReadField( msg, pField, from, to, timebase );
|
||||
}
|
||||
@@ -1910,14 +1839,12 @@ identical, under the assumption that the in-order delta code will catch it.
|
||||
*/
|
||||
void MSG_WriteDeltaEntity( const entity_state_t *from, const entity_state_t *to, sizebuf_t *msg, qboolean force, int delta_type, double timebase, int baseline )
|
||||
{
|
||||
delta_info_t *dt = NULL;
|
||||
delta_t *pField;
|
||||
int i, startBit;
|
||||
int numChanges = 0;
|
||||
delta_info_t *dt = NULL;
|
||||
int numChanges = 0;
|
||||
|
||||
if( to == NULL )
|
||||
{
|
||||
int fRemoveType;
|
||||
int fRemoveType;
|
||||
|
||||
if( from == NULL ) return;
|
||||
|
||||
@@ -1935,7 +1862,7 @@ void MSG_WriteDeltaEntity( const entity_state_t *from, const entity_state_t *to,
|
||||
return;
|
||||
}
|
||||
|
||||
startBit = msg->iCurBit;
|
||||
int startBit = msg->iCurBit;
|
||||
|
||||
if( to->number < 0 || to->number >= GI->max_edicts )
|
||||
Host_Error( "%s: Bad entity number: %i\n", __func__, to->number );
|
||||
@@ -1973,13 +1900,13 @@ void MSG_WriteDeltaEntity( const entity_state_t *from, const entity_state_t *to,
|
||||
|
||||
Assert( dt && dt->bInitialized );
|
||||
|
||||
pField = dt->pFields;
|
||||
delta_t *pField = dt->pFields;
|
||||
Assert( pField != NULL );
|
||||
|
||||
if( delta_type == DELTA_STATIC )
|
||||
{
|
||||
// static entities won't to be custom encoded
|
||||
for( i = 0; i < dt->numFields; i++ )
|
||||
for( int i = 0; i < dt->numFields; i++ )
|
||||
dt->pFields[i].bInactive = false;
|
||||
}
|
||||
else
|
||||
@@ -1989,7 +1916,7 @@ void MSG_WriteDeltaEntity( const entity_state_t *from, const entity_state_t *to,
|
||||
}
|
||||
|
||||
// process fields
|
||||
for( i = 0; i < dt->numFields; i++, pField++ )
|
||||
for( int i = 0; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
if( Delta_WriteField( msg, pField, from, to, timebase ))
|
||||
numChanges++;
|
||||
@@ -2013,10 +1940,8 @@ Can go from either a baseline or a previous packet_entity
|
||||
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, const entity_state_t *from, entity_state_t *to, int number, int delta_type, double timebase )
|
||||
{
|
||||
#if !XASH_DEDICATED
|
||||
delta_info_t *dt = NULL;
|
||||
delta_t *pField;
|
||||
int i, fRemoveType;
|
||||
int baseline_offset = 0;
|
||||
delta_info_t *dt = NULL;
|
||||
int baseline_offset = 0;
|
||||
|
||||
if( number < 0 || number >= clgame.maxEntities )
|
||||
{
|
||||
@@ -2024,7 +1949,7 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, const entity_state_t *from, entity
|
||||
return false;
|
||||
}
|
||||
|
||||
fRemoveType = MSG_ReadUBitLong( msg, 2 );
|
||||
int fRemoveType = MSG_ReadUBitLong( msg, 2 );
|
||||
|
||||
if( fRemoveType )
|
||||
{
|
||||
@@ -2097,11 +2022,11 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, const entity_state_t *from, entity
|
||||
return true;
|
||||
}
|
||||
|
||||
pField = dt->pFields;
|
||||
delta_t *pField = dt->pFields;
|
||||
Assert( pField != NULL );
|
||||
|
||||
// process fields
|
||||
for( i = 0; i < dt->numFields; i++, pField++ )
|
||||
for( int i = 0; i < dt->numFields; i++, pField++ )
|
||||
{
|
||||
Delta_ReadField( msg, pField, from, to, timebase );
|
||||
}
|
||||
@@ -2115,7 +2040,6 @@ void Delta_ParseTableField_GS( sizebuf_t *msg )
|
||||
const char *s = MSG_ReadString( msg );
|
||||
delta_info_t *dt = Delta_FindStruct( s );
|
||||
goldsrc_delta_t null = { 0 };
|
||||
int i, num_fields;
|
||||
|
||||
// delta encoders it's already initialized on this machine (local game)
|
||||
if( delta_init )
|
||||
@@ -2124,13 +2048,13 @@ void Delta_ParseTableField_GS( sizebuf_t *msg )
|
||||
if( !dt )
|
||||
Host_Error( "%s: not initialized", __func__ );
|
||||
|
||||
num_fields = MSG_ReadShort( msg );
|
||||
int num_fields = MSG_ReadShort( msg );
|
||||
if( num_fields > dt->maxFields )
|
||||
Host_Error( "%s: numFields > maxFields", __func__ );
|
||||
|
||||
MSG_StartBitWriting( msg );
|
||||
|
||||
for( i = 0; i < num_fields; i++ )
|
||||
for( int i = 0; i < num_fields; i++ )
|
||||
{
|
||||
goldsrc_delta_t to;
|
||||
|
||||
@@ -2157,14 +2081,11 @@ send delta communication encoding
|
||||
*/
|
||||
void Delta_WriteDescriptionToClient( sizebuf_t *msg )
|
||||
{
|
||||
int tableIndex;
|
||||
int fieldIndex;
|
||||
|
||||
for( tableIndex = 0; tableIndex < Delta_NumTables(); tableIndex++ )
|
||||
for( int tableIndex = 0; tableIndex < Delta_NumTables(); tableIndex++ )
|
||||
{
|
||||
delta_info_t *dt = Delta_FindStructByIndex( tableIndex );
|
||||
delta_info_t *dt = Delta_FindStructByIndex( tableIndex );
|
||||
|
||||
for( fieldIndex = 0; fieldIndex < dt->numFields; fieldIndex++ )
|
||||
for( int fieldIndex = 0; fieldIndex < dt->numFields; fieldIndex++ )
|
||||
Delta_WriteTableField( msg, tableIndex, &dt->pFields[fieldIndex] );
|
||||
}
|
||||
}
|
||||
@@ -2178,9 +2099,7 @@ void Delta_WriteDescriptionToClient( sizebuf_t *msg )
|
||||
*/
|
||||
void GAME_EXPORT Delta_AddEncoder( char *name, pfnDeltaEncode encodeFunc )
|
||||
{
|
||||
delta_info_t *dt;
|
||||
|
||||
dt = Delta_FindStructByEncoder( name );
|
||||
delta_info_t *dt = Delta_FindStructByEncoder( name );
|
||||
|
||||
if( !dt || !dt->bInitialized )
|
||||
{
|
||||
@@ -2200,11 +2119,10 @@ void GAME_EXPORT Delta_AddEncoder( char *name, pfnDeltaEncode encodeFunc )
|
||||
|
||||
int GAME_EXPORT Delta_FindField( delta_t *pFields, const char *fieldname )
|
||||
{
|
||||
delta_info_t *dt;
|
||||
delta_t *pField;
|
||||
int i;
|
||||
delta_t *pField;
|
||||
int i;
|
||||
|
||||
dt = Delta_FindStructByDelta( pFields );
|
||||
delta_info_t *dt = Delta_FindStructByDelta( pFields );
|
||||
if( dt == NULL || !fieldname || !fieldname[0] )
|
||||
return -1;
|
||||
|
||||
@@ -2218,11 +2136,10 @@ int GAME_EXPORT Delta_FindField( delta_t *pFields, const char *fieldname )
|
||||
|
||||
void GAME_EXPORT Delta_SetField( delta_t *pFields, const char *fieldname )
|
||||
{
|
||||
delta_info_t *dt;
|
||||
delta_t *pField;
|
||||
int i;
|
||||
delta_t *pField;
|
||||
int i;
|
||||
|
||||
dt = Delta_FindStructByDelta( pFields );
|
||||
delta_info_t *dt = Delta_FindStructByDelta( pFields );
|
||||
if( dt == NULL || !fieldname || !fieldname[0] )
|
||||
return;
|
||||
|
||||
@@ -2238,11 +2155,10 @@ void GAME_EXPORT Delta_SetField( delta_t *pFields, const char *fieldname )
|
||||
|
||||
void GAME_EXPORT Delta_UnsetField( delta_t *pFields, const char *fieldname )
|
||||
{
|
||||
delta_info_t *dt;
|
||||
delta_t *pField;
|
||||
int i;
|
||||
delta_t *pField;
|
||||
int i;
|
||||
|
||||
dt = Delta_FindStructByDelta( pFields );
|
||||
delta_info_t *dt = Delta_FindStructByDelta( pFields );
|
||||
if( dt == NULL || !fieldname || !fieldname[0] )
|
||||
return;
|
||||
|
||||
@@ -2258,9 +2174,7 @@ void GAME_EXPORT Delta_UnsetField( delta_t *pFields, const char *fieldname )
|
||||
|
||||
void GAME_EXPORT Delta_SetFieldByIndex( delta_t *pFields, int fieldNumber )
|
||||
{
|
||||
delta_info_t *dt;
|
||||
|
||||
dt = Delta_FindStructByDelta( pFields );
|
||||
delta_info_t *dt = Delta_FindStructByDelta( pFields );
|
||||
if( dt == NULL || fieldNumber < 0 || fieldNumber >= dt->numFields )
|
||||
return;
|
||||
|
||||
@@ -2269,9 +2183,7 @@ void GAME_EXPORT Delta_SetFieldByIndex( delta_t *pFields, int fieldNumber )
|
||||
|
||||
void GAME_EXPORT Delta_UnsetFieldByIndex( delta_t *pFields, int fieldNumber )
|
||||
{
|
||||
delta_info_t *dt;
|
||||
|
||||
dt = Delta_FindStructByDelta( pFields );
|
||||
delta_info_t *dt = Delta_FindStructByDelta( pFields );
|
||||
if( dt == NULL || fieldNumber < 0 || fieldNumber >= dt->numFields )
|
||||
return;
|
||||
|
||||
@@ -2287,7 +2199,6 @@ void Test_RunDelta( void )
|
||||
delta_test_struct_t from, to = { 0 };
|
||||
delta_test_struct_t null = { 0 };
|
||||
sizebuf_t msg;
|
||||
int i;
|
||||
char buffer[4096] = { 0 };
|
||||
const double timebase = 123.123;
|
||||
|
||||
@@ -2319,12 +2230,12 @@ void Test_RunDelta( void )
|
||||
|
||||
MSG_Init( &msg, "test message", buffer, sizeof( buffer ));
|
||||
|
||||
for( i = 0; i < dt->numFields; i++ )
|
||||
for( int i = 0; i < dt->numFields; i++ )
|
||||
Delta_WriteField( &msg, &dt->pFields[i], &null, &from, timebase );
|
||||
|
||||
MSG_SeekToBit( &msg, 0, SEEK_SET );
|
||||
|
||||
for( i = 0; i < dt->numFields; i++ )
|
||||
for( int i = 0; i < dt->numFields; i++ )
|
||||
Delta_ReadField( &msg, &dt->pFields[i], &null, &to, timebase );
|
||||
|
||||
Con_Printf( "struct as encoded to delta:\n" );
|
||||
|
||||
@@ -257,7 +257,6 @@ NET_GetHostByName
|
||||
static qboolean NET_GetHostByName( const char *hostname, int family, struct sockaddr_storage *addr )
|
||||
{
|
||||
struct addrinfo *ai = NULL, *cur;
|
||||
struct addrinfo hints;
|
||||
qboolean ret = false;
|
||||
|
||||
#if XASH_NO_IPV6_RESOLVE
|
||||
@@ -265,8 +264,10 @@ static qboolean NET_GetHostByName( const char *hostname, int family, struct sock
|
||||
return false;
|
||||
#endif
|
||||
|
||||
memset( &hints, 0, sizeof( hints ));
|
||||
hints.ai_family = family;
|
||||
struct addrinfo hints =
|
||||
{
|
||||
.ai_family = family,
|
||||
};
|
||||
|
||||
if( !getaddrinfo( hostname, NULL, &hints, &ai ))
|
||||
{
|
||||
@@ -405,8 +406,8 @@ idnewt:28000
|
||||
*/
|
||||
net_gai_state_t NET_StringToSockaddr( const char *s, struct sockaddr_storage *sadr, qboolean nonblocking, int family )
|
||||
{
|
||||
int ret = 0, port;
|
||||
char *colon;
|
||||
int ret = 0;
|
||||
int port;
|
||||
char copy[128];
|
||||
byte ip6[16];
|
||||
struct sockaddr_storage temp;
|
||||
@@ -430,7 +431,7 @@ net_gai_state_t NET_StringToSockaddr( const char *s, struct sockaddr_storage *sa
|
||||
|
||||
// strip off a trailing :port if present
|
||||
((struct sockaddr_in *)sadr)->sin_port = 0;
|
||||
for( colon = copy; *colon; colon++ )
|
||||
for( char *colon = copy; *colon; colon++ )
|
||||
{
|
||||
if( *colon == ':' )
|
||||
{
|
||||
@@ -521,7 +522,7 @@ NET_StringToFilterAdr
|
||||
*/
|
||||
qboolean NET_StringToFilterAdr( const char *s, netadr_t *adr, uint *prefixlen )
|
||||
{
|
||||
char copy[128], *temp;
|
||||
char copy[128];
|
||||
qboolean hasCIDR = false;
|
||||
byte ip6[16];
|
||||
uint len;
|
||||
@@ -533,7 +534,7 @@ qboolean NET_StringToFilterAdr( const char *s, netadr_t *adr, uint *prefixlen )
|
||||
|
||||
// copy the string and remove CIDR prefix
|
||||
Q_strncpy( copy, s, sizeof( copy ));
|
||||
temp = Q_strrchr( copy, '/' );
|
||||
char *temp = Q_strrchr( copy, '/' );
|
||||
|
||||
if( temp )
|
||||
{
|
||||
@@ -595,11 +596,9 @@ qboolean NET_StringToFilterAdr( const char *s, netadr_t *adr, uint *prefixlen )
|
||||
|
||||
if( !hasCIDR )
|
||||
{
|
||||
int i;
|
||||
|
||||
*prefixlen = 32;
|
||||
|
||||
for( i = 3; i >= 0; i-- )
|
||||
for( int i = 3; i >= 0; i-- )
|
||||
{
|
||||
if( !adr->ip[i] )
|
||||
*prefixlen -= 8;
|
||||
@@ -609,13 +608,11 @@ qboolean NET_StringToFilterAdr( const char *s, netadr_t *adr, uint *prefixlen )
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t mask;
|
||||
|
||||
len = bound( 0, len, 32 );
|
||||
*prefixlen = len;
|
||||
|
||||
// drop unneeded bits
|
||||
mask = htonl( adr->ip4 ) & ( 0xFFFFFFFF << ( 32 - len ));
|
||||
uint32_t mask = htonl( adr->ip4 ) & ( 0xFFFFFFFF << ( 32 - len ));
|
||||
adr->ip4 = ntohl( mask );
|
||||
}
|
||||
|
||||
@@ -864,17 +861,17 @@ guaranteed to return -1, 0 or 1
|
||||
int NET_CompareAdrSort( const void *_a, const void *_b )
|
||||
{
|
||||
const netadr_t *a = _a, *b = _b;
|
||||
int porta, portb, portdiff, addrdiff;
|
||||
netadrtype_t type_a, type_b;
|
||||
int addrdiff;
|
||||
|
||||
type_a = NET_NetadrType( a );
|
||||
type_b = NET_NetadrType( b );
|
||||
netadrtype_t type_a = NET_NetadrType( a );
|
||||
netadrtype_t type_b = NET_NetadrType( b );
|
||||
|
||||
if( type_a != type_b )
|
||||
return bound( -1, (int)type_a - (int)type_b, 1 );
|
||||
|
||||
porta = ntohs( a->port );
|
||||
portb = ntohs( b->port );
|
||||
int porta = ntohs( a->port );
|
||||
int portb = ntohs( b->port );
|
||||
int portdiff;
|
||||
if( porta < portb )
|
||||
portdiff = -1;
|
||||
else if( porta > portb )
|
||||
@@ -944,7 +941,6 @@ qboolean NET_StringToAdr( const char *string, netadr_t *adr )
|
||||
net_gai_state_t NET_StringToAdrNB( const char *string, netadr_t *adr, qboolean v6only )
|
||||
{
|
||||
struct sockaddr_storage s;
|
||||
net_gai_state_t res;
|
||||
|
||||
memset( adr, 0, sizeof( netadr_t ));
|
||||
|
||||
@@ -954,7 +950,7 @@ net_gai_state_t NET_StringToAdrNB( const char *string, netadr_t *adr, qboolean v
|
||||
return NET_EAI_OK;
|
||||
}
|
||||
|
||||
res = NET_StringToSockaddr( string, &s, true, v6only ? AF_INET6 : AF_UNSPEC );
|
||||
net_gai_state_t res = NET_StringToSockaddr( string, &s, true, v6only ? AF_INET6 : AF_UNSPEC );
|
||||
|
||||
if( res == NET_EAI_OK )
|
||||
NET_SockadrToNetadr( &s, adr );
|
||||
@@ -976,20 +972,17 @@ NET_GetLoopPacket
|
||||
*/
|
||||
static qboolean NET_GetLoopPacket( netsrc_t sock, netadr_t *from, byte *data, size_t *length )
|
||||
{
|
||||
net_loopback_t *loop;
|
||||
int i;
|
||||
|
||||
if( !data || !length )
|
||||
return false;
|
||||
|
||||
loop = &net.loopbacks[sock];
|
||||
net_loopback_t *loop = &net.loopbacks[sock];
|
||||
|
||||
if( loop->send - loop->get > MAX_LOOPBACK )
|
||||
loop->get = loop->send - MAX_LOOPBACK;
|
||||
|
||||
if( loop->get >= loop->send )
|
||||
return false;
|
||||
i = loop->get & MASK_LOOPBACK;
|
||||
int i = loop->get & MASK_LOOPBACK;
|
||||
loop->get++;
|
||||
|
||||
memcpy( data, loop->msgs[i].data, loop->msgs[i].datalen );
|
||||
@@ -1008,12 +1001,9 @@ NET_SendLoopPacket
|
||||
*/
|
||||
static void NET_SendLoopPacket( netsrc_t sock, size_t length, const void *data, netadr_t to )
|
||||
{
|
||||
net_loopback_t *loop;
|
||||
int i;
|
||||
net_loopback_t *loop = &net.loopbacks[sock^1];
|
||||
|
||||
loop = &net.loopbacks[sock^1];
|
||||
|
||||
i = loop->send & MASK_LOOPBACK;
|
||||
int i = loop->send & MASK_LOOPBACK;
|
||||
loop->send++;
|
||||
|
||||
memcpy( loop->msgs[i].data, data, length );
|
||||
@@ -1062,12 +1052,10 @@ double linked list remove queue
|
||||
*/
|
||||
static void NET_ClearLaggedList( packetlag_t *list )
|
||||
{
|
||||
packetlag_t *p, *n;
|
||||
|
||||
p = list->next;
|
||||
packetlag_t *p = list->next;
|
||||
while( p && p != list )
|
||||
{
|
||||
n = p->next;
|
||||
packetlag_t *n = p->next;
|
||||
|
||||
NET_RemoveFromPacketList( p );
|
||||
|
||||
@@ -1094,8 +1082,6 @@ add lagged packet to stream
|
||||
*/
|
||||
static void NET_AddToLagged( netsrc_t sock, packetlag_t *list, packetlag_t *packet, netadr_t *from, size_t length, const void *data, float timestamp )
|
||||
{
|
||||
byte *pStart;
|
||||
|
||||
if( packet->prev || packet->next )
|
||||
return;
|
||||
|
||||
@@ -1104,7 +1090,7 @@ static void NET_AddToLagged( netsrc_t sock, packetlag_t *list, packetlag_t *pack
|
||||
list->prev = packet;
|
||||
packet->next = list;
|
||||
|
||||
pStart = (byte *)Z_Malloc( length );
|
||||
byte *pStart = (byte *)Z_Malloc( length );
|
||||
memcpy( pStart, data, length );
|
||||
packet->data = pStart;
|
||||
packet->size = length;
|
||||
@@ -1122,10 +1108,8 @@ adjust time to next fake lag
|
||||
static void NET_AdjustLag( void )
|
||||
{
|
||||
static double lasttime = 0.0;
|
||||
float diff, converge;
|
||||
double dt;
|
||||
|
||||
dt = host.realtime - lasttime;
|
||||
double dt = host.realtime - lasttime;
|
||||
dt = bound( 0.0, dt, 0.1 );
|
||||
lasttime = host.realtime;
|
||||
|
||||
@@ -1133,8 +1117,8 @@ static void NET_AdjustLag( void )
|
||||
{
|
||||
if( net_fakelag.value != net.fakelag )
|
||||
{
|
||||
diff = net_fakelag.value - net.fakelag;
|
||||
converge = dt * 200.0f;
|
||||
float diff = net_fakelag.value - net.fakelag;
|
||||
float converge = dt * 200.0f;
|
||||
if( fabs( diff ) < converge )
|
||||
converge = fabs( diff );
|
||||
if( diff < 0.0f )
|
||||
@@ -1159,18 +1143,13 @@ add fake lagged packet into rececived message
|
||||
*/
|
||||
static qboolean NET_LagPacket( qboolean newdata, netsrc_t sock, netadr_t *from, size_t *length, void *data )
|
||||
{
|
||||
packetlag_t *pNewPacketLag;
|
||||
packetlag_t *pPacket;
|
||||
int ninterval;
|
||||
float curtime;
|
||||
|
||||
if( net.fakelag <= 0.0f )
|
||||
{
|
||||
NET_ClearLagData( true, true );
|
||||
return newdata;
|
||||
}
|
||||
|
||||
curtime = host.realtime;
|
||||
float curtime = host.realtime;
|
||||
|
||||
if( newdata )
|
||||
{
|
||||
@@ -1181,7 +1160,7 @@ static qboolean NET_LagPacket( qboolean newdata, netsrc_t sock, netadr_t *from,
|
||||
net.losscount[sock]++;
|
||||
if( net_fakeloss.value <= 0.0f )
|
||||
{
|
||||
ninterval = fabs( net_fakeloss.value );
|
||||
int ninterval = fabs( net_fakeloss.value );
|
||||
if( ninterval < 2 ) ninterval = 2;
|
||||
|
||||
if(( net.losscount[sock] % ninterval ) == 0 )
|
||||
@@ -1199,12 +1178,12 @@ static qboolean NET_LagPacket( qboolean newdata, netsrc_t sock, netadr_t *from,
|
||||
}
|
||||
}
|
||||
|
||||
pNewPacketLag = (packetlag_t *)Z_Malloc( sizeof( packetlag_t ));
|
||||
packetlag_t *pNewPacketLag = (packetlag_t *)Z_Malloc( sizeof( packetlag_t ));
|
||||
// queue packet to simulate fake lag
|
||||
NET_AddToLagged( sock, &net.lagdata[sock], pNewPacketLag, from, *length, data, curtime );
|
||||
}
|
||||
|
||||
pPacket = net.lagdata[sock].next;
|
||||
packetlag_t *pPacket = net.lagdata[sock].next;
|
||||
|
||||
while( pPacket != &net.lagdata[sock] )
|
||||
{
|
||||
@@ -1356,8 +1335,6 @@ queue normal and lagged packets
|
||||
static qboolean NET_QueuePacket( int net_socket, netsrc_t sock, netadr_t *from, byte *data, size_t *length )
|
||||
{
|
||||
byte buf[NET_MAX_FRAGMENT];
|
||||
int ret;
|
||||
WSAsize_t addr_len;
|
||||
struct sockaddr_storage addr = { 0 };
|
||||
|
||||
*length = 0;
|
||||
@@ -1365,8 +1342,8 @@ static qboolean NET_QueuePacket( int net_socket, netsrc_t sock, netadr_t *from,
|
||||
if( !NET_IsSocketValid( net_socket ))
|
||||
return NET_LagPacket( false, sock, from, length, data );
|
||||
|
||||
addr_len = sizeof( addr );
|
||||
ret = recvfrom( net_socket, buf, sizeof( buf ), 0, (struct sockaddr *)&addr, &addr_len );
|
||||
WSAsize_t addr_len = sizeof( addr );
|
||||
int ret = recvfrom( net_socket, buf, sizeof( buf ), 0, (struct sockaddr *)&addr, &addr_len );
|
||||
|
||||
NET_SockadrToNetadr( &addr, from );
|
||||
|
||||
@@ -1394,7 +1371,7 @@ static qboolean NET_QueuePacket( int net_socket, netsrc_t sock, netadr_t *from,
|
||||
}
|
||||
else
|
||||
{
|
||||
int err = WSAGetLastError();
|
||||
int err = WSAGetLastError();
|
||||
|
||||
switch( err )
|
||||
{
|
||||
@@ -1464,25 +1441,22 @@ static int NET_SendLong( netsrc_t sock, int net_socket, const char *buf, size_t
|
||||
if( splitsize > sizeof( SPLITPACKET ) && sock == NS_SERVER && len > splitsize )
|
||||
{
|
||||
char packet[SPLITPACKET_MAX_SIZE];
|
||||
int total_sent, size, packet_count;
|
||||
int ret, packet_number;
|
||||
int body_size = splitsize - sizeof( SPLITPACKET );
|
||||
SPLITPACKET *pPacket;
|
||||
|
||||
net.sequence_number++;
|
||||
if( net.sequence_number <= 0 )
|
||||
net.sequence_number = 1;
|
||||
|
||||
pPacket = (SPLITPACKET *)packet;
|
||||
SPLITPACKET *pPacket = (SPLITPACKET *)packet;
|
||||
pPacket->sequence_number = net.sequence_number;
|
||||
pPacket->net_id = NET_HEADER_SPLITPACKET;
|
||||
packet_number = 0;
|
||||
total_sent = 0;
|
||||
packet_count = (len + body_size - 1) / body_size;
|
||||
int packet_number = 0;
|
||||
int total_sent = 0;
|
||||
int packet_count = (len + body_size - 1) / body_size;
|
||||
|
||||
while( len > 0 )
|
||||
{
|
||||
size = Q_min( body_size, len );
|
||||
int size = Q_min( body_size, len );
|
||||
pPacket->packet_id = (packet_number << 8) + packet_count;
|
||||
memcpy( packet + sizeof( SPLITPACKET ), buf + ( packet_number * body_size ), size );
|
||||
|
||||
@@ -1497,7 +1471,7 @@ static int NET_SendLong( netsrc_t sock, int net_socket, const char *buf, size_t
|
||||
packet_number + 1, packet_count, size, net.sequence_number, NET_AdrToString( adr ));
|
||||
}
|
||||
|
||||
ret = sendto( net_socket, packet, size + sizeof( SPLITPACKET ), flags, (const struct sockaddr *)to, tolen );
|
||||
int ret = sendto( net_socket, packet, size + sizeof( SPLITPACKET ), flags, (const struct sockaddr *)to, tolen );
|
||||
if( ret < 0 ) return ret; // error
|
||||
|
||||
if( ret >= size )
|
||||
@@ -1524,7 +1498,6 @@ NET_SendPacketEx
|
||||
*/
|
||||
void NET_SendPacketEx( netsrc_t sock, size_t length, const void *data, netadr_t to, size_t splitsize )
|
||||
{
|
||||
int ret;
|
||||
struct sockaddr_storage addr = { 0 };
|
||||
SOCKET net_socket = 0;
|
||||
netadrtype_t type = NET_NetadrType( &to );
|
||||
@@ -1553,7 +1526,7 @@ void NET_SendPacketEx( netsrc_t sock, size_t length, const void *data, netadr_t
|
||||
|
||||
NET_NetadrToSockadr( &to, &addr );
|
||||
|
||||
ret = NET_SendLong( sock, net_socket, data, length, 0, &addr, NET_SockAddrLen( &addr ), splitsize );
|
||||
int ret = NET_SendLong( sock, net_socket, data, length, 0, &addr, NET_SockAddrLen( &addr ), splitsize );
|
||||
|
||||
if( NET_IsSocketError( ret ))
|
||||
{
|
||||
@@ -1601,7 +1574,7 @@ NET_IPSocket
|
||||
static int NET_IPSocket( const char *net_iface, int port, int family )
|
||||
{
|
||||
struct sockaddr_storage addr = { 0 };
|
||||
int err, net_socket;
|
||||
int net_socket;
|
||||
uint optval = 1;
|
||||
dword _true = 1;
|
||||
int pfamily = PF_INET;
|
||||
@@ -1611,7 +1584,7 @@ static int NET_IPSocket( const char *net_iface, int port, int family )
|
||||
|
||||
if( NET_IsSocketError(( net_socket = socket( pfamily, SOCK_DGRAM, IPPROTO_UDP ))))
|
||||
{
|
||||
err = WSAGetLastError();
|
||||
int err = WSAGetLastError();
|
||||
if( err != WSAEAFNOSUPPORT )
|
||||
Con_DPrintf( S_WARN "%s: port: %d socket: %s\n", __func__, port, NET_ErrorString( ));
|
||||
return INVALID_SOCKET;
|
||||
@@ -1680,7 +1653,7 @@ static int NET_IPSocket( const char *net_iface, int port, int family )
|
||||
|
||||
if( NET_IsSocketError( setsockopt( net_socket, IPPROTO_IP, IP_TOS, (const char *)&optval, sizeof( optval ))))
|
||||
{
|
||||
err = WSAGetLastError();
|
||||
int err = WSAGetLastError();
|
||||
if( err != WSAENOPROTOOPT )
|
||||
Con_Printf( S_WARN "%s: port: %d setsockopt IP_TOS: %s\n", __func__, port, NET_ErrorString( ));
|
||||
closesocket( net_socket );
|
||||
@@ -1794,7 +1767,6 @@ static void NET_DetermineLocalAddress( void )
|
||||
char buff[512];
|
||||
struct sockaddr_storage address;
|
||||
WSAsize_t namelen;
|
||||
const char *net_addr_string;
|
||||
|
||||
memset( &net_local, 0, sizeof( netadr_t ));
|
||||
memset( &net6_local, 0, sizeof( netadr_t ));
|
||||
@@ -1822,7 +1794,7 @@ static void NET_DetermineLocalAddress( void )
|
||||
if( !NET_IsSocketError( getsockname( net.ip_sockets[NS_SERVER], (struct sockaddr *)&address, &namelen )))
|
||||
{
|
||||
net_local.port = ((struct sockaddr_in *)&address)->sin_port;
|
||||
net_addr_string = NET_AdrToString( net_local );
|
||||
const char *net_addr_string = NET_AdrToString( net_local );
|
||||
Con_Printf( "Server IPv4 address %s\n", net_addr_string );
|
||||
Cvar_FullSet( "net_address", net_addr_string, net_address.flags );
|
||||
}
|
||||
@@ -1845,7 +1817,7 @@ static void NET_DetermineLocalAddress( void )
|
||||
if( !NET_IsSocketError( getsockname( net.ip6_sockets[NS_SERVER], (struct sockaddr *)&address, &namelen )))
|
||||
{
|
||||
net6_local.port = ((struct sockaddr_in6 *)&address)->sin6_port;
|
||||
net_addr_string = NET_AdrToString( net6_local );
|
||||
const char *net_addr_string = NET_AdrToString( net6_local );
|
||||
Con_Printf( "Server IPv6 address %s\n", net_addr_string );
|
||||
Cvar_FullSet( "net6_address", net_addr_string, net6_address.flags );
|
||||
}
|
||||
@@ -1887,9 +1859,8 @@ void NET_Config( qboolean multiplayer, qboolean changeport )
|
||||
// validate sockets for dedicated
|
||||
if( Host_IsDedicated( ))
|
||||
{
|
||||
qboolean nov4, nov6;
|
||||
nov4 = net.allow_ip && NET_IsSocketError( net.ip_sockets[NS_SERVER] );
|
||||
nov6 = net.allow_ip6 && NET_IsSocketError( net.ip6_sockets[NS_SERVER] );
|
||||
qboolean nov4 = net.allow_ip && NET_IsSocketError( net.ip_sockets[NS_SERVER] );
|
||||
qboolean nov6 = net.allow_ip6 && NET_IsSocketError( net.ip6_sockets[NS_SERVER] );
|
||||
|
||||
if( nov4 && nov6 )
|
||||
Host_Error( "Couldn't allocate IPv4 and IPv6 server ports.\n" );
|
||||
@@ -1908,10 +1879,8 @@ void NET_Config( qboolean multiplayer, qboolean changeport )
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
// shut down any existing sockets
|
||||
for( i = 0; i < NS_COUNT; i++ )
|
||||
for( int i = 0; i < NS_COUNT; i++ )
|
||||
{
|
||||
if( NET_IsSocketValid( net.ip_sockets[i] ))
|
||||
{
|
||||
@@ -1989,7 +1958,6 @@ NET_Init
|
||||
void NET_Init( void )
|
||||
{
|
||||
char cmd[64];
|
||||
int i = 1;
|
||||
|
||||
if( net.initialized ) return;
|
||||
|
||||
@@ -2014,7 +1982,7 @@ void NET_Init( void )
|
||||
Cvar_RegisterVariable( &net6_address );
|
||||
|
||||
// prepare some network data
|
||||
for( i = 0; i < NS_COUNT; i++ )
|
||||
for( int i = 0; i < NS_COUNT; i++ )
|
||||
{
|
||||
net.lagdata[i].prev = &net.lagdata[i];
|
||||
net.lagdata[i].next = &net.lagdata[i];
|
||||
|
||||
@@ -53,10 +53,6 @@ static int PM_SampleMiptex( const msurface_t *surf, const vec3_t point )
|
||||
mextrasurf_t *info = surf->info;
|
||||
mfacebevel_t *fb = info->bevel;
|
||||
int contents;
|
||||
vec_t ds, dt;
|
||||
int x, y;
|
||||
mtexinfo_t *tx;
|
||||
texture_t *mt;
|
||||
|
||||
// fill the default contents
|
||||
if( fb ) contents = fb->contents;
|
||||
@@ -65,8 +61,8 @@ static int PM_SampleMiptex( const msurface_t *surf, const vec3_t point )
|
||||
if( !surf->texinfo || !surf->texinfo->texture )
|
||||
return contents;
|
||||
|
||||
tx = surf->texinfo;
|
||||
mt = tx->texture;
|
||||
mtexinfo_t *tx = surf->texinfo;
|
||||
texture_t *mt = tx->texture;
|
||||
|
||||
if( mt->name[0] != '{' )
|
||||
return contents;
|
||||
@@ -76,18 +72,16 @@ static int PM_SampleMiptex( const msurface_t *surf, const vec3_t point )
|
||||
#if !XASH_DEDICATED
|
||||
if( !Host_IsDedicated() )
|
||||
{
|
||||
const byte *data;
|
||||
|
||||
data = ref.dllFuncs.R_GetTextureOriginalBuffer( mt->gl_texturenum );
|
||||
const byte *data = ref.dllFuncs.R_GetTextureOriginalBuffer( mt->gl_texturenum );
|
||||
|
||||
if( !data ) return contents; // original doesn't kept
|
||||
|
||||
ds = DotProduct( point, tx->vecs[0] ) + tx->vecs[0][3];
|
||||
dt = DotProduct( point, tx->vecs[1] ) + tx->vecs[1][3];
|
||||
vec_t ds = DotProduct( point, tx->vecs[0] ) + tx->vecs[0][3];
|
||||
vec_t dt = DotProduct( point, tx->vecs[1] ) + tx->vecs[1][3];
|
||||
|
||||
// convert ST to real pixels position
|
||||
x = fix_coord( ds, mt->width - 1 );
|
||||
y = fix_coord( dt, mt->height - 1 );
|
||||
int x = fix_coord( ds, mt->width - 1 );
|
||||
int y = fix_coord( dt, mt->height - 1 );
|
||||
|
||||
ASSERT( x >= 0 && y >= 0 );
|
||||
|
||||
@@ -108,18 +102,12 @@ PM_RecursiveSurfCheck
|
||||
*/
|
||||
msurface_t *PM_RecursiveSurfCheck( model_t *mod, mnode_t *node, vec3_t p1, vec3_t p2 )
|
||||
{
|
||||
float t1, t2, frac;
|
||||
int i, side;
|
||||
msurface_t *surf;
|
||||
vec3_t mid;
|
||||
int numsurfaces, firstsurface;
|
||||
|
||||
loc0:
|
||||
if( node->contents < 0 )
|
||||
return NULL;
|
||||
|
||||
t1 = PlaneDiff( p1, node->plane );
|
||||
t2 = PlaneDiff( p2, node->plane );
|
||||
float t1 = PlaneDiff( p1, node->plane );
|
||||
float t2 = PlaneDiff( p2, node->plane );
|
||||
|
||||
if( t1 >= -FRAC_EPSILON && t2 >= -FRAC_EPSILON )
|
||||
{
|
||||
@@ -133,24 +121,25 @@ loc0:
|
||||
goto loc0;
|
||||
}
|
||||
|
||||
side = (t1 < 0.0f);
|
||||
frac = t1 / ( t1 - t2 );
|
||||
int side = (t1 < 0.0f);
|
||||
float frac = t1 / ( t1 - t2 );
|
||||
frac = bound( 0.0f, frac, 1.0f );
|
||||
|
||||
vec3_t mid;
|
||||
VectorLerp( p1, frac, p2, mid );
|
||||
|
||||
if(( surf = PM_RecursiveSurfCheck( mod, node_child( node, side, mod ), p1, mid )) != NULL )
|
||||
msurface_t *surf = PM_RecursiveSurfCheck( mod, node_child( node, side, mod ), p1, mid );
|
||||
if( surf != NULL )
|
||||
return surf;
|
||||
|
||||
// walk through real faces
|
||||
numsurfaces = node_numsurfaces( node, mod );
|
||||
firstsurface = node_firstsurface( node, mod );
|
||||
for( i = 0; i < numsurfaces; i++ )
|
||||
int numsurfaces = node_numsurfaces( node, mod );
|
||||
int firstsurface = node_firstsurface( node, mod );
|
||||
for( int i = 0; i < numsurfaces; i++ )
|
||||
{
|
||||
msurface_t *surf = &mod->surfaces[firstsurface + i];
|
||||
mextrasurf_t *info = surf->info;
|
||||
mfacebevel_t *fb = info->bevel;
|
||||
int j, contents;
|
||||
vec3_t delta;
|
||||
|
||||
if( !fb ) continue; // ???
|
||||
@@ -159,6 +148,7 @@ loc0:
|
||||
if( DotProduct( delta, delta ) >= fb->radius )
|
||||
continue; // no intersection
|
||||
|
||||
int j;
|
||||
for( j = 0; j < fb->numedges; j++ )
|
||||
{
|
||||
if( PlaneDiff( mid, &fb->edges[j] ) > FRAC_EPSILON )
|
||||
@@ -169,7 +159,7 @@ loc0:
|
||||
continue; // we are outside the bounds of the facet
|
||||
|
||||
// hit the surface
|
||||
contents = PM_SampleMiptex( surf, mid );
|
||||
int contents = PM_SampleMiptex( surf, mid );
|
||||
|
||||
if( contents != CONTENTS_EMPTY )
|
||||
return surf;
|
||||
@@ -189,27 +179,24 @@ assume physentity is valid
|
||||
*/
|
||||
msurface_t *PM_TraceSurface( physent_t *pe, vec3_t start, vec3_t end )
|
||||
{
|
||||
matrix4x4 matrix;
|
||||
model_t *bmodel;
|
||||
hull_t *hull;
|
||||
vec3_t start_l, end_l;
|
||||
vec3_t offset;
|
||||
|
||||
bmodel = pe->model;
|
||||
model_t *bmodel = pe->model;
|
||||
|
||||
if( !bmodel || bmodel->type != mod_brush )
|
||||
return NULL;
|
||||
|
||||
hull = &pe->model->hulls[0];
|
||||
hull_t *hull = &pe->model->hulls[0];
|
||||
vec3_t offset;
|
||||
VectorSubtract( hull->clip_mins, vec3_origin, offset );
|
||||
VectorAdd( offset, pe->origin, offset );
|
||||
|
||||
vec3_t start_l, end_l;
|
||||
VectorSubtract( start, offset, start_l );
|
||||
VectorSubtract( end, offset, end_l );
|
||||
|
||||
// rotate start and end into the models frame of reference
|
||||
if( !VectorIsNull( pe->angles ))
|
||||
{
|
||||
matrix4x4 matrix;
|
||||
Matrix4x4_CreateFromEntity( matrix, pe->angles, offset, 1.0f );
|
||||
Matrix4x4_VectorITransform( matrix, start, start_l );
|
||||
Matrix4x4_VectorITransform( matrix, end, end_l );
|
||||
@@ -227,12 +214,6 @@ optimized trace for light gathering
|
||||
*/
|
||||
static int PM_TestLine_r( model_t *mod, mnode_t *node, vec_t p1f, vec_t p2f, const vec3_t start, const vec3_t stop, linetrace_t *trace )
|
||||
{
|
||||
float front, back;
|
||||
float frac, midf;
|
||||
int i, r, side;
|
||||
vec3_t mid;
|
||||
int numsurfaces, firstsurface;
|
||||
|
||||
loc0:
|
||||
if( node->contents < 0 )
|
||||
{
|
||||
@@ -245,8 +226,8 @@ loc0:
|
||||
return CONTENTS_EMPTY;
|
||||
}
|
||||
|
||||
front = PlaneDiff( start, node->plane );
|
||||
back = PlaneDiff( stop, node->plane );
|
||||
float front = PlaneDiff( start, node->plane );
|
||||
float back = PlaneDiff( stop, node->plane );
|
||||
|
||||
if( front >= -FRAC_EPSILON && back >= -FRAC_EPSILON )
|
||||
{
|
||||
@@ -260,14 +241,15 @@ loc0:
|
||||
goto loc0;
|
||||
}
|
||||
|
||||
side = (front < 0);
|
||||
frac = front / (front - back);
|
||||
int side = (front < 0);
|
||||
float frac = front / (front - back);
|
||||
frac = bound( 0.0f, frac, 1.0f );
|
||||
|
||||
vec3_t mid;
|
||||
VectorLerp( start, frac, stop, mid );
|
||||
midf = p1f + ( p2f - p1f ) * frac;
|
||||
float midf = p1f + ( p2f - p1f ) * frac;
|
||||
|
||||
r = PM_TestLine_r( mod, node_child( node, side, mod ), p1f, midf, start, mid, trace );
|
||||
int r = PM_TestLine_r( mod, node_child( node, side, mod ), p1f, midf, start, mid, trace );
|
||||
|
||||
if( r != CONTENTS_EMPTY )
|
||||
{
|
||||
@@ -278,14 +260,13 @@ loc0:
|
||||
}
|
||||
|
||||
// walk through real faces
|
||||
numsurfaces = node_numsurfaces( node, mod );
|
||||
firstsurface = node_firstsurface( node, mod );
|
||||
for( i = 0; i < numsurfaces; i++ )
|
||||
int numsurfaces = node_numsurfaces( node, mod );
|
||||
int firstsurface = node_firstsurface( node, mod );
|
||||
for( int i = 0; i < numsurfaces; i++ )
|
||||
{
|
||||
msurface_t *surf = &mod->surfaces[firstsurface + i];
|
||||
mextrasurf_t *info = surf->info;
|
||||
mfacebevel_t *fb = info->bevel;
|
||||
int j, contents;
|
||||
vec3_t delta;
|
||||
|
||||
if( !fb ) continue;
|
||||
@@ -294,6 +275,7 @@ loc0:
|
||||
if( DotProduct( delta, delta ) >= fb->radius )
|
||||
continue; // no intersection
|
||||
|
||||
int j;
|
||||
for( j = 0; j < fb->numedges; j++ )
|
||||
{
|
||||
if( PlaneDiff( mid, &fb->edges[j] ) > FRAC_EPSILON )
|
||||
@@ -304,7 +286,7 @@ loc0:
|
||||
continue; // we are outside the bounds of the facet
|
||||
|
||||
// hit the surface
|
||||
contents = PM_SampleMiptex( surf, mid );
|
||||
int contents = PM_SampleMiptex( surf, mid );
|
||||
|
||||
// fill the trace and out
|
||||
trace->contents = contents;
|
||||
@@ -321,21 +303,15 @@ loc0:
|
||||
|
||||
int PM_TestLineExt( playermove_t *pmove, physent_t *ents, int numents, const vec3_t start, const vec3_t end, int flags )
|
||||
{
|
||||
linetrace_t trace, trace_bbox;
|
||||
matrix4x4 matrix;
|
||||
hull_t *hull = NULL;
|
||||
vec3_t offset, start_l, end_l;
|
||||
qboolean rotated;
|
||||
physent_t *pe;
|
||||
int i;
|
||||
|
||||
trace.contents = CONTENTS_EMPTY;
|
||||
trace.fraction = 1.0f;
|
||||
trace.surface = NULL;
|
||||
|
||||
for( i = 0; i < numents; i++ )
|
||||
linetrace_t trace =
|
||||
{
|
||||
pe = &ents[i];
|
||||
.contents = CONTENTS_EMPTY,
|
||||
.fraction = 1.0f,
|
||||
};
|
||||
|
||||
for( int i = 0; i < numents; i++ )
|
||||
{
|
||||
physent_t *pe = &ents[i];
|
||||
|
||||
if( i != 0 && FBitSet( flags, PM_WORLD_ONLY ))
|
||||
break;
|
||||
@@ -346,16 +322,20 @@ int PM_TestLineExt( playermove_t *pmove, physent_t *ents, int numents, const vec
|
||||
if( FBitSet( flags, PM_GLASS_IGNORE ) && pe->rendermode != kRenderNormal )
|
||||
continue;
|
||||
|
||||
hull = &pe->model->hulls[0];
|
||||
hull_t *hull = &pe->model->hulls[0];
|
||||
vec3_t offset;
|
||||
|
||||
hull = PM_HullForBsp( pe, pmove, offset );
|
||||
|
||||
qboolean rotated;
|
||||
if( pe->solid == SOLID_BSP && !VectorIsNull( pe->angles ))
|
||||
rotated = true;
|
||||
else rotated = false;
|
||||
|
||||
vec3_t start_l, end_l;
|
||||
if( rotated )
|
||||
{
|
||||
matrix4x4 matrix;
|
||||
Matrix4x4_CreateFromEntity( matrix, pe->angles, offset, 1.0f );
|
||||
Matrix4x4_VectorITransform( matrix, start, start_l );
|
||||
Matrix4x4_VectorITransform( matrix, end, end_l );
|
||||
@@ -366,9 +346,11 @@ int PM_TestLineExt( playermove_t *pmove, physent_t *ents, int numents, const vec
|
||||
VectorSubtract( end, pe->origin, end_l );
|
||||
}
|
||||
|
||||
trace_bbox.contents = CONTENTS_EMPTY;
|
||||
trace_bbox.fraction = 1.0f;
|
||||
trace_bbox.surface = NULL;
|
||||
linetrace_t trace_bbox =
|
||||
{
|
||||
.contents = CONTENTS_EMPTY,
|
||||
.fraction = 1.0f,
|
||||
};
|
||||
|
||||
PM_TestLine_r( pe->model, &pe->model->nodes[hull->firstclipnode], 0.0f, 1.0f, start_l, end_l, &trace_bbox );
|
||||
|
||||
|
||||
@@ -63,14 +63,12 @@ can just be stored out and get a proper hull_t structure.
|
||||
*/
|
||||
void PM_InitBoxHull( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
pm_boxhull.clipnodes16 = (mclipnode16_t *)box_clipnodes16;
|
||||
pm_boxhull.planes = pm_boxplanes;
|
||||
pm_boxhull.firstclipnode = 0;
|
||||
pm_boxhull.lastclipnode = 5;
|
||||
|
||||
for( i = 0; i < 6; i++ )
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
pm_boxplanes[i].type = i>>1;
|
||||
pm_boxplanes[i].normal[i>>1] = 1.0f;
|
||||
@@ -112,8 +110,6 @@ PM_HullPointContents
|
||||
*/
|
||||
int GAME_EXPORT PM_HullPointContents( hull_t *hull, int num, const vec3_t p )
|
||||
{
|
||||
mplane_t *plane;
|
||||
|
||||
if( !hull || !hull->planes ) // fantom bmodels?
|
||||
return CONTENTS_NONE;
|
||||
|
||||
@@ -121,7 +117,7 @@ int GAME_EXPORT PM_HullPointContents( hull_t *hull, int num, const vec3_t p )
|
||||
{
|
||||
while( num >= 0 )
|
||||
{
|
||||
plane = &hull->planes[hull->clipnodes32[num].planenum];
|
||||
mplane_t *plane = &hull->planes[hull->clipnodes32[num].planenum];
|
||||
num = hull->clipnodes32[num].children[PlaneDiff( p, plane ) < 0];
|
||||
}
|
||||
}
|
||||
@@ -129,7 +125,7 @@ int GAME_EXPORT PM_HullPointContents( hull_t *hull, int num, const vec3_t p )
|
||||
{
|
||||
while( num >= 0 )
|
||||
{
|
||||
plane = &hull->planes[hull->clipnodes16[num].planenum];
|
||||
mplane_t *plane = &hull->planes[hull->clipnodes16[num].planenum];
|
||||
num = hull->clipnodes16[num].children[PlaneDiff( p, plane ) < 0];
|
||||
}
|
||||
}
|
||||
@@ -145,11 +141,10 @@ assume physent is valid
|
||||
*/
|
||||
hull_t *PM_HullForBsp( physent_t *pe, playermove_t *pmove, float *offset )
|
||||
{
|
||||
hull_t *hull;
|
||||
|
||||
Assert( pe != NULL );
|
||||
Assert( pe->model != NULL );
|
||||
|
||||
hull_t *hull;
|
||||
switch( pmove->usehull )
|
||||
{
|
||||
case 1:
|
||||
@@ -184,8 +179,7 @@ generate multiple hulls as hitboxes
|
||||
*/
|
||||
static hull_t *PM_HullForStudio( physent_t *pe, playermove_t *pmove, int *numhitboxes )
|
||||
{
|
||||
vec3_t size;
|
||||
|
||||
vec3_t size;
|
||||
VectorSubtract( host.player_maxs[pmove->usehull], host.player_mins[pmove->usehull], size );
|
||||
VectorScale( size, 0.5f, size );
|
||||
|
||||
@@ -324,25 +318,22 @@ loc0:
|
||||
|
||||
pmtrace_t PM_PlayerTraceExt( playermove_t *pmove, vec3_t start, vec3_t end, int flags, int numents, physent_t *ents, int ignore_pe, pfnIgnore pmFilter )
|
||||
{
|
||||
physent_t *pe;
|
||||
matrix4x4 matrix;
|
||||
pmtrace_t trace_bbox;
|
||||
pmtrace_t trace_hitbox;
|
||||
pmtrace_t trace_total;
|
||||
vec3_t offset, start_l, end_l;
|
||||
vec3_t temp, mins, maxs;
|
||||
int i, j, hullcount;
|
||||
qboolean rotated, transform_bbox;
|
||||
hull_t *hull = NULL;
|
||||
pmtrace_t trace_total;
|
||||
|
||||
memset( &trace_total, 0, sizeof( trace_total ));
|
||||
VectorCopy( end, trace_total.endpos );
|
||||
trace_total.fraction = 1.0f;
|
||||
trace_total.ent = -1;
|
||||
|
||||
for( i = 0; i < numents; i++ )
|
||||
for( int i = 0; i < numents; i++ )
|
||||
{
|
||||
pe = &ents[i];
|
||||
physent_t *pe = &ents[i];
|
||||
matrix4x4 matrix;
|
||||
vec3_t offset, start_l, end_l;
|
||||
vec3_t mins, maxs;
|
||||
int hullcount;
|
||||
qboolean rotated, transform_bbox;
|
||||
hull_t *hull = NULL;
|
||||
|
||||
if( i != 0 && ( flags & PM_WORLD_ONLY ))
|
||||
break;
|
||||
@@ -438,7 +429,7 @@ pmtrace_t PM_PlayerTraceExt( playermove_t *pmove, vec3_t start, vec3_t end, int
|
||||
World_TransformAABB( matrix, host.player_mins[pmove->usehull], host.player_maxs[pmove->usehull], mins, maxs );
|
||||
VectorSubtract( hull->clip_mins, mins, offset ); // calc new local offset
|
||||
|
||||
for( j = 0; j < 3; j++ )
|
||||
for( int j = 0; j < 3; j++ )
|
||||
{
|
||||
if( start_l[j] >= 0.0f )
|
||||
start_l[j] -= offset[j];
|
||||
@@ -455,6 +446,7 @@ pmtrace_t PM_PlayerTraceExt( playermove_t *pmove, vec3_t start, vec3_t end, int
|
||||
VectorSubtract( end, offset, end_l );
|
||||
}
|
||||
|
||||
pmtrace_t trace_bbox;
|
||||
PM_InitPMTrace( &trace_bbox, end );
|
||||
|
||||
if( hullcount < 1 )
|
||||
@@ -477,10 +469,11 @@ pmtrace_t PM_PlayerTraceExt( playermove_t *pmove, vec3_t start, vec3_t end, int
|
||||
}
|
||||
else
|
||||
{
|
||||
int last_hitgroup;
|
||||
int last_hitgroup = 0;
|
||||
|
||||
for( last_hitgroup = 0, j = 0; j < hullcount; j++ )
|
||||
for( int j = 0; j < hullcount; j++ )
|
||||
{
|
||||
pmtrace_t trace_hitbox;
|
||||
PM_InitPMTrace( &trace_hitbox, end );
|
||||
|
||||
PM_RecursiveHullCheck( &hull[j], hull[j].firstclipnode, 0, 1, start_l, end_l, &trace_hitbox );
|
||||
@@ -513,7 +506,7 @@ pmtrace_t PM_PlayerTraceExt( playermove_t *pmove, vec3_t start, vec3_t end, int
|
||||
|
||||
if( rotated )
|
||||
{
|
||||
VectorCopy( trace_bbox.plane.normal, temp );
|
||||
vec3_t temp = Vec3( trace_bbox.plane.normal );
|
||||
Matrix4x4_TransformPositivePlane( matrix, temp, trace_bbox.plane.dist, trace_bbox.plane.normal, &trace_bbox.plane.dist );
|
||||
}
|
||||
else
|
||||
@@ -534,19 +527,16 @@ pmtrace_t PM_PlayerTraceExt( playermove_t *pmove, vec3_t start, vec3_t end, int
|
||||
|
||||
int PM_TestPlayerPosition( playermove_t *pmove, vec3_t pos, pmtrace_t *ptrace, pfnIgnore pmFilter )
|
||||
{
|
||||
int i, j, hullcount;
|
||||
vec3_t pos_l, offset;
|
||||
hull_t *hull = NULL;
|
||||
vec3_t mins, maxs;
|
||||
pmtrace_t trace;
|
||||
physent_t *pe;
|
||||
|
||||
trace = PM_PlayerTraceExt( pmove, pmove->origin, pmove->origin, 0, pmove->numphysent, pmove->physents, -1, pmFilter );
|
||||
pmtrace_t trace = PM_PlayerTraceExt( pmove, pmove->origin, pmove->origin, 0, pmove->numphysent, pmove->physents, -1, pmFilter );
|
||||
if( ptrace ) *ptrace = trace;
|
||||
|
||||
for( i = 0; i < pmove->numphysent; i++ )
|
||||
for( int i = 0; i < pmove->numphysent; i++ )
|
||||
{
|
||||
pe = &pmove->physents[i];
|
||||
physent_t *pe = &pmove->physents[i];
|
||||
vec3_t pos_l, offset;
|
||||
vec3_t mins, maxs;
|
||||
hull_t *hull = NULL;
|
||||
int hullcount;
|
||||
|
||||
// run custom user filter
|
||||
if( pmFilter != NULL )
|
||||
@@ -607,7 +597,7 @@ int PM_TestPlayerPosition( playermove_t *pmove, vec3_t pos, pmtrace_t *ptrace, p
|
||||
World_TransformAABB( matrix, host.player_mins[pmove->usehull], host.player_maxs[pmove->usehull], mins, maxs );
|
||||
VectorSubtract( hull->clip_mins, mins, offset ); // calc new local offset
|
||||
|
||||
for( j = 0; j < 3; j++ )
|
||||
for( int j = 0; j < 3; j++ )
|
||||
{
|
||||
if( pos_l[j] >= 0.0f )
|
||||
pos_l[j] -= offset[j];
|
||||
@@ -645,7 +635,7 @@ int PM_TestPlayerPosition( playermove_t *pmove, vec3_t pos, pmtrace_t *ptrace, p
|
||||
}
|
||||
else
|
||||
{
|
||||
for( j = 0; j < hullcount; j++ )
|
||||
for( int j = 0; j < hullcount; j++ )
|
||||
{
|
||||
if( PM_HullPointContents( &hull[j], hull[j].firstclipnode, pos_l ) == CONTENTS_SOLID )
|
||||
return i;
|
||||
@@ -684,21 +674,16 @@ PM_PointContents
|
||||
*/
|
||||
int PM_PointContents( playermove_t *pmove, const vec3_t p )
|
||||
{
|
||||
int i, contents;
|
||||
hull_t *hull;
|
||||
vec3_t test;
|
||||
physent_t *pe;
|
||||
|
||||
// sanity check
|
||||
if( !p || !pmove->physents[0].model )
|
||||
return CONTENTS_NONE;
|
||||
|
||||
// get base contents from world
|
||||
contents = PM_HullPointContents( &pmove->physents[0].model->hulls[0], 0, p );
|
||||
int contents = PM_HullPointContents( &pmove->physents[0].model->hulls[0], 0, p );
|
||||
|
||||
for( i = 1; i < pmove->numphysent; i++ )
|
||||
for( int i = 1; i < pmove->numphysent; i++ )
|
||||
{
|
||||
pe = &pmove->physents[i];
|
||||
physent_t *pe = &pmove->physents[i];
|
||||
|
||||
if( pe->solid != SOLID_NOT ) // disabled ?
|
||||
continue;
|
||||
@@ -707,11 +692,12 @@ int PM_PointContents( playermove_t *pmove, const vec3_t p )
|
||||
if( !pe->model ) continue;
|
||||
|
||||
// check water brushes accuracy
|
||||
hull = &pe->model->hulls[0];
|
||||
hull_t *hull = &pe->model->hulls[0];
|
||||
vec3_t test;
|
||||
|
||||
if( FBitSet( pe->model->flags, MODEL_HAS_ORIGIN ) && !VectorIsNull( pe->angles ))
|
||||
{
|
||||
matrix4x4 matrix;
|
||||
matrix4x4 matrix;
|
||||
|
||||
Matrix4x4_CreateFromEntity( matrix, pe->angles, pe->origin, 1.0f );
|
||||
Matrix4x4_VectorITransform( matrix, p, test );
|
||||
@@ -742,26 +728,24 @@ PM_TraceModel
|
||||
*/
|
||||
float PM_TraceModel( playermove_t *pmove, physent_t *pe, float *start, float *end, trace_t *trace )
|
||||
{
|
||||
int old_usehull;
|
||||
vec3_t start_l, end_l;
|
||||
vec3_t offset, temp;
|
||||
qboolean rotated;
|
||||
matrix4x4 matrix;
|
||||
hull_t *hull;
|
||||
|
||||
PM_InitTrace( trace, end );
|
||||
|
||||
old_usehull = pmove->usehull;
|
||||
int old_usehull = pmove->usehull;
|
||||
pmove->usehull = 2;
|
||||
|
||||
hull = PM_HullForBsp( pe, pmove, offset );
|
||||
vec3_t offset;
|
||||
hull_t *hull = PM_HullForBsp( pe, pmove, offset );
|
||||
|
||||
pmove->usehull = old_usehull;
|
||||
|
||||
qboolean rotated;
|
||||
if( pe->solid == SOLID_BSP && !VectorIsNull( pe->angles ))
|
||||
rotated = true;
|
||||
else rotated = false;
|
||||
|
||||
vec3_t start_l, end_l;
|
||||
matrix4x4 matrix;
|
||||
|
||||
if( rotated )
|
||||
{
|
||||
Matrix4x4_CreateFromEntity( matrix, pe->angles, offset, 1.0f );
|
||||
@@ -779,7 +763,7 @@ float PM_TraceModel( playermove_t *pmove, physent_t *pe, float *start, float *en
|
||||
|
||||
if( rotated )
|
||||
{
|
||||
VectorCopy( trace->plane.normal, temp );
|
||||
vec3_t temp = Vec3( trace->plane.normal );
|
||||
Matrix4x4_TransformPositivePlane( matrix, temp, trace->plane.dist, trace->plane.normal, &trace->plane.dist );
|
||||
}
|
||||
|
||||
@@ -790,10 +774,8 @@ float PM_TraceModel( playermove_t *pmove, physent_t *pe, float *start, float *en
|
||||
|
||||
pmtrace_t *PM_TraceLine( playermove_t *pmove, float *start, float *end, int flags, int usehull, int ignore_pe )
|
||||
{
|
||||
static pmtrace_t tr;
|
||||
int old_usehull;
|
||||
|
||||
old_usehull = pmove->usehull;
|
||||
static pmtrace_t tr;
|
||||
int old_usehull = pmove->usehull;
|
||||
pmove->usehull = usehull;
|
||||
|
||||
switch( flags )
|
||||
@@ -813,10 +795,8 @@ pmtrace_t *PM_TraceLine( playermove_t *pmove, float *start, float *end, int flag
|
||||
|
||||
pmtrace_t *PM_TraceLineEx( playermove_t *pmove, float *start, float *end, int flags, int usehull, pfnIgnore pmFilter )
|
||||
{
|
||||
static pmtrace_t tr;
|
||||
int old_usehull;
|
||||
|
||||
old_usehull = pmove->usehull;
|
||||
static pmtrace_t tr;
|
||||
int old_usehull = pmove->usehull;
|
||||
pmove->usehull = usehull;
|
||||
|
||||
switch( flags )
|
||||
@@ -844,12 +824,10 @@ struct msurface_s *PM_TraceSurfacePmove( playermove_t *pmove, int ground, float
|
||||
|
||||
const char *PM_TraceTexture( playermove_t *pmove, int ground, float *vstart, float *vend )
|
||||
{
|
||||
msurface_t *surf;
|
||||
|
||||
if( ground < 0 || ground >= pmove->numphysent )
|
||||
return NULL; // bad ground
|
||||
|
||||
surf = PM_TraceSurface( &pmove->physents[ground], vstart, vend );
|
||||
msurface_t *surf = PM_TraceSurface( &pmove->physents[ground], vstart, vend );
|
||||
|
||||
if( !surf || !surf->texinfo || !surf->texinfo->texture )
|
||||
return NULL;
|
||||
@@ -859,8 +837,7 @@ const char *PM_TraceTexture( playermove_t *pmove, int ground, float *vstart, flo
|
||||
|
||||
int PM_PointContentsPmove( playermove_t *pmove, const float *p, int *truecontents )
|
||||
{
|
||||
int cont, truecont;
|
||||
|
||||
int truecont, cont;
|
||||
truecont = cont = PM_PointContents( pmove, p );
|
||||
if( truecontents ) *truecontents = truecont;
|
||||
|
||||
@@ -871,9 +848,7 @@ int PM_PointContentsPmove( playermove_t *pmove, const float *p, int *truecontent
|
||||
|
||||
void PM_StuckTouch( playermove_t *pmove, int hitent, pmtrace_t *tr )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < pmove->numtouch; i++ )
|
||||
for( int i = 0; i < pmove->numtouch; i++ )
|
||||
{
|
||||
if( pmove->touchindex[i].ent == hitent )
|
||||
return;
|
||||
|
||||
@@ -363,17 +363,14 @@ static qboolean Sound_ResampleInternal( wavdata_t *sc, int outrate, int outwidth
|
||||
const int incount = sc->samples;
|
||||
const int insize = sc->size;
|
||||
qboolean handled = false;
|
||||
double stepscale;
|
||||
double t1, t2;
|
||||
int outcount;
|
||||
|
||||
if( inrate == outrate && inwidth == outwidth && inchannels == outchannels )
|
||||
return false;
|
||||
|
||||
t1 = Platform_DoubleTime();
|
||||
double t1 = Platform_DoubleTime();
|
||||
|
||||
stepscale = (double)inrate / outrate; // this is usually 0.5, 1, or 2
|
||||
outcount = sc->samples / stepscale;
|
||||
double stepscale = (double)inrate / outrate; // this is usually 0.5, 1, or 2
|
||||
int outcount = sc->samples / stepscale;
|
||||
sc->size = outcount * outwidth * outchannels;
|
||||
sc->channels = outchannels;
|
||||
|
||||
@@ -404,7 +401,7 @@ static qboolean Sound_ResampleInternal( wavdata_t *sc, int outrate, int outwidth
|
||||
return false;
|
||||
}
|
||||
|
||||
t2 = Platform_DoubleTime();
|
||||
double t2 = Platform_DoubleTime();
|
||||
sc->rate = outrate;
|
||||
sc->width = outwidth;
|
||||
|
||||
@@ -418,8 +415,8 @@ static qboolean Sound_ResampleInternal( wavdata_t *sc, int outrate, int outwidth
|
||||
|
||||
qboolean Sound_Process( wavdata_t **wav, int rate, int width, int channels, uint flags )
|
||||
{
|
||||
wavdata_t *snd = *wav;
|
||||
qboolean result = true;
|
||||
wavdata_t *snd = *wav;
|
||||
qboolean result = true;
|
||||
|
||||
// check for buffers
|
||||
if( unlikely( !snd || !snd->buffer ))
|
||||
@@ -446,10 +443,9 @@ qboolean Sound_Process( wavdata_t **wav, int rate, int width, int channels, uint
|
||||
|
||||
qboolean Sound_SupportedFileFormat( const char *fileext )
|
||||
{
|
||||
const loadwavfmt_t *format;
|
||||
if( !COM_StringEmpty( fileext ))
|
||||
{
|
||||
for( format = sound.loadformats; format && format->ext; format++ )
|
||||
for( const loadwavfmt_t *format = sound.loadformats; format && format->ext; format++ )
|
||||
{
|
||||
if( !Q_stricmp( format->ext, fileext ))
|
||||
return true;
|
||||
|
||||
@@ -59,9 +59,7 @@ static void SoundList_Free( soundlst_t *lst )
|
||||
|
||||
void SoundList_Shutdown( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < SoundList_Groups; i++ )
|
||||
for( int i = 0; i < SoundList_Groups; i++ )
|
||||
SoundList_Free( &soundlst[i] );
|
||||
}
|
||||
|
||||
@@ -120,15 +118,11 @@ const char *SoundList_GetRandom( enum soundlst_group_e group )
|
||||
static qboolean SoundList_ParseGroup( soundlst_t *lst, char **file )
|
||||
{
|
||||
string token;
|
||||
int count = 0, slen = 0, i;
|
||||
char *p;
|
||||
|
||||
p = *file;
|
||||
int count = 0, slen = 0;
|
||||
char *p = *file;
|
||||
|
||||
while(( p = COM_ParseFile( p, token, sizeof( token ))))
|
||||
{
|
||||
int len;
|
||||
|
||||
if( !Q_strcmp( token, "}" ))
|
||||
break;
|
||||
|
||||
@@ -143,7 +137,7 @@ static qboolean SoundList_ParseGroup( soundlst_t *lst, char **file )
|
||||
return false;
|
||||
}
|
||||
|
||||
len = Q_strlen( token ) + 1;
|
||||
int len = Q_strlen( token ) + 1;
|
||||
if( slen < len )
|
||||
slen = len;
|
||||
|
||||
@@ -163,7 +157,7 @@ static qboolean SoundList_ParseGroup( soundlst_t *lst, char **file )
|
||||
lst->max = count;
|
||||
lst->snd = Mem_Malloc( host.mempool, count * slen ); // allocate single buffer for the whole group
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
*file = COM_ParseFile( *file, token, sizeof( token ));
|
||||
|
||||
@@ -176,15 +170,13 @@ static qboolean SoundList_ParseGroup( soundlst_t *lst, char **file )
|
||||
static qboolean SoundList_ParseRange( soundlst_t *lst, char **file )
|
||||
{
|
||||
string token, snd;
|
||||
char *p;
|
||||
int i = 0;
|
||||
|
||||
lst->type = SoundList_Range;
|
||||
*file = COM_ParseFile( *file, snd, sizeof( snd ));
|
||||
|
||||
// validate format string, count all % characters
|
||||
p = snd;
|
||||
i = 0;
|
||||
char *p = snd;
|
||||
int i = 0;
|
||||
while(( p = Q_strchr( p, '%' )))
|
||||
{
|
||||
// only decimal
|
||||
@@ -228,14 +220,12 @@ static qboolean SoundList_ParseRange( soundlst_t *lst, char **file )
|
||||
static qboolean SoundList_Parse( char *file )
|
||||
{
|
||||
string token;
|
||||
int i;
|
||||
|
||||
while(( file = COM_ParseFile( file, token, sizeof( token ))))
|
||||
{
|
||||
soundlst_t *lst = NULL;
|
||||
char *p;
|
||||
|
||||
for( i = 0; i < SoundList_Groups; i++ )
|
||||
for( int i = 0; i < SoundList_Groups; i++ )
|
||||
{
|
||||
if( !Q_strcmp( token, soundlst_groups[i] ))
|
||||
{
|
||||
@@ -250,7 +240,7 @@ static qboolean SoundList_Parse( char *file )
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
p = COM_ParseFile( file, token, sizeof( token ));
|
||||
char *p = COM_ParseFile( file, token, sizeof( token ));
|
||||
|
||||
// group is a range
|
||||
if( !Q_strcmp( token, "{" ))
|
||||
@@ -287,9 +277,7 @@ cleanup:
|
||||
|
||||
static void SoundList_Print_f( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < SoundList_Groups; i++ )
|
||||
for( int i = 0; i < SoundList_Groups; i++ )
|
||||
{
|
||||
soundlst_t *lst = &soundlst[i];
|
||||
|
||||
@@ -301,10 +289,8 @@ static void SoundList_Print_f( void )
|
||||
break;
|
||||
case SoundList_List:
|
||||
{
|
||||
int j;
|
||||
|
||||
Con_Reportf( "%-16s\t" S_MAGENTA "List" S_DEFAULT " [", soundlst_groups[i] );
|
||||
for( j = 0; j < lst->max; j++ )
|
||||
for( int j = 0; j < lst->max; j++ )
|
||||
Con_Reportf( "%s%s", &lst->snd[j * lst->min], j + 1 == lst->max ? "" : ", " );
|
||||
Con_Reportf( "]\n" );
|
||||
break;
|
||||
|
||||
@@ -82,8 +82,6 @@ static void Sys_FlushLogfile( void )
|
||||
|
||||
void Sys_InitLog( void )
|
||||
{
|
||||
const char *mode;
|
||||
|
||||
if( Sys_CheckParm( "-log" ))
|
||||
{
|
||||
if( !Sys_GetParmFromCmdLine( "-log", s_ld.log_path ) || !isalnum((byte)s_ld.log_path[0] ))
|
||||
@@ -95,6 +93,7 @@ void Sys_InitLog( void )
|
||||
|
||||
s_ld.log_time = Sys_CheckParm( "-logtime" );
|
||||
|
||||
const char *mode;
|
||||
if( host.change_game && host.type != HOST_DEDICATED )
|
||||
mode = "a";
|
||||
else mode = "w";
|
||||
@@ -282,15 +281,15 @@ static void Sys_PrintStdout( const char *logtime, size_t logtime_len, const char
|
||||
|
||||
void Sys_PrintLog( const char *pMsg )
|
||||
{
|
||||
time_t crt_time;
|
||||
const struct tm *crt_tm;
|
||||
const struct tm *crt_tm = NULL;
|
||||
char logtime[32] = "";
|
||||
static char lastchar;
|
||||
qboolean print_time = false;
|
||||
size_t len, logtime_len = 0;
|
||||
size_t logtime_len = 0;
|
||||
|
||||
if( !lastchar || lastchar == '\n' )
|
||||
{
|
||||
time_t crt_time;
|
||||
if( time( &crt_time ) >= 0 )
|
||||
{
|
||||
crt_tm = localtime( &crt_time );
|
||||
@@ -307,7 +306,7 @@ void Sys_PrintLog( const char *pMsg )
|
||||
// spew to stdout
|
||||
Sys_PrintStdout( logtime, logtime_len, pMsg );
|
||||
|
||||
len = Q_strlen( pMsg );
|
||||
size_t len = Q_strlen( pMsg );
|
||||
|
||||
// save last char to detect when line was not ended
|
||||
lastchar = len > 0 ? pMsg[len - 1] : 0;
|
||||
@@ -341,9 +340,7 @@ CONSOLE PRINT
|
||||
static void Con_Printfv( qboolean debug, const char *szFmt, va_list args )
|
||||
{
|
||||
static char buffer[MAX_PRINT_MSG];
|
||||
qboolean add_newline;
|
||||
|
||||
add_newline = Q_vsnprintf( buffer, sizeof( buffer ), szFmt, args ) < 0;
|
||||
qboolean add_newline = Q_vsnprintf( buffer, sizeof( buffer ), szFmt, args ) < 0;
|
||||
|
||||
if( debug && !Q_strcmp( buffer, "0\n" ))
|
||||
return; // hlrally spam
|
||||
|
||||
@@ -176,14 +176,13 @@ Sys_ParseCommandLine
|
||||
void Sys_ParseCommandLine( int argc, const char **argv )
|
||||
{
|
||||
const char *blank = "censored";
|
||||
int i;
|
||||
|
||||
host.argc = argc;
|
||||
host.argv = argv;
|
||||
|
||||
if( !host.change_game ) return;
|
||||
|
||||
for( i = 0; i < host.argc; i++ )
|
||||
for( int i = 0; i < host.argc; i++ )
|
||||
{
|
||||
// we don't want to return to first game
|
||||
if( !Q_stricmp( "-game", host.argv[i] )) host.argv[i] = blank;
|
||||
@@ -208,9 +207,7 @@ where the given parameter apears, or 0 if not present
|
||||
*/
|
||||
int Sys_CheckParm( const char *parm )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 1; i < host.argc; i++ )
|
||||
for( int i = 1; i < host.argc; i++ )
|
||||
{
|
||||
if( !host.argv[i] )
|
||||
continue;
|
||||
@@ -259,7 +256,6 @@ qboolean Sys_GetIntFromCmdLine( const char* argName, int *out )
|
||||
//=======================================================================
|
||||
qboolean Sys_LoadLibrary( dll_info_t *dll )
|
||||
{
|
||||
size_t i;
|
||||
string errorstring;
|
||||
|
||||
// check errors
|
||||
@@ -285,7 +281,7 @@ qboolean Sys_LoadLibrary( dll_info_t *dll )
|
||||
}
|
||||
|
||||
// Get the function adresses
|
||||
for( i = 0; i < dll->num_fcts; i++ )
|
||||
for( size_t i = 0; i < dll->num_fcts; i++ )
|
||||
{
|
||||
const dllfunc_t *func = &dll->fcts[i];
|
||||
if( !( *func->func = COM_GetProcAddress( dll->link, func->name )))
|
||||
@@ -557,13 +553,12 @@ it explicitly doesn't use internal allocation or string copy utils
|
||||
qboolean Sys_NewInstance( const char *gamedir, const char *finalmsg )
|
||||
{
|
||||
qboolean replaced_arg = false;
|
||||
int i;
|
||||
|
||||
#if XASH_NSWITCH
|
||||
char newargs[4096];
|
||||
const char *exe = host.argv[0]; // arg 0 is always the full NRO path
|
||||
|
||||
for( i = 0; i < host.argc; i++ )
|
||||
for( int i = 0; i < host.argc; i++ )
|
||||
{
|
||||
Q_strncat( newargs, host.argv[i], sizeof( newargs ));
|
||||
Q_strncat( newargs, " ", sizeof( newargs ));
|
||||
@@ -593,12 +588,11 @@ qboolean Sys_NewInstance( const char *gamedir, const char *finalmsg )
|
||||
envSetNextLoad( exe, newargs );
|
||||
exit( 0 );
|
||||
#else
|
||||
int exelen;
|
||||
char *exe = NULL, **newargs;
|
||||
|
||||
char *exe = NULL;
|
||||
// don't use engine allocation utils here
|
||||
// they will be freed after Host_Shutdown
|
||||
newargs = calloc( host.argc + 4, sizeof( *newargs ));
|
||||
char **newargs = calloc( host.argc + 4, sizeof( *newargs ));
|
||||
int i;
|
||||
|
||||
for( i = 0; i < host.argc; i++ )
|
||||
{
|
||||
@@ -628,7 +622,7 @@ qboolean Sys_NewInstance( const char *gamedir, const char *finalmsg )
|
||||
exe = strdup( "app0:/eboot.bin" );
|
||||
sceAppMgrLoadExec( exe, newargs, NULL );
|
||||
#else
|
||||
exelen = wai_getExecutablePath( NULL, 0, NULL );
|
||||
int exelen = wai_getExecutablePath( NULL, 0, NULL );
|
||||
if( exelen >= 0 )
|
||||
{
|
||||
exe = malloc( exelen + 1 );
|
||||
@@ -661,15 +655,13 @@ Get platform-specific native object
|
||||
*/
|
||||
void *Sys_GetNativeObject( const char *obj )
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
if( COM_StringEmptyOrNULL( obj ))
|
||||
return NULL;
|
||||
|
||||
if( !Q_strcmp( obj, "MenuFactory" ))
|
||||
return UI_GetMenuFactory();
|
||||
|
||||
ptr = FS_GetNativeObject( obj );
|
||||
void *ptr = FS_GetNativeObject( obj );
|
||||
|
||||
if( ptr )
|
||||
return ptr;
|
||||
|
||||
@@ -28,18 +28,16 @@ World_TransformAABB
|
||||
*/
|
||||
void World_TransformAABB( matrix4x4 transform, const vec3_t mins, const vec3_t maxs, vec3_t outmins, vec3_t outmaxs )
|
||||
{
|
||||
vec3_t p1, p2;
|
||||
matrix4x4 itransform;
|
||||
int i;
|
||||
|
||||
if( !outmins || !outmaxs ) return;
|
||||
|
||||
matrix4x4 itransform;
|
||||
Matrix4x4_Invert_Simple( itransform, transform );
|
||||
ClearBounds( outmins, outmaxs );
|
||||
|
||||
// compute a full bounding box
|
||||
for( i = 0; i < 8; i++ )
|
||||
for( int i = 0; i < 8; i++ )
|
||||
{
|
||||
vec3_t p1, p2;
|
||||
p1[0] = ( i & 1 ) ? mins[0] : maxs[0];
|
||||
p1[1] = ( i & 2 ) ? mins[1] : maxs[1];
|
||||
p1[2] = ( i & 4 ) ? mins[2] : maxs[2];
|
||||
@@ -57,7 +55,7 @@ void World_TransformAABB( matrix4x4 transform, const vec3_t mins, const vec3_t m
|
||||
}
|
||||
|
||||
// sanity check
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
if( outmins[i] > outmaxs[i] )
|
||||
{
|
||||
|
||||
@@ -31,15 +31,13 @@ GNU General Public License for more details.
|
||||
|
||||
static void *Q_realloc( void *mem, size_t size )
|
||||
{
|
||||
void *newmem;
|
||||
|
||||
if( mem && size == 0 )
|
||||
{
|
||||
Q_free( mem );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
newmem = Q_malloc( size );
|
||||
void *newmem = Q_malloc( size );
|
||||
if( mem && newmem )
|
||||
{
|
||||
memcpy( newmem, mem, size );
|
||||
@@ -577,7 +575,6 @@ static qboolean Mem_CheckAlloc( mempool_t *pool, void *data )
|
||||
if( pool )
|
||||
{
|
||||
memheader_t *target_big = (memheader_t *)((byte *)data - sizeof( memheader_t ));
|
||||
memheader_small_t *target_small = (memheader_small_t *)((byte *)data - sizeof( memheader_small_t ));
|
||||
|
||||
for( memheader_t *header = pool->chain; header; header = header->next )
|
||||
{
|
||||
@@ -585,6 +582,8 @@ static qboolean Mem_CheckAlloc( mempool_t *pool, void *data )
|
||||
return true;
|
||||
}
|
||||
|
||||
memheader_small_t *target_small = (memheader_small_t *)((byte *)data - sizeof( memheader_small_t ));
|
||||
|
||||
for( memheader_small_t *header = pool->chain_small; header; header = header->next )
|
||||
{
|
||||
if( header == target_small )
|
||||
@@ -593,10 +592,9 @@ static qboolean Mem_CheckAlloc( mempool_t *pool, void *data )
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t i;
|
||||
for( i = 0, pool = poolchain; i < poolcount; i++, pool++ )
|
||||
for( size_t i = 0; i < poolcount; i++ )
|
||||
{
|
||||
if( Mem_CheckAlloc( pool, data ))
|
||||
if( Mem_CheckAlloc( &poolchain[i], data ))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -615,11 +613,10 @@ qboolean Mem_IsAllocatedExt( poolhandle_t poolptr, void *data )
|
||||
|
||||
void _Mem_Check( const char *filename, int fileline )
|
||||
{
|
||||
mempool_t *pool;
|
||||
size_t i;
|
||||
|
||||
for( i = 0, pool = poolchain; i < poolcount; i++, pool++ )
|
||||
for( size_t i = 0; i < poolcount; i++ )
|
||||
{
|
||||
mempool_t *pool = &poolchain[i];
|
||||
|
||||
for( memheader_t *mem = pool->chain; mem; mem = mem->next )
|
||||
Mem_CheckAllocHeaderBig( __func__, mem, filename, fileline );
|
||||
|
||||
@@ -630,12 +627,13 @@ void _Mem_Check( const char *filename, int fileline )
|
||||
|
||||
void Mem_PrintStats( void )
|
||||
{
|
||||
size_t count = 0, size = 0, realsize = 0, i;
|
||||
mempool_t *pool;
|
||||
size_t count = 0, size = 0, realsize = 0;
|
||||
|
||||
Mem_Check();
|
||||
for( i = 0, pool = poolchain; i < poolcount; i++, pool++ )
|
||||
for( size_t i = 0; i < poolcount; i++ )
|
||||
{
|
||||
mempool_t *pool = &poolchain[i];
|
||||
|
||||
if( !pool->filename )
|
||||
continue;
|
||||
|
||||
@@ -650,15 +648,13 @@ void Mem_PrintStats( void )
|
||||
|
||||
static void Mem_PrintList( size_t minallocationsize )
|
||||
{
|
||||
mempool_t *pool;
|
||||
size_t i;
|
||||
|
||||
Mem_Check();
|
||||
|
||||
Con_Printf( "memory pool list:\n" );
|
||||
Con_Printf( "\t^3size\t\t\t\tname\n");
|
||||
for( i = 0, pool = poolchain; i < poolcount; i++, pool++ )
|
||||
for( size_t i = 0; i < poolcount; i++ )
|
||||
{
|
||||
mempool_t *pool = &poolchain[i];
|
||||
long changed_size = (long)pool->totalsize - (long)pool->lastchecksize;
|
||||
|
||||
if( !pool->filename )
|
||||
|
||||
@@ -78,14 +78,12 @@ Android_GetAndroidID
|
||||
const char *Android_GetAndroidID( void )
|
||||
{
|
||||
static char id[32];
|
||||
jstring resultJNIStr;
|
||||
const char *resultCStr;
|
||||
|
||||
if( !COM_StringEmpty( id ))
|
||||
return id;
|
||||
|
||||
resultJNIStr = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.getAndroidID );
|
||||
resultCStr = (*jni.env)->GetStringUTFChars( jni.env, resultJNIStr, NULL );
|
||||
jstring resultJNIStr = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.getAndroidID );
|
||||
const char *resultCStr = (*jni.env)->GetStringUTFChars( jni.env, resultJNIStr, NULL );
|
||||
Q_strncpy( id, resultCStr, sizeof( id ) );
|
||||
(*jni.env)->ReleaseStringUTFChars( jni.env, resultJNIStr, resultCStr );
|
||||
(*jni.env)->DeleteLocalRef( jni.env, resultJNIStr );
|
||||
@@ -101,11 +99,8 @@ Android_LoadID
|
||||
const char *Android_LoadID( void )
|
||||
{
|
||||
static char id[32];
|
||||
jstring resultJNIStr;
|
||||
const char *resultCStr;
|
||||
|
||||
resultJNIStr = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.loadAndroidID );
|
||||
resultCStr = (*jni.env)->GetStringUTFChars( jni.env, resultJNIStr, NULL );
|
||||
jstring resultJNIStr = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.loadAndroidID );
|
||||
const char *resultCStr = (*jni.env)->GetStringUTFChars( jni.env, resultJNIStr, NULL );
|
||||
Q_strncpy( id, resultCStr, sizeof( id ) );
|
||||
(*jni.env)->ReleaseStringUTFChars( jni.env, resultJNIStr, resultCStr );
|
||||
(*jni.env)->DeleteLocalRef( jni.env, resultJNIStr );
|
||||
|
||||
@@ -23,7 +23,6 @@ GNU General Public License for more details.
|
||||
void *ANDROID_LoadLibrary( const char *path )
|
||||
{
|
||||
const char *name = COM_FileWithoutPath( path );
|
||||
void *handle;
|
||||
|
||||
Con_Reportf( "%s: loading \"%s\" (name: \"%s\")\n", __func__, path, name );
|
||||
|
||||
@@ -36,7 +35,7 @@ void *ANDROID_LoadLibrary( const char *path )
|
||||
|
||||
Con_Reportf( "%s: trying APK path \"%s\"\n", __func__, fullpath );
|
||||
|
||||
handle = dlopen( fullpath, RTLD_NOW );
|
||||
void *handle = dlopen( fullpath, RTLD_NOW );
|
||||
if( handle )
|
||||
{
|
||||
Con_Reportf( "%s: loaded from APK path\n", __func__ );
|
||||
@@ -58,7 +57,7 @@ void *ANDROID_LoadLibrary( const char *path )
|
||||
Q_strncpy( libpath, hInst->fullPath, sizeof( libpath ));
|
||||
Mem_Free( hInst );
|
||||
|
||||
handle = dlopen( libpath, RTLD_NOW );
|
||||
void *handle = dlopen( libpath, RTLD_NOW );
|
||||
if( handle )
|
||||
{
|
||||
Con_Reportf( "%s: loaded from VFS path\n", __func__ );
|
||||
@@ -77,7 +76,7 @@ void *ANDROID_LoadLibrary( const char *path )
|
||||
|
||||
// find in system search path (APK's LD_LIBRARY_PATH)
|
||||
Con_Reportf( "%s: trying LD_LIBRARY_PATH for \"%s\"\n", __func__, name );
|
||||
handle = dlopen( name, RTLD_NOW );
|
||||
void *handle = dlopen( name, RTLD_NOW );
|
||||
if( handle )
|
||||
{
|
||||
Con_Reportf( "%s: loaded from LD_LIBRARY_PATH\n", __func__ );
|
||||
|
||||
@@ -52,9 +52,7 @@ byte scantokey[128] =
|
||||
// will be implemented later
|
||||
void Platform_RunEvents( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for( i = 0; i < keystate.buf_head;i++ )
|
||||
for( int i = 0; i < keystate.buf_head;i++ )
|
||||
{
|
||||
int k = keystate.buf[i];
|
||||
int key = scantokey[k&0x7f];
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user