From 6af1ae32aedf09e9ee9f54544e30968d4ef82a70 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Wed, 11 Mar 2020 04:10:21 -0500 Subject: [PATCH] Migrate grids [skip ci] --- world/client.cpp | 2 +- zone/command.cpp | 18 +++++++++--------- zone/questmgr.cpp | 2 +- zone/spawn2.cpp | 2 +- zone/waypoints.cpp | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/world/client.cpp b/world/client.cpp index c33b3a8d1..c24dea2ab 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -1588,7 +1588,7 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) database.GetZoneName(pp.binds[4].zoneId), pp.binds[4].zoneId, pp.binds[4].x, pp.binds[4].y, pp.binds[4].z); /* Starting Items inventory */ - database.SetStartingItems(&pp, &inv, pp.race, pp.class_, pp.deity, pp.zone_id, pp.name, GetAdmin()); + content_db.SetStartingItems(&pp, &inv, pp.race, pp.class_, pp.deity, pp.zone_id, pp.name, GetAdmin()); // now we give the pp and the inv we made to StoreCharacter // to see if we can store it diff --git a/zone/command.cpp b/zone/command.cpp index 512992f51..8fa109cc8 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -2422,10 +2422,10 @@ void command_setlsinfo(Client *c, const Seperator *sep) void command_grid(Client *c, const Seperator *sep) { if (strcasecmp("max", sep->arg[1]) == 0) { - c->Message(Chat::White, "Highest grid ID in this zone: %d", database.GetHighestGrid(zone->GetZoneID())); + c->Message(Chat::White, "Highest grid ID in this zone: %d", content_db.GetHighestGrid(zone->GetZoneID())); } else if (strcasecmp("add", sep->arg[1]) == 0) { - database.ModifyGrid(c, false, atoi(sep->arg[2]), atoi(sep->arg[3]), atoi(sep->arg[4]), zone->GetZoneID()); + content_db.ModifyGrid(c, false, atoi(sep->arg[2]), atoi(sep->arg[3]), atoi(sep->arg[4]), zone->GetZoneID()); } else if (strcasecmp("show", sep->arg[1]) == 0) { @@ -2445,7 +2445,7 @@ void command_grid(Client *c, const Seperator *sep) target->CastToNPC()->GetGrid() ); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { c->Message(Chat::White, "Error querying database."); c->Message(Chat::White, query.c_str()); @@ -2485,7 +2485,7 @@ void command_grid(Client *c, const Seperator *sep) } } else if (strcasecmp("delete", sep->arg[1]) == 0) { - database.ModifyGrid(c, true, atoi(sep->arg[2]), 0, 0, zone->GetZoneID()); + content_db.ModifyGrid(c, true, atoi(sep->arg[2]), 0, 0, zone->GetZoneID()); } else { c->Message(Chat::White, "Usage: #grid add/delete grid_num wandertype pausetype"); @@ -2500,18 +2500,18 @@ void command_wp(Client *c, const Seperator *sep) if (strcasecmp("add", sep->arg[1]) == 0) { if (wp == 0) //default to highest if it's left blank, or we enter 0 - wp = database.GetHighestWaypoint(zone->GetZoneID(), atoi(sep->arg[2])) + 1; + wp = content_db.GetHighestWaypoint(zone->GetZoneID(), atoi(sep->arg[2])) + 1; if (strcasecmp("-h", sep->arg[5]) == 0) { - database.AddWP(c, atoi(sep->arg[2]),wp, c->GetPosition(), atoi(sep->arg[3]),zone->GetZoneID()); + content_db.AddWP(c, atoi(sep->arg[2]),wp, c->GetPosition(), atoi(sep->arg[3]),zone->GetZoneID()); } else { auto position = c->GetPosition(); position.w = -1; - database.AddWP(c, atoi(sep->arg[2]),wp, position, atoi(sep->arg[3]),zone->GetZoneID()); + content_db.AddWP(c, atoi(sep->arg[2]),wp, position, atoi(sep->arg[3]),zone->GetZoneID()); } } else if (strcasecmp("delete", sep->arg[1]) == 0) - database.DeleteWaypoint(c, atoi(sep->arg[2]),wp,zone->GetZoneID()); + content_db.DeleteWaypoint(c, atoi(sep->arg[2]),wp,zone->GetZoneID()); else c->Message(Chat::White,"Usage: #wp add/delete grid_num pause wp_num [-h]"); } @@ -7111,7 +7111,7 @@ void command_wpadd(Client *c, const Seperator *sep) position.w = -1; } - uint32 tmp_grid = database.AddWPForSpawn(c, s2info->GetID(), position, pause, type1, type2, zone->GetZoneID()); + uint32 tmp_grid = content_db.AddWPForSpawn(c, s2info->GetID(), position, pause, type1, type2, zone->GetZoneID()); if (tmp_grid) { target->CastToNPC()->SetGrid(tmp_grid); } diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 73936bc2c..c9e2ace70 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -1832,7 +1832,7 @@ void QuestManager::showgrid(int grid) { std::string query = StringFormat("SELECT `x`,`y`,`z` FROM grid_entries " "WHERE `gridid` = %i AND `zoneid` = %i " "ORDER BY `number`", grid, zone->GetZoneID()); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { LogQuests("Error loading grid [{}] for showgrid(): [{}]", grid, results.ErrorMessage().c_str()); return; diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index 958500550..437846176 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -239,7 +239,7 @@ bool Spawn2::Process() { if (spawn_group->wp_spawns && grid_ > 0) { glm::vec4 wploc; - starting_wp = database.GetRandomWaypointLocFromGrid(wploc, zone->GetZoneID(), grid_); + starting_wp = content_db.GetRandomWaypointLocFromGrid(wploc, zone->GetZoneID(), grid_); if (wploc.x != 0.0f || wploc.y != 0.0f || wploc.z != 0.0f) { loc = wploc; diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 65f4fd099..7c44472c1 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -578,7 +578,7 @@ void NPC::AssignWaypoints(int32 grid, int start_wp) // Retrieve the wander and pause types for this grid std::string query = StringFormat("SELECT `type`, `type2` FROM `grid` WHERE `id` = %i AND `zoneid` = %i", grid, zone->GetZoneID()); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { return; } @@ -597,7 +597,7 @@ void NPC::AssignWaypoints(int32 grid, int start_wp) query = StringFormat("SELECT `x`,`y`,`z`,`pause`,`heading`, `centerpoint` " "FROM grid_entries WHERE `gridid` = %i AND `zoneid` = %i " "ORDER BY `number`", grid, zone->GetZoneID()); - results = database.QueryDatabase(query); + results = content_db.QueryDatabase(query); if (!results.Success()) { return; } @@ -1148,7 +1148,7 @@ int ZoneDatabase::GetRandomWaypointLocFromGrid(glm::vec4 &loc, uint16 zoneid, in std::string query = StringFormat("SELECT `x`,`y`,`z`,`heading` " "FROM grid_entries WHERE `gridid` = %i AND `zoneid` = %u ORDER BY `number`", grid, zone->GetZoneID()); - auto results = database.QueryDatabase(query); + auto results = content_db.QueryDatabase(query); if (!results.Success()) { Log(Logs::General, Logs::Error, "MySQL Error while trying get random waypoint loc from grid %i in zoneid %u; %s", grid, zoneid, results.ErrorMessage().c_str()); return 0;