-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chat-http-api
- Loading branch information
Showing
7 changed files
with
134 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
dDatabase/CDClientDatabase/CDClientTables/CDTamingBuildPuzzleTable.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#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; | ||
} |
60 changes: 60 additions & 0 deletions
60
dDatabase/CDClientDatabase/CDClientTables/CDTamingBuildPuzzleTable.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#pragma once | ||
#include "CDTable.h" | ||
|
||
/** | ||
* Information for the minigame to be completed | ||
*/ | ||
struct CDTamingBuildPuzzle { | ||
UNUSED_COLUMN(uint32_t id = 0;) | ||
|
||
// The LOT of the object that is to be created | ||
LOT puzzleModelLot = LOT_NULL; | ||
|
||
// The LOT of the NPC | ||
UNUSED_COLUMN(LOT npcLot = LOT_NULL;) | ||
|
||
// The .lxfml file that contains the bricks required to build the model | ||
std::string validPieces{}; | ||
|
||
// The .lxfml file that contains the bricks NOT required to build the model | ||
UNUSED_COLUMN(std::string invalidPieces{};) | ||
|
||
// Difficulty value | ||
UNUSED_COLUMN(int32_t difficulty = 1;) | ||
|
||
// The time limit to complete the build | ||
float timeLimit = 30.0f; | ||
|
||
// The number of pieces required to complete the minigame | ||
int32_t numValidPieces = 6; | ||
|
||
// Number of valid pieces | ||
UNUSED_COLUMN(int32_t totalNumPieces = 16;) | ||
|
||
// Model name | ||
UNUSED_COLUMN(std::string modelName{};) | ||
|
||
// The .lxfml file that contains the full model | ||
UNUSED_COLUMN(std::string fullModel{};) | ||
|
||
// The duration of the pet taming minigame | ||
UNUSED_COLUMN(float duration = 45.0f;) | ||
|
||
// The imagination cost for the tamer to start the minigame | ||
int32_t imaginationCost = 10; | ||
}; | ||
|
||
class CDTamingBuildPuzzleTable : public CDTable<CDTamingBuildPuzzleTable, std::unordered_map<LOT, CDTamingBuildPuzzle>> { | ||
public: | ||
/** | ||
* Load values from the CD client database | ||
*/ | ||
void LoadValuesFromDatabase(); | ||
|
||
/** | ||
* Gets the pet ability table corresponding to the pet LOT | ||
* @returns A pointer to the corresponding table, or nullptr if one cannot be found | ||
*/ | ||
[[nodiscard]] | ||
const CDTamingBuildPuzzle* GetByLOT(const LOT lot) const; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.