mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 18:24:12 +00:00
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:
@@ -405,18 +405,18 @@ void Item::DisassembleModel(uint32_t numToDismantle) {
|
||||
|
||||
auto result = query.execQuery();
|
||||
|
||||
if (result.eof() || result.fieldIsNull(0)) {
|
||||
if (result.eof() || result.fieldIsNull("render_asset")) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string renderAsset = std::string(result.getStringField(0));
|
||||
std::string renderAsset = std::string(result.getStringField("render_asset"));
|
||||
|
||||
// normalize path slashes
|
||||
for (auto& c : renderAsset) {
|
||||
if (c == '\\') c = '/';
|
||||
}
|
||||
|
||||
std::string lxfmlFolderName = std::string(result.getStringField(1));
|
||||
std::string lxfmlFolderName = std::string(result.getStringField("LXFMLFolder"));
|
||||
if (!lxfmlFolderName.empty()) lxfmlFolderName.insert(0, "/");
|
||||
|
||||
std::vector<std::string> renderAssetSplit = GeneralUtils::SplitString(renderAsset, '/');
|
||||
|
@@ -8,10 +8,13 @@
|
||||
#include "MissionComponent.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
#include "CDSkillBehaviorTable.h"
|
||||
|
||||
ItemSet::ItemSet(const uint32_t id, InventoryComponent* inventoryComponent) {
|
||||
using namespace std::string_view_literals;
|
||||
|
||||
this->m_ID = id;
|
||||
this->m_InventoryComponent = inventoryComponent;
|
||||
|
||||
@@ -27,14 +30,16 @@ ItemSet::ItemSet(const uint32_t id, InventoryComponent* inventoryComponent) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto i = 0; i < 5; ++i) {
|
||||
if (result.fieldIsNull(i)) {
|
||||
constexpr std::array rowNames = { "skillSetWith2"sv, "skillSetWith3"sv, "skillSetWith4"sv, "skillSetWith5"sv, "skillSetWith6"sv };
|
||||
for (auto i = 0; i < rowNames.size(); ++i) {
|
||||
const auto rowName = rowNames[i];
|
||||
if (result.fieldIsNull(rowName.data())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto skillQuery = CDClientDatabase::CreatePreppedStmt(
|
||||
"SELECT SkillID FROM ItemSetSkills WHERE SkillSetID = ?;");
|
||||
skillQuery.bind(1, result.getIntField(i));
|
||||
skillQuery.bind(1, result.getIntField(rowName.data()));
|
||||
|
||||
auto skillResult = skillQuery.execQuery();
|
||||
|
||||
@@ -43,13 +48,13 @@ ItemSet::ItemSet(const uint32_t id, InventoryComponent* inventoryComponent) {
|
||||
}
|
||||
|
||||
while (!skillResult.eof()) {
|
||||
if (skillResult.fieldIsNull(0)) {
|
||||
if (skillResult.fieldIsNull("SkillID")) {
|
||||
skillResult.nextRow();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto skillId = skillResult.getIntField(0);
|
||||
const auto skillId = skillResult.getIntField("SkillID");
|
||||
|
||||
switch (i) {
|
||||
case 0:
|
||||
@@ -75,7 +80,7 @@ ItemSet::ItemSet(const uint32_t id, InventoryComponent* inventoryComponent) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string ids = result.getStringField(5);
|
||||
std::string ids = result.getStringField("itemIDs");
|
||||
|
||||
ids.erase(std::remove_if(ids.begin(), ids.end(), ::isspace), ids.end());
|
||||
|
||||
|
Reference in New Issue
Block a user