...
 
Commits (1)
......@@ -109,6 +109,9 @@ add_definitions(-DRADIANT_PATCH_VERSION="${NetRadiant_VERSION_PATCH}")
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 ()
......
......@@ -220,7 +220,7 @@ public:
AddSplineControl(control, pSP);
for (int j = 2;; j++) {
char buffer[16];
char buffer[18];
sprintf(buffer, "control%i", j);
e.SpawnString(buffer, NULL, &control);
......
......@@ -20,6 +20,7 @@
#ifndef __DTREE_H__
#define __DTREE_H__
#include <cassert>
#include "qerplugin.h"
#include "signal/isignal.h"
#include "string/string.h"
......@@ -83,7 +84,7 @@ public:
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"
......@@ -66,7 +67,7 @@ bool LoadFile(const char *filename, byte **bufferptr)
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;
......
......@@ -21,6 +21,7 @@
#include <string.h>
#include <math.h>
#include <cassert>
#include "misc.h"
......@@ -244,10 +245,10 @@ void CPortals::Load()
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++) {
......
......@@ -34,9 +34,7 @@ bool LoadExclusionList(char *filename, std::list<Str> *exclusionList)
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++;
......@@ -60,9 +58,7 @@ bool LoadGList(char *filename, ui::ListStore loadlist)
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);
......
......@@ -198,9 +198,9 @@ bool Q_Exec(const char *pCmd, bool bCreateConsole)
// 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;
......
......@@ -69,7 +69,7 @@ bool CBspPortal::Build(char *def)
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);
......
......@@ -151,7 +151,7 @@ inline float istream_read_float32_be( InputStreamType& istream ){
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;
}
......
......@@ -76,11 +76,11 @@ bool Q_Exec( const char *cmd, char *cmdline, const char *, bool, bool waitfor ){
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;
......
......@@ -2173,7 +2173,6 @@ int PicoRemapModel( picoModel_t *model, char *remapFile ){
}
/* remap shader's ambient color */
else if ( !_pico_stricmp( p->token,"ambient" ) ) {
picoColor_t color;
picoVec3_t v;
/* get vector from parser */
......@@ -2182,16 +2181,13 @@ int PicoRemapModel( picoModel_t *model, char *remapFile ){
}
/* 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 */
......@@ -2200,16 +2196,13 @@ int PicoRemapModel( picoModel_t *model, char *remapFile ){
}
/* 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 */
......@@ -2218,9 +2211,7 @@ int PicoRemapModel( picoModel_t *model, char *remapFile ){
}
/* 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 );
......
......@@ -33,6 +33,7 @@
----------------------------------------------------------------------------- */
/* dependencies */
#include <assert.h>
#include "picointernal.h"
#include "globaldefs.h"
......@@ -228,6 +229,7 @@ static picoModel_t *_ms3d_load( PM_PARAMS_LOAD ){
/* get number of vertices */
bufptr = GetWord( bufptr,&numVerts );
assert(bufptr);
ptrToVerts = bufptr;
#ifdef DEBUG_PM_MS3D
......@@ -291,6 +293,7 @@ static picoModel_t *_ms3d_load( PM_PARAMS_LOAD ){
}
/* get number of groups */
bufptr = GetWord( bufptr,&numGroups );
assert(bufptr);
// ptrToGroups = bufptr;
#ifdef DEBUG_PM_MS3D
......@@ -332,6 +335,7 @@ static picoModel_t *_ms3d_load( PM_PARAMS_LOAD ){
/* get triangle index */
bufptr = GetWord( bufptr,(int *)&triangleIndex );
assert(bufptr);
/* get ptr to triangle data */
triangle = (TMsTriangle *)( ptrToTris + ( sizeof( TMsTriangle ) * triangleIndex ) );
......@@ -376,6 +380,7 @@ static picoModel_t *_ms3d_load( PM_PARAMS_LOAD ){
}
/* get number of materials */
bufptr = GetWord( bufptr,&numMaterials );
assert(bufptr);
#ifdef DEBUG_PM_MS3D
printf( "NumMaterials: %d\n",numMaterials );
......
......@@ -43,6 +43,7 @@
#include "file.h"
#include <stdlib.h>
#include <cassert>
#include "str.h"
......@@ -120,7 +121,7 @@ bool save_var( const char *filename, const char *section, const char *key, const
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 );
......
......@@ -22,6 +22,7 @@
#include "xmltextags.h"
#include <string>
#include <cassert>
#include "qerplugin.h"
#include "stream/stringstream.h"
......@@ -155,6 +156,10 @@ bool XmlTagBuilder::AddShaderNode( const char* shader, TextureType textureType,
break;
case TEXTURE:
newnode = xmlNewNode( NULL, (xmlChar*)"texture" );
break;
default:
assert(false);
break;
};
newnode = xmlDocCopyNode( newnode, doc, 1 );
......
......@@ -26,7 +26,7 @@
#include <list>
class EntityFilterWrapper : public Filter {
bool m_active;
bool m_active = false;
bool m_invert;
EntityFilter &m_filter;
public:
......
......@@ -303,7 +303,7 @@ bool MD5Model_parse(Model &model, Tokeniser &tokeniser)
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();
......
......@@ -789,7 +789,7 @@ evaluateTexture(const TextureExpression &texture, const ShaderParameters &params
float evaluateFloat(const ShaderValue &value, const ShaderParameters &params, 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";
}
......
......@@ -558,7 +558,7 @@ void InitDirectory(const char *directory, ArchiveModules &archiveModules)
}
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")) {
......
......@@ -302,7 +302,7 @@ void Brush::buildBRep()
class FaceFilterWrapper : public Filter {
FaceFilter &m_filter;
bool m_active;
bool m_active = false;
bool m_invert;
public:
FaceFilterWrapper(FaceFilter &filter, bool invert) :
......@@ -349,7 +349,7 @@ bool face_filtered(Face &face)
class BrushFilterWrapper : public Filter {
bool m_active;
bool m_active = false;
bool m_invert;
BrushFilter &m_filter;
public:
......
......@@ -142,7 +142,7 @@ bool EntityClassDoom3_parseUnknown(Tokeniser &tokeniser)
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) {
......@@ -196,7 +196,7 @@ void Model_resolveInheritance(const char *name, Model &model)
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];
......@@ -235,7 +235,7 @@ bool EntityClassDoom3_parseModel(Tokeniser &tokeniser)
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();
......@@ -245,11 +245,11 @@ bool EntityClassDoom3_parseModel(Tokeniser &tokeniser)
} 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, ",")) {
......@@ -259,7 +259,7 @@ bool EntityClassDoom3_parseModel(Tokeniser &tokeniser)
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();
......@@ -352,14 +352,14 @@ static bool EntityClass_parse(EntityClass &entityClass, Tokeniser &tokeniser)
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;
......@@ -371,7 +371,7 @@ static bool EntityClass_parse(EntityClass &entityClass, Tokeniser &tokeniser)
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;
......@@ -380,7 +380,7 @@ static bool EntityClass_parse(EntityClass &entityClass, Tokeniser &tokeniser)
}
} 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;
......@@ -456,7 +456,7 @@ static bool EntityClass_parse(EntityClass &entityClass, Tokeniser &tokeniser)
} 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);
}
......@@ -489,7 +489,7 @@ static bool EntityClass_parse(EntityClass &entityClass, Tokeniser &tokeniser)
}
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 "
......
......@@ -197,6 +197,7 @@ bool portable_app_setup()
#include <unistd.h>
#include <glib.h>
#include <cassert>
const char *LINK_NAME =
#if GDEF_OS_LINUX
......@@ -242,10 +243,10 @@ void environment_init(int argc, char const *argv[])
// 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);
......
......@@ -49,6 +49,7 @@
#include <gdk/gdkkeysyms.h>
#include <uilib/uilib.h>
#include <cassert>
#include "os/path.h"
#include "math/aabb.h"
......@@ -788,7 +789,7 @@ static void DoGtkTextEditor(const char *filename, guint cursorpos)
void *old_filename;
rewind(f);
fread(buf, 1, len, f);
assert(fread(buf, 1, len, f));
gtk_window_set_title(text_editor, filename);
......
......@@ -2713,7 +2713,7 @@ void Patch::BuildVertexArray()
class PatchFilterWrapper : public Filter {
bool m_active;
bool m_active = false;
bool m_invert;
PatchFilter &m_filter;
public:
......
......@@ -26,6 +26,7 @@
please contact Id Software immediately at info@idsoftware.com.
*/
#include <cassert>
#include "points.h"
#include "debugging/debugging.h"
......@@ -274,7 +275,7 @@ int LoadFile(const char *filename, void **bufferptr)
return -1;
}
fread(*bufferptr, 1, len, f);
assert(fread(*bufferptr, 1, len, f));
fclose(f);
// we need to end the buffer with a 0
......
......@@ -330,13 +330,14 @@ struct CGameDialog_GameFile {
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);
......
......@@ -43,6 +43,7 @@
#include <uilib/uilib.h>
#include <gdk/gdkkeysyms.h>
#include <cassert>
#include "generic/callback.h"
#include "string/string.h"
......@@ -1545,6 +1546,8 @@ void XYWnd::XY_LoadBackgroundImage(const char *name)
m_ix = 1;
m_iy = 2;
break;
default:
assert(false);
}
Vector3 min, max;
......
......@@ -25,6 +25,7 @@
#include "globaldefs.h"
#include <stdio.h>
#include <assert.h>
#include "cmdlib.h"
#include "mathlib.h"
#include "polyset.h"
......@@ -77,7 +78,7 @@ static void ReadPolysetGeometry( triangle_t *tripool, FILE *input, int count, tr
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++ )
{
......@@ -124,7 +125,7 @@ void TRI_LoadPolysets( const char *filename, polyset_t **ppPSET, int *numpsets )
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 );
}
......@@ -148,7 +149,7 @@ void TRI_LoadPolysets( const char *filename, polyset_t **ppPSET, int *numpsets )
/* 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 ) {
......@@ -161,7 +162,7 @@ void TRI_LoadPolysets( const char *filename, polyset_t **ppPSET, int *numpsets )
// 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 ) {
......@@ -171,7 +172,7 @@ void TRI_LoadPolysets( const char *filename, polyset_t **ppPSET, int *numpsets )
i = -1;
do {
++i;
fread( &( tex[i] ), sizeof( char ), 1, input );
assert(fread( &( tex[i] ), sizeof( char ), 1, input ));
} while ( tex[i] != '\0' );
/*
......@@ -199,7 +200,7 @@ void TRI_LoadPolysets( const char *filename, polyset_t **ppPSET, int *numpsets )
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 ) {
......
......@@ -39,7 +39,7 @@ static int ReadString( FILE *fp, char *buffer ){
do
{
fread( &buffer[i], 1, sizeof( char ), fp );
assert(fread( &buffer[i], 1, sizeof( char ), fp ));
bytesRead++;
} while ( buffer[i++] != 0 );
buffer[i] = 0;
......@@ -67,10 +67,10 @@ static void LoadMapName( FILE *fp, char *buffer, int thisChunkLen ){
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;
......@@ -99,7 +99,7 @@ static void LoadMaterialList( FILE *fp, long thisChunkLen, _3DSMaterial_t *pMat
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 );
}
......@@ -135,7 +135,7 @@ static void LoadMaterialList( FILE *fp, long thisChunkLen, _3DSMaterial_t *pMat
}
break;
default:
fread( s_buffer, chunkLen - 6, 1, fp );
assert(fread( s_buffer, chunkLen - 6, 1, fp ));
break;
}
......@@ -208,9 +208,9 @@ static void LoadMeshMaterialGroup( FILE *fp, long thisChunkLen, _3DSMeshMaterial
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 );
......@@ -253,11 +253,11 @@ static void LoadNamedTriObject( FILE *fp, long thisChunkLen, _3DSTriObject_t *pT
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 ) {
......@@ -270,9 +270,9 @@ static void LoadNamedTriObject( FILE *fp, long thisChunkLen, _3DSTriObject_t *pT
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
......@@ -298,9 +298,9 @@ static void LoadNamedTriObject( FILE *fp, long thisChunkLen, _3DSTriObject_t *pT
}
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 ) {
......@@ -312,7 +312,7 @@ static void LoadNamedTriObject( FILE *fp, long thisChunkLen, _3DSTriObject_t *pT
}
break;
default:
fread( s_buffer, chunkLen - 6, 1, fp );
assert(fread( s_buffer, chunkLen - 6, 1, fp ));
bytesRead += chunkLen;
break;
}
......@@ -371,7 +371,7 @@ static void LoadNamedObject( FILE *fp, long thisChunkLen, _3DSNamedObject_t *pNO
numTriObjects++;
break;
default:
fread( s_buffer, chunkLen - 6, 1, fp );
assert(fread( s_buffer, chunkLen - 6, 1, fp ));
break;
}
......@@ -423,7 +423,7 @@ static void LoadEditChunk( FILE *fp, long thisChunkLen, _3DSEditChunk_t *pEC ){
break;
case _3DS_CHUNK_MESH_VERSION:
default:
fread( s_buffer, chunkLen - 6, 1, fp );
assert(fread( s_buffer, chunkLen - 6, 1, fp ));
break;
}
......@@ -485,10 +485,10 @@ static void Load3DS( const char *filename, _3DS_t *p3DS, qboolean verbose ){
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;
}
}
......
......@@ -85,6 +85,9 @@ void MD3_ComputeTagFromTri( md3Tag_t *pTag, float pTri[3][3] ){
hypotSide = 2;
origin = 1;
}
else {
assert(0);
}
len[hypotSide] = -1;
if ( len[0] > len[1] && len[0] > len[2] ) {
......@@ -96,6 +99,9 @@ void MD3_ComputeTagFromTri( md3Tag_t *pTag, float pTri[3][3] ){
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] ) {
......@@ -107,6 +113,9 @@ void MD3_ComputeTagFromTri( md3Tag_t *pTag, float pTri[3][3] ){
else if ( len[2] > len[0] && len[2] > len[1] ) {
shortestSide = 2;
}
else {
assert(0);
}
len[shortestSide] = -1;
......@@ -154,7 +163,7 @@ void MD3_Dump( const char *filename ){
fileSize = filelength( fp );
_buffer = malloc( fileSize );
fread( _buffer, fileSize, 1, fp );
assert(fread( _buffer, fileSize, 1, fp ));
fclose( fp );
buffer = ( char * ) _buffer;
......
......@@ -249,7 +249,7 @@ void LoadSoundtrack( void ){
}
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 );
......
......@@ -127,7 +127,7 @@ static void ProcessAdvertisements( void ) {
static void SetCloneModelNumbers( void ){
int i, j;
int models;
char modelValue[ 10 ];
char modelValue[ 12 ];
const char *value, *value2, *value3;
......
......@@ -39,7 +39,7 @@
*/
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;
......
......@@ -288,7 +288,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm,
/* 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 );
......@@ -372,7 +372,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm,
/* 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 );
......
......@@ -34,6 +34,7 @@
/* dependencies */
#include <assert.h>
#include "q3map2.h"
......@@ -1742,9 +1743,10 @@ static qboolean SubmapRawLuxel( rawLightmap_t *lm, int x, int y, float bx, float
}
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 */
......@@ -1766,6 +1768,7 @@ static qboolean SubmapRawLuxel( rawLightmap_t *lm, int x, int y, float bx, float
}
else {
Sys_FPrintf( SYS_WRN, "WARNING: Spurious lightmap T vector\n" );
assert(0);
}
VectorSubtract( origin2, origin, originVecs[ 1 ] );
......
......@@ -669,7 +669,7 @@ int FloodEntities( tree_t *tree ){
node_t *headnode;
entity_t *e, *tripped;
const char *value;
int tripcount;
int tripcount = 0;
headnode = tree->headnode;
......
......@@ -34,6 +34,7 @@
/* dependencies */
#include <assert.h>
#include "q3map2.h"
......@@ -719,7 +720,7 @@ void FinishShader( shaderInfo_t *si ){
/* 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 ];
......@@ -956,8 +957,10 @@ void Parse1DMatrixAppend( char *buffer, int x, vec_t *m ){
}
}
#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()
......@@ -1185,7 +1188,7 @@ static void ParseShaderFile( const char *filename ){
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 );
......@@ -1196,7 +1199,7 @@ static void ParseShaderFile( const char *filename ){
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 );
......@@ -1207,7 +1210,7 @@ static void ParseShaderFile( const char *filename ){
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 );
......@@ -1251,7 +1254,7 @@ static void ParseShaderFile( const char *filename ){
/* 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 );
}
}
......
......@@ -34,6 +34,7 @@
/* dependencies */
#include <assert.h>
#include "q3map2.h"
......@@ -783,7 +784,7 @@ byte GetShaderIndexForPoint( indexMap_t *im, vec3_t eMins, vec3_t eMaxs, vec3_t
#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)
/*
......
......@@ -987,8 +987,7 @@ void CreateEdge( vec4_t plane, vec3_t a, vec3_t b, edge_t *edge ){
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 );
......
......@@ -254,7 +254,7 @@ int EmitDrawNode_r( node_t *node ){
void SetModelNumbers( void ){
int i;
int models;
char value[10];
char value[12];
models = 1;
for ( i = 1 ; i < numEntities ; i++ ) {
......