mirror of
https://github.com/araxiaonline/mod-mythic-plus.git
synced 2026-06-13 03:02:24 -04:00
Adding data storage and commands
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
#include "Chat.h"
|
||||
#include "MpDataStore.h"
|
||||
#include "MpLogger.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
using namespace Acore::ChatCommands;
|
||||
|
||||
// make sure this is the new way to do this, i think it's the old busted shit
|
||||
class MythicPlus_CommandScript : public CommandScript
|
||||
{
|
||||
@@ -9,11 +14,66 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
ChatCommandTable GetCommands() const override
|
||||
{
|
||||
static ChatCommandTable commandTableSet =
|
||||
{
|
||||
{"mythic", HandleSet, SEC_PLAYER, Console::No},
|
||||
{"", HandleSet, SEC_PLAYER, Console::No},
|
||||
};
|
||||
|
||||
static ChatCommandTable commandTableMain =
|
||||
{
|
||||
{"status", HandleStatus, SEC_PLAYER, Console::Yes},
|
||||
{"set", commandTableSet}
|
||||
};
|
||||
|
||||
static ChatCommandTable commandTable =
|
||||
{
|
||||
{"mp", commandTableMain},
|
||||
{"mythicplus", HandleConsoleCommand, SEC_CONSOLE, Console::Yes},
|
||||
};
|
||||
|
||||
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static bool HandleConsoleCommand(ChatHandler* handler, const std::vector<std::string>& args)
|
||||
{
|
||||
handler->SendSysMessage("Hello Console from MythicPlus! ({})", args.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleSet(ChatHandler* handler, const std::vector<std::string>& args)
|
||||
{
|
||||
MpLogger::debug("HandleSet()");
|
||||
MpDataStore* mpds = MpDataStore::getInstance();
|
||||
const PlayerData* players = mpds->GetPlayerData();
|
||||
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
MpLogger::debug("HandleSet() player: {}", player->GetName());
|
||||
|
||||
mpds->SetPlayerDifficulty(player->GetGUID(), MP_DIFFICULTY_MYTHIC);
|
||||
|
||||
handler->SendSysMessage("Hello World from MythicPlus! ({})", args.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleStatus(ChatHandler* handler)
|
||||
{
|
||||
MpLogger::debug("HandleStatus()");
|
||||
MpDataStore* mpds = MpDataStore::getInstance();
|
||||
const PlayerData* players = mpds->GetPlayerData();
|
||||
|
||||
|
||||
handler->SendSysMessage("Hello World from MythicPlus! ()");
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void Add_MP_CommandScripts()
|
||||
{
|
||||
MpLogger::debug("Add_MP_CommandScripts()");
|
||||
new MythicPlus_CommandScript();
|
||||
}
|
||||
|
||||
@@ -11,41 +11,50 @@ MpDataStore::~MpDataStore() {
|
||||
}
|
||||
|
||||
void MpDataStore::AddGroupData(ObjectGuid guid, GroupData gd) {
|
||||
MpLogger::debug("Adding group data for group %u", guid.GetCounter());
|
||||
groupData[guid] = gd;
|
||||
MpLogger::debug("AddGroupData for group {}", guid.GetCounter());
|
||||
groupData->insert({guid, gd});
|
||||
}
|
||||
|
||||
void MpDataStore::RemoveGroupData(ObjectGuid guid) {
|
||||
MpLogger::debug("Removing group data for group %u", guid.GetCounter());
|
||||
groupData.erase(guid);
|
||||
MpLogger::debug("RemoveGroupData for group {}", guid.GetCounter());
|
||||
groupData->erase(guid);
|
||||
}
|
||||
|
||||
void MpDataStore::AddPlayerData(ObjectGuid guid, PlayerData pd) {
|
||||
MpLogger::debug("Adding player data for player %u", guid.GetCounter());
|
||||
playerData[guid] = pd;
|
||||
MpLogger::debug("AddPlayerData for player {}", guid.GetCounter());
|
||||
playerData->insert({guid, pd});
|
||||
}
|
||||
|
||||
const PlayerData* MpDataStore::GetPlayerData() {
|
||||
return playerData;
|
||||
}
|
||||
|
||||
void MpDataStore::SetPlayerDifficulty(ObjectGuid guid, uint8 difficulty) {
|
||||
MpLogger::debug("SetPlayerDifficulty for player {}", guid.GetCounter());
|
||||
playerData->at(guid).difficulty = difficulty;
|
||||
}
|
||||
|
||||
void MpDataStore::RemovePlayerData(ObjectGuid guid) {
|
||||
MpLogger::debug("Removing player data for player %u", guid.GetCounter());
|
||||
playerData.erase(guid);
|
||||
MpLogger::debug("RemovePlayerData for player {}", guid.GetCounter());
|
||||
playerData->erase(guid);
|
||||
}
|
||||
|
||||
void MpDataStore::AddInstanceData(ObjectGuid guid, MapData md) {
|
||||
MpLogger::debug("Adding instance data for instance %u", guid.GetCounter());
|
||||
instanceData[guid] = md;
|
||||
MpLogger::debug("AddInstanceData for instance {}", guid.GetCounter());
|
||||
instanceData->insert({guid, md});
|
||||
}
|
||||
|
||||
void MpDataStore::RemoveInstanceData(ObjectGuid guid) {
|
||||
MpLogger::debug("Removing instance data for instance %u", guid.GetCounter());
|
||||
instanceData.erase(guid);
|
||||
MpLogger::debug("RemoveInstanceData for instance {}", guid.GetCounter());
|
||||
instanceData->erase(guid);
|
||||
}
|
||||
|
||||
void MpDataStore::AddInstanceCreatureData(ObjectGuid guid, MapCreatureData mcd) {
|
||||
MpLogger::debug("Adding instance creature data for creature %u", guid.GetCounter());
|
||||
instanceCreatureData[guid] = mcd;
|
||||
MpLogger::debug("AddInstanceCreatureData for creature {}", guid.GetCounter());
|
||||
instanceCreatureData->insert({guid, mcd});
|
||||
}
|
||||
|
||||
void MpDataStore::RemoveInstanceCreatureData(ObjectGuid guid) {
|
||||
MpLogger::debug("Removing instance creature data for creature %u", guid.GetCounter());
|
||||
instanceCreatureData.erase(guid);
|
||||
MpLogger::debug("RemoveInstanceCreatureData data for creature {}", guid.GetCounter());
|
||||
instanceCreatureData->erase(guid);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ struct GroupData
|
||||
struct PlayerData
|
||||
{
|
||||
Player* player;
|
||||
uint8 difficulty;
|
||||
};
|
||||
|
||||
struct MapData
|
||||
@@ -41,22 +42,27 @@ private:
|
||||
MpDataStore();
|
||||
~MpDataStore();
|
||||
|
||||
std::map<ObjectGuid, GroupData> groupData;
|
||||
std::map<ObjectGuid, PlayerData> playerData;
|
||||
std::map<ObjectGuid, MapData> instanceData;
|
||||
std::map<ObjectGuid, MapCreatureData> instanceCreatureData;
|
||||
std::map<ObjectGuid, GroupData>* groupData;
|
||||
std::map<ObjectGuid, PlayerData>* playerData;
|
||||
std::map<ObjectGuid, MapData>* instanceData;
|
||||
std::map<ObjectGuid, MapCreatureData>* instanceCreatureData;
|
||||
|
||||
public:
|
||||
void AddGroupData(ObjectGuid guid, GroupData gd);
|
||||
void RemoveGroupData(ObjectGuid guid);
|
||||
|
||||
void AddPlayerData(ObjectGuid guid, PlayerData pd);
|
||||
void RemovePlayerData(ObjectGuid guid);
|
||||
void SetPlayerDifficulty(ObjectGuid guid, uint8 difficulty);
|
||||
const PlayerData* GetPlayerData();
|
||||
|
||||
void AddInstanceData(ObjectGuid guid, MapData md);
|
||||
void RemoveInstanceData(ObjectGuid guid);
|
||||
|
||||
void AddInstanceCreatureData(ObjectGuid guid, MapCreatureData mcd);
|
||||
void RemoveInstanceCreatureData(ObjectGuid guid);
|
||||
|
||||
static MpDataStore * getInstance() {
|
||||
static MpDataStore* getInstance() {
|
||||
static MpDataStore instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user