Migrate spawn tables [skip ci]

This commit is contained in:
Akkadius 2020-03-12 00:00:39 -05:00
parent 9048265283
commit 286c08b8d5
13 changed files with 64 additions and 61 deletions

View File

@ -485,6 +485,7 @@ void Database::BuryCorpsesInInstance(uint16 instance_id) {
void Database::DeleteInstance(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); std::string query = StringFormat("DELETE FROM instance_list WHERE id=%u", instance_id);
QueryDatabase(query); QueryDatabase(query);

View File

@ -84,8 +84,10 @@ int main(int argc, char **argv) {
SharedDatabase database; SharedDatabase database;
LogInfo("Connecting to database"); LogInfo("Connecting to database");
if(!database.Connect(Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(), if (!database.Connect(
Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) { 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"); LogError("Unable to connect to the database, cannot continue without a database connection");
return 1; return 1;
} }

View File

@ -81,7 +81,7 @@ void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, u
NPCType *made_npc = nullptr; 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) { if (npc_type == nullptr) {
//log write //log write
LogError("Unknown npc type for swarm pet spell id: [{}]", spell_id); 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; NPCType *made_npc = nullptr;
const NPCType *npc_type = database.LoadNPCTypesData(typesid); const NPCType *npc_type = content_db.LoadNPCTypesData(typesid);
if(npc_type == nullptr) { if(npc_type == nullptr) {
//log write //log write
LogError("Unknown npc type for swarm pet type id: [{}]", typesid); 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; return;
//assuming we have pets in our table; we take the first pet as a base type. //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; auto make_npc = new NPCType;
memcpy(make_npc, base_type, sizeof(NPCType)); memcpy(make_npc, base_type, sizeof(NPCType));

View File

@ -871,7 +871,7 @@ void Mob::MakeAura(uint16 spell_id)
return; return;
} }
const auto base = database.LoadNPCTypesData(record.npc_type); const auto base = content_db.LoadNPCTypesData(record.npc_type);
if (base == nullptr) { if (base == nullptr) {
Message(Chat::Red, "Unable to load NPC data for aura %s", spells[spell_id].teleport_zone); Message(Chat::Red, "Unable to load NPC data for aura %s", spells[spell_id].teleport_zone);
LogError( LogError(

View File

@ -6205,21 +6205,21 @@ void Client::NPCSpawn(NPC *target_npc, const char *identifier, uint32 extra)
if (id == "create") { if (id == "create") {
// extra tries to create the npc_type ID within the range for the current zone (zone_id * 1000) // 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") { else if (id == "add") {
// extra sets the respawn timer for 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") { 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") { 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); target_npc->Depop(false);
} }
else if (id == "delete") { 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); target_npc->Depop(false);
} }
else { else {
@ -6323,7 +6323,7 @@ void Client::Doppelganger(uint16 spell_id, Mob *target, const char *name_overrid
NPCType *made_npc = nullptr; 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) { if(npc_type == nullptr) {
LogError("Unknown npc type for doppelganger spell id: [{}]", spell_id); LogError("Unknown npc type for doppelganger spell id: [{}]", spell_id);
Message(0,"Unable to find pet!"); Message(0,"Unable to find pet!");

View File

@ -3097,7 +3097,7 @@ void command_npctypespawn(Client *c, const Seperator *sep)
{ {
if (sep->IsNumber(1)) { if (sep->IsNumber(1)) {
const NPCType* tmp = 0; const NPCType* tmp = 0;
if ((tmp = database.LoadNPCTypesData(atoi(sep->arg[1])))) { if ((tmp = content_db.LoadNPCTypesData(atoi(sep->arg[1])))) {
//tmp->fixedZ = 1; //tmp->fixedZ = 1;
auto npc = new NPC(tmp, 0, c->GetPosition(), GravityBehavior::Water); auto npc = new NPC(tmp, 0, c->GetPosition(), GravityBehavior::Water);
if (npc && sep->IsNumber(2)) if (npc && sep->IsNumber(2))
@ -4196,7 +4196,7 @@ void command_viewnpctype(Client *c, const Seperator *sep)
else else
{ {
uint32 npctypeid=atoi(sep->arg[1]); uint32 npctypeid=atoi(sep->arg[1]);
const NPCType* npct = database.LoadNPCTypesData(npctypeid); const NPCType* npct = content_db.LoadNPCTypesData(npctypeid);
if (npct) { if (npct) {
c->Message(Chat::White, " NPCType Info, "); c->Message(Chat::White, " NPCType Info, ");
c->Message(Chat::White, " NPCTypeID: %u", npct->npc_id); 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) // Option to try to create the npc_type ID within the range for the current zone (zone_id * 1000)
extra = 1; 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()); c->Message(Chat::White, "%s created successfully!", target->GetName());
} }
else if (strcasecmp(sep->arg[1], "add") == 0) { 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 // Respawn Timer default if not set
extra = 1200; 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()); c->Message(Chat::White, "%s added successfully!", target->GetName());
} }
else if (strcasecmp(sep->arg[1], "update") == 0) { 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()); c->Message(Chat::White, "%s updated!", target->GetName());
} }
else if (strcasecmp(sep->arg[1], "remove") == 0) { 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()); c->Message(Chat::White, "%s removed successfully from database!", target->GetName());
target->Depop(false); target->Depop(false);
} }
else if (strcasecmp(sep->arg[1], "delete") == 0) { 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()); c->Message(Chat::White, "%s deleted from database!", target->GetName());
target->Depop(false); 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'", 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()); c->GetX(), c->GetY(), c->GetZ(), c->GetHeading(),s2->GetID());
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
c->Message(Chat::Red, "Update failed! MySQL gave the following error:"); c->Message(Chat::Red, "Update failed! MySQL gave the following error:");
c->Message(Chat::Red, results.ErrorMessage().c_str()); c->Message(Chat::Red, results.ErrorMessage().c_str());
@ -8607,7 +8607,7 @@ void command_npcedit(Client *c, const Seperator *sep)
c->GetTarget()->CastToNPC()->GetSpawnGroupId() ); c->GetTarget()->CastToNPC()->GetSpawnGroupId() );
std::string query = StringFormat("UPDATE spawn2 SET animation = %i " "WHERE spawngroupID = %i", animation, std::string query = StringFormat("UPDATE spawn2 SET animation = %i " "WHERE spawngroupID = %i", animation,
c->GetTarget()->CastToNPC()->GetSpawnGroupId()); c->GetTarget()->CastToNPC()->GetSpawnGroupId());
database.QueryDatabase(query); content_db.QueryDatabase(query);
c->GetTarget()->SetAppearance(EmuAppearance(animation)); c->GetTarget()->SetAppearance(EmuAppearance(animation));
return; return;
@ -8728,7 +8728,7 @@ void command_qglobal(Client *c, const Seperator *sep) {
} }
if(!strcasecmp(sep->arg[1], "view")) { if(!strcasecmp(sep->arg[1], "view")) {
const NPCType *type = database.LoadNPCTypesData(target->GetNPCTypeID()); const NPCType *type = content_db.LoadNPCTypesData(target->GetNPCTypeID());
if(!type) if(!type)
c->Message(Chat::Yellow, "Invalid NPC type."); c->Message(Chat::Yellow, "Invalid NPC type.");
else if(type->qglobal) else if(type->qglobal)
@ -9725,7 +9725,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep)
return; return;
} }
database.NPCSpawnDB(6, zone->GetShortName(), zone->GetInstanceVersion(), c, target->CastToNPC()); content_db.NPCSpawnDB(6, zone->GetShortName(), zone->GetInstanceVersion(), c, target->CastToNPC());
return; return;
} }
@ -9746,7 +9746,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep)
(sep->arg[7]? atof(sep->arg[7]): 0), (sep->arg[7]? atof(sep->arg[7]): 0),
(sep->arg[8]? atof(sep->arg[8]): 0), (sep->arg[8]? atof(sep->arg[8]): 0),
(sep->arg[9]? atoi(sep->arg[9]): 0)); (sep->arg[9]? atoi(sep->arg[9]): 0));
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
c->Message(Chat::White, "Invalid Arguments -- MySQL gave the following error:"); c->Message(Chat::White, "Invalid Arguments -- MySQL gave the following error:");
c->Message(Chat::Red, results.ErrorMessage().c_str()); 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) " std::string query = StringFormat("INSERT INTO spawnentry (spawngroupID, npcID, chance) "
"VALUES (%i, %i, %i)", "VALUES (%i, %i, %i)",
atoi(sep->arg[2]), atoi(sep->arg[3]), atoi(sep->arg[4])); 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()) { if (!results.Success()) {
c->Message(Chat::White, "Invalid Arguments -- MySQL gave the following error:"); c->Message(Chat::White, "Invalid Arguments -- MySQL gave the following error:");
c->Message(Chat::Red, results.ErrorMessage().c_str()); 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[3]), atof(sep->arg[4]), atof(sep->arg[5]),
atof(sep->arg[6]), atof(sep->arg[7]), atoi(sep->arg[8]), atof(sep->arg[6]), atof(sep->arg[7]), atoi(sep->arg[8]),
atoi(sep->arg[2])); atoi(sep->arg[2]));
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
c->Message(Chat::White, "Invalid Arguments -- MySQL gave the following error:"); c->Message(Chat::White, "Invalid Arguments -- MySQL gave the following error:");
c->Message(Chat::Red, results.ErrorMessage().c_str()); 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', " "SET dist = '0', max_x = '0', min_x = '0', "
"max_y = '0', min_y = '0', delay = '0' " "max_y = '0', min_y = '0', delay = '0' "
"WHERE id = '%i' ", atoi(sep->arg[2])); "WHERE id = '%i' ", atoi(sep->arg[2]));
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
c->Message(Chat::White, "Invalid Arguments -- MySQL gave the following error:"); c->Message(Chat::White, "Invalid Arguments -- MySQL gave the following error:");
c->Message(Chat::Red, results.ErrorMessage().c_str()); 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) { 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])); c->Message(Chat::White, "Mob of group %i added successfully!", atoi(sep->arg[2]));
return; 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()); 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()) { if(!results.Success()) {
c->Message(Chat::Red, "Update failed! MySQL gave the following error:"); c->Message(Chat::Red, "Update failed! MySQL gave the following error:");
c->Message(Chat::Red, results.ErrorMessage().c_str()); 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' " std::string query = StringFormat("UPDATE spawn2 SET x = '%f', y = '%f', z = '%f', heading = '%f' "
"WHERE id = '%i'", "WHERE id = '%i'",
c->GetX(), c->GetY(), c->GetZ(), c->GetHeading(),s2->GetID()); c->GetX(), c->GetY(), c->GetZ(), c->GetHeading(),s2->GetID());
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
c->Message(Chat::Red, "Update failed! MySQL gave the following error:"); c->Message(Chat::Red, "Update failed! MySQL gave the following error:");
c->Message(Chat::Red, results.ErrorMessage().c_str()); 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 " std::string query = StringFormat("UPDATE spawn2 SET respawntime = %u, variance = %u "
"WHERE id = '%i'", new_rs, new_var, s2->GetID()); "WHERE id = '%i'", new_rs, new_var, s2->GetID());
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
c->Message(Chat::Red, "Update failed! MySQL gave the following error:"); c->Message(Chat::Red, "Update failed! MySQL gave the following error:");
c->Message(Chat::Red, results.ErrorMessage().c_str()); 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 " std::string query = StringFormat("UPDATE spawn2 SET version = %i "
"WHERE spawngroupID = '%i'", "WHERE spawngroupID = '%i'",
version, c->GetTarget()->CastToNPC()->GetSpawnGroupId()); version, c->GetTarget()->CastToNPC()->GetSpawnGroupId());
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
c->Message(Chat::Red, "Update failed! MySQL gave the following error:"); c->Message(Chat::Red, "Update failed! MySQL gave the following error:");
c->Message(Chat::Red, results.ErrorMessage().c_str()); c->Message(Chat::Red, results.ErrorMessage().c_str());

