25 Dec 2012

This commit is contained in:
g-cont 2012-12-25 00:00:00 +04:00 committed by Alibek Omarov
parent 6ab812ec1c
commit e9b16a49f4
4 changed files with 177 additions and 74 deletions

View File

@ -1,3 +1,22 @@
build 2148
Engine: implement support of new BSP format that called BSP31
Engine: added new feature - big lightmaps 256x256 instead of 128x128. This is used for new BSP format 31
Render: new texture viewer implemented (navigate pages with arrow keys)
Engine: added cvar gl_keeptjunctions from Quake (removes a collinear points, economy some vertexes)
Sound: test thing: release sentence sounds after playing
Engine: rewrited code for anti (_-=ZhekA=-_) system
Console: don't moving cursor if autocomplete was failed on second or all next arguments
Engine: release all elements of client game cvar (was potential memory leak)
Engine: allow change game for dedicated servers
Server: added default case for Studio Blending Interface while server is not loaded (e.g. remote connection). Was here a potential crashpoint.
Engine: parse "wad" field from entity string and use wad ordering for loading textures that may have matched names but placed in different wads
Network: change protocol to 47. Old demos will stop working.
Network: rewrite delta-comparing code. In theory this may reduce a network traffic
Server: fix crash for fast switching between singleplayer and multiplayer
Server: optimize MOVETYPE_COMPOUND code
Server: added missed flag FL_FAKECLIENT for bots
build 2112
Engine: fix bug with ambient sounds that won't writes into demo

View File

