mirror of
https://github.com/EQEmu/Server.git
synced 2026-01-05 08:23:52 +00:00
Migrate adventure database calls [skip ci]
This commit is contained in:
parent
dde9b98e4f
commit
7cf52d467e
@ -632,53 +632,90 @@ AdventureTemplate *AdventureManager::GetAdventureTemplate(int id)
|
||||
|
||||
bool AdventureManager::LoadAdventureTemplates()
|
||||
{
|
||||
std::string query = "SELECT id, zone, zone_version, "
|
||||
"is_hard, 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 FROM adventure_template";
|
||||
std::string query =
|
||||
SQL (
|
||||
SELECT
|
||||
id,
|
||||
zone,
|
||||
zone_version,
|
||||
is_hard,
|
||||
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
|
||||
FROM
|
||||
adventure_template
|
||||
)
|
||||
;
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
auto aTemplate = new AdventureTemplate;
|
||||
aTemplate->id = atoi(row[0]);
|
||||
strcpy(aTemplate->zone, row[1]);
|
||||
aTemplate->zone_version = atoi(row[2]);
|
||||
aTemplate->is_hard = atoi(row[3]);
|
||||
aTemplate->min_level = atoi(row[4]);
|
||||
aTemplate->max_level = atoi(row[5]);
|
||||
aTemplate->type = atoi(row[6]);
|
||||
aTemplate->type_data = atoi(row[7]);
|
||||
aTemplate->type_count = atoi(row[8]);
|
||||
aTemplate->assa_x = atof(row[9]);
|
||||
aTemplate->assa_y = atof(row[10]);
|
||||
aTemplate->assa_z = atof(row[11]);
|
||||
aTemplate->assa_h = atof(row[12]);
|
||||
strn0cpy(aTemplate->text, row[13], sizeof(aTemplate->text));
|
||||
aTemplate->duration = atoi(row[14]);
|
||||
aTemplate->zone_in_time = atoi(row[15]);
|
||||
aTemplate->win_points = atoi(row[16]);
|
||||
aTemplate->lose_points = atoi(row[17]);
|
||||
aTemplate->theme = atoi(row[18]);
|
||||
aTemplate->zone_in_zone_id = atoi(row[19]);
|
||||
aTemplate->zone_in_x = atof(row[20]);
|
||||
aTemplate->zone_in_y = atof(row[21]);
|
||||
aTemplate->zone_in_object_id = atoi(row[22]);
|
||||
aTemplate->dest_x = atof(row[23]);
|
||||
aTemplate->dest_y = atof(row[24]);
|
||||
aTemplate->dest_z = atof(row[25]);
|
||||
aTemplate->dest_h = atof(row[26]);
|
||||
aTemplate->graveyard_zone_id = atoi(row[27]);
|
||||
aTemplate->graveyard_x = atof(row[28]);
|
||||
aTemplate->graveyard_y = atof(row[29]);
|
||||
aTemplate->graveyard_z = atof(row[30]);
|
||||
aTemplate->graveyard_radius = atof(row[31]);
|
||||
adventure_templates[aTemplate->id] = aTemplate;
|
||||
}
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
auto adventure_template = new AdventureTemplate;
|
||||
adventure_template->id = atoi(row[0]);
|
||||
strcpy(adventure_template->zone, row[1]);
|
||||
|
||||
adventure_template->zone_version = atoi(row[2]);
|
||||
adventure_template->is_hard = atoi(row[3]);
|
||||
adventure_template->min_level = atoi(row[4]);
|
||||
adventure_template->max_level = atoi(row[5]);
|
||||
adventure_template->type = atoi(row[6]);
|
||||
adventure_template->type_data = atoi(row[7]);
|
||||
adventure_template->type_count = atoi(row[8]);
|
||||
adventure_template->assa_x = atof(row[9]);
|
||||
adventure_template->assa_y = atof(row[10]);
|
||||
adventure_template->assa_z = atof(row[11]);
|
||||
adventure_template->assa_h = atof(row[12]);
|
||||
|
||||
strn0cpy(adventure_template->text, row[13], sizeof(adventure_template->text));
|
||||
|
||||
adventure_template->duration = atoi(row[14]);
|
||||
adventure_template->zone_in_time = atoi(row[15]);
|
||||
adventure_template->win_points = atoi(row[16]);
|
||||
adventure_template->lose_points = atoi(row[17]);
|
||||
adventure_template->theme = atoi(row[18]);
|
||||
adventure_template->zone_in_zone_id = atoi(row[19]);
|
||||
adventure_template->zone_in_x = atof(row[20]);
|
||||
adventure_template->zone_in_y = atof(row[21]);
|
||||
adventure_template->zone_in_object_id = atoi(row[22]);
|
||||
adventure_template->dest_x = atof(row[23]);
|
||||
adventure_template->dest_y = atof(row[24]);
|
||||
adventure_template->dest_z = atof(row[25]);
|
||||
adventure_template->dest_h = atof(row[26]);
|
||||
adventure_template->graveyard_zone_id = atoi(row[27]);
|
||||
adventure_template->graveyard_x = atof(row[28]);
|
||||
adventure_template->graveyard_y = atof(row[29]);
|
||||
adventure_template->graveyard_z = atof(row[30]);
|
||||
adventure_template->graveyard_radius = atof(row[31]);
|
||||
|
||||
adventure_templates[adventure_template->id] = adventure_template;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -686,7 +723,7 @@ bool AdventureManager::LoadAdventureTemplates()
|
||||
bool AdventureManager::LoadAdventureEntries()
|
||||
{
|
||||
std::string query = "SELECT id, template_id FROM adventure_template_entry";
|
||||
auto results = database.QueryDatabase(query);
|
||||
auto results = content_db.QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
{
|
||||
return false;
|
||||
|
||||
@ -137,6 +137,25 @@ void LoadDatabaseConnections()
|
||||
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multi-tenancy: Content database
|
||||
*/
|
||||
if (!Config->ContentDbHost.empty()) {
|
||||
if (!content_db.Connect(
|
||||
!Config->ContentDbHost.empty() ? Config->ContentDbHost.c_str() : Config->DatabaseHost.c_str(),
|
||||
!Config->ContentDbUsername.empty() ? Config->ContentDbUsername.c_str() : Config->DatabaseUsername.c_str(),
|
||||
!Config->ContentDbPassword.empty() ? Config->ContentDbPassword.c_str() : Config->DatabasePassword.c_str(),
|
||||
!Config->ContentDbName.empty() ? Config->ContentDbName.c_str() : Config->DatabaseDB.c_str(),
|
||||
Config->ContentDbPort != 0 ? Config->ContentDbPort : Config->DatabasePort
|
||||
)) {
|
||||
LogError("Cannot continue without a content database connection");
|
||||
std::exit(1);
|
||||
}
|
||||
} else {
|
||||
content_db.SetMysql(database.getMySQL());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CheckForXMLConfigUpgrade()
|
||||
@ -587,6 +606,7 @@ int main(int argc, char** argv) {
|
||||
if (InterserverTimer.Check()) {
|
||||
InterserverTimer.Start();
|
||||
database.ping();
|
||||
content_db.ping();
|
||||
|
||||
std::string window_title = StringFormat("World: %s Clients: %i", Config->LongName.c_str(), client_list.GetClientCount());
|
||||
UpdateWindowTitle(window_title);
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#include "sof_char_create_data.h"
|
||||
|
||||
WorldDatabase database;
|
||||
WorldDatabase content_db;
|
||||
extern std::vector<RaceClassAllocation> character_create_allocations;
|
||||
extern std::vector<RaceClassCombos> character_create_race_class_combos;
|
||||
|
||||
|
||||
@ -46,5 +46,6 @@ private:
|
||||
};
|
||||
|
||||
extern WorldDatabase database;
|
||||
extern WorldDatabase content_db;
|
||||
|
||||
#endif /*WORLDDB_H_*/
|
||||
|
||||
@ -1595,7 +1595,7 @@ bool Mob::CanPurchaseAlternateAdvancementRank(AA::Rank *rank, bool check_price,
|
||||
|
||||
void Zone::LoadAlternateAdvancement() {
|
||||
LogInfo("Loading Alternate Advancement Data");
|
||||
if(!database.LoadAlternateAdvancementAbilities(aa_abilities,
|
||||
if(!content_db.LoadAlternateAdvancementAbilities(aa_abilities,
|
||||
aa_ranks))
|
||||
{
|
||||
aa_abilities.clear();
|
||||
|
||||
@ -8225,7 +8225,7 @@ void command_npcedit(Client *c, const Seperator *sep)
|
||||
if (strcasecmp(sep->arg[1], "adventure_template_id") == 0) {
|
||||
c->Message(Chat::Yellow,"NPCID %u now has field 'adventure_template_id' set to %s.", npcTypeID, sep->argplus[2]);
|
||||
std::string query = StringFormat("UPDATE npc_types SET adventure_template_id = '%s' WHERE id = %i", sep->argplus[2],npcTypeID);
|
||||
database.QueryDatabase(query);
|
||||
content_db.QueryDatabase(query);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -2209,7 +2209,7 @@ void Zone::DeleteQGlobal(std::string name, uint32 npcID, uint32 charID, uint32 z
|
||||
void Zone::LoadAdventureFlavor()
|
||||
{
|
||||
const std::string query = "SELECT id, text FROM adventure_template_entry_flavor";
|
||||
auto results = database.QueryDatabase(query);
|
||||
auto results = content_db.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user