From 286c08b8d5ef5efe390172bda1ce8ac537b4ffc3 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Thu, 12 Mar 2020 00:00:39 -0500 Subject: [PATCH] Migrate spawn tables [skip ci] --- common/database_instances.cpp | 1 + shared_memory/main.cpp | 6 +++-- zone/aa.cpp | 6 ++--- zone/aura.cpp | 2 +- zone/client.cpp | 12 +++++----- zone/command.cpp | 40 ++++++++++++++++---------------- zone/forage.cpp | 2 +- zone/pets.cpp | 10 ++++---- zone/quest_parser_collection.cpp | 2 +- zone/questmgr.cpp | 10 ++++---- zone/spawn2.cpp | 20 ++++++++-------- zone/trap.cpp | 6 ++--- zone/zone.cpp | 8 +++---- 13 files changed, 64 insertions(+), 61 deletions(-) diff --git a/common/database_instances.cpp b/common/database_instances.cpp index 548a84bdb..b84924192 100644 --- a/common/database_instances.cpp +++ b/common/database_instances.cpp @@ -485,6 +485,7 @@ void Database::BuryCorpsesInInstance(uint16 instance_id) { void Database::DeleteInstance(uint16 instance_id) { + // TODO: BOUNDARY REWRITE std::string query = StringFormat("DELETE FROM instance_list WHERE id=%u", instance_id); QueryDatabase(query); diff --git a/shared_memory/main.cpp b/shared_memory/main.cpp index 69b46d896..fe4821e4a 100644 --- a/shared_memory/main.cpp +++ b/shared_memory/main.cpp @@ -84,8 +84,10 @@ int main(int argc, char **argv) { SharedDatabase database; LogInfo("Connecting to database"); - if(!database.Connect(Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(), - Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) { + if (!database.Connect( + Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(), + Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort + )) { LogError("Unable to connect to the database, cannot continue without a database connection"); return 1; } diff --git a/zone/aa.cpp b/zone/aa.cpp index c9e2eea9a..2e77684db 100644 --- a/zone/aa.cpp +++ b/zone/aa.cpp @@ -81,7 +81,7 @@ void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, u NPCType *made_npc = nullptr; - const NPCType *npc_type = database.LoadNPCTypesData(pet.npc_id); + const NPCType *npc_type = content_db.LoadNPCTypesData(pet.npc_id); if (npc_type == nullptr) { //log write LogError("Unknown npc type for swarm pet spell id: [{}]", spell_id); @@ -186,7 +186,7 @@ void Mob::TypesTemporaryPets(uint32 typesid, Mob *targ, const char *name_overrid NPCType *made_npc = nullptr; - const NPCType *npc_type = database.LoadNPCTypesData(typesid); + const NPCType *npc_type = content_db.LoadNPCTypesData(typesid); if(npc_type == nullptr) { //log write LogError("Unknown npc type for swarm pet type id: [{}]", typesid); @@ -281,7 +281,7 @@ void Mob::WakeTheDead(uint16 spell_id, Mob *target, uint32 duration) return; //assuming we have pets in our table; we take the first pet as a base type. - const NPCType *base_type = database.LoadNPCTypesData(500); + const NPCType *base_type = content_db.LoadNPCTypesData(500); auto make_npc = new NPCType; memcpy(make_npc, base_type, sizeof(NPCType)); diff --git a/zone/aura.cpp b/zone/aura.cpp index 2c00f529e..40cf4a481 100644 --- a/zone/aura.cpp +++ b/zone/aura.cpp @@ -871,7 +871,7 @@ void Mob::MakeAura(uint16 spell_id) return; } - const auto base = database.LoadNPCTypesData(record.npc_type); + const auto base = content_db.LoadNPCTypesData(record.npc_type); if (base == nullptr) { Message(Chat::Red, "Unable to load NPC data for aura %s", spells[spell_id].teleport_zone); LogError( diff --git a/zone/client.cpp b/zone/client.cpp index 70f543da9..377aae041 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -6205,21 +6205,21 @@ void Client::NPCSpawn(NPC *target_npc, const char *identifier, uint32 extra) if (id == "create") { // extra tries to create the npc_type ID within the range for the current zone (zone_id * 1000) - database.NPCSpawnDB(0, zone->GetShortName(), zone->GetInstanceVersion(), this, target_npc->CastToNPC(), extra); + content_db.NPCSpawnDB(0, zone->GetShortName(), zone->GetInstanceVersion(), this, target_npc->CastToNPC(), extra); } else if (id == "add") { // extra sets the respawn timer for add - database.NPCSpawnDB(1, zone->GetShortName(), zone->GetInstanceVersion(), this, target_npc->CastToNPC(), extra); + content_db.NPCSpawnDB(1, zone->GetShortName(), zone->GetInstanceVersion(), this, target_npc->CastToNPC(), extra); } else if (id == "update") { - database.NPCSpawnDB(2, zone->GetShortName(), zone->GetInstanceVersion(), this, target_npc->CastToNPC()); + content_db.NPCSpawnDB(2, zone->GetShortName(), zone->GetInstanceVersion(), this, target_npc->CastToNPC()); } else if (id == "remove") { - database.NPCSpawnDB(3, zone->GetShortName(), zone->GetInstanceVersion(), this, target_npc->CastToNPC()); + content_db.NPCSpawnDB(3, zone->GetShortName(), zone->GetInstanceVersion(), this, target_npc->CastToNPC()); target_npc->Depop(false); } else if (id == "delete") { - database.NPCSpawnDB(4, zone->GetShortName(), zone->GetInstanceVersion(), this, target_npc->CastToNPC()); + content_db.NPCSpawnDB(4, zone->GetShortName(), zone->GetInstanceVersion(), this, target_npc->CastToNPC()); target_npc->Depop(false); } else { @@ -6323,7 +6323,7 @@ void Client::Doppelganger(uint16 spell_id, Mob *target, const char *name_overrid NPCType *made_npc = nullptr; - const NPCType *npc_type = database.LoadNPCTypesData(pet.npc_id); + const NPCType *npc_type = content_db.LoadNPCTypesData(pet.npc_id); if(npc_type == nullptr) { LogError("Unknown npc type for doppelganger spell id: [{}]", spell_id); Message(0,"Unable to find pet!"); diff --git a/zone/command.cpp b/zone/command.cpp index 8fa109cc8..ebf2b0457 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -3097,7 +3097,7 @@ void command_npctypespawn(Client *c, const Seperator *sep) { if (sep->IsNumber(1)) { const NPCType* tmp = 0; - if ((tmp = database.LoadNPCTypesData(atoi(sep->arg[1])))) { + if ((tmp = content_db.LoadNPCTypesData(atoi(sep->arg[1])))) { //tmp->fixedZ = 1; auto npc = new NPC(tmp, 0, c->GetPosition(), GravityBehavior::Water); if (npc && sep->IsNumber(2)) @@ -4196,7 +4196,7 @@ void command_viewnpctype(Client *c, const Seperator *sep) else { uint32 npctypeid=atoi(sep->arg[1]); - const NPCType* npct = database.LoadNPCTypesData(npctypeid); + const NPCType* npct = content_db.LoadNPCTypesData(npctypeid); if (npct) { c->Message(Chat::White, " NPCType Info, "); c->Message(Chat::White, " NPCTypeID: %u", npct->npc_id); @@ -5811,7 +5811,7 @@ void command_npcspawn(Client *c, const Seperator *sep) // Option to try to create the npc_type ID within the range for the current zone (zone_id * 1000) extra = 1; } - database.NPCSpawnDB(0, zone->GetShortName(), zone->GetInstanceVersion(), c, target->CastToNPC(), extra); + content_db.NPCSpawnDB(0, zone->GetShortName(), zone->GetInstanceVersion(), c, target->CastToNPC(), extra); c->Message(Chat::White, "%s created successfully!", target->GetName()); } else if (strcasecmp(sep->arg[1], "add") == 0) { @@ -5824,20 +5824,20 @@ void command_npcspawn(Client *c, const Seperator *sep) // Respawn Timer default if not set extra = 1200; } - database.NPCSpawnDB(1, zone->GetShortName(), zone->GetInstanceVersion(), c, target->CastToNPC(), extra); + content_db.NPCSpawnDB(1, zone->GetShortName(), zone->GetInstanceVersion(), c, target->CastToNPC(), extra); c->Message(Chat::White, "%s added successfully!", target->GetName()); } else if (strcasecmp(sep->arg[1], "update") == 0) { - database.NPCSpawnDB(2, zone->GetShortName(), zone->GetInstanceVersion(), c, target->CastToNPC()); + content_db.NPCSpawnDB(2, zone->GetShortName(), zone->GetInstanceVersion(), c, target->CastToNPC()); c->Message(Chat::White, "%s updated!", target->GetName()); } else if (strcasecmp(sep->arg[1], "remove") == 0) { - database.NPCSpawnDB(3, zone->GetShortName(), zone->GetInstanceVersion(), c, target->CastToNPC()); + content_db.NPCSpawnDB(3, zone->GetShortName(), zone->GetInstanceVersion(), c, target->CastToNPC()); c->Message(Chat::White, "%s removed successfully from database!", target->GetName()); target->Depop(false); } else if (strcasecmp(sep->arg[1], "delete") == 0) { - database.NPCSpawnDB(4, zone->GetShortName(), zone->GetInstanceVersion(), c, target->CastToNPC()); + content_db.NPCSpawnDB(4, zone->GetShortName(), zone->GetInstanceVersion(), c, target->CastToNPC()); c->Message(Chat::White, "%s deleted from database!", target->GetName()); target->Depop(false); } @@ -5866,7 +5866,7 @@ void command_spawnfix(Client *c, const Seperator *sep) { std::string query = StringFormat("UPDATE spawn2 SET x = '%f', y = '%f', z = '%f', heading = '%f' WHERE id = '%i'", c->GetX(), c->GetY(), c->GetZ(), c->GetHeading(),s2->GetID()); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { c->Message(Chat::Red, "Update failed! MySQL gave the following error:"); c->Message(Chat::Red, results.ErrorMessage().c_str()); @@ -8607,7 +8607,7 @@ void command_npcedit(Client *c, const Seperator *sep) c->GetTarget()->CastToNPC()->GetSpawnGroupId() ); std::string query = StringFormat("UPDATE spawn2 SET animation = %i " "WHERE spawngroupID = %i", animation, c->GetTarget()->CastToNPC()->GetSpawnGroupId()); - database.QueryDatabase(query); + content_db.QueryDatabase(query); c->GetTarget()->SetAppearance(EmuAppearance(animation)); return; @@ -8728,7 +8728,7 @@ void command_qglobal(Client *c, const Seperator *sep) { } if(!strcasecmp(sep->arg[1], "view")) { - const NPCType *type = database.LoadNPCTypesData(target->GetNPCTypeID()); + const NPCType *type = content_db.LoadNPCTypesData(target->GetNPCTypeID()); if(!type) c->Message(Chat::Yellow, "Invalid NPC type."); else if(type->qglobal) @@ -9725,7 +9725,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep) return; } - database.NPCSpawnDB(6, zone->GetShortName(), zone->GetInstanceVersion(), c, target->CastToNPC()); + content_db.NPCSpawnDB(6, zone->GetShortName(), zone->GetInstanceVersion(), c, target->CastToNPC()); return; } @@ -9746,7 +9746,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep) (sep->arg[7]? atof(sep->arg[7]): 0), (sep->arg[8]? atof(sep->arg[8]): 0), (sep->arg[9]? atoi(sep->arg[9]): 0)); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { c->Message(Chat::White, "Invalid Arguments -- MySQL gave the following error:"); c->Message(Chat::Red, results.ErrorMessage().c_str()); @@ -9766,7 +9766,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep) std::string query = StringFormat("INSERT INTO spawnentry (spawngroupID, npcID, chance) " "VALUES (%i, %i, %i)", atoi(sep->arg[2]), atoi(sep->arg[3]), atoi(sep->arg[4])); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { c->Message(Chat::White, "Invalid Arguments -- MySQL gave the following error:"); c->Message(Chat::Red, results.ErrorMessage().c_str()); @@ -9789,7 +9789,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep) atof(sep->arg[3]), atof(sep->arg[4]), atof(sep->arg[5]), atof(sep->arg[6]), atof(sep->arg[7]), atoi(sep->arg[8]), atoi(sep->arg[2])); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { c->Message(Chat::White, "Invalid Arguments -- MySQL gave the following error:"); c->Message(Chat::Red, results.ErrorMessage().c_str()); @@ -9811,7 +9811,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep) "SET dist = '0', max_x = '0', min_x = '0', " "max_y = '0', min_y = '0', delay = '0' " "WHERE id = '%i' ", atoi(sep->arg[2])); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { c->Message(Chat::White, "Invalid Arguments -- MySQL gave the following error:"); c->Message(Chat::Red, results.ErrorMessage().c_str()); @@ -9824,7 +9824,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep) } if (strcasecmp(sep->arg[1], "addgroupspawn") == 0 && atoi(sep->arg[2])!=0) { - database.NPCSpawnDB(5, zone->GetShortName(), zone->GetInstanceVersion(), c, 0, atoi(sep->arg[2])); + content_db.NPCSpawnDB(5, zone->GetShortName(), zone->GetInstanceVersion(), c, 0, atoi(sep->arg[2])); c->Message(Chat::White, "Mob of group %i added successfully!", atoi(sep->arg[2])); return; } @@ -9843,7 +9843,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep) } std::string query = StringFormat("DELETE FROM spawn2 WHERE id = '%i'", s2->GetID()); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if(!results.Success()) { c->Message(Chat::Red, "Update failed! MySQL gave the following error:"); c->Message(Chat::Red, results.ErrorMessage().c_str()); @@ -9872,7 +9872,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep) std::string query = StringFormat("UPDATE spawn2 SET x = '%f', y = '%f', z = '%f', heading = '%f' " "WHERE id = '%i'", c->GetX(), c->GetY(), c->GetZ(), c->GetHeading(),s2->GetID()); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { c->Message(Chat::Red, "Update failed! MySQL gave the following error:"); c->Message(Chat::Red, results.ErrorMessage().c_str()); @@ -9912,7 +9912,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep) std::string query = StringFormat("UPDATE spawn2 SET respawntime = %u, variance = %u " "WHERE id = '%i'", new_rs, new_var, s2->GetID()); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { c->Message(Chat::Red, "Update failed! MySQL gave the following error:"); c->Message(Chat::Red, results.ErrorMessage().c_str()); @@ -9941,7 +9941,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep) std::string query = StringFormat("UPDATE spawn2 SET version = %i " "WHERE spawngroupID = '%i'", version, c->GetTarget()->CastToNPC()->GetSpawnGroupId()); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { c->Message(Chat::Red, "Update failed! MySQL gave the following error:"); c->Message(Chat::Red, results.ErrorMessage().c_str()); diff --git a/zone/forage.cpp b/zone/forage.cpp index 8e0290900..f14f1f968 100644 --- a/zone/forage.cpp +++ b/zone/forage.cpp @@ -280,7 +280,7 @@ void Client::GoFish() if (npc_chance > 0 && npc_id) { if (zone->random.Roll(npc_chance)) { if (zone->CanDoCombat()) { - const NPCType *tmp = database.LoadNPCTypesData(npc_id); + const NPCType *tmp = content_db.LoadNPCTypesData(npc_id); if (tmp != nullptr) { auto positionNPC = GetPosition(); positionNPC.x = positionNPC.x + 3; diff --git a/zone/pets.cpp b/zone/pets.cpp index b4897940a..6a5ae12ca 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -211,14 +211,14 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, //lookup our pets table record for this type PetRecord record; - if(!database.GetPoweredPetEntry(pettype, act_power, &record)) { + if(!content_db.GetPoweredPetEntry(pettype, act_power, &record)) { Message(Chat::Red, "Unable to find data for pet %s", pettype); LogError("Unable to find data for pet [{}], check pets table", pettype); return; } //find the NPC data for the specified NPC type - const NPCType *base = database.LoadNPCTypesData(record.npc_type); + const NPCType *base = content_db.LoadNPCTypesData(record.npc_type); if(base == nullptr) { Message(Chat::Red, "Unable to load NPC data for pet %s", pettype); LogError("Unable to load NPC data for pet [{}] (NPC ID [{}]), check pets and npc_types tables", pettype, record.npc_type); @@ -348,7 +348,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, "130, 139, 141, 183, 236, 237, 238, 239, 254, 266, 329, 330, 378, 379, " "380, 381, 382, 383, 404, 522) " "ORDER BY RAND() LIMIT 1", zone->GetShortName()); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { safe_delete(npc_type); return; @@ -364,7 +364,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, monsterid = 567; // give the summoned pet the attributes of the monster we found - const NPCType* monster = database.LoadNPCTypesData(monsterid); + const NPCType* monster = content_db.LoadNPCTypesData(monsterid); if(monster) { npc_type->race = monster->race; npc_type->size = monster->size; @@ -389,7 +389,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, memset(petinv, 0, sizeof(petinv)); const EQEmu::ItemData *item = nullptr; - if (database.GetBasePetItems(record.equipmentset, petinv)) { + if (content_db.GetBasePetItems(record.equipmentset, petinv)) { for (int i = EQEmu::invslot::EQUIPMENT_BEGIN; i <= EQEmu::invslot::EQUIPMENT_END; i++) if (petinv[i]) { item = database.GetItem(petinv[i]); diff --git a/zone/quest_parser_collection.cpp b/zone/quest_parser_collection.cpp index c3d38ce4f..9815a5ebb 100644 --- a/zone/quest_parser_collection.cpp +++ b/zone/quest_parser_collection.cpp @@ -488,7 +488,7 @@ QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string } //second look for /quests/zone/npcname.ext (precedence) - const NPCType *npc_type = database.LoadNPCTypesData(npcid); + const NPCType *npc_type = content_db.LoadNPCTypesData(npcid); if (!npc_type && npcid != ZONE_CONTROLLER_NPC_ID) { return nullptr; } diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index c9e2ace70..aa7f439d2 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -193,7 +193,7 @@ void QuestManager::write(const char *file, const char *str) { Mob* QuestManager::spawn2(int npc_type, int grid, int unused, const glm::vec4& position) { const NPCType* tmp = 0; - if (tmp = database.LoadNPCTypesData(npc_type)) + if (tmp = content_db.LoadNPCTypesData(npc_type)) { auto npc = new NPC(tmp, nullptr, position, GravityBehavior::Water); npc->AddLootTable(); @@ -217,7 +217,7 @@ Mob* QuestManager::unique_spawn(int npc_type, int grid, int unused, const glm::v } const NPCType* tmp = 0; - if (tmp = database.LoadNPCTypesData(npc_type)) + if (tmp = content_db.LoadNPCTypesData(npc_type)) { auto npc = new NPC(tmp, nullptr, position, GravityBehavior::Water); npc->AddLootTable(); @@ -252,7 +252,7 @@ Mob *QuestManager::spawn_from_spawn2(uint32 spawn2_id) if (found_spawn) { SpawnGroup *spawn_group = zone->spawn_group_list.GetSpawnGroup(found_spawn->SpawnGroupID()); if (!spawn_group) { - database.LoadSpawnGroupsByID(found_spawn->SpawnGroupID(), &zone->spawn_group_list); + content_db.LoadSpawnGroupsByID(found_spawn->SpawnGroupID(), &zone->spawn_group_list); spawn_group = zone->spawn_group_list.GetSpawnGroup(found_spawn->SpawnGroupID()); if (!spawn_group) { return nullptr; @@ -272,7 +272,7 @@ Mob *QuestManager::spawn_from_spawn2(uint32 spawn2_id) return nullptr; } - const NPCType *tmp = database.LoadNPCTypesData(npcid); + const NPCType *tmp = content_db.LoadNPCTypesData(npcid); if (!tmp) { return nullptr; } @@ -1758,7 +1758,7 @@ void QuestManager::respawn(int npcTypeID, int grid) { quests_running_.push(e); const NPCType* npcType = nullptr; - if ((npcType = database.LoadNPCTypesData(npcTypeID))) + if ((npcType = content_db.LoadNPCTypesData(npcTypeID))) { owner = new NPC(npcType, nullptr, owner->GetPosition(), GravityBehavior::Water); owner->CastToNPC()->AddLootTable(); diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index 437846176..5f4f465f4 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -192,7 +192,7 @@ bool Spawn2::Process() { } //try to find our NPC type. - const NPCType *tmp = database.LoadNPCTypesData(npcid); + const NPCType *tmp = content_db.LoadNPCTypesData(npcid); if (tmp == nullptr) { LogSpawns("Spawn2 [{}]: Spawn group [{}] yeilded an invalid NPC type [{}]", spawn2_id, spawngroup_id_, npcid); Reset(); //try again later @@ -431,7 +431,7 @@ bool ZoneDatabase::PopulateZoneSpawnListClose(uint32 zoneid, LinkedList gettimeofday(&tv, nullptr); /* Bulk Load NPC Types Data into the cache */ - database.LoadNPCTypesData(0, true); + content_db.LoadNPCTypesData(0, true); std::string spawn_query = StringFormat( "SELECT " @@ -535,7 +535,7 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList &spa gettimeofday(&tv, nullptr); /* Bulk Load NPC Types Data into the cache */ - database.LoadNPCTypesData(0, true); + content_db.LoadNPCTypesData(0, true); std::string spawn_query = StringFormat( "SELECT " @@ -907,7 +907,7 @@ void SpawnConditionManager::UpdateDBEvent(SpawnEvent &event) { event.next.day, event.next.month, event.next.year, event.enabled? 1: 0, event.strict? 1: 0, event.id); - database.QueryDatabase(query); + content_db.QueryDatabase(query); } void SpawnConditionManager::UpdateDBCondition(const char* zone_name, uint32 instance_id, uint16 cond_id, int16 value) { @@ -916,7 +916,7 @@ void SpawnConditionManager::UpdateDBCondition(const char* zone_name, uint32 inst "(id, value, zone, instance_id) " "VALUES( %u, %u, '%s', %u)", cond_id, value, zone_name, instance_id); - database.QueryDatabase(query); + content_db.QueryDatabase(query); } bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std::string &zone_name) { @@ -926,7 +926,7 @@ bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std: "next_month, next_year, enabled, " "action, argument, strict, zone " "FROM spawn_events WHERE id = %d", event_id); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { return false; } @@ -968,7 +968,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in std::string query = StringFormat("SELECT id, onchange, value " "FROM spawn_conditions " "WHERE zone = '%s'", zone_name); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { return false; } @@ -989,7 +989,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in query = StringFormat("SELECT id, value FROM spawn_condition_values " "WHERE zone = '%s' AND instance_id = %u", zone_name, instance_id); - results = database.QueryDatabase(query); + results = content_db.QueryDatabase(query); if (!results.Success()) { spawn_conditions.clear(); return false; @@ -1006,7 +1006,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in query = StringFormat("SELECT id, cond_id, period, next_minute, next_hour, " "next_day, next_month, next_year, enabled, action, argument, strict " "FROM spawn_events WHERE zone = '%s'", zone_name); - results = database.QueryDatabase(query); + results = content_db.QueryDatabase(query); if (!results.Success()) { return false; } @@ -1376,7 +1376,7 @@ int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instanc "WHERE zone = '%s' AND instance_id = %u AND id = %d", zone_short, instance_id, condition_id ); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { LogSpawns("Unable to query remote condition [{}] from zone [{}] in Get request", condition_id, zone_short); return 0; //dunno a better thing to do... diff --git a/zone/trap.cpp b/zone/trap.cpp index e235e3912..7d205e563 100644 --- a/zone/trap.cpp +++ b/zone/trap.cpp @@ -162,7 +162,7 @@ void Trap::Trigger(Mob* trigger) for (i = 0; i < effectvalue2; i++) { - if ((tmp = database.LoadNPCTypesData(effectvalue))) + if ((tmp = content_db.LoadNPCTypesData(effectvalue))) { auto randomOffset = glm::vec4(zone->random.Int(-5, 5),zone->random.Int(-5, 5),zone->random.Int(-5, 5), zone->random.Int(0, 249)); auto spawnPosition = randomOffset + glm::vec4(m_Position, 0.0f); @@ -187,7 +187,7 @@ void Trap::Trigger(Mob* trigger) for (i = 0; i < effectvalue2; i++) { - if ((tmp = database.LoadNPCTypesData(effectvalue))) + if ((tmp = content_db.LoadNPCTypesData(effectvalue))) { auto randomOffset = glm::vec4(zone->random.Int(-2, 2), zone->random.Int(-2, 2), zone->random.Int(-2, 2), zone->random.Int(0, 249)); auto spawnPosition = randomOffset + glm::vec4(m_Position, 0.0f); @@ -452,7 +452,7 @@ void Trap::CreateHiddenTrigger() if(hiddenTrigger) return; - const NPCType *base_type = database.LoadNPCTypesData(500); + const NPCType *base_type = content_db.LoadNPCTypesData(500); auto make_npc = new NPCType; memcpy(make_npc, base_type, sizeof(NPCType)); make_npc->max_hp = 100000; diff --git a/zone/zone.cpp b/zone/zone.cpp index c976f7b1d..8e3a6f750 100755 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -436,7 +436,7 @@ void Zone::LoadTempMerchantData() { "AND se.spawngroupid = s2.spawngroupid " "AND s2.zone = '%s' AND s2.version = %i " "ORDER BY ml.slot ", GetShortName(), GetInstanceVersion()); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { return; } @@ -509,7 +509,7 @@ void Zone::GetMerchantDataForZoneLoad() { "WHERE nt.merchant_id = ml.merchantid AND nt.id = se.npcid " "AND se.spawngroupid = s2.spawngroupid AND s2.zone = '%s' AND s2.version = %i " "ORDER BY ml.slot ", GetShortName(), GetInstanceVersion()); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); std::map >::iterator cur; uint32 npcid = 0; if (results.RowCount() == 0) { @@ -1580,7 +1580,7 @@ void Zone::RepopClose(const glm::vec4& client_position, uint32 repop_distance) quest_manager.ClearAllTimers(); - if (!database.PopulateZoneSpawnListClose(zoneid, spawn2_list, GetInstanceVersion(), client_position, repop_distance)) + if (!content_db.PopulateZoneSpawnListClose(zoneid, spawn2_list, GetInstanceVersion(), client_position, repop_distance)) LogDebug("Error in Zone::Repop: database.PopulateZoneSpawnList failed"); initgrids_timer.Start(); @@ -2286,7 +2286,7 @@ void Zone::DoAdventureActions() { if(ds->assa_count >= RuleI(Adventure, NumberKillsForBossSpawn)) { - const NPCType* tmp = database.LoadNPCTypesData(ds->data_id); + const NPCType* tmp = content_db.LoadNPCTypesData(ds->data_id); if(tmp) { NPC* npc = new NPC(tmp, nullptr, glm::vec4(ds->assa_x, ds->assa_y, ds->assa_z, ds->assa_h), GravityBehavior::Water);