[Grids] Convert Grid/Grid Entries to Repositories (#4011)

* [Grids] Convert Grid/Grid Entries to Repositories

- Convert `AddWaypoint()`, `AddWaypointForSpawn()`, `DeleteWaypoint()`, `GetHighestWaypoint()`, `GetRandomWaypointFromGrid()`, `GridExistsInZone()`, and `ModifyGrid()` to repositories.

* Update grid.cpp

* Update questmgr.cpp

* Update waypoints.cpp

* Update waypoints.cpp
This commit is contained in:
Alex King
2024-01-29 00:37:34 -05:00
committed by GitHub
parent 8e3218aaf7
commit 2e0ed82986
11 changed files with 418 additions and 327 deletions
+21
View File
@@ -71,6 +71,27 @@ public:
return grids;
}
static int GetHighestGrid(Database& db, uint32 zone_id)
{
auto results = db.QueryDatabase(
fmt::format(
SQL(
SELECT COALESCE(MAX(`id`), 0) FROM `{}`
WHERE `zoneid` = {}
),
TableName(),
zone_id
)
);
if (!results.Success() || !results.RowCount()) {
return 0;
}
auto row = results.begin();
return Strings::ToInt(row[0]);
}
};
#endif //EQEMU_GRID_REPOSITORY_H