...
 
Commits (3)
......@@ -82,6 +82,12 @@ endif ()
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
addflags("-Werror")
addflags("-pedantic-errors")
set(CMAKE_VERBOSE_MAKEFILE ON)
addflags(-fstack-protector -fstack-protector-strong -fstack-protector-all)
#addflags("-fsanitize=address,undefined") # break __asan::ReportGenericError
#add_definitions(-D_GLIBCXX_DEBUG=1)
#add_definitions(-D_GLIBCXX_DEBUG_PEDANTIC=1)
endif ()
addflags("-Wall")
......@@ -89,6 +95,7 @@ addflags("-Wextra")
addflags("-pedantic")
addflags_c("-Wno-deprecated-declarations") # vfs.c: g_strdown
addflags_cxx("-Wno-deprecated-declarations") # various gtk
addflags("-Wno-unused-function")
addflags("-Wno-unused-variable")
......@@ -249,7 +256,7 @@ endif ()
# Game packs
#-----------------------------------------------------------------------
option(DOWNLOAD_GAMEPACKS "Download game packs" ON)
option(DOWNLOAD_GAMEPACKS "Download game packs" OFF)
add_custom_target(game_packs_free
COMMAND ${CMAKE_COMMAND} -E make_directory games
COMMAND DOWNLOAD_GAMEPACKS=yes SOURCE_DIR="${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/install-gamepacks.sh" "${PROJECT_BINARY_DIR}"
......
......@@ -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;
......
......@@ -214,7 +214,7 @@ std::list<DWinding *> *CreateTrace(dleaf_t *leaf, int c, vis_header *header, byt
}
}
delete repeatlist;
delete[] repeatlist;
return pointlist;
}
......
......@@ -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);
......
......@@ -90,13 +90,11 @@ public:
};
class ForEachFace : public BrushVisitor {
Brush &m_brush;
public:
mutable int m_contentFlagsVis;
mutable int m_surfaceFlagsVis;
ForEachFace(Brush &brush)
: m_brush(brush)
ForEachFace()
{
m_contentFlagsVis = -1;
m_surfaceFlagsVis = -1;
......@@ -140,7 +138,7 @@ public:
{
Brush *brush = Node_getBrush(path.top());
if (brush != 0) {
ForEachFace faces(*brush);
ForEachFace faces{};
brush->forEachFace(faces);
// contentflags?
if (m_content) {
......
......@@ -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;
......
......@@ -182,7 +182,7 @@ inline ub4 hash(
const UB1Traits& ub1traits,
const UB4x1Traits& ub4x1traits
){
register ub4 a,b,c,len;
ub4 a,b,c,len;
/* Set up the internal state */
len = length;
......@@ -203,17 +203,17 @@ inline ub4 hash(
c += length;
switch ( len ) /* all the case statements fall through */
{
case 11: c += ( ( ub4 ) UB1Traits::as_ub1( k[10] ) << 24 ); __attribute((fallthrough));
case 10: c += ( ( ub4 ) UB1Traits::as_ub1( k[9] ) << 16 ); __attribute((fallthrough));
case 9: c += ( ( ub4 ) UB1Traits::as_ub1( k[8] ) << 8 ); __attribute((fallthrough));
case 11: c += ( ( ub4 ) UB1Traits::as_ub1( k[10] ) << 24 ); [[clang::fallthrough]];
case 10: c += ( ( ub4 ) UB1Traits::as_ub1( k[9] ) << 16 ); [[clang::fallthrough]];
case 9: c += ( ( ub4 ) UB1Traits::as_ub1( k[8] ) << 8 ); [[clang::fallthrough]];
/* the first byte of c is reserved for the length */
case 8: b += ( ( ub4 ) UB1Traits::as_ub1( k[7] ) << 24 ); __attribute((fallthrough));
case 7: b += ( ( ub4 ) UB1Traits::as_ub1( k[6] ) << 16 ); __attribute((fallthrough));
case 6: b += ( ( ub4 ) UB1Traits::as_ub1( k[5] ) << 8 ); __attribute((fallthrough));
case 5: b += UB1Traits::as_ub1( k[4] ); __attribute((fallthrough));
case 4: a += ( ( ub4 ) UB1Traits::as_ub1( k[3] ) << 24 ); __attribute((fallthrough));
case 3: a += ( ( ub4 ) UB1Traits::as_ub1( k[2] ) << 16 ); __attribute((fallthrough));
case 2: a += ( ( ub4 ) UB1Traits::as_ub1( k[1] ) << 8 ); __attribute((fallthrough));
case 8: b += ( ( ub4 ) UB1Traits::as_ub1( k[7] ) << 24 ); [[clang::fallthrough]];
case 7: b += ( ( ub4 ) UB1Traits::as_ub1( k[6] ) << 16 ); [[clang::fallthrough]];
case 6: b += ( ( ub4 ) UB1Traits::as_ub1( k[5] ) << 8 ); [[clang::fallthrough]];
case 5: b += UB1Traits::as_ub1( k[4] ); [[clang::fallthrough]];
case 4: a += ( ( ub4 ) UB1Traits::as_ub1( k[3] ) << 24 ); [[clang::fallthrough]];
case 3: a += ( ( ub4 ) UB1Traits::as_ub1( k[2] ) << 16 ); [[clang::fallthrough]];
case 2: a += ( ( ub4 ) UB1Traits::as_ub1( k[1] ) << 8 ); [[clang::fallthrough]];
case 1: a += UB1Traits::as_ub1( k[0] );
/* case 0: nothing left to add */
}
......@@ -240,7 +240,7 @@ inline ub4 hash2(
ub4 initval, /* the previous hash, or an arbitrary value */
const UB4Traits& ub4traits
){
register ub4 a,b,c,len;
ub4 a,b,c,len;
/* Set up the internal state */
len = length;
......
......@@ -207,7 +207,7 @@ void instantiate(){
Test test;
const Test& testconst = test;
{
Callback<void()> a = makeCallbackF(&test0free);
Callback<void()> a = makeCallbackF(test0free);
Callback<void()> b = Test::Test0Caller( test );
b = makeCallback( Test::Test0(), test );
Callback<void()> c = Test::Test0ConstCaller( testconst );
......@@ -221,7 +221,7 @@ void instantiate(){
}
{
typedef Callback<void(A1)> TestCallback1;
TestCallback1 a = makeCallbackF(&test1free);
TestCallback1 a = makeCallbackF(test1free);
TestCallback1 b = Test::Test1Caller( test );
b = makeCallback( Test::Test1(), test );
TestCallback1 c = Test::Test1ConstCaller( testconst );
......
......@@ -70,54 +70,36 @@ namespace detail {
namespace detail {
template<class Type>
struct ConvertFromOpaque {
struct ConvertToOpaque {
};
// reference
template<class Type>
struct ConvertFromOpaque {
};
template<class T>
inline const void *convertToOpaque(const T &t) {
return &t;
}
// pointer
template<class T>
struct ConvertFromOpaque<const T &> {
static T const &apply(void *p) {
return *static_cast<const T *>(p);
struct ConvertToOpaque<T const *> {
static void const *apply(const T *t) {
return t;
}
};
template<class T>
inline void *convertToOpaque(T &t) {
return &t;
}
template<class T>
struct ConvertFromOpaque<T &> {
static T &apply(void *p) {
return *static_cast<T *>( p );
struct ConvertFromOpaque<T const *> {
static T const *apply(void const *p) {
return static_cast<T const *>(p);
}
};
// pointer
template<class T>
inline const void *convertToOpaque(const T *t) {
return t;
}
template<class T>
struct ConvertFromOpaque<const T *> {
static const T *apply(void *p) {
return static_cast<const T *>(p);
struct ConvertToOpaque<T *> {
static void *apply(T *t) {
return t;
}
};
template<class T>
inline void *convertToOpaque(T *t) {
return t;
}
template<class T>
struct ConvertFromOpaque<T *> {
static T *apply(void *p) {
......@@ -125,35 +107,35 @@ namespace detail {
}
};
// function pointer
template<class R, class... Ts>
inline const void *convertToOpaque(R(*const &t)(Ts...)) {
return &t;
}
template<class R, class... Ts>
struct ConvertFromOpaque<R(*const &)(Ts...)> {
using Type = R(*)(Ts...);
// reference
static Type const &apply(void *p) {
return *static_cast<Type *>(p);
template<class T>
struct ConvertToOpaque<T const &> {
static void const *apply(T const &t) {
return &t;
}
};
template<class R, class... Ts>
inline void *convertToOpaque(R(*&t)(Ts...)) {
return &t;
}
template<class T>
struct ConvertFromOpaque<T const &> {
static T const &apply(void const *p) {
return *static_cast<T const *>(p);
}
};
template<class R, class... Ts>
struct ConvertFromOpaque<R(*&)(Ts...)> {
using Type = R(*)(Ts...);
template<class T>
struct ConvertToOpaque<T &> {
static void *apply(T &t) {
return &t;
}
};
static Type &apply(void *p) {
return *static_cast<Type *>(p);
}
};
template<class T>
struct ConvertFromOpaque<T &> {
static T &apply(void *p) {
return *static_cast<T *>( p );
}
};
template<class Caller, class F>
class BindFirstOpaqueN;
......@@ -182,7 +164,7 @@ namespace detail {
}
void *getEnvironment() const {
return const_cast<void *>(detail::convertToOpaque(firstBound));
return const_cast<void *>(detail::ConvertToOpaque<FirstBound>::apply(firstBound));
}
};
......
......@@ -122,4 +122,24 @@
#endif
#endif
#define CPP_CAT_(a, b) a ## b
#define CPP_CAT(a, b) CPP_CAT_(a, b)
#define CPP_STR_(x) #x
#define CPP_STR(x) CPP_STR_(x)
#define WARNING_SUPPRESS(x) \
_Pragma (CPP_STR(GCC diagnostic push)) \
_Pragma (CPP_STR(GCC diagnostic ignored CPP_STR(CPP_CAT(-W,x))))
#define WARNING_RESTORE(x) \
_Pragma (CPP_STR(GCC diagnostic pop))
#if defined(__clang__)
#define WARNING_SUPPRESS_CLANG(x) WARNING_SUPPRESS(x)
#define WARNING_RESTORE_CLANG(x) WARNING_RESTORE(x)
#else
#define WARNING_SUPPRESS_CLANG(x)
#define WARNING_RESTORE_CLANG(x)
#endif
#endif
......@@ -30,14 +30,14 @@
GdkCursor *create_blank_cursor()
{
return gdk_cursor_new(GDK_BLANK_CURSOR);
return gdk_cursor_new_for_display(gdk_display_get_default(), GDK_BLANK_CURSOR);
}
void blank_cursor(ui::Widget widget)
{
GdkCursor *cursor = create_blank_cursor();
gdk_window_set_cursor(gtk_widget_get_window(widget), cursor);
gdk_cursor_unref(cursor);
g_object_unref(cursor);
}
void default_cursor(ui::Widget widget)
......
......@@ -56,8 +56,10 @@ create_dialog_table(unsigned int rows, unsigned int columns, unsigned int row_sp
{
auto table = ui::Table(rows, columns, FALSE);
table.show();
WARNING_SUPPRESS(deprecated-declarations)
gtk_table_set_row_spacings(table, row_spacing);
gtk_table_set_col_spacings(table, col_spacing);
WARNING_RESTORE(deprecated-declarations)
gtk_container_set_border_width(GTK_CONTAINER(table), border);
return table;
}
......
......@@ -78,7 +78,7 @@ GdkGLContext *glwidget_context_created(ui::GLArea self)
ui::GLArea glwidget_new(bool zbuffer)
{
auto self = ui::GLArea(GTK_GL_AREA(gtk_gl_area_new()));
auto self = ui::GLArea::from(GTK_GL_AREA(gtk_gl_area_new()));
gtk_gl_area_set_has_depth_buffer(self, zbuffer);
gtk_gl_area_set_auto_render(self, false);
......
......@@ -79,7 +79,7 @@ static char my_tcpip_address[NET_NAMELEN];
const int DEFAULTnet_hostport = 26000;
const int MAXHOSTNAMELEN = 256;
#define MAXHOSTNAMELEN 256
static int net_acceptsocket = -1; // socket for fielding new connections
static int net_controlsocket;
......
......@@ -166,7 +166,7 @@ int aabb_test_plane( const aabb_t *aabb, const float *plane ){
from "Graphics Gems", Academic Press, 1990
*/
const int NUMDIM = 3;
#define NUMDIM 3
const int RIGHT = 0;
const int LEFT = 1;
const int MIDDLE = 2;
......
......@@ -1738,7 +1738,7 @@ void m4x4_solve_ge( m4x4_t matrix, vec4_t x ){
#endif
int matrix_solve_ge( vec_t* matrix, vec_t* aug, vec3_t x ){
const int N = 3;
#define N 3
int indx[N];
int c,r;
int i;
......
......@@ -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 );
......
......@@ -444,7 +444,7 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
#endif
continue;
}
else if ( ( p_index_LUT[triangle->index_xyz[j]].next == NULL ) ) { // Not equal to Main entry, and no LL entry
else if ( p_index_LUT[triangle->index_xyz[j]].next == NULL ) { // Not equal to Main entry, and no LL entry
// Add first entry of LL from Main
p_index_LUT2 = (index_LUT_t *)_pico_alloc( sizeof( index_LUT_t ) );
if ( p_index_LUT2 == NULL ) {
......
......@@ -50,7 +50,7 @@ const int MD2_MAX_TRIANGLES = 4096;
const int MD2_MAX_VERTS = 2048;
const int MD2_MAX_FRAMES = 512;
const int MD2_MAX_MD2SKINS = 32;
const int MD2_MAX_SKINNAME = 64;
#define MD2_MAX_SKINNAME 64
typedef struct index_LUT_s
{
......@@ -491,7 +491,7 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
continue;
}
else if ( ( p_index_LUT[p_md2Triangle->index_xyz[j]].next == NULL ) ) { // Not equal to Main entry, and no LL entry
else if ( p_index_LUT[p_md2Triangle->index_xyz[j]].next == NULL ) { // Not equal to Main entry, and no LL entry
// Add first entry of LL from Main
p_index_LUT2 = (index_LUT_t *)_pico_alloc( sizeof( index_LUT_t ) );
if ( p_index_LUT2 == NULL ) {
......
......@@ -33,6 +33,7 @@
----------------------------------------------------------------------------- */
/* dependencies */
#include <assert.h>
#include "picointernal.h"
#include "globaldefs.h"
......@@ -57,7 +58,7 @@ static picoColor_t white = { 255,255,255,255 };
/* ms3d limits */
const int MS3D_MAX_VERTS = 8192;
const int MS3D_MAX_TRIS = 16384;
const int MS3D_MAX_GROUPS = 128;
#define MS3D_MAX_GROUPS 128
const int MS3D_MAX_MATERIALS = 128;
const int MS3D_MAX_JOINTS = 128;
const int MS3D_MAX_KEYFRAMES = 216;
......@@ -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 );
......
......@@ -102,53 +102,55 @@ Property<T> make_property(Self &self) {
// chain
template <class DST, class SRC, class X, class A>
struct PropertyChainImpl {
static void ExportThunk(const Callback<void(DST)> &self, SRC value) {
PropertyImpl<SRC, DST>::Export(value, self);
}
static void Export(const X &self, const Callback<void(DST)> &returnz) {
A::Get::thunk_(self, ConstReferenceCaller<Callback<void(DST)>, void(SRC), ExportThunk>(returnz));
}
static void Import(X &self, DST value) {
SRC out;
PropertyImpl<SRC, DST>::Import(out, value);
A::Set::thunk_(self, out);
}
};
template<class I_Outer, class I_Inner>
Property<detail::propertyimpl_other<I_Outer>> make_property_chain(detail::propertyimpl_self<I_Inner> &it) {
using DST = detail::propertyimpl_other<I_Outer>;
using SRC = detail::propertyimpl_self<I_Outer>;
using X = detail::propertyimpl_self<I_Inner>;
using A = property_impl<I_Inner>;
struct I {
static void ExportThunk(const Callback<void(DST)> &self, SRC value) {
PropertyImpl<SRC, DST>::Export(value, self);
}
static void Export(const X &self, const Callback<void(DST)> &returnz) {
A::Get::thunk_(self, ConstReferenceCaller<Callback<void(DST)>, void(SRC), ExportThunk>(returnz));
}
static void Import(X &self, DST value) {
SRC out;
PropertyImpl<SRC, DST>::Import(out, value);
A::Set::thunk_(self, out);
}
};
return make_property<PropertyAdaptor<X, DST, I>>(it);
return make_property<PropertyAdaptor<X, DST, PropertyChainImpl<DST, SRC, X, A>>>(it);
}
template <class DST, class SRC, class A>
struct PropertyChainImpl_free {
static void ExportThunk(const Callback<void(DST)> &self, SRC value) {
PropertyImpl<SRC, DST>::Export(value, self);
}
static void Export(const Callback<void(DST)> &returnz) {
A::Get::thunk_(nullptr, ConstReferenceCaller<Callback<void(DST)>, void(SRC), ExportThunk>(returnz));
}
static void Import(DST value) {
SRC out;
PropertyImpl<SRC, DST>::Import(out, value);
A::Set::thunk_(nullptr, out);
}
};
template<class I_Outer, class I_Inner>
Property<detail::propertyimpl_other<I_Outer>> make_property_chain() {
using DST = detail::propertyimpl_other<I_Outer>;
using SRC = detail::propertyimpl_self<I_Outer>;
using A = property_impl_free<I_Inner>;
struct I {
static void ExportThunk(const Callback<void(DST)> &self, SRC value) {
PropertyImpl<SRC, DST>::Export(value, self);
}
static void Export(const Callback<void(DST)> &returnz) {
A::Get::thunk_(nullptr, ConstReferenceCaller<Callback<void(DST)>, void(SRC), ExportThunk>(returnz));
}
static void Import(DST value) {
SRC out;
PropertyImpl<SRC, DST>::Import(out, value);
A::Set::thunk_(nullptr, out);
}
};
return make_property<PropertyAdaptorFree<DST, I>>();
return make_property<PropertyAdaptorFree<DST, PropertyChainImpl_free<DST, SRC, A>>>();
}
// specializations
......
......@@ -43,7 +43,7 @@ bool isSelected() const {
}
};
class ObservedSelectable : public Selectable
class ObservedSelectable final : public Selectable
{
SelectionChangeCallback m_onchanged;
bool m_selected;
......
......@@ -146,8 +146,13 @@ inline bool string_equal_prefix( const char* string, const char* prefix ){
/// \brief Returns true if the ending of \p string is equal to \p suffix.
/// O(n)
inline bool string_equal_suffix( const char* string, const char* suffix){
const char *s = string + string_length( string ) - string_length( suffix );
return string_equal_n( s , suffix, string_length( suffix ) );
auto aLen = string_length(string);
auto bLen = string_length(suffix);
if (bLen > aLen) {
return false;
}
const char *s = string + aLen - bLen;
return string_equal_n(s , suffix, bLen);
}
/// \brief Copies \p other into \p string and returns \p string.
......
......@@ -51,7 +51,9 @@ namespace ui {
>::type
>;
WARNING_SUPPRESS_CLANG(keyword-macro)
#define this (verify<self>::test(*static_cast<self>(const_cast<pointer_remove_const<decltype(this)>::type>(this))))
WARNING_RESTORE_CLANG(keyword-macro)
IMPL(Editable, GTK_EDITABLE);
......@@ -180,11 +182,13 @@ namespace ui {
gtk_window_add_accel_group(this, group);
}
WARNING_SUPPRESS(deprecated-declarations)
IMPL(Alignment, GTK_ALIGNMENT);
Alignment::Alignment(float xalign, float yalign, float xscale, float yscale)
: Alignment(GTK_ALIGNMENT(gtk_alignment_new(xalign, yalign, xscale, yscale)))
{}
WARNING_RESTORE(deprecated-declarations)
IMPL(Frame, GTK_FRAME);
......@@ -228,10 +232,12 @@ namespace ui {
GTK_MENU_ITEM((mnemonic ? gtk_menu_item_new_with_mnemonic : gtk_menu_item_new_with_label)(label)))
{}
WARNING_SUPPRESS(deprecated-declarations)
IMPL(TearoffMenuItem, GTK_TEAROFF_MENU_ITEM);
TearoffMenuItem::TearoffMenuItem(ui::New_t) : TearoffMenuItem(GTK_TEAROFF_MENU_ITEM(gtk_tearoff_menu_item_new()))
{}
WARNING_RESTORE(deprecated-declarations)
IMPL(ComboBoxText, GTK_COMBO_BOX_TEXT);
......@@ -260,6 +266,7 @@ namespace ui {
gtk_box_pack_end(this, child, expand, fill, padding);
}
WARNING_SUPPRESS(deprecated-declarations)
IMPL(VBox, GTK_VBOX);
VBox::VBox(bool homogenous, int spacing) : VBox(GTK_VBOX(gtk_vbox_new(homogenous, spacing)))
......@@ -279,12 +286,14 @@ namespace ui {
VPaned::VPaned(ui::New_t) : VPaned(GTK_VPANED(gtk_vpaned_new()))
{}
WARNING_RESTORE(deprecated-declarations)
IMPL(Menu, GTK_MENU);
Menu::Menu(ui::New_t) : Menu(GTK_MENU(gtk_menu_new()))
{}
WARNING_SUPPRESS(deprecated-declarations)
IMPL(Table, GTK_TABLE);
Table::Table(std::size_t rows, std::size_t columns, bool homogenous) : Table(
......@@ -299,6 +308,7 @@ namespace ui {
padding.x, padding.y
);
}
WARNING_RESTORE(deprecated-declarations)
IMPL(TextView, GTK_TEXT_VIEW);
......@@ -358,6 +368,7 @@ namespace ui {
GTK_SPIN_BUTTON(gtk_spin_button_new(adjustment, climb_rate, digits)))
{}
WARNING_SUPPRESS(deprecated-declarations)
IMPL(HScale, GTK_HSCALE);
HScale::HScale(Adjustment adjustment) : HScale(GTK_HSCALE(gtk_hscale_new(adjustment)))
......@@ -365,6 +376,7 @@ namespace ui {
HScale::HScale(double min, double max, double step) : HScale(GTK_HSCALE(gtk_hscale_new_with_range(min, max, step)))
{}
WARNING_RESTORE(deprecated-declarations)
IMPL(Adjustment, GTK_ADJUSTMENT);
......
#ifndef INCLUDED_UILIB_H
#define INCLUDED_UILIB_H
#include "globaldefs.h"
#include <string>
#include <glib-object.h>
......@@ -599,7 +601,9 @@ namespace ui {
}
}
WARNING_SUPPRESS_CLANG(keyword-macro)
#define this (*static_cast<self>(this))
WARNING_RESTORE_CLANG(keyword-macro)
template<class Lambda>
gulong Object::connect(char const *detailed_signal, Lambda &&c_handler, void *data)
......
......@@ -52,6 +52,9 @@ inline int string_range_parse_unsigned_decimal_integer( const char* first, const
int result = 0;
for (; first != last; ++first )
{
if (!isdigit(*first)) {
break;
}
result *= 10;
result += *first - '0';
}
......
......@@ -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 );
......
......@@ -55,7 +55,6 @@ private:
CopiedString m_savefilename;
xmlDocPtr doc;
xmlXPathContextPtr context;
xmlNodeSetPtr nodePtr;
xmlXPathObjectPtr XpathEval( const char* queryString ){
xmlChar* expression = (xmlChar*)queryString;
......
......@@ -26,7 +26,7 @@
#include <list>
class EntityFilterWrapper : public Filter {
bool m_active;
bool m_active = false;
bool m_invert;
EntityFilter &m_filter;
public:
......
......@@ -66,7 +66,7 @@ public:
virtual TreeXMLImporter &child() = 0;
};
class SubPrimitiveImporter : public TreeXMLImporter {
class SubPrimitiveImporter final : public TreeXMLImporter {
XMLImporter *m_importer;
public:
SubPrimitiveImporter(XMLImporter *importer) : m_importer(importer)
......@@ -94,7 +94,7 @@ public:
}
};
class PrimitiveImporter : public TreeXMLImporter {
class PrimitiveImporter final : public TreeXMLImporter {
scene::Node &m_parent;
XMLImporter *m_importer;
char m_child[sizeof(SubPrimitiveImporter)];
......@@ -149,7 +149,7 @@ public:
}
};
class EntityImporter : public TreeXMLImporter {
class EntityImporter final : public TreeXMLImporter {
scene::Node &m_parent;
char m_node[sizeof(NodeSmartReference)];
char m_child[sizeof(PrimitiveImporter)];
......
......@@ -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();
......
......@@ -39,7 +39,7 @@
#include "traverselib.h"
#include "render.h"
class VectorLightList : public LightList {
class VectorLightList final : public LightList {
typedef std::vector<const RendererLight *> Lights;
Lights m_lights;
public:
......
......@@ -43,7 +43,7 @@
#include "traverselib.h"
#include "render.h"
class VectorLightList : public LightList {
class VectorLightList final : public LightList {
typedef std::vector<const RendererLight *> Lights;
Lights m_lights;
public:
......
......@@ -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:
......
......@@ -118,40 +118,40 @@ inline void Winding_DrawWireframe(const Winding &winding)
inline void Winding_Draw(const Winding &winding, const Vector3 &normal, RenderStateFlags state)
{
glVertexPointer(3, GL_FLOAT, sizeof(WindingVertex), &winding.points.data()->vertex);
GLsizei stride = sizeof(WindingVertex);
const WindingVertex *first = winding.points.data();
auto size = winding.numpoints;
glVertexPointer(3, GL_FLOAT, stride, &first->vertex);
if ((state & RENDER_BUMP) != 0) {
Vector3 normals[c_brush_maxFaces];
typedef Vector3 *Vector3Iter;
for (Vector3Iter i = normals, end = normals + winding.numpoints; i != end; ++i) {
for (Vector3Iter i = normals, end = normals + size; i != end; ++i) {
*i = normal;
}
if (GlobalShaderCache().useShaderLanguage()) {
glNormalPointer(GL_FLOAT, sizeof(Vector3), normals);
glVertexAttribPointerARB(c_attr_TexCoord0, 2, GL_FLOAT, 0, sizeof(WindingVertex),
&winding.points.data()->texcoord);
glVertexAttribPointerARB(c_attr_Tangent, 3, GL_FLOAT, 0, sizeof(WindingVertex),
&winding.points.data()->tangent);
glVertexAttribPointerARB(c_attr_Binormal, 3, GL_FLOAT, 0, sizeof(WindingVertex),
&winding.points.data()->bitangent);
glVertexAttribPointerARB(c_attr_TexCoord0, 2, GL_FLOAT, 0, stride, &first->texcoord);
glVertexAttribPointerARB(c_attr_Tangent, 3, GL_FLOAT, 0, stride, &first->tangent);
glVertexAttribPointerARB(c_attr_Binormal, 3, GL_FLOAT, 0, stride, &first->bitangent);
} else {
glVertexAttribPointerARB(11, 3, GL_FLOAT, 0, sizeof(Vector3), normals);
glVertexAttribPointerARB(8, 2, GL_FLOAT, 0, sizeof(WindingVertex), &winding.points.data()->texcoord);
glVertexAttribPointerARB(9, 3, GL_FLOAT, 0, sizeof(WindingVertex), &winding.points.data()->tangent);
glVertexAttribPointerARB(10, 3, GL_FLOAT, 0, sizeof(WindingVertex), &winding.points.data()->bitangent);
glVertexAttribPointerARB(8, 2, GL_FLOAT, 0, stride, &first->texcoord);
glVertexAttribPointerARB(9, 3, GL_FLOAT, 0, stride, &first->tangent);
glVertexAttribPointerARB(10, 3, GL_FLOAT, 0, stride, &first->bitangent);
}
} else {
if (state & RENDER_LIGHTING) {
Vector3 normals[c_brush_maxFaces];
typedef Vector3 *Vector3Iter;
for (Vector3Iter i = normals, last = normals + winding.numpoints; i != last; ++i) {
for (Vector3Iter i = normals, last = normals + size; i != last; ++i) {
*i = normal;
}
glNormalPointer(GL_FLOAT, sizeof(Vector3), normals);
}
if (state & RENDER_TEXTURE) {
glTexCoordPointer(2, GL_FLOAT, sizeof(WindingVertex), &winding.points.data()->texcoord);
glTexCoordPointer(2, GL_FLOAT, stride, &first->texcoord);
}
}
#if 0
......@@ -163,7 +163,7 @@ inline void Winding_Draw(const Winding &winding, const Vector3 &normal, RenderSt
glDrawArrays( GL_LINE_LOOP, 0, GLsizei( winding.numpoints ) );
}
#else
glDrawArrays(GL_POLYGON, 0, GLsizei(winding.numpoints));
glDrawArrays(GL_POLYGON, 0, GLsizei(size));
#endif
#if 0
......@@ -2633,7 +2633,7 @@ triangles_same_winding(const BasicVector3<Element> &x1, const BasicVector3<Eleme
typedef const Plane3 *PlanePointer;
typedef PlanePointer *PlanesIterator;
class VectorLightList : public LightList {
class VectorLightList final : public LightList {
typedef std::vector<const RendererLight *> Lights;
Lights m_lights;
public:
......
......@@ -284,29 +284,31 @@ public:
}
};
template <class Widget, class Self, class T, class native>
struct AddDataCustomWrapper {
static void Export(const native &self, const Callback<void(T)> &returnz)
{
native *p = &const_cast<native &>(self);
auto widget = Self::from(p);
Widget::Get::thunk_(widget, returnz);
}
static void Import(native &self, T value)
{
native *p = &self;
auto widget = Self::from(p);
Widget::Set::thunk_(widget, value);
}
};
template<class Widget>
void AddDataCustom(DialogDataList &self, typename Widget::Type widget, Property<typename Widget::Other> const &property)
{
using Self = typename Widget::Type;
using T = typename Widget::Other;
using native = typename std::remove_pointer<typename Self::native>::type;
struct Wrapper {
static void Export(const native &self, const Callback<void(T)> &returnz)
{
native *p = &const_cast<native &>(self);
auto widget = Self::from(p);
Widget::Get::thunk_(widget, returnz);
}
static void Import(native &self, T value)
{
native *p = &self;
auto widget = Self::from(p);
Widget::Set::thunk_(widget, value);
}
};
self.push_back(new CallbackDialogData<typename Widget::Other>(
make_property<PropertyAdaptor<native, T, Wrapper>>(*static_cast<native *>(widget)),
self.push_back(new CallbackDialogData<T>(
make_property<PropertyAdaptor<native, T, AddDataCustomWrapper<Widget, Self, T, native>>>(*static_cast<native *>(widget)),
property
));
}
......
......@@ -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 "
......
......@@ -198,7 +198,7 @@ namespace {
}
};
class AttributeImporter : public TreeXMLImporter {
class AttributeImporter final : public TreeXMLImporter {
StringOutputStream &m_comment;
public:
......@@ -278,7 +278,7 @@ namespace {
}
class ClassImporter : public TreeXMLImporter {
class ClassImporter final : public TreeXMLImporter {
EntityClassCollector &m_collector;
EntityClass *m_eclass;
StringOutputStream m_comment;
......@@ -358,7 +358,7 @@ namespace {
}
};
class ItemImporter : public TreeXMLImporter {
class ItemImporter final : public TreeXMLImporter {
public:
ItemImporter(ListAttributeType &list, const XMLElement &element)
{
......@@ -389,7 +389,7 @@ namespace {
return string_equal(name, "item");
}
class ListAttributeImporter : public TreeXMLImporter {
class ListAttributeImporter final : public TreeXMLImporter {
ListAttributeType *m_listType;
Storage<ItemImporter> m_item;
public:
......@@ -436,7 +436,7 @@ namespace {
return string_equal(name, "list");
}
class ClassesImporter : public TreeXMLImporter {
class ClassesImporter final : public TreeXMLImporter {
EntityClassCollector &m_collector;
Storage<ClassImporter> m_class;
Storage<ListAttributeImporter> m_list;
......
......@@ -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);
......