[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:
Chris Miles
2021-09-05 01:21:23 -05:00
committed by GitHub
parent 943c623be0
commit e7dd8d49a9
116 changed files with 12094 additions and 3131 deletions
@@ -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
+168 -70
View File
@@ -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 -13
View File
@@ -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