Skip to content

Commit

Permalink
Merge pull request #6570 from LandSandBoat/module_entity_loading_db
Browse files Browse the repository at this point in the history
Modules: Replace p.stmt with query inside LoadLuaModules
  • Loading branch information
zach2good authored Dec 20, 2024
2 parents 96e822c + 08b343d commit de2f341
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/map/utils/moduleutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,24 @@ namespace moduleutils
// we need to sanity check them here by checking the name and port against the database.
if (parts.size() >= 3 && parts[0] == "xi" && parts[1] == "zones")
{
auto zoneName = parts[2];
auto currentPort = map_port == 0 ? settings::get<uint16>("network.MAP_PORT") : map_port;
const auto zoneName = parts[2];
const auto currentPort = map_port == 0 ? settings::get<uint16>("network.MAP_PORT") : map_port;

auto rset = db::preparedStmt("SELECT `name`, zoneport FROM zone_settings WHERE `name` = ? AND zoneport = ?", zoneName, currentPort);
/*
TODO: Why doesn't preparedStmt work here?
auto rset = db::preparedStmt("SELECT name, zoneport FROM zone_settings WHERE name = ? AND zoneport = ?", zoneName, currentPort);
[debug] preparedStmt: SELECT name, zoneport FROM zone_settings WHERE name = ? AND zoneport = ? (db::preparedStmt::<lambda_1>::()::<lambda_1>::operator ():517)
[debug] binding 1: GM_Home (db::detail::bindValue:368)
[debug] binding 2: 54230 (db::detail::bindValue:368)
But then no rows in the rset?
*/
const auto rset = db::query(fmt::format("SELECT name, zoneport FROM zone_settings WHERE name = '{}' AND zoneport = {}", zoneName, currentPort).c_str());
if (rset && rset->rowsCount() == 0)
{
DebugModules(fmt::format("{} does not appear to exist on this process.", zoneName));
DebugModules(fmt::format("{} does not appear to exist on this process (port: {})", zoneName, currentPort));
skipOverrideCheck = true;
continue;
}
Expand Down

0 comments on commit de2f341

Please sign in to comment.