@ -679,9 +679,9 @@ byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int out
pix3 = (byte *)inRow2 + p1[x];
pix4 = (byte *)inRow2 + p2[x];
normal[0] = (pix1[0] * (1.0f/127) - 1.0f) + (pix2[0] * (1.0f/127) - 1.0f) + (pix3[0] * (1.0f/127) - 1.0f) + (pix4[0] * (1.0f/127) - 1.0f);
normal[1] = (pix1[1] * (1.0f/127) - 1.0f) + (pix2[1] * (1.0f/127) - 1.0f) + (pix3[1] * (1.0f/127) - 1.0f) + (pix4[1] * (1.0f/127) - 1.0f);
normal[2] = (pix1[2] * (1.0f/127) - 1.0f) + (pix2[2] * (1.0f/127) - 1.0f) + (pix3[2] * (1.0f/127) - 1.0f) + (pix4[2] * (1.0f/127) - 1.0f);
normal[0] = (pix1[0] * (1.0f/127.0f) - 1.0f) + (pix2[0] * (1.0f/127.0f) - 1.0f) + (pix3[0] * (1.0f/127.0f) - 1.0f) + (pix4[0] * (1.0f/127.0f) - 1.0f);
normal[1] = (pix1[1] * (1.0f/127.0f) - 1.0f) + (pix2[1] * (1.0f/127.0f) - 1.0f) + (pix3[1] * (1.0f/127.0f) - 1.0f) + (pix4[1] * (1.0f/127.0f) - 1.0f);
normal[2] = (pix1[2] * (1.0f/127.0f) - 1.0f) + (pix2[2] * (1.0f/127.0f) - 1.0f) + (pix3[2] * (1.0f/127.0f) - 1.0f) + (pix4[2] * (1.0f/127.0f) - 1.0f);
if( !VectorNormalizeLength( normal ))
VectorSet( normal, 0.0f, 0.0f, 1.0f );
@ -764,9 +764,9 @@ static void GL_BuildMipMap( byte *in, int width, int height, qboolean isNormalMa
{
for( x = 0; x < width; x += 8, in += 8, out += 4 )
{
normal[0] = (in[0] * (1.0f/127) - 1.0f) + (in[4] * (1.0f/127) - 1.0f) + (in[width+0] * (1.0f/127) - 1.0f) + (in[width+4] * (1.0f/127) - 1.0f);
normal[1] = (in[1] * (1.0f/127) - 1.0f) + (in[5] * (1.0f/127) - 1.0f) + (in[width+1] * (1.0f/127) - 1.0f) + (in[width+5] * (1.0f/127) - 1.0f);
normal[2] = (in[2] * (1.0f/127) - 1.0f) + (in[6] * (1.0f/127) - 1.0f) + (in[width+2] * (1.0f/127) - 1.0f) + (in[width+6] * (1.0f/127) - 1.0f);
normal[0] = (in[0] * (1.0f/127.0f) - 1.0f) + (in[4] * (1.0f/127.0f) - 1.0f) + (in[width+0] * (1.0f/127.0f) - 1.0f) + (in[width+4] * (1.0f/127.0f) - 1.0f);
normal[1] = (in[1] * (1.0f/127.0f) - 1.0f) + (in[5] * (1.0f/127.0f) - 1.0f) + (in[width+1] * (1.0f/127.0f) - 1.0f) + (in[width+5] * (1.0f/127.0f) - 1.0f);
normal[2] = (in[2] * (1.0f/127.0f) - 1.0f) + (in[6] * (1.0f/127.0f) - 1.0f) + (in[width+2] * (1.0f/127.0f) - 1.0f) + (in[width+6] * (1.0f/127.0f) - 1.0f);
if( !VectorNormalizeLength( normal ))
VectorSet( normal, 0.0f, 0.0f, 1.0f );

View File

@ -597,8 +597,10 @@ qboolean Delta_ParseField( char **delta_script, const delta_field_t *pInfo, delt
pField->flags |= DT_INTEGER;
else if( !Q_strcmp( token, "DT_ANGLE" ))
pField->flags |= DT_ANGLE;
else if( !Q_strncmp( token, "DT_TIMEWINDOW", 13 ))
pField->flags |= DT_TIMEWINDOW;
else if( !Q_strcmp( token, "DT_TIMEWINDOW_8" ))
pField->flags |= DT_TIMEWINDOW_8;
else if( !Q_strcmp( token, "DT_TIMEWINDOW_BIG" ))
pField->flags |= DT_TIMEWINDOW_BIG;
else if( !Q_strcmp( token, "DT_STRING" ))
pField->flags |= DT_STRING;
else if( !Q_strcmp( token, "DT_SIGNED" ))
@ -868,18 +870,98 @@ void Delta_Shutdown( void )
delta_init = false;
}
/*
=====================
Delta_ClampIntegerField
prevent data to out of range
=====================
*/
int Delta_ClampIntegerField( int iValue, qboolean bSigned, int bits )
{
switch( bits )
{
case 1:
iValue = bound( 0, (byte)iValue, 1 );
break;
case 2:
if( bSigned ) iValue = bound( -1, (short)iValue, 2 );
else iValue = bound( 0, (word)iValue, 3 );
break;
case 3:
if( bSigned ) iValue = bound( -3, (short)iValue, 4 );
else iValue = bound( 0, (word)iValue, 7 );
break;
case 4:
if( bSigned ) iValue = bound( -7, (short)iValue, 8 );
else iValue = bound( 0, (word)iValue, 15 );
break;
case 5:
if( bSigned ) iValue = bound( -15, (short)iValue, 16 );
else iValue = bound( 0, (word)iValue, 31 );
break;
case 6:
if( bSigned ) iValue = bound( -31, (short)iValue, 32 );
else iValue = bound( 0, (word)iValue, 63 );
break;
case 7:
if( bSigned ) iValue = bound( -63, (short)iValue, 64 );
else iValue = bound( 0, (word)iValue, 127 );
break;
case 8:
if( bSigned ) iValue = bound( -127, (short)iValue, 128 );
else iValue = bound( 0, (word)iValue, 255 );
break;
case 9:
if( bSigned ) iValue = bound( -255, (short)iValue, 256 );
else iValue = bound( 0, (word)iValue, 511 );
break;
case 10:
if( bSigned ) iValue = bound( -511, (short)iValue, 512 );
else iValue = bound( 0, (word)iValue, 1023 );
break;
case 11:
if( bSigned ) iValue = bound( -1023, (short)iValue, 1024 );
else iValue = bound( 0, (word)iValue, 2047 );
break;
case 12:
if( bSigned ) iValue = bound( -2047, (short)iValue, 2048 );
else iValue = bound( 0, (word)iValue, 4095 );
break;
case 13:
if( bSigned ) iValue = bound( -4095, (short)iValue, 4096 );
else iValue = bound( 0, (word)iValue, 8191 );
break;
case 14:
if( bSigned ) iValue = bound( -8191, (short)iValue, 8192 );
else iValue = bound( 0, (word)iValue, 16383 );
break;
case 15:
if( bSigned ) iValue = bound( -16383, (short)iValue, 16384 );
else iValue = bound( 0, (word)iValue, 32767 );
break;
case 16:
if( bSigned ) iValue = bound( -32767, (short)iValue, 32768 );
else iValue = bound( 0, (word)iValue, 65535 );
break;
}
return iValue; // clamped;
}
/*
=====================
Delta_CompareField
compare fields by offsets
assume from and to is valid
TODO: multiply timewindow by 100 and 1000 before comparing
TODO: clamping and premultiply before comparing
TESTTEST: clamp all fields and multiply by specified value before comparing
=====================
*/
qboolean Delta_CompareField( delta_t *pField, void *from, void *to )
qboolean Delta_CompareField( delta_t *pField, void *from, void *to, float timebase )
{
qboolean bSigned = ( pField->flags & DT_SIGNED ) ? true : false;
float val_a, val_b;
int fromF, toF;
ASSERT( pField );
@ -903,6 +985,11 @@ qboolean Delta_CompareField( delta_t *pField, void *from, void *to )
fromF = *(byte *)((byte *)from + pField->offset );
toF = *(byte *)((byte *)to + pField->offset );
}
fromF = Delta_ClampIntegerField( fromF, bSigned, pField->bits );
toF = Delta_ClampIntegerField( toF, bSigned, pField->bits );
fromF *= pField->multiplier;
toF *= pField->multiplier;
}
else if( pField->flags & DT_SHORT )
{
@ -916,6 +1003,11 @@ qboolean Delta_CompareField( delta_t *pField, void *from, void *to )
fromF = *(word *)((byte *)from + pField->offset );
toF = *(word *)((byte *)to + pField->offset );
}
fromF = Delta_ClampIntegerField( fromF, bSigned, pField->bits );
toF = Delta_ClampIntegerField( toF, bSigned, pField->bits );
fromF *= pField->multiplier;
toF *= pField->multiplier;
}
else if( pField->flags & DT_INTEGER )
{
@ -929,13 +1021,36 @@ qboolean Delta_CompareField( delta_t *pField, void *from, void *to )
fromF = *(uint *)((byte *)from + pField->offset );
toF = *(uint *)((byte *)to + pField->offset );
}
fromF = Delta_ClampIntegerField( fromF, bSigned, pField->bits );
toF = Delta_ClampIntegerField( toF, bSigned, pField->bits );
fromF *= pField->multiplier;
toF *= pField->multiplier;
}
else if( pField->flags & ( DT_FLOAT|DT_ANGLE|DT_TIMEWINDOW ))
else if( pField->flags & ( DT_FLOAT|DT_ANGLE ))
{
// don't convert floats to integers
fromF = *((int *)((byte *)from + pField->offset ));
toF = *((int *)((byte *)to + pField->offset ));
}
else if( pField->flags & DT_TIMEWINDOW_8 )
{
val_a = (*(float *)((byte *)from + pField->offset )) * 100.0f;
val_b = (*(float *)((byte *)to + pField->offset )) * 100.0f;
val_a -= (timebase * 100.0f);
val_b -= (timebase * 100.0f);
fromF = *((int *)&val_a);
toF = *((int *)&val_b);
}
else if( pField->flags & DT_TIMEWINDOW_BIG )
{
val_a = (*(float *)((byte *)from + pField->offset )) * 1000.0f;
val_b = (*(float *)((byte *)to + pField->offset )) * 1000.0f;
val_a -= (timebase * 1000.0f);
val_b -= (timebase * 1000.0f);
fromF = *((int *)&val_a);
toF = *((int *)&val_b);
}
else if( pField->flags & DT_STRING )
{
// compare strings
@ -949,65 +1064,12 @@ qboolean Delta_CompareField( delta_t *pField, void *from, void *to )
return ( fromF == toF ) ? true : false;
}
/*
=====================
Delta_ClampIntegerField
prevent data to out of range
TODO: add missed cases
=====================
*/
int Delta_ClampIntegerField( int iValue, qboolean bSigned, int bits )
{
switch( bits )
{
case 8:
if( bSigned ) iValue = bound( -127, (short)iValue, 128 );
else iValue = bound( 0, (word)iValue, 255 );
break;
case 9:
if( bSigned ) iValue = bound( -255, (short)iValue, 256 );
else iValue = bound( 0, (word)iValue, 511 );
break;
case 10:
if( bSigned ) iValue = bound( -511, (short)iValue, 511 );
else iValue = bound( 0, (word)iValue, 1023 );
break;
case 11:
if( bSigned ) iValue = bound( -1023, (short)iValue, 1023 );
else iValue = bound( 0, (word)iValue, 2047 );
break;
case 12:
if( bSigned ) iValue = bound( -2047, (short)iValue, 2047 );
else iValue = bound( 0, (word)iValue, 4095 );
break;
case 13:
if( bSigned ) iValue = bound( -4095, (short)iValue, 4095 );
else iValue = bound( 0, (word)iValue, 8191 );
break;
case 14:
if( bSigned ) iValue = bound( -8191, (short)iValue, 8191 );
else iValue = bound( 0, (word)iValue, 16383 );
break;
case 15:
if( bSigned ) iValue = bound( -16383, (short)iValue, 16383 );
else iValue = bound( 0, (word)iValue, 32767 );
break;
case 16:
if( bSigned ) iValue = bound( -32767, (short)iValue, 32767 );
else iValue = bound( 0, (word)iValue, 65535 );
break;
}
return iValue; // clamped;
}
/*
=====================
Delta_WriteField
write fields by offsets
assume from and to is valid
TODO: write path for signed\unsigned
=====================
*/
qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, void *to, float timebase )
@ -1017,7 +1079,7 @@ qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, void *to
uint iValue;
const char *pStr;
if( Delta_CompareField( pField, from, to ))
if( Delta_CompareField( pField, from, to, timebase ))
{
BF_WriteOneBit( msg, 0 ); // unchanged
return false;
@ -1060,11 +1122,19 @@ qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, void *to
// result may be wrong on client-side
BF_WriteBitAngle( msg, flAngle, pField->bits );
}
else if( pField->flags & DT_TIMEWINDOW )
else if( pField->flags & DT_TIMEWINDOW_8 )
{
flValue = *(float *)((byte *)to + pField->offset );
flTime = ( timebase - flValue );
iValue = (uint)( flTime * 1000 );
flTime = (timebase * 100.0f) - (flValue * 100.0f);
iValue = (uint)flTime;
BF_WriteBitLong( msg, iValue, pField->bits, bSigned );
}
else if( pField->flags & DT_TIMEWINDOW_BIG )
{
flValue = *(float *)((byte *)to + pField->offset );
flTime = (timebase * 1000.0f) - (flValue * 1000.0f);
iValue = (uint)flTime;
BF_WriteBitLong( msg, iValue, pField->bits, bSigned );
}
@ -1162,7 +1232,21 @@ qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, void *from, void *to,
}
*(float *)((byte *)to + pField->offset ) = flAngle;
}
else if( pField->flags & DT_TIMEWINDOW )
else if( pField->flags & DT_TIMEWINDOW_8 )
{
if( bChanged )
{
iValue = BF_ReadBitLong( msg, pField->bits, bSigned );
flValue = (float)((int)(iValue * 0.01f ));
flTime = timebase + flValue;
}
else
{
flTime = *(float *)((byte *)from + pField->offset );
}
*(float *)((byte *)to + pField->offset ) = flTime;
}
else if( pField->flags & DT_TIMEWINDOW_BIG )
{
if( bChanged )
{

View File

@ -21,10 +21,10 @@ GNU General Public License for more details.
#define DT_FLOAT BIT( 2 ) // A floating point field
#define DT_INTEGER BIT( 3 ) // 4 byte integer
#define DT_ANGLE BIT( 4 ) // A floating point angle ( will get masked correctly )
#define DT_TIMEWINDOW BIT( 5 ) // A floating point timestamp, relative to sv.time
// and re-encoded on the client relative to the client's clock
#define DT_STRING BIT( 6 ) // A null terminated string, sent as 8 byte chars
#define DT_SIGNED BIT( 7 ) // sign modificator
#define DT_TIMEWINDOW_8 BIT( 5 ) // A floating point timestamp, relative to sv.time
#define DT_TIMEWINDOW_BIG BIT( 6 ) // and re-encoded on the client relative to the client's clock
#define DT_STRING BIT( 7 ) // A null terminated string, sent as 8 byte chars
#define DT_SIGNED BIT( 8 ) // sign modificator
#define offsetof( s, m ) (size_t)&(((s *)0)->m)
#define NUM_FIELDS( x ) ((sizeof( x ) / sizeof( x[0] )) - 1)