07 Jul 2010
This commit is contained in:
parent
3f1d4a8d2a
commit
9f9228adc4
|
@ -23,7 +23,6 @@ int com_buildnum( void )
|
|||
break;
|
||||
d += mond[m];
|
||||
}
|
||||
|
||||
d += com.atoi( &date[4] ) - 1;
|
||||
y = com.atoi( &date[7] ) - 1900;
|
||||
b = d + (int)((y - 1) * 365.25f );
|
||||
|
|
|
@ -15,7 +15,7 @@ bool Image_LoadBMP( const char *name, const byte *buffer, size_t filesize )
|
|||
byte *buf_p, *pixbuf;
|
||||
byte palette[256][4];
|
||||
int i, columns, column, rows, row, bpp = 1;
|
||||
int cbPalBytes = 0;
|
||||
int cbPalBytes = 0, padSize = 0;
|
||||
bmp_t bhdr;
|
||||
|
||||
if( filesize < sizeof( bhdr )) return false;
|
||||
|
@ -40,6 +40,7 @@ bool Image_LoadBMP( const char *name, const byte *buffer, size_t filesize )
|
|||
|
||||
// bogus file header check
|
||||
if( bhdr.reserved0 != 0 ) return false;
|
||||
if( bhdr.planes != 1 ) return false;
|
||||
|
||||
if( memcmp( bhdr.id, "BM", 2 ))
|
||||
{
|
||||
|
@ -47,6 +48,12 @@ bool Image_LoadBMP( const char *name, const byte *buffer, size_t filesize )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( bhdr.bitmapHeaderSize != 0x28 )
|
||||
{
|
||||
MsgDev( D_ERROR, "Image_LoadBMP: invalid header size %i\n", bhdr.bitmapHeaderSize );
|
||||
return false;
|
||||
}
|
||||
|
||||
// bogus info header check
|
||||
if( bhdr.fileSize != filesize )
|
||||
{
|
||||
|
@ -54,13 +61,6 @@ bool Image_LoadBMP( const char *name, const byte *buffer, size_t filesize )
|
|||
return false;
|
||||
}
|
||||
|
||||
// bogus bit depth?
|
||||
if( bhdr.bitsPerPixel < 8 )
|
||||
{
|
||||
MsgDev( D_ERROR, "Image_LoadBMP: monochrome and 4-bit BMP files not supported (%s)\n", name );
|
||||
return false;
|
||||
}
|
||||
|
||||
// bogus compression? Only non-compressed supported.
|
||||
if( bhdr.compression != BI_RGB )
|
||||
{
|
||||
|
@ -68,15 +68,13 @@ bool Image_LoadBMP( const char *name, const byte *buffer, size_t filesize )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( bhdr.bitsPerPixel == 8 )
|
||||
image.width = columns = (bhdr.width + 3) & ~3;
|
||||
else image.width = columns = bhdr.width;
|
||||
image.height = rows = (bhdr.height < 0 ) ? -bhdr.height : bhdr.height;
|
||||
image.width = columns = bhdr.width;
|
||||
image.height = rows = abs( bhdr.height );
|
||||
|
||||
if(!Image_ValidSize( name ))
|
||||
return false;
|
||||
|
||||
if( bhdr.bitsPerPixel == 8 )
|
||||
if( bhdr.bitsPerPixel <= 8 )
|
||||
{
|
||||
// figure out how many entires are actually in the table
|
||||
if( bhdr.colors == 0 )
|
||||
|
@ -113,8 +111,25 @@ bool Image_LoadBMP( const char *name, const byte *buffer, size_t filesize )
|
|||
|
||||
buf_p += cbPalBytes;
|
||||
image.size = image.width * image.height * bpp;
|
||||
// image.size = ((buffer + filesize) - buf_p) * bpp;
|
||||
image.rgba = Mem_Alloc( Sys.imagepool, image.size );
|
||||
image.bps = image.width * (bhdr.bitsPerPixel >> 3);
|
||||
|
||||
switch( bhdr.bitsPerPixel )
|
||||
{
|
||||
case 1:
|
||||
padSize = (( 32 - ( bhdr.width % 32 )) / 8 ) % 4;
|
||||
break;
|
||||
case 4:
|
||||
padSize = (( 8 - ( bhdr.width % 8 )) / 2 ) % 4;
|
||||
break;
|
||||
case 16:
|
||||
padSize = ( 4 - ( image.width * 2 % 4 )) % 4;
|
||||
break;
|
||||
case 8:
|
||||
case 24:
|
||||
padSize = ( 4 - ( image.bps % 4 )) % 4;
|
||||
break;
|
||||
}
|
||||
|
||||
for( row = rows - 1; row >= 0; row-- )
|
||||
{
|
||||
|
@ -123,18 +138,46 @@ bool Image_LoadBMP( const char *name, const byte *buffer, size_t filesize )
|
|||
for( column = 0; column < columns; column++ )
|
||||
{
|
||||
byte red, green, blue, alpha;
|
||||
int palIndex;
|
||||
word shortPixel;
|
||||
int c, k, palIndex;
|
||||
|
||||
switch( bhdr.bitsPerPixel )
|
||||
{
|
||||
case 1:
|
||||
alpha = *buf_p++;
|
||||
column--; // ingnore main iterations
|
||||
for( c = 0, k = 128; c < 8; c++, k >>= 1 )
|
||||
{
|
||||
red = (!!(alpha & k) == 1 ? 0xFF : 0x00);
|
||||
*pixbuf++ = red;
|
||||
*pixbuf++ = red;
|
||||
*pixbuf++ = red;
|
||||
*pixbuf++ = 0x00;
|
||||
if( ++column == columns )
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
alpha = *buf_p++;
|
||||
palIndex = alpha >> 4;
|
||||
*pixbuf++ = palette[palIndex][2];
|
||||
*pixbuf++ = palette[palIndex][1];
|
||||
*pixbuf++ = palette[palIndex][0];
|
||||
*pixbuf++ = palette[palIndex][3];
|
||||
if( ++column == columns ) break;
|
||||
palIndex = alpha & 0x0F;
|
||||
*pixbuf++ = palette[palIndex][2];
|
||||
*pixbuf++ = palette[palIndex][1];
|
||||
*pixbuf++ = palette[palIndex][0];
|
||||
*pixbuf++ = palette[palIndex][3];
|
||||
break;
|
||||
case 8:
|
||||
palIndex = *buf_p++;
|
||||
red = palette[palIndex][2];
|
||||
green = palette[palIndex][1];
|
||||
blue = palette[palIndex][0];
|
||||
alpha = palette[palIndex][3];
|
||||
|
||||
|
||||
if( image.cmd_flags & IL_KEEP_8BIT )
|
||||
{
|
||||
*pixbuf++ = palIndex;
|
||||
|
@ -183,6 +226,7 @@ bool Image_LoadBMP( const char *name, const byte *buffer, size_t filesize )
|
|||
if(!( image.cmd_flags & IL_KEEP_8BIT ) && ( red != green || green != blue ))
|
||||
image.flags |= IMAGE_HAS_COLOR;
|
||||
}
|
||||
buf_p += padSize; // actual only for 4-bit bmps
|
||||
}
|
||||
|
||||
image.depth = image.num_mips = 1;
|
||||
|
|
|
@ -221,60 +221,67 @@ int com_atoi(const char *str)
|
|||
|
||||
if( !str ) return 0;
|
||||
|
||||
if(*str == '-')
|
||||
if( *str == '-' )
|
||||
{
|
||||
sign = -1;
|
||||
str++;
|
||||
}
|
||||
else sign = 1;
|
||||
|
||||
// check for empty charachters in string
|
||||
while( *str == ' ' && str ) str++;
|
||||
|
||||
// check for hex
|
||||
if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X') )
|
||||
if( str[0] == '0' && ( str[1] == 'x' || str[1] == 'X' ))
|
||||
{
|
||||
str += 2;
|
||||
while(1)
|
||||
while( 1 )
|
||||
{
|
||||
c = *str++;
|
||||
if (c >= '0' && c <= '9') val = (val<<4) + c - '0';
|
||||
else if (c >= 'a' && c <= 'f') val = (val<<4) + c - 'a' + 10;
|
||||
else if (c >= 'A' && c <= 'F') val = (val<<4) + c - 'A' + 10;
|
||||
if( c >= '0' && c <= '9' ) val = (val<<4) + c - '0';
|
||||
else if( c >= 'a' && c <= 'f' ) val = (val<<4) + c - 'a' + 10;
|
||||
else if( c >= 'A' && c <= 'F' ) val = (val<<4) + c - 'A' + 10;
|
||||
else return val * sign;
|
||||
}
|
||||
}
|
||||
|
||||
// check for character
|
||||
if (str[0] == '\'') return sign * str[1];
|
||||
if( str[0] == '\'' )
|
||||
return sign * str[1];
|
||||
|
||||
// assume decimal
|
||||
while (1)
|
||||
while( 1 )
|
||||
{
|
||||
c = *str++;
|
||||
if (c <'0' || c > '9')
|
||||
if( c < '0' || c > '9' )
|
||||
return val * sign;
|
||||
val = val*10 + c - '0';
|
||||
val = val * 10 + c - '0';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
float com_atof(const char *str)
|
||||
float com_atof( const char *str )
|
||||
{
|
||||
double val = 0;
|
||||
int c, sign, decimal, total;
|
||||
|
||||
if( !str ) return 0.0f;
|
||||
|
||||
if (*str == '-')
|
||||
if( *str == '-' )
|
||||
{
|
||||
sign = -1;
|
||||
str++;
|
||||
}
|
||||
else sign = 1;
|
||||
|
||||
// check for empty charachters in string
|
||||
while( *str == ' ' && str ) str++;
|
||||
|
||||
// check for hex
|
||||
if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
|
||||
if( str[0] == '0' && ( str[1] == 'x' || str[1] == 'X' ))
|
||||
{
|
||||
str += 2;
|
||||
while (1)
|
||||
while( 1 )
|
||||
{
|
||||
c = *str++;
|
||||
if (c >= '0' && c <= '9') val = (val * 16) + c - '0';
|
||||
|
|
18
todo.log
18
todo.log
|
@ -20,18 +20,8 @@ fopen
|
|||
1. Поддержка loop для ogg vorbis
|
||||
2. переписать studiomdl для использования VFS
|
||||
|
||||
Xash 0.72 Beta 5.07.10
|
||||
Xash 13.12.2010 first stable version!
|
||||
|
||||
1.game interface - new revision OK
|
||||
2.clgame interface - new revision OK
|
||||
3.entity_state - new revision OK
|
||||
4.rework dlights OK
|
||||
5.rework decals OK
|
||||
6.batch drawing decals OK
|
||||
7.draw lightmapped decals OK
|
||||
8.draw decals on bmodels OK
|
||||
9.implement save\restore for decals OK
|
||||
10.create animated decals OK
|
||||
11.fix external shader lighting bug OK
|
||||
12.revision resources
|
||||
13.implement the sv_lightpoint OK
|
||||
1. Выбросить всё лишнее из кода.
|
||||
2. Отключить удаленный запуск по переменной окружения
|
||||
3. Переписать утилиты в отдельные приложения
|
||||
|
|
|
@ -1059,14 +1059,14 @@ void ResizeTexture( s_texture_t *ptexture )
|
|||
// dword alignment for each scan
|
||||
ptexture->skintop = ptexture->min_t;
|
||||
ptexture->skinleft = ptexture->min_s;
|
||||
ptexture->skinwidth = (int)((ptexture->max_s - ptexture->min_s) + 1 + 3) & ~3;
|
||||
ptexture->skinwidth = (int)(ptexture->max_s - ptexture->min_s) + 1;
|
||||
ptexture->skinheight = (int)(ptexture->max_t - ptexture->min_t) + 1;
|
||||
ptexture->size = ptexture->skinwidth * ptexture->skinheight + 256 * 3;
|
||||
percent = ((ptexture->skinwidth * ptexture->skinheight) / (float)(ptexture->srcwidth * ptexture->srcheight)) * 100.0f;
|
||||
|
||||
Msg("BMP %s [%d %d] (%.0f%%) %6s\n", ptexture->name, ptexture->skinwidth, ptexture->skinheight, percent, memprint( ptexture->size ));
|
||||
|
||||
if( ptexture->size > 1536 * 1536)
|
||||
if( ptexture->size > 1536 * 1536 )
|
||||
{
|
||||
Msg("%g %g %g %g\n", ptexture->min_s, ptexture->max_s, ptexture->min_t, ptexture->max_t );
|
||||
Sys_Break("texture too large\n");
|
||||
|
@ -1076,18 +1076,18 @@ void ResizeTexture( s_texture_t *ptexture )
|
|||
ptexture->pdata = pdest;
|
||||
|
||||
// data is saved as a multiple of 4
|
||||
srcadjwidth = (ptexture->srcwidth + 3) & ~3;
|
||||
srcadjwidth = ptexture->srcwidth;
|
||||
|
||||
// move the picture data to the model area, replicating missing data, deleting unused data.
|
||||
for (i = 0, t = ptexture->srcheight - ptexture->skinheight - ptexture->skintop + 10 * ptexture->srcheight; i < ptexture->skinheight; i++, t++)
|
||||
for( i = 0, t = ptexture->srcheight - ptexture->skinheight - ptexture->skintop + 10 * ptexture->srcheight; i < ptexture->skinheight; i++, t++ )
|
||||
{
|
||||
while (t >= ptexture->srcheight) t -= ptexture->srcheight;
|
||||
while (t < 0) t += ptexture->srcheight;
|
||||
while( t >= ptexture->srcheight ) t -= ptexture->srcheight;
|
||||
while( t < 0 ) t += ptexture->srcheight;
|
||||
|
||||
for (j = 0, s = ptexture->skinleft + 10 * ptexture->srcwidth; j < ptexture->skinwidth; j++, s++)
|
||||
for( j = 0, s = ptexture->skinleft + 10 * ptexture->srcwidth; j < ptexture->skinwidth; j++, s++ )
|
||||
{
|
||||
while (s >= ptexture->srcwidth) s -= ptexture->srcwidth;
|
||||
*(pdest++) = *(ptexture->ppicture + s + t * srcadjwidth);
|
||||
while( s >= ptexture->srcwidth ) s -= ptexture->srcwidth;
|
||||
*(pdest++) = *( ptexture->ppicture + s + t * srcadjwidth );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue