22 Nov 2010
This commit is contained in:
parent
15138ca306
commit
50e48e3740
|
@ -9,7 +9,6 @@ debug.bat
|
|||
backup.lst
|
||||
backup.bat
|
||||
release.bat
|
||||
launchers.bat
|
||||
change.log
|
||||
|
||||
cl_dll\
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
typedef float vec_t;
|
||||
typedef vec_t vec4_t[4];
|
||||
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
#include "util_vector.h"
|
||||
|
|
|
@ -19,9 +19,13 @@
|
|||
// surface flags
|
||||
#define SURF_PLANEBACK BIT( 0 )
|
||||
|
||||
#define CONTENTS_NODE 1 // fake contents to determine nodes
|
||||
#define ZISCALE ((float)0x8000)
|
||||
|
||||
#define MIPLEVELS 4
|
||||
#define VERTEXSIZE 7
|
||||
#define MAXLIGHTMAPS 4
|
||||
#define NUM_AMBIENTS 4 // automatic ambient sounds
|
||||
|
||||
// model types
|
||||
typedef enum
|
||||
{
|
||||
|
@ -32,14 +36,6 @@ typedef enum
|
|||
mod_studio
|
||||
} modtype_t;
|
||||
|
||||
typedef struct alight_s
|
||||
{
|
||||
int ambientlight; // clip at 128
|
||||
int shadelight; // clip at 192 - ambientlight
|
||||
vec3_t color;
|
||||
float *plightvec;
|
||||
} alight_t;
|
||||
|
||||
typedef struct mplane_s
|
||||
{
|
||||
vec3_t normal;
|
||||
|
@ -49,6 +45,137 @@ typedef struct mplane_s
|
|||
byte pad[2];
|
||||
} mplane_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t position;
|
||||
} mvertex_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short v[2];
|
||||
unsigned int cachededgeoffset;
|
||||
} medge_t;
|
||||
|
||||
typedef struct texture_s
|
||||
{
|
||||
char name[16];
|
||||
unsigned int width, height;
|
||||
int gl_texturenum;
|
||||
struct msurface_s *texturechain; // for gl_texsort drawing
|
||||
int anim_total; // total tenths in sequence ( 0 = no)
|
||||
int anim_min, anim_max; // time for this frame min <=time< max
|
||||
struct texture_s *anim_next; // in the animation sequence
|
||||
struct texture_s *alternate_anims; // bmodels in frmae 1 use these
|
||||
unsigned int offsets[MIPLEVELS]; // four mip maps stored
|
||||
} texture_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float vecs[2][4]; // [s/t] unit vectors in world space.
|
||||
// [i][3] is the s/t offset relative to the origin.
|
||||
// s or t = dot(3Dpoint,vecs[i])+vecs[i][3]
|
||||
float mipadjust; // mipmap limits for very small surfaces
|
||||
texture_t *texture;
|
||||
int flags; // sky or slime, no lightmap or 256 subdivision
|
||||
} mtexinfo_t;
|
||||
|
||||
typedef struct glpoly_s
|
||||
{
|
||||
struct glpoly_s *next;
|
||||
struct glpoly_s *chain;
|
||||
int numverts;
|
||||
int flags; // for SURF_UNDERWATER
|
||||
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
|
||||
} glpoly_t;
|
||||
|
||||
typedef struct mnode_s
|
||||
{
|
||||
// common with leaf
|
||||
int contents; // 0, to differentiate from leafs
|
||||
int visframe; // node needs to be traversed if current
|
||||
|
||||
float minmaxs[6]; // for bounding box culling
|
||||
struct mnode_s *parent;
|
||||
|
||||
// node specific
|
||||
mplane_t *plane;
|
||||
struct mnode_s *children[2];
|
||||
|
||||
unsigned short firstsurface;
|
||||
unsigned short numsurfaces;
|
||||
} mnode_t;
|
||||
|
||||
typedef struct msurface_s msurface_t;
|
||||
typedef struct decal_s decal_t;
|
||||
|
||||
// JAY: Compress this as much as possible
|
||||
struct decal_s
|
||||
{
|
||||
decal_t *pnext; // linked list for each surface
|
||||
msurface_t *psurface; // Surface id for persistence / unlinking
|
||||
short dx; // Offsets into surface texture
|
||||
short dy; // (in texture coordinates, so we don't need floats)
|
||||
short texture; // Decal texture
|
||||
byte scale; // Pixel scale
|
||||
byte flags; // Decal flags
|
||||
|
||||
short entityIndex; // Entity this is attached to
|
||||
};
|
||||
|
||||
typedef struct mleaf_s
|
||||
{
|
||||
// common with node
|
||||
int contents;
|
||||
int visframe; // node needs to be traversed if current
|
||||
|
||||
float minmaxs[6]; // for bounding box culling
|
||||
|
||||
struct mnode_s *parent;
|
||||
// leaf specific
|
||||
byte *visdata; // decompressed visdata after loading
|
||||
byte *pasdata; // decompressed pasdata after loading (was efrags)
|
||||
|
||||
msurface_t **firstmarksurface;
|
||||
int nummarksurfaces;
|
||||
int key; // BSP sequence number for leaf's contents
|
||||
byte ambient_sound_level[NUM_AMBIENTS];
|
||||
|
||||
} mleaf_t;
|
||||
|
||||
typedef struct msurface_s
|
||||
{
|
||||
int visframe; // should be drawn when node is crossed
|
||||
|
||||
mplane_t *plane; // pointer to shared plane
|
||||
int flags; // see SURF_ #defines
|
||||
|
||||
int firstedge; // look up in model->surfedges[], negative numbers
|
||||
int numedges; // are backwards edges
|
||||
|
||||
short texturemins[2];
|
||||
short extents[2];
|
||||
|
||||
int light_s, light_t; // gl lightmap coordinates
|
||||
|
||||
glpoly_t *polys; // multiple if warped
|
||||
struct msurface_s *texturechain;
|
||||
|
||||
mtexinfo_t *texinfo;
|
||||
|
||||
// lighting info
|
||||
int dlightframe; // last frame the surface was checked by an animated light
|
||||
int dlightbits; // dynamically generated. Indicates if the surface illumination
|
||||
// is modified by an animated light.
|
||||
|
||||
int lightmaptexturenum;
|
||||
byte styles[MAXLIGHTMAPS];
|
||||
int cached_light[MAXLIGHTMAPS]; // values currently used in lightmap
|
||||
qboolean cached_dlight; // true if dynamic light in cache
|
||||
|
||||
color24 *samples; // note: this is the actual lightmap data for this surface
|
||||
decal_t *pdecals;
|
||||
} msurface_t;
|
||||
|
||||
typedef struct hull_s
|
||||
{
|
||||
dclipnode_t *clipnodes;
|
||||
|
@ -59,72 +186,13 @@ typedef struct hull_s
|
|||
vec3_t clip_maxs;
|
||||
} hull_t;
|
||||
|
||||
typedef struct
|
||||
#ifndef CACHE_USER
|
||||
#define CACHE_USER
|
||||
typedef struct cache_user_s
|
||||
{
|
||||
char name[16];
|
||||
int contents;
|
||||
|
||||
// put here info about fog color and density ?
|
||||
} mtexture_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float vecs[2][4];
|
||||
mtexture_t *texture;
|
||||
int flags; // texture flags
|
||||
} mtexinfo_t;
|
||||
|
||||
typedef struct msurface_s
|
||||
{
|
||||
mplane_t *plane; // pointer to shared plane
|
||||
int flags; // see SURF_ #defines
|
||||
|
||||
int firstedge; // look up in model->surfedges[], negative numbers
|
||||
int numedges; // are backwards edges
|
||||
|
||||
mtexinfo_t *texinfo;
|
||||
|
||||
short texturemins[2];
|
||||
short extents[2];
|
||||
|
||||
// lighting info
|
||||
byte *samples; // [numstyles*surfsize]
|
||||
int numstyles;
|
||||
byte styles[4]; // index into d_lightstylevalue[] for animated lights
|
||||
// no one surface can be effected by more than 4
|
||||
// animated lights.
|
||||
} msurface_t;
|
||||
|
||||
typedef struct mleaf_s
|
||||
{
|
||||
// common with node
|
||||
int contents;
|
||||
struct mnode_s *parent;
|
||||
mplane_t *plane; // always == NULL
|
||||
|
||||
// leaf specific
|
||||
byte *visdata; // decompressed visdata after loading
|
||||
byte *pasdata; // decompressed pasdata after loading
|
||||
byte ambient_sound_level[NUM_AMBIENTS];
|
||||
struct efrag_s *efrags;
|
||||
|
||||
msurface_t **firstmarksurface;
|
||||
int nummarksurfaces;
|
||||
} mleaf_t;
|
||||
|
||||
typedef struct mnode_s
|
||||
{
|
||||
// common with leaf
|
||||
int contents; // CONTENTS_NODE, to differentiate from leafs
|
||||
struct mnode_s *parent;
|
||||
mplane_t *plane; // always != NULL
|
||||
|
||||
// node specific
|
||||
struct mnode_s *children[2];
|
||||
|
||||
msurface_t *firstface; // used for grab lighting info, decals etc
|
||||
unsigned int numfaces;
|
||||
} mnode_t;
|
||||
void *data; // extradata
|
||||
} cache_user_t;
|
||||
#endif
|
||||
|
||||
typedef struct model_s
|
||||
{
|
||||
|
@ -136,7 +204,12 @@ typedef struct model_s
|
|||
int numframes; // sprite's framecount
|
||||
byte *mempool; // private mempool (was synctype)
|
||||
int flags; // hl compatibility
|
||||
|
||||
//
|
||||
// volume occupied by the model
|
||||
//
|
||||
vec3_t mins, maxs; // bounding box at angles '0 0 0'
|
||||
float radius;
|
||||
|
||||
// brush model
|
||||
int firstmodelsurface;
|
||||
|
@ -152,10 +225,10 @@ typedef struct model_s
|
|||
mleaf_t *leafs;
|
||||
|
||||
int numvertexes;
|
||||
vec3_t *vertexes;
|
||||
mvertex_t *vertexes;
|
||||
|
||||
int numedges;
|
||||
dedge_t *edges;
|
||||
medge_t *edges;
|
||||
|
||||
int numnodes;
|
||||
mnode_t *nodes;
|
||||
|
@ -178,12 +251,31 @@ typedef struct model_s
|
|||
hull_t hulls[MAX_MAP_HULLS];
|
||||
|
||||
int numtextures;
|
||||
mtexture_t **textures;
|
||||
texture_t **textures;
|
||||
|
||||
byte *lightdata; // for GetEntityIllum
|
||||
byte *extradata; // models extradata
|
||||
byte *visdata;
|
||||
|
||||
color24 *lightdata;
|
||||
char *entities;
|
||||
//
|
||||
// additional model data
|
||||
//
|
||||
cache_user_t cache; // only access through Mod_Extradata
|
||||
} model_t;
|
||||
|
||||
typedef vec_t vec4_t[4];
|
||||
|
||||
typedef struct alight_s
|
||||
{
|
||||
int ambientlight; // clip at 128
|
||||
int shadelight; // clip at 192 - ambientlight
|
||||
vec3_t color;
|
||||
float *plightvec;
|
||||
} alight_t;
|
||||
|
||||
typedef struct auxvert_s
|
||||
{
|
||||
float fv[3]; // viewspace x, y
|
||||
} auxvert_t;
|
||||
|
||||
#endif//COM_MODEL_H
|
|
@ -555,7 +555,7 @@ void CL_DrawRing( int modelIndex, float frame, int rendermode, const vec3_t sour
|
|||
VectorSubtract( center, last1, screen );
|
||||
|
||||
// Is that box in PVS && frustum?
|
||||
if( !CM_BoxVisible( screen, tmp, re->GetCurrentVis( )) || re->CullBox( screen, tmp ))
|
||||
if( !Mod_BoxVisible( screen, tmp, re->GetCurrentVis( )) || re->CullBox( screen, tmp ))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1083,7 +1083,7 @@ qboolean CL_CullBeam( const vec3_t start, const vec3_t end, qboolean pvsOnly )
|
|||
}
|
||||
|
||||
// check bbox
|
||||
if( CM_BoxVisible( mins, maxs, re->GetCurrentVis( )))
|
||||
if( Mod_BoxVisible( mins, maxs, re->GetCurrentVis( )))
|
||||
{
|
||||
if( pvsOnly || !re->CullBox( mins, maxs ))
|
||||
{
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "client.h"
|
||||
#include "byteorder.h"
|
||||
#include "net_encode.h"
|
||||
|
||||
#define dem_cmd 0
|
||||
|
@ -26,7 +25,7 @@ void CL_WriteDemoCmd( usercmd_t *pcmd )
|
|||
usercmd_t cmd;
|
||||
byte c;
|
||||
|
||||
fl = LittleFloat(( float )host.realtime );
|
||||
fl = ( float )host.realtime;
|
||||
FS_Write( cls.demofile, &fl, sizeof( fl ));
|
||||
|
||||
c = dem_cmd;
|
||||
|
@ -34,32 +33,11 @@ void CL_WriteDemoCmd( usercmd_t *pcmd )
|
|||
|
||||
// correct for byte order, bytes don't matter
|
||||
cmd = *pcmd;
|
||||
|
||||
cmd.lerp_msec = LittleShort( cmd.lerp_msec );
|
||||
cmd.msec = LittleLong( cmd.msec );
|
||||
|
||||
// byte order stuff
|
||||
for( i = 0; i < 3; i++ )
|
||||
cmd.viewangles[i] = LittleFloat( cmd.viewangles[i] );
|
||||
|
||||
cmd.forwardmove = LittleFloat( cmd.forwardmove );
|
||||
cmd.sidemove = LittleFloat( cmd.sidemove );
|
||||
cmd.upmove = LittleFloat( cmd.upmove );
|
||||
cmd.lightlevel = LittleLong( cmd.lightlevel );
|
||||
cmd.buttons = LittleLong( cmd.buttons );
|
||||
cmd.impulse = LittleLong( cmd.impulse );
|
||||
cmd.weaponselect = LittleLong( cmd.weaponselect );
|
||||
cmd.impact_index = LittleLong( cmd.impact_index );
|
||||
|
||||
cmd.impact_position[0] = LittleFloat( cmd.impact_position[0] );
|
||||
cmd.impact_position[1] = LittleFloat( cmd.impact_position[1] );
|
||||
cmd.impact_position[2] = LittleFloat( cmd.impact_position[2] );
|
||||
|
||||
FS_Write( cls.demofile, &cmd, sizeof( cmd ));
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
fl = LittleFloat( cl.refdef.cl_viewangles[i] );
|
||||
fl = cl.refdef.cl_viewangles[i];
|
||||
FS_Write( cls.demofile, &fl, sizeof( fl ));
|
||||
}
|
||||
}
|
||||
|
@ -73,19 +51,18 @@ Dumps the current net message, prefixed by the length
|
|||
*/
|
||||
void CL_WriteDemoMessage( sizebuf_t *msg, int head_size )
|
||||
{
|
||||
int len, swlen;
|
||||
int swlen;
|
||||
|
||||
if( !cls.demofile ) return;
|
||||
if( cl.refdef.paused || cls.key_dest == key_menu )
|
||||
return;
|
||||
|
||||
// the first eight bytes are just packet sequencing stuff
|
||||
len = BF_GetNumBytesWritten( msg ) - head_size;
|
||||
swlen = LittleLong( len );
|
||||
swlen = BF_GetNumBytesWritten( msg ) - head_size;
|
||||
|
||||
if( !swlen ) return; // ignore null messages
|
||||
FS_Write( cls.demofile, &swlen, 4 );
|
||||
FS_Write( cls.demofile, BF_GetData( msg ) + head_size, len );
|
||||
FS_Write( cls.demofile, BF_GetData( msg ) + head_size, swlen );
|
||||
}
|
||||
|
||||
void CL_WriteDemoHeader( const char *name )
|
||||
|
@ -136,7 +113,7 @@ void CL_WriteDemoHeader( const char *name )
|
|||
if( BF_GetNumBytesWritten( &buf ) > ( BF_GetMaxBytes( &buf ) / 2 ))
|
||||
{
|
||||
// write it out
|
||||
len = LittleLong( BF_GetNumBytesWritten( &buf ));
|
||||
len = BF_GetNumBytesWritten( &buf );
|
||||
FS_Write( cls.demofile, &len, 4 );
|
||||
FS_Write( cls.demofile, BF_GetData( &buf ), len );
|
||||
BF_Clear( &buf );
|
||||
|
@ -157,7 +134,7 @@ void CL_WriteDemoHeader( const char *name )
|
|||
if( BF_GetNumBytesWritten( &buf ) > ( BF_GetMaxBytes( &buf ) / 2 ))
|
||||
{
|
||||
// write it out
|
||||
len = LittleLong( BF_GetNumBytesWritten( &buf ));
|
||||
len = BF_GetNumBytesWritten( &buf );
|
||||
FS_Write( cls.demofile, &len, 4 );
|
||||
FS_Write( cls.demofile, BF_GetData( &buf ), len );
|
||||
BF_Clear( &buf );
|
||||
|
@ -183,7 +160,7 @@ void CL_WriteDemoHeader( const char *name )
|
|||
if( BF_GetNumBytesWritten( &buf ) > ( BF_GetMaxBytes( &buf ) / 2 ))
|
||||
{
|
||||
// write it out
|
||||
len = LittleLong( BF_GetNumBytesWritten( &buf ));
|
||||
len = BF_GetNumBytesWritten( &buf );
|
||||
FS_Write( cls.demofile, &len, 4 );
|
||||
FS_Write( cls.demofile, BF_GetData( &buf ), len );
|
||||
BF_Clear( &buf );
|
||||
|
@ -216,7 +193,7 @@ void CL_WriteDemoHeader( const char *name )
|
|||
MSG_WriteDeltaMovevars( &buf, &nullmovevars, &clgame.movevars );
|
||||
|
||||
// write it to the demo file
|
||||
len = LittleLong( BF_GetNumBytesWritten( &buf ));
|
||||
len = BF_GetNumBytesWritten( &buf );
|
||||
FS_Write( cls.demofile, &len, 4 );
|
||||
FS_Write( cls.demofile, BF_GetData( &buf ), len );
|
||||
|
||||
|
@ -336,7 +313,6 @@ void CL_ReadDemoMessage( void )
|
|||
return;
|
||||
}
|
||||
|
||||
curSize = LittleLong( curSize );
|
||||
if( curSize == -1 )
|
||||
{
|
||||
CL_DemoCompleted();
|
||||
|
@ -437,8 +413,6 @@ qboolean CL_GetComment( const char *demoname, char *comment )
|
|||
return false;
|
||||
}
|
||||
|
||||
curSize = LittleLong( curSize );
|
||||
|
||||
if( curSize == -1 )
|
||||
{
|
||||
FS_Close( demfile );
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "client.h"
|
||||
#include "byteorder.h"
|
||||
#include "matrix_lib.h"
|
||||
#include "const.h"
|
||||
#include "triangleapi.h"
|
||||
|
@ -2576,7 +2575,7 @@ pfnBoxVisible
|
|||
static qboolean pfnBoxVisible( const vec3_t mins, const vec3_t maxs )
|
||||
{
|
||||
if( !re ) return false;
|
||||
return CM_BoxVisible( mins, maxs, re->GetCurrentVis());
|
||||
return Mod_BoxVisible( mins, maxs, re->GetCurrentVis());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3697,7 +3696,7 @@ qboolean CL_LoadProgs( const char *name )
|
|||
|
||||
clgame.hInstance = FS_LoadLibrary( name, false );
|
||||
if( !clgame.hInstance ) return false;
|
||||
Msg( "exports size %i\n", sizeof( HUD_FUNCTIONS ));
|
||||
|
||||
// clear exports
|
||||
for( func = cdll_exports; func && func->name; func++ )
|
||||
*func->func = NULL;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "client.h"
|
||||
#include "byteorder.h"
|
||||
#include "net_encode.h"
|
||||
#include "cl_tent.h"
|
||||
#include "input.h"
|
||||
|
@ -583,7 +582,7 @@ void CL_SendConnectPacket( void )
|
|||
return;
|
||||
}
|
||||
|
||||
if( adr.port == 0 ) adr.port = BigShort( PORT_SERVER );
|
||||
if( adr.port == 0 ) adr.port = BF_BigShort( PORT_SERVER );
|
||||
port = Cvar_VariableValue( "net_qport" );
|
||||
|
||||
userinfo->modified = false;
|
||||
|
@ -625,7 +624,7 @@ void CL_CheckForResend( void )
|
|||
return;
|
||||
}
|
||||
|
||||
if( adr.port == 0 ) adr.port = BigShort( PORT_SERVER );
|
||||
if( adr.port == 0 ) adr.port = BF_BigShort( PORT_SERVER );
|
||||
cls.connect_time = host.realtime; // for retransmit requests
|
||||
|
||||
MsgDev( D_NOTE, "Connecting to %s...\n", cls.servername );
|
||||
|
@ -719,7 +718,7 @@ void CL_Rcon_f( void )
|
|||
}
|
||||
|
||||
NET_StringToAdr( rcon_address->string, &to );
|
||||
if( to.port == 0 ) to.port = BigShort( PORT_SERVER );
|
||||
if( to.port == 0 ) to.port = BF_BigShort( PORT_SERVER );
|
||||
}
|
||||
|
||||
NET_SendPacket( NS_CLIENT, com.strlen( message ) + 1, message, to );
|
||||
|
@ -864,7 +863,7 @@ void CL_LocalServers_f( void )
|
|||
|
||||
// send a broadcast packet
|
||||
adr.type = NA_BROADCAST;
|
||||
adr.port = BigShort( PORT_SERVER );
|
||||
adr.port = BF_BigShort( PORT_SERVER );
|
||||
|
||||
Netchan_OutOfBandPrint( NS_CLIENT, adr, "info %i", PROTOCOL_VERSION );
|
||||
}
|
||||
|
@ -899,7 +898,7 @@ void CL_Packet_f( void )
|
|||
return;
|
||||
}
|
||||
|
||||
if( !adr.port ) adr.port = BigShort( PORT_SERVER );
|
||||
if( !adr.port ) adr.port = BF_BigShort( PORT_SERVER );
|
||||
|
||||
in = Cmd_Argv( 2 );
|
||||
out = send + 4;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "client.h"
|
||||
#include "byteorder.h"
|
||||
#include "qfont.h"
|
||||
|
||||
convar_t *scr_viewsize;
|
||||
|
@ -286,16 +285,16 @@ static void SCR_LoadCreditsFont( void )
|
|||
int i;
|
||||
|
||||
src = (qfont_t *)buffer;
|
||||
clgame.scrInfo.iCharHeight = LittleLong( src->rowheight );
|
||||
clgame.scrInfo.iCharHeight = src->rowheight;
|
||||
|
||||
// build rectangles
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
cls.creditsFont.fontRc[i].left = LittleShort( (word)src->fontinfo[i].startoffset ) % fontWidth;
|
||||
cls.creditsFont.fontRc[i].right = cls.creditsFont.fontRc[i].left + LittleShort( src->fontinfo[i].charwidth );
|
||||
cls.creditsFont.fontRc[i].top = LittleShort( (word)src->fontinfo[i].startoffset ) / fontWidth;
|
||||
cls.creditsFont.fontRc[i].bottom = cls.creditsFont.fontRc[i].top + LittleLong( src->rowheight );
|
||||
clgame.scrInfo.charWidths[i] = LittleLong( src->fontinfo[i].charwidth );
|
||||
cls.creditsFont.fontRc[i].left = (word)src->fontinfo[i].startoffset % fontWidth;
|
||||
cls.creditsFont.fontRc[i].right = cls.creditsFont.fontRc[i].left + src->fontinfo[i].charwidth;
|
||||
cls.creditsFont.fontRc[i].top = (word)src->fontinfo[i].startoffset / fontWidth;
|
||||
cls.creditsFont.fontRc[i].bottom = cls.creditsFont.fontRc[i].top + src->rowheight;
|
||||
clgame.scrInfo.charWidths[i] = src->fontinfo[i].charwidth;
|
||||
}
|
||||
cls.creditsFont.valid = true;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "client.h"
|
||||
#include "byteorder.h"
|
||||
#include "matrix_lib.h"
|
||||
#include "const.h"
|
||||
#include "r_studioint.h"
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "sound.h"
|
||||
#include "byteorder.h"
|
||||
|
||||
// during registration it is possible to have more sounds
|
||||
// than could actually be referenced during gameplay,
|
||||
|
|
|
@ -861,14 +861,14 @@ void S_Music_f( void )
|
|||
else if( c == 2 )
|
||||
{
|
||||
string intro, main, track;
|
||||
char *ext[] = { "wav", "mp3", "ogg" };
|
||||
char *ext[] = { "wav", "mp3" };
|
||||
int i;
|
||||
|
||||
com.strncpy( track, Cmd_Argv( 1 ), sizeof( track ));
|
||||
com.snprintf( intro, sizeof( intro ), "%s_intro", Cmd_Argv( 1 ));
|
||||
com.snprintf( main, sizeof( main ), "%s_main", Cmd_Argv( 1 ));
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
for( i = 0; i < 2; i++ )
|
||||
{
|
||||
if( FS_FileExists( va( "media/%s.%s", intro, ext[i] ))
|
||||
&& FS_FileExists( va( "media/%s.%s", main, ext[i] )))
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "common.h"
|
||||
#include "sound.h"
|
||||
#include "client.h"
|
||||
#include "byteorder.h"
|
||||
|
||||
#define IPAINTBUFFER 0
|
||||
#define IROOMBUFFER 1
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "common.h"
|
||||
#include "sound.h"
|
||||
#include "client.h"
|
||||
#include "byteorder.h"
|
||||
|
||||
portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
|
||||
static bg_track_t s_bgTrack;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "client.h"
|
||||
#include "byteorder.h"
|
||||
#include <vfw.h> // video for windows
|
||||
|
||||
typedef struct movie_state_s
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#define DVIS_PVS 0
|
||||
#define DVIS_PHS 1
|
||||
|
||||
extern convar_t *cm_novis;
|
||||
extern convar_t *sv_novis;
|
||||
|
||||
typedef struct leaflist_s
|
||||
{
|
||||
|
@ -57,13 +57,13 @@ extern model_t *worldmodel;
|
|||
//
|
||||
byte *CM_LeafPVS( int leafnum );
|
||||
byte *CM_LeafPHS( int leafnum );
|
||||
int CM_PointLeafnum( const vec3_t p );
|
||||
mleaf_t *CM_PointInLeaf( const vec3_t p, mnode_t *node );
|
||||
int CM_BoxLeafnums( const vec3_t mins, const vec3_t maxs, short *list, int listsize, int *lastleaf );
|
||||
qboolean CM_BoxVisible( const vec3_t mins, const vec3_t maxs, const byte *visbits );
|
||||
int CM_HullPointContents( hull_t *hull, int num, const vec3_t p );
|
||||
int CM_PointContents( const vec3_t p );
|
||||
void CM_AmbientLevels( const vec3_t p, byte *pvolumes );
|
||||
int Mod_PointLeafnum( const vec3_t p );
|
||||
mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node );
|
||||
int Mod_BoxLeafnums( const vec3_t mins, const vec3_t maxs, short *list, int listsize, int *lastleaf );
|
||||
qboolean Mod_BoxVisible( const vec3_t mins, const vec3_t maxs, const byte *visbits );
|
||||
int Mod_HullPointContents( hull_t *hull, int num, const vec3_t p );
|
||||
int Mod_PointContents( const vec3_t p );
|
||||
void Mod_AmbientLevels( const vec3_t p, byte *pvolumes );
|
||||
|
||||
//
|
||||
// cm_portals.c
|
||||
|
@ -73,10 +73,10 @@ byte *CM_FatPVS( const vec3_t org, qboolean portal );
|
|||
byte *CM_FatPHS( const vec3_t org, qboolean portal );
|
||||
|
||||
//
|
||||
// cm_model.c
|
||||
// model.c
|
||||
//
|
||||
qboolean CM_InitPhysics( void );
|
||||
void CM_FreePhysics( void );
|
||||
void Mod_Init( void );
|
||||
void Mod_Shutdown( void );
|
||||
script_t *CM_GetEntityScript( void );
|
||||
void CM_SetupHulls( float mins[4][3], float maxs[4][3] );
|
||||
void Mod_GetBounds( int handle, vec3_t mins, vec3_t maxs );
|
||||
|
|
|
@ -6,189 +6,3 @@
|
|||
#include "cm_local.h"
|
||||
#include "mathlib.h"
|
||||
#include "world.h"
|
||||
|
||||
/*
|
||||
==================
|
||||
CM_PointInLeaf
|
||||
|
||||
==================
|
||||
*/
|
||||
mleaf_t *CM_PointInLeaf( const vec3_t p, mnode_t *node )
|
||||
{
|
||||
mleaf_t *leaf;
|
||||
|
||||
// find which leaf the point is in
|
||||
while( node->plane )
|
||||
node = node->children[(node->plane->type < 3 ? p[node->plane->type] : DotProduct(p, node->plane->normal)) < node->plane->dist];
|
||||
leaf = (mleaf_t *)node;
|
||||
|
||||
return leaf;
|
||||
}
|
||||
|
||||
int CM_PointLeafnum( const vec3_t p )
|
||||
{
|
||||
// map not loaded
|
||||
if ( !worldmodel ) return 0;
|
||||
return CM_PointInLeaf( p, worldmodel->nodes ) - worldmodel->leafs - 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
======================================================================
|
||||
|
||||
LEAF LISTING
|
||||
|
||||
======================================================================
|
||||
*/
|
||||
void CM_BoxLeafnums_r( leaflist_t *ll, mnode_t *node )
|
||||
{
|
||||
mplane_t *plane;
|
||||
int s;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
if( node->contents == CONTENTS_SOLID )
|
||||
return;
|
||||
|
||||
if( node->contents < 0 )
|
||||
{
|
||||
mleaf_t *leaf = (mleaf_t *)node;
|
||||
|
||||
// it's a leaf!
|
||||
if( ll->count >= ll->maxcount )
|
||||
{
|
||||
ll->overflowed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
ll->list[ll->count++] = leaf - worldmodel->leafs - 1;
|
||||
return;
|
||||
}
|
||||
|
||||
plane = node->plane;
|
||||
s = BOX_ON_PLANE_SIDE( ll->mins, ll->maxs, plane );
|
||||
|
||||
if( s == 1 )
|
||||
{
|
||||
node = node->children[0];
|
||||
}
|
||||
else if( s == 2 )
|
||||
{
|
||||
node = node->children[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// go down both
|
||||
if( ll->topnode == -1 )
|
||||
ll->topnode = node - worldmodel->nodes;
|
||||
CM_BoxLeafnums_r( ll, node->children[0] );
|
||||
node = node->children[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CM_BoxLeafnums
|
||||
==================
|
||||
*/
|
||||
int CM_BoxLeafnums( const vec3_t mins, const vec3_t maxs, short *list, int listsize, int *topnode )
|
||||
{
|
||||
leaflist_t ll;
|
||||
|
||||
if( !worldmodel ) return 0;
|
||||
|
||||
cm.checkcount++;
|
||||
VectorCopy( mins, ll.mins );
|
||||
VectorCopy( maxs, ll.maxs );
|
||||
ll.count = 0;
|
||||
ll.maxcount = listsize;
|
||||
ll.list = list;
|
||||
ll.topnode = -1;
|
||||
ll.overflowed = false;
|
||||
|
||||
CM_BoxLeafnums_r( &ll, worldmodel->nodes );
|
||||
|
||||
if( topnode ) *topnode = ll.topnode;
|
||||
return ll.count;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
CM_BoxVisible
|
||||
|
||||
Returns true if any leaf in boxspace
|
||||
is potentially visible
|
||||
=============
|
||||
*/
|
||||
qboolean CM_BoxVisible( const vec3_t mins, const vec3_t maxs, const byte *visbits )
|
||||
{
|
||||
short leafList[MAX_BOX_LEAFS];
|
||||
int i, count;
|
||||
|
||||
if( !visbits || !mins || !maxs )
|
||||
return true;
|
||||
|
||||
// FIXME: Could save a loop here by traversing the tree in this routine like the code above
|
||||
count = CM_BoxLeafnums( mins, maxs, leafList, MAX_BOX_LEAFS, NULL );
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
int leafnum = leafList[i];
|
||||
|
||||
if( visbits[leafnum>>3] & (1<<( leafnum & 7 )))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
POINT TESTING IN HULLS
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
==================
|
||||
CM_HullPointContents
|
||||
|
||||
==================
|
||||
*/
|
||||
int CM_HullPointContents( hull_t *hull, int num, const vec3_t p )
|
||||
{
|
||||
while( num >= 0 )
|
||||
num = hull->clipnodes[num].children[(hull->planes[hull->clipnodes[num].planenum].type < 3 ? p[hull->planes[hull->clipnodes[num].planenum].type] : DotProduct (hull->planes[hull->clipnodes[num].planenum].normal, p)) < hull->planes[hull->clipnodes[num].planenum].dist];
|
||||
return num;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CM_PointContents
|
||||
|
||||
==================
|
||||
*/
|
||||
int CM_PointContents( const vec3_t p )
|
||||
{
|
||||
if( !worldmodel ) return 0;
|
||||
return CM_HullPointContents( &worldmodel->hulls[0], 0, p );
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CM_AmbientLevels
|
||||
|
||||
grab the ambient sound levels for current point
|
||||
==================
|
||||
*/
|
||||
void CM_AmbientLevels( const vec3_t p, byte *pvolumes )
|
||||
{
|
||||
mleaf_t *leaf;
|
||||
|
||||
if( !worldmodel || !p || !pvolumes )
|
||||
return;
|
||||
|
||||
leaf = CM_PointInLeaf( p, worldmodel->nodes );
|
||||
*(int *)pvolumes = *(int *)leaf->ambient_sound_level;
|
||||
}
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "client.h"
|
||||
#include "byteorder.h"
|
||||
#include "const.h"
|
||||
#include "bspfile.h"
|
||||
#include "../cl_dll/kbutton.h"
|
||||
|
@ -69,23 +68,23 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
|
|||
|
||||
Mem_Set( buf, 0, MAX_SYSPATH );
|
||||
FS_Read( f, buf, MAX_SYSPATH );
|
||||
ver = LittleLong(*(uint *)buf);
|
||||
ver = *(uint *)buf;
|
||||
|
||||
switch( ver )
|
||||
{
|
||||
case Q1BSP_VERSION:
|
||||
case HLBSP_VERSION:
|
||||
header = (dheader_t *)buf;
|
||||
if( LittleLong( header->lumps[LUMP_PLANES].filelen ) % sizeof( dplane_t ))
|
||||
if( header->lumps[LUMP_PLANES].filelen % sizeof( dplane_t ))
|
||||
{
|
||||
lumpofs = LittleLong( header->lumps[LUMP_PLANES].fileofs );
|
||||
lumplen = LittleLong( header->lumps[LUMP_PLANES].filelen );
|
||||
lumpofs = header->lumps[LUMP_PLANES].fileofs;
|
||||
lumplen = header->lumps[LUMP_PLANES].filelen;
|
||||
gearbox = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lumpofs = LittleLong( header->lumps[LUMP_ENTITIES].fileofs );
|
||||
lumplen = LittleLong( header->lumps[LUMP_ENTITIES].filelen );
|
||||
lumpofs = header->lumps[LUMP_ENTITIES].fileofs;
|
||||
lumplen = header->lumps[LUMP_ENTITIES].filelen;
|
||||
gearbox = false;
|
||||
}
|
||||
break;
|
||||
|
@ -270,7 +269,7 @@ qboolean Cmd_GetMusicList( const char *s, char *completedname, int length )
|
|||
{
|
||||
const char *ext = FS_FileExtension( t->filenames[i] );
|
||||
|
||||
if( !com.stricmp( ext, "wav" ) || !com.stricmp( ext, "mp3" ) || !com.stricmp( ext, "ogg" ));
|
||||
if( !com.stricmp( ext, "wav" ) || !com.stricmp( ext, "mp3" ));
|
||||
else continue;
|
||||
|
||||
FS_FileBase( t->filenames[i], matchbuf );
|
||||
|
@ -408,7 +407,7 @@ qboolean Cmd_GetSoundList( const char *s, char *completedname, int length )
|
|||
{
|
||||
const char *ext = FS_FileExtension( t->filenames[i] );
|
||||
|
||||
if( !com.stricmp( ext, "wav" ) || !com.stricmp( ext, "mp3" ) || !com.stricmp( ext, "ogg" ));
|
||||
if( !com.stricmp( ext, "wav" ) || !com.stricmp( ext, "mp3" ));
|
||||
else continue;
|
||||
|
||||
com.strncpy( matchbuf, t->filenames[i] + com.strlen(snddir), MAX_STRING );
|
||||
|
@ -655,22 +654,22 @@ qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
|
|||
|
||||
Mem_Set( buf, 0, MAX_SYSPATH );
|
||||
FS_Read( f, buf, MAX_SYSPATH );
|
||||
ver = LittleLong(*(uint *)buf);
|
||||
ver = *(uint *)buf;
|
||||
|
||||
switch( ver )
|
||||
{
|
||||
case Q1BSP_VERSION:
|
||||
case HLBSP_VERSION:
|
||||
header = (dheader_t *)buf;
|
||||
if( LittleLong( header->lumps[LUMP_PLANES].filelen ) % sizeof( dplane_t ))
|
||||
if( header->lumps[LUMP_PLANES].filelen % sizeof( dplane_t ))
|
||||
{
|
||||
lumpofs = LittleLong( header->lumps[LUMP_PLANES].fileofs );
|
||||
lumplen = LittleLong( header->lumps[LUMP_PLANES].filelen );
|
||||
lumpofs = header->lumps[LUMP_PLANES].fileofs;
|
||||
lumplen = header->lumps[LUMP_PLANES].filelen;
|
||||
}
|
||||
else
|
||||
{
|
||||
lumpofs = LittleLong( header->lumps[LUMP_ENTITIES].fileofs );
|
||||
lumplen = LittleLong( header->lumps[LUMP_ENTITIES].filelen );
|
||||
lumpofs = header->lumps[LUMP_ENTITIES].fileofs;
|
||||
lumplen = header->lumps[LUMP_ENTITIES].filelen;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "client.h"
|
||||
#include "keydefs.h"
|
||||
#include "protocol.h" // get the protocol version
|
||||
#include "byteorder.h"
|
||||
#include "con_nprint.h"
|
||||
#include "qfont.h"
|
||||
|
||||
|
@ -354,16 +353,16 @@ static void Con_LoadConchars( void )
|
|||
int i;
|
||||
|
||||
src = (qfont_t *)buffer;
|
||||
con.charHeight = LittleLong( src->rowheight );
|
||||
con.charHeight = src->rowheight;
|
||||
|
||||
// build rectangles
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
con.chars.fontRc[i].left = LittleShort( (word)src->fontinfo[i].startoffset ) % fontWidth;
|
||||
con.chars.fontRc[i].right = con.chars.fontRc[i].left + LittleShort( src->fontinfo[i].charwidth );
|
||||
con.chars.fontRc[i].top = LittleShort( (word)src->fontinfo[i].startoffset ) / fontWidth;
|
||||
con.chars.fontRc[i].bottom = con.chars.fontRc[i].top + LittleLong( src->rowheight );
|
||||
con.charWidths[i] = LittleLong( src->fontinfo[i].charwidth );
|
||||
con.chars.fontRc[i].left = (word)src->fontinfo[i].startoffset % fontWidth;
|
||||
con.chars.fontRc[i].right = con.chars.fontRc[i].left + src->fontinfo[i].charwidth;
|
||||
con.chars.fontRc[i].top = (word)src->fontinfo[i].startoffset / fontWidth;
|
||||
con.chars.fontRc[i].bottom = con.chars.fontRc[i].top + src->rowheight;
|
||||
con.charWidths[i] = src->fontinfo[i].charwidth;
|
||||
}
|
||||
con.chars.valid = true;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "studio.h"
|
||||
#include "byteorder.h"
|
||||
#include "mathlib.h"
|
||||
#include "const.h"
|
||||
#include "client.h"
|
||||
|
|
|
@ -806,9 +806,9 @@ void Host_Init( const int argc, const char **argv )
|
|||
if( host.developer > 1 ) Cvar_SetFloat( "sv_cheats", 1.0f );
|
||||
}
|
||||
|
||||
Mod_Init();
|
||||
NET_Init();
|
||||
Netchan_Init();
|
||||
CM_InitPhysics();
|
||||
|
||||
SV_Init();
|
||||
CL_Init();
|
||||
|
@ -874,7 +874,7 @@ void Host_Free( void )
|
|||
host.state = HOST_SHUTDOWN; // prepare host to normal shutdown
|
||||
com.strncpy( host.finalmsg, "Server shutdown\n", MAX_STRING );
|
||||
|
||||
CM_FreePhysics();
|
||||
Mod_Shutdown();
|
||||
Host_FreeRender();
|
||||
S_Shutdown();
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "common.h"
|
||||
#include "byteorder.h"
|
||||
|
||||
#define MAX_INFO_KEY 64
|
||||
#define MAX_INFO_VALUE 64
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
|
||||
#include "cm_local.h"
|
||||
#include "sprite.h"
|
||||
#include "byteorder.h"
|
||||
#include "mathlib.h"
|
||||
#include "matrix_lib.h"
|
||||
#include "studio.h"
|
||||
#include "wadfile.h"
|
||||
#include "world.h"
|
||||
|
||||
clipmap_t cm;
|
||||
|
||||
|
@ -23,7 +23,8 @@ model_t *loadmodel;
|
|||
model_t *worldmodel;
|
||||
|
||||
// cvars
|
||||
convar_t *cm_novis;
|
||||
convar_t *sv_novis; // disable server culling entities by vis
|
||||
convar_t *gl_subdivide_size;
|
||||
|
||||
// default hullmins
|
||||
static vec3_t cm_hullmins[4] =
|
||||
|
@ -103,6 +104,190 @@ static int CM_StudioBodyVariations( model_t *mod )
|
|||
return count;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Mod_PointInLeaf
|
||||
|
||||
==================
|
||||
*/
|
||||
mleaf_t *Mod_PointInLeaf( const vec3_t p, mnode_t *node )
|
||||
{
|
||||
mleaf_t *leaf;
|
||||
|
||||
// find which leaf the point is in
|
||||
while( node->contents >= 0 )
|
||||
node = node->children[(node->plane->type < 3 ? p[node->plane->type] : DotProduct(p, node->plane->normal)) < node->plane->dist];
|
||||
leaf = (mleaf_t *)node;
|
||||
|
||||
return leaf;
|
||||
}
|
||||
|
||||
int Mod_PointLeafnum( const vec3_t p )
|
||||
{
|
||||
// map not loaded
|
||||
if ( !worldmodel ) return 0;
|
||||
return Mod_PointInLeaf( p, worldmodel->nodes ) - worldmodel->leafs - 1;
|
||||
}
|
||||
|
||||
/*
|
||||
======================================================================
|
||||
|
||||
LEAF LISTING
|
||||
|
||||
======================================================================
|
||||
*/
|
||||
static void Mod_BoxLeafnums_r( leaflist_t *ll, mnode_t *node )
|
||||
{
|
||||
mplane_t *plane;
|
||||
int s;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
if( node->contents == CONTENTS_SOLID )
|
||||
return;
|
||||
|
||||
if( node->contents < 0 )
|
||||
{
|
||||
mleaf_t *leaf = (mleaf_t *)node;
|
||||
|
||||
// it's a leaf!
|
||||
if( ll->count >= ll->maxcount )
|
||||
{
|
||||
ll->overflowed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
ll->list[ll->count++] = leaf - worldmodel->leafs - 1;
|
||||
return;
|
||||
}
|
||||
|
||||
plane = node->plane;
|
||||
s = BOX_ON_PLANE_SIDE( ll->mins, ll->maxs, plane );
|
||||
|
||||
if( s == 1 )
|
||||
{
|
||||
node = node->children[0];
|
||||
}
|
||||
else if( s == 2 )
|
||||
{
|
||||
node = node->children[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// go down both
|
||||
if( ll->topnode == -1 )
|
||||
ll->topnode = node - worldmodel->nodes;
|
||||
Mod_BoxLeafnums_r( ll, node->children[0] );
|
||||
node = node->children[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Mod_BoxLeafnums
|
||||
==================
|
||||
*/
|
||||
int Mod_BoxLeafnums( const vec3_t mins, const vec3_t maxs, short *list, int listsize, int *topnode )
|
||||
{
|
||||
leaflist_t ll;
|
||||
|
||||
if( !worldmodel ) return 0;
|
||||
|
||||
cm.checkcount++;
|
||||
VectorCopy( mins, ll.mins );
|
||||
VectorCopy( maxs, ll.maxs );
|
||||
ll.count = 0;
|
||||
ll.maxcount = listsize;
|
||||
ll.list = list;
|
||||
ll.topnode = -1;
|
||||
ll.overflowed = false;
|
||||
|
||||
Mod_BoxLeafnums_r( &ll, worldmodel->nodes );
|
||||
|
||||
if( topnode ) *topnode = ll.topnode;
|
||||
return ll.count;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
Mod_BoxVisible
|
||||
|
||||
Returns true if any leaf in boxspace
|
||||
is potentially visible
|
||||
=============
|
||||
*/
|
||||
qboolean Mod_BoxVisible( const vec3_t mins, const vec3_t maxs, const byte *visbits )
|
||||
{
|
||||
short leafList[MAX_BOX_LEAFS];
|
||||
int i, count;
|
||||
|
||||
if( !visbits || !mins || !maxs )
|
||||
return true;
|
||||
|
||||
// FIXME: Could save a loop here by traversing the tree in this routine like the code above
|
||||
count = Mod_BoxLeafnums( mins, maxs, leafList, MAX_BOX_LEAFS, NULL );
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
int leafnum = leafList[i];
|
||||
|
||||
if( visbits[leafnum>>3] & (1<<( leafnum & 7 )))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
POINT TESTING IN HULLS
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
/*
|
||||
==================
|
||||
Mod_HullPointContents
|
||||
|
||||
==================
|
||||
*/
|
||||
int Mod_HullPointContents( hull_t *hull, int num, const vec3_t p )
|
||||
{
|
||||
while( num >= 0 )
|
||||
num = hull->clipnodes[num].children[(hull->planes[hull->clipnodes[num].planenum].type < 3 ? p[hull->planes[hull->clipnodes[num].planenum].type] : DotProduct (hull->planes[hull->clipnodes[num].planenum].normal, p)) < hull->planes[hull->clipnodes[num].planenum].dist];
|
||||
return num;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Mod_PointContents
|
||||
|
||||
==================
|
||||
*/
|
||||
int Mod_PointContents( const vec3_t p )
|
||||
{
|
||||
if( !worldmodel ) return 0;
|
||||
return Mod_HullPointContents( &worldmodel->hulls[0], 0, p );
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Mod_AmbientLevels
|
||||
|
||||
grab the ambient sound levels for current point
|
||||
==================
|
||||
*/
|
||||
void Mod_AmbientLevels( const vec3_t p, byte *pvolumes )
|
||||
{
|
||||
mleaf_t *leaf;
|
||||
|
||||
if( !worldmodel || !p || !pvolumes )
|
||||
return;
|
||||
|
||||
leaf = Mod_PointInLeaf( p, worldmodel->nodes );
|
||||
*(int *)pvolumes = *(int *)leaf->ambient_sound_level;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CM_FreeModel
|
||||
|
@ -125,17 +310,16 @@ static void CM_FreeModel( model_t *mod )
|
|||
===============================================================================
|
||||
*/
|
||||
|
||||
qboolean CM_InitPhysics( void )
|
||||
void Mod_Init( void )
|
||||
{
|
||||
cm_novis = Cvar_Get( "cm_novis", "0", 0, "force to ignore server visibility" );
|
||||
sv_novis = Cvar_Get( "sv_novis", "0", 0, "force to ignore server visibility" );
|
||||
gl_subdivide_size = Cvar_Get( "gl_subdivide_size", "128", CVAR_ARCHIVE, "how large water polygons should be" );
|
||||
|
||||
cm.studiopool = Mem_AllocPool( "Studio Cache" );
|
||||
|
||||
Mem_Set( cm.nullrow, 0xFF, MAX_MAP_LEAFS / 8 );
|
||||
return true;
|
||||
}
|
||||
|
||||
void CM_FreePhysics( void )
|
||||
void Mod_Shutdown( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -157,14 +341,14 @@ void CM_FreePhysics( void )
|
|||
BSP_LoadSubmodels
|
||||
=================
|
||||
*/
|
||||
static void BSP_LoadSubmodels( dlump_t *l )
|
||||
static void Mod_LoadSubmodels( dlump_t *l )
|
||||
{
|
||||
dmodel_t *in;
|
||||
dmodel_t *out;
|
||||
int i, j, count;
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
if( l->filelen % sizeof( *in )) Host_Error( "BSP_LoadModels: funny lump size\n" );
|
||||
if( l->filelen % sizeof( *in )) Host_Error( "Mod_LoadBModel: funny lump size\n" );
|
||||
count = l->filelen / sizeof( *in );
|
||||
|
||||
if( count < 1 ) Host_Error( "Map %s without models\n", loadmodel->name );
|
||||
|
@ -180,17 +364,17 @@ static void BSP_LoadSubmodels( dlump_t *l )
|
|||
for( j = 0; j < 3; j++ )
|
||||
{
|
||||
// spread the mins / maxs by a pixel
|
||||
out->mins[j] = LittleFloat( in->mins[j] ) - 1;
|
||||
out->maxs[j] = LittleFloat( in->maxs[j] ) + 1;
|
||||
out->origin[j] = LittleFloat( in->origin[j] );
|
||||
out->mins[j] = in->mins[j] - 1;
|
||||
out->maxs[j] = in->maxs[j] + 1;
|
||||
out->origin[j] = in->origin[j];
|
||||
}
|
||||
|
||||
for( j = 0; j < MAX_MAP_HULLS; j++ )
|
||||
out->headnode[j] = LittleLong( in->headnode[j] );
|
||||
out->headnode[j] = in->headnode[j];
|
||||
|
||||
out->visleafs = LittleLong( in->visleafs );
|
||||
out->firstface = LittleLong( in->firstface );
|
||||
out->numfaces = LittleLong( in->numfaces );
|
||||
out->visleafs = in->visleafs;
|
||||
out->firstface = in->firstface;
|
||||
out->numfaces = in->numfaces;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,7 +386,7 @@ BSP_LoadTextures
|
|||
static void BSP_LoadTextures( dlump_t *l )
|
||||
{
|
||||
dmiptexlump_t *in;
|
||||
mtexture_t *out;
|
||||
texture_t *out;
|
||||
mip_t *mt;
|
||||
int i;
|
||||
|
||||
|
@ -214,14 +398,12 @@ static void BSP_LoadTextures( dlump_t *l )
|
|||
}
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
in->nummiptex = LittleLong( in->nummiptex );
|
||||
|
||||
loadmodel->numtextures = in->nummiptex;
|
||||
loadmodel->textures = (mtexture_t **)Mem_Alloc( loadmodel->mempool, loadmodel->numtextures * sizeof( mtexture_t* ));
|
||||
loadmodel->textures = (texture_t **)Mem_Alloc( loadmodel->mempool, loadmodel->numtextures * sizeof( texture_t* ));
|
||||
|
||||
for( i = 0; i < loadmodel->numtextures; i++ )
|
||||
{
|
||||
in->dataofs[i] = LittleLong( in->dataofs[i] );
|
||||
if( in->dataofs[i] == -1 ) continue; // bad offset ?
|
||||
|
||||
mt = (mip_t *)((byte *)in + in->dataofs[i] );
|
||||
|
@ -259,9 +441,9 @@ static void BSP_LoadTexInfo( const dlump_t *l )
|
|||
for( i = 0; i < count; i++, in++, out++ )
|
||||
{
|
||||
for( j = 0; j < 8; j++ )
|
||||
out->vecs[0][j] = LittleFloat( in->vecs[0][j] );
|
||||
out->vecs[0][j] = in->vecs[0][j];
|
||||
|
||||
miptex = LittleLong( in->miptex );
|
||||
miptex = in->miptex;
|
||||
if( miptex < 0 || miptex > loadmodel->numtextures )
|
||||
Host_Error( "BSP_LoadTexInfo: bad miptex number in '%s'\n", loadmodel->name );
|
||||
out->texture = loadmodel->textures[miptex];
|
||||
|
@ -275,7 +457,8 @@ BSP_LoadLighting
|
|||
*/
|
||||
static void BSP_LoadLighting( const dlump_t *l )
|
||||
{
|
||||
byte d, *in, *out;
|
||||
byte d, *in;
|
||||
color24 *out;
|
||||
int i;
|
||||
|
||||
if( !l->filelen ) return;
|
||||
|
@ -285,15 +468,15 @@ static void BSP_LoadLighting( const dlump_t *l )
|
|||
{
|
||||
case Q1BSP_VERSION:
|
||||
// expand the white lighting data
|
||||
loadmodel->lightdata = Mem_Alloc( loadmodel->mempool, l->filelen * 3 );
|
||||
loadmodel->lightdata = (color24 *)Mem_Alloc( loadmodel->mempool, l->filelen * sizeof( color24 ));
|
||||
out = loadmodel->lightdata;
|
||||
|
||||
for( i = 0; i < l->filelen; i++ )
|
||||
for( i = 0; i < l->filelen; i++, out++ )
|
||||
{
|
||||
d = *in++;
|
||||
*out++ = d;
|
||||
*out++ = d;
|
||||
*out++ = d;
|
||||
out->r = d;
|
||||
out->g = d;
|
||||
out->b = d;
|
||||
}
|
||||
break;
|
||||
case HLBSP_VERSION:
|
||||
|
@ -375,12 +558,12 @@ static void BSP_LoadSurfaces( const dlump_t *l )
|
|||
|
||||
for( i = 0; i < count; i++, in++, out++ )
|
||||
{
|
||||
out->firstedge = LittleLong( in->firstedge );
|
||||
out->numedges = LittleLong( in->numedges );
|
||||
out->firstedge = in->firstedge;
|
||||
out->numedges = in->numedges;
|
||||
|
||||
if( LittleShort( in->side )) out->flags |= SURF_PLANEBACK;
|
||||
out->plane = loadmodel->planes + LittleLong( in->planenum );
|
||||
out->texinfo = loadmodel->texinfo + LittleLong( in->texinfo );
|
||||
if( in->side ) out->flags |= SURF_PLANEBACK;
|
||||
out->plane = loadmodel->planes + in->planenum;
|
||||
out->texinfo = loadmodel->texinfo + in->texinfo;
|
||||
|
||||
// some DMC maps have bad textures
|
||||
if( out->texinfo->texture )
|
||||
|
@ -395,7 +578,7 @@ static void BSP_LoadSurfaces( const dlump_t *l )
|
|||
BSP_CalcSurfaceExtents( out );
|
||||
|
||||
if( out->flags & SURF_DRAWTILED ) lightofs = -1;
|
||||
else lightofs = LittleLong( in->lightofs );
|
||||
else lightofs = in->lightofs;
|
||||
|
||||
if( loadmodel->lightdata && lightofs != -1 )
|
||||
{
|
||||
|
@ -403,12 +586,6 @@ static void BSP_LoadSurfaces( const dlump_t *l )
|
|||
out->samples = loadmodel->lightdata + lightofs;
|
||||
else out->samples = loadmodel->lightdata + (lightofs * 3);
|
||||
}
|
||||
|
||||
while( out->numstyles < LM_STYLES && in->styles[out->numstyles] != 255 )
|
||||
{
|
||||
out->styles[out->numstyles] = in->styles[out->numstyles];
|
||||
out->numstyles++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -420,8 +597,8 @@ BSP_LoadVertexes
|
|||
static void BSP_LoadVertexes( const dlump_t *l )
|
||||
{
|
||||
dvertex_t *in;
|
||||
float *out;
|
||||
int i, j, count;
|
||||
mvertex_t *out;
|
||||
int i, count;
|
||||
|
||||
in = (void *)( mod_base + l->fileofs );
|
||||
if( l->filelen % sizeof( *in ))
|
||||
|
@ -429,12 +606,11 @@ static void BSP_LoadVertexes( const dlump_t *l )
|
|||
count = l->filelen / sizeof( *in );
|
||||
|
||||
loadmodel->numvertexes = count;
|
||||
out = (float *)loadmodel->vertexes = Mem_Alloc( loadmodel->mempool, count * sizeof( vec3_t ));
|
||||
out = loadmodel->vertexes = Mem_Alloc( loadmodel->mempool, count * sizeof( mvertex_t ));
|
||||
|
||||
for( i = 0; i < count; i++, in++, out += 3 )
|
||||
for( i = 0; i < count; i++, in++, out++ )
|
||||
{
|
||||
for( j = 0; j < 3; j++ )
|
||||
out[j] = LittleFloat( in->point[j] );
|
||||
VectorCopy( in->point, out->position );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -445,21 +621,22 @@ BSP_LoadEdges
|
|||
*/
|
||||
static void BSP_LoadEdges( const dlump_t *l )
|
||||
{
|
||||
dedge_t *in, *out;
|
||||
dedge_t *in;
|
||||
medge_t *out;
|
||||
int i, count;
|
||||
|
||||
in = (void *)( mod_base + l->fileofs );
|
||||
if( l->filelen % sizeof( *in ))
|
||||
Host_Error( "BSP_LoadEdges: funny lump size in %s\n", loadmodel->name );
|
||||
|
||||
count = l->filelen / sizeof( dedge_t );
|
||||
loadmodel->edges = out = Mem_Alloc( loadmodel->mempool, count * sizeof( dedge_t ));
|
||||
count = l->filelen / sizeof( *in );
|
||||
loadmodel->edges = out = Mem_Alloc( loadmodel->mempool, count * sizeof( medge_t ));
|
||||
loadmodel->numedges = count;
|
||||
|
||||
for( i = 0; i < count; i++, in++, out++ )
|
||||
{
|
||||
out->v[0] = (word)LittleShort( in->v[0] );
|
||||
out->v[1] = (word)LittleShort( in->v[1] );
|
||||
out->v[0] = (word)in->v[0];
|
||||
out->v[1] = (word)in->v[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -471,7 +648,7 @@ BSP_LoadSurfEdges
|
|||
static void BSP_LoadSurfEdges( const dlump_t *l )
|
||||
{
|
||||
dsurfedge_t *in, *out;
|
||||
int i, count;
|
||||
int count;
|
||||
|
||||
in = (void *)( mod_base + l->fileofs );
|
||||
if( l->filelen % sizeof( *in ))
|
||||
|
@ -481,8 +658,7 @@ static void BSP_LoadSurfEdges( const dlump_t *l )
|
|||
loadmodel->surfedges = out = Mem_Alloc( loadmodel->mempool, count * sizeof( dsurfedge_t ));
|
||||
loadmodel->numsurfedges = count;
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
out[i] = LittleLong( in[i] );
|
||||
Mem_Copy( out, in, count * sizeof( dsurfedge_t ));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -504,7 +680,7 @@ static void BSP_LoadMarkFaces( const dlump_t *l )
|
|||
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
j = LittleLong( in[i] );
|
||||
j = in[i];
|
||||
if( j < 0 || j >= loadmodel->numsurfaces )
|
||||
Host_Error( "BSP_LoadMarkFaces: bad surface number in '%s'\n", loadmodel->name );
|
||||
loadmodel->marksurfaces[i] = loadmodel->surfaces + j;
|
||||
|
@ -545,15 +721,14 @@ static void BSP_LoadNodes( dlump_t *l )
|
|||
|
||||
for( i = 0; i < loadmodel->numnodes; i++, out++, in++ )
|
||||
{
|
||||
p = LittleLong( in->planenum );
|
||||
p = in->planenum;
|
||||
out->plane = loadmodel->planes + p;
|
||||
out->contents = CONTENTS_NODE;
|
||||
out->firstface = loadmodel->surfaces + LittleLong( in->firstface );
|
||||
out->numfaces = LittleLong( in->numfaces );
|
||||
out->firstsurface = in->firstface;
|
||||
out->numsurfaces = in->numfaces;
|
||||
|
||||
for( j = 0; j < 2; j++ )
|
||||
{
|
||||
p = LittleShort( in->children[j] );
|
||||
p = in->children[j];
|
||||
if( p >= 0 ) out->children[j] = loadmodel->nodes + p;
|
||||
else out->children[j] = (mnode_t *)(loadmodel->leafs + ( -1 - p ));
|
||||
}
|
||||
|
@ -586,11 +761,10 @@ static void BSP_LoadLeafs( dlump_t *l )
|
|||
|
||||
for( i = 0; i < count; i++, in++, out++ )
|
||||
{
|
||||
p = LittleLong( in->contents );
|
||||
p = in->contents;
|
||||
out->contents = p;
|
||||
out->plane = NULL; // differentiate to nodes
|
||||
|
||||
p = LittleLong( in->visofs );
|
||||
p = in->visofs;
|
||||
|
||||
if( p == -1 ) out->visdata = NULL;
|
||||
else out->visdata = cm.pvs + p;
|
||||
|
@ -601,8 +775,8 @@ static void BSP_LoadLeafs( dlump_t *l )
|
|||
for( j = 0; j < 4; j++ )
|
||||
out->ambient_sound_level[j] = in->ambient_level[j];
|
||||
|
||||
out->firstmarksurface = loadmodel->marksurfaces + LittleShort( in->firstmarksurface );
|
||||
out->nummarksurfaces = LittleShort( in->nummarksurfaces );
|
||||
out->firstmarksurface = loadmodel->marksurfaces + in->firstmarksurface;
|
||||
out->nummarksurfaces = in->nummarksurfaces;
|
||||
}
|
||||
|
||||
if( loadmodel->leafs[0].contents != CONTENTS_SOLID )
|
||||
|
@ -634,12 +808,12 @@ static void BSP_LoadPlanes( dlump_t *l )
|
|||
{
|
||||
for( j = 0; j < 3; j++ )
|
||||
{
|
||||
out->normal[j] = LittleFloat( in->normal[j] );
|
||||
out->normal[j] = in->normal[j];
|
||||
if( out->normal[j] < 0.0f ) out->signbits |= 1<<j;
|
||||
}
|
||||
|
||||
out->dist = LittleFloat( in->dist );
|
||||
out->type = LittleLong( in->type );
|
||||
out->dist = in->dist;
|
||||
out->type = in->type;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -726,9 +900,9 @@ static void BSP_LoadClipnodes( dlump_t *l )
|
|||
|
||||
for( i = 0; i < count; i++, out++, in++ )
|
||||
{
|
||||
out->planenum = LittleLong( in->planenum );
|
||||
out->children[0] = LittleShort( in->children[0] );
|
||||
out->children[1] = LittleShort( in->children[1] );
|
||||
out->planenum = in->planenum;
|
||||
out->children[0] = in->children[0];
|
||||
out->children[1] = in->children[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -784,7 +958,7 @@ static void CM_BrushModel( model_t *mod, byte *buffer )
|
|||
int i, j;
|
||||
|
||||
header = (dheader_t *)buffer;
|
||||
i = LittleLong( header->version );
|
||||
i = header->version;
|
||||
|
||||
switch( i )
|
||||
{
|
||||
|
@ -802,10 +976,6 @@ static void CM_BrushModel( model_t *mod, byte *buffer )
|
|||
|
||||
// swap all the lumps
|
||||
mod_base = (byte *)header;
|
||||
|
||||
for( i = 0; i < sizeof( dheader_t ) / 4; i++ )
|
||||
((int *)header)[i] = LittleLong((( int *)header)[i] );
|
||||
|
||||
loadmodel->mempool = Mem_AllocPool( va( "sv: ^2%s^7", loadmodel->name ));
|
||||
|
||||
// load into heap
|
||||
|
@ -834,7 +1004,7 @@ static void CM_BrushModel( model_t *mod, byte *buffer )
|
|||
BSP_LoadLeafs( &header->lumps[LUMP_LEAFS] );
|
||||
BSP_LoadNodes( &header->lumps[LUMP_NODES] );
|
||||
BSP_LoadClipnodes( &header->lumps[LUMP_CLIPNODES] );
|
||||
BSP_LoadSubmodels( &header->lumps[LUMP_MODELS] );
|
||||
Mod_LoadSubmodels( &header->lumps[LUMP_MODELS] );
|
||||
|
||||
CM_MakeHull0 ();
|
||||
|
||||
|
@ -893,8 +1063,8 @@ static void CM_StudioModel( model_t *mod, byte *buffer )
|
|||
loadmodel->registration_sequence = cm.registration_sequence;
|
||||
|
||||
loadmodel->mempool = Mem_AllocPool( va("^2%s^7", loadmodel->name ));
|
||||
loadmodel->extradata = Mem_Alloc( loadmodel->mempool, LittleLong( phdr->length ));
|
||||
Mem_Copy( loadmodel->extradata, buffer, LittleLong( phdr->length ));
|
||||
loadmodel->cache.data = Mem_Alloc( loadmodel->mempool, phdr->length );
|
||||
Mem_Copy( loadmodel->cache.data, buffer, phdr->length );
|
||||
|
||||
// setup bounding box
|
||||
VectorCopy( phdr->bbmin, loadmodel->mins );
|
||||
|
@ -990,7 +1160,7 @@ model_t *CM_ModForName( const char *name, qboolean world )
|
|||
loadmodel = mod;
|
||||
|
||||
// call the apropriate loader
|
||||
switch( LittleLong( *(uint *)buf ))
|
||||
switch( *(uint *)buf )
|
||||
{
|
||||
case IDSTUDIOHEADER:
|
||||
CM_StudioModel( mod, buf );
|
||||
|
@ -1263,6 +1433,6 @@ Mod_Extradata
|
|||
void *Mod_Extradata( model_t *mod )
|
||||
{
|
||||
if( mod && mod->type == mod_studio )
|
||||
return mod->extradata;
|
||||
return mod->cache.data;
|
||||
return NULL;
|
||||
}
|
|
@ -13,6 +13,19 @@
|
|||
static dword BitWriteMasks[32][33];
|
||||
static dword ExtraMasks[32];
|
||||
|
||||
short BF_BigShort( short swap )
|
||||
{
|
||||
short *s = &swap;
|
||||
|
||||
__asm {
|
||||
mov ebx, s
|
||||
mov al, [ebx+1]
|
||||
mov ah, [ebx ]
|
||||
mov [ebx], ax
|
||||
}
|
||||
return *s;
|
||||
}
|
||||
|
||||
void BF_InitMasks( void )
|
||||
{
|
||||
uint startbit, endbit;
|
||||
|
|
|
@ -51,6 +51,7 @@ void BF_SeekToBit( sizebuf_t *bf, int bitPos );
|
|||
void BF_SeekToByte( sizebuf_t *bf, int bytePos );
|
||||
void BF_ExciseBits( sizebuf_t *bf, int startbit, int bitstoremove );
|
||||
qboolean BF_CheckOverflow( sizebuf_t *bf );
|
||||
short BF_BigShort( short swap );
|
||||
|
||||
// init writing
|
||||
void BF_StartWriting( sizebuf_t *bf, void *pData, int nBytes, int iStartBit, int nBits );
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "common.h"
|
||||
#include "netchan.h"
|
||||
#include "mathlib.h"
|
||||
#include "byteorder.h"
|
||||
#include "net_encode.h"
|
||||
|
||||
#define MAKE_FRAGID( id, count ) ((( id & 0xffff ) << 16 ) | ( count & 0xffff ))
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "netchan.h"
|
||||
#include "byteorder.h"
|
||||
#include "mathlib.h"
|
||||
#include "net_encode.h"
|
||||
#include "event_api.h"
|
||||
|
|
|
@ -537,10 +537,10 @@ static qboolean PM_StudioSetupModel( physent_t *pe )
|
|||
{
|
||||
model_t *mod = pe->studiomodel;
|
||||
|
||||
if( !mod || !mod->extradata )
|
||||
if( !mod || !mod->cache.data )
|
||||
return false;
|
||||
|
||||
pm_studiohdr = (studiohdr_t *)mod->extradata;
|
||||
pm_studiohdr = (studiohdr_t *)mod->cache.data;
|
||||
PM_StudioSetUpTransform( pe );
|
||||
PM_StudioSetupBones( pe );
|
||||
return true;
|
||||
|
@ -553,10 +553,10 @@ qboolean PM_StudioExtractBbox( model_t *mod, int sequence, float *mins, float *m
|
|||
|
||||
ASSERT( mod != NULL );
|
||||
|
||||
if( mod->type != mod_studio || !mod->extradata )
|
||||
if( mod->type != mod_studio || !mod->cache.data )
|
||||
return false;
|
||||
|
||||
phdr = (studiohdr_t *)mod->extradata;
|
||||
phdr = (studiohdr_t *)mod->cache.data;
|
||||
if( !phdr->numhitboxes ) return false;
|
||||
|
||||
pseqdesc = (mstudioseqdesc_t *)((byte *)phdr + phdr->seqindex);
|
||||
|
|
|
@ -14,7 +14,7 @@ PM_RecursiveSurfCheck
|
|||
|
||||
==================
|
||||
*/
|
||||
msurface_t *PM_RecursiveSurfCheck( mnode_t *node, vec3_t p1, vec3_t p2 )
|
||||
msurface_t *PM_RecursiveSurfCheck( model_t *model, mnode_t *node, vec3_t p1, vec3_t p2 )
|
||||
{
|
||||
float t1, t2, frac;
|
||||
int side, ds, dt;
|
||||
|
@ -40,9 +40,9 @@ msurface_t *PM_RecursiveSurfCheck( mnode_t *node, vec3_t p1, vec3_t p2 )
|
|||
}
|
||||
|
||||
if( t1 >= 0 && t2 >= 0 )
|
||||
return PM_RecursiveSurfCheck( node->children[0], p1, p2 );
|
||||
return PM_RecursiveSurfCheck( model, node->children[0], p1, p2 );
|
||||
if( t1 < 0 && t2 < 0 )
|
||||
return PM_RecursiveSurfCheck( node->children[1], p1, p2 );
|
||||
return PM_RecursiveSurfCheck( model, node->children[1], p1, p2 );
|
||||
|
||||
frac = t1 / ( t1 - t2 );
|
||||
|
||||
|
@ -54,16 +54,16 @@ msurface_t *PM_RecursiveSurfCheck( mnode_t *node, vec3_t p1, vec3_t p2 )
|
|||
side = (t1 < 0);
|
||||
|
||||
// now this is weird.
|
||||
surf = PM_RecursiveSurfCheck( node->children[side], p1, mid );
|
||||
surf = PM_RecursiveSurfCheck( model, node->children[side], p1, mid );
|
||||
|
||||
if( surf != NULL || ( t1 >= 0 && t2 >= 0 ) || ( t1 < 0 && t2 < 0 ))
|
||||
{
|
||||
return surf;
|
||||
}
|
||||
|
||||
surf = node->firstface;
|
||||
surf = model->surfaces + node->firstsurface;
|
||||
|
||||
for( i = 0; i < node->numfaces; i++, surf++ )
|
||||
for( i = 0; i < node->numsurfaces; i++, surf++ )
|
||||
{
|
||||
ds = (int)((float)DotProduct( mid, surf->texinfo->vecs[0] ) + surf->texinfo->vecs[0][3] );
|
||||
dt = (int)((float)DotProduct( mid, surf->texinfo->vecs[1] ) + surf->texinfo->vecs[1][3] );
|
||||
|
@ -78,7 +78,7 @@ msurface_t *PM_RecursiveSurfCheck( mnode_t *node, vec3_t p1, vec3_t p2 )
|
|||
}
|
||||
}
|
||||
|
||||
return PM_RecursiveSurfCheck( node->children[side^1], mid, p2 );
|
||||
return PM_RecursiveSurfCheck( model, node->children[side^1], mid, p2 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -129,7 +129,7 @@ const char *PM_TraceTexture( physent_t *pe, vec3_t start, vec3_t end )
|
|||
#endif
|
||||
}
|
||||
|
||||
surf = PM_RecursiveSurfCheck( &bmodel->nodes[hull->firstclipnode], start_l, end_l );
|
||||
surf = PM_RecursiveSurfCheck( bmodel, &bmodel->nodes[hull->firstclipnode], start_l, end_l );
|
||||
|
||||
if( !surf || !surf->texinfo || !surf->texinfo->texture )
|
||||
return NULL;
|
||||
|
|
|
@ -179,7 +179,7 @@ CM_LeafPVS
|
|||
*/
|
||||
byte *CM_LeafPVS( int leafnum )
|
||||
{
|
||||
if( !worldmodel || leafnum <= 0 || leafnum >= worldmodel->numleafs || !cm.pvs || cm_novis->integer )
|
||||
if( !worldmodel || leafnum <= 0 || leafnum >= worldmodel->numleafs || !cm.pvs || sv_novis->integer )
|
||||
return cm.nullrow;
|
||||
|
||||
return worldmodel->leafs[leafnum+1].visdata;
|
||||
|
@ -192,7 +192,7 @@ CM_LeafPHS
|
|||
*/
|
||||
byte *CM_LeafPHS( int leafnum )
|
||||
{
|
||||
if( !worldmodel || leafnum <= 0 || leafnum >= worldmodel->numleafs || !cm.phs || cm_novis->integer )
|
||||
if( !worldmodel || leafnum <= 0 || leafnum >= worldmodel->numleafs || !cm.phs || sv_novis->integer )
|
||||
return cm.nullrow;
|
||||
|
||||
return worldmodel->leafs[leafnum+1].pasdata;
|
||||
|
@ -261,7 +261,7 @@ so we can't use a single PVS point
|
|||
*/
|
||||
byte *CM_FatPVS( const vec3_t org, qboolean portal )
|
||||
{
|
||||
if( !cm.pvs || cm_novis->integer )
|
||||
if( !cm.pvs || sv_novis->integer )
|
||||
return cm.nullrow;
|
||||
|
||||
bitvector = fatpvs;
|
||||
|
@ -282,7 +282,7 @@ so we can't use a single PHS point
|
|||
*/
|
||||
byte *CM_FatPHS( const vec3_t org, qboolean portal )
|
||||
{
|
||||
if( !cm.pvs || cm_novis->integer )
|
||||
if( !cm.pvs || sv_novis->integer )
|
||||
return cm.nullrow;
|
||||
|
||||
bitvector = fatphs;
|
|
@ -186,15 +186,11 @@ SOURCE=.\client\cl_view.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\cm_model.c
|
||||
SOURCE=.\common\model.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\cm_portals.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\cm_test.c
|
||||
SOURCE=.\common\portals.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "server.h"
|
||||
#include "byteorder.h"
|
||||
|
||||
sv_client_t *sv_client; // current client
|
||||
|
||||
|
@ -127,7 +126,7 @@ void SV_SetMaster_f( void )
|
|||
continue;
|
||||
}
|
||||
|
||||
if( !master_adr[slot].port ) master_adr[slot].port = BigShort( PORT_MASTER );
|
||||
if( !master_adr[slot].port ) master_adr[slot].port = BF_BigShort( PORT_MASTER );
|
||||
Msg( "Master server at %s\n", NET_AdrToString( master_adr[slot] ));
|
||||
Msg( "Sending a ping.\n" );
|
||||
Netchan_OutOfBandPrint( NS_SERVER, master_adr[slot], "ping" );
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "common.h"
|
||||
#include "server.h"
|
||||
#include "net_encode.h"
|
||||
#include "byteorder.h"
|
||||
#include "matrix_lib.h"
|
||||
#include "event_flags.h"
|
||||
#include "pm_defs.h"
|
||||
|
@ -238,7 +237,7 @@ qboolean SV_Send( int dest, const vec3_t origin, const edict_t *ent )
|
|||
// intentional fallthrough
|
||||
case MSG_PAS:
|
||||
if( origin == NULL ) return false;
|
||||
leafnum = CM_PointLeafnum( origin );
|
||||
leafnum = Mod_PointLeafnum( origin );
|
||||
mask = CM_LeafPHS( leafnum );
|
||||
break;
|
||||
case MSG_PVS_R:
|
||||
|
@ -246,7 +245,7 @@ qboolean SV_Send( int dest, const vec3_t origin, const edict_t *ent )
|
|||
// intentional fallthrough
|
||||
case MSG_PVS:
|
||||
if( origin == NULL ) return false;
|
||||
leafnum = CM_PointLeafnum( origin );
|
||||
leafnum = Mod_PointLeafnum( origin );
|
||||
mask = CM_LeafPVS( leafnum );
|
||||
break;
|
||||
case MSG_ONE:
|
||||
|
@ -288,7 +287,7 @@ qboolean SV_Send( int dest, const vec3_t origin, const edict_t *ent )
|
|||
viewOrg = cl->pViewEntity->v.origin;
|
||||
else viewOrg = cl->edict->v.origin;
|
||||
|
||||
leafnum = CM_PointLeafnum( viewOrg );
|
||||
leafnum = Mod_PointLeafnum( viewOrg );
|
||||
if( mask && (!(mask[leafnum>>3] & (1<<( leafnum & 7 )))))
|
||||
continue;
|
||||
}
|
||||
|
@ -330,7 +329,7 @@ static qboolean SV_OriginIn( int mode, const vec3_t v1, const vec3_t v2 )
|
|||
int leafnum;
|
||||
byte *mask;
|
||||
|
||||
leafnum = CM_PointLeafnum( v1 );
|
||||
leafnum = Mod_PointLeafnum( v1 );
|
||||
|
||||
switch( mode )
|
||||
{
|
||||
|
@ -345,7 +344,7 @@ static qboolean SV_OriginIn( int mode, const vec3_t v1, const vec3_t v2 )
|
|||
break;
|
||||
}
|
||||
|
||||
leafnum = CM_PointLeafnum( v2 );
|
||||
leafnum = Mod_PointLeafnum( v2 );
|
||||
|
||||
if( mask && (!( mask[leafnum>>3] & (1<<( leafnum & 7 )))))
|
||||
return false;
|
||||
|
@ -361,8 +360,8 @@ check brush boxes in fat pvs
|
|||
*/
|
||||
static qboolean SV_BoxInPVS( const vec3_t org, const vec3_t absmin, const vec3_t absmax )
|
||||
{
|
||||
// if( !CM_BoxVisible( absmin, absmax, CM_FatPVS( org, false )))
|
||||
if( !CM_BoxVisible( absmin, absmax, CM_LeafPVS( CM_PointLeafnum( org ))))
|
||||
// if( !Mod_BoxVisible( absmin, absmax, CM_FatPVS( org, false )))
|
||||
if( !Mod_BoxVisible( absmin, absmax, CM_LeafPVS( Mod_PointLeafnum( org ))))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -380,22 +379,22 @@ void SV_WriteEntityPatch( const char *filename )
|
|||
|
||||
Mem_Set( buf, 0, MAX_SYSPATH );
|
||||
FS_Read( f, buf, MAX_SYSPATH );
|
||||
ver = LittleLong(*(uint *)buf);
|
||||
ver = *(uint *)buf;
|
||||
|
||||
switch( ver )
|
||||
{
|
||||
case Q1BSP_VERSION:
|
||||
case HLBSP_VERSION:
|
||||
header = (dheader_t *)buf;
|
||||
if( LittleLong( header->lumps[LUMP_PLANES].filelen ) % sizeof( dplane_t ))
|
||||
if( header->lumps[LUMP_PLANES].filelen % sizeof( dplane_t ))
|
||||
{
|
||||
lumpofs = LittleLong( header->lumps[LUMP_PLANES].fileofs );
|
||||
lumplen = LittleLong( header->lumps[LUMP_PLANES].filelen );
|
||||
lumpofs = header->lumps[LUMP_PLANES].fileofs;
|
||||
lumplen = header->lumps[LUMP_PLANES].filelen;
|
||||
}
|
||||
else
|
||||
{
|
||||
lumpofs = LittleLong( header->lumps[LUMP_ENTITIES].fileofs );
|
||||
lumplen = LittleLong( header->lumps[LUMP_ENTITIES].filelen );
|
||||
lumpofs = header->lumps[LUMP_ENTITIES].fileofs;
|
||||
lumplen = header->lumps[LUMP_ENTITIES].filelen;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -432,22 +431,22 @@ script_t *SV_GetEntityScript( const char *filename )
|
|||
|
||||
Mem_Set( buf, 0, MAX_SYSPATH );
|
||||
FS_Read( f, buf, MAX_SYSPATH );
|
||||
ver = LittleLong(*(uint *)buf);
|
||||
ver = *(uint *)buf;
|
||||
|
||||
switch( ver )
|
||||
{
|
||||
case Q1BSP_VERSION:
|
||||
case HLBSP_VERSION:
|
||||
header = (dheader_t *)buf;
|
||||
if( LittleLong( header->lumps[LUMP_PLANES].filelen ) % sizeof( dplane_t ))
|
||||
if( header->lumps[LUMP_PLANES].filelen % sizeof( dplane_t ))
|
||||
{
|
||||
lumpofs = LittleLong( header->lumps[LUMP_PLANES].fileofs );
|
||||
lumplen = LittleLong( header->lumps[LUMP_PLANES].filelen );
|
||||
lumpofs = header->lumps[LUMP_PLANES].fileofs;
|
||||
lumplen = header->lumps[LUMP_PLANES].filelen;
|
||||
}
|
||||
else
|
||||
{
|
||||
lumpofs = LittleLong( header->lumps[LUMP_ENTITIES].fileofs );
|
||||
lumplen = LittleLong( header->lumps[LUMP_ENTITIES].filelen );
|
||||
lumpofs = header->lumps[LUMP_ENTITIES].fileofs;
|
||||
lumplen = header->lumps[LUMP_ENTITIES].filelen;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -1918,7 +1917,7 @@ pfnBoxVisible
|
|||
*/
|
||||
static int pfnBoxVisible( const float *mins, const float *maxs, const byte *pset )
|
||||
{
|
||||
return CM_BoxVisible( mins, maxs, pset );
|
||||
return Mod_BoxVisible( mins, maxs, pset );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3494,7 +3493,7 @@ void SV_PlaybackEventFull( int flags, const edict_t *pInvoker, word eventindex,
|
|||
if(!( flags & FEV_GLOBAL ))
|
||||
{
|
||||
// setup pvs cluster for invoker
|
||||
leafnum = CM_PointLeafnum( pvspoint );
|
||||
leafnum = Mod_PointLeafnum( pvspoint );
|
||||
mask = CM_LeafPVS( leafnum );
|
||||
}
|
||||
|
||||
|
@ -3512,7 +3511,7 @@ void SV_PlaybackEventFull( int flags, const edict_t *pInvoker, word eventindex,
|
|||
|
||||
if(!( flags & FEV_GLOBAL ))
|
||||
{
|
||||
leafnum = CM_PointLeafnum( cl->edict->v.origin );
|
||||
leafnum = Mod_PointLeafnum( cl->edict->v.origin );
|
||||
if( mask && (!(mask[leafnum>>3] & (1<<(leafnum & 7)))))
|
||||
continue;
|
||||
}
|
||||
|
@ -3645,7 +3644,7 @@ int pfnCheckVisibility( const edict_t *ent, byte *pset )
|
|||
// NOTE: uncommenat this if you want to get more accuracy culling on large brushes
|
||||
if( CM_GetModelType( ent->v.modelindex ) == mod_brush )
|
||||
{
|
||||
if( !CM_BoxVisible( ent->v.absmin, ent->v.absmax, pset ))
|
||||
if( !Mod_BoxVisible( ent->v.absmin, ent->v.absmax, pset ))
|
||||
return 0;
|
||||
result = 3; // visible passed by BoxVisible
|
||||
}
|
||||
|
|
|
@ -589,10 +589,10 @@ qboolean SV_StudioExtractBbox( model_t *mod, int sequence, float *mins, float *m
|
|||
|
||||
ASSERT( mod != NULL );
|
||||
|
||||
if( mod->type != mod_studio || !mod->extradata )
|
||||
if( mod->type != mod_studio || !mod->cache.data )
|
||||
return false;
|
||||
|
||||
phdr = (studiohdr_t *)mod->extradata;
|
||||
phdr = (studiohdr_t *)mod->cache.data;
|
||||
if( !phdr->numhitboxes ) return false;
|
||||
|
||||
pseqdesc = (mstudioseqdesc_t *)((byte *)phdr + phdr->seqindex);
|
||||
|
|
|
@ -981,7 +981,7 @@ SV_RecursiveSurfCheck
|
|||
|
||||
==================
|
||||
*/
|
||||
msurface_t *SV_RecursiveSurfCheck( mnode_t *node, vec3_t p1, vec3_t p2 )
|
||||
msurface_t *SV_RecursiveSurfCheck( model_t *model, mnode_t *node, vec3_t p1, vec3_t p2 )
|
||||
{
|
||||
float t1, t2, frac;
|
||||
int side, ds, dt;
|
||||
|
@ -1007,9 +1007,9 @@ msurface_t *SV_RecursiveSurfCheck( mnode_t *node, vec3_t p1, vec3_t p2 )
|
|||
}
|
||||
|
||||
if( t1 >= 0 && t2 >= 0 )
|
||||
return SV_RecursiveSurfCheck( node->children[0], p1, p2 );
|
||||
return SV_RecursiveSurfCheck( model, node->children[0], p1, p2 );
|
||||
if( t1 < 0 && t2 < 0 )
|
||||
return SV_RecursiveSurfCheck( node->children[1], p1, p2 );
|
||||
return SV_RecursiveSurfCheck( model, node->children[1], p1, p2 );
|
||||
|
||||
frac = t1 / ( t1 - t2 );
|
||||
|
||||
|
@ -1021,16 +1021,16 @@ msurface_t *SV_RecursiveSurfCheck( mnode_t *node, vec3_t p1, vec3_t p2 )
|
|||
side = (t1 < 0);
|
||||
|
||||
// now this is weird.
|
||||
surf = SV_RecursiveSurfCheck( node->children[side], p1, mid );
|
||||
surf = SV_RecursiveSurfCheck( model, node->children[side], p1, mid );
|
||||
|
||||
if( surf != NULL || ( t1 >= 0 && t2 >= 0 ) || ( t1 < 0 && t2 < 0 ))
|
||||
{
|
||||
return surf;
|
||||
}
|
||||
|
||||
surf = node->firstface;
|
||||
surf = model->surfaces + node->firstsurface;
|
||||
|
||||
for( i = 0; i < node->numfaces; i++, surf++ )
|
||||
for( i = 0; i < node->numsurfaces; i++, surf++ )
|
||||
{
|
||||
ds = (int)((float)DotProduct( mid, surf->texinfo->vecs[0] ) + surf->texinfo->vecs[0][3] );
|
||||
dt = (int)((float)DotProduct( mid, surf->texinfo->vecs[1] ) + surf->texinfo->vecs[1][3] );
|
||||
|
@ -1045,7 +1045,7 @@ msurface_t *SV_RecursiveSurfCheck( mnode_t *node, vec3_t p1, vec3_t p2 )
|
|||
}
|
||||
}
|
||||
|
||||
return SV_RecursiveSurfCheck( node->children[side^1], mid, p2 );
|
||||
return SV_RecursiveSurfCheck( model, node->children[side^1], mid, p2 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1096,7 +1096,7 @@ const char *SV_TraceTexture( edict_t *ent, const vec3_t start, const vec3_t end
|
|||
#endif
|
||||
}
|
||||
|
||||
surf = SV_RecursiveSurfCheck( &bmodel->nodes[hull->firstclipnode], start_l, end_l );
|
||||
surf = SV_RecursiveSurfCheck( bmodel, &bmodel->nodes[hull->firstclipnode], start_l, end_l );
|
||||
|
||||
if( !surf || !surf->texinfo || !surf->texinfo->texture )
|
||||
return NULL;
|
||||
|
@ -1390,7 +1390,7 @@ static float sv_modulate;
|
|||
SV_RecursiveLightPoint
|
||||
=================
|
||||
*/
|
||||
static qboolean SV_RecursiveLightPoint( mnode_t *node, const vec3_t start, const vec3_t end )
|
||||
static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec3_t start, const vec3_t end )
|
||||
{
|
||||
int side;
|
||||
mplane_t *plane;
|
||||
|
@ -1399,7 +1399,7 @@ static qboolean SV_RecursiveLightPoint( mnode_t *node, const vec3_t start, const
|
|||
vec3_t mid, scale;
|
||||
float front, back, frac;
|
||||
int i, map, size, s, t;
|
||||
byte *lm;
|
||||
color24 *lm;
|
||||
|
||||
// didn't hit anything
|
||||
if( !node->plane ) return false;
|
||||
|
@ -1419,23 +1419,23 @@ static qboolean SV_RecursiveLightPoint( mnode_t *node, const vec3_t start, const
|
|||
|
||||
side = front < 0;
|
||||
if(( back < 0 ) == side )
|
||||
return SV_RecursiveLightPoint( node->children[side], start, end );
|
||||
return SV_RecursiveLightPoint( model, node->children[side], start, end );
|
||||
|
||||
frac = front / ( front - back );
|
||||
|
||||
VectorLerp( start, frac, end, mid );
|
||||
|
||||
// co down front side
|
||||
if( SV_RecursiveLightPoint( node->children[side], start, mid ))
|
||||
if( SV_RecursiveLightPoint( model, node->children[side], start, mid ))
|
||||
return true; // hit something
|
||||
|
||||
if(( back < 0 ) == side )
|
||||
return false;// didn't hit anything
|
||||
|
||||
// check for impact on this node
|
||||
surf = node->firstface;
|
||||
surf = model->surfaces + node->firstsurface;
|
||||
|
||||
for( i = 0; i < node->numfaces; i++, surf++ )
|
||||
for( i = 0; i < node->numsurfaces; i++, surf++ )
|
||||
{
|
||||
tex = surf->texinfo;
|
||||
|
||||
|
@ -1456,16 +1456,16 @@ static qboolean SV_RecursiveLightPoint( mnode_t *node, const vec3_t start, const
|
|||
|
||||
VectorClear( sv_pointColor );
|
||||
|
||||
lm = surf->samples + 3 * (t * ((surf->extents[0] >> 4) + 1) + s);
|
||||
size = ((surf->extents[0] >> 4) + 1) * ((surf->extents[1] >> 4) + 1) * 3;
|
||||
lm = surf->samples + (t * ((surf->extents[0] >> 4) + 1) + s);
|
||||
size = ((surf->extents[0] >> 4) + 1) * ((surf->extents[1] >> 4) + 1);
|
||||
|
||||
for( map = 0; map < surf->numstyles; map++ )
|
||||
for( map = 0; map < MAXLIGHTMAPS && surf->styles[map] != 255; map++ )
|
||||
{
|
||||
VectorScale( sv.lightstyles[surf->styles[map]].rgb, sv_modulate, scale );
|
||||
|
||||
sv_pointColor[0] += lm[0] * scale[0];
|
||||
sv_pointColor[1] += lm[1] * scale[1];
|
||||
sv_pointColor[2] += lm[2] * scale[2];
|
||||
sv_pointColor[0] += lm->r * scale[0];
|
||||
sv_pointColor[1] += lm->g * scale[1];
|
||||
sv_pointColor[2] += lm->b * scale[2];
|
||||
|
||||
lm += size; // skip to next lightmap
|
||||
}
|
||||
|
@ -1473,7 +1473,7 @@ static qboolean SV_RecursiveLightPoint( mnode_t *node, const vec3_t start, const
|
|||
}
|
||||
|
||||
// go down back side
|
||||
return SV_RecursiveLightPoint( node->children[!side], mid, end );
|
||||
return SV_RecursiveLightPoint( model, node->children[!side], mid, end );
|
||||
}
|
||||
|
||||
void SV_RunLightStyles( void )
|
||||
|
@ -1561,7 +1561,7 @@ int SV_LightForEntity( edict_t *pEdict )
|
|||
VectorSet( sv_pointColor, 1.0f, 1.0f, 1.0f );
|
||||
|
||||
sv_modulate = sv_lighting_modulate->value * (1.0f / 255);
|
||||
SV_RecursiveLightPoint( worldmodel->nodes, start, end );
|
||||
SV_RecursiveLightPoint( worldmodel, worldmodel->nodes, start, end );
|
||||
|
||||
return VectorAvg( sv_pointColor );
|
||||
}
|
|
@ -194,10 +194,13 @@ typedef struct
|
|||
vec3_t bbmax;
|
||||
} mstudiobbox_t;
|
||||
|
||||
#ifndef CACHE_USER
|
||||
#define CACHE_USER
|
||||
typedef struct cache_user_s
|
||||
{
|
||||
void *data;
|
||||
void *data; // extradata
|
||||
} cache_user_t;
|
||||
#endif
|
||||
|
||||
// demand loaded sequence groups
|
||||
typedef struct
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "launch.h"
|
||||
#include "bspfile.h"
|
||||
#include "byteorder.h"
|
||||
|
||||
#define NUM_BYTES 256
|
||||
#define CRC32_INIT_VALUE 0xFFFFFFFFUL
|
||||
|
@ -225,8 +224,7 @@ qboolean CRC32_MapFile( dword *crcvalue, const char *filename )
|
|||
file_t *f;
|
||||
dheader_t header;
|
||||
char buffer[1024];
|
||||
int i, num_bytes;
|
||||
int lumpofs, lumplen;
|
||||
int i, num_bytes, lumplen;
|
||||
qboolean blue_shift = false;
|
||||
|
||||
f = FS_Open( filename, "rb", false );
|
||||
|
@ -241,10 +239,8 @@ qboolean CRC32_MapFile( dword *crcvalue, const char *filename )
|
|||
return false;
|
||||
}
|
||||
|
||||
i = LittleLong( header.version );
|
||||
|
||||
// invalid version ?
|
||||
if( i != Q1BSP_VERSION && i != HLBSP_VERSION )
|
||||
if( header.version != Q1BSP_VERSION && header.version != HLBSP_VERSION )
|
||||
{
|
||||
FS_Close( f );
|
||||
return false;
|
||||
|
@ -254,7 +250,7 @@ qboolean CRC32_MapFile( dword *crcvalue, const char *filename )
|
|||
CRC32_Init( crcvalue );
|
||||
|
||||
// check for Blue-Shift maps
|
||||
if( LittleLong( header.lumps[LUMP_PLANES].filelen ) % sizeof( dplane_t ))
|
||||
if( header.lumps[LUMP_PLANES].filelen % sizeof( dplane_t ))
|
||||
blue_shift = true;
|
||||
|
||||
for( i = 0; i < HEADER_LUMPS; i++ )
|
||||
|
@ -262,9 +258,8 @@ qboolean CRC32_MapFile( dword *crcvalue, const char *filename )
|
|||
if( blue_shift && i == LUMP_PLANES ) continue;
|
||||
else if( i == LUMP_ENTITIES ) continue;
|
||||
|
||||
lumpofs = LittleLong( header.lumps[i].fileofs );
|
||||
lumplen = LittleLong( header.lumps[i].filelen );
|
||||
FS_Seek( f, lumpofs, SEEK_SET );
|
||||
lumplen = header.lumps[i].filelen;
|
||||
FS_Seek( f, header.lumps[i].fileofs, SEEK_SET );
|
||||
|
||||
while( lumplen > 0 )
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "launch.h"
|
||||
#include "wadfile.h"
|
||||
#include "filesystem.h"
|
||||
#include "byteorder.h"
|
||||
#include "library.h"
|
||||
#include "mathlib.h"
|
||||
|
||||
|
@ -471,9 +470,6 @@ pack_t *FS_LoadPackPAK( const char *packfile )
|
|||
return NULL;
|
||||
}
|
||||
|
||||
header.dirofs = LittleLong( header.dirofs );
|
||||
header.dirlen = LittleLong( header.dirlen );
|
||||
|
||||
if( header.dirlen % sizeof( dpackfile_t ))
|
||||
{
|
||||
MsgDev( D_ERROR, "%s has an invalid directory size. Ignored.\n", packfile );
|
||||
|
@ -518,9 +514,7 @@ pack_t *FS_LoadPackPAK( const char *packfile )
|
|||
// parse the directory
|
||||
for( i = 0; i < numpackfiles; i++ )
|
||||
{
|
||||
fs_offset_t offset = LittleLong( info[i].filepos );
|
||||
fs_offset_t size = LittleLong( info[i].filelen );
|
||||
FS_AddFileToPack( info[i].name, pack, offset, size );
|
||||
FS_AddFileToPack( info[i].name, pack, info[i].filepos, info[i].filelen );
|
||||
}
|
||||
|
||||
Mem_Free( info );
|
||||
|
@ -3553,9 +3547,6 @@ static qboolean W_ReadLumpTable( wfile_t *wad )
|
|||
// swap everything
|
||||
for( i = 0; i < numlumps; i++ )
|
||||
{
|
||||
int filepos = LittleLong( srclumps[i].filepos );
|
||||
int realsize = LittleLong( srclumps[i].disksize );
|
||||
int size = LittleLong( srclumps[i].size );
|
||||
char name[16];
|
||||
|
||||
// cleanup lumpname
|
||||
|
@ -3565,7 +3556,7 @@ static qboolean W_ReadLumpTable( wfile_t *wad )
|
|||
k = com.strlen( com.strrchr( name, '*' ));
|
||||
if( k ) name[com.strlen( name ) - k] = '!'; // quake1 issues (can't save images that contain '*' symbol)
|
||||
|
||||
W_AddFileToWad( name, wad, filepos, size, realsize, srclumps[i].type, srclumps[i].compression );
|
||||
W_AddFileToWad( name, wad, srclumps[i].filepos, srclumps[i].size, srclumps[i].disksize, srclumps[i].type, srclumps[i].compression );
|
||||
}
|
||||
|
||||
// release source lumps
|
||||
|
@ -3662,7 +3653,7 @@ qboolean W_WriteLump( wfile_t *wad, dlumpinfo_t *lump, const void* data, size_t
|
|||
Mem_Free( outbuf );
|
||||
return ( lump->disksize != 0 ) ? true : false;
|
||||
default: // CMP_NONE method
|
||||
lump->size = lump->disksize = LittleLong( datasize );
|
||||
lump->size = lump->disksize = datasize;
|
||||
lump->compression = CMP_NONE;
|
||||
write( wad->handle, data, datasize ); // just write file
|
||||
return true;
|
||||
|
@ -3680,8 +3671,6 @@ int W_Check( const char *filename )
|
|||
{
|
||||
file_t *testwad;
|
||||
dwadinfo_t header;
|
||||
int numlumps;
|
||||
int infotableofs;
|
||||
|
||||
testwad = FS_Open( filename, "rb", false );
|
||||
if( !testwad ) return 0; // just not exist
|
||||
|
@ -3704,15 +3693,14 @@ int W_Check( const char *filename )
|
|||
return -2; // invalid id
|
||||
}
|
||||
|
||||
numlumps = LittleLong( header.numlumps );
|
||||
if( numlumps < 0 || numlumps > MAX_FILES_IN_WAD )
|
||||
if( header.numlumps < 0 || header.numlumps > MAX_FILES_IN_WAD )
|
||||
{
|
||||
// invalid lump number
|
||||
FS_Close( testwad );
|
||||
return -3; // invalid lumpcount
|
||||
}
|
||||
infotableofs = LittleLong( header.infotableofs );
|
||||
if( FS_Seek( testwad, infotableofs, SEEK_SET ))
|
||||
|
||||
if( FS_Seek( testwad, header.infotableofs, SEEK_SET ))
|
||||
{
|
||||
// corrupted or not wad
|
||||
FS_Close( testwad );
|
||||
|
@ -3757,8 +3745,8 @@ wfile_t *W_Open( const char *filename, const char *mode )
|
|||
|
||||
// save space for header
|
||||
hdr.ident = IDWAD3HEADER;
|
||||
hdr.numlumps = LittleLong( wad->numlumps );
|
||||
hdr.infotableofs = LittleLong(sizeof( dwadinfo_t ));
|
||||
hdr.numlumps = wad->numlumps;
|
||||
hdr.infotableofs = sizeof( dwadinfo_t );
|
||||
write( wad->handle, &hdr, sizeof( hdr ));
|
||||
write( wad->handle, comment, com.strlen( comment ) + 1 );
|
||||
wad->infotableofs = tell( wad->handle );
|
||||
|
@ -3797,13 +3785,13 @@ wfile_t *W_Open( const char *filename, const char *mode )
|
|||
return NULL;
|
||||
}
|
||||
|
||||
wad->numlumps = LittleLong( header.numlumps );
|
||||
wad->numlumps = header.numlumps;
|
||||
if( wad->numlumps >= MAX_FILES_IN_WAD && wad->mode == O_APPEND )
|
||||
{
|
||||
MsgDev( D_WARN, "W_Open: %s is full (%i lumps)\n", wad->numlumps );
|
||||
wad->mode = O_RDONLY; // set read-only mode
|
||||
}
|
||||
wad->infotableofs = LittleLong( header.infotableofs ); // save infotableofs position
|
||||
wad->infotableofs = header.infotableofs; // save infotableofs position
|
||||
if( lseek( wad->handle, wad->infotableofs, SEEK_SET ) == -1 )
|
||||
{
|
||||
MsgDev( D_ERROR, "W_Open: %s can't find lump allocation table\n", filename );
|
||||
|
@ -3867,8 +3855,8 @@ void W_Close( wfile_t *wad )
|
|||
|
||||
// write the header
|
||||
hdr.ident = IDWAD3HEADER;
|
||||
hdr.numlumps = LittleLong( wad->numlumps );
|
||||
hdr.infotableofs = LittleLong( ofs );
|
||||
hdr.numlumps = wad->numlumps;
|
||||
hdr.infotableofs = ofs;
|
||||
|
||||
lseek( wad->handle, 0, SEEK_SET );
|
||||
write( wad->handle, &hdr, sizeof( hdr ));
|
||||
|
@ -3920,7 +3908,7 @@ fs_offset_t W_SaveLump( wfile_t *wad, const char *lump, const void* data, size_t
|
|||
|
||||
// write header
|
||||
W_CleanupName( lump, info->name );
|
||||
info->filepos = LittleLong( tell( wad->handle ));
|
||||
info->filepos = tell( wad->handle );
|
||||
info->compression = cmp;
|
||||
info->type = type;
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "launch.h"
|
||||
#include "wadfile.h"
|
||||
#include "byteorder.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
convar_t *hpk_maxsize;
|
||||
|
@ -402,17 +401,17 @@ static qboolean HPAK_Validate( const char *filename, qboolean quiet )
|
|||
if( !quiet ) MsgDev( D_INFO, "Validating %s\n", pakname );
|
||||
|
||||
FS_Read( f, &hdr, sizeof( hdr ));
|
||||
if( LittleLong( hdr.ident )!= IDCUSTOMHEADER || LittleLong( hdr.version ) != IDCUSTOM_VERSION )
|
||||
if( hdr.ident != IDCUSTOMHEADER || hdr.version != IDCUSTOM_VERSION )
|
||||
{
|
||||
MsgDev( D_ERROR, "HPAK_ValidatePak: %s does not have a valid HPAK header.\n", pakname );
|
||||
FS_Close( f );
|
||||
return false;
|
||||
}
|
||||
|
||||
FS_Seek( f, LittleLong( hdr.seek ), SEEK_SET );
|
||||
FS_Seek( f, hdr.seek, SEEK_SET );
|
||||
FS_Read( f, &num_lumps, sizeof( num_lumps ));
|
||||
|
||||
if( LittleLong( num_lumps ) < 1 || LittleLong( num_lumps ) > MAX_FILES_IN_WAD )
|
||||
if( num_lumps < 1 || num_lumps > MAX_FILES_IN_WAD )
|
||||
{
|
||||
MsgDev( D_ERROR, "HPAK_ValidatePak: %s has too many lumps %u.\n", pakname, num_lumps );
|
||||
FS_Close( f );
|
||||
|
@ -543,7 +542,7 @@ qboolean HPAK_ResourceForHash( const char *filename, char *inHash, resource_t *p
|
|||
|
||||
FS_Read( f, &hdr, sizeof( hdr ));
|
||||
|
||||
if( LittleLong( hdr.ident ) != IDCUSTOMHEADER )
|
||||
if( hdr.ident != IDCUSTOMHEADER )
|
||||
{
|
||||
MsgDev( D_ERROR, "HPAK_ResourceForHash: %s it's not a HPK file.\n", pakname );
|
||||
FS_Close( f );
|
||||
|
@ -560,9 +559,9 @@ qboolean HPAK_ResourceForHash( const char *filename, char *inHash, resource_t *p
|
|||
FS_Seek( f, hdr.seek, SEEK_SET );
|
||||
FS_Read( f, &hpakcontainer.count, sizeof( hpakcontainer.count ));
|
||||
|
||||
if( LittleLong( hpakcontainer.count ) < 1 || LittleLong( hpakcontainer.count ) > MAX_FILES_IN_WAD )
|
||||
if( hpakcontainer.count < 1 || hpakcontainer.count > MAX_FILES_IN_WAD )
|
||||
{
|
||||
MsgDev( D_ERROR, "HPAK_ResourceForHash: %s has too many lumps %u.\n", pakname, LittleLong( hpakcontainer.count ));
|
||||
MsgDev( D_ERROR, "HPAK_ResourceForHash: %s has too many lumps %u.\n", pakname, hpakcontainer.count );
|
||||
FS_Close( f );
|
||||
return false;
|
||||
}
|
||||
|
@ -593,7 +592,7 @@ qboolean HPAK_ResourceForIndex( const char *filename, int index, resource_t *pRe
|
|||
f = FS_Open( pakname, "rb", false );
|
||||
FS_Read( f, &hdr, sizeof( hdr ));
|
||||
|
||||
if( LittleLong( hdr.ident ) != IDCUSTOMHEADER )
|
||||
if( hdr.ident != IDCUSTOMHEADER )
|
||||
{
|
||||
MsgDev( D_ERROR, "HPAK_ResourceForIndex: %s it's not a HPK file.\n", pakname );
|
||||
FS_Close( f );
|
||||
|
@ -610,9 +609,9 @@ qboolean HPAK_ResourceForIndex( const char *filename, int index, resource_t *pRe
|
|||
FS_Seek( f, hdr.seek, SEEK_SET );
|
||||
FS_Read( f, &hpakcontainer.count, sizeof( hpakcontainer.count ));
|
||||
|
||||
if( LittleLong( hpakcontainer.count ) < 1 || LittleLong( hpakcontainer.count ) > MAX_FILES_IN_WAD )
|
||||
if( hpakcontainer.count < 1 || hpakcontainer.count > MAX_FILES_IN_WAD )
|
||||
{
|
||||
MsgDev( D_ERROR, "HPAK_ResourceForIndex: %s has too many lumps %u.\n", pakname, LittleLong( hpakcontainer.count ));
|
||||
MsgDev( D_ERROR, "HPAK_ResourceForIndex: %s has too many lumps %u.\n", pakname, hpakcontainer.count );
|
||||
FS_Close( f );
|
||||
return false;
|
||||
}
|
||||
|
@ -677,7 +676,7 @@ qboolean HPAK_GetDataPointer( const char *filename, resource_t *pResource, byte
|
|||
|
||||
FS_Read( f, &hdr, sizeof( hdr ));
|
||||
|
||||
if( LittleLong( hdr.ident ) != IDCUSTOMHEADER )
|
||||
if( hdr.ident != IDCUSTOMHEADER )
|
||||
{
|
||||
MsgDev( D_ERROR, "HPAK_GetDataPointer: %s it's not a HPK file.\n", pakname );
|
||||
FS_Close( f );
|
||||
|
@ -694,7 +693,7 @@ qboolean HPAK_GetDataPointer( const char *filename, resource_t *pResource, byte
|
|||
FS_Seek( f, hdr.seek, SEEK_SET );
|
||||
FS_Read( f, &num_lumps, sizeof( num_lumps ));
|
||||
|
||||
if( LittleLong( num_lumps ) < 1 || LittleLong( num_lumps ) > MAX_FILES_IN_WAD )
|
||||
if( num_lumps < 1 || num_lumps > MAX_FILES_IN_WAD )
|
||||
{
|
||||
MsgDev( D_ERROR, "HPAK_GetDataPointer: %s has too many lumps %u.\n", filename, num_lumps );
|
||||
FS_Close( f );
|
||||
|
@ -771,7 +770,7 @@ void HPAK_RemoveLump( const char *name, resource_t *resource )
|
|||
FS_Read( f1, &hash_pack_header, sizeof( hpak_header_t ));
|
||||
FS_Write( f2, &hash_pack_header, sizeof( hpak_header_t ));
|
||||
|
||||
if( LittleLong( hash_pack_header.ident )!= IDCUSTOMHEADER || LittleLong( hash_pack_header.version ) != IDCUSTOM_VERSION )
|
||||
if( hash_pack_header.ident != IDCUSTOMHEADER || hash_pack_header.version != IDCUSTOM_VERSION )
|
||||
{
|
||||
MsgDev( D_ERROR, "HPAK_RemoveLump: %s has invalid header.\n", read_path );
|
||||
FS_Close( f1 );
|
||||
|
@ -783,7 +782,7 @@ void HPAK_RemoveLump( const char *name, resource_t *resource )
|
|||
FS_Seek( f1, hash_pack_header.seek, SEEK_SET );
|
||||
FS_Read( f1, &hpak_read.count, sizeof( hpak_read.count ));
|
||||
|
||||
if( LittleLong( hpak_read.count ) < 1 || LittleLong( hpak_read.count ) > MAX_FILES_IN_WAD )
|
||||
if( hpak_read.count < 1 || hpak_read.count > MAX_FILES_IN_WAD )
|
||||
{
|
||||
MsgDev( D_ERROR, "HPAK_RemoveLump: %s has invalid number of lumps.\n", read_path );
|
||||
FS_Close( f1 );
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#define IMAGELIB_H
|
||||
|
||||
#include "launch.h"
|
||||
#include "byteorder.h"
|
||||
|
||||
// skyorder_q2[6] = { 2, 3, 1, 0, 4, 5, }; // Quake, Half-Life skybox ordering
|
||||
// skyorder_ms[6] = { 4, 5, 1, 0, 2, 3 }; // Microsoft DDS ordering (reverse)
|
||||
|
|
|
@ -23,20 +23,20 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, size_t filesize )
|
|||
buf_p = (byte *)buffer;
|
||||
bhdr.id[0] = *buf_p++;
|
||||
bhdr.id[1] = *buf_p++; // move pointer
|
||||
bhdr.fileSize = LittleLong(*(long *)buf_p); buf_p += 4;
|
||||
bhdr.reserved0 = LittleLong(*(long *)buf_p); buf_p += 4;
|
||||
bhdr.bitmapDataOffset = LittleLong(*(long *)buf_p); buf_p += 4;
|
||||
bhdr.bitmapHeaderSize = LittleLong(*(long *)buf_p); buf_p += 4;
|
||||
bhdr.width = LittleLong(*(long *)buf_p); buf_p += 4;
|
||||
bhdr.height = LittleLong(*(long *)buf_p); buf_p += 4;
|
||||
bhdr.planes = LittleShort(*(short *)buf_p); buf_p += 2;
|
||||
bhdr.bitsPerPixel = LittleShort(*(short *)buf_p); buf_p += 2;
|
||||
bhdr.compression = LittleLong(*(long *)buf_p); buf_p += 4;
|
||||
bhdr.bitmapDataSize = LittleLong(*(long *)buf_p); buf_p += 4;
|
||||
bhdr.hRes = LittleLong(*(long *)buf_p); buf_p += 4;
|
||||
bhdr.vRes = LittleLong(*(long *)buf_p); buf_p += 4;
|
||||
bhdr.colors = LittleLong(*(long *)buf_p); buf_p += 4;
|
||||
bhdr.importantColors = LittleLong(*(long *)buf_p); buf_p += 4;
|
||||
bhdr.fileSize = *(long *)buf_p; buf_p += 4;
|
||||
bhdr.reserved0 = *(long *)buf_p; buf_p += 4;
|
||||
bhdr.bitmapDataOffset = *(long *)buf_p; buf_p += 4;
|
||||
bhdr.bitmapHeaderSize = *(long *)buf_p; buf_p += 4;
|
||||
bhdr.width = *(long *)buf_p; buf_p += 4;
|
||||
bhdr.height = *(long *)buf_p; buf_p += 4;
|
||||
bhdr.planes = *(short *)buf_p; buf_p += 2;
|
||||
bhdr.bitsPerPixel = *(short *)buf_p; buf_p += 2;
|
||||
bhdr.compression = *(long *)buf_p; buf_p += 4;
|
||||
bhdr.bitmapDataSize = *(long *)buf_p; buf_p += 4;
|
||||
bhdr.hRes = *(long *)buf_p; buf_p += 4;
|
||||
bhdr.vRes = *(long *)buf_p; buf_p += 4;
|
||||
bhdr.colors = *(long *)buf_p; buf_p += 4;
|
||||
bhdr.importantColors = *(long *)buf_p; buf_p += 4;
|
||||
|
||||
// bogus file header check
|
||||
if( bhdr.reserved0 != 0 ) return false;
|
||||
|
|
|
@ -1703,15 +1703,14 @@ qboolean Image_DecompressDXT( uint target, int level, int intformat, uint width,
|
|||
for( x = 0; x < w; x += 4 )
|
||||
{
|
||||
sColor0 = *((word*)fin);
|
||||
sColor0 = LittleShort(sColor0);
|
||||
sColor0 = sColor0;
|
||||
sColor1 = *((word*)(fin + 2));
|
||||
sColor1 = LittleShort(sColor1);
|
||||
sColor1 = sColor1;
|
||||
|
||||
Image_DXTReadColor(sColor0, colours);
|
||||
Image_DXTReadColor(sColor1, colours + 1);
|
||||
|
||||
bitmask = ((uint*)fin)[1];
|
||||
bitmask = LittleLong( bitmask );
|
||||
fin += 8;
|
||||
|
||||
if (sColor0 > sColor1)
|
||||
|
@ -1779,7 +1778,6 @@ qboolean Image_DecompressDXT( uint target, int level, int intformat, uint width,
|
|||
fin += 8;
|
||||
Image_DXTReadColors( fin, colours );
|
||||
bitmask = ((uint*)fin)[1];
|
||||
bitmask = LittleLong( bitmask );
|
||||
fin += 8;
|
||||
|
||||
// four-color block: derive the other two colors.
|
||||
|
@ -1846,7 +1844,6 @@ qboolean Image_DecompressDXT( uint target, int level, int intformat, uint width,
|
|||
|
||||
Image_DXTReadColors(fin, colours);
|
||||
bitmask = ((uint*)fin)[1];
|
||||
bitmask = LittleLong(bitmask);
|
||||
fin += 8;
|
||||
|
||||
// four-color block: derive the other two colors.
|
||||
|
@ -2098,10 +2095,10 @@ qboolean Image_DecompressARGB( uint target, int level, int intformat, uint width
|
|||
else if( image.palette )
|
||||
{
|
||||
byte *pal = image.palette; //copy ptr
|
||||
r_bitmask = BuffLittleLong( pal ); pal += 4;
|
||||
g_bitmask = BuffLittleLong( pal ); pal += 4;
|
||||
b_bitmask = BuffLittleLong( pal ); pal += 4;
|
||||
a_bitmask = BuffLittleLong( pal ); pal += 4;
|
||||
r_bitmask = *(long *)pal; pal += 4;
|
||||
g_bitmask = *(long *)pal; pal += 4;
|
||||
b_bitmask = *(long *)pal; pal += 4;
|
||||
a_bitmask = *(long *)pal; pal += 4;
|
||||
}
|
||||
else return false; // rgba mask unset
|
||||
|
||||
|
@ -2122,10 +2119,11 @@ qboolean Image_DecompressARGB( uint target, int level, int intformat, uint width
|
|||
{
|
||||
// less than 4 byte to write?
|
||||
if( TempBpp == 1 ) ReadI = *((byte*) fin );
|
||||
else if( TempBpp == 2 ) ReadI = BuffLittleShort( fin );
|
||||
else if( TempBpp == 3 ) ReadI = BuffLittleLong( fin );
|
||||
else if( TempBpp == 2 ) ReadI = *(short *)fin;
|
||||
else if( TempBpp == 3 ) ReadI = *(short *)fin;
|
||||
}
|
||||
else ReadI = BuffLittleLong( fin );
|
||||
else ReadI = *(long *)fin;
|
||||
|
||||
fin += TempBpp;
|
||||
fout[i] = ((ReadI & r_bitmask)>> RedR) << RedL;
|
||||
|
||||
|
@ -2385,7 +2383,6 @@ qboolean Image_LoadDDS( const char *name, const byte *buffer, size_t filesize )
|
|||
}
|
||||
|
||||
Mem_Copy( &header, buffer, sizeof( dds_t ));
|
||||
SwapBlock((int *)&header, sizeof( dds_t ));
|
||||
|
||||
if( header.dwIdent != DDSHEADER ) return false; // it's not a dds file, just skip it
|
||||
if( header.dwSize != sizeof(dds_t) - sizeof( uint )) // size of the structure (minus MagicNum)
|
||||
|
|
|
@ -18,26 +18,17 @@ qboolean Image_LoadPCX( const char *name, const byte *buffer, size_t filesize )
|
|||
byte *pix, *pbuf, *palette, *fin, *enddata;
|
||||
|
||||
fin = (byte *)buffer;
|
||||
Mem_Copy(&pcx, fin, sizeof(pcx));
|
||||
Mem_Copy( &pcx, fin, sizeof( pcx ));
|
||||
fin += sizeof(pcx);
|
||||
|
||||
// probably it's not pcx file
|
||||
if( pcx.manufacturer != 0x0a || pcx.version != 5 || pcx.encoding != 1 ) return false;
|
||||
if( filesize < (int)sizeof(pcx) + 768)
|
||||
if( filesize < (int)sizeof(pcx) + 768 )
|
||||
{
|
||||
MsgDev( D_ERROR, "Image_LoadPCX: file (%s) have invalid size\n", name );
|
||||
return false;
|
||||
}
|
||||
|
||||
pcx.xmax = LittleShort (pcx.xmax);
|
||||
pcx.xmin = LittleShort (pcx.xmin);
|
||||
pcx.ymax = LittleShort (pcx.ymax);
|
||||
pcx.ymin = LittleShort (pcx.ymin);
|
||||
pcx.hres = LittleShort (pcx.hres);
|
||||
pcx.vres = LittleShort (pcx.vres);
|
||||
pcx.bytes_per_line = LittleShort (pcx.bytes_per_line);
|
||||
pcx.palette_type = LittleShort (pcx.palette_type);
|
||||
|
||||
image.width = pcx.xmax + 1 - pcx.xmin;
|
||||
image.height = pcx.ymax + 1 - pcx.ymin;
|
||||
|
||||
|
@ -46,7 +37,8 @@ qboolean Image_LoadPCX( const char *name, const byte *buffer, size_t filesize )
|
|||
MsgDev( D_ERROR, "Image_LoadPCX: (%s) have unknown version '%d'\n", name, pcx.version );
|
||||
return false;
|
||||
}
|
||||
if(!Image_ValidSize( name )) return false;
|
||||
if( !Image_ValidSize( name ))
|
||||
return false;
|
||||
palette = (byte *)buffer + filesize - 768;
|
||||
|
||||
image.depth = 1;
|
||||
|
@ -59,7 +51,7 @@ qboolean Image_LoadPCX( const char *name, const byte *buffer, size_t filesize )
|
|||
for( y = 0; y < image.height && fin < enddata; y++ )
|
||||
{
|
||||
pix = pbuf + y * image.width;
|
||||
for (x = 0; x < image.width && fin < enddata;)
|
||||
for( x = 0; x < image.width && fin < enddata; )
|
||||
{
|
||||
dataByte = *fin++;
|
||||
if( dataByte >= 0xC0 )
|
||||
|
@ -74,7 +66,7 @@ qboolean Image_LoadPCX( const char *name, const byte *buffer, size_t filesize )
|
|||
}
|
||||
// the number of bytes per line is always forced to an even number
|
||||
fin += pcx.bytes_per_line - image.width;
|
||||
while(x < image.width) pix[x++] = 0;
|
||||
while( x < image.width ) pix[x++] = 0;
|
||||
}
|
||||
|
||||
// NOTE: IL_HINT_Q2 does wrong result for sprite frames. use with caution
|
||||
|
@ -138,13 +130,13 @@ qboolean Image_SavePCX( const char *name, rgbdata_t *pix )
|
|||
pcx.bits_per_pixel = 8; // 256 color
|
||||
pcx.xmin = 0;
|
||||
pcx.ymin = 0;
|
||||
pcx.xmax = LittleShort((short)(pix->width - 1));
|
||||
pcx.ymax = LittleShort((short)(pix->height - 1));
|
||||
pcx.hres = LittleShort((short)pix->width);
|
||||
pcx.vres = LittleShort((short)pix->height);
|
||||
pcx.xmax = (short)(pix->width - 1);
|
||||
pcx.ymax = (short)(pix->height - 1);
|
||||
pcx.hres = (short)pix->width;
|
||||
pcx.vres = (short)pix->height;
|
||||
pcx.color_planes = 1; // chunky image
|
||||
pcx.bytes_per_line = LittleShort((short)pix->width);
|
||||
pcx.palette_type = LittleShort( 1 ); // not a grey scale
|
||||
pcx.bytes_per_line = (short)pix->width;
|
||||
pcx.palette_type = 1; // not a grey scale
|
||||
|
||||
// pack the image
|
||||
palette = pix->palette;
|
||||
|
|
|
@ -30,10 +30,10 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, size_t filesize )
|
|||
targa_header.colormap_index = buf_p[0] + buf_p[1] * 256; buf_p += 2;
|
||||
targa_header.colormap_length = buf_p[0] + buf_p[1] * 256; buf_p += 2;
|
||||
targa_header.colormap_size = *buf_p; buf_p += 1;
|
||||
targa_header.x_origin = LittleShort( *((short *)buf_p )); buf_p += 2;
|
||||
targa_header.y_origin = LittleShort( *((short *)buf_p )); buf_p += 2;
|
||||
targa_header.width = image.width = LittleShort(*((short *)buf_p)); buf_p += 2;
|
||||
targa_header.height = image.height = LittleShort(*((short *)buf_p)); buf_p += 2;
|
||||
targa_header.x_origin = *(short *)buf_p; buf_p += 2;
|
||||
targa_header.y_origin = *(short *)buf_p; buf_p += 2;
|
||||
targa_header.width = image.width = *(short *)buf_p; buf_p += 2;
|
||||
targa_header.height = image.height = *(short *)buf_p; buf_p += 2;
|
||||
targa_header.pixel_size = *buf_p++;
|
||||
targa_header.attributes = *buf_p++;
|
||||
if( targa_header.id_length != 0 ) buf_p += targa_header.id_length; // skip TARGA image comment
|
||||
|
|
|
@ -498,51 +498,51 @@ void Image_SetPalette( const byte *pal, uint *d_table )
|
|||
case LUMP_DECAL:
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
rgba[3] = pal[765];
|
||||
rgba[2] = pal[766];
|
||||
rgba[1] = pal[767];
|
||||
rgba[0] = i;
|
||||
d_table[i] = BuffBigLong( rgba );
|
||||
rgba[0] = pal[765];
|
||||
rgba[1] = pal[766];
|
||||
rgba[2] = pal[767];
|
||||
rgba[3] = i;
|
||||
d_table[i] = *(uint *)rgba;
|
||||
}
|
||||
break;
|
||||
case LUMP_TRANSPARENT:
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
rgba[3] = pal[i*3+0];
|
||||
rgba[2] = pal[i*3+1];
|
||||
rgba[1] = pal[i*3+2];
|
||||
rgba[0] = pal[i] == 255 ? pal[i] : 0xFF;
|
||||
d_table[i] = BuffBigLong( rgba );
|
||||
rgba[0] = pal[i*3+0];
|
||||
rgba[1] = pal[i*3+1];
|
||||
rgba[2] = pal[i*3+2];
|
||||
rgba[3] = pal[i] == 255 ? pal[i] : 0xFF;
|
||||
d_table[i] = *(uint *)rgba;
|
||||
}
|
||||
break;
|
||||
case LUMP_QFONT:
|
||||
for (i = 1; i < 256; i++)
|
||||
for( i = 1; i < 256; i++ )
|
||||
{
|
||||
rgba[3] = pal[i*3+0];
|
||||
rgba[2] = pal[i*3+1];
|
||||
rgba[1] = pal[i*3+2];
|
||||
rgba[0] = 0xFF;
|
||||
d_table[i] = BuffBigLong( rgba );
|
||||
rgba[0] = pal[i*3+0];
|
||||
rgba[1] = pal[i*3+1];
|
||||
rgba[2] = pal[i*3+2];
|
||||
rgba[3] = 0xFF;
|
||||
d_table[i] = *(uint *)rgba;
|
||||
}
|
||||
break;
|
||||
case LUMP_NORMAL:
|
||||
for (i = 0; i < 256; i++)
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
rgba[3] = pal[i*3+0];
|
||||
rgba[2] = pal[i*3+1];
|
||||
rgba[1] = pal[i*3+2];
|
||||
rgba[0] = 0xFF;
|
||||
d_table[i] = BuffBigLong( rgba );
|
||||
rgba[0] = pal[i*3+0];
|
||||
rgba[1] = pal[i*3+1];
|
||||
rgba[2] = pal[i*3+2];
|
||||
rgba[3] = 0xFF;
|
||||
d_table[i] = *(uint *)rgba;
|
||||
}
|
||||
break;
|
||||
case LUMP_EXTENDED:
|
||||
for (i = 0; i < 256; i++)
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
rgba[3] = pal[i*4+0];
|
||||
rgba[2] = pal[i*4+1];
|
||||
rgba[1] = pal[i*4+2];
|
||||
rgba[0] = pal[i*4+3];
|
||||
d_table[i] = BuffBigLong( rgba );
|
||||
rgba[0] = pal[i*4+0];
|
||||
rgba[1] = pal[i*4+1];
|
||||
rgba[2] = pal[i*4+2];
|
||||
rgba[3] = pal[i*4+3];
|
||||
d_table[i] = *(uint *)rgba;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -588,7 +588,7 @@ void Image_GetPaletteQ2( void )
|
|||
if(!q2palette_init)
|
||||
{
|
||||
Image_SetPalette( palette_q2, d_8toQ2table );
|
||||
d_8toQ2table[255] &= LittleLong(0xffffff);
|
||||
d_8toQ2table[255] &= 0xFFFFFF;
|
||||
q2palette_init = true;
|
||||
}
|
||||
image.d_currentpal = d_8toQ2table;
|
||||
|
@ -614,7 +614,7 @@ void Image_GetPalettePCX( const byte *pal )
|
|||
if( pal )
|
||||
{
|
||||
Image_SetPalette( pal, d_8to24table );
|
||||
d_8to24table[255] &= LittleLong(0xffffff);
|
||||
d_8to24table[255] &= 0xFFFFFF;
|
||||
image.d_currentpal = d_8to24table;
|
||||
}
|
||||
else Image_GetPaletteQ2();
|
||||
|
@ -638,7 +638,7 @@ void Image_GetPaletteLMP( const byte *pal, int rendermode )
|
|||
if( pal )
|
||||
{
|
||||
Image_SetPalette( pal, d_8to24table );
|
||||
d_8to24table[255] &= LittleLong(0xffffff);
|
||||
d_8to24table[255] &= 0xFFFFFF;
|
||||
image.d_currentpal = d_8to24table;
|
||||
}
|
||||
else if( rendermode == LUMP_QFONT )
|
||||
|
|
|
@ -73,16 +73,14 @@ typically params: 16x16 DXT1 but can be missing
|
|||
size_t Image_VTFCalcLowResSize( vtf_t *hdr )
|
||||
{
|
||||
size_t buffsize = 0;
|
||||
int w, h, format;
|
||||
int format;
|
||||
|
||||
format = Image_VTFFormat( LittleLong( hdr->lowResImageFormat ));
|
||||
format = Image_VTFFormat( hdr->lowResImageFormat );
|
||||
|
||||
// missing lowRes image for -1 value
|
||||
if( format != VTF_UNKNOWN )
|
||||
{
|
||||
w = LittleShort( hdr->lowResImageWidth );
|
||||
h = LittleShort( hdr->lowResImageHeight );
|
||||
buffsize = Image_DXTGetLinearSize( format, w, h, 1, 0 );
|
||||
buffsize = Image_DXTGetLinearSize( format, hdr->lowResImageWidth, hdr->lowResImageHeight, 1, 0 );
|
||||
}
|
||||
return buffsize;
|
||||
}
|
||||
|
@ -100,8 +98,8 @@ size_t Image_VTFCalcMipmapSize( vtf_t *hdr, int mipNum )
|
|||
size_t buffsize = 0;
|
||||
int w, h, mipsize;
|
||||
|
||||
w = max( 1, LittleShort( hdr->width )>>mipNum );
|
||||
h = max( 1, LittleShort( hdr->height )>>mipNum );
|
||||
w = max( 1, hdr->width >> mipNum );
|
||||
h = max( 1, hdr->height >> mipNum );
|
||||
mipsize = Image_DXTGetLinearSize( image.type, w, h, 1, 0 );
|
||||
return mipsize;
|
||||
}
|
||||
|
@ -215,50 +213,52 @@ qboolean Image_LoadVTF( const char *name, const byte *buffer, size_t filesize )
|
|||
byte *fin;
|
||||
string shortname;
|
||||
qboolean oldformat = false;
|
||||
int i, flags, vtfFormat;
|
||||
uint hdrSize, biasSize, resSize, lowResSize;
|
||||
int i, flags;
|
||||
|
||||
fin = (byte *)buffer;
|
||||
Mem_Copy( &vtf, fin, sizeof( vtf ));
|
||||
hdrSize = LittleLong( vtf.hdr_size );
|
||||
hdrSize = vtf.hdr_size;
|
||||
biasSize = 0;
|
||||
|
||||
if( LittleLong( vtf.ident ) != VTFHEADER )
|
||||
if( vtf.ident != VTFHEADER )
|
||||
return false; // it's not a vtf file, just skip it
|
||||
|
||||
FS_FileBase( name, shortname );
|
||||
|
||||
// bounds check
|
||||
i = LittleLong( vtf.ver_major );
|
||||
i = vtf.ver_major;
|
||||
if( i != VTF_VERSION )
|
||||
{
|
||||
MsgDev( D_ERROR, "Image_LoadVTF: %s has wrong ver (%i should be %i)\n", shortname, i, VTF_VERSION );
|
||||
return false;
|
||||
}
|
||||
|
||||
i = LittleLong( vtf.ver_minor );
|
||||
i = vtf.ver_minor;
|
||||
if( i == VTF_SUBVERSION0 && vtf.hdr_size == 64 )
|
||||
oldformat = true; // 7.0 hasn't envmap for cubemap images
|
||||
// all other subversions are valid
|
||||
|
||||
image.width = LittleShort( vtf.width );
|
||||
image.height = LittleShort( vtf.height );
|
||||
if(!Image_ValidSize( name )) return false;
|
||||
image.width = vtf.width;
|
||||
image.height = vtf.height;
|
||||
|
||||
if( !Image_ValidSize( name ))
|
||||
return false;
|
||||
|
||||
// translate VF_flags into IMAGE_flags
|
||||
flags = LittleLong( vtf.flags );
|
||||
flags = vtf.flags;
|
||||
|
||||
if(( flags & VF_ONEBITALPHA ) || ( flags & VF_EIGHTBITALPHA ))
|
||||
image.flags |= IMAGE_HAS_ALPHA;
|
||||
if( flags & VF_ENVMAP ) image.flags |= IMAGE_CUBEMAP;
|
||||
|
||||
vtfFormat = LittleLong( vtf.imageFormat );
|
||||
image.type = Image_VTFFormat( vtfFormat );
|
||||
image.depth = LittleLong( vtf.num_frames );
|
||||
image.num_mips = LittleLong( vtf.numMipLevels );
|
||||
image.type = Image_VTFFormat( vtf.imageFormat );
|
||||
image.depth = vtf.num_frames;
|
||||
image.num_mips = vtf.numMipLevels;
|
||||
|
||||
if( image.type == PF_UNKNOWN )
|
||||
{
|
||||
MsgDev( D_ERROR, "Image_LoadVTF: file (%s) has unknown format %i\n", shortname, vtfFormat );
|
||||
MsgDev( D_ERROR, "Image_LoadVTF: file (%s) has unknown format %i\n", shortname, vtf.imageFormat );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ qboolean Image_LoadFNT( const char *name, const byte *buffer, size_t filesize )
|
|||
qfont_t font;
|
||||
const byte *pal, *fin;
|
||||
size_t size;
|
||||
int i, numcolors;
|
||||
int numcolors;
|
||||
|
||||
if( image.hint == IL_HINT_Q1 )
|
||||
return false; // Quake1 doesn't have qfonts
|
||||
|
@ -71,18 +71,6 @@ qboolean Image_LoadFNT( const char *name, const byte *buffer, size_t filesize )
|
|||
return false;
|
||||
Mem_Copy( &font, buffer, sizeof( font ));
|
||||
|
||||
// swap header
|
||||
font.width = LittleLong( font.width );
|
||||
font.height = LittleLong( font.height );
|
||||
font.rowcount = LittleLong( font.rowcount );
|
||||
font.rowheight = LittleLong( font.rowheight );
|
||||
|
||||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
font.fontinfo[i].startoffset = LittleShort( font.fontinfo[i].startoffset );
|
||||
font.fontinfo[i].charwidth = LittleShort( font.fontinfo[i].charwidth );
|
||||
}
|
||||
|
||||
// last sixty four bytes - what the hell ????
|
||||
size = sizeof( qfont_t ) - 4 + ( 128 * font.width * QCHAR_WIDTH ) + sizeof( short ) + 768 + 64;
|
||||
|
||||
|
@ -103,7 +91,7 @@ qboolean Image_LoadFNT( const char *name, const byte *buffer, size_t filesize )
|
|||
fin = buffer + sizeof( font ) - 4;
|
||||
|
||||
pal = fin + (image.width * image.height);
|
||||
numcolors = BuffLittleShort( pal ), pal += sizeof( short );
|
||||
numcolors = *(short *)pal, pal += sizeof( short );
|
||||
image.flags |= IMAGE_HAS_ALPHA; // fonts always have transparency
|
||||
|
||||
if( numcolors == 768 )
|
||||
|
@ -142,11 +130,10 @@ qboolean Image_LoadMDL( const char *name, const byte *buffer, size_t filesize )
|
|||
int i, flags;
|
||||
|
||||
pin = (mstudiotexture_t *)buffer;
|
||||
flags = LittleLong( pin->flags );
|
||||
flags = pin->flags;
|
||||
|
||||
// Valve never used endian functions for studiomodels...
|
||||
image.width = LittleLong( pin->width );
|
||||
image.height = LittleLong( pin->height );
|
||||
image.width = pin->width;
|
||||
image.height = pin->height;
|
||||
pixels = image.width * image.height;
|
||||
fin = (byte *)pin->index; // setup buffer
|
||||
|
||||
|
@ -226,8 +213,8 @@ qboolean Image_LoadSPR( const char *name, const byte *buffer, size_t filesize )
|
|||
else return false; // unknown mode rejected
|
||||
|
||||
pin = (dspriteframe_t *)buffer;
|
||||
image.width = LittleLong( pin->width );
|
||||
image.height = LittleLong( pin->height );
|
||||
image.width = pin->width;
|
||||
image.height = pin->height;
|
||||
|
||||
if( filesize < image.width * image.height )
|
||||
{
|
||||
|
@ -266,13 +253,16 @@ qboolean Image_LoadWAL( const char *name, const byte *buffer, size_t filesize )
|
|||
}
|
||||
Mem_Copy( &wal, buffer, sizeof( wal ));
|
||||
|
||||
flags = LittleLong(wal.flags);
|
||||
value = LittleLong(wal.value);
|
||||
contents = LittleLong(wal.contents);
|
||||
image.width = LittleLong(wal.width);
|
||||
image.height = LittleLong(wal.height);
|
||||
for(i = 0; i < 4; i++) ofs[i] = LittleLong(wal.offsets[i]);
|
||||
if(!Image_LumpValidSize( name )) return false;
|
||||
flags = wal.flags;
|
||||
value = wal.value;
|
||||
contents = wal.contents;
|
||||
image.width = wal.width;
|
||||
image.height = wal.height;
|
||||
|
||||
Mem_Copy( ofs, wal.offsets, sizeof( ofs ));
|
||||
|
||||
if( !Image_LumpValidSize( name ))
|
||||
return false;
|
||||
|
||||
pixels = image.width * image.height;
|
||||
mipsize = (int)sizeof(wal) + ofs[0] + pixels;
|
||||
|
@ -325,13 +315,14 @@ qboolean Image_LoadFLT( const char *name, const byte *buffer, size_t filesize )
|
|||
// stupid copypaste from DevIL, but it works
|
||||
f = VFS_Create( buffer, filesize );
|
||||
first_pos = VFS_Tell( f );
|
||||
VFS_Read(f, &flat, sizeof(flat));
|
||||
VFS_Read(f, &flat, sizeof( flat ));
|
||||
|
||||
image.width = flat.width;
|
||||
image.height = flat.height;
|
||||
|
||||
if( !Image_LumpValidSize( name ))
|
||||
return false;
|
||||
|
||||
image.width = LittleShort( flat.width );
|
||||
image.height = LittleShort( flat.height );
|
||||
flat.desc[0] = LittleShort( flat.desc[0] );
|
||||
flat.desc[1] = LittleShort( flat.desc[1] );
|
||||
if(!Image_LumpValidSize( name )) return false;
|
||||
Data = (byte *)Mem_Alloc( Sys.imagepool, image.width * image.height );
|
||||
Mem_Set( Data, 247, image.width * image.height ); // set default transparency
|
||||
image.depth = 1;
|
||||
|
@ -424,8 +415,8 @@ qboolean Image_LoadLMP( const char *name, const byte *buffer, size_t filesize )
|
|||
{
|
||||
fin = (byte *)buffer;
|
||||
Mem_Copy( &lmp, fin, sizeof( lmp ));
|
||||
image.width = LittleLong( lmp.width );
|
||||
image.height = LittleLong( lmp.height );
|
||||
image.width = lmp.width;
|
||||
image.height = lmp.height;
|
||||
rendermode = LUMP_NORMAL;
|
||||
fin += sizeof(lmp);
|
||||
}
|
||||
|
@ -437,7 +428,9 @@ qboolean Image_LoadLMP( const char *name, const byte *buffer, size_t filesize )
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!Image_ValidSize( name )) return false;
|
||||
if( !Image_ValidSize( name ))
|
||||
return false;
|
||||
|
||||
image.depth = 1;
|
||||
|
||||
if( image.hint != IL_HINT_Q1 && filesize > (int)sizeof(lmp) + pixels )
|
||||
|
@ -445,7 +438,7 @@ qboolean Image_LoadLMP( const char *name, const byte *buffer, size_t filesize )
|
|||
int numcolors;
|
||||
|
||||
pal = fin + pixels;
|
||||
numcolors = BuffLittleShort( pal );
|
||||
numcolors = *(short *)pal;
|
||||
if( numcolors != 256 ) pal = NULL; // corrupted lump ?
|
||||
else pal += sizeof( short );
|
||||
}
|
||||
|
@ -477,10 +470,13 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, size_t filesize )
|
|||
}
|
||||
|
||||
Mem_Copy( &mip, buffer, sizeof( mip ));
|
||||
image.width = LittleLong( mip.width );
|
||||
image.height = LittleLong( mip.height );
|
||||
if(!Image_ValidSize( name )) return false;
|
||||
for( i = 0; i < 4; i++ ) ofs[i] = LittleLong( mip.offsets[i] );
|
||||
image.width = mip.width;
|
||||
image.height = mip.height;
|
||||
|
||||
if( !Image_ValidSize( name ))
|
||||
return false;
|
||||
|
||||
Mem_Copy( ofs, mip.offsets, sizeof( ofs ));
|
||||
pixels = image.width * image.height;
|
||||
image.depth = 1;
|
||||
|
||||
|
@ -489,7 +485,7 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, size_t filesize )
|
|||
// half-life 1.0.0.1 mip version with palette
|
||||
fin = (byte *)buffer + mip.offsets[0];
|
||||
pal = (byte *)buffer + mip.offsets[0] + (((image.width * image.height) * 85)>>6);
|
||||
numcolors = BuffLittleShort( pal );
|
||||
numcolors = *(short *)pal;
|
||||
if( numcolors != 256 ) pal = NULL; // corrupted mip ?
|
||||
else pal += sizeof( short ); // skip colorsize
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ BSC32=bscmake.exe
|
|||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /opt:nowin98
|
||||
# ADD LINK32 jpg.lib ogg.lib vorbis.lib mpeg.lib user32.lib gdi32.lib shell32.lib advapi32.lib winmm.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc" /nodefaultlib:"libcmt" /libpath:"./imagelib" /libpath:"./soundlib" /opt:nowin98
|
||||
# ADD LINK32 jpeg.lib mpeg.lib user32.lib gdi32.lib shell32.lib advapi32.lib winmm.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc" /nodefaultlib:"libcmt" /libpath:"./imagelib" /libpath:"./soundlib" /opt:nowin98
|
||||
# Begin Custom Build
|
||||
TargetDir=\Xash3D\src_main\temp\launch\!release
|
||||
InputPath=\Xash3D\src_main\temp\launch\!release\launch.dll
|
||||
|
@ -90,7 +90,7 @@ BSC32=bscmake.exe
|
|||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 jpg.lib ogg.lib mpeg.lib vorbis.lib user32.lib gdi32.lib shell32.lib advapi32.lib winmm.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libcmt" /nodefaultlib:"libc" /pdbtype:sept /libpath:"./imagelib" /libpath:"./soundlib"
|
||||
# ADD LINK32 jpeg.lib mpeg.lib user32.lib gdi32.lib shell32.lib advapi32.lib winmm.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libcmt" /nodefaultlib:"libc" /pdbtype:sept /libpath:"./imagelib" /libpath:"./soundlib"
|
||||
# Begin Custom Build
|
||||
TargetDir=\Xash3D\src_main\temp\launch\!debug
|
||||
InputPath=\Xash3D\src_main\temp\launch\!debug\launch.dll
|
||||
|
@ -220,10 +220,6 @@ SOURCE=.\soundlib\snd_mp3.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\soundlib\snd_ogg.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\soundlib\snd_raw.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
#include <winsock.h>
|
||||
#include "launch.h"
|
||||
#include "engine_api.h" // network message length
|
||||
#include "byteorder.h"
|
||||
|
||||
// This is the packet payload without any header bytes (which are attached for actual sending)
|
||||
#define NET_MAX_PAYLOAD 80000
|
||||
|
|
Binary file not shown.
|
@ -353,7 +353,7 @@ qboolean Sound_LoadOGG( const char *name, const byte *buffer, size_t filesize )
|
|||
sound.wav = (byte *)Mem_Alloc( Sys.soundpool, sound.size );
|
||||
|
||||
// decompress ogg into pcm wav format
|
||||
while(( ret = ov_read( &vf, &sound.wav[done], (int)(sound.size - done), big_endian, 2, 1, &dummy )) > 0 )
|
||||
while(( ret = ov_read( &vf, &sound.wav[done], (int)(sound.size - done), false, 2, 1, &dummy )) > 0 )
|
||||
done += ret;
|
||||
sound.samples = done / ( vi->channels * 2 );
|
||||
vc = ov_comment( &vf, -1 );
|
||||
|
@ -477,7 +477,7 @@ long Stream_ReadOGG( stream_t *stream, long bytes, void *buffer )
|
|||
while( 1 )
|
||||
{
|
||||
// read some bytes from the OGG codec
|
||||
c = ov_read(( vorbisfile_t *)stream->ptr, bufPtr, bytesLeft, big_endian, 2, 1, &dummy );
|
||||
c = ov_read(( vorbisfile_t *)stream->ptr, bufPtr, bytesLeft, false, 2, 1, &dummy );
|
||||
|
||||
// no more bytes are left
|
||||
if( c <= 0 ) break;
|
||||
|
|
|
@ -19,22 +19,14 @@ static const loadwavformat_t load_null[] =
|
|||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
// version0 - using only ogg sounds
|
||||
static const loadwavformat_t load_stalker[] =
|
||||
{
|
||||
{ "sound/%s%s.%s", "ogg", Sound_LoadOGG },
|
||||
{ "%s%s.%s", "ogg", Sound_LoadOGG },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
// version1 - using only Doom1 sounds
|
||||
// version0 - using only Doom1 sounds
|
||||
static const loadwavformat_t load_doom1[] =
|
||||
{
|
||||
{ "%s%s.%s", "snd", Sound_LoadSND },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
// version2 - using only Quake1 sounds
|
||||
// version1 - using only Quake1 sounds
|
||||
static const loadwavformat_t load_quake1[] =
|
||||
{
|
||||
{ "sound/%s%s.%s", "wav", Sound_LoadWAV },
|
||||
|
@ -42,15 +34,13 @@ static const loadwavformat_t load_quake1[] =
|
|||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
// version3 - Xash3D default sound profile
|
||||
// version2 - Xash3D default sound profile
|
||||
static const loadwavformat_t load_xash[] =
|
||||
{
|
||||
{ "sound/%s%s.%s", "wav", Sound_LoadWAV },
|
||||
{ "%s%s.%s", "wav", Sound_LoadWAV },
|
||||
{ "sound/%s%s.%s", "mp3", Sound_LoadMPG },
|
||||
{ "%s%s.%s", "mp3", Sound_LoadMPG },
|
||||
{ "sound/%s%s.%s", "ogg", Sound_LoadOGG },
|
||||
{ "%s%s.%s", "ogg", Sound_LoadOGG },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
@ -67,25 +57,17 @@ static const streamformat_t stream_null[] =
|
|||
{ NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
// version0 - using only ogg streams
|
||||
static const streamformat_t stream_stalker[] =
|
||||
{
|
||||
{ "%s%s.%s", "ogg", Stream_OpenOGG, Stream_ReadOGG, Stream_FreeOGG },
|
||||
{ NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
// version1 - using only wav streams
|
||||
// version0 - using only wav streams
|
||||
static const streamformat_t stream_quake3[] =
|
||||
{
|
||||
{ "%s%s.%s", "wav", Stream_OpenWAV, Stream_ReadWAV, Stream_FreeWAV },
|
||||
{ NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
// version3 - Xash3D default stream profile
|
||||
// version1 - Xash3D default stream profile
|
||||
static const streamformat_t stream_xash[] =
|
||||
{
|
||||
{ "%s%s.%s", "mp3", Stream_OpenMPG, Stream_ReadMPG, Stream_FreeMPG },
|
||||
{ "%s%s.%s", "ogg", Stream_OpenOGG, Stream_ReadOGG, Stream_FreeOGG },
|
||||
{ "%s%s.%s", "wav", Stream_OpenWAV, Stream_ReadWAV, Stream_FreeWAV },
|
||||
{ NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
@ -151,11 +133,6 @@ void Sound_Setup( const char *formats, const uint flags )
|
|||
sound.loadformats = load_xash;
|
||||
sound.streamformat = stream_xash;
|
||||
}
|
||||
else if( !com.stricmp( formats, "stalker" ) || !com.stricmp( formats, "S.T.A.L.K.E.R" ))
|
||||
{
|
||||
sound.loadformats = load_stalker;
|
||||
sound.streamformat = stream_stalker;
|
||||
}
|
||||
else if( !com.stricmp( formats, "Doom1" ) || !com.stricmp( formats, "Doom2" ))
|
||||
{
|
||||
sound.loadformats = load_doom1;
|
||||
|
@ -211,25 +188,6 @@ byte *Sound_Copy( size_t size )
|
|||
return out;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Sound_ByteSwapRawSamples
|
||||
=================
|
||||
*/
|
||||
void Sound_ByteSwapRawSamples( int samples, int width, int s_channels, const byte *data )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !big_endian ) return;
|
||||
if( width != 2 ) return;
|
||||
|
||||
if( s_channels == 2 )
|
||||
samples <<= 1;
|
||||
|
||||
for( i = 0; i < samples; i++ )
|
||||
((short *)data)[i] = LittleShort((( short *)data)[i] );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Sound_ConvertToSigned
|
||||
|
@ -301,8 +259,8 @@ qboolean Sound_ResampleInternal( wavdata_t *sc, int inrate, int inwidth, int out
|
|||
|
||||
if( inwidth == 2 )
|
||||
{
|
||||
sample = LittleShort(((short *)data)[srcsample*2+0] );
|
||||
sample2 = LittleShort(((short *)data)[srcsample*2+1] );
|
||||
sample = ((short *)data)[srcsample*2+0];
|
||||
sample2 = ((short *)data)[srcsample*2+1];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -329,7 +287,7 @@ qboolean Sound_ResampleInternal( wavdata_t *sc, int inrate, int inwidth, int out
|
|||
srcsample = samplefrac >> 8;
|
||||
samplefrac += fracstep;
|
||||
|
||||
if( inwidth == 2 ) sample = LittleShort(((short *)data)[srcsample] );
|
||||
if( inwidth == 2 ) sample = ((short *)data)[srcsample];
|
||||
else sample = (int)( (char)(data[srcsample])) << 8;
|
||||
|
||||
if( outwidth == 2 ) ((short *)sound.tempbuffer)[i] = sample;
|
||||
|
|
|
@ -99,7 +99,6 @@ qboolean StreamFindNextChunk( file_t *file, const char *name, int *last_chunk )
|
|||
|
||||
FS_Seek( file, 4, SEEK_CUR );
|
||||
FS_Read( file, &iff_chunk_len, sizeof( iff_chunk_len ));
|
||||
iff_chunk_len = LittleLong( iff_chunk_len );
|
||||
if( iff_chunk_len < 0 )
|
||||
return false; // didn't find the chunk
|
||||
|
||||
|
@ -306,7 +305,7 @@ stream_t *Stream_OpenWAV( const char *filename )
|
|||
FS_Read( file, chunkName, 4 );
|
||||
|
||||
FS_Read( file, &t, sizeof( t ));
|
||||
if( LittleShort( t ) != 1 )
|
||||
if( t != 1 )
|
||||
{
|
||||
MsgDev( D_ERROR, "Stream_OpenWAV: %s not a microsoft PCM format\n", filename );
|
||||
FS_Close( file );
|
||||
|
@ -314,15 +313,14 @@ stream_t *Stream_OpenWAV( const char *filename )
|
|||
}
|
||||
|
||||
FS_Read( file, &t, sizeof( t ));
|
||||
sound.channels = LittleShort( t );
|
||||
sound.channels = t;
|
||||
|
||||
FS_Read( file, &sound.rate, sizeof( int ));
|
||||
sound.rate = LittleLong( sound.rate );
|
||||
|
||||
FS_Seek( file, 6, SEEK_CUR );
|
||||
|
||||
FS_Read( file, &t, sizeof( t ));
|
||||
sound.width = LittleShort( t ) / 8;
|
||||
sound.width = t / 8;
|
||||
|
||||
sound.loopstart = 0;
|
||||
|
||||
|
@ -336,7 +334,7 @@ stream_t *Stream_OpenWAV( const char *filename )
|
|||
}
|
||||
|
||||
FS_Read( file, &sound.samples, sizeof( int ));
|
||||
sound.samples = ( LittleLong( sound.samples ) / sound.width ) / sound.channels;
|
||||
sound.samples = ( sound.samples / sound.width ) / sound.channels;
|
||||
|
||||
// at this point we have valid stream
|
||||
stream = Mem_Alloc( Sys.soundpool, sizeof( stream_t ));
|
||||
|
@ -370,7 +368,6 @@ long Stream_ReadWAV( stream_t *stream, long bytes, void *buffer )
|
|||
stream->pos += bytes;
|
||||
samples = ( bytes / stream->width ) / stream->channels;
|
||||
FS_Read( stream->file, buffer, bytes );
|
||||
Sound_ByteSwapRawSamples( samples, stream->width, stream->channels, buffer );
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#define SOUNDLIB_H
|
||||
|
||||
#include "launch.h"
|
||||
#include "byteorder.h"
|
||||
|
||||
typedef struct loadwavformat_s
|
||||
{
|
||||
|
@ -105,9 +104,4 @@ void Stream_FreeMPG( stream_t *stream );
|
|||
//
|
||||
qboolean Sound_SaveWAV( const char *name, wavdata_t *pix );
|
||||
|
||||
//
|
||||
// snd_utils.c
|
||||
//
|
||||
void Sound_ByteSwapRawSamples( int samples, int width, int s_channels, const byte *data );
|
||||
|
||||
#endif//SOUNDLIB_H
|
Binary file not shown.
|
@ -6,7 +6,6 @@
|
|||
#include "launch.h"
|
||||
#include "ripper.h"
|
||||
#include "wadfile.h"
|
||||
#include "byteorder.h"
|
||||
|
||||
#define IDBSPMODHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I') // little-endian "IBSP" q2 bsp's
|
||||
#define VDBSPMODHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'V') // little-endian "VBSP" hl2 bsp's
|
||||
|
@ -219,7 +218,6 @@ void Conv_BspTextures( const char *name, dlump_t *l, const char *ext )
|
|||
FS_FileBase( name, genericname );
|
||||
|
||||
m = (dmiptexlump_t *)(bsp_base + l->fileofs);
|
||||
m->nummiptex = LittleLong( m->nummiptex );
|
||||
dofs = m->dataofs;
|
||||
|
||||
detail_txt = FS_Open( va( "%s/%s_detail.txt", gs_gamedir, name ), "wb", false );
|
||||
|
@ -230,7 +228,6 @@ void Conv_BspTextures( const char *name, dlump_t *l, const char *ext )
|
|||
// first pass: store all names into linear array
|
||||
for( i = 0; i < m->nummiptex; i++ )
|
||||
{
|
||||
dofs[i] = LittleLong( dofs[i] );
|
||||
if( dofs[i] == -1 ) continue;
|
||||
|
||||
// needs to simulate directly loading
|
||||
|
@ -242,7 +239,7 @@ void Conv_BspTextures( const char *name, dlump_t *l, const char *ext )
|
|||
|
||||
// detailtexture detected
|
||||
if( det_name ) FS_Printf( detail_txt, "%s detail/%s 10.0 10.0\n", mip->name, det_name );
|
||||
if( !LittleLong( mip->offsets[0] )) continue; // not in bsp, skipped
|
||||
if( !mip->offsets[0] ) continue; // not in bsp, skipped
|
||||
|
||||
// check for '*' symbol issues
|
||||
k = com.strlen( com.strrchr( mip->name, '*' ));
|
||||
|
@ -256,12 +253,11 @@ void Conv_BspTextures( const char *name, dlump_t *l, const char *ext )
|
|||
// second pass: convert lumps
|
||||
for( i = 0; i < m->nummiptex; i++ )
|
||||
{
|
||||
dofs[i] = LittleLong( dofs[i] );
|
||||
if( dofs[i] == -1 ) continue;
|
||||
|
||||
// needs to simulate direct loading
|
||||
mip = (mip_t *)((byte *)m + dofs[i]);
|
||||
if( !LittleLong( mip->offsets[0] )) continue; // not in bsp
|
||||
if( !mip->offsets[0] ) continue; // not in bsp
|
||||
|
||||
buffer = ((byte *)m + dofs[i]); // buffer
|
||||
size = (int)sizeof(mip_t) + (((mip->width * mip->height) * 85)>>6);
|
||||
|
@ -282,10 +278,9 @@ ConvBSP
|
|||
*/
|
||||
qboolean ConvBSP( const char *name, byte *buffer, size_t filesize, const char *ext )
|
||||
{
|
||||
dbspheader_t *header = (dbspheader_t *)buffer;
|
||||
int i = LittleLong( header->version );
|
||||
dbspheader_t *header = (dbspheader_t *)buffer;
|
||||
|
||||
switch( i )
|
||||
switch( header->version )
|
||||
{
|
||||
case 28:
|
||||
case 29:
|
||||
|
@ -297,13 +292,8 @@ qboolean ConvBSP( const char *name, byte *buffer, size_t filesize, const char *e
|
|||
default:
|
||||
return false; // another bsp version
|
||||
}
|
||||
bsp_base = (byte*)buffer;
|
||||
|
||||
for( i = 0; i < 15; i++ )
|
||||
{
|
||||
header->lumps[i].fileofs = LittleLong(header->lumps[i].fileofs);
|
||||
header->lumps[i].filelen = LittleLong(header->lumps[i].filelen);
|
||||
}
|
||||
bsp_base = (byte*)buffer;
|
||||
Conv_BspTextures( name, &header->lumps[2], ext ); // LUMP_TEXTURES
|
||||
|
||||
return true;
|
||||
|
@ -323,7 +313,7 @@ qboolean Conv_CheckMap( const char *mapname )
|
|||
}
|
||||
|
||||
// detect game type
|
||||
switch( LittleLong( hdr.ident ))
|
||||
switch( hdr.ident )
|
||||
{
|
||||
case 28: // quake 1 beta
|
||||
case 29: // quake 1 release
|
||||
|
@ -335,7 +325,7 @@ qboolean Conv_CheckMap( const char *mapname )
|
|||
FS_Close( f );
|
||||
return true;
|
||||
case IDBSPMODHEADER: // continue checking
|
||||
if( LittleLong( hdr.version ) == 38 )
|
||||
if( hdr.version == 38 )
|
||||
{
|
||||
game_family = GAME_QUAKE2;
|
||||
FS_Close( f );
|
||||
|
@ -343,7 +333,7 @@ qboolean Conv_CheckMap( const char *mapname )
|
|||
}
|
||||
break;
|
||||
case VDBSPMODHEADER: // continue checking
|
||||
switch( LittleLong( hdr.version ))
|
||||
switch( hdr.version )
|
||||
{
|
||||
case 18:
|
||||
game_family = GAME_HALFLIFE2_BETA;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "launch.h"
|
||||
#include "ripper.h"
|
||||
#include "byteorder.h"
|
||||
#include "sprite.h"
|
||||
|
||||
// sprite_decompiler.c
|
||||
|
@ -154,8 +153,8 @@ void *SPR_ConvertFrame( const char *name, const char *ext, void *pin, int framen
|
|||
int i, pixels, width, height;
|
||||
|
||||
pinframe = (dspriteframe_t *)pin;
|
||||
width = LittleLong( pinframe->width );
|
||||
height = LittleLong( pinframe->height );
|
||||
width = pinframe->width;
|
||||
height = pinframe->height;
|
||||
fin = (byte *)(pinframe + 1);
|
||||
if( width <= 0 || height <= 0 )
|
||||
{
|
||||
|
@ -200,18 +199,18 @@ void *SPR_ConvertFrame( const char *name, const char *ext, void *pin, int framen
|
|||
{
|
||||
i = groupframenum - 1;
|
||||
com.strncpy( spr.group[spr.numgroup].frame[i].name, framename, MAX_STRING );
|
||||
spr.group[spr.numgroup].frame[i].origin[0] = -(float)LittleLong(pinframe->origin[0]);
|
||||
spr.group[spr.numgroup].frame[i].origin[1] = (float)LittleLong(pinframe->origin[1]);
|
||||
spr.group[spr.numgroup].frame[i].width = (float)LittleLong(pinframe->width);
|
||||
spr.group[spr.numgroup].frame[i].height = (float)LittleLong(pinframe->height);
|
||||
spr.group[spr.numgroup].frame[i].origin[0] = -(float)pinframe->origin[0];
|
||||
spr.group[spr.numgroup].frame[i].origin[1] = (float)pinframe->origin[1];
|
||||
spr.group[spr.numgroup].frame[i].width = (float)pinframe->width;
|
||||
spr.group[spr.numgroup].frame[i].height = (float)pinframe->height;
|
||||
}
|
||||
else
|
||||
{
|
||||
com.strncpy( spr.frame[framenum].name, framename, MAX_STRING );
|
||||
spr.frame[framenum].origin[0] = -(float)LittleLong(pinframe->origin[0]);
|
||||
spr.frame[framenum].origin[1] = (float)LittleLong(pinframe->origin[1]);
|
||||
spr.frame[framenum].width = (float)LittleLong(pinframe->width);
|
||||
spr.frame[framenum].height = (float)LittleLong(pinframe->height);
|
||||
spr.frame[framenum].origin[0] = -(float)pinframe->origin[0];
|
||||
spr.frame[framenum].origin[1] = (float)pinframe->origin[1];
|
||||
spr.frame[framenum].width = (float)pinframe->width;
|
||||
spr.frame[framenum].height = (float)pinframe->height;
|
||||
}
|
||||
|
||||
if( FS_CheckParm( "-force32" ) && spr.texFormat == SPR_INDEXALPHA )
|
||||
|
@ -256,12 +255,12 @@ void *SPR_ConvertGroup( const char *name, const char *ext, void *pin, int framen
|
|||
void *ptemp;
|
||||
|
||||
pingroup = (dspritegroup_t *)pin;
|
||||
numframes = LittleLong( pingroup->numframes );
|
||||
numframes = pingroup->numframes;
|
||||
pin_intervals = (dspriteinterval_t *)(pingroup + 1);
|
||||
|
||||
for (i = 0; i < numframes; i++)
|
||||
for( i = 0; i < numframes; i++ )
|
||||
{
|
||||
spr.group[spr.numgroup].interval[i] = LittleLong( pin_intervals->interval );
|
||||
spr.group[spr.numgroup].interval[i] = pin_intervals->interval;
|
||||
pin_intervals++;
|
||||
}
|
||||
|
||||
|
@ -269,7 +268,7 @@ void *SPR_ConvertGroup( const char *name, const char *ext, void *pin, int framen
|
|||
spr.group[spr.numgroup].numframes = numframes - 1;
|
||||
ptemp = (void *)pin_intervals;
|
||||
|
||||
for (i = 0; i < numframes; i++ )
|
||||
for( i = 0; i < numframes; i++ )
|
||||
{
|
||||
ptemp = SPR_ConvertFrame( name, ext, ptemp, framenum + i, i + 1 );
|
||||
}
|
||||
|
@ -352,35 +351,35 @@ qboolean ConvSPR( const char *name, byte *buffer, size_t filesize, const char *e
|
|||
pin = (dspriteq1_t *)buffer;
|
||||
Mem_Set( &spr, 0, sizeof( spr ));
|
||||
|
||||
switch( LittleLong( pin->ident ))
|
||||
switch( pin->ident )
|
||||
{
|
||||
case IDSPRQ1HEADER:
|
||||
switch( LittleLong( pin->version ))
|
||||
switch( pin->version )
|
||||
{
|
||||
case SPRITEQ1_VERSION:
|
||||
spr.totalframes = LittleLong( pin->numframes );
|
||||
spr.totalframes = pin->numframes;
|
||||
spr.texFormat = SPR_ALPHTEST; // constant
|
||||
spr.type = LittleLong( pin->type );
|
||||
spr.type = pin->type;
|
||||
pframetype = (dframetype_t *)(pin + 1);
|
||||
spr.truecolor = false;
|
||||
break;
|
||||
case SPRITE32_VERSION:
|
||||
spr.totalframes = LittleLong( pin->numframes );
|
||||
spr.totalframes = pin->numframes;
|
||||
spr.texFormat = SPR_ADDITIVE; // constant
|
||||
spr.type = LittleLong( pin->type );
|
||||
spr.type = pin->type;
|
||||
|
||||
pframetype = (dframetype_t *)(pin + 1);
|
||||
spr.truecolor = true;
|
||||
break;
|
||||
case SPRITEHL_VERSION:
|
||||
pinhl = (dspritehl_t *)buffer; // reorganize header
|
||||
spr.totalframes = LittleLong( pinhl->numframes );
|
||||
spr.texFormat = LittleLong( pinhl->texFormat );
|
||||
spr.type = LittleLong( pinhl->type );
|
||||
spr.totalframes = pinhl->numframes;
|
||||
spr.texFormat = pinhl->texFormat;
|
||||
spr.type = pinhl->type;
|
||||
numi = (short *)(pinhl + 1);
|
||||
spr.truecolor = false;
|
||||
|
||||
if( LittleShort( *numi ) == 256 )
|
||||
if( *numi == 256 )
|
||||
{
|
||||
byte *src = (byte *)(numi + 1);
|
||||
rgbdata_t *pal = NULL;
|
||||
|
@ -411,30 +410,30 @@ qboolean ConvSPR( const char *name, byte *buffer, size_t filesize, const char *e
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Msg("\"%s.%s\" unknown version %i\n", name, "spr", LittleLong( pin->version ));
|
||||
Msg("\"%s.%s\" unknown version %i\n", name, "spr", pin->version );
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case IDSPRQ2HEADER:
|
||||
switch( LittleLong( pin->version ))
|
||||
switch( pin->version )
|
||||
{
|
||||
case SPRITEQ2_VERSION:
|
||||
pinq2 = (dspriteq2_t *)buffer;
|
||||
spr.totalframes = LittleLong( pinq2->numframes );
|
||||
spr.totalframes = pinq2->numframes;
|
||||
spr.texFormat = SPR_ALPHTEST; // constants
|
||||
spr.type = SPR_FWD_PARALLEL;
|
||||
spr.truecolor = false;
|
||||
for( i = 0; i < spr.totalframes; i++ )
|
||||
{
|
||||
spr.frame[i].width = LittleLong( pinq2->frames[i].width );
|
||||
spr.frame[i].height = LittleLong( pinq2->frames[i].height );
|
||||
spr.frame[i].origin[0] = LittleLong( pinq2->frames[i].origin_x );
|
||||
spr.frame[i].origin[1] = LittleLong( pinq2->frames[i].origin_y );
|
||||
spr.frame[i].width = pinq2->frames[i].width;
|
||||
spr.frame[i].height = pinq2->frames[i].height;
|
||||
spr.frame[i].origin[0] = pinq2->frames[i].origin_x;
|
||||
spr.frame[i].origin[1] = pinq2->frames[i].origin_y;
|
||||
SP2_ConvertFrame( pinq2->frames[i].name, ext, i );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Msg("\"%s.%s\" unknown version %i\n", name, "sp2", LittleLong( pin->version ));
|
||||
Msg( "\"%s.%s\" unknown version %i\n", name, "sp2", pin->version );
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -446,7 +445,7 @@ qboolean ConvSPR( const char *name, byte *buffer, size_t filesize, const char *e
|
|||
// .SPR save frames as normal images
|
||||
for( i = 0; pframetype && i < spr.totalframes; i++ )
|
||||
{
|
||||
frametype_t frametype = LittleLong( pframetype->type );
|
||||
frametype_t frametype = pframetype->type;
|
||||
|
||||
if( frametype == FRAME_SINGLE )
|
||||
pframetype = (dframetype_t *)SPR_ConvertFrame( name, ext, (pframetype + 1), i, 0 );
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "utils.h"
|
||||
#include "sprite.h"
|
||||
#include "byteorder.h"
|
||||
#include "mathlib.h"
|
||||
|
||||
#define MAX_FRAMES 256
|
||||
|
@ -46,14 +45,10 @@ void WriteFrame( file_t *f, int framenum )
|
|||
dspriteframe_t *pframe;
|
||||
|
||||
pframe = (dspriteframe_t *)frames[framenum].pdata;
|
||||
pframe->origin[0] = LittleLong( pframe->origin[0] );
|
||||
pframe->origin[1] = LittleLong( pframe->origin[1] );
|
||||
pframe->width = LittleLong (pframe->width);
|
||||
pframe->height = LittleLong (pframe->height);
|
||||
|
||||
// write frame as 32-bit indexed image
|
||||
FS_Write(f, pframe, sizeof(*pframe));
|
||||
FS_Write(f, (byte *)(pframe + 1), pframe->height * pframe->width );
|
||||
FS_Write( f, pframe, sizeof( *pframe ));
|
||||
FS_Write( f, (byte *)(pframe + 1), pframe->height * pframe->width );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -73,11 +68,10 @@ void WriteSprite( file_t *f )
|
|||
+ ((sprite.bounds[1]>>1) * (sprite.bounds[1]>>1)));
|
||||
|
||||
// write out the sprite header
|
||||
SwapBlock((int *)&sprite, sizeof(dsprite_t));
|
||||
FS_Write( f, &sprite, sizeof(sprite));
|
||||
FS_Write( f, &sprite, sizeof( sprite ));
|
||||
|
||||
// write out palette (768 bytes)
|
||||
FS_Write( f, (void *)&cnt, sizeof(cnt));
|
||||
FS_Write( f, (void *)&cnt, sizeof( cnt ));
|
||||
FS_Write( f, sprite_pal, cnt * 3 );
|
||||
|
||||
for (i = 0; i < sprite.numframes; i++)
|
||||
|
@ -100,8 +94,8 @@ void WriteSprite( file_t *f )
|
|||
numframes = frames[groupframe].numgroupframes;
|
||||
|
||||
// set and write the group header
|
||||
dsgroup.numframes = LittleLong( numframes );
|
||||
FS_Write( f, &dsgroup, sizeof(dsgroup));
|
||||
dsgroup.numframes = numframes;
|
||||
FS_Write( f, &dsgroup, sizeof( dsgroup ));
|
||||
totinterval = 0.0f; // write the interval array
|
||||
|
||||
for( j = 0; j < numframes; j++ )
|
||||
|
@ -109,7 +103,7 @@ void WriteSprite( file_t *f )
|
|||
dspriteinterval_t temp;
|
||||
|
||||
totinterval += frames[groupframe+1+j].interval;
|
||||
temp.interval = LittleFloat( totinterval );
|
||||
temp.interval = totinterval;
|
||||
FS_Write( f, &temp, sizeof( temp ));
|
||||
}
|
||||
for( j = 0; j < numframes; j++ )
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "utils.h"
|
||||
#include "wadfile.h"
|
||||
#include "byteorder.h"
|
||||
#include "mathlib.h"
|
||||
|
||||
string wadoutname;
|
||||
|
@ -216,8 +215,8 @@ void Cmd_GrabMip( void )
|
|||
plump_end = plump + plump_size; // sentinel
|
||||
|
||||
mip = (mip_t *)plump;
|
||||
mip->width = LittleLong( w );
|
||||
mip->height = LittleLong( h );
|
||||
mip->width = w;
|
||||
mip->height = h;
|
||||
com.strncpy( mip->name, lumpname, sizeof(mip->name));
|
||||
plump = (byte *)&mip->offsets[4];
|
||||
|
||||
|
@ -225,7 +224,7 @@ void Cmd_GrabMip( void )
|
|||
linedelta = wadpic->width - w;
|
||||
|
||||
source = plump;
|
||||
mip->offsets[0] = LittleLong( plump - (byte *)mip );
|
||||
mip->offsets[0] = plump - (byte *)mip;
|
||||
|
||||
// apply scissor to source
|
||||
for( y = yl; y < yh; y++ )
|
||||
|
@ -278,7 +277,7 @@ void Cmd_GrabMip( void )
|
|||
int pixTest;
|
||||
|
||||
VectorClear( d_color ); // no distortion yet
|
||||
mip->offsets[miplevel] = LittleLong(plump - (byte *)mip);
|
||||
mip->offsets[miplevel] = plump - (byte *)mip;
|
||||
|
||||
mipstep = 1<<miplevel;
|
||||
pixTest = (int)((float)(mipstep * mipstep) * 0.4 ); // 40% of pixels
|
||||
|
@ -381,8 +380,8 @@ void Cmd_GrabPic( void )
|
|||
plump_size = (int)sizeof(*pic) + (xh * yh) + sizeof(short) + 768;
|
||||
plump = lump = (byte *)Mem_Alloc( wadpool, plump_size );
|
||||
pic = (lmp_t *)plump;
|
||||
pic->width = LittleLong( xh - xl );
|
||||
pic->height = LittleLong( yh - yl );
|
||||
pic->width = xh - xl;
|
||||
pic->height = yh - yl;
|
||||
|
||||
// apply scissor to source
|
||||
plump = (byte *)(pic + 1);
|
||||
|
|
|
@ -1,169 +0,0 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// byteorder.h - byte order functions
|
||||
//=======================================================================
|
||||
#ifndef BYTEORDER_H
|
||||
#define BYTEORDER_H
|
||||
|
||||
// byte order swap functions
|
||||
_inline word WordSwap( word swap )
|
||||
{
|
||||
word *s = &swap;
|
||||
|
||||
__asm {
|
||||
mov ebx, s
|
||||
mov al, [ebx+1]
|
||||
mov ah, [ebx ]
|
||||
mov [ebx], ax
|
||||
}
|
||||
return *s;
|
||||
}
|
||||
|
||||
#define ShortSwap(x) WordSwap((short)x)
|
||||
|
||||
_inline uint UintSwap( uint *swap )
|
||||
{
|
||||
uint *i = swap;
|
||||
|
||||
__asm {
|
||||
mov ebx, i
|
||||
mov eax, [ebx]
|
||||
bswap eax
|
||||
mov [ebx], eax
|
||||
}
|
||||
return *i;
|
||||
}
|
||||
|
||||
#define LongSwap(x) UintSwap((uint *)&x)
|
||||
#define FloatSwap(x) UintSwap((uint *)&x)
|
||||
|
||||
_inline double DoubleSwap( double swap )
|
||||
{
|
||||
#define dswap(x, y) t=b[x];b[x]=b[y];b[y]=b[x];
|
||||
|
||||
byte t, *b = ((byte *)&swap);
|
||||
dswap(0,7);
|
||||
dswap(1,6);
|
||||
dswap(2,5);
|
||||
dswap(3,4);
|
||||
|
||||
#undef dswap
|
||||
|
||||
return swap;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
// Endianess handling
|
||||
//============================================================================
|
||||
// using BSD-style defines: BYTE_ORDER is defined to either BIG_ENDIAN or LITTLE_ENDIAN
|
||||
|
||||
// Initializations
|
||||
#if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
|
||||
#undef BYTE_ORDER
|
||||
#undef LITTLE_ENDIAN
|
||||
#undef BIG_ENDIAN
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#define BIG_ENDIAN 4321
|
||||
#endif
|
||||
|
||||
// If we still don't know the CPU endianess at this point, we try to guess
|
||||
#ifndef BYTE_ORDER
|
||||
#if defined(WIN32)
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#else
|
||||
#if defined(SUNOS)
|
||||
#if defined(__i386) || defined(__amd64)
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#else
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#endif
|
||||
#else
|
||||
#warning "Unable to determine the CPU endianess. Defaulting to little endian"
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
// little endian
|
||||
#define big_endian false
|
||||
#define BigShort(l) ShortSwap(l)
|
||||
#define LittleShort(l) (l)
|
||||
#define BigLong(l) LongSwap(l)
|
||||
#define LittleLong(l) (l)
|
||||
#define BigFloat(l) FloatSwap(l)
|
||||
#define LittleFloat(l) (l)
|
||||
#define BigDouble(l) DoubleSwap(l)
|
||||
#define LittleDouble(l) (l)
|
||||
#else
|
||||
// big endian
|
||||
#define big_endian true
|
||||
#define BigShort(l) (l)
|
||||
#define LittleShort(l) ShortSwap(l)
|
||||
#define BigLong(l) (l)
|
||||
#define LittleLong(l) LongSwap(l)
|
||||
#define BigFloat(l) (l)
|
||||
#define LittleFloat(l) FloatSwap(l)
|
||||
#define BigDouble(l) (l)
|
||||
#define LittleDouble(l) DoubleSwap(l)
|
||||
#endif
|
||||
|
||||
// extract from buffer
|
||||
_inline unsigned long BuffBigLong( const byte *buf )
|
||||
{
|
||||
return (buf[0]<<24)|(buf[1]<<16)|(buf[2]<<8)|buf[3];
|
||||
}
|
||||
|
||||
_inline unsigned short BuffBigShort( const byte *buf )
|
||||
{
|
||||
return (buf[0]<<8)|buf[1];
|
||||
}
|
||||
|
||||
_inline float BuffBigFloat( const byte *buf )
|
||||
{
|
||||
return BuffBigLong( buf );
|
||||
}
|
||||
|
||||
_inline double BuffBigDouble( const byte *buf )
|
||||
{
|
||||
return (buf[0]<<64)|(buf[1]<<56)|(buf[2]<<40)|(buf[3]<<32)|(buf[4]<<24)|(buf[5]<<16)|(buf[6]<<8)|buf[7];
|
||||
}
|
||||
|
||||
_inline unsigned long BuffLittleLong( const byte *buf )
|
||||
{
|
||||
return (buf[3]<<24)|(buf[2]<<16)|(buf[1]<<8)|buf[0];
|
||||
}
|
||||
|
||||
_inline unsigned short BuffLittleShort( const byte *buf )
|
||||
{
|
||||
return (buf[1]<<8)|buf[0];
|
||||
}
|
||||
|
||||
_inline float BuffLittleFloat( const byte *buf )
|
||||
{
|
||||
return BuffLittleLong( buf );
|
||||
}
|
||||
|
||||
_inline signed __int64 BuffLittleLong64( const byte *buf )
|
||||
{
|
||||
return (buf[7]<<64)|(buf[6]<<56)|(buf[5]<<40)|(buf[4]<<32)|(buf[3]<<24)|(buf[2]<<16)|(buf[1]<<8)|buf[0];
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
SwapBlock
|
||||
|
||||
generic lump swaping
|
||||
=============
|
||||
*/
|
||||
_inline void SwapBlock( int *block, int sizeOfBlock )
|
||||
{
|
||||
int i;
|
||||
|
||||
sizeOfBlock >>= 2;
|
||||
|
||||
for( i = 0; i < sizeOfBlock; i++ )
|
||||
block[i] = LittleLong( block[i] );
|
||||
}
|
||||
|
||||
#endif//BYTEORDER_H
|
|
@ -53,24 +53,4 @@
|
|||
#error MAX_COORD_INTEGER does not match COORD_INTEGER_BITS
|
||||
#endif
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
Generic LAUNCH.DLL INTERFACE
|
||||
==============================================================================
|
||||
*/
|
||||
typedef struct launch_exp_s
|
||||
{
|
||||
// interface validator
|
||||
size_t api_size; // must matched with sizeof(launch_api_t)
|
||||
size_t com_size; // must matched with sizeof(stdlib_api_t)
|
||||
|
||||
void (*Init)( const int argc, const char **argv ); // init host
|
||||
void (*Main)( void ); // host frame
|
||||
void (*Free)( void ); // close host
|
||||
void (*CPrint)( const char *msg ); // host print
|
||||
void (*CmdForward)( void ); // cmd forward to server
|
||||
void (*CmdComplete)( char *complete_string ); // cmd autocomplete for system console
|
||||
} launch_exp_t;
|
||||
|
||||
#endif//ENGINE_API_H
|
|
@ -722,6 +722,26 @@ typedef struct stdilib_api_s
|
|||
const char* (*timestamp)( int format ); // returns current time stamp
|
||||
} stdlib_api_t;
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
Generic LAUNCH.DLL INTERFACE
|
||||
==============================================================================
|
||||
*/
|
||||
typedef struct launch_exp_s
|
||||
{
|
||||
// interface validator
|
||||
size_t api_size; // must matched with sizeof(launch_api_t)
|
||||
size_t com_size; // must matched with sizeof(stdlib_api_t)
|
||||
|
||||
void (*Init)( const int argc, const char **argv ); // init host
|
||||
void (*Main)( void ); // host frame
|
||||
void (*Free)( void ); // close host
|
||||
void (*CPrint)( const char *msg ); // host print
|
||||
void (*CmdForward)( void ); // cmd forward to server
|
||||
void (*CmdComplete)( char *complete_string ); // cmd autocomplete for system console
|
||||
} launch_exp_t;
|
||||
|
||||
// this is the only function actually exported at the linker level
|
||||
typedef void *(*launch_t)( stdlib_api_t*, void* );
|
||||
typedef struct { size_t api_size; size_t com_size; } generic_api_t;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
@echo off
|
||||
|
||||
cd utils
|
||||
cd bsplib
|
||||
makefile.nmake
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "r_local.h"
|
||||
#include "byteorder.h"
|
||||
#include "mathlib.h"
|
||||
#include "matrix_lib.h"
|
||||
#include "const.h"
|
||||
|
@ -2175,7 +2174,6 @@ static rgbdata_t *R_ParseStudioSkin( script_t *script, const byte *buf, size_t s
|
|||
FS_Close( f );
|
||||
return NULL;
|
||||
}
|
||||
SwapBlock( (int *)&hdr, sizeof( hdr ));
|
||||
|
||||
if( hdr.numtextures == 0 )
|
||||
{
|
||||
|
@ -2193,7 +2191,6 @@ static rgbdata_t *R_ParseStudioSkin( script_t *script, const byte *buf, size_t s
|
|||
FS_Close( f );
|
||||
return NULL;
|
||||
}
|
||||
SwapBlock( (int *)&hdr, sizeof( hdr ));
|
||||
}
|
||||
|
||||
if( hdr.textureindex > 0 && hdr.numtextures <= MAXSTUDIOSKINS )
|
||||
|
@ -3322,8 +3319,8 @@ static rgbdata_t *R_InitNoTexture( int *flags, int *samples )
|
|||
for( x = 0; x < 16; x++ )
|
||||
{
|
||||
if(( y < 8 ) ^ ( x < 8 ))
|
||||
((uint *)&data2D)[y*16+x] = LittleLong( 0xFFFF00FF );
|
||||
else ((uint *)&data2D)[y*16+x] = LittleLong( 0xFF000000 );
|
||||
((uint *)&data2D)[y*16+x] = 0xFFFF00FF;
|
||||
else ((uint *)&data2D)[y*16+x] = 0xFF000000;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
@ -3333,8 +3330,8 @@ static rgbdata_t *R_InitNoTexture( int *flags, int *samples )
|
|||
for( x = 0; x < 16; x++ )
|
||||
{
|
||||
if( x == 0 || x == 15 || y == 0 || y == 15 )
|
||||
((uint *)&data2D)[y*16+x] = LittleLong( 0xFFFFFFFF );
|
||||
else ((uint *)&data2D)[y*16+x] = LittleLong( 0xFF000000 );
|
||||
((uint *)&data2D)[y*16+x] = 0xFFFFFFFF;
|
||||
else ((uint *)&data2D)[y*16+x] = 0xFF000000;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -3611,7 +3608,7 @@ static rgbdata_t *R_InitSkyTexture( int *flags, int *samples )
|
|||
|
||||
// skybox texture
|
||||
for( i = 0; i < 256; i++ )
|
||||
((uint *)&data2D)[i] = LittleLong( 0xFFFFDEB5 );
|
||||
((uint *)&data2D)[i] = 0xFFFFDEB5;
|
||||
|
||||
*flags = TF_NOPICMIP|TF_UNCOMPRESSED;
|
||||
*samples = 3;
|
||||
|
|
|
@ -26,7 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "wadfile.h"
|
||||
#include "mathlib.h"
|
||||
#include "matrix_lib.h"
|
||||
#include "byteorder.h"
|
||||
#include "bspfile.h"
|
||||
#include "cl_entity.h"
|
||||
|
||||
|
@ -460,7 +459,7 @@ ref_model_t *Mod_ForName( const char *name, qboolean crash )
|
|||
FS_FileBase( mod->name, cached.modelname );
|
||||
|
||||
// call the apropriate loader
|
||||
switch( LittleLong( *(uint *)buf ))
|
||||
switch( *(uint *)buf )
|
||||
{
|
||||
case IDSTUDIOHEADER:
|
||||
Mod_StudioLoadModel( mod, buf );
|
||||
|
@ -1239,7 +1238,7 @@ static void Mod_LoadTextures( const dlump_t *l )
|
|||
}
|
||||
|
||||
in = (void *)(mod_base + l->fileofs);
|
||||
count = LittleLong( in->nummiptex );
|
||||
count = in->nummiptex;
|
||||
|
||||
cached.textures = Mem_Alloc( cached_mempool, count * sizeof( *out ));
|
||||
|
||||
|
@ -1251,7 +1250,7 @@ static void Mod_LoadTextures( const dlump_t *l )
|
|||
|
||||
for( i = 0; i < count; i++, out++ )
|
||||
{
|
||||
in->dataofs[i] = LittleLong( in->dataofs[i] );
|
||||
in->dataofs[i] = in->dataofs[i];
|
||||
|
||||
if( in->dataofs[i] == -1 )
|
||||
{
|
||||
|
@ -1273,8 +1272,8 @@ static void Mod_LoadTextures( const dlump_t *l )
|
|||
com.strncpy( out->name, mt->name, sizeof( out->name ));
|
||||
|
||||
// original dimensions for adjust lightmap on a face
|
||||
out->width = LittleLong( mt->width );
|
||||
out->height = LittleLong( mt->height );
|
||||
out->width = mt->width;
|
||||
out->height = mt->height;
|
||||
out->base = mt;
|
||||
|
||||
// sky must be loading first
|
||||
|
@ -1463,7 +1462,7 @@ static void Mod_LoadVertexes( const dlump_t *l )
|
|||
for( i = 0; i < count; i++, in++, out += 3 )
|
||||
{
|
||||
for( j = 0; j < 3; j++ )
|
||||
out[j] = LittleFloat( in->point[j] );
|
||||
out[j] = in->point[j];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1498,16 +1497,16 @@ static void Mod_LoadSubmodels( const dlump_t *l )
|
|||
|
||||
for( j = 0; j < 3; j++ )
|
||||
{
|
||||
out->mins[j] = LittleFloat( in->mins[j] );
|
||||
out->maxs[j] = LittleFloat( in->maxs[j] );
|
||||
out->origin[j] = LittleFloat( in->origin[j] );
|
||||
out->mins[j] = in->mins[j];
|
||||
out->maxs[j] = in->maxs[j];
|
||||
out->origin[j] = in->origin[j];
|
||||
}
|
||||
|
||||
out->radius = RadiusFromBounds( out->mins, out->maxs );
|
||||
out->firstnode = LittleLong( in->headnode[0] ); // drawing hull #0
|
||||
out->firstface = LittleLong( in->firstface );
|
||||
out->numfaces = LittleLong( in->numfaces );
|
||||
out->visleafs = LittleLong( in->visleafs );
|
||||
out->firstnode = in->headnode[0]; // drawing hull #0
|
||||
out->firstface = in->firstface;
|
||||
out->numfaces = in->numfaces;
|
||||
out->visleafs = in->visleafs;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1537,9 +1536,9 @@ static void Mod_LoadTexInfo( const dlump_t *l )
|
|||
for( i = 0; i < count; i++, in++, out++ )
|
||||
{
|
||||
for( j = 0; j < 8; j++ )
|
||||
out->vecs[0][j] = LittleFloat( in->vecs[0][j] );
|
||||
out->vecs[0][j] = in->vecs[0][j];
|
||||
|
||||
miptex = LittleLong( in->miptex );
|
||||
miptex = in->miptex;
|
||||
if( miptex < 0 || miptex > loadmodel->numshaders )
|
||||
Host_Error( "Mod_LoadTexInfo: bad shader number in '%s'\n", loadmodel->name );
|
||||
out->texturenum = miptex;
|
||||
|
@ -1576,12 +1575,12 @@ static void Mod_LoadSurfaces( const dlump_t *l )
|
|||
|
||||
for( i = 0; i < count; i++, in++, out++ )
|
||||
{
|
||||
out->firstedge = LittleLong( in->firstedge );
|
||||
out->numedges = LittleLong( in->numedges );
|
||||
out->firstedge = in->firstedge;
|
||||
out->numedges = in->numedges;
|
||||
|
||||
if( LittleShort( in->side )) out->flags |= SURF_PLANEBACK;
|
||||
out->plane = loadbmodel->planes + LittleLong( in->planenum );
|
||||
out->texinfo = loadbmodel->texinfo + LittleLong( in->texinfo );
|
||||
if( in->side ) out->flags |= SURF_PLANEBACK;
|
||||
out->plane = loadbmodel->planes + in->planenum;
|
||||
out->texinfo = loadbmodel->texinfo + in->texinfo;
|
||||
texnum = out->texinfo->texturenum;
|
||||
|
||||
if( texnum < 0 || texnum > cached.numtextures )
|
||||
|
@ -1605,7 +1604,7 @@ static void Mod_LoadSurfaces( const dlump_t *l )
|
|||
out->lmHeight = (out->extents[1] >> 4) + 1;
|
||||
|
||||
if( out->flags & SURF_DRAWTILED ) lightofs = -1;
|
||||
else lightofs = LittleLong( in->lightofs );
|
||||
else lightofs = in->lightofs;
|
||||
|
||||
if( loadbmodel->lightdata && lightofs != -1 )
|
||||
{
|
||||
|
@ -1659,7 +1658,7 @@ static void Mod_LoadMarkFaces( const dlump_t *l )
|
|||
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
j = LittleLong( in[i] );
|
||||
j = in[i];
|
||||
if( j < 0 || j >= loadbmodel->numsurfaces )
|
||||
Host_Error( "Mod_LoadMarkFaces: bad surface number in '%s'\n", loadmodel->name );
|
||||
loadbmodel->marksurfaces[i] = loadbmodel->surfaces + j;
|
||||
|
@ -1691,15 +1690,15 @@ static void Mod_LoadNodes( const dlump_t *l )
|
|||
{
|
||||
qboolean badBounds = false;
|
||||
|
||||
out->plane = loadbmodel->planes + LittleLong( in->planenum );
|
||||
out->firstface = loadbmodel->surfaces + LittleLong( in->firstface );
|
||||
out->numfaces = LittleLong( in->numfaces );
|
||||
out->plane = loadbmodel->planes + in->planenum;
|
||||
out->firstface = loadbmodel->surfaces + in->firstface;
|
||||
out->numfaces = in->numfaces;
|
||||
out->contents = CONTENTS_NODE;
|
||||
|
||||
for( j = 0; j < 3; j++ )
|
||||
{
|
||||
out->mins[j] = (float)LittleShort( in->mins[j] );
|
||||
out->maxs[j] = (float)LittleShort( in->maxs[j] );
|
||||
out->mins[j] = (float)in->mins[j];
|
||||
out->maxs[j] = (float)in->maxs[j];
|
||||
if( out->mins[j] > out->maxs[j] ) badBounds = true;
|
||||
}
|
||||
|
||||
|
@ -1715,7 +1714,7 @@ static void Mod_LoadNodes( const dlump_t *l )
|
|||
|
||||
for( j = 0; j < 2; j++ )
|
||||
{
|
||||
p = LittleShort( in->children[j] );
|
||||
p = in->children[j];
|
||||
if( p >= 0 ) out->children[j] = loadbmodel->nodes + p;
|
||||
else out->children[j] = (mnode_t *)(loadbmodel->leafs + ( -1 - p ));
|
||||
}
|
||||
|
@ -1751,8 +1750,8 @@ static void Mod_LoadLeafs( const dlump_t *l )
|
|||
|
||||
for( j = 0; j < 3; j++ )
|
||||
{
|
||||
out->mins[j] = (float)LittleShort( in->mins[j] );
|
||||
out->maxs[j] = (float)LittleShort( in->maxs[j] );
|
||||
out->mins[j] = (float)in->mins[j];
|
||||
out->maxs[j] = (float)in->maxs[j];
|
||||
if( out->mins[j] > out->maxs[j] ) badBounds = true;
|
||||
}
|
||||
|
||||
|
@ -1767,13 +1766,13 @@ static void Mod_LoadLeafs( const dlump_t *l )
|
|||
}
|
||||
|
||||
out->plane = NULL; // to differentiate from nodes
|
||||
out->contents = LittleLong( in->contents );
|
||||
out->contents = in->contents;
|
||||
|
||||
p = LittleLong( in->visofs );
|
||||
p = in->visofs;
|
||||
out->compressed_vis = (p == -1) ? NULL : loadbmodel->visdata + p;
|
||||
|
||||
out->firstMarkSurface = loadbmodel->marksurfaces + LittleShort( in->firstmarksurface );
|
||||
out->numMarkSurfaces = LittleShort( in->nummarksurfaces );
|
||||
out->firstMarkSurface = loadbmodel->marksurfaces + in->firstmarksurface;
|
||||
out->numMarkSurfaces = in->nummarksurfaces;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1797,8 +1796,8 @@ static void Mod_LoadEdges( const dlump_t *l )
|
|||
|
||||
for( i = 0; i < count; i++, in++, out++ )
|
||||
{
|
||||
out->v[0] = (word)LittleShort( in->v[0] );
|
||||
out->v[1] = (word)LittleShort( in->v[1] );
|
||||
out->v[0] = (word)in->v[0];
|
||||
out->v[1] = (word)in->v[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1810,7 +1809,7 @@ Mod_LoadSurfEdges
|
|||
static void Mod_LoadSurfEdges( const dlump_t *l )
|
||||
{
|
||||
dsurfedge_t *in, *out;
|
||||
int i, count;
|
||||
int count;
|
||||
|
||||
in = (void *)( mod_base + l->fileofs );
|
||||
if( l->filelen % sizeof( *in ))
|
||||
|
@ -1820,8 +1819,7 @@ static void Mod_LoadSurfEdges( const dlump_t *l )
|
|||
cached.surfedges = out = Mem_Alloc( cached_mempool, count * sizeof( dsurfedge_t ));
|
||||
cached.numsurfedges = count;
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
out[i] = LittleLong( in[i] );
|
||||
Mem_Copy( out, in, count * sizeof( dsurfedge_t ));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1847,12 +1845,10 @@ static void Mod_LoadPlanes( const dlump_t *l )
|
|||
|
||||
for( i = 0; i < count; i++, in++, out++ )
|
||||
{
|
||||
out->normal[0] = LittleFloat( in->normal[0] );
|
||||
out->normal[1] = LittleFloat( in->normal[1] );
|
||||
out->normal[2] = LittleFloat( in->normal[2] );
|
||||
VectorCopy( in->normal, out->normal );
|
||||
out->signbits = SignbitsForPlane( out->normal );
|
||||
out->dist = LittleFloat( in->dist );
|
||||
out->type = LittleLong( in->type );
|
||||
out->dist = in->dist;
|
||||
out->type = in->type;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2582,7 +2578,7 @@ void Mod_BrushLoadModel( ref_model_t *mod, const void *buffer )
|
|||
int i, j;
|
||||
|
||||
header = (dheader_t *)buffer;
|
||||
cached.version = LittleLong( header->version );
|
||||
cached.version = header->version;
|
||||
|
||||
switch( cached.version )
|
||||
{
|
||||
|
@ -2597,10 +2593,6 @@ void Mod_BrushLoadModel( ref_model_t *mod, const void *buffer )
|
|||
mod->type = mod_brush;
|
||||
mod_base = (byte *)header;
|
||||
|
||||
// swap all the lumps
|
||||
for( i = 0; i < sizeof( dheader_t )/4; i++ )
|
||||
((int *)header )[i] = LittleLong( ((int *)header )[i] );
|
||||
|
||||
// load into heap
|
||||
Mod_LoadSubmodels( &header->lumps[LUMP_MODELS] );
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "r_local.h"
|
||||
#include "mathlib.h"
|
||||
#include "byteorder.h"
|
||||
#include "const.h"
|
||||
#include "cl_entity.h"
|
||||
|
||||
|
@ -54,7 +53,6 @@ static dframetype_t *R_SpriteLoadFrame( ref_model_t *mod, void *pin, mspritefram
|
|||
com.snprintf( name, MAX_STRING, "Sprite( %s_%s_%i%i )", sp_name, frame_prefix, framenum/10, framenum%10 );
|
||||
|
||||
pinframe = (dspriteframe_t *)pin;
|
||||
SwapBlock((int *)pinframe, sizeof( dspriteframe_t ));
|
||||
|
||||
// setup frame description
|
||||
pspriteframe = Mem_Alloc( mod->mempool, sizeof( mspriteframe_t ));
|
||||
|
@ -92,7 +90,6 @@ static dframetype_t *CL_LoadSpriteFrame( const char *szSpriteName, void *pin, in
|
|||
com.snprintf( name, MAX_STRING, "Sprite( \"%s_%s_%i%i\" )", sp_name, frame_prefix, framenum/10, framenum%10 );
|
||||
|
||||
pinframe = (dspriteframe_t *)pin;
|
||||
SwapBlock((int *)pinframe, sizeof( dspriteframe_t ));
|
||||
|
||||
// NOTE: just loading all single frame into one shader
|
||||
// we supported only single frames in this case
|
||||
|
@ -118,15 +115,14 @@ static dframetype_t *CL_SpriteSkipGroup( const char *szSpriteName, void *pin, in
|
|||
pin_intervals = (dspriteinterval_t *)(pingroup + 1);
|
||||
|
||||
// skip intervals
|
||||
for( i = 0; i < LittleLong( pingroup->numframes ); i++ )
|
||||
for( i = 0; i < pingroup->numframes; i++ )
|
||||
pin_intervals++;
|
||||
|
||||
// skip group frames
|
||||
ptemp = (void *)pin_intervals;
|
||||
for( i = 0; i < LittleLong( pingroup->numframes ); i++ )
|
||||
for( i = 0; i < pingroup->numframes; i++ )
|
||||
{
|
||||
pinframe = (dspriteframe_t *)ptemp;
|
||||
SwapBlock((int *)pinframe, sizeof( dspriteframe_t ));
|
||||
ptemp = (dframetype_t *)((byte *)(pinframe + 1) + pinframe->width * pinframe->height );
|
||||
}
|
||||
return (dframetype_t *)ptemp;
|
||||
|
@ -144,7 +140,7 @@ static dframetype_t *R_SpriteLoadGroup( ref_model_t *mod, void * pin, mspritefra
|
|||
void *ptemp;
|
||||
|
||||
pingroup = (dspritegroup_t *)pin;
|
||||
numframes = LittleLong( pingroup->numframes );
|
||||
numframes = pingroup->numframes;
|
||||
|
||||
groupsize = sizeof(mspritegroup_t) + (numframes - 1) * sizeof( pspritegroup->frames[0] );
|
||||
pspritegroup = Mem_Alloc( mod->mempool, groupsize );
|
||||
|
@ -157,7 +153,7 @@ static dframetype_t *R_SpriteLoadGroup( ref_model_t *mod, void * pin, mspritefra
|
|||
|
||||
for( i = 0; i < numframes; i++ )
|
||||
{
|
||||
*poutintervals = LittleFloat( pin_intervals->interval );
|
||||
*poutintervals = pin_intervals->interval;
|
||||
if( *poutintervals <= 0.0 ) *poutintervals = 1.0f; // set error value
|
||||
if( frame_type == FRAME_GROUP ) R_ShaderAddStageIntervals( *poutintervals );
|
||||
else if( frame_type == FRAME_ANGLED ) R_ShaderAddStageIntervals( -1.0f );
|
||||
|
@ -194,7 +190,7 @@ void Mod_SpriteLoadModel( ref_model_t *mod, const void *buffer )
|
|||
qboolean twoSided;
|
||||
|
||||
pin = (dsprite_t *)buffer;
|
||||
i = LittleLong( pin->version );
|
||||
i = pin->version;
|
||||
|
||||
if( i != SPRITE_VERSION )
|
||||
{
|
||||
|
@ -202,24 +198,24 @@ void Mod_SpriteLoadModel( ref_model_t *mod, const void *buffer )
|
|||
return;
|
||||
}
|
||||
|
||||
numframes = LittleLong( pin->numframes );
|
||||
size = sizeof (msprite_t) + (numframes - 1) * sizeof( psprite->frames );
|
||||
numframes = pin->numframes;
|
||||
size = sizeof( msprite_t ) + ( numframes - 1 ) * sizeof( psprite->frames );
|
||||
|
||||
psprite = Mem_Alloc( mod->mempool, size );
|
||||
mod->extradata = psprite; // make link to extradata
|
||||
mod->numshaders = 0; // reset frames
|
||||
|
||||
psprite->type = LittleLong( pin->type );
|
||||
psprite->rendermode = LittleLong( pin->texFormat );
|
||||
psprite->type = pin->type;
|
||||
psprite->rendermode = pin->texFormat;
|
||||
psprite->numframes = numframes;
|
||||
twoSided = (LittleLong( pin->facetype == SPR_CULL_NONE )) ? true : false;
|
||||
mod->mins[0] = mod->mins[1] = -LittleLong( pin->bounds[0] ) / 2;
|
||||
mod->maxs[0] = mod->maxs[1] = LittleLong( pin->bounds[0] ) / 2;
|
||||
mod->mins[2] = -LittleLong( pin->bounds[1] ) / 2;
|
||||
mod->maxs[2] = LittleLong( pin->bounds[1] ) / 2;
|
||||
twoSided = ( pin->facetype == SPR_CULL_NONE ) ? true : false;
|
||||
mod->mins[0] = mod->mins[1] = -pin->bounds[0] / 2;
|
||||
mod->maxs[0] = mod->maxs[1] = pin->bounds[0] / 2;
|
||||
mod->mins[2] = -pin->bounds[1] / 2;
|
||||
mod->maxs[2] = pin->bounds[1] / 2;
|
||||
numi = (short *)(pin + 1);
|
||||
|
||||
if( LittleShort( *numi ) == 256 )
|
||||
if( *numi == 256 )
|
||||
{
|
||||
byte *src = (byte *)(numi+1);
|
||||
rgbdata_t *pal;
|
||||
|
@ -271,7 +267,7 @@ void Mod_SpriteLoadModel( ref_model_t *mod, const void *buffer )
|
|||
|
||||
for( i = 0; i < numframes; i++ )
|
||||
{
|
||||
frametype_t frametype = LittleLong( pframetype->type );
|
||||
frametype_t frametype = pframetype->type;
|
||||
psprite->frames[i].type = frametype;
|
||||
frame_type = frametype;
|
||||
|
||||
|
@ -329,31 +325,31 @@ ref_shader_t *CL_LoadSprite( const char *szSpriteName )
|
|||
pin = (dsprite_t *)buffer;
|
||||
|
||||
// make sure what is really sprite
|
||||
if( LittleLong( pin->ident ) != IDSPRITEHEADER )
|
||||
if( pin->ident != IDSPRITEHEADER )
|
||||
{
|
||||
MsgDev( D_ERROR, "CL_LoadSprite: %s not a sprite\n", szSpriteName );
|
||||
Mem_Free( buffer );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( LittleLong( pin->version ) != SPRITE_VERSION )
|
||||
if( pin->version != SPRITE_VERSION )
|
||||
{
|
||||
MsgDev( D_ERROR, "CL_LoadSprite: %s invalid sprite version\n", szSpriteName );
|
||||
Mem_Free( buffer );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
numframes = LittleLong( pin->numframes );
|
||||
twoSided = (LittleLong( pin->facetype == SPR_CULL_NONE )) ? true : false;
|
||||
numframes = pin->numframes;
|
||||
twoSided = ( pin->facetype == SPR_CULL_NONE ) ? true : false;
|
||||
numi = (short *)( pin + 1 );
|
||||
|
||||
if( LittleShort( *numi ) == 256 )
|
||||
if( *numi == 256 )
|
||||
{
|
||||
byte *src = (byte *)(numi+1);
|
||||
rgbdata_t *pal;
|
||||
|
||||
// install palette
|
||||
switch( LittleLong( pin->texFormat ))
|
||||
switch( pin->texFormat )
|
||||
{
|
||||
case SPR_ADDGLOW:
|
||||
pal = FS_LoadImage( "#normal.pal", src, 768 );
|
||||
|
@ -402,7 +398,7 @@ ref_shader_t *CL_LoadSprite( const char *szSpriteName )
|
|||
|
||||
for( i = 0; i < numframes; i++ )
|
||||
{
|
||||
switch( LittleLong( pframetype->type ))
|
||||
switch( pframetype->type )
|
||||
{
|
||||
case FRAME_SINGLE:
|
||||
pframetype = CL_LoadSpriteFrame( szSpriteName, pframetype + 1, i );
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "r_local.h"
|
||||
#include "byteorder.h"
|
||||
#include "mathlib.h"
|
||||
#include "matrix_lib.h"
|
||||
#include "cl_entity.h"
|
||||
|
@ -663,8 +662,8 @@ void Mod_StudioLoadModel( ref_model_t *mod, const void *buffer )
|
|||
|
||||
if( !phdr ) return; // there were problems
|
||||
mod->extradata = poutmodel = (mstudiodata_t *)Mod_Malloc( mod, sizeof( mstudiodata_t ));
|
||||
poutmodel->phdr = (studiohdr_t *)Mod_Malloc( mod, LittleLong( phdr->length ));
|
||||
Mem_Copy( poutmodel->phdr, buffer, LittleLong( phdr->length ));
|
||||
poutmodel->phdr = (studiohdr_t *)Mod_Malloc( mod, phdr->length );
|
||||
Mem_Copy( poutmodel->phdr, buffer, phdr->length );
|
||||
|
||||
if( phdr->numtextures == 0 )
|
||||
{
|
||||
|
@ -673,8 +672,8 @@ void Mod_StudioLoadModel( ref_model_t *mod, const void *buffer )
|
|||
else MsgDev( D_ERROR, "StudioLoadModel: %s missing textures file\n", mod->name );
|
||||
|
||||
if( !thdr ) return; // there were problems
|
||||
poutmodel->thdr = (studiohdr_t *)Mod_Malloc( mod, LittleLong( thdr->length ));
|
||||
Mem_Copy( poutmodel->thdr, texbuf, LittleLong( thdr->length ));
|
||||
poutmodel->thdr = (studiohdr_t *)Mod_Malloc( mod, thdr->length );
|
||||
Mem_Copy( poutmodel->thdr, texbuf, thdr->length );
|
||||
if( texbuf ) Mem_Free( texbuf );
|
||||
}
|
||||
else poutmodel->thdr = poutmodel->phdr; // just make link
|
||||
|
@ -1079,7 +1078,7 @@ mstudioanim_t *R_StudioGetAnim( ref_model_t *m_pRefModel, mstudioseqdesc_t *pseq
|
|||
|
||||
buf = FS_LoadFile( filepath, &filesize );
|
||||
if( !buf || !filesize ) Host_Error( "R_StudioGetAnim: can't load %s\n", filepath );
|
||||
if( IDSEQGRPHEADER != LittleLong(*(uint *)buf ))
|
||||
if( IDSEQGRPHEADER != *(uint *)buf )
|
||||
Host_Error( "R_StudioGetAnim: %s is corrupted\n", filepath );
|
||||
|
||||
MsgDev( D_NOTE, "R_StudioGetAnim: %s\n", filepath );
|
||||
|
|
Reference in New Issue