diff --git a/monocle/src/main.cpp b/monocle/src/main.cpp index 9e5fdc8..465ae3f 100644 --- a/monocle/src/main.cpp +++ b/monocle/src/main.cpp @@ -73,7 +73,7 @@ static mon::QAngle RandomAng(small_prng& rng, PITCH_YAW_TYPE type, bool has_roll case PYT_COUNT: default: p = y = 0.f; - MON_ASSERT(0); + MON_UNREACHABLE(); } return {p, y, has_roll ? rng.next_float(-180.f, 180.f) : 0.f}; } diff --git a/monocle/src/vag_search.hpp b/monocle/src/vag_search.hpp index 6b19063..09e0111 100644 --- a/monocle/src/vag_search.hpp +++ b/monocle/src/vag_search.hpp @@ -80,7 +80,7 @@ struct SearchPortal { break; default: lock_axis = -1; - MON_ASSERT(0); + MON_UNREACHABLE(); } float lock_ax_val = rng.next_elem(lock_opts); const AABB& pos_space = rng.next_elem(pos_spaces); diff --git a/monocle_lib/src/game/source_math.hpp b/monocle_lib/src/game/source_math.hpp index a118b4d..e26c5aa 100644 --- a/monocle_lib/src/game/source_math.hpp +++ b/monocle_lib/src/game/source_math.hpp @@ -23,9 +23,9 @@ enum GameVersion : uint16_t { GV_9862575, }; -constexpr float PORTAL_HALF_WIDTH = 32.f; -constexpr float PORTAL_HALF_HEIGHT = 54.f; -constexpr float PORTAL_HOLE_DEPTH = 500.f; +inline constexpr float PORTAL_HALF_WIDTH = 32.f; +inline constexpr float PORTAL_HALF_HEIGHT = 54.f; +inline constexpr float PORTAL_HOLE_DEPTH = 500.f; // sets FPU flags to what the game uses, setup before using any monocle code class MonocleFloatingPointScope { @@ -139,6 +139,8 @@ struct Vector { } std::string ToString(std::string_view delim = ", ") const; + + MON_VECTOR_CLASS_EXTRA; }; struct QAngle { @@ -160,6 +162,8 @@ struct QAngle { { return x == o.x && y == o.y && z == o.z; } + + MON_QANGLE_CLASS_EXTRA; }; struct matrix3x4_t { @@ -184,6 +188,8 @@ struct matrix3x4_t { } std::string DebugToString() const; + + MON_MATRIX3X4_CLASS_EXTRA; }; struct VMatrix { @@ -213,12 +219,13 @@ struct VMatrix { return m[i]; } -public: // replacements for operator* VMatrix Multiply(const VMatrix& vm, GameVersion gv) const; Vector Multiply(const Vector& v, GameVersion gv) const; std::string DebugToString() const; + + MON_VMATRIX_CLASS_EXTRA; }; struct VPlane { @@ -239,15 +246,17 @@ struct VPlane { } std::string ToString() const; + + MON_VPLANE_CLASS_EXTRA; }; // g_DefaultViewVectors -static constexpr Vector PLAYER_CROUCH_MINS{-16.f, -16.f, 0.f}; -static constexpr Vector PLAYER_CROUCH_MAXS{16.f, 16.f, 36.f}; -static constexpr Vector PLAYER_CROUCH_HALF = (PLAYER_CROUCH_MINS + PLAYER_CROUCH_MAXS) * .5f; -static constexpr Vector PLAYER_STAND_MINS{-16.f, -16.f, 0.f}; -static constexpr Vector PLAYER_STAND_MAXS{16.f, 16.f, 72.f}; -static constexpr Vector PLAYER_STAND_HALF = (PLAYER_STAND_MINS + PLAYER_STAND_MAXS) * .5f; +inline constexpr Vector PLAYER_CROUCH_MINS{-16.f, -16.f, 0.f}; +inline constexpr Vector PLAYER_CROUCH_MAXS{16.f, 16.f, 36.f}; +inline constexpr Vector PLAYER_CROUCH_HALF = (PLAYER_CROUCH_MINS + PLAYER_CROUCH_MAXS) * .5f; +inline constexpr Vector PLAYER_STAND_MINS{-16.f, -16.f, 0.f}; +inline constexpr Vector PLAYER_STAND_MAXS{16.f, 16.f, 72.f}; +inline constexpr Vector PLAYER_STAND_HALF = (PLAYER_STAND_MINS + PLAYER_STAND_MAXS) * .5f; struct Entity { @@ -267,7 +276,6 @@ struct Entity { bool is_player; -public: #ifdef DEBUG_NAN_CTORS Entity() : is_player(true), player(Vector{}, true) {} #else @@ -297,6 +305,8 @@ struct Entity { } std::string SetPosCmd() const; + + MON_ENTITY_CLASS_EXTRA; }; struct plane_bits { @@ -329,6 +339,8 @@ struct Portal { std::string NewLocationCmd(std::string_view portal_name, bool escape_quotes = false) const; std::string DebugToString(std::string_view portal_name) const; + + MON_PORTAL_CLASS_EXTRA; }; /* @@ -412,7 +424,7 @@ enum class PlacementOrder { COUNT = 2, }; -static std::array PlacementOrderStrs{ +inline std::array PlacementOrderStrs{ "BLUE_UpdatePortalTransformationMatrix", "ORANGE_UpdatePortalTransformationMatrix", }; @@ -447,6 +459,8 @@ struct PortalPair { std::string NewLocationCmd(std::string_view delim = "\n", bool escape_quotes = false) const; std::string DebugToString() const; + + MON_PORTAL_PAIR_CLASS_EXTRA; }; enum PlaneSideResult { diff --git a/monocle_lib/src/monocle_config.hpp b/monocle_lib/src/monocle_config.hpp index b684fa6..f768dcc 100644 --- a/monocle_lib/src/monocle_config.hpp +++ b/monocle_lib/src/monocle_config.hpp @@ -1,11 +1,11 @@ #pragma once -#ifdef MON_CFG_INCLUDE -#include MON_CFG_INCLUDE +#ifdef MON_CFG_INCLUDE_EXTRA +#include MON_CFG_INCLUDE_EXTRA #endif #define MON_LIB_VERSION_MAJOR 1 -#define MON_LIB_VERSION_MINOR 0 +#define MON_LIB_VERSION_MINOR 1 #ifndef MON_F_FMT #define MON_F_FMT "{:.9g}" @@ -36,3 +36,41 @@ } while (0) #endif #endif + +/* +* These will be inlined in the respective classes - can be used for implicit conversions to/from +* your types. The easiest way to handle these is to create a custom header different from +* MON_CFG_INCLUDE_EXTRA and include it before any monocle headers. +*/ + +#ifndef MON_VECTOR_CLASS_EXTRA +#define MON_VECTOR_CLASS_EXTRA +#endif + +#ifndef MON_QANGLE_CLASS_EXTRA +#define MON_QANGLE_CLASS_EXTRA +#endif + +#ifndef MON_MATRIX3X4_CLASS_EXTRA +#define MON_MATRIX3X4_CLASS_EXTRA +#endif + +#ifndef MON_VMATRIX_CLASS_EXTRA +#define MON_VMATRIX_CLASS_EXTRA +#endif + +#ifndef MON_VPLANE_CLASS_EXTRA +#define MON_VPLANE_CLASS_EXTRA +#endif + +#ifndef MON_ENTITY_CLASS_EXTRA +#define MON_ENTITY_CLASS_EXTRA +#endif + +#ifndef MON_PORTAL_CLASS_EXTRA +#define MON_PORTAL_CLASS_EXTRA +#endif + +#ifndef MON_PORTAL_PAIR_CLASS_EXTRA +#define MON_PORTAL_PAIR_CLASS_EXTRA +#endif