mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 20:51:29 +00:00
Add character id based expedition apis
Add static expedition methods to add or remove character lockouts Add CreateLockout static helper to ExpeditionLockoutTimer Refactor existing character lockout removal to allow removal of lockouts for offline characters (was only used by #dz lockouts remove command) Fix #dz list member count
This commit is contained in:
parent
3e373210c5
commit
d61879fd3c
@ -154,7 +154,7 @@
|
|||||||
#define ServerOP_ExpeditionDzCompass 0x040a
|
#define ServerOP_ExpeditionDzCompass 0x040a
|
||||||
#define ServerOP_ExpeditionDzSafeReturn 0x040b
|
#define ServerOP_ExpeditionDzSafeReturn 0x040b
|
||||||
#define ServerOP_ExpeditionDzZoneIn 0x040c
|
#define ServerOP_ExpeditionDzZoneIn 0x040c
|
||||||
#define ServerOP_ExpeditionRemoveCharLockouts 0x040d
|
#define ServerOP_ExpeditionCharacterLockout 0x040d
|
||||||
#define ServerOP_ExpeditionSaveInvite 0x040e
|
#define ServerOP_ExpeditionSaveInvite 0x040e
|
||||||
#define ServerOP_ExpeditionRequestInvite 0x040f
|
#define ServerOP_ExpeditionRequestInvite 0x040f
|
||||||
#define ServerOP_ExpeditionReplayOnJoin 0x0410
|
#define ServerOP_ExpeditionReplayOnJoin 0x0410
|
||||||
@ -2059,9 +2059,13 @@ struct ServerExpeditionSetting_Struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct ServerExpeditionCharacterLockout_Struct {
|
struct ServerExpeditionCharacterLockout_Struct {
|
||||||
char character_name[64];
|
uint8 remove;
|
||||||
char expedition_name[128];
|
uint32 character_id;
|
||||||
char event_name[256];
|
uint64 expire_time;
|
||||||
|
uint32 duration;
|
||||||
|
char uuid[37];
|
||||||
|
char expedition_name[128];
|
||||||
|
char event_name[256];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ServerExpeditionCharacterID_Struct {
|
struct ServerExpeditionCharacterID_Struct {
|
||||||
|
|||||||
@ -428,10 +428,14 @@ void ExpeditionMessage::HandleZoneMessage(ServerPacket* pack)
|
|||||||
ExpeditionMessage::MakeLeader(pack);
|
ExpeditionMessage::MakeLeader(pack);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ServerOP_ExpeditionRemoveCharLockouts:
|
case ServerOP_ExpeditionCharacterLockout:
|
||||||
{
|
{
|
||||||
auto buf = reinterpret_cast<ServerExpeditionCharacterLockout_Struct*>(pack->pBuffer);
|
auto buf = reinterpret_cast<ServerExpeditionCharacterLockout_Struct*>(pack->pBuffer);
|
||||||
client_list.SendPacket(buf->character_name, pack);
|
auto cle = client_list.FindCLEByCharacterID(buf->character_id);
|
||||||
|
if (cle && cle->Server())
|
||||||
|
{
|
||||||
|
cle->Server()->SendPacket(pack);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ServerOP_ExpeditionSaveInvite:
|
case ServerOP_ExpeditionSaveInvite:
|
||||||
|
|||||||
@ -1381,7 +1381,7 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
|
|||||||
case ServerOP_ExpeditionMembersRemoved:
|
case ServerOP_ExpeditionMembersRemoved:
|
||||||
case ServerOP_ExpeditionDzAddPlayer:
|
case ServerOP_ExpeditionDzAddPlayer:
|
||||||
case ServerOP_ExpeditionDzMakeLeader:
|
case ServerOP_ExpeditionDzMakeLeader:
|
||||||
case ServerOP_ExpeditionRemoveCharLockouts:
|
case ServerOP_ExpeditionCharacterLockout:
|
||||||
case ServerOP_ExpeditionSaveInvite:
|
case ServerOP_ExpeditionSaveInvite:
|
||||||
case ServerOP_ExpeditionRequestInvite:
|
case ServerOP_ExpeditionRequestInvite:
|
||||||
{
|
{
|
||||||
|
|||||||
@ -39,7 +39,6 @@ extern volatile bool RunLoops;
|
|||||||
#include "../common/string_util.h"
|
#include "../common/string_util.h"
|
||||||
#include "../common/data_verification.h"
|
#include "../common/data_verification.h"
|
||||||
#include "../common/profanity_manager.h"
|
#include "../common/profanity_manager.h"
|
||||||
#include "../common/util/uuid.h"
|
|
||||||
#include "data_bucket.h"
|
#include "data_bucket.h"
|
||||||
#include "expedition.h"
|
#include "expedition.h"
|
||||||
#include "expedition_database.h"
|
#include "expedition_database.h"
|
||||||
@ -9643,12 +9642,7 @@ void Client::AddExpeditionLockout(
|
|||||||
void Client::AddNewExpeditionLockout(
|
void Client::AddNewExpeditionLockout(
|
||||||
const std::string& expedition_name, const std::string& event_name, uint32_t seconds, std::string uuid)
|
const std::string& expedition_name, const std::string& event_name, uint32_t seconds, std::string uuid)
|
||||||
{
|
{
|
||||||
if (uuid.empty())
|
auto lockout = ExpeditionLockoutTimer::CreateLockout(expedition_name, event_name, seconds, uuid);
|
||||||
{
|
|
||||||
uuid = EQ::Util::UUID::Generate().ToString();
|
|
||||||
}
|
|
||||||
ExpeditionLockoutTimer lockout{uuid, expedition_name, event_name, 0, seconds};
|
|
||||||
lockout.Reset(); // sets expire time
|
|
||||||
AddExpeditionLockout(lockout, true);
|
AddExpeditionLockout(lockout, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9672,22 +9666,30 @@ void Client::RemoveExpeditionLockout(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::RemoveAllExpeditionLockouts(std::string expedition_name)
|
void Client::RemoveAllExpeditionLockouts(const std::string& expedition_name, bool update_db)
|
||||||
{
|
{
|
||||||
if (expedition_name.empty())
|
if (expedition_name.empty())
|
||||||
{
|
{
|
||||||
ExpeditionDatabase::DeleteAllCharacterLockouts(CharacterID());
|
if (update_db)
|
||||||
|
{
|
||||||
|
ExpeditionDatabase::DeleteAllCharacterLockouts(CharacterID());
|
||||||
|
}
|
||||||
m_expedition_lockouts.clear();
|
m_expedition_lockouts.clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ExpeditionDatabase::DeleteAllCharacterLockouts(CharacterID(), expedition_name);
|
if (update_db)
|
||||||
|
{
|
||||||
|
ExpeditionDatabase::DeleteAllCharacterLockouts(CharacterID(), expedition_name);
|
||||||
|
}
|
||||||
|
|
||||||
m_expedition_lockouts.erase(std::remove_if(m_expedition_lockouts.begin(), m_expedition_lockouts.end(),
|
m_expedition_lockouts.erase(std::remove_if(m_expedition_lockouts.begin(), m_expedition_lockouts.end(),
|
||||||
[&](const ExpeditionLockoutTimer& lockout) {
|
[&](const ExpeditionLockoutTimer& lockout) {
|
||||||
return lockout.GetExpeditionName() == expedition_name;
|
return lockout.GetExpeditionName() == expedition_name;
|
||||||
}
|
}
|
||||||
), m_expedition_lockouts.end());
|
), m_expedition_lockouts.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
SendExpeditionLockoutTimers();
|
SendExpeditionLockoutTimers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9728,6 +9730,8 @@ bool Client::HasExpeditionLockout(
|
|||||||
|
|
||||||
void Client::LoadAllExpeditionLockouts()
|
void Client::LoadAllExpeditionLockouts()
|
||||||
{
|
{
|
||||||
|
m_expedition_lockouts.clear();
|
||||||
|
|
||||||
auto lockouts = ExpeditionDatabase::LoadCharacterLockouts(CharacterID());
|
auto lockouts = ExpeditionDatabase::LoadCharacterLockouts(CharacterID());
|
||||||
for (const auto& lockout : lockouts)
|
for (const auto& lockout : lockouts)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1133,7 +1133,7 @@ public:
|
|||||||
uint32 GetPendingExpeditionInviteID() const { return m_pending_expedition_invite.expedition_id; }
|
uint32 GetPendingExpeditionInviteID() const { return m_pending_expedition_invite.expedition_id; }
|
||||||
bool HasExpeditionLockout(const std::string& expedition_name, const std::string& event_name, bool include_expired = false);
|
bool HasExpeditionLockout(const std::string& expedition_name, const std::string& event_name, bool include_expired = false);
|
||||||
bool IsInExpedition() const { return m_expedition_id != 0; }
|
bool IsInExpedition() const { return m_expedition_id != 0; }
|
||||||
void RemoveAllExpeditionLockouts(std::string expedition_name = {});
|
void RemoveAllExpeditionLockouts(const std::string& expedition_name, bool update_db = false);
|
||||||
void RemoveExpeditionLockout(
|
void RemoveExpeditionLockout(
|
||||||
const std::string& expedition_name, const std::string& event_name, bool update_db = false, bool update_client = true);
|
const std::string& expedition_name, const std::string& event_name, bool update_db = false, bool update_client = true);
|
||||||
void RequestPendingExpeditionInvite();
|
void RequestPendingExpeditionInvite();
|
||||||
|
|||||||
@ -6889,7 +6889,7 @@ void command_dz(Client* c, const Seperator* sep)
|
|||||||
instance_list.version,
|
instance_list.version,
|
||||||
instance_list.start_time,
|
instance_list.start_time,
|
||||||
instance_list.duration,
|
instance_list.duration,
|
||||||
COUNT(instance_list.id) member_count
|
COUNT(instance_list_player.id) member_count
|
||||||
FROM dynamic_zones
|
FROM dynamic_zones
|
||||||
INNER JOIN instance_list ON dynamic_zones.instance_id = instance_list.id
|
INNER JOIN instance_list ON dynamic_zones.instance_id = instance_list.id
|
||||||
LEFT JOIN instance_list_player ON instance_list.id = instance_list_player.id
|
LEFT JOIN instance_list_player ON instance_list.id = instance_list_player.id
|
||||||
@ -6944,7 +6944,7 @@ void command_dz(Client* c, const Seperator* sep)
|
|||||||
"Removing [{}]:[{}] lockout on [{}].", sep->arg[4], sep->arg[5], sep->arg[3]
|
"Removing [{}]:[{}] lockout on [{}].", sep->arg[4], sep->arg[5], sep->arg[3]
|
||||||
).c_str());
|
).c_str());
|
||||||
}
|
}
|
||||||
Expedition::RemoveCharacterLockouts(sep->arg[3], sep->arg[4], sep->arg[5]);
|
Expedition::RemoveLockoutsByCharacterName(sep->arg[3], sep->arg[4], sep->arg[5]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -1586,18 +1586,78 @@ void Expedition::SendWorldGetOnlineMembers(
|
|||||||
worldserver.SendPacket(pack.get());
|
worldserver.SendPacket(pack.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Expedition::RemoveCharacterLockouts(
|
void Expedition::SendWorldCharacterLockout(
|
||||||
std::string character_name, std::string expedition_name, std::string event_name)
|
uint32_t character_id, const ExpeditionLockoutTimer& lockout, bool remove)
|
||||||
{
|
{
|
||||||
uint32_t pack_size = sizeof(ServerExpeditionCharacterLockout_Struct);
|
uint32_t pack_size = sizeof(ServerExpeditionCharacterLockout_Struct);
|
||||||
auto pack = std::unique_ptr<ServerPacket>(new ServerPacket(ServerOP_ExpeditionRemoveCharLockouts, pack_size));
|
auto pack = std::unique_ptr<ServerPacket>(new ServerPacket(ServerOP_ExpeditionCharacterLockout, pack_size));
|
||||||
auto buf = reinterpret_cast<ServerExpeditionCharacterLockout_Struct*>(pack->pBuffer);
|
auto buf = reinterpret_cast<ServerExpeditionCharacterLockout_Struct*>(pack->pBuffer);
|
||||||
strn0cpy(buf->character_name, character_name.c_str(), sizeof(buf->character_name));
|
buf->remove = remove;
|
||||||
strn0cpy(buf->expedition_name, expedition_name.c_str(), sizeof(buf->expedition_name));
|
buf->character_id = character_id;
|
||||||
strn0cpy(buf->event_name, event_name.c_str(), sizeof(buf->event_name));
|
buf->expire_time = lockout.GetExpireTime();
|
||||||
|
buf->duration = lockout.GetDuration();
|
||||||
|
strn0cpy(buf->uuid, lockout.GetExpeditionUUID().c_str(), sizeof(buf->uuid));
|
||||||
|
strn0cpy(buf->expedition_name, lockout.GetExpeditionName().c_str(), sizeof(buf->expedition_name));
|
||||||
|
strn0cpy(buf->event_name, lockout.GetEventName().c_str(), sizeof(buf->event_name));
|
||||||
worldserver.SendPacket(pack.get());
|
worldserver.SendPacket(pack.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Expedition::AddLockoutByCharacterID(
|
||||||
|
uint32_t character_id, const std::string& expedition_name, const std::string& event_name,
|
||||||
|
uint32_t seconds, const std::string& uuid)
|
||||||
|
{
|
||||||
|
if (character_id)
|
||||||
|
{
|
||||||
|
auto lockout = ExpeditionLockoutTimer::CreateLockout(expedition_name, event_name, seconds, uuid);
|
||||||
|
ExpeditionDatabase::InsertCharacterLockouts(character_id, { lockout }, true);
|
||||||
|
SendWorldCharacterLockout(character_id, lockout, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Expedition::AddLockoutByCharacterName(
|
||||||
|
const std::string& character_name, const std::string& expedition_name, const std::string& event_name,
|
||||||
|
uint32_t seconds, const std::string& uuid)
|
||||||
|
{
|
||||||
|
if (!character_name.empty())
|
||||||
|
{
|
||||||
|
uint32_t character_id = database.GetCharacterID(character_name.c_str());
|
||||||
|
AddLockoutByCharacterID(character_id, expedition_name, event_name, seconds, uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Expedition::RemoveLockoutsByCharacterID(
|
||||||
|
uint32_t character_id, const std::string& expedition_name, const std::string& event_name)
|
||||||
|
{
|
||||||
|
if (character_id)
|
||||||
|
{
|
||||||
|
if (!event_name.empty())
|
||||||
|
{
|
||||||
|
ExpeditionDatabase::DeleteCharacterLockout(character_id, expedition_name, event_name);
|
||||||
|
}
|
||||||
|
else if (!expedition_name.empty())
|
||||||
|
{
|
||||||
|
ExpeditionDatabase::DeleteAllCharacterLockouts(character_id, expedition_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ExpeditionDatabase::DeleteAllCharacterLockouts(character_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
ExpeditionLockoutTimer lockout{{}, expedition_name, event_name, 0, 0};
|
||||||
|
SendWorldCharacterLockout(character_id, lockout, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Expedition::RemoveLockoutsByCharacterName(
|
||||||
|
const std::string& character_name, const std::string& expedition_name, const std::string& event_name)
|
||||||
|
{
|
||||||
|
if (!character_name.empty())
|
||||||
|
{
|
||||||
|
uint32_t character_id = database.GetCharacterID(character_name.c_str());
|
||||||
|
RemoveLockoutsByCharacterID(character_id, expedition_name, event_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Expedition::HandleWorldMessage(ServerPacket* pack)
|
void Expedition::HandleWorldMessage(ServerPacket* pack)
|
||||||
{
|
{
|
||||||
switch (pack->opcode)
|
switch (pack->opcode)
|
||||||
@ -1818,15 +1878,21 @@ void Expedition::HandleWorldMessage(ServerPacket* pack)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ServerOP_ExpeditionRemoveCharLockouts:
|
case ServerOP_ExpeditionCharacterLockout:
|
||||||
{
|
{
|
||||||
auto buf = reinterpret_cast<ServerExpeditionCharacterLockout_Struct*>(pack->pBuffer);
|
auto buf = reinterpret_cast<ServerExpeditionCharacterLockout_Struct*>(pack->pBuffer);
|
||||||
Client* client = entity_list.GetClientByName(buf->character_name);
|
Client* client = entity_list.GetClientByCharID(buf->character_id);
|
||||||
if (client)
|
if (client)
|
||||||
{
|
{
|
||||||
if (buf->event_name[0] != '\0')
|
if (!buf->remove)
|
||||||
{
|
{
|
||||||
client->RemoveExpeditionLockout(buf->expedition_name, buf->event_name, true);
|
client->AddExpeditionLockout(ExpeditionLockoutTimer{
|
||||||
|
buf->uuid, buf->expedition_name, buf->event_name, buf->expire_time, buf->duration
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (buf->event_name[0] != '\0')
|
||||||
|
{
|
||||||
|
client->RemoveExpeditionLockout(buf->expedition_name, buf->event_name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1982,3 +2048,20 @@ std::string Expedition::GetLootEventBySpawnID(uint32_t spawn_id)
|
|||||||
|
|
||||||
return event_name;
|
return event_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<ExpeditionLockoutTimer> Expedition::GetExpeditionLockoutsByCharacterID(uint32_t character_id)
|
||||||
|
{
|
||||||
|
std::vector<ExpeditionLockoutTimer> lockouts;
|
||||||
|
|
||||||
|
auto client = entity_list.GetClientByCharID(character_id);
|
||||||
|
if (client)
|
||||||
|
{
|
||||||
|
lockouts = client->GetExpeditionLockouts();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lockouts = ExpeditionDatabase::LoadCharacterLockouts(character_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lockouts;
|
||||||
|
}
|
||||||
|
|||||||
@ -77,8 +77,16 @@ public:
|
|||||||
static Expedition* FindCachedExpeditionByCharacterName(const std::string& char_name);
|
static Expedition* FindCachedExpeditionByCharacterName(const std::string& char_name);
|
||||||
static Expedition* FindCachedExpeditionByID(uint32_t expedition_id);
|
static Expedition* FindCachedExpeditionByID(uint32_t expedition_id);
|
||||||
static Expedition* FindCachedExpeditionByInstanceID(uint32_t instance_id);
|
static Expedition* FindCachedExpeditionByInstanceID(uint32_t instance_id);
|
||||||
static void RemoveCharacterLockouts(std::string character_name, std::string expedition_name = {}, std::string event_name = {});
|
static std::vector<ExpeditionLockoutTimer> GetExpeditionLockoutsByCharacterID(uint32_t character_id);
|
||||||
static void HandleWorldMessage(ServerPacket* pack);
|
static void HandleWorldMessage(ServerPacket* pack);
|
||||||
|
static void AddLockoutByCharacterID(uint32_t character_id, const std::string& expedition_name,
|
||||||
|
const std::string& event_name, uint32_t seconds, const std::string& uuid = {});
|
||||||
|
static void AddLockoutByCharacterName(const std::string& character_name, const std::string& expedition_name,
|
||||||
|
const std::string& event_name, uint32_t seconds, const std::string& uuid = {});
|
||||||
|
static void RemoveLockoutsByCharacterID(uint32_t character_id,
|
||||||
|
const std::string& expedition_name = {}, const std::string& event_name = {});
|
||||||
|
static void RemoveLockoutsByCharacterName(const std::string& character_name,
|
||||||
|
const std::string& expedition_name = {}, const std::string& event_name = {});
|
||||||
|
|
||||||
uint32_t GetID() const { return m_id; }
|
uint32_t GetID() const { return m_id; }
|
||||||
uint16_t GetInstanceID() const { return m_dynamiczone.GetInstanceID(); }
|
uint16_t GetInstanceID() const { return m_dynamiczone.GetInstanceID(); }
|
||||||
@ -143,6 +151,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
static void CacheExpeditions(MySQLRequestResult& results);
|
static void CacheExpeditions(MySQLRequestResult& results);
|
||||||
static void SendWorldGetOnlineMembers(const std::vector<std::pair<uint32_t, uint32_t>>& expedition_character_ids);
|
static void SendWorldGetOnlineMembers(const std::vector<std::pair<uint32_t, uint32_t>>& expedition_character_ids);
|
||||||
|
static void SendWorldCharacterLockout(uint32_t character_id, const ExpeditionLockoutTimer& lockout, bool remove);
|
||||||
|
|
||||||
void AddLockout(const ExpeditionLockoutTimer& lockout, bool members_only = false);
|
void AddLockout(const ExpeditionLockoutTimer& lockout, bool members_only = false);
|
||||||
void AddInternalMember(const std::string& char_name, uint32_t char_id, ExpeditionMemberStatus status);
|
void AddInternalMember(const std::string& char_name, uint32_t char_id, ExpeditionMemberStatus status);
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "expedition_lockout_timer.h"
|
#include "expedition_lockout_timer.h"
|
||||||
#include "../common/string_util.h"
|
#include "../common/string_util.h"
|
||||||
|
#include "../common/util/uuid.h"
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
const char* const DZ_REPLAY_TIMER_NAME = "Replay Timer"; // see December 14, 2016 patch notes
|
const char* const DZ_REPLAY_TIMER_NAME = "Replay Timer"; // see December 14, 2016 patch notes
|
||||||
@ -40,6 +41,19 @@ ExpeditionLockoutTimer::ExpeditionLockoutTimer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExpeditionLockoutTimer ExpeditionLockoutTimer::CreateLockout(
|
||||||
|
const std::string& expedition_name, const std::string& event_name, uint32_t seconds, std::string uuid)
|
||||||
|
{
|
||||||
|
if (uuid.empty())
|
||||||
|
{
|
||||||
|
uuid = EQ::Util::UUID::Generate().ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
ExpeditionLockoutTimer lockout{uuid, expedition_name, event_name, 0, seconds};
|
||||||
|
lockout.Reset(); // sets expire time
|
||||||
|
return lockout;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t ExpeditionLockoutTimer::GetSecondsRemaining() const
|
uint32_t ExpeditionLockoutTimer::GetSecondsRemaining() const
|
||||||
{
|
{
|
||||||
auto now = std::chrono::system_clock::now();
|
auto now = std::chrono::system_clock::now();
|
||||||
|
|||||||
@ -34,6 +34,10 @@ public:
|
|||||||
const std::string& expedition_uuid, const std::string& expedition_name,
|
const std::string& expedition_uuid, const std::string& expedition_name,
|
||||||
const std::string& event_name, uint64_t expire_time, uint32_t duration);
|
const std::string& event_name, uint64_t expire_time, uint32_t duration);
|
||||||
|
|
||||||
|
static ExpeditionLockoutTimer CreateLockout(
|
||||||
|
const std::string& expedition_name, const std::string& event_name,
|
||||||
|
uint32_t seconds, std::string uuid = {});
|
||||||
|
|
||||||
struct DaysHoursMinutes
|
struct DaysHoursMinutes
|
||||||
{
|
{
|
||||||
std::string days;
|
std::string days;
|
||||||
|
|||||||
@ -1791,12 +1791,12 @@ void Lua_Client::AddExpeditionLockout(std::string expedition_name, std::string e
|
|||||||
|
|
||||||
void Lua_Client::RemoveAllExpeditionLockouts() {
|
void Lua_Client::RemoveAllExpeditionLockouts() {
|
||||||
Lua_Safe_Call_Void();
|
Lua_Safe_Call_Void();
|
||||||
self->RemoveAllExpeditionLockouts();
|
self->RemoveAllExpeditionLockouts({}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lua_Client::RemoveAllExpeditionLockouts(std::string expedition_name) {
|
void Lua_Client::RemoveAllExpeditionLockouts(std::string expedition_name) {
|
||||||
Lua_Safe_Call_Void();
|
Lua_Safe_Call_Void();
|
||||||
self->RemoveAllExpeditionLockouts(expedition_name);
|
self->RemoveAllExpeditionLockouts(expedition_name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lua_Client::RemoveExpeditionLockout(std::string expedition_name, std::string event_name) {
|
void Lua_Client::RemoveExpeditionLockout(std::string expedition_name, std::string event_name) {
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
#include "encounter.h"
|
#include "encounter.h"
|
||||||
#include "lua_encounter.h"
|
#include "lua_encounter.h"
|
||||||
#include "data_bucket.h"
|
#include "data_bucket.h"
|
||||||
|
#include "expedition.h"
|
||||||
|
|
||||||
struct Events { };
|
struct Events { };
|
||||||
struct Factions { };
|
struct Factions { };
|
||||||
@ -2180,15 +2181,101 @@ void lua_set_content_flag(std::string flag_name, bool enabled){
|
|||||||
}
|
}
|
||||||
|
|
||||||
Lua_Expedition lua_get_expedition() {
|
Lua_Expedition lua_get_expedition() {
|
||||||
return quest_manager.GetExpeditionForCurrentInstance();
|
if (zone && zone->GetInstanceID() != 0)
|
||||||
|
{
|
||||||
|
return Expedition::FindCachedExpeditionByInstanceID(zone->GetInstanceID());
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Lua_Expedition lua_get_expedition_by_char_id(uint32 char_id) {
|
Lua_Expedition lua_get_expedition_by_char_id(uint32 char_id) {
|
||||||
return quest_manager.GetExpeditionByCharID(char_id);
|
return Expedition::FindCachedExpeditionByCharacterID(char_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Lua_Expedition lua_get_expedition_by_instance_id(uint32 instance_id) {
|
Lua_Expedition lua_get_expedition_by_instance_id(uint32 instance_id) {
|
||||||
return quest_manager.GetExpeditionByInstanceID(instance_id);
|
return Expedition::FindCachedExpeditionByInstanceID(instance_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
luabind::object lua_get_expedition_lockout_by_char_id(lua_State* L, uint32 char_id, std::string expedition_name, std::string event_name) {
|
||||||
|
luabind::adl::object lua_table = luabind::newtable(L);
|
||||||
|
|
||||||
|
auto lockouts = Expedition::GetExpeditionLockoutsByCharacterID(char_id);
|
||||||
|
|
||||||
|
auto it = std::find_if(lockouts.begin(), lockouts.end(), [&](const ExpeditionLockoutTimer& lockout) {
|
||||||
|
return lockout.IsSameLockout(expedition_name, event_name);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (it != lockouts.end())
|
||||||
|
{
|
||||||
|
lua_table["remaining"] = it->GetSecondsRemaining();
|
||||||
|
lua_table["uuid"] = it->GetExpeditionUUID();
|
||||||
|
}
|
||||||
|
|
||||||
|
return lua_table;
|
||||||
|
}
|
||||||
|
|
||||||
|
luabind::object lua_get_expedition_lockouts_by_char_id(lua_State* L, uint32 char_id) {
|
||||||
|
luabind::adl::object lua_table = luabind::newtable(L);
|
||||||
|
|
||||||
|
auto lockouts = Expedition::GetExpeditionLockoutsByCharacterID(char_id);
|
||||||
|
for (const auto& lockout : lockouts)
|
||||||
|
{
|
||||||
|
auto lockout_table = lua_table[lockout.GetExpeditionName()];
|
||||||
|
if (luabind::type(lockout_table) != LUA_TTABLE)
|
||||||
|
{
|
||||||
|
lockout_table = luabind::newtable(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto event_table = lockout_table[lockout.GetEventName()];
|
||||||
|
if (luabind::type(event_table) != LUA_TTABLE)
|
||||||
|
{
|
||||||
|
event_table = luabind::newtable(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
event_table["remaining"] = lockout.GetSecondsRemaining();
|
||||||
|
event_table["uuid"] = lockout.GetExpeditionUUID();
|
||||||
|
}
|
||||||
|
return lua_table;
|
||||||
|
}
|
||||||
|
|
||||||
|
luabind::object lua_get_expedition_lockouts_by_char_id(lua_State* L, uint32 char_id, std::string expedition_name) {
|
||||||
|
luabind::adl::object lua_table = luabind::newtable(L);
|
||||||
|
|
||||||
|
auto lockouts = Expedition::GetExpeditionLockoutsByCharacterID(char_id);
|
||||||
|
for (const auto& lockout : lockouts)
|
||||||
|
{
|
||||||
|
if (lockout.GetExpeditionName() == expedition_name)
|
||||||
|
{
|
||||||
|
auto event_table = lua_table[lockout.GetEventName()];
|
||||||
|
if (luabind::type(event_table) != LUA_TTABLE)
|
||||||
|
{
|
||||||
|
event_table = luabind::newtable(L);
|
||||||
|
}
|
||||||
|
event_table["remaining"] = lockout.GetSecondsRemaining();
|
||||||
|
event_table["uuid"] = lockout.GetExpeditionUUID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lua_table;
|
||||||
|
}
|
||||||
|
|
||||||
|
void lua_add_expedition_lockout_by_char_id(uint32 char_id, std::string expedition_name, std::string event_name, uint32 seconds) {
|
||||||
|
Expedition::AddLockoutByCharacterID(char_id, expedition_name, event_name, seconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lua_add_expedition_lockout_by_char_id(uint32 char_id, std::string expedition_name, std::string event_name, uint32 seconds, std::string uuid) {
|
||||||
|
Expedition::AddLockoutByCharacterID(char_id, expedition_name, event_name, seconds, uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lua_remove_expedition_lockout_by_char_id(uint32 char_id, std::string expedition_name, std::string event_name) {
|
||||||
|
Expedition::RemoveLockoutsByCharacterID(char_id, expedition_name, event_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lua_remove_all_expedition_lockouts_by_char_id(uint32 char_id) {
|
||||||
|
Expedition::RemoveLockoutsByCharacterID(char_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lua_remove_all_expedition_lockouts_by_char_id(uint32 char_id, std::string expedition_name) {
|
||||||
|
Expedition::RemoveLockoutsByCharacterID(char_id, expedition_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LuaCreateNPCParse(name, c_type, default_value) do { \
|
#define LuaCreateNPCParse(name, c_type, default_value) do { \
|
||||||
@ -2790,9 +2877,17 @@ luabind::scope lua_register_general() {
|
|||||||
luabind::def("is_content_flag_enabled", (bool(*)(std::string))&lua_is_content_flag_enabled),
|
luabind::def("is_content_flag_enabled", (bool(*)(std::string))&lua_is_content_flag_enabled),
|
||||||
luabind::def("set_content_flag", (void(*)(std::string, bool))&lua_set_content_flag),
|
luabind::def("set_content_flag", (void(*)(std::string, bool))&lua_set_content_flag),
|
||||||
|
|
||||||
luabind::def("get_expedition", (Lua_Expedition(*)())&lua_get_expedition),
|
luabind::def("get_expedition", &lua_get_expedition),
|
||||||
luabind::def("get_expedition_by_char_id", (Lua_Expedition(*)(uint32 char_id))&lua_get_expedition_by_char_id),
|
luabind::def("get_expedition_by_char_id", &lua_get_expedition_by_char_id),
|
||||||
luabind::def("get_expedition_by_instance_id", (Lua_Expedition(*)(uint32 instance_id))&lua_get_expedition_by_instance_id)
|
luabind::def("get_expedition_by_instance_id", &lua_get_expedition_by_instance_id),
|
||||||
|
luabind::def("get_expedition_lockout_by_char_id", &lua_get_expedition_lockout_by_char_id),
|
||||||
|
luabind::def("get_expedition_lockouts_by_char_id", (luabind::object(*)(lua_State*, uint32))&lua_get_expedition_lockouts_by_char_id),
|
||||||
|
luabind::def("get_expedition_lockouts_by_char_id", (luabind::object(*)(lua_State*, uint32, std::string))&lua_get_expedition_lockouts_by_char_id),
|
||||||
|
luabind::def("add_expedition_lockout_by_char_id", (void(*)(uint32, std::string, std::string, uint32))&lua_add_expedition_lockout_by_char_id),
|
||||||
|
luabind::def("add_expedition_lockout_by_char_id", (void(*)(uint32, std::string, std::string, uint32, std::string))&lua_add_expedition_lockout_by_char_id),
|
||||||
|
luabind::def("remove_expedition_lockout_by_char_id", &lua_remove_expedition_lockout_by_char_id),
|
||||||
|
luabind::def("remove_all_expedition_lockouts_by_char_id", (void(*)(uint32))&lua_remove_all_expedition_lockouts_by_char_id),
|
||||||
|
luabind::def("remove_all_expedition_lockouts_by_char_id", (void(*)(uint32, std::string))&lua_remove_all_expedition_lockouts_by_char_id)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
#include "entity.h"
|
#include "entity.h"
|
||||||
#include "event_codes.h"
|
#include "event_codes.h"
|
||||||
#include "expedition.h"
|
|
||||||
#include "guild_mgr.h"
|
#include "guild_mgr.h"
|
||||||
#include "qglobals.h"
|
#include "qglobals.h"
|
||||||
#include "queryserv.h"
|
#include "queryserv.h"
|
||||||
@ -4328,22 +4327,3 @@ void QuestManager::UpdateZoneHeader(std::string type, std::string value) {
|
|||||||
entity_list.QueueClients(0, outapp);
|
entity_list.QueueClients(0, outapp);
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
Expedition* QuestManager::GetExpeditionByCharID(uint32 char_id)
|
|
||||||
{
|
|
||||||
return Expedition::FindCachedExpeditionByCharacterID(char_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
Expedition* QuestManager::GetExpeditionByInstanceID(uint32 instance_id)
|
|
||||||
{
|
|
||||||
return Expedition::FindCachedExpeditionByInstanceID(instance_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
Expedition* QuestManager::GetExpeditionForCurrentInstance()
|
|
||||||
{
|
|
||||||
if (zone && zone->GetInstanceID() != 0)
|
|
||||||
{
|
|
||||||
return Expedition::FindCachedExpeditionByInstanceID(zone->GetInstanceID());
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -366,9 +366,6 @@ public:
|
|||||||
bool DisableRecipe(uint32 recipe_id);
|
bool DisableRecipe(uint32 recipe_id);
|
||||||
void ClearNPCTypeCache(int npctype_id);
|
void ClearNPCTypeCache(int npctype_id);
|
||||||
void ReloadZoneStaticData();
|
void ReloadZoneStaticData();
|
||||||
Expedition* GetExpeditionByCharID(uint32 char_id);
|
|
||||||
Expedition* GetExpeditionByInstanceID(uint32 instance_id);
|
|
||||||
Expedition* GetExpeditionForCurrentInstance();
|
|
||||||
|
|
||||||
Client *GetInitiator() const;
|
Client *GetInitiator() const;
|
||||||
NPC *GetNPC() const;
|
NPC *GetNPC() const;
|
||||||
|
|||||||
@ -2907,7 +2907,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
|||||||
case ServerOP_ExpeditionDzSafeReturn:
|
case ServerOP_ExpeditionDzSafeReturn:
|
||||||
case ServerOP_ExpeditionDzZoneIn:
|
case ServerOP_ExpeditionDzZoneIn:
|
||||||
case ServerOP_ExpeditionDzDuration:
|
case ServerOP_ExpeditionDzDuration:
|
||||||
case ServerOP_ExpeditionRemoveCharLockouts:
|
case ServerOP_ExpeditionCharacterLockout:
|
||||||
{
|
{
|
||||||
Expedition::HandleWorldMessage(pack);
|
Expedition::HandleWorldMessage(pack);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user