From 352f654ede30b1278ce6cc1d00624b04a00c4153 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 12 Feb 2022 21:02:52 -0800 Subject: [PATCH 1/4] Added GM in GameMessages --- dGame/dGameMessages/GameMessages.cpp | 12 ++++++++++++ dGame/dGameMessages/GameMessages.h | 1 + dNet/dMessageIdentifiers.h | 1 + 3 files changed, 14 insertions(+) diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index c327ab83..971f1d81 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -1516,6 +1516,18 @@ void GameMessages::SendRequestActivityEnter(LWOOBJID objectId, const SystemAddre SEND_PACKET } +void GameMessages::NotifyLevelRewards(LWOOBJID objectID, const SystemAddress& sysAddr, uint32_t level, bool sending_rewards) { + CBITSTREAM + CMSGHEADER + + bitStream.Write(objectID); + bitStream.Write(GAME_MSG::GAME_MSG_NOTIFY_LEVEL_REWARDS); + + bitStream.Write(level); + bitStream.Write(sending_rewards); + + SEND_PACKET +} void GameMessages::SendSetShootingGalleryParams(LWOOBJID objectId, const SystemAddress& sysAddr, float cameraFOV, diff --git a/dGame/dGameMessages/GameMessages.h b/dGame/dGameMessages/GameMessages.h index 430d48d9..87e3fc94 100644 --- a/dGame/dGameMessages/GameMessages.h +++ b/dGame/dGameMessages/GameMessages.h @@ -68,6 +68,7 @@ namespace GameMessages { void SendOfferMission(const LWOOBJID& entity, const SystemAddress& sysAddr, int32_t missionID, const LWOOBJID& offererID); void SendNotifyMission(Entity * entity, const SystemAddress& sysAddr, int missionID, int missionState, bool sendingRewards); void SendNotifyMissionTask(Entity * entity, const SystemAddress& sysAddr, int missionID, int taskMask, std::vector updates); + void NotifyLevelRewards(LWOOBJID objectID, const SystemAddress& sysAddr, uint32_t level, bool sending_rewards); void SendModifyLEGOScore(Entity* entity, const SystemAddress& sysAddr, int64_t score, eLootSourceType sourceType); void SendUIMessageServerToSingleClient(Entity* entity, const SystemAddress& sysAddr, const std::string& message, NDGFxValue args); diff --git a/dNet/dMessageIdentifiers.h b/dNet/dMessageIdentifiers.h index d4f4e62b..36e85df2 100644 --- a/dNet/dMessageIdentifiers.h +++ b/dNet/dMessageIdentifiers.h @@ -532,6 +532,7 @@ enum GAME_MSG : unsigned short { GAME_MSG_RESPONSE_MOVE_ITEM_BETWEEN_INVENTORY_TYPES = 1667, GAME_MSG_PLAYER_SET_CAMERA_CYCLING_MODE = 1676, GAME_MSG_NOTIFY_SERVER_LEVEL_PROCESSING_COMPLETE = 1734, + GAME_MSG_NOTIFY_LEVEL_REWARDS = 1735, GAME_MSG_MARK_INVENTORY_ITEM_AS_ACTIVE = 1767, END }; \ No newline at end of file From afa38ae890a428256736044ecf719b75590763fc Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 12 Feb 2022 21:03:04 -0800 Subject: [PATCH 2/4] Added call to GM in CharacterComponent --- dGame/dComponents/CharacterComponent.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index c7a216f3..d7a41a8b 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -12,6 +12,7 @@ #include "EntityManager.h" #include "PossessorComponent.h" #include "VehiclePhysicsComponent.h" +#include "GameMessages.h" CharacterComponent::CharacterComponent(Entity* parent, Character* character) : Component(parent) { m_Character = character; @@ -191,6 +192,7 @@ void CharacterComponent::HandleLevelUp() auto* rewardsTable = CDClientManager::Instance()->GetTable("Rewards"); const auto& rewards = rewardsTable->GetByLevelID(m_Level); + bool rewardingItem = rewards.size() > 0; auto* parent = m_Character->GetEntity(); @@ -214,29 +216,23 @@ void CharacterComponent::HandleLevelUp() case 0: inventoryComponent->AddItem(reward->value, reward->count); break; - case 4: { auto* items = inventoryComponent->GetInventory(ITEMS); items->SetSize(items->GetSize() + reward->value); } break; - case 9: controllablePhysicsComponent->SetSpeedMultiplier(static_cast(reward->value) / 500.0f); break; - case 11: - break; - case 12: break; - default: break; } - } - + } + GameMessages::NotifyLevelRewards(parent->GetObjectID(), parent->GetSystemAddress(), m_Level, rewardingItem); } void CharacterComponent::SetGMLevel(int gmlevel) { From 1c43d7f38c96b777d0a98c54f267fee1406b783c Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 20 Feb 2022 19:23:03 -0800 Subject: [PATCH 3/4] GameMessage is correct --- dGame/dGameMessages/GameMessages.cpp | 4 ++-- dGame/dGameMessages/GameMessages.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 971f1d81..a6cf4ed3 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -1516,12 +1516,12 @@ void GameMessages::SendRequestActivityEnter(LWOOBJID objectId, const SystemAddre SEND_PACKET } -void GameMessages::NotifyLevelRewards(LWOOBJID objectID, const SystemAddress& sysAddr, uint32_t level, bool sending_rewards) { +void GameMessages::NotifyLevelRewards(LWOOBJID objectID, const SystemAddress& sysAddr, int level, bool sending_rewards) { CBITSTREAM CMSGHEADER bitStream.Write(objectID); - bitStream.Write(GAME_MSG::GAME_MSG_NOTIFY_LEVEL_REWARDS); + bitStream.Write((uint16_t)GAME_MSG::GAME_MSG_NOTIFY_LEVEL_REWARDS); bitStream.Write(level); bitStream.Write(sending_rewards); diff --git a/dGame/dGameMessages/GameMessages.h b/dGame/dGameMessages/GameMessages.h index 87e3fc94..671c3b3a 100644 --- a/dGame/dGameMessages/GameMessages.h +++ b/dGame/dGameMessages/GameMessages.h @@ -68,7 +68,7 @@ namespace GameMessages { void SendOfferMission(const LWOOBJID& entity, const SystemAddress& sysAddr, int32_t missionID, const LWOOBJID& offererID); void SendNotifyMission(Entity * entity, const SystemAddress& sysAddr, int missionID, int missionState, bool sendingRewards); void SendNotifyMissionTask(Entity * entity, const SystemAddress& sysAddr, int missionID, int taskMask, std::vector updates); - void NotifyLevelRewards(LWOOBJID objectID, const SystemAddress& sysAddr, uint32_t level, bool sending_rewards); + void NotifyLevelRewards(LWOOBJID objectID, const SystemAddress& sysAddr, int level, bool sending_rewards); void SendModifyLEGOScore(Entity* entity, const SystemAddress& sysAddr, int64_t score, eLootSourceType sourceType); void SendUIMessageServerToSingleClient(Entity* entity, const SystemAddress& sysAddr, const std::string& message, NDGFxValue args); From 1c116fb0c4e6248ed2dfb8cad626147906cda255 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 20 Feb 2022 19:23:17 -0800 Subject: [PATCH 4/4] Sending rewards works fully --- dGame/dComponents/CharacterComponent.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index d7a41a8b..3daa437e 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -208,6 +208,8 @@ void CharacterComponent::HandleLevelUp() { return; } + // Tell the client we beginning to send level rewards. + if(rewardingItem) GameMessages::NotifyLevelRewards(parent->GetObjectID(), parent->GetSystemAddress(), m_Level, rewardingItem); for (auto* reward : rewards) { @@ -232,7 +234,8 @@ void CharacterComponent::HandleLevelUp() break; } } - GameMessages::NotifyLevelRewards(parent->GetObjectID(), parent->GetSystemAddress(), m_Level, rewardingItem); + // Tell the client we have finished sending level rewards. + if(rewardingItem) GameMessages::NotifyLevelRewards(parent->GetObjectID(), parent->GetSystemAddress(), m_Level, !rewardingItem); } void CharacterComponent::SetGMLevel(int gmlevel) {