fixed issues for newest version

This commit is contained in:
2025-01-24 17:13:52 -05:00
parent b4013b7024
commit ad39d53c58
4 changed files with 24 additions and 19 deletions

View File

@@ -93,11 +93,11 @@ public:
}
// Loads advancement information from the database into memory when players are logged in or server starts.
int32 LoadAdvencementRanks();
int32 LoadAdvancementRanks();
int32 LoadMaterialTypes();
int32 LoadPlayerAdvancements(Player* player);
// Methods for looking up advancment rank data
// Methods for looking up advancement rank data
MpAdvancementRank* GetAdvancementRank(uint32 rank, MpAdvancements advancement);
// Methods for updating and setting data related to current player advancements

View File

@@ -27,10 +27,19 @@ enum class MP_EVENT_CODE
};
// Send an error event to the client
bool SendEventError(Player* player, const std::string& method, MP_EVENT_CODE code, std::string message)
{
std::vector<std::string> clientError = { std::to_string(static_cast<int>(code)), message };
MpLogger::error("Event Processor) Sending client error: {} {}", code, message);
sMpClientDispatcher->Dispatch(MpClientEvent::Error, player, clientError);
return false;
}
class UpdateAdvancements : public MpEventInterface
{
public:
const std::string& EventName() const override
const std::string EventName() const override
{
return "UpgradeAdvancement";
}
@@ -72,7 +81,7 @@ class UpdateAdvancements : public MpEventInterface
if(! sAdvancementMgr->UpgradeAdvancement(player, static_cast<MpAdvancements>(advancementId), diceLevel, itemEntry1, itemEntry2, itemEntry3)) {
return SendEventError(player, EventName(),MP_EVENT_CODE::INVALID_ARGUMENT, "Failed to upgrade advancement for player " + player->GetName());
}
std::vector<std::string> eventData = {"0", "success"};
eventData = {"0", "success"};
// Send response back to the client
sMpClientDispatcher->Dispatch(MpClientEvent::UpgradeAdvancement, player, eventData);
@@ -84,7 +93,7 @@ class UpdateAdvancements : public MpEventInterface
class GetAdvancementRank : public MpEventInterface
{
public:
const std::string& EventName() const override
const std::string EventName() const override
{
return "GetAdvancementRank";
}
@@ -114,7 +123,7 @@ class GetAdvancementRank : public MpEventInterface
return SendEventError(player, EventName(),MP_EVENT_CODE::INVALID_ARGUMENT, "Failed to get advancement rank for player " + player->GetName());
}
std::vector<std::string> eventData = {std::to_string(rank->rank), std::to_string(rank->advancementId)};
eventData = {std::to_string(rank->rank), std::to_string(rank->advancementId)};
// Send response back to the client
sMpClientDispatcher->Dispatch(MpClientEvent::GetAdvancementRank, player, eventData);
@@ -123,15 +132,6 @@ class GetAdvancementRank : public MpEventInterface
}
};
// Send an error event to the client
bool SendEventError(Player* player, const std::string& method, MP_EVENT_CODE code, std::string message)
{
std::vector<std::string> clientError = { std::to_string(static_cast<int>(code)), message };
MpLogger::error("Event Processor) Sending client error: {}", clientError);
sMpClientDispatcher->Dispatch(MpClientEvent::Error, player, clientError);
return false;
}
void MP_Register_EventHandlers()
{
auto updateAdvancements = std::make_shared<UpdateAdvancements>();

View File

@@ -27,7 +27,7 @@ public:
virtual ~MpEventInterface() = default;
[[nodiscard]] virtual bool Execute(Player* player, std::vector<std::string>& args) = 0;
[[nodiscard]] virtual const std::string& EventName() const = 0;
[[nodiscard]] virtual const std::string EventName() const = 0;
};
using EventParseRslt = std::tuple<MpEvent, uint32_t, std::vector<std::string>>;

View File

@@ -1,5 +1,6 @@
#include "CharacterDatabase.h"
#include "MpDataStore.h"
#include "Chat.h"
#include "Group.h"
#include "MpLogger.h"
@@ -54,8 +55,9 @@ void MpDataStore::AddGroupData(Group *group, MpGroupData groupData) {
if(!player) {
MpLogger::error("AddGroupData called with null player in instance");
}
player->GetSession()->SendNotification("The group leader has changed the difficulty setting. You have been removed from the instance.");
ChatHandler(player->GetSession()).SendSysMessage("The group leader has changed the difficulty setting. You have been removed from the instance.");
//("The group leader has changed the difficulty setting. You have been removed from the instance.");
// player->GetSession()->SendNotification("The group leader has changed the difficulty setting. You have been removed from the instance.");
}
}
@@ -77,7 +79,10 @@ void MpDataStore::AddGroupData(Group *group, MpGroupData groupData) {
MpLogger::error("AddGroupData called with null player in instance");
}
player->GetSession()->SendNotification("The group leader has changed the difficulty setting. You have been removed from the instance.");
if(player) {
ChatHandler(player->GetSession()).SendSysMessage("The group leader has changed the difficulty setting. You have been removed from the instance.");
// player->GetSession()->SendNotification("The group leader has changed the difficulty setting. You have been removed from the instance."); -- previous implementation for older core users
}
}
}