View File

@ -280,7 +280,7 @@ void Client::GoFish()
if (npc_chance > 0 && npc_id) { if (npc_chance > 0 && npc_id) {
if (zone->random.Roll(npc_chance)) { if (zone->random.Roll(npc_chance)) {
if (zone->CanDoCombat()) { if (zone->CanDoCombat()) {
const NPCType *tmp = database.LoadNPCTypesData(npc_id); const NPCType *tmp = content_db.LoadNPCTypesData(npc_id);
if (tmp != nullptr) { if (tmp != nullptr) {
auto positionNPC = GetPosition(); auto positionNPC = GetPosition();
positionNPC.x = positionNPC.x + 3; positionNPC.x = positionNPC.x + 3;

View File

@ -211,14 +211,14 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower,
//lookup our pets table record for this type //lookup our pets table record for this type
PetRecord record; 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); Message(Chat::Red, "Unable to find data for pet %s", pettype);
LogError("Unable to find data for pet [{}], check pets table", pettype); LogError("Unable to find data for pet [{}], check pets table", pettype);
return; return;
} }
//find the NPC data for the specified NPC type //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) { if(base == nullptr) {
Message(Chat::Red, "Unable to load NPC data for pet %s", pettype); 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); 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, " "130, 139, 141, 183, 236, 237, 238, 239, 254, 266, 329, 330, 378, 379, "
"380, 381, 382, 383, 404, 522) " "380, 381, 382, 383, 404, 522) "
"ORDER BY RAND() LIMIT 1", zone->GetShortName()); "ORDER BY RAND() LIMIT 1", zone->GetShortName());
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
safe_delete(npc_type); safe_delete(npc_type);
return; return;
@ -364,7 +364,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower,
monsterid = 567; monsterid = 567;
// give the summoned pet the attributes of the monster we found // 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) { if(monster) {
npc_type->race = monster->race; npc_type->race = monster->race;
npc_type->size = monster->size; 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)); memset(petinv, 0, sizeof(petinv));
const EQEmu::ItemData *item = nullptr; 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++) for (int i = EQEmu::invslot::EQUIPMENT_BEGIN; i <= EQEmu::invslot::EQUIPMENT_END; i++)
if (petinv[i]) { if (petinv[i]) {
item = database.GetItem(petinv[i]); item = database.GetItem(petinv[i]);

View File

@ -488,7 +488,7 @@ QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string
} }
//second look for /quests/zone/npcname.ext (precedence) //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) { if (!npc_type && npcid != ZONE_CONTROLLER_NPC_ID) {
return nullptr; return nullptr;
} }

