From 26e5bed55c5e1b393a3fdf7d86c833174559c90e Mon Sep 17 00:00:00 2001 From: Tim Leonard Date: Wed, 10 Jan 2024 21:11:01 +0000 Subject: [PATCH] Fixed up some discord messages for dark souls 2. --- .../PlayerData/DS2_PlayerDataManager.cpp | 34 +++++++++++++++++-- .../QuickMatch/DS2_QuickMatchManager.cpp | 18 ++++++++++ .../GameManagers/Signs/DS2_SignManager.cpp | 4 +-- .../GameManagers/Signs/DS3_SignManager.cpp | 4 +-- 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/Source/Server.DarkSouls2/Server/GameService/GameManagers/PlayerData/DS2_PlayerDataManager.cpp b/Source/Server.DarkSouls2/Server/GameService/GameManagers/PlayerData/DS2_PlayerDataManager.cpp index 0be6535e..86dc7b1e 100644 --- a/Source/Server.DarkSouls2/Server/GameService/GameManagers/PlayerData/DS2_PlayerDataManager.cpp +++ b/Source/Server.DarkSouls2/Server/GameService/GameManagers/PlayerData/DS2_PlayerDataManager.cpp @@ -265,9 +265,6 @@ MessageHandleResult DS2_PlayerDataManager::Handle_RequestUpdatePlayerStatus(Game return MessageHandleResult::Error; } - State.SetHasInitialState(true); - - #if 0 static DiffTracker Tracker; @@ -320,6 +317,37 @@ MessageHandleResult DS2_PlayerDataManager::Handle_RequestUpdatePlayerStatus(Game #endif + // Send discord notification when the user lights a bonfire. + if (State.GetPlayerStatus().has_stats_info()) + { + std::vector& litBonfires = State.GetLitBonfires_Mutable(); + + for (size_t i = 0; i < State.GetPlayerStatus().stats_info().unlocked_bonfires_size(); i++) + { + uint32_t bonfireId = State.GetPlayerStatus().stats_info().unlocked_bonfires(i); + if (auto Iter = std::find(litBonfires.begin(), litBonfires.end(), bonfireId); Iter == litBonfires.end()) + { + if (State.GetHasInitialState()) + { + std::string BonfireName = GetEnumString((DS2_BonfireId)bonfireId); + + LogS(Client->GetName().c_str(), "Has lit bonfire %i (%s).", bonfireId, BonfireName.c_str()); + + if (!BonfireName.empty()) + { + ServerInstance->SendDiscordNotice(Client->shared_from_this(), DiscordNoticeType::BonfireLit, + StringFormat("Lit the '%s' bonfire.", BonfireName.c_str()) + ); + } + } + + litBonfires.push_back(bonfireId); + } + } + } + + State.SetHasInitialState(true); + return MessageHandleResult::Handled; } diff --git a/Source/Server.DarkSouls2/Server/GameService/GameManagers/QuickMatch/DS2_QuickMatchManager.cpp b/Source/Server.DarkSouls2/Server/GameService/GameManagers/QuickMatch/DS2_QuickMatchManager.cpp index 9bdcb55f..d4a9a129 100644 --- a/Source/Server.DarkSouls2/Server/GameService/GameManagers/QuickMatch/DS2_QuickMatchManager.cpp +++ b/Source/Server.DarkSouls2/Server/GameService/GameManagers/QuickMatch/DS2_QuickMatchManager.cpp @@ -206,6 +206,24 @@ MessageHandleResult DS2_QuickMatchManager::Handle_RequestRegisterQuickMatch(Game return MessageHandleResult::Error; } + if (ServerInstance->GetConfig().SendDiscordNotice_QuickMatch) + { + std::string ModeName = ""; + switch (NewMatch->GameMode) + { + case DS2_Frpg2RequestMessage::QuickMatchGameMode::QuickMatchGameMode_Blue: ModeName = "Blue Sentinel"; break; + case DS2_Frpg2RequestMessage::QuickMatchGameMode::QuickMatchGameMode_Brotherhood: ModeName = "Brotherhood of Blood"; break; + } + + ServerInstance->SendDiscordNotice(Client->shared_from_this(), DiscordNoticeType::UndeadMatch, + StringFormat("Started a public '%s' undead match.", ModeName.c_str()), + 0, + { + { "Soul Memory", std::to_string(Client->GetPlayerState().GetSoulMemory()), true }, + } + ); + } + return MessageHandleResult::Handled; } diff --git a/Source/Server.DarkSouls2/Server/GameService/GameManagers/Signs/DS2_SignManager.cpp b/Source/Server.DarkSouls2/Server/GameService/GameManagers/Signs/DS2_SignManager.cpp index 625b594b..dcbf3133 100644 --- a/Source/Server.DarkSouls2/Server/GameService/GameManagers/Signs/DS2_SignManager.cpp +++ b/Source/Server.DarkSouls2/Server/GameService/GameManagers/Signs/DS2_SignManager.cpp @@ -262,7 +262,7 @@ MessageHandleResult DS2_SignManager::Handle_RequestCreateSign(GameClient* Client if (Sign->Type == DS2_Frpg2RequestMessage::SignType_RedSoapstone) { ServerInstance->SendDiscordNotice(Client->shared_from_this(), DiscordNoticeType::SummonSignPvP, - StringFormat("Placed a red summon sign in '%s'.", GetEnumString(Sign->OnlineAreaId).c_str()), + StringFormat("Placed a red summon sign in '%s'.", GetEnumString((DS2_OnlineAreaId)Sign->OnlineAreaId).c_str()), 0, { { "Soul Memory", std::to_string(Client->GetPlayerState().GetSoulMemory()), true }, @@ -272,7 +272,7 @@ MessageHandleResult DS2_SignManager::Handle_RequestCreateSign(GameClient* Client else { ServerInstance->SendDiscordNotice(Client->shared_from_this(), DiscordNoticeType::SummonSign, - StringFormat("Placed a summon sign in '%s'.", GetEnumString(Sign->OnlineAreaId).c_str()), + StringFormat("Placed a summon sign in '%s'.", GetEnumString((DS2_OnlineAreaId)Sign->OnlineAreaId).c_str()), 0, { { "Soul Memory", std::to_string(Client->GetPlayerState().GetSoulMemory()), true }, diff --git a/Source/Server.DarkSouls3/Server/GameService/GameManagers/Signs/DS3_SignManager.cpp b/Source/Server.DarkSouls3/Server/GameService/GameManagers/Signs/DS3_SignManager.cpp index a74ef5e2..1266a72a 100644 --- a/Source/Server.DarkSouls3/Server/GameService/GameManagers/Signs/DS3_SignManager.cpp +++ b/Source/Server.DarkSouls3/Server/GameService/GameManagers/Signs/DS3_SignManager.cpp @@ -269,7 +269,7 @@ MessageHandleResult DS3_SignManager::Handle_RequestCreateSign(GameClient* Client if (Sign->Type == DS3_Frpg2RequestMessage::SignType_RedSoapstone) { ServerInstance->SendDiscordNotice(Client->shared_from_this(), DiscordNoticeType::SummonSignPvP, - StringFormat("Placed a public red summon sign in '%s'.", GetEnumString(Sign->OnlineAreaId).c_str()), + StringFormat("Placed a public red summon sign in '%s'.", GetEnumString((DS3_OnlineAreaId)Sign->OnlineAreaId).c_str()), 0, { { "Soul Level", std::to_string(Client->GetPlayerState().GetSoulLevel()), true }, @@ -280,7 +280,7 @@ MessageHandleResult DS3_SignManager::Handle_RequestCreateSign(GameClient* Client else { ServerInstance->SendDiscordNotice(Client->shared_from_this(), DiscordNoticeType::SummonSign, - StringFormat("Placed a public summon sign in '%s'.", GetEnumString(Sign->OnlineAreaId).c_str()), + StringFormat("Placed a public summon sign in '%s'.", GetEnumString((DS3_OnlineAreaId)Sign->OnlineAreaId).c_str()), 0, { { "Soul Level", std::to_string(Client->GetPlayerState().GetSoulLevel()), true },