Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dCommon/DluAssert.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define __DLUASSERT__H__

#include <assert.h>
#define _DEBUG

#ifdef _DEBUG
# define DluAssert(expression) assert(expression)
Expand Down
1 change: 1 addition & 0 deletions dCommon/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ constexpr const char* GetFileNameFromAbsolutePath(const char* path) {
// is used in the instruction instead of the start of the absolute path.
#define LOG(message, ...) do { auto str = FILENAME_AND_LINE; Game::logger->Log(str, message, ##__VA_ARGS__); } while(0)
#define LOG_DEBUG(message, ...) do { auto str = FILENAME_AND_LINE; Game::logger->LogDebug(str, message, ##__VA_ARGS__); } while(0)
#define LOG_TEST(message, ...) do { auto str = FILENAME_AND_LINE; Game::logger->LogDebug(str, message, ##__VA_ARGS__); Game::logger->Flush();} while(0)

// Writer class for writing data to files.
class Writer {
Expand Down
16 changes: 0 additions & 16 deletions dCommon/dEnums/eMovementPlatformState.h

This file was deleted.

2 changes: 2 additions & 0 deletions dDatabase/CDClientDatabase/CDClientManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "CDRailActivatorComponent.h"
#include "CDRewardCodesTable.h"
#include "CDPetComponentTable.h"
#include "CDMovingPlatformComponentTable.h"

#include <exception>

Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "CDMovingPlatformComponentTable.h"

CDMovingPlatformComponentTable::CDMovingPlatformComponentTable() {
auto& entries = GetEntriesMutable();
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MovingPlatforms");
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(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));

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(entries.insert(std::make_pair(tableData.getIntField("id", -1), entry)).second);
tableData.nextRow();
}
}

const std::optional<CDMovingPlatformTableEntry> CDMovingPlatformComponentTable::GetPlatformEntry(ComponentID id) {
auto& entries = GetEntriesMutable();
auto itr = entries.find(id);
if (itr == entries.end()) {
CachePlatformEntry(id);
itr = entries.find(id);
}
return itr != entries.end() ? std::make_optional<CDMovingPlatformTableEntry>(itr->second) : std::nullopt;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#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, std::map<ComponentID, CDMovingPlatformTableEntry>> {
public:
CDMovingPlatformComponentTable();

void CachePlatformEntry(ComponentID id);
const std::optional<CDMovingPlatformTableEntry> GetPlatformEntry(ComponentID id);
};
#endif //!__CDMOVINGPLATFORMCOMPONENTTABLE__H__
1 change: 1 addition & 0 deletions dDatabase/CDClientDatabase/CDClientTables/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set(DDATABASE_CDCLIENTDATABASE_CDCLIENTTABLES_SOURCES "CDActivitiesTable.cpp"
"CDLevelProgressionLookupTable.cpp"
"CDLootMatrixTable.cpp"
"CDLootTableTable.cpp"
"CDMovingPlatformComponentTable.cpp"
"CDMissionEmailTable.cpp"
"CDMissionNPCComponentTable.cpp"
"CDMissionsTable.cpp"
Expand Down
2 changes: 1 addition & 1 deletion dGame/EntityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ Entity* EntityManager::GetSpawnPointEntity(const std::string& spawnName) const {
// Check if the spawn point entity is valid just in case
return spawnPoint == m_SpawnPoints.end() ? nullptr : GetEntity(spawnPoint->second);
}

#include <thread>
const std::unordered_map<std::string, LWOOBJID>& EntityManager::GetSpawnPointEntities() const {
return m_SpawnPoints;
}
Expand Down
Loading