View File

@ -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) { Mob* QuestManager::spawn2(int npc_type, int grid, int unused, const glm::vec4& position) {
const NPCType* tmp = 0; 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); auto npc = new NPC(tmp, nullptr, position, GravityBehavior::Water);
npc->AddLootTable(); npc->AddLootTable();
@ -217,7 +217,7 @@ Mob* QuestManager::unique_spawn(int npc_type, int grid, int unused, const glm::v
} }
const NPCType* tmp = 0; 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); auto npc = new NPC(tmp, nullptr, position, GravityBehavior::Water);
npc->AddLootTable(); npc->AddLootTable();
@ -252,7 +252,7 @@ Mob *QuestManager::spawn_from_spawn2(uint32 spawn2_id)
if (found_spawn) { if (found_spawn) {
SpawnGroup *spawn_group = zone->spawn_group_list.GetSpawnGroup(found_spawn->SpawnGroupID()); SpawnGroup *spawn_group = zone->spawn_group_list.GetSpawnGroup(found_spawn->SpawnGroupID());
if (!spawn_group) { 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()); spawn_group = zone->spawn_group_list.GetSpawnGroup(found_spawn->SpawnGroupID());
if (!spawn_group) { if (!spawn_group) {
return nullptr; return nullptr;
@ -272,7 +272,7 @@ Mob *QuestManager::spawn_from_spawn2(uint32 spawn2_id)
return nullptr; return nullptr;
} }
const NPCType *tmp = database.LoadNPCTypesData(npcid); const NPCType *tmp = content_db.LoadNPCTypesData(npcid);
if (!tmp) { if (!tmp) {
return nullptr; return nullptr;
} }
@ -1758,7 +1758,7 @@ void QuestManager::respawn(int npcTypeID, int grid) {
quests_running_.push(e); quests_running_.push(e);
const NPCType* npcType = nullptr; 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 = new NPC(npcType, nullptr, owner->GetPosition(), GravityBehavior::Water);
owner->CastToNPC()->AddLootTable(); owner->CastToNPC()->AddLootTable();

View File

@ -192,7 +192,7 @@ bool Spawn2::Process() {
} }
//try to find our NPC type. //try to find our NPC type.
const NPCType *tmp = database.LoadNPCTypesData(npcid); const NPCType *tmp = content_db.LoadNPCTypesData(npcid);
if (tmp == nullptr) { if (tmp == nullptr) {
LogSpawns("Spawn2 [{}]: Spawn group [{}] yeilded an invalid NPC type [{}]", spawn2_id, spawngroup_id_, npcid); LogSpawns("Spawn2 [{}]: Spawn group [{}] yeilded an invalid NPC type [{}]", spawn2_id, spawngroup_id_, npcid);
Reset(); //try again later Reset(); //try again later
@ -431,7 +431,7 @@ bool ZoneDatabase::PopulateZoneSpawnListClose(uint32 zoneid, LinkedList<Spawn2*>
gettimeofday(&tv, nullptr); gettimeofday(&tv, nullptr);
/* Bulk Load NPC Types Data into the cache */ /* Bulk Load NPC Types Data into the cache */
database.LoadNPCTypesData(0, true); content_db.LoadNPCTypesData(0, true);
std::string spawn_query = StringFormat( std::string spawn_query = StringFormat(
"SELECT " "SELECT "
@ -535,7 +535,7 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spa
gettimeofday(&tv, nullptr); gettimeofday(&tv, nullptr);
/* Bulk Load NPC Types Data into the cache */ /* Bulk Load NPC Types Data into the cache */
database.LoadNPCTypesData(0, true); content_db.LoadNPCTypesData(0, true);
std::string spawn_query = StringFormat( std::string spawn_query = StringFormat(
"SELECT " "SELECT "
@ -907,7 +907,7 @@ void SpawnConditionManager::UpdateDBEvent(SpawnEvent &event) {
event.next.day, event.next.month, event.next.day, event.next.month,
event.next.year, event.enabled? 1: 0, event.next.year, event.enabled? 1: 0,
event.strict? 1: 0, event.id); 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) { 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) " "(id, value, zone, instance_id) "
"VALUES( %u, %u, '%s', %u)", "VALUES( %u, %u, '%s', %u)",
cond_id, value, zone_name, instance_id); 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) { 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, " "next_month, next_year, enabled, "
"action, argument, strict, zone " "action, argument, strict, zone "
"FROM spawn_events WHERE id = %d", event_id); "FROM spawn_events WHERE id = %d", event_id);
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
return false; return false;
} }
@ -968,7 +968,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
std::string query = StringFormat("SELECT id, onchange, value " std::string query = StringFormat("SELECT id, onchange, value "
"FROM spawn_conditions " "FROM spawn_conditions "
"WHERE zone = '%s'", zone_name); "WHERE zone = '%s'", zone_name);
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
return false; return false;
} }
@ -989,7 +989,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
query = StringFormat("SELECT id, value FROM spawn_condition_values " query = StringFormat("SELECT id, value FROM spawn_condition_values "
"WHERE zone = '%s' AND instance_id = %u", "WHERE zone = '%s' AND instance_id = %u",
zone_name, instance_id); zone_name, instance_id);
results = database.QueryDatabase(query); results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
spawn_conditions.clear(); spawn_conditions.clear();
return false; 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, " query = StringFormat("SELECT id, cond_id, period, next_minute, next_hour, "
"next_day, next_month, next_year, enabled, action, argument, strict " "next_day, next_month, next_year, enabled, action, argument, strict "
"FROM spawn_events WHERE zone = '%s'", zone_name); "FROM spawn_events WHERE zone = '%s'", zone_name);
results = database.QueryDatabase(query); results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
return false; 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", "WHERE zone = '%s' AND instance_id = %u AND id = %d",
zone_short, instance_id, condition_id zone_short, instance_id, condition_id
); );
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
LogSpawns("Unable to query remote condition [{}] from zone [{}] in Get request", condition_id, zone_short); LogSpawns("Unable to query remote condition [{}] from zone [{}] in Get request", condition_id, zone_short);
return 0; //dunno a better thing to do... return 0; //dunno a better thing to do...

