fix the build
This commit is contained in:
parent
fafa271a46
commit
13524d59ef
|
|
@ -94,6 +94,8 @@ bool VectorCompare( const vec3_t v1, const vec3_t v2 );
|
|||
bool VectorIsOnAxis( vec3_t v );
|
||||
bool VectorIsOnAxialPlane( vec3_t v );
|
||||
|
||||
void MakeNormalVectors( vec3_t forward, vec3_t right, vec3_t up );
|
||||
|
||||
vec_t VectorLength( const vec3_t v );
|
||||
|
||||
void VectorMA( const vec3_t va, vec_t scale, const vec3_t vb, vec3_t vc );
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ polyset_t *ASE_GetSurfaceAnimation( int which, int *pNumFrames, int skipFrameSta
|
|||
|
||||
*pNumFrames = numFramesToKeep;
|
||||
|
||||
psets = calloc( sizeof( polyset_t ) * numFramesToKeep, 1 );
|
||||
psets = safe_calloc( sizeof( polyset_t ) * numFramesToKeep );
|
||||
|
||||
for ( f = 0, i = 0; i < numFramesInAnimation; i++ )
|
||||
{
|
||||
|
|
@ -230,7 +230,7 @@ polyset_t *ASE_GetSurfaceAnimation( int which, int *pNumFrames, int skipFrameSta
|
|||
strcpy( psets[f].name, pObject->name );
|
||||
strcpy( psets[f].materialname, ase.materials[pObject->materialRef].name );
|
||||
|
||||
psets[f].triangles = calloc( sizeof( triangle_t ) * pObject->anim.frames[i].numFaces, 1 );
|
||||
psets[f].triangles = safe_calloc( sizeof( triangle_t ) * pObject->anim.frames[i].numFaces );
|
||||
psets[f].numtriangles = pObject->anim.frames[i].numFaces;
|
||||
|
||||
for ( t = 0; t < pObject->anim.frames[i].numFaces; t++ )
|
||||
|
|
@ -632,25 +632,25 @@ static void ASE_KeyMESH( const char *token ){
|
|||
VERBOSE( ( ".....num tvertexes: %d\n", pMesh->numTVertexes ) );
|
||||
}
|
||||
else if ( strEqual( token, "*MESH_VERTEX_LIST" ) ) {
|
||||
pMesh->vertexes = calloc( sizeof( aseVertex_t ) * pMesh->numVertexes, 1 );
|
||||
pMesh->vertexes = safe_calloc( sizeof( aseVertex_t ) * pMesh->numVertexes );
|
||||
pMesh->currentVertex = 0;
|
||||
VERBOSE( ( ".....parsing MESH_VERTEX_LIST\n" ) );
|
||||
ASE_ParseBracedBlock( ASE_KeyMESH_VERTEX_LIST );
|
||||
}
|
||||
else if ( strEqual( token, "*MESH_TVERTLIST" ) ) {
|
||||
pMesh->currentVertex = 0;
|
||||
pMesh->tvertexes = calloc( sizeof( aseTVertex_t ) * pMesh->numTVertexes, 1 );
|
||||
pMesh->tvertexes = safe_calloc( sizeof( aseTVertex_t ) * pMesh->numTVertexes );
|
||||
VERBOSE( ( ".....parsing MESH_TVERTLIST\n" ) );
|
||||
ASE_ParseBracedBlock( ASE_KeyMESH_TVERTLIST );
|
||||
}
|
||||
else if ( strEqual( token, "*MESH_FACE_LIST" ) ) {
|
||||
pMesh->faces = calloc( sizeof( aseFace_t ) * pMesh->numFaces, 1 );
|
||||
pMesh->faces = safe_calloc( sizeof( aseFace_t ) * pMesh->numFaces );
|
||||
pMesh->currentFace = 0;
|
||||
VERBOSE( ( ".....parsing MESH_FACE_LIST\n" ) );
|
||||
ASE_ParseBracedBlock( ASE_KeyMESH_FACE_LIST );
|
||||
}
|
||||
else if ( strEqual( token, "*MESH_TFACELIST" ) ) {
|
||||
pMesh->tfaces = calloc( sizeof( aseFace_t ) * pMesh->numFaces, 1 );
|
||||
pMesh->tfaces = safe_calloc( sizeof( aseFace_t ) * pMesh->numFaces );
|
||||
pMesh->currentFace = 0;
|
||||
VERBOSE( ( ".....parsing MESH_TFACE_LIST\n" ) );
|
||||
ASE_ParseBracedBlock( ASE_KeyTFACE_LIST );
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "../common/cmdlib.h"
|
||||
#include "cmdlib.h"
|
||||
#include "mathlib.h"
|
||||
#include "polyset.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ void IncDrawVerts(){
|
|||
numDrawVertsBuffer = MAX_MAP_DRAW_VERTS;
|
||||
}
|
||||
|
||||
drawVerts = realloc( drawVerts, sizeof( drawVert_t ) * numDrawVertsBuffer );
|
||||
drawVerts = void_ptr( realloc( drawVerts, sizeof( drawVert_t ) * numDrawVertsBuffer ) );
|
||||
|
||||
if ( !drawVerts ) {
|
||||
Error( "realloc() failed (IncDrawVerts)" );
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
#ifdef SAFE_MALLOC
|
||||
// FIXME switch to -std=c99 or above to use proper %zu format specifier for size_t
|
||||
void *safe_malloc( size_t size ){
|
||||
void_ptr safe_malloc( size_t size ){
|
||||
void *p = malloc( size );
|
||||
if ( !p ) {
|
||||
Error( "safe_malloc failed on allocation of %lu bytes", (unsigned long)size );
|
||||
|
|
@ -55,7 +55,7 @@ void *safe_malloc( size_t size ){
|
|||
return p;
|
||||
}
|
||||
|
||||
void *safe_malloc_info( size_t size, const char* info ){
|
||||
void_ptr safe_malloc_info( size_t size, const char* info ){
|
||||
void *p = malloc( size );
|
||||
if ( !p ) {
|
||||
Error( "%s: safe_malloc failed on allocation of %lu bytes", info, (unsigned long)size );
|
||||
|
|
@ -63,7 +63,7 @@ void *safe_malloc_info( size_t size, const char* info ){
|
|||
return p;
|
||||
}
|
||||
|
||||
void *safe_calloc( size_t size ){
|
||||
void_ptr safe_calloc( size_t size ){
|
||||
void *p = calloc( 1, size );
|
||||
if ( !p ) {
|
||||
Error( "safe_calloc failed on allocation of %lu bytes", (unsigned long)size );
|
||||
|
|
@ -71,7 +71,7 @@ void *safe_calloc( size_t size ){
|
|||
return p;
|
||||
}
|
||||
|
||||
void *safe_calloc_info( size_t size, const char* info ){
|
||||
void_ptr safe_calloc_info( size_t size, const char* info ){
|
||||
void *p = calloc( 1, size );
|
||||
if ( !p ) {
|
||||
Error( "%s: safe_calloc failed on allocation of %lu bytes", info, (unsigned long)size );
|
||||
|
|
@ -327,7 +327,7 @@ int FileTime( const char *path ){
|
|||
|
||||
//http://stackoverflow.com/questions/27303062/strstr-function-like-that-ignores-upper-or-lower-case
|
||||
//chux: Somewhat tricky to match the corner cases of strstr() with inputs like "x","", "","x", "",""
|
||||
char *strIstr( const char* haystack, const char* needle ) {
|
||||
const char *strIstr( const char* haystack, const char* needle ) {
|
||||
do {
|
||||
const char* h = haystack;
|
||||
const char* n = needle;
|
||||
|
|
@ -342,6 +342,10 @@ char *strIstr( const char* haystack, const char* needle ) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char *strIstr( char* haystack, const char* needle ) {
|
||||
return const_cast<char*>( strIstr( const_cast<const char*>( haystack ), needle ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy src to string dst of size size. At most size-1 characters
|
||||
* will be copied. Always NUL terminates (unless size == 0).
|
||||
|
|
@ -571,7 +575,7 @@ bool path_is_absolute( const char* path ){
|
|||
}
|
||||
|
||||
/// \brief Returns a pointer to the last slash or to terminating null character if not found.
|
||||
char* path_get_last_separator( const char* path ){
|
||||
const char* path_get_last_separator( const char* path ){
|
||||
const char *end = path + strlen( path );
|
||||
const char *src = end;
|
||||
|
||||
|
|
@ -582,8 +586,12 @@ char* path_get_last_separator( const char* path ){
|
|||
return end;
|
||||
}
|
||||
|
||||
char* path_get_last_separator( char* path ){
|
||||
return const_cast<char*>( path_get_last_separator( const_cast<const char*>( path ) ) );
|
||||
}
|
||||
|
||||
/// \brief Returns a pointer to the first character of the filename component of \p path.
|
||||
char* path_get_filename_start( const char* path ){
|
||||
const char* path_get_filename_start( const char* path ){
|
||||
const char *src = path + strlen( path );
|
||||
|
||||
while ( src != path && !path_separator( src[-1] ) ){
|
||||
|
|
@ -592,8 +600,12 @@ char* path_get_filename_start( const char* path ){
|
|||
return src;
|
||||
}
|
||||
|
||||
char* path_get_filename_start( char* path ){
|
||||
return const_cast<char*>( path_get_filename_start( const_cast<const char*>( path ) ) );
|
||||
}
|
||||
|
||||
/// \brief Returns a pointer to the character after the end of the filename component of \p path - either the extension separator or the terminating null character.
|
||||
char* path_get_filename_base_end( const char* path ){
|
||||
const char* path_get_filename_base_end( const char* path ){
|
||||
const char *end = path + strlen( path );
|
||||
const char *src = end;
|
||||
|
||||
|
|
@ -604,9 +616,12 @@ char* path_get_filename_base_end( const char* path ){
|
|||
return end;
|
||||
}
|
||||
|
||||
char* path_get_filename_base_end( char* path ){
|
||||
return const_cast<char*>( path_get_filename_base_end( const_cast<const char*>( path ) ) );
|
||||
}
|
||||
|
||||
/// \brief Returns a pointer to the first character of the file extension of \p path, or to terminating null character if not found.
|
||||
char* path_get_extension( const char* path ){
|
||||
const char* path_get_extension( const char* path ){
|
||||
const char *end = path + strlen( path );
|
||||
const char *src = end;
|
||||
|
||||
|
|
@ -617,6 +632,10 @@ char* path_get_extension( const char* path ){
|
|||
return end;
|
||||
}
|
||||
|
||||
char* path_get_extension( char* path ){
|
||||
return const_cast<char*>( path_get_extension( const_cast<const char*>( path ) ) );
|
||||
}
|
||||
|
||||
/// \brief Appends trailing slash, unless \p path is empty or already has slash.
|
||||
void path_add_slash( char *path ){
|
||||
char* end = path + strlen( path );
|
||||
|
|
|
|||
|
|
@ -62,10 +62,24 @@
|
|||
|
||||
#define SAFE_MALLOC
|
||||
#ifdef SAFE_MALLOC
|
||||
void *safe_malloc( size_t size );
|
||||
void *safe_malloc_info( size_t size, const char* info );
|
||||
void *safe_calloc( size_t size );
|
||||
void *safe_calloc_info( size_t size, const char* info );
|
||||
|
||||
class void_ptr
|
||||
{
|
||||
private:
|
||||
void *ptr;
|
||||
public:
|
||||
void_ptr() = delete;
|
||||
void_ptr( void *p ) : ptr( p ) {}
|
||||
template<typename T>
|
||||
operator T*() const {
|
||||
return static_cast<T*>( ptr );
|
||||
}
|
||||
};
|
||||
|
||||
void_ptr safe_malloc( size_t size );
|
||||
void_ptr safe_malloc_info( size_t size, const char* info );
|
||||
void_ptr safe_calloc( size_t size );
|
||||
void_ptr safe_calloc_info( size_t size, const char* info );
|
||||
#else
|
||||
#define safe_malloc( size ) malloc( size )
|
||||
#define safe_malloc_info( size, info ) malloc( size )
|
||||
|
|
@ -90,9 +104,10 @@ static inline char *strLower( char *string ){
|
|||
}
|
||||
static inline char *copystring( const char *src ){ // version of strdup() with safe_malloc()
|
||||
const size_t size = strlen( src ) + 1;
|
||||
return memcpy( safe_malloc( size ), src, size );
|
||||
return void_ptr( memcpy( safe_malloc( size ), src, size ) );
|
||||
}
|
||||
char* strIstr( const char* haystack, const char* needle );
|
||||
const char* strIstr( const char* haystack, const char* needle );
|
||||
char* strIstr( char* haystack, const char* needle );
|
||||
#ifdef WIN32
|
||||
#define Q_stricmp stricmp
|
||||
#define Q_strnicmp strnicmp
|
||||
|
|
@ -174,10 +189,14 @@ static inline bool path_separator( const char c ){
|
|||
return c == '/' || c == '\\';
|
||||
}
|
||||
bool path_is_absolute( const char* path );
|
||||
char* path_get_last_separator( const char* path );
|
||||
char* path_get_filename_start( const char* path );
|
||||
char* path_get_filename_base_end( const char* path );
|
||||
char* path_get_extension( const char* path );
|
||||
const char* path_get_last_separator( const char* path );
|
||||
char* path_get_last_separator( char* path );
|
||||
const char* path_get_filename_start( const char* path );
|
||||
char* path_get_filename_start( char* path );
|
||||
const char* path_get_filename_base_end( const char* path );
|
||||
char* path_get_filename_base_end( char* path );
|
||||
const char* path_get_extension( const char* path );
|
||||
char* path_get_extension( char* path );
|
||||
void path_add_slash( char *path );
|
||||
void path_set_extension( char *path, const char *extension );
|
||||
void DefaultExtension( char *path, const char *extension );
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ void xml_SendNode( xmlNodePtr node ){
|
|||
}
|
||||
}
|
||||
|
||||
void xml_Select( char *msg, int entitynum, int brushnum, bool bError ){
|
||||
void xml_Select( const char *msg, int entitynum, int brushnum, bool bError ){
|
||||
xmlNodePtr node, select;
|
||||
char buf[1024];
|
||||
char level[2];
|
||||
|
|
@ -168,7 +168,7 @@ void xml_Select( char *msg, int entitynum, int brushnum, bool bError ){
|
|||
}
|
||||
}
|
||||
|
||||
void xml_Point( char *msg, vec3_t pt ){
|
||||
void xml_Point( const char *msg, vec3_t pt ){
|
||||
xmlNodePtr node, point;
|
||||
char buf[1024];
|
||||
char level[2];
|
||||
|
|
@ -190,7 +190,7 @@ void xml_Point( char *msg, vec3_t pt ){
|
|||
}
|
||||
|
||||
#define WINDING_BUFSIZE 2048
|
||||
void xml_Winding( char *msg, vec3_t p[], int numpoints, bool die ){
|
||||
void xml_Winding( const char *msg, vec3_t p[], int numpoints, bool die ){
|
||||
xmlNodePtr node, winding;
|
||||
char buf[WINDING_BUFSIZE];
|
||||
char smlbuf[128];
|
||||
|
|
@ -201,7 +201,7 @@ void xml_Winding( char *msg, vec3_t p[], int numpoints, bool die ){
|
|||
xmlNodeAddContent( node, (const xmlChar*)msg );
|
||||
level[0] = (int)'0' + SYS_ERR;
|
||||
level[1] = 0;
|
||||
xmlSetProp( node, (xmlChar*)"level", (const xmlChar *)level );
|
||||
xmlSetProp( node, (const xmlChar*)"level", (const xmlChar *)level );
|
||||
// a 'winding' node
|
||||
sprintf( buf, "%i ", numpoints );
|
||||
for ( i = 0; i < numpoints; i++ )
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ xmlNodePtr xml_NodeForVec( vec3_t v );
|
|||
void xml_SendNode( xmlNodePtr node );
|
||||
// print a message in q3map output and send the corresponding select information down the xml stream
|
||||
// bError: do we end with an error on this one or do we go ahead?
|
||||
void xml_Select( char *msg, int entitynum, int brushnum, bool bError );
|
||||
void xml_Select( const char *msg, int entitynum, int brushnum, bool bError );
|
||||
// end q3map with an error message and send a point information in the xml stream
|
||||
// note: we might want to add a boolean to use this as a warning or an error thing..
|
||||
void xml_Winding( char *msg, vec3_t p[], int numpoints, bool die );
|
||||
void xml_Point( char *msg, vec3_t pt );
|
||||
void xml_Winding( const char *msg, vec3_t p[], int numpoints, bool die );
|
||||
void xml_Point( const char *msg, vec3_t pt );
|
||||
|
||||
void Broadcast_Setup( const char *dest );
|
||||
void Broadcast_Shutdown();
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@
|
|||
#include <jpeglib.h>
|
||||
#include <jerror.h>
|
||||
|
||||
#include "cmdlib.h"
|
||||
|
||||
/* Expanded data source object for stdio input */
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -358,7 +360,7 @@ int LoadJPGBuff( void *src_buffer, int src_size, unsigned char **pic, int *width
|
|||
size = cinfo.output_width * cinfo.output_height * 4;
|
||||
*width = cinfo.output_width;
|
||||
*height = cinfo.output_height;
|
||||
*pic = calloc( 1, size + 1 );
|
||||
*pic = safe_calloc( size + 1 );
|
||||
|
||||
buffer = ( *cinfo.mem->alloc_sarray )( ( j_common_ptr ) & cinfo, JPOOL_IMAGE, row_stride, 1 );
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ mutex_t *MutexAlloc( void ){
|
|||
}
|
||||
crit = (CRITICAL_SECTION *) safe_malloc( sizeof( CRITICAL_SECTION ) );
|
||||
InitializeCriticalSection( crit );
|
||||
return (void *) crit;
|
||||
return reinterpret_cast<mutex_t *>( crit );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ winding_t *CopyWinding( const winding_t *w ){
|
|||
if ( !w ) {
|
||||
Error( "CopyWinding: winding is NULL" );
|
||||
}
|
||||
return memcpy( AllocWinding( w->numpoints ), w, offsetof( winding_t, p[w->numpoints] ) );
|
||||
return void_ptr( memcpy( AllocWinding( w->numpoints ), w, offsetof( winding_t, p[w->numpoints] ) ) );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -426,7 +426,7 @@ winding_accu_t *CopyWindingAccuIncreaseSizeAndFreeOld( winding_accu_t *w ){
|
|||
Error( "CopyWindingAccuIncreaseSizeAndFreeOld: winding is NULL" );
|
||||
}
|
||||
|
||||
winding_accu_t *c = memcpy( AllocWindingAccu( w->numpoints + 1 ), w, offsetof( winding_accu_t, p[w->numpoints] ) );
|
||||
winding_accu_t *c = void_ptr( memcpy( AllocWindingAccu( w->numpoints + 1 ), w, offsetof( winding_accu_t, p[w->numpoints] ) ) );
|
||||
FreeWindingAccu( w );
|
||||
return c;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ void AddScriptToStack( const char *filename, int index ){
|
|||
Sys_Printf( "entering %s\n", script->filename );
|
||||
}
|
||||
|
||||
script->buffer = buffer;
|
||||
script->buffer = void_ptr( buffer );
|
||||
script->line = 1;
|
||||
script->script_p = script->buffer;
|
||||
script->end_p = script->buffer + size;
|
||||
|
|
@ -356,7 +356,7 @@ bool TokenAvailable( void ) {
|
|||
//=====================================================================
|
||||
|
||||
|
||||
void MatchToken( char *match ) {
|
||||
void MatchToken( const char *match ) {
|
||||
GetToken( true );
|
||||
|
||||
if ( !strEqual( token, match ) ) {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ bool GetToken( bool crossline );
|
|||
void UnGetToken( void );
|
||||
bool TokenAvailable( void );
|
||||
|
||||
void MatchToken( char *match );
|
||||
void MatchToken( const char *match );
|
||||
|
||||
void Parse1DMatrix( int x, vec_t *m );
|
||||
void Parse2DMatrix( int y, int x, vec_t *m );
|
||||
|
|
|
|||
|
|
@ -575,7 +575,7 @@ void RunThreadsOn( int workcnt, bool showpacifier, void ( *func )( int ) ){
|
|||
for ( i = 0 ; i < numthreads ; i++ )
|
||||
{
|
||||
/* Default pthread attributes: joinable & non-realtime scheduling */
|
||||
if ( pthread_create( &work_threads[i], &attr, (void*)func, (void*)(size_t)i ) != 0 ) {
|
||||
if ( pthread_create( &work_threads[i], &attr, (void *(*)(void *)) func, (void*)(size_t)i ) != 0 ) {
|
||||
Error( "pthread_create failed" );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ void TRI_LoadPolysets( const char *filename, polyset_t **ppPSET, int *numpsets )
|
|||
Error( "%s is not a Alias object separated triangle file, magic number is wrong.", filename );
|
||||
}
|
||||
|
||||
pPSET = calloc( 1, POLYSET_MAXPOLYSETS * sizeof( polyset_t ) );
|
||||
ptri = calloc( 1, POLYSET_MAXTRIANGLES * sizeof( triangle_t ) );
|
||||
pPSET = safe_calloc( POLYSET_MAXPOLYSETS * sizeof( polyset_t ) );
|
||||
ptri = safe_calloc( POLYSET_MAXTRIANGLES * sizeof( triangle_t ) );
|
||||
|
||||
*ppPSET = pPSET;
|
||||
|
||||
|
|
|
|||
|
|
@ -2919,7 +2919,7 @@ int inflate_blocks(inflate_blocks_statef *s, z_streamp z, int r)
|
|||
case 3: /* illegal */
|
||||
DUMPBITS(3)
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"invalid block type";
|
||||
z->msg = "invalid block type";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
|
|
@ -2929,7 +2929,7 @@ int inflate_blocks(inflate_blocks_statef *s, z_streamp z, int r)
|
|||
if ((((~b) >> 16) & 0xffff) != (b & 0xffff))
|
||||
{
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"invalid stored block lengths";
|
||||
z->msg = "invalid stored block lengths";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
|
|
@ -2962,7 +2962,7 @@ int inflate_blocks(inflate_blocks_statef *s, z_streamp z, int r)
|
|||
if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
|
||||
{
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"too many length or distance symbols";
|
||||
z->msg = "too many length or distance symbols";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
|
|
@ -3032,7 +3032,7 @@ int inflate_blocks(inflate_blocks_statef *s, z_streamp z, int r)
|
|||
{
|
||||
ZFREE(z, s->sub.trees.blens);
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"invalid bit length repeat";
|
||||
z->msg = "invalid bit length repeat";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
|
|
@ -3320,16 +3320,16 @@ static int huft_build(uInt *b, uInt n, uInt s, const uInt *d, const uInt *e, inf
|
|||
uInt f; /* i repeats in table every f entries */
|
||||
int g; /* maximum code length */
|
||||
int h; /* table level */
|
||||
register uInt i; /* counter, current code */
|
||||
register uInt j; /* counter */
|
||||
register int k; /* number of bits in current code */
|
||||
uInt i; /* counter, current code */
|
||||
uInt j; /* counter */
|
||||
int k; /* number of bits in current code */
|
||||
int l; /* bits per table (returned in m) */
|
||||
uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */
|
||||
register uInt *p; /* pointer into c[], b[], or v[] */
|
||||
uInt *p; /* pointer into c[], b[], or v[] */
|
||||
inflate_huft *q; /* points to current table */
|
||||
struct inflate_huft_s r; /* table entry for structure assignment */
|
||||
inflate_huft *u[BMAX]; /* table stack */
|
||||
register int w; /* bits before this table == (l * h) */
|
||||
int w; /* bits before this table == (l * h) */
|
||||
uInt x[BMAX+1]; /* bit offsets, then code stack */
|
||||
uInt *xp; /* pointer into x */
|
||||
int y; /* number of dummy codes added */
|
||||
|
|
@ -3515,10 +3515,10 @@ int inflate_trees_bits(uInt *c, uInt *bb, inflate_huft * *tb, inflate_huft *hp,
|
|||
r = huft_build(c, 19, 19, (uInt*)Z_NULL, (uInt*)Z_NULL,
|
||||
tb, bb, hp, &hn, v);
|
||||
if (r == Z_DATA_ERROR)
|
||||
z->msg = (char*)"oversubscribed dynamic bit lengths tree";
|
||||
z->msg = "oversubscribed dynamic bit lengths tree";
|
||||
else if (r == Z_BUF_ERROR || *bb == 0)
|
||||
{
|
||||
z->msg = (char*)"incomplete dynamic bit lengths tree";
|
||||
z->msg = "incomplete dynamic bit lengths tree";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
ZFREE(z, v);
|
||||
|
|
@ -3551,10 +3551,10 @@ int inflate_trees_dynamic(uInt nl, uInt nd, uInt *c, uInt *bl, uInt *bd, inflate
|
|||
if (r != Z_OK || *bl == 0)
|
||||
{
|
||||
if (r == Z_DATA_ERROR)
|
||||
z->msg = (char*)"oversubscribed literal/length tree";
|
||||
z->msg = "oversubscribed literal/length tree";
|
||||
else if (r != Z_MEM_ERROR)
|
||||
{
|
||||
z->msg = (char*)"incomplete literal/length tree";
|
||||
z->msg = "incomplete literal/length tree";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
ZFREE(z, v);
|
||||
|
|
@ -3566,18 +3566,18 @@ int inflate_trees_dynamic(uInt nl, uInt nd, uInt *c, uInt *bl, uInt *bd, inflate
|
|||
if (r != Z_OK || (*bd == 0 && nl > 257))
|
||||
{
|
||||
if (r == Z_DATA_ERROR)
|
||||
z->msg = (char*)"oversubscribed distance tree";
|
||||
z->msg = "oversubscribed distance tree";
|
||||
else if (r == Z_BUF_ERROR) {
|
||||
#ifdef PKZIP_BUG_WORKAROUND
|
||||
r = Z_OK;
|
||||
}
|
||||
#else
|
||||
z->msg = (char*)"incomplete distance tree";
|
||||
z->msg = "incomplete distance tree";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
else if (r != Z_MEM_ERROR)
|
||||
{
|
||||
z->msg = (char*)"empty distance tree with lengths";
|
||||
z->msg = "empty distance tree with lengths";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
ZFREE(z, v);
|
||||
|
|
@ -3867,7 +3867,7 @@ int inflate_fast(uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, inflate_b
|
|||
}
|
||||
else
|
||||
{
|
||||
z->msg = (char*)"invalid distance code";
|
||||
z->msg = "invalid distance code";
|
||||
UNGRAB
|
||||
UPDATE
|
||||
return Z_DATA_ERROR;
|
||||
|
|
@ -3898,7 +3898,7 @@ int inflate_fast(uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, inflate_b
|
|||
}
|
||||
else
|
||||
{
|
||||
z->msg = (char*)"invalid literal/length code";
|
||||
z->msg = "invalid literal/length code";
|
||||
UNGRAB
|
||||
UPDATE
|
||||
return Z_DATA_ERROR;
|
||||
|
|
@ -4055,7 +4055,7 @@ int inflate_codes(inflate_blocks_statef *s, z_streamp z, int r)
|
|||
break;
|
||||
}
|
||||
c->mode = BADCODE; /* invalid code */
|
||||
z->msg = (char*)"invalid literal/length code";
|
||||
z->msg = "invalid literal/length code";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
case LENEXT: /* i: getting length extra (have base) */
|
||||
|
|
@ -4087,7 +4087,7 @@ int inflate_codes(inflate_blocks_statef *s, z_streamp z, int r)
|
|||
break;
|
||||
}
|
||||
c->mode = BADCODE; /* invalid code */
|
||||
z->msg = (char*)"invalid distance code";
|
||||
z->msg = "invalid distance code";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
case DISTEXT: /* i: getting distance extra */
|
||||
|
|
@ -4396,14 +4396,14 @@ int inflate(z_streamp z, int f)
|
|||
if (((z->state->sub.method = iNEXTBYTE) & 0xf) != Z_DEFLATED)
|
||||
{
|
||||
z->state->mode = imBAD;
|
||||
z->msg = (char*)"unknown compression method";
|
||||
z->msg = "unknown compression method";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
if ((z->state->sub.method >> 4) + 8 > z->state->wbits)
|
||||
{
|
||||
z->state->mode = imBAD;
|
||||
z->msg = (char*)"invalid window size";
|
||||
z->msg = "invalid window size";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
|
|
@ -4414,7 +4414,7 @@ int inflate(z_streamp z, int f)
|
|||
if (((z->state->sub.method << 8) + b) % 31)
|
||||
{
|
||||
z->state->mode = imBAD;
|
||||
z->msg = (char*)"incorrect header check";
|
||||
z->msg = "incorrect header check";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
|
|
@ -4445,7 +4445,7 @@ int inflate(z_streamp z, int f)
|
|||
return Z_NEED_DICT;
|
||||
case imDICT0:
|
||||
z->state->mode = imBAD;
|
||||
z->msg = (char*)"need dictionary";
|
||||
z->msg = "need dictionary";
|
||||
z->state->sub.marker = 0; /* can try inflateSync */
|
||||
return Z_STREAM_ERROR;
|
||||
case imBLOCKS:
|
||||
|
|
@ -4487,7 +4487,7 @@ int inflate(z_streamp z, int f)
|
|||
if (z->state->sub.check.was != z->state->sub.check.need)
|
||||
{
|
||||
z->state->mode = imBAD;
|
||||
z->msg = (char*)"incorrect data check";
|
||||
z->msg = "incorrect data check";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ typedef struct z_stream_s {
|
|||
unsigned int avail_out; /* remaining free space at next_out */
|
||||
unsigned long total_out; /* total nb of unsigned chars output so */
|
||||
|
||||
char *msg; /* last error message, NULL if no error */
|
||||
const char *msg; /* last error message, NULL if no error */
|
||||
struct internal_state *state; /* not visible by applications */
|
||||
|
||||
alloc_func zalloc; /* used to allocate the internal state */
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ static void LoadMeshMaterialGroup( FILE *fp, long thisChunkLen, _3DSMeshMaterial
|
|||
ReadString( fp, mmg.name );
|
||||
|
||||
fread( &mmg.numFaces, sizeof( mmg.numFaces ), 1, fp );
|
||||
mmg.pFaces = malloc( sizeof( mmg.pFaces[0] ) * mmg.numFaces );
|
||||
mmg.pFaces = safe_malloc( sizeof( mmg.pFaces[0] ) * mmg.numFaces );
|
||||
fread( mmg.pFaces, sizeof( mmg.pFaces[0] ), mmg.numFaces, fp );
|
||||
|
||||
if ( s_verbose ) {
|
||||
|
|
@ -256,7 +256,7 @@ static void LoadNamedTriObject( FILE *fp, long thisChunkLen, _3DSTriObject_t *pT
|
|||
fread( &triObj.numFaces, sizeof( triObj.numFaces ), 1, fp );
|
||||
assert( triObj.pFaces == 0 );
|
||||
|
||||
triObj.pFaces = malloc( sizeof( triObj.pFaces[0] ) * triObj.numFaces );
|
||||
triObj.pFaces = safe_malloc( sizeof( triObj.pFaces[0] ) * triObj.numFaces );
|
||||
fread( triObj.pFaces, sizeof( triObj.pFaces[0] ), triObj.numFaces, fp );
|
||||
bytesRead += sizeof( triObj.numFaces ) + triObj.numFaces * sizeof( triObj.pFaces[0] ) + 6;
|
||||
|
||||
|
|
@ -271,7 +271,7 @@ static void LoadNamedTriObject( FILE *fp, long thisChunkLen, _3DSTriObject_t *pT
|
|||
break;
|
||||
case _3DS_CHUNK_POINT_ARRAY:
|
||||
fread( &triObj.numPoints, sizeof( triObj.numPoints ), 1, fp );
|
||||
triObj.pPoints = malloc( sizeof( triObj.pPoints[0] ) * triObj.numPoints );
|
||||
triObj.pPoints = safe_malloc( sizeof( triObj.pPoints[0] ) * triObj.numPoints );
|
||||
fread( triObj.pPoints, sizeof( triObj.pPoints[0] ), triObj.numPoints, fp );
|
||||
bytesRead += sizeof( triObj.numPoints ) + triObj.numPoints * sizeof( triObj.pPoints[0] ) + 6;
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ static void LoadNamedTriObject( FILE *fp, long thisChunkLen, _3DSTriObject_t *pT
|
|||
break;
|
||||
case _3DS_CHUNK_TEX_VERTS:
|
||||
fread( &triObj.numTexVerts, sizeof( triObj.numTexVerts ), 1, fp );
|
||||
triObj.pTexVerts = malloc( sizeof( triObj.pTexVerts[0] ) * triObj.numTexVerts );
|
||||
triObj.pTexVerts = safe_malloc( sizeof( triObj.pTexVerts[0] ) * triObj.numTexVerts );
|
||||
fread( triObj.pTexVerts, sizeof( triObj.pTexVerts[0] ), triObj.numTexVerts, fp );
|
||||
bytesRead += sizeof( triObj.numTexVerts ) + sizeof( triObj.pTexVerts[0] ) * triObj.numTexVerts + 6;
|
||||
|
||||
|
|
@ -335,7 +335,7 @@ static void LoadNamedTriObject( FILE *fp, long thisChunkLen, _3DSTriObject_t *pT
|
|||
assert( pTO->numFaces == meshMaterialGroups[0].numFaces );
|
||||
}
|
||||
|
||||
pTO->pMeshMaterialGroups = malloc( sizeof( _3DSMeshMaterialGroup_t ) * numMeshMaterialGroups );
|
||||
pTO->pMeshMaterialGroups = safe_malloc( sizeof( _3DSMeshMaterialGroup_t ) * numMeshMaterialGroups );
|
||||
memcpy( pTO->pMeshMaterialGroups, meshMaterialGroups, numMeshMaterialGroups * sizeof( meshMaterialGroups[0] ) );
|
||||
pTO->numMeshMaterialGroups = numMeshMaterialGroups;
|
||||
|
||||
|
|
@ -382,7 +382,7 @@ static void LoadNamedObject( FILE *fp, long thisChunkLen, _3DSNamedObject_t *pNO
|
|||
}
|
||||
|
||||
strcpy( pNO->name, name );
|
||||
pNO->pTriObjects = malloc( sizeof( _3DSTriObject_t ) * numTriObjects );
|
||||
pNO->pTriObjects = safe_malloc( sizeof( _3DSTriObject_t ) * numTriObjects );
|
||||
memcpy( pNO->pTriObjects, triObj, sizeof( triObj[0] ) * numTriObjects );
|
||||
pNO->numTriObjects = numTriObjects;
|
||||
|
||||
|
|
@ -441,8 +441,8 @@ static void LoadEditChunk( FILE *fp, long thisChunkLen, _3DSEditChunk_t *pEC ){
|
|||
|
||||
pEC->numNamedObjects = numNamedObjects;
|
||||
|
||||
pEC->pMaterials = malloc( sizeof( _3DSMaterial_t ) * numMaterials );
|
||||
pEC->pNamedObjects = malloc( sizeof( _3DSNamedObject_t ) * numNamedObjects );
|
||||
pEC->pMaterials = safe_malloc( sizeof( _3DSMaterial_t ) * numMaterials );
|
||||
pEC->pNamedObjects = safe_malloc( sizeof( _3DSNamedObject_t ) * numNamedObjects );
|
||||
|
||||
memcpy( pEC->pMaterials, mat, numMaterials * sizeof( mat[0] ) );
|
||||
memcpy( pEC->pNamedObjects, namedObjects, numNamedObjects * sizeof( namedObjects[0] ) );
|
||||
|
|
@ -570,8 +570,8 @@ void _3DS_LoadPolysets( const char *filename, polyset_t **ppPSET, int *numpsets,
|
|||
numPolysets = _3ds.editChunk.numNamedObjects;
|
||||
|
||||
// allocate memory
|
||||
pPSET = calloc( 1, numPolysets * sizeof( polyset_t ) );
|
||||
triangles = ptri = calloc( 1, POLYSET_MAXTRIANGLES * sizeof( triangle_t ) );
|
||||
pPSET = safe_calloc( numPolysets * sizeof( polyset_t ) );
|
||||
triangles = ptri = safe_calloc( POLYSET_MAXTRIANGLES * sizeof( triangle_t ) );
|
||||
|
||||
// copy the data over
|
||||
for ( i = 0; i < numPolysets; i++ )
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ void Cmd_Grab( void ){
|
|||
}
|
||||
|
||||
// crop it to the proper size
|
||||
cropped = malloc( w * h );
|
||||
cropped = safe_malloc( w * h );
|
||||
for ( y = 0 ; y < h ; y++ )
|
||||
{
|
||||
memcpy( cropped + y * w, byteimage + ( y + yl ) * byteimagewidth + xl, w );
|
||||
|
|
@ -129,7 +129,7 @@ void Cmd_Raw( void ){
|
|||
}
|
||||
|
||||
// crop it to the proper size
|
||||
cropped = malloc( w * h );
|
||||
cropped = safe_malloc( w * h );
|
||||
for ( y = 0 ; y < h ; y++ )
|
||||
{
|
||||
memcpy( cropped + y * w, byteimage + ( y + yl ) * byteimagewidth + xl, w );
|
||||
|
|
@ -235,7 +235,7 @@ void Cmd_Colormap( void ){
|
|||
levels = 64;
|
||||
brights = 1; // ignore 255 (transparent)
|
||||
|
||||
cropped = malloc( ( levels + 256 ) * 256 );
|
||||
cropped = safe_malloc( ( levels + 256 ) * 256 );
|
||||
lump_p = cropped;
|
||||
|
||||
// shaded levels
|
||||
|
|
@ -430,7 +430,7 @@ byte AveragePixels( int count ){
|
|||
*/
|
||||
|
||||
// 3dstudio environment map suffixes
|
||||
char *suf[6] = {"rt", "ft", "lf", "bk", "up", "dn"};
|
||||
const char *suf[6] = {"rt", "ft", "lf", "bk", "up", "dn"};
|
||||
|
||||
/*
|
||||
=================
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ void MD3_Dump( const char *filename ){
|
|||
}
|
||||
|
||||
fileSize = Q_filelength( fp );
|
||||
_buffer = malloc( fileSize );
|
||||
_buffer = safe_malloc( fileSize );
|
||||
fread( _buffer, fileSize, 1, fp );
|
||||
fclose( fp );
|
||||
|
||||
|
|
|
|||
|
|
@ -832,7 +832,7 @@ void Cmd_SpriteBase( void ){
|
|||
|
||||
printf( "---------------------\n" );
|
||||
|
||||
g_data.surfData[0].verts[0] = ( float * ) calloc( 1, sizeof( float ) * 6 * 4 );
|
||||
g_data.surfData[0].verts[0] = safe_calloc( sizeof( float ) * 6 * 4 );
|
||||
|
||||
g_data.surfData[0].header.numVerts = 4;
|
||||
|
||||
|
|
@ -1087,7 +1087,7 @@ void GrabFrame( const char *frame ){
|
|||
if ( g_data.surfData[i].verts[g_data.model.numFrames] ) {
|
||||
free( g_data.surfData[i].verts[g_data.model.numFrames] );
|
||||
}
|
||||
frameXyz = g_data.surfData[i].verts[g_data.model.numFrames] = calloc( 1, sizeof( float ) * 6 * g_data.surfData[i].header.numVerts );
|
||||
frameXyz = g_data.surfData[i].verts[g_data.model.numFrames] = safe_calloc( sizeof( float ) * 6 * g_data.surfData[i].header.numVerts );
|
||||
frameNormals = frameXyz + 3;
|
||||
|
||||
for ( t = 0; t < psets[i].numtriangles; t++ )
|
||||
|
|
@ -1773,7 +1773,7 @@ static void BuildAnimationFromOAFs( const char *filename, ObjectAnimationFrame_t
|
|||
if ( g_data.surfData[i].verts[f] ) {
|
||||
free( g_data.surfData[i].verts[f] );
|
||||
}
|
||||
frameXyz = g_data.surfData[i].verts[f] = calloc( 1, sizeof( float ) * 6 * g_data.surfData[i].header.numVerts );
|
||||
frameXyz = g_data.surfData[i].verts[f] = safe_calloc( sizeof( float ) * 6 * g_data.surfData[i].header.numVerts );
|
||||
frameNormals = frameXyz + 3;
|
||||
|
||||
for ( t = 0; t < pOAF->surfaces[i]->numtriangles; t++ )
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ int P3DLoad( const char *filename ){
|
|||
|
||||
p3d.len = Q_filelength( fp );
|
||||
|
||||
p3d.curpos = p3d.buffer = malloc( p3d.len );
|
||||
p3d.curpos = p3d.buffer = safe_malloc( p3d.len );
|
||||
|
||||
if ( fread( p3d.buffer, p3d.len, 1, fp ) != 1 ) {
|
||||
fclose( fp );
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ polyset_t *Polyset_SplitSets( polyset_t *psets, int numpolysets, int *pNumNewPol
|
|||
|
||||
printf( "Warning: creating %d polysets from input of %d polysets\n", numNewPolysets, numpolysets );
|
||||
|
||||
newpsets = calloc( sizeof( polyset_t ) * numNewPolysets, 1 );
|
||||
newpsets = safe_calloc( sizeof( polyset_t ) * numNewPolysets );
|
||||
|
||||
for ( np = 0, op = 0; op < numpolysets; op++ )
|
||||
{
|
||||
|
|
@ -129,9 +129,9 @@ polyset_t *Polyset_CollapseSets( polyset_t *psets, int numpolysets ){
|
|||
sumtriangles += oldpsets[p].numtriangles;
|
||||
}
|
||||
|
||||
psets = calloc( 1, sizeof( polyset_t ) );
|
||||
psets = safe_calloc( sizeof( polyset_t ) );
|
||||
psets[0].numtriangles = sumtriangles;
|
||||
psets[0].triangles = malloc( MD3_MAX_TRIANGLES * sizeof( triangle_t ) );
|
||||
psets[0].triangles = safe_malloc( MD3_MAX_TRIANGLES * sizeof( triangle_t ) );
|
||||
|
||||
// each call to "LoadPolysets" only allocates a single large chunk of
|
||||
// triangle memory that is utilized by all the polysets loaded by
|
||||
|
|
|
|||
|
|
@ -106,14 +106,14 @@ void FindShaderFiles( char *filename ){
|
|||
char linebuffer[1024];
|
||||
int len, i;
|
||||
char *buf;
|
||||
char *diffuseExtensions[] =
|
||||
const char *diffuseExtensions[] =
|
||||
{
|
||||
".TGA",
|
||||
".WAL",
|
||||
".PCX",
|
||||
0
|
||||
};
|
||||
char *otherExtensions[] =
|
||||
const char *otherExtensions[] =
|
||||
{
|
||||
".specular.TGA",
|
||||
".blend.TGA",
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ int GetLittleLong( void ){
|
|||
return val;
|
||||
}
|
||||
|
||||
void FindNextChunk( char *name ){
|
||||
void FindNextChunk( const char *name ){
|
||||
while ( 1 )
|
||||
{
|
||||
data_p = last_chunk;
|
||||
|
|
@ -112,7 +112,7 @@ void FindNextChunk( char *name ){
|
|||
}
|
||||
}
|
||||
|
||||
void FindChunk( char *name ){
|
||||
void FindChunk( const char *name ){
|
||||
last_chunk = iff_data;
|
||||
FindNextChunk( name );
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ void DumpChunks( void ){
|
|||
memcpy( str, data_p, 4 );
|
||||
data_p += 4;
|
||||
iff_chunk_len = GetLittleLong();
|
||||
printf( "0x%x : %s (%d)\n", (int)( data_p - 4 ), str, iff_chunk_len );
|
||||
printf( "0x%p : %s (%d)\n", data_p - 4, str, iff_chunk_len );
|
||||
data_p += ( iff_chunk_len + 1 ) & ~1;
|
||||
} while ( data_p < iff_end );
|
||||
}
|
||||
|
|
@ -248,7 +248,7 @@ void LoadSoundtrack( void ){
|
|||
return;
|
||||
}
|
||||
len = Q_filelength( f );
|
||||
s_soundtrack = malloc( len );
|
||||
s_soundtrack = safe_malloc( len );
|
||||
fread( s_soundtrack, 1, len, f );
|
||||
fclose( f );
|
||||
|
||||
|
|
@ -945,8 +945,8 @@ void Cmd_Video( void ){
|
|||
GetToken( false );
|
||||
s_resample_height = atoi( token );
|
||||
|
||||
resampled = malloc( sizeof( unsigned char ) * 4 * s_resample_width * s_resample_height );
|
||||
compressed = malloc( sizeof( long ) * 2 * ( s_resample_width / 4 ) * ( s_resample_height / 4 ) );
|
||||
resampled = safe_malloc( sizeof( unsigned char ) * 4 * s_resample_width * s_resample_height );
|
||||
compressed = safe_malloc( sizeof( long ) * 2 * ( s_resample_width / 4 ) * ( s_resample_height / 4 ) );
|
||||
|
||||
printf( "Resample width: %d\n", s_resample_width );
|
||||
printf( "Resample height: %d\n", s_resample_height );
|
||||
|
|
@ -1064,7 +1064,7 @@ void Cmd_Video( void ){
|
|||
unsigned char *uncompressed;
|
||||
char buffer[1000];
|
||||
|
||||
uncompressed = malloc( sizeof( unsigned char ) * 4 * s_resample_width * s_resample_height );
|
||||
uncompressed = safe_malloc( sizeof( unsigned char ) * 4 * s_resample_width * s_resample_height );
|
||||
BTCDecompressFrame( compressed, uncompressed );
|
||||
|
||||
for ( y = 0; y < s_resample_height / 2; y++ )
|
||||
|
|
|
|||
|
|
@ -41,9 +41,8 @@ StrList;
|
|||
|
||||
static inline StrList* StrList_allocate( size_t strNum ){
|
||||
StrList* ret = safe_calloc( offsetof( StrList, s[strNum] ) );
|
||||
memcpy( ret,
|
||||
&( StrList const ){ .n = 0, .max = strNum },
|
||||
sizeof( StrList ) );
|
||||
ret->n = 0;
|
||||
ret->max = strNum;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -196,9 +195,8 @@ StrBuf;
|
|||
|
||||
static inline StrBuf* StrBuf_allocate( size_t strLen ){
|
||||
StrBuf* ret = safe_calloc( offsetof( StrBuf, s[strLen] ) );
|
||||
memcpy( ret,
|
||||
&( StrBuf const ){ .strlen = 0, .max = strLen },
|
||||
sizeof( StrBuf ) );
|
||||
ret->strlen = 0;
|
||||
ret->max = strLen;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -611,7 +611,7 @@ vec_t BrushVolume( brush_t *brush ){
|
|||
writes a map with the split bsp brushes
|
||||
*/
|
||||
|
||||
void WriteBSPBrushMap( char *name, brush_t *list ){
|
||||
void WriteBSPBrushMap( const char *name, brush_t *list ){
|
||||
FILE *f;
|
||||
side_t *s;
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ void ProcessWorldModel( void ){
|
|||
xmlAddChild( leaknode, polyline );
|
||||
level[0] = (int) '0' + SYS_ERR;
|
||||
level[1] = 0;
|
||||
xmlSetProp( leaknode, (xmlChar*)"level", (const xmlChar*)level );
|
||||
xmlSetProp( leaknode, (const xmlChar*)"level", (const xmlChar*)level );
|
||||
xml_SendNode( leaknode );
|
||||
if ( leaktest ) {
|
||||
Sys_FPrintf( SYS_WRN, "--- MAP LEAKED, ABORTING LEAKTEST ---\n" );
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ void IncDrawVerts(){
|
|||
numBSPDrawVertsBuffer *= 3; // multiply by 1.5
|
||||
numBSPDrawVertsBuffer /= 2;
|
||||
|
||||
newBspDrawVerts = realloc( bspDrawVerts, sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer );
|
||||
newBspDrawVerts = void_ptr( realloc( bspDrawVerts, sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer ) );
|
||||
|
||||
if ( !newBspDrawVerts ) {
|
||||
free (bspDrawVerts);
|
||||
|
|
@ -276,7 +276,7 @@ int GetLumpElements( bspHeader_t *header, int lump, int size ){
|
|||
returns a pointer to the specified lump
|
||||
*/
|
||||
|
||||
void *GetLump( bspHeader_t *header, int lump ){
|
||||
void_ptr GetLump( bspHeader_t *header, int lump ){
|
||||
return (void*)( (byte*) header + header->lumps[ lump ].offset );
|
||||
}
|
||||
|
||||
|
|
@ -871,7 +871,7 @@ void GetVectorForKey( const entity_t *ent, const char *key, vec3_t vec ){
|
|||
}
|
||||
}
|
||||
|
||||
bool entity_read_bool( bool *bool_value, const entity_t *entity, ... ){
|
||||
bool entity_read_keyvalue( bool *bool_value, const entity_t *entity, ... ){
|
||||
va_list argptr;
|
||||
va_start( argptr, entity );
|
||||
const char* key;
|
||||
|
|
@ -886,7 +886,7 @@ bool entity_read_bool( bool *bool_value, const entity_t *entity, ... ){
|
|||
va_end( argptr );
|
||||
return false;
|
||||
}
|
||||
bool entity_read_int( int *int_value, const entity_t *entity, ... ){
|
||||
bool entity_read_keyvalue( int *int_value, const entity_t *entity, ... ){
|
||||
va_list argptr;
|
||||
va_start( argptr, entity );
|
||||
const char* key;
|
||||
|
|
@ -901,7 +901,7 @@ bool entity_read_int( int *int_value, const entity_t *entity, ... ){
|
|||
va_end( argptr );
|
||||
return false;
|
||||
}
|
||||
bool entity_read_float( float *float_value, const entity_t *entity, ... ){
|
||||
bool entity_read_keyvalue( float *float_value, const entity_t *entity, ... ){
|
||||
va_list argptr;
|
||||
va_start( argptr, entity );
|
||||
const char* key;
|
||||
|
|
@ -916,7 +916,7 @@ bool entity_read_float( float *float_value, const entity_t *entity, ... ){
|
|||
va_end( argptr );
|
||||
return false;
|
||||
}
|
||||
bool entity_read_vector3( float (*vector3_value)[3], const entity_t *entity, ... ){
|
||||
bool entity_read_keyvalue( float (*vector3_value)[3], const entity_t *entity, ... ){
|
||||
va_list argptr;
|
||||
va_start( argptr, entity );
|
||||
const char* key;
|
||||
|
|
@ -936,7 +936,7 @@ bool entity_read_vector3( float (*vector3_value)[3], const entity_t *entity, ...
|
|||
va_end( argptr );
|
||||
return false;
|
||||
}
|
||||
bool entity_read_string( char (*string_value)[], const entity_t *entity, ... ){
|
||||
bool entity_read_keyvalue( char (*string_value)[1024], const entity_t *entity, ... ){
|
||||
va_list argptr;
|
||||
va_start( argptr, entity );
|
||||
const char* key;
|
||||
|
|
@ -951,7 +951,7 @@ bool entity_read_string( char (*string_value)[], const entity_t *entity, ... ){
|
|||
va_end( argptr );
|
||||
return false;
|
||||
}
|
||||
bool entity_read_string_ptr( const char **string_ptr_value, const entity_t *entity, ... ){
|
||||
bool entity_read_keyvalue( const char **string_ptr_value, const entity_t *entity, ... ){
|
||||
va_list argptr;
|
||||
va_start( argptr, entity );
|
||||
const char* key;
|
||||
|
|
|
|||
|
|
@ -452,7 +452,7 @@ void LoadIBSPFile( const char *filename ){
|
|||
SwapBlock( (int*) ( (byte*) header + sizeof( int ) ), sizeof( *header ) - sizeof( int ) );
|
||||
|
||||
/* make sure it matches the format we're trying to load */
|
||||
if ( !force && *( (int*) header->ident ) != *( (int*) game->bspIdent ) ) {
|
||||
if ( !force && *( (int*) header->ident ) != *( (const int*) game->bspIdent ) ) {
|
||||
Error( "%s is not a %s file", filename, game->bspIdent );
|
||||
}
|
||||
if ( !force && header->version != game->bspVersion ) {
|
||||
|
|
@ -524,7 +524,7 @@ void PartialLoadIBSPFile( const char *filename ){
|
|||
SwapBlock( (int*) ( (byte*) header + sizeof( int ) ), sizeof( *header ) - sizeof( int ) );
|
||||
|
||||
/* make sure it matches the format we're trying to load */
|
||||
if ( !force && *( (int*) header->ident ) != *( (int*) game->bspIdent ) ) {
|
||||
if ( !force && *( (int*) header->ident ) != *( (const int*) game->bspIdent ) ) {
|
||||
Error( "%s is not a %s file", filename, game->bspIdent );
|
||||
}
|
||||
if ( !force && header->version != game->bspVersion ) {
|
||||
|
|
@ -564,7 +564,7 @@ void WriteIBSPFile( const char *filename ){
|
|||
//% Swapfile();
|
||||
|
||||
/* set up header */
|
||||
*( (int*) (bspHeader_t*) header->ident ) = *( (int*) game->bspIdent );
|
||||
*( (int*) (bspHeader_t*) header->ident ) = *( (const int*) game->bspIdent );
|
||||
header->version = LittleLong( game->bspVersion );
|
||||
|
||||
/* write initial header */
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ void LoadRBSPFile( const char *filename ){
|
|||
SwapBlock( (int*) ( (byte*) header + sizeof( int ) ), sizeof( *header ) - sizeof( int ) );
|
||||
|
||||
/* make sure it matches the format we're trying to load */
|
||||
if ( !force && *( (int*) header->ident ) != *( (int*) game->bspIdent ) ) {
|
||||
if ( !force && *( (int*) header->ident ) != *( (const int*) game->bspIdent ) ) {
|
||||
Error( "%s is not a %s file", filename, game->bspIdent );
|
||||
}
|
||||
if ( !force && header->version != game->bspVersion ) {
|
||||
|
|
@ -295,7 +295,7 @@ void WriteRBSPFile( const char *filename ){
|
|||
//% Swapfile();
|
||||
|
||||
/* set up header */
|
||||
*( (int*) (bspHeader_t*) header->ident ) = *( (int*) game->bspIdent );
|
||||
*( (int*) (bspHeader_t*) header->ident ) = *( (const int*) game->bspIdent );
|
||||
header->version = LittleLong( game->bspVersion );
|
||||
|
||||
/* write initial header */
|
||||
|
|
|
|||
|
|
@ -47,8 +47,9 @@ int FixAAS( int argc, char **argv ){
|
|||
int length, checksum;
|
||||
void *buffer;
|
||||
FILE *file;
|
||||
char aas[ 1024 ], **ext;
|
||||
char *exts[] =
|
||||
char aas[ 1024 ];
|
||||
const char **ext;
|
||||
const char *exts[] =
|
||||
{
|
||||
".aas",
|
||||
"_b0.aas",
|
||||
|
|
@ -123,7 +124,7 @@ abspHeader_t;
|
|||
typedef struct abspLumpTest_s
|
||||
{
|
||||
int radix, minCount;
|
||||
char *name;
|
||||
const char *name;
|
||||
}
|
||||
abspLumpTest_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ exwinding:
|
|||
static void ConvertOriginBrush( FILE *f, int num, vec3_t origin, bool brushPrimitives ){
|
||||
int originSize = 256;
|
||||
|
||||
char pattern[6][7][3] = {
|
||||
char pattern[6][7][4] = {
|
||||
{ "+++", "+-+", "-++", "- ", " + ", " - ", "- " },
|
||||
{ "+++", "-++", "++-", "- ", " +", "+ ", " +" },
|
||||
{ "+++", "++-", "+-+", " - ", " +", " - ", " +" },
|
||||
|
|
@ -375,7 +375,7 @@ static void ConvertBrush( FILE *f, int num, bspBrush_t *brush, vec3_t origin, bo
|
|||
bspBrushSide_t *side;
|
||||
side_t *buildSide;
|
||||
bspShader_t *shader;
|
||||
char *texture;
|
||||
const char *texture;
|
||||
plane_t *buildPlane;
|
||||
vec3_t pts[ 3 ];
|
||||
bspDrawVert_t *vert[3];
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ struct HelpOption
|
|||
void HelpOptions(const char* group_name, int indentation, int width, struct HelpOption* options, int count)
|
||||
{
|
||||
indentation *= 2;
|
||||
char* indent = malloc(indentation+1);
|
||||
char* indent = safe_malloc(indentation+1);
|
||||
memset(indent, ' ', indentation);
|
||||
indent[indentation] = 0;
|
||||
printf("%s%s:\n", indent, group_name);
|
||||
indentation += 2;
|
||||
indent = realloc(indent, indentation+1);
|
||||
indent = void_ptr( realloc(indent, indentation+1) );
|
||||
memset(indent, ' ', indentation);
|
||||
indent[indentation] = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ static int AddItemToTraceNode( traceNode_t *node, int num ){
|
|||
if ( node->maxItems <= 0 ) {
|
||||
node->maxItems = GROW_NODE_ITEMS;
|
||||
}
|
||||
node->items = realloc( node->items, node->maxItems * sizeof( *node->items ) );
|
||||
node->items = void_ptr( realloc( node->items, node->maxItems * sizeof( *node->items ) ) );
|
||||
if ( !node->items ) {
|
||||
Error( "node->items out of memory" );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ int ImportLightmapsMain( int argc, char **argv ){
|
|||
sprintf( filename, "%s/lightmap_%04d.tga", dirname, i );
|
||||
Sys_Printf( "Loading %s\n", filename );
|
||||
buffer = NULL;
|
||||
len = vfsLoadFile( filename, (void*) &buffer, -1 );
|
||||
len = vfsLoadFile( filename, (void**) &buffer, -1 );
|
||||
if ( len < 0 ) {
|
||||
Sys_Warning( "Unable to load image %s\n", filename );
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ int main( int argc, char **argv ){
|
|||
|
||||
/* init model library */
|
||||
PicoInit();
|
||||
PicoSetMallocFunc( safe_malloc );
|
||||
PicoSetMallocFunc( malloc );
|
||||
PicoSetFreeFunc( free );
|
||||
PicoSetPrintFunc( PicoPrintFunc );
|
||||
PicoSetLoadFileFunc( PicoLoadFileFunc );
|
||||
|
|
|
|||
|
|
@ -1628,7 +1628,8 @@ void LoadEntityIndexMap( entity_t *e ){
|
|||
im->pixels = pixels;
|
||||
|
||||
/* get height offsets */
|
||||
char offset[ 4096 ];
|
||||
// char offset[ 4096 ];
|
||||
char offset[ 1024 ];
|
||||
if( ENT_READKV( &offset, mapEnt, "_offsets", "offsets" ) ){
|
||||
/* value is a space-separated set of numbers */
|
||||
char *search = offset;
|
||||
|
|
|
|||
|
|
@ -522,7 +522,7 @@ int MiniMapBSPMain( int argc, char **argv ){
|
|||
i++;
|
||||
Sys_Printf( "Samples set to %i\n", minimap.samples );
|
||||
free( minimap.sample_offsets );
|
||||
minimap.sample_offsets = malloc( 2 * sizeof( *minimap.sample_offsets ) * minimap.samples );
|
||||
minimap.sample_offsets = safe_malloc( 2 * sizeof( *minimap.sample_offsets ) * minimap.samples );
|
||||
MiniMapMakeSampleOffsets();
|
||||
}
|
||||
else if ( strEqual( argv[ i ], "-random" ) ) {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
#define MAX_GAME_PATHS 10
|
||||
#define MAX_PAK_PATHS 200
|
||||
|
||||
char *homePath;
|
||||
const char *homePath;
|
||||
char installPath[ MAX_OS_PATH ];
|
||||
|
||||
int numBasePaths;
|
||||
|
|
@ -52,7 +52,7 @@ int numGamePaths;
|
|||
char *gamePaths[ MAX_GAME_PATHS ];
|
||||
int numPakPaths;
|
||||
char *pakPaths[ MAX_PAK_PATHS ];
|
||||
char *homeBasePath = NULL;
|
||||
const char *homeBasePath = NULL;
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -263,7 +263,7 @@ void AddBasePath( char *path ){
|
|||
adds a base path to the beginning of the list, prefixed by ~/
|
||||
*/
|
||||
|
||||
void AddHomeBasePath( char *path ){
|
||||
void AddHomeBasePath( const char *path ){
|
||||
int i;
|
||||
char temp[ MAX_OS_PATH ];
|
||||
|
||||
|
|
@ -313,7 +313,7 @@ void AddHomeBasePath( char *path ){
|
|||
adds a game path to the list
|
||||
*/
|
||||
|
||||
void AddGamePath( char *path ){
|
||||
void AddGamePath( const char *path ){
|
||||
int i;
|
||||
|
||||
/* dummy check */
|
||||
|
|
|
|||
|
|
@ -524,7 +524,7 @@ typedef float tcMod_t[ 3 ][ 3 ];
|
|||
/* ydnar: for multiple game support */
|
||||
typedef struct surfaceParm_s
|
||||
{
|
||||
char *name;
|
||||
const char *name;
|
||||
int contentFlags, contentFlagsClear;
|
||||
int surfaceFlags, surfaceFlagsClear;
|
||||
int compileFlags, compileFlagsClear;
|
||||
|
|
@ -541,16 +541,16 @@ miniMapMode_t;
|
|||
|
||||
typedef struct game_s
|
||||
{
|
||||
char *arg; /* -game matches this */
|
||||
char *gamePath; /* main game data dir */
|
||||
char *homeBasePath; /* home sub-dir on unix */
|
||||
char *magic; /* magic word for figuring out base path */
|
||||
char *shaderPath; /* shader directory */
|
||||
const char *arg; /* -game matches this */
|
||||
const char *gamePath; /* main game data dir */
|
||||
const char *homeBasePath; /* home sub-dir on unix */
|
||||
const char *magic; /* magic word for figuring out base path */
|
||||
const char *shaderPath; /* shader directory */
|
||||
int maxLMSurfaceVerts; /* default maximum meta surface verts */
|
||||
int maxSurfaceVerts; /* default maximum surface verts */
|
||||
int maxSurfaceIndexes; /* default maximum surface indexes (tris * 3) */
|
||||
bool emitFlares; /* when true, emit flare surfaces */
|
||||
char *flareShader; /* default flare shader (MUST BE SET) */
|
||||
const char *flareShader; /* default flare shader (MUST BE SET) */
|
||||
bool wolfLight; /* when true, lights work like wolf q3map */
|
||||
int lightmapSize; /* bsp lightmap width/height */
|
||||
float lightmapGamma; /* default lightmap gamma */
|
||||
|
|
@ -573,8 +573,8 @@ typedef struct game_s
|
|||
float miniMapBorder; /* minimap border amount */
|
||||
bool miniMapKeepAspect; /* minimap keep aspect ratio by letterboxing */
|
||||
miniMapMode_t miniMapMode; /* minimap mode */
|
||||
char *miniMapNameFormat; /* minimap name format */
|
||||
char *bspIdent; /* 4-letter bsp file prefix */
|
||||
const char *miniMapNameFormat; /* minimap name format */
|
||||
const char *bspIdent; /* 4-letter bsp file prefix */
|
||||
int bspVersion; /* bsp version to use */
|
||||
bool lumpSwap; /* cod-style len/ofs order */
|
||||
bspFunc load, write; /* load/write function pointers */
|
||||
|
|
@ -700,7 +700,7 @@ typedef struct shaderInfo_s
|
|||
int compileFlags;
|
||||
float value; /* light value */
|
||||
|
||||
char *flareShader; /* for light flares */
|
||||
const char *flareShader; /* for light flares */
|
||||
char *damageShader; /* ydnar: sof2 damage shader name */
|
||||
char *backShader; /* for surfaces that generate different front and back passes */
|
||||
char *cloneShader; /* ydnar: for cloning of a surface */
|
||||
|
|
@ -997,7 +997,7 @@ surfaceType_t;
|
|||
#ifndef MAIN_C
|
||||
extern
|
||||
#endif
|
||||
char *surfaceTypes[ NUM_SURFACE_TYPES ]
|
||||
const char *surfaceTypes[ NUM_SURFACE_TYPES ]
|
||||
#ifndef MAIN_C
|
||||
;
|
||||
#else
|
||||
|
|
@ -1556,7 +1556,7 @@ bool BoundBrush( brush_t *brush );
|
|||
bool CreateBrushWindings( brush_t *brush );
|
||||
brush_t *BrushFromBounds( vec3_t mins, vec3_t maxs );
|
||||
vec_t BrushVolume( brush_t *brush );
|
||||
void WriteBSPBrushMap( char *name, brush_t *list );
|
||||
void WriteBSPBrushMap( const char *name, brush_t *list );
|
||||
|
||||
void FilterDetailBrushesIntoTree( entity_t *e, tree_t *tree );
|
||||
void FilterStructuralBrushesIntoTree( entity_t *e, tree_t *tree );
|
||||
|
|
@ -1586,8 +1586,6 @@ mesh_t *RemoveLinearMeshColumnsRows( mesh_t *in );
|
|||
void MakeMeshNormals( mesh_t in );
|
||||
void PutMeshOnCurve( mesh_t in );
|
||||
|
||||
void MakeNormalVectors( vec3_t forward, vec3_t right, vec3_t up );
|
||||
|
||||
|
||||
/* map.c */
|
||||
void LoadMapFile( char *filename, bool onlyLights, bool noCollapseGroups );
|
||||
|
|
@ -1864,11 +1862,11 @@ void TCModTranslate( tcMod_t mod, float s, float t );
|
|||
void TCModScale( tcMod_t mod, float s, float t );
|
||||
void TCModRotate( tcMod_t mod, float euler );
|
||||
|
||||
bool ApplySurfaceParm( char *name, int *contentFlags, int *surfaceFlags, int *compileFlags );
|
||||
bool ApplySurfaceParm( const char *name, int *contentFlags, int *surfaceFlags, int *compileFlags );
|
||||
|
||||
void BeginMapShaderFile( const char *mapFile );
|
||||
void WriteMapShaderFile( void );
|
||||
shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace );
|
||||
shaderInfo_t *CustomShader( shaderInfo_t *si, const char *find, char *replace );
|
||||
void EmitVertexRemapShader( char *from, char *to );
|
||||
|
||||
void LoadShaderInfo( void );
|
||||
|
|
@ -1887,7 +1885,7 @@ void BSPFilesCleanup();
|
|||
void SwapBlock( int *block, int size );
|
||||
|
||||
int GetLumpElements( bspHeader_t *header, int lump, int size );
|
||||
void *GetLump( bspHeader_t *header, int lump );
|
||||
void_ptr GetLump( bspHeader_t *header, int lump );
|
||||
int CopyLump( bspHeader_t *header, int lump, void *dest, int size );
|
||||
int CopyLump_Allocate( bspHeader_t *header, int lump, void **dest, int size, int *allocationVariable );
|
||||
void AddLump( FILE *file, bspHeader_t *header, int lumpNum, const void *data, int length );
|
||||
|
|
@ -1913,20 +1911,13 @@ void GetVectorForKey( const entity_t *ent, const char *ke
|
|||
/* entity: read key value generic macro
|
||||
returns true on successful read
|
||||
returns false and does not modify value otherwise */
|
||||
bool entity_read_bool( bool *bool_value, const entity_t *entity, ... );
|
||||
bool entity_read_int( int *int_value, const entity_t *entity, ... );
|
||||
bool entity_read_float( float *float_value, const entity_t *entity, ... ); // warning: float[3] may be passed here erroneously, if not written as &float[3]
|
||||
bool entity_read_vector3( float (*vector3_value)[3], const entity_t *entity, ... );
|
||||
bool entity_read_string( char (*string_value)[], const entity_t *entity, ... ); // explicit pointer to array to avoid erroneous mix of char* and char**
|
||||
bool entity_read_string_ptr( const char **string_ptr_value, const entity_t *entity, ... );
|
||||
#define ENT_READKV( value_ptr, entity, keys... ) _Generic( ( value_ptr ), \
|
||||
bool*: entity_read_bool, \
|
||||
int*: entity_read_int, \
|
||||
float*: entity_read_float, \
|
||||
float (*)[3]: entity_read_vector3,\
|
||||
char (*)[]: entity_read_string, \
|
||||
const char**: entity_read_string_ptr\
|
||||
)( value_ptr, entity, keys, NULL )
|
||||
bool entity_read_keyvalue( bool *bool_value, const entity_t *entity, ... );
|
||||
bool entity_read_keyvalue( int *int_value, const entity_t *entity, ... );
|
||||
bool entity_read_keyvalue( float *float_value, const entity_t *entity, ... ); // warning: float[3] may be passed here erroneously, if not written as &float[3]
|
||||
bool entity_read_keyvalue( float (*vector3_value)[3], const entity_t *entity, ... );
|
||||
bool entity_read_keyvalue( char (*string_value)[1024], const entity_t *entity, ... ); // explicit pointer to array to avoid erroneous mix of char* and char**
|
||||
bool entity_read_keyvalue( const char **string_ptr_value, const entity_t *entity, ... );
|
||||
#define ENT_READKV( value_ptr, entity, keys... ) entity_read_keyvalue( value_ptr, entity, keys, NULL )
|
||||
|
||||
const char *ent_classname( const entity_t *entity );
|
||||
bool ent_class_is( const entity_t *entity, const char *classname );
|
||||
|
|
@ -2132,8 +2123,8 @@ Q_EXTERN char name[ 1024 ];
|
|||
Q_EXTERN char source[ 1024 ];
|
||||
Q_EXTERN char outbase[ 32 ];
|
||||
|
||||
Q_EXTERN int sampleSize; /* lightmap sample size in units */
|
||||
Q_EXTERN int minSampleSize; /* minimum sample size to use at all */
|
||||
Q_EXTERN int sampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_SAMPLE_SIZE ); /* lightmap sample size in units */
|
||||
Q_EXTERN int minSampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_MIN_SAMPLE_SIZE ); /* minimum sample size to use at all */
|
||||
Q_EXTERN int sampleScale; /* vortex: lightmap sample scale (ie quality)*/
|
||||
|
||||
Q_EXTERN int mapEntityNum Q_ASSIGN( 0 );
|
||||
|
|
@ -2258,8 +2249,8 @@ Q_EXTERN bool loMem Q_ASSIGN( false );
|
|||
Q_EXTERN bool noStyles Q_ASSIGN( false );
|
||||
Q_EXTERN bool keepLights Q_ASSIGN( false );
|
||||
|
||||
Q_EXTERN int sampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_SAMPLE_SIZE );
|
||||
Q_EXTERN int minSampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_MIN_SAMPLE_SIZE );
|
||||
//Q_EXTERN int sampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_SAMPLE_SIZE );
|
||||
//Q_EXTERN int minSampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_MIN_SAMPLE_SIZE );
|
||||
Q_EXTERN float noVertexLighting Q_ASSIGN( 0.0f );
|
||||
Q_EXTERN bool nolm Q_ASSIGN( false );
|
||||
Q_EXTERN bool noGridLighting Q_ASSIGN( false );
|
||||
|
|
@ -2589,7 +2580,7 @@ Q_EXTERN bspAdvertisement_t bspAds[ MAX_MAP_ADVERTISEMENTS ];
|
|||
{ \
|
||||
Error( # ptr " over 2 GB" ); \
|
||||
} \
|
||||
ptr = realloc( ptr, sizeof( *ptr ) * allocated ); \
|
||||
ptr = void_ptr( realloc( ptr, sizeof( *ptr ) * allocated ) ); \
|
||||
if ( !ptr ) { \
|
||||
Error( # ptr " out of memory" ); } \
|
||||
} \
|
||||
|
|
@ -2604,7 +2595,7 @@ Q_EXTERN bspAdvertisement_t bspAds[ MAX_MAP_ADVERTISEMENTS ];
|
|||
if ( used >= allocated ) \
|
||||
{ \
|
||||
allocated += add; \
|
||||
ptr = realloc( ptr, sizeof( *ptr ) * allocated ); \
|
||||
ptr = void_ptr( realloc( ptr, sizeof( *ptr ) * allocated ) ); \
|
||||
if ( !ptr ) { \
|
||||
Error( # ptr " out of memory" ); } \
|
||||
} \
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ void TCModRotate( tcMod_t mod, float euler ){
|
|||
applies a named surfaceparm to the supplied flags
|
||||
*/
|
||||
|
||||
bool ApplySurfaceParm( char *name, int *contentFlags, int *surfaceFlags, int *compileFlags ){
|
||||
bool ApplySurfaceParm( const char *name, int *contentFlags, int *surfaceFlags, int *compileFlags ){
|
||||
int i, fake;
|
||||
surfaceParm_t *sp;
|
||||
|
||||
|
|
@ -415,7 +415,7 @@ void WriteMapShaderFile( void ){
|
|||
sets up a custom map shader
|
||||
*/
|
||||
|
||||
shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ){
|
||||
shaderInfo_t *CustomShader( shaderInfo_t *si, const char *find, char *replace ){
|
||||
shaderInfo_t *csi;
|
||||
char shader[ MAX_QPATH ];
|
||||
char *s;
|
||||
|
|
@ -1719,11 +1719,10 @@ static void ParseShaderFile( const char *filename ){
|
|||
striEqual( token, "q3map_rgbGen" ) || striEqual( token, "q3map_rgbMod" ) ||
|
||||
striEqual( token, "q3map_alphaGen" ) || striEqual( token, "q3map_alphaMod" ) ) {
|
||||
colorMod_t *cm, *cm2;
|
||||
int alpha;
|
||||
|
||||
|
||||
/* alphamods are colormod + 1 */
|
||||
alpha = ( striEqual( token, "q3map_alphaGen" ) || striEqual( token, "q3map_alphaMod" ) ) ? 1 : 0;
|
||||
const bool alpha = striEqual( token, "q3map_alphaGen" ) || striEqual( token, "q3map_alphaMod" );
|
||||
|
||||
/* allocate new colormod */
|
||||
cm = safe_calloc( sizeof( *cm ) );
|
||||
|
|
@ -1779,25 +1778,25 @@ static void ParseShaderFile( const char *filename ){
|
|||
|
||||
/* dotProduct ( X Y Z ) */
|
||||
else if ( striEqual( token, "dotProduct" ) ) {
|
||||
cm->type = CM_COLOR_DOT_PRODUCT + alpha;
|
||||
cm->type = alpha? CM_ALPHA_DOT_PRODUCT : CM_COLOR_DOT_PRODUCT;
|
||||
Parse1DMatrixAppend( shaderText, 3, cm->data );
|
||||
}
|
||||
|
||||
/* dotProductScale ( X Y Z MIN MAX ) */
|
||||
else if ( striEqual( token, "dotProductScale" ) ) {
|
||||
cm->type = CM_COLOR_DOT_PRODUCT_SCALE + alpha;
|
||||
cm->type = alpha? CM_ALPHA_DOT_PRODUCT_SCALE : CM_COLOR_DOT_PRODUCT_SCALE;
|
||||
Parse1DMatrixAppend( shaderText, 5, cm->data );
|
||||
}
|
||||
|
||||
/* dotProduct2 ( X Y Z ) */
|
||||
else if ( striEqual( token, "dotProduct2" ) ) {
|
||||
cm->type = CM_COLOR_DOT_PRODUCT_2 + alpha;
|
||||
cm->type = alpha? CM_ALPHA_DOT_PRODUCT_2 : CM_COLOR_DOT_PRODUCT_2;
|
||||
Parse1DMatrixAppend( shaderText, 3, cm->data );
|
||||
}
|
||||
|
||||
/* dotProduct2scale ( X Y Z MIN MAX ) */
|
||||
else if ( striEqual( token, "dotProduct2scale" ) ) {
|
||||
cm->type = CM_COLOR_DOT_PRODUCT_2_SCALE + alpha;
|
||||
cm->type = alpha? CM_ALPHA_DOT_PRODUCT_2_SCALE : CM_COLOR_DOT_PRODUCT_2_SCALE;
|
||||
Parse1DMatrixAppend( shaderText, 5, cm->data );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ void TriangulatePatchSurface( entity_t *e, mapDrawSurface_t *ds ){
|
|||
#define MAXAREA_MAXTRIES 8
|
||||
int MaxAreaIndexes( bspDrawVert_t *vert, int cnt, int *indexes ){
|
||||
int r, s, t, bestR = 0, bestS = 1, bestT = 2;
|
||||
int i, j, try;
|
||||
int i, j;
|
||||
double A, bestA = -1, V, bestV = -1;
|
||||
vec3_t ab, ac, bc, cross;
|
||||
bspDrawVert_t *buf;
|
||||
|
|
@ -458,9 +458,9 @@ int MaxAreaIndexes( bspDrawVert_t *vert, int cnt, int *indexes ){
|
|||
Sys_FPrintf( SYS_WRN, "value was REALLY bad\n" );
|
||||
*/
|
||||
|
||||
for ( try = 0; try < MAXAREA_MAXTRIES; ++try )
|
||||
for ( int trai = 0; trai < MAXAREA_MAXTRIES; ++trai )
|
||||
{
|
||||
if ( try ) {
|
||||
if ( trai ) {
|
||||
bestR = rand() % cnt;
|
||||
bestS = rand() % cnt;
|
||||
bestT = rand() % cnt;
|
||||
|
|
@ -604,7 +604,7 @@ void MaxAreaFaceSurface( mapDrawSurface_t *ds ){
|
|||
|
||||
void FanFaceSurface( mapDrawSurface_t *ds ){
|
||||
int i, j, k, a, b, c;
|
||||
int color[ MAX_LIGHTMAPS ][ 4 ] = {0};
|
||||
int color[ MAX_LIGHTMAPS ][ 4 ] = {{0}};
|
||||
bspDrawVert_t *verts, *centroid, *dv;
|
||||
double iv;
|
||||
|
||||
|
|
|
|||
|
|
@ -1412,7 +1412,8 @@ void CreatePassages( int portalnum ){
|
|||
/* ydnar: prefer correctness to stack overflow */
|
||||
//% memcpy( &in, p->winding, (int)((fixedWinding_t *)0)->points[p->winding->numpoints] );
|
||||
if ( p->winding->numpoints <= MAX_POINTS_ON_FIXED_WINDING ) {
|
||||
memcpy( &in, p->winding, offsetof( fixedWinding_t, points[p->winding->numpoints] ) );
|
||||
memcpy( &in, p->winding, (size_t)((fixedWinding_t *)0)->points[p->winding->numpoints] );
|
||||
// memcpy( &in, p->winding, offsetof( fixedWinding_t, points[p->winding->numpoints] ) );
|
||||
}
|
||||
else{
|
||||
memcpy( &in, p->winding, sizeof( fixedWinding_t ) );
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user