diff --git a/dDatabase/GameDatabase/TestSQL/TestSQLDatabase.cpp b/dDatabase/GameDatabase/TestSQL/TestSQLDatabase.cpp index 0c07adde..064f857b 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::UpdateModelPositionRotation(const LWOOBJID& propertyId, const NiPoint3& position, const NiQuaternion& rotation) { +void TestSQLDatabase::UpdateModel(const LWOOBJID& propertyId, const NiPoint3& position, const NiQuaternion& rotation, const std::array, 5>& behaviors) { } @@ -288,3 +288,15 @@ std::vector TestSQLDatabase::GetRewardCodesByAccountID(const uint32_t return {}; } +void TestSQLDatabase::AddBehavior(const IBehaviors::Info& info) { + +} + +std::string TestSQLDatabase::GetBehavior(const int32_t behaviorId) { + return {}; +} + +void TestSQLDatabase::RemoveBehavior(const int32_t behaviorId) { + +} + diff --git a/dDatabase/GameDatabase/TestSQL/TestSQLDatabase.h b/dDatabase/GameDatabase/TestSQL/TestSQLDatabase.h index 085dc532..c7591942 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 UpdateModelPositionRotation(const LWOOBJID& propertyId, const NiPoint3& position, const NiQuaternion& rotation) override; + void UpdateModel(const LWOOBJID& propertyId, 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; @@ -86,6 +86,9 @@ class TestSQLDatabase : public GameDatabase { std::vector GetIgnoreList(const uint32_t playerId) override; void InsertRewardCode(const uint32_t account_id, const uint32_t reward_code) override; std::vector GetRewardCodesByAccountID(const uint32_t account_id) override; + virtual void AddBehavior(const IBehaviors::Info& info); + virtual std::string GetBehavior(const int32_t behaviorId); + virtual void RemoveBehavior(const int32_t behaviorId); }; #endif //!TESTSQLDATABASE_H diff --git a/tests/dGameTests/GameDependencies.h b/tests/dGameTests/GameDependencies.h index 49bafc74..9f8dbb2b 100644 --- a/tests/dGameTests/GameDependencies.h +++ b/tests/dGameTests/GameDependencies.h @@ -9,6 +9,8 @@ #include "EntityManager.h" #include "dConfig.h" #include "dZoneManager.h" +#include "GameDatabase/TestSQL/TestSQLDatabase.h" +#include "Database.h" #include class dZoneManager; @@ -38,6 +40,7 @@ protected: Game::entityManager = new EntityManager(); Game::zoneManager = new dZoneManager(); Game::zoneManager->LoadZone(LWOZONEID(1, 0, 0)); + Database::_setDatabase(new TestSQLDatabase()); // this new is managed by the Database // Create a CDClientManager instance and load from defaults CDClientManager::LoadValuesFromDefaults(); diff --git a/tests/dGameTests/dComponentsTests/SavingTests.cpp b/tests/dGameTests/dComponentsTests/SavingTests.cpp index 9debefe5..b21c86f9 100644 --- a/tests/dGameTests/dComponentsTests/SavingTests.cpp +++ b/tests/dGameTests/dComponentsTests/SavingTests.cpp @@ -64,6 +64,7 @@ TEST_F(SavingTest, CharacterComponentTest) { auto hairStylePrev = characterComponent->m_Character->GetHairStyle(); auto pantsColorPrev = characterComponent->m_Character->GetPantsColor(); auto leftHandPrev = characterComponent->m_Character->GetLeftHand(); + auto shirtStylePrev = characterComponent->m_Character->GetShirtStyle(); auto mouthPrev = characterComponent->m_Character->GetMouth(); auto rightHandPrev = characterComponent->m_Character->GetRightHand(); auto shirtColorPrev = characterComponent->m_Character->GetShirtColor(); @@ -75,7 +76,7 @@ TEST_F(SavingTest, CharacterComponentTest) { characterComponent = entity->AddComponent(character.get(), UNASSIGNED_SYSTEM_ADDRESS); characterComponent->LoadFromXml(entity->GetCharacter()->GetXMLDoc()); - // Check that the buff component is the same as before + // Check that the buff component is the same as before which means resaving data and loading it back in didn't change anything ASSERT_EQ(statsPrev, characterComponent->StatisticsToString()); ASSERT_EQ(claimCodesPrev, characterComponent->GetClaimCodes()); ASSERT_EQ(eyebrowsPrev, characterComponent->m_Character->GetEyebrows()); @@ -86,7 +87,27 @@ TEST_F(SavingTest, CharacterComponentTest) { ASSERT_EQ(leftHandPrev, characterComponent->m_Character->GetLeftHand()); ASSERT_EQ(mouthPrev, characterComponent->m_Character->GetMouth()); ASSERT_EQ(rightHandPrev, characterComponent->m_Character->GetRightHand()); + ASSERT_EQ(shirtStylePrev, characterComponent->m_Character->GetShirtStyle()); ASSERT_EQ(shirtColorPrev, characterComponent->m_Character->GetShirtColor()); + + // Check that no data was lost during the saving process. + ASSERT_EQ("32114;69;343;13;163;2;181;2;388;252;146;24451;25;9022;41898;42186;42524;4404;0;0;0;0;0;0;0;0;0;", characterComponent->StatisticsToString()); + + // need a variable because the macro does not support {} + const std::array correctCodes = { 1073741968, 0, 0, 0 }; + ASSERT_EQ(correctCodes, characterComponent->GetClaimCodes()); + ASSERT_EQ(1, characterComponent->m_Character->GetEyebrows()); + ASSERT_EQ(2, characterComponent->m_Character->GetEyes()); + ASSERT_EQ(9, characterComponent->m_Character->GetHairColor()); + ASSERT_EQ(8, characterComponent->m_Character->GetHairStyle()); + ASSERT_EQ(3, characterComponent->m_Character->GetPantsColor()); + ASSERT_EQ(27634704, characterComponent->m_Character->GetLeftHand()); + ASSERT_EQ(3, characterComponent->m_Character->GetMouth()); + ASSERT_EQ(27187396, characterComponent->m_Character->GetRightHand()); + ASSERT_EQ(13, characterComponent->m_Character->GetShirtColor()); + + // Fails currently due to not reading style from xml + // ASSERT_EQ(27, characterComponent->m_Character->GetShirtStyle()); // character->GetXMLDoc().Print(&printer); // std::string xmlDataModified(printer.CStr());