diff --git a/dDatabase/GameDatabase/ITables/IBehaviors.h b/dDatabase/GameDatabase/ITables/IBehaviors.h index 531167e2..e791ebef 100644 --- a/dDatabase/GameDatabase/ITables/IBehaviors.h +++ b/dDatabase/GameDatabase/ITables/IBehaviors.h @@ -8,15 +8,15 @@ class IBehaviors { public: struct Info { - int32_t behaviorId{}; + LWOOBJID behaviorId{}; uint32_t characterId{}; std::string behaviorInfo; }; // This Add also takes care of updating if it exists. virtual void AddBehavior(const Info& info) = 0; - virtual std::string GetBehavior(const int32_t behaviorId) = 0; - virtual void RemoveBehavior(const int32_t behaviorId) = 0; + virtual std::string GetBehavior(const LWOOBJID behaviorId) = 0; + virtual void RemoveBehavior(const LWOOBJID behaviorId) = 0; }; #endif //!IBEHAVIORS_H diff --git a/dDatabase/GameDatabase/ITables/IPropertyContents.h b/dDatabase/GameDatabase/ITables/IPropertyContents.h index e965e05c..82cbcc77 100644 --- a/dDatabase/GameDatabase/ITables/IPropertyContents.h +++ b/dDatabase/GameDatabase/ITables/IPropertyContents.h @@ -17,7 +17,7 @@ public: LWOOBJID id{}; LOT lot{}; uint32_t ugcId{}; - std::array behaviors{}; + std::array behaviors{}; }; // Inserts a new UGC model into the database. @@ -34,9 +34,9 @@ public: virtual void InsertNewPropertyModel(const LWOOBJID& propertyId, const IPropertyContents::Model& model, const std::string_view name) = 0; // Update the model position and rotation for the given property id. - virtual void UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array, 5>& behaviors) = 0; - virtual void UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array behaviorIDs) { - std::array, 5> behaviors; + virtual void UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array, 5>& behaviors) = 0; + virtual void UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array behaviorIDs) { + std::array, 5> behaviors; for (int32_t i = 0; i < behaviors.size(); i++) behaviors[i].first = behaviorIDs[i]; UpdateModel(modelID, position, rotation, behaviors); } diff --git a/dDatabase/GameDatabase/MySQL/MySQLDatabase.h b/dDatabase/GameDatabase/MySQL/MySQLDatabase.h index 9b0b38a6..13f84e9a 100644 --- a/dDatabase/GameDatabase/MySQL/MySQLDatabase.h +++ b/dDatabase/GameDatabase/MySQL/MySQLDatabase.h @@ -75,7 +75,7 @@ public: std::vector GetPropertyModels(const LWOOBJID& propertyId) override; void RemoveUnreferencedUgcModels() override; void InsertNewPropertyModel(const LWOOBJID& propertyId, const IPropertyContents::Model& model, const std::string_view name) override; - void UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array, 5>& behaviors) override; + void UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array, 5>& behaviors) override; void RemoveModel(const LWOOBJID& modelId) override; void UpdatePerformanceCost(const LWOZONEID& zoneId, const float performanceCost) override; void InsertNewBugReport(const IBugReports::Info& info) override; @@ -110,8 +110,8 @@ public: void InsertRewardCode(const uint32_t account_id, const uint32_t reward_code) override; std::vector GetRewardCodesByAccountID(const uint32_t account_id) override; void AddBehavior(const IBehaviors::Info& info) override; - std::string GetBehavior(const int32_t behaviorId) override; - void RemoveBehavior(const int32_t characterId) override; + std::string GetBehavior(const LWOOBJID behaviorId) override; + void RemoveBehavior(const LWOOBJID characterId) override; void UpdateAccountGmLevel(const uint32_t accountId, const eGameMasterLevel gmLevel) override; std::optional GetProperties(const IProperty::PropertyLookup& params) override; std::vector GetDescendingLeaderboard(const uint32_t activityId) override; diff --git a/dDatabase/GameDatabase/MySQL/Tables/Behaviors.cpp b/dDatabase/GameDatabase/MySQL/Tables/Behaviors.cpp index f4647865..01a2eb6e 100644 --- a/dDatabase/GameDatabase/MySQL/Tables/Behaviors.cpp +++ b/dDatabase/GameDatabase/MySQL/Tables/Behaviors.cpp @@ -9,11 +9,11 @@ void MySQLDatabase::AddBehavior(const IBehaviors::Info& info) { ); } -void MySQLDatabase::RemoveBehavior(const int32_t behaviorId) { +void MySQLDatabase::RemoveBehavior(const LWOOBJID behaviorId) { ExecuteDelete("DELETE FROM behaviors WHERE behavior_id = ?", behaviorId); } -std::string MySQLDatabase::GetBehavior(const int32_t behaviorId) { +std::string MySQLDatabase::GetBehavior(const LWOOBJID behaviorId) { auto result = ExecuteSelect("SELECT behavior_info FROM behaviors WHERE behavior_id = ?", behaviorId); return result->next() ? result->getString("behavior_info").c_str() : ""; } diff --git a/dDatabase/GameDatabase/MySQL/Tables/PropertyContents.cpp b/dDatabase/GameDatabase/MySQL/Tables/PropertyContents.cpp index fe63fc49..44394518 100644 --- a/dDatabase/GameDatabase/MySQL/Tables/PropertyContents.cpp +++ b/dDatabase/GameDatabase/MySQL/Tables/PropertyContents.cpp @@ -20,11 +20,11 @@ std::vector MySQLDatabase::GetPropertyModels(const LWO model.rotation.y = result->getFloat("ry"); model.rotation.z = result->getFloat("rz"); model.ugcId = result->getUInt64("ugc_id"); - model.behaviors[0] = result->getInt("behavior_1"); - model.behaviors[1] = result->getInt("behavior_2"); - model.behaviors[2] = result->getInt("behavior_3"); - model.behaviors[3] = result->getInt("behavior_4"); - model.behaviors[4] = result->getInt("behavior_5"); + model.behaviors[0] = result->getUInt64("behavior_1"); + model.behaviors[1] = result->getUInt64("behavior_2"); + model.behaviors[2] = result->getUInt64("behavior_3"); + model.behaviors[3] = result->getUInt64("behavior_4"); + model.behaviors[4] = result->getUInt64("behavior_5"); toReturn.push_back(std::move(model)); } @@ -52,7 +52,7 @@ void MySQLDatabase::InsertNewPropertyModel(const LWOOBJID& propertyId, const IPr } } -void MySQLDatabase::UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array, 5>& behaviors) { +void MySQLDatabase::UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array, 5>& behaviors) { ExecuteUpdate( "UPDATE properties_contents SET x = ?, y = ?, z = ?, rx = ?, ry = ?, rz = ?, rw = ?, " "behavior_1 = ?, behavior_2 = ?, behavior_3 = ?, behavior_4 = ?, behavior_5 = ? WHERE id = ?;", @@ -79,11 +79,11 @@ IPropertyContents::Model MySQLDatabase::GetModel(const LWOOBJID modelID) { model.rotation.y = result->getFloat("ry"); model.rotation.z = result->getFloat("rz"); model.ugcId = result->getUInt64("ugc_id"); - model.behaviors[0] = result->getInt("behavior_1"); - model.behaviors[1] = result->getInt("behavior_2"); - model.behaviors[2] = result->getInt("behavior_3"); - model.behaviors[3] = result->getInt("behavior_4"); - model.behaviors[4] = result->getInt("behavior_5"); + model.behaviors[0] = result->getUInt64("behavior_1"); + model.behaviors[1] = result->getUInt64("behavior_2"); + model.behaviors[2] = result->getUInt64("behavior_3"); + model.behaviors[3] = result->getUInt64("behavior_4"); + model.behaviors[4] = result->getUInt64("behavior_5"); } return model; diff --git a/dDatabase/GameDatabase/SQLite/SQLiteDatabase.h b/dDatabase/GameDatabase/SQLite/SQLiteDatabase.h index f6c545af..4112f87d 100644 --- a/dDatabase/GameDatabase/SQLite/SQLiteDatabase.h +++ b/dDatabase/GameDatabase/SQLite/SQLiteDatabase.h @@ -73,7 +73,7 @@ public: std::vector GetPropertyModels(const LWOOBJID& propertyId) override; void RemoveUnreferencedUgcModels() override; void InsertNewPropertyModel(const LWOOBJID& propertyId, const IPropertyContents::Model& model, const std::string_view name) override; - void UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array, 5>& behaviors) override; + void UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array, 5>& behaviors) override; void RemoveModel(const LWOOBJID& modelId) override; void UpdatePerformanceCost(const LWOZONEID& zoneId, const float performanceCost) override; void InsertNewBugReport(const IBugReports::Info& info) override; @@ -108,8 +108,8 @@ public: void InsertRewardCode(const uint32_t account_id, const uint32_t reward_code) override; std::vector GetRewardCodesByAccountID(const uint32_t account_id) override; void AddBehavior(const IBehaviors::Info& info) override; - std::string GetBehavior(const int32_t behaviorId) override; - void RemoveBehavior(const int32_t characterId) override; + std::string GetBehavior(const LWOOBJID behaviorId) override; + void RemoveBehavior(const LWOOBJID characterId) override; void UpdateAccountGmLevel(const uint32_t accountId, const eGameMasterLevel gmLevel) override; std::optional GetProperties(const IProperty::PropertyLookup& params) override; std::vector GetDescendingLeaderboard(const uint32_t activityId) override; diff --git a/dDatabase/GameDatabase/SQLite/Tables/Behaviors.cpp b/dDatabase/GameDatabase/SQLite/Tables/Behaviors.cpp index 05cadbcd..849338c1 100644 --- a/dDatabase/GameDatabase/SQLite/Tables/Behaviors.cpp +++ b/dDatabase/GameDatabase/SQLite/Tables/Behaviors.cpp @@ -9,11 +9,11 @@ void SQLiteDatabase::AddBehavior(const IBehaviors::Info& info) { ); } -void SQLiteDatabase::RemoveBehavior(const int32_t behaviorId) { +void SQLiteDatabase::RemoveBehavior(const LWOOBJID behaviorId) { ExecuteDelete("DELETE FROM behaviors WHERE behavior_id = ?", behaviorId); } -std::string SQLiteDatabase::GetBehavior(const int32_t behaviorId) { +std::string SQLiteDatabase::GetBehavior(const LWOOBJID behaviorId) { auto [_, result] = ExecuteSelect("SELECT behavior_info FROM behaviors WHERE behavior_id = ?", behaviorId); return !result.eof() ? result.getStringField("behavior_info") : ""; } diff --git a/dDatabase/GameDatabase/SQLite/Tables/PropertyContents.cpp b/dDatabase/GameDatabase/SQLite/Tables/PropertyContents.cpp index 960e1113..a04f3536 100644 --- a/dDatabase/GameDatabase/SQLite/Tables/PropertyContents.cpp +++ b/dDatabase/GameDatabase/SQLite/Tables/PropertyContents.cpp @@ -19,11 +19,11 @@ std::vector SQLiteDatabase::GetPropertyModels(const LW model.rotation.y = result.getFloatField("ry"); model.rotation.z = result.getFloatField("rz"); model.ugcId = result.getInt64Field("ugc_id"); - model.behaviors[0] = result.getIntField("behavior_1"); - model.behaviors[1] = result.getIntField("behavior_2"); - model.behaviors[2] = result.getIntField("behavior_3"); - model.behaviors[3] = result.getIntField("behavior_4"); - model.behaviors[4] = result.getIntField("behavior_5"); + model.behaviors[0] = result.getInt64Field("behavior_1"); + model.behaviors[1] = result.getInt64Field("behavior_2"); + model.behaviors[2] = result.getInt64Field("behavior_3"); + model.behaviors[3] = result.getInt64Field("behavior_4"); + model.behaviors[4] = result.getInt64Field("behavior_5"); toReturn.push_back(std::move(model)); result.nextRow(); @@ -52,7 +52,7 @@ void SQLiteDatabase::InsertNewPropertyModel(const LWOOBJID& propertyId, const IP } } -void SQLiteDatabase::UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array, 5>& behaviors) { +void SQLiteDatabase::UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array, 5>& behaviors) { ExecuteUpdate( "UPDATE properties_contents SET x = ?, y = ?, z = ?, rx = ?, ry = ?, rz = ?, rw = ?, " "behavior_1 = ?, behavior_2 = ?, behavior_3 = ?, behavior_4 = ?, behavior_5 = ? WHERE id = ?;", @@ -80,11 +80,11 @@ IPropertyContents::Model SQLiteDatabase::GetModel(const LWOOBJID modelID) { model.rotation.y = result.getFloatField("ry"); model.rotation.z = result.getFloatField("rz"); model.ugcId = result.getInt64Field("ugc_id"); - model.behaviors[0] = result.getIntField("behavior_1"); - model.behaviors[1] = result.getIntField("behavior_2"); - model.behaviors[2] = result.getIntField("behavior_3"); - model.behaviors[3] = result.getIntField("behavior_4"); - model.behaviors[4] = result.getIntField("behavior_5"); + model.behaviors[0] = result.getInt64Field("behavior_1"); + model.behaviors[1] = result.getInt64Field("behavior_2"); + model.behaviors[2] = result.getInt64Field("behavior_3"); + model.behaviors[3] = result.getInt64Field("behavior_4"); + model.behaviors[4] = result.getInt64Field("behavior_5"); } while (result.nextRow()); } diff --git a/dDatabase/GameDatabase/TestSQL/TestSQLDatabase.cpp b/dDatabase/GameDatabase/TestSQL/TestSQLDatabase.cpp index 01b3961f..8dd03f27 100644 --- a/dDatabase/GameDatabase/TestSQL/TestSQLDatabase.cpp +++ b/dDatabase/GameDatabase/TestSQL/TestSQLDatabase.cpp @@ -168,7 +168,7 @@ void TestSQLDatabase::InsertNewPropertyModel(const LWOOBJID& propertyId, const I } -void TestSQLDatabase::UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array, 5>& behaviors) { +void TestSQLDatabase::UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array, 5>& behaviors) { } @@ -292,11 +292,11 @@ void TestSQLDatabase::AddBehavior(const IBehaviors::Info& info) { } -std::string TestSQLDatabase::GetBehavior(const int32_t behaviorId) { +std::string TestSQLDatabase::GetBehavior(const LWOOBJID behaviorId) { return {}; } -void TestSQLDatabase::RemoveBehavior(const int32_t behaviorId) { +void TestSQLDatabase::RemoveBehavior(const LWOOBJID behaviorId) { } diff --git a/dDatabase/GameDatabase/TestSQL/TestSQLDatabase.h b/dDatabase/GameDatabase/TestSQL/TestSQLDatabase.h index 8016f333..59f7fe08 100644 --- a/dDatabase/GameDatabase/TestSQL/TestSQLDatabase.h +++ b/dDatabase/GameDatabase/TestSQL/TestSQLDatabase.h @@ -52,7 +52,7 @@ class TestSQLDatabase : public GameDatabase { std::vector GetPropertyModels(const LWOOBJID& propertyId) override; void RemoveUnreferencedUgcModels() override; void InsertNewPropertyModel(const LWOOBJID& propertyId, const IPropertyContents::Model& model, const std::string_view name) override; - void UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array, 5>& behaviors) override; + void UpdateModel(const LWOOBJID& modelID, const NiPoint3& position, const NiQuaternion& rotation, const std::array, 5>& behaviors) override; void RemoveModel(const LWOOBJID& modelId) override; void UpdatePerformanceCost(const LWOZONEID& zoneId, const float performanceCost) override; void InsertNewBugReport(const IBugReports::Info& info) override; @@ -87,8 +87,8 @@ class TestSQLDatabase : public GameDatabase { void InsertRewardCode(const uint32_t account_id, const uint32_t reward_code) override; std::vector GetRewardCodesByAccountID(const uint32_t account_id) override; void AddBehavior(const IBehaviors::Info& info) override; - std::string GetBehavior(const int32_t behaviorId) override; - void RemoveBehavior(const int32_t behaviorId) override; + std::string GetBehavior(const LWOOBJID behaviorId) override; + void RemoveBehavior(const LWOOBJID behaviorId) override; void UpdateAccountGmLevel(const uint32_t accountId, const eGameMasterLevel gmLevel) override; std::optional GetProperties(const IProperty::PropertyLookup& params) override { return {}; }; std::vector GetDescendingLeaderboard(const uint32_t activityId) override { return {}; }; diff --git a/dGame/dComponents/ModelComponent.cpp b/dGame/dComponents/ModelComponent.cpp index 250365b2..c74a67b6 100644 --- a/dGame/dComponents/ModelComponent.cpp +++ b/dGame/dComponents/ModelComponent.cpp @@ -67,7 +67,7 @@ void ModelComponent::LoadBehaviors() { for (const auto& behavior : behaviors) { if (behavior.empty()) continue; - const auto behaviorId = GeneralUtils::TryParse(behavior); + const auto behaviorId = GeneralUtils::TryParse(behavior); if (!behaviorId.has_value() || behaviorId.value() == 0) continue; LOG_DEBUG("Loading behavior %d", behaviorId.value()); @@ -78,7 +78,7 @@ void ModelComponent::LoadBehaviors() { tinyxml2::XMLDocument behaviorXml; auto res = behaviorXml.Parse(behaviorStr.c_str(), behaviorStr.size()); - LOG_DEBUG("Behavior %i %d: %s", res, behaviorId.value(), behaviorStr.c_str()); + LOG_DEBUG("Behavior %llu %d: %s", res, behaviorId.value(), behaviorStr.c_str()); const auto* const behaviorRoot = behaviorXml.FirstChildElement("Behavior"); if (!behaviorRoot) { @@ -116,8 +116,11 @@ void ModelComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialU if (bIsInitialUpdate) outBitStream.Write0(); // We are not writing model editing info } -void ModelComponent::UpdatePendingBehaviorId(const int32_t newId) { - for (auto& behavior : m_Behaviors) if (behavior.GetBehaviorId() == -1) behavior.SetBehaviorId(newId); +void ModelComponent::UpdatePendingBehaviorId(const LWOOBJID newId, const LWOOBJID oldId) { + for (auto& behavior : m_Behaviors) { + if (behavior.GetBehaviorId() != oldId) continue; + behavior.SetBehaviorId(newId); + } } void ModelComponent::SendBehaviorListToClient(AMFArrayValue& args) const { @@ -134,7 +137,7 @@ void ModelComponent::VerifyBehaviors() { for (auto& behavior : m_Behaviors) behavior.VerifyLastEditedState(); } -void ModelComponent::SendBehaviorBlocksToClient(int32_t behaviorToSend, AMFArrayValue& args) const { +void ModelComponent::SendBehaviorBlocksToClient(const LWOOBJID behaviorToSend, AMFArrayValue& args) const { args.Insert("BehaviorID", std::to_string(behaviorToSend)); args.Insert("objectID", std::to_string(m_Parent->GetObjectID())); for (auto& behavior : m_Behaviors) if (behavior.GetBehaviorId() == behaviorToSend) behavior.SendBehaviorBlocksToClient(args); @@ -165,8 +168,8 @@ void ModelComponent::MoveToInventory(MoveToInventoryMessage& msg) { } } -std::array, 5> ModelComponent::GetBehaviorsForSave() const { - std::array, 5> toReturn{}; +std::array, 5> ModelComponent::GetBehaviorsForSave() const { + std::array, 5> toReturn{}; for (auto i = 0; i < m_Behaviors.size(); i++) { const auto& behavior = m_Behaviors.at(i); if (behavior.GetBehaviorId() == -1) continue; diff --git a/dGame/dComponents/ModelComponent.h b/dGame/dComponents/ModelComponent.h index b67a53d2..029bc371 100644 --- a/dGame/dComponents/ModelComponent.h +++ b/dGame/dComponents/ModelComponent.h @@ -97,7 +97,7 @@ public: void MoveToInventory(MoveToInventoryMessage& msg); // Updates the pending behavior ID to the new ID. - void UpdatePendingBehaviorId(const int32_t newId); + void UpdatePendingBehaviorId(const LWOOBJID newId, const LWOOBJID oldId); // Sends the behavior list to the client. @@ -112,11 +112,11 @@ public: */ void SendBehaviorListToClient(AMFArrayValue& args) const; - void SendBehaviorBlocksToClient(int32_t behaviorToSend, AMFArrayValue& args) const; + void SendBehaviorBlocksToClient(const LWOOBJID behaviorToSend, AMFArrayValue& args) const; void VerifyBehaviors(); - std::array, 5> GetBehaviorsForSave() const; + std::array, 5> GetBehaviorsForSave() const; const std::vector& GetBehaviors() const { return m_Behaviors; }; diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp index 0b0b9eaf..cccf4bcf 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp @@ -10,5 +10,5 @@ AddActionMessage::AddActionMessage(const AMFArrayValue& arguments) m_Action = Action{ *actionValue }; - LOG_DEBUG("actionIndex %i stripId %i stateId %i type %s valueParameterName %s valueParameterString %s valueParameterDouble %f m_BehaviorId %i", m_ActionIndex, m_ActionContext.GetStripId(), m_ActionContext.GetStateId(), m_Action.GetType().data(), m_Action.GetValueParameterName().data(), m_Action.GetValueParameterString().data(), m_Action.GetValueParameterDouble(), m_BehaviorId); + LOG_DEBUG("actionIndex %i stripId %i stateId %i type %s valueParameterName %s valueParameterString %s valueParameterDouble %f m_BehaviorId %llu", m_ActionIndex, m_ActionContext.GetStripId(), m_ActionContext.GetStateId(), m_Action.GetType().data(), m_Action.GetValueParameterName().data(), m_Action.GetValueParameterString().data(), m_Action.GetValueParameterDouble(), m_BehaviorId); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp index 45e3d974..895f6103 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp @@ -5,5 +5,5 @@ AddMessage::AddMessage(const AMFArrayValue& arguments) : BehaviorMessageBase{ ar if (!behaviorIndexValue) return; m_BehaviorIndex = static_cast(behaviorIndexValue->GetValue()); - LOG_DEBUG("behaviorId %i index %i", m_BehaviorId, m_BehaviorIndex); + LOG_DEBUG("behaviorId %llu index %i", m_BehaviorId, m_BehaviorIndex); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp index c2933fbf..92b4b03b 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp @@ -19,7 +19,7 @@ AddStripMessage::AddStripMessage(const AMFArrayValue& arguments) m_ActionsToAdd.emplace_back(*actionValue); - LOG_DEBUG("xPosition %f yPosition %f stripId %i stateId %i behaviorId %i t %s valueParameterName %s valueParameterString %s valueParameterDouble %f", m_Position.GetX(), m_Position.GetY(), m_ActionContext.GetStripId(), m_ActionContext.GetStateId(), m_BehaviorId, m_ActionsToAdd.back().GetType().data(), m_ActionsToAdd.back().GetValueParameterName().data(), m_ActionsToAdd.back().GetValueParameterString().data(), m_ActionsToAdd.back().GetValueParameterDouble()); + LOG_DEBUG("xPosition %f yPosition %f stripId %i stateId %i behaviorId %llu t %s valueParameterName %s valueParameterString %s valueParameterDouble %f", m_Position.GetX(), m_Position.GetY(), m_ActionContext.GetStripId(), m_ActionContext.GetStateId(), m_BehaviorId, m_ActionsToAdd.back().GetType().data(), m_ActionsToAdd.back().GetValueParameterName().data(), m_ActionsToAdd.back().GetValueParameterString().data(), m_ActionsToAdd.back().GetValueParameterDouble()); } LOG_DEBUG("number of actions %i", m_ActionsToAdd.size()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.cpp index fb26f37f..ad9df673 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.cpp @@ -4,14 +4,14 @@ #include "BehaviorStates.h" #include "dCommonVars.h" -int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(const AMFArrayValue& arguments) { +LWOOBJID BehaviorMessageBase::GetBehaviorIdFromArgument(const AMFArrayValue& arguments) { static constexpr std::string_view key = "BehaviorID"; const auto* const behaviorIDValue = arguments.Get(key); - int32_t behaviorId = DefaultBehaviorId; + LWOOBJID behaviorId = DefaultBehaviorId; if (behaviorIDValue && behaviorIDValue->GetValueType() == eAmf::String) { behaviorId = - GeneralUtils::TryParse(behaviorIDValue->GetValue()).value_or(behaviorId); + GeneralUtils::TryParse(behaviorIDValue->GetValue()).value_or(behaviorId); } else if (arguments.Get(key) && arguments.Get(key)->GetValueType() != eAmf::Undefined) { throw std::invalid_argument("Unable to find behavior ID"); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h index cc8c293d..9c13b2d4 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h @@ -11,19 +11,19 @@ enum class BehaviorState : uint32_t; /** * @brief The behaviorID target of this ControlBehaviors message - * + * */ class BehaviorMessageBase { public: - static constexpr int32_t DefaultBehaviorId{ -1 }; + static constexpr LWOOBJID DefaultBehaviorId{ -1 }; BehaviorMessageBase(const AMFArrayValue& arguments) : m_BehaviorId{ GetBehaviorIdFromArgument(arguments) } {} - [[nodiscard]] int32_t GetBehaviorId() const noexcept { return m_BehaviorId; } + [[nodiscard]] LWOOBJID GetBehaviorId() const noexcept { return m_BehaviorId; } [[nodiscard]] bool IsDefaultBehaviorId() const noexcept { return m_BehaviorId == DefaultBehaviorId; } protected: - [[nodiscard]] int32_t GetBehaviorIdFromArgument(const AMFArrayValue& arguments); + [[nodiscard]] LWOOBJID GetBehaviorIdFromArgument(const AMFArrayValue& arguments); [[nodiscard]] int32_t GetActionIndexFromArgument(const AMFArrayValue& arguments, const std::string_view keyName = "actionIndex") const; - int32_t m_BehaviorId{ DefaultBehaviorId }; + LWOOBJID m_BehaviorId{ DefaultBehaviorId }; }; #endif //!__BEHAVIORMESSAGEBASE__H__ diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.cpp index 1efc5aee..b505ca79 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.cpp @@ -6,6 +6,6 @@ MergeStripsMessage::MergeStripsMessage(const AMFArrayValue& arguments) , m_SourceActionContext{ arguments, "srcStateID", "srcStripID" } , m_DestinationActionContext{ arguments, "dstStateID", "dstStripID" } { - LOG_DEBUG("srcstripId %i dststripId %i srcstateId %i dststateId %i dstactionIndex %i behaviorId %i", m_SourceActionContext.GetStripId(), m_DestinationActionContext.GetStripId(), m_SourceActionContext.GetStateId(), m_DestinationActionContext.GetStateId(), m_DstActionIndex, m_BehaviorId); + LOG_DEBUG("srcstripId %i dststripId %i srcstateId %i dststateId %i dstactionIndex %i behaviorId %llu", m_SourceActionContext.GetStripId(), m_DestinationActionContext.GetStripId(), m_SourceActionContext.GetStateId(), m_DestinationActionContext.GetStateId(), m_DstActionIndex, m_BehaviorId); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.cpp index 9791bc2a..bcce9a5a 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.cpp @@ -7,5 +7,5 @@ MigrateActionsMessage::MigrateActionsMessage(const AMFArrayValue& arguments) , m_SourceActionContext{ arguments, "srcStateID", "srcStripID" } , m_DestinationActionContext{ arguments, "dstStateID", "dstStripID" } { - LOG_DEBUG("srcactionIndex %i dstactionIndex %i srcstripId %i dststripId %i srcstateId %i dststateId %i behaviorId %i", m_SrcActionIndex, m_DstActionIndex, m_SourceActionContext.GetStripId(), m_DestinationActionContext.GetStripId(), m_SourceActionContext.GetStateId(), m_DestinationActionContext.GetStateId(), m_BehaviorId); + LOG_DEBUG("srcactionIndex %i dstactionIndex %i srcstripId %i dststripId %i srcstateId %i dststateId %i behaviorId %llu", m_SrcActionIndex, m_DstActionIndex, m_SourceActionContext.GetStripId(), m_DestinationActionContext.GetStripId(), m_SourceActionContext.GetStateId(), m_DestinationActionContext.GetStateId(), m_BehaviorId); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp index cab5c4a3..e8d16283 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp @@ -5,5 +5,5 @@ MoveToInventoryMessage::MoveToInventoryMessage(const AMFArrayValue& arguments) : if (!behaviorIndexValue) return; m_BehaviorIndex = static_cast(behaviorIndexValue->GetValue()); - LOG_DEBUG("behaviorId %i behaviorIndex %i", m_BehaviorId, m_BehaviorIndex); + LOG_DEBUG("behaviorId %llu behaviorIndex %i", m_BehaviorId, m_BehaviorIndex); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.cpp index 99fe6f6a..b87a0523 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.cpp @@ -6,5 +6,5 @@ RearrangeStripMessage::RearrangeStripMessage(const AMFArrayValue& arguments) , m_DstActionIndex{ GetActionIndexFromArgument(arguments, "dstActionIndex") } , m_ActionContext{ arguments } { - LOG_DEBUG("srcactionIndex %i dstactionIndex %i stripId %i behaviorId %i stateId %i", m_SrcActionIndex, m_DstActionIndex, m_ActionContext.GetStripId(), m_BehaviorId, m_ActionContext.GetStateId()); + LOG_DEBUG("srcactionIndex %i dstactionIndex %i stripId %i behaviorId %llu stateId %i", m_SrcActionIndex, m_DstActionIndex, m_ActionContext.GetStripId(), m_BehaviorId, m_ActionContext.GetStateId()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.cpp index 15407012..206988b0 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.cpp @@ -5,5 +5,5 @@ RemoveActionsMessage::RemoveActionsMessage(const AMFArrayValue& arguments) , m_ActionIndex{ GetActionIndexFromArgument(arguments) } , m_ActionContext{ arguments } { - LOG_DEBUG("behaviorId %i actionIndex %i stripId %i stateId %i", m_BehaviorId, m_ActionIndex, m_ActionContext.GetStripId(), m_ActionContext.GetStateId()); + LOG_DEBUG("behaviorId %llu actionIndex %i stripId %i stateId %i", m_BehaviorId, m_ActionIndex, m_ActionContext.GetStripId(), m_ActionContext.GetStateId()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.cpp index f0275377..3de22b65 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.cpp @@ -4,5 +4,5 @@ RemoveStripMessage::RemoveStripMessage(const AMFArrayValue& arguments) : BehaviorMessageBase{ arguments } , m_ActionContext{ arguments } { - LOG_DEBUG("stripId %i stateId %i behaviorId %i", m_ActionContext.GetStripId(), m_ActionContext.GetStateId(), m_BehaviorId); + LOG_DEBUG("stripId %i stateId %i behaviorId %llu", m_ActionContext.GetStripId(), m_ActionContext.GetStateId(), m_BehaviorId); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp index 82d88bf8..93f21b1e 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp @@ -5,5 +5,5 @@ RenameMessage::RenameMessage(const AMFArrayValue& arguments) : BehaviorMessageBa if (!nameAmf) return; m_Name = nameAmf->GetValue(); - LOG_DEBUG("behaviorId %i n %s", m_BehaviorId, m_Name.c_str()); + LOG_DEBUG("behaviorId %llu n %s", m_BehaviorId, m_Name.c_str()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.cpp index 6003c982..bd95a71f 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.cpp @@ -7,5 +7,5 @@ SplitStripMessage::SplitStripMessage(const AMFArrayValue& arguments) , m_DestinationActionContext{ arguments, "dstStateID", "dstStripID" } , m_DestinationPosition{ arguments, "dstStripUI" } { - LOG_DEBUG("behaviorId %i xPosition %f yPosition %f sourceStrip %i destinationStrip %i sourceState %i destinationState %i srcActindex %i", m_BehaviorId, m_DestinationPosition.GetX(), m_DestinationPosition.GetY(), m_SourceActionContext.GetStripId(), m_DestinationActionContext.GetStripId(), m_SourceActionContext.GetStateId(), m_DestinationActionContext.GetStateId(), m_SrcActionIndex); + LOG_DEBUG("behaviorId %llu xPosition %f yPosition %f sourceStrip %i destinationStrip %i sourceState %i destinationState %i srcActindex %i", m_BehaviorId, m_DestinationPosition.GetX(), m_DestinationPosition.GetY(), m_SourceActionContext.GetStripId(), m_DestinationActionContext.GetStripId(), m_SourceActionContext.GetStateId(), m_DestinationActionContext.GetStateId(), m_SrcActionIndex); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp index 04111a7d..2f0f8ad4 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp @@ -12,5 +12,5 @@ UpdateActionMessage::UpdateActionMessage(const AMFArrayValue& arguments) m_Action = Action{ *actionValue }; - LOG_DEBUG("type %s valueParameterName %s valueParameterString %s valueParameterDouble %f behaviorId %i actionIndex %i stripId %i stateId %i", m_Action.GetType().data(), m_Action.GetValueParameterName().data(), m_Action.GetValueParameterString().data(), m_Action.GetValueParameterDouble(), m_BehaviorId, m_ActionIndex, m_ActionContext.GetStripId(), m_ActionContext.GetStateId()); + LOG_DEBUG("type %s valueParameterName %s valueParameterString %s valueParameterDouble %f behaviorId %llu actionIndex %i stripId %i stateId %i", m_Action.GetType().data(), m_Action.GetValueParameterName().data(), m_Action.GetValueParameterString().data(), m_Action.GetValueParameterDouble(), m_BehaviorId, m_ActionIndex, m_ActionContext.GetStripId(), m_ActionContext.GetStateId()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.cpp index badb8c7a..2aa4bf50 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.cpp @@ -5,5 +5,5 @@ UpdateStripUiMessage::UpdateStripUiMessage(const AMFArrayValue& arguments) , m_Position{ arguments } , m_ActionContext{ arguments } { - LOG_DEBUG("xPosition %f yPosition %f stripId %i stateId %i behaviorId %i", m_Position.GetX(), m_Position.GetY(), m_ActionContext.GetStripId(), m_ActionContext.GetStateId(), m_BehaviorId); + LOG_DEBUG("xPosition %f yPosition %f stripId %i stateId %i behaviorId %llu", m_Position.GetX(), m_Position.GetY(), m_ActionContext.GetStripId(), m_ActionContext.GetStateId(), m_BehaviorId); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviors.cpp b/dGame/dPropertyBehaviors/ControlBehaviors.cpp index 756a615c..27ff0d2f 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviors.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviors.cpp @@ -30,22 +30,27 @@ #include "SplitStripMessage.h" #include "UpdateActionMessage.h" #include "UpdateStripUiMessage.h" +#include "eObjectBits.h" void ControlBehaviors::RequestUpdatedID(ControlBehaviorContext& context) { + BehaviorMessageBase msgBase{ context.arguments }; + const auto oldBehaviorID = msgBase.GetBehaviorId(); ObjectIDManager::RequestPersistentID( - [context](uint32_t persistentId) { + [context, oldBehaviorID](uint32_t persistentId) { if (!context) { LOG("Model to update behavior ID for is null. Cannot update ID."); return; } + LWOOBJID persistentIdBig = persistentId; + GeneralUtils::SetBit(persistentIdBig, eObjectBits::CHARACTER); // This updates the behavior ID of the behavior should this be a new behavior AMFArrayValue args; - args.Insert("behaviorID", std::to_string(persistentId)); + args.Insert("behaviorID", std::to_string(persistentIdBig)); args.Insert("objectID", std::to_string(context.modelComponent->GetParent()->GetObjectID())); GameMessages::SendUIMessageServerToSingleClient(context.modelOwner, context.modelOwner->GetSystemAddress(), "UpdateBehaviorID", args); - context.modelComponent->UpdatePendingBehaviorId(persistentId); + context.modelComponent->UpdatePendingBehaviorId(persistentIdBig, oldBehaviorID); ControlBehaviors::Instance().SendBehaviorListToClient(context); }); diff --git a/dGame/dPropertyBehaviors/PropertyBehavior.h b/dGame/dPropertyBehaviors/PropertyBehavior.h index 67df78df..124d3f0e 100644 --- a/dGame/dPropertyBehaviors/PropertyBehavior.h +++ b/dGame/dPropertyBehaviors/PropertyBehavior.h @@ -27,8 +27,8 @@ public: void SendBehaviorListToClient(AMFArrayValue& args) const; void SendBehaviorBlocksToClient(AMFArrayValue& args) const; - [[nodiscard]] int32_t GetBehaviorId() const noexcept { return m_BehaviorId; } - void SetBehaviorId(int32_t id) noexcept { m_BehaviorId = id; } + [[nodiscard]] LWOOBJID GetBehaviorId() const noexcept { return m_BehaviorId; } + void SetBehaviorId(LWOOBJID id) noexcept { m_BehaviorId = id; } void Serialize(tinyxml2::XMLElement& behavior) const; void Deserialize(const tinyxml2::XMLElement& behavior); @@ -58,7 +58,7 @@ private: // The behavior id for this behavior. This is expected to be fully unique, however an id of -1 means this behavior was just created // and needs to be assigned an id. - int32_t m_BehaviorId = -1; + LWOOBJID m_BehaviorId = -1; }; #endif //!__PROPERTYBEHAVIOR__H__ diff --git a/migrations/dlu/mysql/20_behavior_ids_object_bits.sql b/migrations/dlu/mysql/20_behavior_ids_object_bits.sql new file mode 100644 index 00000000..9514545e --- /dev/null +++ b/migrations/dlu/mysql/20_behavior_ids_object_bits.sql @@ -0,0 +1,21 @@ +UPDATE behaviors SET behavior_id = behavior_id | 0x1000000000000000; +ALTER TABLE properties_contents MODIFY behavior_1 BIGINT DEFAULT 0; +ALTER TABLE properties_contents MODIFY behavior_2 BIGINT DEFAULT 0; +ALTER TABLE properties_contents MODIFY behavior_3 BIGINT DEFAULT 0; +ALTER TABLE properties_contents MODIFY behavior_4 BIGINT DEFAULT 0; +ALTER TABLE properties_contents MODIFY behavior_5 BIGINT DEFAULT 0; +UPDATE properties_contents SET + behavior_1 = behavior_1 | 0x1000000000000000 + WHERE behavior_1 != 0; +UPDATE properties_contents SET + behavior_2 = behavior_2 | 0x1000000000000000 + WHERE behavior_2 != 0; +UPDATE properties_contents SET + behavior_3 = behavior_3 | 0x1000000000000000 + WHERE behavior_3 != 0; +UPDATE properties_contents SET + behavior_4 = behavior_4 | 0x1000000000000000 + WHERE behavior_4 != 0; +UPDATE properties_contents SET + behavior_5 = behavior_5 | 0x1000000000000000 + WHERE behavior_5 != 0; diff --git a/migrations/dlu/sqlite/3_behavior_ids_object_bits.sql b/migrations/dlu/sqlite/3_behavior_ids_object_bits.sql new file mode 100644 index 00000000..0598326f --- /dev/null +++ b/migrations/dlu/sqlite/3_behavior_ids_object_bits.sql @@ -0,0 +1,31 @@ +UPDATE behaviors SET behavior_id = behavior_id | 0x1000000000000000; +ALTER TABLE properties_contents ADD COLUMN behavior_1_1 BIGINT DEFAULT 0; +ALTER TABLE properties_contents ADD COLUMN behavior_2_1 BIGINT DEFAULT 0; +ALTER TABLE properties_contents ADD COLUMN behavior_3_1 BIGINT DEFAULT 0; +ALTER TABLE properties_contents ADD COLUMN behavior_4_1 BIGINT DEFAULT 0; +ALTER TABLE properties_contents ADD COLUMN behavior_5_1 BIGINT DEFAULT 0; +UPDATE properties_contents SET + behavior_1_1 = behavior_1 | 0x1000000000000000 + WHERE behavior_1 != 0; +UPDATE properties_contents SET + behavior_2_1 = behavior_2 | 0x1000000000000000 + WHERE behavior_2 != 0; +UPDATE properties_contents SET + behavior_3_1 = behavior_3 | 0x1000000000000000 + WHERE behavior_3 != 0; +UPDATE properties_contents SET + behavior_4_1 = behavior_4 | 0x1000000000000000 + WHERE behavior_4 != 0; +UPDATE properties_contents SET + behavior_5_1 = behavior_5 | 0x1000000000000000 + WHERE behavior_5 != 0; +ALTER TABLE properties_contents DROP COLUMN behavior_1; +ALTER TABLE properties_contents DROP COLUMN behavior_2; +ALTER TABLE properties_contents DROP COLUMN behavior_3; +ALTER TABLE properties_contents DROP COLUMN behavior_4; +ALTER TABLE properties_contents DROP COLUMN behavior_5; +ALTER TABLE properties_contents RENAME COLUMN behavior_1_1 TO behavior_1; +ALTER TABLE properties_contents RENAME COLUMN behavior_2_1 TO behavior_2; +ALTER TABLE properties_contents RENAME COLUMN behavior_3_1 TO behavior_3; +ALTER TABLE properties_contents RENAME COLUMN behavior_4_1 TO behavior_4; +ALTER TABLE properties_contents RENAME COLUMN behavior_5_1 TO behavior_5;