Merge origin/main into experimental: behaviors, raw terrain scene lookups, property model fixes, player count

Main's model behaviors (every rotation, DoDamage, OnTimer, OnStartup, MoveBackToStart, moves along the model's
local axes), raw terrain reading with scene lookups and scene tools, property model and brick by brick fixes and the
chat server's player count fix, merged onto this branch's structures:

- game messages stay structs; the angular velocity messages join them and the handler sets a message's target
- strips own their speed again and the block names, moves and rotations stay in the shared action table
  (PropertyBehaviorActions, which the dashboard's behavior player reads; it now lists rotations too)
- the zone keeps reading its file through ZoneFile and takes the boundaries from it, then loads the raw terrain as main
  does; the old dNavigation terrain reader is gone
- the show all response stays a struct and logs a player count mismatch as main does
- the property management component tells models who sent a chat message

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-10 10:57:45 -06:00
56 changed files with 2418 additions and 438 deletions

View File

@@ -9,26 +9,8 @@ struct NiColor {
constexpr NiColor(float red, float green, float blue) : m_Red(red), m_Green(green), m_Blue(blue) {}
constexpr NiColor() : NiColor(0.0f, 0.0f, 0.0f) {}
/* reduce RGB files to grayscale, with or without alpha
* using the equation given in Poynton's ColorFAQ at
* <http://www.inforamp.net/~poynton/> // dead link
* Copyright (c) 1998-01-04 Charles Poynton poynton at inforamp.net
*
* Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
*
* We approximate this with
*
* Y = 0.21268 * R + 0.7151 * G + 0.07217 * B
*
* which can be expressed with integers as
*
* Y = (6969 * R + 23434 * G + 2365 * B)/32768
*
* The calculation is to be done in a linear colorspace.
*
* Other integer coefficents can be used via png_set_rgb_to_gray().
*/
float ToXYZ() const { return (m_Red * 0.212671f) + (m_Green * 0.71516f) + (m_Blue * 0.072169f); };
// Relative luminance (Rec. 709 weights) of a linear color
constexpr float Luminance() const { return (m_Red * 0.212671f) + (m_Green * 0.71516f) + (m_Blue * 0.072169f); }
};
#endif // NICOLOR_H

View File

@@ -16,9 +16,11 @@ namespace PropertyBehaviorActions {
constexpr std::string_view ON_INTERACT = "OnInteract";
constexpr std::string_view ON_ATTACK = "OnAttack";
constexpr std::string_view ON_CHAT = "OnChat";
constexpr std::array TRIGGERS{ ON_INTERACT, ON_ATTACK, ON_CHAT };
constexpr std::string_view ON_STARTUP = "OnStartup";
constexpr std::string_view ON_TIMER = "OnTimer";
constexpr std::array TRIGGERS{ ON_INTERACT, ON_ATTACK, ON_CHAT, ON_STARTUP, ON_TIMER };
// Moves the block's distance along a world axis at the model's speed
// Moves the block's distance along one of the model's local axes (right x, up y, forward z) at the strip's speed
struct Move {
std::string_view type;
char axis; // 'x', 'y' or 'z'
@@ -30,6 +32,13 @@ namespace PropertyBehaviorActions {
Move{ "MoveForward", 'z', 1.0f }, Move{ "MoveBackward", 'z', -1.0f },
};
// Turns the block's degrees about one of the model's local axes (tilt x, spin y, roll z) at the strip's speed
constexpr std::array ROTATIONS{
Move{ "Spin", 'y', 1.0f }, Move{ "SpinNegative", 'y', -1.0f },
Move{ "Tilt", 'x', 1.0f }, Move{ "TiltNegative", 'x', -1.0f },
Move{ "Roll", 'z', 1.0f }, Move{ "RollNegative", 'z', -1.0f },
};
// Blocks that make an object: spawns make one enemy at the model; drops give every player one powerup per unit of
// the block's value
struct LotBlock {
@@ -63,6 +72,8 @@ namespace PropertyBehaviorActions {
// The rest, each with its own handling
constexpr std::string_view SET_SPEED = "SetSpeed";
constexpr std::string_view MOVE_BACK_TO_START = "MoveBackToStart";
constexpr std::string_view DO_DAMAGE = "DoDamage";
constexpr std::string_view SMASH = "Smash";
constexpr std::string_view UNSMASH = "UnSmash";
constexpr std::string_view WAIT = "Wait";
@@ -70,9 +81,9 @@ namespace PropertyBehaviorActions {
constexpr std::string_view PRIVATE_MESSAGE = "PrivateMessage";
constexpr std::string_view PLAY_SOUND = "PlaySound";
constexpr std::string_view RESTART = "Restart";
constexpr std::array OTHERS{ SET_SPEED, SMASH, UNSMASH, WAIT, CHAT, PRIVATE_MESSAGE, PLAY_SOUND, RESTART };
constexpr std::array OTHERS{ SET_SPEED, MOVE_BACK_TO_START, DO_DAMAGE, SMASH, UNSMASH, WAIT, CHAT, PRIVATE_MESSAGE, PLAY_SOUND, RESTART };
// The speed models move at until a Set Speed block (ModelComponent)
// The speed a strip's moves and rotations start at until a Set Speed block (Strip)
constexpr float DEFAULT_SPEED = 3.0f;
// The table entry for a block type, or nullptr

View File

@@ -52,7 +52,7 @@ constexpr LWOMAPID LWOMAPID_INVALID = -1; //!< Invalid LWOMAPID
constexpr uint64_t LWOZONEID_INVALID = 0; //!< Invalid LWOZONEID
constexpr uint32_t MAX_MESSAGE_LENGTH = 0x500000; //!< Prevent exceptionally large msgs from being processed. Should always be used to check user provided inputs.
constexpr float PI = 3.14159f;
constexpr float PI = 3.14159265358979323846264338327950288f;
//============ STRUCTS ==============

23
dCommon/dMath.h Normal file
View File

@@ -0,0 +1,23 @@
// Darkflame Universe
// Copyright 2025
#ifndef DMATH_H
#define DMATH_H
#include <cmath>
namespace Math {
constexpr float PI = 3.14159265358979323846264338327950288f;
constexpr float RATIO_DEG_TO_RAD = PI / 180.0f;
constexpr float RATIO_RAD_TO_DEG = 180.0f / PI;
inline float DegToRad(float degrees) {
return degrees * RATIO_DEG_TO_RAD;
}
inline float RadToDeg(float radians) {
return radians * RATIO_RAD_TO_DEG;
}
};
#endif //!DMATH_H