chore: Use string to access SQLite columns (#1535)

* use string to access field name

* Update DEVGMCommands.cpp

* corrected column name

* constexpr array

include <array>

Revert "constexpr array"

This reverts commit 1492e8b1773ed5fbbe767c74466ca263178ecdd4.

Revert "include <array>"

This reverts commit 2b7a67e89ad673d420f496be97f9bc51fd2d5e59.

include <array>

constexpr array

---------

Co-authored-by: jadebenn <jonahbenn@yahoo.com>
This commit is contained in:
David Markowitz
2024-04-13 21:41:51 -07:00
committed by GitHub
parent 3a6123fe36
commit 5049f215ba
18 changed files with 67 additions and 62 deletions

View File

@@ -33,10 +33,10 @@ Precondition::Precondition(const uint32_t condition) {
return;
}
this->type = static_cast<PreconditionType>(result.fieldIsNull(0) ? 0 : result.getIntField(0));
this->type = static_cast<PreconditionType>(result.fieldIsNull("type") ? 0 : result.getIntField("type"));
if (!result.fieldIsNull(1)) {
std::istringstream stream(result.getStringField(1));
if (!result.fieldIsNull("targetLOT")) {
std::istringstream stream(result.getStringField("targetLOT"));
std::string token;
while (std::getline(stream, token, ',')) {
@@ -45,7 +45,7 @@ Precondition::Precondition(const uint32_t condition) {
}
}
this->count = result.fieldIsNull(2) ? 1 : result.getIntField(2);
this->count = result.fieldIsNull("targetCount") ? 1 : result.getIntField("targetCount");
result.finalize();
}

View File

@@ -704,7 +704,7 @@ namespace DEVGMCommands {
auto tables = query.execQuery();
while (!tables.eof()) {
std::string message = std::to_string(tables.getIntField(0)) + " - " + tables.getStringField(1);
std::string message = std::to_string(tables.getIntField("id")) + " - " + tables.getStringField("name");
ChatPackets::SendSystemMessage(sysAddr, GeneralUtils::UTF8ToUTF16(message, message.size()));
tables.nextRow();
}