Compare commits

..

5 Commits

Author SHA1 Message Date
David Markowitz
7513dc6f49 Merge branch 'fix-windows-debug' of https://github.com/DarkflameUniverse/DarkflameServer into fix-windows-debug 2024-10-28 00:31:01 -07:00
David Markowitz
26a9d2eaaa use a name for the config 2024-10-28 00:30:49 -07:00
EmosewaMC
bb143ccf21 apple pls 2024-10-28 00:16:39 -07:00
David Markowitz
0509aaf855 Update to have debug and release builds 2024-10-27 20:07:00 -07:00
David Markowitz
e0b54645dc copy over zlibd debug file
probably fixes other issues, but makes it so windows debug builds work again
also adds windows debug building to catch this stuff
2024-10-27 11:10:17 -07:00
21 changed files with 305 additions and 277 deletions

View File

@@ -8,12 +8,13 @@ on:
jobs:
build-and-test:
name: Build & Test (${{ matrix.os }})
name: Build & Test (${{ matrix.os }} - ${{ matrix.cfg }})
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
matrix:
os: [ windows-2022, ubuntu-22.04, macos-13 ]
cfg: [ debug, release ]
steps:
- uses: actions/checkout@v3
@@ -33,9 +34,9 @@ jobs:
- name: cmake
uses: lukka/run-cmake@v10
with:
configurePreset: "ci-${{matrix.os}}"
buildPreset: "ci-${{matrix.os}}"
testPreset: "ci-${{matrix.os}}"
configurePreset: "ci-${{matrix.os}}-${{matrix.cfg}}"
buildPreset: "ci-${{matrix.os}}-${{matrix.cfg}}"
testPreset: "ci-${{matrix.os}}-${{matrix.cfg}}"
- name: artifacts
uses: actions/upload-artifact@v3
with:

View File

