Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion monocle/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
}
Expand Down
2 changes: 1 addition & 1 deletion monocle/src/vag_search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
38 changes: 26 additions & 12 deletions monocle_lib/src/game/source_math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -139,6 +139,8 @@ struct Vector {
}

std::string ToString(std::string_view delim = ", ") const;

MON_VECTOR_CLASS_EXTRA;
};

struct QAngle {
Expand All @@ -160,6 +162,8 @@ struct QAngle {
{
return x == o.x && y == o.y && z == o.z;
}

MON_QANGLE_CLASS_EXTRA;
};

struct matrix3x4_t {
Expand All @@ -184,6 +188,8 @@ struct matrix3x4_t {
}

std::string DebugToString() const;

MON_MATRIX3X4_CLASS_EXTRA;
};

struct VMatrix {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {

Expand All @@ -267,7 +276,6 @@ struct Entity {

bool is_player;

public:
#ifdef DEBUG_NAN_CTORS
Entity() : is_player(true), player(Vector{}, true) {}
#else
Expand Down Expand Up @@ -297,6 +305,8 @@ struct Entity {
}

std::string SetPosCmd() const;

MON_ENTITY_CLASS_EXTRA;
};

struct plane_bits {
Expand Down Expand Up @@ -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;
};

/*
Expand Down Expand Up @@ -412,7 +424,7 @@ enum class PlacementOrder {
COUNT = 2,
};

static std::array<const char*, (int)PlacementOrder::COUNT> PlacementOrderStrs{
inline std::array<const char*, (int)PlacementOrder::COUNT> PlacementOrderStrs{
"BLUE_UpdatePortalTransformationMatrix",
"ORANGE_UpdatePortalTransformationMatrix",
};
Expand Down Expand Up @@ -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 {
Expand Down
44 changes: 41 additions & 3 deletions monocle_lib/src/monocle_config.hpp
Original file line number Diff line number Diff line change
@@ -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}"
Expand Down Expand Up @@ -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
Loading