mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-01 19:56:38 +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:
+21
-2
@@ -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",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+216
-47
@@ -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);
|
||||
}
|
||||
|
||||
+72
-15
@@ -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
|
||||
|
||||
+15
-2
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
));
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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)
|
||||
|
||||
+65
-44
@@ -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
|
||||
|
||||
@@ -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 {};
|
||||
}
|
||||
@@ -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
@@ -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
|
||||
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user