mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-14 07:47:13 +00:00
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>
119 lines
4.5 KiB
C++
119 lines
4.5 KiB
C++
#pragma once
|
|
|
|
#ifndef __DCOMMONVARS__H__
|
|
#define __DCOMMONVARS__H__
|
|
|
|
#include <compare>
|
|
#include <cstdint>
|
|
#include <set>
|
|
#include <string>
|
|
#include "BitStream.h"
|
|
#include "BitStreamUtils.h"
|
|
#include "MessageType/Client.h"
|
|
#include "ServiceType.h"
|
|
|
|
#pragma warning (disable:4251) //Disables SQL warnings
|
|
|
|
static_assert(sizeof(void*) == 8, "The server only builds for 64-bit targets");
|
|
|
|
// These are the same define, but they mean two different things in different contexts
|
|
// so a different define to distinguish what calculation is happening will help clarity.
|
|
#define FRAMES_TO_MS(x) (1000 / (x))
|
|
#define MS_TO_FRAMES(x) (1000 / (x))
|
|
|
|
//=========== FRAME TIMINGS ===========
|
|
constexpr uint32_t highFramerate = 60;
|
|
constexpr uint32_t mediumFramerate = 30;
|
|
constexpr uint32_t lowFramerate = 15;
|
|
|
|
constexpr uint32_t highFrameDelta = FRAMES_TO_MS(highFramerate);
|
|
constexpr uint32_t mediumFrameDelta = FRAMES_TO_MS(mediumFramerate);
|
|
constexpr uint32_t lowFrameDelta = FRAMES_TO_MS(lowFramerate);
|
|
|
|
//=========== TYPEDEFS ==========
|
|
|
|
using LOT = int32_t; //!< A LOT
|
|
using LWOOBJID = int64_t; //!< An object ID (should be unsigned actually but ok)
|
|
using TSkillID = int32_t; //!< A skill ID
|
|
using LWOCLONEID = uint32_t; //!< Used for Clone IDs
|
|
using LWOMAPID = uint16_t; //!< Used for Map IDs
|
|
using LWOINSTANCEID = uint16_t; //!< Used for Instance IDs
|
|
using PROPERTYCLONELIST = uint32_t; //!< Used for Property Clone IDs
|
|
using StripId = uint32_t;
|
|
|
|
constexpr LWOOBJID LWOOBJID_EMPTY = 0; //!< An empty object ID
|
|
constexpr LOT LOT_NULL = -1; //!< A null LOT
|
|
constexpr int32_t LOOTTYPE_NONE = 0; //!< No loot type available
|
|
constexpr float SECONDARY_PRIORITY = 1.0f; //!< Secondary Priority
|
|
constexpr uint32_t INVENTORY_MAX = 9999999; //!< The Maximum Inventory Size
|
|
constexpr LWOCLONEID LWOCLONEID_INVALID = -1; //!< Invalid LWOCLONEID
|
|
constexpr LWOINSTANCEID LWOINSTANCEID_INVALID = -1; //!< Invalid LWOINSTANCEID
|
|
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.14159265358979323846264338327950288f;
|
|
|
|
//============ STRUCTS ==============
|
|
|
|
struct LWOZONEID {
|
|
public:
|
|
constexpr const LWOMAPID& GetMapID() const noexcept { return m_MapID; }
|
|
constexpr const LWOINSTANCEID& GetInstanceID() const noexcept { return m_InstanceID; }
|
|
constexpr const LWOCLONEID& GetCloneID() const noexcept { return m_CloneID; }
|
|
|
|
//In order: def constr, constr, assign op
|
|
constexpr LWOZONEID() noexcept = default;
|
|
constexpr LWOZONEID(const LWOMAPID& mapID, const LWOINSTANCEID& instanceID, const LWOCLONEID& cloneID) noexcept { m_MapID = mapID; m_InstanceID = instanceID; m_CloneID = cloneID; }
|
|
constexpr LWOZONEID(const LWOZONEID& replacement) noexcept { *this = replacement; }
|
|
constexpr bool operator==(const LWOZONEID&) const = default;
|
|
constexpr auto operator<=>(const LWOZONEID&) const = default;
|
|
|
|
private:
|
|
LWOMAPID m_MapID = LWOMAPID_INVALID; //1000 for VE, 1100 for AG, etc...
|
|
LWOINSTANCEID m_InstanceID = LWOINSTANCEID_INVALID; //Instances host the same world, but on a different dWorld process.
|
|
LWOCLONEID m_CloneID = LWOCLONEID_INVALID; //To differentiate between "your property" and "my property". Always 0 for non-prop worlds.
|
|
};
|
|
|
|
|
|
struct FriendData {
|
|
public:
|
|
bool isOnline = false;
|
|
bool isBestFriend = false;
|
|
bool isFTP = false;
|
|
LWOZONEID zoneID;
|
|
LWOOBJID friendID;
|
|
std::string friendName;
|
|
|
|
void Serialize(RakNet::BitStream& bitStream) const {
|
|
bitStream.Write<uint8_t>(isOnline);
|
|
bitStream.Write<uint8_t>(isBestFriend);
|
|
bitStream.Write<uint8_t>(isFTP);
|
|
bitStream.Write<uint32_t>(0); //???
|
|
bitStream.Write<uint8_t>(0); //???
|
|
bitStream.Write(zoneID.GetMapID());
|
|
bitStream.Write(zoneID.GetInstanceID());
|
|
bitStream.Write(zoneID.GetCloneID());
|
|
bitStream.Write(friendID);
|
|
|
|
uint32_t maxSize = 33;
|
|
uint32_t size = static_cast<uint32_t>(friendName.length());
|
|
uint32_t remSize = static_cast<uint32_t>(maxSize - size);
|
|
|
|
if (size > maxSize) size = maxSize;
|
|
|
|
for (uint32_t i = 0; i < size; ++i) {
|
|
bitStream.Write<uint16_t>(friendName[i]);
|
|
}
|
|
|
|
for (uint32_t j = 0; j < remSize; ++j) {
|
|
bitStream.Write<uint16_t>(0);
|
|
}
|
|
|
|
bitStream.Write<uint32_t>(0); //???
|
|
bitStream.Write<uint16_t>(0); //???
|
|
}
|
|
};
|
|
|
|
#endif //!__DCOMMONVARS__H__
|