diff options
-rw-r--r-- | compat/assert.hpp | 49 | ||||
-rw-r--r-- | compat/defs.hpp | 9 | ||||
m--------- | corrade | 0 | ||||
-rw-r--r-- | floor-mesh.cpp | 5 | ||||
m--------- | magnum | 0 | ||||
-rw-r--r-- | main.cpp | 1 | ||||
-rw-r--r-- | tile-atlas.hpp | 1 |
7 files changed, 27 insertions, 38 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 <cstdlib> #include <cstdio> #include <type_traits> namespace Magnum::Examples::detail { -template<typename...Xs> -constexpr inline void abort(const char* fmt, Xs... xs) +template<std::size_t N, typename...Xs> +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 <cstddef> -#include <type_traits> - -namespace Magnum::Examples { - -using size_t = std::size_t; -using ssize_t = std::common_type_t<std::ptrdiff_t, std::make_signed_t<std::size_t>>; - -} // namespace Magnum::Examples #ifdef _MSC_VER # define FUNCTION_NAME __FUNCSIG__ diff --git a/corrade b/corrade -Subproject 14bd297582a567c24ce07b02cffdc16db8a7758 +Subproject 9e35d4eb31b60c8d0aaa2d0028eae469b59ed7b 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<std::array<Vector3, 4>, 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 -Subproject bd5f6670c26d79be4bb0e33ef2f46ae519e2991 +Subproject 17638a2ad50094ece8eeb7ad7f9b06033d05d84 @@ -5,7 +5,6 @@ #include "chunk.hpp" #include "floor-mesh.hpp" #include "wall-mesh.hpp" -#include "compat/defs.hpp" #include <bitset> 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<UnsignedShort, 6> 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]}, |