mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 12:41:30 +00:00
[Shared Tasks] Shared Tasks System Implementation (#1451)
* Shared tasks WIP; lots of logging; shared tasks and tasks work internally the same for now; lots to cleanup yet * Update task_manager.cpp * Add tables * World message handler * Zone message handler * More messaging * More rearranging * Task creation work (wip) * Tweaks * Decoupled things, added a shared task manager, moved logic to the manager, created the shared task object, now creating a sense of state on creation and members, zero validation, happy path * Cleanup unnecessary getter * More work on shared task persistence and state loading * Add int64 support into repositories * More state handling, creation loads all tables * Wrap up shared task state creation and removal * Move more lookup operations to preloading (memory). Restore shared task state during world bootup * Implement shared task updates * Add members other than just leader in task confirmations * Update shared_task_manager.cpp * Hook task cancellation for shared task removal (middleware) * Remove dynamic_zone_id from SharedTasks model in repositories (for now) since we will likely be one to many with DZ objects * Get members to show up in the window on creation * Add opcodes, cleanup * Add opcode handlers * Split some methods out, self removal of shared task and updating members * Implement offline shared task sync * Style changes * Send memberlist on initial login; implement remove player from shared task window * Refactorings, cleanup * Implement make leader in shared tasks window * Implement add player, sync shared task state after add * Add opcodes for remaining clients * Shared task invite dialogue window implementation and response handling (including validation) * Logging * Remove comment * Some cleanup * Pass NPC context through shared task request logic * Remove extra SharedTaskMember fields * Add message constants * Remove static * Only use dz for expedition request This passes expedition creation parameters through DynamicZone instead of injecting ExpeditionRequest since it can hold creation data now * Store expedition leader on dz This shifts to using the leader object that exists in the core dynamic zone object. It will be moved to the dynamic zone table later with other columns that should just be on the dz to make loading easier. Expeditions are probably the only dz type that will use this for window updates and command auth. Other systems on live do fill the window but don't keep it updated * Store expedition name on dz This uses the name stored on dz (for window packets) instead of duplicating it. This will be moved completely to dz table later * Store uuid on dynamic zone This lets dynamic zones generate the uuid instead of expeditions. Other dz type systems may want to make use of this. Lockouts should also be moved to dynamic zones at some point in the future so this will be necessary for that * Move expedition db columns to dz These columns should just belong to the core dynamic zone. This will simplify loading from the database and in the future a separate expedition table may no longer be necessary. * Move window packet methods to dz It makes more sense for these methods to be in the core This will also allow support for other systems to use the window, though live behavior that updates the window for shared task missions when not in an expedition is likely unintended since it's not updated on changes. * Store dynamic zone ids on clients These will now be used for client dynamic zone lookups to remove dependency on any dz type system caches * Move member management to dz This moves server messaging for adding and removing members to internal dynamic zone methods Set default dz member status to Unknown * Move member status caching to dz This moves world member status caching into internal dz methods Zone member updates for created expeditions are now async and sent after world replies with member statuses. Prior to this two memberlist packets were sent to members in other zones on creation to update statuses. This also fixes a bug with member statuses being wrong for offline raid members in the zone that created an expedition. Note that live kicks offline players out of raids so this is only to support emu behavior. * Move member status updates to dz * Set dz member status on all client dzs This also renames the zone entry dz update method and moves window update to a dynamic zone method. Eventually expedition components should just be merged with dz and handled as another dz type * Save instance safe return on characters Add character_instance_safereturns table and repository Previously dz safe return only worked for online characters via the dz kicktimer or offline characters with a workaround that moved them when an expedition was deleted. There were various edge cases that would cause characters to be moved to bind instead (succoring after removal, camping before kick timer, removed while offline, bulk kickplayers removal with some offline) This updates a character's instance safereturn every time they enter a zone. If a character enters world in an instance that expired or are no longer part of they'll be moved to their instance safereturn (if the safereturn data is for the same zone-instance). Bind is still a fallback This may also be used for non-dz instancing so it's named generically This removes the expedition MoveMembersToSafeReturn workaround which deprecates the is_current_member column of dynamic_zone_members and will be removed in a followup patch. * Remove is_current_member from dz members This was only being used in the workaround to move past members to dz safereturns if they were still inside the dz but not online * Let dz check leader in world This moves expedition leader processing in world to the dynamic zone. This is a step in phasing out the separate expedition class for things that can run off the dynamic zone core with simple dz type checks This greatly simplifies checking leader on member and status changes without needing callbacks. Other dz types that may use the dz leader object can just handle it directly on the dz the same as expeditions * Let dz handle member expire warnings This moves expire warning checks to dz. This will make it easier for other dz types to issue expire warnings if needed * Use separate dynamic zone cache Dynamic zones are no longer member objects of expeditions and have been placed into their own cache. This was done so other dz types can be cached without relying on their systems. Client and zone dz Lookups are now independent of any system This continues the process of phasing out a separate expedition cache. Eventually expeditions can just be run directly as dynamic zones internally with a few dz type checks. Add dz serialization methods (cereal) for passing server dz creation Modify #dz list to show cache and database separately. Also adds #dz cache reload. This command will reload expeditions too since they currently hold references to the dz in their own zone cache. Add a dynamic zone processing class to world to process all types and move expedition processing to it * Move expedition makeleader processing to dz * Let dz handle expedition deletions This removes the need for separate expedition cache in world This will greatly simplify world dynamic zone caching and processing. Dynamic zones that are expeditions can just handle this directly. Once lockouts and other components are completely moved to dynamic zones the separate expedition cache in zone will also no longer be necessary * Remove ExpeditionBase class Since world no longer caches expeditions this will not be necessary * Fix windows compile * Implement task dz creation Prototype dz creation for shared tasks * Add and remove shared task members from dz Also keep leader updated (used in choose zone window) * Fix client crash on failed shared task * Fix linux compile and warning * Check client nullptr for dz message This was accidently removed when expedition makeleader was moved * Disable dz creation for solo tasks * Add shared task repository headers to CMakeLists * Add shared task dynamic zones table * Add shared task dz database persistence * Get members from db on shared task dz creation This fixes a case where removing a member from a shared task dz would fail if the member's name was empty. This could happen if the shared task dz was created while a member was offline. This also changes the dz member removal method to only check id. It might be possible to change all dz member validations to only check ids since names are primarily for window updates, but shared task dz member names need to be non-empty anyway to support possible live-like dz window usage in the future. * Add character message methods to world Add simple and eqstr message methods to ClientList Add shared task manager methods to message all members or leader * Add SyncClientSharedTaskState and nested sync strategies to cover M3 work * Fix whitespace * Implement task request cooldown timer This implements the task request cooldown (15 seconds) that live uses when a task is accepted. This will also need to be set when shared tasks are offered (likely due to additional group/raid validations) * Implement shared task selector validation This implements the validation and filtering that occurs before the task selection window is sent to a client for shared tasks To keep things live-like, task selectors that contain a shared task will be run through shared task validation and drop non-shared tasks. Live doesn't mix types in task selections and this makes validation simpler. Also note that live sends shared task selectors via a different opcode than solo tasks but that has not been implemented yet * Add separate shared task select opcodes Live uses separate opcodes for solo and shared task selection windows * Convert ActivityType to enum class * Refactor task selector serialization This adds serializer methods to task and task objective structs for the task selection windows. This combines the duplicate task selector methods to reduce code duplication and simplify serialization * Add shared task selector This sends shared task selection window using the shared task specific opcode and adds an opcode handler for shared task accepts which are sent by client in response to setting selection window to shared task type. * Refactor task objective serialization This adds a serialization method to the task objective struct for serializing objectives in the window list and combines the separate client-based methods to reduce duplicated code. * Add task level spread and player count columns * Implement shared task accept validation This adds a common method for shared task character request queries * Add task replay and request timer columns * Add character task timers table * Use shared task accept time on clients This overrides client task accept time with shared task's creation time. This is needed for accurate window task timers and lockout messages especially for characters added to shared tasks post creation * Implement task timer lockouts This implements replay and request task timers for solo and shared tasks * Add solo and shared task timer validation * Remove logging of padding array This gets interpreted as a c string which may not be null terminated * Implement /kickplayers task This also fixes current CancelTask behavior for leader which was performing kickplayers functionality through the remove task button * Implement /taskquit command * Implement shared task invite validation Remove active invitation before invite accept validation * Remove local client db persistence during SyncClientSharedTaskRemoveLocalIfNotExists * Add missing accept time arg to assign task * Only validate non-zero task invite requirements * Fix task error log crash * Separate task cooldown timer messaging * Use method to check for client shared task * Avoid unneeded task invite validation query Only need to query character data for levels for non-zero level spread * Implement /tasktimers command May want to add some type of throttled caching mechanism for this in the future * Add /tasktimers rate limiter * Intercept shared task completion; more work to come * Change SharedTaskActivityState and SharedTasks time objects to datetime * Add updated_time updates to SharedTaskActivities * Mark shared tasks as complete when all activities are completed * Save a database query on shared task completion and use the active record in memory * Don't record shared task completions to the quest log * Implement RecordSharedTaskCompletion, add tables, repositories * Update shared_task_manager.cpp * Update shared_task_manager.cpp * Add shared task replay timers This is still not feature complete. On live any past members that ever joined the shared task will receive a replay timer when it's completed * Create FindCharactersInSharedTasks that searches through memory * Remove namespace shorthand and formatting * More minor cleanup * Implement PurgeAllSharedTasks via #task command * Add #task purgetimers * Decrease m_keepalive time between processes * Remove type ordering in /tasktimer query * Add comment for task packet reward multiplier This is likely a reward multiplier that changes text color based on value to represent any scaled bonus or penalty * Add replay timers to past members This implements the live behavior that adds replay timers to any previous member of a shared task. This likely exists to avoid possible exploits. Shared task member history is stored in memory and is used to assign replay timers. This history will be lost on world crashes or restarts but is simpler than saving past member state in database. This also makes world send shared task replay timer messages since past members need to be messaged now * Move PurgeTaskTimers client method to tasks.cpp * Remove dz members when purging shared tasks Server dz states need to be updated before shared tasks are deleted * Use exact name in shared task invites This removes the wildcards from shared task invite character queries which was sometimes selecting the wrong character Taskadd validation is called even for invalid characters to allow for proper messages to occur * Clear declined active shared task invitations This also notifies leader for declined shared task invites * Store shared task member names This adds back the character name field to SharedTaskMember. This should make serialization easier in the future and reduce database lookups when names are needed for /task commands * Implement /taskplayerlist command * Replace queries with member name lookups Now that shared task members store names these queries are unnecessary This also adds not-a-member messages for /taskremove and /taskmakeleader * Implement shared task member change packet This avoids sending the full member list to members when a single member is added or removed and lets the client generate chat messages for it. * Serialize shared task member list from world This uses cereal to serialize the full member list from world and removes the zone query workarounds * Initialize client task state array This was causing sql query errors on client state reloads The client task information array was uninitialized resulting in being filled with 0xcdcdcdcd values in msvc debug builds. Under release builds this may have resulted in indeterminate values A better fix would be to refactor some of this legacy code * Add shared task command messages Add messages for non-leader task commands This adds taskadd, taskremove, taskmakeleader, and taskquit messages The leader receives double messages for taskremove like live due to the client generated message as well as the explicit one. It also receives double server messages if the leader /taskremoves self. * Replace some task messages with eqstrs This also updates to use live colors * Avoid shared task invite leader lookup query Since member names are stored now this query is also unnecessary * Avoid reloading client state on shared task accept This was unnecessarily reloading client task state when added to a shared task. This also resulted in all active tasks being resent to shared task members on creation. The shared task itself is the only task that needs to be sent which is handled by AcceptNewTask. * Remove active shared task invite on zone Live doesn't re-send shared task invites after zoning like it does for expeditions so there's no need to keep these around. This fixes active invitations never getting reset on characters that zone or go offline. * Choose new shared task leader if leader removed * Add separate shared task kickplayers method * Enable EVENT_CAST_ON for clients This will be required for a shared task objective (The Creator) in DoN * Revert "Avoid reloading client state on shared task accept" This reverts commit 3af14fee2de8b109ffb6c2b2fc67731e1531a665. Without this clients added to a task after some objectives have been completed don't get updated state. Will need to investigate this later * Disallow looting inside a dz by non-members Non-members of a dynamic zone should not be allowed to loot npcs inside it. This should have been disabled for expeditions already but was still allowed due to an oversight (or live behavior changed). This is less critical for shared tasks since members can be added and removed at will without leaving a dz but still an important feature. * Change load where criteria * Increase task completion emote column size * Use eqstr for task item reward message * Implement radiant and ebon crystal rewards This adds reward columns for radiant and ebon crystals to the tasks table and updates task description serialization * Send task completion emote before rewards This matches live and makes it a little easier to see item rewards when tasks have a long completion emote. This also changes it to send via the same normal message opcode that live uses. * Do not send a shared task in completed task history * Allow EVENT_TASK_STAGE_COMPLETE for quest goals This invokes event_task_stage_complete for task elements flagged with a quest controlled goal method. It should be expected behavior that a completed task stage always fires this event even if a quest controls it * Add SyncSharedTaskZoneClientDoneCountState * Swap return for continue in this case * Formatting * Simplify * Formatting * Formatting * Formatting * Remove errant check * Formatting, add setter for shared tasks * Remove debugging * Comments in PR * More PR follow up * Formatting * Cleanup * Update packet comments * Comments * More cleanup * Send command error message if not in shared task /taskadd is the only command with this feedback on live. Newer live clients also generate this instead of the server sending the message * Implement expire_time on SharedTask object and add a purge on world bootup * Comment * Add SyncClientSharedTaskStateToLocal where clients fall out of sync and no longer have a task locally * Clamp shared task activity updates to max done count and discard updates out of bounds * Fix packet send * Revert packet send * Adjust clamping OOO for completed time check. Add completed tables to purge truncation * Refactor kill update logic so that shared task kill updates only update one client instead of all clients * Cleanup how we're checking for active tasks * Forward task sets that contain shared tasks This forwards task sets that contain a shared task to shared task selector validation like normal task selectors * Change eqstr for empty solo task offers This is the message live appears to use if all task offers are filtered out by solo task validation * Fix max active tasks client message This message starts at the third argument. It was maybe intended to be an npc say message but live just sends it as a normal eqstr with the first two arguments nulled. * Load client task state after zoning complete This fixes a possible race where a character removed from a shared task while zoning would be stuck with an incorrect character activities state after zoning was completed. This was caused by the character loading task state to early on zone entry but never receiving the remove player message from world since they are missing from the world cle until zoning is completed. Loading client state after zone connection is completed makes sure the client has the latest state and available to the world cle * Send message to clients removed while zoning This message should usually only be sent to characters that were removed from a shared task while zoning but will occur for any sync state removals where a message wouldn't have already occured. * Post rebase fix * HG comment for checking active task * Addressing HG comments around zeroing out a shared task id * Remove errant comment * Post rebase database manifest updates * Update eqemu_logsys_log_aliases.h * More rebase catches * Bump database version for last commit Co-authored-by: hg <4683435+hgtw@users.noreply.github.com>
This commit is contained in:
parent
943c623be0
commit
e7dd8d49a9
@ -32,7 +32,6 @@ SET(common_sources
|
||||
eq_stream_proxy.cpp
|
||||
eqtime.cpp
|
||||
event_sub.cpp
|
||||
expedition_base.cpp
|
||||
expedition_lockout_timer.cpp
|
||||
extprofile.cpp
|
||||
faction.cpp
|
||||
@ -72,6 +71,7 @@ SET(common_sources
|
||||
serialize_buffer.cpp
|
||||
server_event_scheduler.cpp
|
||||
serverinfo.cpp
|
||||
shared_tasks.cpp
|
||||
shareddb.cpp
|
||||
skills.cpp
|
||||
spdat.cpp
|
||||
@ -154,6 +154,7 @@ SET(repositories
|
||||
repositories/base/base_character_disciplines_repository.h
|
||||
repositories/base/base_character_expedition_lockouts_repository.h
|
||||
repositories/base/base_character_inspect_messages_repository.h
|
||||
repositories/base/base_character_instance_safereturns_repository.h
|
||||
repositories/base/base_character_item_recast_repository.h
|
||||
repositories/base/base_character_languages_repository.h
|
||||
repositories/base/base_character_leadership_abilities_repository.h
|
||||
@ -165,11 +166,15 @@ SET(repositories
|
||||
repositories/base/base_character_potionbelt_repository.h
|
||||
repositories/base/base_character_skills_repository.h
|
||||
repositories/base/base_character_spells_repository.h
|
||||
repositories/base/base_character_task_timers_repository.h
|
||||
repositories/base/base_character_tasks_repository.h
|
||||
repositories/base/base_char_create_combinations_repository.h
|
||||
repositories/base/base_char_create_point_allocations_repository.h
|
||||
repositories/base/base_char_recipe_list_repository.h
|
||||
repositories/base/base_completed_tasks_repository.h
|
||||
repositories/base/base_completed_shared_tasks_repository.h
|
||||
repositories/base/base_completed_shared_task_members_repository.h
|
||||
repositories/base/base_completed_shared_task_activity_state_repository.h
|
||||
repositories/base/base_content_flags_repository.h
|
||||
repositories/base/base_damageshieldtypes_repository.h
|
||||
repositories/base/base_data_buckets_repository.h
|
||||
@ -255,6 +260,10 @@ SET(repositories
|
||||
repositories/base/base_rule_values_repository.h
|
||||
repositories/base/base_saylink_repository.h
|
||||
repositories/base/base_server_scheduled_events_repository.h
|
||||
repositories/base/base_shared_tasks_repository.h
|
||||
repositories/base/base_shared_task_activity_state_repository.h
|
||||
repositories/base/base_shared_task_dynamic_zones_repository.h
|
||||
repositories/base/base_shared_task_members_repository.h
|
||||
repositories/base/base_skill_caps_repository.h
|
||||
repositories/base/base_spawn2_repository.h
|
||||
repositories/base/base_spawnentry_repository.h
|
||||
@ -318,6 +327,7 @@ SET(repositories
|
||||
repositories/character_disciplines_repository.h
|
||||
repositories/character_expedition_lockouts_repository.h
|
||||
repositories/character_inspect_messages_repository.h
|
||||
repositories/character_instance_safereturns_repository.h
|
||||
repositories/character_item_recast_repository.h
|
||||
repositories/character_languages_repository.h
|
||||
repositories/character_leadership_abilities_repository.h
|
||||
@ -329,11 +339,15 @@ SET(repositories
|
||||
repositories/character_potionbelt_repository.h
|
||||
repositories/character_skills_repository.h
|
||||
repositories/character_spells_repository.h
|
||||
repositories/character_task_timers_repository.h
|
||||
repositories/character_tasks_repository.h
|
||||
repositories/char_create_combinations_repository.h
|
||||
repositories/char_create_point_allocations_repository.h
|
||||
repositories/char_recipe_list_repository.h
|
||||
repositories/completed_tasks_repository.h
|
||||
repositories/completed_shared_tasks_repository.h
|
||||
repositories/completed_shared_task_members_repository.h
|
||||
repositories/completed_shared_task_activity_state_repository.h
|
||||
repositories/content_flags_repository.h
|
||||
repositories/damageshieldtypes_repository.h
|
||||
repositories/data_buckets_repository.h
|
||||
@ -419,6 +433,10 @@ SET(repositories
|
||||
repositories/rule_values_repository.h
|
||||
repositories/saylink_repository.h
|
||||
repositories/server_scheduled_events_repository.h
|
||||
repositories/shared_tasks_repository.h
|
||||
repositories/shared_task_activity_state_repository.h
|
||||
repositories/shared_task_dynamic_zones_repository.h
|
||||
repositories/shared_task_members_repository.h
|
||||
repositories/skill_caps_repository.h
|
||||
repositories/spawn2_repository.h
|
||||
repositories/spawnentry_repository.h
|
||||
@ -497,7 +515,6 @@ SET(common_headers
|
||||
eqtime.h
|
||||
errmsg.h
|
||||
event_sub.h
|
||||
expedition_base.h
|
||||
expedition_lockout_timer.h
|
||||
extprofile.h
|
||||
faction.h
|
||||
@ -553,11 +570,13 @@ SET(common_headers
|
||||
server_event_scheduler.h
|
||||
serverinfo.h
|
||||
servertalk.h
|
||||
shared_tasks.h
|
||||
shareddb.h
|
||||
skills.h
|
||||
spdat.h
|
||||
string_util.h
|
||||
struct_strategy.h
|
||||
tasks.h
|
||||
textures.h
|
||||
timer.h
|
||||
types.h
|
||||
|
||||
@ -53,6 +53,7 @@ namespace DatabaseSchema {
|
||||
{"character_expedition_lockouts", "character_id"},
|
||||
{"character_exp_modifiers", "character_id"},
|
||||
{"character_inspect_messages", "id"},
|
||||
{"character_instance_safereturns", "character_id"},
|
||||
{"character_item_recast", "id"},
|
||||
{"character_languages", "id"},
|
||||
{"character_leadership_abilities", "id"},
|
||||
@ -64,6 +65,7 @@ namespace DatabaseSchema {
|
||||
{"character_potionbelt", "id"},
|
||||
{"character_skills", "id"},
|
||||
{"character_spells", "id"},
|
||||
{"character_task_timers", "character_id"},
|
||||
{"character_tasks", "charid"},
|
||||
{"character_tribute", "id"},
|
||||
{"completed_tasks", "charid"},
|
||||
@ -119,6 +121,7 @@ namespace DatabaseSchema {
|
||||
"character_expedition_lockouts",
|
||||
"character_exp_modifiers",
|
||||
"character_inspect_messages",
|
||||
"character_instance_safereturns",
|
||||
"character_item_recast",
|
||||
"character_languages",
|
||||
"character_leadership_abilities",
|
||||
@ -130,6 +133,7 @@ namespace DatabaseSchema {
|
||||
"character_potionbelt",
|
||||
"character_skills",
|
||||
"character_spells",
|
||||
"character_task_timers",
|
||||
"character_tasks",
|
||||
"character_tribute",
|
||||
"completed_tasks",
|
||||
@ -310,6 +314,9 @@ namespace DatabaseSchema {
|
||||
"banned_ips",
|
||||
"bug_reports",
|
||||
"bugs",
|
||||
"completed_shared_task_activity_state",
|
||||
"completed_shared_task_members",
|
||||
"completed_shared_tasks",
|
||||
"dynamic_zone_members",
|
||||
"dynamic_zones",
|
||||
"eventlog",
|
||||
@ -319,8 +326,8 @@ namespace DatabaseSchema {
|
||||
"group_id",
|
||||
"group_leaders",
|
||||
"hackers",
|
||||
"ip_exemptions",
|
||||
"instance_list",
|
||||
"ip_exemptions",
|
||||
"item_tick",
|
||||
"lfguild",
|
||||
"merchantlist_temp",
|
||||
@ -332,6 +339,10 @@ namespace DatabaseSchema {
|
||||
"respawn_times",
|
||||
"saylink",
|
||||
"server_scheduled_events",
|
||||
"shared_task_activity_state",
|
||||
"shared_task_dynamic_zones",
|
||||
"shared_task_members",
|
||||
"shared_tasks",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include "repositories/instance_list_player_repository.h"
|
||||
#include "rulesys.h"
|
||||
#include "servertalk.h"
|
||||
#include "util/uuid.h"
|
||||
|
||||
DynamicZoneBase::DynamicZoneBase(DynamicZonesRepository::DynamicZoneInstance&& entry)
|
||||
{
|
||||
@ -13,16 +14,12 @@ DynamicZoneBase::DynamicZoneBase(DynamicZonesRepository::DynamicZoneInstance&& e
|
||||
|
||||
uint32_t DynamicZoneBase::Create()
|
||||
{
|
||||
if (m_id != 0)
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
if (GetInstanceID() == 0)
|
||||
{
|
||||
CreateInstance();
|
||||
}
|
||||
|
||||
m_uuid = EQ::Util::UUID::Generate().ToString();
|
||||
m_id = SaveToDatabase();
|
||||
|
||||
return m_id;
|
||||
@ -75,6 +72,11 @@ uint32_t DynamicZoneBase::CreateInstance()
|
||||
void DynamicZoneBase::LoadRepositoryResult(DynamicZonesRepository::DynamicZoneInstance&& dz_entry)
|
||||
{
|
||||
m_id = dz_entry.id;
|
||||
m_uuid = std::move(dz_entry.uuid);
|
||||
m_name = std::move(dz_entry.name);
|
||||
m_leader.id = dz_entry.leader_id;
|
||||
m_min_players = dz_entry.min_players;
|
||||
m_max_players = dz_entry.max_players;
|
||||
m_instance_id = dz_entry.instance_id;
|
||||
m_type = static_cast<DynamicZoneType>(dz_entry.type);
|
||||
m_compass.zone_id = dz_entry.compass_zone_id;
|
||||
@ -104,6 +106,12 @@ void DynamicZoneBase::AddMemberFromRepositoryResult(
|
||||
DynamicZoneMembersRepository::MemberWithName&& entry)
|
||||
{
|
||||
auto status = DynamicZoneMemberStatus::Unknown;
|
||||
|
||||
if (m_leader.id == entry.character_id)
|
||||
{
|
||||
m_leader.name = entry.character_name;
|
||||
}
|
||||
|
||||
AddInternalMember({ entry.character_id, std::move(entry.character_name), status });
|
||||
}
|
||||
|
||||
@ -114,6 +122,11 @@ uint32_t DynamicZoneBase::SaveToDatabase()
|
||||
if (m_instance_id != 0)
|
||||
{
|
||||
auto insert_dz = DynamicZonesRepository::NewEntity();
|
||||
insert_dz.uuid = m_uuid;
|
||||
insert_dz.name = m_name;
|
||||
insert_dz.leader_id = m_leader.id;
|
||||
insert_dz.min_players = m_min_players;
|
||||
insert_dz.max_players = m_max_players;
|
||||
insert_dz.instance_id = m_instance_id,
|
||||
insert_dz.type = static_cast<int>(m_type);
|
||||
insert_dz.compass_zone_id = m_compass.zone_id;
|
||||
@ -137,34 +150,80 @@ uint32_t DynamicZoneBase::SaveToDatabase()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DynamicZoneBase::AddCharacter(uint32_t character_id)
|
||||
bool DynamicZoneBase::AddMember(const DynamicZoneMember& add_member)
|
||||
{
|
||||
DynamicZoneMembersRepository::AddMember(GetDatabase(), m_id, character_id);
|
||||
GetDatabase().AddClientToInstance(m_instance_id, character_id);
|
||||
SendInstanceAddRemoveCharacter(character_id, false); // stops client kick timer
|
||||
}
|
||||
|
||||
void DynamicZoneBase::RemoveCharacter(uint32_t character_id)
|
||||
{
|
||||
DynamicZoneMembersRepository::RemoveMember(GetDatabase(), m_id, character_id);
|
||||
GetDatabase().RemoveClientFromInstance(m_instance_id, character_id);
|
||||
SendInstanceAddRemoveCharacter(character_id, true); // start client kick timer
|
||||
}
|
||||
|
||||
void DynamicZoneBase::RemoveAllCharacters(bool enable_removal_timers)
|
||||
{
|
||||
if (GetInstanceID() == 0)
|
||||
if (HasMember(add_member.id))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (enable_removal_timers)
|
||||
DynamicZoneMembersRepository::AddMember(GetDatabase(), m_id, add_member.id);
|
||||
GetDatabase().AddClientToInstance(m_instance_id, add_member.id);
|
||||
|
||||
ProcessMemberAddRemove(add_member, false);
|
||||
SendServerPacket(CreateServerMemberAddRemovePacket(add_member, false).get());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DynamicZoneBase::RemoveMember(uint32_t character_id)
|
||||
{
|
||||
auto remove_member = GetMemberData(character_id);
|
||||
return RemoveMember(remove_member);
|
||||
}
|
||||
|
||||
bool DynamicZoneBase::RemoveMember(const std::string& character_name)
|
||||
{
|
||||
auto remove_member = GetMemberData(character_name);
|
||||
return RemoveMember(remove_member);
|
||||
}
|
||||
|
||||
bool DynamicZoneBase::RemoveMember(const DynamicZoneMember& remove_member)
|
||||
{
|
||||
if (remove_member.id == 0)
|
||||
{
|
||||
SendInstanceRemoveAllCharacters();
|
||||
return false;
|
||||
}
|
||||
|
||||
DynamicZoneMembersRepository::RemoveMember(GetDatabase(), m_id, remove_member.id);
|
||||
GetDatabase().RemoveClientFromInstance(m_instance_id, remove_member.id);
|
||||
|
||||
ProcessMemberAddRemove(remove_member, true);
|
||||
SendServerPacket(CreateServerMemberAddRemovePacket(remove_member, true).get());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DynamicZoneBase::SwapMember(
|
||||
const DynamicZoneMember& add_member, const std::string& remove_char_name)
|
||||
{
|
||||
auto remove_member = GetMemberData(remove_char_name);
|
||||
if (!add_member.IsValid() || !remove_member.IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// make remove and add atomic to avoid racing with separate world messages
|
||||
DynamicZoneMembersRepository::RemoveMember(GetDatabase(), m_id, remove_member.id);
|
||||
GetDatabase().RemoveClientFromInstance(m_instance_id, remove_member.id);
|
||||
|
||||
DynamicZoneMembersRepository::AddMember(GetDatabase(), m_id, add_member.id);
|
||||
GetDatabase().AddClientToInstance(m_instance_id, add_member.id);
|
||||
|
||||
ProcessMemberAddRemove(remove_member, true);
|
||||
ProcessMemberAddRemove(add_member, false);
|
||||
SendServerPacket(CreateServerMemberSwapPacket(remove_member, add_member).get());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DynamicZoneBase::RemoveAllMembers()
|
||||
{
|
||||
DynamicZoneMembersRepository::RemoveAllMembers(GetDatabase(), m_id);
|
||||
GetDatabase().RemoveClientsFromInstance(GetInstanceID());
|
||||
|
||||
ProcessRemoveAllMembers();
|
||||
SendServerPacket(CreateServerRemoveAllMembersPacket().get());
|
||||
}
|
||||
|
||||
void DynamicZoneBase::SaveMembers(const std::vector<DynamicZoneMember>& members)
|
||||
@ -181,7 +240,6 @@ void DynamicZoneBase::SaveMembers(const std::vector<DynamicZoneMember>& members)
|
||||
DynamicZoneMembersRepository::DynamicZoneMembers member_entry{};
|
||||
member_entry.dynamic_zone_id = m_id;
|
||||
member_entry.character_id = member.id;
|
||||
member_entry.is_current_member = true;
|
||||
insert_members.emplace_back(member_entry);
|
||||
|
||||
InstanceListPlayerRepository::InstanceListPlayer player_entry;
|
||||
@ -206,7 +264,7 @@ void DynamicZoneBase::SetCompass(const DynamicZoneLocation& location, bool updat
|
||||
DynamicZonesRepository::UpdateCompass(GetDatabase(),
|
||||
m_id, m_compass.zone_id, m_compass.x, m_compass.y, m_compass.z);
|
||||
|
||||
SendGlobalLocationChange(ServerOP_DzSetCompass, location);
|
||||
SendServerPacket(CreateServerDzLocationPacket(ServerOP_DzSetCompass, location).get());
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,7 +285,7 @@ void DynamicZoneBase::SetSafeReturn(const DynamicZoneLocation& location, bool up
|
||||
DynamicZonesRepository::UpdateSafeReturn(GetDatabase(), m_id, m_safereturn.zone_id,
|
||||
m_safereturn.x, m_safereturn.y, m_safereturn.z, m_safereturn.heading);
|
||||
|
||||
SendGlobalLocationChange(ServerOP_DzSetSafeReturn, location);
|
||||
SendServerPacket(CreateServerDzLocationPacket(ServerOP_DzSetSafeReturn, location).get());
|
||||
}
|
||||
}
|
||||
|
||||
@ -249,7 +307,7 @@ void DynamicZoneBase::SetZoneInLocation(const DynamicZoneLocation& location, boo
|
||||
DynamicZonesRepository::UpdateZoneIn(GetDatabase(), m_id, m_zone_id,
|
||||
m_zonein.x, m_zonein.y, m_zonein.z, m_zonein.heading, m_has_zonein);
|
||||
|
||||
SendGlobalLocationChange(ServerOP_DzSetZoneIn, location);
|
||||
SendServerPacket(CreateServerDzLocationPacket(ServerOP_DzSetZoneIn, location).get());
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,35 +316,71 @@ void DynamicZoneBase::SetZoneInLocation(float x, float y, float z, float heading
|
||||
SetZoneInLocation({ 0, x, y, z, heading }, update_db);
|
||||
}
|
||||
|
||||
void DynamicZoneBase::SetLeader(const DynamicZoneMember& new_leader, bool update_db)
|
||||
{
|
||||
m_leader = new_leader;
|
||||
|
||||
if (update_db)
|
||||
{
|
||||
DynamicZonesRepository::UpdateLeaderID(GetDatabase(), m_id, new_leader.id);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t DynamicZoneBase::GetSecondsRemaining() const
|
||||
{
|
||||
auto remaining = std::chrono::duration_cast<std::chrono::seconds>(GetDurationRemaining()).count();
|
||||
return std::max(0, static_cast<int>(remaining));
|
||||
}
|
||||
|
||||
std::unique_ptr<ServerPacket> DynamicZoneBase::CreateServerAddRemoveCharacterPacket(
|
||||
uint32_t character_id, bool removed)
|
||||
std::unique_ptr<ServerPacket> DynamicZoneBase::CreateServerMemberAddRemovePacket(
|
||||
const DynamicZoneMember& member, bool removed)
|
||||
{
|
||||
constexpr uint32_t pack_size = sizeof(ServerDzCharacter_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_DzAddRemoveCharacter, pack_size);
|
||||
auto buf = reinterpret_cast<ServerDzCharacter_Struct*>(pack->pBuffer);
|
||||
buf->zone_id = GetZoneID();
|
||||
buf->instance_id = GetInstanceID();
|
||||
buf->remove = removed;
|
||||
buf->character_id = character_id;
|
||||
constexpr uint32_t pack_size = sizeof(ServerDzMember_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_DzAddRemoveMember, pack_size);
|
||||
auto buf = reinterpret_cast<ServerDzMember_Struct*>(pack->pBuffer);
|
||||
buf->dz_id = GetID();
|
||||
buf->dz_zone_id = GetZoneID();
|
||||
buf->dz_instance_id = GetInstanceID();
|
||||
buf->sender_zone_id = GetCurrentZoneID();
|
||||
buf->sender_instance_id = GetCurrentInstanceID();
|
||||
buf->removed = removed;
|
||||
buf->character_id = member.id;
|
||||
buf->character_status = static_cast<uint8_t>(member.status);
|
||||
strn0cpy(buf->character_name, member.name.c_str(), sizeof(buf->character_name));
|
||||
|
||||
return pack;
|
||||
}
|
||||
|
||||
std::unique_ptr<ServerPacket> DynamicZoneBase::CreateServerRemoveAllCharactersPacket()
|
||||
std::unique_ptr<ServerPacket> DynamicZoneBase::CreateServerMemberSwapPacket(
|
||||
const DynamicZoneMember& remove_member, const DynamicZoneMember& add_member)
|
||||
{
|
||||
constexpr uint32_t pack_size = sizeof(ServerDzCharacter_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_DzRemoveAllCharacters, pack_size);
|
||||
auto buf = reinterpret_cast<ServerDzCharacter_Struct*>(pack->pBuffer);
|
||||
buf->zone_id = GetZoneID();
|
||||
buf->instance_id = GetInstanceID();
|
||||
buf->remove = true;
|
||||
buf->character_id = 0;
|
||||
constexpr uint32_t pack_size = sizeof(ServerDzMemberSwap_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_DzSwapMembers, pack_size);
|
||||
auto buf = reinterpret_cast<ServerDzMemberSwap_Struct*>(pack->pBuffer);
|
||||
buf->dz_id = GetID();
|
||||
buf->dz_zone_id = GetZoneID();
|
||||
buf->dz_instance_id = GetInstanceID();
|
||||
buf->sender_zone_id = GetCurrentZoneID();
|
||||
buf->sender_instance_id = GetCurrentInstanceID();
|
||||
buf->add_character_status = static_cast<uint8_t>(add_member.status);
|
||||
buf->add_character_id = add_member.id;
|
||||
buf->remove_character_id = remove_member.id;
|
||||
strn0cpy(buf->add_character_name, add_member.name.c_str(), sizeof(buf->add_character_name));
|
||||
strn0cpy(buf->remove_character_name, remove_member.name.c_str(), sizeof(buf->remove_character_name));
|
||||
|
||||
return pack;
|
||||
}
|
||||
|
||||
std::unique_ptr<ServerPacket> DynamicZoneBase::CreateServerRemoveAllMembersPacket()
|
||||
{
|
||||
constexpr uint32_t pack_size = sizeof(ServerDzID_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_DzRemoveAllMembers, pack_size);
|
||||
auto buf = reinterpret_cast<ServerDzID_Struct*>(pack->pBuffer);
|
||||
buf->dz_id = GetID();
|
||||
buf->dz_zone_id = GetZoneID();
|
||||
buf->dz_instance_id = GetInstanceID();
|
||||
buf->sender_zone_id = GetCurrentZoneID();
|
||||
buf->sender_instance_id = GetCurrentInstanceID();
|
||||
|
||||
return pack;
|
||||
}
|
||||
@ -309,10 +403,25 @@ std::unique_ptr<ServerPacket> DynamicZoneBase::CreateServerDzLocationPacket(
|
||||
return pack;
|
||||
}
|
||||
|
||||
std::unique_ptr<ServerPacket> DynamicZoneBase::CreateServerMemberStatusPacket(
|
||||
uint32_t character_id, DynamicZoneMemberStatus status)
|
||||
{
|
||||
constexpr uint32_t pack_size = sizeof(ServerDzMemberStatus_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_DzUpdateMemberStatus, pack_size);
|
||||
auto buf = reinterpret_cast<ServerDzMemberStatus_Struct*>(pack->pBuffer);
|
||||
buf->dz_id = GetID();
|
||||
buf->sender_zone_id = GetCurrentZoneID();
|
||||
buf->sender_instance_id = GetCurrentInstanceID();
|
||||
buf->status = static_cast<uint8_t>(status);
|
||||
buf->character_id = character_id;
|
||||
|
||||
return pack;
|
||||
}
|
||||
|
||||
uint32_t DynamicZoneBase::GetDatabaseMemberCount()
|
||||
{
|
||||
return DynamicZoneMembersRepository::GetCountWhere(GetDatabase(),
|
||||
fmt::format("dynamic_zone_id = {} AND is_current_member = TRUE", m_id));
|
||||
fmt::format("dynamic_zone_id = {}", m_id));
|
||||
}
|
||||
|
||||
bool DynamicZoneBase::HasDatabaseMember(uint32_t character_id)
|
||||
@ -323,7 +432,7 @@ bool DynamicZoneBase::HasDatabaseMember(uint32_t character_id)
|
||||
}
|
||||
|
||||
auto entries = DynamicZoneMembersRepository::GetWhere(GetDatabase(), fmt::format(
|
||||
"dynamic_zone_id = {} AND character_id = {} AND is_current_member = TRUE",
|
||||
"dynamic_zone_id = {} AND character_id = {}",
|
||||
m_id, character_id
|
||||
));
|
||||
|
||||
@ -411,6 +520,33 @@ bool DynamicZoneBase::SetInternalMemberStatus(uint32_t character_id, DynamicZone
|
||||
return false;
|
||||
}
|
||||
|
||||
void DynamicZoneBase::SetMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status)
|
||||
{
|
||||
auto update_member = GetMemberData(character_id);
|
||||
if (update_member.IsValid())
|
||||
{
|
||||
ProcessMemberStatusChange(character_id, status);
|
||||
SendServerPacket(CreateServerMemberStatusPacket(character_id, status).get());
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZoneBase::ProcessMemberAddRemove(const DynamicZoneMember& member, bool removed)
|
||||
{
|
||||
if (!removed)
|
||||
{
|
||||
AddInternalMember(member);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveInternalMember(member.id);
|
||||
}
|
||||
}
|
||||
|
||||
bool DynamicZoneBase::ProcessMemberStatusChange(uint32_t character_id, DynamicZoneMemberStatus status)
|
||||
{
|
||||
return SetInternalMemberStatus(character_id, status);
|
||||
}
|
||||
|
||||
std::string DynamicZoneBase::GetDynamicZoneTypeName(DynamicZoneType dz_type)
|
||||
{
|
||||
switch (dz_type)
|
||||
@ -428,3 +564,36 @@ std::string DynamicZoneBase::GetDynamicZoneTypeName(DynamicZoneType dz_type)
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
EQ::Net::DynamicPacket DynamicZoneBase::GetSerializedDzPacket()
|
||||
{
|
||||
EQ::Net::DynamicPacket dyn_pack;
|
||||
dyn_pack.PutSerialize(0, *this);
|
||||
|
||||
LogDynamicZonesDetail("Serialized server dz size [{}]", dyn_pack.Length());
|
||||
return dyn_pack;
|
||||
}
|
||||
|
||||
std::unique_ptr<ServerPacket> DynamicZoneBase::CreateServerDzCreatePacket(
|
||||
uint16_t origin_zone_id, uint16_t origin_instance_id)
|
||||
{
|
||||
EQ::Net::DynamicPacket dyn_pack = GetSerializedDzPacket();
|
||||
|
||||
auto pack_size = sizeof(ServerDzCreateSerialized_Struct) + dyn_pack.Length();
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_DzCreated, static_cast<uint32_t>(pack_size));
|
||||
auto buf = reinterpret_cast<ServerDzCreateSerialized_Struct*>(pack->pBuffer);
|
||||
buf->origin_zone_id = origin_zone_id;
|
||||
buf->origin_instance_id = origin_instance_id;
|
||||
buf->cereal_size = static_cast<uint32_t>(dyn_pack.Length());
|
||||
memcpy(buf->cereal_data, dyn_pack.Data(), dyn_pack.Length());
|
||||
|
||||
return pack;
|
||||
}
|
||||
|
||||
void DynamicZoneBase::LoadSerializedDzPacket(char* cereal_data, uint32_t cereal_size)
|
||||
{
|
||||
LogDynamicZonesDetail("Deserializing server dz size [{}]", cereal_size);
|
||||
EQ::Util::MemoryStreamReader ss(cereal_data, cereal_size);
|
||||
cereal::BinaryInputArchive archive(ss);
|
||||
archive(*this);
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define COMMON_DYNAMIC_ZONE_BASE_H
|
||||
|
||||
#include "eq_constants.h"
|
||||
#include "net/packet.h"
|
||||
#include "repositories/dynamic_zones_repository.h"
|
||||
#include "repositories/dynamic_zone_members_repository.h"
|
||||
#include <algorithm>
|
||||
@ -18,7 +19,7 @@ struct DynamicZoneMember
|
||||
{
|
||||
uint32_t id = 0;
|
||||
std::string name;
|
||||
DynamicZoneMemberStatus status = DynamicZoneMemberStatus::Online;
|
||||
DynamicZoneMemberStatus status = DynamicZoneMemberStatus::Unknown;
|
||||
|
||||
DynamicZoneMember() = default;
|
||||
DynamicZoneMember(uint32_t id, std::string name_)
|
||||
@ -29,6 +30,12 @@ struct DynamicZoneMember
|
||||
bool IsOnline() const { return status == DynamicZoneMemberStatus::Online ||
|
||||
status == DynamicZoneMemberStatus::InDynamicZone; }
|
||||
bool IsValid() const { return id != 0 && !name.empty(); }
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive& archive)
|
||||
{
|
||||
archive(id, name, status);
|
||||
}
|
||||
};
|
||||
|
||||
struct DynamicZoneLocation
|
||||
@ -42,6 +49,12 @@ struct DynamicZoneLocation
|
||||
DynamicZoneLocation() = default;
|
||||
DynamicZoneLocation(uint32_t zone_id_, float x_, float y_, float z_, float heading_)
|
||||
: zone_id(zone_id_), x(x_), y(y_), z(z_), heading(heading_) {}
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive& archive)
|
||||
{
|
||||
archive(zone_id, x, y, z, heading);
|
||||
}
|
||||
};
|
||||
|
||||
class DynamicZoneBase
|
||||
@ -64,6 +77,7 @@ public:
|
||||
uint64_t GetExpireTime() const { return std::chrono::system_clock::to_time_t(m_expire_time); }
|
||||
uint32_t GetID() const { return m_id; }
|
||||
uint16_t GetInstanceID() const { return static_cast<uint16_t>(m_instance_id); }
|
||||
uint32_t GetLeaderID() const { return m_leader.id; }
|
||||
uint32_t GetMaxPlayers() const { return m_max_players; }
|
||||
uint32_t GetMemberCount() const { return static_cast<uint32_t>(m_members.size()); }
|
||||
uint32_t GetMinPlayers() const { return m_min_players; }
|
||||
@ -74,6 +88,7 @@ public:
|
||||
DynamicZoneType GetType() const { return m_type; }
|
||||
const std::string& GetLeaderName() const { return m_leader.name; }
|
||||
const std::string& GetName() const { return m_name; }
|
||||
const std::string& GetUUID() const { return m_uuid; }
|
||||
const DynamicZoneMember& GetLeader() const { return m_leader; }
|
||||
const std::vector<DynamicZoneMember>& GetMembers() const { return m_members; }
|
||||
const DynamicZoneLocation& GetCompassLocation() const { return m_compass; }
|
||||
@ -81,14 +96,12 @@ public:
|
||||
const DynamicZoneLocation& GetZoneInLocation() const { return m_zonein; }
|
||||
std::chrono::system_clock::duration GetDurationRemaining() const { return m_expire_time - std::chrono::system_clock::now(); }
|
||||
|
||||
void AddCharacter(uint32_t character_id);
|
||||
void AddInternalMember(const DynamicZoneMember& member);
|
||||
bool AddMember(const DynamicZoneMember& add_member);
|
||||
void AddMemberFromRepositoryResult(DynamicZoneMembersRepository::MemberWithName&& entry);
|
||||
void ClearInternalMembers() { m_members.clear(); }
|
||||
uint32_t Create();
|
||||
uint32_t GetDatabaseMemberCount();
|
||||
DynamicZoneMember GetMemberData(uint32_t character_id);
|
||||
DynamicZoneMember GetMemberData(const std::string& character_name);
|
||||
EQ::Net::DynamicPacket GetSerializedDzPacket();
|
||||
bool HasDatabaseMember(uint32_t character_id);
|
||||
bool HasMember(uint32_t character_id);
|
||||
bool HasMember(const std::string& character_name);
|
||||
@ -98,38 +111,52 @@ public:
|
||||
bool IsInstanceID(uint32_t instance_id) const { return (m_instance_id != 0 && m_instance_id == instance_id); }
|
||||
bool IsValid() const { return m_instance_id != 0; }
|
||||
bool IsSameDz(uint32_t zone_id, uint32_t instance_id) const { return zone_id == m_zone_id && instance_id == m_instance_id; }
|
||||
void RemoveAllCharacters(bool enable_removal_timers = true);
|
||||
void RemoveCharacter(uint32_t character_id);
|
||||
void RemoveInternalMember(uint32_t character_id);
|
||||
void LoadSerializedDzPacket(char* cereal_data, uint32_t cereal_size);
|
||||
void RemoveAllMembers();
|
||||
bool RemoveMember(uint32_t character_id);
|
||||
bool RemoveMember(const std::string& character_name);
|
||||
bool RemoveMember(const DynamicZoneMember& remove_member);
|
||||
void SaveMembers(const std::vector<DynamicZoneMember>& members);
|
||||
void SetCompass(const DynamicZoneLocation& location, bool update_db = false);
|
||||
void SetCompass(uint32_t zone_id, float x, float y, float z, bool update_db = false);
|
||||
bool SetInternalMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status);
|
||||
void SetLeader(const DynamicZoneMember& leader) { m_leader = leader; }
|
||||
void SetDuration(uint32_t seconds) { m_duration = std::chrono::seconds(seconds); }
|
||||
void SetLeader(const DynamicZoneMember& leader, bool update_db = false);
|
||||
void SetMaxPlayers(uint32_t max_players) { m_max_players = max_players; }
|
||||
void SetMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status);
|
||||
void SetMinPlayers(uint32_t min_players) { m_min_players = min_players; }
|
||||
void SetName(const std::string& name) { m_name = name; }
|
||||
void SetSafeReturn(const DynamicZoneLocation& location, bool update_db = false);
|
||||
void SetSafeReturn(uint32_t zone_id, float x, float y, float z, float heading, bool update_db = false);
|
||||
void SetType(DynamicZoneType type) { m_type = type; }
|
||||
void SetUUID(std::string uuid) { m_uuid = std::move(uuid); }
|
||||
void SetZoneInLocation(const DynamicZoneLocation& location, bool update_db = false);
|
||||
void SetZoneInLocation(float x, float y, float z, float heading, bool update_db = false);
|
||||
bool SwapMember(const DynamicZoneMember& add_member, const std::string& remove_char_name);
|
||||
|
||||
protected:
|
||||
virtual uint16_t GetCurrentInstanceID() { return 0; }
|
||||
virtual uint16_t GetCurrentZoneID() { return 0; }
|
||||
virtual Database& GetDatabase() = 0;
|
||||
virtual void ProcessCompassChange(const DynamicZoneLocation& location) { m_compass = location; }
|
||||
virtual void SendInstanceAddRemoveCharacter(uint32_t character_id, bool remove) = 0;
|
||||
virtual void SendInstanceRemoveAllCharacters() = 0;
|
||||
virtual void SendGlobalLocationChange(uint16_t server_opcode, const DynamicZoneLocation& location) = 0;
|
||||
virtual void ProcessMemberAddRemove(const DynamicZoneMember& member, bool removed);
|
||||
virtual bool ProcessMemberStatusChange(uint32_t member_id, DynamicZoneMemberStatus status);
|
||||
virtual void ProcessRemoveAllMembers(bool silent = false) { m_members.clear(); }
|
||||
virtual bool SendServerPacket(ServerPacket* packet) = 0;
|
||||
|
||||
void AddInternalMember(const DynamicZoneMember& member);
|
||||
uint32_t Create();
|
||||
uint32_t CreateInstance();
|
||||
void LoadRepositoryResult(DynamicZonesRepository::DynamicZoneInstance&& dz_entry);
|
||||
void RemoveInternalMember(uint32_t character_id);
|
||||
uint32_t SaveToDatabase();
|
||||
bool SetInternalMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status);
|
||||
|
||||
std::unique_ptr<ServerPacket> CreateServerAddRemoveCharacterPacket(uint32_t character_id, bool removed);
|
||||
std::unique_ptr<ServerPacket> CreateServerRemoveAllCharactersPacket();
|
||||
std::unique_ptr<ServerPacket> CreateServerDzCreatePacket(uint16_t origin_zone_id, uint16_t origin_instance_id);
|
||||
std::unique_ptr<ServerPacket> CreateServerDzLocationPacket(uint16_t server_opcode, const DynamicZoneLocation& location);
|
||||
std::unique_ptr<ServerPacket> CreateServerMemberAddRemovePacket(const DynamicZoneMember& member, bool removed);
|
||||
std::unique_ptr<ServerPacket> CreateServerMemberStatusPacket(uint32_t character_id, DynamicZoneMemberStatus status);
|
||||
std::unique_ptr<ServerPacket> CreateServerMemberSwapPacket(const DynamicZoneMember& remove_member, const DynamicZoneMember& add_member);
|
||||
std::unique_ptr<ServerPacket> CreateServerRemoveAllMembersPacket();
|
||||
|
||||
uint32_t m_id = 0;
|
||||
uint32_t m_zone_id = 0;
|
||||
@ -139,7 +166,9 @@ protected:
|
||||
uint32_t m_max_players = 0;
|
||||
bool m_never_expires = false;
|
||||
bool m_has_zonein = false;
|
||||
bool m_has_member_statuses = false;
|
||||
std::string m_name;
|
||||
std::string m_uuid;
|
||||
DynamicZoneMember m_leader;
|
||||
DynamicZoneType m_type{ DynamicZoneType::None };
|
||||
DynamicZoneLocation m_compass;
|
||||
@ -149,6 +178,34 @@ protected:
|
||||
std::chrono::time_point<std::chrono::system_clock> m_start_time;
|
||||
std::chrono::time_point<std::chrono::system_clock> m_expire_time;
|
||||
std::vector<DynamicZoneMember> m_members;
|
||||
|
||||
public:
|
||||
template<class Archive>
|
||||
void serialize(Archive& archive)
|
||||
{
|
||||
archive(
|
||||
m_id,
|
||||
m_zone_id,
|
||||
m_instance_id,
|
||||
m_zone_version,
|
||||
m_min_players,
|
||||
m_max_players,
|
||||
m_never_expires,
|
||||
m_has_zonein,
|
||||
m_has_member_statuses,
|
||||
m_name,
|
||||
m_uuid,
|
||||
m_leader,
|
||||
m_type,
|
||||
m_compass,
|
||||
m_safereturn,
|
||||
m_zonein,
|
||||
m_duration,
|
||||
m_start_time,
|
||||
m_expire_time,
|
||||
m_members
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -355,7 +355,6 @@ N(OP_OpenContainer),
|
||||
N(OP_OpenDiscordMerchant),
|
||||
N(OP_OpenGuildTributeMaster),
|
||||
N(OP_OpenInventory),
|
||||
N(OP_OpenNewTasksWindow),
|
||||
N(OP_OpenTributeMaster),
|
||||
N(OP_PDeletePetition),
|
||||
N(OP_PetBuffWindow),
|
||||
@ -464,6 +463,19 @@ N(OP_SetServerFilter),
|
||||
N(OP_SetStartCity),
|
||||
N(OP_SetTitle),
|
||||
N(OP_SetTitleReply),
|
||||
N(OP_SharedTaskMemberList),
|
||||
N(OP_SharedTaskAddPlayer),
|
||||
N(OP_SharedTaskRemovePlayer),
|
||||
N(OP_SharedTaskMakeLeader),
|
||||
N(OP_SharedTaskMemberInvite),
|
||||
N(OP_SharedTaskInvite),
|
||||
N(OP_SharedTaskInviteResponse),
|
||||
N(OP_SharedTaskAcceptNew),
|
||||
N(OP_SharedTaskMemberChange),
|
||||
N(OP_SharedTaskPlayerList),
|
||||
N(OP_SharedTaskSelectWindow),
|
||||
N(OP_SharedTaskQuit),
|
||||
N(OP_TaskTimers),
|
||||
N(OP_Shielding),
|
||||
N(OP_ShopDelItem),
|
||||
N(OP_ShopEnd),
|
||||
@ -499,7 +511,8 @@ N(OP_TaskActivityComplete),
|
||||
N(OP_TaskDescription),
|
||||
N(OP_TaskHistoryReply),
|
||||
N(OP_TaskHistoryRequest),
|
||||
N(OP_TaskMemberList),
|
||||
N(OP_TaskRequestTimer),
|
||||
N(OP_TaskSelectWindow),
|
||||
N(OP_Taunt),
|
||||
N(OP_TestBuff),
|
||||
N(OP_TGB),
|
||||
|
||||
@ -3714,17 +3714,66 @@ struct SetTitleReply_Struct {
|
||||
uint32 entity_id;
|
||||
};
|
||||
|
||||
struct TaskMemberList_Struct {
|
||||
/*00*/ uint32 gopher_id;
|
||||
/*04*/ uint32 unknown04;
|
||||
/*08*/ uint32 member_count; //1 less than the number of members
|
||||
/*12*/ char list_pointer[0];
|
||||
struct SharedTaskMemberList_Struct {
|
||||
/*00*/ uint32 gopher_id;
|
||||
/*04*/ uint32 unknown04;
|
||||
/*08*/ uint32 member_count; //1 less than the number of members
|
||||
///*12*/ char list_pointer[0];
|
||||
char member_name[1]; //null terminated string
|
||||
uint32 monster_mission; // class chosen
|
||||
uint8 task_leader; //boolean flag
|
||||
|
||||
/* list is of the form:
|
||||
char member_name[1] //null terminated string
|
||||
uint8 task_leader //boolean flag
|
||||
*/
|
||||
};
|
||||
|
||||
struct SharedTaskQuit_Struct {
|
||||
int32 field1;
|
||||
int32 field2;
|
||||
int32 field3;
|
||||
};
|
||||
|
||||
struct SharedTaskAddPlayer_Struct {
|
||||
int32 field1;
|
||||
int32 field2;
|
||||
char player_name[64];
|
||||
};
|
||||
|
||||
struct SharedTaskMakeLeader_Struct {
|
||||
int32 field1;
|
||||
int32 field2;
|
||||
char player_name[64];
|
||||
};
|
||||
|
||||
struct SharedTaskRemovePlayer_Struct {
|
||||
int32 field1;
|
||||
int32 field2;
|
||||
char player_name[64];
|
||||
};
|
||||
|
||||
struct SharedTaskInvite_Struct {
|
||||
int32_t unknown00; // probably the unique character id sent in some packets
|
||||
int32_t invite_id; // invite id sent back in response
|
||||
char task_name[64];
|
||||
char inviter_name[64];
|
||||
};
|
||||
|
||||
struct SharedTaskInviteResponse_Struct {
|
||||
int32_t unknown00; // 0
|
||||
int32_t invite_id; // same id sent in the invite, probably for server verification
|
||||
int8_t accepted; // 0: declined 1: accepted
|
||||
int8_t padding[3]; // padding garbage probably
|
||||
};
|
||||
|
||||
struct SharedTaskAccept_Struct {
|
||||
int32_t unknown00;
|
||||
int32_t unknown04;
|
||||
uint32_t npc_entity_id; // npc task giver entity id (sent in selection window)
|
||||
uint32_t task_id;
|
||||
float reward_multiplier; // added after titanium (sent in selection window)
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
||||
// Old struct not used by Task System implementation but left for reference
|
||||
@ -3817,7 +3866,7 @@ struct TaskHistory_Struct {
|
||||
#endif
|
||||
|
||||
struct AcceptNewTask_Struct {
|
||||
uint32 unknown00;
|
||||
uint32 task_type; // type sent in selection window
|
||||
uint32 task_id; //set to 0 for 'decline'
|
||||
uint32 task_master_id; //entity ID
|
||||
};
|
||||
|
||||
@ -235,9 +235,11 @@ void EQEmuLogSys::ProcessGMSay(
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the process that actually ran this is zone
|
||||
* Processes that actually support hooks
|
||||
*/
|
||||
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone) {
|
||||
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone ||
|
||||
EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformWorld
|
||||
) {
|
||||
on_log_gmsay_hook(log_category, message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,6 +123,7 @@ namespace Logs {
|
||||
DynamicZones,
|
||||
Scheduler,
|
||||
Cheat,
|
||||
ClientList,
|
||||
MaxCategoryID /* Don't Remove this */
|
||||
};
|
||||
|
||||
@ -203,7 +204,8 @@ namespace Logs {
|
||||
"Expeditions",
|
||||
"DynamicZones",
|
||||
"Scheduler",
|
||||
"Cheat"
|
||||
"Cheat",
|
||||
"ClientList",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -656,6 +656,16 @@
|
||||
OutF(LogSys, Logs::Detail, Logs::Cheat, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define LogClientList(message, ...) do {\
|
||||
if (LogSys.log_settings[Logs::ClientList].is_category_enabled == 1)\
|
||||
OutF(LogSys, Logs::General, Logs::ClientList, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define LogClientListDetail(message, ...) do {\
|
||||
if (LogSys.log_settings[Logs::ClientList].is_category_enabled == 1)\
|
||||
OutF(LogSys, Logs::Detail, Logs::ClientList, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define Log(debug_level, log_category, message, ...) do {\
|
||||
if (LogSys.log_settings[log_category].is_category_enabled == 1)\
|
||||
LogSys.Out(debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
@ -1028,6 +1038,18 @@
|
||||
#define LogDynamicZonesDetail(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogCheatList(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogCheatDetail(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogClientList(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogClientListDetail(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define Log(debug_level, log_category, message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
|
||||
@ -1,23 +0,0 @@
|
||||
#include "expedition_base.h"
|
||||
#include "repositories/expeditions_repository.h"
|
||||
|
||||
ExpeditionBase::ExpeditionBase(uint32_t id, const std::string& uuid,
|
||||
const std::string& expedition_name, const DynamicZoneMember& leader
|
||||
) :
|
||||
m_id(id),
|
||||
m_uuid(uuid),
|
||||
m_expedition_name(expedition_name),
|
||||
m_leader(leader)
|
||||
{
|
||||
}
|
||||
|
||||
void ExpeditionBase::LoadRepositoryResult(ExpeditionsRepository::ExpeditionWithLeader&& entry)
|
||||
{
|
||||
m_id = entry.id;
|
||||
m_uuid = std::move(entry.uuid);
|
||||
m_expedition_name = std::move(entry.expedition_name);
|
||||
m_add_replay_on_join = entry.add_replay_on_join;
|
||||
m_is_locked = entry.is_locked;
|
||||
m_leader.id = entry.leader_id;
|
||||
m_leader.name = std::move(entry.leader_name);
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
#ifndef COMMON_EXPEDITION_BASE_H
|
||||
#define COMMON_EXPEDITION_BASE_H
|
||||
|
||||
#include "dynamic_zone_base.h"
|
||||
#include "repositories/expeditions_repository.h"
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
class ExpeditionBase
|
||||
{
|
||||
public:
|
||||
virtual ~ExpeditionBase() = default;
|
||||
ExpeditionBase(const ExpeditionBase&) = default;
|
||||
ExpeditionBase(ExpeditionBase&&) = default;
|
||||
ExpeditionBase& operator=(const ExpeditionBase&) = default;
|
||||
ExpeditionBase& operator=(ExpeditionBase&&) = default;
|
||||
|
||||
uint32_t GetID() const { return m_id; }
|
||||
uint32_t GetLeaderID() const { return m_leader.id; }
|
||||
const std::string& GetName() const { return m_expedition_name; }
|
||||
const std::string& GetLeaderName() const { return m_leader.name; }
|
||||
const std::string& GetUUID() const { return m_uuid; }
|
||||
const DynamicZoneMember& GetLeader() const { return m_leader; }
|
||||
|
||||
void LoadRepositoryResult(ExpeditionsRepository::ExpeditionWithLeader&& entry);
|
||||
|
||||
protected:
|
||||
ExpeditionBase() = default;
|
||||
ExpeditionBase(uint32_t id, const std::string& uuid, const std::string& expedition_name,
|
||||
const DynamicZoneMember& leader);
|
||||
|
||||
uint32_t m_id = 0;
|
||||
bool m_is_locked = false;
|
||||
bool m_add_replay_on_join = true;
|
||||
std::string m_uuid;
|
||||
std::string m_expedition_name;
|
||||
DynamicZoneMember m_leader;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,355 @@
|
||||
/**
|
||||
* DO NOT MODIFY THIS FILE
|
||||
*
|
||||
* This repository was automatically generated and is NOT to be modified directly.
|
||||
* Any repository modifications are meant to be made to the repository extending the base.
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_BASE_CHARACTER_INSTANCE_SAFERETURNS_REPOSITORY_H
|
||||
#define EQEMU_BASE_CHARACTER_INSTANCE_SAFERETURNS_REPOSITORY_H
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
|
||||
class BaseCharacterInstanceSafereturnsRepository {
|
||||
public:
|
||||
struct CharacterInstanceSafereturns {
|
||||
int id;
|
||||
int character_id;
|
||||
int instance_zone_id;
|
||||
int instance_id;
|
||||
int safe_zone_id;
|
||||
float safe_x;
|
||||
float safe_y;
|
||||
float safe_z;
|
||||
float safe_heading;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"character_id",
|
||||
"instance_zone_id",
|
||||
"instance_id",
|
||||
"safe_zone_id",
|
||||
"safe_x",
|
||||
"safe_y",
|
||||
"safe_z",
|
||||
"safe_heading",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("character_instance_safereturns");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static CharacterInstanceSafereturns NewEntity()
|
||||
{
|
||||
CharacterInstanceSafereturns entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.character_id = 0;
|
||||
entry.instance_zone_id = 0;
|
||||
entry.instance_id = 0;
|
||||
entry.safe_zone_id = 0;
|
||||
entry.safe_x = 0;
|
||||
entry.safe_y = 0;
|
||||
entry.safe_z = 0;
|
||||
entry.safe_heading = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static CharacterInstanceSafereturns GetCharacterInstanceSafereturnsEntry(
|
||||
const std::vector<CharacterInstanceSafereturns> &character_instance_safereturnss,
|
||||
int character_instance_safereturns_id
|
||||
)
|
||||
{
|
||||
for (auto &character_instance_safereturns : character_instance_safereturnss) {
|
||||
if (character_instance_safereturns.id == character_instance_safereturns_id) {
|
||||
return character_instance_safereturns;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static CharacterInstanceSafereturns FindOne(
|
||||
Database& db,
|
||||
int character_instance_safereturns_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
character_instance_safereturns_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
CharacterInstanceSafereturns entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.character_id = atoi(row[1]);
|
||||
entry.instance_zone_id = atoi(row[2]);
|
||||
entry.instance_id = atoi(row[3]);
|
||||
entry.safe_zone_id = atoi(row[4]);
|
||||
entry.safe_x = static_cast<float>(atof(row[5]));
|
||||
entry.safe_y = static_cast<float>(atof(row[6]));
|
||||
entry.safe_z = static_cast<float>(atof(row[7]));
|
||||
entry.safe_heading = static_cast<float>(atof(row[8]));
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
Database& db,
|
||||
int character_instance_safereturns_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
character_instance_safereturns_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
CharacterInstanceSafereturns character_instance_safereturns_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(character_instance_safereturns_entry.character_id));
|
||||
update_values.push_back(columns[2] + " = " + std::to_string(character_instance_safereturns_entry.instance_zone_id));
|
||||
update_values.push_back(columns[3] + " = " + std::to_string(character_instance_safereturns_entry.instance_id));
|
||||
update_values.push_back(columns[4] + " = " + std::to_string(character_instance_safereturns_entry.safe_zone_id));
|
||||
update_values.push_back(columns[5] + " = " + std::to_string(character_instance_safereturns_entry.safe_x));
|
||||
update_values.push_back(columns[6] + " = " + std::to_string(character_instance_safereturns_entry.safe_y));
|
||||
update_values.push_back(columns[7] + " = " + std::to_string(character_instance_safereturns_entry.safe_z));
|
||||
update_values.push_back(columns[8] + " = " + std::to_string(character_instance_safereturns_entry.safe_heading));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
character_instance_safereturns_entry.id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static CharacterInstanceSafereturns InsertOne(
|
||||
Database& db,
|
||||
CharacterInstanceSafereturns character_instance_safereturns_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.id));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.character_id));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.instance_zone_id));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.instance_id));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_zone_id));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_x));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_y));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_z));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_heading));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
character_instance_safereturns_entry.id = results.LastInsertedID();
|
||||
return character_instance_safereturns_entry;
|
||||
}
|
||||
|
||||
character_instance_safereturns_entry = NewEntity();
|
||||
|
||||
return character_instance_safereturns_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<CharacterInstanceSafereturns> character_instance_safereturns_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &character_instance_safereturns_entry: character_instance_safereturns_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.id));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.character_id));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.instance_zone_id));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.instance_id));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_zone_id));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_x));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_y));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_z));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_heading));
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<CharacterInstanceSafereturns> All(Database& db)
|
||||
{
|
||||
std::vector<CharacterInstanceSafereturns> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
CharacterInstanceSafereturns entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.character_id = atoi(row[1]);
|
||||
entry.instance_zone_id = atoi(row[2]);
|
||||
entry.instance_id = atoi(row[3]);
|
||||
entry.safe_zone_id = atoi(row[4]);
|
||||
entry.safe_x = static_cast<float>(atof(row[5]));
|
||||
entry.safe_y = static_cast<float>(atof(row[6]));
|
||||
entry.safe_z = static_cast<float>(atof(row[7]));
|
||||
entry.safe_heading = static_cast<float>(atof(row[8]));
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<CharacterInstanceSafereturns> GetWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
std::vector<CharacterInstanceSafereturns> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE {}",
|
||||
BaseSelect(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
CharacterInstanceSafereturns entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.character_id = atoi(row[1]);
|
||||
entry.instance_zone_id = atoi(row[2]);
|
||||
entry.instance_id = atoi(row[3]);
|
||||
entry.safe_zone_id = atoi(row[4]);
|
||||
entry.safe_x = static_cast<float>(atof(row[5]));
|
||||
entry.safe_y = static_cast<float>(atof(row[6]));
|
||||
entry.safe_z = static_cast<float>(atof(row[7]));
|
||||
entry.safe_heading = static_cast<float>(atof(row[8]));
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static int DeleteWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {}",
|
||||
TableName(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int Truncate(Database& db)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"TRUNCATE TABLE {}",
|
||||
TableName()
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_BASE_CHARACTER_INSTANCE_SAFERETURNS_REPOSITORY_H
|
||||
336
common/repositories/base/base_character_task_timers_repository.h
Normal file
336
common/repositories/base/base_character_task_timers_repository.h
Normal file
@ -0,0 +1,336 @@
|
||||
/**
|
||||
* DO NOT MODIFY THIS FILE
|
||||
*
|
||||
* This repository was automatically generated and is NOT to be modified directly.
|
||||
* Any repository modifications are meant to be made to the repository extending the base.
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_BASE_CHARACTER_TASK_TIMERS_REPOSITORY_H
|
||||
#define EQEMU_BASE_CHARACTER_TASK_TIMERS_REPOSITORY_H
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterTaskTimersRepository {
|
||||
public:
|
||||
struct CharacterTaskTimers {
|
||||
int id;
|
||||
int character_id;
|
||||
int task_id;
|
||||
int timer_type;
|
||||
time_t expire_time;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"character_id",
|
||||
"task_id",
|
||||
"timer_type",
|
||||
"expire_time",
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"character_id",
|
||||
"task_id",
|
||||
"timer_type",
|
||||
"UNIX_TIMESTAMP(expire_time)",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string SelectColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", SelectColumns()));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("character_task_timers");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static CharacterTaskTimers NewEntity()
|
||||
{
|
||||
CharacterTaskTimers entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.character_id = 0;
|
||||
entry.task_id = 0;
|
||||
entry.timer_type = 0;
|
||||
entry.expire_time = std::time(nullptr);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static CharacterTaskTimers GetCharacterTaskTimersEntry(
|
||||
const std::vector<CharacterTaskTimers> &character_task_timerss,
|
||||
int character_task_timers_id
|
||||
)
|
||||
{
|
||||
for (auto &character_task_timers : character_task_timerss) {
|
||||
if (character_task_timers.id == character_task_timers_id) {
|
||||
return character_task_timers;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static CharacterTaskTimers FindOne(
|
||||
Database& db,
|
||||
int character_task_timers_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
character_task_timers_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
CharacterTaskTimers entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.character_id = atoi(row[1]);
|
||||
entry.task_id = atoi(row[2]);
|
||||
entry.timer_type = atoi(row[3]);
|
||||
entry.expire_time = strtoll(row[4], nullptr, 10);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
Database& db,
|
||||
int character_task_timers_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
character_task_timers_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
CharacterTaskTimers character_task_timers_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(character_task_timers_entry.character_id));
|
||||
update_values.push_back(columns[2] + " = " + std::to_string(character_task_timers_entry.task_id));
|
||||
update_values.push_back(columns[3] + " = " + std::to_string(character_task_timers_entry.timer_type));
|
||||
update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + std::to_string(character_task_timers_entry.expire_time) + ")");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
character_task_timers_entry.id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static CharacterTaskTimers InsertOne(
|
||||
Database& db,
|
||||
CharacterTaskTimers character_task_timers_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(character_task_timers_entry.id));
|
||||
insert_values.push_back(std::to_string(character_task_timers_entry.character_id));
|
||||
insert_values.push_back(std::to_string(character_task_timers_entry.task_id));
|
||||
insert_values.push_back(std::to_string(character_task_timers_entry.timer_type));
|
||||
insert_values.push_back("FROM_UNIXTIME(" + std::to_string(character_task_timers_entry.expire_time) + ")");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
character_task_timers_entry.id = results.LastInsertedID();
|
||||
return character_task_timers_entry;
|
||||
}
|
||||
|
||||
character_task_timers_entry = NewEntity();
|
||||
|
||||
return character_task_timers_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<CharacterTaskTimers> character_task_timers_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &character_task_timers_entry: character_task_timers_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(character_task_timers_entry.id));
|
||||
insert_values.push_back(std::to_string(character_task_timers_entry.character_id));
|
||||
insert_values.push_back(std::to_string(character_task_timers_entry.task_id));
|
||||
insert_values.push_back(std::to_string(character_task_timers_entry.timer_type));
|
||||
insert_values.push_back("FROM_UNIXTIME(" + std::to_string(character_task_timers_entry.expire_time) + ")");
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<CharacterTaskTimers> All(Database& db)
|
||||
{
|
||||
std::vector<CharacterTaskTimers> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
CharacterTaskTimers entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.character_id = atoi(row[1]);
|
||||
entry.task_id = atoi(row[2]);
|
||||
entry.timer_type = atoi(row[3]);
|
||||
entry.expire_time = strtoll(row[4], nullptr, 10);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<CharacterTaskTimers> GetWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
std::vector<CharacterTaskTimers> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE {}",
|
||||
BaseSelect(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
CharacterTaskTimers entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.character_id = atoi(row[1]);
|
||||
entry.task_id = atoi(row[2]);
|
||||
entry.timer_type = atoi(row[3]);
|
||||
entry.expire_time = strtoll(row[4], nullptr, 10);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static int DeleteWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {}",
|
||||
TableName(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int Truncate(Database& db)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"TRUNCATE TABLE {}",
|
||||
TableName()
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_BASE_CHARACTER_TASK_TIMERS_REPOSITORY_H
|
||||
@ -0,0 +1,337 @@
|
||||
/**
|
||||
* DO NOT MODIFY THIS FILE
|
||||
*
|
||||
* This repository was automatically generated and is NOT to be modified directly.
|
||||
* Any repository modifications are meant to be made to the repository extending the base.
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_BASE_COMPLETED_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H
|
||||
#define EQEMU_BASE_COMPLETED_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCompletedSharedTaskActivityStateRepository {
|
||||
public:
|
||||
struct CompletedSharedTaskActivityState {
|
||||
int64 shared_task_id;
|
||||
int activity_id;
|
||||
int done_count;
|
||||
time_t updated_time;
|
||||
time_t completed_time;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("shared_task_id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"shared_task_id",
|
||||
"activity_id",
|
||||
"done_count",
|
||||
"updated_time",
|
||||
"completed_time",
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"shared_task_id",
|
||||
"activity_id",
|
||||
"done_count",
|
||||
"UNIX_TIMESTAMP(updated_time)",
|
||||
"UNIX_TIMESTAMP(completed_time)",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string SelectColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", SelectColumns()));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("completed_shared_task_activity_state");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static CompletedSharedTaskActivityState NewEntity()
|
||||
{
|
||||
CompletedSharedTaskActivityState entry{};
|
||||
|
||||
entry.shared_task_id = 0;
|
||||
entry.activity_id = 0;
|
||||
entry.done_count = 0;
|
||||
entry.updated_time = 0;
|
||||
entry.completed_time = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static CompletedSharedTaskActivityState GetCompletedSharedTaskActivityStateEntry(
|
||||
const std::vector<CompletedSharedTaskActivityState> &completed_shared_task_activity_states,
|
||||
int completed_shared_task_activity_state_id
|
||||
)
|
||||
{
|
||||
for (auto &completed_shared_task_activity_state : completed_shared_task_activity_states) {
|
||||
if (completed_shared_task_activity_state.shared_task_id == completed_shared_task_activity_state_id) {
|
||||
return completed_shared_task_activity_state;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static CompletedSharedTaskActivityState FindOne(
|
||||
Database& db,
|
||||
int completed_shared_task_activity_state_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
completed_shared_task_activity_state_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
CompletedSharedTaskActivityState entry{};
|
||||
|
||||
entry.shared_task_id = strtoll(row[0], nullptr, 10);
|
||||
entry.activity_id = atoi(row[1]);
|
||||
entry.done_count = atoi(row[2]);
|
||||
entry.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
|
||||
entry.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
Database& db,
|
||||
int completed_shared_task_activity_state_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
completed_shared_task_activity_state_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
CompletedSharedTaskActivityState completed_shared_task_activity_state_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[0] + " = " + std::to_string(completed_shared_task_activity_state_entry.shared_task_id));
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(completed_shared_task_activity_state_entry.activity_id));
|
||||
update_values.push_back(columns[2] + " = " + std::to_string(completed_shared_task_activity_state_entry.done_count));
|
||||
update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.updated_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.updated_time) : "null") + ")");
|
||||
update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.completed_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.completed_time) : "null") + ")");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
completed_shared_task_activity_state_entry.shared_task_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static CompletedSharedTaskActivityState InsertOne(
|
||||
Database& db,
|
||||
CompletedSharedTaskActivityState completed_shared_task_activity_state_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.shared_task_id));
|
||||
insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.activity_id));
|
||||
insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.done_count));
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.updated_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.updated_time) : "null") + ")");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.completed_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.completed_time) : "null") + ")");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
completed_shared_task_activity_state_entry.shared_task_id = results.LastInsertedID();
|
||||
return completed_shared_task_activity_state_entry;
|
||||
}
|
||||
|
||||
completed_shared_task_activity_state_entry = NewEntity();
|
||||
|
||||
return completed_shared_task_activity_state_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<CompletedSharedTaskActivityState> completed_shared_task_activity_state_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &completed_shared_task_activity_state_entry: completed_shared_task_activity_state_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.shared_task_id));
|
||||
insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.activity_id));
|
||||
insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.done_count));
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.updated_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.updated_time) : "null") + ")");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.completed_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.completed_time) : "null") + ")");
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<CompletedSharedTaskActivityState> All(Database& db)
|
||||
{
|
||||
std::vector<CompletedSharedTaskActivityState> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
CompletedSharedTaskActivityState entry{};
|
||||
|
||||
entry.shared_task_id = strtoll(row[0], nullptr, 10);
|
||||
entry.activity_id = atoi(row[1]);
|
||||
entry.done_count = atoi(row[2]);
|
||||
entry.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
|
||||
entry.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<CompletedSharedTaskActivityState> GetWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
std::vector<CompletedSharedTaskActivityState> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE {}",
|
||||
BaseSelect(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
CompletedSharedTaskActivityState entry{};
|
||||
|
||||
entry.shared_task_id = strtoll(row[0], nullptr, 10);
|
||||
entry.activity_id = atoi(row[1]);
|
||||
entry.done_count = atoi(row[2]);
|
||||
entry.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
|
||||
entry.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static int DeleteWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {}",
|
||||
TableName(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int Truncate(Database& db)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"TRUNCATE TABLE {}",
|
||||
TableName()
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_BASE_COMPLETED_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H
|
||||
@ -0,0 +1,317 @@
|
||||
/**
|
||||
* DO NOT MODIFY THIS FILE
|
||||
*
|
||||
* This repository was automatically generated and is NOT to be modified directly.
|
||||
* Any repository modifications are meant to be made to the repository extending the base.
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_BASE_COMPLETED_SHARED_TASK_MEMBERS_REPOSITORY_H
|
||||
#define EQEMU_BASE_COMPLETED_SHARED_TASK_MEMBERS_REPOSITORY_H
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCompletedSharedTaskMembersRepository {
|
||||
public:
|
||||
struct CompletedSharedTaskMembers {
|
||||
int64 shared_task_id;
|
||||
int64 character_id;
|
||||
int is_leader;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("shared_task_id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"shared_task_id",
|
||||
"character_id",
|
||||
"is_leader",
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"shared_task_id",
|
||||
"character_id",
|
||||
"is_leader",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string SelectColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", SelectColumns()));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("completed_shared_task_members");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static CompletedSharedTaskMembers NewEntity()
|
||||
{
|
||||
CompletedSharedTaskMembers entry{};
|
||||
|
||||
entry.shared_task_id = 0;
|
||||
entry.character_id = 0;
|
||||
entry.is_leader = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static CompletedSharedTaskMembers GetCompletedSharedTaskMembersEntry(
|
||||
const std::vector<CompletedSharedTaskMembers> &completed_shared_task_memberss,
|
||||
int completed_shared_task_members_id
|
||||
)
|
||||
{
|
||||
for (auto &completed_shared_task_members : completed_shared_task_memberss) {
|
||||
if (completed_shared_task_members.shared_task_id == completed_shared_task_members_id) {
|
||||
return completed_shared_task_members;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static CompletedSharedTaskMembers FindOne(
|
||||
Database& db,
|
||||
int completed_shared_task_members_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
completed_shared_task_members_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
CompletedSharedTaskMembers entry{};
|
||||
|
||||
entry.shared_task_id = strtoll(row[0], nullptr, 10);
|
||||
entry.character_id = strtoll(row[1], nullptr, 10);
|
||||
entry.is_leader = atoi(row[2]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
Database& db,
|
||||
int completed_shared_task_members_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
completed_shared_task_members_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
CompletedSharedTaskMembers completed_shared_task_members_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[0] + " = " + std::to_string(completed_shared_task_members_entry.shared_task_id));
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(completed_shared_task_members_entry.character_id));
|
||||
update_values.push_back(columns[2] + " = " + std::to_string(completed_shared_task_members_entry.is_leader));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
completed_shared_task_members_entry.shared_task_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static CompletedSharedTaskMembers InsertOne(
|
||||
Database& db,
|
||||
CompletedSharedTaskMembers completed_shared_task_members_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(completed_shared_task_members_entry.shared_task_id));
|
||||
insert_values.push_back(std::to_string(completed_shared_task_members_entry.character_id));
|
||||
insert_values.push_back(std::to_string(completed_shared_task_members_entry.is_leader));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
completed_shared_task_members_entry.shared_task_id = results.LastInsertedID();
|
||||
return completed_shared_task_members_entry;
|
||||
}
|
||||
|
||||
completed_shared_task_members_entry = NewEntity();
|
||||
|
||||
return completed_shared_task_members_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<CompletedSharedTaskMembers> completed_shared_task_members_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &completed_shared_task_members_entry: completed_shared_task_members_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(completed_shared_task_members_entry.shared_task_id));
|
||||
insert_values.push_back(std::to_string(completed_shared_task_members_entry.character_id));
|
||||
insert_values.push_back(std::to_string(completed_shared_task_members_entry.is_leader));
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<CompletedSharedTaskMembers> All(Database& db)
|
||||
{
|
||||
std::vector<CompletedSharedTaskMembers> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
CompletedSharedTaskMembers entry{};
|
||||
|
||||
entry.shared_task_id = strtoll(row[0], nullptr, 10);
|
||||
entry.character_id = strtoll(row[1], nullptr, 10);
|
||||
entry.is_leader = atoi(row[2]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<CompletedSharedTaskMembers> GetWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
std::vector<CompletedSharedTaskMembers> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE {}",
|
||||
BaseSelect(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
CompletedSharedTaskMembers entry{};
|
||||
|
||||
entry.shared_task_id = strtoll(row[0], nullptr, 10);
|
||||
entry.character_id = strtoll(row[1], nullptr, 10);
|
||||
entry.is_leader = atoi(row[2]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static int DeleteWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {}",
|
||||
TableName(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int Truncate(Database& db)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"TRUNCATE TABLE {}",
|
||||
TableName()
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_BASE_COMPLETED_SHARED_TASK_MEMBERS_REPOSITORY_H
|
||||
@ -0,0 +1,347 @@
|
||||
/**
|
||||
* DO NOT MODIFY THIS FILE
|
||||
*
|
||||
* This repository was automatically generated and is NOT to be modified directly.
|
||||
* Any repository modifications are meant to be made to the repository extending the base.
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_BASE_COMPLETED_SHARED_TASKS_REPOSITORY_H
|
||||
#define EQEMU_BASE_COMPLETED_SHARED_TASKS_REPOSITORY_H
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCompletedSharedTasksRepository {
|
||||
public:
|
||||
struct CompletedSharedTasks {
|
||||
int64 id;
|
||||
int task_id;
|
||||
time_t accepted_time;
|
||||
time_t expire_time;
|
||||
time_t completion_time;
|
||||
int is_locked;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"task_id",
|
||||
"accepted_time",
|
||||
"expire_time",
|
||||
"completion_time",
|
||||
"is_locked",
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"task_id",
|
||||
"UNIX_TIMESTAMP(accepted_time)",
|
||||
"UNIX_TIMESTAMP(expire_time)",
|
||||
"UNIX_TIMESTAMP(completion_time)",
|
||||
"is_locked",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string SelectColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", SelectColumns()));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("completed_shared_tasks");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static CompletedSharedTasks NewEntity()
|
||||
{
|
||||
CompletedSharedTasks entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.task_id = 0;
|
||||
entry.accepted_time = 0;
|
||||
entry.expire_time = 0;
|
||||
entry.completion_time = 0;
|
||||
entry.is_locked = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static CompletedSharedTasks GetCompletedSharedTasksEntry(
|
||||
const std::vector<CompletedSharedTasks> &completed_shared_taskss,
|
||||
int completed_shared_tasks_id
|
||||
)
|
||||
{
|
||||
for (auto &completed_shared_tasks : completed_shared_taskss) {
|
||||
if (completed_shared_tasks.id == completed_shared_tasks_id) {
|
||||
return completed_shared_tasks;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static CompletedSharedTasks FindOne(
|
||||
Database& db,
|
||||
int completed_shared_tasks_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
completed_shared_tasks_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
CompletedSharedTasks entry{};
|
||||
|
||||
entry.id = strtoll(row[0], nullptr, 10);
|
||||
entry.task_id = atoi(row[1]);
|
||||
entry.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10);
|
||||
entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
|
||||
entry.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
entry.is_locked = atoi(row[5]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
Database& db,
|
||||
int completed_shared_tasks_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
completed_shared_tasks_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
CompletedSharedTasks completed_shared_tasks_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[0] + " = " + std::to_string(completed_shared_tasks_entry.id));
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(completed_shared_tasks_entry.task_id));
|
||||
update_values.push_back(columns[2] + " = FROM_UNIXTIME(" + (completed_shared_tasks_entry.accepted_time > 0 ? std::to_string(completed_shared_tasks_entry.accepted_time) : "null") + ")");
|
||||
update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (completed_shared_tasks_entry.expire_time > 0 ? std::to_string(completed_shared_tasks_entry.expire_time) : "null") + ")");
|
||||
update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (completed_shared_tasks_entry.completion_time > 0 ? std::to_string(completed_shared_tasks_entry.completion_time) : "null") + ")");
|
||||
update_values.push_back(columns[5] + " = " + std::to_string(completed_shared_tasks_entry.is_locked));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
completed_shared_tasks_entry.id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static CompletedSharedTasks InsertOne(
|
||||
Database& db,
|
||||
CompletedSharedTasks completed_shared_tasks_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(completed_shared_tasks_entry.id));
|
||||
insert_values.push_back(std::to_string(completed_shared_tasks_entry.task_id));
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.accepted_time > 0 ? std::to_string(completed_shared_tasks_entry.accepted_time) : "null") + ")");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.expire_time > 0 ? std::to_string(completed_shared_tasks_entry.expire_time) : "null") + ")");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.completion_time > 0 ? std::to_string(completed_shared_tasks_entry.completion_time) : "null") + ")");
|
||||
insert_values.push_back(std::to_string(completed_shared_tasks_entry.is_locked));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
completed_shared_tasks_entry.id = results.LastInsertedID();
|
||||
return completed_shared_tasks_entry;
|
||||
}
|
||||
|
||||
completed_shared_tasks_entry = NewEntity();
|
||||
|
||||
return completed_shared_tasks_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<CompletedSharedTasks> completed_shared_tasks_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &completed_shared_tasks_entry: completed_shared_tasks_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(completed_shared_tasks_entry.id));
|
||||
insert_values.push_back(std::to_string(completed_shared_tasks_entry.task_id));
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.accepted_time > 0 ? std::to_string(completed_shared_tasks_entry.accepted_time) : "null") + ")");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.expire_time > 0 ? std::to_string(completed_shared_tasks_entry.expire_time) : "null") + ")");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.completion_time > 0 ? std::to_string(completed_shared_tasks_entry.completion_time) : "null") + ")");
|
||||
insert_values.push_back(std::to_string(completed_shared_tasks_entry.is_locked));
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<CompletedSharedTasks> All(Database& db)
|
||||
{
|
||||
std::vector<CompletedSharedTasks> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
CompletedSharedTasks entry{};
|
||||
|
||||
entry.id = strtoll(row[0], nullptr, 10);
|
||||
entry.task_id = atoi(row[1]);
|
||||
entry.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10);
|
||||
entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
|
||||
entry.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
entry.is_locked = atoi(row[5]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<CompletedSharedTasks> GetWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
std::vector<CompletedSharedTasks> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE {}",
|
||||
BaseSelect(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
CompletedSharedTasks entry{};
|
||||
|
||||
entry.id = strtoll(row[0], nullptr, 10);
|
||||
entry.task_id = atoi(row[1]);
|
||||
entry.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10);
|
||||
entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
|
||||
entry.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
entry.is_locked = atoi(row[5]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static int DeleteWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {}",
|
||||
TableName(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int Truncate(Database& db)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"TRUNCATE TABLE {}",
|
||||
TableName()
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_BASE_COMPLETED_SHARED_TASKS_REPOSITORY_H
|
||||
@ -21,7 +21,6 @@ public:
|
||||
int id;
|
||||
int dynamic_zone_id;
|
||||
int character_id;
|
||||
int is_current_member;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
@ -35,7 +34,6 @@ public:
|
||||
"id",
|
||||
"dynamic_zone_id",
|
||||
"character_id",
|
||||
"is_current_member",
|
||||
};
|
||||
}
|
||||
|
||||
@ -71,10 +69,9 @@ public:
|
||||
{
|
||||
DynamicZoneMembers entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.dynamic_zone_id = 0;
|
||||
entry.character_id = 0;
|
||||
entry.is_current_member = 1;
|
||||
entry.id = 0;
|
||||
entry.dynamic_zone_id = 0;
|
||||
entry.character_id = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
@ -110,10 +107,9 @@ public:
|
||||
if (results.RowCount() == 1) {
|
||||
DynamicZoneMembers entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.dynamic_zone_id = atoi(row[1]);
|
||||
entry.character_id = atoi(row[2]);
|
||||
entry.is_current_member = atoi(row[3]);
|
||||
entry.id = atoi(row[0]);
|
||||
entry.dynamic_zone_id = atoi(row[1]);
|
||||
entry.character_id = atoi(row[2]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
@ -149,7 +145,6 @@ public:
|
||||
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(dynamic_zone_members_entry.dynamic_zone_id));
|
||||
update_values.push_back(columns[2] + " = " + std::to_string(dynamic_zone_members_entry.character_id));
|
||||
update_values.push_back(columns[3] + " = " + std::to_string(dynamic_zone_members_entry.is_current_member));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@ -174,7 +169,6 @@ public:
|
||||
insert_values.push_back(std::to_string(dynamic_zone_members_entry.id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_members_entry.dynamic_zone_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_members_entry.character_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_members_entry.is_current_member));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@ -207,7 +201,6 @@ public:
|
||||
insert_values.push_back(std::to_string(dynamic_zone_members_entry.id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_members_entry.dynamic_zone_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_members_entry.character_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_members_entry.is_current_member));
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
@ -241,10 +234,9 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
DynamicZoneMembers entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.dynamic_zone_id = atoi(row[1]);
|
||||
entry.character_id = atoi(row[2]);
|
||||
entry.is_current_member = atoi(row[3]);
|
||||
entry.id = atoi(row[0]);
|
||||
entry.dynamic_zone_id = atoi(row[1]);
|
||||
entry.character_id = atoi(row[2]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
@ -269,10 +261,9 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
DynamicZoneMembers entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.dynamic_zone_id = atoi(row[1]);
|
||||
entry.character_id = atoi(row[2]);
|
||||
entry.is_current_member = atoi(row[3]);
|
||||
entry.id = atoi(row[0]);
|
||||
entry.dynamic_zone_id = atoi(row[1]);
|
||||
entry.character_id = atoi(row[2]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
@ -18,23 +18,28 @@
|
||||
class BaseDynamicZonesRepository {
|
||||
public:
|
||||
struct DynamicZones {
|
||||
int id;
|
||||
int instance_id;
|
||||
int type;
|
||||
int compass_zone_id;
|
||||
float compass_x;
|
||||
float compass_y;
|
||||
float compass_z;
|
||||
int safe_return_zone_id;
|
||||
float safe_return_x;
|
||||
float safe_return_y;
|
||||
float safe_return_z;
|
||||
float safe_return_heading;
|
||||
float zone_in_x;
|
||||
float zone_in_y;
|
||||
float zone_in_z;
|
||||
float zone_in_heading;
|
||||
int has_zone_in;
|
||||
int id;
|
||||
int instance_id;
|
||||
int type;
|
||||
std::string uuid;
|
||||
std::string name;
|
||||
int leader_id;
|
||||
int min_players;
|
||||
int max_players;
|
||||
int compass_zone_id;
|
||||
float compass_x;
|
||||
float compass_y;
|
||||
float compass_z;
|
||||
int safe_return_zone_id;
|
||||
float safe_return_x;
|
||||
float safe_return_y;
|
||||
float safe_return_z;
|
||||
float safe_return_heading;
|
||||
float zone_in_x;
|
||||
float zone_in_y;
|
||||
float zone_in_z;
|
||||
float zone_in_heading;
|
||||
int has_zone_in;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
@ -48,6 +53,11 @@ public:
|
||||
"id",
|
||||
"instance_id",
|
||||
"type",
|
||||
"uuid",
|
||||
"name",
|
||||
"leader_id",
|
||||
"min_players",
|
||||
"max_players",
|
||||
"compass_zone_id",
|
||||
"compass_x",
|
||||
"compass_y",
|
||||
@ -100,6 +110,11 @@ public:
|
||||
entry.id = 0;
|
||||
entry.instance_id = 0;
|
||||
entry.type = 0;
|
||||
entry.uuid = "";
|
||||
entry.name = "";
|
||||
entry.leader_id = 0;
|
||||
entry.min_players = 0;
|
||||
entry.max_players = 0;
|
||||
entry.compass_zone_id = 0;
|
||||
entry.compass_x = 0;
|
||||
entry.compass_y = 0;
|
||||
@ -152,20 +167,25 @@ public:
|
||||
entry.id = atoi(row[0]);
|
||||
entry.instance_id = atoi(row[1]);
|
||||
entry.type = atoi(row[2]);
|
||||
entry.compass_zone_id = atoi(row[3]);
|
||||
entry.compass_x = static_cast<float>(atof(row[4]));
|
||||
entry.compass_y = static_cast<float>(atof(row[5]));
|
||||
entry.compass_z = static_cast<float>(atof(row[6]));
|
||||
entry.safe_return_zone_id = atoi(row[7]);
|
||||
entry.safe_return_x = static_cast<float>(atof(row[8]));
|
||||
entry.safe_return_y = static_cast<float>(atof(row[9]));
|
||||
entry.safe_return_z = static_cast<float>(atof(row[10]));
|
||||
entry.safe_return_heading = static_cast<float>(atof(row[11]));
|
||||
entry.zone_in_x = static_cast<float>(atof(row[12]));
|
||||
entry.zone_in_y = static_cast<float>(atof(row[13]));
|
||||
entry.zone_in_z = static_cast<float>(atof(row[14]));
|
||||
entry.zone_in_heading = static_cast<float>(atof(row[15]));
|
||||
entry.has_zone_in = atoi(row[16]);
|
||||
entry.uuid = row[3] ? row[3] : "";
|
||||
entry.name = row[4] ? row[4] : "";
|
||||
entry.leader_id = atoi(row[5]);
|
||||
entry.min_players = atoi(row[6]);
|
||||
entry.max_players = atoi(row[7]);
|
||||
entry.compass_zone_id = atoi(row[8]);
|
||||
entry.compass_x = static_cast<float>(atof(row[9]));
|
||||
entry.compass_y = static_cast<float>(atof(row[10]));
|
||||
entry.compass_z = static_cast<float>(atof(row[11]));
|
||||
entry.safe_return_zone_id = atoi(row[12]);
|
||||
entry.safe_return_x = static_cast<float>(atof(row[13]));
|
||||
entry.safe_return_y = static_cast<float>(atof(row[14]));
|
||||
entry.safe_return_z = static_cast<float>(atof(row[15]));
|
||||
entry.safe_return_heading = static_cast<float>(atof(row[16]));
|
||||
entry.zone_in_x = static_cast<float>(atof(row[17]));
|
||||
entry.zone_in_y = static_cast<float>(atof(row[18]));
|
||||
entry.zone_in_z = static_cast<float>(atof(row[19]));
|
||||
entry.zone_in_heading = static_cast<float>(atof(row[20]));
|
||||
entry.has_zone_in = atoi(row[21]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
@ -201,20 +221,25 @@ public:
|
||||
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(dynamic_zones_entry.instance_id));
|
||||
update_values.push_back(columns[2] + " = " + std::to_string(dynamic_zones_entry.type));
|
||||
update_values.push_back(columns[3] + " = " + std::to_string(dynamic_zones_entry.compass_zone_id));
|
||||
update_values.push_back(columns[4] + " = " + std::to_string(dynamic_zones_entry.compass_x));
|
||||
update_values.push_back(columns[5] + " = " + std::to_string(dynamic_zones_entry.compass_y));
|
||||
update_values.push_back(columns[6] + " = " + std::to_string(dynamic_zones_entry.compass_z));
|
||||
update_values.push_back(columns[7] + " = " + std::to_string(dynamic_zones_entry.safe_return_zone_id));
|
||||
update_values.push_back(columns[8] + " = " + std::to_string(dynamic_zones_entry.safe_return_x));
|
||||
update_values.push_back(columns[9] + " = " + std::to_string(dynamic_zones_entry.safe_return_y));
|
||||
update_values.push_back(columns[10] + " = " + std::to_string(dynamic_zones_entry.safe_return_z));
|
||||
update_values.push_back(columns[11] + " = " + std::to_string(dynamic_zones_entry.safe_return_heading));
|
||||
update_values.push_back(columns[12] + " = " + std::to_string(dynamic_zones_entry.zone_in_x));
|
||||
update_values.push_back(columns[13] + " = " + std::to_string(dynamic_zones_entry.zone_in_y));
|
||||
update_values.push_back(columns[14] + " = " + std::to_string(dynamic_zones_entry.zone_in_z));
|
||||
update_values.push_back(columns[15] + " = " + std::to_string(dynamic_zones_entry.zone_in_heading));
|
||||
update_values.push_back(columns[16] + " = " + std::to_string(dynamic_zones_entry.has_zone_in));
|
||||
update_values.push_back(columns[3] + " = '" + EscapeString(dynamic_zones_entry.uuid) + "'");
|
||||
update_values.push_back(columns[4] + " = '" + EscapeString(dynamic_zones_entry.name) + "'");
|
||||
update_values.push_back(columns[5] + " = " + std::to_string(dynamic_zones_entry.leader_id));
|
||||
update_values.push_back(columns[6] + " = " + std::to_string(dynamic_zones_entry.min_players));
|
||||
update_values.push_back(columns[7] + " = " + std::to_string(dynamic_zones_entry.max_players));
|
||||
update_values.push_back(columns[8] + " = " + std::to_string(dynamic_zones_entry.compass_zone_id));
|
||||
update_values.push_back(columns[9] + " = " + std::to_string(dynamic_zones_entry.compass_x));
|
||||
update_values.push_back(columns[10] + " = " + std::to_string(dynamic_zones_entry.compass_y));
|
||||
update_values.push_back(columns[11] + " = " + std::to_string(dynamic_zones_entry.compass_z));
|
||||
update_values.push_back(columns[12] + " = " + std::to_string(dynamic_zones_entry.safe_return_zone_id));
|
||||
update_values.push_back(columns[13] + " = " + std::to_string(dynamic_zones_entry.safe_return_x));
|
||||
update_values.push_back(columns[14] + " = " + std::to_string(dynamic_zones_entry.safe_return_y));
|
||||
update_values.push_back(columns[15] + " = " + std::to_string(dynamic_zones_entry.safe_return_z));
|
||||
update_values.push_back(columns[16] + " = " + std::to_string(dynamic_zones_entry.safe_return_heading));
|
||||
update_values.push_back(columns[17] + " = " + std::to_string(dynamic_zones_entry.zone_in_x));
|
||||
update_values.push_back(columns[18] + " = " + std::to_string(dynamic_zones_entry.zone_in_y));
|
||||
update_values.push_back(columns[19] + " = " + std::to_string(dynamic_zones_entry.zone_in_z));
|
||||
update_values.push_back(columns[20] + " = " + std::to_string(dynamic_zones_entry.zone_in_heading));
|
||||
update_values.push_back(columns[21] + " = " + std::to_string(dynamic_zones_entry.has_zone_in));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@ -239,6 +264,11 @@ public:
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.id));
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.instance_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.type));
|
||||
insert_values.push_back("'" + EscapeString(dynamic_zones_entry.uuid) + "'");
|
||||
insert_values.push_back("'" + EscapeString(dynamic_zones_entry.name) + "'");
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.leader_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.min_players));
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.max_players));
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.compass_zone_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.compass_x));
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.compass_y));
|
||||
@ -285,6 +315,11 @@ public:
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.id));
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.instance_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.type));
|
||||
insert_values.push_back("'" + EscapeString(dynamic_zones_entry.uuid) + "'");
|
||||
insert_values.push_back("'" + EscapeString(dynamic_zones_entry.name) + "'");
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.leader_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.min_players));
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.max_players));
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.compass_zone_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.compass_x));
|
||||
insert_values.push_back(std::to_string(dynamic_zones_entry.compass_y));
|
||||
@ -335,20 +370,25 @@ public:
|
||||
entry.id = atoi(row[0]);
|
||||
entry.instance_id = atoi(row[1]);
|
||||
entry.type = atoi(row[2]);
|
||||
entry.compass_zone_id = atoi(row[3]);
|
||||
entry.compass_x = static_cast<float>(atof(row[4]));
|
||||
entry.compass_y = static_cast<float>(atof(row[5]));
|
||||
entry.compass_z = static_cast<float>(atof(row[6]));
|
||||
entry.safe_return_zone_id = atoi(row[7]);
|
||||
entry.safe_return_x = static_cast<float>(atof(row[8]));
|
||||
entry.safe_return_y = static_cast<float>(atof(row[9]));
|
||||
entry.safe_return_z = static_cast<float>(atof(row[10]));
|
||||
entry.safe_return_heading = static_cast<float>(atof(row[11]));
|
||||
entry.zone_in_x = static_cast<float>(atof(row[12]));
|
||||
entry.zone_in_y = static_cast<float>(atof(row[13]));
|
||||
entry.zone_in_z = static_cast<float>(atof(row[14]));
|
||||
entry.zone_in_heading = static_cast<float>(atof(row[15]));
|
||||
entry.has_zone_in = atoi(row[16]);
|
||||
entry.uuid = row[3] ? row[3] : "";
|
||||
entry.name = row[4] ? row[4] : "";
|
||||
entry.leader_id = atoi(row[5]);
|
||||
entry.min_players = atoi(row[6]);
|
||||
entry.max_players = atoi(row[7]);
|
||||
entry.compass_zone_id = atoi(row[8]);
|
||||
entry.compass_x = static_cast<float>(atof(row[9]));
|
||||
entry.compass_y = static_cast<float>(atof(row[10]));
|
||||
entry.compass_z = static_cast<float>(atof(row[11]));
|
||||
entry.safe_return_zone_id = atoi(row[12]);
|
||||
entry.safe_return_x = static_cast<float>(atof(row[13]));
|
||||
entry.safe_return_y = static_cast<float>(atof(row[14]));
|
||||
entry.safe_return_z = static_cast<float>(atof(row[15]));
|
||||
entry.safe_return_heading = static_cast<float>(atof(row[16]));
|
||||
entry.zone_in_x = static_cast<float>(atof(row[17]));
|
||||
entry.zone_in_y = static_cast<float>(atof(row[18]));
|
||||
entry.zone_in_z = static_cast<float>(atof(row[19]));
|
||||
entry.zone_in_heading = static_cast<float>(atof(row[20]));
|
||||
entry.has_zone_in = atoi(row[21]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
@ -376,20 +416,25 @@ public:
|
||||
entry.id = atoi(row[0]);
|
||||
entry.instance_id = atoi(row[1]);
|
||||
entry.type = atoi(row[2]);
|
||||
entry.compass_zone_id = atoi(row[3]);
|
||||
entry.compass_x = static_cast<float>(atof(row[4]));
|
||||
entry.compass_y = static_cast<float>(atof(row[5]));
|
||||
entry.compass_z = static_cast<float>(atof(row[6]));
|
||||
entry.safe_return_zone_id = atoi(row[7]);
|
||||
entry.safe_return_x = static_cast<float>(atof(row[8]));
|
||||
entry.safe_return_y = static_cast<float>(atof(row[9]));
|
||||
entry.safe_return_z = static_cast<float>(atof(row[10]));
|
||||
entry.safe_return_heading = static_cast<float>(atof(row[11]));
|
||||
entry.zone_in_x = static_cast<float>(atof(row[12]));
|
||||
entry.zone_in_y = static_cast<float>(atof(row[13]));
|
||||
entry.zone_in_z = static_cast<float>(atof(row[14]));
|
||||
entry.zone_in_heading = static_cast<float>(atof(row[15]));
|
||||
entry.has_zone_in = atoi(row[16]);
|
||||
entry.uuid = row[3] ? row[3] : "";
|
||||
entry.name = row[4] ? row[4] : "";
|
||||
entry.leader_id = atoi(row[5]);
|
||||
entry.min_players = atoi(row[6]);
|
||||
entry.max_players = atoi(row[7]);
|
||||
entry.compass_zone_id = atoi(row[8]);
|
||||
entry.compass_x = static_cast<float>(atof(row[9]));
|
||||
entry.compass_y = static_cast<float>(atof(row[10]));
|
||||
entry.compass_z = static_cast<float>(atof(row[11]));
|
||||
entry.safe_return_zone_id = atoi(row[12]);
|
||||
entry.safe_return_x = static_cast<float>(atof(row[13]));
|
||||
entry.safe_return_y = static_cast<float>(atof(row[14]));
|
||||
entry.safe_return_z = static_cast<float>(atof(row[15]));
|
||||
entry.safe_return_heading = static_cast<float>(atof(row[16]));
|
||||
entry.zone_in_x = static_cast<float>(atof(row[17]));
|
||||
entry.zone_in_y = static_cast<float>(atof(row[18]));
|
||||
entry.zone_in_z = static_cast<float>(atof(row[19]));
|
||||
entry.zone_in_heading = static_cast<float>(atof(row[20]));
|
||||
entry.has_zone_in = atoi(row[21]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
@ -18,15 +18,10 @@
|
||||
class BaseExpeditionsRepository {
|
||||
public:
|
||||
struct Expeditions {
|
||||
int id;
|
||||
std::string uuid;
|
||||
int dynamic_zone_id;
|
||||
std::string expedition_name;
|
||||
int leader_id;
|
||||
int min_players;
|
||||
int max_players;
|
||||
int add_replay_on_join;
|
||||
int is_locked;
|
||||
int id;
|
||||
int dynamic_zone_id;
|
||||
int add_replay_on_join;
|
||||
int is_locked;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
@ -38,12 +33,7 @@ public:
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"uuid",
|
||||
"dynamic_zone_id",
|
||||
"expedition_name",
|
||||
"leader_id",
|
||||
"min_players",
|
||||
"max_players",
|
||||
"add_replay_on_join",
|
||||
"is_locked",
|
||||
};
|
||||
@ -82,12 +72,7 @@ public:
|
||||
Expeditions entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.uuid = "";
|
||||
entry.dynamic_zone_id = 0;
|
||||
entry.expedition_name = "";
|
||||
entry.leader_id = 0;
|
||||
entry.min_players = 0;
|
||||
entry.max_players = 0;
|
||||
entry.add_replay_on_join = 1;
|
||||
entry.is_locked = 0;
|
||||
|
||||
@ -126,14 +111,9 @@ public:
|
||||
Expeditions entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.uuid = row[1] ? row[1] : "";
|
||||
entry.dynamic_zone_id = atoi(row[2]);
|
||||
entry.expedition_name = row[3] ? row[3] : "";
|
||||
entry.leader_id = atoi(row[4]);
|
||||
entry.min_players = atoi(row[5]);
|
||||
entry.max_players = atoi(row[6]);
|
||||
entry.add_replay_on_join = atoi(row[7]);
|
||||
entry.is_locked = atoi(row[8]);
|
||||
entry.dynamic_zone_id = atoi(row[1]);
|
||||
entry.add_replay_on_join = atoi(row[2]);
|
||||
entry.is_locked = atoi(row[3]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
@ -167,14 +147,9 @@ public:
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[1] + " = '" + EscapeString(expeditions_entry.uuid) + "'");
|
||||
update_values.push_back(columns[2] + " = " + std::to_string(expeditions_entry.dynamic_zone_id));
|
||||
update_values.push_back(columns[3] + " = '" + EscapeString(expeditions_entry.expedition_name) + "'");
|
||||
update_values.push_back(columns[4] + " = " + std::to_string(expeditions_entry.leader_id));
|
||||
update_values.push_back(columns[5] + " = " + std::to_string(expeditions_entry.min_players));
|
||||
update_values.push_back(columns[6] + " = " + std::to_string(expeditions_entry.max_players));
|
||||
update_values.push_back(columns[7] + " = " + std::to_string(expeditions_entry.add_replay_on_join));
|
||||
update_values.push_back(columns[8] + " = " + std::to_string(expeditions_entry.is_locked));
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(expeditions_entry.dynamic_zone_id));
|
||||
update_values.push_back(columns[2] + " = " + std::to_string(expeditions_entry.add_replay_on_join));
|
||||
update_values.push_back(columns[3] + " = " + std::to_string(expeditions_entry.is_locked));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@ -197,12 +172,7 @@ public:
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(expeditions_entry.id));
|
||||
insert_values.push_back("'" + EscapeString(expeditions_entry.uuid) + "'");
|
||||
insert_values.push_back(std::to_string(expeditions_entry.dynamic_zone_id));
|
||||
insert_values.push_back("'" + EscapeString(expeditions_entry.expedition_name) + "'");
|
||||
insert_values.push_back(std::to_string(expeditions_entry.leader_id));
|
||||
insert_values.push_back(std::to_string(expeditions_entry.min_players));
|
||||
insert_values.push_back(std::to_string(expeditions_entry.max_players));
|
||||
insert_values.push_back(std::to_string(expeditions_entry.add_replay_on_join));
|
||||
insert_values.push_back(std::to_string(expeditions_entry.is_locked));
|
||||
|
||||
@ -235,12 +205,7 @@ public:
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(expeditions_entry.id));
|
||||
insert_values.push_back("'" + EscapeString(expeditions_entry.uuid) + "'");
|
||||
insert_values.push_back(std::to_string(expeditions_entry.dynamic_zone_id));
|
||||
insert_values.push_back("'" + EscapeString(expeditions_entry.expedition_name) + "'");
|
||||
insert_values.push_back(std::to_string(expeditions_entry.leader_id));
|
||||
insert_values.push_back(std::to_string(expeditions_entry.min_players));
|
||||
insert_values.push_back(std::to_string(expeditions_entry.max_players));
|
||||
insert_values.push_back(std::to_string(expeditions_entry.add_replay_on_join));
|
||||
insert_values.push_back(std::to_string(expeditions_entry.is_locked));
|
||||
|
||||
@ -277,14 +242,9 @@ public:
|
||||
Expeditions entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.uuid = row[1] ? row[1] : "";
|
||||
entry.dynamic_zone_id = atoi(row[2]);
|
||||
entry.expedition_name = row[3] ? row[3] : "";
|
||||
entry.leader_id = atoi(row[4]);
|
||||
entry.min_players = atoi(row[5]);
|
||||
entry.max_players = atoi(row[6]);
|
||||
entry.add_replay_on_join = atoi(row[7]);
|
||||
entry.is_locked = atoi(row[8]);
|
||||
entry.dynamic_zone_id = atoi(row[1]);
|
||||
entry.add_replay_on_join = atoi(row[2]);
|
||||
entry.is_locked = atoi(row[3]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
@ -310,14 +270,9 @@ public:
|
||||
Expeditions entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.uuid = row[1] ? row[1] : "";
|
||||
entry.dynamic_zone_id = atoi(row[2]);
|
||||
entry.expedition_name = row[3] ? row[3] : "";
|
||||
entry.leader_id = atoi(row[4]);
|
||||
entry.min_players = atoi(row[5]);
|
||||
entry.max_players = atoi(row[6]);
|
||||
entry.add_replay_on_join = atoi(row[7]);
|
||||
entry.is_locked = atoi(row[8]);
|
||||
entry.dynamic_zone_id = atoi(row[1]);
|
||||
entry.add_replay_on_join = atoi(row[2]);
|
||||
entry.is_locked = atoi(row[3]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
@ -0,0 +1,337 @@
|
||||
/**
|
||||
* DO NOT MODIFY THIS FILE
|
||||
*
|
||||
* This repository was automatically generated and is NOT to be modified directly.
|
||||
* Any repository modifications are meant to be made to the repository extending the base.
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_BASE_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H
|
||||
#define EQEMU_BASE_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseSharedTaskActivityStateRepository {
|
||||
public:
|
||||
struct SharedTaskActivityState {
|
||||
int64 shared_task_id;
|
||||
int activity_id;
|
||||
int done_count;
|
||||
time_t updated_time;
|
||||
time_t completed_time;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("shared_task_id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"shared_task_id",
|
||||
"activity_id",
|
||||
"done_count",
|
||||
"updated_time",
|
||||
"completed_time",
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"shared_task_id",
|
||||
"activity_id",
|
||||
"done_count",
|
||||
"UNIX_TIMESTAMP(updated_time)",
|
||||
"UNIX_TIMESTAMP(completed_time)",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string SelectColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", SelectColumns()));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("shared_task_activity_state");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static SharedTaskActivityState NewEntity()
|
||||
{
|
||||
SharedTaskActivityState entry{};
|
||||
|
||||
entry.shared_task_id = 0;
|
||||
entry.activity_id = 0;
|
||||
entry.done_count = 0;
|
||||
entry.updated_time = 0;
|
||||
entry.completed_time = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static SharedTaskActivityState GetSharedTaskActivityStateEntry(
|
||||
const std::vector<SharedTaskActivityState> &shared_task_activity_states,
|
||||
int shared_task_activity_state_id
|
||||
)
|
||||
{
|
||||
for (auto &shared_task_activity_state : shared_task_activity_states) {
|
||||
if (shared_task_activity_state.shared_task_id == shared_task_activity_state_id) {
|
||||
return shared_task_activity_state;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static SharedTaskActivityState FindOne(
|
||||
Database& db,
|
||||
int shared_task_activity_state_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
shared_task_activity_state_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
SharedTaskActivityState entry{};
|
||||
|
||||
entry.shared_task_id = strtoll(row[0], nullptr, 10);
|
||||
entry.activity_id = atoi(row[1]);
|
||||
entry.done_count = atoi(row[2]);
|
||||
entry.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
|
||||
entry.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
Database& db,
|
||||
int shared_task_activity_state_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
shared_task_activity_state_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
SharedTaskActivityState shared_task_activity_state_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[0] + " = " + std::to_string(shared_task_activity_state_entry.shared_task_id));
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(shared_task_activity_state_entry.activity_id));
|
||||
update_values.push_back(columns[2] + " = " + std::to_string(shared_task_activity_state_entry.done_count));
|
||||
update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (shared_task_activity_state_entry.updated_time > 0 ? std::to_string(shared_task_activity_state_entry.updated_time) : "null") + ")");
|
||||
update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (shared_task_activity_state_entry.completed_time > 0 ? std::to_string(shared_task_activity_state_entry.completed_time) : "null") + ")");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
shared_task_activity_state_entry.shared_task_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static SharedTaskActivityState InsertOne(
|
||||
Database& db,
|
||||
SharedTaskActivityState shared_task_activity_state_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(shared_task_activity_state_entry.shared_task_id));
|
||||
insert_values.push_back(std::to_string(shared_task_activity_state_entry.activity_id));
|
||||
insert_values.push_back(std::to_string(shared_task_activity_state_entry.done_count));
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (shared_task_activity_state_entry.updated_time > 0 ? std::to_string(shared_task_activity_state_entry.updated_time) : "null") + ")");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (shared_task_activity_state_entry.completed_time > 0 ? std::to_string(shared_task_activity_state_entry.completed_time) : "null") + ")");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
shared_task_activity_state_entry.shared_task_id = results.LastInsertedID();
|
||||
return shared_task_activity_state_entry;
|
||||
}
|
||||
|
||||
shared_task_activity_state_entry = NewEntity();
|
||||
|
||||
return shared_task_activity_state_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<SharedTaskActivityState> shared_task_activity_state_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &shared_task_activity_state_entry: shared_task_activity_state_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(shared_task_activity_state_entry.shared_task_id));
|
||||
insert_values.push_back(std::to_string(shared_task_activity_state_entry.activity_id));
|
||||
insert_values.push_back(std::to_string(shared_task_activity_state_entry.done_count));
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (shared_task_activity_state_entry.updated_time > 0 ? std::to_string(shared_task_activity_state_entry.updated_time) : "null") + ")");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (shared_task_activity_state_entry.completed_time > 0 ? std::to_string(shared_task_activity_state_entry.completed_time) : "null") + ")");
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<SharedTaskActivityState> All(Database& db)
|
||||
{
|
||||
std::vector<SharedTaskActivityState> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
SharedTaskActivityState entry{};
|
||||
|
||||
entry.shared_task_id = strtoll(row[0], nullptr, 10);
|
||||
entry.activity_id = atoi(row[1]);
|
||||
entry.done_count = atoi(row[2]);
|
||||
entry.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
|
||||
entry.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<SharedTaskActivityState> GetWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
std::vector<SharedTaskActivityState> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE {}",
|
||||
BaseSelect(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
SharedTaskActivityState entry{};
|
||||
|
||||
entry.shared_task_id = strtoll(row[0], nullptr, 10);
|
||||
entry.activity_id = atoi(row[1]);
|
||||
entry.done_count = atoi(row[2]);
|
||||
entry.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
|
||||
entry.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static int DeleteWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {}",
|
||||
TableName(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int Truncate(Database& db)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"TRUNCATE TABLE {}",
|
||||
TableName()
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_BASE_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H
|
||||
@ -0,0 +1,293 @@
|
||||
/**
|
||||
* DO NOT MODIFY THIS FILE
|
||||
*
|
||||
* This repository was automatically generated and is NOT to be modified directly.
|
||||
* Any repository modifications are meant to be made to the repository extending the base.
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_BASE_SHARED_TASK_DYNAMIC_ZONES_REPOSITORY_H
|
||||
#define EQEMU_BASE_SHARED_TASK_DYNAMIC_ZONES_REPOSITORY_H
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
|
||||
class BaseSharedTaskDynamicZonesRepository {
|
||||
public:
|
||||
struct SharedTaskDynamicZones {
|
||||
int64 shared_task_id;
|
||||
int dynamic_zone_id;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("shared_task_id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"shared_task_id",
|
||||
"dynamic_zone_id",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("shared_task_dynamic_zones");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static SharedTaskDynamicZones NewEntity()
|
||||
{
|
||||
SharedTaskDynamicZones entry{};
|
||||
|
||||
entry.shared_task_id = 0;
|
||||
entry.dynamic_zone_id = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static SharedTaskDynamicZones GetSharedTaskDynamicZonesEntry(
|
||||
const std::vector<SharedTaskDynamicZones> &shared_task_dynamic_zoness,
|
||||
int shared_task_dynamic_zones_id
|
||||
)
|
||||
{
|
||||
for (auto &shared_task_dynamic_zones : shared_task_dynamic_zoness) {
|
||||
if (shared_task_dynamic_zones.shared_task_id == shared_task_dynamic_zones_id) {
|
||||
return shared_task_dynamic_zones;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static SharedTaskDynamicZones FindOne(
|
||||
Database& db,
|
||||
int shared_task_dynamic_zones_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
shared_task_dynamic_zones_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
SharedTaskDynamicZones entry{};
|
||||
|
||||
entry.shared_task_id = strtoll(row[0], NULL, 10);
|
||||
entry.dynamic_zone_id = atoi(row[1]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
Database& db,
|
||||
int shared_task_dynamic_zones_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
shared_task_dynamic_zones_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
SharedTaskDynamicZones shared_task_dynamic_zones_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[0] + " = " + std::to_string(shared_task_dynamic_zones_entry.shared_task_id));
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(shared_task_dynamic_zones_entry.dynamic_zone_id));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
shared_task_dynamic_zones_entry.shared_task_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static SharedTaskDynamicZones InsertOne(
|
||||
Database& db,
|
||||
SharedTaskDynamicZones shared_task_dynamic_zones_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(shared_task_dynamic_zones_entry.shared_task_id));
|
||||
insert_values.push_back(std::to_string(shared_task_dynamic_zones_entry.dynamic_zone_id));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
shared_task_dynamic_zones_entry.shared_task_id = results.LastInsertedID();
|
||||
return shared_task_dynamic_zones_entry;
|
||||
}
|
||||
|
||||
shared_task_dynamic_zones_entry = NewEntity();
|
||||
|
||||
return shared_task_dynamic_zones_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<SharedTaskDynamicZones> shared_task_dynamic_zones_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &shared_task_dynamic_zones_entry: shared_task_dynamic_zones_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(shared_task_dynamic_zones_entry.shared_task_id));
|
||||
insert_values.push_back(std::to_string(shared_task_dynamic_zones_entry.dynamic_zone_id));
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<SharedTaskDynamicZones> All(Database& db)
|
||||
{
|
||||
std::vector<SharedTaskDynamicZones> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
SharedTaskDynamicZones entry{};
|
||||
|
||||
entry.shared_task_id = strtoll(row[0], NULL, 10);
|
||||
entry.dynamic_zone_id = atoi(row[1]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<SharedTaskDynamicZones> GetWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
std::vector<SharedTaskDynamicZones> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE {}",
|
||||
BaseSelect(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
SharedTaskDynamicZones entry{};
|
||||
|
||||
entry.shared_task_id = strtoll(row[0], NULL, 10);
|
||||
entry.dynamic_zone_id = atoi(row[1]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static int DeleteWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {}",
|
||||
TableName(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int Truncate(Database& db)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"TRUNCATE TABLE {}",
|
||||
TableName()
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_BASE_SHARED_TASK_DYNAMIC_ZONES_REPOSITORY_H
|
||||
302
common/repositories/base/base_shared_task_members_repository.h
Normal file
302
common/repositories/base/base_shared_task_members_repository.h
Normal file
@ -0,0 +1,302 @@
|
||||
/**
|
||||
* DO NOT MODIFY THIS FILE
|
||||
*
|
||||
* This repository was automatically generated and is NOT to be modified directly.
|
||||
* Any repository modifications are meant to be made to the repository extending the base.
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_BASE_SHARED_TASK_MEMBERS_REPOSITORY_H
|
||||
#define EQEMU_BASE_SHARED_TASK_MEMBERS_REPOSITORY_H
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
|
||||
class BaseSharedTaskMembersRepository {
|
||||
public:
|
||||
struct SharedTaskMembers {
|
||||
int64 shared_task_id;
|
||||
int64 character_id;
|
||||
int is_leader;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("shared_task_id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"shared_task_id",
|
||||
"character_id",
|
||||
"is_leader",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("shared_task_members");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static SharedTaskMembers NewEntity()
|
||||
{
|
||||
SharedTaskMembers entry{};
|
||||
|
||||
entry.shared_task_id = 0;
|
||||
entry.character_id = 0;
|
||||
entry.is_leader = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static SharedTaskMembers GetSharedTaskMembersEntry(
|
||||
const std::vector<SharedTaskMembers> &shared_task_memberss,
|
||||
int shared_task_members_id
|
||||
)
|
||||
{
|
||||
for (auto &shared_task_members : shared_task_memberss) {
|
||||
if (shared_task_members.shared_task_id == shared_task_members_id) {
|
||||
return shared_task_members;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static SharedTaskMembers FindOne(
|
||||
Database& db,
|
||||
int shared_task_members_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
shared_task_members_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
SharedTaskMembers entry{};
|
||||
|
||||
entry.shared_task_id = strtoll(row[0], NULL, 10);
|
||||
entry.character_id = strtoll(row[1], NULL, 10);
|
||||
entry.is_leader = atoi(row[2]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
Database& db,
|
||||
int shared_task_members_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
shared_task_members_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
SharedTaskMembers shared_task_members_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[0] + " = " + std::to_string(shared_task_members_entry.shared_task_id));
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(shared_task_members_entry.character_id));
|
||||
update_values.push_back(columns[2] + " = " + std::to_string(shared_task_members_entry.is_leader));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
shared_task_members_entry.shared_task_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static SharedTaskMembers InsertOne(
|
||||
Database& db,
|
||||
SharedTaskMembers shared_task_members_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(shared_task_members_entry.shared_task_id));
|
||||
insert_values.push_back(std::to_string(shared_task_members_entry.character_id));
|
||||
insert_values.push_back(std::to_string(shared_task_members_entry.is_leader));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
shared_task_members_entry.shared_task_id = results.LastInsertedID();
|
||||
return shared_task_members_entry;
|
||||
}
|
||||
|
||||
shared_task_members_entry = NewEntity();
|
||||
|
||||
return shared_task_members_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<SharedTaskMembers> shared_task_members_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &shared_task_members_entry: shared_task_members_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(shared_task_members_entry.shared_task_id));
|
||||
insert_values.push_back(std::to_string(shared_task_members_entry.character_id));
|
||||
insert_values.push_back(std::to_string(shared_task_members_entry.is_leader));
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<SharedTaskMembers> All(Database& db)
|
||||
{
|
||||
std::vector<SharedTaskMembers> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
SharedTaskMembers entry{};
|
||||
|
||||
entry.shared_task_id = strtoll(row[0], NULL, 10);
|
||||
entry.character_id = strtoll(row[1], NULL, 10);
|
||||
entry.is_leader = atoi(row[2]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<SharedTaskMembers> GetWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
std::vector<SharedTaskMembers> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE {}",
|
||||
BaseSelect(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
SharedTaskMembers entry{};
|
||||
|
||||
entry.shared_task_id = strtoll(row[0], NULL, 10);
|
||||
entry.character_id = strtoll(row[1], NULL, 10);
|
||||
entry.is_leader = atoi(row[2]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static int DeleteWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {}",
|
||||
TableName(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int Truncate(Database& db)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"TRUNCATE TABLE {}",
|
||||
TableName()
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_BASE_SHARED_TASK_MEMBERS_REPOSITORY_H
|
||||
346
common/repositories/base/base_shared_tasks_repository.h
Normal file
346
common/repositories/base/base_shared_tasks_repository.h
Normal file
@ -0,0 +1,346 @@
|
||||
/**
|
||||
* DO NOT MODIFY THIS FILE
|
||||
*
|
||||
* This repository was automatically generated and is NOT to be modified directly.
|
||||
* Any repository modifications are meant to be made to the repository extending the base.
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_BASE_SHARED_TASKS_REPOSITORY_H
|
||||
#define EQEMU_BASE_SHARED_TASKS_REPOSITORY_H
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseSharedTasksRepository {
|
||||
public:
|
||||
struct SharedTasks {
|
||||
int64 id;
|
||||
int task_id;
|
||||
time_t accepted_time;
|
||||
time_t expire_time;
|
||||
time_t completion_time;
|
||||
int is_locked;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"task_id",
|
||||
"accepted_time",
|
||||
"expire_time",
|
||||
"completion_time",
|
||||
"is_locked",
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"task_id",
|
||||
"UNIX_TIMESTAMP(accepted_time)",
|
||||
"UNIX_TIMESTAMP(expire_time)",
|
||||
"UNIX_TIMESTAMP(completion_time)",
|
||||
"is_locked",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string SelectColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", SelectColumns()));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("shared_tasks");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static SharedTasks NewEntity()
|
||||
{
|
||||
SharedTasks entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.task_id = 0;
|
||||
entry.accepted_time = 0;
|
||||
entry.expire_time = 0;
|
||||
entry.completion_time = 0;
|
||||
entry.is_locked = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static SharedTasks GetSharedTasksEntry(
|
||||
const std::vector<SharedTasks> &shared_taskss,
|
||||
int shared_tasks_id
|
||||
)
|
||||
{
|
||||
for (auto &shared_tasks : shared_taskss) {
|
||||
if (shared_tasks.id == shared_tasks_id) {
|
||||
return shared_tasks;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static SharedTasks FindOne(
|
||||
Database& db,
|
||||
int shared_tasks_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
shared_tasks_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
SharedTasks entry{};
|
||||
|
||||
entry.id = strtoll(row[0], nullptr, 10);
|
||||
entry.task_id = atoi(row[1]);
|
||||
entry.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10);
|
||||
entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
|
||||
entry.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
entry.is_locked = atoi(row[5]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
Database& db,
|
||||
int shared_tasks_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
shared_tasks_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
SharedTasks shared_tasks_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(shared_tasks_entry.task_id));
|
||||
update_values.push_back(columns[2] + " = FROM_UNIXTIME(" + (shared_tasks_entry.accepted_time > 0 ? std::to_string(shared_tasks_entry.accepted_time) : "null") + ")");
|
||||
update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (shared_tasks_entry.expire_time > 0 ? std::to_string(shared_tasks_entry.expire_time) : "null") + ")");
|
||||
update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (shared_tasks_entry.completion_time > 0 ? std::to_string(shared_tasks_entry.completion_time) : "null") + ")");
|
||||
update_values.push_back(columns[5] + " = " + std::to_string(shared_tasks_entry.is_locked));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
shared_tasks_entry.id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static SharedTasks InsertOne(
|
||||
Database& db,
|
||||
SharedTasks shared_tasks_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(shared_tasks_entry.id));
|
||||
insert_values.push_back(std::to_string(shared_tasks_entry.task_id));
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (shared_tasks_entry.accepted_time > 0 ? std::to_string(shared_tasks_entry.accepted_time) : "null") + ")");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (shared_tasks_entry.expire_time > 0 ? std::to_string(shared_tasks_entry.expire_time) : "null") + ")");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (shared_tasks_entry.completion_time > 0 ? std::to_string(shared_tasks_entry.completion_time) : "null") + ")");
|
||||
insert_values.push_back(std::to_string(shared_tasks_entry.is_locked));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
shared_tasks_entry.id = results.LastInsertedID();
|
||||
return shared_tasks_entry;
|
||||
}
|
||||
|
||||
shared_tasks_entry = NewEntity();
|
||||
|
||||
return shared_tasks_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<SharedTasks> shared_tasks_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &shared_tasks_entry: shared_tasks_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(shared_tasks_entry.id));
|
||||
insert_values.push_back(std::to_string(shared_tasks_entry.task_id));
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (shared_tasks_entry.accepted_time > 0 ? std::to_string(shared_tasks_entry.accepted_time) : "null") + ")");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (shared_tasks_entry.expire_time > 0 ? std::to_string(shared_tasks_entry.expire_time) : "null") + ")");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (shared_tasks_entry.completion_time > 0 ? std::to_string(shared_tasks_entry.completion_time) : "null") + ")");
|
||||
insert_values.push_back(std::to_string(shared_tasks_entry.is_locked));
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<SharedTasks> All(Database& db)
|
||||
{
|
||||
std::vector<SharedTasks> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
SharedTasks entry{};
|
||||
|
||||
entry.id = strtoll(row[0], nullptr, 10);
|
||||
entry.task_id = atoi(row[1]);
|
||||
entry.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10);
|
||||
entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
|
||||
entry.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
entry.is_locked = atoi(row[5]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<SharedTasks> GetWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
std::vector<SharedTasks> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE {}",
|
||||
BaseSelect(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
SharedTasks entry{};
|
||||
|
||||
entry.id = strtoll(row[0], nullptr, 10);
|
||||
entry.task_id = atoi(row[1]);
|
||||
entry.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10);
|
||||
entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
|
||||
entry.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
entry.is_locked = atoi(row[5]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static int DeleteWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {}",
|
||||
TableName(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int Truncate(Database& db)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"TRUNCATE TABLE {}",
|
||||
TableName()
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_BASE_SHARED_TASKS_REPOSITORY_H
|
||||
@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseTasksRepository {
|
||||
public:
|
||||
@ -29,11 +30,18 @@ public:
|
||||
int cashreward;
|
||||
int xpreward;
|
||||
int rewardmethod;
|
||||
int reward_radiant_crystals;
|
||||
int reward_ebon_crystals;
|
||||
int minlevel;
|
||||
int maxlevel;
|
||||
int level_spread;
|
||||
int min_players;
|
||||
int max_players;
|
||||
int repeatable;
|
||||
int faction_reward;
|
||||
std::string completion_emote;
|
||||
int replay_timer_seconds;
|
||||
int request_timer_seconds;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
@ -55,11 +63,47 @@ public:
|
||||
"cashreward",
|
||||
"xpreward",
|
||||
"rewardmethod",
|
||||
"reward_radiant_crystals",
|
||||
"reward_ebon_crystals",
|
||||
"minlevel",
|
||||
"maxlevel",
|
||||
"level_spread",
|
||||
"min_players",
|
||||
"max_players",
|
||||
"repeatable",
|
||||
"faction_reward",
|
||||
"completion_emote",
|
||||
"replay_timer_seconds",
|
||||
"request_timer_seconds",
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"type",
|
||||
"duration",
|
||||
"duration_code",
|
||||
"title",
|
||||
"description",
|
||||
"reward",
|
||||
"rewardid",
|
||||
"cashreward",
|
||||
"xpreward",
|
||||
"rewardmethod",
|
||||
"reward_radiant_crystals",
|
||||
"reward_ebon_crystals",
|
||||
"minlevel",
|
||||
"maxlevel",
|
||||
"level_spread",
|
||||
"min_players",
|
||||
"max_players",
|
||||
"repeatable",
|
||||
"faction_reward",
|
||||
"completion_emote",
|
||||
"replay_timer_seconds",
|
||||
"request_timer_seconds",
|
||||
};
|
||||
}
|
||||
|
||||
@ -68,6 +112,11 @@ public:
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string SelectColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", SelectColumns()));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("tasks");
|
||||
@ -77,7 +126,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
@ -95,22 +144,29 @@ public:
|
||||
{
|
||||
Tasks entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.type = 0;
|
||||
entry.duration = 0;
|
||||
entry.duration_code = 0;
|
||||
entry.title = "";
|
||||
entry.description = "";
|
||||
entry.reward = "";
|
||||
entry.rewardid = 0;
|
||||
entry.cashreward = 0;
|
||||
entry.xpreward = 0;
|
||||
entry.rewardmethod = 2;
|
||||
entry.minlevel = 0;
|
||||
entry.maxlevel = 0;
|
||||
entry.repeatable = 1;
|
||||
entry.faction_reward = 0;
|
||||
entry.completion_emote = "";
|
||||
entry.id = 0;
|
||||
entry.type = 0;
|
||||
entry.duration = 0;
|
||||
entry.duration_code = 0;
|
||||
entry.title = "";
|
||||
entry.description = "";
|
||||
entry.reward = "";
|
||||
entry.rewardid = 0;
|
||||
entry.cashreward = 0;
|
||||
entry.xpreward = 0;
|
||||
entry.rewardmethod = 2;
|
||||
entry.reward_radiant_crystals = 0;
|
||||
entry.reward_ebon_crystals = 0;
|
||||
entry.minlevel = 0;
|
||||
entry.maxlevel = 0;
|
||||
entry.level_spread = 0;
|
||||
entry.min_players = 0;
|
||||
entry.max_players = 0;
|
||||
entry.repeatable = 1;
|
||||
entry.faction_reward = 0;
|
||||
entry.completion_emote = "";
|
||||
entry.replay_timer_seconds = 0;
|
||||
entry.request_timer_seconds = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
@ -146,22 +202,29 @@ public:
|
||||
if (results.RowCount() == 1) {
|
||||
Tasks entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.type = atoi(row[1]);
|
||||
entry.duration = atoi(row[2]);
|
||||
entry.duration_code = atoi(row[3]);
|
||||
entry.title = row[4] ? row[4] : "";
|
||||
entry.description = row[5] ? row[5] : "";
|
||||
entry.reward = row[6] ? row[6] : "";
|
||||
entry.rewardid = atoi(row[7]);
|
||||
entry.cashreward = atoi(row[8]);
|
||||
entry.xpreward = atoi(row[9]);
|
||||
entry.rewardmethod = atoi(row[10]);
|
||||
entry.minlevel = atoi(row[11]);
|
||||
entry.maxlevel = atoi(row[12]);
|
||||
entry.repeatable = atoi(row[13]);
|
||||
entry.faction_reward = atoi(row[14]);
|
||||
entry.completion_emote = row[15] ? row[15] : "";
|
||||
entry.id = atoi(row[0]);
|
||||
entry.type = atoi(row[1]);
|
||||
entry.duration = atoi(row[2]);
|
||||
entry.duration_code = atoi(row[3]);
|
||||
entry.title = row[4] ? row[4] : "";
|
||||
entry.description = row[5] ? row[5] : "";
|
||||
entry.reward = row[6] ? row[6] : "";
|
||||
entry.rewardid = atoi(row[7]);
|
||||
entry.cashreward = atoi(row[8]);
|
||||
entry.xpreward = atoi(row[9]);
|
||||
entry.rewardmethod = atoi(row[10]);
|
||||
entry.reward_radiant_crystals = atoi(row[11]);
|
||||
entry.reward_ebon_crystals = atoi(row[12]);
|
||||
entry.minlevel = atoi(row[13]);
|
||||
entry.maxlevel = atoi(row[14]);
|
||||
entry.level_spread = atoi(row[15]);
|
||||
entry.min_players = atoi(row[16]);
|
||||
entry.max_players = atoi(row[17]);
|
||||
entry.repeatable = atoi(row[18]);
|
||||
entry.faction_reward = atoi(row[19]);
|
||||
entry.completion_emote = row[20] ? row[20] : "";
|
||||
entry.replay_timer_seconds = atoi(row[21]);
|
||||
entry.request_timer_seconds = atoi(row[22]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
@ -206,11 +269,18 @@ public:
|
||||
update_values.push_back(columns[8] + " = " + std::to_string(tasks_entry.cashreward));
|
||||
update_values.push_back(columns[9] + " = " + std::to_string(tasks_entry.xpreward));
|
||||
update_values.push_back(columns[10] + " = " + std::to_string(tasks_entry.rewardmethod));
|
||||
update_values.push_back(columns[11] + " = " + std::to_string(tasks_entry.minlevel));
|
||||
update_values.push_back(columns[12] + " = " + std::to_string(tasks_entry.maxlevel));
|
||||
update_values.push_back(columns[13] + " = " + std::to_string(tasks_entry.repeatable));
|
||||
update_values.push_back(columns[14] + " = " + std::to_string(tasks_entry.faction_reward));
|
||||
update_values.push_back(columns[15] + " = '" + EscapeString(tasks_entry.completion_emote) + "'");
|
||||
update_values.push_back(columns[11] + " = " + std::to_string(tasks_entry.reward_radiant_crystals));
|
||||
update_values.push_back(columns[12] + " = " + std::to_string(tasks_entry.reward_ebon_crystals));
|
||||
update_values.push_back(columns[13] + " = " + std::to_string(tasks_entry.minlevel));
|
||||
update_values.push_back(columns[14] + " = " + std::to_string(tasks_entry.maxlevel));
|
||||
update_values.push_back(columns[15] + " = " + std::to_string(tasks_entry.level_spread));
|
||||
update_values.push_back(columns[16] + " = " + std::to_string(tasks_entry.min_players));
|
||||
update_values.push_back(columns[17] + " = " + std::to_string(tasks_entry.max_players));
|
||||
update_values.push_back(columns[18] + " = " + std::to_string(tasks_entry.repeatable));
|
||||
update_values.push_back(columns[19] + " = " + std::to_string(tasks_entry.faction_reward));
|
||||
update_values.push_back(columns[20] + " = '" + EscapeString(tasks_entry.completion_emote) + "'");
|
||||
update_values.push_back(columns[21] + " = " + std::to_string(tasks_entry.replay_timer_seconds));
|
||||
update_values.push_back(columns[22] + " = " + std::to_string(tasks_entry.request_timer_seconds));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@ -243,11 +313,18 @@ public:
|
||||
insert_values.push_back(std::to_string(tasks_entry.cashreward));
|
||||
insert_values.push_back(std::to_string(tasks_entry.xpreward));
|
||||
insert_values.push_back(std::to_string(tasks_entry.rewardmethod));
|
||||
insert_values.push_back(std::to_string(tasks_entry.reward_radiant_crystals));
|
||||
insert_values.push_back(std::to_string(tasks_entry.reward_ebon_crystals));
|
||||
insert_values.push_back(std::to_string(tasks_entry.minlevel));
|
||||
insert_values.push_back(std::to_string(tasks_entry.maxlevel));
|
||||
insert_values.push_back(std::to_string(tasks_entry.level_spread));
|
||||
insert_values.push_back(std::to_string(tasks_entry.min_players));
|
||||
insert_values.push_back(std::to_string(tasks_entry.max_players));
|
||||
insert_values.push_back(std::to_string(tasks_entry.repeatable));
|
||||
insert_values.push_back(std::to_string(tasks_entry.faction_reward));
|
||||
insert_values.push_back("'" + EscapeString(tasks_entry.completion_emote) + "'");
|
||||
insert_values.push_back(std::to_string(tasks_entry.replay_timer_seconds));
|
||||
insert_values.push_back(std::to_string(tasks_entry.request_timer_seconds));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@ -288,11 +365,18 @@ public:
|
||||
insert_values.push_back(std::to_string(tasks_entry.cashreward));
|
||||
insert_values.push_back(std::to_string(tasks_entry.xpreward));
|
||||
insert_values.push_back(std::to_string(tasks_entry.rewardmethod));
|
||||
insert_values.push_back(std::to_string(tasks_entry.reward_radiant_crystals));
|
||||
insert_values.push_back(std::to_string(tasks_entry.reward_ebon_crystals));
|
||||
insert_values.push_back(std::to_string(tasks_entry.minlevel));
|
||||
insert_values.push_back(std::to_string(tasks_entry.maxlevel));
|
||||
insert_values.push_back(std::to_string(tasks_entry.level_spread));
|
||||
insert_values.push_back(std::to_string(tasks_entry.min_players));
|
||||
insert_values.push_back(std::to_string(tasks_entry.max_players));
|
||||
insert_values.push_back(std::to_string(tasks_entry.repeatable));
|
||||
insert_values.push_back(std::to_string(tasks_entry.faction_reward));
|
||||
insert_values.push_back("'" + EscapeString(tasks_entry.completion_emote) + "'");
|
||||
insert_values.push_back(std::to_string(tasks_entry.replay_timer_seconds));
|
||||
insert_values.push_back(std::to_string(tasks_entry.request_timer_seconds));
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
@ -326,22 +410,29 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Tasks entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.type = atoi(row[1]);
|
||||
entry.duration = atoi(row[2]);
|
||||
entry.duration_code = atoi(row[3]);
|
||||
entry.title = row[4] ? row[4] : "";
|
||||
entry.description = row[5] ? row[5] : "";
|
||||
entry.reward = row[6] ? row[6] : "";
|
||||
entry.rewardid = atoi(row[7]);
|
||||
entry.cashreward = atoi(row[8]);
|
||||
entry.xpreward = atoi(row[9]);
|
||||
entry.rewardmethod = atoi(row[10]);
|
||||
entry.minlevel = atoi(row[11]);
|
||||
entry.maxlevel = atoi(row[12]);
|
||||
entry.repeatable = atoi(row[13]);
|
||||
entry.faction_reward = atoi(row[14]);
|
||||
entry.completion_emote = row[15] ? row[15] : "";
|
||||
entry.id = atoi(row[0]);
|
||||
entry.type = atoi(row[1]);
|
||||
entry.duration = atoi(row[2]);
|
||||
entry.duration_code = atoi(row[3]);
|
||||
entry.title = row[4] ? row[4] : "";
|
||||
entry.description = row[5] ? row[5] : "";
|
||||
entry.reward = row[6] ? row[6] : "";
|
||||
entry.rewardid = atoi(row[7]);
|
||||
entry.cashreward = atoi(row[8]);
|
||||
entry.xpreward = atoi(row[9]);
|
||||
entry.rewardmethod = atoi(row[10]);
|
||||
entry.reward_radiant_crystals = atoi(row[11]);
|
||||
entry.reward_ebon_crystals = atoi(row[12]);
|
||||
entry.minlevel = atoi(row[13]);
|
||||
entry.maxlevel = atoi(row[14]);
|
||||
entry.level_spread = atoi(row[15]);
|
||||
entry.min_players = atoi(row[16]);
|
||||
entry.max_players = atoi(row[17]);
|
||||
entry.repeatable = atoi(row[18]);
|
||||
entry.faction_reward = atoi(row[19]);
|
||||
entry.completion_emote = row[20] ? row[20] : "";
|
||||
entry.replay_timer_seconds = atoi(row[21]);
|
||||
entry.request_timer_seconds = atoi(row[22]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
@ -366,22 +457,29 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Tasks entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.type = atoi(row[1]);
|
||||
entry.duration = atoi(row[2]);
|
||||
entry.duration_code = atoi(row[3]);
|
||||
entry.title = row[4] ? row[4] : "";
|
||||
entry.description = row[5] ? row[5] : "";
|
||||
entry.reward = row[6] ? row[6] : "";
|
||||
entry.rewardid = atoi(row[7]);
|
||||
entry.cashreward = atoi(row[8]);
|
||||
entry.xpreward = atoi(row[9]);
|
||||
entry.rewardmethod = atoi(row[10]);
|
||||
entry.minlevel = atoi(row[11]);
|
||||
entry.maxlevel = atoi(row[12]);
|
||||
entry.repeatable = atoi(row[13]);
|
||||
entry.faction_reward = atoi(row[14]);
|
||||
entry.completion_emote = row[15] ? row[15] : "";
|
||||
entry.id = atoi(row[0]);
|
||||
entry.type = atoi(row[1]);
|
||||
entry.duration = atoi(row[2]);
|
||||
entry.duration_code = atoi(row[3]);
|
||||
entry.title = row[4] ? row[4] : "";
|
||||
entry.description = row[5] ? row[5] : "";
|
||||
entry.reward = row[6] ? row[6] : "";
|
||||
entry.rewardid = atoi(row[7]);
|
||||
entry.cashreward = atoi(row[8]);
|
||||
entry.xpreward = atoi(row[9]);
|
||||
entry.rewardmethod = atoi(row[10]);
|
||||
entry.reward_radiant_crystals = atoi(row[11]);
|
||||
entry.reward_ebon_crystals = atoi(row[12]);
|
||||
entry.minlevel = atoi(row[13]);
|
||||
entry.maxlevel = atoi(row[14]);
|
||||
entry.level_spread = atoi(row[15]);
|
||||
entry.min_players = atoi(row[16]);
|
||||
entry.max_players = atoi(row[17]);
|
||||
entry.repeatable = atoi(row[18]);
|
||||
entry.faction_reward = atoi(row[19]);
|
||||
entry.completion_emote = row[20] ? row[20] : "";
|
||||
entry.replay_timer_seconds = atoi(row[21]);
|
||||
entry.request_timer_seconds = atoi(row[22]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
108
common/repositories/character_instance_safereturns_repository.h
Normal file
108
common/repositories/character_instance_safereturns_repository.h
Normal file
@ -0,0 +1,108 @@
|
||||
/**
|
||||
* 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 EQEMU_CHARACTER_INSTANCE_SAFERETURNS_REPOSITORY_H
|
||||
#define EQEMU_CHARACTER_INSTANCE_SAFERETURNS_REPOSITORY_H
|
||||
|
||||
#include "../database.h"
|
||||
#include "../string_util.h"
|
||||
#include "base/base_character_instance_safereturns_repository.h"
|
||||
|
||||
class CharacterInstanceSafereturnsRepository: public BaseCharacterInstanceSafereturnsRepository {
|
||||
public:
|
||||
|
||||
/**
|
||||
* This file was auto generated and can be modified and extended upon
|
||||
*
|
||||
* Base repository methods are automatically
|
||||
* generated in the "base" version of this repository. The base repository
|
||||
* is immutable and to be left untouched, while methods in this class
|
||||
* are used as extension methods for more specific persistence-layer
|
||||
* accessors or mutators.
|
||||
*
|
||||
* Base Methods (Subject to be expanded upon in time)
|
||||
*
|
||||
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||
*
|
||||
* InsertOne
|
||||
* UpdateOne
|
||||
* DeleteOne
|
||||
* FindOne
|
||||
* GetWhere(std::string where_filter)
|
||||
* DeleteWhere(std::string where_filter)
|
||||
* InsertMany
|
||||
* All
|
||||
*
|
||||
* Example custom methods in a repository
|
||||
*
|
||||
* CharacterInstanceSafereturnsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||
* CharacterInstanceSafereturnsRepository::GetWhereNeverExpires()
|
||||
* CharacterInstanceSafereturnsRepository::GetWhereXAndY()
|
||||
* CharacterInstanceSafereturnsRepository::DeleteWhereXAndY()
|
||||
*
|
||||
* Most of the above could be covered by base methods, but if you as a developer
|
||||
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||
* method and encapsulate filters there
|
||||
*/
|
||||
|
||||
// Custom extended repository methods here
|
||||
|
||||
static CharacterInstanceSafereturns InsertOneOrUpdate(
|
||||
Database& db, CharacterInstanceSafereturns& character_instance_safereturns_entry)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.id));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.character_id));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.instance_zone_id));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.instance_id));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_zone_id));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_x));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_y));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_z));
|
||||
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_heading));
|
||||
|
||||
auto results = db.QueryDatabase(fmt::format(SQL(
|
||||
{} VALUES ({})
|
||||
ON DUPLICATE KEY UPDATE
|
||||
instance_zone_id = VALUES(instance_zone_id),
|
||||
instance_id = VALUES(instance_id),
|
||||
safe_zone_id = VALUES(safe_zone_id),
|
||||
safe_x = VALUES(safe_x),
|
||||
safe_y = VALUES(safe_y),
|
||||
safe_z = VALUES(safe_z),
|
||||
safe_heading = VALUES(safe_heading)
|
||||
),
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
));
|
||||
|
||||
if (results.Success())
|
||||
{
|
||||
character_instance_safereturns_entry.id = results.LastInsertedID();
|
||||
return character_instance_safereturns_entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
};
|
||||
|
||||
#endif //EQEMU_CHARACTER_INSTANCE_SAFERETURNS_REPOSITORY_H
|
||||
70
common/repositories/character_task_timers_repository.h
Normal file
70
common/repositories/character_task_timers_repository.h
Normal file
@ -0,0 +1,70 @@
|
||||
/**
|
||||
* 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 EQEMU_CHARACTER_TASK_TIMERS_REPOSITORY_H
|
||||
#define EQEMU_CHARACTER_TASK_TIMERS_REPOSITORY_H
|
||||
|
||||
#include "../database.h"
|
||||
#include "../string_util.h"
|
||||
#include "base/base_character_task_timers_repository.h"
|
||||
|
||||
class CharacterTaskTimersRepository: public BaseCharacterTaskTimersRepository {
|
||||
public:
|
||||
|
||||
/**
|
||||
* This file was auto generated and can be modified and extended upon
|
||||
*
|
||||
* Base repository methods are automatically
|
||||
* generated in the "base" version of this repository. The base repository
|
||||
* is immutable and to be left untouched, while methods in this class
|
||||
* are used as extension methods for more specific persistence-layer
|
||||
* accessors or mutators.
|
||||
*
|
||||
* Base Methods (Subject to be expanded upon in time)
|
||||
*
|
||||
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||
*
|
||||
* InsertOne
|
||||
* UpdateOne
|
||||
* DeleteOne
|
||||
* FindOne
|
||||
* GetWhere(std::string where_filter)
|
||||
* DeleteWhere(std::string where_filter)
|
||||
* InsertMany
|
||||
* All
|
||||
*
|
||||
* Example custom methods in a repository
|
||||
*
|
||||
* CharacterTaskTimersRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||
* CharacterTaskTimersRepository::GetWhereNeverExpires()
|
||||
* CharacterTaskTimersRepository::GetWhereXAndY()
|
||||
* CharacterTaskTimersRepository::DeleteWhereXAndY()
|
||||
*
|
||||
* Most of the above could be covered by base methods, but if you as a developer
|
||||
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||
* method and encapsulate filters there
|
||||
*/
|
||||
|
||||
// Custom extended repository methods here
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_CHARACTER_TASK_TIMERS_REPOSITORY_H
|
||||
@ -0,0 +1,70 @@
|
||||
/**
|
||||
* 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 EQEMU_COMPLETED_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H
|
||||
#define EQEMU_COMPLETED_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H
|
||||
|
||||
#include "../database.h"
|
||||
#include "../string_util.h"
|
||||
#include "base/base_completed_shared_task_activity_state_repository.h"
|
||||
|
||||
class CompletedSharedTaskActivityStateRepository: public BaseCompletedSharedTaskActivityStateRepository {
|
||||
public:
|
||||
|
||||
/**
|
||||
* This file was auto generated and can be modified and extended upon
|
||||
*
|
||||
* Base repository methods are automatically
|
||||
* generated in the "base" version of this repository. The base repository
|
||||
* is immutable and to be left untouched, while methods in this class
|
||||
* are used as extension methods for more specific persistence-layer
|
||||
* accessors or mutators.
|
||||
*
|
||||
* Base Methods (Subject to be expanded upon in time)
|
||||
*
|
||||
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||
*
|
||||
* InsertOne
|
||||
* UpdateOne
|
||||
* DeleteOne
|
||||
* FindOne
|
||||
* GetWhere(std::string where_filter)
|
||||
* DeleteWhere(std::string where_filter)
|
||||
* InsertMany
|
||||
* All
|
||||
*
|
||||
* Example custom methods in a repository
|
||||
*
|
||||
* CompletedSharedTaskActivityStateRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||
* CompletedSharedTaskActivityStateRepository::GetWhereNeverExpires()
|
||||
* CompletedSharedTaskActivityStateRepository::GetWhereXAndY()
|
||||
* CompletedSharedTaskActivityStateRepository::DeleteWhereXAndY()
|
||||
*
|
||||
* Most of the above could be covered by base methods, but if you as a developer
|
||||
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||
* method and encapsulate filters there
|
||||
*/
|
||||
|
||||
// Custom extended repository methods here
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_COMPLETED_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H
|
||||
@ -0,0 +1,70 @@
|
||||
/**
|
||||
* 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 EQEMU_COMPLETED_SHARED_TASK_MEMBERS_REPOSITORY_H
|
||||
#define EQEMU_COMPLETED_SHARED_TASK_MEMBERS_REPOSITORY_H
|
||||
|
||||
#include "../database.h"
|
||||
#include "../string_util.h"
|
||||
#include "base/base_completed_shared_task_members_repository.h"
|
||||
|
||||
class CompletedSharedTaskMembersRepository: public BaseCompletedSharedTaskMembersRepository {
|
||||
public:
|
||||
|
||||
/**
|
||||
* This file was auto generated and can be modified and extended upon
|
||||
*
|
||||
* Base repository methods are automatically
|
||||
* generated in the "base" version of this repository. The base repository
|
||||
* is immutable and to be left untouched, while methods in this class
|
||||
* are used as extension methods for more specific persistence-layer
|
||||
* accessors or mutators.
|
||||
*
|
||||
* Base Methods (Subject to be expanded upon in time)
|
||||
*
|
||||
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||
*
|
||||
* InsertOne
|
||||
* UpdateOne
|
||||
* DeleteOne
|
||||
* FindOne
|
||||
* GetWhere(std::string where_filter)
|
||||
* DeleteWhere(std::string where_filter)
|
||||
* InsertMany
|
||||
* All
|
||||
*
|
||||
* Example custom methods in a repository
|
||||
*
|
||||
* CompletedSharedTaskMembersRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||
* CompletedSharedTaskMembersRepository::GetWhereNeverExpires()
|
||||
* CompletedSharedTaskMembersRepository::GetWhereXAndY()
|
||||
* CompletedSharedTaskMembersRepository::DeleteWhereXAndY()
|
||||
*
|
||||
* Most of the above could be covered by base methods, but if you as a developer
|
||||
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||
* method and encapsulate filters there
|
||||
*/
|
||||
|
||||
// Custom extended repository methods here
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_COMPLETED_SHARED_TASK_MEMBERS_REPOSITORY_H
|
||||
70
common/repositories/completed_shared_tasks_repository.h
Normal file
70
common/repositories/completed_shared_tasks_repository.h
Normal file
@ -0,0 +1,70 @@
|
||||
/**
|
||||
* 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 EQEMU_COMPLETED_SHARED_TASKS_REPOSITORY_H
|
||||
#define EQEMU_COMPLETED_SHARED_TASKS_REPOSITORY_H
|
||||
|
||||
#include "../database.h"
|
||||
#include "../string_util.h"
|
||||
#include "base/base_completed_shared_tasks_repository.h"
|
||||
|
||||
class CompletedSharedTasksRepository: public BaseCompletedSharedTasksRepository {
|
||||
public:
|
||||
|
||||
/**
|
||||
* This file was auto generated and can be modified and extended upon
|
||||
*
|
||||
* Base repository methods are automatically
|
||||
* generated in the "base" version of this repository. The base repository
|
||||
* is immutable and to be left untouched, while methods in this class
|
||||
* are used as extension methods for more specific persistence-layer
|
||||
* accessors or mutators.
|
||||
*
|
||||
* Base Methods (Subject to be expanded upon in time)
|
||||
*
|
||||
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||
*
|
||||
* InsertOne
|
||||
* UpdateOne
|
||||
* DeleteOne
|
||||
* FindOne
|
||||
* GetWhere(std::string where_filter)
|
||||
* DeleteWhere(std::string where_filter)
|
||||
* InsertMany
|
||||
* All
|
||||
*
|
||||
* Example custom methods in a repository
|
||||
*
|
||||
* CompletedSharedTasksRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||
* CompletedSharedTasksRepository::GetWhereNeverExpires()
|
||||
* CompletedSharedTasksRepository::GetWhereXAndY()
|
||||
* CompletedSharedTasksRepository::DeleteWhereXAndY()
|
||||
*
|
||||
* Most of the above could be covered by base methods, but if you as a developer
|
||||
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||
* method and encapsulate filters there
|
||||
*/
|
||||
|
||||
// Custom extended repository methods here
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_COMPLETED_SHARED_TASKS_REPOSITORY_H
|
||||
@ -69,7 +69,6 @@ public:
|
||||
uint32_t id;
|
||||
uint32_t dynamic_zone_id;
|
||||
uint32_t character_id;
|
||||
int is_current_member;
|
||||
std::string character_name;
|
||||
};
|
||||
|
||||
@ -80,32 +79,17 @@ public:
|
||||
dynamic_zone_members.id,
|
||||
dynamic_zone_members.dynamic_zone_id,
|
||||
dynamic_zone_members.character_id,
|
||||
dynamic_zone_members.is_current_member,
|
||||
character_data.name
|
||||
FROM dynamic_zone_members
|
||||
INNER JOIN character_data ON dynamic_zone_members.character_id = character_data.id
|
||||
));
|
||||
}
|
||||
|
||||
static std::vector<MemberWithName> GetWithNames(Database& db,
|
||||
const std::vector<uint32_t>& dynamic_zone_ids)
|
||||
static std::vector<MemberWithName> GetAllWithNames(Database& db)
|
||||
{
|
||||
if (dynamic_zone_ids.empty())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<MemberWithName> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(fmt::format(SQL(
|
||||
{}
|
||||
WHERE dynamic_zone_members.dynamic_zone_id IN ({})
|
||||
AND dynamic_zone_members.is_current_member = TRUE;
|
||||
),
|
||||
SelectMembersWithNames(),
|
||||
fmt::join(dynamic_zone_ids, ",")
|
||||
));
|
||||
|
||||
auto results = db.QueryDatabase(SelectMembersWithNames());
|
||||
if (results.Success())
|
||||
{
|
||||
all_entries.reserve(results.RowCount());
|
||||
@ -118,7 +102,6 @@ public:
|
||||
entry.id = strtoul(row[col++], nullptr, 10);
|
||||
entry.dynamic_zone_id = strtoul(row[col++], nullptr, 10);
|
||||
entry.character_id = strtoul(row[col++], nullptr, 10);
|
||||
entry.is_current_member = strtoul(row[col++], nullptr, 10);
|
||||
entry.character_name = row[col++];
|
||||
|
||||
all_entries.emplace_back(std::move(entry));
|
||||
@ -173,7 +156,7 @@ public:
|
||||
(dynamic_zone_id, character_id)
|
||||
VALUES
|
||||
({}, {})
|
||||
ON DUPLICATE KEY UPDATE is_current_member = TRUE;
|
||||
ON DUPLICATE KEY UPDATE id = id;
|
||||
),
|
||||
TableName(),
|
||||
dynamic_zone_id,
|
||||
@ -184,7 +167,7 @@ public:
|
||||
static void RemoveMember(Database& db, uint32_t dynamic_zone_id, uint32_t character_id)
|
||||
{
|
||||
db.QueryDatabase(fmt::format(SQL(
|
||||
UPDATE {} SET is_current_member = FALSE
|
||||
DELETE FROM {}
|
||||
WHERE dynamic_zone_id = {} AND character_id = {};
|
||||
),
|
||||
TableName(), dynamic_zone_id, character_id
|
||||
@ -194,7 +177,7 @@ public:
|
||||
static void RemoveAllMembers(Database& db, uint32_t dynamic_zone_id)
|
||||
{
|
||||
db.QueryDatabase(fmt::format(SQL(
|
||||
UPDATE {} SET is_current_member = FALSE
|
||||
DELETE FROM {}
|
||||
WHERE dynamic_zone_id = {};
|
||||
),
|
||||
TableName(), dynamic_zone_id
|
||||
@ -206,7 +189,7 @@ public:
|
||||
if (!dynamic_zone_ids.empty())
|
||||
{
|
||||
db.QueryDatabase(fmt::format(SQL(
|
||||
UPDATE {} SET is_current_member = FALSE
|
||||
DELETE FROM {}
|
||||
WHERE dynamic_zone_id IN ({});
|
||||
),
|
||||
TableName(), fmt::join(dynamic_zone_ids, ",")
|
||||
@ -226,7 +209,6 @@ public:
|
||||
insert_values.push_back(std::to_string(dynamic_zone_members_entry.id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_members_entry.dynamic_zone_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_members_entry.character_id));
|
||||
insert_values.push_back(std::to_string(dynamic_zone_members_entry.is_current_member));
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
@ -235,7 +217,7 @@ public:
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"INSERT INTO {} ({}) VALUES {} ON DUPLICATE KEY UPDATE is_current_member = TRUE;",
|
||||
"INSERT INTO {} ({}) VALUES {} ON DUPLICATE KEY UPDATE id = id;",
|
||||
TableName(),
|
||||
ColumnsRaw(),
|
||||
implode(",", insert_chunks)
|
||||
|
||||
@ -68,6 +68,11 @@ public:
|
||||
struct DynamicZoneInstance
|
||||
{
|
||||
uint32_t id;
|
||||
std::string uuid;
|
||||
std::string name;
|
||||
int leader_id;
|
||||
int min_players;
|
||||
int max_players;
|
||||
int instance_id;
|
||||
int type;
|
||||
int compass_zone_id;
|
||||
@ -97,6 +102,11 @@ public:
|
||||
return std::string(SQL(
|
||||
SELECT
|
||||
dynamic_zones.id,
|
||||
dynamic_zones.uuid,
|
||||
dynamic_zones.name,
|
||||
dynamic_zones.leader_id,
|
||||
dynamic_zones.min_players,
|
||||
dynamic_zones.max_players,
|
||||
dynamic_zones.instance_id,
|
||||
dynamic_zones.type,
|
||||
dynamic_zones.compass_zone_id,
|
||||
@ -130,6 +140,11 @@ public:
|
||||
|
||||
int col = 0;
|
||||
entry.id = strtoul(row[col++], nullptr, 10);
|
||||
entry.uuid = row[col++];
|
||||
entry.name = row[col++];
|
||||
entry.leader_id = strtol(row[col++], nullptr, 10);
|
||||
entry.min_players = strtol(row[col++], nullptr, 10);
|
||||
entry.max_players = strtol(row[col++], nullptr, 10);
|
||||
entry.instance_id = strtol(row[col++], nullptr, 10);
|
||||
entry.type = strtol(row[col++], nullptr, 10);
|
||||
entry.compass_zone_id = strtol(row[col++], nullptr, 10);
|
||||
@ -157,21 +172,15 @@ public:
|
||||
return entry;
|
||||
}
|
||||
|
||||
static std::vector<DynamicZoneInstance> GetWithInstance(Database& db,
|
||||
const std::vector<uint32_t>& dynamic_zone_ids)
|
||||
static std::vector<DynamicZoneInstance> AllWithInstanceNotExpired(Database& db)
|
||||
{
|
||||
if (dynamic_zone_ids.empty())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<DynamicZoneInstance> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(fmt::format(
|
||||
"{} WHERE dynamic_zones.id IN ({}) ORDER BY dynamic_zones.id;",
|
||||
SelectDynamicZoneJoinInstance(),
|
||||
fmt::join(dynamic_zone_ids, ",")
|
||||
));
|
||||
auto results = db.QueryDatabase(fmt::format(SQL(
|
||||
{} WHERE
|
||||
(instance_list.start_time + instance_list.duration) > UNIX_TIMESTAMP()
|
||||
AND instance_list.never_expires = 0
|
||||
), SelectDynamicZoneJoinInstance()));
|
||||
|
||||
if (results.Success())
|
||||
{
|
||||
@ -240,6 +249,18 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static void UpdateLeaderID(Database& db, uint32_t dz_id, uint32_t leader_id)
|
||||
{
|
||||
if (dz_id != 0)
|
||||
{
|
||||
std::string query = fmt::format(SQL(
|
||||
UPDATE {} SET leader_id = {} WHERE {} = {};
|
||||
), TableName(), leader_id, PrimaryKey(), dz_id);
|
||||
|
||||
db.QueryDatabase(query);
|
||||
}
|
||||
}
|
||||
|
||||
struct DynamicZoneInstancePlayerCount
|
||||
{
|
||||
uint32_t id;
|
||||
@ -267,7 +288,6 @@ public:
|
||||
FROM dynamic_zones
|
||||
INNER JOIN instance_list ON dynamic_zones.instance_id = instance_list.id
|
||||
LEFT JOIN dynamic_zone_members ON dynamic_zones.id = dynamic_zone_members.dynamic_zone_id
|
||||
AND dynamic_zone_members.is_current_member = TRUE
|
||||
GROUP BY instance_list.id
|
||||
ORDER BY dynamic_zones.id;
|
||||
));
|
||||
@ -301,6 +321,41 @@ public:
|
||||
}
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<uint32_t> GetStaleIDs(Database& db)
|
||||
{
|
||||
std::vector<uint32_t> all_entries;
|
||||
|
||||
// dzs with no members, missing instance, or expired instance
|
||||
auto results = db.QueryDatabase(SQL(
|
||||
SELECT
|
||||
dynamic_zones.id
|
||||
FROM dynamic_zones
|
||||
LEFT JOIN instance_list ON dynamic_zones.instance_id = instance_list.id
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT dynamic_zone_id, COUNT(*) member_count
|
||||
FROM dynamic_zone_members
|
||||
GROUP BY dynamic_zone_id
|
||||
) dynamic_zone_members
|
||||
ON dynamic_zone_members.dynamic_zone_id = dynamic_zones.id
|
||||
WHERE
|
||||
instance_list.id IS NULL
|
||||
OR dynamic_zone_members.member_count IS NULL
|
||||
OR dynamic_zone_members.member_count = 0
|
||||
OR ((instance_list.start_time + instance_list.duration) <= UNIX_TIMESTAMP()
|
||||
AND instance_list.never_expires = 0);
|
||||
));
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row)
|
||||
{
|
||||
all_entries.push_back(atoi(row[0]));
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //EQEMU_DYNAMIC_ZONES_REPOSITORY_H
|
||||
|
||||
@ -65,100 +65,6 @@ public:
|
||||
|
||||
// Custom extended repository methods here
|
||||
|
||||
struct ExpeditionWithLeader
|
||||
{
|
||||
uint32_t id;
|
||||
std::string uuid;
|
||||
uint32_t dynamic_zone_id;
|
||||
std::string expedition_name;
|
||||
uint32_t min_players;
|
||||
uint32_t max_players;
|
||||
int add_replay_on_join;
|
||||
int is_locked;
|
||||
uint32_t leader_id;
|
||||
std::string leader_name;
|
||||
};
|
||||
|
||||
static std::string SelectExpeditionsJoinLeader()
|
||||
{
|
||||
return std::string(SQL(
|
||||
SELECT
|
||||
expeditions.id,
|
||||
expeditions.uuid,
|
||||
expeditions.dynamic_zone_id,
|
||||
expeditions.expedition_name,
|
||||
expeditions.min_players,
|
||||
expeditions.max_players,
|
||||
expeditions.add_replay_on_join,
|
||||
expeditions.is_locked,
|
||||
expeditions.leader_id,
|
||||
character_data.name leader_name
|
||||
FROM expeditions
|
||||
INNER JOIN character_data ON expeditions.leader_id = character_data.id
|
||||
));
|
||||
}
|
||||
|
||||
static ExpeditionWithLeader FillExpeditionWithLeaderFromRow(MySQLRequestRow& row)
|
||||
{
|
||||
ExpeditionWithLeader entry{};
|
||||
|
||||
int col = 0;
|
||||
entry.id = strtoul(row[col++], nullptr, 10);
|
||||
entry.uuid = row[col++];
|
||||
entry.dynamic_zone_id = strtoul(row[col++], nullptr, 10);
|
||||
entry.expedition_name = row[col++];
|
||||
entry.min_players = strtoul(row[col++], nullptr, 10);
|
||||
entry.max_players = strtoul(row[col++], nullptr, 10);
|
||||
entry.add_replay_on_join = strtoul(row[col++], nullptr, 10);
|
||||
entry.is_locked = strtoul(row[col++], nullptr, 10);
|
||||
entry.leader_id = strtoul(row[col++], nullptr, 10);
|
||||
entry.leader_name = row[col++];
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static std::vector<ExpeditionWithLeader> GetAllWithLeaderName(Database& db)
|
||||
{
|
||||
std::vector<ExpeditionWithLeader> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(fmt::format(
|
||||
"{} ORDER BY expeditions.id;",
|
||||
SelectExpeditionsJoinLeader()
|
||||
));
|
||||
|
||||
if (results.Success())
|
||||
{
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row)
|
||||
{
|
||||
ExpeditionWithLeader entry = FillExpeditionWithLeaderFromRow(row);
|
||||
all_entries.emplace_back(std::move(entry));
|
||||
}
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static ExpeditionWithLeader GetWithLeaderName(Database& db, uint32_t expedition_id)
|
||||
{
|
||||
ExpeditionWithLeader entry{};
|
||||
|
||||
auto results = db.QueryDatabase(fmt::format(
|
||||
"{} WHERE expeditions.id = {};",
|
||||
SelectExpeditionsJoinLeader(),
|
||||
expedition_id
|
||||
));
|
||||
|
||||
if (results.Success() && results.RowCount() > 0)
|
||||
{
|
||||
auto row = results.begin();
|
||||
entry = FillExpeditionWithLeaderFromRow(row);
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
struct CharacterExpedition
|
||||
{
|
||||
uint32_t id;
|
||||
@ -186,7 +92,6 @@ public:
|
||||
FROM character_data
|
||||
LEFT JOIN dynamic_zone_members
|
||||
ON character_data.id = dynamic_zone_members.character_id
|
||||
AND dynamic_zone_members.is_current_member = TRUE
|
||||
LEFT JOIN expeditions
|
||||
ON dynamic_zone_members.dynamic_zone_id = expeditions.dynamic_zone_id
|
||||
WHERE character_data.name IN ({})
|
||||
@ -232,7 +137,6 @@ public:
|
||||
ON expeditions.dynamic_zone_id = dynamic_zone_members.dynamic_zone_id
|
||||
WHERE
|
||||
dynamic_zone_members.character_id = {}
|
||||
AND dynamic_zone_members.is_current_member = TRUE;
|
||||
),
|
||||
character_id
|
||||
));
|
||||
|
||||
70
common/repositories/shared_task_activity_state_repository.h
Normal file
70
common/repositories/shared_task_activity_state_repository.h
Normal file
@ -0,0 +1,70 @@
|
||||
/**
|
||||
* 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 EQEMU_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H
|
||||
#define EQEMU_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H
|
||||
|
||||
#include "../database.h"
|
||||
#include "../string_util.h"
|
||||
#include "base/base_shared_task_activity_state_repository.h"
|
||||
|
||||
class SharedTaskActivityStateRepository: public BaseSharedTaskActivityStateRepository {
|
||||
public:
|
||||
|
||||
/**
|
||||
* This file was auto generated and can be modified and extended upon
|
||||
*
|
||||
* Base repository methods are automatically
|
||||
* generated in the "base" version of this repository. The base repository
|
||||
* is immutable and to be left untouched, while methods in this class
|
||||
* are used as extension methods for more specific persistence-layer
|
||||
* accessors or mutators.
|
||||
*
|
||||
* Base Methods (Subject to be expanded upon in time)
|
||||
*
|
||||
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||
*
|
||||
* InsertOne
|
||||
* UpdateOne
|
||||
* DeleteOne
|
||||
* FindOne
|
||||
* GetWhere(std::string where_filter)
|
||||
* DeleteWhere(std::string where_filter)
|
||||
* InsertMany
|
||||
* All
|
||||
*
|
||||
* Example custom methods in a repository
|
||||
*
|
||||
* SharedTaskActivityStateRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||
* SharedTaskActivityStateRepository::GetWhereNeverExpires()
|
||||
* SharedTaskActivityStateRepository::GetWhereXAndY()
|
||||
* SharedTaskActivityStateRepository::DeleteWhereXAndY()
|
||||
*
|
||||
* Most of the above could be covered by base methods, but if you as a developer
|
||||
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||
* method and encapsulate filters there
|
||||
*/
|
||||
|
||||
// Custom extended repository methods here
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H
|
||||
70
common/repositories/shared_task_dynamic_zones_repository.h
Normal file
70
common/repositories/shared_task_dynamic_zones_repository.h
Normal file
@ -0,0 +1,70 @@
|
||||
/**
|
||||
* 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 EQEMU_SHARED_TASK_DYNAMIC_ZONES_REPOSITORY_H
|
||||
#define EQEMU_SHARED_TASK_DYNAMIC_ZONES_REPOSITORY_H
|
||||
|
||||
#include "../database.h"
|
||||
#include "../string_util.h"
|
||||
#include "base/base_shared_task_dynamic_zones_repository.h"
|
||||
|
||||
class SharedTaskDynamicZonesRepository: public BaseSharedTaskDynamicZonesRepository {
|
||||
public:
|
||||
|
||||
/**
|
||||
* This file was auto generated and can be modified and extended upon
|
||||
*
|
||||
* Base repository methods are automatically
|
||||
* generated in the "base" version of this repository. The base repository
|
||||
* is immutable and to be left untouched, while methods in this class
|
||||
* are used as extension methods for more specific persistence-layer
|
||||
* accessors or mutators.
|
||||
*
|
||||
* Base Methods (Subject to be expanded upon in time)
|
||||
*
|
||||
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||
*
|
||||
* InsertOne
|
||||
* UpdateOne
|
||||
* DeleteOne
|
||||
* FindOne
|
||||
* GetWhere(std::string where_filter)
|
||||
* DeleteWhere(std::string where_filter)
|
||||
* InsertMany
|
||||
* All
|
||||
*
|
||||
* Example custom methods in a repository
|
||||
*
|
||||
* SharedTaskDynamicZonesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||
* SharedTaskDynamicZonesRepository::GetWhereNeverExpires()
|
||||
* SharedTaskDynamicZonesRepository::GetWhereXAndY()
|
||||
* SharedTaskDynamicZonesRepository::DeleteWhereXAndY()
|
||||
*
|
||||
* Most of the above could be covered by base methods, but if you as a developer
|
||||
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||
* method and encapsulate filters there
|
||||
*/
|
||||
|
||||
// Custom extended repository methods here
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_SHARED_TASK_DYNAMIC_ZONES_REPOSITORY_H
|
||||
70
common/repositories/shared_task_members_repository.h
Normal file
70
common/repositories/shared_task_members_repository.h
Normal file
@ -0,0 +1,70 @@
|
||||
/**
|
||||
* 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 EQEMU_SHARED_TASK_MEMBERS_REPOSITORY_H
|
||||
#define EQEMU_SHARED_TASK_MEMBERS_REPOSITORY_H
|
||||
|
||||
#include "../database.h"
|
||||
#include "../string_util.h"
|
||||
#include "base/base_shared_task_members_repository.h"
|
||||
|
||||
class SharedTaskMembersRepository: public BaseSharedTaskMembersRepository {
|
||||
public:
|
||||
|
||||
/**
|
||||
* This file was auto generated and can be modified and extended upon
|
||||
*
|
||||
* Base repository methods are automatically
|
||||
* generated in the "base" version of this repository. The base repository
|
||||
* is immutable and to be left untouched, while methods in this class
|
||||
* are used as extension methods for more specific persistence-layer
|
||||
* accessors or mutators.
|
||||
*
|
||||
* Base Methods (Subject to be expanded upon in time)
|
||||
*
|
||||
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||
*
|
||||
* InsertOne
|
||||
* UpdateOne
|
||||
* DeleteOne
|
||||
* FindOne
|
||||
* GetWhere(std::string where_filter)
|
||||
* DeleteWhere(std::string where_filter)
|
||||
* InsertMany
|
||||
* All
|
||||
*
|
||||
* Example custom methods in a repository
|
||||
*
|
||||
* SharedTaskMembersRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||
* SharedTaskMembersRepository::GetWhereNeverExpires()
|
||||
* SharedTaskMembersRepository::GetWhereXAndY()
|
||||
* SharedTaskMembersRepository::DeleteWhereXAndY()
|
||||
*
|
||||
* Most of the above could be covered by base methods, but if you as a developer
|
||||
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||
* method and encapsulate filters there
|
||||
*/
|
||||
|
||||
// Custom extended repository methods here
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_SHARED_TASK_MEMBERS_REPOSITORY_H
|
||||
70
common/repositories/shared_tasks_repository.h
Normal file
70
common/repositories/shared_tasks_repository.h
Normal file
@ -0,0 +1,70 @@
|
||||
/**
|
||||
* 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 EQEMU_SHARED_TASKS_REPOSITORY_H
|
||||
#define EQEMU_SHARED_TASKS_REPOSITORY_H
|
||||
|
||||
#include "../database.h"
|
||||
#include "../string_util.h"
|
||||
#include "base/base_shared_tasks_repository.h"
|
||||
|
||||
class SharedTasksRepository: public BaseSharedTasksRepository {
|
||||
public:
|
||||
|
||||
/**
|
||||
* This file was auto generated and can be modified and extended upon
|
||||
*
|
||||
* Base repository methods are automatically
|
||||
* generated in the "base" version of this repository. The base repository
|
||||
* is immutable and to be left untouched, while methods in this class
|
||||
* are used as extension methods for more specific persistence-layer
|
||||
* accessors or mutators.
|
||||
*
|
||||
* Base Methods (Subject to be expanded upon in time)
|
||||
*
|
||||
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||
*
|
||||
* InsertOne
|
||||
* UpdateOne
|
||||
* DeleteOne
|
||||
* FindOne
|
||||
* GetWhere(std::string where_filter)
|
||||
* DeleteWhere(std::string where_filter)
|
||||
* InsertMany
|
||||
* All
|
||||
*
|
||||
* Example custom methods in a repository
|
||||
*
|
||||
* SharedTasksRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||
* SharedTasksRepository::GetWhereNeverExpires()
|
||||
* SharedTasksRepository::GetWhereXAndY()
|
||||
* SharedTasksRepository::DeleteWhereXAndY()
|
||||
*
|
||||
* Most of the above could be covered by base methods, but if you as a developer
|
||||
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||
* method and encapsulate filters there
|
||||
*/
|
||||
|
||||
// Custom extended repository methods here
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_SHARED_TASKS_REPOSITORY_H
|
||||
@ -538,6 +538,7 @@ RULE_BOOL(TaskSystem, RecordCompletedTasks, true, "Record completed tasks")
|
||||
RULE_BOOL(TaskSystem, RecordCompletedOptionalActivities, false, "Record completed optional activities")
|
||||
RULE_BOOL(TaskSystem, KeepOneRecordPerCompletedTask, true, "Keep only one record per completed task")
|
||||
RULE_BOOL(TaskSystem, EnableTaskProximity, true, "Enable task proximity system")
|
||||
RULE_INT(TaskSystem, RequestCooldownTimerSeconds, 15, "Seconds between allowing characters to request tasks (live-like default: 15 seconds)")
|
||||
RULE_CATEGORY_END()
|
||||
|
||||
RULE_CATEGORY(Range)
|
||||
|
||||
@ -6,7 +6,10 @@
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include "../common/net/packet.h"
|
||||
#include <cereal/cereal.hpp>
|
||||
#include <cereal/archives/binary.hpp>
|
||||
#include <cereal/types/chrono.hpp>
|
||||
#include <cereal/types/string.hpp>
|
||||
#include <cereal/types/vector.hpp>
|
||||
|
||||
#define SERVER_TIMEOUT 45000 // how often keepalive gets sent
|
||||
#define INTERSERVER_TIMER 10000
|
||||
@ -141,14 +144,9 @@
|
||||
#define ServerOP_LFPMatches 0x0214
|
||||
#define ServerOP_ClientVersionSummary 0x0215
|
||||
|
||||
// expedition
|
||||
#define ServerOP_ExpeditionCreate 0x0400
|
||||
#define ServerOP_ExpeditionDeleted 0x0401
|
||||
#define ServerOP_ExpeditionLeaderChanged 0x0402
|
||||
#define ServerOP_ExpeditionLockout 0x0403
|
||||
#define ServerOP_ExpeditionMemberChange 0x0404
|
||||
#define ServerOP_ExpeditionMemberSwap 0x0405
|
||||
#define ServerOP_ExpeditionMemberStatus 0x0406
|
||||
#define ServerOP_ExpeditionGetMemberStatuses 0x0407
|
||||
#define ServerOP_ExpeditionDzAddPlayer 0x0408
|
||||
#define ServerOP_ExpeditionDzMakeLeader 0x0409
|
||||
#define ServerOP_ExpeditionCharacterLockout 0x040d
|
||||
@ -156,17 +154,23 @@
|
||||
#define ServerOP_ExpeditionRequestInvite 0x040f
|
||||
#define ServerOP_ExpeditionReplayOnJoin 0x0410
|
||||
#define ServerOP_ExpeditionLockState 0x0411
|
||||
#define ServerOP_ExpeditionMembersRemoved 0x0412
|
||||
#define ServerOP_ExpeditionLockoutDuration 0x0414
|
||||
#define ServerOP_ExpeditionExpireWarning 0x0416
|
||||
|
||||
#define ServerOP_DzAddRemoveCharacter 0x0450
|
||||
#define ServerOP_DzRemoveAllCharacters 0x0451
|
||||
// dz
|
||||
#define ServerOP_DzAddRemoveMember 0x0450
|
||||
#define ServerOP_DzRemoveAllMembers 0x0451
|
||||
#define ServerOP_DzSetSecondsRemaining 0x0452
|
||||
#define ServerOP_DzDurationUpdate 0x0453
|
||||
#define ServerOP_DzSetCompass 0x0454
|
||||
#define ServerOP_DzSetSafeReturn 0x0455
|
||||
#define ServerOP_DzSetZoneIn 0x0456
|
||||
#define ServerOP_DzSwapMembers 0x0457
|
||||
#define ServerOP_DzGetMemberStatuses 0x0458
|
||||
#define ServerOP_DzUpdateMemberStatus 0x0459
|
||||
#define ServerOP_DzLeaderChanged 0x045a
|
||||
#define ServerOP_DzExpireWarning 0x045b
|
||||
#define ServerOP_DzCreated 0x045c
|
||||
#define ServerOP_DzDeleted 0x045d
|
||||
|
||||
#define ServerOP_LSInfo 0x1000
|
||||
#define ServerOP_LSStatus 0x1001
|
||||
@ -395,7 +399,10 @@ public:
|
||||
}
|
||||
|
||||
void WriteUInt8(uint8 value) { *(uint8 *)(pBuffer + _wpos) = value; _wpos += sizeof(uint8); }
|
||||
void WriteInt8(uint8_t value) { *(uint8_t *)(pBuffer + _wpos) = value; _wpos += sizeof(uint8_t); }
|
||||
void WriteUInt32(uint32 value) { *(uint32 *)(pBuffer + _wpos) = value; _wpos += sizeof(uint32); }
|
||||
void WriteInt32(int32_t value) { *(int32_t *)(pBuffer + _wpos) = value; _wpos += sizeof(int32_t); }
|
||||
|
||||
void WriteString(const char * str) { uint32 len = static_cast<uint32>(strlen(str)) + 1; memcpy(pBuffer + _wpos, str, len); _wpos += len; }
|
||||
|
||||
uint8 ReadUInt8() { uint8 value = *(uint8 *)(pBuffer + _rpos); _rpos += sizeof(uint8); return value; }
|
||||
@ -2025,47 +2032,28 @@ struct ServerExpeditionID_Struct {
|
||||
uint32 sender_instance_id;
|
||||
};
|
||||
|
||||
struct ServerExpeditionLeaderID_Struct {
|
||||
uint32 expedition_id;
|
||||
struct ServerDzLeaderID_Struct {
|
||||
uint32 dz_id;
|
||||
uint32 leader_id;
|
||||
};
|
||||
|
||||
struct ServerExpeditionMemberChange_Struct {
|
||||
uint32 expedition_id;
|
||||
uint32 sender_zone_id;
|
||||
uint16 sender_instance_id;
|
||||
uint8 removed; // 0: added, 1: removed
|
||||
uint32 char_id;
|
||||
char char_name[64];
|
||||
};
|
||||
|
||||
struct ServerExpeditionMemberSwap_Struct {
|
||||
uint32 expedition_id;
|
||||
uint32 sender_zone_id;
|
||||
uint16 sender_instance_id;
|
||||
uint32 add_char_id;
|
||||
uint32 remove_char_id;
|
||||
char add_char_name[64];
|
||||
char remove_char_name[64];
|
||||
};
|
||||
|
||||
struct ServerExpeditionMemberStatus_Struct {
|
||||
uint32 expedition_id;
|
||||
struct ServerDzMemberStatus_Struct {
|
||||
uint32 dz_id;
|
||||
uint32 sender_zone_id;
|
||||
uint16 sender_instance_id;
|
||||
uint8 status; // 0: unknown 1: Online 2: Offline 3: In Dynamic Zone 4: Link Dead
|
||||
uint32 character_id;
|
||||
};
|
||||
|
||||
struct ServerExpeditionMemberStatusEntry_Struct {
|
||||
struct ServerDzMemberStatusEntry_Struct {
|
||||
uint32 character_id;
|
||||
uint8 online_status; // 0: unknown 1: Online 2: Offline 3: In Dynamic Zone 4: Link Dead
|
||||
};
|
||||
|
||||
struct ServerExpeditionMemberStatuses_Struct {
|
||||
uint32 expedition_id;
|
||||
struct ServerDzMemberStatuses_Struct {
|
||||
uint32 dz_id;
|
||||
uint32 count;
|
||||
ServerExpeditionMemberStatusEntry_Struct entries[0];
|
||||
ServerDzMemberStatusEntry_Struct entries[0];
|
||||
};
|
||||
|
||||
struct ServerExpeditionLockout_Struct {
|
||||
@ -2109,8 +2097,8 @@ struct ServerExpeditionCharacterID_Struct {
|
||||
uint32_t character_id;
|
||||
};
|
||||
|
||||
struct ServerExpeditionExpireWarning_Struct {
|
||||
uint32_t expedition_id;
|
||||
struct ServerDzExpireWarning_Struct {
|
||||
uint32_t dz_id;
|
||||
uint32_t minutes_remaining;
|
||||
};
|
||||
|
||||
@ -2123,13 +2111,21 @@ struct ServerDzCommand_Struct {
|
||||
};
|
||||
|
||||
struct ServerDzCommandMakeLeader_Struct {
|
||||
uint32 expedition_id;
|
||||
uint32 dz_id;
|
||||
uint32 requester_id;
|
||||
uint8 is_online; // set by world, 0: new leader name offline, 1: online
|
||||
uint8 is_success; // set by world, 0: makeleader failed, 1: success (is online member)
|
||||
char new_leader_name[64];
|
||||
};
|
||||
|
||||
struct ServerDzID_Struct {
|
||||
uint32 dz_id;
|
||||
uint16 dz_zone_id;
|
||||
uint16 dz_instance_id; // for cache-independent redundancy (messages to dz's instance)
|
||||
uint32 sender_zone_id;
|
||||
uint16 sender_instance_id;
|
||||
};
|
||||
|
||||
struct ServerDzLocation_Struct {
|
||||
uint32 dz_id;
|
||||
uint32 sender_zone_id;
|
||||
@ -2141,11 +2137,29 @@ struct ServerDzLocation_Struct {
|
||||
float heading;
|
||||
};
|
||||
|
||||
struct ServerDzCharacter_Struct {
|
||||
uint16 zone_id;
|
||||
uint16 instance_id;
|
||||
uint8 remove; // 0: added 1: removed
|
||||
struct ServerDzMember_Struct {
|
||||
uint32 dz_id;
|
||||
uint16 dz_zone_id;
|
||||
uint16 dz_instance_id; // for cache redundancy
|
||||
uint16 sender_zone_id;
|
||||
uint16 sender_instance_id;
|
||||
uint8 removed; // 0: added, 1: removed
|
||||
uint32 character_id;
|
||||
uint8 character_status; // 0: unknown 1: Online 2: Offline 3: In Dynamic Zone 4: Link Dead
|
||||
char character_name[64];
|
||||
};
|
||||
|
||||
struct ServerDzMemberSwap_Struct {
|
||||
uint32 dz_id;
|
||||
uint16 dz_zone_id;
|
||||
uint16 dz_instance_id; // for cache redundancy
|
||||
uint16 sender_zone_id;
|
||||
uint16 sender_instance_id;
|
||||
uint32 add_character_id;
|
||||
uint32 remove_character_id;
|
||||
uint8 add_character_status;
|
||||
char add_character_name[64];
|
||||
char remove_character_name[64];
|
||||
};
|
||||
|
||||
struct ServerDzSetDuration_Struct {
|
||||
@ -2153,6 +2167,13 @@ struct ServerDzSetDuration_Struct {
|
||||
uint32 seconds;
|
||||
};
|
||||
|
||||
struct ServerDzCreateSerialized_Struct {
|
||||
uint16_t origin_zone_id;
|
||||
uint16_t origin_instance_id;
|
||||
uint32_t cereal_size;
|
||||
char cereal_data[0];
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif
|
||||
|
||||
139
common/shared_tasks.cpp
Normal file
139
common/shared_tasks.cpp
Normal file
@ -0,0 +1,139 @@
|
||||
#include "shared_tasks.h"
|
||||
#include "repositories/character_data_repository.h"
|
||||
#include <algorithm>
|
||||
|
||||
std::vector<SharedTaskActivityStateEntry> SharedTask::GetActivityState() const
|
||||
{
|
||||
return m_shared_task_activity_state;
|
||||
}
|
||||
|
||||
std::vector<SharedTaskMember> SharedTask::GetMembers() const
|
||||
{
|
||||
return m_members;
|
||||
}
|
||||
|
||||
void SharedTask::SetSharedTaskActivityState(const std::vector<SharedTaskActivityStateEntry> &activity_state)
|
||||
{
|
||||
SharedTask::m_shared_task_activity_state = activity_state;
|
||||
}
|
||||
|
||||
void SharedTask::SetTaskData(const TasksRepository::Tasks &task_data)
|
||||
{
|
||||
SharedTask::m_task_data = task_data;
|
||||
}
|
||||
|
||||
void SharedTask::SetTaskActivityData(const std::vector<TaskActivitiesRepository::TaskActivities> &task_activity_data)
|
||||
{
|
||||
SharedTask::m_task_activity_data = task_activity_data;
|
||||
}
|
||||
|
||||
const TasksRepository::Tasks &SharedTask::GetTaskData() const
|
||||
{
|
||||
return m_task_data;
|
||||
}
|
||||
|
||||
const std::vector<TaskActivitiesRepository::TaskActivities> &SharedTask::GetTaskActivityData() const
|
||||
{
|
||||
return m_task_activity_data;
|
||||
}
|
||||
|
||||
void SharedTask::SetMembers(const std::vector<SharedTaskMember> &members)
|
||||
{
|
||||
SharedTask::m_members = members;
|
||||
}
|
||||
|
||||
const SharedTasksRepository::SharedTasks &SharedTask::GetDbSharedTask() const
|
||||
{
|
||||
return m_db_shared_task;
|
||||
}
|
||||
|
||||
void SharedTask::SetDbSharedTask(const SharedTasksRepository::SharedTasks &m_db_shared_task)
|
||||
{
|
||||
SharedTask::m_db_shared_task = m_db_shared_task;
|
||||
}
|
||||
|
||||
SharedTaskRequestCharacters SharedTask::GetRequestCharacters(Database &db, uint32_t requested_character_id)
|
||||
{
|
||||
SharedTaskRequestCharacters request{};
|
||||
|
||||
request.group_type = SharedTaskRequestGroupType::Group;
|
||||
request.characters = CharacterDataRepository::GetWhere(
|
||||
db, fmt::format(
|
||||
"id IN (select charid from group_id where groupid = (select groupid from group_id where charid = {}))",
|
||||
requested_character_id
|
||||
)
|
||||
);
|
||||
|
||||
if (request.characters.empty()) {
|
||||
request.group_type = SharedTaskRequestGroupType::Raid;
|
||||
request.characters = CharacterDataRepository::GetWhere(
|
||||
db, fmt::format(
|
||||
"id IN (select charid from raid_members where raidid = (select raidid from raid_members where charid = {}))",
|
||||
requested_character_id
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (request.characters.empty()) // solo request
|
||||
{
|
||||
request.group_type = SharedTaskRequestGroupType::Solo;
|
||||
request.characters = CharacterDataRepository::GetWhere(
|
||||
db, fmt::format(
|
||||
"id = {} LIMIT 1",
|
||||
requested_character_id
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
request.lowest_level = std::numeric_limits<uint8_t>::max();
|
||||
request.highest_level = 0;
|
||||
for (const auto &character: request.characters) {
|
||||
request.lowest_level = std::min(request.lowest_level, character.level);
|
||||
request.highest_level = std::max(request.highest_level, character.level);
|
||||
request.character_ids.emplace_back(character.id); // convenience
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
void SharedTask::AddCharacterToMemberHistory(uint32_t character_id)
|
||||
{
|
||||
auto it = std::find(member_id_history.begin(), member_id_history.end(), character_id);
|
||||
if (it == member_id_history.end()) {
|
||||
member_id_history.emplace_back(character_id);
|
||||
}
|
||||
}
|
||||
|
||||
SharedTaskMember SharedTask::FindMemberFromCharacterID(uint32_t character_id) const
|
||||
{
|
||||
auto it = std::find_if(
|
||||
m_members.begin(), m_members.end(),
|
||||
[&](const SharedTaskMember &member) {
|
||||
return member.character_id == character_id;
|
||||
}
|
||||
);
|
||||
|
||||
return it != m_members.end() ? *it : SharedTaskMember{};
|
||||
}
|
||||
|
||||
SharedTaskMember SharedTask::FindMemberFromCharacterName(const std::string &character_name) const
|
||||
{
|
||||
auto it = std::find_if(
|
||||
m_members.begin(), m_members.end(),
|
||||
[&](const SharedTaskMember &member) {
|
||||
return strcasecmp(member.character_name.c_str(), character_name.c_str()) == 0;
|
||||
}
|
||||
);
|
||||
|
||||
return it != m_members.end() ? *it : SharedTaskMember{};
|
||||
}
|
||||
|
||||
SharedTaskMember SharedTask::GetLeader() const
|
||||
{
|
||||
for (const auto &member : m_members) {
|
||||
if (member.is_leader) {
|
||||
return member;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
204
common/shared_tasks.h
Normal file
204
common/shared_tasks.h
Normal file
@ -0,0 +1,204 @@
|
||||
#ifndef EQEMU_SHARED_TASKS_H
|
||||
#define EQEMU_SHARED_TASKS_H
|
||||
|
||||
#include "database.h"
|
||||
#include "types.h"
|
||||
#include "repositories/character_data_repository.h"
|
||||
#include "repositories/tasks_repository.h"
|
||||
#include "repositories/task_activities_repository.h"
|
||||
#include "repositories/shared_tasks_repository.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
// ops
|
||||
#define ServerOP_SharedTaskRequest 0x0300 // zone -> world. Player trying to get task. Relayed world -> zone on confirmation
|
||||
#define ServerOP_SharedTaskAddPlayer 0x0301 // bidirectional. /taskaddplayer request zone -> world. success world -> zone
|
||||
#define ServerOP_SharedTaskMakeLeader 0x0302 // zone -> world -> zone
|
||||
#define ServerOP_SharedTaskRemovePlayer 0x0303 // zone -> world -> zone
|
||||
#define ServerOP_SharedTaskAttemptRemove 0x0304 // zone -> world. Player trying to delete task
|
||||
#define ServerOP_SharedTaskUpdate 0x0305 // zone -> world. Client sending task update to world. Relayed world -> zone on confirmation
|
||||
#define ServerOP_SharedTaskMemberlist 0x0306 // world -> zone. Send shared task memberlist
|
||||
#define ServerOP_SharedTaskRequestMemberlist 0x0307 // zone -> world. Send shared task memberlist (zone in initial for now, could change)
|
||||
#define ServerOP_SharedTaskAcceptNewTask 0x0308 // world -> zone. World verified, continue AcceptNewTask
|
||||
#define ServerOP_SharedTaskInvitePlayer 0x0309 // world -> zone. Sends task invite to player
|
||||
#define ServerOP_SharedTaskInviteAcceptedPlayer 0x0310 // zone -> world. Confirming task invite
|
||||
#define ServerOP_SharedTaskCreateDynamicZone 0x0311 // zone -> world
|
||||
#define ServerOP_SharedTaskPurgeAllCommand 0x0312 // zone -> world
|
||||
#define ServerOP_SharedTaskPlayerList 0x0313 // zone -> world /taskplayerlist command
|
||||
#define ServerOP_SharedTaskMemberChange 0x0314 // world -> zone. Send shared task single member added/removed (client also handles message)
|
||||
#define ServerOP_SharedTaskKickPlayers 0x0315 // zone -> world /kickplayers task
|
||||
|
||||
enum class SharedTaskRequestGroupType {
|
||||
Solo = 0,
|
||||
Group,
|
||||
Raid
|
||||
};
|
||||
|
||||
// used in
|
||||
// ServerOP_SharedTaskRequest
|
||||
|
||||
// ServerOP_SharedTaskAcceptNewTask
|
||||
struct ServerSharedTaskRequest_Struct {
|
||||
uint32 requested_character_id;
|
||||
uint32 requested_task_id;
|
||||
uint32 requested_npc_type_id; // original task logic passthrough
|
||||
uint32 accept_time;
|
||||
};
|
||||
|
||||
// ServerOP_SharedTaskInvitePlayer
|
||||
struct ServerSharedTaskInvitePlayer_Struct {
|
||||
uint32 requested_character_id;
|
||||
uint32 invite_shared_task_id;
|
||||
char task_name[64];
|
||||
char inviter_name[64];
|
||||
};
|
||||
|
||||
// ServerOP_SharedTaskAttemptRemove
|
||||
// gets re-used when sent back to clients
|
||||
struct ServerSharedTaskAttemptRemove_Struct {
|
||||
uint32 requested_character_id;
|
||||
uint32 requested_task_id;
|
||||
bool remove_from_db;
|
||||
};
|
||||
|
||||
// used in the shared task request process (currently)
|
||||
struct SharedTaskMember {
|
||||
uint32 character_id = 0;
|
||||
std::string character_name;
|
||||
bool is_leader = false;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive& archive)
|
||||
{
|
||||
archive(character_id, character_name, is_leader);
|
||||
}
|
||||
};
|
||||
|
||||
// used in shared task requests to validate group/raid members
|
||||
struct SharedTaskRequestCharacters {
|
||||
int lowest_level;
|
||||
int highest_level;
|
||||
SharedTaskRequestGroupType group_type;
|
||||
std::vector<uint32_t> character_ids;
|
||||
std::vector<CharacterDataRepository::CharacterData> characters;
|
||||
};
|
||||
|
||||
// ServerOP_SharedTaskMemberlist
|
||||
// builds the buffer and sends to clients directly
|
||||
struct ServerSharedTaskMemberListPacket_Struct {
|
||||
uint32 destination_character_id;
|
||||
uint32 cereal_size;
|
||||
char cereal_serialized_members[0]; // serialized member list using cereal
|
||||
};
|
||||
|
||||
struct ServerSharedTaskMemberChangePacket_Struct {
|
||||
uint32 destination_character_id;
|
||||
uint32 shared_task_id;
|
||||
bool removed;
|
||||
char player_name[64];
|
||||
};
|
||||
|
||||
struct SharedTaskActivityStateEntry {
|
||||
uint32 activity_id;
|
||||
uint32 done_count;
|
||||
uint32 max_done_count; // goalcount
|
||||
uint32 updated_time;
|
||||
uint32 completed_time;
|
||||
};
|
||||
|
||||
struct ServerSharedTaskActivityUpdate_Struct {
|
||||
uint32 source_character_id;
|
||||
uint32 task_id;
|
||||
uint32 activity_id;
|
||||
uint32 done_count;
|
||||
bool ignore_quest_update;
|
||||
};
|
||||
|
||||
struct ServerSharedTaskRequestMemberlist_Struct {
|
||||
uint32 source_character_id;
|
||||
uint32 task_id;
|
||||
};
|
||||
|
||||
struct ServerSharedTaskRemovePlayer_Struct {
|
||||
uint32 source_character_id;
|
||||
uint32 task_id;
|
||||
char player_name[64];
|
||||
};
|
||||
|
||||
struct ServerSharedTaskAddPlayer_Struct {
|
||||
uint32 source_character_id;
|
||||
uint32 task_id;
|
||||
char player_name[64];
|
||||
};
|
||||
|
||||
struct ServerSharedTaskMakeLeader_Struct {
|
||||
uint32 source_character_id;
|
||||
uint32 task_id;
|
||||
char player_name[64];
|
||||
};
|
||||
|
||||
struct ServerSharedTaskInviteAccepted_Struct {
|
||||
uint32 source_character_id;
|
||||
uint32 shared_task_id;
|
||||
bool accepted;
|
||||
char player_name[64];
|
||||
};
|
||||
|
||||
struct ServerSharedTaskCreateDynamicZone_Struct {
|
||||
uint32 source_character_id;
|
||||
uint32 task_id;
|
||||
uint32 cereal_size;
|
||||
char cereal_data[0]; // serialized dz with creation parameters
|
||||
};
|
||||
|
||||
struct ServerSharedTaskPlayerList_Struct {
|
||||
uint32 source_character_id;
|
||||
uint32 task_id;
|
||||
};
|
||||
|
||||
struct ServerSharedTaskKickPlayers_Struct {
|
||||
uint32 source_character_id;
|
||||
uint32 task_id;
|
||||
};
|
||||
|
||||
class SharedTask {
|
||||
public:
|
||||
// used in both zone and world validation
|
||||
static SharedTaskRequestCharacters GetRequestCharacters(Database& db, uint32_t requested_character_id);
|
||||
|
||||
void AddCharacterToMemberHistory(uint32_t character_id);
|
||||
SharedTaskMember FindMemberFromCharacterID(uint32_t character_id) const;
|
||||
SharedTaskMember FindMemberFromCharacterName(const std::string& character_name) const;
|
||||
SharedTaskMember GetLeader() const;
|
||||
std::vector<SharedTaskActivityStateEntry> GetActivityState() const;
|
||||
std::vector<SharedTaskMember> GetMembers() const;
|
||||
|
||||
// getters
|
||||
const std::vector<TaskActivitiesRepository::TaskActivities> &GetTaskActivityData() const;
|
||||
const TasksRepository::Tasks &GetTaskData() const;
|
||||
|
||||
// setters
|
||||
void SetMembers(const std::vector<SharedTaskMember> &members);
|
||||
void SetSharedTaskActivityState(const std::vector<SharedTaskActivityStateEntry> &activity_state);
|
||||
void SetTaskActivityData(const std::vector<TaskActivitiesRepository::TaskActivities> &task_activity_data);
|
||||
void SetTaskData(const TasksRepository::Tasks &task_data);
|
||||
|
||||
// active record of database shared task
|
||||
const SharedTasksRepository::SharedTasks &GetDbSharedTask() const;
|
||||
void SetDbSharedTask(const SharedTasksRepository::SharedTasks &m_db_shared_task);
|
||||
|
||||
std::vector<SharedTaskActivityStateEntry> m_shared_task_activity_state;
|
||||
std::vector<SharedTaskMember> m_members;
|
||||
std::vector<uint32_t> member_id_history; // past and present members for replay timers
|
||||
std::vector<uint32_t> dynamic_zone_ids;
|
||||
|
||||
protected:
|
||||
SharedTasksRepository::SharedTasks m_db_shared_task;
|
||||
|
||||
// reference to task data (only for this shared task)
|
||||
TasksRepository::Tasks m_task_data;
|
||||
std::vector<TaskActivitiesRepository::TaskActivities> m_task_activity_data;
|
||||
};
|
||||
|
||||
#endif //EQEMU_SHARED_TASKS_H
|
||||
445
common/tasks.h
Normal file
445
common/tasks.h
Normal file
@ -0,0 +1,445 @@
|
||||
#ifndef EQEMU_TASKS_H
|
||||
#define EQEMU_TASKS_H
|
||||
|
||||
#include "serialize_buffer.h"
|
||||
|
||||
#define MAXTASKS 10000
|
||||
#define MAXTASKSETS 1000
|
||||
#define MAXACTIVEQUESTS 19 // The Client has a hard cap of 19 active quests, 29 in SoD+
|
||||
#define MAXCHOOSERENTRIES 40 // The Max Chooser (Task Selector entries) is capped at 40 in the Titanium Client.
|
||||
#define MAXACTIVITIESPERTASK 20 // The Client has a hard cap of 20 activities per task.
|
||||
#define TASKSLOTEMPTY 0 // This is used to determine if a client's active task slot is empty.
|
||||
|
||||
#define TASKSLOTTASK 0
|
||||
#define TASKSLOTSHAREDTASK 0
|
||||
|
||||
// Command Codes for worldserver ServerOP_ReloadTasks
|
||||
#define RELOADTASKS 0
|
||||
#define RELOADTASKGOALLISTS 1
|
||||
#define RELOADTASKPROXIMITIES 2
|
||||
#define RELOADTASKSETS 3
|
||||
|
||||
typedef enum {
|
||||
METHODSINGLEID = 0,
|
||||
METHODLIST = 1,
|
||||
METHODQUEST = 2
|
||||
} TaskMethodType;
|
||||
|
||||
enum class TaskActivityType : int32_t // task element/objective
|
||||
{
|
||||
Unknown = -1, // hidden
|
||||
None = 0,
|
||||
Deliver = 1,
|
||||
Kill = 2,
|
||||
Loot = 3,
|
||||
SpeakWith = 4,
|
||||
Explore = 5,
|
||||
TradeSkill = 6,
|
||||
Fish = 7,
|
||||
Forage = 8,
|
||||
CastOn = 9,
|
||||
SkillOn = 10,
|
||||
Touch = 11,
|
||||
Collect = 13,
|
||||
GiveCash = 100
|
||||
};
|
||||
|
||||
enum class TaskTimerType
|
||||
{
|
||||
Replay = 0,
|
||||
Request
|
||||
};
|
||||
|
||||
struct ActivityInformation {
|
||||
int step_number;
|
||||
TaskActivityType activity_type;
|
||||
std::string target_name; // name mob, location -- default empty, max length 64
|
||||
std::string item_list; // likely defaults to empty
|
||||
std::string skill_list; // IDs ; separated -- default -1
|
||||
std::string spell_list; // IDs ; separated -- default 0
|
||||
std::string description_override; // overrides auto generated description -- default empty, max length 128
|
||||
int skill_id; // older clients, first id from above
|
||||
int spell_id; // older clients, first id from above
|
||||
int goal_id;
|
||||
TaskMethodType goal_method;
|
||||
int goal_count;
|
||||
int deliver_to_npc;
|
||||
std::vector<int> zone_ids;
|
||||
std::string zones; // IDs ; separated, ZoneID is the first in this list for older clients -- default empty string, max length 64
|
||||
bool optional;
|
||||
|
||||
inline bool CheckZone(int zone_id)
|
||||
{
|
||||
if (zone_ids.empty()) {
|
||||
return true;
|
||||
}
|
||||
return std::find(zone_ids.begin(), zone_ids.end(), zone_id) != zone_ids.end();
|
||||
}
|
||||
|
||||
void SerializeSelector(SerializeBuffer& out, EQ::versions::ClientVersion client_version) const
|
||||
{
|
||||
out.WriteInt32(static_cast<int32_t>(activity_type));
|
||||
out.WriteInt32(0); // solo/group/raid request type? (no longer in live)
|
||||
out.WriteString(target_name); // target name used in objective type string (max 64)
|
||||
|
||||
if (client_version >= EQ::versions::ClientVersion::RoF)
|
||||
{
|
||||
out.WriteLengthString(item_list); // used in objective type string (can be empty for none)
|
||||
out.WriteInt32(activity_type == TaskActivityType::GiveCash ? 1 : goal_count);
|
||||
out.WriteLengthString(skill_list); // used in SkillOn objective type string, "-1" for none
|
||||
out.WriteLengthString(spell_list); // used in CastOn objective type string, "0" for none
|
||||
out.WriteString(zones); // used in objective zone column and task select "begins in" (may have multiple, "0" for "unknown zone", empty for "ALL")
|
||||
}
|
||||
else
|
||||
{
|
||||
out.WriteString(item_list);
|
||||
out.WriteInt32(activity_type == TaskActivityType::GiveCash ? 1 : goal_count);
|
||||
out.WriteInt32(skill_id);
|
||||
out.WriteInt32(spell_id);
|
||||
out.WriteInt32(zone_ids.empty() ? 0 : zone_ids.front());
|
||||
}
|
||||
|
||||
out.WriteString(description_override);
|
||||
|
||||
if (client_version >= EQ::versions::ClientVersion::RoF) {
|
||||
out.WriteString(zones); // serialized again after description (seems unused)
|
||||
}
|
||||
}
|
||||
|
||||
void SerializeObjective(SerializeBuffer& out, EQ::versions::ClientVersion client_version, int done_count) const
|
||||
{
|
||||
// cash objectives internally repurpose goal_count to store cash amount and
|
||||
// done_count as a boolean (should not be sent as actual completed/goal counts)
|
||||
int real_goal_count = goal_count;
|
||||
if (activity_type == TaskActivityType::GiveCash)
|
||||
{
|
||||
done_count = (done_count >= goal_count) ? 1 : 0;
|
||||
real_goal_count = 1;
|
||||
}
|
||||
|
||||
out.WriteInt32(static_cast<int32_t>(activity_type));
|
||||
|
||||
if (client_version >= EQ::versions::ClientVersion::RoF) {
|
||||
out.WriteInt8(optional ? 1 : 0);
|
||||
} else {
|
||||
out.WriteInt32(optional ? 1 : 0);
|
||||
}
|
||||
|
||||
out.WriteInt32(0); // solo/group/raid request type? (no longer in live)
|
||||
out.WriteString(target_name); // target name used in objective type string (max 64)
|
||||
|
||||
if (client_version >= EQ::versions::ClientVersion::RoF)
|
||||
{
|
||||
out.WriteLengthString(item_list); // used in objective type string (can be empty for none)
|
||||
out.WriteInt32(real_goal_count);
|
||||
out.WriteLengthString(skill_list); // used in SkillOn objective type string, "-1" for none
|
||||
out.WriteLengthString(spell_list); // used in CastOn objective type string, "0" for none
|
||||
out.WriteString(zones); // used in objective zone column and task select "begins in" ("0" for "unknown zone", empty for "ALL")
|
||||
}
|
||||
else
|
||||
{
|
||||
out.WriteString(item_list);
|
||||
out.WriteInt32(real_goal_count);
|
||||
out.WriteInt32(skill_id);
|
||||
out.WriteInt32(spell_id);
|
||||
out.WriteInt32(zone_ids.empty() ? 0 : zone_ids.front());
|
||||
}
|
||||
|
||||
out.WriteInt32(0); // unknown id
|
||||
out.WriteString(description_override);
|
||||
out.WriteInt32(done_count);
|
||||
out.WriteInt8(1); // unknown
|
||||
|
||||
if (client_version >= EQ::versions::ClientVersion::RoF)
|
||||
{
|
||||
out.WriteString(zones); // serialized again after description (seems unused)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
ActivitiesSequential = 0,
|
||||
ActivitiesStepped = 1
|
||||
} SequenceType;
|
||||
|
||||
enum class TaskType {
|
||||
Task = 0, // can have at max 1
|
||||
Shared = 1, // can have at max 1
|
||||
Quest = 2, // can have at max 19 or 29 depending on client
|
||||
E = 3 // can have at max 19 or 29 depending on client, not present in live anymore
|
||||
};
|
||||
|
||||
static const uint8 TASK_TYPE_TASK = 0;
|
||||
static const uint8 TASK_TYPE_SHARED = 1;
|
||||
static const uint8 TASK_TYPE_QUEST = 2;
|
||||
|
||||
enum class DurationCode {
|
||||
None = 0,
|
||||
Short = 1,
|
||||
Medium = 2,
|
||||
Long = 3
|
||||
};
|
||||
|
||||
struct TaskInformation {
|
||||
TaskType type;
|
||||
int duration{};
|
||||
DurationCode duration_code; // description for time investment for when duration == 0
|
||||
std::string title{}; // max length 64
|
||||
std::string description{}; // max length 4000, 2048 on Tit
|
||||
std::string reward{};
|
||||
std::string item_link{}; // max length 128 older clients, item link gets own string
|
||||
std::string completion_emote{}; // emote after completing task, yellow. Maybe should make more generic ... but yellow for now!
|
||||
int reward_id{};
|
||||
int cash_reward{}; // Expressed in copper
|
||||
int experience_reward{};
|
||||
int faction_reward{}; // just a npc_faction_id
|
||||
TaskMethodType reward_method;
|
||||
int reward_radiant_crystals;
|
||||
int reward_ebon_crystals;
|
||||
int activity_count{};
|
||||
SequenceType sequence_mode;
|
||||
int last_step{};
|
||||
short min_level{};
|
||||
short max_level{};
|
||||
int level_spread;
|
||||
int min_players;
|
||||
int max_players;
|
||||
bool repeatable{};
|
||||
int replay_timer_seconds;
|
||||
int request_timer_seconds;
|
||||
ActivityInformation activity_information[MAXACTIVITIESPERTASK];
|
||||
|
||||
void SerializeSelector(SerializeBuffer& out, EQ::versions::ClientVersion client_version) const
|
||||
{
|
||||
if (client_version != EQ::versions::ClientVersion::Titanium) {
|
||||
out.WriteFloat(1.0f); // reward multiplier (affects color, <1.0: yellow-red, 1.0: white, >1.0: lightgreen-green)
|
||||
}
|
||||
|
||||
out.WriteUInt32(duration); // task duration (seconds) (0: task_duration_code used, "Unlimited" on live)
|
||||
out.WriteUInt32(static_cast<int>(duration_code)); // 1: Short 2: Medium 3: Long anything else Unlimited (no longer in live)
|
||||
out.WriteString(title); // max 64 with null
|
||||
out.WriteString(description); // max 4000 with null
|
||||
|
||||
if (client_version != EQ::versions::ClientVersion::Titanium) {
|
||||
out.WriteUInt8(0); // 0: no rewards 1: enables "Reward Preview" button
|
||||
}
|
||||
|
||||
// selector only needs to send the first objective to fill description starting zone
|
||||
out.WriteUInt32(std::min(activity_count, 1)); // number of task objectives
|
||||
if (activity_count > 0)
|
||||
{
|
||||
out.WriteUInt32(0); // objective index
|
||||
activity_information[0].SerializeSelector(out, client_version);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
ActivityHidden = 0,
|
||||
ActivityActive = 1,
|
||||
ActivityCompleted = 2
|
||||
} ActivityState;
|
||||
|
||||
struct ClientActivityInformation {
|
||||
int activity_id;
|
||||
int done_count;
|
||||
ActivityState activity_state;
|
||||
bool updated; // Flag so we know if we need to updated the database
|
||||
};
|
||||
|
||||
struct ClientTaskInformation {
|
||||
int slot; // intrusive, but makes things easier :P
|
||||
int task_id;
|
||||
int current_step;
|
||||
int accepted_time;
|
||||
bool updated;
|
||||
ClientActivityInformation activity[MAXACTIVITIESPERTASK];
|
||||
};
|
||||
|
||||
struct CompletedTaskInformation {
|
||||
int task_id;
|
||||
int completed_time;
|
||||
bool activity_done[MAXACTIVITIESPERTASK];
|
||||
};
|
||||
|
||||
namespace Tasks {
|
||||
|
||||
inline int GetActivityStateIdentifier(ActivityState activity_state)
|
||||
{
|
||||
switch (activity_state) {
|
||||
case ActivityHidden:
|
||||
return 0;
|
||||
case ActivityActive:
|
||||
return 1;
|
||||
case ActivityCompleted:
|
||||
return 2;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
inline std::string GetActivityStateDescription(ActivityState activity_state)
|
||||
{
|
||||
switch (activity_state) {
|
||||
case ActivityHidden:
|
||||
return "Hidden";
|
||||
case ActivityActive:
|
||||
return "Active";
|
||||
case ActivityCompleted:
|
||||
return "Completed";
|
||||
default:
|
||||
return "Hidden";
|
||||
}
|
||||
}
|
||||
|
||||
inline int GetTaskTypeIdentifier(TaskType task_type)
|
||||
{
|
||||
switch (task_type) {
|
||||
case TaskType::Task:
|
||||
return 0;
|
||||
case TaskType::Shared:
|
||||
return 1;
|
||||
case TaskType::Quest:
|
||||
return 2;
|
||||
case TaskType::E:
|
||||
return 3;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
inline std::string GetTaskTypeDescription(TaskType task_type)
|
||||
{
|
||||
switch (task_type) {
|
||||
case TaskType::Task:
|
||||
return "Task";
|
||||
case TaskType::Shared:
|
||||
return "Shared";
|
||||
case TaskType::Quest:
|
||||
return "Quest";
|
||||
case TaskType::E:
|
||||
return "E";
|
||||
default:
|
||||
return "Task";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace SharedTaskMessage {
|
||||
constexpr uint16 TASK_ASSIGN_WAIT_REPLAY_TIMER = 8017; // This task can not be assigned to you because you must wait %1d:%2h:%3m before you can do another task of this type.
|
||||
constexpr uint16 COULD_NOT_USE_COMMAND = 8272; // You could not use this command because you are not currently assigned to a shared task.
|
||||
constexpr uint16 AVG_LVL_LOW = 8553; // You can not be assigned this shared task because your party's average level is too low.
|
||||
constexpr uint16 AVG_LVL_HIGH = 8889; // You can not be assigned this shared task because your party's average level is too high.
|
||||
constexpr uint16 LVL_SPREAD_HIGH = 8890; // You can not be assigned this shared task because your party's level spread is too high.
|
||||
constexpr uint16 PARTY_EXCEED_MAX_PLAYER = 8891; // You can not be assigned this shared task because your party exceeds the maximum allowed number of players.
|
||||
constexpr uint16 LEADER_NOT_MEET_REQUIREMENTS = 8892; // You can not be assigned this shared task because the leader does not meet the shared task requirements.
|
||||
constexpr uint16 SHARED_TASK_NOT_MEET_MIN_NUM_PLAYER = 8895; // You can not be assigned this shared task because your party does not contain the minimum required number of players.
|
||||
constexpr uint16 WILL_REMOVE_ZONE_TWO_MIN_RAID_NOT_MIN_NUM_PLAYER = 8908; // %1 will be removed from their zone in two minutes because your raid does not meet the minimum requirement of qualified players.
|
||||
constexpr uint16 WILL_REMOVE_ZONE_TWO_MIN_GROUP_NOT_MIN_NUM_PLAYER = 8909; // %1 will be removed from their zone in two minutes because your group does not meet the minimum requirement of qualified players.
|
||||
constexpr uint16 WILL_REMOVE_AREA_TWO_MIN_RAID_NOT_MIN_NUM_PLAYER = 8910; // %1 will be removed from their area in two minutes because your raid does not meet the minimum requirement of qualified players.
|
||||
constexpr uint16 WILL_REMOVE_AREA_TWO_MIN_GROUP_NOT_MIN_NUM_PLAYER = 8911; // %1 will be removed from their area in two minutes because your group does not meet the minimum requirement of qualified players.
|
||||
constexpr uint16 HAS_REMOVED_ZONE_TWO_MIN_RAID_NOT_MIN_NUM_PLAYER = 8912; // %1 has been removed from their zone because your raid does not meet the minimum requirement of qualified players.
|
||||
constexpr uint16 HAS_REMOVED_ZONE_TWO_MIN_GROUP_NOT_MIN_NUM_PLAYER = 8913; // %1 has been removed from their zone because your group does not meet the minimum requirement of qualified players.
|
||||
constexpr uint16 HAS_REMOVED_AREA_TWO_MIN_RAID_NOT_MIN_NUM_PLAYER = 8914; // %1 has been removed from their area because your raid does not meet the minimum requirement of qualified players.
|
||||
constexpr uint16 HAS_REMOVED_AREA_TWO_MIN_GROUP_NOT_MIN_NUM_PLAYER = 8915; // %1 has been removed from their area because your group does not meet the minimum requirement of qualified players.
|
||||
constexpr uint16 SEND_INVITE_TO = 8916; // Sending a shared task invitation to %1.
|
||||
constexpr uint16 COULD_NOT_BE_INVITED = 8917; // %1 could not be invited to join you.
|
||||
constexpr uint16 YOU_ARE_NOT_LEADER_COMMAND_ISSUE = 8919; // You are not the shared task leader. Only %1 can issue this command.
|
||||
constexpr uint16 SWAP_SENDING_INVITATION_TO = 8920; // Sending an invitation to: %1. They must accept in order to swap party members.
|
||||
constexpr uint16 SWAP_ACCEPTED_OFFER = 8921; // %1 has accepted your offer to join your shared task. Swapping %1 for %2.
|
||||
constexpr uint16 IS_NOT_MEMBER = 8922; // %1 is not a member of this shared task.
|
||||
constexpr uint16 NOT_ALLOW_PLAYER_REMOVE = 8923; // The shared task is not allowing players to be removed from it at this time.
|
||||
constexpr uint16 PLAYER_HAS_BEEN_REMOVED = 8924; // %1 has been removed from your shared task, '%2'.
|
||||
constexpr uint16 TRANSFER_LEADERSHIP_NOT_ONLINE = 8925; // %1 is not currently online. You can only transfer leadership to an online member of the shared task.
|
||||
constexpr uint16 MADE_LEADER = 8926; // %1 has been made the leader for this shared task.
|
||||
constexpr uint16 YOU_MADE_LEADER = 8927; // You have been made the leader of this shared task.
|
||||
constexpr uint16 LEADER_PRINT = 8928; // Shared Task Leader: %1
|
||||
constexpr uint16 MEMBERS_PRINT = 8929; // Shared Task Members: %1
|
||||
constexpr uint16 PLAYER_ACCEPTED_OFFER_JOIN = 8930; // %1 has accepted your offer to join your shared task.
|
||||
constexpr uint16 PLAYER_HAS_BEEN_ADDED = 8931; // %1 has been added to your shared task, '%2'.
|
||||
constexpr uint16 ACCEPTED_OFFER_TO_JOIN_BUT_COULD_NOT = 8932; // %1 accepted your offer to join your shared task but could not.
|
||||
constexpr uint16 PLAYER_DECLINED_OFFER = 8933; // %1 has declined your offer to join your shared task.
|
||||
constexpr uint16 PLAYER_HAS_ASKED_YOU_TO_JOIN = 8934; // %1 has asked you to join the shared task '%2'. Would you like to join?
|
||||
constexpr uint16 NO_REQUEST_BECAUSE_HAVE_ONE = 8935; // You may not request a shared task because you already have one.
|
||||
constexpr uint16 NO_REQUEST_BECAUSE_RAID_HAS_ONE = 8936; // You may not request a shared task because someone in your raid, %1, already has one.
|
||||
constexpr uint16 NO_REQUEST_BECAUSE_GROUP_HAS_ONE = 8937; // You may not request a shared task because someone in your group, %1, already has one.
|
||||
constexpr uint16 YOU_DO_NOT_MEET_REQ_AVAILABLE = 8938; // You do not meet the requirements for any available shared tasks.
|
||||
constexpr uint16 YOUR_RAID_DOES_NOT_MEET_REQ = 8939; // Your raid does not meet the requirements for any available shared tasks.
|
||||
constexpr uint16 YOUR_GROUP_DOES_NOT_MEET_REQ = 8940; // Your group does not meet the requirements for any available shared tasks.
|
||||
constexpr uint16 YOUR_GROUP__RAID_DOES_NOT_MEET_REQ = 8941; // You can not be assigned this shared task because the raid or group does not meet the shared task requirements.
|
||||
constexpr uint16 YOU_NO_LONGER_MEMBER = 8942; // You are no longer a member of the shared task.
|
||||
constexpr uint16 YOU_MAY_NOT_REQUEST_EXPANSION = 8943; // You may not request this shared task because you do not have the required expansion.
|
||||
constexpr uint16 PLAYER_MAY_NOT_REQUEST_EXPANSION = 8944; // You may not request this shared task because %1 does not have the required expansion.
|
||||
constexpr uint16 TWO_MIN_REQ_TASK_TERMINATED = 8945; // If your party does not meet the requirements in two minutes, the shared task will be terminated.
|
||||
constexpr uint16 YOU_MUST_WAIT_REPLAY_TIMER = 8946; // You may not request this shared task because you must wait %1d:%2h:%3m before you can do another task of this type.
|
||||
constexpr uint16 PLAYER_MUST_WAIT_REPLAY_TIMER = 8947; // You may not request this shared task because %1 must wait %2d:%3h:%4m before they can do another task of this type.
|
||||
constexpr uint16 PLAYER_NOW_LEADER = 8948; // %1 is now the leader of your shared task, '%2'.
|
||||
constexpr uint16 HAS_ENDED = 8951; // Your shared task, '%1', has ended.
|
||||
constexpr uint16 YOU_ALREADY_LEADER = 8952; // You are already the leader of the shared task.
|
||||
constexpr uint16 TASK_NO_LONGER_ACTIVE = 8953; // Your shared task, '%1', is no longer active.
|
||||
constexpr uint16 YOU_HAVE_BEEN_ADDED_TO_TASK = 8954; // You have been added to the shared task '%1'.
|
||||
constexpr uint16 YOU_ARE_NOW_LEADER = 8955; // You are now the leader of your shared task, '%1'.
|
||||
constexpr uint16 YOU_HAVE_BEEN_REMOVED = 8956; // You have been removed from the shared task '%1'.
|
||||
constexpr uint16 YOU_ARE_NO_LONGER_A_MEMBER = 8960; // You are no longer a member of the shared task, '%1'.
|
||||
constexpr uint16 YOUR_TASK_NOW_LOCKED = 8961; // Your shared task is now locked. You may no longer add or remove players.
|
||||
constexpr uint16 TASK_NOT_ALLOWING_PLAYERS_AT_TIME = 8962; // The shared task is not allowing players to be added at this time.
|
||||
constexpr uint16 PLAYER_NOT_ONLINE_TO_ADD = 8963; // %1 is not currently online. A player needs to be online to be added to a shared task.
|
||||
constexpr uint16 CANT_ADD_PLAYER_ALREADY_MEMBER = 8964; // You can not add %1 because they are already a member of this shared task.
|
||||
constexpr uint16 CANT_ADD_PLAYER_ALREADY_ASSIGNED = 8965; // You can not add %1 because they are already assigned to another shared task.
|
||||
constexpr uint16 PLAYER_ALREADY_OUTSTANDING_INVITATION_THIS = 8966; // %1 already has an outstanding invitation to join this shared task.
|
||||
constexpr uint16 PLAYER_ALREADY_OUTSTANDING_ANOTHER = 8967; // %1 already has an outstanding invitation to join another shared task. Players may only have one invitation outstanding.
|
||||
constexpr uint16 CANT_ADD_PLAYER_MAX_PLAYERS = 8968; // You can not add another player since you currently have the maximum number of players allowed (%1) in this shared task.
|
||||
constexpr uint16 CANT_ADD_PLAYER_MAX_LEVEL_SPREAD = 8969; // You can not add this player because you would exceed the maximum level spread (%1) for this shared task.
|
||||
constexpr uint16 CANT_ADD_PLAYER_MAX_AVERAGE_LEVEL = 8970; // You can not add this player because you would exceed the maximum average level for this shared task.
|
||||
constexpr uint16 CANT_ADD_PLAYER_FALL_MIN_AVG_LEVEL = 8971; // You can not add this player because you would fall below the minimum average level for this shared task.
|
||||
constexpr uint16 PLAYER_DOES_NOT_OWN_EXPANSION = 8972; // %1 does not own the expansion needed for this shared task.
|
||||
constexpr uint16 CANT_ADD_PLAYER_PARTY_FILTER_REQ_FOR_TASK = 8973; // You can not add this player because your party would no longer meet the filter requirements for this shared task.
|
||||
constexpr uint16 CANT_ADD_PLAYER_ONE_OF_GROUP_RAID_HAS_TASK = 8977; // You can not add %1 because they or one of their group or raid members is in another shared task.
|
||||
constexpr uint16 CANT_JOIN_GROUP_ACTIVE_TASK = 8978; // You can not join that group because you have an active shared task.
|
||||
constexpr uint16 CANT_ADD_PLAYER_REPLAY_TIMER = 8979; // You may not add %1 because they must wait %2d:%3h:%4m before they can do another task of this type.
|
||||
constexpr uint16 CANT_LOOT_BECAUSE_TASK_LOCKED_BELONG = 8980; // You may not loot that corpse because you are not in the shared task the corpse belongs to.
|
||||
constexpr uint16 CANT_ADD_PLAYER_BECAUSE_GROUP_RAID_BELONG_TASK = 8981; // The player could not be added to the raid because they or one of their group members is in a different shared task.
|
||||
constexpr uint16 PLAYER_CANT_ADD_GROUP_BECAUSE_DIFF_TASK = 8982; // %1 can not be added to the group because they are in a different shared task.
|
||||
constexpr uint16 YOU_CANT_ADD_TO_GROUP_BECAUSE_DIFF_TASK = 8983; // You can not be added to the group because you are in a different shared task.
|
||||
constexpr uint16 PLAYER_CANT_ADD_RAID_BECAUSE_DIFF_TASK = 8984; // %1 can not be added to the raid because they are in a different shared task.
|
||||
constexpr uint16 YOU_CANT_ADD_RAID_BECAUSE_DIFF_TASK = 8985; // You can not be added to the raid because you are in a different shared task.
|
||||
constexpr uint16 REPLAY_TIMER_REMAINING = 8987; // '%1' replay timer: %2d:%3h:%4m remaining.
|
||||
constexpr uint16 YOU_NO_CURRENT_REPLAY_TIMERS = 8989; // You do not currently have any task replay timers.
|
||||
constexpr uint16 SURE_QUIT_TASK = 8995; // Are you sure you want to quit the task '%1'?
|
||||
constexpr uint16 SURE_REMOVE_SELF_FROM_TASK = 8996; // Are you sure you want to remove yourself from the shared task '%1'
|
||||
constexpr uint16 TASK_ASSIGN_WAIT_REQUEST_TIMER = 14506; // This task can not be assigned to you because you must wait %1d:%2h:%3m before you can request another task of this type.
|
||||
constexpr uint16 REQUEST_TIMER_REMAINING = 14507; // '%1' request timer: %2d:%3h:%4m remaining.
|
||||
constexpr uint16 YOU_MUST_WAIT_REQUEST_TIMER = 14508; // You may not request this shared task because you must wait %1d:%2h:%3m before you can request another task of this type.
|
||||
constexpr uint16 RECEIVED_REQUEST_TIMER = 14509; // You have received a request timer for '%1': %2d:%3h:%4m remaining.
|
||||
constexpr uint16 RECEIVED_REPLAY_TIMER = 14510; // You have received a replay timer for '%1': %2d:%3h:%4m remaining.
|
||||
constexpr uint16 PLAYER_MUST_WAIT_REQUEST_TIMER = 14511; // You may not request this shared task because %1 must wait %2d:%3h:%4m before they can request another task of this type.
|
||||
constexpr uint16 CANT_ADD_PLAYER_REQUEST_TIMER = 14512; // You may not add %1 because they must wait %2d:%3h:%4m before they can request another task of this type.
|
||||
|
||||
// for eqstrs not in current emu clients (some are also used by non-shared tasks)
|
||||
constexpr auto GetEQStr(uint16 eqstr_id)
|
||||
{
|
||||
switch (eqstr_id)
|
||||
{
|
||||
case SharedTaskMessage::COULD_NOT_USE_COMMAND:
|
||||
return "You could not use this command because you are not currently assigned to a shared task.";
|
||||
case SharedTaskMessage::TASK_ASSIGN_WAIT_REQUEST_TIMER:
|
||||
return "This task can not be assigned to you because you must wait {}d:{}h:{}m before you can request another task of this type.";
|
||||
case SharedTaskMessage::REQUEST_TIMER_REMAINING:
|
||||
return "'{}' request timer: {}d:{}h:{}m remaining.";
|
||||
case SharedTaskMessage::YOU_MUST_WAIT_REQUEST_TIMER:
|
||||
return "You may not request this shared task because you must wait {}d:{}h:{}m before you can request another task of this type.";
|
||||
case SharedTaskMessage::RECEIVED_REQUEST_TIMER:
|
||||
return "You have received a request timer for '{}': {}d:{}h:{}m remaining.";
|
||||
case SharedTaskMessage::RECEIVED_REPLAY_TIMER:
|
||||
return "You have received a replay timer for '{}': {}d:{}h:{}m remaining.";
|
||||
case SharedTaskMessage::PLAYER_MUST_WAIT_REQUEST_TIMER:
|
||||
return "You may not request this shared task because {} must wait {}d:{}h:{}m before they can request another task of this type.";
|
||||
case SharedTaskMessage::CANT_ADD_PLAYER_REQUEST_TIMER:
|
||||
return "You may not add {} because they must wait {}d:{}h:{}m before they can request another task of this type.";
|
||||
default:
|
||||
LogTasks("[GetEQStr] Unhandled eqstr id [{}]", eqstr_id);
|
||||
break;
|
||||
}
|
||||
return "Unknown EQStr";
|
||||
}
|
||||
}
|
||||
|
||||
#endif //EQEMU_TASKS_H
|
||||
@ -34,7 +34,7 @@
|
||||
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
|
||||
*/
|
||||
|
||||
#define CURRENT_BINARY_DATABASE_VERSION 9168
|
||||
#define CURRENT_BINARY_DATABASE_VERSION 9172
|
||||
|
||||
#ifdef BOTS
|
||||
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9028
|
||||
|
||||
@ -560,12 +560,14 @@ OP_TaskActivityComplete=0x71cd
|
||||
OP_AcceptNewTask=0x394d
|
||||
OP_CancelTask=0x0c7f
|
||||
OP_TaskMemberList=0x748e # Was 0x1656
|
||||
OP_OpenNewTasksWindow=0x436c # Was 0x11de
|
||||
OP_TaskSelectWindow=0x436c
|
||||
OP_SharedTaskSelectWindow=0x436c
|
||||
OP_AvaliableTask=0x2bf8 # Was 0x2377
|
||||
OP_TaskHistoryRequest=0x6cf6
|
||||
OP_TaskHistoryReply=0x25eb
|
||||
OP_DeclineAllTasks=0x0000
|
||||
OP_TaskRequestTimer=0x4b76
|
||||
OP_SharedTaskQuit=0x0000
|
||||
|
||||
# Title opcodes
|
||||
OP_NewTitlesAvailable=0x45d1
|
||||
|
||||
@ -567,13 +567,26 @@ OP_CompletedTasks=0x4eba
|
||||
OP_TaskActivityComplete=0x5e19
|
||||
OP_AcceptNewTask=0x0a23
|
||||
OP_CancelTask=0x39f0
|
||||
OP_TaskMemberList=0x5727
|
||||
OP_OpenNewTasksWindow=0x48a2
|
||||
OP_AvaliableTask=0x36e8
|
||||
OP_TaskHistoryRequest=0x5f1c
|
||||
OP_TaskHistoryReply=0x3d05
|
||||
OP_DeclineAllTasks=0x0000
|
||||
OP_TaskRequestTimer=0x7a48
|
||||
OP_TaskSelectWindow=0x705b
|
||||
|
||||
# Shared Tasks
|
||||
OP_SharedTaskMemberList=0x1e7d #
|
||||
OP_SharedTaskRemovePlayer=0x4865 # /taskremoveplayer
|
||||
OP_SharedTaskAddPlayer=0x36e8 # /taskaddplayer
|
||||
OP_SharedTaskMakeLeader=0x37f2 # /taskmakeleader
|
||||
OP_SharedTaskInvite=0x3444 # Dialog window
|
||||
OP_SharedTaskInviteResponse=0x7582 # Dialog window response
|
||||
OP_SharedTaskAcceptNew=0x6646 #
|
||||
OP_SharedTaskMemberChange=0x0119 #
|
||||
OP_TaskTimers=0x2b0f # /tasktimers
|
||||
OP_SharedTaskQuit=0x322e # /taskquit
|
||||
OP_SharedTaskSelectWindow=0x48a2
|
||||
OP_SharedTaskPlayerList=0x5727 # /taskplayerlist
|
||||
|
||||
# Title opcodes
|
||||
OP_NewTitlesAvailable=0x0d32
|
||||
|
||||
@ -527,8 +527,6 @@ OP_LDoNOpen=0x6129 # C
|
||||
|
||||
# Task packets
|
||||
OP_TaskActivityComplete=0x4df0 # C
|
||||
OP_TaskMemberList=0x34ed # C
|
||||
OP_OpenNewTasksWindow=0x4dd5 # C
|
||||
OP_AvaliableTask=0x2136 # C
|
||||
OP_AcceptNewTask=0x5832 # C
|
||||
OP_TaskHistoryRequest=0x29d7 # C
|
||||
@ -536,7 +534,21 @@ OP_TaskHistoryReply=0x3d2a # C
|
||||
OP_CancelTask=0x726b # C
|
||||
OP_DeclineAllTasks=0x0000 #
|
||||
OP_TaskRequestTimer=0x2e70
|
||||
OP_TaskSelectWindow=0x009b
|
||||
|
||||
# Shared Tasks
|
||||
OP_SharedTaskMemberList=0x55f4 #
|
||||
OP_SharedTaskRemovePlayer=0x4a12 # /taskremoveplayer
|
||||
OP_SharedTaskAddPlayer=0x2136 # /taskaddplayer
|
||||
OP_SharedTaskMakeLeader=0x1da9 # /taskmakeleader
|
||||
OP_SharedTaskInvite=0x40c5 # Dialog window
|
||||
OP_SharedTaskInviteResponse=0x7abb # Dialog window response
|
||||
OP_SharedTaskAcceptNew=0x4751 # Not sure why this has a separate handler
|
||||
OP_SharedTaskMemberChange=0x98f6 # Not sure yet?
|
||||
OP_TaskTimers=0x01cb # /tasktimers
|
||||
OP_SharedTaskQuit=0x5854 # /taskquit
|
||||
OP_SharedTaskSelectWindow=0x4dd5
|
||||
OP_SharedTaskPlayerList=0x34ed # /taskplayerlist
|
||||
|
||||
OP_Shroud=0x6d1f
|
||||
OP_ShroudRemove=0x17f6
|
||||
|
||||
@ -496,7 +496,8 @@ OP_LDoNOpen=0x4b92 #Xinu 03/19/09
|
||||
|
||||
#Task packets
|
||||
OP_TaskActivityComplete=0x7338 #
|
||||
OP_OpenNewTasksWindow=0x17C3 #
|
||||
OP_SharedTaskSelectWindow=0x17C3
|
||||
OP_TaskSelectWindow=0x17C3
|
||||
OP_AvaliableTask=0x5d1d #Xinu 03/19/09
|
||||
OP_AcceptNewTask=0x66A8 #
|
||||
OP_TaskHistoryRequest=0x3035 #
|
||||
@ -511,7 +512,7 @@ OP_TaskMakeLeader=0x5050
|
||||
OP_TaskAddPlayer=0x5d1d
|
||||
OP_TaskRemovePlayer=0x516f
|
||||
OP_TaskPlayerList=0x0ad6
|
||||
OP_TaskQuit=0x2c8c
|
||||
OP_SharedTaskQuit=0x2c8c
|
||||
OP_TaskRequestTimer=0x0b08
|
||||
|
||||
#Title opcodes
|
||||
|
||||
@ -459,8 +459,7 @@ OP_TaskActivityComplete=0x54eb
|
||||
OP_CompletedTasks=0x76a2 # ShowEQ 10/27/05
|
||||
OP_TaskDescription=0x5ef7 # ShowEQ 10/27/05
|
||||
OP_TaskActivity=0x682d # ShowEQ 10/27/05
|
||||
OP_TaskMemberList=0x722f #not sure
|
||||
OP_OpenNewTasksWindow=0x5e7c #combined with OP_AvaliableTask I think
|
||||
OP_TaskSelectWindow=0x5e7c
|
||||
OP_AvaliableTask=0x0000
|
||||
OP_AcceptNewTask=0x207f
|
||||
OP_TaskHistoryRequest=0x5df4
|
||||
@ -473,11 +472,22 @@ OP_TaskMemberChange=0x5886
|
||||
OP_TaskMakeLeader=0x1b25
|
||||
OP_TaskAddPlayer=0x6bc4
|
||||
OP_TaskRemovePlayer=0x37b9
|
||||
OP_TaskPlayerList=0x3961
|
||||
OP_TaskQuit=0x35dd
|
||||
OP_TaskRequestTimer=0x6a1d
|
||||
#task complete related: 0x0000 (24 bytes), 0x0000 (8 bytes), 0x0000 (4 bytes)
|
||||
|
||||
# Shared Tasks
|
||||
OP_SharedTaskMemberList=0x722f #
|
||||
OP_SharedTaskRemovePlayer=0x37b9 # /taskremoveplayer
|
||||
OP_SharedTaskAddPlayer=0x6934 # /taskaddplayer
|
||||
OP_SharedTaskMakeLeader=0x1b25 # /taskmakeleader
|
||||
OP_SharedTaskInvite=0x79b4 # Dialog window
|
||||
OP_SharedTaskInviteResponse=0x0358 # Dialog window response
|
||||
OP_SharedTaskAcceptNew=0x194d # Not sure why this has a separate handler
|
||||
OP_SharedTaskMemberChange=0x5886 # Not sure yet?
|
||||
OP_TaskTimers=0x6a1d # /tasktimers
|
||||
OP_SharedTaskQuit=0x35dd # /taskquit
|
||||
OP_SharedTaskSelectWindow=0x013f
|
||||
OP_SharedTaskPlayerList=0x3961 # /taskplayerlist
|
||||
|
||||
OP_RequestClientZoneChange=0x7834 # ShowEQ 10/27/05
|
||||
|
||||
|
||||
@ -551,8 +551,6 @@ OP_LDoNInspect=0x0aaa
|
||||
|
||||
# Task packets
|
||||
OP_TaskActivityComplete=0x5832 # C
|
||||
OP_TaskMemberList=0x66ba # C
|
||||
OP_OpenNewTasksWindow=0x98f6 # C
|
||||
OP_AvaliableTask=0x6255 # C Mispelled?
|
||||
OP_AcceptNewTask=0x17d5 # C
|
||||
OP_TaskHistoryRequest=0x547c # C
|
||||
@ -560,6 +558,21 @@ OP_TaskHistoryReply=0x4524 # C
|
||||
OP_CancelTask=0x3bf5 # C
|
||||
OP_DeclineAllTasks=0x0000 #
|
||||
OP_TaskRequestTimer=0x719e
|
||||
OP_TaskSelectWindow=0x7309
|
||||
|
||||
# Shared Tasks
|
||||
OP_SharedTaskMemberList=0x584e #
|
||||
OP_SharedTaskRemovePlayer=0x18e2 # /taskremoveplayer
|
||||
OP_SharedTaskAddPlayer=0x6255 # /taskaddplayer
|
||||
OP_SharedTaskMakeLeader=0x5933 # /taskmakeleader
|
||||
OP_SharedTaskInvite=0x55f4 # Dialog window
|
||||
OP_SharedTaskInviteResponse=0x26e5 # Dialog window response
|
||||
OP_SharedTaskAcceptNew=0x6ded # Not sure why this has a separate handler
|
||||
OP_SharedTaskMemberChange=0x1402 # Not sure yet?
|
||||
OP_TaskTimers=0x09b4 # /tasktimers
|
||||
OP_SharedTaskQuit=0x6aba # /taskquit
|
||||
OP_SharedTaskSelectWindow=0x98f6
|
||||
OP_SharedTaskPlayerList=0x66ba # /taskplayerlist
|
||||
|
||||
# Title opcodes
|
||||
OP_NewTitlesAvailable=0x4b49 # C
|
||||
|
||||
@ -422,6 +422,10 @@
|
||||
9166|2021_02_12_dynamic_zone_members.sql|SHOW TABLES LIKE 'dynamic_zone_members'|empty|
|
||||
9167|2021_06_06_beastlord_pets.sql|SHOW TABLES LIKE 'pets_beastlord_data'|empty|
|
||||
9168|2021_08_31_pvp_duration.sql|SHOW COLUMNS FROM `spells_new` LIKE 'pvp_duration'|empty|
|
||||
9169|2021_06_06_dynamic_zone_moved_columns.sql|SELECT * FROM db_version WHERE version >= 9169|empty|
|
||||
9170|2021_03_03_instance_safereturns.sql|SHOW TABLES LIKE 'character_instance_safereturns'|empty|
|
||||
9171|2021_03_30_remove_dz_is_current_member.sql|SHOW COLUMNS FROM `dynamic_zone_members` LIKE 'is_current_member'|not_empty|
|
||||
9172|2021_05_21_shared_tasks.sql|SHOW TABLES LIKE 'shared_tasks'|empty|
|
||||
|
||||
# Upgrade conditions:
|
||||
# This won't be needed after this system is implemented, but it is used database that are not
|
||||
|
||||
13
utils/sql/git/required/2021_03_03_instance_safereturns.sql
Normal file
13
utils/sql/git/required/2021_03_03_instance_safereturns.sql
Normal file
@ -0,0 +1,13 @@
|
||||
CREATE TABLE `character_instance_safereturns` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`character_id` int(10) unsigned NOT NULL,
|
||||
`instance_zone_id` int(11) NOT NULL DEFAULT 0,
|
||||
`instance_id` int(11) NOT NULL DEFAULT 0,
|
||||
`safe_zone_id` int(11) NOT NULL DEFAULT 0,
|
||||
`safe_x` float NOT NULL DEFAULT 0,
|
||||
`safe_y` float NOT NULL DEFAULT 0,
|
||||
`safe_z` float NOT NULL DEFAULT 0,
|
||||
`safe_heading` float NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `character_id` (`character_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
@ -0,0 +1,6 @@
|
||||
-- remove any non-current members for new behavior
|
||||
DELETE FROM `dynamic_zone_members`
|
||||
WHERE is_current_member = 0;
|
||||
|
||||
ALTER TABLE `dynamic_zone_members`
|
||||
DROP COLUMN `is_current_member`;
|
||||
97
utils/sql/git/required/2021_05_21_shared_tasks.sql
Normal file
97
utils/sql/git/required/2021_05_21_shared_tasks.sql
Normal file
@ -0,0 +1,97 @@
|
||||
-- shared task tables
|
||||
CREATE TABLE `shared_tasks`
|
||||
(
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`task_id` int(11) DEFAULT NULL,
|
||||
`accepted_time` datetime DEFAULT NULL,
|
||||
`expire_time` datetime DEFAULT NULL,
|
||||
`completion_time` datetime DEFAULT NULL,
|
||||
`is_locked` tinyint(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE `shared_task_members`
|
||||
(
|
||||
`shared_task_id` bigint(20) NOT NULL,
|
||||
`character_id` bigint(20) NOT NULL,
|
||||
`is_leader` tinyint(4) DEFAULT NULL,
|
||||
PRIMARY KEY (`shared_task_id`, `character_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE `shared_task_activity_state`
|
||||
(
|
||||
`shared_task_id` bigint(20) NOT NULL,
|
||||
`activity_id` int(11) NOT NULL,
|
||||
`done_count` int(11) DEFAULT NULL,
|
||||
`updated_time` datetime DEFAULT NULL,
|
||||
`completed_time` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`shared_task_id`, `activity_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE `shared_task_dynamic_zones`
|
||||
(
|
||||
`shared_task_id` bigint(20) NOT NULL,
|
||||
`dynamic_zone_id` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`shared_task_id`, `dynamic_zone_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
-- completed shared task tables - simply stores completed for reporting and logging
|
||||
|
||||
CREATE TABLE `completed_shared_tasks`
|
||||
(
|
||||
`id` bigint(20) NOT NULL,
|
||||
`task_id` int(11) DEFAULT NULL,
|
||||
`accepted_time` datetime DEFAULT NULL,
|
||||
`expire_time` datetime DEFAULT NULL,
|
||||
`completion_time` datetime DEFAULT NULL,
|
||||
`is_locked` tinyint(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE `completed_shared_task_members`
|
||||
(
|
||||
`shared_task_id` bigint(20) NOT NULL,
|
||||
`character_id` bigint(20) NOT NULL,
|
||||
`is_leader` tinyint(4) DEFAULT NULL,
|
||||
PRIMARY KEY (`shared_task_id`, `character_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE `completed_shared_task_activity_state`
|
||||
(
|
||||
`shared_task_id` bigint(20) NOT NULL,
|
||||
`activity_id` int(11) NOT NULL,
|
||||
`done_count` int(11) DEFAULT NULL,
|
||||
`updated_time` datetime DEFAULT NULL,
|
||||
`completed_time` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`shared_task_id`, `activity_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
-- tasks
|
||||
|
||||
ALTER TABLE `tasks`
|
||||
ADD COLUMN `level_spread` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `maxlevel`,
|
||||
ADD COLUMN `min_players` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `level_spread`,
|
||||
ADD COLUMN `max_players` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `min_players`,
|
||||
ADD COLUMN `replay_timer_seconds` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `completion_emote`,
|
||||
ADD COLUMN `request_timer_seconds` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `replay_timer_seconds`;
|
||||
|
||||
-- character timers
|
||||
|
||||
CREATE TABLE `character_task_timers`
|
||||
(
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`character_id` int(10) unsigned NOT NULL DEFAULT 0,
|
||||
`task_id` int(10) unsigned NOT NULL DEFAULT 0,
|
||||
`timer_type` int(11) NOT NULL DEFAULT 0,
|
||||
`expire_time` datetime NOT NULL DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `character_id` (`character_id`),
|
||||
KEY `task_id` (`task_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
ALTER TABLE `tasks`
|
||||
CHANGE COLUMN `completion_emote` `completion_emote` VARCHAR (512) NOT NULL DEFAULT '' COLLATE 'latin1_swedish_ci' AFTER `faction_reward`;
|
||||
|
||||
ALTER TABLE `tasks`
|
||||
ADD COLUMN `reward_radiant_crystals` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `rewardmethod`,
|
||||
ADD COLUMN `reward_ebon_crystals` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `reward_radiant_crystals`;
|
||||
@ -0,0 +1,23 @@
|
||||
ALTER TABLE `dynamic_zones`
|
||||
ADD COLUMN `uuid` VARCHAR(36) NOT NULL COLLATE 'latin1_swedish_ci' AFTER `type`,
|
||||
ADD COLUMN `name` VARCHAR(128) NOT NULL DEFAULT '' COLLATE 'latin1_swedish_ci' AFTER `uuid`,
|
||||
ADD COLUMN `leader_id` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `name`,
|
||||
ADD COLUMN `min_players` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `leader_id`,
|
||||
ADD COLUMN `max_players` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `min_players`;
|
||||
|
||||
-- migrate any currently active expeditions
|
||||
UPDATE dynamic_zones
|
||||
INNER JOIN expeditions ON expeditions.dynamic_zone_id = dynamic_zones.id
|
||||
SET
|
||||
dynamic_zones.uuid = expeditions.uuid,
|
||||
dynamic_zones.name = expeditions.expedition_name,
|
||||
dynamic_zones.leader_id = expeditions.leader_id,
|
||||
dynamic_zones.min_players = expeditions.min_players,
|
||||
dynamic_zones.max_players = expeditions.max_players;
|
||||
|
||||
ALTER TABLE `expeditions`
|
||||
DROP COLUMN `uuid`,
|
||||
DROP COLUMN `expedition_name`,
|
||||
DROP COLUMN `leader_id`,
|
||||
DROP COLUMN `min_players`,
|
||||
DROP COLUMN `max_players`;
|
||||
@ -8,12 +8,11 @@ SET(world_sources
|
||||
clientlist.cpp
|
||||
console.cpp
|
||||
dynamic_zone.cpp
|
||||
dynamic_zone_manager.cpp
|
||||
eql_config.cpp
|
||||
eqemu_api_world_data_service.cpp
|
||||
expedition.cpp
|
||||
expedition_database.cpp
|
||||
expedition_message.cpp
|
||||
expedition_state.cpp
|
||||
launcher_link.cpp
|
||||
launcher_list.cpp
|
||||
lfplist.cpp
|
||||
@ -21,6 +20,8 @@ SET(world_sources
|
||||
login_server_list.cpp
|
||||
main.cpp
|
||||
queryserv.cpp
|
||||
shared_task_manager.cpp
|
||||
shared_task_world_messaging.cpp
|
||||
ucs.cpp
|
||||
web_interface.cpp
|
||||
web_interface_eqw.cpp
|
||||
@ -44,18 +45,19 @@ SET(world_headers
|
||||
clientlist.h
|
||||
console.h
|
||||
dynamic_zone.h
|
||||
dynamic_zone_manager.h
|
||||
eql_config.h
|
||||
eqemu_api_world_data_service.h
|
||||
expedition.h
|
||||
expedition_database.h
|
||||
expedition_message.h
|
||||
expedition_state.h
|
||||
launcher_link.h
|
||||
launcher_list.h
|
||||
lfplist.h
|
||||
login_server.h
|
||||
login_server_list.h
|
||||
queryserv.h
|
||||
shared_task_manager.h
|
||||
shared_task_world_messaging.h
|
||||
sof_char_create_data.h
|
||||
ucs.h
|
||||
web_interface.h
|
||||
|
||||
@ -121,7 +121,7 @@ Client::Client(EQStreamInterface* ieqs)
|
||||
|
||||
m_ClientVersion = eqs->ClientVersion();
|
||||
m_ClientVersionBit = EQ::versions::ConvertClientVersionToClientVersionBit(m_ClientVersion);
|
||||
|
||||
|
||||
numclients++;
|
||||
}
|
||||
|
||||
@ -833,19 +833,12 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
|
||||
|
||||
if(instance_id > 0)
|
||||
{
|
||||
if(!database.VerifyInstanceAlive(instance_id, GetCharID()))
|
||||
if (!database.VerifyInstanceAlive(instance_id, GetCharID()) ||
|
||||
!database.VerifyZoneInstance(zone_id, instance_id))
|
||||
{
|
||||
zone_id = database.MoveCharacterToBind(charid);
|
||||
zone_id = database.MoveCharacterToInstanceSafeReturn(charid, zone_id, instance_id);
|
||||
instance_id = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!database.VerifyZoneInstance(zone_id, instance_id))
|
||||
{
|
||||
zone_id = database.MoveCharacterToBind(charid);
|
||||
instance_id = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_player_zoning) {
|
||||
@ -1154,34 +1147,23 @@ void Client::EnterWorld(bool TryBootup) {
|
||||
return;
|
||||
|
||||
ZoneServer* zone_server = nullptr;
|
||||
if(instance_id > 0)
|
||||
if (instance_id > 0)
|
||||
{
|
||||
if(database.VerifyInstanceAlive(instance_id, GetCharID()))
|
||||
{
|
||||
if(database.VerifyZoneInstance(zone_id, instance_id))
|
||||
{
|
||||
zone_server = zoneserver_list.FindByInstanceID(instance_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
instance_id = 0;
|
||||
zone_server = nullptr;
|
||||
database.MoveCharacterToBind(GetCharID());
|
||||
TellClientZoneUnavailable();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!database.VerifyInstanceAlive(instance_id, GetCharID()) ||
|
||||
!database.VerifyZoneInstance(zone_id, instance_id))
|
||||
{
|
||||
instance_id = 0;
|
||||
zone_server = nullptr;
|
||||
database.MoveCharacterToBind(GetCharID());
|
||||
database.MoveCharacterToInstanceSafeReturn(GetCharID(), zone_id, instance_id);
|
||||
TellClientZoneUnavailable();
|
||||
return;
|
||||
}
|
||||
|
||||
zone_server = zoneserver_list.FindByInstanceID(instance_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
zone_server = zoneserver_list.FindByZoneID(zone_id);
|
||||
}
|
||||
|
||||
const char *zone_name = ZoneName(zone_id, true);
|
||||
if (zone_server) {
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include "clientlist.h"
|
||||
#include "login_server.h"
|
||||
#include "login_server_list.h"
|
||||
#include "shared_task_manager.h"
|
||||
#include "worlddb.h"
|
||||
#include "zoneserver.h"
|
||||
#include "world_config.h"
|
||||
@ -30,6 +31,7 @@ extern uint32 numplayers;
|
||||
extern LoginServerList loginserverlist;
|
||||
extern ClientList client_list;
|
||||
extern volatile bool RunLoops;
|
||||
extern SharedTaskManager shared_task_manager;
|
||||
|
||||
/**
|
||||
* @param in_id
|
||||
@ -249,6 +251,8 @@ void ClientListEntry::LeavingZone(ZoneServer *iZS, CLE_Status iOnline)
|
||||
}
|
||||
SetOnline(iOnline);
|
||||
|
||||
shared_task_manager.RemoveActiveInvitationByCharacterID(CharID());
|
||||
|
||||
if (pzoneserver) {
|
||||
pzoneserver->RemovePlayer();
|
||||
LSUpdate(pzoneserver);
|
||||
|
||||
@ -332,30 +332,91 @@ void ClientList::CLCheckStale() {
|
||||
}
|
||||
}
|
||||
|
||||
void ClientList::ClientUpdate(ZoneServer* zoneserver, ServerClientList_Struct* scl) {
|
||||
LinkedListIterator<ClientListEntry*> iterator(clientlist);
|
||||
ClientListEntry* cle;
|
||||
void ClientList::ClientUpdate(ZoneServer *zoneserver, ServerClientList_Struct *scl)
|
||||
{
|
||||
LinkedListIterator<ClientListEntry *> iterator(clientlist);
|
||||
ClientListEntry *cle;
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
while (iterator.MoreElements()) {
|
||||
if (iterator.GetData()->GetID() == scl->wid) {
|
||||
cle = iterator.GetData();
|
||||
if (scl->remove == 2){
|
||||
if (scl->remove == 2) {
|
||||
cle->LeavingZone(zoneserver, CLE_Status::Offline);
|
||||
}
|
||||
else if (scl->remove == 1)
|
||||
else if (scl->remove == 1) {
|
||||
cle->LeavingZone(zoneserver, CLE_Status::Zoning);
|
||||
else
|
||||
}
|
||||
else {
|
||||
cle->Update(zoneserver, scl);
|
||||
}
|
||||
return;
|
||||
}
|
||||
iterator.Advance();
|
||||
}
|
||||
if (scl->remove == 2)
|
||||
if (scl->remove == 2) {
|
||||
cle = new ClientListEntry(GetNextCLEID(), zoneserver, scl, CLE_Status::Online);
|
||||
else if (scl->remove == 1)
|
||||
}
|
||||
else if (scl->remove == 1) {
|
||||
cle = new ClientListEntry(GetNextCLEID(), zoneserver, scl, CLE_Status::Zoning);
|
||||
else
|
||||
}
|
||||
else {
|
||||
cle = new ClientListEntry(GetNextCLEID(), zoneserver, scl, CLE_Status::InZone);
|
||||
}
|
||||
|
||||
LogClientListDetail(
|
||||
"[ClientUpdate] "
|
||||
" remove [{}]"
|
||||
" wid [{}]"
|
||||
" IP [{}]"
|
||||
" zone [{}]"
|
||||
" instance_id [{}]"
|
||||
" Admin [{}]"
|
||||
" charid [{}]"
|
||||
" name [{}]"
|
||||
" AccountID [{}]"
|
||||
" AccountName [{}]"
|
||||
" LSAccountID [{}]"
|
||||
" lskey [{}]"
|
||||
" race [{}]"
|
||||
" class_ [{}]"
|
||||
" level [{}]"
|
||||
" anon [{}]"
|
||||
" tellsoff [{}]"
|
||||
" guild_id [{}]"
|
||||
" LFG [{}]"
|
||||
" gm [{}]"
|
||||
" ClientVersion [{}]"
|
||||
" LFGFromLevel [{}]"
|
||||
" LFGToLevel [{}]"
|
||||
" LFGMatchFilter [{}]"
|
||||
" LFGComments [{}]",
|
||||
scl->remove,
|
||||
scl->wid,
|
||||
scl->IP,
|
||||
scl->zone,
|
||||
scl->instance_id,
|
||||
scl->Admin,
|
||||
scl->charid,
|
||||
scl->name,
|
||||
scl->AccountID,
|
||||
scl->AccountName,
|
||||
scl->LSAccountID,
|
||||
scl->lskey,
|
||||
scl->race,
|
||||
scl->class_,
|
||||
scl->level,
|
||||
scl->anon,
|
||||
scl->tellsoff,
|
||||
scl->guild_id,
|
||||
scl->LFG,
|
||||
scl->gm,
|
||||
scl->ClientVersion,
|
||||
scl->LFGFromLevel,
|
||||
scl->LFGToLevel,
|
||||
scl->LFGMatchFilter,
|
||||
scl->LFGComments
|
||||
);
|
||||
|
||||
clientlist.Insert(cle);
|
||||
zoneserver->ChangeWID(scl->charid, cle->GetID());
|
||||
}
|
||||
@ -1508,3 +1569,73 @@ void ClientList::GetClientList(Json::Value &response)
|
||||
Iterator.Advance();
|
||||
}
|
||||
}
|
||||
|
||||
void ClientList::SendCharacterMessage(uint32_t character_id, int chat_type, const std::string& message)
|
||||
{
|
||||
auto character = FindCLEByCharacterID(character_id);
|
||||
SendCharacterMessage(character, chat_type, message);
|
||||
}
|
||||
|
||||
void ClientList::SendCharacterMessage(const std::string& character_name, int chat_type, const std::string& message)
|
||||
{
|
||||
auto character = FindCharacter(character_name.c_str());
|
||||
SendCharacterMessage(character, chat_type, message);
|
||||
}
|
||||
|
||||
void ClientList::SendCharacterMessage(ClientListEntry* character, int chat_type, const std::string& message)
|
||||
{
|
||||
if (!character || !character->Server())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t pack_size = sizeof(CZMessagePlayer_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_CZMessagePlayer, pack_size);
|
||||
auto buf = reinterpret_cast<CZMessagePlayer_Struct*>(pack->pBuffer);
|
||||
buf->type = chat_type;
|
||||
strn0cpy(buf->character_name, character->name(), sizeof(buf->character_name));
|
||||
strn0cpy(buf->message, message.c_str(), sizeof(buf->message));
|
||||
|
||||
character->Server()->SendPacket(pack.get());
|
||||
}
|
||||
|
||||
void ClientList::SendCharacterMessageID(uint32_t character_id,
|
||||
int chat_type, int eqstr_id, std::initializer_list<std::string> args)
|
||||
{
|
||||
auto character = FindCLEByCharacterID(character_id);
|
||||
SendCharacterMessageID(character, chat_type, eqstr_id, args);
|
||||
}
|
||||
|
||||
void ClientList::SendCharacterMessageID(const std::string& character_name,
|
||||
int chat_type, int eqstr_id, std::initializer_list<std::string> args)
|
||||
{
|
||||
auto character = FindCharacter(character_name.c_str());
|
||||
SendCharacterMessageID(character, chat_type, eqstr_id, args);
|
||||
}
|
||||
|
||||
void ClientList::SendCharacterMessageID(ClientListEntry* character,
|
||||
int chat_type, int eqstr_id, std::initializer_list<std::string> args)
|
||||
{
|
||||
if (!character || !character->Server())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SerializeBuffer serialized_args;
|
||||
for (const auto& arg : args)
|
||||
{
|
||||
serialized_args.WriteString(arg);
|
||||
}
|
||||
|
||||
uint32_t args_size = static_cast<uint32_t>(serialized_args.size());
|
||||
uint32_t pack_size = sizeof(CZClientMessageString_Struct) + args_size;
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_CZClientMessageString, pack_size);
|
||||
auto buf = reinterpret_cast<CZClientMessageString_Struct*>(pack->pBuffer);
|
||||
buf->string_id = eqstr_id;
|
||||
buf->chat_type = chat_type;
|
||||
strn0cpy(buf->character_name, character->name(), sizeof(buf->character_name));
|
||||
buf->args_size = args_size;
|
||||
memcpy(buf->args, serialized_args.buffer(), serialized_args.size());
|
||||
|
||||
character->Server()->SendPacket(pack.get());
|
||||
}
|
||||
|
||||
@ -72,6 +72,13 @@ public:
|
||||
|
||||
void GetClientList(Json::Value &response);
|
||||
|
||||
void SendCharacterMessage(uint32_t character_id, int chat_type, const std::string& message);
|
||||
void SendCharacterMessage(const std::string& character_name, int chat_type, const std::string& message);
|
||||
void SendCharacterMessage(ClientListEntry* character, int chat_type, const std::string& message);
|
||||
void SendCharacterMessageID(uint32_t character_id, int chat_type, int eqstr_id, std::initializer_list<std::string> args = {});
|
||||
void SendCharacterMessageID(const std::string& character_name, int chat_type, int eqstr_id, std::initializer_list<std::string> args = {});
|
||||
void SendCharacterMessageID(ClientListEntry* character, int chat_type, int eqstr_id, std::initializer_list<std::string> args = {});
|
||||
|
||||
private:
|
||||
void OnTick(EQ::Timer *t);
|
||||
inline uint32 GetNextCLEID() { return NextCLEID++; }
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
#include "dynamic_zone.h"
|
||||
#include "expedition.h"
|
||||
#include "expedition_state.h"
|
||||
#include "cliententry.h"
|
||||
#include "clientlist.h"
|
||||
#include "dynamic_zone_manager.h"
|
||||
#include "worlddb.h"
|
||||
#include "zonelist.h"
|
||||
#include "zoneserver.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/repositories/instance_list_repository.h"
|
||||
|
||||
extern ClientList client_list;
|
||||
extern ZSList zoneserver_list;
|
||||
|
||||
Database& DynamicZone::GetDatabase()
|
||||
@ -14,17 +16,72 @@ Database& DynamicZone::GetDatabase()
|
||||
return database;
|
||||
}
|
||||
|
||||
bool DynamicZone::SendServerPacket(ServerPacket* packet)
|
||||
{
|
||||
return zoneserver_list.SendPacket(packet);
|
||||
}
|
||||
|
||||
DynamicZone* DynamicZone::FindDynamicZoneByID(uint32_t dz_id)
|
||||
{
|
||||
auto expedition = expedition_state.GetExpeditionByDynamicZoneID(dz_id);
|
||||
if (expedition)
|
||||
auto dz = dynamic_zone_manager.dynamic_zone_cache.find(dz_id);
|
||||
if (dz != dynamic_zone_manager.dynamic_zone_cache.end())
|
||||
{
|
||||
return &expedition->GetDynamicZone();
|
||||
return dz->second.get();
|
||||
}
|
||||
// todo: other system caches
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DynamicZone::ChooseNewLeader()
|
||||
{
|
||||
if (m_members.empty() || !m_choose_leader_cooldown_timer.Check())
|
||||
{
|
||||
m_choose_leader_needed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
auto it = std::find_if(m_members.begin(), m_members.end(), [&](const DynamicZoneMember& member) {
|
||||
if (member.id != GetLeaderID() && member.IsOnline()) {
|
||||
auto member_cle = client_list.FindCLEByCharacterID(member.id);
|
||||
return (member_cle && member_cle->GetOnline() == CLE_Status::InZone);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (it == m_members.end())
|
||||
{
|
||||
// no online members found, fallback to choosing any member
|
||||
it = std::find_if(m_members.begin(), m_members.end(),
|
||||
[&](const DynamicZoneMember& member) { return member.id != GetLeaderID(); });
|
||||
}
|
||||
|
||||
if (it != m_members.end() && SetNewLeader(it->id))
|
||||
{
|
||||
m_choose_leader_needed = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool DynamicZone::SetNewLeader(uint32_t member_id)
|
||||
{
|
||||
auto new_leader = GetMemberData(member_id);
|
||||
if (!new_leader.IsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
LogDynamicZonesDetail("Replacing dz [{}] leader [{}] with [{}]", GetID(), GetLeaderName(), new_leader.name);
|
||||
SetLeader(new_leader, true);
|
||||
SendZonesLeaderChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
void DynamicZone::CheckLeader()
|
||||
{
|
||||
if (m_choose_leader_needed)
|
||||
{
|
||||
ChooseNewLeader();
|
||||
}
|
||||
}
|
||||
|
||||
DynamicZoneStatus DynamicZone::Process()
|
||||
{
|
||||
DynamicZoneStatus status = DynamicZoneStatus::Normal;
|
||||
@ -47,9 +104,24 @@ DynamicZoneStatus DynamicZone::Process()
|
||||
}
|
||||
}
|
||||
|
||||
if (GetType() == DynamicZoneType::Expedition && status != DynamicZoneStatus::ExpiredEmpty)
|
||||
{
|
||||
CheckExpireWarning();
|
||||
CheckLeader();
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void DynamicZone::SendZonesDynamicZoneDeleted()
|
||||
{
|
||||
uint32_t pack_size = sizeof(ServerDzID_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_DzDeleted, pack_size);
|
||||
auto buf = reinterpret_cast<ServerDzID_Struct*>(pack->pBuffer);
|
||||
buf->dz_id = GetID();
|
||||
zoneserver_list.SendPacket(pack.get());
|
||||
}
|
||||
|
||||
void DynamicZone::SetSecondsRemaining(uint32_t seconds_remaining)
|
||||
{
|
||||
auto now = std::chrono::system_clock::now();
|
||||
@ -82,10 +154,25 @@ void DynamicZone::SendZonesDurationUpdate()
|
||||
zoneserver_list.SendPacket(pack.get());
|
||||
}
|
||||
|
||||
void DynamicZone::SendZonesLeaderChanged()
|
||||
{
|
||||
uint32_t pack_size = sizeof(ServerDzLeaderID_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_DzLeaderChanged, pack_size);
|
||||
auto buf = reinterpret_cast<ServerDzLeaderID_Struct*>(pack->pBuffer);
|
||||
buf->dz_id = GetID();
|
||||
buf->leader_id = GetLeaderID();
|
||||
zoneserver_list.SendPacket(pack.get());
|
||||
}
|
||||
|
||||
void DynamicZone::HandleZoneMessage(ServerPacket* pack)
|
||||
{
|
||||
switch (pack->opcode)
|
||||
{
|
||||
case ServerOP_DzCreated:
|
||||
{
|
||||
dynamic_zone_manager.CacheNewDynamicZone(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzSetCompass:
|
||||
case ServerOP_DzSetSafeReturn:
|
||||
case ServerOP_DzSetZoneIn:
|
||||
@ -110,15 +197,41 @@ void DynamicZone::HandleZoneMessage(ServerPacket* pack)
|
||||
zoneserver_list.SendPacket(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzAddRemoveCharacter:
|
||||
case ServerOP_DzRemoveAllCharacters:
|
||||
case ServerOP_DzAddRemoveMember:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzCharacter_Struct*>(pack->pBuffer);
|
||||
ZoneServer* instance_zs = zoneserver_list.FindByInstanceID(buf->instance_id);
|
||||
if (instance_zs)
|
||||
auto buf = reinterpret_cast<ServerDzMember_Struct*>(pack->pBuffer);
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
instance_zs->SendPacket(pack);
|
||||
auto status = static_cast<DynamicZoneMemberStatus>(buf->character_status);
|
||||
dz->ProcessMemberAddRemove({ buf->character_id, buf->character_name, status }, buf->removed);
|
||||
}
|
||||
zoneserver_list.SendPacket(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzSwapMembers:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzMemberSwap_Struct*>(pack->pBuffer);
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
// we add first in world so new member can be chosen if leader is removed
|
||||
auto status = static_cast<DynamicZoneMemberStatus>(buf->add_character_status);
|
||||
dz->ProcessMemberAddRemove({ buf->add_character_id, buf->add_character_name, status }, false);
|
||||
dz->ProcessMemberAddRemove({ buf->remove_character_id, buf->remove_character_name }, true);
|
||||
}
|
||||
zoneserver_list.SendPacket(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzRemoveAllMembers:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzID_Struct*>(pack->pBuffer);
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
dz->ProcessRemoveAllMembers();
|
||||
}
|
||||
zoneserver_list.SendPacket(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzSetSecondsRemaining:
|
||||
@ -131,31 +244,131 @@ void DynamicZone::HandleZoneMessage(ServerPacket* pack)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzGetMemberStatuses:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzID_Struct*>(pack->pBuffer);
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
dz->SendZoneMemberStatuses(buf->sender_zone_id, buf->sender_instance_id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzUpdateMemberStatus:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzMemberStatus_Struct*>(pack->pBuffer);
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
auto status = static_cast<DynamicZoneMemberStatus>(buf->status);
|
||||
dz->ProcessMemberStatusChange(buf->character_id, status);
|
||||
}
|
||||
zoneserver_list.SendPacket(pack);
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void DynamicZone::SendInstanceAddRemoveCharacter(uint32_t character_id, bool remove)
|
||||
void DynamicZone::ProcessMemberAddRemove(const DynamicZoneMember& member, bool removed)
|
||||
{
|
||||
ZoneServer* instance_zs = zoneserver_list.FindByInstanceID(GetInstanceID());
|
||||
if (instance_zs)
|
||||
DynamicZoneBase::ProcessMemberAddRemove(member, removed);
|
||||
|
||||
if (GetType() == DynamicZoneType::Expedition && removed && member.id == GetLeaderID())
|
||||
{
|
||||
auto pack = CreateServerAddRemoveCharacterPacket(character_id, remove);
|
||||
instance_zs->SendPacket(pack.get());
|
||||
ChooseNewLeader();
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendInstanceRemoveAllCharacters()
|
||||
bool DynamicZone::ProcessMemberStatusChange(uint32_t character_id, DynamicZoneMemberStatus status)
|
||||
{
|
||||
ZoneServer* instance_zs = zoneserver_list.FindByInstanceID(GetInstanceID());
|
||||
if (instance_zs)
|
||||
bool changed = DynamicZoneBase::SetInternalMemberStatus(character_id, status);
|
||||
if (changed && GetType() == DynamicZoneType::Expedition)
|
||||
{
|
||||
auto pack = CreateServerRemoveAllCharactersPacket();
|
||||
instance_zs->SendPacket(pack.get());
|
||||
// any member status update will trigger a leader fix if leader was offline
|
||||
if (GetLeader().status == DynamicZoneMemberStatus::Offline && GetMemberCount() > 1)
|
||||
{
|
||||
ChooseNewLeader();
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
void DynamicZone::SendGlobalLocationChange(uint16_t server_opcode, const DynamicZoneLocation& location)
|
||||
void DynamicZone::SendZonesExpireWarning(uint32_t minutes_remaining)
|
||||
{
|
||||
auto pack = CreateServerDzLocationPacket(server_opcode, location);
|
||||
uint32_t pack_size = sizeof(ServerDzExpireWarning_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_DzExpireWarning, pack_size);
|
||||
auto buf = reinterpret_cast<ServerDzExpireWarning_Struct*>(pack->pBuffer);
|
||||
buf->dz_id = GetID();
|
||||
buf->minutes_remaining = minutes_remaining;
|
||||
zoneserver_list.SendPacket(pack.get());
|
||||
}
|
||||
|
||||
void DynamicZone::SendZoneMemberStatuses(uint16_t zone_id, uint16_t instance_id)
|
||||
{
|
||||
uint32_t members_count = static_cast<uint32_t>(m_members.size());
|
||||
uint32_t entries_size = sizeof(ServerDzMemberStatusEntry_Struct) * members_count;
|
||||
uint32_t pack_size = sizeof(ServerDzMemberStatuses_Struct) + entries_size;
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_DzGetMemberStatuses, pack_size);
|
||||
auto buf = reinterpret_cast<ServerDzMemberStatuses_Struct*>(pack->pBuffer);
|
||||
buf->dz_id = GetID();
|
||||
buf->count = members_count;
|
||||
|
||||
for (int i = 0; i < m_members.size(); ++i)
|
||||
{
|
||||
buf->entries[i].character_id = m_members[i].id;
|
||||
buf->entries[i].online_status = static_cast<uint8_t>(m_members[i].status);
|
||||
}
|
||||
|
||||
zoneserver_list.SendPacket(zone_id, instance_id, pack.get());
|
||||
}
|
||||
|
||||
void DynamicZone::CacheMemberStatuses()
|
||||
{
|
||||
if (m_has_member_statuses)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// called when a new dz is cached to fill member statuses
|
||||
std::string zone_name{};
|
||||
std::vector<ClientListEntry*> all_clients;
|
||||
all_clients.reserve(client_list.GetClientCount());
|
||||
client_list.GetClients(zone_name.c_str(), all_clients);
|
||||
|
||||
for (const auto& member : m_members)
|
||||
{
|
||||
auto it = std::find_if(all_clients.begin(), all_clients.end(),
|
||||
[&](const ClientListEntry* cle) { return (cle && cle->CharID() == member.id); });
|
||||
|
||||
auto status = DynamicZoneMemberStatus::Offline;
|
||||
if (it != all_clients.end())
|
||||
{
|
||||
status = DynamicZoneMemberStatus::Online;
|
||||
if (IsSameDz((*it)->zone(), (*it)->instance()))
|
||||
{
|
||||
status = DynamicZoneMemberStatus::InDynamicZone;
|
||||
}
|
||||
}
|
||||
|
||||
SetInternalMemberStatus(member.id, status);
|
||||
}
|
||||
|
||||
m_has_member_statuses = true;
|
||||
}
|
||||
|
||||
void DynamicZone::CheckExpireWarning()
|
||||
{
|
||||
if (m_warning_cooldown_timer.Check(false))
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
auto remaining = GetDurationRemaining();
|
||||
if ((remaining > 14min && remaining < 15min) ||
|
||||
(remaining > 4min && remaining < 5min) ||
|
||||
(remaining > 0min && remaining < 1min))
|
||||
{
|
||||
int minutes = std::chrono::duration_cast<std::chrono::minutes>(remaining).count() + 1;
|
||||
SendZonesExpireWarning(minutes);
|
||||
m_warning_cooldown_timer.Start(120000); // 2 minute cooldown after a warning
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
#define WORLD_DYNAMIC_ZONE_H
|
||||
|
||||
#include "../common/dynamic_zone_base.h"
|
||||
#include "../common/rulesys.h"
|
||||
#include "../common/timer.h"
|
||||
|
||||
class Database;
|
||||
class ServerPacket;
|
||||
@ -24,18 +26,32 @@ public:
|
||||
|
||||
void SetSecondsRemaining(uint32_t seconds_remaining) override;
|
||||
|
||||
void CacheMemberStatuses();
|
||||
DynamicZoneStatus Process();
|
||||
bool SetNewLeader(uint32_t member_id);
|
||||
|
||||
protected:
|
||||
Database& GetDatabase() override;
|
||||
void SendInstanceAddRemoveCharacter(uint32_t character_id, bool remove) override;
|
||||
void SendInstanceRemoveAllCharacters() override;
|
||||
void SendGlobalLocationChange(uint16_t server_opcode, const DynamicZoneLocation& location) override;
|
||||
void ProcessMemberAddRemove(const DynamicZoneMember& member, bool removed) override;
|
||||
bool ProcessMemberStatusChange(uint32_t member_id, DynamicZoneMemberStatus status) override;
|
||||
bool SendServerPacket(ServerPacket* packet) override;
|
||||
|
||||
private:
|
||||
friend class DynamicZoneManager;
|
||||
|
||||
void CheckExpireWarning();
|
||||
void CheckLeader();
|
||||
void ChooseNewLeader();
|
||||
void SendZoneMemberStatuses(uint16_t zone_id, uint16_t instance_id);
|
||||
void SendZonesDurationUpdate();
|
||||
void SendZonesDynamicZoneDeleted();
|
||||
void SendZonesExpireWarning(uint32_t minutes_remaining);
|
||||
void SendZonesLeaderChanged();
|
||||
|
||||
bool m_is_pending_early_shutdown = false;
|
||||
bool m_choose_leader_needed = false;
|
||||
Timer m_choose_leader_cooldown_timer{ static_cast<uint32_t>(RuleI(Expedition, ChooseLeaderCooldownTime)) };
|
||||
Timer m_warning_cooldown_timer{ 1 }; // non-zero so it's enabled initially
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
166
world/dynamic_zone_manager.cpp
Normal file
166
world/dynamic_zone_manager.cpp
Normal file
@ -0,0 +1,166 @@
|
||||
#include "dynamic_zone_manager.h"
|
||||
#include "dynamic_zone.h"
|
||||
#include "worlddb.h"
|
||||
#include "zonelist.h"
|
||||
#include "zoneserver.h"
|
||||
#include "../common/rulesys.h"
|
||||
#include "../common/repositories/expeditions_repository.h"
|
||||
#include "../common/repositories/expedition_lockouts_repository.h"
|
||||
|
||||
extern ZSList zoneserver_list;
|
||||
|
||||
DynamicZoneManager dynamic_zone_manager;
|
||||
|
||||
DynamicZoneManager::DynamicZoneManager() :
|
||||
m_process_throttle_timer{ static_cast<uint32_t>(RuleI(DynamicZone, WorldProcessRate)) }
|
||||
{
|
||||
}
|
||||
|
||||
void DynamicZoneManager::PurgeExpiredDynamicZones()
|
||||
{
|
||||
// purge when no members, instance is expired, or instance doesn't exist.
|
||||
// this prevents characters remaining members of dzs that expired while
|
||||
// server was offline but delayed instance purging hasn't cleaned yet
|
||||
auto dz_ids = DynamicZonesRepository::GetStaleIDs(database);
|
||||
|
||||
if (!dz_ids.empty())
|
||||
{
|
||||
LogDynamicZones("Purging [{}] dynamic zone(s)", dz_ids.size());
|
||||
|
||||
DynamicZoneMembersRepository::DeleteWhere(database,
|
||||
fmt::format("dynamic_zone_id IN ({})", fmt::join(dz_ids, ",")));
|
||||
DynamicZonesRepository::DeleteWhere(database,
|
||||
fmt::format("id IN ({})", fmt::join(dz_ids, ",")));
|
||||
}
|
||||
}
|
||||
|
||||
DynamicZone* DynamicZoneManager::CreateNew(
|
||||
DynamicZone& dz_request, const std::vector<DynamicZoneMember>& members)
|
||||
{
|
||||
// this creates a new dz instance and saves it to both db and cache
|
||||
uint32_t dz_id = dz_request.Create();
|
||||
if (dz_id == 0)
|
||||
{
|
||||
LogDynamicZones("Failed to create dynamic zone for zone [{}]", dz_request.GetZoneID());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto dz = std::make_unique<DynamicZone>(dz_request);
|
||||
if (!members.empty())
|
||||
{
|
||||
dz->SaveMembers(members);
|
||||
dz->CacheMemberStatuses();
|
||||
}
|
||||
|
||||
LogDynamicZones("Created new dz [{}] for zone [{}]", dz_id, dz_request.GetZoneID());
|
||||
|
||||
auto pack = dz->CreateServerDzCreatePacket(0, 0);
|
||||
zoneserver_list.SendPacket(pack.get());
|
||||
|
||||
auto inserted = dynamic_zone_cache.emplace(dz_id, std::move(dz));
|
||||
return inserted.first->second.get();
|
||||
}
|
||||
|
||||
void DynamicZoneManager::CacheNewDynamicZone(ServerPacket* pack)
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzCreateSerialized_Struct*>(pack->pBuffer);
|
||||
|
||||
auto new_dz = std::make_unique<DynamicZone>();
|
||||
new_dz->LoadSerializedDzPacket(buf->cereal_data, buf->cereal_size);
|
||||
new_dz->CacheMemberStatuses();
|
||||
|
||||
// reserialize with member statuses cached before forwarding (restore origin zone)
|
||||
auto repack = new_dz->CreateServerDzCreatePacket(buf->origin_zone_id, buf->origin_instance_id);
|
||||
|
||||
uint32_t dz_id = new_dz->GetID();
|
||||
dynamic_zone_cache.emplace(dz_id, std::move(new_dz));
|
||||
LogDynamicZones("Cached new dynamic zone [{}]", dz_id);
|
||||
|
||||
zoneserver_list.SendPacket(repack.get());
|
||||
}
|
||||
|
||||
void DynamicZoneManager::CacheAllFromDatabase()
|
||||
{
|
||||
BenchTimer bench;
|
||||
|
||||
auto dynamic_zones = DynamicZonesRepository::AllWithInstanceNotExpired(database);
|
||||
auto dynamic_zone_members = DynamicZoneMembersRepository::GetAllWithNames(database);
|
||||
|
||||
dynamic_zone_cache.clear();
|
||||
dynamic_zone_cache.reserve(dynamic_zones.size());
|
||||
|
||||
for (auto& entry : dynamic_zones)
|
||||
{
|
||||
uint32_t dz_id = entry.id;
|
||||
auto dz = std::make_unique<DynamicZone>(std::move(entry));
|
||||
|
||||
for (auto& member : dynamic_zone_members)
|
||||
{
|
||||
if (member.dynamic_zone_id == dz_id)
|
||||
{
|
||||
dz->AddMemberFromRepositoryResult(std::move(member));
|
||||
}
|
||||
}
|
||||
|
||||
// note leader status won't be updated here until leader is set by owning system (expeditions)
|
||||
dz->CacheMemberStatuses();
|
||||
|
||||
dynamic_zone_cache.emplace(dz_id, std::move(dz));
|
||||
}
|
||||
|
||||
LogDynamicZones("Caching [{}] dynamic zone(s) took [{}s]", dynamic_zone_cache.size(), bench.elapsed());
|
||||
}
|
||||
|
||||
void DynamicZoneManager::Process()
|
||||
{
|
||||
if (!m_process_throttle_timer.Check())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<uint32_t> dynamic_zone_ids;
|
||||
|
||||
for (const auto& dz_iter : dynamic_zone_cache)
|
||||
{
|
||||
DynamicZone* dz = dz_iter.second.get();
|
||||
|
||||
// dynamic zone is not deleted until its zone has no clients to prevent exploits
|
||||
// clients should be removed by zone-based kick timers if expired but not empty
|
||||
DynamicZoneStatus status = dz->Process();
|
||||
if (status == DynamicZoneStatus::ExpiredEmpty)
|
||||
{
|
||||
LogDynamicZones("[{}] expired with [{}] members, notifying zones and deleting", dz->GetID(), dz->GetMemberCount());
|
||||
dynamic_zone_ids.emplace_back(dz->GetID());
|
||||
dz->SendZonesDynamicZoneDeleted(); // delete dz from zone caches
|
||||
}
|
||||
}
|
||||
|
||||
if (!dynamic_zone_ids.empty())
|
||||
{
|
||||
for (const auto& dz_id : dynamic_zone_ids)
|
||||
{
|
||||
dynamic_zone_cache.erase(dz_id);
|
||||
}
|
||||
|
||||
// need to look up expedition ids until lockouts are moved to dynamic zones
|
||||
std::vector<uint32_t> expedition_ids;
|
||||
auto expeditions = ExpeditionsRepository::GetWhere(database,
|
||||
fmt::format("dynamic_zone_id IN ({})", fmt::join(dynamic_zone_ids, ",")));
|
||||
|
||||
if (!expeditions.empty())
|
||||
{
|
||||
for (const auto& expedition : expeditions)
|
||||
{
|
||||
expedition_ids.emplace_back(expedition.id);
|
||||
}
|
||||
ExpeditionLockoutsRepository::DeleteWhere(database,
|
||||
fmt::format("expedition_id IN ({})", fmt::join(expedition_ids, ",")));
|
||||
}
|
||||
|
||||
ExpeditionsRepository::DeleteWhere(database,
|
||||
fmt::format("dynamic_zone_id IN ({})", fmt::join(dynamic_zone_ids, ",")));
|
||||
DynamicZoneMembersRepository::RemoveAllMembers(database, dynamic_zone_ids);
|
||||
DynamicZonesRepository::DeleteWhere(database,
|
||||
fmt::format("id IN ({})", fmt::join(dynamic_zone_ids, ",")));
|
||||
}
|
||||
}
|
||||
32
world/dynamic_zone_manager.h
Normal file
32
world/dynamic_zone_manager.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef WORLD_DYNAMIC_ZONE_MANAGER_H
|
||||
#define WORLD_DYNAMIC_ZONE_MANAGER_H
|
||||
|
||||
#include "../common/timer.h"
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
extern class DynamicZoneManager dynamic_zone_manager;
|
||||
|
||||
class DynamicZone;
|
||||
struct DynamicZoneMember;
|
||||
class ServerPacket;
|
||||
|
||||
class DynamicZoneManager
|
||||
{
|
||||
public:
|
||||
DynamicZoneManager();
|
||||
|
||||
void CacheAllFromDatabase();
|
||||
void CacheNewDynamicZone(ServerPacket* pack);
|
||||
DynamicZone* CreateNew(DynamicZone& dz_request, const std::vector<DynamicZoneMember>& members);
|
||||
void Process();
|
||||
void PurgeExpiredDynamicZones();
|
||||
|
||||
std::unordered_map<uint32_t, std::unique_ptr<DynamicZone>> dynamic_zone_cache;
|
||||
|
||||
private:
|
||||
Timer m_process_throttle_timer{};
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,237 +0,0 @@
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include "expedition.h"
|
||||
#include "expedition_database.h"
|
||||
#include "cliententry.h"
|
||||
#include "clientlist.h"
|
||||
#include "zonelist.h"
|
||||
#include "zoneserver.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/rulesys.h"
|
||||
|
||||
extern ClientList client_list;
|
||||
extern ZSList zoneserver_list;
|
||||
|
||||
Expedition::Expedition() :
|
||||
m_choose_leader_cooldown_timer{ static_cast<uint32_t>(RuleI(Expedition, ChooseLeaderCooldownTime)) }
|
||||
{
|
||||
m_warning_cooldown_timer.Enable();
|
||||
}
|
||||
|
||||
void Expedition::SetDynamicZone(DynamicZone&& dz)
|
||||
{
|
||||
dz.SetName(GetName());
|
||||
dz.SetLeader(GetLeader());
|
||||
|
||||
m_dynamic_zone = std::move(dz);
|
||||
}
|
||||
|
||||
void Expedition::RemoveMember(uint32_t character_id)
|
||||
{
|
||||
GetDynamicZone().RemoveInternalMember(character_id);
|
||||
|
||||
if (character_id == m_leader.id)
|
||||
{
|
||||
ChooseNewLeader();
|
||||
}
|
||||
}
|
||||
|
||||
void Expedition::ChooseNewLeader()
|
||||
{
|
||||
const auto& members = GetDynamicZone().GetMembers();
|
||||
if (members.empty() || !m_choose_leader_cooldown_timer.Check())
|
||||
{
|
||||
m_choose_leader_needed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
auto it = std::find_if(members.begin(), members.end(), [&](const DynamicZoneMember& member) {
|
||||
if (member.id != m_leader.id && member.IsOnline()) {
|
||||
auto member_cle = client_list.FindCLEByCharacterID(member.id);
|
||||
return (member_cle && member_cle->GetOnline() == CLE_Status::InZone);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (it == members.end())
|
||||
{
|
||||
// no online members found, fallback to choosing any member
|
||||
it = std::find_if(members.begin(), members.end(),
|
||||
[&](const DynamicZoneMember& member) { return (member.id != m_leader.id); });
|
||||
}
|
||||
|
||||
if (it != members.end() && SetNewLeader(*it))
|
||||
{
|
||||
m_choose_leader_needed = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Expedition::SetNewLeader(const DynamicZoneMember& member)
|
||||
{
|
||||
if (!GetDynamicZone().HasMember(member.id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
LogExpeditionsModerate("Replacing [{}] leader [{}] with [{}]", m_id, m_leader.name, member.name);
|
||||
ExpeditionDatabase::UpdateLeaderID(m_id, member.id);
|
||||
m_leader = member;
|
||||
m_dynamic_zone.SetLeader(m_leader);
|
||||
SendZonesLeaderChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Expedition::SendZonesExpeditionDeleted()
|
||||
{
|
||||
uint32_t pack_size = sizeof(ServerExpeditionID_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_ExpeditionDeleted, pack_size);
|
||||
auto buf = reinterpret_cast<ServerExpeditionID_Struct*>(pack->pBuffer);
|
||||
buf->expedition_id = GetID();
|
||||
zoneserver_list.SendPacket(pack.get());
|
||||
}
|
||||
|
||||
void Expedition::SendZonesExpireWarning(uint32_t minutes_remaining)
|
||||
{
|
||||
uint32_t pack_size = sizeof(ServerExpeditionExpireWarning_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_ExpeditionExpireWarning, pack_size);
|
||||
auto buf = reinterpret_cast<ServerExpeditionExpireWarning_Struct*>(pack->pBuffer);
|
||||
buf->expedition_id = GetID();
|
||||
buf->minutes_remaining = minutes_remaining;
|
||||
zoneserver_list.SendPacket(pack.get());
|
||||
}
|
||||
|
||||
void Expedition::SendZonesLeaderChanged()
|
||||
{
|
||||
uint32_t pack_size = sizeof(ServerExpeditionLeaderID_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_ExpeditionLeaderChanged, pack_size);
|
||||
auto buf = reinterpret_cast<ServerExpeditionLeaderID_Struct*>(pack->pBuffer);
|
||||
buf->expedition_id = GetID();
|
||||
buf->leader_id = m_leader.id;
|
||||
zoneserver_list.SendPacket(pack.get());
|
||||
}
|
||||
|
||||
void Expedition::CheckExpireWarning()
|
||||
{
|
||||
if (m_warning_cooldown_timer.Check(false))
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
auto remaining = GetDynamicZone().GetDurationRemaining();
|
||||
if ((remaining > 14min && remaining < 15min) ||
|
||||
(remaining > 4min && remaining < 5min) ||
|
||||
(remaining > 0min && remaining < 1min))
|
||||
{
|
||||
int minutes = std::chrono::duration_cast<std::chrono::minutes>(remaining).count() + 1;
|
||||
SendZonesExpireWarning(minutes);
|
||||
m_warning_cooldown_timer.Start(70000); // 1 minute 10 seconds
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Expedition::CheckLeader()
|
||||
{
|
||||
if (m_choose_leader_needed)
|
||||
{
|
||||
ChooseNewLeader();
|
||||
}
|
||||
}
|
||||
|
||||
bool Expedition::Process()
|
||||
{
|
||||
// returns true if expedition needs to be deleted from world cache and db
|
||||
// expedition is not deleted until its dz has no clients to prevent exploits
|
||||
auto status = m_dynamic_zone.Process();
|
||||
if (status == DynamicZoneStatus::ExpiredEmpty)
|
||||
{
|
||||
LogExpeditions("Expedition [{}] expired or empty, notifying zones and deleting", GetID());
|
||||
SendZonesExpeditionDeleted();
|
||||
return true;
|
||||
}
|
||||
|
||||
CheckExpireWarning();
|
||||
CheckLeader();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Expedition::UpdateMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status)
|
||||
{
|
||||
GetDynamicZone().SetInternalMemberStatus(character_id, status);
|
||||
|
||||
// temporary until move to using dz leader object completely
|
||||
if (character_id == m_leader.id)
|
||||
{
|
||||
m_leader.status = GetDynamicZone().GetLeader().status;
|
||||
}
|
||||
|
||||
// any member status update will trigger a leader fix if leader was offline
|
||||
if (m_leader.status == DynamicZoneMemberStatus::Offline && GetDynamicZone().GetMemberCount() > 1)
|
||||
{
|
||||
ChooseNewLeader();
|
||||
}
|
||||
}
|
||||
|
||||
void Expedition::SendZoneMemberStatuses(uint16_t zone_id, uint16_t instance_id)
|
||||
{
|
||||
const auto& members = GetDynamicZone().GetMembers();
|
||||
|
||||
uint32_t members_count = static_cast<uint32_t>(members.size());
|
||||
uint32_t entries_size = sizeof(ServerExpeditionMemberStatusEntry_Struct) * members_count;
|
||||
uint32_t pack_size = sizeof(ServerExpeditionMemberStatuses_Struct) + entries_size;
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_ExpeditionGetMemberStatuses, pack_size);
|
||||
auto buf = reinterpret_cast<ServerExpeditionMemberStatuses_Struct*>(pack->pBuffer);
|
||||
buf->expedition_id = GetID();
|
||||
buf->count = members_count;
|
||||
|
||||
for (int i = 0; i < members.size(); ++i)
|
||||
{
|
||||
buf->entries[i].character_id = members[i].id;
|
||||
buf->entries[i].online_status = static_cast<uint8_t>(members[i].status);
|
||||
}
|
||||
|
||||
zoneserver_list.SendPacket(zone_id, instance_id, pack.get());
|
||||
}
|
||||
|
||||
void Expedition::CacheMemberStatuses()
|
||||
{
|
||||
// called when a new expedition is cached to fill member statuses
|
||||
std::string zone_name{};
|
||||
std::vector<ClientListEntry*> all_clients;
|
||||
all_clients.reserve(client_list.GetClientCount());
|
||||
client_list.GetClients(zone_name.c_str(), all_clients);
|
||||
|
||||
for (const auto& member : GetDynamicZone().GetMembers())
|
||||
{
|
||||
auto it = std::find_if(all_clients.begin(), all_clients.end(),
|
||||
[&](const ClientListEntry* cle) { return (cle && cle->CharID() == member.id); });
|
||||
|
||||
auto status = DynamicZoneMemberStatus::Offline;
|
||||
if (it != all_clients.end())
|
||||
{
|
||||
status = DynamicZoneMemberStatus::Online;
|
||||
if (GetDynamicZone().IsSameDz((*it)->zone(), (*it)->instance()))
|
||||
{
|
||||
status = DynamicZoneMemberStatus::InDynamicZone;
|
||||
}
|
||||
}
|
||||
|
||||
GetDynamicZone().SetInternalMemberStatus(member.id, status);
|
||||
}
|
||||
}
|
||||
@ -1,57 +0,0 @@
|
||||
/**
|
||||
* 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 WORLD_EXPEDITION_H
|
||||
#define WORLD_EXPEDITION_H
|
||||
|
||||
#include "dynamic_zone.h"
|
||||
#include "../common/expedition_base.h"
|
||||
#include "../common/timer.h"
|
||||
#include <cstdint>
|
||||
|
||||
class Expedition : public ExpeditionBase
|
||||
{
|
||||
public:
|
||||
Expedition();
|
||||
|
||||
void RemoveMember(uint32_t character_id);
|
||||
void CacheMemberStatuses();
|
||||
void CheckExpireWarning();
|
||||
void CheckLeader();
|
||||
void ChooseNewLeader();
|
||||
DynamicZone& GetDynamicZone() { return m_dynamic_zone; }
|
||||
bool Process();
|
||||
void SendZoneMemberStatuses(uint16_t zone_id, uint16_t instance_id);
|
||||
void SendZonesExpeditionDeleted();
|
||||
void SendZonesExpireWarning(uint32_t minutes_remaining);
|
||||
void SetDynamicZone(DynamicZone&& dz);
|
||||
bool SetNewLeader(const DynamicZoneMember& member);
|
||||
void UpdateMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status);
|
||||
|
||||
private:
|
||||
void SendZonesLeaderChanged();
|
||||
|
||||
bool m_choose_leader_needed = false;
|
||||
Timer m_choose_leader_cooldown_timer;
|
||||
Timer m_warning_cooldown_timer;
|
||||
DynamicZone m_dynamic_zone;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -19,8 +19,9 @@
|
||||
*/
|
||||
|
||||
#include "expedition_database.h"
|
||||
#include "expedition.h"
|
||||
#include "worlddb.h"
|
||||
#include "../common/repositories/expeditions_repository.h"
|
||||
#include "../common/repositories/expedition_lockouts_repository.h"
|
||||
#include "../common/repositories/dynamic_zone_members_repository.h"
|
||||
|
||||
void ExpeditionDatabase::PurgeExpiredExpeditions()
|
||||
@ -34,7 +35,7 @@ void ExpeditionDatabase::PurgeExpiredExpeditions()
|
||||
LEFT JOIN instance_list ON dynamic_zones.instance_id = instance_list.id
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT dynamic_zone_id, COUNT(IF(is_current_member = TRUE, 1, NULL)) member_count
|
||||
SELECT dynamic_zone_id, COUNT(*) member_count
|
||||
FROM dynamic_zone_members
|
||||
GROUP BY dynamic_zone_id
|
||||
) dynamic_zone_members
|
||||
@ -59,8 +60,9 @@ void ExpeditionDatabase::PurgeExpiredExpeditions()
|
||||
|
||||
if (!expedition_ids.empty())
|
||||
{
|
||||
ExpeditionDatabase::MoveMembersToSafeReturn(expedition_ids);
|
||||
ExpeditionDatabase::DeleteExpeditions(expedition_ids);
|
||||
auto joined_expedition_ids = fmt::join(expedition_ids, ",");
|
||||
ExpeditionsRepository::DeleteWhere(database, fmt::format("id IN ({})", joined_expedition_ids));
|
||||
ExpeditionLockoutsRepository::DeleteWhere(database, fmt::format("expedition_id IN ({})", joined_expedition_ids));
|
||||
DynamicZoneMembersRepository::RemoveAllMembers(database, dynamic_zone_ids);
|
||||
}
|
||||
}
|
||||
@ -75,56 +77,3 @@ void ExpeditionDatabase::PurgeExpiredCharacterLockouts()
|
||||
|
||||
database.QueryDatabase(query);
|
||||
}
|
||||
|
||||
void ExpeditionDatabase::DeleteExpeditions(const std::vector<uint32_t>& expedition_ids)
|
||||
{
|
||||
LogExpeditionsDetail("Deleting [{}] expedition(s)", expedition_ids.size());
|
||||
|
||||
std::string expedition_ids_query = fmt::format("{}", fmt::join(expedition_ids, ","));
|
||||
|
||||
if (!expedition_ids_query.empty())
|
||||
{
|
||||
auto query = fmt::format("DELETE FROM expeditions WHERE id IN ({});", expedition_ids_query);
|
||||
database.QueryDatabase(query);
|
||||
|
||||
query = fmt::format("DELETE FROM expedition_lockouts WHERE expedition_id IN ({});", expedition_ids_query);
|
||||
database.QueryDatabase(query);
|
||||
}
|
||||
}
|
||||
|
||||
void ExpeditionDatabase::UpdateLeaderID(uint32_t expedition_id, uint32_t leader_id)
|
||||
{
|
||||
LogExpeditionsDetail("Updating leader [{}] for expedition [{}]", leader_id, expedition_id);
|
||||
|
||||
auto query = fmt::format(SQL(
|
||||
UPDATE expeditions SET leader_id = {} WHERE id = {};
|
||||
), leader_id, expedition_id);
|
||||
|
||||
database.QueryDatabase(query);
|
||||
}
|
||||
|
||||
void ExpeditionDatabase::MoveMembersToSafeReturn(const std::vector<uint32_t>& expedition_ids)
|
||||
{
|
||||
LogExpeditionsDetail("Moving members from [{}] expedition(s) to safereturn", expedition_ids.size());
|
||||
|
||||
// only offline members still in expired dz zones should be updated here
|
||||
std::string query = fmt::format(SQL(
|
||||
UPDATE character_data
|
||||
INNER JOIN dynamic_zone_members ON character_data.id = dynamic_zone_members.character_id
|
||||
INNER JOIN expeditions ON dynamic_zone_members.dynamic_zone_id = expeditions.dynamic_zone_id
|
||||
INNER JOIN dynamic_zones ON expeditions.dynamic_zone_id = dynamic_zones.id
|
||||
INNER JOIN instance_list ON dynamic_zones.instance_id = instance_list.id
|
||||
AND character_data.zone_instance = instance_list.id
|
||||
AND character_data.zone_id = instance_list.zone
|
||||
SET
|
||||
zone_id = IF(safe_return_zone_id > 0, safe_return_zone_id, zone_id),
|
||||
zone_instance = IF(safe_return_zone_id > 0, 0, zone_instance),
|
||||
x = IF(safe_return_zone_id > 0, safe_return_x, x),
|
||||
y = IF(safe_return_zone_id > 0, safe_return_y, y),
|
||||
z = IF(safe_return_zone_id > 0, safe_return_z, z),
|
||||
heading = IF(safe_return_zone_id > 0, safe_return_heading, heading)
|
||||
WHERE expeditions.id IN ({});
|
||||
), fmt::join(expedition_ids, ","));
|
||||
|
||||
database.QueryDatabase(query);
|
||||
}
|
||||
|
||||
@ -28,11 +28,8 @@ class Expedition;
|
||||
|
||||
namespace ExpeditionDatabase
|
||||
{
|
||||
void DeleteExpeditions(const std::vector<uint32_t>& expedition_ids);
|
||||
void MoveMembersToSafeReturn(const std::vector<uint32_t>& expedition_ids);
|
||||
void PurgeExpiredExpeditions();
|
||||
void PurgeExpiredCharacterLockouts();
|
||||
void UpdateLeaderID(uint32_t expedition_id, uint32_t leader_id);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -18,9 +18,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "expedition.h"
|
||||
#include "dynamic_zone.h"
|
||||
#include "expedition_message.h"
|
||||
#include "expedition_state.h"
|
||||
#include "cliententry.h"
|
||||
#include "clientlist.h"
|
||||
#include "zonelist.h"
|
||||
@ -37,50 +36,9 @@ void ExpeditionMessage::HandleZoneMessage(ServerPacket* pack)
|
||||
{
|
||||
case ServerOP_ExpeditionCreate:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerExpeditionID_Struct*>(pack->pBuffer);
|
||||
expedition_state.CacheFromDatabase(buf->expedition_id);
|
||||
zoneserver_list.SendPacket(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_ExpeditionMemberChange:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerExpeditionMemberChange_Struct*>(pack->pBuffer);
|
||||
expedition_state.MemberChange(buf->expedition_id, { buf->char_id, buf->char_name }, buf->removed);
|
||||
zoneserver_list.SendPacket(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_ExpeditionMemberSwap:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerExpeditionMemberSwap_Struct*>(pack->pBuffer);
|
||||
expedition_state.MemberChange(buf->expedition_id, { buf->add_char_id, buf->add_char_name }, false);
|
||||
expedition_state.MemberChange(buf->expedition_id, { buf->remove_char_id, buf->remove_char_name }, true);
|
||||
zoneserver_list.SendPacket(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_ExpeditionMembersRemoved:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerExpeditionID_Struct*>(pack->pBuffer);
|
||||
expedition_state.RemoveAllMembers(buf->expedition_id);
|
||||
zoneserver_list.SendPacket(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_ExpeditionMemberStatus:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerExpeditionMemberStatus_Struct*>(pack->pBuffer);
|
||||
auto expedition = expedition_state.GetExpedition(buf->expedition_id);
|
||||
if (expedition)
|
||||
{
|
||||
auto status = static_cast<DynamicZoneMemberStatus>(buf->status);
|
||||
expedition->UpdateMemberStatus(buf->character_id, status);
|
||||
}
|
||||
zoneserver_list.SendPacket(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_ExpeditionGetMemberStatuses:
|
||||
{
|
||||
ExpeditionMessage::GetMemberStatuses(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_ExpeditionDzAddPlayer:
|
||||
{
|
||||
ExpeditionMessage::AddPlayer(pack);
|
||||
@ -145,10 +103,10 @@ void ExpeditionMessage::MakeLeader(ServerPacket* pack)
|
||||
ClientListEntry* new_leader_cle = client_list.FindCharacter(buf->new_leader_name);
|
||||
if (new_leader_cle && new_leader_cle->Server())
|
||||
{
|
||||
auto expedition = expedition_state.GetExpedition(buf->expedition_id);
|
||||
if (expedition)
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz && dz->GetLeaderID() == buf->requester_id)
|
||||
{
|
||||
buf->is_success = expedition->SetNewLeader({ new_leader_cle->CharID(), new_leader_cle->name() });
|
||||
buf->is_success = dz->SetNewLeader(new_leader_cle->CharID());
|
||||
}
|
||||
|
||||
buf->is_online = true;
|
||||
@ -164,16 +122,6 @@ void ExpeditionMessage::MakeLeader(ServerPacket* pack)
|
||||
}
|
||||
}
|
||||
|
||||
void ExpeditionMessage::GetMemberStatuses(ServerPacket* pack)
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerExpeditionID_Struct*>(pack->pBuffer);
|
||||
auto expedition = expedition_state.GetExpedition(buf->expedition_id);
|
||||
if (expedition)
|
||||
{
|
||||
expedition->SendZoneMemberStatuses(buf->sender_zone_id, buf->sender_instance_id);
|
||||
}
|
||||
}
|
||||
|
||||
void ExpeditionMessage::SaveInvite(ServerPacket* pack)
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzCommand_Struct*>(pack->pBuffer);
|
||||
|
||||
@ -26,7 +26,6 @@ class ServerPacket;
|
||||
namespace ExpeditionMessage
|
||||
{
|
||||
void AddPlayer(ServerPacket* pack);
|
||||
void GetMemberStatuses(ServerPacket* pack);
|
||||
void HandleZoneMessage(ServerPacket* pack);
|
||||
void MakeLeader(ServerPacket* pack);
|
||||
void RequestInvite(ServerPacket* pack);
|
||||
|
||||
@ -1,172 +0,0 @@
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include "expedition_state.h"
|
||||
#include "expedition.h"
|
||||
#include "expedition_database.h"
|
||||
#include "worlddb.h"
|
||||
#include "../common/dynamic_zone_base.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/repositories/dynamic_zone_members_repository.h"
|
||||
#include <algorithm>
|
||||
|
||||
ExpeditionState expedition_state;
|
||||
|
||||
Expedition* ExpeditionState::GetExpedition(uint32_t expedition_id)
|
||||
{
|
||||
auto it = std::find_if(m_expeditions.begin(), m_expeditions.end(),
|
||||
[&](const std::unique_ptr<Expedition>& expedition) {
|
||||
return expedition->GetID() == expedition_id;
|
||||
});
|
||||
|
||||
return (it != m_expeditions.end()) ? it->get() : nullptr;
|
||||
}
|
||||
|
||||
Expedition* ExpeditionState::GetExpeditionByDynamicZoneID(uint32_t dz_id)
|
||||
{
|
||||
auto it = std::find_if(m_expeditions.begin(), m_expeditions.end(),
|
||||
[&](const std::unique_ptr<Expedition>& expedition) {
|
||||
return expedition->GetDynamicZone().GetID() == dz_id;
|
||||
});
|
||||
|
||||
return (it != m_expeditions.end()) ? it->get() : nullptr;
|
||||
}
|
||||
|
||||
void ExpeditionState::CacheFromDatabase(uint32_t expedition_id)
|
||||
{
|
||||
if (expedition_id == 0 || GetExpedition(expedition_id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto expedition = ExpeditionsRepository::GetWithLeaderName(database, expedition_id);
|
||||
CacheExpeditions({ std::move(expedition) });
|
||||
}
|
||||
|
||||
void ExpeditionState::CacheAllFromDatabase()
|
||||
{
|
||||
BenchTimer benchmark;
|
||||
|
||||
auto expeditions = ExpeditionsRepository::GetAllWithLeaderName(database);
|
||||
m_expeditions.clear();
|
||||
m_expeditions.reserve(expeditions.size());
|
||||
|
||||
CacheExpeditions(std::move(expeditions));
|
||||
|
||||
LogExpeditions("Caching [{}] expedition(s) took [{}s]", m_expeditions.size(), benchmark.elapsed());
|
||||
}
|
||||
|
||||
void ExpeditionState::CacheExpeditions(
|
||||
std::vector<ExpeditionsRepository::ExpeditionWithLeader>&& expedition_entries)
|
||||
{
|
||||
// bulk load expedition dzs and members before caching
|
||||
std::vector<uint32_t> dynamic_zone_ids;
|
||||
for (const auto& entry : expedition_entries)
|
||||
{
|
||||
dynamic_zone_ids.emplace_back(entry.dynamic_zone_id);
|
||||
}
|
||||
|
||||
auto dynamic_zones = DynamicZonesRepository::GetWithInstance(database, dynamic_zone_ids);
|
||||
auto dynamic_zone_members = DynamicZoneMembersRepository::GetWithNames(database, dynamic_zone_ids);
|
||||
|
||||
for (auto& entry : expedition_entries)
|
||||
{
|
||||
auto expedition = std::make_unique<Expedition>();
|
||||
expedition->LoadRepositoryResult(std::move(entry));
|
||||
|
||||
auto dz_entry_iter = std::find_if(dynamic_zones.begin(), dynamic_zones.end(),
|
||||
[&](const DynamicZonesRepository::DynamicZoneInstance& dz_entry) {
|
||||
return dz_entry.id == entry.dynamic_zone_id;
|
||||
});
|
||||
|
||||
if (dz_entry_iter != dynamic_zones.end())
|
||||
{
|
||||
expedition->SetDynamicZone(std::move(*dz_entry_iter));
|
||||
}
|
||||
|
||||
for (auto& member : dynamic_zone_members)
|
||||
{
|
||||
if (member.dynamic_zone_id == entry.dynamic_zone_id)
|
||||
{
|
||||
expedition->GetDynamicZone().AddMemberFromRepositoryResult(std::move(member));
|
||||
}
|
||||
}
|
||||
|
||||
// stored on expedition in db but on dz in memory cache
|
||||
expedition->GetDynamicZone().SetMinPlayers(entry.min_players);
|
||||
expedition->GetDynamicZone().SetMaxPlayers(entry.max_players);
|
||||
|
||||
expedition->CacheMemberStatuses();
|
||||
|
||||
m_expeditions.emplace_back(std::move(expedition));
|
||||
}
|
||||
}
|
||||
|
||||
void ExpeditionState::MemberChange(
|
||||
uint32_t expedition_id, const DynamicZoneMember& member, bool remove)
|
||||
{
|
||||
auto expedition = GetExpedition(expedition_id);
|
||||
if (expedition)
|
||||
{
|
||||
if (remove) {
|
||||
expedition->RemoveMember(member.id);
|
||||
} else {
|
||||
expedition->GetDynamicZone().AddInternalMember(member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExpeditionState::RemoveAllMembers(uint32_t expedition_id)
|
||||
{
|
||||
auto expedition = GetExpedition(expedition_id);
|
||||
if (expedition)
|
||||
{
|
||||
expedition->GetDynamicZone().ClearInternalMembers();
|
||||
}
|
||||
}
|
||||
|
||||
void ExpeditionState::Process()
|
||||
{
|
||||
if (!m_process_throttle_timer.Check())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<uint32_t> expedition_ids;
|
||||
std::vector<uint32_t> dynamic_zone_ids;
|
||||
|
||||
for (auto it = m_expeditions.begin(); it != m_expeditions.end();)
|
||||
{
|
||||
bool is_deleted = (*it)->Process();
|
||||
if (is_deleted)
|
||||
{
|
||||
expedition_ids.emplace_back((*it)->GetID());
|
||||
dynamic_zone_ids.emplace_back((*it)->GetDynamicZone().GetID());
|
||||
}
|
||||
it = is_deleted ? m_expeditions.erase(it) : it + 1;
|
||||
}
|
||||
|
||||
if (!expedition_ids.empty())
|
||||
{
|
||||
ExpeditionDatabase::MoveMembersToSafeReturn(expedition_ids);
|
||||
ExpeditionDatabase::DeleteExpeditions(expedition_ids);
|
||||
DynamicZoneMembersRepository::RemoveAllMembers(database, dynamic_zone_ids);
|
||||
}
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
/**
|
||||
* 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 WORLD_EXPEDITION_STATE_H
|
||||
#define WORLD_EXPEDITION_STATE_H
|
||||
|
||||
#include "../common/repositories/expeditions_repository.h"
|
||||
#include "../common/rulesys.h"
|
||||
#include "../common/timer.h"
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
extern class ExpeditionState expedition_state;
|
||||
|
||||
class Expedition;
|
||||
struct DynamicZoneMember;
|
||||
|
||||
class ExpeditionState
|
||||
{
|
||||
public:
|
||||
void CacheExpeditions(std::vector<ExpeditionsRepository::ExpeditionWithLeader>&& expedition_entries);
|
||||
void CacheFromDatabase(uint32_t expedition_id);
|
||||
void CacheAllFromDatabase();
|
||||
Expedition* GetExpedition(uint32_t expedition_id);
|
||||
Expedition* GetExpeditionByDynamicZoneID(uint32_t dz_id);
|
||||
void MemberChange(uint32_t expedition_id, const DynamicZoneMember& member, bool remove);
|
||||
void Process();
|
||||
void RemoveAllMembers(uint32_t expedition_id);
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<Expedition>> m_expeditions;
|
||||
Timer m_process_throttle_timer{static_cast<uint32_t>(RuleI(DynamicZone, WorldProcessRate))};
|
||||
};
|
||||
|
||||
#endif
|
||||
244
world/main.cpp
244
world/main.cpp
@ -46,6 +46,7 @@
|
||||
#include "../common/crash.h"
|
||||
#include "client.h"
|
||||
#include "worlddb.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <process.h>
|
||||
#define snprintf _snprintf
|
||||
@ -53,12 +54,14 @@
|
||||
#define strcasecmp _stricmp
|
||||
#include <conio.h>
|
||||
#else
|
||||
|
||||
#include <pthread.h>
|
||||
#include "../common/unix.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/sem.h>
|
||||
#include <sys/shm.h>
|
||||
|
||||
#if not defined (FREEBSD) && not defined (DARWIN)
|
||||
union semun {
|
||||
int val;
|
||||
@ -88,41 +91,45 @@ union semun {
|
||||
#include "queryserv.h"
|
||||
#include "web_interface.h"
|
||||
#include "console.h"
|
||||
#include "dynamic_zone_manager.h"
|
||||
#include "expedition_database.h"
|
||||
#include "expedition_state.h"
|
||||
|
||||
#include "../common/net/servertalk_server.h"
|
||||
#include "../zone/data_bucket.h"
|
||||
#include "world_server_command_handler.h"
|
||||
#include "../common/content/world_content_service.h"
|
||||
#include "../common/repositories/character_task_timers_repository.h"
|
||||
#include "../common/repositories/merchantlist_temp_repository.h"
|
||||
#include "world_store.h"
|
||||
#include "world_event_scheduler.h"
|
||||
#include "shared_task_manager.h"
|
||||
|
||||
WorldStore world_store;
|
||||
ClientList client_list;
|
||||
GroupLFPList LFPGroupList;
|
||||
ZSList zoneserver_list;
|
||||
LoginServerList loginserverlist;
|
||||
UCSConnection UCSLink;
|
||||
WorldStore world_store;
|
||||
ClientList client_list;
|
||||
GroupLFPList LFPGroupList;
|
||||
ZSList zoneserver_list;
|
||||
LoginServerList loginserverlist;
|
||||
UCSConnection UCSLink;
|
||||
QueryServConnection QSLink;
|
||||
LauncherList launcher_list;
|
||||
AdventureManager adventure_manager;
|
||||
LauncherList launcher_list;
|
||||
AdventureManager adventure_manager;
|
||||
WorldEventScheduler event_scheduler;
|
||||
EQ::Random emu_random;
|
||||
volatile bool RunLoops = true;
|
||||
uint32 numclients = 0;
|
||||
uint32 numzones = 0;
|
||||
bool holdzones = false;
|
||||
const WorldConfig *Config;
|
||||
EQEmuLogSys LogSys;
|
||||
SharedTaskManager shared_task_manager;
|
||||
EQ::Random emu_random;
|
||||
volatile bool RunLoops = true;
|
||||
uint32 numclients = 0;
|
||||
uint32 numzones = 0;
|
||||
bool holdzones = false;
|
||||
const WorldConfig *Config;
|
||||
EQEmuLogSys LogSys;
|
||||
WorldContentService content_service;
|
||||
WebInterfaceList web_interface;
|
||||
WebInterfaceList web_interface;
|
||||
|
||||
void CatchSignal(int sig_num);
|
||||
void CheckForServerScript(bool force_download = false);
|
||||
|
||||
inline void UpdateWindowTitle(std::string new_title) {
|
||||
inline void UpdateWindowTitle(std::string new_title)
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
SetConsoleTitle(new_title.c_str());
|
||||
#endif
|
||||
@ -154,7 +161,7 @@ void LoadDatabaseConnections()
|
||||
*/
|
||||
if (!Config->ContentDbHost.empty()) {
|
||||
if (!content_db.Connect(
|
||||
Config->ContentDbHost.c_str() ,
|
||||
Config->ContentDbHost.c_str(),
|
||||
Config->ContentDbUsername.c_str(),
|
||||
Config->ContentDbPassword.c_str(),
|
||||
Config->ContentDbName.c_str(),
|
||||
@ -164,7 +171,8 @@ void LoadDatabaseConnections()
|
||||
LogError("Cannot continue without a content database connection");
|
||||
std::exit(1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
content_db.SetMysql(database.getMySQL());
|
||||
}
|
||||
|
||||
@ -174,7 +182,7 @@ void CheckForXMLConfigUpgrade()
|
||||
{
|
||||
if (!std::ifstream("eqemu_config.json") && std::ifstream("eqemu_config.xml")) {
|
||||
CheckForServerScript(true);
|
||||
if(system("perl eqemu_server.pl convert_xml"));
|
||||
if (system("perl eqemu_server.pl convert_xml")) {}
|
||||
}
|
||||
else {
|
||||
CheckForServerScript();
|
||||
@ -205,7 +213,7 @@ void RegisterLoginservers()
|
||||
}
|
||||
}
|
||||
else {
|
||||
LinkedList<LoginConfig *> loginlist = Config->loginlist;
|
||||
LinkedList<LoginConfig *> loginlist = Config->loginlist;
|
||||
LinkedListIterator<LoginConfig *> iterator(loginlist);
|
||||
iterator.Reset();
|
||||
while (iterator.MoreElements()) {
|
||||
@ -274,7 +282,8 @@ static void GMSayHookCallBackProcessWorld(uint16 log_category, std::string messa
|
||||
* @param argv
|
||||
* @return
|
||||
*/
|
||||
int main(int argc, char** argv) {
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
RegisterExecutablePlatform(ExePlatformWorld);
|
||||
LogSys.LoadLogSettingsDefaults();
|
||||
set_exception_handler();
|
||||
@ -445,7 +454,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
LogInfo("Loading EQ time of day");
|
||||
TimeOfDay_Struct eqTime;
|
||||
time_t realtime;
|
||||
time_t realtime;
|
||||
eqTime = database.LoadTime(realtime);
|
||||
zoneserver_list.worldclock.SetCurrentEQTimeOfDay(eqTime, realtime);
|
||||
Timer EQTimeTimer(600000);
|
||||
@ -457,37 +466,50 @@ int main(int argc, char** argv) {
|
||||
LogInfo("Deleted [{}] stale player corpses from database", database.DeleteStalePlayerCorpses());
|
||||
|
||||
LogInfo("Loading adventures");
|
||||
if (!adventure_manager.LoadAdventureTemplates())
|
||||
{
|
||||
if (!adventure_manager.LoadAdventureTemplates()) {
|
||||
LogInfo("Unable to load adventure templates");
|
||||
}
|
||||
|
||||
if (!adventure_manager.LoadAdventureEntries())
|
||||
{
|
||||
if (!adventure_manager.LoadAdventureEntries()) {
|
||||
LogInfo("Unable to load adventure templates");
|
||||
}
|
||||
|
||||
adventure_manager.LoadLeaderboardInfo();
|
||||
|
||||
LogInfo("Purging expired dynamic zones and members");
|
||||
dynamic_zone_manager.PurgeExpiredDynamicZones();
|
||||
|
||||
LogInfo("Purging expired expeditions");
|
||||
ExpeditionDatabase::PurgeExpiredExpeditions();
|
||||
ExpeditionDatabase::PurgeExpiredCharacterLockouts();
|
||||
|
||||
LogInfo("Purging expired character task timers");
|
||||
CharacterTaskTimersRepository::DeleteWhere(database, "expire_time <= NOW()");
|
||||
|
||||
LogInfo("Purging expired instances");
|
||||
database.PurgeExpiredInstances();
|
||||
|
||||
Timer PurgeInstanceTimer(450000);
|
||||
PurgeInstanceTimer.Start(450000);
|
||||
|
||||
LogInfo("Loading active expeditions");
|
||||
expedition_state.CacheAllFromDatabase();
|
||||
LogInfo("Loading dynamic zones");
|
||||
dynamic_zone_manager.CacheAllFromDatabase();
|
||||
|
||||
LogInfo("Loading char create info");
|
||||
content_db.LoadCharacterCreateAllocations();
|
||||
content_db.LoadCharacterCreateCombos();
|
||||
|
||||
LogInfo("Initializing [EventScheduler]");
|
||||
event_scheduler.SetDatabase(&database)->LoadScheduledEvents();
|
||||
|
||||
LogInfo("Initializing [SharedTaskManager]");
|
||||
shared_task_manager.SetDatabase(&database)
|
||||
->SetContentDatabase(&content_db)
|
||||
->LoadTaskData()
|
||||
->LoadSharedTaskState();
|
||||
|
||||
shared_task_manager.PurgeExpiredSharedTasks();
|
||||
|
||||
std::unique_ptr<EQ::Net::ConsoleServer> console;
|
||||
if (Config->TelnetEnabled) {
|
||||
LogInfo("Console (TCP) listener started");
|
||||
@ -500,8 +522,8 @@ int main(int argc, char** argv) {
|
||||
server_connection = std::make_unique<EQ::Net::ServertalkServer>();
|
||||
|
||||
EQ::Net::ServertalkServerOptions server_opts;
|
||||
server_opts.port = Config->WorldTCPPort;
|
||||
server_opts.ipv6 = false;
|
||||
server_opts.port = Config->WorldTCPPort;
|
||||
server_opts.ipv6 = false;
|
||||
server_opts.credentials = Config->SharedKey;
|
||||
server_connection->Listen(server_opts);
|
||||
LogInfo("Server (TCP) listener started");
|
||||
@ -516,50 +538,62 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
);
|
||||
|
||||
server_connection->OnConnectionRemoved("Zone", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("Removed Zone Server connection from [{0}]",
|
||||
connection->GetUUID());
|
||||
server_connection->OnConnectionRemoved(
|
||||
"Zone", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("Removed Zone Server connection from [{0}]",
|
||||
connection->GetUUID());
|
||||
|
||||
numzones--;
|
||||
zoneserver_list.Remove(connection->GetUUID());
|
||||
});
|
||||
numzones--;
|
||||
zoneserver_list.Remove(connection->GetUUID());
|
||||
}
|
||||
);
|
||||
|
||||
server_connection->OnConnectionIdentified("Launcher", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("New Launcher connection from [{2}] at [{0}:{1}]",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
server_connection->OnConnectionIdentified(
|
||||
"Launcher", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("New Launcher connection from [{2}] at [{0}:{1}]",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
|
||||
launcher_list.Add(connection);
|
||||
});
|
||||
launcher_list.Add(connection);
|
||||
}
|
||||
);
|
||||
|
||||
server_connection->OnConnectionRemoved("Launcher", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("Removed Launcher connection from [{0}]",
|
||||
connection->GetUUID());
|
||||
server_connection->OnConnectionRemoved(
|
||||
"Launcher", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("Removed Launcher connection from [{0}]",
|
||||
connection->GetUUID());
|
||||
|
||||
launcher_list.Remove(connection);
|
||||
});
|
||||
launcher_list.Remove(connection);
|
||||
}
|
||||
);
|
||||
|
||||
server_connection->OnConnectionIdentified("QueryServ", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("New Query Server connection from [{2}] at [{0}:{1}]",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
server_connection->OnConnectionIdentified(
|
||||
"QueryServ", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("New Query Server connection from [{2}] at [{0}:{1}]",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
|
||||
QSLink.AddConnection(connection);
|
||||
});
|
||||
QSLink.AddConnection(connection);
|
||||
}
|
||||
);
|
||||
|
||||
server_connection->OnConnectionRemoved("QueryServ", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("Removed Query Server connection from [{0}]",
|
||||
connection->GetUUID());
|
||||
server_connection->OnConnectionRemoved(
|
||||
"QueryServ", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("Removed Query Server connection from [{0}]",
|
||||
connection->GetUUID());
|
||||
|
||||
QSLink.RemoveConnection(connection);
|
||||
});
|
||||
QSLink.RemoveConnection(connection);
|
||||
}
|
||||
);
|
||||
|
||||
server_connection->OnConnectionIdentified("UCS", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("New UCS Server connection from [{2}] at [{0}:{1}]",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
server_connection->OnConnectionIdentified(
|
||||
"UCS", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("New UCS Server connection from [{2}] at [{0}:{1}]",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
|
||||
UCSLink.SetConnection(connection);
|
||||
UCSLink.SetConnection(connection);
|
||||
|
||||
zoneserver_list.UpdateUCSServerAvailable();
|
||||
});
|
||||
zoneserver_list.UpdateUCSServerAvailable();
|
||||
}
|
||||
);
|
||||
|
||||
server_connection->OnConnectionRemoved(
|
||||
"UCS", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
@ -575,26 +609,30 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
);
|
||||
|
||||
server_connection->OnConnectionIdentified("WebInterface", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("New WebInterface Server connection from [{2}] at [{0}:{1}]",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
server_connection->OnConnectionIdentified(
|
||||
"WebInterface", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("New WebInterface Server connection from [{2}] at [{0}:{1}]",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
|
||||
web_interface.AddConnection(connection);
|
||||
});
|
||||
web_interface.AddConnection(connection);
|
||||
}
|
||||
);
|
||||
|
||||
server_connection->OnConnectionRemoved("WebInterface", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("Removed WebInterface Server connection from [{0}]",
|
||||
connection->GetUUID());
|
||||
server_connection->OnConnectionRemoved(
|
||||
"WebInterface", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogInfo("Removed WebInterface Server connection from [{0}]",
|
||||
connection->GetUUID());
|
||||
|
||||
web_interface.RemoveConnection(connection);
|
||||
});
|
||||
web_interface.RemoveConnection(connection);
|
||||
}
|
||||
);
|
||||
|
||||
EQStreamManagerInterfaceOptions opts(9000, false, false);
|
||||
opts.daybreak_options.resend_delay_ms = RuleI(Network, ResendDelayBaseMS);
|
||||
opts.daybreak_options.resend_delay_ms = RuleI(Network, ResendDelayBaseMS);
|
||||
opts.daybreak_options.resend_delay_factor = RuleR(Network, ResendDelayFactor);
|
||||
opts.daybreak_options.resend_delay_min = RuleI(Network, ResendDelayMinMS);
|
||||
opts.daybreak_options.resend_delay_max = RuleI(Network, ResendDelayMaxMS);
|
||||
opts.daybreak_options.outgoing_data_rate = RuleR(Network, ClientDataRate);
|
||||
opts.daybreak_options.resend_delay_min = RuleI(Network, ResendDelayMinMS);
|
||||
opts.daybreak_options.resend_delay_max = RuleI(Network, ResendDelayMaxMS);
|
||||
opts.daybreak_options.outgoing_data_rate = RuleR(Network, ClientDataRate);
|
||||
|
||||
EQ::Net::EQStreamManager eqsm(opts);
|
||||
|
||||
@ -607,14 +645,16 @@ int main(int argc, char** argv) {
|
||||
zoneserver_list.reminder->Disable();
|
||||
Timer InterserverTimer(INTERSERVER_TIMER); // does MySQL pings and auto-reconnect
|
||||
InterserverTimer.Trigger();
|
||||
uint8 ReconnectCounter = 100;
|
||||
uint8 ReconnectCounter = 100;
|
||||
std::shared_ptr<EQStreamInterface> eqs;
|
||||
EQStreamInterface *eqsi;
|
||||
EQStreamInterface *eqsi;
|
||||
|
||||
eqsm.OnNewConnection([&stream_identifier](std::shared_ptr<EQ::Net::EQStream> stream) {
|
||||
stream_identifier.AddStream(stream);
|
||||
LogInfo("New connection from IP {0}:{1}", stream->GetRemoteIP(), ntohs(stream->GetRemotePort()));
|
||||
});
|
||||
eqsm.OnNewConnection(
|
||||
[&stream_identifier](std::shared_ptr<EQ::Net::EQStream> stream) {
|
||||
stream_identifier.AddStream(stream);
|
||||
LogInfo("New connection from IP {0}:{1}", stream->GetRemoteIP(), ntohs(stream->GetRemotePort()));
|
||||
}
|
||||
);
|
||||
|
||||
while (RunLoops) {
|
||||
Timer::SetCurrentTime();
|
||||
@ -626,7 +666,7 @@ int main(int argc, char** argv) {
|
||||
//check the stream identifier for any now-identified streams
|
||||
while ((eqsi = stream_identifier.PopIdentified())) {
|
||||
//now that we know what patch they are running, start up their client object
|
||||
struct in_addr in{};
|
||||
struct in_addr in{};
|
||||
in.s_addr = eqsi->GetRemoteIP();
|
||||
if (RuleB(World, UseBannedIPsTable)) { //Lieka: Check to see if we have the responsibility for blocking IPs.
|
||||
LogInfo("Checking inbound connection [{}] against BannedIPs table", inet_ntoa(in));
|
||||
@ -642,7 +682,11 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
if (!RuleB(World, UseBannedIPsTable)) {
|
||||
LogInfo("New connection from [{}]:[{}], processing connection", inet_ntoa(in), ntohs(eqsi->GetRemotePort()));
|
||||
LogInfo(
|
||||
"New connection from [{}]:[{}], processing connection",
|
||||
inet_ntoa(in),
|
||||
ntohs(eqsi->GetRemotePort())
|
||||
);
|
||||
auto client = new Client(eqsi);
|
||||
// @merth: client->zoneattempt=0;
|
||||
client_list.Add(client);
|
||||
@ -657,6 +701,7 @@ int main(int argc, char** argv) {
|
||||
database.PurgeExpiredInstances();
|
||||
database.PurgeAllDeletedDataBuckets();
|
||||
ExpeditionDatabase::PurgeExpiredCharacterLockouts();
|
||||
CharacterTaskTimersRepository::DeleteWhere(database, "expire_time <= NOW()");
|
||||
}
|
||||
|
||||
if (EQTimeTimer.Check()) {
|
||||
@ -672,14 +717,18 @@ int main(int argc, char** argv) {
|
||||
launcher_list.Process();
|
||||
LFPGroupList.Process();
|
||||
adventure_manager.Process();
|
||||
expedition_state.Process();
|
||||
dynamic_zone_manager.Process();
|
||||
|
||||
if (InterserverTimer.Check()) {
|
||||
InterserverTimer.Start();
|
||||
database.ping();
|
||||
content_db.ping();
|
||||
|
||||
std::string window_title = StringFormat("World: %s Clients: %i", Config->LongName.c_str(), client_list.GetClientCount());
|
||||
std::string window_title = StringFormat(
|
||||
"World: %s Clients: %i",
|
||||
Config->LongName.c_str(),
|
||||
client_list.GetClientCount()
|
||||
);
|
||||
UpdateWindowTitle(window_title);
|
||||
}
|
||||
|
||||
@ -696,12 +745,14 @@ int main(int argc, char** argv) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CatchSignal(int sig_num) {
|
||||
void CatchSignal(int sig_num)
|
||||
{
|
||||
LogInfo("Caught signal [{}]", sig_num);
|
||||
RunLoops = false;
|
||||
}
|
||||
|
||||
void UpdateWindowTitle(char* iNewTitle) {
|
||||
void UpdateWindowTitle(char *iNewTitle)
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
char tmp[500];
|
||||
if (iNewTitle) {
|
||||
@ -714,18 +765,23 @@ void UpdateWindowTitle(char* iNewTitle) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void CheckForServerScript(bool force_download) {
|
||||
void CheckForServerScript(bool force_download)
|
||||
{
|
||||
/* Fetch EQEmu Server script */
|
||||
if (!std::ifstream("eqemu_server.pl") || force_download) {
|
||||
|
||||
if(force_download)
|
||||
std::remove("eqemu_server.pl"); /* Delete local before fetch */
|
||||
if (force_download) {
|
||||
std::remove("eqemu_server.pl");
|
||||
} /* Delete local before fetch */
|
||||
|
||||
std::cout << "Pulling down EQEmu Server Maintenance Script (eqemu_server.pl)..." << std::endl;
|
||||
#ifdef _WIN32
|
||||
if(system("perl -MLWP::UserAgent -e \"require LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; my $response = $ua->get('https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/eqemu_server.pl'); if ($response->is_success){ open(FILE, '> eqemu_server.pl'); print FILE $response->decoded_content; close(FILE); }\""));
|
||||
#else
|
||||
if(system("wget -N --no-check-certificate --quiet -O eqemu_server.pl https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/eqemu_server.pl"));
|
||||
if (system(
|
||||
"wget -N --no-check-certificate --quiet -O eqemu_server.pl https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/eqemu_server.pl"
|
||||
)) {}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1820
world/shared_task_manager.cpp
Normal file
1820
world/shared_task_manager.cpp
Normal file
File diff suppressed because it is too large
Load Diff
132
world/shared_task_manager.h
Normal file
132
world/shared_task_manager.h
Normal file
@ -0,0 +1,132 @@
|
||||
#ifndef EQEMU_SHARED_TASK_MANAGER_H
|
||||
#define EQEMU_SHARED_TASK_MANAGER_H
|
||||
|
||||
#include "../common/database.h"
|
||||
#include "../common/shared_tasks.h"
|
||||
|
||||
class DynamicZone;
|
||||
|
||||
namespace EQ {
|
||||
namespace Net {
|
||||
class DynamicPacket;
|
||||
}
|
||||
}
|
||||
|
||||
struct SharedTaskActiveInvitation {
|
||||
uint32 shared_task_id;
|
||||
uint32 character_id;
|
||||
};
|
||||
|
||||
class SharedTaskManager {
|
||||
public:
|
||||
SharedTaskManager *SetDatabase(Database *db);
|
||||
SharedTaskManager *SetContentDatabase(Database *db);
|
||||
|
||||
// loads task data into memory
|
||||
SharedTaskManager *LoadTaskData();
|
||||
|
||||
// loads shared task state into memory
|
||||
void LoadSharedTaskState();
|
||||
|
||||
// helper, references task memory data
|
||||
TasksRepository::Tasks GetSharedTaskDataByTaskId(uint32 task_id);
|
||||
std::vector<TaskActivitiesRepository::TaskActivities> GetSharedTaskActivityDataByTaskId(uint32 task_id);
|
||||
|
||||
// gets group / raid members belonging to requested character
|
||||
std::vector<SharedTaskMember> GetRequestMembers(
|
||||
uint32 requestor_character_id,
|
||||
const std::vector<CharacterDataRepository::CharacterData> &characters
|
||||
);
|
||||
|
||||
// client attempting to create a shared task
|
||||
void AttemptSharedTaskCreation(uint32 requested_task_id, uint32 requested_character_id, uint32 npc_type_id);
|
||||
void AttemptSharedTaskRemoval(uint32 requested_task_id, uint32 requested_character_id, bool remove_from_db);
|
||||
|
||||
// shared task activity update middleware
|
||||
void SharedTaskActivityUpdate(
|
||||
uint32 source_character_id,
|
||||
uint32 task_id,
|
||||
uint32 activity_id,
|
||||
uint32 done_count,
|
||||
bool ignore_quest_update
|
||||
);
|
||||
|
||||
SharedTask *FindSharedTaskByTaskIdAndCharacterId(uint32 task_id, uint32 character_id);
|
||||
SharedTask *FindSharedTaskById(int64 shared_task_id);
|
||||
|
||||
void DeleteSharedTask(int64 shared_task_id);
|
||||
void SaveSharedTaskActivityState(int64 shared_task_id, std::vector<SharedTaskActivityStateEntry> activity_state);
|
||||
|
||||
bool IsSharedTaskLeader(SharedTask *s, uint32 character_id);
|
||||
void SendAcceptNewSharedTaskPacket(uint32 character_id, uint32 task_id, uint32_t npc_context_id, int accept_time);
|
||||
void SendRemovePlayerFromSharedTaskPacket(uint32 character_id, uint32 task_id, bool remove_from_db);
|
||||
void SendSharedTaskMemberList(uint32 character_id, const std::vector<SharedTaskMember> &members);
|
||||
void SendSharedTaskMemberList(uint32 character_id, const EQ::Net::DynamicPacket &serialized_members);
|
||||
void SendSharedTaskMemberChange(
|
||||
uint32 character_id,
|
||||
int64 shared_task_id,
|
||||
const std::string &player_name,
|
||||
bool removed
|
||||
);
|
||||
void RemovePlayerFromSharedTask(SharedTask *s, uint32 character_id);
|
||||
void PrintSharedTaskState();
|
||||
void RemovePlayerFromSharedTaskByPlayerName(SharedTask *s, const std::string &character_name);
|
||||
void RemoveEveryoneFromSharedTask(SharedTask *s, uint32 requested_character_id);
|
||||
|
||||
void MakeLeaderByPlayerName(SharedTask *s, const std::string &character_name);
|
||||
void AddPlayerByCharacterIdAndName(SharedTask *s, int64 character_id, const std::string &character_name);
|
||||
void InvitePlayerByPlayerName(SharedTask *s, const std::string &player_name);
|
||||
|
||||
// invitations
|
||||
void QueueActiveInvitation(int64 shared_task_id, int64 character_id);
|
||||
bool IsInvitationActive(uint32 shared_task_id, uint32 character_id);
|
||||
void RemoveActiveInvitation(int64 shared_task_id, int64 character_id);
|
||||
void RemoveActiveInvitationByCharacterID(uint32_t character_id);
|
||||
|
||||
// dz
|
||||
void CreateDynamicZone(SharedTask *s, DynamicZone &dz_request);
|
||||
|
||||
void PurgeAllSharedTasks();
|
||||
|
||||
// messages
|
||||
void SendLeaderMessage(SharedTask *s, int chat_type, const std::string &message);
|
||||
void SendLeaderMessageID(SharedTask *s, int chat_type, int eqstr_id, std::initializer_list<std::string> args = {});
|
||||
void SendMembersMessage(SharedTask *s, int chat_type, const std::string &message);
|
||||
void SendMembersMessageID(SharedTask *s, int chat_type, int eqstr_id, std::initializer_list<std::string> args = {});
|
||||
|
||||
const std::vector<SharedTask> &GetSharedTasks() const;
|
||||
void SetSharedTasks(const std::vector<SharedTask> &shared_tasks);
|
||||
|
||||
SharedTaskManager * PurgeExpiredSharedTasks();
|
||||
protected:
|
||||
// reference to database
|
||||
Database *m_database;
|
||||
Database *m_content_database;
|
||||
|
||||
// reference to task data (all)
|
||||
std::vector<TasksRepository::Tasks> m_task_data{};
|
||||
std::vector<TaskActivitiesRepository::TaskActivities> m_task_activity_data{};
|
||||
|
||||
// internal shared tasks list
|
||||
std::vector<SharedTask> m_shared_tasks{};
|
||||
|
||||
// store a reference of active invitations that have been sent to players
|
||||
std::vector<SharedTaskActiveInvitation> m_active_invitations{};
|
||||
|
||||
void AddReplayTimers(SharedTask *s);
|
||||
bool CanAddPlayer(SharedTask *s, uint32_t character_id, std::string player_name, bool accepted);
|
||||
bool CanRequestSharedTask(uint32_t task_id, uint32_t character_id, const SharedTaskRequestCharacters &request);
|
||||
void ChooseNewLeader(SharedTask *s);
|
||||
void SendSharedTaskMemberListToAllMembers(SharedTask *s);
|
||||
void SendSharedTaskMemberAddedToAllMembers(SharedTask *s, const std::string &player_name);
|
||||
void SendSharedTaskMemberRemovedToAllMembers(SharedTask *s, const std::string &player_name);
|
||||
void SaveMembers(SharedTask *s, std::vector<SharedTaskMember> members);
|
||||
void SendSharedTaskInvitePacket(SharedTask *s, int64 invited_character_id);
|
||||
void RecordSharedTaskCompletion(SharedTask *s);
|
||||
void RemoveAllMembersFromDynamicZones(SharedTask *s);
|
||||
|
||||
// memory search
|
||||
std::vector<uint32_t> FindCharactersInSharedTasks(const std::vector<uint32_t> &find_characters);
|
||||
};
|
||||
|
||||
#endif //EQEMU_SHARED_TASK_MANAGER_H
|
||||
355
world/shared_task_world_messaging.cpp
Normal file
355
world/shared_task_world_messaging.cpp
Normal file
@ -0,0 +1,355 @@
|
||||
#include "shared_task_world_messaging.h"
|
||||
#include "cliententry.h"
|
||||
#include "worlddb.h"
|
||||
#include "../common/shared_tasks.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/repositories/tasks_repository.h"
|
||||
#include "../common/tasks.h"
|
||||
#include "cliententry.h"
|
||||
#include "clientlist.h"
|
||||
#include "zonelist.h"
|
||||
#include "zoneserver.h"
|
||||
#include "shared_task_manager.h"
|
||||
#include "../common/repositories/shared_task_members_repository.h"
|
||||
#include "../common/repositories/task_activities_repository.h"
|
||||
#include "dynamic_zone.h"
|
||||
|
||||
extern ClientList client_list;
|
||||
extern ZSList zoneserver_list;
|
||||
extern SharedTaskManager shared_task_manager;
|
||||
|
||||
void SharedTaskWorldMessaging::HandleZoneMessage(ServerPacket *pack)
|
||||
{
|
||||
switch (pack->opcode) {
|
||||
case ServerOP_SharedTaskRequest: {
|
||||
auto *r = (ServerSharedTaskRequest_Struct *) pack->pBuffer;
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskRequest] Received request from character [{}] task_id [{}] npc_type_id [{}]",
|
||||
r->requested_character_id,
|
||||
r->requested_task_id,
|
||||
r->requested_npc_type_id
|
||||
);
|
||||
|
||||
shared_task_manager.AttemptSharedTaskCreation(
|
||||
r->requested_task_id,
|
||||
r->requested_character_id,
|
||||
r->requested_npc_type_id
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskAttemptRemove: {
|
||||
auto *r = (ServerSharedTaskAttemptRemove_Struct *) pack->pBuffer;
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskAttemptRemove] Received request from character [{}] task_id [{}] remove_from_db [{}]",
|
||||
r->requested_character_id,
|
||||
r->requested_task_id,
|
||||
r->remove_from_db
|
||||
);
|
||||
|
||||
shared_task_manager.AttemptSharedTaskRemoval(
|
||||
r->requested_task_id,
|
||||
r->requested_character_id,
|
||||
r->remove_from_db
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskKickPlayers: {
|
||||
auto r = reinterpret_cast<ServerSharedTaskKickPlayers_Struct *>(pack->pBuffer);
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskKickPlayers] Received request from character [{}] task_id [{}]",
|
||||
r->source_character_id,
|
||||
r->task_id
|
||||
);
|
||||
|
||||
auto t = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->source_character_id);
|
||||
if (t) {
|
||||
auto leader = t->GetLeader();
|
||||
if (leader.character_id != r->source_character_id) {
|
||||
client_list.SendCharacterMessageID(
|
||||
r->source_character_id, Chat::Red,
|
||||
SharedTaskMessage::YOU_ARE_NOT_LEADER_COMMAND_ISSUE, {leader.character_name}
|
||||
);
|
||||
}
|
||||
else {
|
||||
shared_task_manager.RemoveEveryoneFromSharedTask(t, r->source_character_id);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskUpdate: {
|
||||
auto *r = (ServerSharedTaskActivityUpdate_Struct *) pack->pBuffer;
|
||||
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskUpdate] Received request from character [{}] task_id [{}] activity_id [{}] donecount [{}] ignore_quest_update [{}]",
|
||||
r->source_character_id,
|
||||
r->task_id,
|
||||
r->activity_id,
|
||||
r->done_count,
|
||||
(r->ignore_quest_update ? "true" : "false")
|
||||
);
|
||||
|
||||
shared_task_manager.SharedTaskActivityUpdate(
|
||||
r->source_character_id,
|
||||
r->task_id,
|
||||
r->activity_id,
|
||||
r->done_count,
|
||||
r->ignore_quest_update
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskRequestMemberlist: {
|
||||
auto *r = (ServerSharedTaskRequestMemberlist_Struct *) pack->pBuffer;
|
||||
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskRequestMemberlist] Received request from character [{}] task_id [{}]",
|
||||
r->source_character_id,
|
||||
r->task_id
|
||||
);
|
||||
|
||||
auto t = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->source_character_id);
|
||||
if (t) {
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskRequestMemberlist] Found shared task character [{}] shared_task_id [{}]",
|
||||
r->source_character_id,
|
||||
t->GetDbSharedTask().id
|
||||
);
|
||||
|
||||
shared_task_manager.SendSharedTaskMemberList(
|
||||
r->source_character_id,
|
||||
t->GetMembers()
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskRemovePlayer: {
|
||||
auto *r = (ServerSharedTaskRemovePlayer_Struct *) pack->pBuffer;
|
||||
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskRemovePlayer] Received request from character [{}] task_id [{}] player_name [{}]",
|
||||
r->source_character_id,
|
||||
r->task_id,
|
||||
r->player_name
|
||||
);
|
||||
|
||||
auto t = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->source_character_id);
|
||||
if (t) {
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskRemovePlayer] Found shared task character [{}] shared_task_id [{}]",
|
||||
r->source_character_id,
|
||||
t->GetDbSharedTask().id
|
||||
);
|
||||
|
||||
auto leader = t->GetLeader();
|
||||
if (leader.character_id != r->source_character_id) {
|
||||
client_list.SendCharacterMessageID(
|
||||
r->source_character_id, Chat::Red,
|
||||
SharedTaskMessage::YOU_ARE_NOT_LEADER_COMMAND_ISSUE, {leader.character_name}
|
||||
);
|
||||
}
|
||||
else {
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskRemovePlayer] character_id [{}] shared_task_id [{}] is_leader",
|
||||
r->source_character_id,
|
||||
t->GetDbSharedTask().id
|
||||
);
|
||||
|
||||
std::string character_name = r->player_name;
|
||||
shared_task_manager.RemovePlayerFromSharedTaskByPlayerName(t, character_name);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskMakeLeader: {
|
||||
auto *r = (ServerSharedTaskMakeLeader_Struct *) pack->pBuffer;
|
||||
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskMakeLeader] Received request from character [{}] task_id [{}] player_name [{}]",
|
||||
r->source_character_id,
|
||||
r->task_id,
|
||||
r->player_name
|
||||
);
|
||||
|
||||
auto t = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->source_character_id);
|
||||
if (t) {
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskMakeLeader] Found shared task character [{}] shared_task_id [{}]",
|
||||
r->source_character_id,
|
||||
t->GetDbSharedTask().id
|
||||
);
|
||||
|
||||
auto leader = t->GetLeader();
|
||||
if (leader.character_id != r->source_character_id) {
|
||||
client_list.SendCharacterMessageID(
|
||||
r->source_character_id, Chat::Red,
|
||||
SharedTaskMessage::YOU_ARE_NOT_LEADER_COMMAND_ISSUE, {leader.character_name}
|
||||
);
|
||||
}
|
||||
else if (strcasecmp(leader.character_name.c_str(), r->player_name) == 0) {
|
||||
client_list.SendCharacterMessageID(
|
||||
r->source_character_id,
|
||||
Chat::Red,
|
||||
SharedTaskMessage::YOU_ALREADY_LEADER
|
||||
);
|
||||
}
|
||||
else {
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskMakeLeader] character_id [{}] shared_task_id [{}] is_leader",
|
||||
r->source_character_id,
|
||||
t->GetDbSharedTask().id
|
||||
);
|
||||
|
||||
std::string character_name = r->player_name;
|
||||
shared_task_manager.MakeLeaderByPlayerName(t, character_name);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskAddPlayer: {
|
||||
auto *r = (ServerSharedTaskAddPlayer_Struct *) pack->pBuffer;
|
||||
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskAddPlayer] Received request from character [{}] task_id [{}] player_name [{}]",
|
||||
r->source_character_id,
|
||||
r->task_id,
|
||||
r->player_name
|
||||
);
|
||||
|
||||
auto t = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(r->task_id, r->source_character_id);
|
||||
if (t) {
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskAddPlayer] Found shared task character [{}] shared_task_id [{}]",
|
||||
r->source_character_id,
|
||||
t->GetDbSharedTask().id
|
||||
);
|
||||
|
||||
auto leader = t->GetLeader();
|
||||
if (leader.character_id != r->source_character_id) {
|
||||
// taskadd is client sided with System color in newer clients, server side might still be red
|
||||
client_list.SendCharacterMessageID(
|
||||
r->source_character_id, Chat::Red,
|
||||
SharedTaskMessage::YOU_ARE_NOT_LEADER_COMMAND_ISSUE, {leader.character_name}
|
||||
);
|
||||
}
|
||||
else {
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskAddPlayer] character_id [{}] shared_task_id [{}] is_leader",
|
||||
r->source_character_id,
|
||||
t->GetDbSharedTask().id
|
||||
);
|
||||
|
||||
std::string character_name = r->player_name;
|
||||
shared_task_manager.InvitePlayerByPlayerName(t, character_name);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskInviteAcceptedPlayer: {
|
||||
auto *r = (ServerSharedTaskInviteAccepted_Struct *) pack->pBuffer;
|
||||
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskInviteAcceptedPlayer] Received request from source_character_id [{}] shared_task_id [{}] accepted [{}]",
|
||||
r->source_character_id,
|
||||
r->shared_task_id,
|
||||
r->accepted
|
||||
);
|
||||
|
||||
auto t = shared_task_manager.FindSharedTaskById(r->shared_task_id);
|
||||
if (t && shared_task_manager.IsInvitationActive(r->shared_task_id, r->source_character_id)) {
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskInviteAcceptedPlayer] Found shared task character [{}] shared_task_id [{}]",
|
||||
r->source_character_id,
|
||||
t->GetDbSharedTask().id
|
||||
);
|
||||
|
||||
shared_task_manager.RemoveActiveInvitation(r->shared_task_id, r->source_character_id);
|
||||
|
||||
if (r->accepted) {
|
||||
shared_task_manager.AddPlayerByCharacterIdAndName(t, r->source_character_id, r->player_name);
|
||||
}
|
||||
else {
|
||||
shared_task_manager.SendLeaderMessageID(
|
||||
t,
|
||||
Chat::Red,
|
||||
SharedTaskMessage::PLAYER_DECLINED_OFFER,
|
||||
{r->player_name}
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskCreateDynamicZone: {
|
||||
auto buf = reinterpret_cast<ServerSharedTaskCreateDynamicZone_Struct *>(pack->pBuffer);
|
||||
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskCreateDynamicZone] Received request from source_character_id [{}] task_id [{}]",
|
||||
buf->source_character_id,
|
||||
buf->task_id
|
||||
);
|
||||
|
||||
auto t = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(buf->task_id, buf->source_character_id);
|
||||
if (t) {
|
||||
DynamicZone dz;
|
||||
dz.LoadSerializedDzPacket(buf->cereal_data, buf->cereal_size);
|
||||
|
||||
shared_task_manager.CreateDynamicZone(t, dz);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskPurgeAllCommand: {
|
||||
LogTasksDetail("[ServerOP_SharedTaskPurgeAllCommand] Received request to purge all shared tasks");
|
||||
|
||||
shared_task_manager.PurgeAllSharedTasks();
|
||||
auto p = std::make_unique<ServerPacket>(
|
||||
ServerOP_SharedTaskPurgeAllCommand,
|
||||
0
|
||||
);
|
||||
|
||||
zoneserver_list.SendPacket(p.get());
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskPlayerList: {
|
||||
auto buf = reinterpret_cast<ServerSharedTaskPlayerList_Struct *>(pack->pBuffer);
|
||||
|
||||
LogTasksDetail(
|
||||
"[ServerOP_SharedTaskPlayerList] Received request from source_character_id [{}] task_id [{}]",
|
||||
buf->source_character_id,
|
||||
buf->task_id
|
||||
);
|
||||
|
||||
auto s = shared_task_manager.FindSharedTaskByTaskIdAndCharacterId(buf->task_id, buf->source_character_id);
|
||||
if (s) {
|
||||
std::vector<std::string> player_names;
|
||||
|
||||
for (const auto &member : s->GetMembers()) {
|
||||
player_names.emplace_back(member.character_name);
|
||||
|
||||
if (member.is_leader) {
|
||||
client_list.SendCharacterMessageID(
|
||||
buf->source_character_id, Chat::Yellow,
|
||||
SharedTaskMessage::LEADER_PRINT, {member.character_name}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
std::string player_list = fmt::format("{}", fmt::join(player_names, ", "));
|
||||
client_list.SendCharacterMessageID(
|
||||
buf->source_character_id, Chat::Yellow,
|
||||
SharedTaskMessage::MEMBERS_PRINT, {player_list}
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
18
world/shared_task_world_messaging.h
Normal file
18
world/shared_task_world_messaging.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef EQEMU_SHARED_TASK_WORLD_MESSAGING_H
|
||||
#define EQEMU_SHARED_TASK_WORLD_MESSAGING_H
|
||||
|
||||
#include "../common/types.h"
|
||||
#include "../common/servertalk.h"
|
||||
#include "../common/shared_tasks.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/repositories/tasks_repository.h"
|
||||
#include "../common/tasks.h"
|
||||
|
||||
class SharedTaskWorldMessaging {
|
||||
public:
|
||||
static void HandleZoneMessage(ServerPacket *pack);
|
||||
};
|
||||
|
||||
|
||||
#endif //EQEMU_SHARED_TASK_WORLD_MESSAGING_H
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#include <cstdlib>
|
||||
#include <vector>
|
||||
#include "sof_char_create_data.h"
|
||||
#include "../common/repositories/character_instance_safereturns_repository.h"
|
||||
#include "../common/repositories/criteria/content_filter_criteria.h"
|
||||
#include "world_store.h"
|
||||
|
||||
@ -477,6 +478,54 @@ int WorldDatabase::MoveCharacterToBind(int character_id, uint8 bind_number)
|
||||
return zone_id;
|
||||
}
|
||||
|
||||
int WorldDatabase::MoveCharacterToInstanceSafeReturn(
|
||||
int character_id,
|
||||
int instance_zone_id,
|
||||
int instance_id
|
||||
)
|
||||
{
|
||||
int zone_id = 0;
|
||||
|
||||
// only moves if safe return is for specified zone instance
|
||||
auto entries = CharacterInstanceSafereturnsRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"character_id = {} AND instance_zone_id = {} AND instance_id = {} AND safe_zone_id > 0",
|
||||
character_id, instance_zone_id, instance_id
|
||||
)
|
||||
);
|
||||
|
||||
if (!entries.empty()) {
|
||||
auto entry = entries.front();
|
||||
|
||||
auto results = QueryDatabase(
|
||||
fmt::format(
|
||||
SQL(
|
||||
UPDATE character_data
|
||||
SET zone_id = {}, zone_instance = 0, x = {}, y = {}, z = {}, heading = {}
|
||||
WHERE id = {};
|
||||
),
|
||||
entry.safe_zone_id,
|
||||
entry.safe_x,
|
||||
entry.safe_y,
|
||||
entry.safe_z,
|
||||
entry.safe_heading,
|
||||
character_id
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success() && results.RowsAffected() > 0) {
|
||||
zone_id = entry.safe_zone_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (zone_id == 0) {
|
||||
zone_id = MoveCharacterToBind(character_id);
|
||||
}
|
||||
|
||||
return zone_id;
|
||||
}
|
||||
|
||||
bool WorldDatabase::GetStartZone(
|
||||
PlayerProfile_Struct *p_player_profile_struct,
|
||||
CharCreate_Struct *p_char_create_struct,
|
||||
|
||||
@ -32,6 +32,7 @@ public:
|
||||
bool GetStartZone(PlayerProfile_Struct* p_player_profile_struct, CharCreate_Struct* p_char_create_struct, bool is_titanium);
|
||||
void GetCharSelectInfo(uint32 account_id, EQApplicationPacket **out_app, uint32 client_version_bit);
|
||||
int MoveCharacterToBind(int character_id, uint8 bind_number = 0);
|
||||
int MoveCharacterToInstanceSafeReturn(int character_id, int instance_zone_id, int instance_id);
|
||||
|
||||
void GetLauncherList(std::vector<std::string> &result);
|
||||
bool GetCharacterLevel(const char *name, int &level);
|
||||
|
||||
@ -43,7 +43,7 @@ ZSList::ZSList()
|
||||
memset(pLockedZones, 0, sizeof(pLockedZones));
|
||||
|
||||
m_tick = std::make_unique<EQ::Timer>(5000, true, std::bind(&ZSList::OnTick, this, std::placeholders::_1));
|
||||
m_keepalive = std::make_unique<EQ::Timer>(1500, true, std::bind(&ZSList::OnKeepAlive, this, std::placeholders::_1));
|
||||
m_keepalive = std::make_unique<EQ::Timer>(1000, true, std::bind(&ZSList::OnKeepAlive, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
ZSList::~ZSList() {
|
||||
|
||||
@ -38,6 +38,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "world_store.h"
|
||||
#include "dynamic_zone.h"
|
||||
#include "expedition_message.h"
|
||||
#include "shared_task_world_messaging.h"
|
||||
#include "../common/shared_tasks.h"
|
||||
|
||||
extern ClientList client_list;
|
||||
extern GroupLFPList LFPGroupList;
|
||||
@ -1181,7 +1183,6 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
|
||||
adventure_manager.IncrementAssassinationCount(*((uint16*)pack->pBuffer));
|
||||
break;
|
||||
}
|
||||
|
||||
case ServerOP_AdventureZoneData:
|
||||
{
|
||||
adventure_manager.GetZoneData(*((uint16*)pack->pBuffer));
|
||||
@ -1368,17 +1369,28 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
|
||||
case ServerOP_ExpeditionLockoutDuration:
|
||||
case ServerOP_ExpeditionLockState:
|
||||
case ServerOP_ExpeditionReplayOnJoin:
|
||||
case ServerOP_ExpeditionExpireWarning:
|
||||
{
|
||||
zoneserver_list.SendPacket(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskRequest:
|
||||
case ServerOP_SharedTaskAddPlayer:
|
||||
case ServerOP_SharedTaskAttemptRemove:
|
||||
case ServerOP_SharedTaskUpdate:
|
||||
case ServerOP_SharedTaskRequestMemberlist:
|
||||
case ServerOP_SharedTaskRemovePlayer:
|
||||
case ServerOP_SharedTaskInviteAcceptedPlayer:
|
||||
case ServerOP_SharedTaskMakeLeader:
|
||||
case ServerOP_SharedTaskCreateDynamicZone:
|
||||
case ServerOP_SharedTaskPurgeAllCommand:
|
||||
case ServerOP_SharedTaskPlayerList:
|
||||
case ServerOP_SharedTaskKickPlayers:
|
||||
{
|
||||
SharedTaskWorldMessaging::HandleZoneMessage(pack);
|
||||
break;
|
||||
}
|
||||
|
||||
case ServerOP_ExpeditionCreate:
|
||||
case ServerOP_ExpeditionGetMemberStatuses:
|
||||
case ServerOP_ExpeditionMemberChange:
|
||||
case ServerOP_ExpeditionMemberStatus:
|
||||
case ServerOP_ExpeditionMemberSwap:
|
||||
case ServerOP_ExpeditionMembersRemoved:
|
||||
case ServerOP_ExpeditionDzAddPlayer:
|
||||
case ServerOP_ExpeditionDzMakeLeader:
|
||||
case ServerOP_ExpeditionCharacterLockout:
|
||||
@ -1388,12 +1400,16 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
|
||||
ExpeditionMessage::HandleZoneMessage(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzAddRemoveCharacter:
|
||||
case ServerOP_DzRemoveAllCharacters:
|
||||
case ServerOP_DzCreated:
|
||||
case ServerOP_DzAddRemoveMember:
|
||||
case ServerOP_DzSwapMembers:
|
||||
case ServerOP_DzRemoveAllMembers:
|
||||
case ServerOP_DzGetMemberStatuses:
|
||||
case ServerOP_DzSetSecondsRemaining:
|
||||
case ServerOP_DzSetCompass:
|
||||
case ServerOP_DzSetSafeReturn:
|
||||
case ServerOP_DzSetZoneIn:
|
||||
case ServerOP_DzUpdateMemberStatus:
|
||||
{
|
||||
DynamicZone::HandleZoneMessage(pack);
|
||||
break;
|
||||
|
||||
@ -129,6 +129,7 @@ SET(zone_sources
|
||||
quest_parser_collection.cpp
|
||||
raids.cpp
|
||||
raycast_mesh.cpp
|
||||
shared_task_zone_messaging.cpp
|
||||
spawn2.cpp
|
||||
spawn2.h
|
||||
spawngroup.cpp
|
||||
@ -255,6 +256,7 @@ SET(zone_headers
|
||||
raids.h
|
||||
raycast_mesh.h
|
||||
skills.h
|
||||
shared_task_zone_messaging.h
|
||||
spawn2.cpp
|
||||
spawn2.h
|
||||
spawngroup.h
|
||||
|
||||
@ -2350,6 +2350,18 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQ::skills::SkillTy
|
||||
int32 finalxp = give_exp_client->GetExperienceForKill(this);
|
||||
finalxp = give_exp_client->mod_client_xp(finalxp, this);
|
||||
|
||||
// handle task credit on behalf of the killer
|
||||
if (RuleB(TaskSystem, EnableTaskSystem)) {
|
||||
LogTasksDetail(
|
||||
"[NPC::Death] Triggering HandleUpdateTasksOnKill for [{}] npc [{}]",
|
||||
give_exp_client->GetCleanName(),
|
||||
GetNPCTypeID()
|
||||
);
|
||||
give_exp_client
|
||||
->GetTaskState()
|
||||
->HandleUpdateTasksOnKill(give_exp_client, GetNPCTypeID());
|
||||
}
|
||||
|
||||
if (kr) {
|
||||
if (!IsLdonTreasure && MerchantType == 0) {
|
||||
kr->SplitExp((finalxp), this);
|
||||
@ -2368,8 +2380,6 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQ::skills::SkillTy
|
||||
|
||||
mod_npc_killed_merit(kr->members[i].member);
|
||||
|
||||
if (RuleB(TaskSystem, EnableTaskSystem))
|
||||
kr->members[i].member->UpdateTasksOnKill(GetNPCTypeID());
|
||||
PlayerCount++;
|
||||
}
|
||||
}
|
||||
@ -2417,9 +2427,6 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQ::skills::SkillTy
|
||||
|
||||
mod_npc_killed_merit(c);
|
||||
|
||||
if (RuleB(TaskSystem, EnableTaskSystem))
|
||||
c->UpdateTasksOnKill(GetNPCTypeID());
|
||||
|
||||
PlayerCount++;
|
||||
}
|
||||
}
|
||||
@ -2468,9 +2475,6 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQ::skills::SkillTy
|
||||
|
||||
mod_npc_killed_merit(give_exp_client);
|
||||
|
||||
if (RuleB(TaskSystem, EnableTaskSystem))
|
||||
give_exp_client->UpdateTasksOnKill(GetNPCTypeID());
|
||||
|
||||
// QueryServ Logging - Solo
|
||||
if (RuleB(QueryServ, PlayerLogNPCKills)) {
|
||||
auto pack = new ServerPacket(ServerOP_QSPlayerLogNPCKills,
|
||||
|
||||
201
zone/client.cpp
201
zone/client.cpp
@ -348,9 +348,10 @@ Client::Client(EQStreamInterface* ieqs)
|
||||
temp_pvp = false;
|
||||
is_client_moving = false;
|
||||
|
||||
/**
|
||||
* GM
|
||||
*/
|
||||
// rate limiter
|
||||
m_list_task_timers_rate_limit.Start(1000);
|
||||
|
||||
// gm
|
||||
SetDisplayMobInfoWindow(true);
|
||||
SetDevToolsEnabled(true);
|
||||
|
||||
@ -1550,46 +1551,56 @@ void Client::SendSound(){//Makes a sound.
|
||||
safe_delete(outapp);
|
||||
|
||||
}
|
||||
void Client::UpdateWho(uint8 remove) {
|
||||
if (account_id == 0)
|
||||
void Client::UpdateWho(uint8 remove)
|
||||
{
|
||||
if (account_id == 0) {
|
||||
return;
|
||||
if (!worldserver.Connected())
|
||||
}
|
||||
if (!worldserver.Connected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto pack = new ServerPacket(ServerOP_ClientList, sizeof(ServerClientList_Struct));
|
||||
ServerClientList_Struct* scl = (ServerClientList_Struct*) pack->pBuffer;
|
||||
scl->remove = remove;
|
||||
scl->wid = this->GetWID();
|
||||
scl->IP = this->GetIP();
|
||||
scl->charid = this->CharacterID();
|
||||
strcpy(scl->name, this->GetName());
|
||||
auto *s = (ServerClientList_Struct *) pack->pBuffer;
|
||||
s->remove = remove;
|
||||
s->wid = this->GetWID();
|
||||
s->IP = this->GetIP();
|
||||
s->charid = this->CharacterID();
|
||||
strcpy(s->name, this->GetName());
|
||||
|
||||
scl->gm = GetGM();
|
||||
scl->Admin = this->Admin();
|
||||
scl->AccountID = this->AccountID();
|
||||
strcpy(scl->AccountName, this->AccountName());
|
||||
scl->LSAccountID = this->LSAccountID();
|
||||
strn0cpy(scl->lskey, lskey, sizeof(scl->lskey));
|
||||
scl->zone = zone->GetZoneID();
|
||||
scl->instance_id = zone->GetInstanceID();
|
||||
scl->race = this->GetRace();
|
||||
scl->class_ = GetClass();
|
||||
scl->level = GetLevel();
|
||||
if (m_pp.anon == 0)
|
||||
scl->anon = 0;
|
||||
else if (m_pp.anon == 1)
|
||||
scl->anon = 1;
|
||||
else if (m_pp.anon >= 2)
|
||||
scl->anon = 2;
|
||||
s->gm = GetGM();
|
||||
s->Admin = this->Admin();
|
||||
s->AccountID = this->AccountID();
|
||||
strcpy(s->AccountName, this->AccountName());
|
||||
|
||||
scl->ClientVersion = static_cast<unsigned int>(ClientVersion());
|
||||
scl->tellsoff = tellsoff;
|
||||
scl->guild_id = guild_id;
|
||||
scl->LFG = LFG;
|
||||
if(LFG) {
|
||||
scl->LFGFromLevel = LFGFromLevel;
|
||||
scl->LFGToLevel = LFGToLevel;
|
||||
scl->LFGMatchFilter = LFGMatchFilter;
|
||||
memcpy(scl->LFGComments, LFGComments, sizeof(scl->LFGComments));
|
||||
s->LSAccountID = this->LSAccountID();
|
||||
strn0cpy(s->lskey, lskey, sizeof(s->lskey));
|
||||
|
||||
s->zone = zone->GetZoneID();
|
||||
s->instance_id = zone->GetInstanceID();
|
||||
s->race = this->GetRace();
|
||||
s->class_ = GetClass();
|
||||
s->level = GetLevel();
|
||||
|
||||
if (m_pp.anon == 0) {
|
||||
s->anon = 0;
|
||||
}
|
||||
else if (m_pp.anon == 1) {
|
||||
s->anon = 1;
|
||||
}
|
||||
else if (m_pp.anon >= 2) {
|
||||
s->anon = 2;
|
||||
}
|
||||
|
||||
s->ClientVersion = static_cast<unsigned int>(ClientVersion());
|
||||
s->tellsoff = tellsoff;
|
||||
s->guild_id = guild_id;
|
||||
s->LFG = LFG;
|
||||
if (LFG) {
|
||||
s->LFGFromLevel = LFGFromLevel;
|
||||
s->LFGToLevel = LFGToLevel;
|
||||
s->LFGMatchFilter = LFGMatchFilter;
|
||||
memcpy(s->LFGComments, LFGComments, sizeof(s->LFGComments));
|
||||
}
|
||||
|
||||
worldserver.SendPacket(pack);
|
||||
@ -3368,11 +3379,7 @@ void Client::LinkDead()
|
||||
raid->MemberZoned(this);
|
||||
}
|
||||
|
||||
Expedition* expedition = GetExpedition();
|
||||
if (expedition)
|
||||
{
|
||||
expedition->SetMemberStatus(this, DynamicZoneMemberStatus::LinkDead);
|
||||
}
|
||||
SetDynamicZoneMemberStatus(DynamicZoneMemberStatus::LinkDead);
|
||||
|
||||
// save_timer.Start(2500);
|
||||
linkdead_timer.Start(RuleI(Zone,ClientLinkdeadMS));
|
||||
@ -5730,16 +5737,27 @@ void Client::AddPVPPoints(uint32 Points)
|
||||
SendPVPStats();
|
||||
}
|
||||
|
||||
void Client::AddCrystals(uint32 Radiant, uint32 Ebon)
|
||||
void Client::AddCrystals(uint32 radiant, uint32 ebon)
|
||||
{
|
||||
m_pp.currentRadCrystals += Radiant;
|
||||
m_pp.careerRadCrystals += Radiant;
|
||||
m_pp.currentEbonCrystals += Ebon;
|
||||
m_pp.careerEbonCrystals += Ebon;
|
||||
m_pp.currentRadCrystals += radiant;
|
||||
m_pp.careerRadCrystals += radiant;
|
||||
m_pp.currentEbonCrystals += ebon;
|
||||
m_pp.careerEbonCrystals += ebon;
|
||||
|
||||
SaveCurrency();
|
||||
|
||||
SendCrystalCounts();
|
||||
|
||||
// newer clients handle message client side (older clients likely used eqstr 5967 and 5968, this matches live)
|
||||
if (radiant > 0)
|
||||
{
|
||||
MessageString(Chat::Yellow, YOU_RECEIVE, fmt::format("{} Radiant Crystals", radiant).c_str());
|
||||
}
|
||||
|
||||
if (ebon > 0)
|
||||
{
|
||||
MessageString(Chat::Yellow, YOU_RECEIVE, fmt::format("{} Ebon Crystals", ebon).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void Client::SetEbonCrystals(uint32 value) {
|
||||
@ -9515,28 +9533,25 @@ void Client::SendCrossZoneMessageString(
|
||||
}
|
||||
}
|
||||
|
||||
void Client::UpdateExpeditionInfoAndLockouts()
|
||||
void Client::SendDynamicZoneUpdates()
|
||||
{
|
||||
// this is processed by client after entering a zone
|
||||
// bit inefficient since each do lookups but it avoids duplicating code here
|
||||
SendDzCompassUpdate();
|
||||
SetDynamicZoneMemberStatus(DynamicZoneMemberStatus::Online);
|
||||
|
||||
m_expedition_lockouts = ExpeditionDatabase::LoadCharacterLockouts(CharacterID());
|
||||
|
||||
// expeditions are the only dz type that keep the window updated
|
||||
auto expedition = GetExpedition();
|
||||
if (expedition)
|
||||
{
|
||||
expedition->SendClientExpeditionInfo(this);
|
||||
expedition->GetDynamicZone()->SendClientWindowUpdate(this);
|
||||
|
||||
// live synchronizes lockouts obtained during the active expedition to
|
||||
// members once they zone into the expedition's dynamic zone instance
|
||||
if (expedition->GetDynamicZone().IsCurrentZoneDzInstance())
|
||||
if (expedition->GetDynamicZone()->IsCurrentZoneDzInstance())
|
||||
{
|
||||
expedition->SyncCharacterLockouts(CharacterID(), m_expedition_lockouts);
|
||||
expedition->SetMemberStatus(this, DynamicZoneMemberStatus::InDynamicZone);
|
||||
}
|
||||
else
|
||||
{
|
||||
expedition->SetMemberStatus(this, DynamicZoneMemberStatus::Online);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9546,18 +9561,29 @@ void Client::UpdateExpeditionInfoAndLockouts()
|
||||
RequestPendingExpeditionInvite();
|
||||
}
|
||||
|
||||
Expedition* Client::CreateExpedition(DynamicZone& dz_instance, ExpeditionRequest& request)
|
||||
Expedition* Client::CreateExpedition(DynamicZone& dz, bool disable_messages)
|
||||
{
|
||||
return Expedition::TryCreate(this, dz_instance, request);
|
||||
return Expedition::TryCreate(this, dz, disable_messages);
|
||||
}
|
||||
|
||||
Expedition* Client::CreateExpedition(
|
||||
const std::string& zone_name, uint32 version, uint32 duration, const std::string& expedition_name,
|
||||
uint32 min_players, uint32 max_players, bool disable_messages)
|
||||
{
|
||||
DynamicZone dz_instance{ ZoneID(zone_name), version, duration, DynamicZoneType::Expedition };
|
||||
ExpeditionRequest request{ expedition_name, min_players, max_players, disable_messages };
|
||||
return Expedition::TryCreate(this, dz_instance, request);
|
||||
DynamicZone dz{ ZoneID(zone_name), version, duration, DynamicZoneType::Expedition };
|
||||
dz.SetName(expedition_name);
|
||||
dz.SetMinPlayers(min_players);
|
||||
dz.SetMaxPlayers(max_players);
|
||||
|
||||
return Expedition::TryCreate(this, dz, disable_messages);
|
||||
}
|
||||
|
||||
void Client::CreateTaskDynamicZone(int task_id, DynamicZone& dz_request)
|
||||
{
|
||||
if (task_state)
|
||||
{
|
||||
task_state->CreateTaskDynamicZone(this, task_id, dz_request);
|
||||
}
|
||||
}
|
||||
|
||||
Expedition* Client::GetExpedition() const
|
||||
@ -9877,24 +9903,59 @@ void Client::GoToDzSafeReturnOrBind(const DynamicZone* dynamic_zone)
|
||||
GoToBind();
|
||||
}
|
||||
|
||||
void Client::AddDynamicZoneID(uint32_t dz_id)
|
||||
{
|
||||
auto it = std::find_if(m_dynamic_zone_ids.begin(), m_dynamic_zone_ids.end(),
|
||||
[&](uint32_t current_dz_id) { return current_dz_id == dz_id; });
|
||||
|
||||
if (it == m_dynamic_zone_ids.end())
|
||||
{
|
||||
LogDynamicZonesDetail("Adding dz [{}] to client [{}]", dz_id, GetName());
|
||||
m_dynamic_zone_ids.push_back(dz_id);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::RemoveDynamicZoneID(uint32_t dz_id)
|
||||
{
|
||||
LogDynamicZonesDetail("Removing dz [{}] from client [{}]", dz_id, GetName());
|
||||
m_dynamic_zone_ids.erase(std::remove_if(m_dynamic_zone_ids.begin(), m_dynamic_zone_ids.end(),
|
||||
[&](uint32_t current_dz_id) { return current_dz_id == dz_id; }
|
||||
), m_dynamic_zone_ids.end());
|
||||
}
|
||||
|
||||
std::vector<DynamicZone*> Client::GetDynamicZones(uint32_t zone_id, int zone_version)
|
||||
{
|
||||
std::vector<DynamicZone*> client_dzs;
|
||||
|
||||
// check client systems for any associated dynamic zones optionally filtered by zone
|
||||
Expedition* expedition = GetExpedition();
|
||||
if (expedition &&
|
||||
(zone_id == 0 || expedition->GetDynamicZone().GetZoneID() == zone_id) &&
|
||||
(zone_version < 0 || expedition->GetDynamicZone().GetZoneVersion() == zone_version))
|
||||
for (uint32_t dz_id : m_dynamic_zone_ids)
|
||||
{
|
||||
client_dzs.emplace_back(&expedition->GetDynamicZone());
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(dz_id);
|
||||
if (dz &&
|
||||
(zone_id == 0 || dz->GetZoneID() == zone_id) &&
|
||||
(zone_version < 0 || dz->GetZoneVersion() == zone_version))
|
||||
{
|
||||
client_dzs.emplace_back(dz);
|
||||
}
|
||||
}
|
||||
|
||||
// todo: tasks, missions (shared tasks), and quests with an associated dz to zone_id
|
||||
|
||||
return client_dzs;
|
||||
}
|
||||
|
||||
void Client::SetDynamicZoneMemberStatus(DynamicZoneMemberStatus status)
|
||||
{
|
||||
// sets status on all associated dzs client may have. if client is online
|
||||
// inside a dz, only that dz has the "In Dynamic Zone" status set
|
||||
for (auto& dz : GetDynamicZones())
|
||||
{
|
||||
// the rule to disable this status is handled internally by the dz
|
||||
if (status == DynamicZoneMemberStatus::Online && dz->IsCurrentZoneDzInstance())
|
||||
{
|
||||
status = DynamicZoneMemberStatus::InDynamicZone;
|
||||
}
|
||||
dz->SetMemberStatus(CharacterID(), status);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::MovePCDynamicZone(uint32 zone_id, int zone_version, bool msg_if_invalid)
|
||||
{
|
||||
if (zone_id == 0)
|
||||
|
||||
@ -80,6 +80,7 @@ namespace EQ
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <deque>
|
||||
#include <ctime>
|
||||
|
||||
|
||||
#define CLIENT_TIMEOUT 90000
|
||||
@ -1030,6 +1031,9 @@ public:
|
||||
void SendTaskActivityComplete(int task_id, int activity_id, int task_index, TaskType task_type, int task_incomplete=1);
|
||||
void SendTaskFailed(int task_id, int task_index, TaskType task_type);
|
||||
void SendTaskComplete(int task_index);
|
||||
bool HasTaskRequestCooldownTimer();
|
||||
void SendTaskRequestCooldownTimerMessage();
|
||||
void StartTaskRequestCooldownTimer();
|
||||
inline ClientTaskState *GetTaskState() const { return task_state; }
|
||||
inline void CancelTask(int task_index, TaskType task_type)
|
||||
{
|
||||
@ -1095,7 +1099,7 @@ public:
|
||||
}
|
||||
}
|
||||
inline void UpdateTasksForItem(
|
||||
ActivityType activity_type,
|
||||
TaskActivityType activity_type,
|
||||
int item_id,
|
||||
int count = 1
|
||||
)
|
||||
@ -1202,7 +1206,7 @@ public:
|
||||
bool enforce_level_requirement = false
|
||||
) {
|
||||
if (task_state) {
|
||||
task_state->AcceptNewTask(this, task_id, npc_id, enforce_level_requirement);
|
||||
task_state->AcceptNewTask(this, task_id, npc_id, std::time(nullptr), enforce_level_requirement);
|
||||
}
|
||||
}
|
||||
inline int ActiveSpeakTask(int npc_type_id)
|
||||
@ -1262,6 +1266,15 @@ public:
|
||||
{
|
||||
return (task_state ? task_state->CompletedTasksInSet(task_set_id) : 0);
|
||||
}
|
||||
void PurgeTaskTimers();
|
||||
|
||||
// shared task shims / middleware
|
||||
// these variables are used as a shim to intercept normal localized task functionality
|
||||
// and pipe it into zone -> world and back to world -> zone
|
||||
// world is authoritative
|
||||
bool m_requesting_shared_task = false;
|
||||
bool m_shared_task_update = false;
|
||||
bool m_requested_shared_task_removal = false;
|
||||
|
||||
inline const EQ::versions::ClientVersion ClientVersion() const { return m_ClientVersion; }
|
||||
inline const uint32 ClientVersionBit() const { return m_ClientVersionBit; }
|
||||
@ -1330,9 +1343,9 @@ public:
|
||||
const std::string& event_Name, int seconds, const std::string& uuid = {}, bool update_db = false);
|
||||
void AddNewExpeditionLockout(const std::string& expedition_name,
|
||||
const std::string& event_name, uint32_t duration, std::string uuid = {});
|
||||
Expedition* CreateExpedition(DynamicZone& dz_instance, ExpeditionRequest& request);
|
||||
Expedition* CreateExpedition(
|
||||
const std::string& zone_name, uint32 version, uint32 duration, const std::string& expedition_name,
|
||||
Expedition* CreateExpedition(DynamicZone& dz, bool disable_messages = false);
|
||||
Expedition* CreateExpedition(const std::string& zone_name,
|
||||
uint32 version, uint32 duration, const std::string& expedition_name,
|
||||
uint32 min_players, uint32 max_players, bool disable_messages = false);
|
||||
Expedition* GetExpedition() const;
|
||||
uint32 GetExpeditionID() const { return m_expedition_id; }
|
||||
@ -1350,7 +1363,6 @@ public:
|
||||
void SendExpeditionLockoutTimers();
|
||||
void SetExpeditionID(uint32 expedition_id) { m_expedition_id = expedition_id; };
|
||||
void SetPendingExpeditionInvite(ExpeditionInvite&& invite) { m_pending_expedition_invite = invite; }
|
||||
void UpdateExpeditionInfoAndLockouts();
|
||||
void DzListTimers();
|
||||
void SetDzRemovalTimer(bool enable_timer);
|
||||
void SendDzCompassUpdate();
|
||||
@ -1360,6 +1372,11 @@ public:
|
||||
std::vector<DynamicZone*> GetDynamicZones(uint32_t zone_id = 0, int zone_version = -1);
|
||||
std::unique_ptr<EQApplicationPacket> CreateDzSwitchListPacket(const std::vector<DynamicZone*>& dzs);
|
||||
std::unique_ptr<EQApplicationPacket> CreateCompassPacket(const std::vector<DynamicZoneCompassEntry_Struct>& entries);
|
||||
void AddDynamicZoneID(uint32_t dz_id);
|
||||
void RemoveDynamicZoneID(uint32_t dz_id);
|
||||
void SendDynamicZoneUpdates();
|
||||
void SetDynamicZoneMemberStatus(DynamicZoneMemberStatus status);
|
||||
void CreateTaskDynamicZone(int task_id, DynamicZone& dz_request);
|
||||
|
||||
void CalcItemScale();
|
||||
bool CalcItemScale(uint32 slot_x, uint32 slot_y); // behavior change: 'slot_y' is now [RANGE]_END and not [RANGE]_END + 1
|
||||
@ -1590,6 +1607,9 @@ public:
|
||||
void ShowDevToolsMenu();
|
||||
CheatManager cheat_manager;
|
||||
|
||||
// rate limit
|
||||
Timer m_list_task_timers_rate_limit = {};
|
||||
|
||||
protected:
|
||||
friend class Mob;
|
||||
void CalcItemBonuses(StatBonuses* newbon);
|
||||
@ -1821,6 +1841,7 @@ private:
|
||||
Timer position_update_timer; /* Timer used when client hasn't updated within a 10 second window */
|
||||
Timer consent_throttle_timer;
|
||||
Timer dynamiczone_removal_timer;
|
||||
Timer task_request_timer;
|
||||
|
||||
glm::vec3 m_Proximity;
|
||||
glm::vec4 last_position_before_bulk_update;
|
||||
@ -1855,6 +1876,14 @@ private:
|
||||
ClientTaskState *task_state;
|
||||
int TotalSecondsPlayed;
|
||||
|
||||
// we use this very sparingly at the zone level
|
||||
// used for keeping clients in donecount sync before world sends absolute confirmations of state
|
||||
int64 m_shared_task_id = 0;
|
||||
public:
|
||||
void SetSharedTaskId(int64 shared_task_id);
|
||||
int64 GetSharedTaskId() const;
|
||||
private:
|
||||
|
||||
//Anti Spam Stuff
|
||||
Timer *KarmaUpdateTimer;
|
||||
uint32 TotalKarma;
|
||||
@ -1927,6 +1956,7 @@ private:
|
||||
std::vector<ExpeditionLockoutTimer> m_expedition_lockouts;
|
||||
glm::vec3 m_quest_compass;
|
||||
bool m_has_quest_compass = false;
|
||||
std::vector<uint32_t> m_dynamic_zone_ids;
|
||||
|
||||
#ifdef BOTS
|
||||
|
||||
|
||||
@ -63,7 +63,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "worldserver.h"
|
||||
#include "zone.h"
|
||||
#include "mob_movement_manager.h"
|
||||
#include "../common/repositories/character_instance_safereturns_repository.h"
|
||||
#include "../common/repositories/criteria/content_filter_criteria.h"
|
||||
#include "../common/shared_tasks.h"
|
||||
|
||||
#ifdef BOTS
|
||||
#include "bot.h"
|
||||
@ -381,6 +383,7 @@ void MapOpcodes()
|
||||
ConnectedOpcodes[OP_TargetCommand] = &Client::Handle_OP_TargetCommand;
|
||||
ConnectedOpcodes[OP_TargetMouse] = &Client::Handle_OP_TargetMouse;
|
||||
ConnectedOpcodes[OP_TaskHistoryRequest] = &Client::Handle_OP_TaskHistoryRequest;
|
||||
ConnectedOpcodes[OP_TaskTimers] = &Client::Handle_OP_TaskTimers;
|
||||
ConnectedOpcodes[OP_Taunt] = &Client::Handle_OP_Taunt;
|
||||
ConnectedOpcodes[OP_TestBuff] = &Client::Handle_OP_TestBuff;
|
||||
ConnectedOpcodes[OP_TGB] = &Client::Handle_OP_TGB;
|
||||
@ -414,6 +417,15 @@ void MapOpcodes()
|
||||
ConnectedOpcodes[OP_ZoneChange] = &Client::Handle_OP_ZoneChange;
|
||||
ConnectedOpcodes[OP_ResetAA] = &Client::Handle_OP_ResetAA;
|
||||
ConnectedOpcodes[OP_UnderWorld] = &Client::Handle_OP_UnderWorld;
|
||||
|
||||
// shared tasks
|
||||
ConnectedOpcodes[OP_SharedTaskRemovePlayer] = &Client::Handle_OP_SharedTaskRemovePlayer;
|
||||
ConnectedOpcodes[OP_SharedTaskAddPlayer] = &Client::Handle_OP_SharedTaskAddPlayer;
|
||||
ConnectedOpcodes[OP_SharedTaskMakeLeader] = &Client::Handle_OP_SharedTaskMakeLeader;
|
||||
ConnectedOpcodes[OP_SharedTaskInviteResponse] = &Client::Handle_OP_SharedTaskInviteResponse;
|
||||
ConnectedOpcodes[OP_SharedTaskAcceptNew] = &Client::Handle_OP_SharedTaskAccept;
|
||||
ConnectedOpcodes[OP_SharedTaskQuit] = &Client::Handle_OP_SharedTaskQuit;
|
||||
ConnectedOpcodes[OP_SharedTaskPlayerList] = &Client::Handle_OP_SharedTaskPlayerList;
|
||||
}
|
||||
|
||||
void ClearMappedOpcode(EmuOpcode op)
|
||||
@ -526,6 +538,9 @@ void Client::CompleteConnect()
|
||||
/* Sets GM Flag if needed & Sends Petition Queue */
|
||||
UpdateAdmin(false);
|
||||
|
||||
// Task Packets
|
||||
LoadClientTaskState();
|
||||
|
||||
if (IsInAGuild()) {
|
||||
uint8 rank = GuildRank();
|
||||
if (ClientVersion() >= EQ::versions::ClientVersion::RoF)
|
||||
@ -899,7 +914,7 @@ void Client::CompleteConnect()
|
||||
guild_mgr.RequestOnlineGuildMembers(this->CharacterID(), this->GuildID());
|
||||
}
|
||||
|
||||
UpdateExpeditionInfoAndLockouts();
|
||||
SendDynamicZoneUpdates();
|
||||
|
||||
/** Request adventure info **/
|
||||
auto pack = new ServerPacket(ServerOP_AdventureDataRequest, 64);
|
||||
@ -940,6 +955,25 @@ void Client::CompleteConnect()
|
||||
ShowDevToolsMenu();
|
||||
}
|
||||
|
||||
// shared tasks memberlist
|
||||
if (GetTaskState()->HasActiveSharedTask()) {
|
||||
|
||||
// struct
|
||||
auto p = new ServerPacket(
|
||||
ServerOP_SharedTaskRequestMemberlist,
|
||||
sizeof(ServerSharedTaskRequestMemberlist_Struct)
|
||||
);
|
||||
|
||||
auto *r = (ServerSharedTaskRequestMemberlist_Struct *) p->pBuffer;
|
||||
|
||||
// fill
|
||||
r->source_character_id = CharacterID();
|
||||
r->task_id = GetTaskState()->GetActiveSharedTask().task_id;
|
||||
|
||||
// send
|
||||
worldserver.SendPacket(p);
|
||||
safe_delete(p);
|
||||
}
|
||||
}
|
||||
|
||||
// connecting opcode handlers
|
||||
@ -1716,13 +1750,41 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
|
||||
m_inv.SetGMInventory((bool)m_pp.gm); // reset back to current gm state
|
||||
}
|
||||
|
||||
/* Task Packets */
|
||||
LoadClientTaskState();
|
||||
|
||||
ApplyWeaponsStance();
|
||||
|
||||
auto dynamic_zone_member_entries = DynamicZoneMembersRepository::GetWhere(database,
|
||||
fmt::format("character_id = {}", CharacterID()));
|
||||
|
||||
for (const auto& entry : dynamic_zone_member_entries)
|
||||
{
|
||||
m_dynamic_zone_ids.emplace_back(entry.dynamic_zone_id);
|
||||
}
|
||||
|
||||
m_expedition_id = ExpeditionsRepository::GetIDByMemberID(database, CharacterID());
|
||||
|
||||
auto dz = zone->GetDynamicZone();
|
||||
if (dz && dz->GetSafeReturnLocation().zone_id != 0)
|
||||
{
|
||||
auto safereturn = dz->GetSafeReturnLocation();
|
||||
|
||||
auto safereturn_entry = CharacterInstanceSafereturnsRepository::NewEntity();
|
||||
safereturn_entry.character_id = CharacterID();
|
||||
safereturn_entry.instance_zone_id = zone->GetZoneID();
|
||||
safereturn_entry.instance_id = zone->GetInstanceID();
|
||||
safereturn_entry.safe_zone_id = safereturn.zone_id;
|
||||
safereturn_entry.safe_x = safereturn.x;
|
||||
safereturn_entry.safe_y = safereturn.y;
|
||||
safereturn_entry.safe_z = safereturn.z;
|
||||
safereturn_entry.safe_heading = safereturn.heading;
|
||||
|
||||
CharacterInstanceSafereturnsRepository::InsertOneOrUpdate(database, safereturn_entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterInstanceSafereturnsRepository::DeleteWhere(database,
|
||||
fmt::format("character_id = {}", character_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* DevTools Load Settings
|
||||
*/
|
||||
@ -1828,7 +1890,7 @@ void Client::Handle_OP_AcceptNewTask(const EQApplicationPacket *app)
|
||||
AcceptNewTask_Struct *ant = (AcceptNewTask_Struct*)app->pBuffer;
|
||||
|
||||
if (ant->task_id > 0 && RuleB(TaskSystem, EnableTaskSystem) && task_state)
|
||||
task_state->AcceptNewTask(this, ant->task_id, ant->task_master_id);
|
||||
task_state->AcceptNewTask(this, ant->task_id, ant->task_master_id, std::time(nullptr));
|
||||
}
|
||||
|
||||
void Client::Handle_OP_AdventureInfoRequest(const EQApplicationPacket *app)
|
||||
@ -9041,9 +9103,9 @@ void Client::Handle_OP_KickPlayers(const EQApplicationPacket *app)
|
||||
expedition->DzKickPlayers(this);
|
||||
}
|
||||
}
|
||||
else if (buf->kick_task)
|
||||
else if (buf->kick_task && GetTaskState() && GetTaskState()->HasActiveSharedTask())
|
||||
{
|
||||
// todo: shared tasks
|
||||
GetTaskState()->KickPlayersSharedTask(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12820,16 +12882,16 @@ void Client::Handle_OP_Shielding(const EQApplicationPacket *app)
|
||||
While active for the duration of 12 seconds baseline. The 'shield target' will take 50 pct less damage and
|
||||
the 'shielder' will be hit with the damage taken by the 'shield target' after all applicable mitigiont is calculated,
|
||||
the damage on the 'shielder' will be reduced by 25 percent, this reduction can be increased to 50 pct if equiping a shield.
|
||||
You receive a 1% increase in mitigation for every 2 AC on the shield.
|
||||
You receive a 1% increase in mitigation for every 2 AC on the shield.
|
||||
Shielder must stay with in a close distance (15 units) to your 'shield target'. If either move out of range, shield ends, no message given.
|
||||
Both duration and shield range can be modified by AA.
|
||||
Recast is 3 minutes.
|
||||
|
||||
For custom use cases, Mob::ShieldAbility can be used in quests with all parameters being altered. This functional
|
||||
is also used for SPA 201 SE_PetShield, which functions in a simalar manner with pet shielding owner.
|
||||
|
||||
|
||||
Note: If either the shielder or the shield target die all variables are reset on both.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
if (app->size != sizeof(Shielding_Struct)) {
|
||||
@ -12838,7 +12900,7 @@ void Client::Handle_OP_Shielding(const EQApplicationPacket *app)
|
||||
}
|
||||
|
||||
if (GetLevel() < 30) { //Client gives message
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetClass() != WARRIOR){
|
||||
@ -12854,7 +12916,7 @@ void Client::Handle_OP_Shielding(const EQApplicationPacket *app)
|
||||
}
|
||||
|
||||
Shielding_Struct* shield = (Shielding_Struct*)app->pBuffer;
|
||||
|
||||
|
||||
if (ShieldAbility(shield->target_id, 15, 12000, 50, 25, true, false)) {
|
||||
p_timers.Start(timer, SHIELD_ABILITY_RECAST_TIME);
|
||||
}
|
||||
@ -15196,20 +15258,266 @@ void Client::Handle_OP_ResetAA(const EQApplicationPacket *app)
|
||||
return;
|
||||
}
|
||||
|
||||
void Client::Handle_OP_MovementHistoryList(const EQApplicationPacket* app) {
|
||||
void Client::Handle_OP_MovementHistoryList(const EQApplicationPacket *app)
|
||||
{
|
||||
cheat_manager.ProcessMovementHistory(app);
|
||||
}
|
||||
|
||||
void Client::Handle_OP_UnderWorld(const EQApplicationPacket* app) {
|
||||
UnderWorld* m_UnderWorld = (UnderWorld*)app->pBuffer;
|
||||
if (app->size != sizeof(UnderWorld))
|
||||
{
|
||||
void Client::Handle_OP_UnderWorld(const EQApplicationPacket *app)
|
||||
{
|
||||
UnderWorld *m_UnderWorld = (UnderWorld *) app->pBuffer;
|
||||
if (app->size != sizeof(UnderWorld)) {
|
||||
LogDebug("Size mismatch in OP_UnderWorld, expected {}, got [{}]", sizeof(UnderWorld), app->size);
|
||||
DumpPacket(app);
|
||||
return;
|
||||
}
|
||||
auto dist = Distance(glm::vec3(m_UnderWorld->x, m_UnderWorld->y, zone->newzone_data.underworld), glm::vec3(m_UnderWorld->x, m_UnderWorld->y, m_UnderWorld->z));
|
||||
auto dist = Distance(
|
||||
glm::vec3(m_UnderWorld->x, m_UnderWorld->y, zone->newzone_data.underworld),
|
||||
glm::vec3(m_UnderWorld->x, m_UnderWorld->y, m_UnderWorld->z));
|
||||
cheat_manager.MovementCheck(glm::vec3(m_UnderWorld->x, m_UnderWorld->y, m_UnderWorld->z));
|
||||
if (m_UnderWorld->spawn_id == GetID() && dist <= 5.0f && zone->newzone_data.underworld_teleport_index != 0)
|
||||
if (m_UnderWorld->spawn_id == GetID() && dist <= 5.0f && zone->newzone_data.underworld_teleport_index != 0) {
|
||||
cheat_manager.SetExemptStatus(Port, true);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Handle_OP_SharedTaskRemovePlayer(const EQApplicationPacket *app)
|
||||
{
|
||||
if (app->size != sizeof(SharedTaskRemovePlayer_Struct)) {
|
||||
LogPacketClientServer(
|
||||
"Wrong size on Handle_OP_SharedTaskRemovePlayer | got [{}] expected [{}]",
|
||||
app->size,
|
||||
sizeof(SharedTaskRemovePlayer_Struct)
|
||||
);
|
||||
return;
|
||||
}
|
||||
auto *r = (SharedTaskRemovePlayer_Struct *) app->pBuffer;
|
||||
|
||||
LogTasks(
|
||||
"[Handle_OP_SharedTaskRemovePlayer] field1 [{}] field2 [{}] player_name [{}]",
|
||||
r->field1,
|
||||
r->field2,
|
||||
r->player_name
|
||||
);
|
||||
|
||||
// live no-ops this command if not in a shared task
|
||||
if (GetTaskState()->HasActiveSharedTask()) {
|
||||
// struct
|
||||
auto p = new ServerPacket(
|
||||
ServerOP_SharedTaskRemovePlayer,
|
||||
sizeof(ServerSharedTaskRemovePlayer_Struct)
|
||||
);
|
||||
|
||||
auto *rp = (ServerSharedTaskRemovePlayer_Struct *) p->pBuffer;
|
||||
|
||||
// fill
|
||||
rp->source_character_id = CharacterID();
|
||||
rp->task_id = GetTaskState()->GetActiveSharedTask().task_id;
|
||||
strn0cpy(rp->player_name, r->player_name, sizeof(r->player_name));
|
||||
|
||||
LogTasks(
|
||||
"[Handle_OP_SharedTaskRemovePlayer] source_character_id [{}] task_id [{}] player_name [{}]",
|
||||
rp->source_character_id,
|
||||
rp->task_id,
|
||||
rp->player_name
|
||||
);
|
||||
|
||||
// send
|
||||
worldserver.SendPacket(p);
|
||||
safe_delete(p);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Handle_OP_SharedTaskAddPlayer(const EQApplicationPacket *app)
|
||||
{
|
||||
if (app->size != sizeof(SharedTaskAddPlayer_Struct)) {
|
||||
LogPacketClientServer(
|
||||
"Wrong size on Handle_OP_SharedTaskAddPlayer | got [{}] expected [{}]",
|
||||
app->size,
|
||||
sizeof(SharedTaskAddPlayer_Struct)
|
||||
);
|
||||
return;
|
||||
}
|
||||
auto *r = (SharedTaskAddPlayer_Struct *) app->pBuffer;
|
||||
|
||||
LogTasks(
|
||||
"[SharedTaskAddPlayer_Struct] field1 [{}] field2 [{}] player_name [{}]",
|
||||
r->field1,
|
||||
r->field2,
|
||||
r->player_name
|
||||
);
|
||||
|
||||
if (!GetTaskState()->HasActiveSharedTask()) {
|
||||
// this message is generated client-side in newer clients
|
||||
Message(Chat::System, SharedTaskMessage::GetEQStr(SharedTaskMessage::COULD_NOT_USE_COMMAND));
|
||||
}
|
||||
else {
|
||||
// struct
|
||||
auto p = new ServerPacket(
|
||||
ServerOP_SharedTaskAddPlayer,
|
||||
sizeof(ServerSharedTaskAddPlayer_Struct)
|
||||
);
|
||||
|
||||
auto *rp = (ServerSharedTaskAddPlayer_Struct *) p->pBuffer;
|
||||
|
||||
// fill
|
||||
rp->source_character_id = CharacterID();
|
||||
rp->task_id = GetTaskState()->GetActiveSharedTask().task_id;
|
||||
strn0cpy(rp->player_name, r->player_name, sizeof(r->player_name));
|
||||
|
||||
LogTasks(
|
||||
"[Handle_OP_SharedTaskRemovePlayer] source_character_id [{}] task_id [{}] player_name [{}]",
|
||||
rp->source_character_id,
|
||||
rp->task_id,
|
||||
rp->player_name
|
||||
);
|
||||
|
||||
// send
|
||||
worldserver.SendPacket(p);
|
||||
safe_delete(p);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Handle_OP_SharedTaskMakeLeader(const EQApplicationPacket *app)
|
||||
{
|
||||
if (app->size != sizeof(SharedTaskMakeLeader_Struct)) {
|
||||
LogPacketClientServer(
|
||||
"Wrong size on Handle_OP_SharedTaskMakeLeader | got [{}] expected [{}]",
|
||||
app->size,
|
||||
sizeof(SharedTaskMakeLeader_Struct)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
auto *r = (SharedTaskMakeLeader_Struct *) app->pBuffer;
|
||||
LogTasks(
|
||||
"[SharedTaskMakeLeader_Struct] field1 [{}] field2 [{}] player_name [{}]",
|
||||
r->field1,
|
||||
r->field2,
|
||||
r->player_name
|
||||
);
|
||||
|
||||
// live no-ops this command if not in a shared task
|
||||
if (GetTaskState()->HasActiveSharedTask()) {
|
||||
// struct
|
||||
auto p = new ServerPacket(
|
||||
ServerOP_SharedTaskMakeLeader,
|
||||
sizeof(ServerSharedTaskMakeLeader_Struct)
|
||||
);
|
||||
|
||||
auto *rp = (ServerSharedTaskMakeLeader_Struct *) p->pBuffer;
|
||||
|
||||
// fill
|
||||
rp->source_character_id = CharacterID();
|
||||
rp->task_id = GetTaskState()->GetActiveSharedTask().task_id;
|
||||
strn0cpy(rp->player_name, r->player_name, sizeof(r->player_name));
|
||||
|
||||
LogTasks(
|
||||
"[Handle_OP_SharedTaskRemovePlayer] source_character_id [{}] task_id [{}] player_name [{}]",
|
||||
rp->source_character_id,
|
||||
rp->task_id,
|
||||
rp->player_name
|
||||
);
|
||||
|
||||
// send
|
||||
worldserver.SendPacket(p);
|
||||
safe_delete(p);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Handle_OP_SharedTaskInviteResponse(const EQApplicationPacket *app)
|
||||
{
|
||||
if (app->size != sizeof(SharedTaskInviteResponse_Struct)) {
|
||||
LogPacketClientServer(
|
||||
"Wrong size on SharedTaskInviteResponse | got [{}] expected [{}]",
|
||||
app->size,
|
||||
sizeof(SharedTaskInviteResponse_Struct)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
auto *r = (SharedTaskInviteResponse_Struct *) app->pBuffer;
|
||||
LogTasks(
|
||||
"[SharedTaskInviteResponse] unknown00 [{}] invite_id [{}] accepted [{}]",
|
||||
r->unknown00,
|
||||
r->invite_id,
|
||||
r->accepted
|
||||
);
|
||||
|
||||
// struct
|
||||
auto p = new ServerPacket(
|
||||
ServerOP_SharedTaskInviteAcceptedPlayer,
|
||||
sizeof(ServerSharedTaskInviteAccepted_Struct)
|
||||
);
|
||||
|
||||
auto *c = (ServerSharedTaskInviteAccepted_Struct *) p->pBuffer;
|
||||
|
||||
// fill
|
||||
c->source_character_id = CharacterID();
|
||||
c->shared_task_id = r->invite_id;
|
||||
c->accepted = r->accepted;
|
||||
strn0cpy(c->player_name, GetName(), sizeof(c->player_name));
|
||||
|
||||
LogTasks(
|
||||
"[ServerOP_SharedTaskInviteAcceptedPlayer] source_character_id [{}] shared_task_id [{}]",
|
||||
c->source_character_id,
|
||||
c->shared_task_id
|
||||
);
|
||||
|
||||
// send
|
||||
worldserver.SendPacket(p);
|
||||
safe_delete(p);
|
||||
}
|
||||
|
||||
void Client::Handle_OP_SharedTaskAccept(const EQApplicationPacket* app)
|
||||
{
|
||||
auto buf = reinterpret_cast<SharedTaskAccept_Struct*>(app->pBuffer);
|
||||
|
||||
LogTasksDetail(
|
||||
"[OP_SharedTaskAccept] unknown00 [{}] unknown04 [{}] npc_entity_id [{}] task_id [{}]",
|
||||
buf->unknown00,
|
||||
buf->unknown04,
|
||||
buf->npc_entity_id,
|
||||
buf->task_id
|
||||
);
|
||||
|
||||
if (buf->task_id > 0 && RuleB(TaskSystem, EnableTaskSystem) && task_state) {
|
||||
task_state->AcceptNewTask(this, buf->task_id, buf->npc_entity_id, std::time(nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Handle_OP_SharedTaskQuit(const EQApplicationPacket* app)
|
||||
{
|
||||
if (GetTaskState()->HasActiveSharedTask())
|
||||
{
|
||||
CancelTask(TASKSLOTSHAREDTASK, TaskType::Shared);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Handle_OP_TaskTimers(const EQApplicationPacket* app)
|
||||
{
|
||||
GetTaskState()->ListTaskTimers(this);
|
||||
}
|
||||
|
||||
void Client::Handle_OP_SharedTaskPlayerList(const EQApplicationPacket* app)
|
||||
{
|
||||
if (GetTaskState()->HasActiveSharedTask())
|
||||
{
|
||||
uint32_t size = sizeof(ServerSharedTaskPlayerList_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_SharedTaskPlayerList, size);
|
||||
auto buf = reinterpret_cast<ServerSharedTaskPlayerList_Struct*>(pack->pBuffer);
|
||||
buf->source_character_id = CharacterID();
|
||||
buf->task_id = GetTaskState()->GetActiveSharedTask().task_id;
|
||||
|
||||
worldserver.SendPacket(pack.get());
|
||||
}
|
||||
}
|
||||
|
||||
int64 Client::GetSharedTaskId() const
|
||||
{
|
||||
return m_shared_task_id;
|
||||
}
|
||||
|
||||
void Client::SetSharedTaskId(int64 shared_task_id)
|
||||
{
|
||||
Client::m_shared_task_id = shared_task_id;
|
||||
}
|
||||
|
||||
@ -282,6 +282,7 @@
|
||||
void Handle_OP_TargetCommand(const EQApplicationPacket *app);
|
||||
void Handle_OP_TargetMouse(const EQApplicationPacket *app);
|
||||
void Handle_OP_TaskHistoryRequest(const EQApplicationPacket *app);
|
||||
void Handle_OP_TaskTimers(const EQApplicationPacket *app);
|
||||
void Handle_OP_Taunt(const EQApplicationPacket *app);
|
||||
void Handle_OP_TestBuff(const EQApplicationPacket *app);
|
||||
void Handle_OP_TGB(const EQApplicationPacket *app);
|
||||
@ -315,3 +316,12 @@
|
||||
void Handle_OP_ResetAA(const EQApplicationPacket *app);
|
||||
void Handle_OP_MovementHistoryList(const EQApplicationPacket* app);
|
||||
void Handle_OP_UnderWorld(const EQApplicationPacket* app);
|
||||
|
||||
// shared tasks
|
||||
void Handle_OP_SharedTaskRemovePlayer(const EQApplicationPacket *app);
|
||||
void Handle_OP_SharedTaskAddPlayer(const EQApplicationPacket *app);
|
||||
void Handle_OP_SharedTaskMakeLeader(const EQApplicationPacket *app);
|
||||
void Handle_OP_SharedTaskInviteResponse(const EQApplicationPacket *app);
|
||||
void Handle_OP_SharedTaskAccept(const EQApplicationPacket *app);
|
||||
void Handle_OP_SharedTaskQuit(const EQApplicationPacket *app);
|
||||
void Handle_OP_SharedTaskPlayerList(const EQApplicationPacket *app);
|
||||
|
||||
@ -181,11 +181,7 @@ bool Client::Process() {
|
||||
myraid->MemberZoned(this);
|
||||
}
|
||||
|
||||
Expedition* expedition = GetExpedition();
|
||||
if (expedition)
|
||||
{
|
||||
expedition->SetMemberStatus(this, DynamicZoneMemberStatus::Offline);
|
||||
}
|
||||
SetDynamicZoneMemberStatus(DynamicZoneMemberStatus::Offline);
|
||||
|
||||
return false; //delete client
|
||||
}
|
||||
@ -562,11 +558,7 @@ bool Client::Process() {
|
||||
AI_Start(CLIENT_LD_TIMEOUT);
|
||||
SendAppearancePacket(AT_Linkdead, 1);
|
||||
|
||||
Expedition* expedition = GetExpedition();
|
||||
if (expedition)
|
||||
{
|
||||
expedition->SetMemberStatus(this, DynamicZoneMemberStatus::LinkDead);
|
||||
}
|
||||
SetDynamicZoneMemberStatus(DynamicZoneMemberStatus::LinkDead);
|
||||
}
|
||||
}
|
||||
|
||||
@ -698,10 +690,9 @@ void Client::OnDisconnect(bool hard_disconnect) {
|
||||
}
|
||||
}
|
||||
|
||||
Expedition* expedition = GetExpedition();
|
||||
if (expedition && !bZoning)
|
||||
if (!bZoning)
|
||||
{
|
||||
expedition->SetMemberStatus(this, DynamicZoneMemberStatus::Offline);
|
||||
SetDynamicZoneMemberStatus(DynamicZoneMemberStatus::Offline);
|
||||
}
|
||||
|
||||
RemoveAllAuras();
|
||||
|
||||
135
zone/command.cpp
135
zone/command.cpp
@ -61,6 +61,7 @@
|
||||
|
||||
#include "data_bucket.h"
|
||||
#include "command.h"
|
||||
#include "dynamic_zone.h"
|
||||
#include "expedition.h"
|
||||
#include "guild_mgr.h"
|
||||
#include "map.h"
|
||||
@ -76,6 +77,7 @@
|
||||
#include "npc_scale_manager.h"
|
||||
#include "../common/content/world_content_service.h"
|
||||
#include "../common/http/httplib.h"
|
||||
#include "../common/shared_tasks.h"
|
||||
|
||||
extern QueryServ* QServ;
|
||||
extern WorldServer worldserver;
|
||||
@ -7143,7 +7145,19 @@ void command_dz(Client* c, const Seperator* sep)
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcasecmp(sep->arg[1], "expedition") == 0)
|
||||
if (strcasecmp(sep->arg[1], "cache") == 0)
|
||||
{
|
||||
if (strcasecmp(sep->arg[2], "reload") == 0)
|
||||
{
|
||||
DynamicZone::CacheAllFromDatabase();
|
||||
Expedition::CacheAllFromDatabase();
|
||||
c->Message(Chat::White, fmt::format(
|
||||
"Reloaded [{}] dynamic zone(s) and [{}] expedition(s) from database",
|
||||
zone->dynamic_zone_cache.size(), zone->expedition_cache.size()
|
||||
).c_str());
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(sep->arg[1], "expedition") == 0)
|
||||
{
|
||||
if (strcasecmp(sep->arg[2], "list") == 0)
|
||||
{
|
||||
@ -7161,25 +7175,32 @@ void command_dz(Client* c, const Seperator* sep)
|
||||
c->Message(Chat::White, fmt::format("Total Active Expeditions: [{}]", expeditions.size()).c_str());
|
||||
for (const auto& expedition : expeditions)
|
||||
{
|
||||
auto dz = expedition->GetDynamicZone();
|
||||
if (!dz)
|
||||
{
|
||||
LogExpeditions("Expedition [{}] has an invalid dz [{}] in cache", expedition->GetID(), expedition->GetDynamicZoneID());
|
||||
continue;
|
||||
}
|
||||
|
||||
auto leader_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(fmt::format(
|
||||
"#goto {}", expedition->GetLeaderName()), false, expedition->GetLeaderName());
|
||||
auto zone_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(fmt::format(
|
||||
"#zoneinstance {}", expedition->GetDynamicZone().GetInstanceID()), false, "zone");
|
||||
"#zoneinstance {}", dz->GetInstanceID()), false, "zone");
|
||||
|
||||
auto seconds = expedition->GetDynamicZone().GetSecondsRemaining();
|
||||
auto seconds = dz->GetSecondsRemaining();
|
||||
|
||||
c->Message(Chat::White, fmt::format(
|
||||
"expedition id: [{}] dz id: [{}] name: [{}] leader: [{}] {}: [{}]:[{}]:[{}]:[{}] members: [{}] remaining: [{:02}:{:02}:{:02}]",
|
||||
expedition->GetID(),
|
||||
expedition->GetDynamicZone().GetID(),
|
||||
expedition->GetDynamicZoneID(),
|
||||
expedition->GetName(),
|
||||
leader_saylink,
|
||||
zone_saylink,
|
||||
ZoneName(expedition->GetDynamicZone().GetZoneID()),
|
||||
expedition->GetDynamicZone().GetZoneID(),
|
||||
expedition->GetDynamicZone().GetInstanceID(),
|
||||
expedition->GetDynamicZone().GetZoneVersion(),
|
||||
expedition->GetDynamicZone().GetMemberCount(),
|
||||
ZoneName(dz->GetZoneID()),
|
||||
dz->GetZoneID(),
|
||||
dz->GetInstanceID(),
|
||||
dz->GetZoneVersion(),
|
||||
dz->GetMemberCount(),
|
||||
seconds / 3600, // hours
|
||||
(seconds / 60) % 60, // minutes
|
||||
seconds % 60 // seconds
|
||||
@ -7201,7 +7222,7 @@ void command_dz(Client* c, const Seperator* sep)
|
||||
{
|
||||
c->Message(Chat::White, fmt::format("Destroying expedition [{}] ({})",
|
||||
expedition_id, expedition->GetName()).c_str());
|
||||
expedition->RemoveAllMembers();
|
||||
expedition->GetDynamicZone()->RemoveAllMembers();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -7224,9 +7245,46 @@ void command_dz(Client* c, const Seperator* sep)
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(sep->arg[1], "list") == 0)
|
||||
{
|
||||
c->Message(Chat::White, fmt::format("Total Dynamic Zones (cache): [{}]", zone->dynamic_zone_cache.size()).c_str());
|
||||
|
||||
std::vector<DynamicZone*> dynamic_zones;
|
||||
for (const auto& dz : zone->dynamic_zone_cache)
|
||||
{
|
||||
dynamic_zones.emplace_back(dz.second.get());
|
||||
}
|
||||
|
||||
std::sort(dynamic_zones.begin(), dynamic_zones.end(),
|
||||
[](const DynamicZone* lhs, const DynamicZone* rhs) {
|
||||
return lhs->GetID() < rhs->GetID();
|
||||
});
|
||||
|
||||
for (const auto& dz : dynamic_zones)
|
||||
{
|
||||
auto seconds = dz->GetSecondsRemaining();
|
||||
auto zone_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(
|
||||
fmt::format("#zoneinstance {}", dz->GetInstanceID()), false, "zone");
|
||||
|
||||
std::string aligned_type = fmt::format("[{}]", DynamicZone::GetDynamicZoneTypeName(static_cast<DynamicZoneType>(dz->GetType())));
|
||||
c->Message(Chat::White, fmt::format(
|
||||
"id: [{}] type: {:>10} {}: [{}]:[{}]:[{}] members: [{}] remaining: [{:02}:{:02}:{:02}]",
|
||||
dz->GetID(),
|
||||
aligned_type,
|
||||
zone_saylink,
|
||||
dz->GetZoneID(),
|
||||
dz->GetInstanceID(),
|
||||
dz->GetZoneVersion(),
|
||||
dz->GetMemberCount(),
|
||||
seconds / 3600, // hours
|
||||
(seconds / 60) % 60, // minutes
|
||||
seconds % 60 // seconds
|
||||
).c_str());
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(sep->arg[1], "listdb") == 0)
|
||||
{
|
||||
auto dz_list = DynamicZonesRepository::AllDzInstancePlayerCounts(database);
|
||||
c->Message(Chat::White, fmt::format("Total Dynamic Zones: [{}]", dz_list.size()).c_str());
|
||||
c->Message(Chat::White, fmt::format("Total Dynamic Zones (database): [{}]", dz_list.size()).c_str());
|
||||
|
||||
auto now = std::chrono::system_clock::now();
|
||||
|
||||
@ -7243,7 +7301,7 @@ void command_dz(Client* c, const Seperator* sep)
|
||||
fmt::format("#zoneinstance {}", dz.instance), false, "zone");
|
||||
|
||||
c->Message(Chat::White, fmt::format(
|
||||
"dz id: [{}] type: [{}] {}: [{}]:[{}]:[{}] members: [{}] remaining: [{:02}:{:02}:{:02}]",
|
||||
"id: [{}] type: [{}] {}: [{}]:[{}]:[{}] members: [{}] remaining: [{:02}:{:02}:{:02}]",
|
||||
dz.id,
|
||||
DynamicZone::GetDynamicZoneTypeName(static_cast<DynamicZoneType>(dz.type)),
|
||||
zone_saylink,
|
||||
@ -7295,11 +7353,13 @@ void command_dz(Client* c, const Seperator* sep)
|
||||
else
|
||||
{
|
||||
c->Message(Chat::White, "#dz usage:");
|
||||
c->Message(Chat::White, "#dz cache reload - reload the current zone cache from db (also reloads expedition cache dependency)");
|
||||
c->Message(Chat::White, "#dz expedition list - list expeditions in current zone cache");
|
||||
c->Message(Chat::White, "#dz expedition reload - reload expedition zone cache from database");
|
||||
c->Message(Chat::White, "#dz expedition destroy <expedition_id> - destroy expedition globally (must be in cache)");
|
||||
c->Message(Chat::White, "#dz expedition unlock <expedition_id> - unlock expedition");
|
||||
c->Message(Chat::White, "#dz list [all] - list dynamic zone instances from database -- 'all' includes expired");
|
||||
c->Message(Chat::White, "#dz list - list all dynamic zone instances from current zone cache");
|
||||
c->Message(Chat::White, "#dz listdb [all] - list dynamic zone instances from database -- 'all' includes expired");
|
||||
c->Message(Chat::White, "#dz lockouts remove <char_name> - delete all of character's expedition lockouts");
|
||||
c->Message(Chat::White, "#dz lockouts remove <char_name> \"<expedition_name>\" - delete lockouts by expedition");
|
||||
c->Message(Chat::White, "#dz lockouts remove <char_name> \"<expedition_name>\" \"<event_name>\" - delete lockout by expedition event");
|
||||
@ -10526,6 +10586,25 @@ void command_task(Client *c, const Seperator *sep) {
|
||||
EQ::SayLinkEngine::GenerateQuestSaylink("#task reload sets", false, "reload sets")
|
||||
).c_str()
|
||||
);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"--- [{}] Purges targeted characters task timers",
|
||||
EQ::SayLinkEngine::GenerateQuestSaylink("#task purgetimers", false, "purgetimers")
|
||||
).c_str()
|
||||
);
|
||||
|
||||
c->Message(Chat::White, "------------------------------------------------");
|
||||
c->Message(Chat::White, "# Shared Task System Commands");
|
||||
c->Message(Chat::White, "------------------------------------------------");
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"--- [{}] Purges all active Shared Tasks in memory and database ",
|
||||
EQ::SayLinkEngine::GenerateQuestSaylink("#task sharedpurge", false, "sharedpurge")
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -10539,6 +10618,15 @@ void command_task(Client *c, const Seperator *sep) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcasecmp(sep->arg[1], "purgetimers")) {
|
||||
c->Message(15, fmt::format("{}'s task timers have been purged", client_target->GetCleanName()).c_str());
|
||||
if (client_target != c) {
|
||||
client_target->Message(15, "[GM] Your task timers have been purged by a GM");
|
||||
}
|
||||
client_target->PurgeTaskTimers();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcasecmp(sep->arg[1], "update")) {
|
||||
if (sep->argnum >= 3) {
|
||||
int task_id = atoi(sep->arg[2]);
|
||||
@ -10565,6 +10653,27 @@ void command_task(Client *c, const Seperator *sep) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcasecmp(sep->arg[1], "sharedpurge")) {
|
||||
if (!strcasecmp(sep->arg[2], "confirm")) {
|
||||
LogTasksDetail("Sending purge request");
|
||||
auto pack = new ServerPacket(ServerOP_SharedTaskPurgeAllCommand, 0);
|
||||
worldserver.SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"[WARNING] This will purge all active Shared Tasks [{}]?",
|
||||
EQ::SayLinkEngine::GenerateQuestSaylink("#task sharedpurge confirm", false, "confirm")
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcasecmp(sep->arg[1], "assign")) {
|
||||
int task_id = atoi(sep->arg[2]);
|
||||
if ((task_id > 0) && (task_id < MAXTASKS)) {
|
||||
|
||||
@ -1261,16 +1261,16 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
|
||||
return;
|
||||
}
|
||||
|
||||
if (zone && zone->GetInstanceID() != 0)
|
||||
if (!IsPlayerCorpse())
|
||||
{
|
||||
// expeditions may prevent looting based on client's lockouts
|
||||
auto expedition = Expedition::FindCachedExpeditionByZoneInstance(zone->GetZoneID(), zone->GetInstanceID());
|
||||
if (expedition && !expedition->CanClientLootCorpse(client, GetNPCTypeID(), GetID()))
|
||||
// dynamic zones may prevent looting by non-members or based on lockouts
|
||||
auto dz = zone->GetDynamicZone();
|
||||
if (dz && !dz->CanClientLootCorpse(client, GetNPCTypeID(), GetID()))
|
||||
{
|
||||
client->MessageString(Chat::Red, LOOT_NOT_ALLOWED, inst->GetItem()->Name);
|
||||
// note on live this message is only sent once on the first loot attempt of an open corpse
|
||||
client->MessageString(Chat::Loot, LOOT_NOT_ALLOWED, inst->GetItem()->Name);
|
||||
lootitem->auto_loot = -1; // generates client eqstr 1370 "You may not loot that item from this corpse."
|
||||
client->QueuePacket(app);
|
||||
SendEndLootErrorPacket(client);
|
||||
ResetLooter();
|
||||
delete inst;
|
||||
return;
|
||||
}
|
||||
@ -1307,7 +1307,7 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
|
||||
|
||||
/* Update any tasks that have an activity to loot this item */
|
||||
if (RuleB(TaskSystem, EnableTaskSystem))
|
||||
client->UpdateTasksForItem(ActivityLoot, item->ID);
|
||||
client->UpdateTasksForItem(TaskActivityType::Loot, item->ID);
|
||||
|
||||
/* Remove it from Corpse */
|
||||
if (item_data) {
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include "dynamic_zone.h"
|
||||
#include "client.h"
|
||||
#include "expedition.h"
|
||||
#include "string_ids.h"
|
||||
#include "worldserver.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
|
||||
@ -43,6 +44,11 @@ Database& DynamicZone::GetDatabase()
|
||||
return database;
|
||||
}
|
||||
|
||||
bool DynamicZone::SendServerPacket(ServerPacket* packet)
|
||||
{
|
||||
return worldserver.SendPacket(packet);
|
||||
}
|
||||
|
||||
uint16_t DynamicZone::GetCurrentInstanceID()
|
||||
{
|
||||
return zone ? static_cast<uint16_t>(zone->GetInstanceID()) : 0;
|
||||
@ -53,17 +59,119 @@ uint16_t DynamicZone::GetCurrentZoneID()
|
||||
return zone ? static_cast<uint16_t>(zone->GetZoneID()) : 0;
|
||||
}
|
||||
|
||||
DynamicZone* DynamicZone::CreateNew(DynamicZone& dz_request, const std::vector<DynamicZoneMember>& members)
|
||||
{
|
||||
if (!zone || dz_request.GetID() != 0)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// this creates a new dz instance and saves it to both db and cache
|
||||
uint32_t dz_id = dz_request.Create();
|
||||
if (dz_id == 0)
|
||||
{
|
||||
LogDynamicZones("Failed to create dynamic zone for zone [{}]", dz_request.GetZoneID());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto dz = std::make_unique<DynamicZone>(dz_request);
|
||||
if (!members.empty())
|
||||
{
|
||||
dz->SaveMembers(members);
|
||||
}
|
||||
|
||||
LogDynamicZones("Created new dz [{}] for zone [{}]", dz_id, dz_request.GetZoneID());
|
||||
|
||||
// world must be notified before we request async member updates
|
||||
auto pack = dz->CreateServerDzCreatePacket(zone->GetZoneID(), zone->GetInstanceID());
|
||||
worldserver.SendPacket(pack.get());
|
||||
|
||||
auto inserted = zone->dynamic_zone_cache.emplace(dz_id, std::move(dz));
|
||||
|
||||
// expeditions invoke their own updates after installing client update callbacks
|
||||
if (inserted.first->second->GetType() != DynamicZoneType::Expedition)
|
||||
{
|
||||
inserted.first->second->DoAsyncZoneMemberUpdates();
|
||||
}
|
||||
|
||||
return inserted.first->second.get();
|
||||
}
|
||||
|
||||
void DynamicZone::CacheNewDynamicZone(ServerPacket* pack)
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzCreateSerialized_Struct*>(pack->pBuffer);
|
||||
|
||||
// caching new dz created in world or another zone (has member statuses set by world)
|
||||
auto dz = std::make_unique<DynamicZone>();
|
||||
dz->LoadSerializedDzPacket(buf->cereal_data, buf->cereal_size);
|
||||
|
||||
uint32_t dz_id = dz->GetID();
|
||||
auto inserted = zone->dynamic_zone_cache.emplace(dz_id, std::move(dz));
|
||||
|
||||
// expeditions invoke their own updates after installing client update callbacks
|
||||
if (inserted.first->second->GetType() != DynamicZoneType::Expedition)
|
||||
{
|
||||
inserted.first->second->DoAsyncZoneMemberUpdates();
|
||||
}
|
||||
|
||||
LogDynamicZones("Cached new dynamic zone [{}]", dz_id);
|
||||
}
|
||||
|
||||
void DynamicZone::CacheAllFromDatabase()
|
||||
{
|
||||
if (!zone)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BenchTimer bench;
|
||||
|
||||
auto dynamic_zones = DynamicZonesRepository::AllWithInstanceNotExpired(database);
|
||||
auto dynamic_zone_members = DynamicZoneMembersRepository::GetAllWithNames(database);
|
||||
|
||||
zone->dynamic_zone_cache.clear();
|
||||
zone->dynamic_zone_cache.reserve(dynamic_zones.size());
|
||||
|
||||
for (auto& entry : dynamic_zones)
|
||||
{
|
||||
uint32_t dz_id = entry.id;
|
||||
auto dz = std::make_unique<DynamicZone>(std::move(entry));
|
||||
|
||||
for (auto& member : dynamic_zone_members)
|
||||
{
|
||||
if (member.dynamic_zone_id == dz_id)
|
||||
{
|
||||
dz->AddMemberFromRepositoryResult(std::move(member));
|
||||
}
|
||||
}
|
||||
|
||||
zone->dynamic_zone_cache.emplace(dz_id, std::move(dz));
|
||||
}
|
||||
|
||||
LogDynamicZones("Caching [{}] dynamic zone(s) took [{}s]", zone->dynamic_zone_cache.size(), bench.elapsed());
|
||||
}
|
||||
|
||||
DynamicZone* DynamicZone::FindDynamicZoneByID(uint32_t dz_id)
|
||||
{
|
||||
auto expedition = Expedition::FindCachedExpeditionByDynamicZoneID(dz_id);
|
||||
if (expedition)
|
||||
if (!zone)
|
||||
{
|
||||
return &expedition->GetDynamicZone();
|
||||
return nullptr;
|
||||
}
|
||||
// todo: other system caches
|
||||
|
||||
auto dz = zone->dynamic_zone_cache.find(dz_id);
|
||||
if (dz != zone->dynamic_zone_cache.end())
|
||||
{
|
||||
return dz->second.get();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DynamicZone::RegisterOnClientAddRemove(std::function<void(Client*, bool, bool)> on_client_addremove)
|
||||
{
|
||||
m_on_client_addremove = std::move(on_client_addremove);
|
||||
}
|
||||
|
||||
void DynamicZone::StartAllClientRemovalTimers()
|
||||
{
|
||||
for (const auto& client_iter : entity_list.GetClientList())
|
||||
@ -75,38 +183,6 @@ void DynamicZone::StartAllClientRemovalTimers()
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendInstanceRemoveAllCharacters()
|
||||
{
|
||||
// just remove all clients in bulk instead of only characters assigned to the instance
|
||||
if (IsCurrentZoneDzInstance())
|
||||
{
|
||||
DynamicZone::StartAllClientRemovalTimers();
|
||||
}
|
||||
else if (GetInstanceID() != 0)
|
||||
{
|
||||
auto pack = CreateServerRemoveAllCharactersPacket();
|
||||
worldserver.SendPacket(pack.get());
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendInstanceAddRemoveCharacter(uint32_t character_id, bool removed)
|
||||
{
|
||||
// if removing, sets removal timer on client inside the instance
|
||||
if (IsCurrentZoneDzInstance())
|
||||
{
|
||||
Client* client = entity_list.GetClientByCharID(character_id);
|
||||
if (client)
|
||||
{
|
||||
client->SetDzRemovalTimer(removed);
|
||||
}
|
||||
}
|
||||
else if (GetInstanceID() != 0)
|
||||
{
|
||||
auto pack = CreateServerAddRemoveCharacterPacket(character_id, removed);
|
||||
worldserver.SendPacket(pack.get());
|
||||
}
|
||||
}
|
||||
|
||||
bool DynamicZone::IsCurrentZoneDzInstance() const
|
||||
{
|
||||
return (zone && zone->GetInstanceID() != 0 && zone->GetInstanceID() == GetInstanceID());
|
||||
@ -129,8 +205,8 @@ void DynamicZone::SetUpdatedDuration(uint32_t new_duration)
|
||||
m_duration = std::chrono::seconds(new_duration);
|
||||
m_expire_time = m_start_time + m_duration;
|
||||
|
||||
LogDynamicZones("Updated zone [{}]:[{}] seconds remaining: [{}]",
|
||||
m_zone_id, m_instance_id, GetSecondsRemaining());
|
||||
LogDynamicZones("Updated dz [{}] zone [{}]:[{}] seconds remaining: [{}]",
|
||||
m_id, m_zone_id, m_instance_id, GetSecondsRemaining());
|
||||
|
||||
if (zone && IsCurrentZoneDzInstance())
|
||||
{
|
||||
@ -138,31 +214,115 @@ void DynamicZone::SetUpdatedDuration(uint32_t new_duration)
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendGlobalLocationChange(uint16_t server_opcode, const DynamicZoneLocation& location)
|
||||
{
|
||||
auto pack = CreateServerDzLocationPacket(server_opcode, location);
|
||||
worldserver.SendPacket(pack.get());
|
||||
}
|
||||
|
||||
void DynamicZone::HandleWorldMessage(ServerPacket* pack)
|
||||
{
|
||||
switch (pack->opcode)
|
||||
{
|
||||
case ServerOP_DzAddRemoveCharacter:
|
||||
case ServerOP_DzCreated:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzCharacter_Struct*>(pack->pBuffer);
|
||||
Client* client = entity_list.GetClientByCharID(buf->character_id);
|
||||
if (client)
|
||||
auto buf = reinterpret_cast<ServerDzCreateSerialized_Struct*>(pack->pBuffer);
|
||||
if (zone && !zone->IsZone(buf->origin_zone_id, buf->origin_instance_id))
|
||||
{
|
||||
client->SetDzRemovalTimer(buf->remove); // instance kick timer
|
||||
DynamicZone::CacheNewDynamicZone(pack);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzRemoveAllCharacters:
|
||||
case ServerOP_DzDeleted:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzCharacter_Struct*>(pack->pBuffer);
|
||||
if (buf->remove)
|
||||
// sent by world when it deletes an expired or empty dz
|
||||
// any system that held a reference to the dz should have already been notified
|
||||
auto buf = reinterpret_cast<ServerDzID_Struct*>(pack->pBuffer);
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (zone && dz)
|
||||
{
|
||||
dz->SendUpdatesToZoneMembers(true, true); // members silently removed
|
||||
|
||||
// manually handle expeditions to remove any references before the dz is deleted
|
||||
if (dz->GetType() == DynamicZoneType::Expedition)
|
||||
{
|
||||
auto expedition = Expedition::FindCachedExpeditionByDynamicZoneID(dz->GetID());
|
||||
if (expedition)
|
||||
{
|
||||
LogExpeditionsModerate("Deleting expedition [{}] from zone cache", expedition->GetID());
|
||||
zone->expedition_cache.erase(expedition->GetID());
|
||||
}
|
||||
}
|
||||
|
||||
LogDynamicZonesDetail("Deleting dynamic zone [{}] from zone cache", buf->dz_id);
|
||||
zone->dynamic_zone_cache.erase(buf->dz_id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzAddRemoveMember:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzMember_Struct*>(pack->pBuffer);
|
||||
if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id))
|
||||
{
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
auto status = static_cast<DynamicZoneMemberStatus>(buf->character_status);
|
||||
dz->ProcessMemberAddRemove({ buf->character_id, buf->character_name, status }, buf->removed);
|
||||
}
|
||||
}
|
||||
|
||||
if (zone && zone->IsZone(buf->dz_zone_id, buf->dz_instance_id))
|
||||
{
|
||||
// cache independent redundancy to kick removed members from dz's instance
|
||||
Client* client = entity_list.GetClientByCharID(buf->character_id);
|
||||
if (client)
|
||||
{
|
||||
client->SetDzRemovalTimer(buf->removed);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzSwapMembers:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzMemberSwap_Struct*>(pack->pBuffer);
|
||||
if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id))
|
||||
{
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
auto status = static_cast<DynamicZoneMemberStatus>(buf->add_character_status);
|
||||
dz->ProcessMemberAddRemove({ buf->remove_character_id, buf->remove_character_name }, true);
|
||||
dz->ProcessMemberAddRemove({ buf->add_character_id, buf->add_character_name, status }, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (zone && zone->IsZone(buf->dz_zone_id, buf->dz_instance_id))
|
||||
{
|
||||
// cache independent redundancy to kick removed members from dz's instance
|
||||
Client* removed_client = entity_list.GetClientByCharID(buf->remove_character_id);
|
||||
if (removed_client)
|
||||
{
|
||||
removed_client->SetDzRemovalTimer(true);
|
||||
}
|
||||
|
||||
Client* added_client = entity_list.GetClientByCharID(buf->add_character_id);
|
||||
if (added_client)
|
||||
{
|
||||
added_client->SetDzRemovalTimer(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzRemoveAllMembers:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzID_Struct*>(pack->pBuffer);
|
||||
if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id))
|
||||
{
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
dz->ProcessRemoveAllMembers();
|
||||
}
|
||||
}
|
||||
|
||||
if (zone && zone->IsZone(buf->dz_zone_id, buf->dz_instance_id))
|
||||
{
|
||||
// cache independent redundancy to kick removed members from dz's instance
|
||||
DynamicZone::StartAllClientRemovalTimers();
|
||||
}
|
||||
break;
|
||||
@ -203,7 +363,140 @@ void DynamicZone::HandleWorldMessage(ServerPacket* pack)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzGetMemberStatuses:
|
||||
{
|
||||
// reply from world for online member statuses request for async zone member updates
|
||||
auto buf = reinterpret_cast<ServerDzMemberStatuses_Struct*>(pack->pBuffer);
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
for (uint32_t i = 0; i < buf->count; ++i)
|
||||
{
|
||||
auto status = static_cast<DynamicZoneMemberStatus>(buf->entries[i].online_status);
|
||||
dz->SetInternalMemberStatus(buf->entries[i].character_id, status);
|
||||
}
|
||||
dz->m_has_member_statuses = true;
|
||||
dz->SendUpdatesToZoneMembers(false, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzUpdateMemberStatus:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzMemberStatus_Struct*>(pack->pBuffer);
|
||||
if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id))
|
||||
{
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
auto status = static_cast<DynamicZoneMemberStatus>(buf->status);
|
||||
dz->ProcessMemberStatusChange(buf->character_id, status);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzLeaderChanged:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzLeaderID_Struct*>(pack->pBuffer);
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
dz->ProcessLeaderChanged(buf->leader_id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzExpireWarning:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzExpireWarning_Struct*>(pack->pBuffer);
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
dz->SendMembersExpireWarning(buf->minutes_remaining);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> DynamicZone::CreateExpireWarningPacket(uint32_t minutes_remaining)
|
||||
{
|
||||
uint32_t outsize = sizeof(ExpeditionExpireWarning);
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_DzExpeditionEndsWarning, outsize);
|
||||
auto buf = reinterpret_cast<ExpeditionExpireWarning*>(outapp->pBuffer);
|
||||
buf->minutes_remaining = minutes_remaining;
|
||||
return outapp;
|
||||
}
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> DynamicZone::CreateInfoPacket(bool clear)
|
||||
{
|
||||
constexpr uint32_t outsize = sizeof(DynamicZoneInfo_Struct);
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_DzExpeditionInfo, outsize);
|
||||
if (!clear)
|
||||
{
|
||||
auto info = reinterpret_cast<DynamicZoneInfo_Struct*>(outapp->pBuffer);
|
||||
info->assigned = true;
|
||||
strn0cpy(info->dz_name, m_name.c_str(), sizeof(info->dz_name));
|
||||
strn0cpy(info->leader_name, m_leader.name.c_str(), sizeof(info->leader_name));
|
||||
info->max_players = m_max_players;
|
||||
}
|
||||
return outapp;
|
||||
}
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> DynamicZone::CreateMemberListPacket(bool clear)
|
||||
{
|
||||
uint32_t member_count = clear ? 0 : static_cast<uint32_t>(m_members.size());
|
||||
uint32_t member_entries_size = sizeof(DynamicZoneMemberEntry_Struct) * member_count;
|
||||
uint32_t outsize = sizeof(DynamicZoneMemberList_Struct) + member_entries_size;
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_DzMemberList, outsize);
|
||||
auto buf = reinterpret_cast<DynamicZoneMemberList_Struct*>(outapp->pBuffer);
|
||||
|
||||
buf->member_count = member_count;
|
||||
|
||||
if (!clear)
|
||||
{
|
||||
for (auto i = 0; i < m_members.size(); ++i)
|
||||
{
|
||||
strn0cpy(buf->members[i].name, m_members[i].name.c_str(), sizeof(buf->members[i].name));
|
||||
buf->members[i].online_status = static_cast<uint8_t>(m_members[i].status);
|
||||
}
|
||||
}
|
||||
|
||||
return outapp;
|
||||
}
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> DynamicZone::CreateMemberListNamePacket(
|
||||
const std::string& name, bool remove_name)
|
||||
{
|
||||
constexpr uint32_t outsize = sizeof(DynamicZoneMemberListName_Struct);
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_DzMemberListName, outsize);
|
||||
auto buf = reinterpret_cast<DynamicZoneMemberListName_Struct*>(outapp->pBuffer);
|
||||
buf->add_name = !remove_name;
|
||||
strn0cpy(buf->name, name.c_str(), sizeof(buf->name));
|
||||
return outapp;
|
||||
}
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> DynamicZone::CreateMemberListStatusPacket(
|
||||
const std::string& name, DynamicZoneMemberStatus status)
|
||||
{
|
||||
// member list status uses member list struct with a single entry
|
||||
constexpr uint32_t outsize = sizeof(DynamicZoneMemberList_Struct) + sizeof(DynamicZoneMemberEntry_Struct);
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_DzMemberListStatus, outsize);
|
||||
auto buf = reinterpret_cast<DynamicZoneMemberList_Struct*>(outapp->pBuffer);
|
||||
buf->member_count = 1;
|
||||
|
||||
auto entry = static_cast<DynamicZoneMemberEntry_Struct*>(buf->members);
|
||||
strn0cpy(entry->name, name.c_str(), sizeof(entry->name));
|
||||
entry->online_status = static_cast<uint8_t>(status);
|
||||
|
||||
return outapp;
|
||||
}
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> DynamicZone::CreateLeaderNamePacket()
|
||||
{
|
||||
constexpr uint32_t outsize = sizeof(DynamicZoneLeaderName_Struct);
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_DzSetLeaderName, outsize);
|
||||
auto buf = reinterpret_cast<DynamicZoneLeaderName_Struct*>(outapp->pBuffer);
|
||||
strn0cpy(buf->leader_name, m_leader.name.c_str(), sizeof(buf->leader_name));
|
||||
return outapp;
|
||||
}
|
||||
|
||||
void DynamicZone::ProcessCompassChange(const DynamicZoneLocation& location)
|
||||
@ -223,3 +516,264 @@ void DynamicZone::SendCompassUpdateToZoneMembers()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendLeaderNameToZoneMembers()
|
||||
{
|
||||
auto outapp_leader = CreateLeaderNamePacket();
|
||||
|
||||
for (const auto& member : m_members)
|
||||
{
|
||||
Client* member_client = entity_list.GetClientByCharID(member.id);
|
||||
if (member_client)
|
||||
{
|
||||
member_client->QueuePacket(outapp_leader.get());
|
||||
|
||||
if (member.id == m_leader.id && RuleB(Expedition, AlwaysNotifyNewLeaderOnChange))
|
||||
{
|
||||
member_client->MessageString(Chat::Yellow, DZMAKELEADER_YOU);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendMembersExpireWarning(uint32_t minutes_remaining)
|
||||
{
|
||||
// expeditions warn members in all zones not just the dz
|
||||
auto outapp = CreateExpireWarningPacket(minutes_remaining);
|
||||
for (const auto& member : GetMembers())
|
||||
{
|
||||
Client* member_client = entity_list.GetClientByCharID(member.id);
|
||||
if (member_client)
|
||||
{
|
||||
member_client->QueuePacket(outapp.get());
|
||||
|
||||
// live doesn't actually send the chat message with it
|
||||
member_client->MessageString(Chat::Yellow, EXPEDITION_MIN_REMAIN,
|
||||
fmt::format_int(minutes_remaining).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendMemberListToZoneMembers()
|
||||
{
|
||||
auto outapp_members = CreateMemberListPacket(false);
|
||||
|
||||
for (const auto& member : m_members)
|
||||
{
|
||||
Client* member_client = entity_list.GetClientByCharID(member.id);
|
||||
if (member_client)
|
||||
{
|
||||
member_client->QueuePacket(outapp_members.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendMemberListNameToZoneMembers(const std::string& char_name, bool remove)
|
||||
{
|
||||
auto outapp_member_name = CreateMemberListNamePacket(char_name, remove);
|
||||
|
||||
for (const auto& member : m_members)
|
||||
{
|
||||
Client* member_client = entity_list.GetClientByCharID(member.id);
|
||||
if (member_client)
|
||||
{
|
||||
member_client->QueuePacket(outapp_member_name.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendMemberListStatusToZoneMembers(const DynamicZoneMember& update_member)
|
||||
{
|
||||
auto outapp_member_status = CreateMemberListStatusPacket(update_member.name, update_member.status);
|
||||
|
||||
for (const auto& member : m_members)
|
||||
{
|
||||
Client* member_client = entity_list.GetClientByCharID(member.id);
|
||||
if (member_client)
|
||||
{
|
||||
member_client->QueuePacket(outapp_member_status.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendClientWindowUpdate(Client* client)
|
||||
{
|
||||
if (client)
|
||||
{
|
||||
client->QueuePacket(CreateInfoPacket().get());
|
||||
client->QueuePacket(CreateMemberListPacket().get());
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendUpdatesToZoneMembers(bool removing_all, bool silent)
|
||||
{
|
||||
// performs a full update on all members (usually for dz creation or removing all)
|
||||
if (!HasMembers())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> outapp_info = nullptr;
|
||||
std::unique_ptr<EQApplicationPacket> outapp_members = nullptr;
|
||||
|
||||
// only expeditions use the dz window. on live the window is filled by non
|
||||
// expeditions when first created but never kept updated. that behavior could
|
||||
// be replicated in the future by flagging this as a creation update
|
||||
if (m_type == DynamicZoneType::Expedition)
|
||||
{
|
||||
// clearing info also clears member list, no need to send both when removing
|
||||
outapp_info = CreateInfoPacket(removing_all);
|
||||
outapp_members = removing_all ? nullptr : CreateMemberListPacket();
|
||||
}
|
||||
|
||||
for (const auto& member : GetMembers())
|
||||
{
|
||||
Client* client = entity_list.GetClientByCharID(member.id);
|
||||
if (client)
|
||||
{
|
||||
if (removing_all) {
|
||||
client->RemoveDynamicZoneID(GetID());
|
||||
} else {
|
||||
client->AddDynamicZoneID(GetID());
|
||||
}
|
||||
|
||||
client->SendDzCompassUpdate();
|
||||
|
||||
if (outapp_info)
|
||||
{
|
||||
client->QueuePacket(outapp_info.get());
|
||||
}
|
||||
|
||||
if (outapp_members)
|
||||
{
|
||||
client->QueuePacket(outapp_members.get());
|
||||
}
|
||||
|
||||
// callback to the dz system so it can perform any messages or set client data
|
||||
if (m_on_client_addremove)
|
||||
{
|
||||
m_on_client_addremove(client, removing_all, silent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::ProcessMemberAddRemove(const DynamicZoneMember& member, bool removed)
|
||||
{
|
||||
DynamicZoneBase::ProcessMemberAddRemove(member, removed);
|
||||
|
||||
// the affected client always gets a full compass update. for expeditions
|
||||
// client also gets window info update and all members get a member list update
|
||||
Client* client = entity_list.GetClientByCharID(member.id);
|
||||
if (client)
|
||||
{
|
||||
if (!removed) {
|
||||
client->AddDynamicZoneID(GetID());
|
||||
} else {
|
||||
client->RemoveDynamicZoneID(GetID());
|
||||
}
|
||||
|
||||
client->SendDzCompassUpdate();
|
||||
|
||||
if (m_type == DynamicZoneType::Expedition)
|
||||
{
|
||||
// sending clear info also clears member list for removed members
|
||||
client->QueuePacket(CreateInfoPacket(removed).get());
|
||||
}
|
||||
|
||||
if (m_on_client_addremove)
|
||||
{
|
||||
m_on_client_addremove(client, removed, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_type == DynamicZoneType::Expedition)
|
||||
{
|
||||
// send full list when adding (MemberListName adds with "unknown" status)
|
||||
if (!removed) {
|
||||
SendMemberListToZoneMembers();
|
||||
} else {
|
||||
SendMemberListNameToZoneMembers(member.name, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::ProcessRemoveAllMembers(bool silent)
|
||||
{
|
||||
SendUpdatesToZoneMembers(true, silent);
|
||||
DynamicZoneBase::ProcessRemoveAllMembers(silent);
|
||||
}
|
||||
|
||||
void DynamicZone::DoAsyncZoneMemberUpdates()
|
||||
{
|
||||
// gets member statuses from world and performs zone member updates on reply
|
||||
// if we've already received member statuses we can just update immediately
|
||||
if (m_has_member_statuses)
|
||||
{
|
||||
SendUpdatesToZoneMembers();
|
||||
return;
|
||||
}
|
||||
|
||||
constexpr uint32_t pack_size = sizeof(ServerDzID_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_DzGetMemberStatuses, pack_size);
|
||||
auto buf = reinterpret_cast<ServerDzID_Struct*>(pack->pBuffer);
|
||||
buf->dz_id = GetID();
|
||||
buf->sender_zone_id = zone ? zone->GetZoneID() : 0;
|
||||
buf->sender_instance_id = zone ? zone->GetInstanceID() : 0;
|
||||
worldserver.SendPacket(pack.get());
|
||||
}
|
||||
|
||||
bool DynamicZone::ProcessMemberStatusChange(uint32_t member_id, DynamicZoneMemberStatus status)
|
||||
{
|
||||
bool changed = DynamicZoneBase::ProcessMemberStatusChange(member_id, status);
|
||||
|
||||
if (changed && m_type == DynamicZoneType::Expedition)
|
||||
{
|
||||
auto member = GetMemberData(member_id);
|
||||
if (member.IsValid())
|
||||
{
|
||||
SendMemberListStatusToZoneMembers(member);
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
void DynamicZone::ProcessLeaderChanged(uint32_t new_leader_id)
|
||||
{
|
||||
auto new_leader = GetMemberData(new_leader_id);
|
||||
if (!new_leader.IsValid())
|
||||
{
|
||||
LogDynamicZones("Processed invalid new leader id [{}] for dz [{}]", new_leader_id, m_id);
|
||||
return;
|
||||
}
|
||||
|
||||
LogDynamicZones("Replaced [{}] leader [{}] with [{}]", m_id, GetLeaderName(), new_leader.name);
|
||||
|
||||
SetLeader(new_leader);
|
||||
if (GetType() == DynamicZoneType::Expedition)
|
||||
{
|
||||
SendLeaderNameToZoneMembers();
|
||||
}
|
||||
}
|
||||
|
||||
bool DynamicZone::CanClientLootCorpse(Client* client, uint32_t npc_type_id, uint32_t entity_id)
|
||||
{
|
||||
// non-members of a dz cannot loot corpses inside the dz
|
||||
if (!HasMember(client->CharacterID()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// expeditions may prevent looting based on client's lockouts
|
||||
if (GetType() == DynamicZoneType::Expedition)
|
||||
{
|
||||
auto expedition = Expedition::FindCachedExpeditionByZoneInstance(zone->GetZoneID(), zone->GetInstanceID());
|
||||
if (expedition && !expedition->CanClientLootCorpse(client, npc_type_id, entity_id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -27,7 +27,9 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
class Client;
|
||||
class Database;
|
||||
class EQApplicationPacket;
|
||||
class ServerPacket;
|
||||
|
||||
extern const char* const CREATE_NOT_ALL_ADDED;
|
||||
@ -40,26 +42,51 @@ public:
|
||||
DynamicZone() = default;
|
||||
DynamicZone(uint32_t zone_id, uint32_t version, uint32_t duration, DynamicZoneType type);
|
||||
|
||||
static void CacheAllFromDatabase();
|
||||
static void CacheNewDynamicZone(ServerPacket* pack);
|
||||
static DynamicZone* CreateNew(DynamicZone& dz_details, const std::vector<DynamicZoneMember>& members);
|
||||
static DynamicZone* FindDynamicZoneByID(uint32_t dz_id);
|
||||
static void HandleWorldMessage(ServerPacket* pack);
|
||||
|
||||
void SetSecondsRemaining(uint32_t seconds_remaining) override;
|
||||
|
||||
void DoAsyncZoneMemberUpdates();
|
||||
bool CanClientLootCorpse(Client* client, uint32_t npc_type_id, uint32_t entity_id);
|
||||
bool IsCurrentZoneDzInstance() const;
|
||||
void SetUpdatedDuration(uint32_t seconds);
|
||||
void RegisterOnClientAddRemove(std::function<void(Client* client, bool removed, bool silent)> on_client_addremove);
|
||||
void SendClientWindowUpdate(Client* client);
|
||||
void SendLeaderNameToZoneMembers();
|
||||
void SendMemberListToZoneMembers();
|
||||
void SendMemberListNameToZoneMembers(const std::string& char_name, bool remove);
|
||||
void SendMemberListStatusToZoneMembers(const DynamicZoneMember& member);
|
||||
void SendRemoveAllMembersToZoneMembers(bool silent) { ProcessRemoveAllMembers(silent); }
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> CreateExpireWarningPacket(uint32_t minutes_remaining);
|
||||
std::unique_ptr<EQApplicationPacket> CreateInfoPacket(bool clear = false);
|
||||
std::unique_ptr<EQApplicationPacket> CreateLeaderNamePacket();
|
||||
std::unique_ptr<EQApplicationPacket> CreateMemberListPacket(bool clear = false);
|
||||
std::unique_ptr<EQApplicationPacket> CreateMemberListNamePacket(const std::string& name, bool remove_name);
|
||||
std::unique_ptr<EQApplicationPacket> CreateMemberListStatusPacket(const std::string& name, DynamicZoneMemberStatus status);
|
||||
|
||||
protected:
|
||||
uint16_t GetCurrentInstanceID() override;
|
||||
uint16_t GetCurrentZoneID() override;
|
||||
Database& GetDatabase() override;
|
||||
void ProcessCompassChange(const DynamicZoneLocation& location) override;
|
||||
void SendInstanceAddRemoveCharacter(uint32_t character_id, bool remove) override;
|
||||
void SendInstanceRemoveAllCharacters() override;
|
||||
void SendGlobalLocationChange(uint16_t server_opcode, const DynamicZoneLocation& location) override;
|
||||
void ProcessMemberAddRemove(const DynamicZoneMember& member, bool removed) override;
|
||||
bool ProcessMemberStatusChange(uint32_t member_id, DynamicZoneMemberStatus status) override;
|
||||
void ProcessRemoveAllMembers(bool silent = false) override;
|
||||
bool SendServerPacket(ServerPacket* packet) override;
|
||||
|
||||
private:
|
||||
static void StartAllClientRemovalTimers();
|
||||
void ProcessLeaderChanged(uint32_t new_leader_id);
|
||||
void SendCompassUpdateToZoneMembers();
|
||||
void SendMembersExpireWarning(uint32_t minutes);
|
||||
void SendUpdatesToZoneMembers(bool removing_all = false, bool silent = true);
|
||||
void SetUpdatedDuration(uint32_t seconds);
|
||||
|
||||
std::function<void(Client*, bool, bool)> m_on_client_addremove;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -22,7 +22,6 @@
|
||||
#define EXPEDITION_H
|
||||
|
||||
#include "dynamic_zone.h"
|
||||
#include "../common/expedition_base.h"
|
||||
#include "../common/expedition_lockout_timer.h"
|
||||
#include "../common/repositories/expeditions_repository.h"
|
||||
#include <cstdint>
|
||||
@ -47,14 +46,14 @@ enum class ExpeditionLockMessage : uint8_t
|
||||
Begin
|
||||
};
|
||||
|
||||
class Expedition : public ExpeditionBase
|
||||
class Expedition
|
||||
{
|
||||
public:
|
||||
Expedition() = default;
|
||||
Expedition(uint32_t id, const std::string& uuid, DynamicZone&& dz, const std::string& expedition_name,
|
||||
const DynamicZoneMember& leader);
|
||||
Expedition() = delete;
|
||||
Expedition(DynamicZone* dz) : m_dynamic_zone(dz) { assert(m_dynamic_zone != nullptr); }
|
||||
Expedition(DynamicZone* dz, uint32_t id, uint32_t dz_id);
|
||||
|
||||
static Expedition* TryCreate(Client* requester, DynamicZone& dynamiczone, ExpeditionRequest& request);
|
||||
static Expedition* TryCreate(Client* requester, DynamicZone& dynamiczone, bool disable_messages);
|
||||
|
||||
static void CacheFromDatabase(uint32_t expedition_id);
|
||||
static bool CacheAllFromDatabase();
|
||||
@ -79,14 +78,15 @@ public:
|
||||
const std::string& expedition_name = {}, const std::string& event_name = {});
|
||||
static void AddLockoutClients(const ExpeditionLockoutTimer& lockout, uint32_t exclude_id = 0);
|
||||
|
||||
DynamicZone& GetDynamicZone() { return m_dynamiczone; }
|
||||
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; }
|
||||
|
||||
bool AddMember(const std::string& add_char_name, uint32_t add_char_id);
|
||||
void RemoveAllMembers(bool enable_removal_timers = true);
|
||||
bool RemoveMember(const std::string& remove_char_name);
|
||||
void SetMemberStatus(Client* client, DynamicZoneMemberStatus status);
|
||||
void SwapMember(Client* add_client, const std::string& remove_char_name);
|
||||
const std::string& GetName() { return GetDynamicZone()->GetName(); }
|
||||
void RegisterDynamicZoneCallbacks();
|
||||
|
||||
bool IsLocked() const { return m_is_locked; }
|
||||
void SetLocked(bool lock_expedition, ExpeditionLockMessage lock_msg,
|
||||
@ -109,7 +109,6 @@ public:
|
||||
void SetLootEventByNPCTypeID(uint32_t npc_type_id, const std::string& event_name);
|
||||
void SetLootEventBySpawnID(uint32_t spawn_id, const std::string& event_name);
|
||||
|
||||
void SendClientExpeditionInfo(Client* client);
|
||||
void SendWorldMakeLeaderRequest(uint32_t requester_id, const std::string& new_leader_name);
|
||||
void SendWorldPendingInvite(const ExpeditionInvite& invite, const std::string& add_name);
|
||||
|
||||
@ -127,29 +126,22 @@ public:
|
||||
static const int32_t EVENT_TIMER_ID;
|
||||
|
||||
private:
|
||||
static void CacheExpeditions(std::vector<ExpeditionsRepository::ExpeditionWithLeader>&& expeditions);
|
||||
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 ProcessLeaderChanged(uint32_t new_leader_id);
|
||||
void ProcessLockoutDuration(const ExpeditionLockoutTimer& lockout, int seconds, bool members_only = false);
|
||||
void ProcessLockoutUpdate(const ExpeditionLockoutTimer& lockout, bool remove, bool members_only = false);
|
||||
void ProcessMakeLeader(Client* old_leader, Client* new_leader,
|
||||
const std::string& new_leader_name, bool is_success, bool is_online);
|
||||
void ProcessMemberAdded(const std::string& added_char_name, uint32_t added_char_id);
|
||||
void ProcessMemberRemoved(const std::string& removed_char_name, uint32_t removed_char_id);
|
||||
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 SendMemberListToZoneMembers();
|
||||
void SendMemberStatusToZoneMembers(uint32_t update_character_id, DynamicZoneMemberStatus status);
|
||||
void SendMembersExpireWarning(uint32_t minutes);
|
||||
void SendUpdatesToZoneMembers(bool clear = false, bool message_on_clear = true);
|
||||
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);
|
||||
@ -157,24 +149,18 @@ private:
|
||||
const ExpeditionLockoutTimer& lockout, int seconds, bool members_only = false);
|
||||
void SendWorldLockoutUpdate(
|
||||
const ExpeditionLockoutTimer& lockout, bool remove, bool members_only = false);
|
||||
void SendWorldMemberChanged(const std::string& char_name, uint32_t char_id, bool remove);
|
||||
void SendWorldMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status);
|
||||
void SendWorldMemberSwapped(const std::string& remove_char_name, uint32_t remove_char_id,
|
||||
const std::string& add_char_name, uint32_t add_char_id);
|
||||
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> CreateExpireWarningPacket(uint32_t minutes_remaining);
|
||||
std::unique_ptr<EQApplicationPacket> CreateInfoPacket(bool clear = false);
|
||||
std::unique_ptr<EQApplicationPacket> CreateInvitePacket(const std::string& inviter_name, const std::string& swap_remove_name);
|
||||
std::unique_ptr<EQApplicationPacket> CreateMemberListPacket(bool clear = false);
|
||||
std::unique_ptr<EQApplicationPacket> CreateMemberListNamePacket(const std::string& name, bool remove_name);
|
||||
std::unique_ptr<EQApplicationPacket> CreateMemberListStatusPacket(const std::string& name, DynamicZoneMemberStatus status);
|
||||
std::unique_ptr<EQApplicationPacket> CreateLeaderNamePacket();
|
||||
|
||||
DynamicZone m_dynamiczone { DynamicZoneType::Expedition };
|
||||
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
|
||||
|
||||
@ -26,25 +26,21 @@
|
||||
#include "../common/string_util.h"
|
||||
#include <fmt/core.h>
|
||||
|
||||
uint32_t ExpeditionDatabase::InsertExpedition(
|
||||
const std::string& uuid, uint32_t dz_id, const std::string& expedition_name,
|
||||
uint32_t leader_id, uint32_t min_players, uint32_t max_players)
|
||||
uint32_t ExpeditionDatabase::InsertExpedition(uint32_t dz_id)
|
||||
{
|
||||
LogExpeditionsDetail(
|
||||
"Inserting new expedition [{}] leader [{}] uuid [{}]", expedition_name, leader_id, uuid
|
||||
);
|
||||
LogExpeditionsDetail("Inserting new expedition dz [{}]", dz_id);
|
||||
|
||||
std::string query = fmt::format(SQL(
|
||||
INSERT INTO expeditions
|
||||
(uuid, dynamic_zone_id, expedition_name, leader_id, min_players, max_players)
|
||||
(dynamic_zone_id)
|
||||
VALUES
|
||||
('{}', {}, '{}', {}, {}, {});
|
||||
), uuid, dz_id, EscapeString(expedition_name), leader_id, min_players, max_players);
|
||||
({});
|
||||
), dz_id);
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
{
|
||||
LogExpeditions("Failed to obtain an expedition id for [{}]", expedition_name);
|
||||
LogExpeditions("Failed to obtain an expedition id for dz [{}]", dz_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -35,9 +35,7 @@ class MySQLRequestResult;
|
||||
|
||||
namespace ExpeditionDatabase
|
||||
{
|
||||
uint32_t InsertExpedition(
|
||||
const std::string& uuid, uint32_t instance_id, const std::string& expedition_name,
|
||||
uint32_t leader_id, uint32_t min_players, uint32_t max_players);
|
||||
uint32_t InsertExpedition(uint32_t dz_id);
|
||||
std::vector<ExpeditionLockoutTimer> LoadCharacterLockouts(uint32_t character_id);
|
||||
std::vector<ExpeditionLockoutTimer> LoadCharacterLockouts(uint32_t character_id,
|
||||
const std::string& expedition_name);
|
||||
|
||||
@ -30,12 +30,10 @@
|
||||
|
||||
constexpr char SystemName[] = "expedition";
|
||||
|
||||
ExpeditionRequest::ExpeditionRequest(std::string expedition_name,
|
||||
uint32_t min_players, uint32_t max_players, bool disable_messages
|
||||
) :
|
||||
m_expedition_name(std::move(expedition_name)),
|
||||
m_min_players(min_players),
|
||||
m_max_players(max_players),
|
||||
ExpeditionRequest::ExpeditionRequest(const DynamicZone& dz, bool disable_messages) :
|
||||
m_expedition_name(dz.GetName()),
|
||||
m_min_players(dz.GetMinPlayers()),
|
||||
m_max_players(dz.GetMaxPlayers()),
|
||||
m_disable_messages(disable_messages)
|
||||
{
|
||||
}
|
||||
|
||||
@ -35,8 +35,7 @@ class Raid;
|
||||
class ExpeditionRequest
|
||||
{
|
||||
public:
|
||||
ExpeditionRequest(std::string expedition_name, uint32_t min_players,
|
||||
uint32_t max_players, bool disable_messages = false);
|
||||
ExpeditionRequest(const DynamicZone& dz, bool disable_messages = false);
|
||||
|
||||
bool Validate(Client* requester);
|
||||
|
||||
|
||||
@ -367,7 +367,7 @@ void Client::GoFish()
|
||||
PushItemOnCursor(*inst);
|
||||
SendItemPacket(EQ::invslot::slotCursor, inst, ItemPacketLimbo);
|
||||
if (RuleB(TaskSystem, EnableTaskSystem))
|
||||
UpdateTasksForItem(ActivityFish, food_id);
|
||||
UpdateTasksForItem(TaskActivityType::Fish, food_id);
|
||||
|
||||
safe_delete(inst);
|
||||
inst = m_inv.GetItem(EQ::invslot::slotCursor);
|
||||
@ -487,7 +487,7 @@ void Client::ForageItem(bool guarantee) {
|
||||
PushItemOnCursor(*inst);
|
||||
SendItemPacket(EQ::invslot::slotCursor, inst, ItemPacketLimbo);
|
||||
if(RuleB(TaskSystem, EnableTaskSystem))
|
||||
UpdateTasksForItem(ActivityForage, foragedfood);
|
||||
UpdateTasksForItem(TaskActivityType::Forage, foragedfood);
|
||||
|
||||
safe_delete(inst);
|
||||
inst = m_inv.GetItem(EQ::invslot::slotCursor);
|
||||
|
||||
@ -1864,6 +1864,7 @@ Lua_Expedition Lua_Client::CreateExpedition(luabind::object expedition_table) {
|
||||
|
||||
// luabind will catch thrown cast_failed exceptions for invalid/missing args
|
||||
luabind::object instance_info = expedition_table["instance"];
|
||||
luabind::object expedition_info = expedition_table["expedition"];
|
||||
luabind::object zone = instance_info["zone"];
|
||||
|
||||
uint32_t zone_id = 0;
|
||||
@ -1880,6 +1881,9 @@ Lua_Expedition Lua_Client::CreateExpedition(luabind::object expedition_table) {
|
||||
uint32_t zone_duration = luabind::object_cast<uint32_t>(instance_info["duration"]);
|
||||
|
||||
DynamicZone dz{ zone_id, zone_version, zone_duration, DynamicZoneType::Expedition };
|
||||
dz.SetName(luabind::object_cast<std::string>(expedition_info["name"]));
|
||||
dz.SetMinPlayers(luabind::object_cast<uint32_t>(expedition_info["min_players"]));
|
||||
dz.SetMaxPlayers(luabind::object_cast<uint32_t>(expedition_info["max_players"]));
|
||||
|
||||
// the dz_info table supports optional hash entries for 'compass', 'safereturn', and 'zonein' data
|
||||
if (luabind::type(expedition_table["compass"]) == LUA_TTABLE)
|
||||
@ -1900,21 +1904,13 @@ Lua_Expedition Lua_Client::CreateExpedition(luabind::object expedition_table) {
|
||||
dz.SetZoneInLocation(zonein_loc);
|
||||
}
|
||||
|
||||
luabind::object expedition_info = expedition_table["expedition"];
|
||||
|
||||
std::string expedition_name = luabind::object_cast<std::string>(expedition_info["name"]);
|
||||
uint32_t min_players = luabind::object_cast<uint32_t>(expedition_info["min_players"]);
|
||||
uint32_t max_players = luabind::object_cast<uint32_t>(expedition_info["max_players"]);
|
||||
bool disable_messages = false;
|
||||
|
||||
bool disable_messages = false;
|
||||
if (luabind::type(expedition_info["disable_messages"]) == LUA_TBOOLEAN)
|
||||
{
|
||||
disable_messages = luabind::object_cast<bool>(expedition_info["disable_messages"]);
|
||||
}
|
||||
|
||||
ExpeditionRequest request{ expedition_name, min_players, max_players, disable_messages };
|
||||
|
||||
return self->CreateExpedition(dz, request);
|
||||
return self->CreateExpedition(dz, disable_messages);
|
||||
}
|
||||
|
||||
Lua_Expedition Lua_Client::CreateExpedition(std::string zone_name, uint32 version, uint32 duration, std::string expedition_name, uint32 min_players, uint32 max_players) {
|
||||
@ -2053,6 +2049,55 @@ void Lua_Client::MovePCDynamicZone(std::string zone_name, int zone_version, bool
|
||||
return self->MovePCDynamicZone(zone_name, zone_version, msg_if_invalid);
|
||||
}
|
||||
|
||||
void Lua_Client::CreateTaskDynamicZone(int task_id, luabind::object dz_table) {
|
||||
Lua_Safe_Call_Void();
|
||||
|
||||
if (luabind::type(dz_table) != LUA_TTABLE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// luabind will catch thrown cast_failed exceptions for invalid/missing args
|
||||
luabind::object instance_info = dz_table["instance"];
|
||||
luabind::object zone = instance_info["zone"];
|
||||
|
||||
uint32_t zone_id = 0;
|
||||
if (luabind::type(zone) == LUA_TSTRING)
|
||||
{
|
||||
zone_id = ZoneID(luabind::object_cast<std::string>(zone));
|
||||
}
|
||||
else if (luabind::type(zone) == LUA_TNUMBER)
|
||||
{
|
||||
zone_id = luabind::object_cast<uint32_t>(zone);
|
||||
}
|
||||
|
||||
uint32_t zone_version = luabind::object_cast<uint32_t>(instance_info["version"]);
|
||||
|
||||
// tasks override dz duration so duration is ignored here
|
||||
DynamicZone dz{ zone_id, zone_version, 0, DynamicZoneType::None };
|
||||
|
||||
// the dz_info table supports optional hash entries for 'compass', 'safereturn', and 'zonein' data
|
||||
if (luabind::type(dz_table["compass"]) == LUA_TTABLE)
|
||||
{
|
||||
auto compass_loc = GetDynamicZoneLocationFromTable(dz_table["compass"]);
|
||||
dz.SetCompass(compass_loc);
|
||||
}
|
||||
|
||||
if (luabind::type(dz_table["safereturn"]) == LUA_TTABLE)
|
||||
{
|
||||
auto safereturn_loc = GetDynamicZoneLocationFromTable(dz_table["safereturn"]);
|
||||
dz.SetSafeReturn(safereturn_loc);
|
||||
}
|
||||
|
||||
if (luabind::type(dz_table["zonein"]) == LUA_TTABLE)
|
||||
{
|
||||
auto zonein_loc = GetDynamicZoneLocationFromTable(dz_table["zonein"]);
|
||||
dz.SetZoneInLocation(zonein_loc);
|
||||
}
|
||||
|
||||
self->CreateTaskDynamicZone(task_id, dz);
|
||||
}
|
||||
|
||||
void Lua_Client::Fling(float value, float target_x, float target_y, float target_z) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->Fling(value, target_x, target_y, target_z);
|
||||
@ -2515,6 +2560,7 @@ luabind::scope lua_register_client() {
|
||||
.def("MovePCDynamicZone", (void(Lua_Client::*)(std::string))&Lua_Client::MovePCDynamicZone)
|
||||
.def("MovePCDynamicZone", (void(Lua_Client::*)(std::string, int))&Lua_Client::MovePCDynamicZone)
|
||||
.def("MovePCDynamicZone", (void(Lua_Client::*)(std::string, int, bool))&Lua_Client::MovePCDynamicZone)
|
||||
.def("CreateTaskDynamicZone", &Lua_Client::CreateTaskDynamicZone)
|
||||
.def("Fling", (void(Lua_Client::*)(float,float,float,float))&Lua_Client::Fling)
|
||||
.def("Fling", (void(Lua_Client::*)(float,float,float,float,bool))&Lua_Client::Fling)
|
||||
.def("Fling", (void(Lua_Client::*)(float,float,float,float,bool,bool))&Lua_Client::Fling)
|
||||
|
||||
@ -400,6 +400,7 @@ public:
|
||||
void MovePCDynamicZone(std::string zone_name);
|
||||
void MovePCDynamicZone(std::string zone_name, int zone_version);
|
||||
void MovePCDynamicZone(std::string zone_name, int zone_version, bool msg_if_invalid);
|
||||
void CreateTaskDynamicZone(int task_id, luabind::object dz_table);
|
||||
void Fling(float value, float target_x, float target_y, float target_z);
|
||||
void Fling(float value, float target_x, float target_y, float target_z, bool ignore_los);
|
||||
void Fling(float value, float target_x, float target_y, float target_z, bool ignore_los, bool clipping);
|
||||
|
||||
@ -59,7 +59,7 @@ void Lua_Expedition::AddReplayLockoutDuration(int seconds, bool members_only) {
|
||||
|
||||
uint32_t Lua_Expedition::GetDynamicZoneID() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetDynamicZone().GetID();
|
||||
return self->GetDynamicZoneID();
|
||||
}
|
||||
|
||||
uint32_t Lua_Expedition::GetID() {
|
||||
@ -69,7 +69,7 @@ uint32_t Lua_Expedition::GetID() {
|
||||
|
||||
int Lua_Expedition::GetInstanceID() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetDynamicZone().GetInstanceID();
|
||||
return self->GetDynamicZone()->GetInstanceID();
|
||||
}
|
||||
|
||||
std::string Lua_Expedition::GetLeaderName() {
|
||||
@ -104,7 +104,7 @@ std::string Lua_Expedition::GetLootEventBySpawnID(uint32_t spawn_id) {
|
||||
|
||||
uint32_t Lua_Expedition::GetMemberCount() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetDynamicZone().GetMemberCount();
|
||||
return self->GetDynamicZone()->GetMemberCount();
|
||||
}
|
||||
|
||||
luabind::object Lua_Expedition::GetMembers(lua_State* L) {
|
||||
@ -113,7 +113,7 @@ luabind::object Lua_Expedition::GetMembers(lua_State* L) {
|
||||
if (d_)
|
||||
{
|
||||
auto self = reinterpret_cast<NativeType*>(d_);
|
||||
for (const auto& member : self->GetDynamicZone().GetMembers())
|
||||
for (const auto& member : self->GetDynamicZone()->GetMembers())
|
||||
{
|
||||
lua_table[member.name] = member.id;
|
||||
}
|
||||
@ -128,27 +128,27 @@ std::string Lua_Expedition::GetName() {
|
||||
|
||||
int Lua_Expedition::GetSecondsRemaining() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetDynamicZone().GetSecondsRemaining();
|
||||
return self->GetDynamicZone()->GetSecondsRemaining();
|
||||
}
|
||||
|
||||
std::string Lua_Expedition::GetUUID() {
|
||||
Lua_Safe_Call_String();
|
||||
return self->GetUUID();
|
||||
return self->GetDynamicZone()->GetUUID();
|
||||
}
|
||||
|
||||
int Lua_Expedition::GetZoneID() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetDynamicZone().GetZoneID();
|
||||
return self->GetDynamicZone()->GetZoneID();
|
||||
}
|
||||
|
||||
std::string Lua_Expedition::GetZoneName() {
|
||||
Lua_Safe_Call_String();
|
||||
return ZoneName(self->GetDynamicZone().GetZoneID());
|
||||
return ZoneName(self->GetDynamicZone()->GetZoneID());
|
||||
}
|
||||
|
||||
int Lua_Expedition::GetZoneVersion() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetDynamicZone().GetZoneVersion();
|
||||
return self->GetDynamicZone()->GetZoneVersion();
|
||||
}
|
||||
|
||||
bool Lua_Expedition::HasLockout(std::string event_name) {
|
||||
@ -168,7 +168,7 @@ bool Lua_Expedition::IsLocked() {
|
||||
|
||||
void Lua_Expedition::RemoveCompass() {
|
||||
Lua_Safe_Call_Void();
|
||||
self->GetDynamicZone().SetCompass(0, 0, 0, 0, true);
|
||||
self->GetDynamicZone()->SetCompass(0, 0, 0, 0, true);
|
||||
}
|
||||
|
||||
void Lua_Expedition::RemoveLockout(std::string event_name) {
|
||||
@ -178,12 +178,12 @@ void Lua_Expedition::RemoveLockout(std::string event_name) {
|
||||
|
||||
void Lua_Expedition::SetCompass(uint32_t zone_id, float x, float y, float z) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->GetDynamicZone().SetCompass(zone_id, x, y, z, true);
|
||||
self->GetDynamicZone()->SetCompass(zone_id, x, y, z, true);
|
||||
}
|
||||
|
||||
void Lua_Expedition::SetCompass(std::string zone_name, float x, float y, float z) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->GetDynamicZone().SetCompass(ZoneID(zone_name), x, y, z, true);
|
||||
self->GetDynamicZone()->SetCompass(ZoneID(zone_name), x, y, z, true);
|
||||
}
|
||||
|
||||
void Lua_Expedition::SetLocked(bool lock_expedition) {
|
||||
@ -218,23 +218,23 @@ void Lua_Expedition::SetReplayLockoutOnMemberJoin(bool enable) {
|
||||
|
||||
void Lua_Expedition::SetSafeReturn(uint32_t zone_id, float x, float y, float z, float heading) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->GetDynamicZone().SetSafeReturn(zone_id, x, y, z, heading, true);
|
||||
self->GetDynamicZone()->SetSafeReturn(zone_id, x, y, z, heading, true);
|
||||
}
|
||||
|
||||
void Lua_Expedition::SetSafeReturn(std::string zone_name, float x, float y, float z, float heading) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->GetDynamicZone().SetSafeReturn(ZoneID(zone_name), x, y, z, heading, true);
|
||||
self->GetDynamicZone()->SetSafeReturn(ZoneID(zone_name), x, y, z, heading, true);
|
||||
}
|
||||
|
||||
void Lua_Expedition::SetSecondsRemaining(uint32_t seconds_remaining)
|
||||
{
|
||||
Lua_Safe_Call_Void();
|
||||
self->GetDynamicZone().SetSecondsRemaining(seconds_remaining);
|
||||
self->GetDynamicZone()->SetSecondsRemaining(seconds_remaining);
|
||||
}
|
||||
|
||||
void Lua_Expedition::SetZoneInLocation(float x, float y, float z, float heading) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->GetDynamicZone().SetZoneInLocation(x, y, z, heading, true);
|
||||
self->GetDynamicZone()->SetZoneInLocation(x, y, z, heading, true);
|
||||
}
|
||||
|
||||
void Lua_Expedition::UpdateLockoutDuration(std::string event_name, uint32_t duration) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user