mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
Fix repository struct defaults for varchar | text
This commit is contained in:
parent
d691db6621
commit
3aaa5020b1
@ -116,7 +116,7 @@ public:
|
||||
AaAbility entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.name = 0;
|
||||
entry.name = "";
|
||||
entry.category = -1;
|
||||
entry.classes = 131070;
|
||||
entry.races = 65535;
|
||||
|
||||
@ -94,8 +94,8 @@ public:
|
||||
AccountFlags entry{};
|
||||
|
||||
entry.p_accid = 0;
|
||||
entry.p_flag = 0;
|
||||
entry.p_value = 0;
|
||||
entry.p_flag = "";
|
||||
entry.p_value = "";
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public:
|
||||
AdventureTemplateEntryFlavor entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.text = 0;
|
||||
entry.text = "";
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ public:
|
||||
AdventureTemplate entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.zone = 0;
|
||||
entry.zone = "";
|
||||
entry.zone_version = 0;
|
||||
entry.is_hard = 0;
|
||||
entry.is_raid = 0;
|
||||
|
||||
@ -111,7 +111,7 @@ public:
|
||||
|
||||
entry.type = 0;
|
||||
entry.npc_type = 0;
|
||||
entry.name = 0;
|
||||
entry.name = "";
|
||||
entry.spell_id = 0;
|
||||
entry.distance = 60;
|
||||
entry.aura_type = 1;
|
||||
|
||||
@ -91,7 +91,7 @@ public:
|
||||
{
|
||||
BannedIps entry{};
|
||||
|
||||
entry.ip_address = 0;
|
||||
entry.ip_address = "";
|
||||
entry.notes = 0;
|
||||
|
||||
return entry;
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
class BaseDataRepository {
|
||||
public:
|
||||
struct BaseData {
|
||||
int level;
|
||||
int class;
|
||||
int level;
|
||||
int class;
|
||||
std::string hp;
|
||||
std::string mana;
|
||||
std::string end;
|
||||
@ -107,9 +107,8 @@ public:
|
||||
{
|
||||
BaseData entry{};
|
||||
|
||||
entry.level = 0;
|
||||
entry.
|
||||
class = 0;
|
||||
entry.level = 0;
|
||||
entry.class = 0;
|
||||
entry.hp = 0;
|
||||
entry.mana = 0;
|
||||
entry.end = 0;
|
||||
@ -128,7 +127,7 @@ public:
|
||||
)
|
||||
{
|
||||
for (auto &base_data : base_datas) {
|
||||
if (base_data. { class }== base_data_id) {
|
||||
if (base_data.class == base_data_id) {
|
||||
return base_data;
|
||||
}
|
||||
}
|
||||
@ -152,9 +151,8 @@ public:
|
||||
if (results.RowCount() == 1) {
|
||||
BaseData entry{};
|
||||
|
||||
entry.level = atoi(row[0]);
|
||||
entry.
|
||||
class = atoi(row[1]);
|
||||
entry.level = atoi(row[0]);
|
||||
entry.class = atoi(row[1]);
|
||||
entry.hp = atof(row[2]);
|
||||
entry.mana = atof(row[3]);
|
||||
entry.end = atof(row[4]);
|
||||
@ -203,16 +201,14 @@ public:
|
||||
update_values.push_back(columns[8] + " = '" + EscapeString(base_data_entry.mana_fac) + "'");
|
||||
update_values.push_back(columns[9] + " = '" + EscapeString(base_data_entry.end_fac) + "'");
|
||||
|
||||
auto
|
||||
results = content_db.QueryDatabase(
|
||||
auto results = content_db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
base_data_entry.
|
||||
class
|
||||
)
|
||||
base_data_entry.class
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
@ -301,9 +297,8 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
BaseData entry{};
|
||||
|
||||
entry.level = atoi(row[0]);
|
||||
entry.
|
||||
class = atoi(row[1]);
|
||||
entry.level = atoi(row[0]);
|
||||
entry.class = atoi(row[1]);
|
||||
entry.hp = atof(row[2]);
|
||||
entry.mana = atof(row[3]);
|
||||
entry.end = atof(row[4]);
|
||||
|
||||
@ -94,7 +94,7 @@ public:
|
||||
Books entry{};
|
||||
|
||||
entry.name = "";
|
||||
entry.txtfile = 0;
|
||||
entry.txtfile = "";
|
||||
entry.language = 0;
|
||||
|
||||
return entry;
|
||||
|
||||
@ -114,16 +114,16 @@ public:
|
||||
Bugs entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.zone = 0;
|
||||
entry.name = 0;
|
||||
entry.ui = 0;
|
||||
entry.zone = "";
|
||||
entry.name = "";
|
||||
entry.ui = "";
|
||||
entry.x = 0;
|
||||
entry.y = 0;
|
||||
entry.z = 0;
|
||||
entry.type = 0;
|
||||
entry.type = "";
|
||||
entry.flag = 0;
|
||||
entry.target = 0;
|
||||
entry.bug = 0;
|
||||
entry.bug = "";
|
||||
entry.date = 0;
|
||||
entry.status = 0;
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ public:
|
||||
entry.slot_id = 0;
|
||||
entry.spell_id = 0;
|
||||
entry.caster_level = 0;
|
||||
entry.caster_name = 0;
|
||||
entry.caster_name = "";
|
||||
entry.ticsremaining = 0;
|
||||
entry.counters = 0;
|
||||
entry.numhits = 0;
|
||||
|
||||
@ -160,9 +160,7 @@ public:
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(
|
||||
columns[1] + " = '" + EscapeString(character_inspect_messages_entry.inspect_message) + "'"
|
||||
);
|
||||
update_values.push_back(columns[1] + " = '" + EscapeString(character_inspect_messages_entry.inspect_message) + "'");
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
|
||||
@ -34,7 +34,7 @@ public:
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("");
|
||||
return std::string("id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
@ -106,7 +106,7 @@ public:
|
||||
)
|
||||
{
|
||||
for (auto &character_tribute : character_tributes) {
|
||||
if (character_tribute.== character_tribute_id) {
|
||||
if (character_tribute.id == character_tribute_id) {
|
||||
return character_tribute;
|
||||
}
|
||||
}
|
||||
@ -174,7 +174,7 @@ public:
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
character_tribute_entry.
|
||||
character_tribute_entry.id
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ public:
|
||||
|
||||
entry.id = 0;
|
||||
entry.type = 0;
|
||||
entry.value = 0;
|
||||
entry.value = "";
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ public:
|
||||
entry.target = 'None';
|
||||
entry.time = current_timestamp();
|
||||
entry.descriptiontype = "";
|
||||
entry.description = 0;
|
||||
entry.description = "";
|
||||
entry.event_nid = 0;
|
||||
|
||||
return entry;
|
||||
|
||||
@ -98,7 +98,7 @@ public:
|
||||
entry.id = 0;
|
||||
entry.faction_id = 0;
|
||||
entry.mod = 0;
|
||||
entry.mod_name = 0;
|
||||
entry.mod_name = "";
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ public:
|
||||
|
||||
entry.charid = 0;
|
||||
entry.type = 1;
|
||||
entry.name = 0;
|
||||
entry.name = "";
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
@ -122,11 +122,10 @@ public:
|
||||
entry.rare = 0;
|
||||
entry.raid = 0;
|
||||
entry.race = 0;
|
||||
entry.
|
||||
class = 0;
|
||||
entry.bodytype = 0;
|
||||
entry.zone = 0;
|
||||
entry.hot_zone = 0;
|
||||
entry.class = 0;
|
||||
entry.bodytype = 0;
|
||||
entry.zone = 0;
|
||||
entry.hot_zone = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
@ -170,11 +169,10 @@ public:
|
||||
entry.rare = atoi(row[6]);
|
||||
entry.raid = atoi(row[7]);
|
||||
entry.race = row[8];
|
||||
entry.
|
||||
class = row[9];
|
||||
entry.bodytype = row[10];
|
||||
entry.zone = row[11];
|
||||
entry.hot_zone = atoi(row[12]);
|
||||
entry.class = row[9];
|
||||
entry.bodytype = row[10];
|
||||
entry.zone = row[11];
|
||||
entry.hot_zone = atoi(row[12]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
@ -214,8 +212,7 @@ public:
|
||||
update_values.push_back(columns[6] + " = " + std::to_string(global_loot_entry.rare));
|
||||
update_values.push_back(columns[7] + " = " + std::to_string(global_loot_entry.raid));
|
||||
update_values.push_back(columns[8] + " = '" + EscapeString(global_loot_entry.race) + "'");
|
||||
update_values.push_back(columns[9] + " = '" + EscapeString(global_loot_entry.
|
||||
class) +"'");
|
||||
update_values.push_back(columns[9] + " = '" + EscapeString(global_loot_entry.class) + "'");
|
||||
update_values.push_back(columns[10] + " = '" + EscapeString(global_loot_entry.bodytype) + "'");
|
||||
update_values.push_back(columns[11] + " = '" + EscapeString(global_loot_entry.zone) + "'");
|
||||
update_values.push_back(columns[12] + " = " + std::to_string(global_loot_entry.hot_zone));
|
||||
@ -247,8 +244,7 @@ public:
|
||||
insert_values.push_back(std::to_string(global_loot_entry.rare));
|
||||
insert_values.push_back(std::to_string(global_loot_entry.raid));
|
||||
insert_values.push_back("'" + EscapeString(global_loot_entry.race) + "'");
|
||||
insert_values.push_back("'" + EscapeString(global_loot_entry.
|
||||
class) +"'");
|
||||
insert_values.push_back("'" + EscapeString(global_loot_entry.class) + "'");
|
||||
insert_values.push_back("'" + EscapeString(global_loot_entry.bodytype) + "'");
|
||||
insert_values.push_back("'" + EscapeString(global_loot_entry.zone) + "'");
|
||||
insert_values.push_back(std::to_string(global_loot_entry.hot_zone));
|
||||
@ -288,8 +284,7 @@ public:
|
||||
insert_values.push_back(std::to_string(global_loot_entry.rare));
|
||||
insert_values.push_back(std::to_string(global_loot_entry.raid));
|
||||
insert_values.push_back("'" + EscapeString(global_loot_entry.race) + "'");
|
||||
insert_values.push_back("'" + EscapeString(global_loot_entry.
|
||||
class) +"'");
|
||||
insert_values.push_back("'" + EscapeString(global_loot_entry.class) + "'");
|
||||
insert_values.push_back("'" + EscapeString(global_loot_entry.bodytype) + "'");
|
||||
insert_values.push_back("'" + EscapeString(global_loot_entry.zone) + "'");
|
||||
insert_values.push_back(std::to_string(global_loot_entry.hot_zone));
|
||||
@ -335,11 +330,10 @@ public:
|
||||
entry.rare = atoi(row[6]);
|
||||
entry.raid = atoi(row[7]);
|
||||
entry.race = row[8];
|
||||
entry.
|
||||
class = row[9];
|
||||
entry.bodytype = row[10];
|
||||
entry.zone = row[11];
|
||||
entry.hot_zone = atoi(row[12]);
|
||||
entry.class = row[9];
|
||||
entry.bodytype = row[10];
|
||||
entry.zone = row[11];
|
||||
entry.hot_zone = atoi(row[12]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
@ -93,9 +93,9 @@ public:
|
||||
{
|
||||
GmIps entry{};
|
||||
|
||||
entry.name = 0;
|
||||
entry.name = "";
|
||||
entry.account_id = 0;
|
||||
entry.ip_address = 0;
|
||||
entry.ip_address = "";
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ public:
|
||||
|
||||
entry.groupid = 0;
|
||||
entry.charid = 0;
|
||||
entry.name = 0;
|
||||
entry.name = "";
|
||||
entry.ismerc = 0;
|
||||
|
||||
return entry;
|
||||
|
||||
@ -112,7 +112,7 @@ public:
|
||||
entry.maintank = "";
|
||||
entry.assist = "";
|
||||
entry.puller = "";
|
||||
entry.mentoree = 0;
|
||||
entry.mentoree = "";
|
||||
entry.mentor_percent = 0;
|
||||
|
||||
return entry;
|
||||
|
||||
@ -112,7 +112,7 @@ public:
|
||||
entry.total_tribute = 0;
|
||||
entry.last_tribute = 0;
|
||||
entry.banker = 0;
|
||||
entry.public_note = 0;
|
||||
entry.public_note = "";
|
||||
entry.alt = 0;
|
||||
|
||||
return entry;
|
||||
|
||||
@ -109,7 +109,7 @@ public:
|
||||
entry.name = "";
|
||||
entry.leader = 0;
|
||||
entry.minstatus = 0;
|
||||
entry.motd = 0;
|
||||
entry.motd = "";
|
||||
entry.tribute = 0;
|
||||
entry.motd_setter = "";
|
||||
entry.channel = "";
|
||||
|
||||
@ -100,9 +100,9 @@ public:
|
||||
Hackers entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.account = 0;
|
||||
entry.name = 0;
|
||||
entry.hacked = 0;
|
||||
entry.account = "";
|
||||
entry.name = "";
|
||||
entry.hacked = "";
|
||||
entry.zone = 0;
|
||||
entry.date = current_timestamp();
|
||||
|
||||
|
||||
@ -27,13 +27,13 @@
|
||||
class InstanceListRepository {
|
||||
public:
|
||||
struct InstanceList {
|
||||
int id;
|
||||
int zone;
|
||||
int version;
|
||||
int is_global;
|
||||
int start_time;
|
||||
int duration;
|
||||
int never_expires;
|
||||
int id;
|
||||
int zone;
|
||||
int8 version;
|
||||
int8 is_global;
|
||||
int start_time;
|
||||
int duration;
|
||||
int8 never_expires;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
|
||||
@ -103,7 +103,7 @@ public:
|
||||
entry.it_chance = 0;
|
||||
entry.it_level = 0;
|
||||
entry.it_id = 0;
|
||||
entry.it_qglobal = 0;
|
||||
entry.it_qglobal = "";
|
||||
entry.it_bagslot = 0;
|
||||
|
||||
return entry;
|
||||
|
||||
@ -106,8 +106,8 @@ public:
|
||||
Lfguild entry{};
|
||||
|
||||
entry.type = 0;
|
||||
entry.name = 0;
|
||||
entry.comment = 0;
|
||||
entry.name = "";
|
||||
entry.comment = "";
|
||||
entry.fromlevel = 0;
|
||||
entry.tolevel = 0;
|
||||
entry.classes = 0;
|
||||
|
||||
@ -106,11 +106,11 @@ public:
|
||||
LoginAccounts entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.account_name = 0;
|
||||
entry.account_password = 0;
|
||||
entry.account_email = 0;
|
||||
entry.account_name = "";
|
||||
entry.account_password = "";
|
||||
entry.account_email = "";
|
||||
entry.source_loginserver = 0;
|
||||
entry.last_ip_address = 0;
|
||||
entry.last_ip_address = "";
|
||||
entry.last_login_date = 0;
|
||||
entry.created_at = 0;
|
||||
entry.updated_at = current_timestamp();
|
||||
|
||||
@ -104,13 +104,13 @@ public:
|
||||
LoginServerAdmins entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.account_name = 0;
|
||||
entry.account_password = 0;
|
||||
entry.first_name = 0;
|
||||
entry.last_name = 0;
|
||||
entry.email = 0;
|
||||
entry.account_name = "";
|
||||
entry.account_password = "";
|
||||
entry.first_name = "";
|
||||
entry.last_name = "";
|
||||
entry.email = "";
|
||||
entry.registration_date = 0;
|
||||
entry.registration_ip_address = 0;
|
||||
entry.registration_ip_address = "";
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public:
|
||||
LoginServerListTypes entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.description = 0;
|
||||
entry.description = "";
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
@ -108,8 +108,8 @@ public:
|
||||
LoginWorldServers entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.long_name = 0;
|
||||
entry.short_name = 0;
|
||||
entry.long_name = "";
|
||||
entry.short_name = "";
|
||||
entry.tag_description = "";
|
||||
entry.login_server_list_type_id = 0;
|
||||
entry.last_login_date = 0;
|
||||
@ -195,8 +195,7 @@ public:
|
||||
update_values.push_back(columns[1] + " = '" + EscapeString(login_world_servers_entry.long_name) + "'");
|
||||
update_values.push_back(columns[2] + " = '" + EscapeString(login_world_servers_entry.short_name) + "'");
|
||||
update_values.push_back(columns[3] + " = '" + EscapeString(login_world_servers_entry.tag_description) + "'");
|
||||
update_values.push_back(
|
||||
columns[4] + " = " + std::to_string(login_world_servers_entry.login_server_list_type_id));
|
||||
update_values.push_back(columns[4] + " = " + std::to_string(login_world_servers_entry.login_server_list_type_id));
|
||||
update_values.push_back(columns[5] + " = '" + EscapeString(login_world_servers_entry.last_login_date) + "'");
|
||||
update_values.push_back(columns[6] + " = '" + EscapeString(login_world_servers_entry.last_ip_address) + "'");
|
||||
update_values.push_back(columns[7] + " = " + std::to_string(login_world_servers_entry.login_server_admin_id));
|
||||
|
||||
@ -108,8 +108,8 @@ public:
|
||||
entry.timestamp = 0;
|
||||
entry.from = "";
|
||||
entry.subject = "";
|
||||
entry.body = 0;
|
||||
entry.to = 0;
|
||||
entry.body = "";
|
||||
entry.to = "";
|
||||
entry.status = 0;
|
||||
|
||||
return entry;
|
||||
|
||||
@ -101,7 +101,7 @@ public:
|
||||
entry.emoteid = 0;
|
||||
entry.event_ = 0;
|
||||
entry.type = 0;
|
||||
entry.text = 0;
|
||||
entry.text = "";
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
@ -332,7 +332,7 @@ public:
|
||||
NpcTypes entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.name = 0;
|
||||
entry.name = "";
|
||||
entry.lastname = 0;
|
||||
entry.level = 0;
|
||||
entry.race = 0;
|
||||
|
||||
@ -146,7 +146,7 @@ public:
|
||||
NpcTypesTint entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.tint_set_name = 0;
|
||||
entry.tint_set_name = "";
|
||||
entry.red1h = 0;
|
||||
entry.grn1h = 0;
|
||||
entry.blu1h = 0;
|
||||
|
||||
@ -124,7 +124,7 @@ public:
|
||||
entry.charname = "";
|
||||
entry.accountname = "";
|
||||
entry.lastgm = "";
|
||||
entry.petitiontext = 0;
|
||||
entry.petitiontext = "";
|
||||
entry.gmtext = 0;
|
||||
entry.zone = "";
|
||||
entry.urgency = 0;
|
||||
|
||||
@ -107,12 +107,12 @@ public:
|
||||
|
||||
entry.gid = 0;
|
||||
entry.rid = 0;
|
||||
entry.marknpc = 0;
|
||||
entry.maintank = 0;
|
||||
entry.assist = 0;
|
||||
entry.puller = 0;
|
||||
entry.marknpc = "";
|
||||
entry.maintank = "";
|
||||
entry.assist = "";
|
||||
entry.puller = "";
|
||||
entry.leadershipaa = 0;
|
||||
entry.mentoree = 0;
|
||||
entry.mentoree = "";
|
||||
entry.mentor_percent = 0;
|
||||
|
||||
return entry;
|
||||
|
||||
@ -97,7 +97,7 @@ public:
|
||||
|
||||
entry.id = 0;
|
||||
entry.value = 0;
|
||||
entry.zone = 0;
|
||||
entry.zone = "";
|
||||
entry.instance_id = 0;
|
||||
|
||||
return entry;
|
||||
|
||||
@ -124,7 +124,7 @@ public:
|
||||
entry.duration = 0;
|
||||
entry.duration_code = 0;
|
||||
entry.title = "";
|
||||
entry.description = 0;
|
||||
entry.description = "";
|
||||
entry.reward = "";
|
||||
entry.rewardid = 0;
|
||||
entry.cashreward = 0;
|
||||
|
||||
@ -27,12 +27,12 @@
|
||||
class TitlesRepository {
|
||||
public:
|
||||
struct Titles {
|
||||
int id;
|
||||
int8 skill_id;
|
||||
int min_skill_value;
|
||||
int max_skill_value;
|
||||
int min_aa_points;
|
||||
int max_aa_points;
|
||||
int id;
|
||||
int8 skill_id;
|
||||
int min_skill_value;
|
||||
int max_skill_value;
|
||||
int min_aa_points;
|
||||
int max_aa_points;
|
||||
int8 class;
|
||||
int8 gender;
|
||||
int char_id;
|
||||
@ -121,15 +121,14 @@ public:
|
||||
entry.max_skill_value = -1;
|
||||
entry.min_aa_points = -1;
|
||||
entry.max_aa_points = -1;
|
||||
entry.
|
||||
class = -1;
|
||||
entry.gender = -1;
|
||||
entry.char_id = -1;
|
||||
entry.status = -1;
|
||||
entry.item_id = -1;
|
||||
entry.prefix = "";
|
||||
entry.suffix = "";
|
||||
entry.title_set = 0;
|
||||
entry.class = -1;
|
||||
entry.gender = -1;
|
||||
entry.char_id = -1;
|
||||
entry.status = -1;
|
||||
entry.item_id = -1;
|
||||
entry.prefix = "";
|
||||
entry.suffix = "";
|
||||
entry.title_set = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
@ -170,15 +169,14 @@ public:
|
||||
entry.max_skill_value = atoi(row[3]);
|
||||
entry.min_aa_points = atoi(row[4]);
|
||||
entry.max_aa_points = atoi(row[5]);
|
||||
entry.
|
||||
class = atoi(row[6]);
|
||||
entry.gender = atoi(row[7]);
|
||||
entry.char_id = atoi(row[8]);
|
||||
entry.status = atoi(row[9]);
|
||||
entry.item_id = atoi(row[10]);
|
||||
entry.prefix = row[11];
|
||||
entry.suffix = row[12];
|
||||
entry.title_set = atoi(row[13]);
|
||||
entry.class = atoi(row[6]);
|
||||
entry.gender = atoi(row[7]);
|
||||
entry.char_id = atoi(row[8]);
|
||||
entry.status = atoi(row[9]);
|
||||
entry.item_id = atoi(row[10]);
|
||||
entry.prefix = row[11];
|
||||
entry.suffix = row[12];
|
||||
entry.title_set = atoi(row[13]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
@ -215,8 +213,7 @@ public:
|
||||
update_values.push_back(columns[3] + " = " + std::to_string(titles_entry.max_skill_value));
|
||||
update_values.push_back(columns[4] + " = " + std::to_string(titles_entry.min_aa_points));
|
||||
update_values.push_back(columns[5] + " = " + std::to_string(titles_entry.max_aa_points));
|
||||
update_values.push_back(columns[6] + " = " + std::to_string(titles_entry.
|
||||
class));
|
||||
update_values.push_back(columns[6] + " = " + std::to_string(titles_entry.class));
|
||||
update_values.push_back(columns[7] + " = " + std::to_string(titles_entry.gender));
|
||||
update_values.push_back(columns[8] + " = " + std::to_string(titles_entry.char_id));
|
||||
update_values.push_back(columns[9] + " = " + std::to_string(titles_entry.status));
|
||||
@ -249,8 +246,7 @@ public:
|
||||
insert_values.push_back(std::to_string(titles_entry.max_skill_value));
|
||||
insert_values.push_back(std::to_string(titles_entry.min_aa_points));
|
||||
insert_values.push_back(std::to_string(titles_entry.max_aa_points));
|
||||
insert_values.push_back(std::to_string(titles_entry.
|
||||
class));
|
||||
insert_values.push_back(std::to_string(titles_entry.class));
|
||||
insert_values.push_back(std::to_string(titles_entry.gender));
|
||||
insert_values.push_back(std::to_string(titles_entry.char_id));
|
||||
insert_values.push_back(std::to_string(titles_entry.status));
|
||||
@ -291,8 +287,7 @@ public:
|
||||
insert_values.push_back(std::to_string(titles_entry.max_skill_value));
|
||||
insert_values.push_back(std::to_string(titles_entry.min_aa_points));
|
||||
insert_values.push_back(std::to_string(titles_entry.max_aa_points));
|
||||
insert_values.push_back(std::to_string(titles_entry.
|
||||
class));
|
||||
insert_values.push_back(std::to_string(titles_entry.class));
|
||||
insert_values.push_back(std::to_string(titles_entry.gender));
|
||||
insert_values.push_back(std::to_string(titles_entry.char_id));
|
||||
insert_values.push_back(std::to_string(titles_entry.status));
|
||||
@ -339,15 +334,14 @@ public:
|
||||
entry.max_skill_value = atoi(row[3]);
|
||||
entry.min_aa_points = atoi(row[4]);
|
||||
entry.max_aa_points = atoi(row[5]);
|
||||
entry.
|
||||
class = atoi(row[6]);
|
||||
entry.gender = atoi(row[7]);
|
||||
entry.char_id = atoi(row[8]);
|
||||
entry.status = atoi(row[9]);
|
||||
entry.item_id = atoi(row[10]);
|
||||
entry.prefix = row[11];
|
||||
entry.suffix = row[12];
|
||||
entry.title_set = atoi(row[13]);
|
||||
entry.class = atoi(row[6]);
|
||||
entry.gender = atoi(row[7]);
|
||||
entry.char_id = atoi(row[8]);
|
||||
entry.status = atoi(row[9]);
|
||||
entry.item_id = atoi(row[10]);
|
||||
entry.prefix = row[11];
|
||||
entry.suffix = row[12];
|
||||
entry.title_set = atoi(row[13]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
@ -29,17 +29,22 @@ public:
|
||||
struct TradeskillRecipe {
|
||||
int id;
|
||||
std::string name;
|
||||
int tradeskill;
|
||||
int skillneeded;
|
||||
int trivial;
|
||||
uint8 nofail;
|
||||
int replace_container;
|
||||
int16 tradeskill;
|
||||
int16 skillneeded;
|
||||
int16 trivial;
|
||||
int8 nofail;
|
||||
int8 replace_container;
|
||||
std::string notes;
|
||||
uint8 must_learn;
|
||||
uint8 quest;
|
||||
uint8 enabled;
|
||||
int8 must_learn;
|
||||
int8 quest;
|
||||
int8 enabled;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
@ -62,6 +67,21 @@ public:
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string InsertColumnsRaw()
|
||||
{
|
||||
std::vector<std::string> insert_columns;
|
||||
|
||||
for (auto &column : Columns()) {
|
||||
if (column == PrimaryKey()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
insert_columns.push_back(column);
|
||||
}
|
||||
|
||||
return std::string(implode(", ", insert_columns));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("tradeskill_recipe");
|
||||
@ -69,18 +89,25 @@ public:
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return std::string(
|
||||
fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
TableName()
|
||||
)
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
InsertColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static TradeskillRecipe NewEntity()
|
||||
{
|
||||
TradeskillRecipe entry;
|
||||
TradeskillRecipe entry{};
|
||||
|
||||
entry.id = 0;
|
||||
entry.name = "";
|
||||
@ -89,46 +116,215 @@ public:
|
||||
entry.trivial = 0;
|
||||
entry.nofail = 0;
|
||||
entry.replace_container = 0;
|
||||
entry.notes = "";
|
||||
entry.notes = 0;
|
||||
entry.must_learn = 0;
|
||||
entry.quest = 0;
|
||||
entry.enabled = 0;
|
||||
entry.enabled = 1;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static TradeskillRecipe GetRecipe(int recipe_id)
|
||||
static TradeskillRecipe GetTradeskillRecipeEntry(
|
||||
const std::vector<TradeskillRecipe> &tradeskill_recipes,
|
||||
int tradeskill_recipe_id
|
||||
)
|
||||
{
|
||||
for (auto &tradeskill_recipe : tradeskill_recipes) {
|
||||
if (tradeskill_recipe.id == tradeskill_recipe_id) {
|
||||
return tradeskill_recipe;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static TradeskillRecipe FindOne(
|
||||
int tradeskill_recipe_id
|
||||
)
|
||||
{
|
||||
auto results = content_db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {}",
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
recipe_id
|
||||
tradeskill_recipe_id
|
||||
)
|
||||
);
|
||||
|
||||
TradeskillRecipe tradeskill_recipe = NewEntity();
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 0) {
|
||||
return tradeskill_recipe;
|
||||
if (results.RowCount() == 1) {
|
||||
TradeskillRecipe entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.name = row[1];
|
||||
entry.tradeskill = atoi(row[2]);
|
||||
entry.skillneeded = atoi(row[3]);
|
||||
entry.trivial = atoi(row[4]);
|
||||
entry.nofail = atoi(row[5]);
|
||||
entry.replace_container = atoi(row[6]);
|
||||
entry.notes = row[7];
|
||||
entry.must_learn = atoi(row[8]);
|
||||
entry.quest = atoi(row[9]);
|
||||
entry.enabled = atoi(row[10]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
tradeskill_recipe.id = atoi(row[0]);
|
||||
tradeskill_recipe.name = (row[1] ? row[1] : "");
|
||||
tradeskill_recipe.tradeskill = atoi(row[2]);
|
||||
tradeskill_recipe.skillneeded = atoi(row[3]);
|
||||
tradeskill_recipe.trivial = atoi(row[4]);
|
||||
tradeskill_recipe.nofail = atoi(row[5]);
|
||||
tradeskill_recipe.replace_container = atoi(row[6]);
|
||||
tradeskill_recipe.notes = (row[7] ? row[7] : "");
|
||||
tradeskill_recipe.must_learn = atoi(row[8]);
|
||||
tradeskill_recipe.quest = atoi(row[9]);
|
||||
tradeskill_recipe.enabled = atoi(row[10]);
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
return tradeskill_recipe;
|
||||
static int DeleteOne(
|
||||
int tradeskill_recipe_id
|
||||
)
|
||||
{
|
||||
auto results = content_db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
tradeskill_recipe_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
TradeskillRecipe tradeskill_recipe_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[1] + " = '" + EscapeString(tradeskill_recipe_entry.name) + "'");
|
||||
update_values.push_back(columns[2] + " = " + std::to_string(tradeskill_recipe_entry.tradeskill));
|
||||
update_values.push_back(columns[3] + " = " + std::to_string(tradeskill_recipe_entry.skillneeded));
|
||||
update_values.push_back(columns[4] + " = " + std::to_string(tradeskill_recipe_entry.trivial));
|
||||
update_values.push_back(columns[5] + " = " + std::to_string(tradeskill_recipe_entry.nofail));
|
||||
update_values.push_back(columns[6] + " = " + std::to_string(tradeskill_recipe_entry.replace_container));
|
||||
update_values.push_back(columns[7] + " = '" + EscapeString(tradeskill_recipe_entry.notes) + "'");
|
||||
update_values.push_back(columns[8] + " = " + std::to_string(tradeskill_recipe_entry.must_learn));
|
||||
update_values.push_back(columns[9] + " = " + std::to_string(tradeskill_recipe_entry.quest));
|
||||
update_values.push_back(columns[10] + " = " + std::to_string(tradeskill_recipe_entry.enabled));
|
||||
|
||||
auto results = content_db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
tradeskill_recipe_entry.id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static TradeskillRecipe InsertOne(
|
||||
TradeskillRecipe tradeskill_recipe_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.name) + "'");
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.tradeskill));
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.skillneeded));
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.trivial));
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.nofail));
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.replace_container));
|
||||
insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.notes) + "'");
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.must_learn));
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.quest));
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.enabled));
|
||||
|
||||
auto results = content_db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
tradeskill_recipe_entry.id = results.LastInsertedID();
|
||||
return tradeskill_recipe_entry;
|
||||
}
|
||||
|
||||
tradeskill_recipe_entry = InstanceListRepository::NewEntity();
|
||||
|
||||
return tradeskill_recipe_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
std::vector<TradeskillRecipe> tradeskill_recipe_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &tradeskill_recipe_entry: tradeskill_recipe_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.name) + "'");
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.tradeskill));
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.skillneeded));
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.trivial));
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.nofail));
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.replace_container));
|
||||
insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.notes) + "'");
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.must_learn));
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.quest));
|
||||
insert_values.push_back(std::to_string(tradeskill_recipe_entry.enabled));
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = content_db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<TradeskillRecipe> All()
|
||||
{
|
||||
std::vector<TradeskillRecipe> all_entries;
|
||||
|
||||
auto results = content_db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
TradeskillRecipe entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.name = row[1];
|
||||
entry.tradeskill = atoi(row[2]);
|
||||
entry.skillneeded = atoi(row[3]);
|
||||
entry.trivial = atoi(row[4]);
|
||||
entry.nofail = atoi(row[5]);
|
||||
entry.replace_container = atoi(row[6]);
|
||||
entry.notes = row[7];
|
||||
entry.must_learn = atoi(row[8]);
|
||||
entry.quest = atoi(row[9]);
|
||||
entry.enabled = atoi(row[10]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif //EQEMU_TRADESKILL_RECIPE_REPOSITORY_H
|
||||
|
||||
@ -100,7 +100,7 @@ public:
|
||||
entry.id = 0;
|
||||
entry.unknown = 0;
|
||||
entry.name = "";
|
||||
entry.descr = 0;
|
||||
entry.descr = "";
|
||||
entry.isguild = 0;
|
||||
|
||||
return entry;
|
||||
|
||||
@ -96,8 +96,8 @@ public:
|
||||
Variables entry{};
|
||||
|
||||
entry.varname = "";
|
||||
entry.value = 0;
|
||||
entry.information = 0;
|
||||
entry.value = "";
|
||||
entry.information = "";
|
||||
entry.ts = current_timestamp();
|
||||
|
||||
return entry;
|
||||
|
||||
@ -98,7 +98,7 @@ public:
|
||||
VeteranRewardTemplates entry{};
|
||||
|
||||
entry.claim_id = 0;
|
||||
entry.name = 0;
|
||||
entry.name = "";
|
||||
entry.item_id = 0;
|
||||
entry.charges = 0;
|
||||
entry.reward_slot = 0;
|
||||
|
||||
@ -262,7 +262,7 @@ public:
|
||||
entry.short_name = 0;
|
||||
entry.id = 0;
|
||||
entry.file_name = 0;
|
||||
entry.long_name = 0;
|
||||
entry.long_name = "";
|
||||
entry.map_file_name = 0;
|
||||
entry.safe_x = 0;
|
||||
entry.safe_y = 0;
|
||||
|
||||
@ -78,9 +78,8 @@ my $pass = $config->{"server"}{"database"}{"password"};
|
||||
my $dsn = "dbi:mysql:$database_name:$host:3306";
|
||||
my $connect = DBI->connect($dsn, $user, $pass);
|
||||
|
||||
my @tables = ();
|
||||
my @tables = ($requested_table_to_generate);
|
||||
if ($requested_table_to_generate eq "all" || !$requested_table_to_generate) {
|
||||
|
||||
my $table_names_exec = $connect->prepare(
|
||||
"
|
||||
SELECT
|
||||
@ -177,6 +176,9 @@ foreach my $table_to_generate (@tables) {
|
||||
my %table_data = ();
|
||||
my %table_primary_key = ();
|
||||
$ex->execute($database_name, $table_to_generate);
|
||||
|
||||
$table_primary_key{$table_to_generate} = "id";
|
||||
|
||||
while (my @row = $ex->fetchrow_array()) {
|
||||
my $column_name = $row[0];
|
||||
my $table_name = $row[1];
|
||||
@ -197,6 +199,9 @@ foreach my $table_to_generate (@tables) {
|
||||
if ($column_default eq "''") {
|
||||
$default_value = '""';
|
||||
}
|
||||
if (trim($column_default) eq "" && $column_type =~ /text|varchar/i) {
|
||||
$default_value = '""';
|
||||
}
|
||||
|
||||
my $struct_data_type = translate_mysql_data_type_to_c($data_type);
|
||||
|
||||
@ -275,7 +280,7 @@ foreach my $table_to_generate (@tables) {
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach my $column (keys %{ $table_data{$table_to_generate} }) {
|
||||
foreach my $column (keys %{$table_data{$table_to_generate}}) {
|
||||
my $column_data = $table_data{$table_to_generate}{$column};
|
||||
my $data_type = $column_data->[0];
|
||||
my $column_type = $column_data->[1];
|
||||
@ -367,4 +372,4 @@ sub translate_mysql_data_type_to_c {
|
||||
}
|
||||
|
||||
return $struct_data_type;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user