2021-12-05 17:54:36 +00:00
|
|
|
#include "CDRailActivatorComponent.h"
|
|
|
|
#include "GeneralUtils.h"
|
|
|
|
|
2023-08-11 04:27:40 +00:00
|
|
|
void CDRailActivatorComponentTable::LoadValuesFromDatabase() {
|
2022-07-28 13:39:57 +00:00
|
|
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM RailActivatorComponent;");
|
2024-02-09 13:37:58 +00:00
|
|
|
auto& entries = GetEntriesMutable();
|
2022-07-28 13:39:57 +00:00
|
|
|
while (!tableData.eof()) {
|
|
|
|
CDRailActivatorComponent entry;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-07 09:48:59 +00:00
|
|
|
entry.id = tableData.getIntField("id", 0);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-07 09:48:59 +00:00
|
|
|
entry.startAnimation = GeneralUtils::ASCIIToUTF16(tableData.getStringField("startAnim", ""));
|
|
|
|
entry.loopAnimation = GeneralUtils::ASCIIToUTF16(tableData.getStringField("loopAnim", ""));
|
|
|
|
entry.stopAnimation = GeneralUtils::ASCIIToUTF16(tableData.getStringField("stopAnim", ""));
|
|
|
|
entry.startSound = GeneralUtils::ASCIIToUTF16(tableData.getStringField("startSound", ""));
|
|
|
|
entry.loopSound = GeneralUtils::ASCIIToUTF16(tableData.getStringField("loopSound", ""));
|
|
|
|
entry.stopSound = GeneralUtils::ASCIIToUTF16(tableData.getStringField("stopSound", ""));
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-07 09:48:59 +00:00
|
|
|
std::string loopEffectString(tableData.getStringField("effectIDs", ""));
|
2022-07-28 13:39:57 +00:00
|
|
|
entry.loopEffectID = EffectPairFromString(loopEffectString);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-07 09:48:59 +00:00
|
|
|
entry.preconditions = tableData.getStringField("preconditions", "-1");
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-07 09:48:59 +00:00
|
|
|
entry.playerCollision = tableData.getIntField("playerCollision", 0);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-07 09:48:59 +00:00
|
|
|
entry.cameraLocked = tableData.getIntField("cameraLocked", 0);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-07 09:48:59 +00:00
|
|
|
std::string startEffectString(tableData.getStringField("StartEffectID", ""));
|
2022-07-28 13:39:57 +00:00
|
|
|
entry.startEffectID = EffectPairFromString(startEffectString);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-07 09:48:59 +00:00
|
|
|
std::string stopEffectString(tableData.getStringField("StopEffectID", ""));
|
2022-07-28 13:39:57 +00:00
|
|
|
entry.stopEffectID = EffectPairFromString(stopEffectString);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-07 09:48:59 +00:00
|
|
|
entry.damageImmune = tableData.getIntField("DamageImmune", 0);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-07 09:48:59 +00:00
|
|
|
entry.noAggro = tableData.getIntField("NoAggro", 0);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-07 09:48:59 +00:00
|
|
|
entry.showNameBillboard = tableData.getIntField("ShowNameBillboard", 0);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2024-02-09 13:37:58 +00:00
|
|
|
entries.push_back(entry);
|
2022-07-28 13:39:57 +00:00
|
|
|
tableData.nextRow();
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
tableData.finalize();
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CDRailActivatorComponent CDRailActivatorComponentTable::GetEntryByID(int32_t id) const {
|
2024-02-09 13:37:58 +00:00
|
|
|
for (const auto& entry : GetEntries()) {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (entry.id == id)
|
|
|
|
return entry;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
return {};
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
std::pair<uint32_t, std::u16string> CDRailActivatorComponentTable::EffectPairFromString(std::string& str) {
|
|
|
|
const auto split = GeneralUtils::SplitString(str, ':');
|
|
|
|
if (split.size() == 2) {
|
|
|
|
return { std::stoi(split.at(0)), GeneralUtils::ASCIIToUTF16(split.at(1)) };
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
return {};
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
2023-01-07 09:48:59 +00:00
|
|
|
|