mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
* Plumbing * Batch processing in world * Cleanup * Cleanup * Update player_event_logs.cpp * Add player zoning event * Use generics * Comments * Add events * Add more events * AA_GAIN, AA_PURCHASE, FORAGE_SUCCESS, FORAGE_FAILURE * FISH_SUCCESS, FISH_FAILURE, ITEM_DESTROY * Add charges to ITEM_DESTROY * WENT_ONLINE, WENT_OFFLINE * LEVEL_GAIN, LEVEL_LOSS * LOOT_ITEM * MERCHANT_PURCHASE * MERCHANT_SELL * SKILL_UP * Add events * Add more events * TASK_ACCEPT, TASK_COMPLETE, and TASK_UPDATE * GROUNDSPAWN_PICKUP * SAY * REZ_ACCEPTED * COMBINE_FAILURE and COMBINE_SUCCESS * DROPPED_ITEM * DEATH * SPLIT_MONEY * TRADER_PURCHASE and TRADER_SELL * DISCOVER_ITEM * Convert GM_COMMAND to use new macro * Convert ZONING event to use macro * Revert some code changes * Revert "Revert some code changes" This reverts commit d53682f997e89a053a660761085913245db91e9d. * Add cereal generation support to repositories * TRADE * Formatting * Cleanup * Relocate discord_manager to discord folder * Discord sending plumbing * Rename UCS's Database class to UCSDatabase to be more specific and not collide with base Database class for repository usage * More discord sending plumbing * More discord message formatting work * More discord formatting work * Discord formatting of events * Format WENT_ONLINE, WENT_OFFLINE * Add merchant purchase event * Handle Discord MERCHANT_SELL formatter * Update player_event_discord_formatter.cpp * Tweaks * Implement retention truncation * Put mutex locking on batch queue, put processor on its own thread * Process on initial bootup * Implement optional QS processing, implement keepalive from world to QS * Reload player event settings when logs are reloaded in game * Set settings defaults * Update player_event_logs.cpp * Update player_event_logs.cpp * Set retention days on boot * Update player_event_logs.cpp * Player Handin Event Testing. Testing player handin stuff. * Cleanup. * Finish NPC Handin. * set a reference to the client inside of the trade object as well for plugins to process * Fix for windows _inline * Bump to cpp20 default, ignore excessive warnings on windows * Bump FMT to 6.1.2 for cpp20 compat and swap fmt::join for Strings::Join * Windows compile fixes * Update CMakeLists.txt * Update CMakeLists.txt * Update CMakeLists.txt * Create 2022_12_19_player_events_tables.sql * [Formatters] Work on Discord Formatters * Handin money. * Format header * [Formatters] Work on Discord Formatters * Format * Format * [Formatters] More Formatter work, need to test further. * [Formatters] More Work on Formatters. * Add missing #endif * [Formatters] Work on Formatters, fix Bot formatting in ^create help * NPC Handin Discord Formatter * Update player_event_logs.cpp * Discover Item Discord Formatter * Dropped Item Discord Formatter * Split Money Discord Formatter * Trader Discord Formatters * Cleanup. * Trade Event Discord Formatter Groundwork * SAY don't record GM commands * GM_Command don't record #help * Update player_event_logs.cpp * Fill in more event data * Post rebase fixes * Post rebase fix * Discord formatting adjustments * Add event deprecation or unimplemented tag support * Trade events * Add return money and sanity checks. * Update schema * Update ucs.cpp * Update client.cpp * Update 2022_12_19_player_events_tables.sql * Implement archive single line * Replace hackers table and functions with PossibleHack player event * Replace very old eventlog table since the same events are covered by player event logs * Update bot_command.cpp * Record NPC kill events ALL / Named / Raid * Add BatchEventProcessIntervalSeconds rule * Naming * Update CMakeLists.txt * Update database_schema.h * Remove logging function and methods * DB version * Cleanup SendPlayerHandinEvent --------- Co-authored-by: Kinglykrab <kinglykrab@gmail.com> Co-authored-by: Aeadoin <109764533+Aeadoin@users.noreply.github.com>
170 lines
8.5 KiB
C++
170 lines
8.5 KiB
C++
/**
|
|
* EQEmulator: Everquest Server Emulator
|
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; version 2 of the License.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
|
* are required to give you total support for your newly bought product;
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*
|
|
*/
|
|
|
|
#ifndef EXPEDITION_H
|
|
#define EXPEDITION_H
|
|
|
|
#include "dynamic_zone.h"
|
|
#include "../common/expedition_lockout_timer.h"
|
|
#include "../common/repositories/expeditions_repository.h"
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
#include <cassert>
|
|
|
|
class Client;
|
|
class EQApplicationPacket;
|
|
struct ExpeditionInvite;
|
|
class ExpeditionRequest;
|
|
class ServerPacket;
|
|
|
|
extern const char* const DZ_YOU_NOT_ASSIGNED;
|
|
|
|
enum class ExpeditionLockMessage : uint8_t
|
|
{
|
|
None = 0,
|
|
Close,
|
|
Begin
|
|
};
|
|
|
|
class Expedition
|
|
{
|
|
public:
|
|
Expedition() = delete;
|
|
Expedition(DynamicZone* dz);
|
|
Expedition(DynamicZone* dz, uint32_t id, uint32_t dz_id);
|
|
|
|
static Expedition* TryCreate(Client* requester, DynamicZone& dynamiczone, bool disable_messages);
|
|
|
|
static void CacheFromDatabase(uint32_t expedition_id);
|
|
static bool CacheAllFromDatabase();
|
|
static Expedition* FindCachedExpeditionByCharacterID(uint32_t character_id);
|
|
static Expedition* FindCachedExpeditionByCharacterName(const std::string& char_name);
|
|
static Expedition* FindCachedExpeditionByDynamicZoneID(uint32_t dz_id);
|
|
static Expedition* FindCachedExpeditionByID(uint32_t expedition_id);
|
|
static Expedition* FindCachedExpeditionByZoneInstance(uint32_t zone_id, uint32_t instance_id);
|
|
static std::vector<ExpeditionLockoutTimer> GetExpeditionLockoutsByCharacterID(uint32_t character_id);
|
|
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 bool HasLockoutByCharacterID(uint32_t character_id,
|
|
const std::string& expedition_name, const std::string& event_name);
|
|
static bool HasLockoutByCharacterName(const std::string& character_name,
|
|
const std::string& expedition_name, const std::string& event_name);
|
|
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 = {});
|
|
static void AddLockoutClients(const ExpeditionLockoutTimer& lockout, uint32_t exclude_id = 0);
|
|
|
|
uint32_t GetID() const { return m_id; }
|
|
uint32_t GetDynamicZoneID() const { return m_dynamic_zone_id; }
|
|
DynamicZone* GetDynamicZone() const { return m_dynamic_zone; }
|
|
const DynamicZoneMember& GetLeader() { return GetDynamicZone()->GetLeader(); }
|
|
uint32_t GetLeaderID() { return GetDynamicZone()->GetLeaderID(); }
|
|
const std::string& GetLeaderName() { return GetDynamicZone()->GetLeaderName(); }
|
|
const std::unordered_map<std::string, ExpeditionLockoutTimer>& GetLockouts() const { return m_lockouts; }
|
|
const std::string& GetName() { return GetDynamicZone()->GetName(); }
|
|
void RegisterDynamicZoneCallbacks();
|
|
|
|
bool IsLocked() const { return m_is_locked; }
|
|
void SetLocked(bool lock_expedition, ExpeditionLockMessage lock_msg,
|
|
bool update_db = false, uint32_t msg_color = Chat::Yellow);
|
|
|
|
void AddLockout(const std::string& event_name, uint32_t seconds);
|
|
void AddLockoutDuration(const std::string& event_name, int seconds, bool members_only = true);
|
|
void AddReplayLockout(uint32_t seconds);
|
|
void AddReplayLockoutDuration(int seconds, bool members_only = true);
|
|
bool HasLockout(const std::string& event_name);
|
|
bool HasReplayLockout();
|
|
void RemoveLockout(const std::string& event_name);
|
|
void SetReplayLockoutOnMemberJoin(bool add_on_join, bool update_db = false);
|
|
void SyncCharacterLockouts(uint32_t character_id, std::vector<ExpeditionLockoutTimer>& client_lockouts);
|
|
void UpdateLockoutDuration(const std::string& event_name, uint32_t seconds, bool members_only = true);
|
|
|
|
bool CanClientLootCorpse(Client* client, uint32_t npc_type_id, uint32_t spawn_id);
|
|
std::string GetLootEventByNPCTypeID(uint32_t npc_id);
|
|
std::string GetLootEventBySpawnID(uint32_t spawn_id);
|
|
void SetLootEventByNPCTypeID(uint32_t npc_type_id, const std::string& event_name);
|
|
void SetLootEventBySpawnID(uint32_t spawn_id, const std::string& event_name);
|
|
|
|
void SendWorldMakeLeaderRequest(uint32_t requester_id, const std::string& new_leader_name);
|
|
void SendWorldPendingInvite(const ExpeditionInvite& invite, const std::string& add_name);
|
|
|
|
void DzAddPlayer(Client* requester, const std::string& add_char_name, const std::string& swap_remove_name = {});
|
|
void DzAddPlayerContinue(std::string leader_name, std::string add_char_name, std::string swap_remove_name = {});
|
|
void DzInviteResponse(Client* add_client, bool accepted, const std::string& swap_remove_name);
|
|
void DzMakeLeader(Client* requester, std::string new_leader_name);
|
|
void DzPlayerList(Client* requester);
|
|
void DzRemovePlayer(Client* requester, std::string remove_char_name);
|
|
void DzSwapPlayer(Client* requester, std::string remove_char_name, std::string add_char_name);
|
|
void DzQuit(Client* requester);
|
|
void DzKickPlayers(Client* requester);
|
|
|
|
static const int32_t REPLAY_TIMER_ID;
|
|
static const int32_t EVENT_TIMER_ID;
|
|
|
|
private:
|
|
static void CacheExpeditions(std::vector<ExpeditionsRepository::Expeditions>&& expeditions);
|
|
static void SendWorldCharacterLockout(uint32_t character_id, const ExpeditionLockoutTimer& lockout, bool remove);
|
|
|
|
void AddLockout(const ExpeditionLockoutTimer& lockout, bool members_only = false);
|
|
void AddLockoutDurationClients(const ExpeditionLockoutTimer& lockout, int seconds, uint32_t exclude_id = 0);
|
|
bool ConfirmLeaderCommand(Client* requester);
|
|
void OnClientAddRemove(Client* client, bool removed, bool silent);
|
|
void LoadRepositoryResult(const ExpeditionsRepository::Expeditions& entry);
|
|
bool ProcessAddConflicts(Client* leader_client, Client* add_client, bool swapping);
|
|
void ProcessLockoutDuration(const ExpeditionLockoutTimer& lockout, int seconds, bool members_only = false);
|
|
void ProcessLockoutUpdate(const ExpeditionLockoutTimer& lockout, bool remove, bool members_only = false);
|
|
void SaveLockouts(ExpeditionRequest& request);
|
|
void SendClientExpeditionInvite(
|
|
Client* client, const std::string& inviter_name, const std::string& swap_remove_name);
|
|
void SendLeaderMessage(Client* leader_client, uint16_t chat_type, uint32_t string_id,
|
|
const std::initializer_list<std::string>& args = {});
|
|
void SendWorldExpeditionUpdate(uint16_t server_opcode);
|
|
void SendWorldAddPlayerInvite(const std::string& inviter_name, const std::string& swap_remove_name,
|
|
const std::string& add_name, bool pending = false);
|
|
void SendWorldLockoutDuration(
|
|
const ExpeditionLockoutTimer& lockout, int seconds, bool members_only = false);
|
|
void SendWorldLockoutUpdate(
|
|
const ExpeditionLockoutTimer& lockout, bool remove, bool members_only = false);
|
|
void SendWorldSettingChanged(uint16_t server_opcode, bool setting_value);
|
|
void SetDynamicZone(DynamicZone&& dz);
|
|
void TryAddClient(Client* add_client, const std::string& inviter_name,
|
|
const std::string& swap_remove_name, Client* leader_client = nullptr);
|
|
|
|
std::unique_ptr<EQApplicationPacket> CreateInvitePacket(const std::string& inviter_name, const std::string& swap_remove_name);
|
|
|
|
uint32_t m_id = 0;
|
|
uint32_t m_dynamic_zone_id = 0;
|
|
bool m_is_locked = false;
|
|
bool m_add_replay_on_join = true;
|
|
DynamicZone* m_dynamic_zone = nullptr; // should never be null, will exist for lifetime of expedition
|
|
std::unordered_map<std::string, ExpeditionLockoutTimer> m_lockouts;
|
|
std::unordered_map<uint32_t, std::string> m_npc_loot_events; // only valid inside dz zone
|
|
std::unordered_map<uint32_t, std::string> m_spawn_loot_events; // only valid inside dz zone
|
|
};
|
|
|
|
#endif
|