mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-24 22:43:34 +00:00
Merge remote-tracking branch 'upstream/main' into PetFixes
This commit is contained in:
commit
9a9254b583
@ -4,6 +4,8 @@ include(CTest)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CXX_STANDARD_REQUIRED ON)
|
set(CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW) # Set CMAKE visibility policy to NEW on project and subprojects
|
||||||
|
set(CMAKE_CXX_VISIBILITY_PRESET hidden) # Set C++ symbol visibility to default to hidden
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
# Read variables from file
|
# Read variables from file
|
||||||
|
@ -264,8 +264,8 @@ namespace GeneralUtils {
|
|||||||
* @returns The enum entry's value in its underlying type
|
* @returns The enum entry's value in its underlying type
|
||||||
*/
|
*/
|
||||||
template <Enum eType>
|
template <Enum eType>
|
||||||
constexpr typename std::underlying_type_t<eType> CastUnderlyingType(const eType entry) noexcept {
|
constexpr std::underlying_type_t<eType> ToUnderlying(const eType entry) noexcept {
|
||||||
return static_cast<typename std::underlying_type_t<eType>>(entry);
|
return static_cast<std::underlying_type_t<eType>>(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
// on Windows we need to undef these or else they conflict with our numeric limits calls
|
// on Windows we need to undef these or else they conflict with our numeric limits calls
|
||||||
|
@ -58,7 +58,7 @@ void CDLootTableTable::LoadValuesFromDatabase() {
|
|||||||
CDLootTable entry;
|
CDLootTable entry;
|
||||||
uint32_t lootTableIndex = tableData.getIntField("LootTableIndex", -1);
|
uint32_t lootTableIndex = tableData.getIntField("LootTableIndex", -1);
|
||||||
|
|
||||||
entries[lootTableIndex].push_back(ReadRow(tableData));
|
entries[lootTableIndex].emplace_back(ReadRow(tableData));
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
for (auto& [id, table] : entries) {
|
for (auto& [id, table] : entries) {
|
||||||
@ -66,7 +66,7 @@ void CDLootTableTable::LoadValuesFromDatabase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const LootTableEntries& CDLootTableTable::GetTable(uint32_t tableId) {
|
const LootTableEntries& CDLootTableTable::GetTable(const uint32_t tableId) {
|
||||||
auto& entries = GetEntriesMutable();
|
auto& entries = GetEntriesMutable();
|
||||||
auto itr = entries.find(tableId);
|
auto itr = entries.find(tableId);
|
||||||
if (itr != entries.end()) {
|
if (itr != entries.end()) {
|
||||||
@ -79,7 +79,7 @@ const LootTableEntries& CDLootTableTable::GetTable(uint32_t tableId) {
|
|||||||
|
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDLootTable entry;
|
CDLootTable entry;
|
||||||
entries[tableId].push_back(ReadRow(tableData));
|
entries[tableId].emplace_back(ReadRow(tableData));
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
SortTable(entries[tableId]);
|
SortTable(entries[tableId]);
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// Custom Classes
|
// Custom Classes
|
||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
struct CDLootTable {
|
struct CDLootTable {
|
||||||
uint32_t itemid; //!< The LOT of the item
|
uint32_t itemid; //!< The LOT of the item
|
||||||
uint32_t LootTableIndex; //!< The Loot Table Index
|
uint32_t LootTableIndex; //!< The Loot Table Index
|
||||||
@ -20,6 +22,5 @@ private:
|
|||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
void LoadValuesFromDatabase();
|
||||||
// Queries the table with a custom "where" clause
|
// Queries the table with a custom "where" clause
|
||||||
const LootTableEntries& GetTable(uint32_t tableId);
|
const LootTableEntries& GetTable(const uint32_t tableId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ void CDMissionEmailTable::LoadValuesFromDatabase() {
|
|||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MissionEmail");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MissionEmail");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDMissionEmail entry;
|
auto& entry = entries.emplace_back();
|
||||||
entry.ID = tableData.getIntField("ID", -1);
|
entry.ID = tableData.getIntField("ID", -1);
|
||||||
entry.messageType = tableData.getIntField("messageType", -1);
|
entry.messageType = tableData.getIntField("messageType", -1);
|
||||||
entry.notificationGroup = tableData.getIntField("notificationGroup", -1);
|
entry.notificationGroup = tableData.getIntField("notificationGroup", -1);
|
||||||
@ -30,11 +30,8 @@ void CDMissionEmailTable::LoadValuesFromDatabase() {
|
|||||||
entry.locStatus = tableData.getIntField("locStatus", -1);
|
entry.locStatus = tableData.getIntField("locStatus", -1);
|
||||||
entry.gate_version = tableData.getStringField("gate_version", "");
|
entry.gate_version = tableData.getStringField("gate_version", "");
|
||||||
|
|
||||||
entries.push_back(entry);
|
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Queries the table with a custom "where" clause
|
//! Queries the table with a custom "where" clause
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// Custom Classes
|
// Custom Classes
|
||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
struct CDMissionEmail {
|
struct CDMissionEmail {
|
||||||
uint32_t ID;
|
uint32_t ID;
|
||||||
uint32_t messageType;
|
uint32_t messageType;
|
||||||
|
@ -20,18 +20,15 @@ void CDMissionNPCComponentTable::LoadValuesFromDatabase() {
|
|||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MissionNPCComponent");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MissionNPCComponent");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDMissionNPCComponent entry;
|
auto& entry = entries.emplace_back();
|
||||||
entry.id = tableData.getIntField("id", -1);
|
entry.id = tableData.getIntField("id", -1);
|
||||||
entry.missionID = tableData.getIntField("missionID", -1);
|
entry.missionID = tableData.getIntField("missionID", -1);
|
||||||
entry.offersMission = tableData.getIntField("offersMission", -1) == 1 ? true : false;
|
entry.offersMission = tableData.getIntField("offersMission", -1) == 1 ? true : false;
|
||||||
entry.acceptsMission = tableData.getIntField("acceptsMission", -1) == 1 ? true : false;
|
entry.acceptsMission = tableData.getIntField("acceptsMission", -1) == 1 ? true : false;
|
||||||
entry.gate_version = tableData.getStringField("gate_version", "");
|
entry.gate_version = tableData.getStringField("gate_version", "");
|
||||||
|
|
||||||
entries.push_back(entry);
|
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Queries the table with a custom "where" clause
|
//! Queries the table with a custom "where" clause
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// Custom Classes
|
// Custom Classes
|
||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
struct CDMissionNPCComponent {
|
struct CDMissionNPCComponent {
|
||||||
uint32_t id; //!< The ID
|
uint32_t id; //!< The ID
|
||||||
uint32_t missionID; //!< The Mission ID
|
uint32_t missionID; //!< The Mission ID
|
||||||
@ -17,4 +19,3 @@ public:
|
|||||||
// Queries the table with a custom "where" clause
|
// Queries the table with a custom "where" clause
|
||||||
std::vector<CDMissionNPCComponent> Query(std::function<bool(CDMissionNPCComponent)> predicate);
|
std::vector<CDMissionNPCComponent> Query(std::function<bool(CDMissionNPCComponent)> predicate);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ void CDMissionTasksTable::LoadValuesFromDatabase() {
|
|||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MissionTasks");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MissionTasks");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDMissionTasks entry;
|
auto& entry = entries.emplace_back();
|
||||||
entry.id = tableData.getIntField("id", -1);
|
entry.id = tableData.getIntField("id", -1);
|
||||||
UNUSED(entry.locStatus = tableData.getIntField("locStatus", -1));
|
UNUSED(entry.locStatus = tableData.getIntField("locStatus", -1));
|
||||||
entry.taskType = tableData.getIntField("taskType", -1);
|
entry.taskType = tableData.getIntField("taskType", -1);
|
||||||
@ -35,11 +35,8 @@ void CDMissionTasksTable::LoadValuesFromDatabase() {
|
|||||||
UNUSED(entry.localize = tableData.getIntField("localize", -1) == 1 ? true : false);
|
UNUSED(entry.localize = tableData.getIntField("localize", -1) == 1 ? true : false);
|
||||||
UNUSED(entry.gate_version = tableData.getStringField("gate_version", ""));
|
UNUSED(entry.gate_version = tableData.getStringField("gate_version", ""));
|
||||||
|
|
||||||
entries.push_back(entry);
|
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CDMissionTasks> CDMissionTasksTable::Query(std::function<bool(CDMissionTasks)> predicate) {
|
std::vector<CDMissionTasks> CDMissionTasksTable::Query(std::function<bool(CDMissionTasks)> predicate) {
|
||||||
@ -51,7 +48,7 @@ std::vector<CDMissionTasks> CDMissionTasksTable::Query(std::function<bool(CDMiss
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CDMissionTasks*> CDMissionTasksTable::GetByMissionID(uint32_t missionID) {
|
std::vector<CDMissionTasks*> CDMissionTasksTable::GetByMissionID(const uint32_t missionID) {
|
||||||
std::vector<CDMissionTasks*> tasks;
|
std::vector<CDMissionTasks*> tasks;
|
||||||
|
|
||||||
// TODO: this should not be linear(?) and also shouldnt need to be a pointer
|
// TODO: this should not be linear(?) and also shouldnt need to be a pointer
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// Custom Classes
|
// Custom Classes
|
||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
struct CDMissionTasks {
|
struct CDMissionTasks {
|
||||||
uint32_t id; //!< The Mission ID that the task belongs to
|
uint32_t id; //!< The Mission ID that the task belongs to
|
||||||
UNUSED(uint32_t locStatus); //!< ???
|
UNUSED(uint32_t locStatus); //!< ???
|
||||||
@ -25,7 +27,7 @@ public:
|
|||||||
// Queries the table with a custom "where" clause
|
// Queries the table with a custom "where" clause
|
||||||
std::vector<CDMissionTasks> Query(std::function<bool(CDMissionTasks)> predicate);
|
std::vector<CDMissionTasks> Query(std::function<bool(CDMissionTasks)> predicate);
|
||||||
|
|
||||||
std::vector<CDMissionTasks*> GetByMissionID(uint32_t missionID);
|
std::vector<CDMissionTasks*> GetByMissionID(const uint32_t missionID);
|
||||||
|
|
||||||
// TODO: Remove this and replace it with a proper lookup function.
|
// TODO: Remove this and replace it with a proper lookup function.
|
||||||
const CDTable::StorageType& GetEntries() const;
|
const CDTable::StorageType& GetEntries() const;
|
||||||
|
@ -22,7 +22,7 @@ void CDMissionsTable::LoadValuesFromDatabase() {
|
|||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Missions");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Missions");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDMissions entry;
|
auto& entry = entries.emplace_back();
|
||||||
entry.id = tableData.getIntField("id", -1);
|
entry.id = tableData.getIntField("id", -1);
|
||||||
entry.defined_type = tableData.getStringField("defined_type", "");
|
entry.defined_type = tableData.getStringField("defined_type", "");
|
||||||
entry.defined_subtype = tableData.getStringField("defined_subtype", "");
|
entry.defined_subtype = tableData.getStringField("defined_subtype", "");
|
||||||
@ -76,7 +76,6 @@ void CDMissionsTable::LoadValuesFromDatabase() {
|
|||||||
UNUSED(entry.locStatus = tableData.getIntField("locStatus", -1));
|
UNUSED(entry.locStatus = tableData.getIntField("locStatus", -1));
|
||||||
entry.reward_bankinventory = tableData.getIntField("reward_bankinventory", -1);
|
entry.reward_bankinventory = tableData.getIntField("reward_bankinventory", -1);
|
||||||
|
|
||||||
entries.push_back(entry);
|
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
|
@ -75,4 +75,3 @@ public:
|
|||||||
|
|
||||||
static CDMissions Default;
|
static CDMissions Default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ void CDMovementAIComponentTable::LoadValuesFromDatabase() {
|
|||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MovementAIComponent");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM MovementAIComponent");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDMovementAIComponent entry;
|
auto& entry = entries.emplace_back();
|
||||||
entry.id = tableData.getIntField("id", -1);
|
entry.id = tableData.getIntField("id", -1);
|
||||||
entry.MovementType = tableData.getStringField("MovementType", "");
|
entry.MovementType = tableData.getStringField("MovementType", "");
|
||||||
entry.WanderChance = tableData.getFloatField("WanderChance", -1.0f);
|
entry.WanderChance = tableData.getFloatField("WanderChance", -1.0f);
|
||||||
@ -30,11 +30,8 @@ void CDMovementAIComponentTable::LoadValuesFromDatabase() {
|
|||||||
entry.WanderRadius = tableData.getFloatField("WanderRadius", -1.0f);
|
entry.WanderRadius = tableData.getFloatField("WanderRadius", -1.0f);
|
||||||
entry.attachedPath = tableData.getStringField("attachedPath", "");
|
entry.attachedPath = tableData.getStringField("attachedPath", "");
|
||||||
|
|
||||||
entries.push_back(entry);
|
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CDMovementAIComponent> CDMovementAIComponentTable::Query(std::function<bool(CDMovementAIComponent)> predicate) {
|
std::vector<CDMovementAIComponent> CDMovementAIComponentTable::Query(std::function<bool(CDMovementAIComponent)> predicate) {
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// Custom Classes
|
// Custom Classes
|
||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
struct CDMovementAIComponent {
|
struct CDMovementAIComponent {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
std::string MovementType;
|
std::string MovementType;
|
||||||
|
@ -20,17 +20,14 @@ void CDObjectSkillsTable::LoadValuesFromDatabase() {
|
|||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ObjectSkills");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ObjectSkills");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDObjectSkills entry;
|
auto &entry = entries.emplace_back();
|
||||||
entry.objectTemplate = tableData.getIntField("objectTemplate", -1);
|
entry.objectTemplate = tableData.getIntField("objectTemplate", -1);
|
||||||
entry.skillID = tableData.getIntField("skillID", -1);
|
entry.skillID = tableData.getIntField("skillID", -1);
|
||||||
entry.castOnType = tableData.getIntField("castOnType", -1);
|
entry.castOnType = tableData.getIntField("castOnType", -1);
|
||||||
entry.AICombatWeight = tableData.getIntField("AICombatWeight", -1);
|
entry.AICombatWeight = tableData.getIntField("AICombatWeight", -1);
|
||||||
|
|
||||||
entries.push_back(entry);
|
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CDObjectSkills> CDObjectSkillsTable::Query(std::function<bool(CDObjectSkills)> predicate) {
|
std::vector<CDObjectSkills> CDObjectSkillsTable::Query(std::function<bool(CDObjectSkills)> predicate) {
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// Custom Classes
|
// Custom Classes
|
||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
struct CDObjectSkills {
|
struct CDObjectSkills {
|
||||||
uint32_t objectTemplate; //!< The LOT of the item
|
uint32_t objectTemplate; //!< The LOT of the item
|
||||||
uint32_t skillID; //!< The Skill ID of the object
|
uint32_t skillID; //!< The Skill ID of the object
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "CDObjectsTable.h"
|
#include "CDObjectsTable.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
CDObjects m_default;
|
CDObjects ObjDefault;
|
||||||
};
|
};
|
||||||
|
|
||||||
void CDObjectsTable::LoadValuesFromDatabase() {
|
void CDObjectsTable::LoadValuesFromDatabase() {
|
||||||
@ -20,8 +20,10 @@ void CDObjectsTable::LoadValuesFromDatabase() {
|
|||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Objects");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Objects");
|
||||||
auto& entries = GetEntriesMutable();
|
auto& entries = GetEntriesMutable();
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDObjects entry;
|
const uint32_t lot = tableData.getIntField("id", 0);
|
||||||
entry.id = tableData.getIntField("id", -1);
|
|
||||||
|
auto& entry = entries[lot];
|
||||||
|
entry.id = lot;
|
||||||
entry.name = tableData.getStringField("name", "");
|
entry.name = tableData.getStringField("name", "");
|
||||||
UNUSED_COLUMN(entry.placeable = tableData.getIntField("placeable", -1);)
|
UNUSED_COLUMN(entry.placeable = tableData.getIntField("placeable", -1);)
|
||||||
entry.type = tableData.getStringField("type", "");
|
entry.type = tableData.getStringField("type", "");
|
||||||
@ -36,35 +38,34 @@ void CDObjectsTable::LoadValuesFromDatabase() {
|
|||||||
UNUSED_COLUMN(entry.gate_version = tableData.getStringField("gate_version", "");)
|
UNUSED_COLUMN(entry.gate_version = tableData.getStringField("gate_version", "");)
|
||||||
UNUSED_COLUMN(entry.HQ_valid = tableData.getIntField("HQ_valid", -1);)
|
UNUSED_COLUMN(entry.HQ_valid = tableData.getIntField("HQ_valid", -1);)
|
||||||
|
|
||||||
entries.insert(std::make_pair(entry.id, entry));
|
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
ObjDefault.id = 0;
|
||||||
|
|
||||||
m_default.id = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const CDObjects& CDObjectsTable::GetByID(uint32_t LOT) {
|
const CDObjects& CDObjectsTable::GetByID(const uint32_t lot) {
|
||||||
auto& entries = GetEntriesMutable();
|
auto& entries = GetEntriesMutable();
|
||||||
const auto& it = entries.find(LOT);
|
const auto& it = entries.find(lot);
|
||||||
if (it != entries.end()) {
|
if (it != entries.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Objects WHERE id = ?;");
|
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Objects WHERE id = ?;");
|
||||||
query.bind(1, static_cast<int32_t>(LOT));
|
query.bind(1, static_cast<int32_t>(lot));
|
||||||
|
|
||||||
auto tableData = query.execQuery();
|
auto tableData = query.execQuery();
|
||||||
if (tableData.eof()) {
|
if (tableData.eof()) {
|
||||||
entries.insert(std::make_pair(LOT, m_default));
|
entries.emplace(lot, ObjDefault);
|
||||||
return m_default;
|
return ObjDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now get the data
|
// Now get the data
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDObjects entry;
|
const uint32_t lot = tableData.getIntField("id", 0);
|
||||||
entry.id = tableData.getIntField("id", -1);
|
|
||||||
|
auto& entry = entries[lot];
|
||||||
|
entry.id = lot;
|
||||||
entry.name = tableData.getStringField("name", "");
|
entry.name = tableData.getStringField("name", "");
|
||||||
UNUSED(entry.placeable = tableData.getIntField("placeable", -1));
|
UNUSED(entry.placeable = tableData.getIntField("placeable", -1));
|
||||||
entry.type = tableData.getStringField("type", "");
|
entry.type = tableData.getStringField("type", "");
|
||||||
@ -79,17 +80,15 @@ const CDObjects& CDObjectsTable::GetByID(uint32_t LOT) {
|
|||||||
UNUSED(entry.gate_version = tableData.getStringField("gate_version", ""));
|
UNUSED(entry.gate_version = tableData.getStringField("gate_version", ""));
|
||||||
UNUSED(entry.HQ_valid = tableData.getIntField("HQ_valid", -1));
|
UNUSED(entry.HQ_valid = tableData.getIntField("HQ_valid", -1));
|
||||||
|
|
||||||
entries.insert(std::make_pair(entry.id, entry));
|
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
|
|
||||||
const auto& it2 = entries.find(LOT);
|
const auto& it2 = entries.find(lot);
|
||||||
if (it2 != entries.end()) {
|
if (it2 != entries.end()) {
|
||||||
return it2->second;
|
return it2->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_default;
|
return ObjDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// Custom Classes
|
// Custom Classes
|
||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
struct CDObjects {
|
struct CDObjects {
|
||||||
uint32_t id; //!< The LOT of the object
|
uint32_t id; //!< The LOT of the object
|
||||||
std::string name; //!< The internal name of the object
|
std::string name; //!< The internal name of the object
|
||||||
@ -24,6 +26,6 @@ class CDObjectsTable : public CDTable<CDObjectsTable, std::map<uint32_t, CDObjec
|
|||||||
public:
|
public:
|
||||||
void LoadValuesFromDatabase();
|
void LoadValuesFromDatabase();
|
||||||
// Gets an entry by ID
|
// Gets an entry by ID
|
||||||
const CDObjects& GetByID(uint32_t LOT);
|
const CDObjects& GetByID(const uint32_t lot);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,12 +19,11 @@ void CDPackageComponentTable::LoadValuesFromDatabase() {
|
|||||||
// Now get the data
|
// Now get the data
|
||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PackageComponent");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PackageComponent");
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDPackageComponent entry;
|
auto& entry = entries.emplace_back();
|
||||||
entry.id = tableData.getIntField("id", -1);
|
entry.id = tableData.getIntField("id", -1);
|
||||||
entry.LootMatrixIndex = tableData.getIntField("LootMatrixIndex", -1);
|
entry.LootMatrixIndex = tableData.getIntField("LootMatrixIndex", -1);
|
||||||
entry.packageType = tableData.getIntField("packageType", -1);
|
entry.packageType = tableData.getIntField("packageType", -1);
|
||||||
|
|
||||||
entries.push_back(entry);
|
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// Custom Classes
|
// Custom Classes
|
||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
struct CDPackageComponent {
|
struct CDPackageComponent {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
uint32_t LootMatrixIndex;
|
uint32_t LootMatrixIndex;
|
||||||
|
@ -4,32 +4,31 @@ void CDPhysicsComponentTable::LoadValuesFromDatabase() {
|
|||||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PhysicsComponent");
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PhysicsComponent");
|
||||||
auto& entries = GetEntriesMutable();
|
auto& entries = GetEntriesMutable();
|
||||||
while (!tableData.eof()) {
|
while (!tableData.eof()) {
|
||||||
CDPhysicsComponent entry;
|
const uint32_t componentID = tableData.getIntField("id", -1);
|
||||||
entry.id = tableData.getIntField("id", -1);
|
|
||||||
|
auto& entry = entries[componentID];
|
||||||
|
entry.id = componentID;
|
||||||
entry.bStatic = tableData.getIntField("static", -1) != 0;
|
entry.bStatic = tableData.getIntField("static", -1) != 0;
|
||||||
entry.physicsAsset = tableData.getStringField("physics_asset", "");
|
entry.physicsAsset = tableData.getStringField("physics_asset", "");
|
||||||
UNUSED(entry->jump = tableData.getIntField("jump", -1) != 0);
|
UNUSED_COLUMN(entry.jump = tableData.getIntField("jump", -1) != 0;)
|
||||||
UNUSED(entry->doublejump = tableData.getIntField("doublejump", -1) != 0);
|
UNUSED_COLUMN(entry.doubleJump = tableData.getIntField("doublejump", -1) != 0;)
|
||||||
entry.speed = tableData.getFloatField("speed", -1);
|
entry.speed = static_cast<float>(tableData.getFloatField("speed", -1));
|
||||||
UNUSED(entry->rotSpeed = tableData.getFloatField("rotSpeed", -1));
|
UNUSED_COLUMN(entry.rotSpeed = tableData.getFloatField("rotSpeed", -1);)
|
||||||
entry.playerHeight = tableData.getFloatField("playerHeight");
|
entry.playerHeight = static_cast<float>(tableData.getFloatField("playerHeight"));
|
||||||
entry.playerRadius = tableData.getFloatField("playerRadius");
|
entry.playerRadius = static_cast<float>(tableData.getFloatField("playerRadius"));
|
||||||
entry.pcShapeType = tableData.getIntField("pcShapeType");
|
entry.pcShapeType = tableData.getIntField("pcShapeType");
|
||||||
entry.collisionGroup = tableData.getIntField("collisionGroup");
|
entry.collisionGroup = tableData.getIntField("collisionGroup");
|
||||||
UNUSED(entry->airSpeed = tableData.getFloatField("airSpeed"));
|
UNUSED_COLUMN(entry.airSpeed = tableData.getFloatField("airSpeed");)
|
||||||
UNUSED(entry->boundaryAsset = tableData.getStringField("boundaryAsset"));
|
UNUSED_COLUMN(entry.boundaryAsset = tableData.getStringField("boundaryAsset");)
|
||||||
UNUSED(entry->jumpAirSpeed = tableData.getFloatField("jumpAirSpeed"));
|
UNUSED_COLUMN(entry.jumpAirSpeed = tableData.getFloatField("jumpAirSpeed");)
|
||||||
UNUSED(entry->friction = tableData.getFloatField("friction"));
|
UNUSED_COLUMN(entry.friction = tableData.getFloatField("friction");)
|
||||||
UNUSED(entry->gravityVolumeAsset = tableData.getStringField("gravityVolumeAsset"));
|
UNUSED_COLUMN(entry.gravityVolumeAsset = tableData.getStringField("gravityVolumeAsset");)
|
||||||
|
|
||||||
entries.insert(std::make_pair(entry.id, entry));
|
|
||||||
tableData.nextRow();
|
tableData.nextRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData.finalize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CDPhysicsComponent* CDPhysicsComponentTable::GetByID(uint32_t componentID) {
|
CDPhysicsComponent* CDPhysicsComponentTable::GetByID(const uint32_t componentID) {
|
||||||
auto& entries = GetEntriesMutable();
|
auto& entries = GetEntriesMutable();
|
||||||
auto itr = entries.find(componentID);
|
auto itr = entries.find(componentID);
|
||||||
return itr != entries.end() ? &itr->second : nullptr;
|
return itr != entries.end() ? &itr->second : nullptr;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "CDTable.h"
|
#include "CDTable.h"
|
||||||
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct CDPhysicsComponent {
|
struct CDPhysicsComponent {
|
||||||
@ -7,7 +8,7 @@ struct CDPhysicsComponent {
|
|||||||
bool bStatic;
|
bool bStatic;
|
||||||
std::string physicsAsset;
|
std::string physicsAsset;
|
||||||
UNUSED(bool jump);
|
UNUSED(bool jump);
|
||||||
UNUSED(bool doublejump);
|
UNUSED(bool doubleJump);
|
||||||
float speed;
|
float speed;
|
||||||
UNUSED(float rotSpeed);
|
UNUSED(float rotSpeed);
|
||||||
float playerHeight;
|
float playerHeight;
|
||||||
@ -26,5 +27,5 @@ public:
|
|||||||
void LoadValuesFromDatabase();
|
void LoadValuesFromDatabase();
|
||||||
|
|
||||||
static const std::string GetTableName() { return "PhysicsComponent"; };
|
static const std::string GetTableName() { return "PhysicsComponent"; };
|
||||||
CDPhysicsComponent* GetByID(uint32_t componentID);
|
CDPhysicsComponent* GetByID(const uint32_t componentID);
|
||||||
};
|
};
|
||||||
|
132
dGame/Entity.cpp
132
dGame/Entity.cpp
@ -146,17 +146,15 @@ Entity::~Entity() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity* zoneControl = Game::entityManager->GetZoneControlEntity();
|
auto* zoneControl = Game::entityManager->GetZoneControlEntity();
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
|
if (zoneControl) {
|
||||||
script->OnPlayerExit(zoneControl, this);
|
zoneControl->GetScript()->OnPlayerExit(zoneControl, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
|
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
|
||||||
for (Entity* scriptEntity : scriptedActs) {
|
for (Entity* scriptEntity : scriptedActs) {
|
||||||
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
|
scriptEntity->GetScript()->OnPlayerExit(scriptEntity, this);
|
||||||
script->OnPlayerExit(scriptEntity, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -762,9 +760,7 @@ void Entity::Initialize() {
|
|||||||
|
|
||||||
// Hacky way to trigger these when the object has had a chance to get constructed
|
// Hacky way to trigger these when the object has had a chance to get constructed
|
||||||
AddCallbackTimer(0, [this]() {
|
AddCallbackTimer(0, [this]() {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
this->GetScript()->OnStartup(this);
|
||||||
script->OnStartup(this);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!m_Character && Game::entityManager->GetGhostingEnabled()) {
|
if (!m_Character && Game::entityManager->GetGhostingEnabled()) {
|
||||||
@ -839,15 +835,6 @@ bool Entity::HasComponent(const eReplicaComponentType componentId) const {
|
|||||||
return m_Components.find(componentId) != m_Components.end();
|
return m_Components.find(componentId) != m_Components.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ScriptComponent*> Entity::GetScriptComponents() {
|
|
||||||
std::vector<ScriptComponent*> comps;
|
|
||||||
|
|
||||||
auto* scriptComponent = GetComponent<ScriptComponent>();
|
|
||||||
if (scriptComponent) comps.push_back(scriptComponent);
|
|
||||||
|
|
||||||
return comps;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Entity::Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName) {
|
void Entity::Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName) {
|
||||||
if (notificationName == "HitOrHealResult" || notificationName == "Hit") {
|
if (notificationName == "HitOrHealResult" || notificationName == "Hit") {
|
||||||
auto* destroyableComponent = GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = GetComponent<DestroyableComponent>();
|
||||||
@ -1276,9 +1263,7 @@ void Entity::Update(const float deltaTime) {
|
|||||||
// Remove the timer from the list of timers first so that scripts and events can remove timers without causing iterator invalidation
|
// Remove the timer from the list of timers first so that scripts and events can remove timers without causing iterator invalidation
|
||||||
auto timerName = timer.GetName();
|
auto timerName = timer.GetName();
|
||||||
m_Timers.erase(m_Timers.begin() + timerPosition);
|
m_Timers.erase(m_Timers.begin() + timerPosition);
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnTimerDone(this, timerName);
|
||||||
script->OnTimerDone(this, timerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
TriggerEvent(eTriggerEventType::TIMER_DONE, this);
|
TriggerEvent(eTriggerEventType::TIMER_DONE, this);
|
||||||
} else {
|
} else {
|
||||||
@ -1324,9 +1309,7 @@ void Entity::Update(const float deltaTime) {
|
|||||||
Wake();
|
Wake();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnUpdate(this);
|
||||||
script->OnUpdate(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& pair : m_Components) {
|
for (const auto& pair : m_Components) {
|
||||||
if (pair.second == nullptr) continue;
|
if (pair.second == nullptr) continue;
|
||||||
@ -1343,9 +1326,7 @@ void Entity::OnCollisionProximity(LWOOBJID otherEntity, const std::string& proxN
|
|||||||
Entity* other = Game::entityManager->GetEntity(otherEntity);
|
Entity* other = Game::entityManager->GetEntity(otherEntity);
|
||||||
if (!other) return;
|
if (!other) return;
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnProximityUpdate(this, other, proxName, status);
|
||||||
script->OnProximityUpdate(this, other, proxName, status);
|
|
||||||
}
|
|
||||||
|
|
||||||
RocketLaunchpadControlComponent* rocketComp = GetComponent<RocketLaunchpadControlComponent>();
|
RocketLaunchpadControlComponent* rocketComp = GetComponent<RocketLaunchpadControlComponent>();
|
||||||
if (!rocketComp) return;
|
if (!rocketComp) return;
|
||||||
@ -1357,9 +1338,7 @@ void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) {
|
|||||||
auto* other = Game::entityManager->GetEntity(otherEntity);
|
auto* other = Game::entityManager->GetEntity(otherEntity);
|
||||||
if (!other) return;
|
if (!other) return;
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnCollisionPhantom(this, other);
|
||||||
script->OnCollisionPhantom(this, other);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& callback : m_PhantomCollisionCallbacks) {
|
for (const auto& callback : m_PhantomCollisionCallbacks) {
|
||||||
callback(other);
|
callback(other);
|
||||||
@ -1398,9 +1377,7 @@ void Entity::OnCollisionLeavePhantom(const LWOOBJID otherEntity) {
|
|||||||
auto* other = Game::entityManager->GetEntity(otherEntity);
|
auto* other = Game::entityManager->GetEntity(otherEntity);
|
||||||
if (!other) return;
|
if (!other) return;
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnOffCollisionPhantom(this, other);
|
||||||
script->OnOffCollisionPhantom(this, other);
|
|
||||||
}
|
|
||||||
|
|
||||||
TriggerEvent(eTriggerEventType::EXIT, other);
|
TriggerEvent(eTriggerEventType::EXIT, other);
|
||||||
|
|
||||||
@ -1417,46 +1394,32 @@ void Entity::OnCollisionLeavePhantom(const LWOOBJID otherEntity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnFireEventServerSide(Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {
|
void Entity::OnFireEventServerSide(Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnFireEventServerSide(this, sender, args, param1, param2, param3);
|
||||||
script->OnFireEventServerSide(this, sender, args, param1, param2, param3);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnActivityStateChangeRequest(LWOOBJID senderID, int32_t value1, int32_t value2, const std::u16string& stringValue) {
|
void Entity::OnActivityStateChangeRequest(LWOOBJID senderID, int32_t value1, int32_t value2, const std::u16string& stringValue) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnActivityStateChangeRequest(this, senderID, value1, value2, stringValue);
|
||||||
script->OnActivityStateChangeRequest(this, senderID, value1, value2, stringValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnCinematicUpdate(Entity* self, Entity* sender, eCinematicEvent event, const std::u16string& pathName,
|
void Entity::OnCinematicUpdate(Entity* self, Entity* sender, eCinematicEvent event, const std::u16string& pathName,
|
||||||
float_t pathTime, float_t totalTime, int32_t waypoint) {
|
float_t pathTime, float_t totalTime, int32_t waypoint) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnCinematicUpdate(self, sender, event, pathName, pathTime, totalTime, waypoint);
|
||||||
script->OnCinematicUpdate(self, sender, event, pathName, pathTime, totalTime, waypoint);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::NotifyObject(Entity* sender, const std::string& name, int32_t param1, int32_t param2) {
|
void Entity::NotifyObject(Entity* sender, const std::string& name, int32_t param1, int32_t param2) {
|
||||||
GameMessages::SendNotifyObject(GetObjectID(), sender->GetObjectID(), GeneralUtils::ASCIIToUTF16(name), UNASSIGNED_SYSTEM_ADDRESS);
|
GameMessages::SendNotifyObject(GetObjectID(), sender->GetObjectID(), GeneralUtils::ASCIIToUTF16(name), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnNotifyObject(this, sender, name, param1, param2);
|
||||||
script->OnNotifyObject(this, sender, name, param1, param2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnEmoteReceived(const int32_t emote, Entity* target) {
|
void Entity::OnEmoteReceived(const int32_t emote, Entity* target) {
|
||||||
for (auto* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnEmoteReceived(this, emote, target);
|
||||||
script->OnEmoteReceived(this, emote, target);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnUse(Entity* originator) {
|
void Entity::OnUse(Entity* originator) {
|
||||||
TriggerEvent(eTriggerEventType::INTERACT, originator);
|
TriggerEvent(eTriggerEventType::INTERACT, originator);
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnUse(this, originator);
|
||||||
script->OnUse(this, originator);
|
|
||||||
}
|
|
||||||
|
|
||||||
// component base class when
|
|
||||||
|
|
||||||
for (const auto& pair : m_Components) {
|
for (const auto& pair : m_Components) {
|
||||||
if (pair.second == nullptr) continue;
|
if (pair.second == nullptr) continue;
|
||||||
@ -1466,82 +1429,63 @@ void Entity::OnUse(Entity* originator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnHitOrHealResult(Entity* attacker, int32_t damage) {
|
void Entity::OnHitOrHealResult(Entity* attacker, int32_t damage) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnHitOrHealResult(this, attacker, damage);
|
||||||
script->OnHitOrHealResult(this, attacker, damage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnHit(Entity* attacker) {
|
void Entity::OnHit(Entity* attacker) {
|
||||||
TriggerEvent(eTriggerEventType::HIT, attacker);
|
TriggerEvent(eTriggerEventType::HIT, attacker);
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnHit(this, attacker);
|
||||||
script->OnHit(this, attacker);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnZonePropertyEditBegin() {
|
void Entity::OnZonePropertyEditBegin() {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnZonePropertyEditBegin(this);
|
||||||
script->OnZonePropertyEditBegin(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnZonePropertyEditEnd() {
|
void Entity::OnZonePropertyEditEnd() {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnZonePropertyEditEnd(this);
|
||||||
script->OnZonePropertyEditEnd(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnZonePropertyModelEquipped() {
|
void Entity::OnZonePropertyModelEquipped() {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnZonePropertyModelEquipped(this);
|
||||||
script->OnZonePropertyModelEquipped(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnZonePropertyModelPlaced(Entity* player) {
|
void Entity::OnZonePropertyModelPlaced(Entity* player) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnZonePropertyModelPlaced(this, player);
|
||||||
script->OnZonePropertyModelPlaced(this, player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnZonePropertyModelPickedUp(Entity* player) {
|
void Entity::OnZonePropertyModelPickedUp(Entity* player) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnZonePropertyModelPickedUp(this, player);
|
||||||
script->OnZonePropertyModelPickedUp(this, player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnZonePropertyModelRemoved(Entity* player) {
|
void Entity::OnZonePropertyModelRemoved(Entity* player) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnZonePropertyModelRemoved(this, player);
|
||||||
script->OnZonePropertyModelRemoved(this, player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnZonePropertyModelRemovedWhileEquipped(Entity* player) {
|
void Entity::OnZonePropertyModelRemovedWhileEquipped(Entity* player) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnZonePropertyModelRemovedWhileEquipped(this, player);
|
||||||
script->OnZonePropertyModelRemovedWhileEquipped(this, player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnZonePropertyModelRotated(Entity* player) {
|
void Entity::OnZonePropertyModelRotated(Entity* player) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnZonePropertyModelRotated(this, player);
|
||||||
script->OnZonePropertyModelRotated(this, player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnMessageBoxResponse(Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) {
|
void Entity::OnMessageBoxResponse(Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnMessageBoxResponse(this, sender, button, identifier, userData);
|
||||||
script->OnMessageBoxResponse(this, sender, button, identifier, userData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::OnChoiceBoxResponse(Entity* sender, int32_t button, const std::u16string& buttonIdentifier, const std::u16string& identifier) {
|
void Entity::OnChoiceBoxResponse(Entity* sender, int32_t button, const std::u16string& buttonIdentifier, const std::u16string& identifier) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnChoiceBoxResponse(this, sender, button, buttonIdentifier, identifier);
|
||||||
script->OnChoiceBoxResponse(this, sender, button, buttonIdentifier, identifier);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::RequestActivityExit(Entity* sender, LWOOBJID player, bool canceled) {
|
void Entity::RequestActivityExit(Entity* sender, LWOOBJID player, bool canceled) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnRequestActivityExit(sender, player, canceled);
|
||||||
script->OnRequestActivityExit(sender, player, canceled);
|
}
|
||||||
}
|
|
||||||
|
CppScripts::Script* const Entity::GetScript() {
|
||||||
|
auto* scriptComponent = GetComponent<ScriptComponent>();
|
||||||
|
auto* script = scriptComponent ? scriptComponent->GetScript() : CppScripts::GetInvalidScript();
|
||||||
|
DluAssert(script != nullptr);
|
||||||
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::Smash(const LWOOBJID source, const eKillType killType, const std::u16string& deathType) {
|
void Entity::Smash(const LWOOBJID source, const eKillType killType, const std::u16string& deathType) {
|
||||||
@ -1574,9 +1518,7 @@ void Entity::Kill(Entity* murderer, const eKillType killType) {
|
|||||||
|
|
||||||
//OMAI WA MOU, SHINDERIU
|
//OMAI WA MOU, SHINDERIU
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
GetScript()->OnDie(this, murderer);
|
||||||
script->OnDie(this, murderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_Spawner != nullptr) {
|
if (m_Spawner != nullptr) {
|
||||||
m_Spawner->NotifyOfEntityDeath(m_ObjectID);
|
m_Spawner->NotifyOfEntityDeath(m_ObjectID);
|
||||||
|
@ -146,7 +146,8 @@ public:
|
|||||||
|
|
||||||
void AddComponent(eReplicaComponentType componentId, Component* component);
|
void AddComponent(eReplicaComponentType componentId, Component* component);
|
||||||
|
|
||||||
std::vector<ScriptComponent*> GetScriptComponents();
|
// This is expceted to never return nullptr, an assert checks this.
|
||||||
|
CppScripts::Script* const GetScript();
|
||||||
|
|
||||||
void Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName);
|
void Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName);
|
||||||
void Unsubscribe(LWOOBJID scriptObjId, const std::string& notificationName);
|
void Unsubscribe(LWOOBJID scriptObjId, const std::string& notificationName);
|
||||||
|
@ -418,10 +418,16 @@ void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::SerializeEntity(Entity* entity) {
|
void EntityManager::SerializeEntity(Entity* entity) {
|
||||||
if (!entity || entity->GetNetworkId() == 0) return;
|
if (!entity) return;
|
||||||
|
|
||||||
if (std::find(m_EntitiesToSerialize.begin(), m_EntitiesToSerialize.end(), entity->GetObjectID()) == m_EntitiesToSerialize.end()) {
|
EntityManager::SerializeEntity(*entity);
|
||||||
m_EntitiesToSerialize.push_back(entity->GetObjectID());
|
}
|
||||||
|
|
||||||
|
void EntityManager::SerializeEntity(const Entity& entity) {
|
||||||
|
if (entity.GetNetworkId() == 0) return;
|
||||||
|
|
||||||
|
if (std::find(m_EntitiesToSerialize.cbegin(), m_EntitiesToSerialize.cend(), entity.GetObjectID()) == m_EntitiesToSerialize.cend()) {
|
||||||
|
m_EntitiesToSerialize.push_back(entity.GetObjectID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ public:
|
|||||||
void ConstructEntity(Entity* entity, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS, bool skipChecks = false);
|
void ConstructEntity(Entity* entity, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS, bool skipChecks = false);
|
||||||
void DestructEntity(Entity* entity, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
void DestructEntity(Entity* entity, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
void SerializeEntity(Entity* entity);
|
void SerializeEntity(Entity* entity);
|
||||||
|
void SerializeEntity(const Entity& entity);
|
||||||
|
|
||||||
void ConstructAllEntities(const SystemAddress& sysAddr);
|
void ConstructAllEntities(const SystemAddress& sysAddr);
|
||||||
void DestructAllEntities(const SystemAddress& sysAddr);
|
void DestructAllEntities(const SystemAddress& sysAddr);
|
||||||
|
@ -3,15 +3,14 @@
|
|||||||
#include "BehaviorContext.h"
|
#include "BehaviorContext.h"
|
||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
#include "CppScripts.h"
|
#include "CppScripts.h"
|
||||||
|
#include "Entity.h"
|
||||||
|
|
||||||
void SkillEventBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
void SkillEventBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
||||||
auto* target = Game::entityManager->GetEntity(branch.target);
|
auto* target = Game::entityManager->GetEntity(branch.target);
|
||||||
auto* caster = Game::entityManager->GetEntity(context->originator);
|
auto* caster = Game::entityManager->GetEntity(context->originator);
|
||||||
|
|
||||||
if (caster != nullptr && target != nullptr && this->m_effectHandle != nullptr && !this->m_effectHandle->empty()) {
|
if (caster != nullptr && target != nullptr && this->m_effectHandle != nullptr && !this->m_effectHandle->empty()) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(target)) {
|
target->GetScript()->OnSkillEventFired(target, caster, *this->m_effectHandle);
|
||||||
script->OnSkillEventFired(target, caster, *this->m_effectHandle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,8 +20,6 @@ SkillEventBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitSt
|
|||||||
auto* caster = Game::entityManager->GetEntity(context->originator);
|
auto* caster = Game::entityManager->GetEntity(context->originator);
|
||||||
|
|
||||||
if (caster != nullptr && target != nullptr && this->m_effectHandle != nullptr && !this->m_effectHandle->empty()) {
|
if (caster != nullptr && target != nullptr && this->m_effectHandle != nullptr && !this->m_effectHandle->empty()) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(target)) {
|
target->GetScript()->OnSkillEventFired(target, caster, *this->m_effectHandle);
|
||||||
script->OnSkillEventFired(target, caster, *this->m_effectHandle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,15 @@
|
|||||||
#include "UserManager.h"
|
#include "UserManager.h"
|
||||||
#include "CDMissionsTable.h"
|
#include "CDMissionsTable.h"
|
||||||
|
|
||||||
|
AchievementVendorComponent::AchievementVendorComponent(Entity* parent) : VendorComponent(parent) {
|
||||||
|
RefreshInventory(true);
|
||||||
|
};
|
||||||
|
|
||||||
bool AchievementVendorComponent::SellsItem(Entity* buyer, const LOT lot) {
|
bool AchievementVendorComponent::SellsItem(Entity* buyer, const LOT lot) {
|
||||||
auto* missionComponent = buyer->GetComponent<MissionComponent>();
|
auto* missionComponent = buyer->GetComponent<MissionComponent>();
|
||||||
if (!missionComponent) return false;
|
if (!missionComponent) return false;
|
||||||
|
|
||||||
if (m_PlayerPurchasableItems[buyer->GetObjectID()].contains(lot)){
|
if (m_PlayerPurchasableItems[buyer->GetObjectID()].contains(lot)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,3 +74,8 @@ void AchievementVendorComponent::Buy(Entity* buyer, LOT lot, uint32_t count) {
|
|||||||
GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_SUCCESS);
|
GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_SUCCESS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AchievementVendorComponent::RefreshInventory(bool isCreation) {
|
||||||
|
SetHasStandardCostItems(true);
|
||||||
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
|
}
|
||||||
|
@ -11,7 +11,9 @@ class Entity;
|
|||||||
class AchievementVendorComponent final : public VendorComponent {
|
class AchievementVendorComponent final : public VendorComponent {
|
||||||
public:
|
public:
|
||||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::ACHIEVEMENT_VENDOR;
|
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::ACHIEVEMENT_VENDOR;
|
||||||
AchievementVendorComponent(Entity* parent) : VendorComponent(parent) {};
|
AchievementVendorComponent(Entity* parent);
|
||||||
|
|
||||||
|
void RefreshInventory(bool isCreation = false) override;
|
||||||
bool SellsItem(Entity* buyer, const LOT lot);
|
bool SellsItem(Entity* buyer, const LOT lot);
|
||||||
void Buy(Entity* buyer, LOT lot, uint32_t count);
|
void Buy(Entity* buyer, LOT lot, uint32_t count);
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ set(DGAME_DCOMPONENTS_SOURCES
|
|||||||
"HavokVehiclePhysicsComponent.cpp"
|
"HavokVehiclePhysicsComponent.cpp"
|
||||||
"VendorComponent.cpp"
|
"VendorComponent.cpp"
|
||||||
"MiniGameControlComponent.cpp"
|
"MiniGameControlComponent.cpp"
|
||||||
|
"ScriptComponent.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(dComponents OBJECT ${DGAME_DCOMPONENTS_SOURCES})
|
add_library(dComponents OBJECT ${DGAME_DCOMPONENTS_SOURCES})
|
||||||
|
@ -785,16 +785,12 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entity* zoneControl = Game::entityManager->GetZoneControlEntity();
|
Entity* zoneControl = Game::entityManager->GetZoneControlEntity();
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
|
if (zoneControl) zoneControl->GetScript()->OnPlayerDied(zoneControl, m_Parent);
|
||||||
script->OnPlayerDied(zoneControl, m_Parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
|
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
|
||||||
for (Entity* scriptEntity : scriptedActs) {
|
for (Entity* scriptEntity : scriptedActs) {
|
||||||
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
|
scriptEntity->GetScript()->OnPlayerDied(scriptEntity, m_Parent);
|
||||||
script->OnPlayerDied(scriptEntity, m_Parent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,9 +183,7 @@ void MovingPlatformComponent::StartPathing() {
|
|||||||
const auto travelNext = subComponent->mWaitTime + travelTime;
|
const auto travelNext = subComponent->mWaitTime + travelTime;
|
||||||
|
|
||||||
m_Parent->AddCallbackTimer(travelTime, [subComponent, this] {
|
m_Parent->AddCallbackTimer(travelTime, [subComponent, this] {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) {
|
this->m_Parent->GetScript()->OnWaypointReached(m_Parent, subComponent->mNextWaypointIndex);
|
||||||
script->OnWaypointReached(m_Parent, subComponent->mNextWaypointIndex);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
m_Parent->AddCallbackTimer(travelNext, [this] {
|
m_Parent->AddCallbackTimer(travelNext, [this] {
|
||||||
@ -295,9 +293,7 @@ void MovingPlatformComponent::ContinuePathing() {
|
|||||||
const auto travelNext = subComponent->mWaitTime + travelTime;
|
const auto travelNext = subComponent->mWaitTime + travelTime;
|
||||||
|
|
||||||
m_Parent->AddCallbackTimer(travelTime, [subComponent, this] {
|
m_Parent->AddCallbackTimer(travelTime, [subComponent, this] {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) {
|
this->m_Parent->GetScript()->OnWaypointReached(m_Parent, subComponent->mNextWaypointIndex);
|
||||||
script->OnWaypointReached(m_Parent, subComponent->mNextWaypointIndex);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
m_Parent->AddCallbackTimer(travelNext, [this] {
|
m_Parent->AddCallbackTimer(travelNext, [this] {
|
||||||
|
@ -329,9 +329,7 @@ void PetComponent::OnUse(Entity* originator) {
|
|||||||
currentActivities.insert_or_assign(m_Tamer, m_Parent->GetObjectID());
|
currentActivities.insert_or_assign(m_Tamer, m_Parent->GetObjectID());
|
||||||
|
|
||||||
// Notify the start of a pet taming minigame
|
// Notify the start of a pet taming minigame
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) {
|
m_Parent->GetScript()->OnNotifyPetTamingMinigame(m_Parent, originator, ePetTamingNotifyType::BEGIN);
|
||||||
script->OnNotifyPetTamingMinigame(m_Parent, originator, ePetTamingNotifyType::BEGIN);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PetComponent::Update(float deltaTime) {
|
void PetComponent::Update(float deltaTime) {
|
||||||
@ -600,9 +598,7 @@ void PetComponent::RequestSetPetName(std::u16string name) {
|
|||||||
m_Tamer = LWOOBJID_EMPTY;
|
m_Tamer = LWOOBJID_EMPTY;
|
||||||
|
|
||||||
// Notify the end of a pet taming minigame
|
// Notify the end of a pet taming minigame
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) {
|
m_Parent->GetScript()->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::SUCCESS);
|
||||||
script->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::SUCCESS);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
||||||
@ -641,9 +637,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
|||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
|
|
||||||
// Notify the end of a pet taming minigame
|
// Notify the end of a pet taming minigame
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) {
|
m_Parent->GetScript()->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::QUIT);
|
||||||
script->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::QUIT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PetComponent::StartTimer() {
|
void PetComponent::StartTimer() {
|
||||||
@ -692,9 +686,7 @@ void PetComponent::ClientFailTamingMinigame() {
|
|||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
|
|
||||||
// Notify the end of a pet taming minigame
|
// Notify the end of a pet taming minigame
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) {
|
m_Parent->GetScript()->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::FAILED);
|
||||||
script->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::FAILED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PetComponent::Wander() {
|
void PetComponent::Wander() {
|
||||||
|
@ -214,9 +214,7 @@ bool PropertyManagementComponent::Claim(const LWOOBJID playerId) {
|
|||||||
Database::Get()->InsertNewProperty(info, templateId, worldId);
|
Database::Get()->InsertNewProperty(info, templateId, worldId);
|
||||||
|
|
||||||
auto* zoneControlObject = Game::zoneManager->GetZoneControlObject();
|
auto* zoneControlObject = Game::zoneManager->GetZoneControlObject();
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControlObject)) {
|
if (zoneControlObject) zoneControlObject->GetScript()->OnZonePropertyRented(zoneControlObject, entity);
|
||||||
script->OnZonePropertyRented(zoneControlObject, entity);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,12 +414,10 @@ void QuickBuildComponent::StartQuickBuild(Entity* const user) {
|
|||||||
movingPlatform->OnQuickBuildInitilized();
|
movingPlatform->OnQuickBuildInitilized();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto* script : CppScripts::GetEntityScripts(m_Parent)) {
|
auto* script = m_Parent->GetScript();
|
||||||
script->OnQuickBuildStart(m_Parent, user);
|
script->OnQuickBuildStart(m_Parent, user);
|
||||||
}
|
|
||||||
|
|
||||||
// Notify scripts and possible subscribers
|
// Notify scripts and possible subscribers
|
||||||
for (auto* script : CppScripts::GetEntityScripts(m_Parent))
|
|
||||||
script->OnQuickBuildNotifyState(m_Parent, m_State);
|
script->OnQuickBuildNotifyState(m_Parent, m_State);
|
||||||
for (const auto& cb : m_QuickBuildStateCallbacks)
|
for (const auto& cb : m_QuickBuildStateCallbacks)
|
||||||
cb(m_State);
|
cb(m_State);
|
||||||
@ -485,10 +483,9 @@ void QuickBuildComponent::CompleteQuickBuild(Entity* const user) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Notify scripts
|
// Notify scripts
|
||||||
for (auto* script : CppScripts::GetEntityScripts(m_Parent)) {
|
auto* script = m_Parent->GetScript();
|
||||||
script->OnQuickBuildComplete(m_Parent, user);
|
script->OnQuickBuildComplete(m_Parent, user);
|
||||||
script->OnQuickBuildNotifyState(m_Parent, m_State);
|
script->OnQuickBuildNotifyState(m_Parent, m_State);
|
||||||
}
|
|
||||||
|
|
||||||
// Notify subscribers
|
// Notify subscribers
|
||||||
for (const auto& callback : m_QuickBuildStateCallbacks)
|
for (const auto& callback : m_QuickBuildStateCallbacks)
|
||||||
@ -539,8 +536,7 @@ void QuickBuildComponent::ResetQuickBuild(const bool failed) {
|
|||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
|
|
||||||
// Notify scripts and possible subscribers
|
// Notify scripts and possible subscribers
|
||||||
for (auto* script : CppScripts::GetEntityScripts(m_Parent))
|
m_Parent->GetScript()->OnQuickBuildNotifyState(m_Parent, m_State);
|
||||||
script->OnQuickBuildNotifyState(m_Parent, m_State);
|
|
||||||
for (const auto& cb : m_QuickBuildStateCallbacks)
|
for (const auto& cb : m_QuickBuildStateCallbacks)
|
||||||
cb(m_State);
|
cb(m_State);
|
||||||
|
|
||||||
@ -571,8 +567,7 @@ void QuickBuildComponent::CancelQuickBuild(Entity* const entity, const eQuickBui
|
|||||||
m_StateDirty = true;
|
m_StateDirty = true;
|
||||||
|
|
||||||
// Notify scripts and possible subscribers
|
// Notify scripts and possible subscribers
|
||||||
for (auto* script : CppScripts::GetEntityScripts(m_Parent))
|
m_Parent->GetScript()->OnQuickBuildNotifyState(m_Parent, m_State);
|
||||||
script->OnQuickBuildNotifyState(m_Parent, m_State);
|
|
||||||
for (const auto& cb : m_QuickBuildStateCallbacks)
|
for (const auto& cb : m_QuickBuildStateCallbacks)
|
||||||
cb(m_State);
|
cb(m_State);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ void ScriptComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitial
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CppScripts::Script* ScriptComponent::GetScript() {
|
CppScripts::Script* const ScriptComponent::GetScript() {
|
||||||
return m_Script;
|
return m_Script;
|
||||||
}
|
}
|
||||||
|
|
@ -30,7 +30,7 @@ public:
|
|||||||
* Returns the script that's attached to this entity
|
* Returns the script that's attached to this entity
|
||||||
* @return the script that's attached to this entity
|
* @return the script that's attached to this entity
|
||||||
*/
|
*/
|
||||||
CppScripts::Script* GetScript();
|
CppScripts::Script* const GetScript();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether the entity should be serialized, unused
|
* Sets whether the entity should be serialized, unused
|
@ -268,9 +268,7 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c
|
|||||||
|
|
||||||
behavior->Calculate(context, bitStream, { target, 0 });
|
behavior->Calculate(context, bitStream, { target, 0 });
|
||||||
|
|
||||||
for (auto* script : CppScripts::GetEntityScripts(m_Parent)) {
|
m_Parent->GetScript()->OnSkillCast(m_Parent, skillId);
|
||||||
script->OnSkillCast(m_Parent, skillId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!context->foundTarget) {
|
if (!context->foundTarget) {
|
||||||
delete context;
|
delete context;
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
#include "SkillComponent.h"
|
#include "SkillComponent.h"
|
||||||
#include "eEndBehavior.h"
|
#include "eEndBehavior.h"
|
||||||
#include "PlayerManager.h"
|
#include "PlayerManager.h"
|
||||||
|
#include "Game.h"
|
||||||
|
#include "EntityManager.h"
|
||||||
|
|
||||||
TriggerComponent::TriggerComponent(Entity* parent, const std::string triggerInfo): Component(parent) {
|
TriggerComponent::TriggerComponent(Entity* parent, const std::string triggerInfo): Component(parent) {
|
||||||
m_Parent = parent;
|
m_Parent = parent;
|
||||||
@ -182,9 +183,7 @@ std::vector<Entity*> TriggerComponent::GatherTargets(LUTriggers::Command* comman
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleFireEvent(Entity* targetEntity, std::string args) {
|
void TriggerComponent::HandleFireEvent(Entity* targetEntity, std::string args) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(targetEntity)) {
|
targetEntity->GetScript()->OnFireEventServerSide(targetEntity, m_Parent, args, 0, 0, 0);
|
||||||
script->OnFireEventServerSide(targetEntity, m_Parent, args, 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string args){
|
void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string args){
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||||
|
|
||||||
void OnUse(Entity* originator) override;
|
void OnUse(Entity* originator) override;
|
||||||
void RefreshInventory(bool isCreation = false);
|
virtual void RefreshInventory(bool isCreation = false);
|
||||||
void SetupConstants();
|
void SetupConstants();
|
||||||
bool SellsItem(const LOT item) const;
|
bool SellsItem(const LOT item) const;
|
||||||
float GetBuyScalar() const { return m_BuyScalar; }
|
float GetBuyScalar() const { return m_BuyScalar; }
|
||||||
|
@ -136,16 +136,14 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream& inStream, const System
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entity* zoneControl = Game::entityManager->GetZoneControlEntity();
|
Entity* zoneControl = Game::entityManager->GetZoneControlEntity();
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
|
if (zoneControl) {
|
||||||
script->OnPlayerLoaded(zoneControl, entity);
|
zoneControl->GetScript()->OnPlayerLoaded(zoneControl, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPT);
|
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPT);
|
||||||
for (Entity* scriptEntity : scriptedActs) {
|
for (Entity* scriptEntity : scriptedActs) {
|
||||||
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
|
scriptEntity->GetScript()->OnPlayerLoaded(scriptEntity, entity);
|
||||||
script->OnPlayerLoaded(scriptEntity, entity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5123,9 +5123,7 @@ void GameMessages::HandleRespondToMission(RakNet::BitStream& inStream, Entity* e
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(offerer)) {
|
offerer->GetScript()->OnRespondToMission(offerer, missionID, Game::entityManager->GetEntity(playerID), reward);
|
||||||
script->OnRespondToMission(offerer, missionID, Game::entityManager->GetEntity(playerID), reward);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMessages::HandleMissionDialogOK(RakNet::BitStream& inStream, Entity* entity) {
|
void GameMessages::HandleMissionDialogOK(RakNet::BitStream& inStream, Entity* entity) {
|
||||||
@ -5141,9 +5139,7 @@ void GameMessages::HandleMissionDialogOK(RakNet::BitStream& inStream, Entity* en
|
|||||||
inStream.Read(responder);
|
inStream.Read(responder);
|
||||||
player = Game::entityManager->GetEntity(responder);
|
player = Game::entityManager->GetEntity(responder);
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(entity)) {
|
if (entity) entity->GetScript()->OnMissionDialogueOK(entity, player, missionID, iMissionState);
|
||||||
script->OnMissionDialogueOK(entity, player, missionID, iMissionState);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the player's mission component
|
// Get the player's mission component
|
||||||
MissionComponent* missionComponent = static_cast<MissionComponent*>(player->GetComponent(eReplicaComponentType::MISSION));
|
MissionComponent* missionComponent = static_cast<MissionComponent*>(player->GetComponent(eReplicaComponentType::MISSION));
|
||||||
@ -5596,9 +5592,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream& inStream, Entity*
|
|||||||
|
|
||||||
ScriptComponent* script = static_cast<ScriptComponent*>(entity->GetComponent(eReplicaComponentType::SCRIPT));
|
ScriptComponent* script = static_cast<ScriptComponent*>(entity->GetComponent(eReplicaComponentType::SCRIPT));
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(entity)) {
|
entity->GetScript()->OnModularBuildExit(entity, character, count >= 3, modList);
|
||||||
script->OnModularBuildExit(entity, character, count >= 3, modList);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move remaining temp models back to models
|
// Move remaining temp models back to models
|
||||||
std::vector<Item*> items;
|
std::vector<Item*> items;
|
||||||
@ -5774,16 +5768,14 @@ void GameMessages::HandleResurrect(RakNet::BitStream& inStream, Entity* entity)
|
|||||||
bool immediate = inStream.ReadBit();
|
bool immediate = inStream.ReadBit();
|
||||||
|
|
||||||
Entity* zoneControl = Game::entityManager->GetZoneControlEntity();
|
Entity* zoneControl = Game::entityManager->GetZoneControlEntity();
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
|
if (zoneControl) {
|
||||||
script->OnPlayerResurrected(zoneControl, entity);
|
zoneControl->GetScript()->OnPlayerResurrected(zoneControl, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
|
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
|
||||||
for (Entity* scriptEntity : scriptedActs) {
|
for (Entity* scriptEntity : scriptedActs) {
|
||||||
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
|
scriptEntity->GetScript()->OnPlayerResurrected(scriptEntity, entity);
|
||||||
script->OnPlayerResurrected(scriptEntity, entity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6017,9 +6009,7 @@ void GameMessages::HandlePlayerRailArrivedNotification(RakNet::BitStream& inStre
|
|||||||
|
|
||||||
const auto possibleRails = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR);
|
const auto possibleRails = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR);
|
||||||
for (auto* possibleRail : possibleRails) {
|
for (auto* possibleRail : possibleRails) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(possibleRail)) {
|
if (possibleRail) possibleRail->GetScript()->OnPlayerRailArrived(possibleRail, entity, pathName, waypointNumber);
|
||||||
script->OnPlayerRailArrived(possibleRail, entity, pathName, waypointNumber);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ void ParseXml(const std::string& file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (zoneID.value() != currentZoneID) {
|
if (zoneID.value() != currentZoneID) {
|
||||||
LOG_DEBUG("Skipping location because it is in %i and not the current zone (%i)", zoneID.value(), currentZoneID);
|
LOG_DEBUG("Skipping (%s) %i location because it is in %i and not the current zone (%i)", name, lot, zoneID.value(), currentZoneID);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
|
|||||||
RakNet::BitStream loginResponse;
|
RakNet::BitStream loginResponse;
|
||||||
BitStreamUtils::WriteHeader(loginResponse, eConnectionType::CLIENT, eClientMessageType::LOGIN_RESPONSE);
|
BitStreamUtils::WriteHeader(loginResponse, eConnectionType::CLIENT, eClientMessageType::LOGIN_RESPONSE);
|
||||||
|
|
||||||
loginResponse.Write<uint8_t>(GeneralUtils::CastUnderlyingType(responseCode));
|
loginResponse.Write(responseCode);
|
||||||
|
|
||||||
// Event Gating
|
// Event Gating
|
||||||
loginResponse.Write(LUString(Game::config->GetValue("event_1")));
|
loginResponse.Write(LUString(Game::config->GetValue("event_1")));
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "NtCombatChallengeDummy.h"
|
#include "NtCombatChallengeDummy.h"
|
||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
|
#include "Entity.h"
|
||||||
|
|
||||||
void NtCombatChallengeDummy::OnDie(Entity* self, Entity* killer) {
|
void NtCombatChallengeDummy::OnDie(Entity* self, Entity* killer) {
|
||||||
const auto challengeObjectID = self->GetVar<LWOOBJID>(u"challengeObjectID");
|
const auto challengeObjectID = self->GetVar<LWOOBJID>(u"challengeObjectID");
|
||||||
@ -7,9 +8,7 @@ void NtCombatChallengeDummy::OnDie(Entity* self, Entity* killer) {
|
|||||||
auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID);
|
auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID);
|
||||||
|
|
||||||
if (challengeObject != nullptr) {
|
if (challengeObject != nullptr) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(challengeObject)) {
|
challengeObject->GetScript()->OnDie(challengeObject, killer);
|
||||||
script->OnDie(challengeObject, killer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,8 +18,6 @@ void NtCombatChallengeDummy::OnHitOrHealResult(Entity* self, Entity* attacker, i
|
|||||||
auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID);
|
auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID);
|
||||||
|
|
||||||
if (challengeObject != nullptr) {
|
if (challengeObject != nullptr) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(challengeObject)) {
|
challengeObject->GetScript()->OnHitOrHealResult(challengeObject, attacker, damage);
|
||||||
script->OnHitOrHealResult(challengeObject, attacker, damage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,7 @@ void NtCombatChallengeExplodingDummy::OnDie(Entity* self, Entity* killer) {
|
|||||||
auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID);
|
auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID);
|
||||||
|
|
||||||
if (challengeObject != nullptr) {
|
if (challengeObject != nullptr) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(challengeObject)) {
|
challengeObject->GetScript()->OnDie(challengeObject, killer);
|
||||||
script->OnDie(challengeObject, killer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,9 +30,7 @@ void NtCombatChallengeExplodingDummy::OnHitOrHealResult(Entity* self, Entity* at
|
|||||||
auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID);
|
auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID);
|
||||||
|
|
||||||
if (challengeObject != nullptr) {
|
if (challengeObject != nullptr) {
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(challengeObject)) {
|
challengeObject->GetScript()->OnHitOrHealResult(challengeObject, attacker, damage);
|
||||||
script->OnHitOrHealResult(challengeObject, attacker, damage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
auto skillComponent = self->GetComponent<SkillComponent>();
|
auto skillComponent = self->GetComponent<SkillComponent>();
|
||||||
if (skillComponent != nullptr) {
|
if (skillComponent != nullptr) {
|
||||||
|
@ -11,7 +11,6 @@ set(DSCRIPTS_SOURCES
|
|||||||
"InvalidScript.cpp"
|
"InvalidScript.cpp"
|
||||||
"NPCAddRemoveItem.cpp"
|
"NPCAddRemoveItem.cpp"
|
||||||
"NtFactionSpyServer.cpp"
|
"NtFactionSpyServer.cpp"
|
||||||
"ScriptComponent.cpp"
|
|
||||||
"ScriptedPowerupSpawner.cpp"
|
"ScriptedPowerupSpawner.cpp"
|
||||||
"SpawnPetBaseServer.cpp")
|
"SpawnPetBaseServer.cpp")
|
||||||
|
|
||||||
|
@ -322,16 +322,18 @@
|
|||||||
#include "WblRobotCitizen.h"
|
#include "WblRobotCitizen.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
InvalidScript* invalidToReturn = new InvalidScript();
|
// This is in the translation unit instead of the header to prevent wierd linker errors
|
||||||
|
InvalidScript* const InvalidToReturn = new InvalidScript();
|
||||||
std::map<std::string, CppScripts::Script*> m_Scripts;
|
std::map<std::string, CppScripts::Script*> m_Scripts;
|
||||||
};
|
};
|
||||||
|
|
||||||
CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scriptName) {
|
CppScripts::Script* const CppScripts::GetScript(Entity* parent, const std::string& scriptName) {
|
||||||
if (m_Scripts.find(scriptName) != m_Scripts.end()) {
|
auto itr = m_Scripts.find(scriptName);
|
||||||
return m_Scripts[scriptName];
|
if (itr != m_Scripts.end()) {
|
||||||
|
return itr->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
Script* script = invalidToReturn;
|
Script* script = InvalidToReturn;
|
||||||
|
|
||||||
//VE / AG:
|
//VE / AG:
|
||||||
if (scriptName == "scripts\\ai\\AG\\L_AG_SHIP_PLAYER_DEATH_TRIGGER.lua")
|
if (scriptName == "scripts\\ai\\AG\\L_AG_SHIP_PLAYER_DEATH_TRIGGER.lua")
|
||||||
@ -950,7 +952,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
|||||||
|
|
||||||
// handle invalid script reporting if the path is greater than zero and it's not an ignored script
|
// handle invalid script reporting if the path is greater than zero and it's not an ignored script
|
||||||
// information not really needed for sys admins but is for developers
|
// information not really needed for sys admins but is for developers
|
||||||
else if (script == invalidToReturn) {
|
else if (script == InvalidToReturn) {
|
||||||
if ((scriptName.length() > 0) && !((scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua") ||
|
if ((scriptName.length() > 0) && !((scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua") ||
|
||||||
(scriptName == "scripts\\02_server\\Enemy\\General\\L_BASE_ENEMY_SPIDERLING.lua") ||
|
(scriptName == "scripts\\02_server\\Enemy\\General\\L_BASE_ENEMY_SPIDERLING.lua") ||
|
||||||
(scriptName =="scripts\\ai\\FV\\L_ACT_NINJA_STUDENT.lua") ||
|
(scriptName =="scripts\\ai\\FV\\L_ACT_NINJA_STUDENT.lua") ||
|
||||||
@ -963,13 +965,6 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
|||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CppScripts::Script*> CppScripts::GetEntityScripts(Entity* entity) {
|
CppScripts::Script* const CppScripts::GetInvalidScript() {
|
||||||
std::vector<CppScripts::Script*> scripts;
|
return InvalidToReturn;
|
||||||
std::vector<ScriptComponent*> comps = entity->GetScriptComponents();
|
|
||||||
for (ScriptComponent* scriptComp : comps) {
|
|
||||||
if (scriptComp != nullptr) {
|
|
||||||
scripts.push_back(scriptComp->GetScript());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return scripts;
|
|
||||||
}
|
}
|
||||||
|
@ -357,6 +357,10 @@ namespace CppScripts {
|
|||||||
virtual void OnRequestActivityExit(Entity* sender, LWOOBJID player, bool canceled){};
|
virtual void OnRequestActivityExit(Entity* sender, LWOOBJID player, bool canceled){};
|
||||||
};
|
};
|
||||||
|
|
||||||
Script* GetScript(Entity* parent, const std::string& scriptName);
|
Script* const GetScript(Entity* parent, const std::string& scriptName);
|
||||||
std::vector<Script*> GetEntityScripts(Entity* entity);
|
|
||||||
|
// Get the invalid script. Would be a static variable of the namespace, but that would be
|
||||||
|
// more cluttery to use. Also this allows us to control where this invalid script is defined and initialized
|
||||||
|
// since we dont want anyone externally modifying it.
|
||||||
|
Script* const GetInvalidScript();
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
set(DCOMMONTEST_SOURCES
|
set(DCOMMONTEST_SOURCES
|
||||||
"AMFDeserializeTests.cpp"
|
"AMFDeserializeTests.cpp"
|
||||||
"Amf3Tests.cpp"
|
"Amf3Tests.cpp"
|
||||||
"CastUnderlyingTypeTests.cpp"
|
"ToUnderlyingTests.cpp"
|
||||||
"HeaderSkipTest.cpp"
|
"HeaderSkipTest.cpp"
|
||||||
"TestCDFeatureGatingTable.cpp"
|
"TestCDFeatureGatingTable.cpp"
|
||||||
"TestLDFFormat.cpp"
|
"TestLDFFormat.cpp"
|
||||||
|
@ -7,13 +7,13 @@
|
|||||||
#include "eWorldMessageType.h"
|
#include "eWorldMessageType.h"
|
||||||
|
|
||||||
#define ASSERT_TYPE_EQ(TYPE, ENUM)\
|
#define ASSERT_TYPE_EQ(TYPE, ENUM)\
|
||||||
ASSERT_TRUE(typeid(TYPE) == typeid(GeneralUtils::CastUnderlyingType(static_cast<ENUM>(0))));
|
ASSERT_TRUE(typeid(TYPE) == typeid(GeneralUtils::ToUnderlying(static_cast<ENUM>(0))));
|
||||||
|
|
||||||
#define ASSERT_TYPE_NE(TYPE, ENUM)\
|
#define ASSERT_TYPE_NE(TYPE, ENUM)\
|
||||||
ASSERT_FALSE(typeid(TYPE) == typeid(GeneralUtils::CastUnderlyingType(static_cast<ENUM>(0))));
|
ASSERT_FALSE(typeid(TYPE) == typeid(GeneralUtils::ToUnderlying(static_cast<ENUM>(0))));
|
||||||
|
|
||||||
// Verify that the underlying enum types are being cast correctly
|
// Verify that the underlying enum types are being cast correctly
|
||||||
TEST(CastUnderlyingTypeTests, VerifyCastUnderlyingType) {
|
TEST(ToUnderlyingTests, VerifyToUnderlying) {
|
||||||
ASSERT_TYPE_EQ(uint8_t, eGameMasterLevel);
|
ASSERT_TYPE_EQ(uint8_t, eGameMasterLevel);
|
||||||
ASSERT_TYPE_EQ(uint16_t, eGameMessageType);
|
ASSERT_TYPE_EQ(uint16_t, eGameMessageType);
|
||||||
ASSERT_TYPE_EQ(uint32_t, eWorldMessageType)
|
ASSERT_TYPE_EQ(uint32_t, eWorldMessageType)
|
Loading…
Reference in New Issue
Block a user