@@ -1,128 +1,242 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 14,
"patch": 0
},
"configurePresets": [
{
"name": "default",
"displayName": "Default configure step",
"description": "Use 'build' dir and Unix makefiles",
"binaryDir": "${sourceDir}/build",
"generator": "Unix Makefiles"
},
{
"name": "ci-ubuntu-22.04",
"displayName": "CI configure step for Ubuntu",
"description": "Same as default, Used in GitHub actions workflow",
"inherits": "default"
},
{
"name": "ci-macos-13",
"displayName": "CI configure step for MacOS",
"description": "Same as default, Used in GitHub actions workflow",
"inherits": "default"
},
{
"name": "ci-windows-2022",
"displayName": "CI configure step for Windows",
"description": "Set architecture to 64-bit (b/c RakNet)",
"inherits": "default",
"generator": "Visual Studio 17 2022",
"architecture": {
"value": "x64"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "windows-default",
"inherits": "ci-windows-2022",
"displayName": "Windows only Configure Settings",
"description": "Sets build and install directories",
"generator": "Ninja",
"architecture": {
"value": "x64",
"strategy": "external"
}
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default",
"displayName": "Default Build",
"description": "Default Build",
"jobs": 2
},
{
"name": "ci-windows-2022",
"configurePreset": "ci-windows-2022",
"displayName": "Windows CI Build",
"description": "This preset is used by the CI build on windows",
"configuration": "RelWithDebInfo",
"jobs": 2
},
{
"name": "ci-ubuntu-22.04",
"configurePreset": "ci-ubuntu-22.04",
"displayName": "Linux CI Build",
"description": "This preset is used by the CI build on linux",
"jobs": 2
},
{
"name": "ci-macos-13",
"configurePreset": "ci-macos-13",
"displayName": "MacOS CI Build",
"description": "This preset is used by the CI build on MacOS",
"jobs": 2
}
],
"testPresets": [
{
"name": "ci-ubuntu-22.04",
"configurePreset": "ci-ubuntu-22.04",
"displayName": "CI Tests on Linux",
"description": "Runs all tests on a linux configuration",
"execution": {
"jobs": 2
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 14,
"patch": 0
},
"configurePresets": [
{
"name": "default",
"displayName": "Default configure step",
"description": "Use 'build' dir and Unix makefiles",
"binaryDir": "${sourceDir}/build",
"generator": "Unix Makefiles"
},
"output": {
"outputOnFailure": true
}
},
{
"name": "ci-macos-13",
"configurePreset": "ci-macos-13",
"displayName": "CI Tests on MacOS",
"description": "Runs all tests on a Mac configuration",
"execution": {
"jobs": 2
{
"name": "ci-debug",
"displayName": "CI configure step for Debug",
"inherits": "default",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
"output": {
"outputOnFailure": true
}
},
{
"name": "ci-windows-2022",
"configurePreset": "ci-windows-2022",
"displayName": "CI Tests on windows",
"description": "Runs all tests on a windows configuration",
"configuration": "RelWithDebInfo",
"execution": {
"jobs": 2
{
"name": "ci-release",
"displayName": "CI configure step for Release",
"inherits": "default",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
"output": {
"outputOnFailure": true
},
"filter": {
"exclude": {
"name": "((example)|(minigzip))+"
{
"name": "ci-ubuntu-22.04-release",
"displayName": "CI configure step for Ubuntu",
"description": "Same as default, Used in GitHub actions workflow",
"inherits": "ci-release"
},
{
"name": "ci-ubuntu-22.04-debug",
"displayName": "CI configure step for Ubuntu",
"description": "Same as default, Used in GitHub actions workflow",
"inherits": "ci-debug"
},
{
"name": "ci-macos-13-release",
"displayName": "CI configure step for MacOS",
"description": "Same as default, Used in GitHub actions workflow",
"inherits": "ci-release"
},
{
"name": "ci-macos-13-debug",
"displayName": "CI configure step for MacOS",
"description": "Same as default, Used in GitHub actions workflow",
"inherits": "ci-debug"
},
{
"name": "ci-windows-2022-release",
"displayName": "CI configure step for Windows",
"description": "Set architecture to 64-bit (b/c RakNet)",
"inherits": "ci-release",
"generator": "Visual Studio 17 2022",
"architecture": {
"value": "x64"
}
},
{
"name": "ci-windows-2022-debug",
"displayName": "CI configure step for Windows",
"description": "Set architecture to 64-bit (b/c RakNet)",
"inherits": "ci-debug",
"generator": "Visual Studio 17 2022",
"architecture": {
"value": "x64"
}
},
{
"name": "windows-default-release",
"inherits": "ci-windows-2022-release",
"displayName": "Windows only Configure Settings (Release)",
"description": "Sets build and install directories",
"generator": "Ninja",
"architecture": {
"value": "x64",
"strategy": "external"
}
},
{
"name": "windows-default-debug",
"inherits": "ci-windows-2022-debug",
"displayName": "Windows only Configure Settings (Debug)",
"description": "Sets build and install directories",
"generator": "Ninja",
"architecture": {
"value": "x64",
"strategy": "external"
}
}
}
]
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default",
"displayName": "Default Build",
"description": "Default Build",
"jobs": 2
},
{
"name": "ci-windows-2022-debug",
"configurePreset": "ci-windows-2022-debug",
"displayName": "Windows CI Build",
"description": "This preset is used by the CI build on windows",
"configuration": "RelWithDebInfo",
"inherits": "default"
},
{
"name": "ci-windows-2022-release",
"configurePreset": "ci-windows-2022-release",
"displayName": "Windows CI Build",
"description": "This preset is used by the CI build on windows",
"configuration": "RelWithDebInfo",
"inherits": "default"
},
{
"name": "ci-ubuntu-22.04-debug",
"configurePreset": "ci-ubuntu-22.04-debug",
"displayName": "Linux CI Build",
"description": "This preset is used by the CI build on linux",
"inherits": "default"
},
{
"name": "ci-ubuntu-22.04-release",
"configurePreset": "ci-ubuntu-22.04-release",
"displayName": "Linux CI Build",
"description": "This preset is used by the CI build on linux",
"inherits": "default"
},
{
"name": "ci-macos-13-debug",
"configurePreset": "ci-macos-13-debug",
"displayName": "MacOS CI Build",
"description": "This preset is used by the CI build on MacOS",
"inherits": "default"
},
{
"name": "ci-macos-13-release",
"configurePreset": "ci-macos-13-release",
"displayName": "MacOS CI Build",
"description": "This preset is used by the CI build on MacOS",
"inherits": "default"
}
],
"testPresets": [
{
"name": "ci-ubuntu-22.04-debug",
"configurePreset": "ci-ubuntu-22.04-debug",
"displayName": "CI Tests on Linux",
"description": "Runs all tests on a linux configuration",
"configuration": "Debug",
"execution": {
"jobs": 2
},
"output": {
"outputOnFailure": true
}
},
{
"name": "ci-ubuntu-22.04-release",
"configurePreset": "ci-ubuntu-22.04-release",
"displayName": "CI Tests on Linux",
"description": "Runs all tests on a linux configuration",
"configuration": "RelWithDebInfo",
"execution": {
"jobs": 2
},
"output": {
"outputOnFailure": true
}
},
{
"name": "ci-macos-13-debug",
"configurePreset": "ci-macos-13-debug",
"displayName": "CI Tests on MacOS",
"description": "Runs all tests on a Mac configuration",
"configuration": "Debug",
"execution": {
"jobs": 2
},
"output": {
"outputOnFailure": true
}
},
{
"name": "ci-macos-13-release",
"configurePreset": "ci-macos-13-release",
"displayName": "CI Tests on MacOS",
"description": "Runs all tests on a Mac configuration",
"configuration": "RelWithDebInfo",
"execution": {
"jobs": 2
},
"output": {
"outputOnFailure": true
}
},
{
"name": "ci-windows-2022-release",
"configurePreset": "ci-windows-2022-release",
"displayName": "CI Tests on windows",
"description": "Runs all tests on a windows configuration",
"configuration": "RelWithDebInfo",
"execution": {
"jobs": 2
},
"output": {
"outputOnFailure": true
},
"filter": {
"exclude": {
"name": "((example)|(minigzip))+"
}
}
},
{
"name": "ci-windows-2022-debug",
"configurePreset": "ci-windows-2022-debug",
"displayName": "CI Tests on windows",
"description": "Runs all tests on a windows configuration for debug",
"configuration": "Debug",
"execution": {
"jobs": 2
},
"output": {
"outputOnFailure": true
},
"filter": {
"exclude": {
"name": "((example)|(minigzip))+"
}
}
}
]
}

View File

@@ -49,3 +49,12 @@ function(UpdateConfigOption file_name old_option_name new_option_name)
file(APPEND ${file_name} "\n" ${current_value})
endif()
endfunction()
function(DoAppleMariaDBCopy target location)
if(APPLE)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MARIADBCPP_SHARED_LIBRARY_LOCATION}
${location})
endif()
endfunction()

View File

@@ -4,7 +4,6 @@
#include "Game.h"
#include "dConfig.h"
#include "Logger.h"
#include "dPlatforms.h"
namespace {
std::string databaseName;
@@ -40,13 +39,14 @@ void MySQLDatabase::Connect() {
properties["autoReconnect"] = "true";
databaseName = Game::config->GetValue("mysql_database").c_str();
// `connect(const Properties& props)` segfaults in windows debug, but
// `connect(const SQLString& host, const SQLString& user, const SQLString& pwd)` doesn't handle pipes/unix sockets correctly
#if defined(DARKFLAME_PLATFORM_WIN32) && defined(_DEBUG)
con = driver->connect(properties["hostName"].c_str(), properties["user"].c_str(), properties["password"].c_str());
#else
if (properties.find("localSocket") != properties.end() || properties.find("pipe") != properties.end()) {
con = driver->connect(properties);
#endif
} else {
con = driver->connect(properties["hostName"].c_str(), properties["user"].c_str(), properties["password"].c_str());
}
con->setSchema(databaseName.c_str());
}

View File

@@ -15,7 +15,6 @@ ModelComponent::ModelComponent(Entity* parent) : Component(parent) {
m_OriginalRotation = m_Parent->GetDefaultRotation();
m_userModelID = m_Parent->GetVarAs<LWOOBJID>(u"userModelID");
m_Running = false;
}
void ModelComponent::LoadBehaviors() {
@@ -67,11 +66,6 @@ void ModelComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialU
if (bIsInitialUpdate) outBitStream.Write0(); // We are not writing model editing info
}
void ModelComponent::Update(float deltaTime) {
if (!m_Running) return;
for (auto& behavior : m_Behaviors) behavior.Update(deltaTime, *this);
}
void ModelComponent::UpdatePendingBehaviorId(const int32_t newId) {
for (auto& behavior : m_Behaviors) if (behavior.GetBehaviorId() == -1) behavior.SetBehaviorId(newId);
}

View File

@@ -29,8 +29,6 @@ public:
ModelComponent(Entity* parent);
void Update(float deltaTime) override;
void LoadBehaviors();
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
@@ -116,11 +114,7 @@ public:
std::array<std::pair<int32_t, std::string>, 5> GetBehaviorsForSave() const;
void SetIsRunning(bool isRunning) { m_Running = isRunning; }
bool GetIsRunning() const { return m_Running; }
private:
bool m_Running;
/**
* The behaviors of the model
* Note: This is a vector because the order of the behaviors matters when serializing to the client.

View File

@@ -795,6 +795,8 @@ void PetComponent::Wander() {
}
void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) {
AddDrainImaginationTimer(item, fromTaming);
m_ItemId = item->GetId();
m_DatabaseId = item->GetSubKey();
@@ -805,7 +807,6 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) {
inventoryComponent->DespawnPet();
m_Owner = inventoryComponent->GetParent()->GetObjectID();
AddDrainImaginationTimer(fromTaming);
auto* owner = GetOwner();
@@ -858,14 +859,17 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) {
}
}
void PetComponent::AddDrainImaginationTimer(bool fromTaming) {
void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) {
if (Game::config->GetValue("pets_take_imagination") != "1") return;
auto* playerEntity = Game::entityManager->GetEntity(m_Owner);
if (!playerEntity) {
LOG("owner was null or didnt exist!");
return;
}
auto playerInventory = item->GetInventory();
if (!playerInventory) return;
auto playerInventoryComponent = playerInventory->GetComponent();
if (!playerInventoryComponent) return;
auto playerEntity = playerInventoryComponent->GetParent();
if (!playerEntity) return;
auto playerDestroyableComponent = playerEntity->GetComponent<DestroyableComponent>();
if (!playerDestroyableComponent) return;
@@ -874,16 +878,12 @@ void PetComponent::AddDrainImaginationTimer(bool fromTaming) {
if (!fromTaming) playerDestroyableComponent->Imagine(-1);
// Set this to a variable so when this is called back from the player the timer doesn't fire off.
m_Parent->AddCallbackTimer(m_PetInfo.imaginationDrainRate, [this]() {
const auto* owner = Game::entityManager->GetEntity(m_Owner);
if (!owner) {
LOG("owner was null or didnt exist!");
m_Parent->AddCallbackTimer(m_PetInfo.imaginationDrainRate, [playerDestroyableComponent, this, item]() {
if (!playerDestroyableComponent) {
LOG("No petComponent and/or no playerDestroyableComponent");
return;
}
const auto* playerDestroyableComponent = owner->GetComponent<DestroyableComponent>();
if (!playerDestroyableComponent) return;
// If we are out of imagination despawn the pet.
if (playerDestroyableComponent->GetImagination() == 0) {
this->Deactivate();
@@ -893,13 +893,15 @@ void PetComponent::AddDrainImaginationTimer(bool fromTaming) {
GameMessages::SendUseItemRequirementsResponse(playerEntity->GetObjectID(), playerEntity->GetSystemAddress(), eUseItemResponse::NoImaginationForPet);
}
this->AddDrainImaginationTimer();
this->AddDrainImaginationTimer(item);
});
}
void PetComponent::Deactivate() {
GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), -1, u"despawn", "", LWOOBJID_EMPTY, 1, 1, true);
GameMessages::SendMarkInventoryItemAsActive(m_Owner, false, eUnequippableActiveType::PET, m_ItemId, GetOwner()->GetSystemAddress());
activePets.erase(m_Owner);
m_Parent->Kill();
@@ -908,8 +910,6 @@ void PetComponent::Deactivate() {
if (owner == nullptr) return;
GameMessages::SendMarkInventoryItemAsActive(m_Owner, false, eUnequippableActiveType::PET, m_ItemId, owner->GetSystemAddress());
GameMessages::SendAddPetToPlayer(m_Owner, 0, u"", LWOOBJID_EMPTY, LOT_NULL, owner->GetSystemAddress());
GameMessages::SendRegisterPetID(m_Owner, LWOOBJID_EMPTY, owner->GetSystemAddress());
@@ -1034,7 +1034,6 @@ Entity* PetComponent::GetParentEntity() const {
}
PetComponent::~PetComponent() {
m_Owner = LWOOBJID_EMPTY;
}
void PetComponent::SetPetNameForModeration(const std::string& petName) {

View File

@@ -205,7 +205,7 @@ public:
*
* @param item The item that represents this pet in the inventory.
*/
void AddDrainImaginationTimer(bool fromTaming = false);
void AddDrainImaginationTimer(Item* item, bool fromTaming = false);
private:

View File

@@ -253,15 +253,6 @@ void PropertyManagementComponent::OnStartBuilding() {
// Push equipped items
if (inventoryComponent) inventoryComponent->PushEquippedItems();
for (const auto obj : models | std::views::keys) {
auto* const model = Game::entityManager->GetEntity(obj);
if (!model) continue;
auto* const modelComponent = model->GetComponent<ModelComponent>();
if (modelComponent) modelComponent->SetIsRunning(false);
}
}
void PropertyManagementComponent::OnFinishBuilding() {
@@ -274,14 +265,6 @@ void PropertyManagementComponent::OnFinishBuilding() {
UpdateApprovedStatus(false);
Save();
for (const auto obj : models | std::views::keys) {
auto* const model = Game::entityManager->GetEntity(obj);
if (!model) continue;
auto* const modelComponent = model->GetComponent<ModelComponent>();
if (modelComponent) modelComponent->SetIsRunning(true);
}
}
void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const NiPoint3 position, NiQuaternion rotation) {

View File

@@ -22,26 +22,6 @@ Action::Action(const AMFArrayValue& arguments) {
}
}
void Action::Update(float deltaTime, const ModelComponent& modelComponent) {
// Do nothing
if (Running()) return;
// model component default speed is 3.0f
if (m_Type == "FlyUp") {
} else if (m_Type == "FlyDown") {
}
}
bool Action::Done() const noexcept {
return true;
}
bool Action::Running() const noexcept {
return false;
}
void Action::SendBehaviorBlocksToClient(AMFArrayValue& args) const {
auto* const actionArgs = args.PushArray();
actionArgs->Insert("Type", m_Type);

View File

@@ -8,7 +8,6 @@ namespace tinyxml2 {
};
class AMFArrayValue;
class ModelComponent;
/**
* @brief Sent if a ControlBehavior message has an Action associated with it
@@ -18,13 +17,6 @@ class Action {
public:
Action() = default;
Action(const AMFArrayValue& arguments);
void Update(float deltaTime, const ModelComponent& modelComponent);
bool Done() const noexcept;
bool Running() const noexcept;
[[nodiscard]] const std::string& GetType() const { return m_Type; };
[[nodiscard]] const std::string& GetValueParameterName() const { return m_ValueParameterName; };
[[nodiscard]] const std::string& GetValueParameterString() const { return m_ValueParameterString; };

View File

@@ -9,12 +9,6 @@ PropertyBehavior::PropertyBehavior() {
m_LastEditedState = BehaviorState::HOME_STATE;
}
void PropertyBehavior::Update(float deltaTime, const ModelComponent& modelComponent) {
for (auto& [stateId, state] : m_States) {
state.Update(deltaTime, modelComponent);
}
}
template<>
void PropertyBehavior::HandleMsg(AddStripMessage& msg) {
m_States[msg.GetActionContext().GetStateId()].HandleMsg(msg);

View File

@@ -10,7 +10,6 @@ namespace tinyxml2 {
enum class BehaviorState : uint32_t;
class AMFArrayValue;
class ModelComponent;
/**
* Represents the Entity of a Property Behavior and holds data associated with the behavior
@@ -19,8 +18,6 @@ class PropertyBehavior {
public:
PropertyBehavior();
void Update(float deltaTime, const ModelComponent& modelComponent);
template <typename Msg>
void HandleMsg(Msg& msg);

View File

@@ -4,19 +4,13 @@
#include "ControlBehaviorMsgs.h"
#include "tinyxml2.h"
void State::Update(float deltaTime, const ModelComponent& modelComponent) {
for (auto& strip : m_Strips) {
strip.Update(deltaTime, modelComponent);
}
}
template <>
void State::HandleMsg(AddStripMessage& msg) {
if (m_Strips.size() <= msg.GetActionContext().GetStripId()) {
m_Strips.resize(msg.GetActionContext().GetStripId() + 1);
}
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
}
};
template <>
void State::HandleMsg(AddActionMessage& msg) {
@@ -25,7 +19,7 @@ void State::HandleMsg(AddActionMessage& msg) {
}
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
}
};
template <>
void State::HandleMsg(UpdateStripUiMessage& msg) {
@@ -34,7 +28,7 @@ void State::HandleMsg(UpdateStripUiMessage& msg) {
}
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
}
};
template <>
void State::HandleMsg(RemoveActionsMessage& msg) {
@@ -43,7 +37,7 @@ void State::HandleMsg(RemoveActionsMessage& msg) {
}
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
}
};
template <>
void State::HandleMsg(RearrangeStripMessage& msg) {
@@ -52,7 +46,7 @@ void State::HandleMsg(RearrangeStripMessage& msg) {
}
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
}
};
template <>
void State::HandleMsg(UpdateActionMessage& msg) {
@@ -61,7 +55,7 @@ void State::HandleMsg(UpdateActionMessage& msg) {
}
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
}
};
template <>
void State::HandleMsg(RemoveStripMessage& msg) {
@@ -70,7 +64,7 @@ void State::HandleMsg(RemoveStripMessage& msg) {
}
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
}
};
template <>
void State::HandleMsg(SplitStripMessage& msg) {
@@ -87,7 +81,7 @@ void State::HandleMsg(SplitStripMessage& msg) {
m_Strips.at(msg.GetDestinationActionContext().GetStripId()).HandleMsg(msg);
}
}
};
template <>
void State::HandleMsg(MergeStripsMessage& msg) {
@@ -104,7 +98,7 @@ void State::HandleMsg(MergeStripsMessage& msg) {
m_Strips.at(msg.GetDestinationActionContext().GetStripId()).HandleMsg(msg);
}
}
};
template <>
void State::HandleMsg(MigrateActionsMessage& msg) {
@@ -121,7 +115,7 @@ void State::HandleMsg(MigrateActionsMessage& msg) {
m_Strips.at(msg.GetDestinationActionContext().GetStripId()).HandleMsg(msg);
}
}
};
bool State::IsEmpty() const {
for (const auto& strip : m_Strips) {

View File

@@ -8,12 +8,9 @@ namespace tinyxml2 {
}
class AMFArrayValue;
class ModelComponent;
class State {
public:
void Update(float deltaTime, const ModelComponent& modelComponent);
template <typename Msg>
void HandleMsg(Msg& msg);

View File

@@ -4,54 +4,45 @@
#include "ControlBehaviorMsgs.h"
#include "tinyxml2.h"
void Strip::Update(float deltaTime, const ModelComponent& modelComponent) {
if (m_Actions.empty() || m_ActionIndex >= m_Actions.size()) return;
auto& action = m_Actions[m_ActionIndex];
action.Update(deltaTime, modelComponent);
LOG("Running action %s", action.GetType().c_str());
if (action.Done()) m_ActionIndex++;
}
template <>
void Strip::HandleMsg(AddStripMessage& msg) {
m_Actions = msg.GetActionsToAdd();
m_Position = msg.GetPosition();
}
};
template <>
void Strip::HandleMsg(AddActionMessage& msg) {
if (msg.GetActionIndex() == -1) return;
auto newAction = m_Actions.insert(m_Actions.begin() + msg.GetActionIndex(), msg.GetAction());
}
m_Actions.insert(m_Actions.begin() + msg.GetActionIndex(), msg.GetAction());
};
template <>
void Strip::HandleMsg(UpdateStripUiMessage& msg) {
m_Position = msg.GetPosition();
}
};
template <>
void Strip::HandleMsg(RemoveStripMessage& msg) {
m_Actions.clear();
}
};
template <>
void Strip::HandleMsg(RemoveActionsMessage& msg) {
if (msg.GetActionIndex() >= m_Actions.size()) return;
m_Actions.erase(m_Actions.begin() + msg.GetActionIndex(), m_Actions.end());
}
};
template <>
void Strip::HandleMsg(UpdateActionMessage& msg) {
if (msg.GetActionIndex() >= m_Actions.size()) return;
m_Actions.at(msg.GetActionIndex()) = msg.GetAction();
}
};
template <>
void Strip::HandleMsg(RearrangeStripMessage& msg) {
if (msg.GetDstActionIndex() >= m_Actions.size() || msg.GetSrcActionIndex() >= m_Actions.size() || msg.GetSrcActionIndex() <= msg.GetDstActionIndex()) return;
std::rotate(m_Actions.begin() + msg.GetDstActionIndex(), m_Actions.begin() + msg.GetSrcActionIndex(), m_Actions.end());
}
};
template <>
void Strip::HandleMsg(SplitStripMessage& msg) {
@@ -63,7 +54,7 @@ void Strip::HandleMsg(SplitStripMessage& msg) {
m_Actions = msg.GetTransferredActions();
m_Position = msg.GetPosition();
}
}
};
template <>
void Strip::HandleMsg(MergeStripsMessage& msg) {
@@ -73,7 +64,7 @@ void Strip::HandleMsg(MergeStripsMessage& msg) {
} else {
m_Actions.insert(m_Actions.begin() + msg.GetDstActionIndex(), msg.GetMigratedActions().begin(), msg.GetMigratedActions().end());
}
}
};
template <>
void Strip::HandleMsg(MigrateActionsMessage& msg) {
@@ -84,7 +75,7 @@ void Strip::HandleMsg(MigrateActionsMessage& msg) {
} else {
m_Actions.insert(m_Actions.begin() + msg.GetDstActionIndex(), msg.GetMigratedActions().begin(), msg.GetMigratedActions().end());
}
}
};
void Strip::SendBehaviorBlocksToClient(AMFArrayValue& args) const {
m_Position.SendBehaviorBlocksToClient(args);

View File

@@ -11,12 +11,9 @@ namespace tinyxml2 {
}
class AMFArrayValue;
class ModelComponent;
class Strip {
public:
void Update(float deltaTime, const ModelComponent& modelComponent);
template <typename Msg>
void HandleMsg(Msg& msg);
@@ -26,8 +23,6 @@ public:
void Serialize(tinyxml2::XMLElement& strip) const;
void Deserialize(const tinyxml2::XMLElement& strip);
private:
uint32_t m_ActionIndex{ 0 };
std::vector<Action> m_Actions;
StripUiPosition m_Position;
};

View File

@@ -18,3 +18,4 @@ target_link_libraries(MasterServer ${COMMON_LIBRARIES} bcrypt dMasterServer dSer
if(WIN32)
add_dependencies(MasterServer WorldServer AuthServer ChatServer)
endif()
DoAppleMariaDBCopy(MasterServer ${CMAKE_BINARY_DIR})

View File

@@ -15,6 +15,11 @@ endif()
add_custom_target(conncpp_tests
${CMAKE_COMMAND} -E copy $<TARGET_FILE:MariaDB::ConnCpp> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
if(MSVC)
add_custom_target(zlib_tests
${CMAKE_COMMAND} -E copy $<TARGET_FILE:ZLIB::ZLIB> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
# Add the subdirectories
add_subdirectory(dCommonTests)
add_subdirectory(dGameTests)

View File

@@ -18,18 +18,11 @@ list(APPEND DCOMMONTEST_SOURCES ${DENUMS_TESTS})
# Set our executable
add_executable(dCommonTests ${DCOMMONTEST_SOURCES})
add_dependencies(dCommonTests conncpp_tests)
# Apple needs some special linkage for the mariadb connector for tests.
if(APPLE)
add_custom_command(TARGET dCommonTests POST_BUILD
COMMAND otool ARGS -l dCommonTests
COMMAND otool ARGS -L dCommonTests
COMMAND ls
COMMAND otool ARGS -D libmariadbcpp.dylib
COMMAND install_name_tool ARGS -change libmariadbcpp.dylib @rpath/libmariadbcpp.dylib dCommonTests
COMMAND otool ARGS -L dCommonTests
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
if(MSVC)
add_dependencies(dCommonTests zlib_tests)
endif()
# Apple needs some special linkage for the mariadb connector for tests.
DoAppleMariaDBCopy(dCommonTests ${CMAKE_CURRENT_BINARY_DIR})
# Link needed libraries
target_link_libraries(dCommonTests ${COMMON_LIBRARIES} GTest::gtest_main)

View File

@@ -15,12 +15,7 @@ add_executable(dGameTests ${DGAMETEST_SOURCES})
add_dependencies(dGameTests conncpp_tests)
# Apple needs some special linkage for the mariadb connector for tests.
if(APPLE)
add_custom_command(TARGET dGameTests POST_BUILD
COMMAND install_name_tool ARGS -change libmariadbcpp.dylib @rpath/libmariadbcpp.dylib dGameTests
COMMAND otool ARGS -L dGameTests
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
DoAppleMariaDBCopy(dGameTests ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(dGameTests ${COMMON_LIBRARIES} GTest::gtest_main
dGame dScripts dPhysics Detour Recast tinyxml2 dWorldServer dZoneManager dChatFilter dNavigation)