mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-23 05:53:34 +00:00
0367c67c85
* move the pet minigame table loading logic out of petcomponent * misc fixes * actually, using paths is dumb here when they're already char strings. why bother? silly me. * removed unga bunga reference-casting * add back in puzzle not found error message * pre-allocate unordered map and make getter const-correct * Update dDatabase/CDClientDatabase/CDClientTables/CDTamingBuildPuzzleTable.cpp Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> --------- Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>
36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
#include "CDTamingBuildPuzzleTable.h"
|
|
|
|
void CDTamingBuildPuzzleTable::LoadValuesFromDatabase() {
|
|
// First, get the size of the table
|
|
uint32_t size = 0;
|
|
auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM TamingBuildPuzzles");
|
|
while (!tableSize.eof()) {
|
|
size = tableSize.getIntField(0, 0);
|
|
tableSize.nextRow();
|
|
}
|
|
|
|
// Reserve the size
|
|
auto& entries = GetEntriesMutable();
|
|
entries.reserve(size);
|
|
|
|
// Now get the data
|
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM TamingBuildPuzzles");
|
|
while (!tableData.eof()) {
|
|
const auto lot = static_cast<LOT>(tableData.getIntField("NPCLot", LOT_NULL));
|
|
entries.emplace(lot, CDTamingBuildPuzzle{
|
|
.puzzleModelLot = lot,
|
|
.validPieces{ tableData.getStringField("ValidPiecesLXF") },
|
|
.timeLimit = static_cast<float>(tableData.getFloatField("Timelimit", 30.0f)),
|
|
.numValidPieces = tableData.getIntField("NumValidPieces", 6),
|
|
.imaginationCost = tableData.getIntField("imagCostPerBuild", 10)
|
|
});
|
|
tableData.nextRow();
|
|
}
|
|
}
|
|
|
|
const CDTamingBuildPuzzle* CDTamingBuildPuzzleTable::GetByLOT(const LOT lot) const {
|
|
const auto& entries = GetEntries();
|
|
const auto itr = entries.find(lot);
|
|
return itr != entries.cend() ? &itr->second : nullptr;
|
|
}
|