View File

@ -162,7 +162,7 @@ void Trap::Trigger(Mob* trigger)
for (i = 0; i < effectvalue2; i++) 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 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); auto spawnPosition = randomOffset + glm::vec4(m_Position, 0.0f);
@ -187,7 +187,7 @@ void Trap::Trigger(Mob* trigger)
for (i = 0; i < effectvalue2; i++) 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 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); auto spawnPosition = randomOffset + glm::vec4(m_Position, 0.0f);
@ -452,7 +452,7 @@ void Trap::CreateHiddenTrigger()
if(hiddenTrigger) if(hiddenTrigger)
return; return;
const NPCType *base_type = database.LoadNPCTypesData(500); const NPCType *base_type = content_db.LoadNPCTypesData(500);
auto make_npc = new NPCType; auto make_npc = new NPCType;
memcpy(make_npc, base_type, sizeof(NPCType)); memcpy(make_npc, base_type, sizeof(NPCType));
make_npc->max_hp = 100000; make_npc->max_hp = 100000;

View File

@ -436,7 +436,7 @@ void Zone::LoadTempMerchantData() {
"AND se.spawngroupid = s2.spawngroupid " "AND se.spawngroupid = s2.spawngroupid "
"AND s2.zone = '%s' AND s2.version = %i " "AND s2.zone = '%s' AND s2.version = %i "
"ORDER BY ml.slot ", GetShortName(), GetInstanceVersion()); "ORDER BY ml.slot ", GetShortName(), GetInstanceVersion());
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
return; return;
} }
@ -509,7 +509,7 @@ void Zone::GetMerchantDataForZoneLoad() {
"WHERE nt.merchant_id = ml.merchantid AND nt.id = se.npcid " "WHERE nt.merchant_id = ml.merchantid AND nt.id = se.npcid "
"AND se.spawngroupid = s2.spawngroupid AND s2.zone = '%s' AND s2.version = %i " "AND se.spawngroupid = s2.spawngroupid AND s2.zone = '%s' AND s2.version = %i "
"ORDER BY ml.slot ", GetShortName(), GetInstanceVersion()); "ORDER BY ml.slot ", GetShortName(), GetInstanceVersion());
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
std::map<uint32, std::list<MerchantList> >::iterator cur; std::map<uint32, std::list<MerchantList> >::iterator cur;
uint32 npcid = 0; uint32 npcid = 0;
if (results.RowCount() == 0) { if (results.RowCount() == 0) {
@ -1580,7 +1580,7 @@ void Zone::RepopClose(const glm::vec4& client_position, uint32 repop_distance)
quest_manager.ClearAllTimers(); 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"); LogDebug("Error in Zone::Repop: database.PopulateZoneSpawnList failed");
initgrids_timer.Start(); initgrids_timer.Start();
@ -2286,7 +2286,7 @@ void Zone::DoAdventureActions()
{ {
if(ds->assa_count >= RuleI(Adventure, NumberKillsForBossSpawn)) 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) if(tmp)
{ {
NPC* npc = new NPC(tmp, nullptr, glm::vec4(ds->assa_x, ds->assa_y, ds->assa_z, ds->assa_h), GravityBehavior::Water); NPC* npc = new NPC(tmp, nullptr, glm::vec4(ds->assa_x, ds->assa_y, ds->assa_z, ds->assa_h), GravityBehavior::Water);