Migrate objects and pets [skip ci]

This commit is contained in:
Akkadius 2020-03-12 01:47:40 -05:00
parent a37260fec5
commit b22d8f6148
4 changed files with 24 additions and 24 deletions

View File

@ -55,7 +55,7 @@ void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, u
} }
PetRecord record; PetRecord record;
if (!database.GetPoweredPetEntry(spells[spell_id].teleport_zone, act_power, &record)) if (!content_db.GetPoweredPetEntry(spells[spell_id].teleport_zone, act_power, &record))
{ {
LogError("Unknown swarm pet spell id: {}, check pets table", spell_id); LogError("Unknown swarm pet spell id: {}, check pets table", spell_id);
Message(Chat::Red, "Unable to find data for pet %s", spells[spell_id].teleport_zone); Message(Chat::Red, "Unable to find data for pet %s", spells[spell_id].teleport_zone);

View File

@ -10372,7 +10372,7 @@ void command_object(Client *c, const Seperator *sep)
"ORDER BY id", "ORDER BY id",
zone->GetZoneID(), zone->GetInstanceVersion()); zone->GetZoneID(), zone->GetInstanceVersion());
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
c->Message(Chat::White, "Error in objects query"); c->Message(Chat::White, "Error in objects query");
return; return;
@ -10499,7 +10499,7 @@ void command_object(Client *c, const Seperator *sep)
if (id) { if (id) {
// ID specified. Verify that it doesn't already exist. // ID specified. Verify that it doesn't already exist.
query = StringFormat("SELECT COUNT(*) FROM object WHERE ID = %u", id); query = StringFormat("SELECT COUNT(*) FROM object WHERE ID = %u", id);
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (results.Success() && results.RowCount() != 0) { if (results.Success() && results.RowCount() != 0) {
auto row = results.begin(); auto row = results.begin();
if (atoi(row[0]) > 0) // Yep, in database already. if (atoi(row[0]) > 0) // Yep, in database already.
@ -10529,7 +10529,7 @@ void command_object(Client *c, const Seperator *sep)
od.y - 0.2f, od.y + 0.2f, // Much less processing power used this way. od.y - 0.2f, od.y + 0.2f, // Much less processing power used this way.
od.z - 0.2f, od.z + 0.2f); // It's pretty forgiving, though, allowing for close-proximity objects od.z - 0.2f, od.z + 0.2f); // It's pretty forgiving, though, allowing for close-proximity objects
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (results.Success() && results.RowCount() != 0) { if (results.Success() && results.RowCount() != 0) {
auto row = results.begin(); auto row = results.begin();
objectsFound = atoi(row[0]); // Number of nearby objects from database objectsFound = atoi(row[0]); // Number of nearby objects from database
@ -10638,7 +10638,7 @@ void command_object(Client *c, const Seperator *sep)
} else { } else {
// Object not found in-zone in a modifiable form. Check for valid matching circumstances. // Object not found in-zone in a modifiable form. Check for valid matching circumstances.
std::string query = StringFormat("SELECT zoneid, version, type FROM object WHERE id = %u", id); std::string query = StringFormat("SELECT zoneid, version, type FROM object WHERE id = %u", id);
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success() || results.RowCount() == 0) { if (!results.Success() || results.RowCount() == 0) {
c->Message(Chat::White, "ERROR: Object %u not found", id); c->Message(Chat::White, "ERROR: Object %u not found", id);
return; return;
@ -10667,7 +10667,7 @@ void command_object(Client *c, const Seperator *sep)
// Convert to tradeskill object temporarily for changes // Convert to tradeskill object temporarily for changes
query = StringFormat("UPDATE object SET type = %u WHERE id = %u", staticType, id); query = StringFormat("UPDATE object SET type = %u WHERE id = %u", staticType, id);
database.QueryDatabase(query); content_db.QueryDatabase(query);
c->Message(Chat::White, "Static Object %u unlocked for editing. You must zone out and back in to " c->Message(Chat::White, "Static Object %u unlocked for editing. You must zone out and back in to "
"make your changes, then commit them with '#object Save'.", "make your changes, then commit them with '#object Save'.",
@ -10862,7 +10862,7 @@ void command_object(Client *c, const Seperator *sep)
if (!(o = entity_list.FindObject(id))) { if (!(o = entity_list.FindObject(id))) {
std::string query = StringFormat("SELECT zoneid, version, type FROM object WHERE id = %u", id); std::string query = StringFormat("SELECT zoneid, version, type FROM object WHERE id = %u", id);
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success() || results.RowCount() == 0) { if (!results.Success() || results.RowCount() == 0) {
c->Message(Chat::White, "ERROR: Object %u not found", id); c->Message(Chat::White, "ERROR: Object %u not found", id);
return; return;
@ -11002,7 +11002,7 @@ void command_object(Client *c, const Seperator *sep)
// If this ID isn't in the database yet, it's a new object // If this ID isn't in the database yet, it's a new object
bNewObject = true; bNewObject = true;
std::string query = StringFormat("SELECT zoneid, version, type FROM object WHERE id = %u", id); std::string query = StringFormat("SELECT zoneid, version, type FROM object WHERE id = %u", id);
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (results.Success() && results.RowCount() != 0) { if (results.Success() && results.RowCount() != 0) {
auto row = results.begin(); auto row = results.begin();
od.zone_id = atoi(row[0]); od.zone_id = atoi(row[0]);
@ -11097,7 +11097,7 @@ void command_object(Client *c, const Seperator *sep)
od.heading, od.object_name, od.object_type, icon, od.size, od.heading, od.object_name, od.object_type, icon, od.size,
od.solidtype, od.unknown020); od.solidtype, od.unknown020);
results = database.QueryDatabase(query); results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
c->Message(Chat::White, "Database Error: %s", results.ErrorMessage().c_str()); c->Message(Chat::White, "Database Error: %s", results.ErrorMessage().c_str());
return; return;
@ -11229,7 +11229,7 @@ void command_object(Client *c, const Seperator *sep)
"objectname, type, icon, unknown08, unknown10, unknown20 " "objectname, type, icon, unknown08, unknown10, unknown20 "
"FROM object WHERE zoneid = %u) AND version = %u", "FROM object WHERE zoneid = %u) AND version = %u",
od.zone_instance, zone->GetZoneID(), zone->GetInstanceVersion()); od.zone_instance, zone->GetZoneID(), zone->GetInstanceVersion());
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
c->Message(Chat::White, "Database Error: %s", results.ErrorMessage().c_str()); c->Message(Chat::White, "Database Error: %s", results.ErrorMessage().c_str());
return; return;
@ -11249,7 +11249,7 @@ void command_object(Client *c, const Seperator *sep)
"objectname, type, icon, unknown08, unknown10, unknown20 " "objectname, type, icon, unknown08, unknown10, unknown20 "
"FROM object WHERE id = %u AND zoneid = %u AND version = %u", "FROM object WHERE id = %u AND zoneid = %u AND version = %u",
od.zone_instance, id, zone->GetZoneID(), zone->GetInstanceVersion()); od.zone_instance, id, zone->GetZoneID(), zone->GetInstanceVersion());
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (results.Success() && results.RowsAffected() > 0) { if (results.Success() && results.RowsAffected() > 0) {
c->Message(Chat::White, "Copied Object %u into instance version %u", id, od.zone_instance); c->Message(Chat::White, "Copied Object %u into instance version %u", id, od.zone_instance);
return; return;
@ -11266,7 +11266,7 @@ void command_object(Client *c, const Seperator *sep)
// No database error returned. See if we can figure out why. // No database error returned. See if we can figure out why.
query = StringFormat("SELECT zoneid, version FROM object WHERE id = %u", id); query = StringFormat("SELECT zoneid, version FROM object WHERE id = %u", id);
results = database.QueryDatabase(query); results = content_db.QueryDatabase(query);
if (!results.Success()) if (!results.Success())
return; return;
@ -11319,7 +11319,7 @@ void command_object(Client *c, const Seperator *sep)
"WHERE id = %u AND zoneid = %u " "WHERE id = %u AND zoneid = %u "
"AND version = %u LIMIT 1", "AND version = %u LIMIT 1",
id, zone->GetZoneID(), zone->GetInstanceVersion()); id, zone->GetZoneID(), zone->GetInstanceVersion());
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
c->Message(Chat::White, "Object %u deleted", id); c->Message(Chat::White, "Object %u deleted", id);
return; return;
@ -11330,7 +11330,7 @@ void command_object(Client *c, const Seperator *sep)
"WHERE id = %u AND zoneid = %u " "WHERE id = %u AND zoneid = %u "
"AND version = %u LIMIT 1", "AND version = %u LIMIT 1",
id, zone->GetZoneID(), zone->GetInstanceVersion()); id, zone->GetZoneID(), zone->GetInstanceVersion());
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) if (!results.Success())
return; return;
@ -11346,7 +11346,7 @@ void command_object(Client *c, const Seperator *sep)
query = StringFormat("DELETE FROM object WHERE id = %u " query = StringFormat("DELETE FROM object WHERE id = %u "
"AND zoneid = %u AND version = %u LIMIT 1", "AND zoneid = %u AND version = %u LIMIT 1",
id, zone->GetZoneID(), zone->GetInstanceVersion()); id, zone->GetZoneID(), zone->GetInstanceVersion());
results = database.QueryDatabase(query); results = content_db.QueryDatabase(query);
c->Message(Chat::White, "Object %u deleted. NOTE: This static object will remain for anyone currently in " c->Message(Chat::White, "Object %u deleted. NOTE: This static object will remain for anyone currently in "
"the zone until they next zone out and in.", "the zone until they next zone out and in.",
@ -11398,7 +11398,7 @@ void command_object(Client *c, const Seperator *sep)
"unknown08, unknown10, unknown20 " "unknown08, unknown10, unknown20 "
"FROM object WHERE id = %u", "FROM object WHERE id = %u",
id); id);
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success() || results.RowCount() == 0) { if (!results.Success() || results.RowCount() == 0) {
c->Message(Chat::White, "Database Error: %s", results.ErrorMessage().c_str()); c->Message(Chat::White, "Database Error: %s", results.ErrorMessage().c_str());
return; return;

View File

@ -292,11 +292,11 @@ bool Object::Save()
{ {
if (m_id) { if (m_id) {
// Update existing // Update existing
database.UpdateObject(m_id, m_type, m_icon, m_data, m_inst); content_db.UpdateObject(m_id, m_type, m_icon, m_data, m_inst);
} }
else { else {
// Doesn't yet exist, add now // Doesn't yet exist, add now
m_id = database.AddObject(m_type, m_icon, m_data, m_inst); m_id = content_db.AddObject(m_type, m_icon, m_data, m_inst);
} }
return true; return true;
@ -306,11 +306,11 @@ uint16 Object::VarSave()
{ {
if (m_id) { if (m_id) {
// Update existing // Update existing
database.UpdateObject(m_id, m_type, m_icon, m_data, m_inst); content_db.UpdateObject(m_id, m_type, m_icon, m_data, m_inst);
} }
else { else {
// Doesn't yet exist, add now // Doesn't yet exist, add now
m_id = database.AddObject(m_type, m_icon, m_data, m_inst); m_id = content_db.AddObject(m_type, m_icon, m_data, m_inst);
} }
return m_id; return m_id;
} }
@ -319,7 +319,7 @@ uint16 Object::VarSave()
void Object::Delete(bool reset_state) void Object::Delete(bool reset_state)
{ {
if (m_id != 0) { if (m_id != 0) {
database.DeleteObject(m_id); content_db.DeleteObject(m_id);
} }
if (reset_state) { if (reset_state) {
@ -436,7 +436,7 @@ bool Object::Process(){
safe_delete(outapp); safe_delete(outapp);
// Remove object // Remove object
database.DeleteObject(m_id); content_db.DeleteObject(m_id);
return false; return false;
} }
@ -553,7 +553,7 @@ bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object)
safe_delete(outapp); safe_delete(outapp);
// Remove object // Remove object
database.DeleteObject(m_id); content_db.DeleteObject(m_id);
if(!m_ground_spawn) if(!m_ground_spawn)
entity_list.RemoveEntity(this->GetID()); entity_list.RemoveEntity(this->GetID());
} else { } else {

View File

@ -175,7 +175,7 @@ bool Zone::LoadZoneObjects()
"unknown08, unknown10, unknown20, unknown24, unknown76, size, tilt_x, tilt_y, display_name " "unknown08, unknown10, unknown20, unknown24, unknown76, size, tilt_x, tilt_y, display_name "
"FROM object WHERE zoneid = %i AND (version = %u OR version = -1)", "FROM object WHERE zoneid = %i AND (version = %u OR version = -1)",
zoneid, instanceversion); zoneid, instanceversion);
auto results = database.QueryDatabase(query); auto results = content_db.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
LogError("Error Loading Objects from DB: [{}]", LogError("Error Loading Objects from DB: [{}]",
results.ErrorMessage().c_str()); results.ErrorMessage().c_str());