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")
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")
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 ()
# 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}"
#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
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)
{
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;
}
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);
/// \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.
>::type
>;
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wkeyword-macro"
+WARNING_SUPPRESS_CLANG(keyword-macro)
#define this (verify<self>::test(*static_cast<self>(const_cast<pointer_remove_const<decltype(this)>::type>(this))))
-#pragma clang diagnostic pop
+WARNING_RESTORE_CLANG(keyword-macro)
IMPL(Editable, GTK_EDITABLE);
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);
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);
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)))
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(
padding.x, padding.y
);
}
+ WARNING_RESTORE(deprecated-declarations)
IMPL(TextView, GTK_TEXT_VIEW);
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)))
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>
}
}
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wkeyword-macro"
+WARNING_SUPPRESS_CLANG(keyword-macro)
#define this (*static_cast<self>(this))
-#pragma clang diagnostic pop
+WARNING_RESTORE_CLANG(keyword-macro)
template<class Lambda>
gulong Object::connect(char const *detailed_signal, Lambda &&c_handler, void *data)
int result = 0;
for (; first != last; ++first )
{
+ if (!isdigit(*first)) {
+ break;
+ }
result *= 10;
result += *first - '0';
}
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
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
class TextureBrowser;
-extern TextureBrowser g_TextureBrowser;
-
void TextureBrowser_SetSelectedShader(TextureBrowser &textureBrowser, const char *shader);
const char *TextureBrowser_GetSelectedShader(TextureBrowser &textureBrowser);
return FALSE;
}
-
-TextureBrowser g_TextureBrowser;
-
TextureBrowser &GlobalTextureBrowser()
{
- return g_TextureBrowser;
+ static TextureBrowser *_g_TextureBrowser = new TextureBrowser();
+ return *_g_TextureBrowser;
}
bool TextureBrowser_hideUnused()
class TextureBrowser;
+#define g_TextureBrowser GlobalTextureBrowser()
TextureBrowser &GlobalTextureBrowser();
ui::Widget TextureBrowser_constructWindow(ui::Window toplevel);
GraphTreeNode *parent = graph_tree_model_find_parent(model, instance.path());
- GraphTreeNode::iterator i = parent->find(GraphTreeNode::key_type(node_get_name_safe(instance.path().top().get()),
+ auto i = parent->find(GraphTreeNode::key_type(node_get_name_safe(instance.path().top().get()),
instance.path().top().get_pointer()));
+ if (i == parent->end()) {
+ return;
+ }
graph_tree_model_row_deleted(model, i);
void Winding_Clip(const FixedWinding &winding, const Plane3 &plane, const Plane3 &clipPlane, std::size_t adjacent,
FixedWinding &clipped)
{
+ if (!winding.size()) {
+ return;
+ }
PlaneClassification classification = Winding_ClassifyDistance(
plane3_distance_to_point(clipPlane, winding.back().vertex), ON_EPSILON);
PlaneClassification nextClassification;
light_t *light, *light2, **owner;
bspLeaf_t *leaf;
vec3_t origin, dir, mins, maxs;
- float radius, intensity;
+ float radius = 0.0f, intensity;
light_t *buckets[ 256 ];
}
else
{
- radius = 0.0f;
intensity = light->photons;
}