mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-29 08:23:34 +00:00
Fix float types, remove some errant table repositories [skip ci]
This commit is contained in:
parent
9e27ffacff
commit
a824ddec44
@ -37,10 +37,10 @@ public:
|
|||||||
int8 type;
|
int8 type;
|
||||||
int type_data;
|
int type_data;
|
||||||
int16 type_count;
|
int16 type_count;
|
||||||
std::string assa_x;
|
float assa_x;
|
||||||
std::string assa_y;
|
float assa_y;
|
||||||
std::string assa_z;
|
float assa_z;
|
||||||
std::string assa_h;
|
float assa_h;
|
||||||
std::string text;
|
std::string text;
|
||||||
int duration;
|
int duration;
|
||||||
int zone_in_time;
|
int zone_in_time;
|
||||||
@ -48,18 +48,18 @@ public:
|
|||||||
int16 lose_points;
|
int16 lose_points;
|
||||||
int8 theme;
|
int8 theme;
|
||||||
int16 zone_in_zone_id;
|
int16 zone_in_zone_id;
|
||||||
std::string zone_in_x;
|
float zone_in_x;
|
||||||
std::string zone_in_y;
|
float zone_in_y;
|
||||||
int16 zone_in_object_id;
|
int16 zone_in_object_id;
|
||||||
std::string dest_x;
|
float dest_x;
|
||||||
std::string dest_y;
|
float dest_y;
|
||||||
std::string dest_z;
|
float dest_z;
|
||||||
std::string dest_h;
|
float dest_h;
|
||||||
int graveyard_zone_id;
|
int graveyard_zone_id;
|
||||||
std::string graveyard_x;
|
float graveyard_x;
|
||||||
std::string graveyard_y;
|
float graveyard_y;
|
||||||
std::string graveyard_z;
|
float graveyard_z;
|
||||||
std::string graveyard_radius;
|
float graveyard_radius;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
static std::string PrimaryKey()
|
||||||
|
|||||||
@ -27,16 +27,16 @@
|
|||||||
class BaseDataRepository {
|
class BaseDataRepository {
|
||||||
public:
|
public:
|
||||||
struct BaseData {
|
struct BaseData {
|
||||||
int level;
|
int level;
|
||||||
int class;
|
int class;
|
||||||
std::string hp;
|
float hp;
|
||||||
std::string mana;
|
float mana;
|
||||||
std::string end;
|
float end;
|
||||||
std::string unk1;
|
float unk1;
|
||||||
std::string unk2;
|
float unk2;
|
||||||
std::string hp_fac;
|
float hp_fac;
|
||||||
std::string mana_fac;
|
float mana_fac;
|
||||||
std::string end_fac;
|
float end_fac;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
static std::string PrimaryKey()
|
||||||
|
|||||||
@ -31,12 +31,12 @@ public:
|
|||||||
int spellid;
|
int spellid;
|
||||||
int8 type;
|
int8 type;
|
||||||
int zoneid;
|
int zoneid;
|
||||||
std::string x;
|
float x;
|
||||||
std::string y;
|
float y;
|
||||||
std::string z;
|
float z;
|
||||||
std::string x_diff;
|
float x_diff;
|
||||||
std::string y_diff;
|
float y_diff;
|
||||||
std::string z_diff;
|
float z_diff;
|
||||||
std::string message;
|
std::string message;
|
||||||
std::string description;
|
std::string description;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -39,9 +39,9 @@ public:
|
|||||||
std::string category_name;
|
std::string category_name;
|
||||||
std::string reporter_name;
|
std::string reporter_name;
|
||||||
std::string ui_path;
|
std::string ui_path;
|
||||||
std::string pos_x;
|
float pos_x;
|
||||||
std::string pos_y;
|
float pos_y;
|
||||||
std::string pos_z;
|
float pos_z;
|
||||||
int heading;
|
int heading;
|
||||||
int time_played;
|
int time_played;
|
||||||
int target_id;
|
int target_id;
|
||||||
|
|||||||
@ -31,9 +31,9 @@ public:
|
|||||||
std::string zone;
|
std::string zone;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string ui;
|
std::string ui;
|
||||||
std::string x;
|
float x;
|
||||||
std::string y;
|
float y;
|
||||||
std::string z;
|
float z;
|
||||||
std::string type;
|
std::string type;
|
||||||
int8 flag;
|
int8 flag;
|
||||||
std::string target;
|
std::string target;
|
||||||
|
|||||||
@ -27,14 +27,14 @@
|
|||||||
class CharacterBindRepository {
|
class CharacterBindRepository {
|
||||||
public:
|
public:
|
||||||
struct CharacterBind {
|
struct CharacterBind {
|
||||||
int id;
|
int id;
|
||||||
int slot;
|
int slot;
|
||||||
int16 zone_id;
|
int16 zone_id;
|
||||||
int instance_id;
|
int instance_id;
|
||||||
std::string x;
|
float x;
|
||||||
std::string y;
|
float y;
|
||||||
std::string z;
|
float z;
|
||||||
std::string heading;
|
float heading;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
static std::string PrimaryKey()
|
||||||
|
|||||||
@ -32,10 +32,10 @@ public:
|
|||||||
std::string charname;
|
std::string charname;
|
||||||
int16 zone_id;
|
int16 zone_id;
|
||||||
int16 instance_id;
|
int16 instance_id;
|
||||||
std::string x;
|
float x;
|
||||||
std::string y;
|
float y;
|
||||||
std::string z;
|
float z;
|
||||||
std::string heading;
|
float heading;
|
||||||
std::string time_of_death;
|
std::string time_of_death;
|
||||||
int guild_consent_id;
|
int guild_consent_id;
|
||||||
int8 is_rezzed;
|
int8 is_rezzed;
|
||||||
|
|||||||
@ -35,10 +35,10 @@ public:
|
|||||||
std::string suffix;
|
std::string suffix;
|
||||||
int zone_id;
|
int zone_id;
|
||||||
int zone_instance;
|
int zone_instance;
|
||||||
std::string y;
|
float y;
|
||||||
std::string x;
|
float x;
|
||||||
std::string z;
|
float z;
|
||||||
std::string heading;
|
float heading;
|
||||||
int8 gender;
|
int8 gender;
|
||||||
int16 race;
|
int16 race;
|
||||||
int8 class;
|
int8 class;
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public:
|
|||||||
int spell_id;
|
int spell_id;
|
||||||
int hp;
|
int hp;
|
||||||
int mana;
|
int mana;
|
||||||
std::string size;
|
float size;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
static std::string PrimaryKey()
|
||||||
|
|||||||
@ -1,253 +0,0 @@
|
|||||||
/**
|
|
||||||
* EQEmulator: Everquest Server Emulator
|
|
||||||
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; version 2 of the License.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
|
||||||
* are required to give you total support for your newly bought product;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef EQEMU_DB_VERSION_REPOSITORY_H
|
|
||||||
#define EQEMU_DB_VERSION_REPOSITORY_H
|
|
||||||
|
|
||||||
#include "../database.h"
|
|
||||||
#include "../string_util.h"
|
|
||||||
|
|
||||||
class DbVersionRepository {
|
|
||||||
public:
|
|
||||||
struct DbVersion {
|
|
||||||
int version;
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
|
||||||
{
|
|
||||||
return std::string("");
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<std::string> Columns()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
"version",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string ColumnsRaw()
|
|
||||||
{
|
|
||||||
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("db_version");
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string BaseSelect()
|
|
||||||
{
|
|
||||||
return fmt::format(
|
|
||||||
"SELECT {} FROM {}",
|
|
||||||
ColumnsRaw(),
|
|
||||||
TableName()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string BaseInsert()
|
|
||||||
{
|
|
||||||
return fmt::format(
|
|
||||||
"INSERT INTO {} ({}) ",
|
|
||||||
TableName(),
|
|
||||||
InsertColumnsRaw()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static DbVersion NewEntity()
|
|
||||||
{
|
|
||||||
DbVersion entry{};
|
|
||||||
|
|
||||||
entry.version = 0;
|
|
||||||
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
static DbVersion GetDbVersionEntry(
|
|
||||||
const std::vector<DbVersion> &db_versions,
|
|
||||||
int db_version_id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
for (auto &db_version : db_versions) {
|
|
||||||
if (db_version. == db_version_id) {
|
|
||||||
return db_version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NewEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
static DbVersion FindOne(
|
|
||||||
int db_version_id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto results = database.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"{} WHERE id = {} LIMIT 1",
|
|
||||||
BaseSelect(),
|
|
||||||
db_version_id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
auto row = results.begin();
|
|
||||||
if (results.RowCount() == 1) {
|
|
||||||
DbVersion entry{};
|
|
||||||
|
|
||||||
entry.version = atoi(row[0]);
|
|
||||||
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NewEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
static int DeleteOne(
|
|
||||||
int db_version_id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto results = database.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"DELETE FROM {} WHERE {} = {}",
|
|
||||||
TableName(),
|
|
||||||
PrimaryKey(),
|
|
||||||
db_version_id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return (results.Success() ? results.RowsAffected() : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int UpdateOne(
|
|
||||||
DbVersion db_version_entry
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::vector<std::string> update_values;
|
|
||||||
|
|
||||||
auto columns = Columns();
|
|
||||||
|
|
||||||
update_values.push_back(columns[0] + " = " + std::to_string(db_version_entry.version));
|
|
||||||
|
|
||||||
auto results = database.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"UPDATE {} SET {} WHERE {} = {}",
|
|
||||||
TableName(),
|
|
||||||
implode(", ", update_values),
|
|
||||||
PrimaryKey(),
|
|
||||||
db_version_entry.
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return (results.Success() ? results.RowsAffected() : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static DbVersion InsertOne(
|
|
||||||
DbVersion db_version_entry
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::vector<std::string> insert_values;
|
|
||||||
|
|
||||||
insert_values.push_back(std::to_string(db_version_entry.version));
|
|
||||||
|
|
||||||
auto results = database.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"{} VALUES ({})",
|
|
||||||
BaseInsert(),
|
|
||||||
implode(",", insert_values)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (results.Success()) {
|
|
||||||
db_version_entry.id = results.LastInsertedID();
|
|
||||||
return db_version_entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
db_version_entry = InstanceListRepository::NewEntity();
|
|
||||||
|
|
||||||
return db_version_entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int InsertMany(
|
|
||||||
std::vector<DbVersion> db_version_entries
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::vector<std::string> insert_chunks;
|
|
||||||
|
|
||||||
for (auto &db_version_entry: db_version_entries) {
|
|
||||||
std::vector<std::string> insert_values;
|
|
||||||
|
|
||||||
insert_values.push_back(std::to_string(db_version_entry.version));
|
|
||||||
|
|
||||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> insert_values;
|
|
||||||
|
|
||||||
auto results = database.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"{} VALUES {}",
|
|
||||||
BaseInsert(),
|
|
||||||
implode(",", insert_chunks)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return (results.Success() ? results.RowsAffected() : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<DbVersion> All()
|
|
||||||
{
|
|
||||||
std::vector<DbVersion> all_entries;
|
|
||||||
|
|
||||||
auto results = database.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"{}",
|
|
||||||
BaseSelect()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
all_entries.reserve(results.RowCount());
|
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
|
||||||
DbVersion entry{};
|
|
||||||
|
|
||||||
entry.version = atoi(row[0]);
|
|
||||||
|
|
||||||
all_entries.push_back(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
return all_entries;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //EQEMU_DB_VERSION_REPOSITORY_H
|
|
||||||
@ -32,10 +32,10 @@ public:
|
|||||||
std::string zone;
|
std::string zone;
|
||||||
int16 version;
|
int16 version;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string pos_y;
|
float pos_y;
|
||||||
std::string pos_x;
|
float pos_x;
|
||||||
std::string pos_z;
|
float pos_z;
|
||||||
std::string heading;
|
float heading;
|
||||||
int16 opentype;
|
int16 opentype;
|
||||||
int16 guild;
|
int16 guild;
|
||||||
int16 lockpick;
|
int16 lockpick;
|
||||||
@ -48,14 +48,14 @@ public:
|
|||||||
int door_param;
|
int door_param;
|
||||||
std::string dest_zone;
|
std::string dest_zone;
|
||||||
int dest_instance;
|
int dest_instance;
|
||||||
std::string dest_x;
|
float dest_x;
|
||||||
std::string dest_y;
|
float dest_y;
|
||||||
std::string dest_z;
|
float dest_z;
|
||||||
std::string dest_heading;
|
float dest_heading;
|
||||||
int invert_state;
|
int invert_state;
|
||||||
int incline;
|
int incline;
|
||||||
int16 size;
|
int16 size;
|
||||||
std::string buffer;
|
float buffer;
|
||||||
int client_version_mask;
|
int client_version_mask;
|
||||||
int16 is_ldon_door;
|
int16 is_ldon_door;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,293 +0,0 @@
|
|||||||
/**
|
|
||||||
* EQEmulator: Everquest Server Emulator
|
|
||||||
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; version 2 of the License.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
|
||||||
* are required to give you total support for your newly bought product;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef EQEMU_EQTIME_REPOSITORY_H
|
|
||||||
#define EQEMU_EQTIME_REPOSITORY_H
|
|
||||||
|
|
||||||
#include "../database.h"
|
|
||||||
#include "../string_util.h"
|
|
||||||
|
|
||||||
class EqtimeRepository {
|
|
||||||
public:
|
|
||||||
struct Eqtime {
|
|
||||||
int8 minute;
|
|
||||||
int8 hour;
|
|
||||||
int8 day;
|
|
||||||
int8 month;
|
|
||||||
int year;
|
|
||||||
int realtime;
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
|
||||||
{
|
|
||||||
return std::string("");
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<std::string> Columns()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
"minute",
|
|
||||||
"hour",
|
|
||||||
"day",
|
|
||||||
"month",
|
|
||||||
"year",
|
|
||||||
"realtime",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string ColumnsRaw()
|
|
||||||
{
|
|
||||||
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("eqtime");
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string BaseSelect()
|
|
||||||
{
|
|
||||||
return fmt::format(
|
|
||||||
"SELECT {} FROM {}",
|
|
||||||
ColumnsRaw(),
|
|
||||||
TableName()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string BaseInsert()
|
|
||||||
{
|
|
||||||
return fmt::format(
|
|
||||||
"INSERT INTO {} ({}) ",
|
|
||||||
TableName(),
|
|
||||||
InsertColumnsRaw()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Eqtime NewEntity()
|
|
||||||
{
|
|
||||||
Eqtime entry{};
|
|
||||||
|
|
||||||
entry.minute = 0;
|
|
||||||
entry.hour = 0;
|
|
||||||
entry.day = 0;
|
|
||||||
entry.month = 0;
|
|
||||||
entry.year = 0;
|
|
||||||
entry.realtime = 0;
|
|
||||||
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Eqtime GetEqtimeEntry(
|
|
||||||
const std::vector<Eqtime> &eqtimes,
|
|
||||||
int eqtime_id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
for (auto &eqtime : eqtimes) {
|
|
||||||
if (eqtime. == eqtime_id) {
|
|
||||||
return eqtime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NewEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
static Eqtime FindOne(
|
|
||||||
int eqtime_id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto results = database.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"{} WHERE id = {} LIMIT 1",
|
|
||||||
BaseSelect(),
|
|
||||||
eqtime_id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
auto row = results.begin();
|
|
||||||
if (results.RowCount() == 1) {
|
|
||||||
Eqtime entry{};
|
|
||||||
|
|
||||||
entry.minute = atoi(row[0]);
|
|
||||||
entry.hour = atoi(row[1]);
|
|
||||||
entry.day = atoi(row[2]);
|
|
||||||
entry.month = atoi(row[3]);
|
|
||||||
entry.year = atoi(row[4]);
|
|
||||||
entry.realtime = atoi(row[5]);
|
|
||||||
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NewEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
static int DeleteOne(
|
|
||||||
int eqtime_id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto results = database.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"DELETE FROM {} WHERE {} = {}",
|
|
||||||
TableName(),
|
|
||||||
PrimaryKey(),
|
|
||||||
eqtime_id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return (results.Success() ? results.RowsAffected() : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int UpdateOne(
|
|
||||||
Eqtime eqtime_entry
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::vector<std::string> update_values;
|
|
||||||
|
|
||||||
auto columns = Columns();
|
|
||||||
|
|
||||||
update_values.push_back(columns[0] + " = " + std::to_string(eqtime_entry.minute));
|
|
||||||
update_values.push_back(columns[1] + " = " + std::to_string(eqtime_entry.hour));
|
|
||||||
update_values.push_back(columns[2] + " = " + std::to_string(eqtime_entry.day));
|
|
||||||
update_values.push_back(columns[3] + " = " + std::to_string(eqtime_entry.month));
|
|
||||||
update_values.push_back(columns[4] + " = " + std::to_string(eqtime_entry.year));
|
|
||||||
update_values.push_back(columns[5] + " = " + std::to_string(eqtime_entry.realtime));
|
|
||||||
|
|
||||||
auto results = database.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"UPDATE {} SET {} WHERE {} = {}",
|
|
||||||
TableName(),
|
|
||||||
implode(", ", update_values),
|
|
||||||
PrimaryKey(),
|
|
||||||
eqtime_entry.
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return (results.Success() ? results.RowsAffected() : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Eqtime InsertOne(
|
|
||||||
Eqtime eqtime_entry
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::vector<std::string> insert_values;
|
|
||||||
|
|
||||||
insert_values.push_back(std::to_string(eqtime_entry.minute));
|
|
||||||
insert_values.push_back(std::to_string(eqtime_entry.hour));
|
|
||||||
insert_values.push_back(std::to_string(eqtime_entry.day));
|
|
||||||
insert_values.push_back(std::to_string(eqtime_entry.month));
|
|
||||||
insert_values.push_back(std::to_string(eqtime_entry.year));
|
|
||||||
insert_values.push_back(std::to_string(eqtime_entry.realtime));
|
|
||||||
|
|
||||||
auto results = database.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"{} VALUES ({})",
|
|
||||||
BaseInsert(),
|
|
||||||
implode(",", insert_values)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (results.Success()) {
|
|
||||||
eqtime_entry.id = results.LastInsertedID();
|
|
||||||
return eqtime_entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
eqtime_entry = InstanceListRepository::NewEntity();
|
|
||||||
|
|
||||||
return eqtime_entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int InsertMany(
|
|
||||||
std::vector<Eqtime> eqtime_entries
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::vector<std::string> insert_chunks;
|
|
||||||
|
|
||||||
for (auto &eqtime_entry: eqtime_entries) {
|
|
||||||
std::vector<std::string> insert_values;
|
|
||||||
|
|
||||||
insert_values.push_back(std::to_string(eqtime_entry.minute));
|
|
||||||
insert_values.push_back(std::to_string(eqtime_entry.hour));
|
|
||||||
insert_values.push_back(std::to_string(eqtime_entry.day));
|
|
||||||
insert_values.push_back(std::to_string(eqtime_entry.month));
|
|
||||||
insert_values.push_back(std::to_string(eqtime_entry.year));
|
|
||||||
insert_values.push_back(std::to_string(eqtime_entry.realtime));
|
|
||||||
|
|
||||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> insert_values;
|
|
||||||
|
|
||||||
auto results = database.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"{} VALUES {}",
|
|
||||||
BaseInsert(),
|
|
||||||
implode(",", insert_chunks)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return (results.Success() ? results.RowsAffected() : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<Eqtime> All()
|
|
||||||
{
|
|
||||||
std::vector<Eqtime> all_entries;
|
|
||||||
|
|
||||||
auto results = database.QueryDatabase(
|
|
||||||
fmt::format(
|
|
||||||
"{}",
|
|
||||||
BaseSelect()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
all_entries.reserve(results.RowCount());
|
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
|
||||||
Eqtime entry{};
|
|
||||||
|
|
||||||
entry.minute = atoi(row[0]);
|
|
||||||
entry.hour = atoi(row[1]);
|
|
||||||
entry.day = atoi(row[2]);
|
|
||||||
entry.month = atoi(row[3]);
|
|
||||||
entry.year = atoi(row[4]);
|
|
||||||
entry.realtime = atoi(row[5]);
|
|
||||||
|
|
||||||
all_entries.push_back(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
return all_entries;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //EQEMU_EQTIME_REPOSITORY_H
|
|
||||||
@ -27,12 +27,12 @@
|
|||||||
class GraveyardRepository {
|
class GraveyardRepository {
|
||||||
public:
|
public:
|
||||||
struct Graveyard {
|
struct Graveyard {
|
||||||
int id;
|
int id;
|
||||||
int zone_id;
|
int zone_id;
|
||||||
std::string x;
|
float x;
|
||||||
std::string y;
|
float y;
|
||||||
std::string z;
|
float z;
|
||||||
std::string heading;
|
float heading;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
static std::string PrimaryKey()
|
||||||
|
|||||||
@ -30,12 +30,12 @@ public:
|
|||||||
int id;
|
int id;
|
||||||
int zoneid;
|
int zoneid;
|
||||||
int16 version;
|
int16 version;
|
||||||
std::string max_x;
|
float max_x;
|
||||||
std::string max_y;
|
float max_y;
|
||||||
std::string max_z;
|
float max_z;
|
||||||
std::string min_x;
|
float min_x;
|
||||||
std::string min_y;
|
float min_y;
|
||||||
std::string heading;
|
float heading;
|
||||||
std::string name;
|
std::string name;
|
||||||
int item;
|
int item;
|
||||||
int max_allowed;
|
int max_allowed;
|
||||||
|
|||||||
@ -27,9 +27,9 @@
|
|||||||
class LevelExpModsRepository {
|
class LevelExpModsRepository {
|
||||||
public:
|
public:
|
||||||
struct LevelExpMods {
|
struct LevelExpMods {
|
||||||
int level;
|
int level;
|
||||||
std::string exp_mod;
|
float exp_mod;
|
||||||
std::string aa_exp_mod;
|
float aa_exp_mod;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
static std::string PrimaryKey()
|
||||||
|
|||||||
@ -27,15 +27,15 @@
|
|||||||
class LootdropEntriesRepository {
|
class LootdropEntriesRepository {
|
||||||
public:
|
public:
|
||||||
struct LootdropEntries {
|
struct LootdropEntries {
|
||||||
int lootdrop_id;
|
int lootdrop_id;
|
||||||
int item_id;
|
int item_id;
|
||||||
int16 item_charges;
|
int16 item_charges;
|
||||||
int8 equip_item;
|
int8 equip_item;
|
||||||
std::string chance;
|
float chance;
|
||||||
std::string disabled_chance;
|
float disabled_chance;
|
||||||
int8 minlevel;
|
int8 minlevel;
|
||||||
int8 maxlevel;
|
int8 maxlevel;
|
||||||
int8 multiplier;
|
int8 multiplier;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
static std::string PrimaryKey()
|
||||||
|
|||||||
@ -27,12 +27,12 @@
|
|||||||
class LoottableEntriesRepository {
|
class LoottableEntriesRepository {
|
||||||
public:
|
public:
|
||||||
struct LoottableEntries {
|
struct LoottableEntries {
|
||||||
int loottable_id;
|
int loottable_id;
|
||||||
int lootdrop_id;
|
int lootdrop_id;
|
||||||
int8 multiplier;
|
int8 multiplier;
|
||||||
int8 droplimit;
|
int8 droplimit;
|
||||||
int8 mindrop;
|
int8 mindrop;
|
||||||
std::string probability;
|
float probability;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
static std::string PrimaryKey()
|
||||||
|
|||||||
@ -40,7 +40,7 @@ public:
|
|||||||
int8 texture;
|
int8 texture;
|
||||||
int8 helmtexture;
|
int8 helmtexture;
|
||||||
int herosforgemodel;
|
int herosforgemodel;
|
||||||
std::string size;
|
float size;
|
||||||
int hp_regen_rate;
|
int hp_regen_rate;
|
||||||
int mana_regen_rate;
|
int mana_regen_rate;
|
||||||
int loottable_id;
|
int loottable_id;
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
int8 prim_melee_type;
|
int8 prim_melee_type;
|
||||||
int8 sec_melee_type;
|
int8 sec_melee_type;
|
||||||
int8 ranged_type;
|
int8 ranged_type;
|
||||||
std::string runspeed;
|
float runspeed;
|
||||||
int16 MR;
|
int16 MR;
|
||||||
int16 CR;
|
int16 CR;
|
||||||
int16 DR;
|
int16 DR;
|
||||||
@ -92,7 +92,7 @@ public:
|
|||||||
int16 AC;
|
int16 AC;
|
||||||
int8 npc_aggro;
|
int8 npc_aggro;
|
||||||
int8 spawn_limit;
|
int8 spawn_limit;
|
||||||
std::string attack_speed;
|
float attack_speed;
|
||||||
int8 attack_delay;
|
int8 attack_delay;
|
||||||
int8 findable;
|
int8 findable;
|
||||||
int STR;
|
int STR;
|
||||||
@ -119,8 +119,8 @@ public:
|
|||||||
int8 underwater;
|
int8 underwater;
|
||||||
int8 isquest;
|
int8 isquest;
|
||||||
int emoteid;
|
int emoteid;
|
||||||
std::string spellscale;
|
float spellscale;
|
||||||
std::string healscale;
|
float healscale;
|
||||||
int8 no_target_hotkey;
|
int8 no_target_hotkey;
|
||||||
int8 raid_target;
|
int8 raid_target;
|
||||||
int8 armtexture;
|
int8 armtexture;
|
||||||
|
|||||||
@ -30,10 +30,10 @@ public:
|
|||||||
int id;
|
int id;
|
||||||
int zoneid;
|
int zoneid;
|
||||||
int16 version;
|
int16 version;
|
||||||
std::string xpos;
|
float xpos;
|
||||||
std::string ypos;
|
float ypos;
|
||||||
std::string zpos;
|
float zpos;
|
||||||
std::string heading;
|
float heading;
|
||||||
int itemid;
|
int itemid;
|
||||||
int16 charges;
|
int16 charges;
|
||||||
std::string objectname;
|
std::string objectname;
|
||||||
@ -49,9 +49,9 @@ public:
|
|||||||
int unknown72;
|
int unknown72;
|
||||||
int unknown76;
|
int unknown76;
|
||||||
int unknown84;
|
int unknown84;
|
||||||
std::string size;
|
float size;
|
||||||
std::string tilt_x;
|
float tilt_x;
|
||||||
std::string tilt_y;
|
float tilt_y;
|
||||||
std::string display_name;
|
std::string display_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -27,14 +27,14 @@
|
|||||||
class ProximitiesRepository {
|
class ProximitiesRepository {
|
||||||
public:
|
public:
|
||||||
struct Proximities {
|
struct Proximities {
|
||||||
int zoneid;
|
int zoneid;
|
||||||
int exploreid;
|
int exploreid;
|
||||||
std::string minx;
|
float minx;
|
||||||
std::string maxx;
|
float maxx;
|
||||||
std::string miny;
|
float miny;
|
||||||
std::string maxy;
|
float maxy;
|
||||||
std::string minz;
|
float minz;
|
||||||
std::string maxz;
|
float maxz;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
static std::string PrimaryKey()
|
||||||
|
|||||||
@ -31,10 +31,10 @@ public:
|
|||||||
int spawngroupID;
|
int spawngroupID;
|
||||||
std::string zone;
|
std::string zone;
|
||||||
int16 version;
|
int16 version;
|
||||||
std::string x;
|
float x;
|
||||||
std::string y;
|
float y;
|
||||||
std::string z;
|
float z;
|
||||||
std::string heading;
|
float heading;
|
||||||
int respawntime;
|
int respawntime;
|
||||||
int variance;
|
int variance;
|
||||||
int pathgrid;
|
int pathgrid;
|
||||||
|
|||||||
@ -254,10 +254,10 @@ public:
|
|||||||
int persistdeath;
|
int persistdeath;
|
||||||
int field225;
|
int field225;
|
||||||
int field226;
|
int field226;
|
||||||
std::string min_dist;
|
float min_dist;
|
||||||
std::string min_dist_mod;
|
float min_dist_mod;
|
||||||
std::string max_dist;
|
float max_dist;
|
||||||
std::string max_dist_mod;
|
float max_dist_mod;
|
||||||
int min_range;
|
int min_range;
|
||||||
int field232;
|
int field232;
|
||||||
int field233;
|
int field233;
|
||||||
|
|||||||
@ -27,21 +27,21 @@
|
|||||||
class StartZonesRepository {
|
class StartZonesRepository {
|
||||||
public:
|
public:
|
||||||
struct StartZones {
|
struct StartZones {
|
||||||
std::string x;
|
float x;
|
||||||
std::string y;
|
float y;
|
||||||
std::string z;
|
float z;
|
||||||
std::string heading;
|
float heading;
|
||||||
int zone_id;
|
int zone_id;
|
||||||
int bind_id;
|
int bind_id;
|
||||||
int player_choice;
|
int player_choice;
|
||||||
int player_class;
|
int player_class;
|
||||||
int player_deity;
|
int player_deity;
|
||||||
int player_race;
|
int player_race;
|
||||||
int start_zone;
|
int start_zone;
|
||||||
std::string bind_x;
|
float bind_x;
|
||||||
std::string bind_y;
|
float bind_y;
|
||||||
std::string bind_z;
|
float bind_z;
|
||||||
int8 select_rank;
|
int8 select_rank;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
static std::string PrimaryKey()
|
||||||
|
|||||||
@ -34,8 +34,8 @@ public:
|
|||||||
int y;
|
int y;
|
||||||
int z;
|
int z;
|
||||||
int8 chance;
|
int8 chance;
|
||||||
std::string maxzdiff;
|
float maxzdiff;
|
||||||
std::string radius;
|
float radius;
|
||||||
int effect;
|
int effect;
|
||||||
int effectvalue;
|
int effectvalue;
|
||||||
int effectvalue2;
|
int effectvalue2;
|
||||||
|
|||||||
@ -31,18 +31,18 @@ public:
|
|||||||
std::string zone;
|
std::string zone;
|
||||||
int version;
|
int version;
|
||||||
int16 number;
|
int16 number;
|
||||||
std::string y;
|
float y;
|
||||||
std::string x;
|
float x;
|
||||||
std::string z;
|
float z;
|
||||||
std::string heading;
|
float heading;
|
||||||
std::string target_y;
|
float target_y;
|
||||||
std::string target_x;
|
float target_x;
|
||||||
std::string target_z;
|
float target_z;
|
||||||
std::string target_heading;
|
float target_heading;
|
||||||
int16 zoneinst;
|
int16 zoneinst;
|
||||||
int target_zone_id;
|
int target_zone_id;
|
||||||
int target_instance;
|
int target_instance;
|
||||||
std::string buffer;
|
float buffer;
|
||||||
int client_version_mask;
|
int client_version_mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -32,10 +32,10 @@ public:
|
|||||||
std::string file_name;
|
std::string file_name;
|
||||||
std::string long_name;
|
std::string long_name;
|
||||||
std::string map_file_name;
|
std::string map_file_name;
|
||||||
std::string safe_x;
|
float safe_x;
|
||||||
std::string safe_y;
|
float safe_y;
|
||||||
std::string safe_z;
|
float safe_z;
|
||||||
std::string graveyard_id;
|
float graveyard_id;
|
||||||
int8 min_level;
|
int8 min_level;
|
||||||
int8 min_status;
|
int8 min_status;
|
||||||
int zoneidnumber;
|
int zoneidnumber;
|
||||||
@ -44,40 +44,40 @@ public:
|
|||||||
int maxclients;
|
int maxclients;
|
||||||
int ruleset;
|
int ruleset;
|
||||||
std::string note;
|
std::string note;
|
||||||
std::string underworld;
|
float underworld;
|
||||||
std::string minclip;
|
float minclip;
|
||||||
std::string maxclip;
|
float maxclip;
|
||||||
std::string fog_minclip;
|
float fog_minclip;
|
||||||
std::string fog_maxclip;
|
float fog_maxclip;
|
||||||
int8 fog_blue;
|
int8 fog_blue;
|
||||||
int8 fog_red;
|
int8 fog_red;
|
||||||
int8 fog_green;
|
int8 fog_green;
|
||||||
int8 sky;
|
int8 sky;
|
||||||
int8 ztype;
|
int8 ztype;
|
||||||
std::string zone_exp_multiplier;
|
float zone_exp_multiplier;
|
||||||
std::string walkspeed;
|
float walkspeed;
|
||||||
int8 time_type;
|
int8 time_type;
|
||||||
int8 fog_red1;
|
int8 fog_red1;
|
||||||
int8 fog_green1;
|
int8 fog_green1;
|
||||||
int8 fog_blue1;
|
int8 fog_blue1;
|
||||||
std::string fog_minclip1;
|
float fog_minclip1;
|
||||||
std::string fog_maxclip1;
|
float fog_maxclip1;
|
||||||
int8 fog_red2;
|
int8 fog_red2;
|
||||||
int8 fog_green2;
|
int8 fog_green2;
|
||||||
int8 fog_blue2;
|
int8 fog_blue2;
|
||||||
std::string fog_minclip2;
|
float fog_minclip2;
|
||||||
std::string fog_maxclip2;
|
float fog_maxclip2;
|
||||||
int8 fog_red3;
|
int8 fog_red3;
|
||||||
int8 fog_green3;
|
int8 fog_green3;
|
||||||
int8 fog_blue3;
|
int8 fog_blue3;
|
||||||
std::string fog_minclip3;
|
float fog_minclip3;
|
||||||
std::string fog_maxclip3;
|
float fog_maxclip3;
|
||||||
int8 fog_red4;
|
int8 fog_red4;
|
||||||
int8 fog_green4;
|
int8 fog_green4;
|
||||||
int8 fog_blue4;
|
int8 fog_blue4;
|
||||||
std::string fog_minclip4;
|
float fog_minclip4;
|
||||||
std::string fog_maxclip4;
|
float fog_maxclip4;
|
||||||
std::string fog_density;
|
float fog_density;
|
||||||
std::string flag_needed;
|
std::string flag_needed;
|
||||||
int8 canbind;
|
int8 canbind;
|
||||||
int8 cancombat;
|
int8 cancombat;
|
||||||
@ -105,7 +105,7 @@ public:
|
|||||||
int snow_duration2;
|
int snow_duration2;
|
||||||
int snow_duration3;
|
int snow_duration3;
|
||||||
int snow_duration4;
|
int snow_duration4;
|
||||||
std::string gravity;
|
float gravity;
|
||||||
int type;
|
int type;
|
||||||
int8 skylock;
|
int8 skylock;
|
||||||
int fast_regen_hp;
|
int fast_regen_hp;
|
||||||
|
|||||||
@ -117,6 +117,8 @@ foreach my $table_to_generate (@tables) {
|
|||||||
# These tables don't have a typical schema
|
# These tables don't have a typical schema
|
||||||
my @table_ignore_list = (
|
my @table_ignore_list = (
|
||||||
"character_enabledtasks",
|
"character_enabledtasks",
|
||||||
|
"eqtime",
|
||||||
|
"db_version",
|
||||||
"keyring",
|
"keyring",
|
||||||
"profanity_list",
|
"profanity_list",
|
||||||
"zone_flags",
|
"zone_flags",
|
||||||
@ -201,7 +203,7 @@ foreach my $table_to_generate (@tables) {
|
|||||||
my $column_key = $row[5];
|
my $column_key = $row[5];
|
||||||
my $column_default = ($row[6] ? $row[6] : "");
|
my $column_default = ($row[6] ? $row[6] : "");
|
||||||
|
|
||||||
if ($column_key eq "PRI") {
|
if ($column_key eq "PRI" || ($ordinal_position == 0 && $column_name=~/id/i)) {
|
||||||
$table_primary_key{$table_name} = $column_name;
|
$table_primary_key{$table_name} = $column_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,9 +382,16 @@ sub translate_mysql_data_type_to_c {
|
|||||||
elsif ($mysql_data_type =~ /smallint/) {
|
elsif ($mysql_data_type =~ /smallint/) {
|
||||||
$struct_data_type = 'int16';
|
$struct_data_type = 'int16';
|
||||||
}
|
}
|
||||||
|
elsif ($mysql_data_type =~ /bigint/) {
|
||||||
|
$struct_data_type = 'int';
|
||||||
|
# Use regular int for now until we have 64 support
|
||||||
|
}
|
||||||
elsif ($mysql_data_type =~ /int/) {
|
elsif ($mysql_data_type =~ /int/) {
|
||||||
$struct_data_type = 'int';
|
$struct_data_type = 'int';
|
||||||
}
|
}
|
||||||
|
elsif ($mysql_data_type =~ /float|double|decimal/) {
|
||||||
|
$struct_data_type = 'float';
|
||||||
|
}
|
||||||
|
|
||||||
return $struct_data_type;
|
return $struct_data_type;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user