mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-09 08:58:04 +00:00
Further work on subcomponents
serialization is improved, next is re-implementing the actual functionality.
This commit is contained in:
45
dDatabase/Tables/CDMovingPlatformComponentTable.cpp
Normal file
45
dDatabase/Tables/CDMovingPlatformComponentTable.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "CDMovingPlatformComponentTable.h"
|
||||
|
||||
CDMovingPlatformComponentTable::CDMovingPlatformComponentTable() {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MovementAIComponent");
|
||||
while (!tableData.eof()) {
|
||||
CDMovingPlatformTableEntry entry;
|
||||
entry.platformIsSimpleMover = tableData.getIntField("platformIsSimpleMover", 0) == 1;
|
||||
entry.platformStartAtEnd = tableData.getIntField("platformStartAtEnd", 0) == 1;
|
||||
entry.platformMove.x = tableData.getFloatField("platformMoveX", 0.0f);
|
||||
entry.platformMove.y = tableData.getFloatField("platformMoveY", 0.0f);
|
||||
entry.platformMove.z = tableData.getFloatField("platformMoveZ", 0.0f);
|
||||
entry.moveTime = tableData.getFloatField("platformMoveTime", -1.0f);
|
||||
|
||||
DluAssert(m_Platforms.insert(std::make_pair(tableData.getIntField("id", -1), entry)).second);
|
||||
tableData.nextRow();
|
||||
}
|
||||
}
|
||||
|
||||
void CDMovingPlatformComponentTable::CachePlatformEntry(ComponentID id) {
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM MovementAIComponent WHERE id = ?;");
|
||||
query.bind(1, static_cast<int32_t>(id));
|
||||
|
||||
auto tableData = query.execQuery();
|
||||
while (!tableData.eof()) {
|
||||
CDMovingPlatformTableEntry entry;
|
||||
entry.platformIsSimpleMover = tableData.getIntField("platformIsSimpleMover", 0) == 1;
|
||||
entry.platformStartAtEnd = tableData.getIntField("platformStartAtEnd", 0) == 1;
|
||||
entry.platformMove.x = tableData.getFloatField("platformMoveX", 0.0f);
|
||||
entry.platformMove.y = tableData.getFloatField("platformMoveY", 0.0f);
|
||||
entry.platformMove.z = tableData.getFloatField("platformMoveZ", 0.0f);
|
||||
entry.moveTime = tableData.getFloatField("platformMoveTime", -1.0f);
|
||||
|
||||
DluAssert(m_Platforms.insert(std::make_pair(tableData.getIntField("id", -1), entry)).second);
|
||||
tableData.nextRow();
|
||||
}
|
||||
}
|
||||
|
||||
const std::optional<CDMovingPlatformTableEntry> CDMovingPlatformComponentTable::GetPlatformEntry(ComponentID id) {
|
||||
auto itr = m_Platforms.find(id);
|
||||
if (itr == m_Platforms.end()) {
|
||||
CachePlatformEntry(id);
|
||||
itr = m_Platforms.find(id);
|
||||
}
|
||||
return itr != m_Platforms.end() ? std::make_optional<CDMovingPlatformTableEntry>(itr->second) : std::nullopt;
|
||||
}
|
27
dDatabase/Tables/CDMovingPlatformComponentTable.h
Normal file
27
dDatabase/Tables/CDMovingPlatformComponentTable.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef __CDMOVINGPLATFORMCOMPONENTTABLE__H__
|
||||
#define __CDMOVINGPLATFORMCOMPONENTTABLE__H__
|
||||
|
||||
#include "CDTable.h"
|
||||
#include "NiPoint3.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
typedef uint32_t ComponentID;
|
||||
|
||||
struct CDMovingPlatformTableEntry {
|
||||
NiPoint3 platformMove;
|
||||
float moveTime;
|
||||
bool platformIsSimpleMover;
|
||||
bool platformStartAtEnd;
|
||||
};
|
||||
|
||||
class CDMovingPlatformComponentTable : public CDTable<CDMovingPlatformComponentTable> {
|
||||
public:
|
||||
CDMovingPlatformComponentTable();
|
||||
|
||||
void CachePlatformEntry(ComponentID id);
|
||||
const std::optional<CDMovingPlatformTableEntry> GetPlatformEntry(ComponentID id);
|
||||
private:
|
||||
std::map<ComponentID, CDMovingPlatformTableEntry> m_Platforms;
|
||||
};
|
||||
#endif //!__CDMOVINGPLATFORMCOMPONENTTABLE__H__
|
@@ -16,6 +16,7 @@ set(DDATABASE_TABLES_SOURCES "CDActivitiesTable.cpp"
|
||||
"CDLevelProgressionLookupTable.cpp"
|
||||
"CDLootMatrixTable.cpp"
|
||||
"CDLootTableTable.cpp"
|
||||
"CDMovingPlatformComponentTable.cpp"
|
||||
"CDMissionEmailTable.cpp"
|
||||
"CDMissionNPCComponentTable.cpp"
|
||||
"CDMissionsTable.cpp"
|
||||
|
Reference in New Issue
Block a user