1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-13 22:17:45 +00:00
sapphire/src/world/Manager/MapMgr.h

77 lines
1.8 KiB
C
Raw Normal View History

2021-08-30 10:16:05 +02:00
#ifndef SAPPHIRE_MAPMGR_H
#define SAPPHIRE_MAPMGR_H
#include "ForwardsZone.h"
2021-09-07 16:50:13 +02:00
#include <set>
#include <unordered_map>
2021-08-30 10:16:05 +02:00
namespace Sapphire::World::Manager
{
2021-09-07 16:50:13 +02:00
using QuestMap = std::unordered_map< uint32_t, Data::ExdDataGenerated::QuestPtr >;
2021-08-30 10:16:05 +02:00
class MapMgr
{
public:
enum UpdateMode : uint8_t
{
Quest = 1,
GuildLeveAssignment = 2,
GuildOrderGuide = 4,
TripleTriad = 8,
CustomTalk = 16,
PreHandler = 32,
All = 0x3F
};
MapMgr();
void updateAll( Entity::Player& player );
void updateQuests( Entity::Player& player );
private:
struct EventData
{
uint32_t iconId;
uint32_t levelId;
2021-09-07 16:50:13 +02:00
uint32_t eventId;
2021-08-30 10:16:05 +02:00
};
struct less
{
2021-09-07 16:50:13 +02:00
constexpr bool operator()( const EventData& _Left, const EventData& _Right ) const
2021-08-30 10:16:05 +02:00
{
2021-09-07 16:50:13 +02:00
const uint16_t left = _Left.eventId;
const uint16_t right = _Right.eventId;
2021-08-30 10:16:05 +02:00
if( left == right )
{
2021-09-07 16:50:13 +02:00
const uint16_t typeLeft = _Left.eventId >> 16;
const uint16_t typeRight = _Right.eventId >> 16;
2021-08-30 10:16:05 +02:00
return typeLeft < typeRight;
}
return left < right;
}
};
2021-09-07 16:50:13 +02:00
using EventSet = std::multiset< EventData, less >;
QuestMap m_quests;
void insertQuest( Entity::Player& player, uint32_t questId, EventSet& mapData );
2021-08-30 10:16:05 +02:00
2021-09-07 16:50:13 +02:00
bool isQuestVisible( Entity::Player& player, uint32_t questId, Data::ExdDataGenerated::QuestPtr questPtr );
bool isQuestAvailable( Entity::Player& player, uint32_t questId, Data::ExdDataGenerated::QuestPtr questPtr );
bool isTripleTriadAvailable( Entity::Player& player, uint32_t tripleTriadId );
2021-08-30 10:16:05 +02:00
2021-09-07 16:50:13 +02:00
void fillPacket( EventSet& mapData, uint32_t* iconIds, uint32_t* levelIds, uint32_t* eventIds );
void sendPackets( Entity::Player& player, EventSet& mapData, UpdateMode updateMode );
2021-08-30 10:16:05 +02:00
};
}
#endif // SAPPHIRE_MAPMGR_H