mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-10 09:28:06 +00:00
branch back to working state
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include "CDRailActivatorComponent.h"
|
||||
#include "CDRewardCodesTable.h"
|
||||
#include "CDPetComponentTable.h"
|
||||
#include "CDMovingPlatformComponentTable.h"
|
||||
|
||||
#include <exception>
|
||||
|
||||
@@ -110,6 +111,7 @@ DEFINE_TABLE_STORAGE(CDScriptComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDSkillBehaviorTable);
|
||||
DEFINE_TABLE_STORAGE(CDVendorComponentTable);
|
||||
DEFINE_TABLE_STORAGE(CDZoneTableTable);
|
||||
DEFINE_TABLE_STORAGE(CDMovingPlatformComponentTable);
|
||||
|
||||
void CDClientManager::LoadValuesFromDatabase() {
|
||||
if (!CDClientDatabase::isConnected) throw CDClientConnectionException();
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include "CDMovingPlatformComponentTable.h"
|
||||
|
||||
CDMovingPlatformComponentTable::CDMovingPlatformComponentTable() {
|
||||
auto& entries = GetEntriesMutable();
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MovingPlatforms");
|
||||
while (!tableData.eof()) {
|
||||
CDMovingPlatformTableEntry entry;
|
||||
@@ -11,12 +12,13 @@ CDMovingPlatformComponentTable::CDMovingPlatformComponentTable() {
|
||||
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);
|
||||
DluAssert(entries.insert(std::make_pair(tableData.getIntField("id", -1), entry)).second);
|
||||
tableData.nextRow();
|
||||
}
|
||||
}
|
||||
|
||||
void CDMovingPlatformComponentTable::CachePlatformEntry(ComponentID id) {
|
||||
auto& entries = GetEntriesMutable();
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM MovingPlatforms WHERE id = ?;");
|
||||
query.bind(1, static_cast<int32_t>(id));
|
||||
|
||||
@@ -30,16 +32,17 @@ void CDMovingPlatformComponentTable::CachePlatformEntry(ComponentID id) {
|
||||
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);
|
||||
DluAssert(entries.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()) {
|
||||
auto& entries = GetEntriesMutable();
|
||||
auto itr = entries.find(id);
|
||||
if (itr == entries.end()) {
|
||||
CachePlatformEntry(id);
|
||||
itr = m_Platforms.find(id);
|
||||
itr = entries.find(id);
|
||||
}
|
||||
return itr != m_Platforms.end() ? std::make_optional<CDMovingPlatformTableEntry>(itr->second) : std::nullopt;
|
||||
return itr != entries.end() ? std::make_optional<CDMovingPlatformTableEntry>(itr->second) : std::nullopt;
|
||||
}
|
||||
|
@@ -15,13 +15,11 @@ struct CDMovingPlatformTableEntry {
|
||||
bool platformStartAtEnd;
|
||||
};
|
||||
|
||||
class CDMovingPlatformComponentTable : public CDTable<CDMovingPlatformComponentTable> {
|
||||
class CDMovingPlatformComponentTable : public CDTable<CDMovingPlatformComponentTable, std::map<ComponentID, CDMovingPlatformTableEntry>> {
|
||||
public:
|
||||
CDMovingPlatformComponentTable();
|
||||
|
||||
void CachePlatformEntry(ComponentID id);
|
||||
const std::optional<CDMovingPlatformTableEntry> GetPlatformEntry(ComponentID id);
|
||||
private:
|
||||
std::map<ComponentID, CDMovingPlatformTableEntry> m_Platforms;
|
||||
};
|
||||
#endif //!__CDMOVINGPLATFORMCOMPONENTTABLE__H__
|
||||
|
Reference in New Issue
Block a user