addflags_c("-Wno-deprecated-declarations") # vfs.c: g_strdown
-addflags("-Wno-sign-compare")
addflags("-Wno-unused-function")
addflags("-Wno-unused-variable")
addflags("-Wno-unused-parameter")
std::size_t l = strlen( buf );
char* out = buf2;
- for ( int i = 0 ; i < l ; i++ )
+ for ( std::size_t i = 0 ; i < l ; i++ )
{
if ( buf[i] == '\n' ) {
*out++ = '\r';
}
void CPortalsDrawSolidOutline::render( RenderStateFlags state ) const {
- for ( int n = 0; n < portals.portal_count; n++ )
+ for ( unsigned int n = 0; n < portals.portal_count; n++ )
{
if ( portals.lines == 2 && !portals.portal[n].hint ) {
continue;
if ( clip.min[0] < portals.portal[n].min[0] ) {
continue;
}
- else if ( clip.min[1] < portals.portal[n].min[1] ) {
+ if ( clip.min[1] < portals.portal[n].min[1] ) {
continue;
}
- else if ( clip.min[2] < portals.portal[n].min[2] ) {
+ if ( clip.min[2] < portals.portal[n].min[2] ) {
continue;
}
- else if ( clip.max[0] > portals.portal[n].max[0] ) {
+ if ( clip.max[0] > portals.portal[n].max[0] ) {
continue;
}
- else if ( clip.max[1] > portals.portal[n].max[1] ) {
+ if ( clip.max[1] > portals.portal[n].max[1] ) {
continue;
}
- else if ( clip.max[2] > portals.portal[n].max[2] ) {
+ if ( clip.max[2] > portals.portal[n].max[2] ) {
continue;
}
}
glBegin( GL_LINE_LOOP );
- for ( int p = 0; p < portals.portal[n].point_count; p++ )
+ for ( unsigned int p = 0; p < portals.portal[n].point_count; p++ )
glVertex3fv( portals.portal[n].inner_point[p].p );
glEnd();
#define TYPE_CONSTANT( name, value, type ) struct name ## _CONSTANT_ { typedef type Value; static Value evaluate() { return value; } }; typedef ConstantWrapper<name ## _CONSTANT_> name
#define STRING_CONSTANT( name, value ) TYPE_CONSTANT ( name, value, const char* )
#define INTEGER_CONSTANT( name, value ) TYPE_CONSTANT ( name, value, int )
+#define UINT_CONSTANT( name, value ) TYPE_CONSTANT ( name, value, unsigned int )
STRING_CONSTANT( EmptyString, "" );
Safe strncpy that ensures a trailing zero
=============
*/
-void Q_strncpyz( char *dest, const char *src, int destsize ) {
+void Q_strncpyz( char *dest, const char *src, std::size_t destsize ) {
if ( !src ) {
Com_Error( ERR_FATAL, "Q_strncpyz: NULL src" );
}
// never goes past bounds or leaves without a terminating 0
-void Q_strcat( char *dest, int size, const char *src ) {
- int l1;
-
- l1 = strlen( dest );
+void Q_strcat( char *dest, std::size_t size, const char *src ) {
+ auto l1 = strlen( dest );
if ( l1 >= size ) {
Com_Error( ERR_FATAL, "Q_strcat: already overflowed" );
}
}
-void QDECL Com_sprintf( char *dest, int size, const char *fmt, ... ) {
- int len;
+void QDECL Com_sprintf( char *dest, std::size_t size, const char *fmt, ... ) {
va_list argptr;
char bigbuffer[32000]; // big, but small enough to fit in PPC stack
va_start( argptr,fmt );
- len = vsprintf( bigbuffer,fmt,argptr );
+ int ret = vsprintf( bigbuffer,fmt,argptr );
va_end( argptr );
+ if ( ret < 0 ) {
+ Com_Error(ERR_FATAL, "Com_sprintf: vsprintf failed");
+ }
+ auto len = static_cast<size_t>(ret);
if ( len >= sizeof( bigbuffer ) ) {
Com_Error( ERR_FATAL, "Com_sprintf: overflowed bigbuffer" );
}
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
+#include <cstddef>
+
#ifdef WIN32 // mac doesn't have malloc.h
#include <malloc.h> // for _alloca()
#endif
extern "C" {
#endif
-void QDECL Com_sprintf( char *dest, int size, const char *fmt, ... );
+void QDECL Com_sprintf( char *dest, std::size_t size, const char *fmt, ... );
// mode parm for FS_FOpenFile
char *Q_strrchr( const char* string, int c );
// buffer size safe library replacements
-void Q_strncpyz( char *dest, const char *src, int destsize );
-void Q_strcat( char *dest, int size, const char *src );
+void Q_strncpyz( char *dest, const char *src, std::size_t destsize );
+void Q_strcat( char *dest, std::size_t size, const char *src );
// strlen that discounts Quake color sequences
int Q_PrintStrlen( const char *string );
int ofs_position = -1, ofs_st = -1, ofs_normal = -1;
PointerInputStream vaStream (buffer + header.ofs_vertexarrays);
- for (int i = 0; i < header.num_vertexarrays; i++)
+ for (unsigned int i = 0; i < header.num_vertexarrays; i++)
{
iqmvertexarray_t va;
istream_read_iqmVertexarray (vaStream, va);
}
PointerInputStream triangleStream(buffer + header.ofs_triangles);
- for(int i = 0; i < header.num_triangles; ++i)
+ for(unsigned int i = 0; i < header.num_triangles; ++i)
{
iqmTriangle_t triangle;
istream_read_iqmTriangle(triangleStream, triangle);
public:
typedef MapFormat Type;
STRING_CONSTANT( Name, "mapdoom3" );
-INTEGER_CONSTANT( MapVersion, 2 );
+UINT_CONSTANT( MapVersion, 2 );
MapDoom3API( MapDoom3Dependencies& dependencies ) : m_dependencies( dependencies ){
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "doom3 maps", "*.map" ) );
public:
typedef MapFormat Type;
STRING_CONSTANT( Name, "mapquake4" );
-INTEGER_CONSTANT( MapVersion, 3 );
+UINT_CONSTANT( MapVersion, 3 );
MapQuake4API( MapDoom3Dependencies& dependencies ) : m_dependencies( dependencies ){
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake4 maps", "*.map" ) );
// vPos[1] = aabb.origin;
// vPos[2] = vector3_added(aabb.origin, aabb.extents);
- int i, j;
float f = 1 / cos( M_PI / n );
- for ( i = 0; i < width; ++i )
+ for ( std::size_t i = 0; i < width; ++i )
{
float angle = ( M_PI * i ) / n; // 0 to 2pi
float x = vPos[1][0] + ( vPos[2][0] - vPos[1][0] ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f );
float y = vPos[1][1] + ( vPos[2][1] - vPos[1][1] ) * sin( angle ) * ( ( i & 1 ) ? f : 1.0f );
- for ( j = 0; j < height; ++j )
+ for ( std::size_t j = 0; j < height; ++j )
{
float z = vPos[0][2] + ( vPos[2][2] - vPos[0][2] ) * ( j / (float)( height - 1 ) );
PatchControl *v;
// vPos[1] = aabb.origin;
// vPos[2] = vector3_added(aabb.origin, aabb.extents);
- int i, j;
float f = 1 / cos( M_PI / n );
- for ( i = 0; i < width; ++i )
+ for ( std::size_t i = 0; i < width; ++i )
{
float angle = ( M_PI * i ) / n;
- for ( j = 0; j < height; ++j )
+ for ( std::size_t j = 0; j < height; ++j )
{
float x = vPos[1][0] + ( 1.0f - ( j / (float)( height - 1 ) ) ) * ( vPos[2][0] - vPos[1][0] ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f );
float y = vPos[1][1] + ( 1.0f - ( j / (float)( height - 1 ) ) ) * ( vPos[2][1] - vPos[1][1] ) * sin( angle ) * ( ( i & 1 ) ? f : 1.0f );
// vPos[1] = aabb.origin;
// vPos[2] = vector3_added(aabb.origin, aabb.extents);
- int i, j;
float f = 1 / cos( M_PI / n );
float g = 1 / cos( M_PI / ( 2 * m ) );
- for ( i = 0; i < width; ++i )
+ for ( std::size_t i = 0; i < width; ++i )
{
float angle = ( M_PI * i ) / n;
- for ( j = 0; j < height; ++j )
+ for ( std::size_t j = 0; j < height; ++j )
{
float angle2 = ( M_PI * j ) / ( 2 * m );
float x = vPos[1][0] + ( vPos[2][0] - vPos[1][0] ) * sin( angle2 ) * ( ( j & 1 ) ? g : 1.0f ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f );
class RadiantUndoSystem : public UndoSystem
{
-INTEGER_CONSTANT( MAX_UNDO_LEVELS, 1024 );
+UINT_CONSTANT( MAX_UNDO_LEVELS, 1024 );
class Snapshot
{
static void ByteSwapTri( tf_triangle *tri ){
- int i;
+ unsigned int i;
for ( i = 0 ; i < sizeof( tf_triangle ) / 4 ; i++ )
{
determines opaque brushes in the world and find sky shaders for sunlight calculations
*/
-void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all ){
+void SetupBrushesFlags( unsigned int mask_any, unsigned int test_any, unsigned int mask_all, unsigned int test_all ){
int i, j, b;
unsigned int compileFlags, allCompileFlags;
qboolean inside;
void IlluminateRawLightmap( int num );
void IlluminateVertexes( int num );
-void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all );
+void SetupBrushesFlags( unsigned int mask_any, unsigned int test_any, unsigned int mask_all, unsigned int test_all );
void SetupBrushes( void );
void SetupClusters( void );
qboolean ClusterVisible( int a, int b );