From 3d89b33c5f01465372f293abd970160f652824ef Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 5 Oct 2022 16:39:22 +0200 Subject: a --- compat/assert.hpp | 49 ++++++++++++++++++++++++++----------------------- compat/defs.hpp | 9 --------- corrade | 2 +- floor-mesh.cpp | 5 +---- magnum | 2 +- main.cpp | 1 - tile-atlas.hpp | 1 - 7 files changed, 29 insertions(+), 40 deletions(-) diff --git a/compat/assert.hpp b/compat/assert.hpp index 89c89c64..a9dbe0bc 100644 --- a/compat/assert.hpp +++ b/compat/assert.hpp @@ -1,20 +1,22 @@ #pragma once +#include "defs.hpp" #include #include #include namespace Magnum::Examples::detail { -template -constexpr inline void abort(const char* fmt, Xs... xs) +template +constexpr void abort(const char (&fmt)[N], Xs... xs) { - if (std::is_constant_evaluated()) { + if (std::is_constant_evaluated()) + throw "aborting"; + else { std::fprintf(stderr, fmt, xs...); std::putc('\n', stderr); std::fflush(stderr); std::abort(); - } else - throw "aborting"; + } } } // namespace Magnum::Examples::detail @@ -22,28 +24,29 @@ constexpr inline void abort(const char* fmt, Xs... xs) namespace Magnum::Examples { #define ABORT(...) \ - do { \ - if (std::is_constant_evaluated()) \ - throw "aborting"; \ - else \ - ::Magnum::Examples::detail:: \ - abort("aborting at %s:%d", __FILE__, __LINE__); \ + do { \ + if (std::is_constant_evaluated()) \ + throw "aborting"; \ + else \ + ::Magnum::Examples::detail:: \ + abort("%s: aborting at %s:%d", FUNCTION_NAME, __FILE__, __LINE__); \ } while (false) -#define ASSERT(expr) \ - do { \ - if (!(expr)) { \ - ABORT("assertion failed: '%s' in %s:%d", \ - #expr, __FILE__, __LINE__); \ - } \ +#define ASSERT(expr) \ + do { \ + if (!(expr)) { \ + ::Magnum::Examples::detail:: \ + abort("%s: assertion failed: '%s' in %s:%d", \ + FUNCTION_NAME, #expr, __FILE__, __LINE__); \ + } \ } while(false) -#define GAME_DEBUG_OUT(pfx, ...) ([&]() { \ - if constexpr (sizeof((pfx)) > 1) \ - std::fputs((pfx), stderr); \ - std::fprintf(stderr, __VA_ARGS__); \ - std::fputs("\n", stderr); \ - std::fflush(stderr); \ +#define GAME_DEBUG_OUT(pfx, ...) ([&]() { \ + if constexpr (sizeof((pfx)) > 1) \ + std::fputs((pfx), stderr); \ + std::fprintf(stderr, __VA_ARGS__); \ + std::fputs("\n", stderr); \ + std::fflush(stderr); \ }()) #define WARN(...) GAME_DEBUG_OUT("warning: ", __VA_ARGS__) diff --git a/compat/defs.hpp b/compat/defs.hpp index bde7d7e3..cd2e13cb 100644 --- a/compat/defs.hpp +++ b/compat/defs.hpp @@ -1,13 +1,4 @@ #pragma once -#include -#include - -namespace Magnum::Examples { - -using size_t = std::size_t; -using ssize_t = std::common_type_t>; - -} // namespace Magnum::Examples #ifdef _MSC_VER # define FUNCTION_NAME __FUNCSIG__ diff --git a/corrade b/corrade index 14bd2975..9e35d4eb 160000 --- a/corrade +++ b/corrade @@ -1 +1 @@ -Subproject commit 14bd297582a567c24ce07b02cffdc16db8a77589 +Subproject commit 9e35d4eb31b60c8d0aaa2d0028eae469b59ed7b3 diff --git a/floor-mesh.cpp b/floor-mesh.cpp index 48dfe5f2..7156661e 100644 --- a/floor-mesh.cpp +++ b/floor-mesh.cpp @@ -22,7 +22,7 @@ void floor_mesh::set_tile(quad_data& data, tile& x) CORRADE_INTERNAL_ASSERT(x.ground_image); auto texcoords = x.ground_image.atlas->texcoords_for_id(x.ground_image.variant); - for (std::size_t i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) data[i] = { texcoords[i] }; } @@ -69,7 +69,4 @@ std::array, TILE_COUNT> floor_mesh::make_position_array() return array; } -//const decltype(floor_mesh::_index_data) floor_mesh::_index_data = make_index_array(); -//const decltype(floor_mesh::_position_data) floor_mesh::_position_data = make_floor_positions_array(); - } // namespace Magnum::Examples diff --git a/magnum b/magnum index bd5f6670..17638a2a 160000 --- a/magnum +++ b/magnum @@ -1 +1 @@ -Subproject commit bd5f6670c26d79be4bb0e33ef2f46ae519e29917 +Subproject commit 17638a2ad50094ece8eeb7ad7f9b06033d05d843 diff --git a/main.cpp b/main.cpp index 668ac62a..f58228c6 100644 --- a/main.cpp +++ b/main.cpp @@ -5,7 +5,6 @@ #include "chunk.hpp" #include "floor-mesh.hpp" #include "wall-mesh.hpp" -#include "compat/defs.hpp" #include diff --git a/tile-atlas.hpp b/tile-atlas.hpp index 27ee2a24..3416314c 100644 --- a/tile-atlas.hpp +++ b/tile-atlas.hpp @@ -39,7 +39,6 @@ constexpr std::array tile_atlas::indices(std::size_t N) constexpr tile_atlas::quad tile_atlas::floor_quad(const Vector3 center, const Vector2 size) { - ASSERT(size[0] > 0); float x = size[0]*.5f, y = size[1]*.5f; return {{ { x + center[0], -y + center[1], center[2]}, -- cgit v1.2.3