Skip to content

Commit

Permalink
Merge branch 'main' into property_behavior_saving
Browse files Browse the repository at this point in the history
  • Loading branch information
EmosewaMC committed Jun 13, 2024
2 parents db2d4f0 + bcf1058 commit b984cd6
Show file tree
Hide file tree
Showing 42 changed files with 935 additions and 250 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ COPY --from=build /app/build/*Server /app/

# Necessary suplimentary files
COPY --from=build /app/build/*.ini /app/configs/
COPY --from=build /app/build/vanity/*.* /app/vanity/*
COPY --from=build /app/build/vanity/*.* /app/vanity/
COPY --from=build /app/build/navmeshes /app/navmeshes
COPY --from=build /app/build/migrations /app/migrations
COPY --from=build /app/build/*.dcf /app/

# backup of config and vanity files to copy to the host incase
# of a mount clobbering the copy from above
COPY --from=build /app/build/*.ini /app/default-configs/
COPY --from=build /app/build/vanity/*.* /app/default-vanity/*
COPY --from=build /app/build/vanity/*.* /app/default-vanity/

# needed as the container runs with the root user
# and therefore sudo doesn't exist
Expand Down
1 change: 1 addition & 0 deletions dChatServer/ChatServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ int main(int argc, char** argv) {
}

void HandlePacket(Packet* packet) {
if (packet->length < 1) return;
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) {
LOG("A server has disconnected, erasing their connected players from the list.");
} else if (packet->data[0] == ID_NEW_INCOMING_CONNECTION) {
Expand Down
2 changes: 1 addition & 1 deletion dCommon/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void OnTerminate() {
}

void MakeBacktrace() {
struct sigaction sigact;
struct sigaction sigact{};

sigact.sa_sigaction = CritErrHdlr;
sigact.sa_flags = SA_RESTART | SA_SIGINFO;
Expand Down
74 changes: 37 additions & 37 deletions dCommon/LDFFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ class LDFBaseData {

virtual ~LDFBaseData() {}

virtual void WriteToPacket(RakNet::BitStream& packet) = 0;
virtual void WriteToPacket(RakNet::BitStream& packet) const = 0;

virtual const std::u16string& GetKey() = 0;
virtual const std::u16string& GetKey() const = 0;

virtual eLDFType GetValueType() = 0;
virtual eLDFType GetValueType() const = 0;

/** Gets a string from the key/value pair
* @param includeKey Whether or not to include the key in the data
* @param includeTypeId Whether or not to include the type id in the data
* @return The string representation of the data
*/
virtual std::string GetString(bool includeKey = true, bool includeTypeId = true) = 0;
virtual std::string GetString(bool includeKey = true, bool includeTypeId = true) const = 0;

virtual std::string GetValueAsString() = 0;
virtual std::string GetValueAsString() const = 0;

virtual LDFBaseData* Copy() = 0;
virtual LDFBaseData* Copy() const = 0;

/**
* Given an input string, return the data as a LDF key.
Expand All @@ -62,15 +62,15 @@ class LDFData: public LDFBaseData {
T value;

//! Writes the key to the packet
void WriteKey(RakNet::BitStream& packet) {
void WriteKey(RakNet::BitStream& packet) const {
packet.Write<uint8_t>(this->key.length() * sizeof(uint16_t));
for (uint32_t i = 0; i < this->key.length(); ++i) {
packet.Write<uint16_t>(this->key[i]);
}
}

//! Writes the value to the packet
void WriteValue(RakNet::BitStream& packet) {
void WriteValue(RakNet::BitStream& packet) const {
packet.Write<uint8_t>(this->GetValueType());
packet.Write(this->value);
}
Expand All @@ -90,7 +90,7 @@ class LDFData: public LDFBaseData {
/*!
\return The value
*/
const T& GetValue(void) { return this->value; }
const T& GetValue(void) const { return this->value; }

//! Sets the value
/*!
Expand All @@ -102,13 +102,13 @@ class LDFData: public LDFBaseData {
/*!
\return The value string
*/
std::string GetValueString(void) { return ""; }
std::string GetValueString(void) const { return ""; }

