From 4bcdb495e84a8ab1eb4c0beaabfd42cb1d5d0f01 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sun, 6 May 2018 18:00:42 +1000 Subject: [PATCH] clang: fix build. Still doesn't work right --- contrib/bobtoolz/visfind.cpp | 2 +- contrib/ufoaiplug/ufoai_filters.cpp | 6 +- libs/container/hashfunc.h | 24 ++++---- libs/generic/callback.cpp | 4 +- libs/generic/callback.h | 94 ++++++++++++----------------- libs/l_net/l_net_berkley.c | 2 +- libs/mathlib/bbox.c | 2 +- libs/mathlib/m4x4.c | 2 +- libs/picomodel/pm_fm.c | 2 +- libs/picomodel/pm_md2.c | 4 +- libs/picomodel/pm_ms3d.c | 2 +- libs/property.h | 70 ++++++++++----------- libs/selectionlib.h | 2 +- libs/uilib/uilib.cpp | 3 + libs/uilib/uilib.h | 3 + libs/xml/xmltextags.h | 1 - plugins/mapxml/xmlparse.cpp | 6 +- plugins/md3model/model.h | 2 +- plugins/model/model.cpp | 2 +- plugins/vfspk3/vfs.cpp | 2 +- radiant/brush.h | 2 +- radiant/dialog.cpp | 36 +++++------ radiant/eclass_xml.cpp | 10 +-- radiant/referencecache.cpp | 2 +- radiant/scenegraph.h | 2 +- radiant/watchbsp.cpp | 1 - tools/quake3/q3data/md3lib.c | 9 +++ tools/quake3/q3map2/convert_map.c | 6 +- tools/quake3/q3map2/exportents.c | 2 +- tools/quake3/q3map2/light_bounce.c | 4 +- tools/quake3/q3map2/light_ydnar.c | 12 +++- tools/quake3/q3map2/portals.c | 2 +- tools/quake3/q3map2/q3map2.h | 2 +- tools/quake3/q3map2/shaders.c | 4 +- tools/quake3/q3map2/surface_meta.c | 3 +- 35 files changed, 167 insertions(+), 165 deletions(-) diff --git a/contrib/bobtoolz/visfind.cpp b/contrib/bobtoolz/visfind.cpp index 2e49da3e..6c2eb2af 100644 --- a/contrib/bobtoolz/visfind.cpp +++ b/contrib/bobtoolz/visfind.cpp @@ -214,7 +214,7 @@ std::list *CreateTrace(dleaf_t *leaf, int c, vis_header *header, byt } } - delete repeatlist; + delete[] repeatlist; return pointlist; } diff --git a/contrib/ufoaiplug/ufoai_filters.cpp b/contrib/ufoaiplug/ufoai_filters.cpp index de30083a..d9af4fb7 100644 --- a/contrib/ufoaiplug/ufoai_filters.cpp +++ b/contrib/ufoaiplug/ufoai_filters.cpp @@ -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) { diff --git a/libs/container/hashfunc.h b/libs/container/hashfunc.h index 305202d0..ef81fadc 100644 --- a/libs/container/hashfunc.h +++ b/libs/container/hashfunc.h @@ -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; diff --git a/libs/generic/callback.cpp b/libs/generic/callback.cpp index 7022e8cf..22683b67 100644 --- a/libs/generic/callback.cpp +++ b/libs/generic/callback.cpp @@ -207,7 +207,7 @@ void instantiate(){ Test test; const Test& testconst = test; { - Callback a = makeCallbackF(&test0free); + Callback a = makeCallbackF(test0free); Callback b = Test::Test0Caller( test ); b = makeCallback( Test::Test0(), test ); Callback c = Test::Test0ConstCaller( testconst ); @@ -221,7 +221,7 @@ void instantiate(){ } { typedef Callback TestCallback1; - TestCallback1 a = makeCallbackF(&test1free); + TestCallback1 a = makeCallbackF(test1free); TestCallback1 b = Test::Test1Caller( test ); b = makeCallback( Test::Test1(), test ); TestCallback1 c = Test::Test1ConstCaller( testconst ); diff --git a/libs/generic/callback.h b/libs/generic/callback.h index 577dd9d9..c1eb39af 100644 --- a/libs/generic/callback.h +++ b/libs/generic/callback.h @@ -70,54 +70,36 @@ namespace detail { namespace detail { template - struct ConvertFromOpaque { + struct ConvertToOpaque { }; - // reference + template + struct ConvertFromOpaque { + }; - template - inline const void *convertToOpaque(const T &t) { - return &t; - } + // pointer template - struct ConvertFromOpaque { - static T const &apply(void *p) { - return *static_cast(p); + struct ConvertToOpaque { + static void const *apply(const T *t) { + return t; } }; template - inline void *convertToOpaque(T &t) { - return &t; - } - - template - struct ConvertFromOpaque { - static T &apply(void *p) { - return *static_cast( p ); + struct ConvertFromOpaque { + static T const *apply(void const *p) { + return static_cast(p); } }; - // pointer - template - inline const void *convertToOpaque(const T *t) { - return t; - } - - template - struct ConvertFromOpaque { - static const T *apply(void *p) { - return static_cast(p); + struct ConvertToOpaque { + static void *apply(T *t) { + return t; } }; - template - inline void *convertToOpaque(T *t) { - return t; - } - template struct ConvertFromOpaque { static T *apply(void *p) { @@ -125,35 +107,35 @@ namespace detail { } }; - // function pointer - - template - inline const void *convertToOpaque(R(*const &t)(Ts...)) { - return &t; - } - - template - struct ConvertFromOpaque { - using Type = R(*)(Ts...); + // reference - static Type const &apply(void *p) { - return *static_cast(p); + template + struct ConvertToOpaque { + static void const *apply(T const &t) { + return &t; } }; - template - inline void *convertToOpaque(R(*&t)(Ts...)) { - return &t; - } + template + struct ConvertFromOpaque { + static T const &apply(void const *p) { + return *static_cast(p); + } + }; - template - struct ConvertFromOpaque { - using Type = R(*)(Ts...); + template + struct ConvertToOpaque { + static void *apply(T &t) { + return &t; + } + }; - static Type &apply(void *p) { - return *static_cast(p); - } - }; + template + struct ConvertFromOpaque { + static T &apply(void *p) { + return *static_cast( p ); + } + }; template class BindFirstOpaqueN; @@ -182,7 +164,7 @@ namespace detail { } void *getEnvironment() const { - return const_cast(detail::convertToOpaque(firstBound)); + return const_cast(detail::ConvertToOpaque::apply(firstBound)); } }; diff --git a/libs/l_net/l_net_berkley.c b/libs/l_net/l_net_berkley.c index f53f37e8..782a4435 100644 --- a/libs/l_net/l_net_berkley.c +++ b/libs/l_net/l_net_berkley.c @@ -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; diff --git a/libs/mathlib/bbox.c b/libs/mathlib/bbox.c index fe5646d9..c8924646 100644 --- a/libs/mathlib/bbox.c +++ b/libs/mathlib/bbox.c @@ -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; diff --git a/libs/mathlib/m4x4.c b/libs/mathlib/m4x4.c index 45e421f4..b6f7368f 100644 --- a/libs/mathlib/m4x4.c +++ b/libs/mathlib/m4x4.c @@ -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; diff --git a/libs/picomodel/pm_fm.c b/libs/picomodel/pm_fm.c index c4086184..4c8cd28c 100644 --- a/libs/picomodel/pm_fm.c +++ b/libs/picomodel/pm_fm.c @@ -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 ) { diff --git a/libs/picomodel/pm_md2.c b/libs/picomodel/pm_md2.c index 37b5466c..2df1a9e5 100644 --- a/libs/picomodel/pm_md2.c +++ b/libs/picomodel/pm_md2.c @@ -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 ) { diff --git a/libs/picomodel/pm_ms3d.c b/libs/picomodel/pm_ms3d.c index 378265f3..2ed5faf3 100644 --- a/libs/picomodel/pm_ms3d.c +++ b/libs/picomodel/pm_ms3d.c @@ -57,7 +57,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; diff --git a/libs/property.h b/libs/property.h index abdb32f4..35732f5f 100644 --- a/libs/property.h +++ b/libs/property.h @@ -102,53 +102,55 @@ Property make_property(Self &self) { // chain +template +struct PropertyChainImpl { + static void ExportThunk(const Callback &self, SRC value) { + PropertyImpl::Export(value, self); + } + + static void Export(const X &self, const Callback &returnz) { + A::Get::thunk_(self, ConstReferenceCaller, void(SRC), ExportThunk>(returnz)); + } + + static void Import(X &self, DST value) { + SRC out; + PropertyImpl::Import(out, value); + A::Set::thunk_(self, out); + } +}; + template Property> make_property_chain(detail::propertyimpl_self &it) { using DST = detail::propertyimpl_other; using SRC = detail::propertyimpl_self; using X = detail::propertyimpl_self; - using A = property_impl; - struct I { - static void ExportThunk(const Callback &self, SRC value) { - PropertyImpl::Export(value, self); - } - - static void Export(const X &self, const Callback &returnz) { - A::Get::thunk_(self, ConstReferenceCaller, void(SRC), ExportThunk>(returnz)); - } - - static void Import(X &self, DST value) { - SRC out; - PropertyImpl::Import(out, value); - A::Set::thunk_(self, out); - } - }; - return make_property>(it); + return make_property>>(it); } +template +struct PropertyChainImpl_free { + static void ExportThunk(const Callback &self, SRC value) { + PropertyImpl::Export(value, self); + } + + static void Export(const Callback &returnz) { + A::Get::thunk_(nullptr, ConstReferenceCaller, void(SRC), ExportThunk>(returnz)); + } + + static void Import(DST value) { + SRC out; + PropertyImpl::Import(out, value); + A::Set::thunk_(nullptr, out); + } +}; + template Property> make_property_chain() { using DST = detail::propertyimpl_other; using SRC = detail::propertyimpl_self; - using A = property_impl_free; - struct I { - static void ExportThunk(const Callback &self, SRC value) { - PropertyImpl::Export(value, self); - } - - static void Export(const Callback &returnz) { - A::Get::thunk_(nullptr, ConstReferenceCaller, void(SRC), ExportThunk>(returnz)); - } - - static void Import(DST value) { - SRC out; - PropertyImpl::Import(out, value); - A::Set::thunk_(nullptr, out); - } - }; - return make_property>(); + return make_property>>(); } // specializations diff --git a/libs/selectionlib.h b/libs/selectionlib.h index 06a905c7..d6b1d838 100644 --- a/libs/selectionlib.h +++ b/libs/selectionlib.h @@ -43,7 +43,7 @@ bool isSelected() const { } }; -class ObservedSelectable : public Selectable +class ObservedSelectable final : public Selectable { SelectionChangeCallback m_onchanged; bool m_selected; diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index 1f4acb1f..93e6e604 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -51,7 +51,10 @@ namespace ui { >::type >; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wkeyword-macro" #define this (verify::test(*static_cast(const_cast::type>(this)))) +#pragma clang diagnostic pop IMPL(Editable, GTK_EDITABLE); diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index d795b758..96e0d54a 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -599,7 +599,10 @@ namespace ui { } } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wkeyword-macro" #define this (*static_cast(this)) +#pragma clang diagnostic pop template gulong Object::connect(char const *detailed_signal, Lambda &&c_handler, void *data) diff --git a/libs/xml/xmltextags.h b/libs/xml/xmltextags.h index 7a1bae6d..82424299 100644 --- a/libs/xml/xmltextags.h +++ b/libs/xml/xmltextags.h @@ -55,7 +55,6 @@ private: CopiedString m_savefilename; xmlDocPtr doc; xmlXPathContextPtr context; -xmlNodeSetPtr nodePtr; xmlXPathObjectPtr XpathEval( const char* queryString ){ xmlChar* expression = (xmlChar*)queryString; diff --git a/plugins/mapxml/xmlparse.cpp b/plugins/mapxml/xmlparse.cpp index b26c5766..bed19bd1 100644 --- a/plugins/mapxml/xmlparse.cpp +++ b/plugins/mapxml/xmlparse.cpp @@ -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)]; diff --git a/plugins/md3model/model.h b/plugins/md3model/model.h index ea4f0492..5bcd535b 100644 --- a/plugins/md3model/model.h +++ b/plugins/md3model/model.h @@ -39,7 +39,7 @@ #include "traverselib.h" #include "render.h" -class VectorLightList : public LightList { +class VectorLightList final : public LightList { typedef std::vector Lights; Lights m_lights; public: diff --git a/plugins/model/model.cpp b/plugins/model/model.cpp index 1234c7bd..c628b958 100644 --- a/plugins/model/model.cpp +++ b/plugins/model/model.cpp @@ -43,7 +43,7 @@ #include "traverselib.h" #include "render.h" -class VectorLightList : public LightList { +class VectorLightList final : public LightList { typedef std::vector Lights; Lights m_lights; public: diff --git a/plugins/vfspk3/vfs.cpp b/plugins/vfspk3/vfs.cpp index 0829073f..171b2310 100644 --- a/plugins/vfspk3/vfs.cpp +++ b/plugins/vfspk3/vfs.cpp @@ -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")) { diff --git a/radiant/brush.h b/radiant/brush.h index 6114d59a..9955bfba 100644 --- a/radiant/brush.h +++ b/radiant/brush.h @@ -2633,7 +2633,7 @@ triangles_same_winding(const BasicVector3 &x1, const BasicVector3 Lights; Lights m_lights; public: diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index 3b59f6ab..df7daa05 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -284,29 +284,31 @@ public: } }; +template +struct AddDataCustomWrapper { + static void Export(const native &self, const Callback &returnz) + { + native *p = &const_cast(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 void AddDataCustom(DialogDataList &self, typename Widget::Type widget, Property const &property) { using Self = typename Widget::Type; using T = typename Widget::Other; using native = typename std::remove_pointer::type; - struct Wrapper { - static void Export(const native &self, const Callback &returnz) - { - native *p = &const_cast(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( - make_property>(*static_cast(widget)), + self.push_back(new CallbackDialogData( + make_property>>(*static_cast(widget)), property )); } diff --git a/radiant/eclass_xml.cpp b/radiant/eclass_xml.cpp index 5d9d317c..e3b053e7 100644 --- a/radiant/eclass_xml.cpp +++ b/radiant/eclass_xml.cpp @@ -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 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 m_class; Storage m_list; diff --git a/radiant/referencecache.cpp b/radiant/referencecache.cpp index 448cd913..8db271c6 100644 --- a/radiant/referencecache.cpp +++ b/radiant/referencecache.cpp @@ -325,7 +325,7 @@ namespace { } } -struct ModelResource : public Resource { +struct ModelResource final : public Resource { NodeSmartReference m_model; const CopiedString m_originalName; CopiedString m_path; diff --git a/radiant/scenegraph.h b/radiant/scenegraph.h index 48fb08b3..759c34c0 100644 --- a/radiant/scenegraph.h +++ b/radiant/scenegraph.h @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#if !defined( INCLUDEDE_SCENEGRAPH_H ) +#if !defined( INCLUDED_SCENEGRAPH_H ) #define INCLUDED_SCENEGRAPH_H #endif diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index 2803ce94..7ae54879 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -104,7 +104,6 @@ private: char *m_sBSPName; // buffer we use in push mode to receive data directly from the network xmlParserInputBufferPtr m_xmlInputBuffer; - xmlParserInputPtr m_xmlInput; xmlParserCtxtPtr m_xmlParserCtxt; // call this to switch the set listening mode diff --git a/tools/quake3/q3data/md3lib.c b/tools/quake3/q3data/md3lib.c index 93b1dfe0..68085f5c 100644 --- a/tools/quake3/q3data/md3lib.c +++ b/tools/quake3/q3data/md3lib.c @@ -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; diff --git a/tools/quake3/q3map2/convert_map.c b/tools/quake3/q3map2/convert_map.c index 04c4a4d0..9db84665 100644 --- a/tools/quake3/q3map2/convert_map.c +++ b/tools/quake3/q3map2/convert_map.c @@ -110,13 +110,13 @@ void GetBestSurfaceTriangleMatchForBrushside( side_t *buildSide, bspDrawVert_t * continue; } } - if ( abs( DotProduct( vert[0]->xyz, buildPlane->normal ) - buildPlane->dist ) >= distanceEpsilon ) { + if ( fabsf( DotProduct( vert[0]->xyz, buildPlane->normal ) - buildPlane->dist ) >= distanceEpsilon ) { continue; } - if ( abs( DotProduct( vert[1]->xyz, buildPlane->normal ) - buildPlane->dist ) >= distanceEpsilon ) { + if ( fabsf( DotProduct( vert[1]->xyz, buildPlane->normal ) - buildPlane->dist ) >= distanceEpsilon ) { continue; } - if ( abs( DotProduct( vert[2]->xyz, buildPlane->normal ) - buildPlane->dist ) >= distanceEpsilon ) { + if ( fabsf( DotProduct( vert[2]->xyz, buildPlane->normal ) - buildPlane->dist ) >= distanceEpsilon ) { continue; } // Okay. Correct surface type, correct shader, correct plane. Let's start with the business... diff --git a/tools/quake3/q3map2/exportents.c b/tools/quake3/q3map2/exportents.c index b1236608..a0e5d6b6 100644 --- a/tools/quake3/q3map2/exportents.c +++ b/tools/quake3/q3map2/exportents.c @@ -109,4 +109,4 @@ int ExportEntitiesMain( int argc, char **argv ){ /* return to sender */ return 0; -} \ No newline at end of file +} diff --git a/tools/quake3/q3map2/light_bounce.c b/tools/quake3/q3map2/light_bounce.c index 9fe00ef6..bf2b63e5 100644 --- a/tools/quake3/q3map2/light_bounce.c +++ b/tools/quake3/q3map2/light_bounce.c @@ -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 ); diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index c75dac2e..b173b664 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -1719,7 +1719,7 @@ void DirtyRawLightmap( int rawLightmapNum ){ static qboolean SubmapRawLuxel( rawLightmap_t *lm, int x, int y, float bx, float by, int *sampleCluster, vec3_t sampleOrigin, vec3_t sampleNormal ){ int i, *cluster, *cluster2; - float *origin, *origin2, *normal; //% , *normal2; + float *origin = NULL, *origin2 = NULL, *normal; //% , *normal2; vec3_t originVecs[ 2 ]; //% , normalVecs[ 2 ]; @@ -1744,9 +1744,13 @@ static qboolean SubmapRawLuxel( rawLightmap_t *lm, int x, int y, float bx, float Sys_FPrintf( SYS_WRN, "WARNING: Spurious lightmap S vector\n" ); } - VectorSubtract( origin2, origin, originVecs[ 0 ] ); + if (origin && origin2) { + VectorSubtract(origin2, origin, originVecs[0]); + } //% VectorSubtract( normal2, normal, normalVecs[ 0 ] ); + origin = origin2 = NULL; + /* calulate y vector */ if ( ( y < ( lm->sh - 1 ) && bx >= 0.0f ) || ( y == 0 && bx <= 0.0f ) ) { cluster = SUPER_CLUSTER( x, y ); @@ -1768,7 +1772,9 @@ static qboolean SubmapRawLuxel( rawLightmap_t *lm, int x, int y, float bx, float Sys_FPrintf( SYS_WRN, "WARNING: Spurious lightmap T vector\n" ); } - VectorSubtract( origin2, origin, originVecs[ 1 ] ); + if (origin && origin2) { + VectorSubtract(origin2, origin, originVecs[1]); + } /* calculate new origin */ for ( i = 0; i < 3; i++ ) diff --git a/tools/quake3/q3map2/portals.c b/tools/quake3/q3map2/portals.c index 676fa315..c291520f 100644 --- a/tools/quake3/q3map2/portals.c +++ b/tools/quake3/q3map2/portals.c @@ -677,7 +677,7 @@ int FloodEntities( tree_t *tree ){ inside = qfalse; tree->outside_node.occupied = 0; - tripped = qfalse; + tripped = NULL; c_floodedleafs = 0; for ( i = 1; i < numEntities; i++ ) { diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 46fec5ee..655b9f07 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -627,7 +627,7 @@ typedef struct foliage_s struct foliage_s *next; char model[ MAX_QPATH ]; float scale, density, odds; - qboolean inverseAlpha; + int inverseAlpha; } foliage_t; diff --git a/tools/quake3/q3map2/shaders.c b/tools/quake3/q3map2/shaders.c index 166319aa..d1f8be17 100644 --- a/tools/quake3/q3map2/shaders.c +++ b/tools/quake3/q3map2/shaders.c @@ -719,7 +719,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 ]; @@ -1272,7 +1272,7 @@ static void ParseShaderFile( const char *filename ){ else if ( !Q_stricmp( token, "sun" ) /* sof2 */ || !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) ) { float a, b; sun_t *sun; - qboolean ext; + qboolean ext = qfalse; /* ydnar: extended sun directive? */ diff --git a/tools/quake3/q3map2/surface_meta.c b/tools/quake3/q3map2/surface_meta.c index 145e1961..4fff8a74 100644 --- a/tools/quake3/q3map2/surface_meta.c +++ b/tools/quake3/q3map2/surface_meta.c @@ -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 ); -- 2.39.2