mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-23 04:52:29 +00:00
Compare commits
249 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4a66c3918a | |||
| a2c6252c58 | |||
| be00aa1b60 | |||
| b2658a6cbc | |||
| 026133f32a | |||
| 6d4f22a1c0 | |||
| e75f87a535 | |||
| 83e066bffc | |||
| 4639405fdf | |||
| 8ef3e87370 | |||
| bec28769aa | |||
| 8586cdc47e | |||
| 63ba5dc3ab | |||
| fcc7725ca3 | |||
| 5df6a61c96 | |||
| fc5105eed7 | |||
| 243fb781e8 | |||
| ec4d228dd5 | |||
| 2910073373 | |||
| b4d5e807e3 | |||
| 8f729fe948 | |||
| 7160aa651e | |||
| 8414ce02e3 | |||
| 17034a6e47 | |||
| be1772d464 | |||
| a00f086bb8 | |||
| de830e5535 | |||
| d1404a2d95 | |||
| 38da37755d | |||
| 57ac46d090 | |||
| 59f32b8d34 | |||
| a45117cd04 | |||
| 291aaea581 | |||
| 162d34e1d9 | |||
| 86c9be410d | |||
| 30e34c67b4 | |||
| ce8b8da0d6 | |||
| 02e8b125a4 | |||
| 11369247b1 | |||
| d493a6627b | |||
| b07945f0be | |||
| 8f3ac74196 | |||
| bcf7ccefcd | |||
| 9e9ef6809b | |||
| c8f6dbb86d | |||
| 7de50d0e60 | |||
| aaaee6c6a4 | |||
| d7f38361f2 | |||
| 275995a374 | |||
| 7072b5721b | |||
| 123bc5f19a | |||
| e6db71e31e | |||
| 129a738072 | |||
| 0de90dc135 | |||
| 5bc4cff7a9 | |||
| f9191d4ef4 | |||
| 49d751b3d5 | |||
| 14f48fcc93 | |||
| 25addc3bd9 | |||
| 7f12ad325a | |||
| 6636c64c82 | |||
| e2708af6f2 | |||
| 1de0c27629 | |||
| 9ccdb9eb84 | |||
| e69f7a6cf1 | |||
| efd04f8324 | |||
| eeacc62a91 | |||
| a7a525ed0b | |||
| e43538cf73 | |||
| 5b90d26a33 | |||
| 992e4ac59e | |||
| 6b85c914a5 | |||
| 089246db53 | |||
| f3e5423677 | |||
| 0e96099b3d | |||
| 6398381c44 | |||
| 7c1a139991 | |||
| 8554aab2ff | |||
| 77e72ba666 | |||
| 8329760632 | |||
| d8aa8f7e7a | |||
| 29cdd91ca0 | |||
| df99d97431 | |||
| f314e05087 | |||
| d120cf8a40 | |||
| 209b0eb273 | |||
| 763fc82379 | |||
| 6e0d101457 | |||
| a1a4f91ea6 | |||
| 6cc845e05e | |||
| 597e324319 | |||
| f370a6048f | |||
| 9d784d0d9b | |||
| fd7b15abb1 | |||
| b27428a6d8 | |||
| f201d4c999 | |||
| d9c41526e8 | |||
| 07b46ed445 | |||
| 9f9eaed983 | |||
| 862e1e33bf | |||
| dca34cc2ff | |||
| ccb316b11b | |||
| 10ae4ea8f6 | |||
| 7df9b2974b | |||
| 0b3065d7a9 | |||
| 7549fbbeea | |||
| e26eba8e03 | |||
| 02828a73b8 | |||
| 0e710fe5e7 | |||
| 86568e9292 | |||
| bf1d05d639 | |||
| 4eaf44fc33 | |||
| e62a283a79 | |||
| a847e461c1 | |||
| 37fefad58e | |||
| 26b26af8d7 | |||
| ee86001132 | |||
| 7d89c05a48 | |||
| 6e15fae6a0 | |||
| 2f962c2c8a | |||
| 6bbd1e94c3 | |||
| 78d44440eb | |||
| 1e45ffa24d | |||
| 37d5d96871 | |||
| 90725f9fd9 | |||
| c1aa3e7056 | |||
| 1d59fff2bf | |||
| 6beb220e93 | |||
| 3091a84540 | |||
| 9fbab76d40 | |||
| b03d47b9cd | |||
| b583d95f09 | |||
| 6846deb9c8 | |||
| adfec15893 | |||
| 132c936c90 | |||
| a0ed0d57c5 | |||
| 128e8ce08d | |||
| 55629ce396 | |||
| bf7c1252f8 | |||
| e2bfa44df0 | |||
| e5acc7c322 | |||
| 5aaaaed6f1 | |||
| 6d31786456 | |||
| 0aeab11408 | |||
| fc484d0b1c | |||
| 8dcc810b43 | |||
| 04f3d6286c | |||
| 35044becc1 | |||
| e08afb1234 | |||
| b2b87ea4e0 | |||
| 837c0a4385 | |||
| 9b075c28b6 | |||
| c4f05c3864 | |||
| 0c12ca8370 | |||
| a450779c91 | |||
| dc004c2a9d | |||
| d59dcb68ca | |||
| c7dbdfae58 | |||
| 759f9bd007 | |||
| 8f0b80097e | |||
| 71ae03d5bc | |||
| 34dc081306 | |||
| 35b35f85cf | |||
| 90da136b7a | |||
| 5b4aeaa457 | |||
| b02008ec53 | |||
| c709a6aa8e | |||
| 9113508269 | |||
| 1b7c12297d | |||
| b1311780a7 | |||
| 0d734a0837 | |||
| ee54a7eb5f | |||
| a6814d46de | |||
| 9dba6a6680 | |||
| bc875ae554 | |||
| bb897b755f | |||
| a39a825045 | |||
| ccd0713b33 | |||
| 5d94c9844a | |||
| bbe2db7c0f | |||
| 5dc76e595b | |||
| b6b662f1c7 | |||
| 5275201713 | |||
| 1e86e0c02f | |||
| 25c0416f1e | |||
| 326dba6aeb | |||
| b75741ff4e | |||
| 8e62383997 | |||
| 4296e2e39e | |||
| e5f924d1d5 | |||
| fb2aee1827 | |||
| 791d8b329d | |||
| abcf8cbce1 | |||
| 3ed6663c4c | |||
| f22608a43a | |||
| 0e5d578d71 | |||
| 8107ed52e1 | |||
| d904db0e52 | |||
| e6c8a38ffa | |||
| dbe0591b09 | |||
| 5b6f1d38be | |||
| ce85c70a07 | |||
| f814b5bec5 | |||
| 4e40d7eacc | |||
| 31ad0da811 | |||
| 25a19a13dc | |||
| 2a5ddde78a | |||
| eca2ed0321 | |||
| afc32afb02 | |||
| 751db6fffb | |||
| c4eb1f8439 | |||
| d6c03b54a1 | |||
| 261a9e6938 | |||
| ac214f71d4 | |||
| fd878e7b16 | |||
| 58cde58b45 | |||
| cc2ef11158 | |||
| 2dfb7614cc | |||
| 6dffeacc6e | |||
| 2ec6dcbe24 | |||
| 39bc12b582 | |||
| 6d78f926c8 | |||
| 00af2903c3 | |||
| 58fafd0f9c | |||
| 9f0989ee2d | |||
| 14648b96c4 | |||
| bfd1cf9379 | |||
| 3c35e9bbc8 | |||
| d86544ff60 | |||
| 70eed67e08 | |||
| 1c0524681e | |||
| aa9320de3c | |||
| ad28f3c3f3 | |||
| 71dfa9acc0 | |||
| 56d0478ab1 | |||
| 0d02fadb60 | |||
| 4de5a7b86d | |||
| ba3c19ad0b | |||
| 8ec80644ee | |||
| ed7e2b2652 | |||
| a83ad7080a | |||
| 677d595c9d | |||
| 615f4a5304 | |||
| 5fd62d82db | |||
| b938e6223c | |||
| 51c8771bd2 | |||
| cc9196bd65 | |||
| 6303f129af | |||
| 3f0987ba55 |
+10
-1
@@ -7,10 +7,19 @@ name: EQEmulator Server Linux CI
|
||||
concurrency:
|
||||
limit: 1
|
||||
|
||||
volumes:
|
||||
- name: cache
|
||||
host:
|
||||
path: /var/lib/cache
|
||||
|
||||
steps:
|
||||
- name: server-build
|
||||
# Source build script https://github.com/Akkadius/akk-stack/blob/master/containers/eqemu-server/Dockerfile#L20
|
||||
image: akkadius/eqemu-server:latest
|
||||
commands:
|
||||
- sudo chown eqemu:eqemu /drone/src/ * -R
|
||||
- git submodule init && git submodule update && mkdir -p build && cd build && cmake -DEQEMU_BUILD_LOGIN=ON -DEQEMU_ENABLE_BOTS=ON -DEQEMU_BUILD_LUA=ON -G 'Unix Makefiles' .. && make -j$((`nproc`-4))
|
||||
- sudo chown eqemu:eqemu /home/eqemu/.ccache/ * -R
|
||||
- git submodule init && git submodule update && mkdir -p build && cd build && cmake -DEQEMU_BUILD_LOGIN=ON -DEQEMU_ENABLE_BOTS=ON -DEQEMU_BUILD_LUA=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="-O0 -g -DNDEBUG" -G 'Unix Makefiles' .. && make -j$((`nproc`-4))
|
||||
volumes:
|
||||
- name: cache
|
||||
path: /home/eqemu/.ccache/
|
||||
|
||||
+1
-1
@@ -373,7 +373,7 @@ ENDIF()
|
||||
IF(PERL_LIBRARY_ENABLED)
|
||||
OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
|
||||
IF(EQEMU_BUILD_PERL)
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} ${PERL_LIBRARY_LIBS})
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} ${PERL_LIBRARY_LIBS} perlbind)
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${PERL_LIBRARY_INCLUDE}")
|
||||
ADD_DEFINITIONS(-DEMBPERL)
|
||||
ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
|
||||
|
||||
@@ -7,6 +7,7 @@ SET(common_sources
|
||||
compression.cpp
|
||||
condition.cpp
|
||||
content/world_content_service.cpp
|
||||
discord/discord.cpp
|
||||
crash.cpp
|
||||
crc16.cpp
|
||||
crc32.cpp
|
||||
@@ -34,6 +35,7 @@ SET(common_sources
|
||||
event_sub.cpp
|
||||
expedition_lockout_timer.cpp
|
||||
extprofile.cpp
|
||||
discord_manager.cpp
|
||||
faction.cpp
|
||||
file_util.cpp
|
||||
guild_base.cpp
|
||||
@@ -491,6 +493,8 @@ SET(common_headers
|
||||
database_schema.h
|
||||
dbcore.h
|
||||
deity.h
|
||||
discord/discord.h
|
||||
discord_manager.h
|
||||
dynamic_zone_base.h
|
||||
emu_constants.h
|
||||
emu_limits.h
|
||||
|
||||
@@ -23,18 +23,18 @@
|
||||
|
||||
BasePacket::BasePacket(const unsigned char *buf, uint32 len)
|
||||
{
|
||||
this->pBuffer=nullptr;
|
||||
this->size=0;
|
||||
this->_wpos = 0;
|
||||
this->_rpos = 0;
|
||||
this->timestamp.tv_sec = 0;
|
||||
pBuffer=nullptr;
|
||||
size=0;
|
||||
_wpos = 0;
|
||||
_rpos = 0;
|
||||
timestamp.tv_sec = 0;
|
||||
if (len>0) {
|
||||
this->size=len;
|
||||
size=len;
|
||||
pBuffer= new unsigned char[len];
|
||||
if (buf) {
|
||||
memcpy(this->pBuffer,buf,len);
|
||||
memcpy(pBuffer,buf,len);
|
||||
} else {
|
||||
memset(this->pBuffer,0,len);
|
||||
memset(pBuffer,0,len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -380,12 +380,12 @@ const char *GetClassIDName(uint8 class_id, uint8 level)
|
||||
return "Merchant";
|
||||
case DISCORD_MERCHANT:
|
||||
return "Discord Merchant";
|
||||
case ADVENTURERECRUITER:
|
||||
case ADVENTURE_RECRUITER:
|
||||
return "Adventure Recruiter";
|
||||
case ADVENTUREMERCHANT:
|
||||
case ADVENTURE_MERCHANT:
|
||||
return "Adventure Merchant";
|
||||
case CORPSE_CLASS:
|
||||
return "Corpse Class";
|
||||
case LDON_TREASURE:
|
||||
return "LDoN Treasure";
|
||||
case TRIBUTE_MASTER:
|
||||
return "Tribute Master";
|
||||
case GUILD_TRIBUTE_MASTER:
|
||||
@@ -400,7 +400,7 @@ const char *GetClassIDName(uint8 class_id, uint8 level)
|
||||
return "Fellowship Master";
|
||||
case ALT_CURRENCY_MERCHANT:
|
||||
return "Alternate Currency Merchant";
|
||||
case MERCERNARY_MASTER:
|
||||
case MERCENARY_MASTER:
|
||||
return "Mercenary Liaison";
|
||||
default:
|
||||
return "Unknown";
|
||||
|
||||
+4
-5
@@ -55,10 +55,9 @@
|
||||
#define BANKER 40
|
||||
#define MERCHANT 41
|
||||
#define DISCORD_MERCHANT 59
|
||||
#define ADVENTURERECRUITER 60
|
||||
#define ADVENTUREMERCHANT 61
|
||||
#define LDON_TREASURE 62 // objects you can use /open on first seen in LDONs
|
||||
#define CORPSE_CLASS 62 // only seen on Danvi's Corpse in Akheva so far..
|
||||
#define ADVENTURE_RECRUITER 60
|
||||
#define ADVENTURE_MERCHANT 61
|
||||
#define LDON_TREASURE 62 // objects you can use /open on first seen in LDONs, seen on Danvi's Corpse in Akheva
|
||||
#define TRIBUTE_MASTER 63
|
||||
#define GUILD_TRIBUTE_MASTER 64 // not sure
|
||||
#define GUILD_BANKER 66
|
||||
@@ -66,7 +65,7 @@
|
||||
#define DARK_REIGN_MERCHANT 68
|
||||
#define FELLOWSHIP_MASTER 69
|
||||
#define ALT_CURRENCY_MERCHANT 70
|
||||
#define MERCERNARY_MASTER 71
|
||||
#define MERCENARY_MASTER 71
|
||||
|
||||
|
||||
// player class values
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "../database.h"
|
||||
#include "../rulesys.h"
|
||||
#include "../eqemu_logsys.h"
|
||||
#include "../loottable.h"
|
||||
#include "../repositories/content_flags_repository.h"
|
||||
|
||||
|
||||
@@ -139,6 +140,50 @@ bool WorldContentService::IsContentFlagEnabled(const std::string &content_flag)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param content_flag
|
||||
* @return
|
||||
*/
|
||||
bool WorldContentService::IsContentFlagDisabled(const std::string &content_flag)
|
||||
{
|
||||
for (auto &f: GetContentFlags()) {
|
||||
if (f.flag_name == content_flag && f.enabled == false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WorldContentService::DoesPassContentFiltering(const ContentFlags &f)
|
||||
{
|
||||
// if we're not set to (-1 All) then fail when we aren't within minimum expansion
|
||||
if (f.min_expansion > Expansion::EXPANSION_ALL && current_expansion < f.min_expansion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if we're not set to (-1 All) then fail when we aren't within max expansion
|
||||
if (f.max_expansion > Expansion::EXPANSION_ALL && current_expansion > f.max_expansion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if we don't have any enabled flag in enabled flags, we fail
|
||||
for (const auto& flag: SplitString(f.content_flags)) {
|
||||
if (!contains(GetContentFlagsEnabled(), flag)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// if we don't have any disabled flag in disabled flags, we fail
|
||||
for (const auto& flag: SplitString(f.content_flags_disabled)) {
|
||||
if (!contains(GetContentFlagsDisabled(), flag)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WorldContentService::ReloadContentFlags()
|
||||
{
|
||||
std::vector<ContentFlagsRepository::ContentFlags> set_content_flags;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../loottable.h"
|
||||
#include "../repositories/content_flags_repository.h"
|
||||
|
||||
class Database;
|
||||
@@ -53,7 +54,7 @@ namespace Expansion {
|
||||
VeilOfAlaris,
|
||||
RainOfFear,
|
||||
CallOfTheForsaken,
|
||||
TheDarkendSea,
|
||||
TheDarkenedSea,
|
||||
TheBrokenMirror,
|
||||
EmpiresOfKunark,
|
||||
RingOfScale,
|
||||
@@ -126,7 +127,7 @@ public:
|
||||
bool IsVeilOfAlarisEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::VeilOfAlaris || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||
bool IsRainOfFearEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::RainOfFear || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||
bool IsCallOfTheForsakenEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::CallOfTheForsaken || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||
bool IsTheDarkendSeaEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheDarkendSea || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||
bool IsTheDarkenedSeaEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheDarkenedSea || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||
bool IsTheBrokenMirrorEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheBrokenMirror || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||
bool IsEmpiresOfKunarkEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::EmpiresOfKunark || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||
bool IsRingOfScaleEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::RingOfScale || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||
@@ -154,7 +155,7 @@ public:
|
||||
bool IsCurrentExpansionVeilOfAlaris() { return current_expansion == Expansion::ExpansionNumber::VeilOfAlaris; }
|
||||
bool IsCurrentExpansionRainOfFear() { return current_expansion == Expansion::ExpansionNumber::RainOfFear; }
|
||||
bool IsCurrentExpansionCallOfTheForsaken() { return current_expansion == Expansion::ExpansionNumber::CallOfTheForsaken; }
|
||||
bool IsCurrentExpansionTheDarkendSea() { return current_expansion == Expansion::ExpansionNumber::TheDarkendSea; }
|
||||
bool IsCurrentExpansionTheDarkenedSea() { return current_expansion == Expansion::ExpansionNumber::TheDarkenedSea; }
|
||||
bool IsCurrentExpansionTheBrokenMirror() { return current_expansion == Expansion::ExpansionNumber::TheBrokenMirror; }
|
||||
bool IsCurrentExpansionEmpiresOfKunark() { return current_expansion == Expansion::ExpansionNumber::EmpiresOfKunark; }
|
||||
bool IsCurrentExpansionRingOfScale() { return current_expansion == Expansion::ExpansionNumber::RingOfScale; }
|
||||
@@ -165,10 +166,13 @@ public:
|
||||
std::vector<std::string> GetContentFlagsEnabled();
|
||||
std::vector<std::string> GetContentFlagsDisabled();
|
||||
bool IsContentFlagEnabled(const std::string& content_flag);
|
||||
bool IsContentFlagDisabled(const std::string& content_flag);
|
||||
void SetContentFlags(std::vector<ContentFlagsRepository::ContentFlags> content_flags);
|
||||
void ReloadContentFlags();
|
||||
WorldContentService * SetExpansionContext();
|
||||
|
||||
bool DoesPassContentFiltering(const ContentFlags& f);
|
||||
|
||||
WorldContentService * SetDatabase(Database *database);
|
||||
Database *GetDatabase() const;
|
||||
|
||||
|
||||
+200
-209
@@ -50,6 +50,8 @@
|
||||
#include "http/httplib.h"
|
||||
#include "http/uri.h"
|
||||
|
||||
#include "repositories/zone_repository.h"
|
||||
|
||||
extern Client client;
|
||||
|
||||
Database::Database () {
|
||||
@@ -92,112 +94,123 @@ Database::~Database()
|
||||
*/
|
||||
uint32 Database::CheckLogin(const char* name, const char* password, const char *loginserver, int16* oStatus) {
|
||||
|
||||
if(strlen(name) >= 50 || strlen(password) >= 50)
|
||||
if (strlen(name) >= 50 || strlen(password) >= 50)
|
||||
return(0);
|
||||
|
||||
char tmpUN[100];
|
||||
char tmpPW[100];
|
||||
char temporary_username[100];
|
||||
char temporary_password[100];
|
||||
|
||||
DoEscapeString(tmpUN, name, strlen(name));
|
||||
DoEscapeString(tmpPW, password, strlen(password));
|
||||
DoEscapeString(temporary_username, name, strlen(name));
|
||||
DoEscapeString(temporary_password, password, strlen(password));
|
||||
|
||||
std::string query = StringFormat("SELECT id, status FROM account WHERE `name`='%s' AND ls_id='%s' AND password is not null "
|
||||
"and length(password) > 0 and (password='%s' or password=MD5('%s'))",
|
||||
tmpUN, EscapeString(loginserver).c_str(), tmpPW, tmpPW);
|
||||
std::string query = fmt::format(
|
||||
"SELECT id, status FROM account WHERE `name` = '{}' AND ls_id = '{}' AND password is NOT NULL "
|
||||
"AND length(password) > 0 AND (password = '{}' OR password = MD5('{}'))",
|
||||
temporary_username,
|
||||
EscapeString(loginserver),
|
||||
temporary_password,
|
||||
temporary_password
|
||||
);
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
if (!results.Success() || !results.RowCount()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(results.RowCount() == 0)
|
||||
return 0;
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
uint32 id = atoi(row[0]);
|
||||
auto id = std::stoul(row[0]);
|
||||
|
||||
if (oStatus)
|
||||
*oStatus = atoi(row[1]);
|
||||
if (oStatus) {
|
||||
*oStatus = std::stoi(row[1]);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
//Get Banned IP Address List - Only return false if the incoming connection's IP address is not present in the banned_ips table.
|
||||
bool Database::CheckBannedIPs(const char* loginIP)
|
||||
bool Database::CheckBannedIPs(std::string login_ip)
|
||||
{
|
||||
std::string query = StringFormat("SELECT ip_address FROM banned_ips WHERE ip_address='%s'", loginIP);
|
||||
|
||||
auto query = fmt::format(
|
||||
"SELECT ip_address FROM banned_ips WHERE ip_address = '{}'",
|
||||
login_ip
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
if (!results.Success() || results.RowCount() != 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (results.RowCount() != 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Database::AddBannedIP(char* bannedIP, const char* notes) {
|
||||
std::string query = StringFormat("INSERT into banned_ips SET ip_address='%s', notes='%s'", bannedIP, notes);
|
||||
bool Database::AddBannedIP(std::string banned_ip, std::string notes) {
|
||||
auto query = fmt::format(
|
||||
"INSERT into banned_ips SET ip_address = '{}', notes = '{}'",
|
||||
EscapeString(banned_ip),
|
||||
EscapeString(notes)
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Database::CheckGMIPs(const char* ip_address, uint32 account_id) {
|
||||
std::string query = StringFormat("SELECT * FROM `gm_ips` WHERE `ip_address` = '%s' AND `account_id` = %i", ip_address, account_id);
|
||||
bool Database::CheckGMIPs(std::string login_ip, uint32 account_id) {
|
||||
auto query = fmt::format(
|
||||
"SELECT * FROM `gm_ips` WHERE `ip_address` = '{}' AND `account_id` = {}",
|
||||
login_ip,
|
||||
account_id
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 1)
|
||||
if (results.RowCount() == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Database::AddGMIP(char* ip_address, char* name) {
|
||||
std::string query = StringFormat("INSERT into `gm_ips` SET `ip_address` = '%s', `name` = '%s'", ip_address, name);
|
||||
auto results = QueryDatabase(query);
|
||||
return results.Success();
|
||||
}
|
||||
|
||||
void Database::LoginIP(uint32 AccountID, const char* LoginIP) {
|
||||
std::string query = StringFormat("INSERT INTO account_ip SET accid=%i, ip='%s' ON DUPLICATE KEY UPDATE count=count+1, lastused=now()", AccountID, LoginIP);
|
||||
void Database::LoginIP(uint32 account_id, std::string login_ip) {
|
||||
auto query = fmt::format(
|
||||
"INSERT INTO account_ip SET accid = {}, ip = '{}' ON DUPLICATE KEY UPDATE count=count+1, lastused=now()",
|
||||
account_id,
|
||||
login_ip
|
||||
);
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
int16 Database::CheckStatus(uint32 account_id)
|
||||
{
|
||||
std::string query = StringFormat(
|
||||
"SELECT `status`, TIMESTAMPDIFF(SECOND, NOW(), `suspendeduntil`) FROM `account` WHERE `id` = %i",
|
||||
account_id);
|
||||
|
||||
auto query = fmt::format(
|
||||
"SELECT `status`, TIMESTAMPDIFF(SECOND, NOW(), `suspendeduntil`) FROM `account` WHERE `id` = {}",
|
||||
account_id
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
return 0;
|
||||
|
||||
if (results.RowCount() != 1)
|
||||
if (!results.Success() || results.RowCount() != 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
int16 status = atoi(row[0]);
|
||||
int16 status = std::stoi(row[0]);
|
||||
int32 date_diff = 0;
|
||||
|
||||
if (row[1] != nullptr)
|
||||
date_diff = atoi(row[1]);
|
||||
if (row[1]) {
|
||||
date_diff = std::stoi(row[1]);
|
||||
}
|
||||
|
||||
if (date_diff > 0)
|
||||
if (date_diff > 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -307,9 +320,7 @@ bool Database::SetAccountStatus(const std::string& account_name, int16 status)
|
||||
LogInfo("Account [{}] is attempting to be set to status [{}]", account_name, status);
|
||||
|
||||
std::string query = fmt::format(
|
||||
SQL(
|
||||
UPDATE account SET status = {} WHERE name = '{}'
|
||||
),
|
||||
"UPDATE account SET status = {} WHERE name = '{}'",
|
||||
status,
|
||||
account_name
|
||||
);
|
||||
@@ -807,36 +818,34 @@ uint32 Database::GetAccountIDByChar(uint32 char_id) {
|
||||
return atoi(row[0]);
|
||||
}
|
||||
|
||||
uint32 Database::GetAccountIDByName(const char* accname, const char *loginserver, int16* status, uint32* lsid) {
|
||||
if (!isAlphaNumeric(accname))
|
||||
uint32 Database::GetAccountIDByName(std::string account_name, std::string loginserver, int16* status, uint32* lsid) {
|
||||
if (!isAlphaNumeric(account_name.c_str())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string query = StringFormat("SELECT `id`, `status`, `lsaccount_id` FROM `account` WHERE `name` = '%s' AND `ls_id`='%s' LIMIT 1",
|
||||
EscapeString(accname).c_str(), EscapeString(loginserver).c_str());
|
||||
auto query = fmt::format(
|
||||
"SELECT `id`, `status`, `lsaccount_id` FROM `account` WHERE `name` = '{}' AND `ls_id` = '{}' LIMIT 1",
|
||||
EscapeString(account_name),
|
||||
EscapeString(loginserver)
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
if (!results.Success() || !results.RowCount()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (results.RowCount() != 1)
|
||||
return 0;
|
||||
|
||||
auto row = results.begin();
|
||||
auto account_id = std::stoul(row[0]);
|
||||
|
||||
uint32 id = atoi(row[0]);
|
||||
|
||||
if (status)
|
||||
*status = atoi(row[1]);
|
||||
|
||||
if (lsid) {
|
||||
if (row[2])
|
||||
*lsid = atoi(row[2]);
|
||||
else
|
||||
*lsid = 0;
|
||||
if (status) {
|
||||
*status = static_cast<int16>(std::stoi(row[1]));
|
||||
}
|
||||
|
||||
return id;
|
||||
if (lsid) {
|
||||
*lsid = row[2] ? std::stoul(row[2]) : 0;
|
||||
}
|
||||
|
||||
return account_id;
|
||||
}
|
||||
|
||||
void Database::GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID) {
|
||||
@@ -997,6 +1006,18 @@ bool Database::SetVariable(const std::string varname, const std::string &varvalu
|
||||
return true;
|
||||
}
|
||||
|
||||
void Database::SetAccountCRCField(uint32 account_id, std::string field_name, uint64 checksum)
|
||||
{
|
||||
QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE `account` SET `{}` = '{}' WHERE `id` = {}",
|
||||
field_name,
|
||||
checksum,
|
||||
account_id
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Get zone starting points from DB
|
||||
bool Database::GetSafePoints(const char* zone_short_name, uint32 instance_version, float* safe_x, float* safe_y, float* safe_z, float* safe_heading, int16* min_status, uint8* min_level, char *flag_needed) {
|
||||
|
||||
@@ -1088,21 +1109,6 @@ bool Database::GetZoneLongName(const char* short_name, char** long_name, char* f
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 Database::GetZoneGraveyardID(uint32 zone_id, uint32 version) {
|
||||
|
||||
std::string query = StringFormat("SELECT graveyard_id FROM zone WHERE zoneidnumber='%u' AND (version=%i OR version=0) ORDER BY version DESC", zone_id, version);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
return 0;
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return 0;
|
||||
|
||||
auto row = results.begin();
|
||||
return atoi(row[0]);
|
||||
}
|
||||
|
||||
bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zoneid, float* graveyard_x, float* graveyard_y, float* graveyard_z, float* graveyard_heading) {
|
||||
|
||||
std::string query = StringFormat("SELECT zone_id, x, y, z, heading FROM graveyard WHERE id=%i", graveyard_id);
|
||||
@@ -1131,108 +1137,84 @@ bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zon
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){
|
||||
|
||||
std::string query = StringFormat("SELECT peqzone from zone where zoneidnumber='%i' AND (version=%i OR version=0) ORDER BY version DESC", zoneID, version);
|
||||
uint8 Database::GetPEQZone(uint32 zone_id, uint32 version){
|
||||
std::string query = fmt::format(
|
||||
"SELECT peqzone FROM zone WHERE zoneidnumber = {} AND (version = {} OR version = 0) ORDER BY version DESC LIMIT 1",
|
||||
zone_id,
|
||||
version
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
if (!results.Success() || !results.RowCount()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return 0;
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
return atoi(row[0]);
|
||||
return static_cast<uint8>(std::stoi(row[0]));
|
||||
}
|
||||
|
||||
bool Database::CheckNameFilter(const char* name, bool surname)
|
||||
bool Database::CheckNameFilter(std::string name, bool surname)
|
||||
{
|
||||
std::string str_name = name;
|
||||
name = str_tolower(name);
|
||||
|
||||
// the minimum 4 is enforced by the client too
|
||||
if (!name || strlen(name) < 4)
|
||||
{
|
||||
if (name.empty() || name.size() < 4) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Given name length is enforced by the client too
|
||||
if (!surname && strlen(name) > 15)
|
||||
{
|
||||
if (!surname && name.size() > 15) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < str_name.size(); i++)
|
||||
{
|
||||
if(!isalpha(str_name[i]))
|
||||
{
|
||||
for (size_t i = 0; i < name.size(); i++) {
|
||||
if (!isalpha(name[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for(size_t x = 0; x < str_name.size(); ++x)
|
||||
{
|
||||
str_name[x] = tolower(str_name[x]);
|
||||
}
|
||||
|
||||
char c = '\0';
|
||||
uint8 num_c = 0;
|
||||
for(size_t x = 0; x < str_name.size(); ++x)
|
||||
{
|
||||
if(str_name[x] == c)
|
||||
{
|
||||
for (size_t x = 0; x < name.size(); ++x) {
|
||||
if (name[x] == c) {
|
||||
num_c++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
num_c = 1;
|
||||
c = str_name[x];
|
||||
c = name[x];
|
||||
}
|
||||
if(num_c > 2)
|
||||
{
|
||||
|
||||
if (num_c > 2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string query("SELECT name FROM name_filter");
|
||||
std::string query = "SELECT name FROM name_filter";
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
// false through to true? shouldn't it be falls through to false?
|
||||
if (!results.Success()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (auto row = results.begin();row != results.end();++row)
|
||||
{
|
||||
std::string current_row = row[0];
|
||||
|
||||
for(size_t x = 0; x < current_row.size(); ++x)
|
||||
current_row[x] = tolower(current_row[x]);
|
||||
|
||||
if(str_name.find(current_row) != std::string::npos)
|
||||
for (auto row : results) {
|
||||
std::string current_row = str_tolower(row[0]);
|
||||
if (name.find(current_row) != std::string::npos) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Database::AddToNameFilter(const char* name) {
|
||||
|
||||
std::string query = StringFormat("INSERT INTO name_filter (name) values ('%s')", name);
|
||||
bool Database::AddToNameFilter(std::string name) {
|
||||
auto query = fmt::format(
|
||||
"INSERT INTO name_filter (name) values ('{}')",
|
||||
name
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
if (!results.Success() || !results.RowsAffected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (results.RowsAffected() == 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1320,16 +1302,16 @@ bool Database::UpdateName(const char* oldname, const char* newname) {
|
||||
}
|
||||
|
||||
// If the name is used or an error occurs, it returns false, otherwise it returns true
|
||||
bool Database::CheckUsedName(const char* name) {
|
||||
std::string query = StringFormat("SELECT `id` FROM `character_data` WHERE `name` = '%s'", name);
|
||||
bool Database::CheckUsedName(std::string name) {
|
||||
auto query = fmt::format(
|
||||
"SELECT `id` FROM `character_data` WHERE `name` = '{}'",
|
||||
name
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
if (!results.Success() || results.RowCount()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (results.RowCount() > 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1487,41 +1469,25 @@ uint8 Database::GetSkillCap(uint8 skillid, uint8 in_race, uint8 in_class, uint16
|
||||
return base_cap;
|
||||
}
|
||||
|
||||
uint32 Database::GetCharacterInfo(
|
||||
const char *iName,
|
||||
uint32 *oAccID,
|
||||
uint32 *oZoneID,
|
||||
uint32 *oInstanceID,
|
||||
float *oX,
|
||||
float *oY,
|
||||
float *oZ
|
||||
)
|
||||
uint32 Database::GetCharacterInfo(std::string character_name, uint32 *account_id, uint32 *zone_id, uint32 *instance_id)
|
||||
{
|
||||
std::string query = StringFormat(
|
||||
"SELECT `id`, `account_id`, `zone_id`, `zone_instance`, `x`, `y`, `z` FROM `character_data` WHERE `name` = '%s'",
|
||||
EscapeString(iName).c_str()
|
||||
auto query = fmt::format(
|
||||
"SELECT `id`, `account_id`, `zone_id`, `zone_instance` FROM `character_data` WHERE `name` = '{}'",
|
||||
EscapeString(character_name)
|
||||
);
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
if (!results.Success() || !results.RowCount()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (results.RowCount() != 1) {
|
||||
return 0;
|
||||
}
|
||||
auto row = results.begin();
|
||||
auto character_id = std::stoul(row[0]);
|
||||
*account_id = std::stoul(row[1]);
|
||||
*zone_id = std::stoul(row[2]);
|
||||
*instance_id = std::stoul(row[3]);
|
||||
|
||||
auto row = results.begin();
|
||||
uint32 charid = atoi(row[0]);
|
||||
if (oAccID) { *oAccID = atoi(row[1]); }
|
||||
if (oZoneID) { *oZoneID = atoi(row[2]); }
|
||||
if (oInstanceID) { *oInstanceID = atoi(row[3]); }
|
||||
if (oX) { *oX = atof(row[4]); }
|
||||
if (oY) { *oY = atof(row[5]); }
|
||||
if (oZ) { *oZ = atof(row[6]); }
|
||||
|
||||
return charid;
|
||||
return character_id;
|
||||
}
|
||||
|
||||
bool Database::UpdateLiveChar(char* charname, uint32 account_id) {
|
||||
@@ -1645,29 +1611,36 @@ uint32 Database::GetGroupID(const char* name){
|
||||
return atoi(row[0]);
|
||||
}
|
||||
|
||||
/* Is this really getting used properly... A half implementation ? Akkadius */
|
||||
char* Database::GetGroupLeaderForLogin(const char* name, char* leaderbuf) {
|
||||
strcpy(leaderbuf, "");
|
||||
std::string Database::GetGroupLeaderForLogin(std::string character_name) {
|
||||
uint32 group_id = 0;
|
||||
|
||||
std::string query = StringFormat("SELECT `groupid` FROM `group_id` WHERE `name` = '%s'", name);
|
||||
auto query = fmt::format(
|
||||
"SELECT `groupid` FROM `group_id` WHERE `name` = '{}'",
|
||||
character_name
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row)
|
||||
if (row[0])
|
||||
group_id = atoi(row[0]);
|
||||
if (results.Success() && results.RowCount()) {
|
||||
auto row = results.begin();
|
||||
group_id = std::stoul(row[0]);
|
||||
}
|
||||
|
||||
if (group_id == 0)
|
||||
return leaderbuf;
|
||||
if (!group_id) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
query = StringFormat("SELECT `leadername` FROM `group_leaders` WHERE `gid` = '%u' LIMIT 1", group_id);
|
||||
query = fmt::format(
|
||||
"SELECT `leadername` FROM `group_leaders` WHERE `gid` = {} LIMIT 1",
|
||||
group_id
|
||||
);
|
||||
results = QueryDatabase(query);
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row)
|
||||
if (row[0])
|
||||
strcpy(leaderbuf, row[0]);
|
||||
if (results.Success() && results.RowCount()) {
|
||||
auto row = results.begin();
|
||||
return row[0];
|
||||
}
|
||||
|
||||
return leaderbuf;
|
||||
return std::string();
|
||||
}
|
||||
|
||||
void Database::SetGroupLeaderName(uint32 gid, const char* name) {
|
||||
@@ -2262,43 +2235,48 @@ bool Database::SaveTime(int8 minute, int8 hour, int8 day, int8 month, int16 year
|
||||
}
|
||||
|
||||
int Database::GetIPExemption(std::string account_ip) {
|
||||
std::string query = StringFormat("SELECT `exemption_amount` FROM `ip_exemptions` WHERE `exemption_ip` = '%s'", account_ip.c_str());
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (results.Success() && results.RowCount() > 0) {
|
||||
auto row = results.begin();
|
||||
return atoi(row[0]);
|
||||
}
|
||||
|
||||
return RuleI(World, MaxClientsPerIP);
|
||||
}
|
||||
|
||||
void Database::SetIPExemption(std::string account_ip, int exemption_amount) {
|
||||
std::string query = fmt::format(
|
||||
"SELECT `exemption_id` FROM `ip_exemptions` WHERE `exemption_ip` = '{}'",
|
||||
auto query = fmt::format(
|
||||
"SELECT `exemption_amount` FROM `ip_exemptions` WHERE `exemption_ip` = '{}'",
|
||||
account_ip
|
||||
);
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
uint32 exemption_id = 0;
|
||||
if (results.Success() && results.RowCount() > 0) {
|
||||
auto row = results.begin();
|
||||
exemption_id = atoi(row[0]);
|
||||
if (!results.Success() || !results.RowCount()) {
|
||||
return RuleI(World, MaxClientsPerIP);
|
||||
}
|
||||
|
||||
|
||||
auto row = results.begin();
|
||||
return std::stoi(row[0]);
|
||||
}
|
||||
|
||||
void Database::SetIPExemption(std::string account_ip, int exemption_amount) {
|
||||
auto query = fmt::format(
|
||||
"SELECT `exemption_id` FROM `ip_exemptions` WHERE `exemption_ip` = '{}'",
|
||||
account_ip
|
||||
);
|
||||
|
||||
uint32 exemption_id = 0;
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
if (results.Success() && results.RowCount()) {
|
||||
auto row = results.begin();
|
||||
exemption_id = std::stoul(row[0]);
|
||||
}
|
||||
|
||||
query = fmt::format(
|
||||
"INSERT INTO `ip_exemptions` (`exemption_ip`, `exemption_amount`) VALUES ('{}', {})",
|
||||
account_ip,
|
||||
exemption_amount
|
||||
);
|
||||
|
||||
if (exemption_id != 0) {
|
||||
if (exemption_id) {
|
||||
query = fmt::format(
|
||||
"UPDATE `ip_exemptions` SET `exemption_amount` = {} WHERE `exemption_ip` = '{}'",
|
||||
exemption_amount,
|
||||
account_ip
|
||||
);
|
||||
}
|
||||
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
@@ -2516,3 +2494,16 @@ void Database::SourceDatabaseTableFromUrl(std::string table_name, std::string ur
|
||||
}
|
||||
}
|
||||
|
||||
uint8 Database::GetMinStatus(uint32 zone_id, uint32 instance_version)
|
||||
{
|
||||
auto zones = ZoneRepository::GetWhere(
|
||||
*this,
|
||||
fmt::format(
|
||||
"zoneidnumber = {} AND (version = {} OR version = 0) ORDER BY version DESC LIMIT 1",
|
||||
zone_id,
|
||||
instance_version
|
||||
)
|
||||
);
|
||||
|
||||
return !zones.empty() ? zones[0].min_status : 0;
|
||||
}
|
||||
|
||||
+15
-15
@@ -88,7 +88,6 @@ public:
|
||||
|
||||
/* Character Creation */
|
||||
|
||||
bool AddToNameFilter(const char *name);
|
||||
bool CreateCharacter(
|
||||
uint32 account_id,
|
||||
char *name,
|
||||
@@ -121,18 +120,18 @@ public:
|
||||
|
||||
/* General Information Queries */
|
||||
|
||||
bool AddBannedIP(char* bannedIP, const char* notes); //Add IP address to the banned_ips table.
|
||||
bool AddGMIP(char* ip_address, char* name);
|
||||
bool CheckBannedIPs(const char* loginIP); //Check incoming connection against banned IP table.
|
||||
bool CheckGMIPs(const char* loginIP, uint32 account_id);
|
||||
bool CheckNameFilter(const char* name, bool surname = false);
|
||||
bool CheckUsedName(const char* name);
|
||||
bool AddBannedIP(std::string banned_ip, std::string notes); //Add IP address to the banned_ips table.
|
||||
bool AddToNameFilter(std::string name);
|
||||
bool CheckBannedIPs(std::string login_ip); //Check incoming connection against banned IP table.
|
||||
bool CheckGMIPs(std::string login_ip, uint32 account_id);
|
||||
bool CheckNameFilter(std::string name, bool surname = false);
|
||||
bool CheckUsedName(std::string name);
|
||||
|
||||
uint32 GetAccountIDByChar(const char* charname, uint32* oCharID = 0);
|
||||
uint32 GetAccountIDByChar(uint32 char_id);
|
||||
uint32 GetAccountIDByName(const char* accname, const char *loginserver, int16* status = 0, uint32* lsid = 0);
|
||||
uint32 GetAccountIDByName(std::string account_name, std::string loginserver, int16* status = 0, uint32* lsid = 0);
|
||||
uint32 GetCharacterID(const char *name);
|
||||
uint32 GetCharacterInfo(const char* iName, uint32* oAccID = 0, uint32* oZoneID = 0, uint32* oInstanceID = 0, float* oX = 0, float* oY = 0, float* oZ = 0);
|
||||
uint32 GetCharacterInfo(std::string character_name, uint32 *account_id, uint32 *zone_id, uint32 *instance_id);
|
||||
uint32 GetGuildIDByCharID(uint32 char_id);
|
||||
uint32 GetGroupIDByCharID(uint32 char_id);
|
||||
uint32 GetRaidIDByCharID(uint32 char_id);
|
||||
@@ -142,7 +141,7 @@ public:
|
||||
std::string GetCharNameByID(uint32 char_id);
|
||||
std::string GetNPCNameByID(uint32 npc_id);
|
||||
std::string GetCleanNPCNameByID(uint32 npc_id);
|
||||
void LoginIP(uint32 AccountID, const char* LoginIP);
|
||||
void LoginIP(uint32 account_id, std::string login_ip);
|
||||
|
||||
/* Instancing */
|
||||
|
||||
@@ -190,6 +189,8 @@ public:
|
||||
|
||||
int16 CheckStatus(uint32 account_id);
|
||||
|
||||
void SetAccountCRCField(uint32 account_id, std::string field_name, uint64 checksum);
|
||||
|
||||
uint32 CheckLogin(const char* name, const char* password, const char *loginserver, int16* oStatus = 0);
|
||||
uint32 CreateAccount(const char* name, const char* password, int16 status, const char* loginserver, uint32 lsaccount_id);
|
||||
uint32 GetAccountIDFromLSID(const std::string& in_loginserver_id, uint32 in_loginserver_account_id, char* in_account_name = 0, int16* in_status = 0);
|
||||
@@ -206,8 +207,8 @@ public:
|
||||
|
||||
/* Groups */
|
||||
|
||||
char* GetGroupLeaderForLogin(const char* name,char* leaderbuf);
|
||||
char* GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* maintank = nullptr, char* assist = nullptr, char* puller = nullptr, char *marknpc = nullptr, char *mentoree = nullptr, int *mentor_percent = nullptr, GroupLeadershipAA_Struct* GLAA = nullptr);
|
||||
std::string GetGroupLeaderForLogin(std::string character_name);
|
||||
char* GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* maintank = nullptr, char* assist = nullptr, char* puller = nullptr, char *marknpc = nullptr, char *mentoree = nullptr, int *mentor_percent = nullptr, GroupLeadershipAA_Struct* GLAA = nullptr);
|
||||
|
||||
uint32 GetGroupID(const char* name);
|
||||
|
||||
@@ -250,9 +251,8 @@ public:
|
||||
bool GetZoneLongName(const char* short_name, char** long_name, char* file_name = 0, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, uint32* graveyard_id = 0, uint32* maxclients = 0);
|
||||
bool LoadPTimers(uint32 charid, PTimerList &into);
|
||||
|
||||
uint32 GetZoneGraveyardID(uint32 zone_id, uint32 version);
|
||||
|
||||
uint8 GetPEQZone(uint32 zoneID, uint32 version);
|
||||
uint8 GetPEQZone(uint32 zone_id, uint32 version);
|
||||
uint8 GetMinStatus(uint32 zone_id, uint32 instance_version);
|
||||
uint8 GetRaceSkill(uint8 skillid, uint8 in_race);
|
||||
uint8 GetServerType();
|
||||
uint8 GetSkillCap(uint8 skillid, uint8 in_race, uint8 in_class, uint16 in_level);
|
||||
|
||||
@@ -163,6 +163,20 @@ std::string DatabaseDumpService::GetPlayerTablesList()
|
||||
return trim(tables_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
std::string DatabaseDumpService::GetBotTablesList()
|
||||
{
|
||||
std::string tables_list;
|
||||
std::vector<std::string> tables = DatabaseSchema::GetBotTables();
|
||||
for (const auto &table : tables) {
|
||||
tables_list += table + " ";
|
||||
}
|
||||
|
||||
return trim(tables_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@@ -317,6 +331,11 @@ void DatabaseDumpService::Dump()
|
||||
tables_to_dump += GetPlayerTablesList() + " ";
|
||||
dump_descriptor += "-player";
|
||||
}
|
||||
|
||||
if (IsDumpBotTables()) {
|
||||
tables_to_dump += GetBotTablesList() + " ";
|
||||
dump_descriptor += "-bots";
|
||||
}
|
||||
|
||||
if (IsDumpSystemTables()) {
|
||||
tables_to_dump += GetSystemTablesList() + " ";
|
||||
@@ -436,6 +455,7 @@ void DatabaseDumpService::Dump()
|
||||
// LogDebug("[{}] login", (IsDumpLoginServerTables() ? "true" : "false"));
|
||||
// LogDebug("[{}] player", (IsDumpPlayerTables() ? "true" : "false"));
|
||||
// LogDebug("[{}] system", (IsDumpSystemTables() ? "true" : "false"));
|
||||
// LogDebug("[{}] bot", (IsDumpBotTables() ? "true" : "false"));
|
||||
}
|
||||
|
||||
bool DatabaseDumpService::IsDumpSystemTables() const
|
||||
@@ -577,3 +597,13 @@ void DatabaseDumpService::SetDumpStateTables(bool dump_state_tables)
|
||||
{
|
||||
DatabaseDumpService::dump_state_tables = dump_state_tables;
|
||||
}
|
||||
|
||||
bool DatabaseDumpService::IsDumpBotTables() const
|
||||
{
|
||||
return dump_bot_tables;
|
||||
}
|
||||
|
||||
void DatabaseDumpService::SetDumpBotTables(bool dump_bot_tables)
|
||||
{
|
||||
DatabaseDumpService::dump_bot_tables = dump_bot_tables;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ public:
|
||||
void SetDumpDropTableSyntaxOnly(bool dump_drop_table_syntax_only);
|
||||
bool IsDumpStateTables() const;
|
||||
void SetDumpStateTables(bool dump_state_tables);
|
||||
bool IsDumpBotTables() const;
|
||||
void SetDumpBotTables(bool dump_bot_tables);
|
||||
|
||||
private:
|
||||
bool dump_all_tables = false;
|
||||
@@ -67,6 +69,7 @@ private:
|
||||
bool dump_with_compression = false;
|
||||
bool dump_output_to_console = false;
|
||||
bool dump_drop_table_syntax_only = false;
|
||||
bool dump_bot_tables = false;
|
||||
std::string dump_path;
|
||||
std::string dump_file_name;
|
||||
|
||||
@@ -75,6 +78,7 @@ private:
|
||||
std::string GetMySQLVersion();
|
||||
std::string GetBaseMySQLDumpCommand();
|
||||
std::string GetPlayerTablesList();
|
||||
std::string GetBotTablesList();
|
||||
std::string GetSystemTablesList();
|
||||
std::string GetStateTablesList();
|
||||
std::string GetContentTablesList();
|
||||
|
||||
@@ -62,6 +62,7 @@ namespace DatabaseSchema {
|
||||
{"character_pet_buffs", "char_id"},
|
||||
{"character_pet_info", "char_id"},
|
||||
{"character_pet_inventory", "char_id"},
|
||||
{"character_peqzone_flags", "id"},
|
||||
{"character_potionbelt", "id"},
|
||||
{"character_skills", "id"},
|
||||
{"character_spells", "id"},
|
||||
@@ -129,6 +130,7 @@ namespace DatabaseSchema {
|
||||
"character_pet_buffs",
|
||||
"character_pet_info",
|
||||
"character_pet_inventory",
|
||||
"character_peqzone_flags",
|
||||
"character_potionbelt",
|
||||
"character_skills",
|
||||
"character_spells",
|
||||
@@ -373,6 +375,40 @@ namespace DatabaseSchema {
|
||||
"inventory_versions",
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Gets all player bot tables
|
||||
* @note These tables have no content in the PEQ daily dump
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
static std::vector<std::string> GetBotTables()
|
||||
{
|
||||
return {
|
||||
"bot_buffs",
|
||||
"bot_command_settings",
|
||||
"bot_create_combinations",
|
||||
"bot_data",
|
||||
"bot_group_members",
|
||||
"bot_groups",
|
||||
"bot_guild_members",
|
||||
"bot_heal_rotation_members",
|
||||
"bot_heal_rotation_targets",
|
||||
"bot_heal_rotations",
|
||||
"bot_inspect_messages",
|
||||
"bot_inventories",
|
||||
"bot_owner_options",
|
||||
"bot_pet_buffs",
|
||||
"bot_pet_inventories",
|
||||
"bot_pets",
|
||||
"bot_spell_casting_chances",
|
||||
"bot_spells_entries",
|
||||
"bot_stances",
|
||||
"bot_timers",
|
||||
"vw_bot_character_mobs",
|
||||
"vw_bot_groups"
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -167,7 +167,7 @@ MySQLRequestResult DBcore::QueryDatabase(const char *query, uint32 querylen, boo
|
||||
if (LogSys.log_settings[Logs::MySQLQuery].is_category_enabled == 1) {
|
||||
if ((strncasecmp(query, "select", 6) == 0)) {
|
||||
LogMySQLQuery(
|
||||
"{0} ({1} row{2} returned) ({3}s)",
|
||||
"{0}; -- ({1} row{2} returned) ({3}s)",
|
||||
query,
|
||||
requestResult.RowCount(),
|
||||
requestResult.RowCount() == 1 ? "" : "s",
|
||||
@@ -176,7 +176,7 @@ MySQLRequestResult DBcore::QueryDatabase(const char *query, uint32 querylen, boo
|
||||
}
|
||||
else {
|
||||
LogMySQLQuery(
|
||||
"{0} ({1} row{2} affected) ({3}s)",
|
||||
"{0}; -- ({1} row{2} affected) ({3}s)",
|
||||
query,
|
||||
requestResult.RowsAffected(),
|
||||
requestResult.RowsAffected() == 1 ? "" : "s",
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
#include "discord.h"
|
||||
#include "../http/httplib.h"
|
||||
#include "../json/json.h"
|
||||
#include "../string_util.h"
|
||||
#include "../eqemu_logsys.h"
|
||||
|
||||
constexpr int MAX_RETRIES = 10;
|
||||
|
||||
void Discord::SendWebhookMessage(const std::string &message, const std::string &webhook_url)
|
||||
{
|
||||
// validate
|
||||
if (webhook_url.empty()) {
|
||||
LogDiscord("[webhook_url] is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
// validate
|
||||
if (webhook_url.find("http://") == std::string::npos && webhook_url.find("https://") == std::string::npos) {
|
||||
LogDiscord("[webhook_url] [{}] does not contain a valid http/s prefix.", webhook_url);
|
||||
return;
|
||||
}
|
||||
|
||||
// split
|
||||
auto s = SplitString(webhook_url, '/');
|
||||
|
||||
// url
|
||||
std::string base_url = fmt::format("{}//{}", s[0], s[2]);
|
||||
std::string endpoint = replace_string(webhook_url, base_url, "");
|
||||
|
||||
// client
|
||||
httplib::Client cli(base_url.c_str());
|
||||
cli.set_connection_timeout(0, 15000000); // 15 sec
|
||||
cli.set_read_timeout(15, 0); // 15 seconds
|
||||
cli.set_write_timeout(15, 0); // 15 seconds
|
||||
httplib::Headers headers = {
|
||||
{"Content-Type", "application/json"}
|
||||
};
|
||||
|
||||
// payload
|
||||
Json::Value p;
|
||||
p["content"] = message;
|
||||
std::stringstream payload;
|
||||
payload << p;
|
||||
|
||||
bool retry = true;
|
||||
int retries = 0;
|
||||
int retry_timer = 1000;
|
||||
while (retry) {
|
||||
if (auto res = cli.Post(endpoint.c_str(), payload.str(), "application/json")) {
|
||||
if (res->status != 200 && res->status != 204) {
|
||||
LogError("[Discord Client] Code [{}] Error [{}]", res->status, res->body);
|
||||
}
|
||||
if (res->status == 429) {
|
||||
if (!res->body.empty()) {
|
||||
std::stringstream ss(res->body);
|
||||
Json::Value response;
|
||||
|
||||
try {
|
||||
ss >> response;
|
||||
}
|
||||
catch (std::exception const &ex) {
|
||||
LogDiscord("JSON serialization failure [{}] via [{}]", ex.what(), res->body);
|
||||
}
|
||||
|
||||
retry_timer = std::stoi(response["retry_after"].asString()) + 500;
|
||||
}
|
||||
|
||||
LogDiscord("Rate limited... retrying message in [{}ms]", retry_timer);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(retry_timer + 500));
|
||||
}
|
||||
if (res->status == 204) {
|
||||
retry = false;
|
||||
}
|
||||
if (retries > MAX_RETRIES) {
|
||||
LogDiscord("Retries exceeded for message [{}]", message);
|
||||
retry = false;
|
||||
}
|
||||
|
||||
retries++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string Discord::FormatDiscordMessage(uint16 category_id, const std::string &message)
|
||||
{
|
||||
if (category_id == Logs::LogCategory::MySQLQuery) {
|
||||
return fmt::format("```sql\n{}\n```", message);
|
||||
}
|
||||
|
||||
return message + "\n";
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef EQEMU_DISCORD_H
|
||||
#define EQEMU_DISCORD_H
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "../types.h"
|
||||
|
||||
class Discord {
|
||||
public:
|
||||
static void SendWebhookMessage(const std::string& message, const std::string& webhook_url);
|
||||
static std::string FormatDiscordMessage(uint16 category_id, const std::string& message);
|
||||
};
|
||||
|
||||
|
||||
#endif //EQEMU_DISCORD_H
|
||||
@@ -0,0 +1,65 @@
|
||||
#include "discord_manager.h"
|
||||
#include "../common/discord/discord.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/string_util.h"
|
||||
|
||||
void DiscordManager::QueueWebhookMessage(uint32 webhook_id, const std::string &message)
|
||||
{
|
||||
webhook_queue_lock.lock();
|
||||
webhook_message_queue[webhook_id].emplace_back(message);
|
||||
webhook_queue_lock.unlock();
|
||||
}
|
||||
|
||||
constexpr int MAX_MESSAGE_LENGTH = 1900;
|
||||
|
||||
void DiscordManager::ProcessMessageQueue()
|
||||
{
|
||||
if (webhook_message_queue.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
webhook_queue_lock.lock();
|
||||
for (auto &q: webhook_message_queue) {
|
||||
LogDiscord("Processing [{}] messages in queue for webhook ID [{}]...", q.second.size(), q.first);
|
||||
|
||||
auto webhook = LogSys.discord_webhooks[q.first];
|
||||
std::string message;
|
||||
|
||||
for (auto &m: q.second) {
|
||||
// next message would become too large
|
||||
bool next_message_too_large = ((int) m.length() + (int) message.length()) > MAX_MESSAGE_LENGTH;
|
||||
if (next_message_too_large) {
|
||||
Discord::SendWebhookMessage(
|
||||
message,
|
||||
webhook.webhook_url
|
||||
);
|
||||
message = "";
|
||||
}
|
||||
|
||||
message += m;
|
||||
|
||||
// one single message was too large
|
||||
// this should rarely happen but the message will need to be split
|
||||
if ((int) message.length() > MAX_MESSAGE_LENGTH) {
|
||||
for (unsigned mi = 0; mi < message.length(); mi += MAX_MESSAGE_LENGTH) {
|
||||
Discord::SendWebhookMessage(
|
||||
message.substr(mi, MAX_MESSAGE_LENGTH),
|
||||
webhook.webhook_url
|
||||
);
|
||||
}
|
||||
message = "";
|
||||
}
|
||||
}
|
||||
|
||||
// final flush
|
||||
if (!message.empty()) {
|
||||
Discord::SendWebhookMessage(
|
||||
message,
|
||||
webhook.webhook_url
|
||||
);
|
||||
}
|
||||
|
||||
webhook_message_queue.erase(q.first);
|
||||
}
|
||||
webhook_queue_lock.unlock();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef EQEMU_DISCORD_MANAGER_H
|
||||
#define EQEMU_DISCORD_MANAGER_H
|
||||
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "../common/types.h"
|
||||
|
||||
class DiscordManager {
|
||||
public:
|
||||
void QueueWebhookMessage(uint32 webhook_id, const std::string& message);
|
||||
void ProcessMessageQueue();
|
||||
private:
|
||||
std::mutex webhook_queue_lock{};
|
||||
std::map<uint32, std::vector<std::string>> webhook_message_queue{};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
+74
-24
@@ -22,7 +22,6 @@
|
||||
#include "data_verification.h"
|
||||
#include "bodytypes.h"
|
||||
|
||||
|
||||
int16 EQ::invtype::GetInvTypeSize(int16 inv_type) {
|
||||
static const int16 local_array[] = {
|
||||
POSSESSIONS_SIZE,
|
||||
@@ -189,15 +188,16 @@ const std::map<int, std::string>& EQ::constants::GetLanguageMap()
|
||||
{ LANG_HADAL, "Hadal" },
|
||||
{ LANG_UNKNOWN, "Unknown" }
|
||||
};
|
||||
|
||||
return language_map;
|
||||
}
|
||||
|
||||
std::string EQ::constants::GetLanguageName(int language_id)
|
||||
{
|
||||
if (EQ::ValueWithin(language_id, LANG_COMMON_TONGUE, LANG_UNKNOWN)) {
|
||||
auto languages = EQ::constants::GetLanguageMap();
|
||||
return languages[language_id];
|
||||
return EQ::constants::GetLanguageMap().find(language_id)->second;
|
||||
}
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
@@ -211,21 +211,22 @@ const std::map<uint32, std::string>& EQ::constants::GetLDoNThemeMap()
|
||||
{ LDoNThemes::RUJ, "Rujarkian Hills" },
|
||||
{ LDoNThemes::TAK, "Takish-Hiz" },
|
||||
};
|
||||
|
||||
return ldon_theme_map;
|
||||
}
|
||||
|
||||
std::string EQ::constants::GetLDoNThemeName(uint32 theme_id)
|
||||
{
|
||||
if (EQ::ValueWithin(theme_id, LDoNThemes::Unused, LDoNThemes::TAK)) {
|
||||
auto ldon_themes = EQ::constants::GetLDoNThemeMap();
|
||||
return ldon_themes[theme_id];
|
||||
return EQ::constants::GetLDoNThemeMap().find(theme_id)->second;
|
||||
}
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
const std::map<uint8, std::string>& EQ::constants::GetFlyModeMap()
|
||||
const std::map<int8, std::string>& EQ::constants::GetFlyModeMap()
|
||||
{
|
||||
static const std::map<uint8, std::string> flymode_map = {
|
||||
static const std::map<int8, std::string> flymode_map = {
|
||||
{ GravityBehavior::Ground, "Ground" },
|
||||
{ GravityBehavior::Flying, "Flying" },
|
||||
{ GravityBehavior::Levitating, "Levitating" },
|
||||
@@ -233,15 +234,16 @@ const std::map<uint8, std::string>& EQ::constants::GetFlyModeMap()
|
||||
{ GravityBehavior::Floating, "Floating" },
|
||||
{ GravityBehavior::LevitateWhileRunning, "Levitating While Running" },
|
||||
};
|
||||
|
||||
return flymode_map;
|
||||
}
|
||||
|
||||
std::string EQ::constants::GetFlyModeName(uint8 flymode_id)
|
||||
std::string EQ::constants::GetFlyModeName(int8 flymode_id)
|
||||
{
|
||||
if (EQ::ValueWithin(flymode_id, GravityBehavior::Ground, GravityBehavior::LevitateWhileRunning)) {
|
||||
auto flymodes = EQ::constants::GetFlyModeMap();
|
||||
return flymodes[flymode_id];
|
||||
return EQ::constants::GetFlyModeMap().find(flymode_id)->second;
|
||||
}
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
@@ -288,15 +290,16 @@ const std::map<bodyType, std::string>& EQ::constants::GetBodyTypeMap()
|
||||
{ BT_InvisMan, "Invisible Man" },
|
||||
{ BT_Special, "Special" },
|
||||
};
|
||||
|
||||
return bodytype_map;
|
||||
}
|
||||
|
||||
std::string EQ::constants::GetBodyTypeName(bodyType bodytype_id)
|
||||
{
|
||||
auto bodytypes = EQ::constants::GetBodyTypeMap();
|
||||
if (!bodytypes[bodytype_id].empty()) {
|
||||
return bodytypes[bodytype_id];
|
||||
if (EQ::constants::GetBodyTypeMap().find(bodytype_id) != EQ::constants::GetBodyTypeMap().end()) {
|
||||
return EQ::constants::GetBodyTypeMap().find(bodytype_id)->second;
|
||||
}
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
@@ -321,21 +324,23 @@ const std::map<uint8, std::string>& EQ::constants::GetAccountStatusMap()
|
||||
{ AccountStatus::GMImpossible, "GM Impossible" },
|
||||
{ AccountStatus::Max, "GM Max" }
|
||||
};
|
||||
|
||||
return account_status_map;
|
||||
}
|
||||
|
||||
std::string EQ::constants::GetAccountStatusName(uint8 account_status)
|
||||
{
|
||||
auto account_statuses = EQ::constants::GetAccountStatusMap();
|
||||
std::string status_name;
|
||||
for (auto status_level = account_statuses.rbegin(); status_level != account_statuses.rend(); ++status_level) {
|
||||
for (
|
||||
auto status_level = EQ::constants::GetAccountStatusMap().rbegin();
|
||||
status_level != EQ::constants::GetAccountStatusMap().rend();
|
||||
++status_level
|
||||
) {
|
||||
if (account_status >= status_level->first) {
|
||||
status_name = status_level->second;
|
||||
break;
|
||||
return status_level->second;
|
||||
}
|
||||
}
|
||||
|
||||
return status_name;
|
||||
return std::string();
|
||||
}
|
||||
|
||||
const std::map<uint8, std::string>& EQ::constants::GetConsiderLevelMap()
|
||||
@@ -351,15 +356,16 @@ const std::map<uint8, std::string>& EQ::constants::GetConsiderLevelMap()
|
||||
{ ConsiderLevel::Threateningly, "Threateningly" },
|
||||
{ ConsiderLevel::Scowls, "Scowls" }
|
||||
};
|
||||
|
||||
return consider_level_map;
|
||||
}
|
||||
|
||||
std::string EQ::constants::GetConsiderLevelName(uint8 faction_consider_level)
|
||||
{
|
||||
auto consider_levels = EQ::constants::GetConsiderLevelMap();
|
||||
if (!consider_levels[faction_consider_level].empty()) {
|
||||
return consider_levels[faction_consider_level];
|
||||
if (EQ::constants::GetConsiderLevelMap().find(faction_consider_level) != EQ::constants::GetConsiderLevelMap().end()) {
|
||||
return EQ::constants::GetConsiderLevelMap().find(faction_consider_level)->second;
|
||||
}
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
@@ -371,14 +377,58 @@ const std::map<uint8, std::string>& EQ::constants::GetEnvironmentalDamageMap()
|
||||
{ EnvironmentalDamage::Falling, "Falling" },
|
||||
{ EnvironmentalDamage::Trap, "Trap" }
|
||||
};
|
||||
|
||||
return damage_type_map;
|
||||
}
|
||||
|
||||
std::string EQ::constants::GetEnvironmentalDamageName(uint8 damage_type)
|
||||
{
|
||||
if (EQ::ValueWithin(damage_type, EnvironmentalDamage::Lava, EnvironmentalDamage::Trap)) {
|
||||
auto damage_types = EQ::constants::GetEnvironmentalDamageMap();
|
||||
return damage_types[damage_type];
|
||||
return EQ::constants::GetEnvironmentalDamageMap().find(damage_type)->second;
|
||||
}
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
const std::map<uint8, std::string>& EQ::constants::GetStuckBehaviorMap()
|
||||
{
|
||||
static const std::map<uint8, std::string> stuck_behavior_map = {
|
||||
{ StuckBehavior::RunToTarget, "Run To Target" },
|
||||
{ StuckBehavior::WarpToTarget, "Warp To Target" },
|
||||
{ StuckBehavior::TakeNoAction, "Take No Action" },
|
||||
{ StuckBehavior::EvadeCombat, "Evade Combat" }
|
||||
};
|
||||
|
||||
return stuck_behavior_map;
|
||||
}
|
||||
|
||||
std::string EQ::constants::GetStuckBehaviorName(uint8 behavior_id)
|
||||
{
|
||||
if (EQ::ValueWithin(behavior_id, StuckBehavior::RunToTarget, StuckBehavior::EvadeCombat)) {
|
||||
return EQ::constants::GetStuckBehaviorMap().find(behavior_id)->second;
|
||||
}
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
const std::map<uint8, std::string>& EQ::constants::GetSpawnAnimationMap()
|
||||
{
|
||||
static const std::map<uint8, std::string> spawn_animation_map = {
|
||||
{ SpawnAnimations::Standing, "Standing" },
|
||||
{ SpawnAnimations::Sitting, "Sitting" },
|
||||
{ SpawnAnimations::Crouching, "Crouching" },
|
||||
{ SpawnAnimations::Laying, "Laying" },
|
||||
{ SpawnAnimations::Looting, "Looting" }
|
||||
};
|
||||
|
||||
return spawn_animation_map;
|
||||
}
|
||||
|
||||
std::string EQ::constants::GetSpawnAnimationName(uint8 animation_id)
|
||||
{
|
||||
if (EQ::ValueWithin(animation_id, SpawnAnimations::Standing, SpawnAnimations::Looting)) {
|
||||
return EQ::constants::GetSpawnAnimationMap().find(animation_id)->second;
|
||||
}
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
+52
-3
@@ -221,7 +221,7 @@ namespace EQ
|
||||
stanceBurnAE
|
||||
};
|
||||
|
||||
enum GravityBehavior : uint8 {
|
||||
enum GravityBehavior : int8 {
|
||||
Ground,
|
||||
Flying,
|
||||
Levitating,
|
||||
@@ -237,6 +237,21 @@ namespace EQ
|
||||
Trap
|
||||
};
|
||||
|
||||
enum StuckBehavior : uint8 {
|
||||
RunToTarget,
|
||||
WarpToTarget,
|
||||
TakeNoAction,
|
||||
EvadeCombat
|
||||
};
|
||||
|
||||
enum SpawnAnimations : uint8 {
|
||||
Standing,
|
||||
Sitting,
|
||||
Crouching,
|
||||
Laying,
|
||||
Looting
|
||||
};
|
||||
|
||||
const char *GetStanceName(StanceType stance_type);
|
||||
int ConvertStanceTypeToIndex(StanceType stance_type);
|
||||
|
||||
@@ -246,8 +261,8 @@ namespace EQ
|
||||
extern const std::map<uint32, std::string>& GetLDoNThemeMap();
|
||||
std::string GetLDoNThemeName(uint32 theme_id);
|
||||
|
||||
extern const std::map<uint8, std::string>& GetFlyModeMap();
|
||||
std::string GetFlyModeName(uint8 flymode_id);
|
||||
extern const std::map<int8, std::string>& GetFlyModeMap();
|
||||
std::string GetFlyModeName(int8 flymode_id);
|
||||
|
||||
extern const std::map<bodyType, std::string>& GetBodyTypeMap();
|
||||
std::string GetBodyTypeName(bodyType bodytype_id);
|
||||
@@ -261,6 +276,12 @@ namespace EQ
|
||||
extern const std::map<uint8, std::string>& GetEnvironmentalDamageMap();
|
||||
std::string GetEnvironmentalDamageName(uint8 damage_type);
|
||||
|
||||
extern const std::map<uint8, std::string>& GetStuckBehaviorMap();
|
||||
std::string GetStuckBehaviorName(uint8 behavior_id);
|
||||
|
||||
extern const std::map<uint8, std::string>& GetSpawnAnimationMap();
|
||||
std::string GetSpawnAnimationName(uint8 animation_id);
|
||||
|
||||
const int STANCE_TYPE_FIRST = stancePassive;
|
||||
const int STANCE_TYPE_LAST = stanceBurnAE;
|
||||
const int STANCE_TYPE_COUNT = stanceBurnAE;
|
||||
@@ -416,4 +437,32 @@ enum ConsiderLevel : uint8 {
|
||||
Scowls
|
||||
};
|
||||
|
||||
enum TargetDescriptionType : uint8 {
|
||||
LCSelf,
|
||||
UCSelf,
|
||||
LCYou,
|
||||
UCYou,
|
||||
LCYour,
|
||||
UCYour
|
||||
};
|
||||
|
||||
enum ReloadWorld : uint8 {
|
||||
NoRepop = 0,
|
||||
Repop,
|
||||
ForceRepop
|
||||
};
|
||||
|
||||
enum MerchantBucketComparison : uint8 {
|
||||
BucketEqualTo = 0,
|
||||
BucketNotEqualTo,
|
||||
BucketGreaterThanOrEqualTo,
|
||||
BucketLesserThanOrEqualTo,
|
||||
BucketGreaterThan,
|
||||
BucketLesserThan,
|
||||
BucketIsAny,
|
||||
BucketIsNotAny,
|
||||
BucketIsBetween,
|
||||
BucketIsNotBetween
|
||||
};
|
||||
|
||||
#endif /*COMMON_EMU_CONSTANTS_H*/
|
||||
|
||||
@@ -455,6 +455,7 @@ N(OP_ServerListResponse),
|
||||
N(OP_SessionReady),
|
||||
N(OP_SetChatServer),
|
||||
N(OP_SetChatServer2),
|
||||
N(OP_SetFace),
|
||||
N(OP_SetGroupTarget),
|
||||
N(OP_SetGuildMOTD),
|
||||
N(OP_SetGuildRank),
|
||||
@@ -558,6 +559,7 @@ N(OP_WhoAllRequest),
|
||||
N(OP_WhoAllResponse),
|
||||
N(OP_World_Client_CRC1),
|
||||
N(OP_World_Client_CRC2),
|
||||
N(OP_World_Client_CRC3),
|
||||
N(OP_WorldClientReady),
|
||||
N(OP_WorldComplete),
|
||||
N(OP_WorldLogout),
|
||||
|
||||
+22
-11
@@ -2316,9 +2316,12 @@ struct FaceChange_Struct {
|
||||
/*004*/ uint8 hairstyle;
|
||||
/*005*/ uint8 beard;
|
||||
/*006*/ uint8 face;
|
||||
/*007*/ uint32 drakkin_heritage;
|
||||
/*011*/ uint32 drakkin_tattoo;
|
||||
/*015*/ uint32 drakkin_details;
|
||||
/*007*/ uint8 unused_padding;
|
||||
/*008*/ uint32 drakkin_heritage;
|
||||
/*012*/ uint32 drakkin_tattoo;
|
||||
/*016*/ uint32 drakkin_details;
|
||||
/*020*/ uint32 entity_id;
|
||||
/*024*/
|
||||
//there are only 10 faces for barbs changing woad just
|
||||
//increase the face value by ten so if there were 8 woad
|
||||
//designs then there would be 80 barb faces
|
||||
@@ -3621,14 +3624,17 @@ struct LevelAppearance_Struct { //Sends a little graphic on level up
|
||||
};
|
||||
|
||||
struct MerchantList {
|
||||
uint32 id;
|
||||
uint32 slot;
|
||||
uint32 item;
|
||||
int16 faction_required;
|
||||
int8 level_required;
|
||||
uint16 alt_currency_cost;
|
||||
uint32 classes_required;
|
||||
uint8 probability;
|
||||
uint32 id;
|
||||
uint32 slot;
|
||||
uint32 item;
|
||||
int16 faction_required;
|
||||
int8 level_required;
|
||||
uint16 alt_currency_cost;
|
||||
uint32 classes_required;
|
||||
uint8 probability;
|
||||
std::string bucket_name;
|
||||
std::string bucket_value;
|
||||
uint8 bucket_comparison;
|
||||
};
|
||||
|
||||
struct TempMerchantList {
|
||||
@@ -5582,6 +5588,11 @@ struct SayLinkBodyFrame_Struct {
|
||||
/*056*/
|
||||
};
|
||||
|
||||
struct Checksum_Struct {
|
||||
uint64 checksum;
|
||||
uint8 data[2048];
|
||||
};
|
||||
|
||||
struct UpdateMovementEntry {
|
||||
/* 00 */ float Y;
|
||||
/* 04 */ float X;
|
||||
|
||||
+71
-75
@@ -23,6 +23,8 @@
|
||||
#include "platform.h"
|
||||
#include "string_util.h"
|
||||
#include "misc.h"
|
||||
#include "discord/discord.h"
|
||||
#include "repositories/discord_webhooks_repository.h"
|
||||
#include "repositories/logsys_categories_repository.h"
|
||||
|
||||
#include <iostream>
|
||||
@@ -46,6 +48,7 @@ std::ofstream process_log;
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <thread>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -89,7 +92,7 @@ namespace Console {
|
||||
EQEmuLogSys::EQEmuLogSys()
|
||||
{
|
||||
on_log_gmsay_hook = [](uint16 log_type, const std::string &) {};
|
||||
on_log_console_hook = [](uint16 debug_level, uint16 log_type, const std::string &) {};
|
||||
on_log_console_hook = [](uint16 log_type, const std::string &) {};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,6 +111,7 @@ EQEmuLogSys *EQEmuLogSys::LoadLogSettingsDefaults()
|
||||
log_settings[log_category_id].log_to_console = 0;
|
||||
log_settings[log_category_id].log_to_file = 0;
|
||||
log_settings[log_category_id].log_to_gmsay = 0;
|
||||
log_settings[log_category_id].log_to_discord = 0;
|
||||
log_settings[log_category_id].is_category_enabled = 0;
|
||||
}
|
||||
|
||||
@@ -116,22 +120,26 @@ EQEmuLogSys *EQEmuLogSys::LoadLogSettingsDefaults()
|
||||
/**
|
||||
* Set Defaults
|
||||
*/
|
||||
log_settings[Logs::WorldServer].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::ZoneServer].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::QSServer].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::UCSServer].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::Crash].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::MySQLError].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::Loginserver].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::HeadlessClient].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::NPCScaling].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::HotReload].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::HotReload].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::Loot].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::Scheduler].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::Cheat].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::HTTP].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::HTTP].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::WorldServer].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::ZoneServer].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::QSServer].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::UCSServer].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::Crash].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::MySQLError].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::Loginserver].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::HeadlessClient].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::NPCScaling].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::HotReload].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::HotReload].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::Loot].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::Scheduler].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::Cheat].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::HTTP].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::HTTP].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::ChecksumVerification].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::ChecksumVerification].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::CombatRecord].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::Discord].log_to_console = static_cast<uint8>(Logs::General);
|
||||
|
||||
/**
|
||||
* RFC 5424
|
||||
@@ -151,7 +159,8 @@ EQEmuLogSys *EQEmuLogSys::LoadLogSettingsDefaults()
|
||||
const bool log_to_console = log_settings[log_category_id].log_to_console > 0;
|
||||
const bool log_to_file = log_settings[log_category_id].log_to_file > 0;
|
||||
const bool log_to_gmsay = log_settings[log_category_id].log_to_gmsay > 0;
|
||||
const bool is_category_enabled = log_to_console || log_to_file || log_to_gmsay;
|
||||
const bool log_to_discord = log_settings[log_category_id].log_to_discord > 0;
|
||||
const bool is_category_enabled = log_to_console || log_to_file || log_to_gmsay || log_to_discord;
|
||||
if (is_category_enabled) {
|
||||
log_settings[log_category_id].is_category_enabled = 1;
|
||||
}
|
||||
@@ -218,41 +227,12 @@ std::string EQEmuLogSys::FormatOutMessageString(
|
||||
return return_string + "[" + Logs::LogCategoryName[log_category] + "] " + in_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param debug_level
|
||||
* @param log_category
|
||||
* @param message
|
||||
*/
|
||||
void EQEmuLogSys::ProcessGMSay(
|
||||
uint16 debug_level,
|
||||
uint16 log_category,
|
||||
const std::string &message
|
||||
)
|
||||
{
|
||||
/**
|
||||
* Enabling Netcode based GMSay output creates a feedback loop that ultimately ends in a crash
|
||||
*/
|
||||
if (log_category == Logs::LogCategory::Netcode) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes that actually support hooks
|
||||
*/
|
||||
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone ||
|
||||
EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformWorld
|
||||
) {
|
||||
on_log_gmsay_hook(log_category, message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param debug_level
|
||||
* @param log_category
|
||||
* @param message
|
||||
*/
|
||||
void EQEmuLogSys::ProcessLogWrite(
|
||||
uint16 debug_level,
|
||||
uint16 log_category,
|
||||
const std::string &message
|
||||
)
|
||||
@@ -270,10 +250,9 @@ void EQEmuLogSys::ProcessLogWrite(
|
||||
crash_log.close();
|
||||
}
|
||||
|
||||
char time_stamp[80];
|
||||
EQEmuLogSys::SetCurrentTimeStamp(time_stamp);
|
||||
|
||||
if (process_log) {
|
||||
char time_stamp[80];
|
||||
EQEmuLogSys::SetCurrentTimeStamp(time_stamp);
|
||||
process_log << time_stamp << " " << message << std::endl;
|
||||
}
|
||||
}
|
||||
@@ -369,7 +348,7 @@ uint16 EQEmuLogSys::GetGMSayColorFromCategory(uint16 log_category)
|
||||
* @param log_category
|
||||
* @param message
|
||||
*/
|
||||
void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category, const std::string &message)
|
||||
void EQEmuLogSys::ProcessConsoleMessage(uint16 log_category, const std::string &message)
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
HANDLE console_handle;
|
||||
@@ -387,7 +366,7 @@ void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category,
|
||||
std::cout << EQEmuLogSys::GetLinuxConsoleColorFromCategory(log_category) << message << LC_RESET << std::endl;
|
||||
#endif
|
||||
|
||||
on_log_console_hook(debug_level, log_category, message);
|
||||
on_log_console_hook(log_category, message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -444,28 +423,28 @@ void EQEmuLogSys::Out(
|
||||
...
|
||||
)
|
||||
{
|
||||
bool log_to_console = true;
|
||||
if (log_settings[log_category].log_to_console < debug_level) {
|
||||
log_to_console = false;
|
||||
}
|
||||
bool log_to_console = log_settings[log_category].log_to_console > 0 &&
|
||||
log_settings[log_category].log_to_console >= debug_level;
|
||||
bool log_to_file = log_settings[log_category].log_to_file > 0 &&
|
||||
log_settings[log_category].log_to_file >= debug_level;
|
||||
bool log_to_gmsay = log_settings[log_category].log_to_gmsay > 0 &&
|
||||
log_settings[log_category].log_to_gmsay >= debug_level &&
|
||||
log_category != Logs::LogCategory::Netcode &&
|
||||
(EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone ||
|
||||
EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformWorld);
|
||||
bool log_to_discord = EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone &&
|
||||
log_settings[log_category].log_to_discord > 0 &&
|
||||
log_settings[log_category].log_to_discord >= debug_level &&
|
||||
log_settings[log_category].discord_webhook_id > 0 &&
|
||||
log_settings[log_category].discord_webhook_id < MAX_DISCORD_WEBHOOK_ID;
|
||||
|
||||
bool log_to_file = true;
|
||||
if (log_settings[log_category].log_to_file < debug_level) {
|
||||
log_to_file = false;
|
||||
}
|
||||
|
||||
bool log_to_gmsay = true;
|
||||
if (log_settings[log_category].log_to_gmsay < debug_level) {
|
||||
log_to_gmsay = false;
|
||||
}
|
||||
|
||||
const bool nothing_to_log = !log_to_console && !log_to_file && !log_to_gmsay;
|
||||
// bail out if nothing to log
|
||||
const bool nothing_to_log = !log_to_console && !log_to_file && !log_to_gmsay && !log_to_discord;
|
||||
if (nothing_to_log) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string prefix;
|
||||
|
||||
if (RuleB(Logging, PrintFileFunctionAndLine)) {
|
||||
prefix = fmt::format("[{0}::{1}:{2}] ", base_file_name(file), func, line);
|
||||
}
|
||||
@@ -478,13 +457,16 @@ void EQEmuLogSys::Out(
|
||||
std::string output_debug_message = EQEmuLogSys::FormatOutMessageString(log_category, prefix + output_message);
|
||||
|
||||
if (log_to_console) {
|
||||
EQEmuLogSys::ProcessConsoleMessage(debug_level, log_category, output_debug_message);
|
||||
EQEmuLogSys::ProcessConsoleMessage(log_category, output_debug_message);
|
||||
}
|
||||
if (log_to_gmsay) {
|
||||
EQEmuLogSys::ProcessGMSay(debug_level, log_category, output_debug_message);
|
||||
on_log_gmsay_hook(log_category, message);
|
||||
}
|
||||
if (log_to_file) {
|
||||
EQEmuLogSys::ProcessLogWrite(debug_level, log_category, output_debug_message);
|
||||
EQEmuLogSys::ProcessLogWrite(log_category, output_debug_message);
|
||||
}
|
||||
if (log_to_discord && on_log_discord_hook) {
|
||||
on_log_discord_hook(log_category, log_settings[log_category].discord_webhook_id, output_message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -627,16 +609,20 @@ EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings()
|
||||
continue;
|
||||
}
|
||||
|
||||
log_settings[c.log_category_id].log_to_console = static_cast<uint8>(c.log_to_console);
|
||||
log_settings[c.log_category_id].log_to_file = static_cast<uint8>(c.log_to_file);
|
||||
log_settings[c.log_category_id].log_to_gmsay = static_cast<uint8>(c.log_to_gmsay);
|
||||
log_settings[c.log_category_id].log_to_console = static_cast<uint8>(c.log_to_console);
|
||||
log_settings[c.log_category_id].log_to_file = static_cast<uint8>(c.log_to_file);
|
||||
log_settings[c.log_category_id].log_to_gmsay = static_cast<uint8>(c.log_to_gmsay);
|
||||
log_settings[c.log_category_id].log_to_discord = static_cast<uint8>(c.log_to_discord);
|
||||
log_settings[c.log_category_id].discord_webhook_id = c.discord_webhook_id;
|
||||
|
||||
// Determine if any output method is enabled for the category
|
||||
// and set it to 1 so it can used to check if category is enabled
|
||||
const bool log_to_console = log_settings[c.log_category_id].log_to_console > 0;
|
||||
const bool log_to_file = log_settings[c.log_category_id].log_to_file > 0;
|
||||
const bool log_to_gmsay = log_settings[c.log_category_id].log_to_gmsay > 0;
|
||||
const bool is_category_enabled = log_to_console || log_to_file || log_to_gmsay;
|
||||
const bool log_to_discord = log_settings[c.log_category_id].log_to_discord > 0 &&
|
||||
log_settings[c.log_category_id].discord_webhook_id > 0;
|
||||
const bool is_category_enabled = log_to_console || log_to_file || log_to_gmsay || log_to_discord;
|
||||
|
||||
if (is_category_enabled) {
|
||||
log_settings[c.log_category_id].is_category_enabled = 1;
|
||||
@@ -666,6 +652,7 @@ EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings()
|
||||
new_category.log_to_console = log_settings[i].log_to_console;
|
||||
new_category.log_to_gmsay = log_settings[i].log_to_gmsay;
|
||||
new_category.log_to_file = log_settings[i].log_to_file;
|
||||
new_category.log_to_discord = log_settings[i].log_to_discord;
|
||||
|
||||
LogsysCategoriesRepository::InsertOne(*m_database, new_category);
|
||||
}
|
||||
@@ -673,6 +660,14 @@ EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings()
|
||||
|
||||
LogInfo("Loaded [{}] log categories", categories.size());
|
||||
|
||||
auto webhooks = DiscordWebhooksRepository::All(*m_database);
|
||||
if (!webhooks.empty()) {
|
||||
for (auto &w: webhooks) {
|
||||
discord_webhooks[w.id] = {w.id, w.webhook_name, w.webhook_url};
|
||||
}
|
||||
LogInfo("Loaded [{}] Discord webhooks", webhooks.size());
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -682,3 +677,4 @@ EQEmuLogSys *EQEmuLogSys::SetDatabase(Database *db)
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
+44
-11
@@ -127,6 +127,10 @@ namespace Logs {
|
||||
DiaWind,
|
||||
HTTP,
|
||||
Saylink,
|
||||
ChecksumVerification,
|
||||
CombatRecord,
|
||||
Hate,
|
||||
Discord,
|
||||
MaxCategoryID /* Don't Remove this */
|
||||
};
|
||||
|
||||
@@ -212,6 +216,10 @@ namespace Logs {
|
||||
"DialogueWindow",
|
||||
"HTTP",
|
||||
"Saylink",
|
||||
"ChecksumVerification",
|
||||
"CombatRecord",
|
||||
"Hate",
|
||||
"Discord",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -219,6 +227,8 @@ namespace Logs {
|
||||
|
||||
class Database;
|
||||
|
||||
constexpr uint16 MAX_DISCORD_WEBHOOK_ID = 300;
|
||||
|
||||
class EQEmuLogSys {
|
||||
public:
|
||||
EQEmuLogSys();
|
||||
@@ -281,9 +291,19 @@ public:
|
||||
uint8 log_to_file;
|
||||
uint8 log_to_console;
|
||||
uint8 log_to_gmsay;
|
||||
uint8 log_to_discord;
|
||||
int discord_webhook_id;
|
||||
uint8 is_category_enabled; /* When any log output in a category > 0, set this to 1 as (Enabled) */
|
||||
};
|
||||
|
||||
struct OriginationInfo {
|
||||
std::string zone_short_name;
|
||||
std::string zone_long_name;
|
||||
int instance_id;
|
||||
};
|
||||
|
||||
OriginationInfo origination_info{};
|
||||
|
||||
/**
|
||||
* Internally used memory reference for all log settings per category
|
||||
* These are loaded via DB and have defaults loaded in LoadLogSettingsDefaults
|
||||
@@ -291,24 +311,38 @@ public:
|
||||
*/
|
||||
LogSettings log_settings[Logs::LogCategory::MaxCategoryID]{};
|
||||
|
||||
struct DiscordWebhooks {
|
||||
int id;
|
||||
std::string webhook_name;
|
||||
std::string webhook_url;
|
||||
};
|
||||
|
||||
DiscordWebhooks discord_webhooks[MAX_DISCORD_WEBHOOK_ID]{};
|
||||
|
||||
bool file_logs_enabled = false;
|
||||
|
||||
int log_platform = 0;
|
||||
std::string platform_file_name;
|
||||
int log_platform = 0;
|
||||
std::string platform_file_name;
|
||||
|
||||
|
||||
// gmsay
|
||||
uint16 GetGMSayColorFromCategory(uint16 log_category);
|
||||
|
||||
EQEmuLogSys * SetGMSayHandler(std::function<void(uint16 log_type, const std::string &)> f) {
|
||||
EQEmuLogSys *SetGMSayHandler(std::function<void(uint16 log_type, const std::string &)> f)
|
||||
{
|
||||
on_log_gmsay_hook = f;
|
||||
return this;
|
||||
}
|
||||
|
||||
EQEmuLogSys *SetDiscordHandler(std::function<void(uint16 log_category, int webhook_id, const std::string &)> f)
|
||||
{
|
||||
on_log_discord_hook = f;
|
||||
return this;
|
||||
}
|
||||
|
||||
// console
|
||||
void SetConsoleHandler(
|
||||
std::function<void(
|
||||
uint16 debug_level,
|
||||
uint16 log_type,
|
||||
const std::string &
|
||||
)> f
|
||||
@@ -322,18 +356,17 @@ public:
|
||||
private:
|
||||
|
||||
// reference to database
|
||||
Database *m_database;
|
||||
|
||||
std::function<void(uint16 log_category, const std::string &)> on_log_gmsay_hook;
|
||||
std::function<void(uint16 debug_level, uint16 log_category, const std::string &)> on_log_console_hook;
|
||||
Database *m_database;
|
||||
std::function<void(uint16 log_category, const std::string &)> on_log_gmsay_hook;
|
||||
std::function<void(uint16 log_category, int webhook_id, const std::string &)> on_log_discord_hook;
|
||||
std::function<void(uint16 log_category, const std::string &)> on_log_console_hook;
|
||||
|
||||
std::string FormatOutMessageString(uint16 log_category, const std::string &in_message);
|
||||
std::string GetLinuxConsoleColorFromCategory(uint16 log_category);
|
||||
uint16 GetWindowsConsoleColorFromCategory(uint16 log_category);
|
||||
|
||||
void ProcessConsoleMessage(uint16 debug_level, uint16 log_category, const std::string &message);
|
||||
void ProcessGMSay(uint16 debug_level, uint16 log_category, const std::string &message);
|
||||
void ProcessLogWrite(uint16 debug_level, uint16 log_category, const std::string &message);
|
||||
void ProcessConsoleMessage(uint16 log_category, const std::string &message);
|
||||
void ProcessLogWrite(uint16 log_category, const std::string &message);
|
||||
bool IsRfc5424LogCategory(uint16 log_category);
|
||||
};
|
||||
|
||||
|
||||
@@ -696,6 +696,46 @@
|
||||
OutF(LogSys, Logs::Detail, Logs::Saylink, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define LogChecksumVerification(message, ...) do {\
|
||||
if (LogSys.log_settings[Logs::ChecksumVerification].is_category_enabled == 1)\
|
||||
OutF(LogSys, Logs::General, Logs::ChecksumVerification, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define LogChecksumVerificationDetail(message, ...) do {\
|
||||
if (LogSys.log_settings[Logs::ChecksumVerification].is_category_enabled == 1)\
|
||||
OutF(LogSys, Logs::Detail, Logs::ChecksumVerification, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define LogCombatRecord(message, ...) do {\
|
||||
if (LogSys.log_settings[Logs::CombatRecord].is_category_enabled == 1)\
|
||||
OutF(LogSys, Logs::General, Logs::CombatRecord, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define LogCombatRecordDetail(message, ...) do {\
|
||||
if (LogSys.log_settings[Logs::CombatRecord].is_category_enabled == 1)\
|
||||
OutF(LogSys, Logs::Detail, Logs::CombatRecord, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define LogHate(message, ...) do {\
|
||||
if (LogSys.log_settings[Logs::Hate].is_category_enabled == 1)\
|
||||
OutF(LogSys, Logs::General, Logs::Hate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define LogHateDetail(message, ...) do {\
|
||||
if (LogSys.log_settings[Logs::Hate].is_category_enabled == 1)\
|
||||
OutF(LogSys, Logs::Detail, Logs::Hate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define LogDiscord(message, ...) do {\
|
||||
if (LogSys.log_settings[Logs::Discord].is_category_enabled == 1)\
|
||||
OutF(LogSys, Logs::General, Logs::Discord, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define LogDiscordDetail(message, ...) do {\
|
||||
if (LogSys.log_settings[Logs::Discord].is_category_enabled == 1)\
|
||||
OutF(LogSys, Logs::Detail, Logs::Discord, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define Log(debug_level, log_category, message, ...) do {\
|
||||
if (LogSys.log_settings[log_category].is_category_enabled == 1)\
|
||||
LogSys.Out(debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
@@ -1092,6 +1132,54 @@
|
||||
#define LogHTTPDetail(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogSaylink(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogSaylinkDetail(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogScheduler(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogSchedulerDetail(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogCheat(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogCheatDetail(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogLoot(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogLootDetail(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogFood(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogFoodDetail(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogChecksumVerification(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogChecksumVerificationDetail(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogCombatRecord(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogCombatRecordDetail(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogHate(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define LogHateDetail(message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
#define Log(debug_level, log_category, message, ...) do {\
|
||||
} while (0)
|
||||
|
||||
|
||||
+9
-9
@@ -370,7 +370,7 @@ namespace EQ
|
||||
uint32 Slots; // Bitfield for which slots this item can be used in
|
||||
uint32 Price; // Item cost (?)
|
||||
uint32 Icon; // Icon Number
|
||||
uint32 LoreGroup; // Later items use LoreGroup instead of LoreFlag. we might want to see about changing this to int32 since it is commonly -1 and is constantly being cast from signed (-1) to unsigned (4294967295)
|
||||
int32 LoreGroup; // Later items use LoreGroup instead of LoreFlag. we might want to see about changing this to int32 since it is commonly -1 and is constantly being cast from signed (-1) to unsigned (4294967295)
|
||||
bool LoreFlag; // This will be true if LoreGroup is non-zero
|
||||
bool PendingLoreFlag;
|
||||
bool ArtifactFlag;
|
||||
@@ -473,14 +473,14 @@ namespace EQ
|
||||
uint32 LDoNSold;
|
||||
uint32 BaneDmgRaceAmt;
|
||||
uint32 AugRestrict;
|
||||
uint32 Endur;
|
||||
uint32 DotShielding;
|
||||
uint32 Attack;
|
||||
uint32 Regen;
|
||||
uint32 ManaRegen;
|
||||
uint32 EnduranceRegen;
|
||||
uint32 Haste;
|
||||
uint32 DamageShield;
|
||||
int32 Endur;
|
||||
int32 DotShielding;
|
||||
int32 Attack;
|
||||
int32 Regen;
|
||||
int32 ManaRegen;
|
||||
int32 EnduranceRegen;
|
||||
int32 Haste;
|
||||
int32 DamageShield;
|
||||
uint32 RecastDelay;
|
||||
int RecastType;
|
||||
uint32 AugDistiller;
|
||||
|
||||
+21
-21
@@ -214,7 +214,7 @@ EQ::ItemInstance::~ItemInstance()
|
||||
bool EQ::ItemInstance::IsType(item::ItemClass item_class) const
|
||||
{
|
||||
// IsType(<ItemClassTypes>) does not protect against 'm_item = nullptr'
|
||||
|
||||
|
||||
// Check usage type
|
||||
if ((m_use_type == ItemInstWorldContainer) && (item_class == item::ItemClassBag))
|
||||
return true;
|
||||
@@ -245,7 +245,7 @@ bool EQ::ItemInstance::IsStackable() const
|
||||
{
|
||||
if (!m_item)
|
||||
return false;
|
||||
|
||||
|
||||
return m_item->Stackable;
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ bool EQ::ItemInstance::IsCharged() const
|
||||
{
|
||||
if (!m_item)
|
||||
return false;
|
||||
|
||||
|
||||
if (m_item->MaxCharges > 1)
|
||||
return true;
|
||||
else
|
||||
@@ -381,7 +381,7 @@ EQ::ItemInstance* EQ::ItemInstance::PopItem(uint8 index)
|
||||
m_contents.erase(index);
|
||||
return inst; // Return pointer that needs to be deleted (or otherwise managed)
|
||||
}
|
||||
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -476,7 +476,7 @@ uint8 EQ::ItemInstance::GetTotalItemCount() const
|
||||
{
|
||||
if (!m_item)
|
||||
return 0;
|
||||
|
||||
|
||||
uint8 item_count = 1;
|
||||
|
||||
if (m_item && !m_item->IsClassBag()) { return item_count; }
|
||||
@@ -526,7 +526,7 @@ EQ::ItemInstance* EQ::ItemInstance::GetOrnamentationAug(int32 ornamentationAugty
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return this->GetAugment(i);
|
||||
return GetAugment(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -549,7 +549,7 @@ uint32 EQ::ItemInstance::GetOrnamentHeroModel(int32 material_slot) const {
|
||||
bool EQ::ItemInstance::UpdateOrnamentationInfo() {
|
||||
if (!m_item || !m_item->IsClassCommon())
|
||||
return false;
|
||||
|
||||
|
||||
bool ornamentSet = false;
|
||||
|
||||
int32 ornamentationAugtype = RuleI(Character, OrnamentationAugmentType);
|
||||
@@ -642,7 +642,7 @@ void EQ::ItemInstance::PutAugment(uint8 slot, const ItemInstance& augment)
|
||||
{
|
||||
if (!m_item || !m_item->IsClassCommon())
|
||||
return;
|
||||
|
||||
|
||||
PutItem(slot, augment);
|
||||
}
|
||||
|
||||
@@ -655,7 +655,7 @@ void EQ::ItemInstance::PutAugment(SharedDatabase *db, uint8 slot, uint32 item_id
|
||||
if (aug) {
|
||||
PutAugment(slot, *aug);
|
||||
safe_delete(aug);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove augment from item and destroy it
|
||||
@@ -663,7 +663,7 @@ void EQ::ItemInstance::DeleteAugment(uint8 index)
|
||||
{
|
||||
if (!m_item || !m_item->IsClassCommon())
|
||||
return;
|
||||
|
||||
|
||||
DeleteItem(index);
|
||||
}
|
||||
|
||||
@@ -672,7 +672,7 @@ EQ::ItemInstance* EQ::ItemInstance::RemoveAugment(uint8 index)
|
||||
{
|
||||
if (!m_item || !m_item->IsClassCommon())
|
||||
return nullptr;
|
||||
|
||||
|
||||
return PopItem(index);
|
||||
}
|
||||
|
||||
@@ -680,7 +680,7 @@ bool EQ::ItemInstance::IsAugmented()
|
||||
{
|
||||
if (!m_item || !m_item->IsClassCommon())
|
||||
return false;
|
||||
|
||||
|
||||
for (int index = invaug::SOCKET_BEGIN; index <= invaug::SOCKET_END; ++index) {
|
||||
if (GetAugmentItemID(index))
|
||||
return true;
|
||||
@@ -698,7 +698,7 @@ bool EQ::ItemInstance::ContainsAugmentByID(uint32 item_id)
|
||||
if (!item_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for (uint8 augment_slot = invaug::SOCKET_BEGIN; augment_slot <= invaug::SOCKET_END; ++augment_slot) {
|
||||
if (GetAugmentItemID(augment_slot) == item_id) {
|
||||
return true;
|
||||
@@ -718,7 +718,7 @@ int EQ::ItemInstance::CountAugmentByID(uint32 item_id)
|
||||
if (!item_id) {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
|
||||
for (uint8 augment_slot = invaug::SOCKET_BEGIN; augment_slot <= invaug::SOCKET_END; ++augment_slot) {
|
||||
if (GetAugmentItemID(augment_slot) == item_id) {
|
||||
quantity++;
|
||||
@@ -873,7 +873,7 @@ bool EQ::ItemInstance::IsDroppable(bool recurse) const
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1097,7 +1097,7 @@ int EQ::ItemInstance::GetItemElementalFlag(bool augments) const
|
||||
|
||||
int EQ::ItemInstance::GetItemElementalDamage(bool augments) const
|
||||
{
|
||||
int damage = 0;
|
||||
int64 damage = 0;
|
||||
const auto item = GetItem();
|
||||
if (item) {
|
||||
damage = item->ElemDmgAmt;
|
||||
@@ -1162,7 +1162,7 @@ int EQ::ItemInstance::GetItemRequiredLevel(bool augments) const
|
||||
|
||||
int EQ::ItemInstance::GetItemWeaponDamage(bool augments) const
|
||||
{
|
||||
int damage = 0;
|
||||
int64 damage = 0;
|
||||
const auto item = GetItem();
|
||||
if (item) {
|
||||
damage = item->Damage;
|
||||
@@ -1178,7 +1178,7 @@ int EQ::ItemInstance::GetItemWeaponDamage(bool augments) const
|
||||
|
||||
int EQ::ItemInstance::GetItemBackstabDamage(bool augments) const
|
||||
{
|
||||
int damage = 0;
|
||||
int64 damage = 0;
|
||||
const auto item = GetItem();
|
||||
if (item) {
|
||||
damage = item->BackstabDmg;
|
||||
@@ -1236,7 +1236,7 @@ int EQ::ItemInstance::GetItemBaneDamageRace(bool augments) const
|
||||
|
||||
int EQ::ItemInstance::GetItemBaneDamageBody(bodyType against, bool augments) const
|
||||
{
|
||||
int damage = 0;
|
||||
int64 damage = 0;
|
||||
const auto item = GetItem();
|
||||
if (item) {
|
||||
if (item->BaneDmgBody == against)
|
||||
@@ -1253,7 +1253,7 @@ int EQ::ItemInstance::GetItemBaneDamageBody(bodyType against, bool augments) con
|
||||
|
||||
int EQ::ItemInstance::GetItemBaneDamageRace(uint16 against, bool augments) const
|
||||
{
|
||||
int damage = 0;
|
||||
int64 damage = 0;
|
||||
const auto item = GetItem();
|
||||
if (item) {
|
||||
if (item->BaneDmgRace == against)
|
||||
@@ -1745,4 +1745,4 @@ EvolveInfo::EvolveInfo(uint32 first, uint8 max, bool allkills, uint32 L2, uint32
|
||||
|
||||
EvolveInfo::~EvolveInfo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+14
-5
@@ -30,11 +30,19 @@ struct LootTableEntries_Struct {
|
||||
float probability;
|
||||
};
|
||||
|
||||
struct ContentFlags {
|
||||
int16 min_expansion;
|
||||
int16 max_expansion;
|
||||
char content_flags[100];
|
||||
char content_flags_disabled[100];
|
||||
};
|
||||
|
||||
struct LootTable_Struct {
|
||||
uint32 mincash;
|
||||
uint32 maxcash;
|
||||
uint32 avgcoin;
|
||||
uint32 NumEntries;
|
||||
uint32 mincash;
|
||||
uint32 maxcash;
|
||||
uint32 avgcoin;
|
||||
uint32 NumEntries;
|
||||
ContentFlags content_flags;
|
||||
LootTableEntries_Struct Entries[0];
|
||||
};
|
||||
|
||||
@@ -51,7 +59,8 @@ struct LootDropEntries_Struct {
|
||||
};
|
||||
|
||||
struct LootDrop_Struct {
|
||||
uint32 NumEntries;
|
||||
uint32 NumEntries;
|
||||
ContentFlags content_flags;
|
||||
LootDropEntries_Struct Entries[0];
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
@@ -2649,11 +2649,11 @@ struct FaceChange_Struct {
|
||||
/*004*/ uint8 hairstyle;
|
||||
/*005*/ uint8 beard;
|
||||
/*006*/ uint8 face;
|
||||
/*007*/ uint8 unknown007;
|
||||
/*007*/ uint8 unused_padding;
|
||||
/*008*/ uint32 drakkin_heritage;
|
||||
/*012*/ uint32 drakkin_tattoo;
|
||||
/*016*/ uint32 drakkin_details;
|
||||
/*020*/ uint32 unknown020;
|
||||
/*020*/ uint32 entity_id;
|
||||
/*024*/
|
||||
};
|
||||
//there are only 10 faces for barbs changing woad just
|
||||
@@ -5218,6 +5218,11 @@ struct SayLinkBodyFrame_Struct {
|
||||
/*056*/
|
||||
};
|
||||
|
||||
struct Checksum_Struct {
|
||||
uint64_t checksum;
|
||||
uint8_t data[2048];
|
||||
};
|
||||
|
||||
}; /*structs*/
|
||||
|
||||
}; /*RoF2*/
|
||||
|
||||
@@ -2622,11 +2622,11 @@ struct FaceChange_Struct {
|
||||
/*004*/ uint8 hairstyle;
|
||||
/*005*/ uint8 beard;
|
||||
/*006*/ uint8 face;
|
||||
/*007*/ uint8 unknown007;
|
||||
/*007*/ uint8 unused_padding;
|
||||
/*008*/ uint32 drakkin_heritage;
|
||||
/*012*/ uint32 drakkin_tattoo;
|
||||
/*016*/ uint32 drakkin_details;
|
||||
/*020*/ uint32 unknown020;
|
||||
/*020*/ uint32 entity_id;
|
||||
/*024*/
|
||||
};
|
||||
//there are only 10 faces for barbs changing woad just
|
||||
|
||||
@@ -2136,11 +2136,11 @@ struct FaceChange_Struct {
|
||||
/*004*/ uint8 hairstyle;
|
||||
/*005*/ uint8 beard;
|
||||
/*006*/ uint8 face;
|
||||
/*007*/ uint8 unknown007;
|
||||
/*007*/ uint8 unused_padding;
|
||||
/*008*/ uint32 drakkin_heritage;
|
||||
/*012*/ uint32 drakkin_tattoo;
|
||||
/*016*/ uint32 drakkin_details;
|
||||
/*020*/ uint32 unknown020;
|
||||
/*020*/ uint32 entity_id;
|
||||
/*024*/
|
||||
};
|
||||
//there are only 10 faces for barbs changing woad just
|
||||
|
||||
@@ -2106,11 +2106,11 @@ struct FaceChange_Struct {
|
||||
/*004*/ uint8 hairstyle;
|
||||
/*005*/ uint8 beard;
|
||||
/*006*/ uint8 face;
|
||||
/*007*/ uint8 unknown007;
|
||||
/*007*/ uint8 unused_padding;
|
||||
/*008*/ uint32 drakkin_heritage;
|
||||
/*012*/ uint32 drakkin_tattoo;
|
||||
/*016*/ uint32 drakkin_details;
|
||||
/*020*/ uint32 unknown020;
|
||||
/*020*/ uint32 entity_id;
|
||||
/*024*/
|
||||
};
|
||||
//there are only 10 faces for barbs changing woad just
|
||||
|
||||
@@ -1464,6 +1464,30 @@ namespace Titanium
|
||||
FINISH_ENCODE();
|
||||
}
|
||||
|
||||
ENCODE(OP_SetFace)
|
||||
{
|
||||
auto emu = reinterpret_cast<FaceChange_Struct*>((*p)->pBuffer);
|
||||
|
||||
EQApplicationPacket outapp(OP_Illusion, sizeof(structs::Illusion_Struct));
|
||||
auto buf = reinterpret_cast<structs::Illusion_Struct*>(outapp.pBuffer);
|
||||
|
||||
buf->spawnid = emu->entity_id;
|
||||
buf->race = -1; // unchanged
|
||||
buf->gender = -1; // unchanged
|
||||
buf->texture = -1; // unchanged
|
||||
buf->helmtexture = -1; // unchanged
|
||||
buf->face = emu->face;
|
||||
buf->hairstyle = emu->hairstyle;
|
||||
buf->haircolor = emu->haircolor;
|
||||
buf->beard = emu->beard;
|
||||
buf->beardcolor = emu->beardcolor;
|
||||
buf->size = 0.0f; // unchanged
|
||||
|
||||
safe_delete(*p); // not using the original packet
|
||||
|
||||
dest->QueuePacket(&outapp, ack_req);
|
||||
}
|
||||
|
||||
ENCODE(OP_ShopPlayerSell)
|
||||
{
|
||||
ENCODE_LENGTH_EXACT(Merchant_Purchase_Struct);
|
||||
|
||||
@@ -66,6 +66,7 @@ E(OP_ReadBook)
|
||||
E(OP_RespondAA)
|
||||
E(OP_SendCharInfo)
|
||||
E(OP_SendAATable)
|
||||
E(OP_SetFace)
|
||||
E(OP_ShopPlayerSell)
|
||||
E(OP_SpecialMesg)
|
||||
E(OP_TaskDescription)
|
||||
|
||||
@@ -1761,8 +1761,7 @@ struct AdventureRequestResponse_Struct{
|
||||
struct Illusion_Struct {
|
||||
/*000*/ uint32 spawnid;
|
||||
/*004*/ char charname[64];
|
||||
/*068*/ uint16 race;
|
||||
/*070*/ char unknown070[2];
|
||||
/*068*/ int race;
|
||||
/*072*/ uint8 gender;
|
||||
/*073*/ uint8 texture;
|
||||
/*074*/ uint8 helmtexture;
|
||||
|
||||
@@ -2185,11 +2185,11 @@ struct FaceChange_Struct {
|
||||
/*004*/ uint8 hairstyle;
|
||||
/*005*/ uint8 beard;
|
||||
/*006*/ uint8 face;
|
||||
/*007*/ uint8 unknown007;
|
||||
/*007*/ uint8 unused_padding;
|
||||
/*008*/ uint32 drakkin_heritage;
|
||||
/*012*/ uint32 drakkin_tattoo;
|
||||
/*016*/ uint32 drakkin_details;
|
||||
/*020*/ uint32 unknown020;
|
||||
/*020*/ uint32 entity_id;
|
||||
/*024*/
|
||||
};
|
||||
//there are only 10 faces for barbs changing woad just
|
||||
|
||||
@@ -58,7 +58,8 @@ XS(XS_EQDB_field_count)
|
||||
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
|
||||
|
||||
RETVAL = THIS->field_count();
|
||||
XSprePUSH; PUSHu((UV)RETVAL);
|
||||
XSprePUSH;
|
||||
PUSHu((UV) RETVAL);
|
||||
}
|
||||
XSRETURN(1);
|
||||
}
|
||||
@@ -84,7 +85,8 @@ XS(XS_EQDB_affected_rows)
|
||||
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
|
||||
|
||||
RETVAL = THIS->affected_rows();
|
||||
XSprePUSH; PUSHu((UV)RETVAL);
|
||||
XSprePUSH;
|
||||
PUSHu((UV) RETVAL);
|
||||
}
|
||||
XSRETURN(1);
|
||||
}
|
||||
@@ -110,7 +112,8 @@ XS(XS_EQDB_insert_id)
|
||||
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
|
||||
|
||||
RETVAL = THIS->insert_id();
|
||||
XSprePUSH; PUSHu((UV)RETVAL);
|
||||
XSprePUSH;
|
||||
PUSHu((UV) RETVAL);
|
||||
}
|
||||
XSRETURN(1);
|
||||
}
|
||||
@@ -136,7 +139,8 @@ XS(XS_EQDB_get_errno)
|
||||
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
|
||||
|
||||
RETVAL = THIS->get_errno();
|
||||
XSprePUSH; PUSHu((UV)RETVAL);
|
||||
XSprePUSH;
|
||||
PUSHu((UV) RETVAL);
|
||||
}
|
||||
XSRETURN(1);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,8 @@ XS(XS_EQDBRes_num_rows)
|
||||
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
|
||||
|
||||
RETVAL = THIS->num_rows();
|
||||
XSprePUSH; PUSHu((UV)RETVAL);
|
||||
XSprePUSH;
|
||||
PUSHu((UV) RETVAL);
|
||||
}
|
||||
XSRETURN(1);
|
||||
}
|
||||
@@ -80,7 +81,8 @@ XS(XS_EQDBRes_num_fields)
|
||||
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
|
||||
|
||||
RETVAL = THIS->num_fields();
|
||||
XSprePUSH; PUSHu((UV)RETVAL);
|
||||
XSprePUSH;
|
||||
PUSHu((UV) RETVAL);
|
||||
}
|
||||
XSRETURN(1);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "profanity_manager.h"
|
||||
#include "dbcore.h"
|
||||
#include "string_util.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <cstring>
|
||||
@@ -34,15 +35,17 @@ bool EQ::ProfanityManager::LoadProfanityList(DBcore *db) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!load_database_entries(db))
|
||||
if (!load_database_entries(db)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQ::ProfanityManager::UpdateProfanityList(DBcore *db) {
|
||||
if (!load_database_entries(db))
|
||||
if (!load_database_entries(db)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
update_originator_flag = true;
|
||||
|
||||
@@ -58,53 +61,60 @@ bool EQ::ProfanityManager::DeleteProfanityList(DBcore *db) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQ::ProfanityManager::AddProfanity(DBcore *db, const char *profanity) {
|
||||
if (!db || !profanity)
|
||||
bool EQ::ProfanityManager::AddProfanity(DBcore *db, std::string profanity) {
|
||||
if (!db || profanity.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string entry(profanity);
|
||||
std::string entry = str_tolower(profanity);
|
||||
|
||||
std::transform(entry.begin(), entry.end(), entry.begin(), [](unsigned char c) -> unsigned char { return tolower(c); });
|
||||
|
||||
if (check_for_existing_entry(entry.c_str()))
|
||||
if (check_for_existing_entry(entry)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (entry.length() < REDACTION_LENGTH_MIN)
|
||||
if (entry.length() < REDACTION_LENGTH_MIN) {
|
||||
return false;
|
||||
}
|
||||
|
||||
profanity_list.push_back(entry);
|
||||
|
||||
std::string query = "REPLACE INTO `profanity_list` (`word`) VALUES ('";
|
||||
query.append(entry);
|
||||
query.append("')");
|
||||
auto query = fmt::format(
|
||||
"REPLACE INTO `profanity_list` (`word`) VALUES ('{}')",
|
||||
profanity
|
||||
);
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
update_originator_flag = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQ::ProfanityManager::RemoveProfanity(DBcore *db, const char *profanity) {
|
||||
if (!db || !profanity)
|
||||
bool EQ::ProfanityManager::RemoveProfanity(DBcore *db, std::string profanity) {
|
||||
if (!db || profanity.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string entry(profanity);
|
||||
std::string entry = str_tolower(profanity);
|
||||
|
||||
std::transform(entry.begin(), entry.end(), entry.begin(), [](unsigned char c) -> unsigned char { return tolower(c); });
|
||||
|
||||
if (!check_for_existing_entry(entry.c_str()))
|
||||
if (!check_for_existing_entry(entry)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
profanity_list.remove(entry);
|
||||
|
||||
std::string query = "DELETE FROM `profanity_list` WHERE `word` LIKE '";
|
||||
query.append(entry);
|
||||
query.append("'");
|
||||
auto query = fmt::format(
|
||||
"DELETE FROM `profanity_list` WHERE `word` = '{}'",
|
||||
entry
|
||||
);
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
update_originator_flag = true;
|
||||
|
||||
@@ -112,16 +122,16 @@ bool EQ::ProfanityManager::RemoveProfanity(DBcore *db, const char *profanity) {
|
||||
}
|
||||
|
||||
void EQ::ProfanityManager::RedactMessage(char *message) {
|
||||
if (!message)
|
||||
if (!message) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string test_message(message);
|
||||
std::string test_message = str_tolower(message);
|
||||
// hard-coded max length based on channel message buffer size (4096 bytes)..
|
||||
// ..will need to change or remove if other sources are used for redaction
|
||||
if (test_message.length() < REDACTION_LENGTH_MIN || test_message.length() >= 4096)
|
||||
if (test_message.length() < REDACTION_LENGTH_MIN || test_message.length() >= 4096) {
|
||||
return;
|
||||
|
||||
std::transform(test_message.begin(), test_message.end(), test_message.begin(), [](unsigned char c) -> unsigned char { return tolower(c); });
|
||||
}
|
||||
|
||||
for (const auto &iter : profanity_list) { // consider adding textlink checks if it becomes an issue
|
||||
size_t pos = 0;
|
||||
@@ -129,12 +139,17 @@ void EQ::ProfanityManager::RedactMessage(char *message) {
|
||||
|
||||
while (pos != std::string::npos) {
|
||||
pos = test_message.find(iter, start_pos);
|
||||
if (pos == std::string::npos)
|
||||
if (pos == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((pos + iter.length()) == test_message.length() || !isalpha(test_message.at(pos + iter.length()))) {
|
||||
if (pos == 0 || !isalpha(test_message.at(pos - 1)))
|
||||
if (
|
||||
(pos + iter.length()) == test_message.length() ||
|
||||
!isalpha(test_message.at(pos + iter.length()))
|
||||
) {
|
||||
if (pos == 0 || !isalpha(test_message.at(pos - 1))) {
|
||||
memset((message + pos), REDACTION_CHARACTER, iter.length());
|
||||
}
|
||||
}
|
||||
|
||||
start_pos = (pos + iter.length());
|
||||
@@ -143,25 +158,29 @@ void EQ::ProfanityManager::RedactMessage(char *message) {
|
||||
}
|
||||
|
||||
void EQ::ProfanityManager::RedactMessage(std::string &message) {
|
||||
if (message.length() < REDACTION_LENGTH_MIN || message.length() >= 4096)
|
||||
if (message.length() < REDACTION_LENGTH_MIN || message.length() >= 4096) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string test_message(const_cast<const std::string&>(message));
|
||||
std::string test_message = str_tolower(message);
|
||||
|
||||
std::transform(test_message.begin(), test_message.end(), test_message.begin(), [](unsigned char c) -> unsigned char { return tolower(c); });
|
||||
|
||||
for (const auto &iter : profanity_list) { // consider adding textlink checks if it becomes an issue
|
||||
for (const auto &iter : profanity_list) {
|
||||
size_t pos = 0;
|
||||
size_t start_pos = 0;
|
||||
|
||||
while (pos != std::string::npos) {
|
||||
pos = test_message.find(iter, start_pos);
|
||||
if (pos == std::string::npos)
|
||||
if (pos == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((pos + iter.length()) == test_message.length() || !isalpha(test_message.at(pos + iter.length()))) {
|
||||
if (pos == 0 || !isalpha(test_message.at(pos - 1)))
|
||||
if (
|
||||
(pos + iter.length()) == test_message.length() ||
|
||||
!isalpha(test_message.at(pos + iter.length()))
|
||||
) {
|
||||
if (pos == 0 || !isalpha(test_message.at(pos - 1))) {
|
||||
message.replace(pos, iter.length(), iter.length(), REDACTION_CHARACTER);
|
||||
}
|
||||
}
|
||||
|
||||
start_pos = (pos + iter.length());
|
||||
@@ -169,24 +188,18 @@ void EQ::ProfanityManager::RedactMessage(std::string &message) {
|
||||
}
|
||||
}
|
||||
|
||||
bool EQ::ProfanityManager::ContainsCensoredLanguage(const char *message) {
|
||||
if (!message)
|
||||
return false;
|
||||
|
||||
return ContainsCensoredLanguage(std::string(message));
|
||||
}
|
||||
|
||||
bool EQ::ProfanityManager::ContainsCensoredLanguage(const std::string &message) {
|
||||
if (message.length() < REDACTION_LENGTH_MIN || message.length() >= 4096)
|
||||
if (message.length() < REDACTION_LENGTH_MIN || message.length() >= 4096) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string test_message(message);
|
||||
|
||||
std::transform(test_message.begin(), test_message.end(), test_message.begin(), [](unsigned char c) -> unsigned char { return tolower(c); });
|
||||
std::string test_message = str_tolower(message);
|
||||
|
||||
for (const auto &iter : profanity_list) {
|
||||
if (test_message.find(iter) != std::string::npos)
|
||||
if (test_message.find(iter) != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -197,26 +210,28 @@ const std::list<std::string> &EQ::ProfanityManager::GetProfanityList() {
|
||||
}
|
||||
|
||||
bool EQ::ProfanityManager::IsCensorshipActive() {
|
||||
return (profanity_list.size() != 0);
|
||||
return profanity_list.size() != 0;
|
||||
}
|
||||
|
||||
bool EQ::ProfanityManager::load_database_entries(DBcore *db) {
|
||||
if (!db)
|
||||
if (!db) {
|
||||
return false;
|
||||
}
|
||||
|
||||
profanity_list.clear();
|
||||
|
||||
std::string query = "SELECT `word` FROM `profanity_list`";
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
if (std::strlen(row[0]) >= REDACTION_LENGTH_MIN) {
|
||||
std::string entry(row[0]);
|
||||
std::transform(entry.begin(), entry.end(), entry.begin(), [](unsigned char c) -> unsigned char { return tolower(c); });
|
||||
if (!check_for_existing_entry(entry.c_str()))
|
||||
profanity_list.push_back((std::string)entry);
|
||||
for (auto row : results) {
|
||||
std::string entry = str_tolower(row[0]);
|
||||
if (entry.length() >= REDACTION_LENGTH_MIN) {
|
||||
if (!check_for_existing_entry(entry)) {
|
||||
profanity_list.push_back(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,26 +239,31 @@ bool EQ::ProfanityManager::load_database_entries(DBcore *db) {
|
||||
}
|
||||
|
||||
bool EQ::ProfanityManager::clear_database_entries(DBcore *db) {
|
||||
if (!db)
|
||||
if (!db) {
|
||||
return false;
|
||||
}
|
||||
|
||||
profanity_list.clear();
|
||||
|
||||
std::string query = "DELETE FROM `profanity_list`";
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQ::ProfanityManager::check_for_existing_entry(const char *profanity) {
|
||||
if (!profanity)
|
||||
bool EQ::ProfanityManager::check_for_existing_entry(std::string profanity) {
|
||||
if (profanity.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto &iter : profanity_list) {
|
||||
if (iter.compare(profanity) == 0)
|
||||
if (!iter.compare(profanity)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <fmt/format.h>
|
||||
|
||||
|
||||
class DBcore;
|
||||
@@ -34,13 +35,12 @@ namespace EQ
|
||||
static bool UpdateProfanityList(DBcore *db);
|
||||
static bool DeleteProfanityList(DBcore *db);
|
||||
|
||||
static bool AddProfanity(DBcore *db, const char *profanity);
|
||||
static bool RemoveProfanity(DBcore *db, const char *profanity);
|
||||
static bool AddProfanity(DBcore *db, std::string profanity);
|
||||
static bool RemoveProfanity(DBcore *db, std::string profanity);
|
||||
|
||||
static void RedactMessage(char *message);
|
||||
static void RedactMessage(std::string &message);
|
||||
|
||||
static bool ContainsCensoredLanguage(const char *message);
|
||||
static bool ContainsCensoredLanguage(const std::string &message);
|
||||
|
||||
static const std::list<std::string> &GetProfanityList();
|
||||
@@ -53,7 +53,7 @@ namespace EQ
|
||||
private:
|
||||
static bool load_database_entries(DBcore *db);
|
||||
static bool clear_database_entries(DBcore *db);
|
||||
static bool check_for_existing_entry(const char *profanity);
|
||||
static bool check_for_existing_entry(std::string profanity);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAaAbilityRepository {
|
||||
public:
|
||||
@@ -59,11 +60,36 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"name",
|
||||
"category",
|
||||
"classes",
|
||||
"races",
|
||||
"drakkin_heritage",
|
||||
"deities",
|
||||
"status",
|
||||
"type",
|
||||
"charges",
|
||||
"grant_only",
|
||||
"first_rank_id",
|
||||
"enabled",
|
||||
"reset_on_death",
|
||||
};
|
||||
}
|
||||
|
||||
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("aa_ability");
|
||||
@@ -73,7 +99,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAaRankEffectsRepository {
|
||||
public:
|
||||
@@ -41,11 +42,27 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"rank_id",
|
||||
"slot",
|
||||
"effect_id",
|
||||
"base1",
|
||||
"base2",
|
||||
};
|
||||
}
|
||||
|
||||
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("aa_rank_effects");
|
||||
@@ -55,7 +72,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAaRankPrereqsRepository {
|
||||
public:
|
||||
@@ -37,11 +38,25 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"rank_id",
|
||||
"aa_id",
|
||||
"points",
|
||||
};
|
||||
}
|
||||
|
||||
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("aa_rank_prereqs");
|
||||
@@ -51,7 +66,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAaRanksRepository {
|
||||
public:
|
||||
@@ -57,11 +58,35 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"upper_hotkey_sid",
|
||||
"lower_hotkey_sid",
|
||||
"title_sid",
|
||||
"desc_sid",
|
||||
"cost",
|
||||
"level_req",
|
||||
"spell",
|
||||
"spell_type",
|
||||
"recast_time",
|
||||
"expansion",
|
||||
"prev_id",
|
||||
"next_id",
|
||||
};
|
||||
}
|
||||
|
||||
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("aa_ranks");
|
||||
@@ -71,7 +96,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAccountFlagsRepository {
|
||||
public:
|
||||
@@ -37,11 +38,25 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"p_accid",
|
||||
"p_flag",
|
||||
"p_value",
|
||||
};
|
||||
}
|
||||
|
||||
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("account_flags");
|
||||
@@ -51,7 +66,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAccountIpRepository {
|
||||
public:
|
||||
@@ -39,11 +40,26 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"accid",
|
||||
"ip",
|
||||
"count",
|
||||
"lastused",
|
||||
};
|
||||
}
|
||||
|
||||
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("account_ip");
|
||||
@@ -53,7 +69,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
@@ -74,7 +90,7 @@ public:
|
||||
entry.accid = 0;
|
||||
entry.ip = "";
|
||||
entry.count = 1;
|
||||
entry.lastused = "";
|
||||
entry.lastused = std::time(nullptr);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAccountRepository {
|
||||
public:
|
||||
@@ -32,11 +33,14 @@ public:
|
||||
std::string minilogin_ip;
|
||||
int hideme;
|
||||
int rulesflag;
|
||||
std::string suspendeduntil;
|
||||
time_t suspendeduntil;
|
||||
int time_creation;
|
||||
int expansion;
|
||||
std::string ban_reason;
|
||||
std::string suspend_reason;
|
||||
std::string crc_eqgame;
|
||||
std::string crc_skillcaps;
|
||||
std::string crc_basedata;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
@@ -66,6 +70,37 @@ public:
|
||||
"expansion",
|
||||
"ban_reason",
|
||||
"suspend_reason",
|
||||
"crc_eqgame",
|
||||
"crc_skillcaps",
|
||||
"crc_basedata",
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"name",
|
||||
"charname",
|
||||
"sharedplat",
|
||||
"password",
|
||||
"status",
|
||||
"ls_id",
|
||||
"lsaccount_id",
|
||||
"gmspeed",
|
||||
"revoked",
|
||||
"karma",
|
||||
"minilogin_ip",
|
||||
"hideme",
|
||||
"rulesflag",
|
||||
"UNIX_TIMESTAMP(suspendeduntil)",
|
||||
"time_creation",
|
||||
"expansion",
|
||||
"ban_reason",
|
||||
"suspend_reason",
|
||||
"crc_eqgame",
|
||||
"crc_skillcaps",
|
||||
"crc_basedata",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -74,6 +109,11 @@ public:
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string SelectColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", SelectColumns()));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("account");
|
||||
@@ -83,7 +123,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
@@ -115,11 +155,14 @@ public:
|
||||
entry.minilogin_ip = "";
|
||||
entry.hideme = 0;
|
||||
entry.rulesflag = 0;
|
||||
entry.suspendeduntil = "0000-00-00 00:00:00";
|
||||
entry.suspendeduntil = 0;
|
||||
entry.time_creation = 0;
|
||||
entry.expansion = 0;
|
||||
entry.ban_reason = "";
|
||||
entry.suspend_reason = "";
|
||||
entry.crc_eqgame = "";
|
||||
entry.crc_skillcaps = "";
|
||||
entry.crc_basedata = "";
|
||||
|
||||
return entry;
|
||||
}
|
||||
@@ -169,11 +212,14 @@ public:
|
||||
entry.minilogin_ip = row[11] ? row[11] : "";
|
||||
entry.hideme = atoi(row[12]);
|
||||
entry.rulesflag = atoi(row[13]);
|
||||
entry.suspendeduntil = row[14] ? row[14] : "";
|
||||
entry.suspendeduntil = strtoll(row[14] ? row[14] : "-1", nullptr, 10);
|
||||
entry.time_creation = atoi(row[15]);
|
||||
entry.expansion = atoi(row[16]);
|
||||
entry.ban_reason = row[17] ? row[17] : "";
|
||||
entry.suspend_reason = row[18] ? row[18] : "";
|
||||
entry.crc_eqgame = row[19] ? row[19] : "";
|
||||
entry.crc_skillcaps = row[20] ? row[20] : "";
|
||||
entry.crc_basedata = row[21] ? row[21] : "";
|
||||
|
||||
return entry;
|
||||
}
|
||||
@@ -220,11 +266,14 @@ public:
|
||||
update_values.push_back(columns[11] + " = '" + EscapeString(account_entry.minilogin_ip) + "'");
|
||||
update_values.push_back(columns[12] + " = " + std::to_string(account_entry.hideme));
|
||||
update_values.push_back(columns[13] + " = " + std::to_string(account_entry.rulesflag));
|
||||
update_values.push_back(columns[14] + " = '" + EscapeString(account_entry.suspendeduntil) + "'");
|
||||
update_values.push_back(columns[14] + " = FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")");
|
||||
update_values.push_back(columns[15] + " = " + std::to_string(account_entry.time_creation));
|
||||
update_values.push_back(columns[16] + " = " + std::to_string(account_entry.expansion));
|
||||
update_values.push_back(columns[17] + " = '" + EscapeString(account_entry.ban_reason) + "'");
|
||||
update_values.push_back(columns[18] + " = '" + EscapeString(account_entry.suspend_reason) + "'");
|
||||
update_values.push_back(columns[19] + " = '" + EscapeString(account_entry.crc_eqgame) + "'");
|
||||
update_values.push_back(columns[20] + " = '" + EscapeString(account_entry.crc_skillcaps) + "'");
|
||||
update_values.push_back(columns[21] + " = '" + EscapeString(account_entry.crc_basedata) + "'");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@@ -260,11 +309,14 @@ public:
|
||||
insert_values.push_back("'" + EscapeString(account_entry.minilogin_ip) + "'");
|
||||
insert_values.push_back(std::to_string(account_entry.hideme));
|
||||
insert_values.push_back(std::to_string(account_entry.rulesflag));
|
||||
insert_values.push_back("'" + EscapeString(account_entry.suspendeduntil) + "'");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")");
|
||||
insert_values.push_back(std::to_string(account_entry.time_creation));
|
||||
insert_values.push_back(std::to_string(account_entry.expansion));
|
||||
insert_values.push_back("'" + EscapeString(account_entry.ban_reason) + "'");
|
||||
insert_values.push_back("'" + EscapeString(account_entry.suspend_reason) + "'");
|
||||
insert_values.push_back("'" + EscapeString(account_entry.crc_eqgame) + "'");
|
||||
insert_values.push_back("'" + EscapeString(account_entry.crc_skillcaps) + "'");
|
||||
insert_values.push_back("'" + EscapeString(account_entry.crc_basedata) + "'");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@@ -308,11 +360,14 @@ public:
|
||||
insert_values.push_back("'" + EscapeString(account_entry.minilogin_ip) + "'");
|
||||
insert_values.push_back(std::to_string(account_entry.hideme));
|
||||
insert_values.push_back(std::to_string(account_entry.rulesflag));
|
||||
insert_values.push_back("'" + EscapeString(account_entry.suspendeduntil) + "'");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")");
|
||||
insert_values.push_back(std::to_string(account_entry.time_creation));
|
||||
insert_values.push_back(std::to_string(account_entry.expansion));
|
||||
insert_values.push_back("'" + EscapeString(account_entry.ban_reason) + "'");
|
||||
insert_values.push_back("'" + EscapeString(account_entry.suspend_reason) + "'");
|
||||
insert_values.push_back("'" + EscapeString(account_entry.crc_eqgame) + "'");
|
||||
insert_values.push_back("'" + EscapeString(account_entry.crc_skillcaps) + "'");
|
||||
insert_values.push_back("'" + EscapeString(account_entry.crc_basedata) + "'");
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
@@ -360,11 +415,14 @@ public:
|
||||
entry.minilogin_ip = row[11] ? row[11] : "";
|
||||
entry.hideme = atoi(row[12]);
|
||||
entry.rulesflag = atoi(row[13]);
|
||||
entry.suspendeduntil = row[14] ? row[14] : "";
|
||||
entry.suspendeduntil = strtoll(row[14] ? row[14] : "-1", nullptr, 10);
|
||||
entry.time_creation = atoi(row[15]);
|
||||
entry.expansion = atoi(row[16]);
|
||||
entry.ban_reason = row[17] ? row[17] : "";
|
||||
entry.suspend_reason = row[18] ? row[18] : "";
|
||||
entry.crc_eqgame = row[19] ? row[19] : "";
|
||||
entry.crc_skillcaps = row[20] ? row[20] : "";
|
||||
entry.crc_basedata = row[21] ? row[21] : "";
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
@@ -403,11 +461,14 @@ public:
|
||||
entry.minilogin_ip = row[11] ? row[11] : "";
|
||||
entry.hideme = atoi(row[12]);
|
||||
entry.rulesflag = atoi(row[13]);
|
||||
entry.suspendeduntil = row[14] ? row[14] : "";
|
||||
entry.suspendeduntil = strtoll(row[14] ? row[14] : "-1", nullptr, 10);
|
||||
entry.time_creation = atoi(row[15]);
|
||||
entry.expansion = atoi(row[16]);
|
||||
entry.ban_reason = row[17] ? row[17] : "";
|
||||
entry.suspend_reason = row[18] ? row[18] : "";
|
||||
entry.crc_eqgame = row[19] ? row[19] : "";
|
||||
entry.crc_skillcaps = row[20] ? row[20] : "";
|
||||
entry.crc_basedata = row[21] ? row[21] : "";
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAccountRewardsRepository {
|
||||
public:
|
||||
@@ -37,11 +38,25 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"account_id",
|
||||
"reward_id",
|
||||
"amount",
|
||||
};
|
||||
}
|
||||
|
||||
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("account_rewards");
|
||||
@@ -51,7 +66,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAdventureDetailsRepository {
|
||||
public:
|
||||
@@ -49,11 +50,31 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"adventure_id",
|
||||
"instance_id",
|
||||
"count",
|
||||
"assassinate_count",
|
||||
"status",
|
||||
"time_created",
|
||||
"time_zoned",
|
||||
"time_completed",
|
||||
};
|
||||
}
|
||||
|
||||
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("adventure_details");
|
||||
@@ -63,7 +84,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAdventureMembersRepository {
|
||||
public:
|
||||
@@ -35,11 +36,24 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"charid",
|
||||
};
|
||||
}
|
||||
|
||||
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("adventure_members");
|
||||
@@ -49,7 +63,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAdventureStatsRepository {
|
||||
public:
|
||||
@@ -53,11 +54,33 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"player_id",
|
||||
"guk_wins",
|
||||
"mir_wins",
|
||||
"mmc_wins",
|
||||
"ruj_wins",
|
||||
"tak_wins",
|
||||
"guk_losses",
|
||||
"mir_losses",
|
||||
"mmc_losses",
|
||||
"ruj_losses",
|
||||
"tak_losses",
|
||||
};
|
||||
}
|
||||
|
||||
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("adventure_stats");
|
||||
@@ -67,7 +90,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAdventureTemplateEntryFlavorRepository {
|
||||
public:
|
||||
@@ -35,11 +36,24 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"text",
|
||||
};
|
||||
}
|
||||
|
||||
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("adventure_template_entry_flavor");
|
||||
@@ -49,7 +63,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAdventureTemplateEntryRepository {
|
||||
public:
|
||||
@@ -35,11 +36,24 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"template_id",
|
||||
};
|
||||
}
|
||||
|
||||
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("adventure_template_entry");
|
||||
@@ -49,7 +63,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAdventureTemplateRepository {
|
||||
public:
|
||||
@@ -97,11 +98,55 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"zone",
|
||||
"zone_version",
|
||||
"is_hard",
|
||||
"is_raid",
|
||||
"min_level",
|
||||
"max_level",
|
||||
"type",
|
||||
"type_data",
|
||||
"type_count",
|
||||
"assa_x",
|
||||
"assa_y",
|
||||
"assa_z",
|
||||
"assa_h",
|
||||
"text",
|
||||
"duration",
|
||||
"zone_in_time",
|
||||
"win_points",
|
||||
"lose_points",
|
||||
"theme",
|
||||
"zone_in_zone_id",
|
||||
"zone_in_x",
|
||||
"zone_in_y",
|
||||
"zone_in_object_id",
|
||||
"dest_x",
|
||||
"dest_y",
|
||||
"dest_z",
|
||||
"dest_h",
|
||||
"graveyard_zone_id",
|
||||
"graveyard_x",
|
||||
"graveyard_y",
|
||||
"graveyard_z",
|
||||
"graveyard_radius",
|
||||
};
|
||||
}
|
||||
|
||||
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("adventure_template");
|
||||
@@ -111,7 +156,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
@@ -148,7 +193,7 @@ public:
|
||||
entry.zone_in_time = 1800;
|
||||
entry.win_points = 0;
|
||||
entry.lose_points = 0;
|
||||
entry.theme = LDoNThemes::GUK;
|
||||
entry.theme = 1;
|
||||
entry.zone_in_zone_id = 0;
|
||||
entry.zone_in_x = 0;
|
||||
entry.zone_in_y = 0;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAlternateCurrencyRepository {
|
||||
public:
|
||||
@@ -35,11 +36,24 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"item_id",
|
||||
};
|
||||
}
|
||||
|
||||
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("alternate_currency");
|
||||
@@ -49,7 +63,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseAurasRepository {
|
||||
public:
|
||||
@@ -53,11 +54,33 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"type",
|
||||
"npc_type",
|
||||
"name",
|
||||
"spell_id",
|
||||
"distance",
|
||||
"aura_type",
|
||||
"spawn_type",
|
||||
"movement",
|
||||
"duration",
|
||||
"icon",
|
||||
"cast_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("auras");
|
||||
@@ -67,7 +90,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseBaseDataRepository {
|
||||
public:
|
||||
@@ -51,11 +52,32 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"level",
|
||||
"`class`",
|
||||
"hp",
|
||||
"mana",
|
||||
"end",
|
||||
"unk1",
|
||||
"unk2",
|
||||
"hp_fac",
|
||||
"mana_fac",
|
||||
"end_fac",
|
||||
};
|
||||
}
|
||||
|
||||
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("base_data");
|
||||
@@ -65,7 +87,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseBlockedSpellsRepository {
|
||||
public:
|
||||
@@ -55,11 +56,34 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"spellid",
|
||||
"type",
|
||||
"zoneid",
|
||||
"x",
|
||||
"y",
|
||||
"z",
|
||||
"x_diff",
|
||||
"y_diff",
|
||||
"z_diff",
|
||||
"message",
|
||||
"description",
|
||||
};
|
||||
}
|
||||
|
||||
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("blocked_spells");
|
||||
@@ -69,7 +93,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
/**
|
||||
* 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_BOOKS_REPOSITORY_H
|
||||
#define EQEMU_BASE_BOOKS_REPOSITORY_H
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseBooksRepository {
|
||||
public:
|
||||
struct Books {
|
||||
int id;
|
||||
std::string name;
|
||||
std::string txtfile;
|
||||
int language;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"name",
|
||||
"txtfile",
|
||||
"language",
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"name",
|
||||
"txtfile",
|
||||
"language",
|
||||
};
|
||||
}
|
||||
|
||||
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("books");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static Books NewEntity()
|
||||
{
|
||||
Books entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.name = "";
|
||||
entry.txtfile = "";
|
||||
entry.language = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static Books GetBooksEntry(
|
||||
const std::vector<Books> &bookss,
|
||||
int books_id
|
||||
)
|
||||
{
|
||||
for (auto &books : bookss) {
|
||||
if (books.id == books_id) {
|
||||
return books;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static Books FindOne(
|
||||
Database& db,
|
||||
int books_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
books_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
Books entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.name = row[1] ? row[1] : "";
|
||||
entry.txtfile = row[2] ? row[2] : "";
|
||||
entry.language = atoi(row[3]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
Database& db,
|
||||
int books_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
books_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
Books books_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[1] + " = '" + EscapeString(books_entry.name) + "'");
|
||||
update_values.push_back(columns[2] + " = '" + EscapeString(books_entry.txtfile) + "'");
|
||||
update_values.push_back(columns[3] + " = " + std::to_string(books_entry.language));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
books_entry.id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static Books InsertOne(
|
||||
Database& db,
|
||||
Books books_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(books_entry.id));
|
||||
insert_values.push_back("'" + EscapeString(books_entry.name) + "'");
|
||||
insert_values.push_back("'" + EscapeString(books_entry.txtfile) + "'");
|
||||
insert_values.push_back(std::to_string(books_entry.language));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
books_entry.id = results.LastInsertedID();
|
||||
return books_entry;
|
||||
}
|
||||
|
||||
books_entry = NewEntity();
|
||||
|
||||
return books_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<Books> books_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &books_entry: books_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(books_entry.id));
|
||||
insert_values.push_back("'" + EscapeString(books_entry.name) + "'");
|
||||
insert_values.push_back("'" + EscapeString(books_entry.txtfile) + "'");
|
||||
insert_values.push_back(std::to_string(books_entry.language));
|
||||
|
||||
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<Books> All(Database& db)
|
||||
{
|
||||
std::vector<Books> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Books entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.name = row[1] ? row[1] : "";
|
||||
entry.txtfile = row[2] ? row[2] : "";
|
||||
entry.language = atoi(row[3]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<Books> GetWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
std::vector<Books> 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) {
|
||||
Books entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.name = row[1] ? row[1] : "";
|
||||
entry.txtfile = row[2] ? row[2] : "";
|
||||
entry.language = atoi(row[3]);
|
||||
|
||||
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_BOOKS_REPOSITORY_H
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseBugReportsRepository {
|
||||
public:
|
||||
@@ -45,9 +46,9 @@ public:
|
||||
int _unknown_value;
|
||||
std::string bug_report;
|
||||
std::string system_info;
|
||||
std::string report_datetime;
|
||||
time_t report_datetime;
|
||||
int bug_status;
|
||||
std::string last_review;
|
||||
time_t last_review;
|
||||
std::string last_reviewer;
|
||||
std::string reviewer_notes;
|
||||
};
|
||||
@@ -95,11 +96,54 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"zone",
|
||||
"client_version_id",
|
||||
"client_version_name",
|
||||
"account_id",
|
||||
"character_id",
|
||||
"character_name",
|
||||
"reporter_spoof",
|
||||
"category_id",
|
||||
"category_name",
|
||||
"reporter_name",
|
||||
"ui_path",
|
||||
"pos_x",
|
||||
"pos_y",
|
||||
"pos_z",
|
||||
"heading",
|
||||
"time_played",
|
||||
"target_id",
|
||||
"target_name",
|
||||
"optional_info_mask",
|
||||
"_can_duplicate",
|
||||
"_crash_bug",
|
||||
"_target_info",
|
||||
"_character_flags",
|
||||
"_unknown_value",
|
||||
"bug_report",
|
||||
"system_info",
|
||||
"UNIX_TIMESTAMP(report_datetime)",
|
||||
"bug_status",
|
||||
"UNIX_TIMESTAMP(last_review)",
|
||||
"last_reviewer",
|
||||
"reviewer_notes",
|
||||
};
|
||||
}
|
||||
|
||||
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("bug_reports");
|
||||
@@ -109,7 +153,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
@@ -154,9 +198,9 @@ public:
|
||||
entry._unknown_value = 0;
|
||||
entry.bug_report = "";
|
||||
entry.system_info = "";
|
||||
entry.report_datetime = "";
|
||||
entry.report_datetime = std::time(nullptr);
|
||||
entry.bug_status = 0;
|
||||
entry.last_review = "";
|
||||
entry.last_review = std::time(nullptr);
|
||||
entry.last_reviewer = "None";
|
||||
entry.reviewer_notes = "";
|
||||
|
||||
@@ -221,9 +265,9 @@ public:
|
||||
entry._unknown_value = atoi(row[24]);
|
||||
entry.bug_report = row[25] ? row[25] : "";
|
||||
entry.system_info = row[26] ? row[26] : "";
|
||||
entry.report_datetime = row[27] ? row[27] : "";
|
||||
entry.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10);
|
||||
entry.bug_status = atoi(row[28]);
|
||||
entry.last_review = row[29] ? row[29] : "";
|
||||
entry.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10);
|
||||
entry.last_reviewer = row[30] ? row[30] : "";
|
||||
entry.reviewer_notes = row[31] ? row[31] : "";
|
||||
|
||||
@@ -285,9 +329,9 @@ public:
|
||||
update_values.push_back(columns[24] + " = " + std::to_string(bug_reports_entry._unknown_value));
|
||||
update_values.push_back(columns[25] + " = '" + EscapeString(bug_reports_entry.bug_report) + "'");
|
||||
update_values.push_back(columns[26] + " = '" + EscapeString(bug_reports_entry.system_info) + "'");
|
||||
update_values.push_back(columns[27] + " = '" + EscapeString(bug_reports_entry.report_datetime) + "'");
|
||||
update_values.push_back(columns[27] + " = FROM_UNIXTIME(" + (bug_reports_entry.report_datetime > 0 ? std::to_string(bug_reports_entry.report_datetime) : "null") + ")");
|
||||
update_values.push_back(columns[28] + " = " + std::to_string(bug_reports_entry.bug_status));
|
||||
update_values.push_back(columns[29] + " = '" + EscapeString(bug_reports_entry.last_review) + "'");
|
||||
update_values.push_back(columns[29] + " = FROM_UNIXTIME(" + (bug_reports_entry.last_review > 0 ? std::to_string(bug_reports_entry.last_review) : "null") + ")");
|
||||
update_values.push_back(columns[30] + " = '" + EscapeString(bug_reports_entry.last_reviewer) + "'");
|
||||
update_values.push_back(columns[31] + " = '" + EscapeString(bug_reports_entry.reviewer_notes) + "'");
|
||||
|
||||
@@ -338,9 +382,9 @@ public:
|
||||
insert_values.push_back(std::to_string(bug_reports_entry._unknown_value));
|
||||
insert_values.push_back("'" + EscapeString(bug_reports_entry.bug_report) + "'");
|
||||
insert_values.push_back("'" + EscapeString(bug_reports_entry.system_info) + "'");
|
||||
insert_values.push_back("'" + EscapeString(bug_reports_entry.report_datetime) + "'");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.report_datetime > 0 ? std::to_string(bug_reports_entry.report_datetime) : "null") + ")");
|
||||
insert_values.push_back(std::to_string(bug_reports_entry.bug_status));
|
||||
insert_values.push_back("'" + EscapeString(bug_reports_entry.last_review) + "'");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.last_review > 0 ? std::to_string(bug_reports_entry.last_review) : "null") + ")");
|
||||
insert_values.push_back("'" + EscapeString(bug_reports_entry.last_reviewer) + "'");
|
||||
insert_values.push_back("'" + EscapeString(bug_reports_entry.reviewer_notes) + "'");
|
||||
|
||||
@@ -399,9 +443,9 @@ public:
|
||||
insert_values.push_back(std::to_string(bug_reports_entry._unknown_value));
|
||||
insert_values.push_back("'" + EscapeString(bug_reports_entry.bug_report) + "'");
|
||||
insert_values.push_back("'" + EscapeString(bug_reports_entry.system_info) + "'");
|
||||
insert_values.push_back("'" + EscapeString(bug_reports_entry.report_datetime) + "'");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.report_datetime > 0 ? std::to_string(bug_reports_entry.report_datetime) : "null") + ")");
|
||||
insert_values.push_back(std::to_string(bug_reports_entry.bug_status));
|
||||
insert_values.push_back("'" + EscapeString(bug_reports_entry.last_review) + "'");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.last_review > 0 ? std::to_string(bug_reports_entry.last_review) : "null") + ")");
|
||||
insert_values.push_back("'" + EscapeString(bug_reports_entry.last_reviewer) + "'");
|
||||
insert_values.push_back("'" + EscapeString(bug_reports_entry.reviewer_notes) + "'");
|
||||
|
||||
@@ -464,9 +508,9 @@ public:
|
||||
entry._unknown_value = atoi(row[24]);
|
||||
entry.bug_report = row[25] ? row[25] : "";
|
||||
entry.system_info = row[26] ? row[26] : "";
|
||||
entry.report_datetime = row[27] ? row[27] : "";
|
||||
entry.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10);
|
||||
entry.bug_status = atoi(row[28]);
|
||||
entry.last_review = row[29] ? row[29] : "";
|
||||
entry.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10);
|
||||
entry.last_reviewer = row[30] ? row[30] : "";
|
||||
entry.reviewer_notes = row[31] ? row[31] : "";
|
||||
|
||||
@@ -520,9 +564,9 @@ public:
|
||||
entry._unknown_value = atoi(row[24]);
|
||||
entry.bug_report = row[25] ? row[25] : "";
|
||||
entry.system_info = row[26] ? row[26] : "";
|
||||
entry.report_datetime = row[27] ? row[27] : "";
|
||||
entry.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10);
|
||||
entry.bug_status = atoi(row[28]);
|
||||
entry.last_review = row[29] ? row[29] : "";
|
||||
entry.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10);
|
||||
entry.last_reviewer = row[30] ? row[30] : "";
|
||||
entry.reviewer_notes = row[31] ? row[31] : "";
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseBugsRepository {
|
||||
public:
|
||||
@@ -57,11 +58,35 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"zone",
|
||||
"name",
|
||||
"ui",
|
||||
"x",
|
||||
"y",
|
||||
"z",
|
||||
"type",
|
||||
"flag",
|
||||
"target",
|
||||
"bug",
|
||||
"date",
|
||||
"status",
|
||||
};
|
||||
}
|
||||
|
||||
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("bugs");
|
||||
@@ -71,7 +96,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseBuyerRepository {
|
||||
public:
|
||||
@@ -43,11 +44,28 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"charid",
|
||||
"buyslot",
|
||||
"itemid",
|
||||
"itemname",
|
||||
"quantity",
|
||||
"price",
|
||||
};
|
||||
}
|
||||
|
||||
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("buyer");
|
||||
@@ -57,7 +75,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharCreateCombinationsRepository {
|
||||
public:
|
||||
@@ -43,11 +44,28 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"allocation_id",
|
||||
"race",
|
||||
"`class`",
|
||||
"deity",
|
||||
"start_zone",
|
||||
"expansions_req",
|
||||
};
|
||||
}
|
||||
|
||||
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("char_create_combinations");
|
||||
@@ -57,7 +75,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharCreatePointAllocationsRepository {
|
||||
public:
|
||||
@@ -61,11 +62,37 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"base_str",
|
||||
"base_sta",
|
||||
"base_dex",
|
||||
"base_agi",
|
||||
"base_int",
|
||||
"base_wis",
|
||||
"base_cha",
|
||||
"alloc_str",
|
||||
"alloc_sta",
|
||||
"alloc_dex",
|
||||
"alloc_agi",
|
||||
"alloc_int",
|
||||
"alloc_wis",
|
||||
"alloc_cha",
|
||||
};
|
||||
}
|
||||
|
||||
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("char_create_point_allocations");
|
||||
@@ -75,7 +102,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharRecipeListRepository {
|
||||
public:
|
||||
@@ -37,11 +38,25 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"char_id",
|
||||
"recipe_id",
|
||||
"madecount",
|
||||
};
|
||||
}
|
||||
|
||||
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("char_recipe_list");
|
||||
@@ -51,7 +66,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterActivitiesRepository {
|
||||
public:
|
||||
@@ -41,11 +42,27 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"charid",
|
||||
"taskid",
|
||||
"activityid",
|
||||
"donecount",
|
||||
"completed",
|
||||
};
|
||||
}
|
||||
|
||||
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_activities");
|
||||
@@ -55,7 +72,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterAltCurrencyRepository {
|
||||
public:
|
||||
@@ -37,11 +38,25 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"char_id",
|
||||
"currency_id",
|
||||
"amount",
|
||||
};
|
||||
}
|
||||
|
||||
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_alt_currency");
|
||||
@@ -51,7 +66,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterAlternateAbilitiesRepository {
|
||||
public:
|
||||
@@ -39,11 +40,26 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"aa_id",
|
||||
"aa_value",
|
||||
"charges",
|
||||
};
|
||||
}
|
||||
|
||||
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_alternate_abilities");
|
||||
@@ -53,7 +69,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterAurasRepository {
|
||||
public:
|
||||
@@ -37,11 +38,25 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"slot",
|
||||
"spell_id",
|
||||
};
|
||||
}
|
||||
|
||||
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_auras");
|
||||
@@ -51,7 +66,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterBandolierRepository {
|
||||
public:
|
||||
@@ -43,11 +44,28 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"bandolier_id",
|
||||
"bandolier_slot",
|
||||
"item_id",
|
||||
"icon",
|
||||
"bandolier_name",
|
||||
};
|
||||
}
|
||||
|
||||
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_bandolier");
|
||||
@@ -57,7 +75,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterBindRepository {
|
||||
public:
|
||||
@@ -47,11 +48,30 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"slot",
|
||||
"zone_id",
|
||||
"instance_id",
|
||||
"x",
|
||||
"y",
|
||||
"z",
|
||||
"heading",
|
||||
};
|
||||
}
|
||||
|
||||
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_bind");
|
||||
@@ -61,7 +81,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterBuffsRepository {
|
||||
public:
|
||||
@@ -65,11 +66,39 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"character_id",
|
||||
"slot_id",
|
||||
"spell_id",
|
||||
"caster_level",
|
||||
"caster_name",
|
||||
"ticsremaining",
|
||||
"counters",
|
||||
"numhits",
|
||||
"melee_rune",
|
||||
"magic_rune",
|
||||
"persistent",
|
||||
"dot_rune",
|
||||
"caston_x",
|
||||
"caston_y",
|
||||
"caston_z",
|
||||
"ExtraDIChance",
|
||||
"instrument_mod",
|
||||
};
|
||||
}
|
||||
|
||||
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_buffs");
|
||||
@@ -79,7 +108,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterCorpseItemsRepository {
|
||||
public:
|
||||
@@ -53,11 +54,33 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"corpse_id",
|
||||
"equip_slot",
|
||||
"item_id",
|
||||
"charges",
|
||||
"aug_1",
|
||||
"aug_2",
|
||||
"aug_3",
|
||||
"aug_4",
|
||||
"aug_5",
|
||||
"aug_6",
|
||||
"attuned",
|
||||
};
|
||||
}
|
||||
|
||||
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_corpse_items");
|
||||
@@ -67,7 +90,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterCorpsesRepository {
|
||||
public:
|
||||
@@ -27,7 +28,7 @@ public:
|
||||
float y;
|
||||
float z;
|
||||
float heading;
|
||||
std::string time_of_death;
|
||||
time_t time_of_death;
|
||||
int guild_consent_id;
|
||||
int is_rezzed;
|
||||
int is_buried;
|
||||
@@ -125,11 +126,69 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"charid",
|
||||
"charname",
|
||||
"zone_id",
|
||||
"instance_id",
|
||||
"x",
|
||||
"y",
|
||||
"z",
|
||||
"heading",
|
||||
"UNIX_TIMESTAMP(time_of_death)",
|
||||
"guild_consent_id",
|
||||
"is_rezzed",
|
||||
"is_buried",
|
||||
"was_at_graveyard",
|
||||
"is_locked",
|
||||
"exp",
|
||||
"size",
|
||||
"level",
|
||||
"race",
|
||||
"gender",
|
||||
"`class`",
|
||||
"deity",
|
||||
"texture",
|
||||
"helm_texture",
|
||||
"copper",
|
||||
"silver",
|
||||
"gold",
|
||||
"platinum",
|
||||
"hair_color",
|
||||
"beard_color",
|
||||
"eye_color_1",
|
||||
"eye_color_2",
|
||||
"hair_style",
|
||||
"face",
|
||||
"beard",
|
||||
"drakkin_heritage",
|
||||
"drakkin_tattoo",
|
||||
"drakkin_details",
|
||||
"wc_1",
|
||||
"wc_2",
|
||||
"wc_3",
|
||||
"wc_4",
|
||||
"wc_5",
|
||||
"wc_6",
|
||||
"wc_7",
|
||||
"wc_8",
|
||||
"wc_9",
|
||||
};
|
||||
}
|
||||
|
||||
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_corpses");
|
||||
@@ -139,7 +198,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
@@ -166,7 +225,7 @@ public:
|
||||
entry.y = 0;
|
||||
entry.z = 0;
|
||||
entry.heading = 0;
|
||||
entry.time_of_death = "0000-00-00 00:00:00";
|
||||
entry.time_of_death = 0;
|
||||
entry.guild_consent_id = 0;
|
||||
entry.is_rezzed = 0;
|
||||
entry.is_buried = 0;
|
||||
@@ -248,7 +307,7 @@ public:
|
||||
entry.y = static_cast<float>(atof(row[6]));
|
||||
entry.z = static_cast<float>(atof(row[7]));
|
||||
entry.heading = static_cast<float>(atof(row[8]));
|
||||
entry.time_of_death = row[9] ? row[9] : "";
|
||||
entry.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10);
|
||||
entry.guild_consent_id = atoi(row[10]);
|
||||
entry.is_rezzed = atoi(row[11]);
|
||||
entry.is_buried = atoi(row[12]);
|
||||
@@ -327,7 +386,7 @@ public:
|
||||
update_values.push_back(columns[6] + " = " + std::to_string(character_corpses_entry.y));
|
||||
update_values.push_back(columns[7] + " = " + std::to_string(character_corpses_entry.z));
|
||||
update_values.push_back(columns[8] + " = " + std::to_string(character_corpses_entry.heading));
|
||||
update_values.push_back(columns[9] + " = '" + EscapeString(character_corpses_entry.time_of_death) + "'");
|
||||
update_values.push_back(columns[9] + " = FROM_UNIXTIME(" + (character_corpses_entry.time_of_death > 0 ? std::to_string(character_corpses_entry.time_of_death) : "null") + ")");
|
||||
update_values.push_back(columns[10] + " = " + std::to_string(character_corpses_entry.guild_consent_id));
|
||||
update_values.push_back(columns[11] + " = " + std::to_string(character_corpses_entry.is_rezzed));
|
||||
update_values.push_back(columns[12] + " = " + std::to_string(character_corpses_entry.is_buried));
|
||||
@@ -395,7 +454,7 @@ public:
|
||||
insert_values.push_back(std::to_string(character_corpses_entry.y));
|
||||
insert_values.push_back(std::to_string(character_corpses_entry.z));
|
||||
insert_values.push_back(std::to_string(character_corpses_entry.heading));
|
||||
insert_values.push_back("'" + EscapeString(character_corpses_entry.time_of_death) + "'");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (character_corpses_entry.time_of_death > 0 ? std::to_string(character_corpses_entry.time_of_death) : "null") + ")");
|
||||
insert_values.push_back(std::to_string(character_corpses_entry.guild_consent_id));
|
||||
insert_values.push_back(std::to_string(character_corpses_entry.is_rezzed));
|
||||
insert_values.push_back(std::to_string(character_corpses_entry.is_buried));
|
||||
@@ -471,7 +530,7 @@ public:
|
||||
insert_values.push_back(std::to_string(character_corpses_entry.y));
|
||||
insert_values.push_back(std::to_string(character_corpses_entry.z));
|
||||
insert_values.push_back(std::to_string(character_corpses_entry.heading));
|
||||
insert_values.push_back("'" + EscapeString(character_corpses_entry.time_of_death) + "'");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (character_corpses_entry.time_of_death > 0 ? std::to_string(character_corpses_entry.time_of_death) : "null") + ")");
|
||||
insert_values.push_back(std::to_string(character_corpses_entry.guild_consent_id));
|
||||
insert_values.push_back(std::to_string(character_corpses_entry.is_rezzed));
|
||||
insert_values.push_back(std::to_string(character_corpses_entry.is_buried));
|
||||
@@ -551,7 +610,7 @@ public:
|
||||
entry.y = static_cast<float>(atof(row[6]));
|
||||
entry.z = static_cast<float>(atof(row[7]));
|
||||
entry.heading = static_cast<float>(atof(row[8]));
|
||||
entry.time_of_death = row[9] ? row[9] : "";
|
||||
entry.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10);
|
||||
entry.guild_consent_id = atoi(row[10]);
|
||||
entry.is_rezzed = atoi(row[11]);
|
||||
entry.is_buried = atoi(row[12]);
|
||||
@@ -622,7 +681,7 @@ public:
|
||||
entry.y = static_cast<float>(atof(row[6]));
|
||||
entry.z = static_cast<float>(atof(row[7]));
|
||||
entry.heading = static_cast<float>(atof(row[8]));
|
||||
entry.time_of_death = row[9] ? row[9] : "";
|
||||
entry.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10);
|
||||
entry.guild_consent_id = atoi(row[10]);
|
||||
entry.is_rezzed = atoi(row[11]);
|
||||
entry.is_buried = atoi(row[12]);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterCurrencyRepository {
|
||||
public:
|
||||
@@ -65,11 +66,39 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"platinum",
|
||||
"gold",
|
||||
"silver",
|
||||
"copper",
|
||||
"platinum_bank",
|
||||
"gold_bank",
|
||||
"silver_bank",
|
||||
"copper_bank",
|
||||
"platinum_cursor",
|
||||
"gold_cursor",
|
||||
"silver_cursor",
|
||||
"copper_cursor",
|
||||
"radiant_crystals",
|
||||
"career_radiant_crystals",
|
||||
"ebon_crystals",
|
||||
"career_ebon_crystals",
|
||||
};
|
||||
}
|
||||
|
||||
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_currency");
|
||||
@@ -79,7 +108,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterDataRepository {
|
||||
public:
|
||||
@@ -119,7 +120,7 @@ public:
|
||||
int aa_points_spent_old;
|
||||
int aa_points_old;
|
||||
int e_last_invsnapshot;
|
||||
std::string deleted_at;
|
||||
time_t deleted_at;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
@@ -235,11 +236,124 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"account_id",
|
||||
"name",
|
||||
"last_name",
|
||||
"title",
|
||||
"suffix",
|
||||
"zone_id",
|
||||
"zone_instance",
|
||||
"y",
|
||||
"x",
|
||||
"z",
|
||||
"heading",
|
||||
"gender",
|
||||
"race",
|
||||
"`class`",
|
||||
"level",
|
||||
"deity",
|
||||
"birthday",
|
||||
"last_login",
|
||||
"time_played",
|
||||
"level2",
|
||||
"anon",
|
||||
"gm",
|
||||
"face",
|
||||
"hair_color",
|
||||
"hair_style",
|
||||
"beard",
|
||||
"beard_color",
|
||||
"eye_color_1",
|
||||
"eye_color_2",
|
||||
"drakkin_heritage",
|
||||
"drakkin_tattoo",
|
||||
"drakkin_details",
|
||||
"ability_time_seconds",
|
||||
"ability_number",
|
||||
"ability_time_minutes",
|
||||
"ability_time_hours",
|
||||
"exp",
|
||||
"aa_points_spent",
|
||||
"aa_exp",
|
||||
"aa_points",
|
||||
"group_leadership_exp",
|
||||
"raid_leadership_exp",
|
||||
"group_leadership_points",
|
||||
"raid_leadership_points",
|
||||
"points",
|
||||
"cur_hp",
|
||||
"mana",
|
||||
"endurance",
|
||||
"intoxication",
|
||||
"str",
|
||||
"sta",
|
||||
"cha",
|
||||
"dex",
|
||||
"`int`",
|
||||
"agi",
|
||||
"wis",
|
||||
"zone_change_count",
|
||||
"toxicity",
|
||||
"hunger_level",
|
||||
"thirst_level",
|
||||
"ability_up",
|
||||
"ldon_points_guk",
|
||||
"ldon_points_mir",
|
||||
"ldon_points_mmc",
|
||||
"ldon_points_ruj",
|
||||
"ldon_points_tak",
|
||||
"ldon_points_available",
|
||||
"tribute_time_remaining",
|
||||
"career_tribute_points",
|
||||
"tribute_points",
|
||||
"tribute_active",
|
||||
"pvp_status",
|
||||
"pvp_kills",
|
||||
"pvp_deaths",
|
||||
"pvp_current_points",
|
||||
"pvp_career_points",
|
||||
"pvp_best_kill_streak",
|
||||
"pvp_worst_death_streak",
|
||||
"pvp_current_kill_streak",
|
||||
"pvp2",
|
||||
"pvp_type",
|
||||
"show_helm",
|
||||
"group_auto_consent",
|
||||
"raid_auto_consent",
|
||||
"guild_auto_consent",
|
||||
"leadership_exp_on",
|
||||
"RestTimer",
|
||||
"air_remaining",
|
||||
"autosplit_enabled",
|
||||
"lfp",
|
||||
"lfg",
|
||||
"mailkey",
|
||||
"xtargets",
|
||||
"firstlogon",
|
||||
"e_aa_effects",
|
||||
"e_percent_to_aa",
|
||||
"e_expended_aa_spent",
|
||||
"aa_points_spent_old",
|
||||
"aa_points_old",
|
||||
"e_last_invsnapshot",
|
||||
"UNIX_TIMESTAMP(deleted_at)",
|
||||
};
|
||||
}
|
||||
|
||||
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_data");
|
||||
@@ -249,7 +363,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
@@ -368,7 +482,7 @@ public:
|
||||
entry.aa_points_spent_old = 0;
|
||||
entry.aa_points_old = 0;
|
||||
entry.e_last_invsnapshot = 0;
|
||||
entry.deleted_at = "";
|
||||
entry.deleted_at = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
@@ -505,7 +619,7 @@ public:
|
||||
entry.aa_points_spent_old = atoi(row[98]);
|
||||
entry.aa_points_old = atoi(row[99]);
|
||||
entry.e_last_invsnapshot = atoi(row[100]);
|
||||
entry.deleted_at = row[101] ? row[101] : "";
|
||||
entry.deleted_at = strtoll(row[101] ? row[101] : "-1", nullptr, 10);
|
||||
|
||||
return entry;
|
||||
}
|
||||
@@ -639,7 +753,7 @@ public:
|
||||
update_values.push_back(columns[98] + " = " + std::to_string(character_data_entry.aa_points_spent_old));
|
||||
update_values.push_back(columns[99] + " = " + std::to_string(character_data_entry.aa_points_old));
|
||||
update_values.push_back(columns[100] + " = " + std::to_string(character_data_entry.e_last_invsnapshot));
|
||||
update_values.push_back(columns[101] + " = '" + EscapeString(character_data_entry.deleted_at) + "'");
|
||||
update_values.push_back(columns[101] + " = FROM_UNIXTIME(" + (character_data_entry.deleted_at > 0 ? std::to_string(character_data_entry.deleted_at) : "null") + ")");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@@ -762,7 +876,7 @@ public:
|
||||
insert_values.push_back(std::to_string(character_data_entry.aa_points_spent_old));
|
||||
insert_values.push_back(std::to_string(character_data_entry.aa_points_old));
|
||||
insert_values.push_back(std::to_string(character_data_entry.e_last_invsnapshot));
|
||||
insert_values.push_back("'" + EscapeString(character_data_entry.deleted_at) + "'");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (character_data_entry.deleted_at > 0 ? std::to_string(character_data_entry.deleted_at) : "null") + ")");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@@ -893,7 +1007,7 @@ public:
|
||||
insert_values.push_back(std::to_string(character_data_entry.aa_points_spent_old));
|
||||
insert_values.push_back(std::to_string(character_data_entry.aa_points_old));
|
||||
insert_values.push_back(std::to_string(character_data_entry.e_last_invsnapshot));
|
||||
insert_values.push_back("'" + EscapeString(character_data_entry.deleted_at) + "'");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (character_data_entry.deleted_at > 0 ? std::to_string(character_data_entry.deleted_at) : "null") + ")");
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
@@ -1028,7 +1142,7 @@ public:
|
||||
entry.aa_points_spent_old = atoi(row[98]);
|
||||
entry.aa_points_old = atoi(row[99]);
|
||||
entry.e_last_invsnapshot = atoi(row[100]);
|
||||
entry.deleted_at = row[101] ? row[101] : "";
|
||||
entry.deleted_at = strtoll(row[101] ? row[101] : "-1", nullptr, 10);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
@@ -1154,7 +1268,7 @@ public:
|
||||
entry.aa_points_spent_old = atoi(row[98]);
|
||||
entry.aa_points_old = atoi(row[99]);
|
||||
entry.e_last_invsnapshot = atoi(row[100]);
|
||||
entry.deleted_at = row[101] ? row[101] : "";
|
||||
entry.deleted_at = strtoll(row[101] ? row[101] : "-1", nullptr, 10);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterDisciplinesRepository {
|
||||
public:
|
||||
@@ -37,11 +38,25 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"slot_id",
|
||||
"disc_id",
|
||||
};
|
||||
}
|
||||
|
||||
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_disciplines");
|
||||
@@ -51,7 +66,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,327 @@
|
||||
/**
|
||||
* 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_EXP_MODIFIERS_REPOSITORY_H
|
||||
#define EQEMU_BASE_CHARACTER_EXP_MODIFIERS_REPOSITORY_H
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterExpModifiersRepository {
|
||||
public:
|
||||
struct CharacterExpModifiers {
|
||||
int character_id;
|
||||
int zone_id;
|
||||
float aa_modifier;
|
||||
float exp_modifier;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("character_id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"character_id",
|
||||
"zone_id",
|
||||
"aa_modifier",
|
||||
"exp_modifier",
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"character_id",
|
||||
"zone_id",
|
||||
"aa_modifier",
|
||||
"exp_modifier",
|
||||
};
|
||||
}
|
||||
|
||||
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_exp_modifiers");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static CharacterExpModifiers NewEntity()
|
||||
{
|
||||
CharacterExpModifiers entry{};
|
||||
|
||||
entry.character_id = 0;
|
||||
entry.zone_id = 0;
|
||||
entry.aa_modifier = 0;
|
||||
entry.exp_modifier = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static CharacterExpModifiers GetCharacterExpModifiersEntry(
|
||||
const std::vector<CharacterExpModifiers> &character_exp_modifierss,
|
||||
int character_exp_modifiers_id
|
||||
)
|
||||
{
|
||||
for (auto &character_exp_modifiers : character_exp_modifierss) {
|
||||
if (character_exp_modifiers.character_id == character_exp_modifiers_id) {
|
||||
return character_exp_modifiers;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static CharacterExpModifiers FindOne(
|
||||
Database& db,
|
||||
int character_exp_modifiers_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
character_exp_modifiers_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
CharacterExpModifiers entry{};
|
||||
|
||||
entry.character_id = atoi(row[0]);
|
||||
entry.zone_id = atoi(row[1]);
|
||||
entry.aa_modifier = static_cast<float>(atof(row[2]));
|
||||
entry.exp_modifier = static_cast<float>(atof(row[3]));
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
Database& db,
|
||||
int character_exp_modifiers_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
character_exp_modifiers_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
CharacterExpModifiers character_exp_modifiers_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[0] + " = " + std::to_string(character_exp_modifiers_entry.character_id));
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(character_exp_modifiers_entry.zone_id));
|
||||
update_values.push_back(columns[2] + " = " + std::to_string(character_exp_modifiers_entry.aa_modifier));
|
||||
update_values.push_back(columns[3] + " = " + std::to_string(character_exp_modifiers_entry.exp_modifier));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
character_exp_modifiers_entry.character_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static CharacterExpModifiers InsertOne(
|
||||
Database& db,
|
||||
CharacterExpModifiers character_exp_modifiers_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(character_exp_modifiers_entry.character_id));
|
||||
insert_values.push_back(std::to_string(character_exp_modifiers_entry.zone_id));
|
||||
insert_values.push_back(std::to_string(character_exp_modifiers_entry.aa_modifier));
|
||||
insert_values.push_back(std::to_string(character_exp_modifiers_entry.exp_modifier));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
character_exp_modifiers_entry.character_id = results.LastInsertedID();
|
||||
return character_exp_modifiers_entry;
|
||||
}
|
||||
|
||||
character_exp_modifiers_entry = NewEntity();
|
||||
|
||||
return character_exp_modifiers_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<CharacterExpModifiers> character_exp_modifiers_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &character_exp_modifiers_entry: character_exp_modifiers_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(character_exp_modifiers_entry.character_id));
|
||||
insert_values.push_back(std::to_string(character_exp_modifiers_entry.zone_id));
|
||||
insert_values.push_back(std::to_string(character_exp_modifiers_entry.aa_modifier));
|
||||
insert_values.push_back(std::to_string(character_exp_modifiers_entry.exp_modifier));
|
||||
|
||||
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<CharacterExpModifiers> All(Database& db)
|
||||
{
|
||||
std::vector<CharacterExpModifiers> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
CharacterExpModifiers entry{};
|
||||
|
||||
entry.character_id = atoi(row[0]);
|
||||
entry.zone_id = atoi(row[1]);
|
||||
entry.aa_modifier = static_cast<float>(atof(row[2]));
|
||||
entry.exp_modifier = static_cast<float>(atof(row[3]));
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<CharacterExpModifiers> GetWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
std::vector<CharacterExpModifiers> 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) {
|
||||
CharacterExpModifiers entry{};
|
||||
|
||||
entry.character_id = atoi(row[0]);
|
||||
entry.zone_id = atoi(row[1]);
|
||||
entry.aa_modifier = static_cast<float>(atof(row[2]));
|
||||
entry.exp_modifier = static_cast<float>(atof(row[3]));
|
||||
|
||||
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_EXP_MODIFIERS_REPOSITORY_H
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterExpeditionLockoutsRepository {
|
||||
public:
|
||||
@@ -22,7 +23,7 @@ public:
|
||||
int character_id;
|
||||
std::string expedition_name;
|
||||
std::string event_name;
|
||||
std::string expire_time;
|
||||
time_t expire_time;
|
||||
int duration;
|
||||
std::string from_expedition_uuid;
|
||||
};
|
||||
@@ -45,11 +46,29 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"character_id",
|
||||
"expedition_name",
|
||||
"event_name",
|
||||
"UNIX_TIMESTAMP(expire_time)",
|
||||
"duration",
|
||||
"from_expedition_uuid",
|
||||
};
|
||||
}
|
||||
|
||||
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_expedition_lockouts");
|
||||
@@ -59,7 +78,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
@@ -81,7 +100,7 @@ public:
|
||||
entry.character_id = 0;
|
||||
entry.expedition_name = "";
|
||||
entry.event_name = "";
|
||||
entry.expire_time = "";
|
||||
entry.expire_time = std::time(nullptr);
|
||||
entry.duration = 0;
|
||||
entry.from_expedition_uuid = "";
|
||||
|
||||
@@ -123,7 +142,7 @@ public:
|
||||
entry.character_id = atoi(row[1]);
|
||||
entry.expedition_name = row[2] ? row[2] : "";
|
||||
entry.event_name = row[3] ? row[3] : "";
|
||||
entry.expire_time = row[4] ? row[4] : "";
|
||||
entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
entry.duration = atoi(row[5]);
|
||||
entry.from_expedition_uuid = row[6] ? row[6] : "";
|
||||
|
||||
@@ -162,7 +181,7 @@ public:
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(character_expedition_lockouts_entry.character_id));
|
||||
update_values.push_back(columns[2] + " = '" + EscapeString(character_expedition_lockouts_entry.expedition_name) + "'");
|
||||
update_values.push_back(columns[3] + " = '" + EscapeString(character_expedition_lockouts_entry.event_name) + "'");
|
||||
update_values.push_back(columns[4] + " = '" + EscapeString(character_expedition_lockouts_entry.expire_time) + "'");
|
||||
update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (character_expedition_lockouts_entry.expire_time > 0 ? std::to_string(character_expedition_lockouts_entry.expire_time) : "null") + ")");
|
||||
update_values.push_back(columns[5] + " = " + std::to_string(character_expedition_lockouts_entry.duration));
|
||||
update_values.push_back(columns[6] + " = '" + EscapeString(character_expedition_lockouts_entry.from_expedition_uuid) + "'");
|
||||
|
||||
@@ -190,7 +209,7 @@ public:
|
||||
insert_values.push_back(std::to_string(character_expedition_lockouts_entry.character_id));
|
||||
insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expedition_name) + "'");
|
||||
insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.event_name) + "'");
|
||||
insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expire_time) + "'");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (character_expedition_lockouts_entry.expire_time > 0 ? std::to_string(character_expedition_lockouts_entry.expire_time) : "null") + ")");
|
||||
insert_values.push_back(std::to_string(character_expedition_lockouts_entry.duration));
|
||||
insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.from_expedition_uuid) + "'");
|
||||
|
||||
@@ -226,7 +245,7 @@ public:
|
||||
insert_values.push_back(std::to_string(character_expedition_lockouts_entry.character_id));
|
||||
insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expedition_name) + "'");
|
||||
insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.event_name) + "'");
|
||||
insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expire_time) + "'");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (character_expedition_lockouts_entry.expire_time > 0 ? std::to_string(character_expedition_lockouts_entry.expire_time) : "null") + ")");
|
||||
insert_values.push_back(std::to_string(character_expedition_lockouts_entry.duration));
|
||||
insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.from_expedition_uuid) + "'");
|
||||
|
||||
@@ -266,7 +285,7 @@ public:
|
||||
entry.character_id = atoi(row[1]);
|
||||
entry.expedition_name = row[2] ? row[2] : "";
|
||||
entry.event_name = row[3] ? row[3] : "";
|
||||
entry.expire_time = row[4] ? row[4] : "";
|
||||
entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
entry.duration = atoi(row[5]);
|
||||
entry.from_expedition_uuid = row[6] ? row[6] : "";
|
||||
|
||||
@@ -297,7 +316,7 @@ public:
|
||||
entry.character_id = atoi(row[1]);
|
||||
entry.expedition_name = row[2] ? row[2] : "";
|
||||
entry.event_name = row[3] ? row[3] : "";
|
||||
entry.expire_time = row[4] ? row[4] : "";
|
||||
entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
entry.duration = atoi(row[5]);
|
||||
entry.from_expedition_uuid = row[6] ? row[6] : "";
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterInspectMessagesRepository {
|
||||
public:
|
||||
@@ -35,11 +36,24 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"inspect_message",
|
||||
};
|
||||
}
|
||||
|
||||
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_inspect_messages");
|
||||
@@ -49,7 +63,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterInstanceSafereturnsRepository {
|
||||
public:
|
||||
@@ -49,11 +50,31 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
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 SelectColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", SelectColumns()));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("character_instance_safereturns");
|
||||
@@ -63,7 +84,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterItemRecastRepository {
|
||||
public:
|
||||
@@ -37,11 +38,25 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"recast_type",
|
||||
"timestamp",
|
||||
};
|
||||
}
|
||||
|
||||
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_item_recast");
|
||||
@@ -51,7 +66,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterLanguagesRepository {
|
||||
public:
|
||||
@@ -37,11 +38,25 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"lang_id",
|
||||
"value",
|
||||
};
|
||||
}
|
||||
|
||||
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_languages");
|
||||
@@ -51,7 +66,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterLeadershipAbilitiesRepository {
|
||||
public:
|
||||
@@ -37,11 +38,25 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"slot",
|
||||
"rank",
|
||||
};
|
||||
}
|
||||
|
||||
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_leadership_abilities");
|
||||
@@ -51,7 +66,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterMaterialRepository {
|
||||
public:
|
||||
@@ -45,11 +46,29 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"slot",
|
||||
"blue",
|
||||
"green",
|
||||
"red",
|
||||
"use_tint",
|
||||
"color",
|
||||
};
|
||||
}
|
||||
|
||||
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_material");
|
||||
@@ -59,7 +78,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterMemmedSpellsRepository {
|
||||
public:
|
||||
@@ -37,11 +38,25 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"slot_id",
|
||||
"spell_id",
|
||||
};
|
||||
}
|
||||
|
||||
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_memmed_spells");
|
||||
@@ -51,7 +66,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterPetBuffsRepository {
|
||||
public:
|
||||
@@ -53,11 +54,33 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"char_id",
|
||||
"pet",
|
||||
"slot",
|
||||
"spell_id",
|
||||
"caster_level",
|
||||
"castername",
|
||||
"ticsremaining",
|
||||
"counters",
|
||||
"numhits",
|
||||
"rune",
|
||||
"instrument_mod",
|
||||
};
|
||||
}
|
||||
|
||||
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_pet_buffs");
|
||||
@@ -67,7 +90,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterPetInfoRepository {
|
||||
public:
|
||||
@@ -49,11 +50,31 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"char_id",
|
||||
"pet",
|
||||
"petname",
|
||||
"petpower",
|
||||
"spell_id",
|
||||
"hp",
|
||||
"mana",
|
||||
"size",
|
||||
"taunting",
|
||||
};
|
||||
}
|
||||
|
||||
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_pet_info");
|
||||
@@ -63,7 +84,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterPetInventoryRepository {
|
||||
public:
|
||||
@@ -39,11 +40,26 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"char_id",
|
||||
"pet",
|
||||
"slot",
|
||||
"item_id",
|
||||
};
|
||||
}
|
||||
|
||||
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_pet_inventory");
|
||||
@@ -53,7 +69,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterPotionbeltRepository {
|
||||
public:
|
||||
@@ -39,11 +40,26 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"potion_id",
|
||||
"item_id",
|
||||
"icon",
|
||||
};
|
||||
}
|
||||
|
||||
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_potionbelt");
|
||||
@@ -53,7 +69,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterSkillsRepository {
|
||||
public:
|
||||
@@ -37,11 +38,25 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"skill_id",
|
||||
"value",
|
||||
};
|
||||
}
|
||||
|
||||
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_skills");
|
||||
@@ -51,7 +66,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterSpellsRepository {
|
||||
public:
|
||||
@@ -37,11 +38,25 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"slot_id",
|
||||
"spell_id",
|
||||
};
|
||||
}
|
||||
|
||||
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_spells");
|
||||
@@ -51,7 +66,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
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);
|
||||
entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
|
||||
return entry;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ public:
|
||||
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) + ")");
|
||||
update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (character_task_timers_entry.expire_time > 0 ? std::to_string(character_task_timers_entry.expire_time) : "null") + ")");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
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_values.push_back("FROM_UNIXTIME(" + (character_task_timers_entry.expire_time > 0 ? std::to_string(character_task_timers_entry.expire_time) : "null") + ")");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@@ -231,7 +231,7 @@ public:
|
||||
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_values.push_back("FROM_UNIXTIME(" + (character_task_timers_entry.expire_time > 0 ? std::to_string(character_task_timers_entry.expire_time) : "null") + ")");
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
@@ -269,7 +269,7 @@ public:
|
||||
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);
|
||||
entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
@@ -298,7 +298,7 @@ public:
|
||||
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);
|
||||
entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCharacterTasksRepository {
|
||||
public:
|
||||
@@ -41,11 +42,27 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"charid",
|
||||
"taskid",
|
||||
"slot",
|
||||
"type",
|
||||
"acceptedtime",
|
||||
};
|
||||
}
|
||||
|
||||
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_tasks");
|
||||
@@ -55,7 +72,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseCompletedTasksRepository {
|
||||
public:
|
||||
@@ -39,11 +40,26 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"charid",
|
||||
"completedtime",
|
||||
"taskid",
|
||||
"activityid",
|
||||
};
|
||||
}
|
||||
|
||||
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_tasks");
|
||||
@@ -53,7 +69,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseContentFlagsRepository {
|
||||
public:
|
||||
@@ -39,11 +40,26 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"flag_name",
|
||||
"enabled",
|
||||
"notes",
|
||||
};
|
||||
}
|
||||
|
||||
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("content_flags");
|
||||
@@ -53,7 +69,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseDamageshieldtypesRepository {
|
||||
public:
|
||||
@@ -35,11 +36,24 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"spellid",
|
||||
"type",
|
||||
};
|
||||
}
|
||||
|
||||
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("damageshieldtypes");
|
||||
@@ -49,7 +63,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseDataBucketsRepository {
|
||||
public:
|
||||
@@ -39,11 +40,26 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"key",
|
||||
"value",
|
||||
"expires",
|
||||
};
|
||||
}
|
||||
|
||||
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("data_buckets");
|
||||
@@ -53,7 +69,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
@@ -110,7 +126,7 @@ public:
|
||||
if (results.RowCount() == 1) {
|
||||
DataBuckets entry{};
|
||||
|
||||
entry.id = strtoll(row[0], NULL, 10);
|
||||
entry.id = strtoll(row[0], nullptr, 10);
|
||||
entry.key = row[1] ? row[1] : "";
|
||||
entry.value = row[2] ? row[2] : "";
|
||||
entry.expires = atoi(row[3]);
|
||||
@@ -241,7 +257,7 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
DataBuckets entry{};
|
||||
|
||||
entry.id = strtoll(row[0], NULL, 10);
|
||||
entry.id = strtoll(row[0], nullptr, 10);
|
||||
entry.key = row[1] ? row[1] : "";
|
||||
entry.value = row[2] ? row[2] : "";
|
||||
entry.expires = atoi(row[3]);
|
||||
@@ -269,7 +285,7 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
DataBuckets entry{};
|
||||
|
||||
entry.id = strtoll(row[0], NULL, 10);
|
||||
entry.id = strtoll(row[0], nullptr, 10);
|
||||
entry.key = row[1] ? row[1] : "";
|
||||
entry.value = row[2] ? row[2] : "";
|
||||
entry.expires = atoi(row[3]);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseDbStrRepository {
|
||||
public:
|
||||
@@ -37,11 +38,25 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"type",
|
||||
"value",
|
||||
};
|
||||
}
|
||||
|
||||
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("db_str");
|
||||
@@ -51,7 +66,7 @@ public:
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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_DISCORD_WEBHOOKS_REPOSITORY_H
|
||||
#define EQEMU_BASE_DISCORD_WEBHOOKS_REPOSITORY_H
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../string_util.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseDiscordWebhooksRepository {
|
||||
public:
|
||||
struct DiscordWebhooks {
|
||||
int id;
|
||||
std::string webhook_name;
|
||||
std::string webhook_url;
|
||||
time_t created_at;
|
||||
time_t deleted_at;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"webhook_name",
|
||||
"webhook_url",
|
||||
"created_at",
|
||||
"deleted_at",
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"webhook_name",
|
||||
"webhook_url",
|
||||
"UNIX_TIMESTAMP(created_at)",
|
||||
"UNIX_TIMESTAMP(deleted_at)",
|
||||
};
|
||||
}
|
||||
|
||||
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("discord_webhooks");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static DiscordWebhooks NewEntity()
|
||||
{
|
||||
DiscordWebhooks entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.webhook_name = "";
|
||||
entry.webhook_url = "";
|
||||
entry.created_at = 0;
|
||||
entry.deleted_at = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static DiscordWebhooks GetDiscordWebhooksEntry(
|
||||
const std::vector<DiscordWebhooks> &discord_webhookss,
|
||||
int discord_webhooks_id
|
||||
)
|
||||
{
|
||||
for (auto &discord_webhooks : discord_webhookss) {
|
||||
if (discord_webhooks.id == discord_webhooks_id) {
|
||||
return discord_webhooks;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static DiscordWebhooks FindOne(
|
||||
Database& db,
|
||||
int discord_webhooks_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
discord_webhooks_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
DiscordWebhooks entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.webhook_name = row[1] ? row[1] : "";
|
||||
entry.webhook_url = row[2] ? row[2] : "";
|
||||
entry.created_at = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
|
||||
entry.deleted_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
Database& db,
|
||||
int discord_webhooks_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
discord_webhooks_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
DiscordWebhooks discord_webhooks_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[1] + " = '" + EscapeString(discord_webhooks_entry.webhook_name) + "'");
|
||||
update_values.push_back(columns[2] + " = '" + EscapeString(discord_webhooks_entry.webhook_url) + "'");
|
||||
update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (discord_webhooks_entry.created_at > 0 ? std::to_string(discord_webhooks_entry.created_at) : "null") + ")");
|
||||
update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (discord_webhooks_entry.deleted_at > 0 ? std::to_string(discord_webhooks_entry.deleted_at) : "null") + ")");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
discord_webhooks_entry.id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static DiscordWebhooks InsertOne(
|
||||
Database& db,
|
||||
DiscordWebhooks discord_webhooks_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(discord_webhooks_entry.id));
|
||||
insert_values.push_back("'" + EscapeString(discord_webhooks_entry.webhook_name) + "'");
|
||||
insert_values.push_back("'" + EscapeString(discord_webhooks_entry.webhook_url) + "'");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (discord_webhooks_entry.created_at > 0 ? std::to_string(discord_webhooks_entry.created_at) : "null") + ")");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (discord_webhooks_entry.deleted_at > 0 ? std::to_string(discord_webhooks_entry.deleted_at) : "null") + ")");
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
discord_webhooks_entry.id = results.LastInsertedID();
|
||||
return discord_webhooks_entry;
|
||||
}
|
||||
|
||||
discord_webhooks_entry = NewEntity();
|
||||
|
||||
return discord_webhooks_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
std::vector<DiscordWebhooks> discord_webhooks_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &discord_webhooks_entry: discord_webhooks_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(discord_webhooks_entry.id));
|
||||
insert_values.push_back("'" + EscapeString(discord_webhooks_entry.webhook_name) + "'");
|
||||
insert_values.push_back("'" + EscapeString(discord_webhooks_entry.webhook_url) + "'");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (discord_webhooks_entry.created_at > 0 ? std::to_string(discord_webhooks_entry.created_at) : "null") + ")");
|
||||
insert_values.push_back("FROM_UNIXTIME(" + (discord_webhooks_entry.deleted_at > 0 ? std::to_string(discord_webhooks_entry.deleted_at) : "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<DiscordWebhooks> All(Database& db)
|
||||
{
|
||||
std::vector<DiscordWebhooks> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
DiscordWebhooks entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.webhook_name = row[1] ? row[1] : "";
|
||||
entry.webhook_url = row[2] ? row[2] : "";
|
||||
entry.created_at = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
|
||||
entry.deleted_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<DiscordWebhooks> GetWhere(Database& db, std::string where_filter)
|
||||
{
|
||||
std::vector<DiscordWebhooks> 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) {
|
||||
DiscordWebhooks entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.webhook_name = row[1] ? row[1] : "";
|
||||
entry.webhook_url = row[2] ? row[2] : "";
|
||||
entry.created_at = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
|
||||
entry.deleted_at = 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_DISCORD_WEBHOOKS_REPOSITORY_H
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user