//! Writes the data to a packet
/*!
\param packet The packet
*/
void WriteToPacket(RakNet::BitStream& packet) override {
void WriteToPacket(RakNet::BitStream& packet) const override {
this->WriteKey(packet);
this->WriteValue(packet);
}
Expand All @@ -117,21 +117,21 @@ class LDFData: public LDFBaseData {
/*!
\return The key
*/
const std::u16string& GetKey(void) override { return this->key; }
const std::u16string& GetKey(void) const override { return this->key; }

//! Gets the LDF Type
/*!
\return The LDF value type
*/
eLDFType GetValueType(void) override { return LDF_TYPE_UNKNOWN; }
eLDFType GetValueType(void) const override { return LDF_TYPE_UNKNOWN; }

//! Gets the string data
/*!
\param includeKey Whether or not to include the key in the data
\param includeTypeId Whether or not to include the type id in the data
\return The string representation of the data
*/
std::string GetString(const bool includeKey = true, const bool includeTypeId = true) override {
std::string GetString(const bool includeKey = true, const bool includeTypeId = true) const override {
if (GetValueType() == -1) {
return GeneralUtils::UTF16ToWTF8(this->key) + "=-1:<server variable>";
}
Expand All @@ -154,31 +154,31 @@ class LDFData: public LDFBaseData {
return stream.str();
}

std::string GetValueAsString() override {
std::string GetValueAsString() const override {
return this->GetValueString();
}

LDFBaseData* Copy() override {
LDFBaseData* Copy() const override {
return new LDFData<T>(key, value);
}

inline static const T Default = {};
};

// LDF Types
template<> inline eLDFType LDFData<std::u16string>::GetValueType(void) { return LDF_TYPE_UTF_16; };
template<> inline eLDFType LDFData<int32_t>::GetValueType(void) { return LDF_TYPE_S32; };
template<> inline eLDFType LDFData<float>::GetValueType(void) { return LDF_TYPE_FLOAT; };
template<> inline eLDFType LDFData<double>::GetValueType(void) { return LDF_TYPE_DOUBLE; };
template<> inline eLDFType LDFData<uint32_t>::GetValueType(void) { return LDF_TYPE_U32; };
template<> inline eLDFType LDFData<bool>::GetValueType(void) { return LDF_TYPE_BOOLEAN; };
template<> inline eLDFType LDFData<uint64_t>::GetValueType(void) { return LDF_TYPE_U64; };
template<> inline eLDFType LDFData<LWOOBJID>::GetValueType(void) { return LDF_TYPE_OBJID; };
template<> inline eLDFType LDFData<std::string>::GetValueType(void) { return LDF_TYPE_UTF_8; };
template<> inline eLDFType LDFData<std::u16string>::GetValueType(void) const { return LDF_TYPE_UTF_16; };
template<> inline eLDFType LDFData<int32_t>::GetValueType(void) const { return LDF_TYPE_S32; };
template<> inline eLDFType LDFData<float>::GetValueType(void) const { return LDF_TYPE_FLOAT; };
template<> inline eLDFType LDFData<double>::GetValueType(void) const { return LDF_TYPE_DOUBLE; };
template<> inline eLDFType LDFData<uint32_t>::GetValueType(void) const { return LDF_TYPE_U32; };
template<> inline eLDFType LDFData<bool>::GetValueType(void) const { return LDF_TYPE_BOOLEAN; };
template<> inline eLDFType LDFData<uint64_t>::GetValueType(void) const { return LDF_TYPE_U64; };
template<> inline eLDFType LDFData<LWOOBJID>::GetValueType(void) const { return LDF_TYPE_OBJID; };
template<> inline eLDFType LDFData<std::string>::GetValueType(void) const { return LDF_TYPE_UTF_8; };

// The specialized version for std::u16string (UTF-16)
template<>
inline void LDFData<std::u16string>::WriteValue(RakNet::BitStream& packet) {
inline void LDFData<std::u16string>::WriteValue(RakNet::BitStream& packet) const {
packet.Write<uint8_t>(this->GetValueType());

packet.Write<uint32_t>(this->value.length());
Expand All @@ -189,15 +189,15 @@ inline void LDFData<std::u16string>::WriteValue(RakNet::BitStream& packet) {

// The specialized version for bool
template<>
inline void LDFData<bool>::WriteValue(RakNet::BitStream& packet) {
inline void LDFData<bool>::WriteValue(RakNet::BitStream& packet) const {
packet.Write<uint8_t>(this->GetValueType());

packet.Write<uint8_t>(this->value);
}

// The specialized version for std::string (UTF-8)
template<>
inline void LDFData<std::string>::WriteValue(RakNet::BitStream& packet) {
inline void LDFData<std::string>::WriteValue(RakNet::BitStream& packet) const {
packet.Write<uint8_t>(this->GetValueType());

packet.Write<uint32_t>(this->value.length());
Expand All @@ -206,18 +206,18 @@ inline void LDFData<std::string>::WriteValue(RakNet::BitStream& packet) {
}
}

template<> inline std::string LDFData<std::u16string>::GetValueString() {
template<> inline std::string LDFData<std::u16string>::GetValueString() const {
return GeneralUtils::UTF16ToWTF8(this->value, this->value.size());
}

template<> inline std::string LDFData<int32_t>::GetValueString() { return std::to_string(this->value); }
template<> inline std::string LDFData<float>::GetValueString() { return std::to_string(this->value); }
template<> inline std::string LDFData<double>::GetValueString() { return std::to_string(this->value); }
template<> inline std::string LDFData<uint32_t>::GetValueString() { return std::to_string(this->value); }
template<> inline std::string LDFData<bool>::GetValueString() { return std::to_string(this->value); }
template<> inline std::string LDFData<uint64_t>::GetValueString() { return std::to_string(this->value); }
template<> inline std::string LDFData<LWOOBJID>::GetValueString() { return std::to_string(this->value); }
template<> inline std::string LDFData<int32_t>::GetValueString() const { return std::to_string(this->value); }
template<> inline std::string LDFData<float>::GetValueString() const { return std::to_string(this->value); }
template<> inline std::string LDFData<double>::GetValueString() const { return std::to_string(this->value); }
template<> inline std::string LDFData<uint32_t>::GetValueString() const { return std::to_string(this->value); }
template<> inline std::string LDFData<bool>::GetValueString() const { return std::to_string(this->value); }
template<> inline std::string LDFData<uint64_t>::GetValueString() const { return std::to_string(this->value); }
template<> inline std::string LDFData<LWOOBJID>::GetValueString() const { return std::to_string(this->value); }

template<> inline std::string LDFData<std::string>::GetValueString() { return this->value; }
template<> inline std::string LDFData<std::string>::GetValueString() const { return this->value; }

#endif //!__LDFFORMAT__H__
1 change: 1 addition & 0 deletions dCommon/dConfig.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "dConfig.h"

#include <sstream>
#include <algorithm>

#include "BinaryPathFinder.h"
#include "GeneralUtils.h"
Expand Down
21 changes: 21 additions & 0 deletions dCommon/dEnums/eReponseMoveItemBetweenInventoryTypeCode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef __EREPONSEMOVEITEMBETWEENINVENTORYTYPECODE__H__
#define __EREPONSEMOVEITEMBETWEENINVENTORYTYPECODE__H__

#include <cstdint>

enum class eReponseMoveItemBetweenInventoryTypeCode : int32_t {
SUCCESS,
FAIL_GENERIC,
FAIL_INV_FULL,
FAIL_ITEM_NOT_FOUND,
FAIL_CANT_MOVE_TO_THAT_INV_TYPE,
FAIL_NOT_NEAR_BANK,
FAIL_CANT_SWAP_ITEMS,
FAIL_SOURCE_TYPE,
FAIL_WRONG_DEST_TYPE,
FAIL_SWAP_DEST_TYPE,
FAIL_CANT_MOVE_THINKING_HAT,
FAIL_DISMOUNT_BEFORE_MOVING
};

#endif //!__EREPONSEMOVEITEMBETWEENINVENTORYTYPECODE__H__
2 changes: 2 additions & 0 deletions dGame/Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Character::Character(uint32_t id, User* parentUser) {
m_ID = id;
m_ParentUser = parentUser;
m_OurEntity = nullptr;
m_GMLevel = eGameMasterLevel::CIVILIAN;
m_PermissionMap = static_cast<ePermissionMap>(0);
}

Character::~Character() {
Expand Down
18 changes: 9 additions & 9 deletions dGame/Character.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,22 +464,22 @@ class Character {
/**
* The ID of this character. First 32 bits of the ObjectID.
*/
uint32_t m_ID;
uint32_t m_ID{};

/**
* The 64-bit unique ID used in the game.
*/
LWOOBJID m_ObjectID;
LWOOBJID m_ObjectID{ LWOOBJID_EMPTY };

/**
* The user that owns this character.
*/
User* m_ParentUser;
User* m_ParentUser{};

/**
* If the character is in game, this is the entity that it represents, else nullptr.
*/
Entity* m_OurEntity;
Entity* m_OurEntity{};

/**
* 0-9, the Game Master level of this character.
Expand All @@ -506,17 +506,17 @@ class Character {
/**
* Whether the custom name of this character is rejected
*/
bool m_NameRejected;
bool m_NameRejected{};

/**
* The current amount of coins of this character
*/
int64_t m_Coins;
int64_t m_Coins{};

/**
* Whether the character is building
*/
bool m_BuildMode;
bool m_BuildMode{};

/**
* The items equipped by the character on world load
Expand Down Expand Up @@ -583,7 +583,7 @@ class Character {
/**
* The ID of the properties of this character
*/
uint32_t m_PropertyCloneID;
uint32_t m_PropertyCloneID{};

/**
* The XML data for this character, stored as string
Expand Down Expand Up @@ -613,7 +613,7 @@ class Character {
/**
* The last time this character logged in
*/
uint64_t m_LastLogin;
uint64_t m_LastLogin{};

/**
* The gameplay flags this character has (not just true values)
Expand Down
1 change: 1 addition & 0 deletions dGame/User.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ User::User(const SystemAddress& sysAddr, const std::string& username, const std:
m_AccountID = 0;
m_Username = "";
m_SessionKey = "";
m_MuteExpire = 0;

m_MaxGMLevel = eGameMasterLevel::CIVILIAN; //The max GM level this account can assign to it's characters
m_LastCharID = 0;
Expand Down
7 changes: 4 additions & 3 deletions dGame/dBehaviors/BehaviorContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void BehaviorContext::ExecuteUpdates() {
this->scheduledUpdates.clear();
}

void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream& bitStream) {
bool BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream& bitStream) {
BehaviorSyncEntry entry;
auto found = false;

Expand All @@ -128,7 +128,7 @@ void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream& bit
if (!found) {
LOG("Failed to find behavior sync entry with sync id (%i)!", syncId);

return;
return false;
}

auto* behavior = entry.behavior;
Expand All @@ -137,10 +137,11 @@ void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream& bit
if (behavior == nullptr) {
LOG("Invalid behavior for sync id (%i)!", syncId);

return;
return false;
}

behavior->Sync(this, bitStream, branch);
return true;
}


Expand Down
2 changes: 1 addition & 1 deletion dGame/dBehaviors/BehaviorContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct BehaviorContext

void ExecuteUpdates();

void SyncBehavior(uint32_t syncId, RakNet::BitStream& bitStream);
bool SyncBehavior(uint32_t syncId, RakNet::BitStream& bitStream);

void Update(float deltaTime);

Expand Down
3 changes: 2 additions & 1 deletion dGame/dComponents/BaseCombatAIComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@

BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id): Component(parent) {
m_Target = LWOOBJID_EMPTY;
SetAiState(AiState::spawn);
m_DirtyStateOrTarget = true;
m_State = AiState::spawn;
m_Timer = 1.0f;
m_StartPosition = parent->GetPosition();
m_MovementAI = nullptr;
Expand Down
Loading

0 comments on commit b984cd6

Please sign in to comment.