add_definitions(-DRADIANT_ABOUTMSG="${NetRadiant_ABOUT}")
+add_definitions(-D_GLIBCXX_DEBUG=1)
+add_definitions(-D_GLIBCXX_DEBUG_PEDANTIC=1)
+
if (NOT CMAKE_BUILD_TYPE MATCHES Release)
add_definitions(-D_DEBUG=1)
endif ()
AddSplineControl(control, pSP);
for (int j = 2;; j++) {
- char buffer[16];
+ char buffer[18];
sprintf(buffer, "control%i", j);
e.SpawnString(buffer, NULL, &control);
#ifndef __DTREE_H__
#define __DTREE_H__
+#include <cassert>
#include "qerplugin.h"
#include "signal/isignal.h"
#include "string/string.h"
buf[len] = '\0';
// parser will do the cleanup, dont delete.
- fread(buf, len, 1, file);
+ assert(fread(buf, len, 1, file));
CScriptParser parser;
parser.SetScript(buf);
#include <globaldefs.h>
+#include <cassert>
#include "bsploader.h"
#include "dialogs/dialogs-gtk.h"
#include "cmdlib.h"
length = FileLength(f);
buffer = new byte[length + 1];
buffer[length] = 0;
- fread(buffer, 1, length, f);
+ assert(fread(buffer, 1, length, f));
fclose(f);
*bufferptr = buffer;
#include <string.h>
#include <math.h>
+#include <cassert>
#include "misc.h"
in = fopen(fn, "rt");
- fgets(buf, LINE_BUF, in);
- fgets(buf, LINE_BUF, in);
- fgets(buf, LINE_BUF, in);
- fgets(buf, LINE_BUF, in);
+ assert(fgets(buf, LINE_BUF, in));
+ assert(fgets(buf, LINE_BUF, in));
+ assert(fgets(buf, LINE_BUF, in));
+ assert(fgets(buf, LINE_BUF, in));
unsigned int n;
for (n = 0; n < p_count; n++) {
int cnt = 0;
while (!feof(eFile)) {
memset(buffer, 0, 256);
- fscanf(eFile, "%s\n", buffer);
-
- if (strlen(buffer) > 0) {
+ if (fscanf(eFile, "%s\n", buffer)) {
exclusionList->push_back(buffer);
} else {
cnt++;
int cnt = 0;
while (!feof(eFile)) {
memset(buffer, 0, 256);
- fscanf(eFile, "%s\n", buffer);
-
- if (strlen(buffer) > 0) {
+ if (fscanf(eFile, "%s\n", buffer)) {
char *buffer2 = new char[strlen(buffer) + 1];
strcpy(buffer2, buffer);
loadlist.append(0, buffer2);
// NOTE: we could use that to detect when a step finishes. But then it
// would not work for remote compiling stuff.
// execlp (pCmd, pCmd, NULL);
- system(pCmd);
+ int ret = system(pCmd);
printf("system() returned");
- _exit(0);
+ _exit(ret);
break;
}
return true;
char *c = def;
unsigned int n;
int dummy1, dummy2;
- int res_cnt, i;
+ int res_cnt = 0, i;
if (portals.hint_flags) {
res_cnt = sscanf(def, "%u %d %d %d", &point_count, &dummy1, &dummy2, (int *) &hint);
template<typename InputStreamType>
inline typename InputStreamType::byte_type istream_read_byte( InputStreamType& istream ){
- typename InputStreamType::byte_type b;
+ typename InputStreamType::byte_type b = 0;
istream.read( &b, sizeof( typename InputStreamType::byte_type ) );
return b;
}
printf( "Running system...\n" );
printf( "Command: %s\n", pCmd );
#endif
- system( pCmd );
+ int ret = system( pCmd );
#if GDEF_DEBUG
printf( "system() returned\n" );
#endif
- _exit( 0 );
+ _exit( ret );
break;
}
return true;
}
/* remap shader's ambient color */
else if ( !_pico_stricmp( p->token,"ambient" ) ) {
- picoColor_t color;
picoVec3_t v;
/* get vector from parser */
}
/* store as color */
- color[ 0 ] = (picoByte_t)v[ 0 ];
- color[ 1 ] = (picoByte_t)v[ 1 ];
- color[ 2 ] = (picoByte_t)v[ 2 ];
+ picoColor_t color = {(picoByte_t) v[0], (picoByte_t) v[1], (picoByte_t) v[2]};
/* set new ambient color */
PicoSetShaderAmbientColor( shader,color );
}
/* remap shader's diffuse color */
else if ( !_pico_stricmp( p->token,"diffuse" ) ) {
- picoColor_t color;
picoVec3_t v;
/* get vector from parser */
}
/* store as color */
- color[ 0 ] = (picoByte_t)v[ 0 ];
- color[ 1 ] = (picoByte_t)v[ 1 ];
- color[ 2 ] = (picoByte_t)v[ 2 ];
+ picoColor_t color = {(picoByte_t) v[0], (picoByte_t) v[1], (picoByte_t) v[2]};
/* set new ambient color */
PicoSetShaderDiffuseColor( shader,color );
}
/* remap shader's specular color */
else if ( !_pico_stricmp( p->token,"specular" ) ) {
- picoColor_t color;
picoVec3_t v;
/* get vector from parser */
}
/* store as color */
- color[ 0 ] = (picoByte_t)v[ 0 ];
- color[ 1 ] = (picoByte_t)v[ 1 ];
- color[ 2 ] = (picoByte_t)v[ 2 ];
+ picoColor_t color = {(picoByte_t) v[0], (picoByte_t) v[1], (picoByte_t) v[2]};
/* set new ambient color */
PicoSetShaderSpecularColor( shader,color );
----------------------------------------------------------------------------- */
/* dependencies */
+#include <assert.h>
#include "picointernal.h"
#include "globaldefs.h"
/* get number of vertices */
bufptr = GetWord( bufptr,&numVerts );
+ assert(bufptr);
ptrToVerts = bufptr;
#ifdef DEBUG_PM_MS3D
}
/* get number of groups */
bufptr = GetWord( bufptr,&numGroups );
+ assert(bufptr);
// ptrToGroups = bufptr;
#ifdef DEBUG_PM_MS3D
/* get triangle index */
bufptr = GetWord( bufptr,(int *)&triangleIndex );
+ assert(bufptr);
/* get ptr to triangle data */
triangle = (TMsTriangle *)( ptrToTris + ( sizeof( TMsTriangle ) * triangleIndex ) );
}
/* get number of materials */
bufptr = GetWord( bufptr,&numMaterials );
+ assert(bufptr);
#ifdef DEBUG_PM_MS3D
printf( "NumMaterials: %d\n",numMaterials );
#include "file.h"
#include <stdlib.h>
+#include <cassert>
#include "str.h"
len = ftell( rc );
rewind( rc );
buf = malloc( len );
- fread( buf, len, 1, rc );
+ assert(fread( buf, len, 1, rc ));
old_rc.write( reinterpret_cast<MemStream::byte_type*>( buf ), len );
free( buf );
fclose( rc );
#include "xmltextags.h"
#include <string>
+#include <cassert>
#include "qerplugin.h"
#include "stream/stringstream.h"
break;
case TEXTURE:
newnode = xmlNewNode( NULL, (xmlChar*)"texture" );
+ break;
+ default:
+ assert(false);
+ break;
};
newnode = xmlDocCopyNode( newnode, doc, 1 );
#include <list>
class EntityFilterWrapper : public Filter {
- bool m_active;
+ bool m_active = false;
bool m_invert;
EntityFilter &m_filter;
public:
tokeniser.nextLine();
MD5_RETURN_FALSE_IF_FAIL(MD5_parseToken(tokeniser, "shader"));
- const char *shader;
+ const char *shader = nullptr;
MD5_RETURN_FALSE_IF_FAIL(MD5_parseString(tokeniser, shader));
surface.setShader(shader);
tokeniser.nextLine();
float evaluateFloat(const ShaderValue &value, const ShaderParameters ¶ms, const ShaderArguments &args)
{
const char *result = evaluateShaderValue(value.c_str(), params, args);
- float f;
+ float f = 0;
if (!string_parse_float(result, f)) {
globalErrorStream() << "parsing float value failed: " << makeQuoted(result) << "\n";
}
}
const char *ext = strrchr(name, '.');
- char tmppath[PATH_MAX];
+ char tmppath[PATH_MAX + 1];
if (is_dpk_vfs) {
if (!!ext && !string_compare_nocase_upper(ext, ".dpkdir")) {
class FaceFilterWrapper : public Filter {
FaceFilter &m_filter;
- bool m_active;
+ bool m_active = false;
bool m_invert;
public:
FaceFilterWrapper(FaceFilter &filter, bool invert) :
class BrushFilterWrapper : public Filter {
- bool m_active;
+ bool m_active = false;
bool m_invert;
BrushFilter &m_filter;
public:
std::size_t depth = 1;
for (;;) {
- const char *token;
+ const char *token = nullptr;
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseString(tokeniser, token));
if (string_equal(token, "}")) {
if (--depth == 0) {
bool EntityClassDoom3_parseModel(Tokeniser &tokeniser)
{
- const char *name;
+ const char *name = nullptr;
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseString(tokeniser, name));
Model &model = g_models[name];
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseToken(tokeniser));
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseToken(tokeniser, "("));
for (;;) {
- const char *end;
+ const char *end = nullptr;
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseString(tokeniser, end));
if (string_equal(end, ")")) {
tokeniser.nextLine();
} else if (string_equal(parameter, "anim")) {
CopiedString animName;
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseString(tokeniser, animName));
- const char *animFile;
+ const char *animFile = nullptr;
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseString(tokeniser, animFile));
model.m_anims.insert(Model::Anims::value_type(animName, animFile));
- const char *token;
+ const char *token = nullptr;
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseString(tokeniser, token));
while (string_equal(token, ",")) {
if (string_equal(token, "{")) {
for (;;) {
- const char *end;
+ const char *end = nullptr;
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseString(tokeniser, end));
if (string_equal(end, "}")) {
tokeniser.nextLine();
tokeniser.nextLine();
break;
} else if (string_equal(key, "model")) {
- const char *token;
+ const char *token = nullptr;
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseString(tokeniser, token));
entityClass.fixedsize = true;
StringOutputStream buffer(256);
buffer << PathCleaned(token);
entityClass.m_modelpath = buffer.c_str();
} else if (string_equal(key, "editor_color")) {
- const char *value;
+ const char *value = nullptr;
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseString(tokeniser, value));
if (!string_empty(value)) {
entityClass.colorSpecified = true;
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseToken(tokeniser));
} else if (string_equal(key, "editor_mins")) {
entityClass.sizeSpecified = true;
- const char *value;
+ const char *value = nullptr;
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseString(tokeniser, value));
if (!string_empty(value) && !string_equal(value, "?")) {
entityClass.fixedsize = true;
}
} else if (string_equal(key, "editor_maxs")) {
entityClass.sizeSpecified = true;
- const char *value;
+ const char *value = nullptr;
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseString(tokeniser, value));
if (!string_empty(value) && !string_equal(value, "?")) {
entityClass.fixedsize = true;
} else if (string_equal(key, "inherit")) {
entityClass.inheritanceResolved = false;
ASSERT_MESSAGE(entityClass.m_parent.empty(), "only one 'inherit' supported per entityDef");
- const char *token;
+ const char *token = nullptr;
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseString(tokeniser, token));
entityClass.m_parent.push_back(token);
}
}
EntityClassAttribute &attribute = EntityClass_insertAttribute(entityClass, key).second;
attribute.m_type = "string";
- const char *value;
+ const char *value = nullptr;
PARSE_RETURN_FALSE_IF_FAIL(EntityClassDoom3_parseString(tokeniser, value));
if (string_equal(value, "}")) { // hack for quake4 powerups.def bug
globalErrorStream() << "entityDef " << makeQuoted(entityClass.m_name.c_str()) << " key "
#include <unistd.h>
#include <glib.h>
+#include <cassert>
const char *LINK_NAME =
#if GDEF_OS_LINUX
// Important: must be done before calling gtk_init().
char *loginname;
struct passwd *pw;
- seteuid(getuid());
+ assert(seteuid(getuid()) == 0);
if (geteuid() == 0 && (loginname = getlogin()) != 0 &&
(pw = getpwnam(loginname)) != 0) {
- setuid(pw->pw_uid);
+ assert(setuid(pw->pw_uid) == 0);
}
args_init(argc, argv);
#include <gdk/gdkkeysyms.h>
#include <uilib/uilib.h>
+#include <cassert>
#include "os/path.h"
#include "math/aabb.h"
void *old_filename;
rewind(f);
- fread(buf, 1, len, f);
+ assert(fread(buf, 1, len, f));
gtk_window_set_title(text_editor, filename);
class PatchFilterWrapper : public Filter {
- bool m_active;
+ bool m_active = false;
bool m_invert;
PatchFilter &m_filter;
public:
please contact Id Software immediately at info@idsoftware.com.
*/
+#include <cassert>
#include "points.h"
#include "debugging/debugging.h"
return -1;
}
- fread(*bufferptr, 1, len, f);
+ assert(fread(*bufferptr, 1, len, f));
fclose(f);
// we need to end the buffer with a 0
void CGameDialog::CreateGlobalFrame(PreferencesPage &page)
{
std::vector<const char *> games;
- games.reserve(mGames.size());
+ games.reserve(mGames.size() + 1);
for (std::list<CGameDescription *>::iterator i = mGames.begin(); i != mGames.end(); ++i) {
games.push_back((*i)->getRequiredKeyValue("name"));
}
+ games.push_back(nullptr);
page.appendCombo(
"Select the game",
- StringArrayRange(&(*games.begin()), &(*games.end())),
+ StringArrayRange(&(*games.begin()), &(*--games.end())),
make_property<CGameDialog_GameFile>(*this)
);
page.appendCheckBox("Startup", "Show Global Preferences", m_bGamePrompt);
#include <uilib/uilib.h>
#include <gdk/gdkkeysyms.h>
+#include <cassert>
#include "generic/callback.h"
#include "string/string.h"
m_ix = 1;
m_iy = 2;
break;
+ default:
+ assert(false);
}
Vector3 min, max;
#include "globaldefs.h"
#include <stdio.h>
+#include <assert.h>
#include "cmdlib.h"
#include "mathlib.h"
#include "polyset.h"
for ( i = 0; i < count; ++i ) {
int j;
- fread( &tri, sizeof( tf_triangle ), 1, input );
+ assert(fread( &tri, sizeof( tf_triangle ), 1, input ));
ByteSwapTri( &tri );
for ( j = 0 ; j < 3 ; j++ )
{
iLevel = 0;
- fread( &magic, sizeof( int ), 1, input );
+ assert(fread( &magic, sizeof( int ), 1, input ));
if ( BigLong( magic ) != MAGIC ) {
Error( "%s is not a Alias object separated triangle file, magic number is wrong.", filename );
}
/* a file, but this does allow you to do error checking */
/* (which I'm not doing) on a per character basis. */
++i;
- fread( &( name[i] ), sizeof( char ), 1, input );
+ assert(fread( &( name[i] ), sizeof( char ), 1, input ));
} while ( name[i] != '\0' );
if ( i != 0 ) {
// indent();
// fprintf(stdout,"OBJECT START: %s\n",name);
- fread( &count, sizeof( int ), 1, input );
+ assert(fread( &count, sizeof( int ), 1, input ));
count = BigLong( count );
++iLevel;
if ( count != 0 ) {
i = -1;
do {
++i;
- fread( &( tex[i] ), sizeof( char ), 1, input );
+ assert(fread( &( tex[i] ), sizeof( char ), 1, input ));
} while ( tex[i] != '\0' );
/*
i = -1;
do {
++i;
- fread( &( name[i] ), sizeof( char ), 1, input );
+ assert(fread( &( name[i] ), sizeof( char ), 1, input ));
} while ( name[i] != '\0' );
if ( i != 0 ) {
do
{
- fread( &buffer[i], 1, sizeof( char ), fp );
+ assert(fread( &buffer[i], 1, sizeof( char ), fp ));
bytesRead++;
} while ( buffer[i++] != 0 );
buffer[i] = 0;
switch ( chunkID )
{
case _3DS_CHUNK_MAT_MAPNAME:
- fread( buffer, chunkLen - 6, 1, fp );
+ assert(fread( buffer, chunkLen - 6, 1, fp ));
break;
default:
- fread( s_buffer, chunkLen - 6, 1, fp );
+ assert(fread( s_buffer, chunkLen - 6, 1, fp ));
break;
}
bytesRead += chunkLen;
switch ( chunkID )
{
case _3DS_CHUNK_MAT_NAME:
- fread( mat.name, chunkLen - 6, 1, fp );
+ assert(fread( mat.name, chunkLen - 6, 1, fp ));
if ( s_verbose ) {
printf( " found mat name '%s'\n", mat.name );
}
}
break;
default:
- fread( s_buffer, chunkLen - 6, 1, fp );
+ assert(fread( s_buffer, chunkLen - 6, 1, fp ));
break;
}
ReadString( fp, mmg.name );
- fread( &mmg.numFaces, sizeof( mmg.numFaces ), 1, fp );
+ assert(fread( &mmg.numFaces, sizeof( mmg.numFaces ), 1, fp ));
mmg.pFaces = malloc( sizeof( mmg.pFaces[0] ) * mmg.numFaces );
- fread( mmg.pFaces, sizeof( mmg.pFaces[0] ), mmg.numFaces, fp );
+ assert(fread( mmg.pFaces, sizeof( mmg.pFaces[0] ), mmg.numFaces, fp ));
if ( s_verbose ) {
printf( " >>> MESH MATERIAL GROUP '%s' (%d faces)\n", mmg.name, mmg.numFaces );
numMeshMaterialGroups++;
break;
case _3DS_CHUNK_FACE_ARRAY:
- fread( &triObj.numFaces, sizeof( triObj.numFaces ), 1, fp );
+ assert(fread( &triObj.numFaces, sizeof( triObj.numFaces ), 1, fp ));
assert( triObj.pFaces == 0 );
triObj.pFaces = malloc( sizeof( triObj.pFaces[0] ) * triObj.numFaces );
- fread( triObj.pFaces, sizeof( triObj.pFaces[0] ), triObj.numFaces, fp );
+ assert(fread( triObj.pFaces, sizeof( triObj.pFaces[0] ), triObj.numFaces, fp ));
bytesRead += sizeof( triObj.numFaces ) + triObj.numFaces * sizeof( triObj.pFaces[0] ) + 6;
if ( s_verbose ) {
break;
case _3DS_CHUNK_POINT_ARRAY:
- fread( &triObj.numPoints, sizeof( triObj.numPoints ), 1, fp );
+ assert(fread( &triObj.numPoints, sizeof( triObj.numPoints ), 1, fp ));
triObj.pPoints = malloc( sizeof( triObj.pPoints[0] ) * triObj.numPoints );
- fread( triObj.pPoints, sizeof( triObj.pPoints[0] ), triObj.numPoints, fp );
+ assert(fread( triObj.pPoints, sizeof( triObj.pPoints[0] ), triObj.numPoints, fp ));
bytesRead += sizeof( triObj.numPoints ) + triObj.numPoints * sizeof( triObj.pPoints[0] ) + 6;
// flip points around into our coordinate system
}
break;
case _3DS_CHUNK_TEX_VERTS:
- fread( &triObj.numTexVerts, sizeof( triObj.numTexVerts ), 1, fp );
+ assert(fread( &triObj.numTexVerts, sizeof( triObj.numTexVerts ), 1, fp ));
triObj.pTexVerts = malloc( sizeof( triObj.pTexVerts[0] ) * triObj.numTexVerts );
- fread( triObj.pTexVerts, sizeof( triObj.pTexVerts[0] ), triObj.numTexVerts, fp );
+ assert(fread( triObj.pTexVerts, sizeof( triObj.pTexVerts[0] ), triObj.numTexVerts, fp ));
bytesRead += sizeof( triObj.numTexVerts ) + sizeof( triObj.pTexVerts[0] ) * triObj.numTexVerts + 6;
if ( s_verbose ) {
}
break;
default:
- fread( s_buffer, chunkLen - 6, 1, fp );
+ assert(fread( s_buffer, chunkLen - 6, 1, fp ));
bytesRead += chunkLen;
break;
}
numTriObjects++;
break;
default:
- fread( s_buffer, chunkLen - 6, 1, fp );
+ assert(fread( s_buffer, chunkLen - 6, 1, fp ));
break;
}
break;
case _3DS_CHUNK_MESH_VERSION:
default:
- fread( s_buffer, chunkLen - 6, 1, fp );
+ assert(fread( s_buffer, chunkLen - 6, 1, fp ));
break;
}
LoadEditChunk( fp, chunkLen - 6, &editChunk );
break;
case _3DS_CHUNK_KEYFRAME_DATA:
- fread( s_buffer, chunkLen - 6, 1, fp );
+ assert(fread( s_buffer, chunkLen - 6, 1, fp ));
break;
default:
- fread( s_buffer, chunkLen - 6, 1, fp );
+ assert(fread( s_buffer, chunkLen - 6, 1, fp ));
break;
}
}
hypotSide = 2;
origin = 1;
}
+ else {
+ assert(0);
+ }
len[hypotSide] = -1;
if ( len[0] > len[1] && len[0] > len[2] ) {
else if ( len[2] > len[0] && len[2] > len[1] ) {
longestSide = 2;
}
+ else {
+ assert(0);
+ }
len[longestSide] = -1;
if ( len[0] > len[1] && len[0] > len[2] ) {
else if ( len[2] > len[0] && len[2] > len[1] ) {
shortestSide = 2;
}
+ else {
+ assert(0);
+ }
len[shortestSide] = -1;
fileSize = filelength( fp );
_buffer = malloc( fileSize );
- fread( _buffer, fileSize, 1, fp );
+ assert(fread( _buffer, fileSize, 1, fp ));
fclose( fp );
buffer = ( char * ) _buffer;
}
len = Q_filelength( f );
s_soundtrack = malloc( len );
- fread( s_soundtrack, 1, len, f );
+ assert(fread( s_soundtrack, 1, len, f ));
fclose( f );
s_wavinfo = GetWavinfo( name, s_soundtrack, len );
static void SetCloneModelNumbers( void ){
int i, j;
int models;
- char modelValue[ 10 ];
+ char modelValue[ 12 ];
const char *value, *value2, *value3;
*/
void PseudoCompileBSP( qboolean need_tree, const char *BSPFilePath, const char *surfaceFilePath ){
int models;
- char modelValue[10];
+ char modelValue[12];
entity_t *entity;
face_t *faces;
tree_t *tree;
/* multiply by texture color */
if ( !RadSampleImage( si->lightImage->pixels, si->lightImage->width, si->lightImage->height, rw->verts[ samples ].st, textureColor ) ) {
VectorCopy( si->averageColor, textureColor );
- textureColor[ 4 ] = 255.0f;
+ textureColor[ 3 ] = 255.0f;
}
for ( i = 0; i < 3; i++ )
color[ i ] = ( textureColor[ i ] / 255 ) * ( rw->verts[ samples ].color[ lightmapNum ][ i ] / 255.0f );
/* multiply by texture color */
if ( !RadSampleImage( si->lightImage->pixels, si->lightImage->width, si->lightImage->height, st, textureColor ) ) {
VectorCopy( si->averageColor, textureColor );
- textureColor[ 4 ] = 255;
+ textureColor[ 3 ] = 255;
}
for ( i = 0; i < 3; i++ )
color[ i ] = ( textureColor[ i ] / 255 ) * ( radLuxel[ i ] / 255 );
/* dependencies */
+#include <assert.h>
#include "q3map2.h"
}
else {
Sys_FPrintf( SYS_WRN, "WARNING: Spurious lightmap S vector\n" );
+ assert(0);
}
- VectorSubtract( origin2, origin, originVecs[ 0 ] );
+ VectorSubtract(origin2, origin, originVecs[0]);
//% VectorSubtract( normal2, normal, normalVecs[ 0 ] );
/* calulate y vector */
}
else {
Sys_FPrintf( SYS_WRN, "WARNING: Spurious lightmap T vector\n" );
+ assert(0);
}
VectorSubtract( origin2, origin, originVecs[ 1 ] );
node_t *headnode;
entity_t *e, *tripped;
const char *value;
- int tripcount;
+ int tripcount = 0;
headnode = tree->headnode;
/* dependencies */
+#include <assert.h>
#include "q3map2.h"
/* determine error squared */
VectorSubtract( color, si->averageColor, delta );
- delta[ 3 ] = color[ 3 ] - si->averageColor[ 3 ];
+ delta[ 3 ] = color[ 3 ] - 255;
dist = delta[ 0 ] * delta[ 0 ] + delta[ 1 ] * delta[ 1 ] + delta[ 2 ] * delta[ 2 ] + delta[ 3 ] * delta[ 3 ];
if ( dist < bestDist ) {
si->stFlat[ 0 ] = st[ 0 ];
}
}
-
-
+#define snprintf_ignore(s, n, format, ...) do { \
+ size_t __n = snprintf(s, n, format, __VA_ARGS__); \
+ if (__n >= n) { assert(0); } /* truncated, ignore */ \
+} while (0)
/*
ParseShaderFile()
si->implicitMap = IM_OPAQUE;
GetTokenAppend( shaderText, qfalse );
if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) {
- sprintf( si->implicitImagePath, "%s.tga", si->shader );
+ snprintf_ignore( si->implicitImagePath, sizeof si->implicitImagePath, "%s.tga", si->shader );
}
else{
strcpy( si->implicitImagePath, token );
si->implicitMap = IM_MASKED;
GetTokenAppend( shaderText, qfalse );
if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) {
- sprintf( si->implicitImagePath, "%s.tga", si->shader );
+ snprintf_ignore( si->implicitImagePath, sizeof si->implicitImagePath, "%s.tga", si->shader );
}
else{
strcpy( si->implicitImagePath, token );
si->implicitMap = IM_MASKED;
GetTokenAppend( shaderText, qfalse );
if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) {
- sprintf( si->implicitImagePath, "%s.tga", si->shader );
+ snprintf_ignore( si->implicitImagePath, sizeof si->implicitImagePath, "%s.tga", si->shader );
}
else{
strcpy( si->implicitImagePath, token );
/* use top image as sky light image */
if ( si->lightImagePath[ 0 ] == '\0' ) {
- sprintf( si->lightImagePath, "%s_up.tga", si->skyParmsImageBase );
+ snprintf_ignore( si->lightImagePath, sizeof si->lightImagePath, "%s_up.tga", si->skyParmsImageBase );
}
}
/* dependencies */
+#include <assert.h>
#include "q3map2.h"
#define snprintf_ignore(s, n, format, ...) do { \
size_t __n = snprintf(s, n, format, __VA_ARGS__); \
- if (n >= n) {} /* truncated, ignore */ \
+ if (__n >= n) { assert(0); } /* truncated, ignore */ \
} while (0)
/*
edge->kingpinLength = edge->edge[ edge->kingpin ];
VectorNormalize( edge->edge, edge->edge );
- edge->edge[ 3 ] = DotProduct( a, edge->edge );
- edge->length = DotProduct( b, edge->edge ) - edge->edge[ 3 ];
+ edge->length = DotProduct( b, edge->edge ) - DotProduct( a, edge->edge );
/* create perpendicular plane that edge lies in */
CrossProduct( plane, edge->edge, edge->plane );
void SetModelNumbers( void ){
int i;
int models;
- char value[10];
+ char value[12];
models = 1;
for ( i = 1 ; i < numEntities ; i++ ) {