diff --git a/dCommon/DluAssert.h b/dCommon/DluAssert.h new file mode 100644 index 00000000..ce971122 --- /dev/null +++ b/dCommon/DluAssert.h @@ -0,0 +1,14 @@ +#ifndef __DLUASSERT__H__ +#define __DLUASSERT__H__ + +#include + +#define _DEBUG + +#ifdef _DEBUG +# define DluAssert(expression) assert(expression) +#else +# define DluAssert(expression) +#endif + +#endif //!__DLUASSERT__H__ diff --git a/dCommon/Metrics.cpp b/dCommon/Metrics.cpp index b97b5435..3a3b7d78 100644 --- a/dCommon/Metrics.cpp +++ b/dCommon/Metrics.cpp @@ -14,6 +14,7 @@ std::vector Metrics::m_Variables = { MetricVariable::CPUTime, MetricVariable::Sleep, MetricVariable::Frame, + MetricVariable::Database, }; void Metrics::AddMeasurement(MetricVariable variable, int64_t value) { diff --git a/dCommon/Metrics.hpp b/dCommon/Metrics.hpp index c03c914f..b7ac748f 100644 --- a/dCommon/Metrics.hpp +++ b/dCommon/Metrics.hpp @@ -20,6 +20,7 @@ enum class MetricVariable : int32_t CPUTime, Sleep, Frame, + Database, }; struct Metric diff --git a/dDatabase/CDClientDatabase.h b/dDatabase/CDClientDatabase.h index 96f67d64..59f69b7d 100644 --- a/dDatabase/CDClientDatabase.h +++ b/dDatabase/CDClientDatabase.h @@ -16,9 +16,6 @@ // Enable this to cache all entries in each table for fast access, comes with more memory cost //#define CDCLIENT_CACHE_ALL - // Enable this to skip some unused columns in some tables -#define UNUSED(v) - /*! \file CDClientDatabase.hpp \brief An interface between the CDClient.sqlite file and the server diff --git a/dDatabase/CDClientManager.cpp b/dDatabase/CDClientManager.cpp index eeea686f..9df6ff31 100644 --- a/dDatabase/CDClientManager.cpp +++ b/dDatabase/CDClientManager.cpp @@ -40,7 +40,7 @@ CDClientManager::CDClientManager() { CDActivityRewardsTable::Instance(); - UNUSED(CDAnimationsTable::Instance()); + CDAnimationsTable::Instance(); CDBehaviorParameterTable::Instance(); CDBehaviorTemplateTable::Instance(); CDComponentsRegistryTable::Instance(); diff --git a/dDatabase/CDClientManager.h b/dDatabase/CDClientManager.h index 1754fe99..74069ff4 100644 --- a/dDatabase/CDClientManager.h +++ b/dDatabase/CDClientManager.h @@ -4,6 +4,8 @@ #include "Singleton.h" +#define UNUSED_TABLE(v) + /** * Initialize the CDClient tables so they are all loaded into memory. */ diff --git a/dDatabase/Tables/CDActivitiesTable.cpp b/dDatabase/Tables/CDActivitiesTable.cpp index e1660d66..2c2da31e 100644 --- a/dDatabase/Tables/CDActivitiesTable.cpp +++ b/dDatabase/Tables/CDActivitiesTable.cpp @@ -1,27 +1,11 @@ #include "CDActivitiesTable.h" -CDActivitiesTable::CDActivitiesTable(void) { - - // First, get the size of the table - unsigned int size = 0; - auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Activities"); - while (!tableSize.eof()) { - size = tableSize.getIntField(0, 0); - - tableSize.nextRow(); - } - - tableSize.finalize(); - - // Reserve the size - this->entries.reserve(size); - - // Now get the data +CDActivitiesTable::CDActivitiesTable() { auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Activities"); while (!tableData.eof()) { CDActivities entry; - entry.ActivityID = tableData.getIntField("ActivityID", -1); - entry.locStatus = tableData.getIntField("locStatus", -1); + ActivityID activityId = tableData.getIntField("ActivityID", -1); + UNUSED_COLUMN(entry.locStatus = tableData.getIntField("locStatus", -1)); entry.instanceMapID = tableData.getIntField("instanceMapID", -1); entry.minTeams = tableData.getIntField("minTeams", -1); entry.maxTeams = tableData.getIntField("maxTeams", -1); @@ -29,34 +13,26 @@ CDActivitiesTable::CDActivitiesTable(void) { entry.maxTeamSize = tableData.getIntField("maxTeamSize", -1); entry.waitTime = tableData.getIntField("waitTime", -1); entry.startDelay = tableData.getIntField("startDelay", -1); - entry.requiresUniqueData = tableData.getIntField("requiresUniqueData", -1); + UNUSED_COLUMN(entry.requiresUniqueData = tableData.getIntField("requiresUniqueData", -1)); entry.leaderboardType = tableData.getIntField("leaderboardType", -1); - entry.localize = tableData.getIntField("localize", -1); + UNUSED_COLUMN(entry.localize = tableData.getIntField("localize", -1)); entry.optionalCostLOT = tableData.getIntField("optionalCostLOT", -1); entry.optionalCostCount = tableData.getIntField("optionalCostCount", -1); - entry.showUIRewards = tableData.getIntField("showUIRewards", -1); - entry.CommunityActivityFlagID = tableData.getIntField("CommunityActivityFlagID", -1); - entry.gate_version = tableData.getStringField("gate_version", ""); + UNUSED_COLUMN(entry.showUIRewards = tableData.getIntField("showUIRewards", -1)); + UNUSED_COLUMN(entry.CommunityActivityFlagID = tableData.getIntField("CommunityActivityFlagID", -1)); + UNUSED_COLUMN(entry.gate_version = tableData.getStringField("gate_version", "")); entry.noTeamLootOnDeath = tableData.getIntField("noTeamLootOnDeath", -1); - entry.optionalPercentage = tableData.getFloatField("optionalPercentage", -1.0f); + UNUSED_COLUMN(entry.optionalPercentage = tableData.getFloatField("optionalPercentage", -1.0f)); + + auto insertedElement = this->entries.insert_or_assign(activityId, entry); + DluAssert(insertedElement.second == true); - this->entries.push_back(entry); tableData.nextRow(); } - tableData.finalize(); } -std::vector CDActivitiesTable::Query(std::function predicate) { - - std::vector data = cpplinq::from(this->entries) - >> cpplinq::where(predicate) - >> cpplinq::to_vector(); - - return data; +CDActivitiesResult CDActivitiesTable::GetActivity(ActivityID id) { + const auto foundElement = this->entries.find(id); + return foundElement != this->entries.end() ? CDActivitiesResult(foundElement->second) : CDActivitiesResult(); } - -std::vector CDActivitiesTable::GetEntries(void) const { - return this->entries; -} - diff --git a/dDatabase/Tables/CDActivitiesTable.h b/dDatabase/Tables/CDActivitiesTable.h index 4b60afbd..ed454b6e 100644 --- a/dDatabase/Tables/CDActivitiesTable.h +++ b/dDatabase/Tables/CDActivitiesTable.h @@ -1,38 +1,37 @@ #pragma once -// Custom Classes #include "CDTable.h" +typedef uint32_t ActivityID; + struct CDActivities { - unsigned int ActivityID; - unsigned int locStatus; - unsigned int instanceMapID; - unsigned int minTeams; - unsigned int maxTeams; - unsigned int minTeamSize; - unsigned int maxTeamSize; - unsigned int waitTime; - unsigned int startDelay; - bool requiresUniqueData; - unsigned int leaderboardType; - bool localize; - int optionalCostLOT; - int optionalCostCount; - bool showUIRewards; - unsigned int CommunityActivityFlagID; - std::string gate_version; + UNUSED_COLUMN(uint32_t locStatus); + uint32_t instanceMapID; + uint32_t minTeams; + uint32_t maxTeams; + uint32_t minTeamSize; + uint32_t maxTeamSize; + uint32_t waitTime; + uint32_t startDelay; + UNUSED_COLUMN(bool requiresUniqueData); + uint32_t leaderboardType; + UNUSED_COLUMN(bool localize); + int32_t optionalCostLOT; + int32_t optionalCostCount; + UNUSED_COLUMN(bool showUIRewards); + UNUSED_COLUMN(uint32_t CommunityActivityFlagID); + UNUSED_COLUMN(std::string gate_version); bool noTeamLootOnDeath; - float optionalPercentage; + UNUSED_COLUMN(float optionalPercentage); }; +typedef LookupResult CDActivitiesResult; class CDActivitiesTable : public CDTable { private: - std::vector entries; + std::map entries; public: CDActivitiesTable(); // Queries the table with a custom "where" clause - std::vector Query(std::function predicate); - - std::vector GetEntries(void) const; + CDActivitiesResult GetActivity(ActivityID predicate); }; diff --git a/dDatabase/Tables/CDActivityRewardsTable.h b/dDatabase/Tables/CDActivityRewardsTable.h index b5503fb6..9a4a4ce8 100644 --- a/dDatabase/Tables/CDActivityRewardsTable.h +++ b/dDatabase/Tables/CDActivityRewardsTable.h @@ -4,13 +4,13 @@ #include "CDTable.h" struct CDActivityRewards { - unsigned int objectTemplate; //!< The object template (?) - unsigned int ActivityRewardIndex; //!< The activity reward index - int activityRating; //!< The activity rating - unsigned int LootMatrixIndex; //!< The loot matrix index - unsigned int CurrencyIndex; //!< The currency index - unsigned int ChallengeRating; //!< The challenge rating - std::string description; //!< The description + unsigned int objectTemplate; + unsigned int ActivityRewardIndex; + int activityRating; + unsigned int LootMatrixIndex; + unsigned int CurrencyIndex; + unsigned int ChallengeRating; + std::string description; }; class CDActivityRewardsTable : public CDTable { diff --git a/dDatabase/Tables/CDAnimationsTable.cpp b/dDatabase/Tables/CDAnimationsTable.cpp index e1227f39..4f4730de 100644 --- a/dDatabase/Tables/CDAnimationsTable.cpp +++ b/dDatabase/Tables/CDAnimationsTable.cpp @@ -1,56 +1,84 @@ #include "CDAnimationsTable.h" +#include "GeneralUtils.h" +#include "Game.h" -CDAnimationsTable::CDAnimationsTable(void) { +bool CDAnimationsTable::CacheData(CppSQLite3Statement queryToCache) { + auto tableData = queryToCache.execQuery(); + // If we received a bad lookup, cache it anyways so we do not run the query again. + if (tableData.eof()) return false; - // First, get the size of the table - unsigned int size = 0; - auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM Animations"); - while (!tableSize.eof()) { - size = tableSize.getIntField(0, 0); + do { + std::string animation_type = tableData.getStringField("animation_type", ""); + DluAssert(!animation_type.empty()); + AnimationGroupID animationGroupID = tableData.getIntField("animationGroupID", -1); + DluAssert(animationGroupID != -1); - tableSize.nextRow(); - } - - tableSize.finalize(); - - // Reserve the size - this->entries.reserve(size); - - // Now get the data - auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM Animations"); - while (!tableData.eof()) { - CDAnimations entry; - entry.animationGroupID = tableData.getIntField("animationGroupID", -1); - entry.animation_type = tableData.getStringField("animation_type", ""); + CDAnimation entry; entry.animation_name = tableData.getStringField("animation_name", ""); - entry.chance_to_play = tableData.getFloatField("chance_to_play", -1.0f); - entry.min_loops = tableData.getIntField("min_loops", -1); - entry.max_loops = tableData.getIntField("max_loops", -1); - entry.animation_length = tableData.getFloatField("animation_length", -1.0f); - entry.hideEquip = tableData.getIntField("hideEquip", -1) == 1 ? true : false; - entry.ignoreUpperBody = tableData.getIntField("ignoreUpperBody", -1) == 1 ? true : false; - entry.restartable = tableData.getIntField("restartable", -1) == 1 ? true : false; + entry.chance_to_play = tableData.getFloatField("chance_to_play", 1.0f); + entry.min_loops = tableData.getIntField("min_loops", 0); + entry.max_loops = tableData.getIntField("max_loops", 0); + entry.animation_length = tableData.getFloatField("animation_length", 0.0f); + entry.hideEquip = tableData.getIntField("hideEquip", 0) == 1; + entry.ignoreUpperBody = tableData.getIntField("ignoreUpperBody", 0) == 1; + entry.restartable = tableData.getIntField("restartable", 0) == 1; entry.face_animation_name = tableData.getStringField("face_animation_name", ""); - entry.priority = tableData.getFloatField("priority", -1.0f); - entry.blendTime = tableData.getFloatField("blendTime", -1.0f); + entry.priority = tableData.getFloatField("priority", 0.0f); + entry.blendTime = tableData.getFloatField("blendTime", 0.0f); - this->entries.push_back(entry); + this->animations[CDAnimationKey(animation_type, animationGroupID)].push_back(entry); tableData.nextRow(); - } + } while (!tableData.eof()); tableData.finalize(); + + return true; } -std::vector CDAnimationsTable::Query(std::function predicate) { - - std::vector data = cpplinq::from(this->entries) - >> cpplinq::where(predicate) - >> cpplinq::to_vector(); - - return data; +void CDAnimationsTable::CacheAnimations(const CDAnimationKey animationKey) { + auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Animations WHERE animationGroupID = ? and animation_type = ?"); + query.bind(1, static_cast(animationKey.second)); + query.bind(2, animationKey.first.c_str()); + // If we received a bad lookup, cache it anyways so we do not run the query again. + if (!CacheData(query)) { + this->animations[animationKey]; + } } -std::vector CDAnimationsTable::GetEntries(void) const { - return this->entries; +void CDAnimationsTable::CacheAnimationGroup(AnimationGroupID animationGroupID) { + auto animationEntryCached = this->animations.find(CDAnimationKey("", animationGroupID)); + if (animationEntryCached != this->animations.end()) { + return; + } + + auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM Animations WHERE animationGroupID = ?"); + query.bind(1, static_cast(animationGroupID)); + + // Cache the query so we don't run the query again. + CacheData(query); + this->animations[CDAnimationKey("", animationGroupID)]; } +CDAnimationLookupResult CDAnimationsTable::GetAnimation(const AnimationID& animationType, const std::string& previousAnimationName, const AnimationGroupID animationGroupID) { + CDAnimationKey animationKey(animationType, animationGroupID); + auto randomAnimation = GeneralUtils::GenerateRandomNumber(0, 1); + auto animationEntryCached = this->animations.find(animationKey); + if (animationEntryCached == this->animations.end()) { + this->CacheAnimations(animationKey); + } + + auto animationEntry = this->animations.find(animationKey); + + // If we have only one animation, return it regardless of the chance to play. + if (animationEntry->second.size() == 1) { + return CDAnimationLookupResult(animationEntry->second.front()); + } + + for (auto& animationEntry : animationEntry->second) { + randomAnimation -= animationEntry.chance_to_play; + // This is how the client gets the random animation. + if (animationEntry.animation_name != previousAnimationName && randomAnimation <= 0.0f) return CDAnimationLookupResult(animationEntry); + } + + return CDAnimationLookupResult(); +} diff --git a/dDatabase/Tables/CDAnimationsTable.h b/dDatabase/Tables/CDAnimationsTable.h index 43400abf..b92e37cc 100644 --- a/dDatabase/Tables/CDAnimationsTable.h +++ b/dDatabase/Tables/CDAnimationsTable.h @@ -3,9 +3,10 @@ // Custom Classes #include "CDTable.h" -struct CDAnimations { - unsigned int animationGroupID; //!< The animation group ID - std::string animation_type; //!< The animation type +struct CDAnimation { + // unsigned int animationGroupID; + // std::string animation_type; + // The above two are a pair to represent a primary key in the map. std::string animation_name; //!< The animation name float chance_to_play; //!< The chance to play the animation unsigned int min_loops; //!< The minimum number of loops @@ -19,15 +20,20 @@ struct CDAnimations { float blendTime; //!< The blend time }; +typedef LookupResult CDAnimationLookupResult; class CDAnimationsTable : public CDTable { -private: - std::vector entries; - + typedef int32_t AnimationGroupID; + typedef std::string AnimationID; + typedef std::pair CDAnimationKey; public: - CDAnimationsTable(); - // Queries the table with a custom "where" clause - std::vector Query(std::function predicate); - - std::vector GetEntries(void) const; + CDAnimationLookupResult GetAnimation(const AnimationID& animationType, const std::string& previousAnimationName, const AnimationGroupID animationGroupID); + void CacheAnimationGroup(AnimationGroupID animationGroupID); +private: + void CacheAnimations(const CDAnimationKey animationKey); + bool CacheData(CppSQLite3Statement queryToCache); + /** + * Each animation type has a vector of animations. This is because there can be animations have a percent chance to play so one is selected at random. + */ + std::map> animations; }; diff --git a/dDatabase/Tables/CDComponentsRegistryTable.cpp b/dDatabase/Tables/CDComponentsRegistryTable.cpp index 32012f6c..f553e23c 100644 --- a/dDatabase/Tables/CDComponentsRegistryTable.cpp +++ b/dDatabase/Tables/CDComponentsRegistryTable.cpp @@ -1,93 +1,31 @@ #include "CDComponentsRegistryTable.h" #include "eReplicaComponentType.h" +#include "dLogger.h" +#include "Game.h" -#define CDCLIENT_CACHE_ALL +uint64_t CalculateId(uint64_t lhs, uint64_t rhs) { + return (lhs << 32) | rhs; +} -CDComponentsRegistryTable::CDComponentsRegistryTable(void) { +void CDComponentsRegistryTable::ReadRow(CppSQLite3Query& rowData) { + uint32_t id = rowData.getIntField("id", -1); + eReplicaComponentType component_type = static_cast(rowData.getIntField("component_type", 0)); + uint32_t component_id = rowData.getIntField("component_id", -1); -#ifdef CDCLIENT_CACHE_ALL - // First, get the size of the table - unsigned int size = 0; - auto tableSize = CDClientDatabase::ExecuteQuery("SELECT COUNT(*) FROM ComponentsRegistry"); - while (!tableSize.eof()) { - size = tableSize.getIntField(0, 0); + auto insertedEntry = this->mappedEntries.insert_or_assign(CalculateId(id, static_cast(component_type)), component_id); + DluAssert(insertedEntry.second == true); +} - tableSize.nextRow(); - } - - tableSize.finalize(); - - // Reserve the size - //this->entries.reserve(size); - - // Now get the data +CDComponentsRegistryTable::CDComponentsRegistryTable() { auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM ComponentsRegistry"); while (!tableData.eof()) { - CDComponentsRegistry entry; - entry.id = tableData.getIntField("id", -1); - entry.component_type = static_cast(tableData.getIntField("component_type", 0)); - entry.component_id = tableData.getIntField("component_id", -1); - - this->mappedEntries.insert_or_assign(((uint64_t)entry.component_type) << 32 | ((uint64_t)entry.id), entry.component_id); - + ReadRow(tableData); tableData.nextRow(); } - tableData.finalize(); -#endif } int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue) { - const auto& iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id)); - - if (iter == this->mappedEntries.end()) { - return defaultValue; - } - - return iter->second; - -#ifndef CDCLIENT_CACHE_ALL - // Now get the data - std::stringstream query; - - query << "SELECT * FROM ComponentsRegistry WHERE id = " << std::to_string(id); - - auto tableData = CDClientDatabase::ExecuteQuery(query.str()); - while (!tableData.eof()) { - CDComponentsRegistry entry; - entry.id = tableData.getIntField("id", -1); - entry.component_type = tableData.getIntField("component_type", -1); - entry.component_id = tableData.getIntField("component_id", -1); - - //this->entries.push_back(entry); - - //Darwin's stuff: - const auto& it = this->mappedEntries.find(entry.id); - if (it != mappedEntries.end()) { - const auto& iter = it->second.find(entry.component_type); - if (iter == it->second.end()) { - it->second.insert(std::make_pair(entry.component_type, entry.component_id)); - } - } else { - std::map map; - map.insert(std::make_pair(entry.component_type, entry.component_id)); - this->mappedEntries.insert(std::make_pair(entry.id, map)); - } - - tableData.nextRow(); - } - - tableData.finalize(); - - const auto& it2 = this->mappedEntries.find(id); - if (it2 != mappedEntries.end()) { - const auto& iter = it2->second.find(componentType); - if (iter != it2->second.end()) { - return iter->second; - } - } - - return defaultValue; -#endif + const auto iter = this->mappedEntries.find(CalculateId(id, static_cast(componentType))); + return iter != this->mappedEntries.end() ? iter->second : defaultValue; } - diff --git a/dDatabase/Tables/CDComponentsRegistryTable.h b/dDatabase/Tables/CDComponentsRegistryTable.h index 990072c9..2e45f293 100644 --- a/dDatabase/Tables/CDComponentsRegistryTable.h +++ b/dDatabase/Tables/CDComponentsRegistryTable.h @@ -1,21 +1,15 @@ #pragma once -// Custom Classes #include "CDTable.h" enum class eReplicaComponentType : uint32_t; -struct CDComponentsRegistry { - unsigned int id; //!< The LOT is used as the ID - eReplicaComponentType component_type; //!< See ComponentTypes enum for values - unsigned int component_id; //!< The ID used within the component's table (0 may either mean it's non-networked, or that the ID is actually 0 -}; - class CDComponentsRegistryTable : public CDTable { -private: - std::map mappedEntries; //id, component_type, component_id - public: CDComponentsRegistryTable(); int32_t GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue = 0); +private: + void ReadRow(CppSQLite3Query& rowData); +private: + std::unordered_map mappedEntries; }; diff --git a/dDatabase/Tables/CDItemComponentTable.cpp b/dDatabase/Tables/CDItemComponentTable.cpp index 54afc417..d53269c2 100644 --- a/dDatabase/Tables/CDItemComponentTable.cpp +++ b/dDatabase/Tables/CDItemComponentTable.cpp @@ -3,8 +3,7 @@ CDItemComponent CDItemComponentTable::Default = {}; -//! Constructor -CDItemComponentTable::CDItemComponentTable(void) { +CDItemComponentTable::CDItemComponentTable() { Default = CDItemComponent(); #ifdef CDCLIENT_CACHE_ALL @@ -55,13 +54,13 @@ CDItemComponentTable::CDItemComponentTable(void) { entry.currencyLOT = tableData.getIntField("currencyLOT", -1); entry.altCurrencyCost = tableData.getIntField("altCurrencyCost", -1); entry.subItems = tableData.getStringField("subItems", ""); - entry.audioEventUse = tableData.getStringField("audioEventUse", ""); + UNUSED_COLUMN(entry.audioEventUse = tableData.getStringField("audioEventUse", "");) entry.noEquipAnimation = tableData.getIntField("noEquipAnimation", -1) == 1 ? true : false; entry.commendationLOT = tableData.getIntField("commendationLOT", -1); entry.commendationCost = tableData.getIntField("commendationCost", -1); - entry.audioEquipMetaEventSet = tableData.getStringField("audioEquipMetaEventSet", ""); + UNUSED_COLUMN(entry.audioEquipMetaEventSet = tableData.getStringField("audioEquipMetaEventSet", "");) entry.currencyCosts = tableData.getStringField("currencyCosts", ""); - entry.ingredientInfo = tableData.getStringField("ingredientInfo", ""); + UNUSED_COLUMN(entry.ingredientInfo = tableData.getStringField("ingredientInfo", "");) entry.locStatus = tableData.getIntField("locStatus", -1); entry.forgeType = tableData.getIntField("forgeType", -1); entry.SellMultiplier = tableData.getFloatField("SellMultiplier", -1.0f); @@ -74,8 +73,8 @@ CDItemComponentTable::CDItemComponentTable(void) { #endif } -const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int skillID) { - const auto& it = this->entries.find(skillID); +const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int id) { + const auto& it = this->entries.find(id); if (it != this->entries.end()) { return it->second; } @@ -83,11 +82,11 @@ const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int s #ifndef CDCLIENT_CACHE_ALL std::stringstream query; - query << "SELECT * FROM ItemComponent WHERE id = " << std::to_string(skillID); + query << "SELECT * FROM ItemComponent WHERE id = " << std::to_string(id); auto tableData = CDClientDatabase::ExecuteQuery(query.str()); if (tableData.eof()) { - entries.insert(std::make_pair(skillID, Default)); + entries.insert(std::make_pair(id, Default)); return Default; } @@ -125,13 +124,13 @@ const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int s entry.currencyLOT = tableData.getIntField("currencyLOT", -1); entry.altCurrencyCost = tableData.getIntField("altCurrencyCost", -1); entry.subItems = tableData.getStringField("subItems", ""); - UNUSED(entry.audioEventUse = tableData.getStringField("audioEventUse", "")); + UNUSED_COLUMN(entry.audioEventUse = tableData.getStringField("audioEventUse", "")); entry.noEquipAnimation = tableData.getIntField("noEquipAnimation", -1) == 1 ? true : false; entry.commendationLOT = tableData.getIntField("commendationLOT", -1); entry.commendationCost = tableData.getIntField("commendationCost", -1); - UNUSED(entry.audioEquipMetaEventSet = tableData.getStringField("audioEquipMetaEventSet", "")); + UNUSED_COLUMN(entry.audioEquipMetaEventSet = tableData.getStringField("audioEquipMetaEventSet", "")); entry.currencyCosts = tableData.getStringField("currencyCosts", ""); - UNUSED(entry.ingredientInfo = tableData.getStringField("ingredientInfo", "")); + UNUSED_COLUMN(entry.ingredientInfo = tableData.getStringField("ingredientInfo", "")); entry.locStatus = tableData.getIntField("locStatus", -1); entry.forgeType = tableData.getIntField("forgeType", -1); entry.SellMultiplier = tableData.getFloatField("SellMultiplier", -1.0f); @@ -140,7 +139,7 @@ const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int s tableData.nextRow(); } - const auto& it2 = this->entries.find(skillID); + const auto& it2 = this->entries.find(id); if (it2 != this->entries.end()) { return it2->second; } @@ -169,4 +168,3 @@ std::map CDItemComponentTable::ParseCraftingCurrencies(const CDIt return currencies; } - diff --git a/dDatabase/Tables/CDItemComponentTable.h b/dDatabase/Tables/CDItemComponentTable.h index 11c34dd6..1cc46b4a 100644 --- a/dDatabase/Tables/CDItemComponentTable.h +++ b/dDatabase/Tables/CDItemComponentTable.h @@ -5,60 +5,60 @@ #include "dCommonVars.h" struct CDItemComponent { - unsigned int id; //!< The Component ID + uint32_t id; //!< The Component ID std::string equipLocation; //!< The equip location - unsigned int baseValue; //!< The monetary base value of the item + uint32_t baseValue; //!< The monetary base value of the item bool isKitPiece; //!< Whether or not the item belongs to a kit - unsigned int rarity; //!< The rarity of the item - unsigned int itemType; //!< The item type + uint32_t rarity; //!< The rarity of the item + uint32_t itemType; //!< The item type int64_t itemInfo; //!< The item info bool inLootTable; //!< Whether or not the item is in a loot table bool inVendor; //!< Whether or not the item is in a vendor inventory bool isUnique; //!< ??? bool isBOP; //!< ??? bool isBOE; //!< ??? - unsigned int reqFlagID; //!< User must have completed this flag to get the item - unsigned int reqSpecialtyID; //!< ??? - unsigned int reqSpecRank; //!< ??? - unsigned int reqAchievementID; //!< The required achievement must be completed - unsigned int stackSize; //!< The stack size of the item - unsigned int color1; //!< Something to do with item color... - unsigned int decal; //!< The decal of the item - unsigned int offsetGroupID; //!< Something to do with group IDs - unsigned int buildTypes; //!< Something to do with building + uint32_t reqFlagID; //!< User must have completed this flag to get the item + uint32_t reqSpecialtyID; //!< ??? + uint32_t reqSpecRank; //!< ??? + uint32_t reqAchievementID; //!< The required achievement must be completed + uint32_t stackSize; //!< The stack size of the item + uint32_t color1; //!< Something to do with item color... + uint32_t decal; //!< The decal of the item + uint32_t offsetGroupID; //!< Something to do with group IDs + uint32_t buildTypes; //!< Something to do with building std::string reqPrecondition; //!< The required precondition - unsigned int animationFlag; //!< The Animation Flag - unsigned int equipEffects; //!< The effect played when the item is equipped + uint32_t animationFlag; //!< The Animation Flag + uint32_t equipEffects; //!< The effect played when the item is equipped bool readyForQA; //!< ??? - unsigned int itemRating; //!< ??? + uint32_t itemRating; //!< ??? bool isTwoHanded; //!< Whether or not the item is double handed - unsigned int minNumRequired; //!< Maybe the minimum number required for a mission, or to own this object? - unsigned int delResIndex; //!< ??? - unsigned int currencyLOT; //!< ??? - unsigned int altCurrencyCost; //!< ??? + uint32_t minNumRequired; //!< Maybe the minimum number required for a mission, or to own this object? + uint32_t delResIndex; //!< ??? + uint32_t currencyLOT; //!< ??? + uint32_t altCurrencyCost; //!< ??? std::string subItems; //!< A comma seperate string of sub items (maybe for multi-itemed things like faction test gear set) - UNUSED(std::string audioEventUse); //!< ??? + UNUSED_COLUMN(std::string audioEventUse); //!< ??? bool noEquipAnimation; //!< Whether or not there is an equip animation - unsigned int commendationLOT; //!< The commendation LOT - unsigned int commendationCost; //!< The commendation cost - UNUSED(std::string audioEquipMetaEventSet); //!< ??? + uint32_t commendationLOT; //!< The commendation LOT + uint32_t commendationCost; //!< The commendation cost + UNUSED_COLUMN(std::string audioEquipMetaEventSet); //!< ??? std::string currencyCosts; //!< Used for crafting - UNUSED(std::string ingredientInfo); //!< Unused - unsigned int locStatus; //!< ??? - unsigned int forgeType; //!< Forge Type + UNUSED_COLUMN(std::string ingredientInfo); //!< Unused + uint32_t locStatus; //!< ??? + uint32_t forgeType; //!< Forge Type float SellMultiplier; //!< Something to do with early vendors perhaps (but replaced) }; class CDItemComponentTable : public CDTable { private: - std::map entries; + std::map entries; public: CDItemComponentTable(); static std::map ParseCraftingCurrencies(const CDItemComponent& itemComponent); // Gets an entry by ID - const CDItemComponent& GetItemComponentByID(unsigned int skillID); + const CDItemComponent& GetItemComponentByID(uint32_t id); static CDItemComponent Default; }; diff --git a/dDatabase/Tables/CDLootMatrixTable.cpp b/dDatabase/Tables/CDLootMatrixTable.cpp index 8f25e8a3..c6c5cd8e 100644 --- a/dDatabase/Tables/CDLootMatrixTable.cpp +++ b/dDatabase/Tables/CDLootMatrixTable.cpp @@ -29,7 +29,7 @@ CDLootMatrixTable::CDLootMatrixTable(void) { entry.maxToDrop = tableData.getIntField("maxToDrop", -1); entry.id = tableData.getIntField("id", -1); entry.flagID = tableData.getIntField("flagID", -1); - UNUSED(entry.gate_version = tableData.getStringField("gate_version", "")); + UNUSED_COLUMN(entry.gate_version = tableData.getStringField("gate_version", "")); this->entries.push_back(entry); tableData.nextRow(); diff --git a/dDatabase/Tables/CDLootMatrixTable.h b/dDatabase/Tables/CDLootMatrixTable.h index c6035841..c56be7a8 100644 --- a/dDatabase/Tables/CDLootMatrixTable.h +++ b/dDatabase/Tables/CDLootMatrixTable.h @@ -12,7 +12,7 @@ struct CDLootMatrix { unsigned int maxToDrop; //!< The maximum amount of loot from this matrix to drop unsigned int id; //!< The ID of the Loot Matrix unsigned int flagID; //!< ??? - UNUSED(std::string gate_version); //!< The Gate Version + UNUSED_COLUMN(std::string gate_version); //!< The Gate Version }; class CDLootMatrixTable : public CDTable { diff --git a/dDatabase/Tables/CDMissionTasksTable.cpp b/dDatabase/Tables/CDMissionTasksTable.cpp index f32dca1b..ca65c85f 100644 --- a/dDatabase/Tables/CDMissionTasksTable.cpp +++ b/dDatabase/Tables/CDMissionTasksTable.cpp @@ -22,18 +22,18 @@ CDMissionTasksTable::CDMissionTasksTable(void) { while (!tableData.eof()) { CDMissionTasks entry; entry.id = tableData.getIntField("id", -1); - UNUSED(entry.locStatus = tableData.getIntField("locStatus", -1)); + UNUSED_COLUMN(entry.locStatus = tableData.getIntField("locStatus", -1)); entry.taskType = tableData.getIntField("taskType", -1); entry.target = tableData.getIntField("target", -1); entry.targetGroup = tableData.getStringField("targetGroup", ""); entry.targetValue = tableData.getIntField("targetValue", -1); entry.taskParam1 = tableData.getStringField("taskParam1", ""); - UNUSED(entry.largeTaskIcon = tableData.getStringField("largeTaskIcon", "")); - UNUSED(entry.IconID = tableData.getIntField("IconID", -1)); + UNUSED_COLUMN(entry.largeTaskIcon = tableData.getStringField("largeTaskIcon", "")); + UNUSED_COLUMN(entry.IconID = tableData.getIntField("IconID", -1)); entry.uid = tableData.getIntField("uid", -1); - UNUSED(entry.largeTaskIconID = tableData.getIntField("largeTaskIconID", -1)); - UNUSED(entry.localize = tableData.getIntField("localize", -1) == 1 ? true : false); - UNUSED(entry.gate_version = tableData.getStringField("gate_version", "")); + UNUSED_COLUMN(entry.largeTaskIconID = tableData.getIntField("largeTaskIconID", -1)); + UNUSED_COLUMN(entry.localize = tableData.getIntField("localize", -1) == 1 ? true : false); + UNUSED_COLUMN(entry.gate_version = tableData.getStringField("gate_version", "")); this->entries.push_back(entry); tableData.nextRow(); diff --git a/dDatabase/Tables/CDMissionTasksTable.h b/dDatabase/Tables/CDMissionTasksTable.h index fa213faf..f5e780f5 100644 --- a/dDatabase/Tables/CDMissionTasksTable.h +++ b/dDatabase/Tables/CDMissionTasksTable.h @@ -5,18 +5,18 @@ struct CDMissionTasks { unsigned int id; //!< The Mission ID that the task belongs to - UNUSED(unsigned int locStatus); //!< ??? + UNUSED_COLUMN(unsigned int locStatus); //!< ??? unsigned int taskType; //!< The task type unsigned int target; //!< The mission target std::string targetGroup; //!< The mission target group int targetValue; //!< The target value std::string taskParam1; //!< The task param 1 - UNUSED(std::string largeTaskIcon); //!< ??? - UNUSED(unsigned int IconID); //!< ??? + UNUSED_COLUMN(std::string largeTaskIcon); //!< ??? + UNUSED_COLUMN(unsigned int IconID); //!< ??? unsigned int uid; //!< ??? - UNUSED(unsigned int largeTaskIconID); //!< ??? - UNUSED(bool localize); //!< Whether or not the task should be localized - UNUSED(std::string gate_version); //!< ??? + UNUSED_COLUMN(unsigned int largeTaskIconID); //!< ??? + UNUSED_COLUMN(bool localize); //!< Whether or not the task should be localized + UNUSED_COLUMN(std::string gate_version); //!< ??? }; class CDMissionTasksTable : public CDTable { diff --git a/dDatabase/Tables/CDMissionsTable.cpp b/dDatabase/Tables/CDMissionsTable.cpp index d4ee40ae..53137560 100644 --- a/dDatabase/Tables/CDMissionsTable.cpp +++ b/dDatabase/Tables/CDMissionsTable.cpp @@ -71,9 +71,9 @@ CDMissionsTable::CDMissionsTable(void) { entry.isRandom = tableData.getIntField("isRandom", -1) == 1 ? true : false; entry.randomPool = tableData.getStringField("randomPool", ""); entry.UIPrereqID = tableData.getIntField("UIPrereqID", -1); - UNUSED(entry.gate_version = tableData.getStringField("gate_version", "")); - UNUSED(entry.HUDStates = tableData.getStringField("HUDStates", "")); - UNUSED(entry.locStatus = tableData.getIntField("locStatus", -1)); + UNUSED_COLUMN(entry.gate_version = tableData.getStringField("gate_version", "")); + UNUSED_COLUMN(entry.HUDStates = tableData.getStringField("HUDStates", "")); + UNUSED_COLUMN(entry.locStatus = tableData.getIntField("locStatus", -1)); entry.reward_bankinventory = tableData.getIntField("reward_bankinventory", -1); this->entries.push_back(entry); diff --git a/dDatabase/Tables/CDMissionsTable.h b/dDatabase/Tables/CDMissionsTable.h index e6a44b02..8e3f2039 100644 --- a/dDatabase/Tables/CDMissionsTable.h +++ b/dDatabase/Tables/CDMissionsTable.h @@ -54,9 +54,9 @@ struct CDMissions { bool isRandom; //!< ??? std::string randomPool; //!< ??? int UIPrereqID; //!< ??? - UNUSED(std::string gate_version); //!< The gate version - UNUSED(std::string HUDStates); //!< ??? - UNUSED(int locStatus); //!< ??? + UNUSED_COLUMN(std::string gate_version); //!< The gate version + UNUSED_COLUMN(std::string HUDStates); //!< ??? + UNUSED_COLUMN(int locStatus); //!< ??? int reward_bankinventory; //!< The amount of bank space this mission rewards }; diff --git a/dDatabase/Tables/CDObjectsTable.cpp b/dDatabase/Tables/CDObjectsTable.cpp index c68c3e6a..e28fb100 100644 --- a/dDatabase/Tables/CDObjectsTable.cpp +++ b/dDatabase/Tables/CDObjectsTable.cpp @@ -65,18 +65,18 @@ const CDObjects& CDObjectsTable::GetByID(unsigned int LOT) { CDObjects entry; entry.id = tableData.getIntField("id", -1); entry.name = tableData.getStringField("name", ""); - UNUSED(entry.placeable = tableData.getIntField("placeable", -1)); + UNUSED_COLUMN(entry.placeable = tableData.getIntField("placeable", -1)); entry.type = tableData.getStringField("type", ""); - UNUSED(ntry.description = tableData.getStringField(4, "")); - UNUSED(entry.localize = tableData.getIntField("localize", -1)); - UNUSED(entry.npcTemplateID = tableData.getIntField("npcTemplateID", -1)); - UNUSED(entry.displayName = tableData.getStringField("displayName", "")); + UNUSED_COLUMN(ntry.description = tableData.getStringField(4, "")); + UNUSED_COLUMN(entry.localize = tableData.getIntField("localize", -1)); + UNUSED_COLUMN(entry.npcTemplateID = tableData.getIntField("npcTemplateID", -1)); + UNUSED_COLUMN(entry.displayName = tableData.getStringField("displayName", "")); entry.interactionDistance = tableData.getFloatField("interactionDistance", -1.0f); - UNUSED(entry.nametag = tableData.getIntField("nametag", -1)); - UNUSED(entry._internalNotes = tableData.getStringField("_internalNotes", "")); - UNUSED(entry.locStatus = tableData.getIntField("locStatus", -1)); - UNUSED(entry.gate_version = tableData.getStringField("gate_version", "")); - UNUSED(entry.HQ_valid = tableData.getIntField("HQ_valid", -1)); + UNUSED_COLUMN(entry.nametag = tableData.getIntField("nametag", -1)); + UNUSED_COLUMN(entry._internalNotes = tableData.getStringField("_internalNotes", "")); + UNUSED_COLUMN(entry.locStatus = tableData.getIntField("locStatus", -1)); + UNUSED_COLUMN(entry.gate_version = tableData.getStringField("gate_version", "")); + UNUSED_COLUMN(entry.HQ_valid = tableData.getIntField("HQ_valid", -1)); this->entries.insert(std::make_pair(entry.id, entry)); tableData.nextRow(); diff --git a/dDatabase/Tables/CDObjectsTable.h b/dDatabase/Tables/CDObjectsTable.h index 171eddef..dc6cc884 100644 --- a/dDatabase/Tables/CDObjectsTable.h +++ b/dDatabase/Tables/CDObjectsTable.h @@ -6,18 +6,18 @@ struct CDObjects { unsigned int id; //!< The LOT of the object std::string name; //!< The internal name of the object - UNUSED(unsigned int placeable); //!< Whether or not the object is placable + UNUSED_COLUMN(unsigned int placeable); //!< Whether or not the object is placable std::string type; //!< The object type - UNUSED(std::string description); //!< An internal description of the object - UNUSED(unsigned int localize); //!< Whether or not the object should localize - UNUSED(unsigned int npcTemplateID); //!< Something related to NPCs... - UNUSED(std::string displayName); //!< The display name of the object + UNUSED_COLUMN(std::string description); //!< An internal description of the object + UNUSED_COLUMN(unsigned int localize); //!< Whether or not the object should localize + UNUSED_COLUMN(unsigned int npcTemplateID); //!< Something related to NPCs... + UNUSED_COLUMN(std::string displayName); //!< The display name of the object float interactionDistance; //!< The interaction distance of the object - UNUSED(unsigned int nametag); //!< ??? - UNUSED(std::string _internalNotes); //!< Some internal notes (rarely used) - UNUSED(unsigned int locStatus); //!< ??? - UNUSED(std::string gate_version); //!< The gate version for the object - UNUSED(unsigned int HQ_valid); //!< Probably used for the Nexus HQ database on LEGOUniverse.com + UNUSED_COLUMN(unsigned int nametag); //!< ??? + UNUSED_COLUMN(std::string _internalNotes); //!< Some internal notes (rarely used) + UNUSED_COLUMN(unsigned int locStatus); //!< ??? + UNUSED_COLUMN(std::string gate_version); //!< The gate version for the object + UNUSED_COLUMN(unsigned int HQ_valid); //!< Probably used for the Nexus HQ database on LEGOUniverse.com }; class CDObjectsTable : public CDTable { diff --git a/dDatabase/Tables/CDPhysicsComponentTable.cpp b/dDatabase/Tables/CDPhysicsComponentTable.cpp index bb21ed7f..8c705f5b 100644 --- a/dDatabase/Tables/CDPhysicsComponentTable.cpp +++ b/dDatabase/Tables/CDPhysicsComponentTable.cpp @@ -7,19 +7,19 @@ CDPhysicsComponentTable::CDPhysicsComponentTable(void) { entry->id = tableData.getIntField("id", -1); entry->bStatic = tableData.getIntField("static", -1) != 0; entry->physicsAsset = tableData.getStringField("physics_asset", ""); - UNUSED(entry->jump = tableData.getIntField("jump", -1) != 0); - UNUSED(entry->doublejump = tableData.getIntField("doublejump", -1) != 0); + UNUSED_COLUMN(entry->jump = tableData.getIntField("jump", -1) != 0); + UNUSED_COLUMN(entry->doublejump = tableData.getIntField("doublejump", -1) != 0); entry->speed = 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->playerRadius = tableData.getFloatField("playerRadius"); entry->pcShapeType = tableData.getIntField("pcShapeType"); entry->collisionGroup = tableData.getIntField("collisionGroup"); - UNUSED(entry->airSpeed = tableData.getFloatField("airSpeed")); - UNUSED(entry->boundaryAsset = tableData.getStringField("boundaryAsset")); - UNUSED(entry->jumpAirSpeed = tableData.getFloatField("jumpAirSpeed")); - UNUSED(entry->friction = tableData.getFloatField("friction")); - UNUSED(entry->gravityVolumeAsset = tableData.getStringField("gravityVolumeAsset")); + UNUSED_COLUMN(entry->airSpeed = tableData.getFloatField("airSpeed")); + UNUSED_COLUMN(entry->boundaryAsset = tableData.getStringField("boundaryAsset")); + UNUSED_COLUMN(entry->jumpAirSpeed = tableData.getFloatField("jumpAirSpeed")); + UNUSED_COLUMN(entry->friction = tableData.getFloatField("friction")); + UNUSED_COLUMN(entry->gravityVolumeAsset = tableData.getStringField("gravityVolumeAsset")); m_entries.insert(std::make_pair(entry->id, entry)); tableData.nextRow(); diff --git a/dDatabase/Tables/CDPhysicsComponentTable.h b/dDatabase/Tables/CDPhysicsComponentTable.h index e63d337d..ee4dddc1 100644 --- a/dDatabase/Tables/CDPhysicsComponentTable.h +++ b/dDatabase/Tables/CDPhysicsComponentTable.h @@ -6,19 +6,19 @@ struct CDPhysicsComponent { int id; bool bStatic; std::string physicsAsset; - UNUSED(bool jump); - UNUSED(bool doublejump); + UNUSED_COLUMN(bool jump); + UNUSED_COLUMN(bool doublejump); float speed; - UNUSED(float rotSpeed); + UNUSED_COLUMN(float rotSpeed); float playerHeight; float playerRadius; int pcShapeType; int collisionGroup; - UNUSED(float airSpeed); - UNUSED(std::string boundaryAsset); - UNUSED(float jumpAirSpeed); - UNUSED(float friction); - UNUSED(std::string gravityVolumeAsset); + UNUSED_COLUMN(float airSpeed); + UNUSED_COLUMN(std::string boundaryAsset); + UNUSED_COLUMN(float jumpAirSpeed); + UNUSED_COLUMN(float friction); + UNUSED_COLUMN(std::string gravityVolumeAsset); }; class CDPhysicsComponentTable : public CDTable { diff --git a/dDatabase/Tables/CDSkillBehaviorTable.cpp b/dDatabase/Tables/CDSkillBehaviorTable.cpp index c5df78ef..8420a8c6 100644 --- a/dDatabase/Tables/CDSkillBehaviorTable.cpp +++ b/dDatabase/Tables/CDSkillBehaviorTable.cpp @@ -24,24 +24,24 @@ CDSkillBehaviorTable::CDSkillBehaviorTable(void) { while (!tableData.eof()) { CDSkillBehavior entry; entry.skillID = tableData.getIntField("skillID", -1); - UNUSED(entry.locStatus = tableData.getIntField("locStatus", -1)); + UNUSED_COLUMN(entry.locStatus = tableData.getIntField("locStatus", -1)); entry.behaviorID = tableData.getIntField("behaviorID", -1); entry.imaginationcost = tableData.getIntField("imaginationcost", -1); entry.cooldowngroup = tableData.getIntField("cooldowngroup", -1); entry.cooldown = tableData.getFloatField("cooldown", -1.0f); - UNUSED(entry.isNpcEditor = tableData.getIntField("isNpcEditor", -1) == 1 ? true : false); - UNUSED(entry.skillIcon = tableData.getIntField("skillIcon", -1)); - UNUSED(entry.oomSkillID = tableData.getStringField("oomSkillID", "")); - UNUSED(entry.oomBehaviorEffectID = tableData.getIntField("oomBehaviorEffectID", -1)); - UNUSED(entry.castTypeDesc = tableData.getIntField("castTypeDesc", -1)); - UNUSED(entry.imBonusUI = tableData.getIntField("imBonusUI", -1)); - UNUSED(entry.lifeBonusUI = tableData.getIntField("lifeBonusUI", -1)); - UNUSED(entry.armorBonusUI = tableData.getIntField("armorBonusUI", -1)); - UNUSED(entry.damageUI = tableData.getIntField("damageUI", -1)); - UNUSED(entry.hideIcon = tableData.getIntField("hideIcon", -1) == 1 ? true : false); - UNUSED(entry.localize = tableData.getIntField("localize", -1) == 1 ? true : false); - UNUSED(entry.gate_version = tableData.getStringField("gate_version", "")); - UNUSED(entry.cancelType = tableData.getIntField("cancelType", -1)); + UNUSED_COLUMN(entry.isNpcEditor = tableData.getIntField("isNpcEditor", -1) == 1 ? true : false); + UNUSED_COLUMN(entry.skillIcon = tableData.getIntField("skillIcon", -1)); + UNUSED_COLUMN(entry.oomSkillID = tableData.getStringField("oomSkillID", "")); + UNUSED_COLUMN(entry.oomBehaviorEffectID = tableData.getIntField("oomBehaviorEffectID", -1)); + UNUSED_COLUMN(entry.castTypeDesc = tableData.getIntField("castTypeDesc", -1)); + UNUSED_COLUMN(entry.imBonusUI = tableData.getIntField("imBonusUI", -1)); + UNUSED_COLUMN(entry.lifeBonusUI = tableData.getIntField("lifeBonusUI", -1)); + UNUSED_COLUMN(entry.armorBonusUI = tableData.getIntField("armorBonusUI", -1)); + UNUSED_COLUMN(entry.damageUI = tableData.getIntField("damageUI", -1)); + UNUSED_COLUMN(entry.hideIcon = tableData.getIntField("hideIcon", -1) == 1 ? true : false); + UNUSED_COLUMN(entry.localize = tableData.getIntField("localize", -1) == 1 ? true : false); + UNUSED_COLUMN(entry.gate_version = tableData.getStringField("gate_version", "")); + UNUSED_COLUMN(entry.cancelType = tableData.getIntField("cancelType", -1)); this->entries.insert(std::make_pair(entry.skillID, entry)); //this->entries.push_back(entry); diff --git a/dDatabase/Tables/CDSkillBehaviorTable.h b/dDatabase/Tables/CDSkillBehaviorTable.h index eb3094e0..4e6bddb9 100644 --- a/dDatabase/Tables/CDSkillBehaviorTable.h +++ b/dDatabase/Tables/CDSkillBehaviorTable.h @@ -5,24 +5,24 @@ struct CDSkillBehavior { unsigned int skillID; //!< The Skill ID of the skill - UNUSED(unsigned int locStatus); //!< ?? + UNUSED_COLUMN(unsigned int locStatus); //!< ?? unsigned int behaviorID; //!< The Behavior ID of the skill unsigned int imaginationcost; //!< The imagination cost of the skill unsigned int cooldowngroup; //!< The cooldown group ID of the skill float cooldown; //!< The cooldown time of the skill - UNUSED(bool isNpcEditor); //!< ??? - UNUSED(unsigned int skillIcon); //!< The Skill Icon ID - UNUSED(std::string oomSkillID); //!< ??? - UNUSED(unsigned int oomBehaviorEffectID); //!< ??? - UNUSED(unsigned int castTypeDesc); //!< The cast type description(?) - UNUSED(unsigned int imBonusUI); //!< The imagination bonus of the skill - UNUSED(nsigned int lifeBonusUI); //!< The life bonus of the skill - UNUSED(unsigned int armorBonusUI); //!< The armor bonus of the skill - UNUSED(unsigned int damageUI); //!< ??? - UNUSED(bool hideIcon); //!< Whether or not to show the icon - UNUSED(bool localize); //!< ??? - UNUSED(std::string gate_version); //!< ??? - UNUSED(unsigned int cancelType); //!< The cancel type (?) + UNUSED_COLUMN(bool isNpcEditor); //!< ??? + UNUSED_COLUMN(unsigned int skillIcon); //!< The Skill Icon ID + UNUSED_COLUMN(std::string oomSkillID); //!< ??? + UNUSED_COLUMN(unsigned int oomBehaviorEffectID); //!< ??? + UNUSED_COLUMN(unsigned int castTypeDesc); //!< The cast type description(?) + UNUSED_COLUMN(unsigned int imBonusUI); //!< The imagination bonus of the skill + UNUSED_COLUMN(nsigned int lifeBonusUI); //!< The life bonus of the skill + UNUSED_COLUMN(unsigned int armorBonusUI); //!< The armor bonus of the skill + UNUSED_COLUMN(unsigned int damageUI); //!< ??? + UNUSED_COLUMN(bool hideIcon); //!< Whether or not to show the icon + UNUSED_COLUMN(bool localize); //!< ??? + UNUSED_COLUMN(std::string gate_version); //!< ??? + UNUSED_COLUMN(unsigned int cancelType); //!< The cancel type (?) }; class CDSkillBehaviorTable : public CDTable { diff --git a/dDatabase/Tables/CDTable.h b/dDatabase/Tables/CDTable.h index fca16eb8..45c67b0d 100644 --- a/dDatabase/Tables/CDTable.h +++ b/dDatabase/Tables/CDTable.h @@ -2,6 +2,7 @@ #include "CDClientDatabase.h" #include "Singleton.h" +#include "DluAssert.h" #include #include @@ -15,6 +16,9 @@ #endif #include "cpplinq.hpp" +// Enable this to skip some unused columns in some tables +#define UNUSED_COLUMN(v) + #pragma warning (disable : 4244) //Disable double to float conversion warnings #pragma warning (disable : 4715) //Disable "not all control paths return a value" @@ -23,3 +27,15 @@ class CDTable : public Singleton { protected: virtual ~CDTable() = default; }; + +template +class LookupResult { + typedef std::pair DataType; +public: + LookupResult() { m_data.first = T(); m_data.second = false; }; + LookupResult(T& data) { m_data.first = data; m_data.second = true; }; + inline const T& Data() { return m_data.first; }; + inline const bool& FoundData() { return m_data.second; }; +private: + DataType m_data; +}; diff --git a/dDatabase/Tables/CDZoneTableTable.cpp b/dDatabase/Tables/CDZoneTableTable.cpp index bafbf8fe..89158dd7 100644 --- a/dDatabase/Tables/CDZoneTableTable.cpp +++ b/dDatabase/Tables/CDZoneTableTable.cpp @@ -26,25 +26,25 @@ CDZoneTableTable::CDZoneTableTable(void) { entry.ghostdistance = tableData.getFloatField("ghostdistance", -1.0f); entry.population_soft_cap = tableData.getIntField("population_soft_cap", -1); entry.population_hard_cap = tableData.getIntField("population_hard_cap", -1); - UNUSED(entry.DisplayDescription = tableData.getStringField("DisplayDescription", "")); - UNUSED(entry.mapFolder = tableData.getStringField("mapFolder", "")); + UNUSED_COLUMN(entry.DisplayDescription = tableData.getStringField("DisplayDescription", "")); + UNUSED_COLUMN(entry.mapFolder = tableData.getStringField("mapFolder", "")); entry.smashableMinDistance = tableData.getFloatField("smashableMinDistance", -1.0f); entry.smashableMaxDistance = tableData.getFloatField("smashableMaxDistance", -1.0f); - UNUSED(entry.mixerProgram = tableData.getStringField("mixerProgram", "")); - UNUSED(entry.clientPhysicsFramerate = tableData.getStringField("clientPhysicsFramerate", "")); - UNUSED(entry.serverPhysicsFramerate = tableData.getStringField("serverPhysicsFramerate", "")); + UNUSED_COLUMN(entry.mixerProgram = tableData.getStringField("mixerProgram", "")); + UNUSED_COLUMN(entry.clientPhysicsFramerate = tableData.getStringField("clientPhysicsFramerate", "")); + UNUSED_COLUMN(entry.serverPhysicsFramerate = tableData.getStringField("serverPhysicsFramerate", "")); entry.zoneControlTemplate = tableData.getIntField("zoneControlTemplate", -1); entry.widthInChunks = tableData.getIntField("widthInChunks", -1); entry.heightInChunks = tableData.getIntField("heightInChunks", -1); entry.petsAllowed = tableData.getIntField("petsAllowed", -1) == 1 ? true : false; entry.localize = tableData.getIntField("localize", -1) == 1 ? true : false; entry.fZoneWeight = tableData.getFloatField("fZoneWeight", -1.0f); - UNUSED(entry.thumbnail = tableData.getStringField("thumbnail", "")); + UNUSED_COLUMN(entry.thumbnail = tableData.getStringField("thumbnail", "")); entry.PlayerLoseCoinsOnDeath = tableData.getIntField("PlayerLoseCoinsOnDeath", -1) == 1 ? true : false; - UNUSED(entry.disableSaveLoc = tableData.getIntField("disableSaveLoc", -1) == 1 ? true : false); + UNUSED_COLUMN(entry.disableSaveLoc = tableData.getIntField("disableSaveLoc", -1) == 1 ? true : false); entry.teamRadius = tableData.getFloatField("teamRadius", -1.0f); - UNUSED(entry.gate_version = tableData.getStringField("gate_version", "")); - UNUSED(entry.mountsAllowed = tableData.getIntField("mountsAllowed", -1) == 1 ? true : false); + UNUSED_COLUMN(entry.gate_version = tableData.getStringField("gate_version", "")); + UNUSED_COLUMN(entry.mountsAllowed = tableData.getIntField("mountsAllowed", -1) == 1 ? true : false); this->m_Entries.insert(std::make_pair(entry.zoneID, entry)); tableData.nextRow(); diff --git a/dDatabase/Tables/CDZoneTableTable.h b/dDatabase/Tables/CDZoneTableTable.h index f844fd25..e46a87ee 100644 --- a/dDatabase/Tables/CDZoneTableTable.h +++ b/dDatabase/Tables/CDZoneTableTable.h @@ -12,25 +12,25 @@ struct CDZoneTable { float ghostdistance; //!< The ghosting distance unsigned int population_soft_cap; //!< The "soft cap" on the world population unsigned int population_hard_cap; //!< The "hard cap" on the world population - UNUSED(std::string DisplayDescription); //!< The display description of the world - UNUSED(std::string mapFolder); //!< ??? + UNUSED_COLUMN(std::string DisplayDescription); //!< The display description of the world + UNUSED_COLUMN(std::string mapFolder); //!< ??? float smashableMinDistance; //!< The minimum smashable distance? float smashableMaxDistance; //!< The maximum smashable distance? - UNUSED(std::string mixerProgram); //!< ??? - UNUSED(std::string clientPhysicsFramerate); //!< The client physics framerate - UNUSED(std::string serverPhysicsFramerate); //!< The server physics framerate + UNUSED_COLUMN(std::string mixerProgram); //!< ??? + UNUSED_COLUMN(std::string clientPhysicsFramerate); //!< The client physics framerate + UNUSED_COLUMN(std::string serverPhysicsFramerate); //!< The server physics framerate unsigned int zoneControlTemplate; //!< The Zone Control template unsigned int widthInChunks; //!< The width of the world in chunks unsigned int heightInChunks; //!< The height of the world in chunks bool petsAllowed; //!< Whether or not pets are allowed in the world bool localize; //!< Whether or not the world should be localized float fZoneWeight; //!< ??? - UNUSED(std::string thumbnail); //!< The thumbnail of the world + UNUSED_COLUMN(std::string thumbnail); //!< The thumbnail of the world bool PlayerLoseCoinsOnDeath; //!< Whether or not the user loses coins on death - UNUSED(bool disableSaveLoc); //!< Disables the saving location? + UNUSED_COLUMN(bool disableSaveLoc); //!< Disables the saving location? float teamRadius; //!< ??? - UNUSED(std::string gate_version); //!< The gate version - UNUSED(bool mountsAllowed); //!< Whether or not mounts are allowed + UNUSED_COLUMN(std::string gate_version); //!< The gate version + UNUSED_COLUMN(bool mountsAllowed); //!< Whether or not mounts are allowed }; class CDZoneTableTable : public CDTable { diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 13507527..290f4f7e 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -592,8 +592,9 @@ void Entity::Initialize() { m_Components.insert(std::make_pair(eReplicaComponentType::BOUNCER, comp)); } - if ((compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RENDER) > 0 && m_TemplateID != 2365) || m_Character) { - RenderComponent* render = new RenderComponent(this); + int32_t renderaComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::RENDER); + if ((renderaComponentId > 0 && m_TemplateID != 2365) || m_Character) { + RenderComponent* render = new RenderComponent(this, renderaComponentId); m_Components.insert(std::make_pair(eReplicaComponentType::RENDER, render)); } diff --git a/dGame/LeaderboardManager.cpp b/dGame/LeaderboardManager.cpp index d85a95d4..5a4754b9 100644 --- a/dGame/LeaderboardManager.cpp +++ b/dGame/LeaderboardManager.cpp @@ -277,13 +277,11 @@ void LeaderboardManager::SendLeaderboard(uint32_t gameID, InfoType infoType, boo } LeaderboardType LeaderboardManager::GetLeaderboardType(uint32_t gameID) { - auto* activitiesTable = CDClientManager::Instance().GetTable(); - std::vector activities = activitiesTable->Query([=](const CDActivities& entry) { - return (entry.ActivityID == gameID); - }); + CDActivitiesTable* activitiesTable = CDClientManager::Instance().GetTable(); + auto activityResult = activitiesTable->GetActivity(gameID); - for (const auto& activity : activities) { - return static_cast(activity.leaderboardType); + if (activityResult.FoundData()) { + return static_cast(activityResult.Data().leaderboardType); } return LeaderboardType::None; diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index 5549f952..f5b7a1a7 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -22,7 +22,7 @@ #include "Database.h" #include "EntityInfo.h" #include "eMissionTaskType.h" - +#include "RenderComponent.h" std::unordered_map PetComponent::buildCache{}; std::unordered_map PetComponent::currentActivities{}; @@ -525,7 +525,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) { } GameMessages::SendPlayFXEffect(tamer, -1, u"petceleb", "", LWOOBJID_EMPTY, 1, 1, true); - GameMessages::SendPlayAnimation(tamer, u"rebuild-celebrate"); + RenderComponent::PlayAnimation(tamer, u"rebuild-celebrate"); EntityInfo info{}; info.lot = cached->second.puzzleModelLot; diff --git a/dGame/dComponents/RailActivatorComponent.cpp b/dGame/dComponents/RailActivatorComponent.cpp index 49fc105d..2a12caf8 100644 --- a/dGame/dComponents/RailActivatorComponent.cpp +++ b/dGame/dComponents/RailActivatorComponent.cpp @@ -7,6 +7,8 @@ #include "RebuildComponent.h" #include "Game.h" #include "dLogger.h" +#include "RenderComponent.h" +#include "EntityManager.h" RailActivatorComponent::RailActivatorComponent(Entity* parent, int32_t componentID) : Component(parent) { m_ComponentID = componentID; @@ -56,23 +58,10 @@ void RailActivatorComponent::OnUse(Entity* originator) { GameMessages::SendPlayFXEffect(originator->GetObjectID(), m_StartEffect.first, m_StartEffect.second, std::to_string(m_StartEffect.first)); } - + + float animationLength = 0.5f; if (!m_StartAnimation.empty()) { - GameMessages::SendPlayAnimation(originator, m_StartAnimation); - } - - float animationLength; - - if (m_StartAnimation == u"whirlwind-rail-up-earth") { - animationLength = 1.5f; - } else if (m_StartAnimation == u"whirlwind-rail-up-lightning") { - animationLength = 0.5f; - } else if (m_StartAnimation == u"whirlwind-rail-up-ice") { - animationLength = 0.5f; - } else if (m_StartAnimation == u"whirlwind-rail-up-fire") { - animationLength = 0.5f; - } else { - animationLength = 0.5f; + animationLength = RenderComponent::PlayAnimation(originator, m_StartAnimation); } const auto originatorID = originator->GetObjectID(); @@ -111,7 +100,7 @@ void RailActivatorComponent::OnRailMovementReady(Entity* originator) const { } if (!m_LoopAnimation.empty()) { - GameMessages::SendPlayAnimation(originator, m_LoopAnimation); + RenderComponent::PlayAnimation(originator, m_LoopAnimation); } GameMessages::SendSetRailMovement(originator->GetObjectID(), m_PathDirection, m_Path, m_PathStart, @@ -146,7 +135,7 @@ void RailActivatorComponent::OnCancelRailMovement(Entity* originator) { } if (!m_StopAnimation.empty()) { - GameMessages::SendPlayAnimation(originator, m_StopAnimation); + RenderComponent::PlayAnimation(originator, m_StopAnimation); } // Remove the player after they've signalled they're done railing diff --git a/dGame/dComponents/RebuildComponent.cpp b/dGame/dComponents/RebuildComponent.cpp index abd21873..f0b39346 100644 --- a/dGame/dComponents/RebuildComponent.cpp +++ b/dGame/dComponents/RebuildComponent.cpp @@ -16,6 +16,7 @@ #include "Preconditions.h" #include "Loot.h" #include "TeamManager.h" +#include "RenderComponent.h" #include "CppScripts.h" @@ -510,7 +511,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) { character->SetPlayerFlag(flagNumber, true); } } - GameMessages::SendPlayAnimation(user, u"rebuild-celebrate", 1.09f); + RenderComponent::PlayAnimation(user, u"rebuild-celebrate", 1.09f); } void RebuildComponent::ResetRebuild(bool failed) { @@ -520,7 +521,7 @@ void RebuildComponent::ResetRebuild(bool failed) { GameMessages::SendEnableRebuild(m_Parent, false, false, failed, eFailReason::REASON_NOT_GIVEN, m_ResetTime, builder->GetObjectID()); if (failed) { - GameMessages::SendPlayAnimation(builder, u"rebuild-fail"); + RenderComponent::PlayAnimation(builder, u"rebuild-fail"); } } diff --git a/dGame/dComponents/RenderComponent.cpp b/dGame/dComponents/RenderComponent.cpp index ee42acba..bccd6207 100644 --- a/dGame/dComponents/RenderComponent.cpp +++ b/dGame/dComponents/RenderComponent.cpp @@ -11,72 +11,34 @@ #include "GameMessages.h" #include "Game.h" #include "dLogger.h" +#include "CDAnimationsTable.h" std::unordered_map RenderComponent::m_DurationCache{}; -RenderComponent::RenderComponent(Entity* parent) : Component(parent) { +RenderComponent::RenderComponent(Entity* parent, int32_t componentId): Component(parent) { m_Effects = std::vector(); + m_LastAnimationName = ""; + auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM RenderComponent WHERE id = ?;"); + query.bind(1, componentId); + auto result = query.execQuery(); - return; - - /* - auto* table = CDClientManager::Instance().GetTable(); - - const auto entry = table->GetByIDAndType(parent->GetLOT(), eReplicaComponentType::RENDER); - - std::stringstream query; - - query << "SELECT effect1, effect2, effect3, effect4, effect5, effect6 FROM RenderComponent WHERE id = " << std::to_string(entry) << ";"; - - auto result = CDClientDatabase::ExecuteQuery(query.str()); - - if (result.eof()) - { - return; - } - - for (auto i = 0; i < 6; ++i) - { - if (result.fieldIsNull(i)) - { - continue; - } - - const auto id = result.getIntField(i); - - if (id <= 0) - { - continue; - } - - query.clear(); - - query << "SELECT effectType, effectName FROM BehaviorEffect WHERE effectID = " << std::to_string(id) << ";"; - - auto effectResult = CDClientDatabase::ExecuteQuery(query.str()); - - while (!effectResult.eof()) - { - const auto type = effectResult.fieldIsNull(0) ? "" : std::string(effectResult.getStringField(0)); - - const auto name = effectResult.fieldIsNull(1) ? "" : std::string(effectResult.getStringField(1)); - - auto* effect = new Effect(); - - effect->name = name; - effect->type = GeneralUtils::ASCIIToUTF16(type); - effect->scale = 1; - effect->effectID = id; - effect->secondary = LWOOBJID_EMPTY; - - m_Effects.push_back(effect); - - effectResult.nextRow(); + if (!result.eof()) { + auto animationGroupIDs = std::string(result.getStringField("animationGroupIDs", "")); + if (!animationGroupIDs.empty()) { + auto* animationsTable = CDClientManager::Instance().GetTable(); + auto groupIdsSplit = GeneralUtils::SplitString(animationGroupIDs, ','); + for (auto& groupId : groupIdsSplit) { + int32_t groupIdInt; + if (!GeneralUtils::TryParse(groupId, groupIdInt)) { + Game::logger->Log("RenderComponent", "bad animation group Id %s", groupId.c_str()); + continue; + } + m_animationGroupIds.push_back(groupIdInt); + animationsTable->CacheAnimationGroup(groupIdInt); + } } } - result.finalize(); - */ } RenderComponent::~RenderComponent() { @@ -224,3 +186,47 @@ void RenderComponent::StopEffect(const std::string& name, const bool killImmedia std::vector& RenderComponent::GetEffects() { return m_Effects; } + + +float RenderComponent::PlayAnimation(Entity* self, const std::u16string& animation, float priority, float scale) { + if (!self) return 0.0f; + return RenderComponent::PlayAnimation(self, GeneralUtils::UTF16ToWTF8(animation), priority, scale); +} + +float RenderComponent::PlayAnimation(Entity* self, const std::string& animation, float priority, float scale) { + if (!self) return 0.0f; + return RenderComponent::DoAnimation(self, animation, true, priority, scale); +} + +float RenderComponent::GetAnimationTime(Entity* self, const std::u16string& animation) { + if (!self) return 0.0f; + return RenderComponent::GetAnimationTime(self, GeneralUtils::UTF16ToWTF8(animation)); +} + +float RenderComponent::GetAnimationTime(Entity* self, const std::string& animation) { + if (!self) return 0.0f; + return RenderComponent::DoAnimation(self, animation, false); +} + + +float RenderComponent::DoAnimation(Entity* self, const std::string& animation, bool sendAnimation, float priority, float scale) { + if (!self) return 0.0f; + auto* renderComponent = self->GetComponent(); + if (!renderComponent) return 0.0f; + + Game::logger->Log("RenderComponent", "looking up animation %s playing anim %i priority %f scale %f", animation.c_str(), sendAnimation, priority, scale); + auto* animationsTable = CDClientManager::Instance().GetTable(); + for (auto& groupId : renderComponent->m_animationGroupIds) { + Game::logger->Log("RenderComponent", "checking id %i with previous being %s", groupId, renderComponent->GetLastAnimationName().c_str()); + auto animationGroup = animationsTable->GetAnimation(animation, renderComponent->GetLastAnimationName(), groupId); + if (animationGroup.FoundData()) { + auto data = animationGroup.Data(); + Game::logger->Log("RenderComponent", "animation %s priority %f length %f", data.animation_name.c_str(), data.priority, data.animation_length); + if (sendAnimation) GameMessages::SendPlayAnimation(self, GeneralUtils::ASCIIToUTF16(animation), priority, scale); + renderComponent->SetLastAnimationName(data.animation_name); + return data.animation_length; + } + } + Game::logger->Log("RenderComponent", "unable to find animation %s for lot %i", animation.c_str(), self->GetLOT()); + return 0.0f; +} diff --git a/dGame/dComponents/RenderComponent.h b/dGame/dComponents/RenderComponent.h index de8b2907..ef916396 100644 --- a/dGame/dComponents/RenderComponent.h +++ b/dGame/dComponents/RenderComponent.h @@ -58,7 +58,7 @@ class RenderComponent : public Component { public: static const eReplicaComponentType ComponentType = eReplicaComponentType::RENDER; - RenderComponent(Entity* entity); + RenderComponent(Entity* entity, int32_t componentId = -1); ~RenderComponent() override; void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); @@ -104,6 +104,16 @@ public: */ std::vector& GetEffects(); + static float DoAnimation(Entity* self, const std::string& animation, bool sendAnimation, float priority = 0.0f, float scale = 1.0f); + + static float PlayAnimation(Entity* self, const std::u16string& animation, float priority = 0.0f, float scale = 1.0f); + static float PlayAnimation(Entity* self, const std::string& animation, float priority = 0.0f, float scale = 1.0f); + static float GetAnimationTime(Entity* self, const std::string& animation); + static float GetAnimationTime(Entity* self, const std::u16string& animation); + + const std::string& GetLastAnimationName() const { return m_LastAnimationName; }; + void SetLastAnimationName(const std::string& name) { m_LastAnimationName = name; }; + private: /** @@ -111,6 +121,11 @@ private: */ std::vector m_Effects; + std::vector m_animationGroupIds; + + // The last animationName that was played + std::string m_LastAnimationName; + /** * Cache of queries that look for the length of each effect, indexed by effect ID */ diff --git a/dGame/dComponents/ScriptedActivityComponent.cpp b/dGame/dComponents/ScriptedActivityComponent.cpp index bafa1faa..d6700ab2 100644 --- a/dGame/dComponents/ScriptedActivityComponent.cpp +++ b/dGame/dComponents/ScriptedActivityComponent.cpp @@ -26,13 +26,13 @@ #include "CDActivityRewardsTable.h" #include "CDActivitiesTable.h" -ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activityID) : Component(parent) { +ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activityID): Component(parent) { m_ActivityID = activityID; CDActivitiesTable* activitiesTable = CDClientManager::Instance().GetTable(); - std::vector activities = activitiesTable->Query([=](CDActivities entry) {return (entry.ActivityID == m_ActivityID); }); + auto activityResult = activitiesTable->GetActivity(m_ActivityID); - for (CDActivities activity : activities) { - m_ActivityInfo = activity; + if (activityResult.FoundData()) { + m_ActivityInfo = activityResult.Data(); const auto mapID = m_ActivityInfo.instanceMapID; @@ -57,6 +57,7 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit if (destroyableComponent) { // check for LMIs and set the loot LMIs + Game::logger->Log("ScriptedActivityComponent", "i am %i with lmi %i", m_Parent->GetLOT(), destroyableComponent->GetLootMatrixID()); CDActivityRewardsTable* activityRewardsTable = CDClientManager::Instance().GetTable(); std::vector activityRewards = activityRewardsTable->Query([=](CDActivityRewards entry) {return (entry.LootMatrixIndex == destroyableComponent->GetLootMatrixID()); }); @@ -64,13 +65,13 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit if (activityRewards.size() > 0) { startingLMI = activityRewards[0].LootMatrixIndex; + Game::logger->Log("ScriptedActivityComponent", "index 0 is %i %i", activityRewards[0].LootMatrixIndex, activityRewards[0].objectTemplate); } if (startingLMI > 0) { - // now time for bodge :) - std::vector objectTemplateActivities = activityRewardsTable->Query([=](CDActivityRewards entry) {return (activityRewards[0].objectTemplate == entry.objectTemplate); }); for (const auto& item : objectTemplateActivities) { + Game::logger->Log("ScriptedActivityComponent", "%i added loot matrix with rating %i index %i objectTemplate %i", m_Parent->GetLOT(), item.activityRating, item.LootMatrixIndex, item.objectTemplate); if (item.activityRating > 0 && item.activityRating < 5) { m_ActivityLootMatrices.insert({ item.activityRating, item.LootMatrixIndex }); } @@ -99,21 +100,22 @@ void ScriptedActivityComponent::Serialize(RakNet::BitStream* outBitStream, bool void ScriptedActivityComponent::ReloadConfig() { CDActivitiesTable* activitiesTable = CDClientManager::Instance().GetTable(); - std::vector activities = activitiesTable->Query([=](CDActivities entry) {return (entry.ActivityID == m_ActivityID); }); - for (auto activity : activities) { - auto mapID = m_ActivityInfo.instanceMapID; + auto activityResult = activitiesTable->GetActivity(m_ActivityID); + if (activityResult.FoundData()) { + auto data = activityResult.Data(); + auto mapID = data.instanceMapID; if ((mapID == 1203 || mapID == 1261 || mapID == 1303 || mapID == 1403) && Game::config->GetValue("solo_racing") == "1") { m_ActivityInfo.minTeamSize = 1; m_ActivityInfo.minTeams = 1; } else { - m_ActivityInfo.minTeamSize = activity.minTeamSize; - m_ActivityInfo.minTeams = activity.minTeams; + m_ActivityInfo.minTeamSize = data.minTeamSize; + m_ActivityInfo.minTeams = data.minTeams; } } } void ScriptedActivityComponent::HandleMessageBoxResponse(Entity* player, const std::string& id) { - if (m_ActivityInfo.ActivityID == 103) { + if (m_ActivityID == 103) { return; } @@ -125,7 +127,7 @@ void ScriptedActivityComponent::HandleMessageBoxResponse(Entity* player, const s } void ScriptedActivityComponent::PlayerJoin(Entity* player) { - if (m_ActivityInfo.ActivityID == 103 || PlayerIsInQueue(player) || !IsValidActivity(player)) { + if (m_ActivityID == 103 || PlayerIsInQueue(player) || !IsValidActivity(player)) { return; } @@ -390,7 +392,7 @@ void ScriptedActivityComponent::PlayerReady(Entity* player, bool bReady) { } ActivityInstance* ScriptedActivityComponent::NewInstance() { - auto* instance = new ActivityInstance(m_Parent, m_ActivityInfo); + auto* instance = new ActivityInstance(m_Parent, this, m_ActivityInfo); m_Instances.push_back(instance); return instance; } @@ -557,12 +559,12 @@ void ActivityInstance::StartZone() { void ActivityInstance::RewardParticipant(Entity* participant) { auto* missionComponent = participant->GetComponent(); if (missionComponent) { - missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityInfo.ActivityID); + missionComponent->Progress(eMissionTaskType::ACTIVITY, m_OwningComponent->GetActivityID()); } // First, get the activity data auto* activityRewardsTable = CDClientManager::Instance().GetTable(); - std::vector activityRewards = activityRewardsTable->Query([=](CDActivityRewards entry) { return (entry.objectTemplate == m_ActivityInfo.ActivityID); }); + std::vector activityRewards = activityRewardsTable->Query([=](CDActivityRewards entry) { return (entry.objectTemplate == m_OwningComponent->GetActivityID()); }); if (!activityRewards.empty()) { uint32_t minCoins = 0; diff --git a/dGame/dComponents/ScriptedActivityComponent.h b/dGame/dComponents/ScriptedActivityComponent.h index 1d49a62d..84ac0bc2 100644 --- a/dGame/dComponents/ScriptedActivityComponent.h +++ b/dGame/dComponents/ScriptedActivityComponent.h @@ -15,13 +15,18 @@ #include "CDActivitiesTable.h" +class ScriptedActivityComponent; + /** * Represents an instance of an activity, having participants and score */ class ActivityInstance { public: - ActivityInstance(Entity* parent, CDActivities activityInfo) { m_Parent = parent; m_ActivityInfo = activityInfo; }; - //~ActivityInstance(); + ActivityInstance(Entity* parent, ScriptedActivityComponent* parentComponent, CDActivities activityInfo) { + m_Parent = parent; + m_OwningComponent = parentComponent; + m_ActivityInfo = activityInfo; + }; /** * Adds an entity to this activity @@ -88,6 +93,11 @@ private: */ Entity* m_Parent; + /** + * The component that owns this activity (the ScriptedActivityComponent) + */ + ScriptedActivityComponent* m_OwningComponent; + /** * All the participants of this activity */ @@ -212,7 +222,7 @@ public: * Returns the ID of this activity * @return the ID of this activity */ - int GetActivityID() { return m_ActivityInfo.ActivityID; } + int GetActivityID() { return m_ActivityID; } /** * Returns if this activity has a lobby, e.g. if it needs to instance players to some other map diff --git a/dGame/dComponents/SwitchComponent.cpp b/dGame/dComponents/SwitchComponent.cpp index dbdf37a9..d2c1dd50 100644 --- a/dGame/dComponents/SwitchComponent.cpp +++ b/dGame/dComponents/SwitchComponent.cpp @@ -1,6 +1,7 @@ #include "SwitchComponent.h" #include "EntityManager.h" #include "eTriggerEventType.h" +#include "RenderComponent.h" std::vector SwitchComponent::petSwitches; @@ -59,7 +60,7 @@ void SwitchComponent::EntityEnter(Entity* entity) { if (m_PetBouncer != nullptr) { GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), 2602, u"pettriggeractive", "BounceEffect", LWOOBJID_EMPTY, 1, 1, true); - GameMessages::SendPlayAnimation(m_Parent, u"engaged", 0, 1); + RenderComponent::PlayAnimation(m_Parent, u"engaged"); m_PetBouncer->SetPetBouncerEnabled(true); } else { EntityManager::Instance()->SerializeEntity(m_Parent); diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 33a7f104..062fece7 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -34,6 +34,7 @@ #include "eRacingTaskParam.h" #include "eMissionTaskType.h" #include "eMissionState.h" +#include "RenderComponent.h" #include #include @@ -5110,7 +5111,7 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity) if (emote) sAnimationName = emote->animationName; } - GameMessages::SendPlayAnimation(entity, GeneralUtils::ASCIIToUTF16(sAnimationName)); + RenderComponent::PlayAnimation(entity, sAnimationName); } void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { diff --git a/dGame/dUtilities/Loot.cpp b/dGame/dUtilities/Loot.cpp index da0f2487..d1f30e41 100644 --- a/dGame/dUtilities/Loot.cpp +++ b/dGame/dUtilities/Loot.cpp @@ -17,6 +17,7 @@ #include "MissionComponent.h" #include "eMissionState.h" #include "eReplicaComponentType.h" +#include "Metrics.hpp" LootGenerator::LootGenerator() { CDLootTableTable* lootTableTable = CDClientManager::Instance().GetTable(); diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index 0278136b..d426ac12 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -76,6 +76,7 @@ #include "TriggerComponent.h" #include "eServerDisconnectIdentifiers.h" #include "eReplicaComponentType.h" +#include "RenderComponent.h" #include "CDObjectsTable.h" #include "CDZoneTableTable.h" @@ -418,11 +419,11 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if ((chatCommand == "playanimation" || chatCommand == "playanim") && args.size() == 1 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) { std::u16string anim = GeneralUtils::ASCIIToUTF16(args[0], args[0].size()); - GameMessages::SendPlayAnimation(entity, anim); + RenderComponent::PlayAnimation(entity, anim); auto* possessorComponent = entity->GetComponent(); if (possessorComponent) { auto* possessedComponent = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable()); - if (possessedComponent) GameMessages::SendPlayAnimation(possessedComponent, anim); + if (possessedComponent) RenderComponent::PlayAnimation(possessedComponent, anim); } } @@ -1955,7 +1956,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit EntityManager::Instance()->SerializeEntity(closest); } else if (args[1] == "-a" && args.size() >= 3) { - GameMessages::SendPlayAnimation(closest, GeneralUtils::UTF8ToUTF16(args[2])); + RenderComponent::PlayAnimation(closest, args.at(2)); } else if (args[1] == "-s") { for (auto* entry : closest->GetSettings()) { ChatPackets::SendSystemMessage(sysAddr, GeneralUtils::UTF8ToUTF16(entry->GetString())); diff --git a/dMasterServer/MasterServer.cpp b/dMasterServer/MasterServer.cpp index cc2bdd90..7bb70391 100644 --- a/dMasterServer/MasterServer.cpp +++ b/dMasterServer/MasterServer.cpp @@ -49,6 +49,7 @@ namespace Game { dConfig* config = nullptr; AssetManager* assetManager = nullptr; bool shouldShutdown = false; + std::mt19937 randomEngine; } //namespace Game bool shutdownSequenceStarted = false; @@ -290,6 +291,7 @@ int main(int argc, char** argv) { return EXIT_SUCCESS; } + Game::randomEngine = std::mt19937(time(0)); uint32_t maxClients = 999; uint32_t ourPort = 1000; if (Game::config->GetValue("max_clients") != "") maxClients = std::stoi(Game::config->GetValue("max_clients")); @@ -332,8 +334,7 @@ int main(int argc, char** argv) { if (Game::config->GetValue("prestart_servers") != "" && Game::config->GetValue("prestart_servers") == "1") { StartChatServer(); - Game::im->GetInstance(0, false, 0); - Game::im->GetInstance(1000, false, 0); + Game::im->GetInstance(1800, false, 0); StartAuthServer(); } diff --git a/dScripts/02_server/DLU/DLUVanityNPC.cpp b/dScripts/02_server/DLU/DLUVanityNPC.cpp index e3db2353..ba2c6604 100644 --- a/dScripts/02_server/DLU/DLUVanityNPC.cpp +++ b/dScripts/02_server/DLU/DLUVanityNPC.cpp @@ -2,6 +2,7 @@ #include "GameMessages.h" #include "dServer.h" #include "VanityUtilities.h" +#include "RenderComponent.h" void DLUVanityNPC::OnStartup(Entity* self) { m_NPC = VanityUtilities::GetNPC("averysumner - Destroyer of Worlds"); @@ -17,7 +18,7 @@ void DLUVanityNPC::OnStartup(Entity* self) { void DLUVanityNPC::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "setupTeleport") { - GameMessages::SendPlayAnimation(self, u"interact"); + RenderComponent::PlayAnimation(self, u"interact"); GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportBeam", "teleportBeam"); GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportRings", "teleportRings"); diff --git a/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp b/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp index c584f05b..aa04f571 100644 --- a/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp +++ b/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp @@ -14,6 +14,7 @@ #include "GameMessages.h" #include "SkillComponent.h" #include "eReplicaComponentType.h" +#include "RenderComponent.h" #include @@ -695,11 +696,11 @@ float BossSpiderQueenEnemyServer::PlayAnimAndReturnTime(Entity* self, const std: //TODO: Get the actual animation time // Get the anim time - float animTimer = defaultAnimPause; //self:GetAnimationTime{animationID = animID}.time + float animTimer = RenderComponent::GetAnimationTime(self, animID); // If we have an animation play it if (animTimer > 0) { - GameMessages::SendPlayAnimation(self, animID); + animTimer = RenderComponent::PlayAnimation(self, animID); } // If the anim time is less than the the default time use default diff --git a/dScripts/02_server/Enemy/AM/AmDarklingDragon.cpp b/dScripts/02_server/Enemy/AM/AmDarklingDragon.cpp index 28ba0044..0ee5431b 100644 --- a/dScripts/02_server/Enemy/AM/AmDarklingDragon.cpp +++ b/dScripts/02_server/Enemy/AM/AmDarklingDragon.cpp @@ -7,6 +7,7 @@ #include "BaseCombatAIComponent.h" #include "EntityInfo.h" #include "eAninmationFlags.h" +#include "RenderComponent.h" void AmDarklingDragon::OnStartup(Entity* self) { self->SetVar(u"weakspot", 0); @@ -70,9 +71,9 @@ void AmDarklingDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t self->SetVar(u"weakpoint", 2); GameMessages::SendChangeIdleFlags(self->GetObjectID(), eAnimationFlags::IDLE_NONE, eAnimationFlags::IDLE_COMBAT, UNASSIGNED_SYSTEM_ADDRESS); - GameMessages::SendPlayAnimation(self, u"stunstart", 1.7f); + float animationTime = RenderComponent::PlayAnimation(self, u"stunstart", 1.7f); - self->AddTimer("timeToStunLoop", 1); + self->AddTimer("timeToStunLoop", animationTime); auto position = self->GetPosition(); auto forward = self->GetRotation().GetForwardVector(); @@ -121,9 +122,9 @@ void AmDarklingDragon::OnTimerDone(Entity* self, std::string timerName) { } else if (timerName == "ExposeWeakSpotTimer") { self->SetVar(u"weakspot", 1); } else if (timerName == "timeToStunLoop") { - GameMessages::SendPlayAnimation(self, u"stunloop", 1.8f); + RenderComponent::PlayAnimation(self, u"stunloop", 1.8f); } else if (timerName == "ReviveTimer") { - GameMessages::SendPlayAnimation(self, u"stunend", 2.0f); + RenderComponent::PlayAnimation(self, u"stunend", 2.0f); self->AddTimer("backToAttack", 1); } else if (timerName == "backToAttack") { auto* baseCombatAIComponent = self->GetComponent(); @@ -153,5 +154,5 @@ void AmDarklingDragon::OnFireEventServerSide(Entity* self, Entity* sender, std:: self->SetVar(u"Golem", sender->GetObjectID()); - GameMessages::SendPlayAnimation(self, u"quickbuildhold", 1.9f); + RenderComponent::PlayAnimation(self, u"quickbuildhold", 1.9f); } diff --git a/dScripts/02_server/Enemy/FV/FvMaelstromDragon.cpp b/dScripts/02_server/Enemy/FV/FvMaelstromDragon.cpp index e78f537f..664d8b67 100644 --- a/dScripts/02_server/Enemy/FV/FvMaelstromDragon.cpp +++ b/dScripts/02_server/Enemy/FV/FvMaelstromDragon.cpp @@ -5,6 +5,7 @@ #include "DestroyableComponent.h" #include "eAninmationFlags.h" #include "EntityInfo.h" +#include "RenderComponent.h" void FvMaelstromDragon::OnStartup(Entity* self) { self->SetVar(u"weakspot", 0); @@ -86,9 +87,9 @@ void FvMaelstromDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_ self->SetVar(u"weakpoint", 2); GameMessages::SendChangeIdleFlags(self->GetObjectID(), eAnimationFlags::IDLE_NONE, eAnimationFlags::IDLE_COMBAT, UNASSIGNED_SYSTEM_ADDRESS); - GameMessages::SendPlayAnimation(self, u"stunstart", 1.7f); + RenderComponent::PlayAnimation(self, u"stunstart", 1.7f); - self->AddTimer("timeToStunLoop", 1); + self->AddTimer("timeToStunLoop", 1.0f); auto position = self->GetPosition(); auto forward = self->GetRotation().GetForwardVector(); @@ -137,10 +138,10 @@ void FvMaelstromDragon::OnTimerDone(Entity* self, std::string timerName) { } else if (timerName == "ExposeWeakSpotTimer") { self->SetVar(u"weakspot", 1); } else if (timerName == "timeToStunLoop") { - GameMessages::SendPlayAnimation(self, u"stunloop", 1.8f); + RenderComponent::PlayAnimation(self, u"stunloop", 1.8f); } else if (timerName == "ReviveTimer") { - GameMessages::SendPlayAnimation(self, u"stunend", 2.0f); - self->AddTimer("backToAttack", 1); + RenderComponent::PlayAnimation(self, u"stunend", 2.0f); + self->AddTimer("backToAttack", 1.0f); } else if (timerName == "backToAttack") { auto* baseCombatAIComponent = self->GetComponent(); auto* skillComponent = self->GetComponent(); @@ -174,5 +175,5 @@ FvMaelstromDragon::OnFireEventServerSide(Entity* self, Entity* sender, std::stri self->SetVar(u"Golem", sender->GetObjectID()); - GameMessages::SendPlayAnimation(self, u"quickbuildhold", 1.9f); + RenderComponent::PlayAnimation(self, u"quickbuildhold", 1.9f); } diff --git a/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp b/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp index ea3ce9b8..50108ffb 100644 --- a/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp +++ b/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp @@ -6,6 +6,7 @@ #include "EntityInfo.h" #include "SkillComponent.h" #include "eAninmationFlags.h" +#include "RenderComponent.h" void BaseEnemyApe::OnStartup(Entity* self) { self->SetVar(u"timesStunned", 2); @@ -37,7 +38,7 @@ void BaseEnemyApe::OnHit(Entity* self, Entity* attacker) { if (skillComponent) { skillComponent->Reset(); } - GameMessages::SendPlayAnimation(self, u"disable", 1.7f); + RenderComponent::PlayAnimation(self, u"disable", 1.7f); GameMessages::SendChangeIdleFlags(self->GetObjectID(), eAnimationFlags::IDLE_NONE, eAnimationFlags::IDLE_COMBAT, UNASSIGNED_SYSTEM_ADDRESS); const auto reviveTime = self->GetVar(u"reviveTime") != 0.0f ? self->GetVar(u"reviveTime") : 12.0f; diff --git a/dScripts/02_server/Enemy/General/GfApeSmashingQB.cpp b/dScripts/02_server/Enemy/General/GfApeSmashingQB.cpp index 5bba6450..40cc88f4 100644 --- a/dScripts/02_server/Enemy/General/GfApeSmashingQB.cpp +++ b/dScripts/02_server/Enemy/General/GfApeSmashingQB.cpp @@ -1,6 +1,8 @@ #include "GfApeSmashingQB.h" #include "EntityManager.h" #include "GameMessages.h" +#include "Entity.h" +#include "RenderComponent.h" void GfApeSmashingQB::OnStartup(Entity* self) { self->SetNetworkVar(u"lootTagOwner", self->GetVar(u"lootTagOwner")); @@ -16,7 +18,7 @@ void GfApeSmashingQB::OnRebuildComplete(Entity* self, Entity* target) { auto* ape = EntityManager::Instance()->GetEntity(self->GetVar(u"ape")); if (ape != nullptr) { ape->OnFireEventServerSide(target, "rebuildDone"); - GameMessages::SendPlayAnimation(self, u"smash", 1.7f); + RenderComponent::PlayAnimation(self, u"smash", 1.7f); self->AddTimer("anchorBreakTime", 1.0f); } } diff --git a/dScripts/02_server/Equipment/MaestromExtracticatorServer.cpp b/dScripts/02_server/Equipment/MaestromExtracticatorServer.cpp index c01d2362..f02c0568 100644 --- a/dScripts/02_server/Equipment/MaestromExtracticatorServer.cpp +++ b/dScripts/02_server/Equipment/MaestromExtracticatorServer.cpp @@ -4,19 +4,15 @@ #include "EntityManager.h" #include "MissionComponent.h" #include "eMissionTaskType.h" +#include "RenderComponent.h" void MaestromExtracticatorServer::OnStartup(Entity* self) { - //self:SetNetworkVar("current_anim", failAnim) - GameMessages::SendPlayAnimation(self, GeneralUtils::ASCIIToUTF16(failAnim)); - - self->AddTimer("PlayFail", defaultTime); + self->AddTimer("PlayFail", RenderComponent::PlayAnimation(self, failAnim)); self->AddTimer("RemoveSample", destroyAfterNoSampleTime); } -void MaestromExtracticatorServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, - int32_t param2, int32_t param3) { - if (sender == nullptr) - return; +void MaestromExtracticatorServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { + if (sender == nullptr) return; if (args == "attemptCollection") { Entity* player = EntityManager::Instance()->GetEntity(self->GetSpawnerID()); @@ -32,20 +28,17 @@ void MaestromExtracticatorServer::OnFireEventServerSide(Entity* self, Entity* se } void MaestromExtracticatorServer::CollectSample(Entity* self, LWOOBJID sampleObj) { - PlayAnimAndReturnTime(self, collectAnim); - self->AddTimer("RemoveSample", defaultTime); + self->AddTimer("RemoveSample", PlayAnimAndReturnTime(self, collectAnim)); } -void MaestromExtracticatorServer::PlayAnimAndReturnTime(Entity* self, std::string animID) { - GameMessages::SendPlayAnimation(self, GeneralUtils::ASCIIToUTF16(animID)); +float MaestromExtracticatorServer::PlayAnimAndReturnTime(Entity* self, std::string animID) { + return RenderComponent::PlayAnimation(self, animID); } void MaestromExtracticatorServer::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "RemoveSample") { self->ScheduleKillAfterUpdate(); - } - - if (timerName == "PlayFail") { - GameMessages::SendPlayAnimation(self, GeneralUtils::ASCIIToUTF16(failAnim)); + } else if (timerName == "PlayFail") { + RenderComponent::PlayAnimation(self, failAnim); } } diff --git a/dScripts/02_server/Equipment/MaestromExtracticatorServer.h b/dScripts/02_server/Equipment/MaestromExtracticatorServer.h index c4adb51e..c93a1cde 100644 --- a/dScripts/02_server/Equipment/MaestromExtracticatorServer.h +++ b/dScripts/02_server/Equipment/MaestromExtracticatorServer.h @@ -7,12 +7,11 @@ public: void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3); void CollectSample(Entity* self, LWOOBJID sampleObj); - void PlayAnimAndReturnTime(Entity* self, std::string animID); + float PlayAnimAndReturnTime(Entity* self, std::string animID); void OnTimerDone(Entity* self, std::string timerName); private: const std::string failAnim = "idle_maelstrom"; const std::string collectAnim = "collect_maelstrom"; - const float defaultTime = 4.0f; const float destroyAfterNoSampleTime = 8.0f; }; diff --git a/dScripts/02_server/Map/AG/AgMonumentBirds.cpp b/dScripts/02_server/Map/AG/AgMonumentBirds.cpp index ad3417a4..9d4a3349 100644 --- a/dScripts/02_server/Map/AG/AgMonumentBirds.cpp +++ b/dScripts/02_server/Map/AG/AgMonumentBirds.cpp @@ -1,5 +1,8 @@ #include "AgMonumentBirds.h" #include "GameMessages.h" +#include "Entity.h" +#include "RenderComponent.h" +#include "EntityManager.h" //-------------------------------------------------------------- //Makes the ag birds fly away when you get close and smashes them. @@ -16,7 +19,7 @@ void AgMonumentBirds::OnProximityUpdate(Entity* self, Entity* entering, std::str if (name == "MonumentBirds" && status == "ENTER") { self->AddTimer("killBird", 1.0f); - GameMessages::SendPlayAnimation(self, sOnProximityAnim); + RenderComponent::PlayAnimation(self, sOnProximityAnim); self->SetVar(u"IsFlying", true); self->SetVar(u"PlayerID", entering->GetObjectID()); } diff --git a/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp b/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp index da1954d6..4bdf6492 100644 --- a/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp +++ b/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp @@ -5,6 +5,7 @@ #include "ProximityMonitorComponent.h" #include "MissionComponent.h" #include "EntityInfo.h" +#include "RenderComponent.h" void AmSkullkinDrill::OnStartup(Entity* self) { self->SetNetworkVar(u"bIsInUse", false); @@ -70,7 +71,7 @@ void AmSkullkinDrill::OnSkillEventFired(Entity* self, Entity* caster, const std: } void AmSkullkinDrill::TriggerDrill(Entity* self) { - GameMessages::SendPlayAnimation(self, u"slowdown"); + RenderComponent::PlayAnimation(self, u"slowdown"); self->AddTimer("killDrill", 10.0f); @@ -170,7 +171,7 @@ void AmSkullkinDrill::OnArrived(Entity* self, uint32_t waypointIndex) { auto* standObj = GetStandObj(self); if (waypointIndex == 1) { - GameMessages::SendPlayAnimation(self, u"no-spin"); + RenderComponent::PlayAnimation(self, u"no-spin"); GameMessages::SendStopFXEffect(self, true, "active"); GameMessages::SendPlayFXEffect(self->GetObjectID(), -1, u"indicator", "indicator"); @@ -190,7 +191,7 @@ void AmSkullkinDrill::OnArrived(Entity* self, uint32_t waypointIndex) { return; } else { - GameMessages::SendPlayAnimation(self, u"idle"); + RenderComponent::PlayAnimation(self, u"idle"); GameMessages::SendPlayFXEffect(self->GetObjectID(), -1, u"spin", "active"); GameMessages::SendStopFXEffect(self, true, "indicator"); } @@ -215,7 +216,7 @@ void AmSkullkinDrill::PlayCinematic(Entity* self) { void AmSkullkinDrill::PlayAnim(Entity* self, Entity* player, const std::string& animName) { const auto animTime = animName == "spinjitzu-staff-end" ? 0.5f : 1.0f; - GameMessages::SendPlayAnimation(player, GeneralUtils::ASCIIToUTF16(animName)); + RenderComponent::PlayAnimation(player, animName); self->AddTimer("AnimDone_" + animName, animTime); } @@ -308,7 +309,7 @@ void AmSkullkinDrill::OnTimerDone(Entity* self, std::string timerName) { if (animName == "spinjitzu-staff-windup") { TriggerDrill(self); - GameMessages::SendPlayAnimation(player, u"spinjitzu-staff-loop"); + RenderComponent::PlayAnimation(player, u"spinjitzu-staff-loop"); } else if (animName == "spinjitzu-staff-end") { FreezePlayer(self, player, false); diff --git a/dScripts/02_server/Map/AM/AmSkullkinDrillStand.cpp b/dScripts/02_server/Map/AM/AmSkullkinDrillStand.cpp index 628d616a..5493dc24 100644 --- a/dScripts/02_server/Map/AM/AmSkullkinDrillStand.cpp +++ b/dScripts/02_server/Map/AM/AmSkullkinDrillStand.cpp @@ -1,6 +1,8 @@ #include "AmSkullkinDrillStand.h" #include "GameMessages.h" #include "dpEntity.h" +#include "Entity.h" +#include "RenderComponent.h" void AmSkullkinDrillStand::OnStartup(Entity* self) { self->SetVar(u"bActive", true); @@ -31,5 +33,5 @@ void AmSkullkinDrillStand::OnProximityUpdate(Entity* self, Entity* entering, std GameMessages::SendPlayFXEffect(entering->GetObjectID(), 1378, u"create", "pushBack"); - GameMessages::SendPlayAnimation(entering, u"knockback-recovery"); + RenderComponent::PlayAnimation(entering, u"knockback-recovery"); } diff --git a/dScripts/02_server/Map/AM/AmSkullkinTower.cpp b/dScripts/02_server/Map/AM/AmSkullkinTower.cpp index 01acdeaf..f7825f8f 100644 --- a/dScripts/02_server/Map/AM/AmSkullkinTower.cpp +++ b/dScripts/02_server/Map/AM/AmSkullkinTower.cpp @@ -5,6 +5,7 @@ #include "EntityInfo.h" #include "GameMessages.h" #include "MissionComponent.h" +#include "RenderComponent.h" void AmSkullkinTower::OnStartup(Entity* self) { self->SetProximityRadius(20, "Tower"); @@ -117,13 +118,13 @@ void AmSkullkinTower::OnChildRemoved(Entity* self, Entity* child) { self->SetVar(u"legTable", legTable); if (legTable.size() == 2) { - GameMessages::SendPlayAnimation(self, u"wobble-1"); + RenderComponent::PlayAnimation(self, u"wobble-1"); } else if (legTable.size() == 1) { - GameMessages::SendPlayAnimation(self, u"wobble-2"); + RenderComponent::PlayAnimation(self, u"wobble-2"); } else if (legTable.empty()) { const auto animTime = 2.5f; - GameMessages::SendPlayAnimation(self, u"fall"); + RenderComponent::PlayAnimation(self, u"fall"); self->AddTimer("spawnGuys", animTime - 0.2f); diff --git a/dScripts/02_server/Map/GF/GfCaptainsCannon.cpp b/dScripts/02_server/Map/GF/GfCaptainsCannon.cpp index eeabeef6..2b40db3c 100644 --- a/dScripts/02_server/Map/GF/GfCaptainsCannon.cpp +++ b/dScripts/02_server/Map/GF/GfCaptainsCannon.cpp @@ -2,6 +2,7 @@ #include "GameMessages.h" #include "EntityManager.h" #include "MissionComponent.h" +#include "RenderComponent.h" void GfCaptainsCannon::OnUse(Entity* self, Entity* user) { if (self->GetVar(u"bIsInUse")) { @@ -27,7 +28,7 @@ void GfCaptainsCannon::OnUse(Entity* self, Entity* user) { GameMessages::SendTeleport(user->GetObjectID(), position, rotation, user->GetSystemAddress()); - GameMessages::SendPlayAnimation(user, u"cannon-strike-no-equip"); + RenderComponent::PlayAnimation(user, u"cannon-strike-no-equip"); GameMessages::SendPlayFXEffect(user->GetObjectID(), 6039, u"hook", "hook", LWOOBJID_EMPTY, 1, 1, true); @@ -58,7 +59,7 @@ void GfCaptainsCannon::OnTimerDone(Entity* self, std::string timerName) { for (auto* shark : sharkObjects) { if (shark->GetLOT() != m_SharkItemID) continue; - GameMessages::SendPlayAnimation(shark, u"cannon"); + RenderComponent::PlayAnimation(shark, u"cannon"); } GameMessages::SendPlay2DAmbientSound(player, "{7457d85c-4537-4317-ac9d-2f549219ea87}"); diff --git a/dScripts/02_server/Map/GF/GfTikiTorch.cpp b/dScripts/02_server/Map/GF/GfTikiTorch.cpp index 22420679..a4f36da2 100644 --- a/dScripts/02_server/Map/GF/GfTikiTorch.cpp +++ b/dScripts/02_server/Map/GF/GfTikiTorch.cpp @@ -5,6 +5,7 @@ #include "RenderComponent.h" #include "eMissionTaskType.h" #include "eReplicaComponentType.h" +#include "RenderComponent.h" void GfTikiTorch::OnStartup(Entity* self) { LightTorch(self); @@ -16,7 +17,7 @@ void GfTikiTorch::OnUse(Entity* self, Entity* killer) { return; } - GameMessages::SendPlayAnimation(self, u"interact"); + RenderComponent::PlayAnimation(self, u"interact"); self->SetI64(u"userID", killer->GetObjectID()); for (int i = 0; i < m_numspawn; i++) { @@ -55,7 +56,7 @@ void GfTikiTorch::LightTorch(Entity* self) { void GfTikiTorch::OnSkillEventFired(Entity* self, Entity* caster, const std::string& message) { if (self->GetBoolean(u"isBurning") && message == "waterspray") { - GameMessages::SendPlayAnimation(self, u"water"); + RenderComponent::PlayAnimation(self, u"water"); auto* renderComponent = self->GetComponent(); if (renderComponent != nullptr) { diff --git a/dScripts/02_server/Map/GF/MastTeleport.cpp b/dScripts/02_server/Map/GF/MastTeleport.cpp index 6e50c6ec..fd2fe96d 100644 --- a/dScripts/02_server/Map/GF/MastTeleport.cpp +++ b/dScripts/02_server/Map/GF/MastTeleport.cpp @@ -8,6 +8,7 @@ #define _USE_MATH_DEFINES #include #endif +#include "RenderComponent.h" void MastTeleport::OnStartup(Entity* self) { self->SetNetworkVar(u"hookPreconditions", "154;44", UNASSIGNED_SYSTEM_ADDRESS); @@ -58,11 +59,12 @@ void MastTeleport::OnTimerDone(Entity* self, std::string timerName) { GameMessages::SendPlayFXEffect(playerId, 6039, u"hook", "hook", LWOOBJID_EMPTY, 1, 1, true); - GameMessages::SendPlayAnimation(player, u"crow-swing-no-equip", 4.0f); + float animationTime = 6.25f; + animationTime = RenderComponent::PlayAnimation(player, "crow-swing-no-equip", 4.0f); - GameMessages::SendPlayAnimation(self, u"swing"); + RenderComponent::PlayAnimation(self, u"swing"); - self->AddTimer("PlayerAnimDone", 6.25f); + self->AddTimer("PlayerAnimDone", animationTime); } else if (timerName == "PlayerAnimDone") { GameMessages::SendStopFXEffect(player, true, "hook"); diff --git a/dScripts/02_server/Map/General/ExplodingAsset.cpp b/dScripts/02_server/Map/General/ExplodingAsset.cpp index 16340ee6..ee8f8e68 100644 --- a/dScripts/02_server/Map/General/ExplodingAsset.cpp +++ b/dScripts/02_server/Map/General/ExplodingAsset.cpp @@ -4,6 +4,7 @@ #include "MissionComponent.h" #include "SkillComponent.h" #include "eMissionTaskType.h" +#include "RenderComponent.h" //TODO: this has to be updated so that you only get killed if you're in a certain radius. //And so that all entities in a certain radius are killed, not just the attacker. @@ -69,23 +70,6 @@ void ExplodingAsset::OnHit(Entity* self, Entity* attacker) { } void ExplodingAsset::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) { - /* - if msg.objId:BelongsToFaction{factionID = 1}.bIsInFaction then - if (msg.status == "ENTER") then - self:PlayAnimation{ animationID = "bounce" } - self:PlayFXEffect{ name = "bouncin", effectType = "anim" } - self:SetVar("playersNearChest", (self:GetVar("playersNearChest") + 1 )) - elseif (msg.status == "LEAVE") then - self:SetVar("playersNearChest", (self:GetVar("playersNearChest") - 1 )) - if self:GetVar("playersNearChest") < 1 then - self:PlayAnimation{ animationID = "idle" } - self:StopFXEffect{ name = "bouncin" } - self:SetVar("playersNearChest", 0) - end - end - end - */ - auto* destuctableComponent = entering->GetComponent(); if (destuctableComponent == nullptr) return; @@ -95,14 +79,14 @@ void ExplodingAsset::OnProximityUpdate(Entity* self, Entity* entering, std::stri if (!std::count(factions.begin(), factions.end(), 1)) return; if (status == "ENTER") { - GameMessages::SendPlayAnimation(self, u"bounce"); + RenderComponent::PlayAnimation(self, u"bounce"); GameMessages::SendPlayFXEffect(self, -1, u"anim", "bouncin", LWOOBJID_EMPTY, 1, 1, true); self->SetVar(u"playersNearChest", self->GetVar(u"playersNearChest") + 1); } else if (status == "LEAVE") { self->SetVar(u"playersNearChest", self->GetVar(u"playersNearChest") - 1); if (self->GetVar(u"playersNearChest") < 1) { - GameMessages::SendPlayAnimation(self, u"idle"); + RenderComponent::PlayAnimation(self, u"idle"); GameMessages::SendStopFXEffect(self, true, "bouncin"); self->SetVar(u"playersNearChest", 0); } diff --git a/dScripts/02_server/Map/General/Ninjago/NjIceRailActivator.cpp b/dScripts/02_server/Map/General/Ninjago/NjIceRailActivator.cpp index 2549cd0f..8a9230d9 100644 --- a/dScripts/02_server/Map/General/Ninjago/NjIceRailActivator.cpp +++ b/dScripts/02_server/Map/General/Ninjago/NjIceRailActivator.cpp @@ -1,6 +1,8 @@ #include "NjIceRailActivator.h" #include "EntityManager.h" #include "GameMessages.h" +#include "Entity.h" +#include "RenderComponent.h" void NjIceRailActivator::OnPlayerRailArrived(Entity* self, Entity* sender, const std::u16string& pathName, int32_t waypoint) { @@ -9,7 +11,7 @@ void NjIceRailActivator::OnPlayerRailArrived(Entity* self, Entity* sender, const const auto& blockGroup = self->GetVar(BlockGroupVariable); for (auto* block : EntityManager::Instance()->GetEntitiesInGroup(GeneralUtils::UTF16ToWTF8(blockGroup))) { - GameMessages::SendPlayAnimation(block, u"explode"); + RenderComponent::PlayAnimation(block, u"explode"); const auto blockID = block->GetObjectID(); diff --git a/dScripts/02_server/Map/NT/NtAssemblyTubeServer.cpp b/dScripts/02_server/Map/NT/NtAssemblyTubeServer.cpp index b4d75296..26da3aca 100644 --- a/dScripts/02_server/Map/NT/NtAssemblyTubeServer.cpp +++ b/dScripts/02_server/Map/NT/NtAssemblyTubeServer.cpp @@ -4,6 +4,7 @@ #include "MissionComponent.h" #include "eMissionTaskType.h" #include "eMissionState.h" +#include "RenderComponent.h" void NtAssemblyTubeServer::OnStartup(Entity* self) { self->SetProximityRadius(5, "teleport"); @@ -49,7 +50,7 @@ void NtAssemblyTubeServer::RunAssemblyTube(Entity* self, Entity* player) { ); } - GameMessages::SendPlayAnimation(player, u"tube-sucker", 4.0f); + RenderComponent::PlayAnimation(player, u"tube-sucker", 4.0f); const auto animTime = 3; @@ -82,7 +83,7 @@ void NtAssemblyTubeServer::TeleportPlayer(Entity* self, Entity* player) { GameMessages::SendTeleport(player->GetObjectID(), destPosition, destRotation, player->GetSystemAddress(), true); - GameMessages::SendPlayAnimation(player, u"tube-resurrect", 4.0f); + RenderComponent::PlayAnimation(player, u"tube-resurrect", 4.0f); const auto animTime = 2; diff --git a/dScripts/02_server/Map/NT/NtParadoxPanelServer.cpp b/dScripts/02_server/Map/NT/NtParadoxPanelServer.cpp index 0cb0bec4..f7e27711 100644 --- a/dScripts/02_server/Map/NT/NtParadoxPanelServer.cpp +++ b/dScripts/02_server/Map/NT/NtParadoxPanelServer.cpp @@ -4,6 +4,7 @@ #include "EntityManager.h" #include "Character.h" #include "eMissionState.h" +#include "RenderComponent.h" void NtParadoxPanelServer::OnUse(Entity* self, Entity* user) { GameMessages::SendNotifyClientObject(self->GetObjectID(), u"bActive", 1, 0, user->GetObjectID(), "", user->GetSystemAddress()); @@ -32,18 +33,18 @@ void NtParadoxPanelServer::OnUse(Entity* self, Entity* user) { player->GetCharacter()->SetPlayerFlag(flag, true); - GameMessages::SendPlayAnimation(player, u"rebuild-celebrate"); + RenderComponent::PlayAnimation(player, u"rebuild-celebrate"); GameMessages::SendNotifyClientObject(self->GetObjectID(), u"SparkStop", 0, 0, player->GetObjectID(), "", player->GetSystemAddress()); GameMessages::SendSetStunned(player->GetObjectID(), eStateChangeType::POP, player->GetSystemAddress(), LWOOBJID_EMPTY, false, false, true, false, true, true, false, false, true); self->SetVar(u"bActive", false); }); - GameMessages::SendPlayAnimation(user, u"nexus-powerpanel", 6.0f); + RenderComponent::PlayAnimation(user, u"nexus-powerpanel", 6.0f); GameMessages::SendSetStunned(user->GetObjectID(), eStateChangeType::PUSH, user->GetSystemAddress(), LWOOBJID_EMPTY, false, false, true, false, true, true, false, false, true); return; } - GameMessages::SendPlayAnimation(user, shockAnim); + RenderComponent::PlayAnimation(user, shockAnim); const auto dir = self->GetRotation().GetRightVector(); diff --git a/dScripts/02_server/Map/NT/NtParadoxTeleServer.cpp b/dScripts/02_server/Map/NT/NtParadoxTeleServer.cpp index 8b4f19fe..e3ec8d7d 100644 --- a/dScripts/02_server/Map/NT/NtParadoxTeleServer.cpp +++ b/dScripts/02_server/Map/NT/NtParadoxTeleServer.cpp @@ -3,6 +3,7 @@ #include "EntityManager.h" #include "MissionComponent.h" #include "eMissionTaskType.h" +#include "RenderComponent.h" void NtParadoxTeleServer::OnStartup(Entity* self) { self->SetProximityRadius(5, "teleport"); @@ -27,7 +28,7 @@ void NtParadoxTeleServer::OnProximityUpdate(Entity* self, Entity* entering, std: true, true, true, true, true, true, true ); - GameMessages::SendPlayAnimation(player, u"teledeath", 4.0f); + RenderComponent::PlayAnimation(player, u"teledeath", 4.0f); const auto animTime = 2; @@ -73,7 +74,7 @@ void NtParadoxTeleServer::TeleportPlayer(Entity* self, Entity* player) { GameMessages::SendTeleport(player->GetObjectID(), destPosition, destRotation, player->GetSystemAddress(), true); - GameMessages::SendPlayAnimation(player, u"paradox-teleport-in", 4.0f); + RenderComponent::PlayAnimation(player, u"paradox-teleport-in", 4.0f); const auto animTime = 2; diff --git a/dScripts/02_server/Map/NT/NtSleepingGuard.cpp b/dScripts/02_server/Map/NT/NtSleepingGuard.cpp index 145df6c8..92a80582 100644 --- a/dScripts/02_server/Map/NT/NtSleepingGuard.cpp +++ b/dScripts/02_server/Map/NT/NtSleepingGuard.cpp @@ -1,6 +1,7 @@ #include "NtSleepingGuard.h" #include "GameMessages.h" #include "MissionComponent.h" +#include "RenderComponent.h" void NtSleepingGuard::OnStartup(Entity* self) { self->SetNetworkVar(u"asleep", true); @@ -17,7 +18,7 @@ void NtSleepingGuard::OnEmoteReceived(Entity* self, const int32_t emote, Entity* // Set asleep to false self->SetNetworkVar(u"asleep", false); - GameMessages::SendPlayAnimation(self, u"greet"); + RenderComponent::PlayAnimation(self, u"greet"); auto* missionComponent = target->GetComponent(); diff --git a/dScripts/02_server/Map/NT/NtVentureCannonServer.cpp b/dScripts/02_server/Map/NT/NtVentureCannonServer.cpp index e6cd2df6..c1f07bbd 100644 --- a/dScripts/02_server/Map/NT/NtVentureCannonServer.cpp +++ b/dScripts/02_server/Map/NT/NtVentureCannonServer.cpp @@ -1,6 +1,9 @@ #include "NtVentureCannonServer.h" #include "GameMessages.h" #include "EntityManager.h" +#include "Entity.h" +#include "GeneralUtils.h" +#include "RenderComponent.h" void NtVentureCannonServer::OnUse(Entity* self, Entity* user) { auto* player = user; @@ -26,7 +29,7 @@ void NtVentureCannonServer::OnUse(Entity* self, Entity* user) { GameMessages::SendTeleport(playerID, destPosition, destRotation, player->GetSystemAddress(), true); - GameMessages::SendPlayAnimation(player, u"scale-down", 4.0f); + RenderComponent::PlayAnimation(player, u"scale-down", 4.0f); const auto enterCinematicUname = enterCinematic; GameMessages::SendPlayCinematic(player->GetObjectID(), enterCinematicUname, player->GetSystemAddress()); @@ -118,5 +121,5 @@ void NtVentureCannonServer::FirePlayer(Entity* self, Entity* player) { GameMessages::SendTeleport(player->GetObjectID(), destPosition, destRotation, player->GetSystemAddress(), true); - GameMessages::SendPlayAnimation(player, u"venture-cannon-out", 4.0f); + RenderComponent::PlayAnimation(player, u"venture-cannon-out", 4.0f); } diff --git a/dScripts/02_server/Map/njhub/CatapultBaseServer.cpp b/dScripts/02_server/Map/njhub/CatapultBaseServer.cpp index fda103b0..55935c62 100644 --- a/dScripts/02_server/Map/njhub/CatapultBaseServer.cpp +++ b/dScripts/02_server/Map/njhub/CatapultBaseServer.cpp @@ -1,6 +1,8 @@ #include "CatapultBaseServer.h" #include "GameMessages.h" #include "EntityManager.h" +#include "Entity.h" +#include "RenderComponent.h" void CatapultBaseServer::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) { if (name == "BouncerBuilt") { @@ -21,7 +23,7 @@ void CatapultBaseServer::OnTimerDone(Entity* self, std::string timerName) { // tell the arm to the play the platform animation, which is just the arm laying there but with bouncer for (auto* obj : arm) { - GameMessages::SendPlayAnimation(obj, u"idle-platform"); + RenderComponent::PlayAnimation(obj, u"idle-platform"); GameMessages::SendPlayNDAudioEmitter(obj, UNASSIGNED_SYSTEM_ADDRESS, "{8cccf912-69e3-4041-a20b-63e4afafc993}"); // set the art so we can use it again self->SetVar(u"Arm", obj->GetObjectID()); @@ -38,7 +40,7 @@ void CatapultBaseServer::OnTimerDone(Entity* self, std::string timerName) { // tell the arm to player the launcher animation auto animTime = 1; self->AddTimer("resetArm", animTime); - GameMessages::SendPlayAnimation(arm, u"launch"); + RenderComponent::PlayAnimation(arm, u"launch"); } else if (timerName == "bounce") { auto* bouncer = EntityManager::Instance()->GetEntity(self->GetVar(u"Bouncer")); if (bouncer == nullptr) return; @@ -52,7 +54,7 @@ void CatapultBaseServer::OnTimerDone(Entity* self, std::string timerName) { if (arm == nullptr) return; // set the arm back to natural state - GameMessages::SendPlayAnimation(arm, u"idle"); + RenderComponent::PlayAnimation(arm, u"idle"); auto* bouncer = EntityManager::Instance()->GetEntity(self->GetVar(u"Bouncer")); if (bouncer == nullptr) return; diff --git a/dScripts/02_server/Map/njhub/CavePrisonCage.cpp b/dScripts/02_server/Map/njhub/CavePrisonCage.cpp index 0df91884..14cf6719 100644 --- a/dScripts/02_server/Map/njhub/CavePrisonCage.cpp +++ b/dScripts/02_server/Map/njhub/CavePrisonCage.cpp @@ -4,6 +4,7 @@ #include "GameMessages.h" #include "Character.h" #include "dZoneManager.h" +#include "RenderComponent.h" void CavePrisonCage::OnStartup(Entity* self) { const auto& myNum = self->GetVar(u"myNumber"); @@ -101,7 +102,7 @@ void CavePrisonCage::SpawnCounterweight(Entity* self, Spawner* spawner) { } // Play the 'down' animation on the button - GameMessages::SendPlayAnimation(button, u"down"); + RenderComponent::PlayAnimation(button, u"down"); // Setup a timer named 'buttonGoingDown' to be triggered in 5 seconds self->AddTimer("buttonGoingDown", 5.0f); @@ -136,13 +137,13 @@ void CavePrisonCage::OnTimerDone(Entity* self, std::string timerName) { // the anim of the button down is over if (timerName == "buttonGoingDown") { // Play the 'up' animation - GameMessages::SendPlayAnimation(self, u"up"); + RenderComponent::PlayAnimation(self, u"up"); // Setup a timer named 'CageOpen' to be triggered in 1 second self->AddTimer("CageOpen", 1.0f); } else if (timerName == "CageOpen") { // play the idle open anim - GameMessages::SendPlayAnimation(self, u"idle-up"); + RenderComponent::PlayAnimation(self, u"idle-up"); // Get the villeger auto* villager = EntityManager::Instance()->GetEntity(self->GetVar(u"villager")); @@ -199,13 +200,13 @@ void CavePrisonCage::OnTimerDone(Entity* self, std::string timerName) { } // Play the 'up' animation on the button - GameMessages::SendPlayAnimation(button, u"up"); + RenderComponent::PlayAnimation(button, u"up"); // Setup a timer named 'CageClosed' to be triggered in 1 second self->AddTimer("CageClosed", 1.0f); } else if (timerName == "CageClosed") { // play the idle closed anim - GameMessages::SendPlayAnimation(self, u"idle"); + RenderComponent::PlayAnimation(self, u"idle"); // Setup a timer named 'ResetPrison' to be triggered in 10 seconds self->AddTimer("ResetPrison", 10.0f); diff --git a/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp b/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp index dbab7365..d5880029 100644 --- a/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp +++ b/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp @@ -9,6 +9,7 @@ #include "SkillComponent.h" #include "TeamManager.h" #include +#include "RenderComponent.h" // // // // // // // // Event handling // @@ -261,7 +262,7 @@ void NjMonastryBossInstance::HandleCounterWeightSpawned(Entity* self, Entity* co skillComponent->CalculateBehavior(1635, 39097, frakjaw->GetObjectID(), true, false); } - GameMessages::SendPlayAnimation(frakjaw, StunnedAnimation); + RenderComponent::PlayAnimation(frakjaw, StunnedAnimation); GameMessages::SendPlayNDAudioEmitter(frakjaw, UNASSIGNED_SYSTEM_ADDRESS, CounterSmashAudio); // Before wave 4 we should lower frakjaw from the ledge @@ -281,7 +282,7 @@ void NjMonastryBossInstance::HandleCounterWeightSpawned(Entity* self, Entity* co } void NjMonastryBossInstance::HandleLowerFrakjawSpawned(Entity* self, Entity* lowerFrakjaw) { - GameMessages::SendPlayAnimation(lowerFrakjaw, TeleportInAnimation); + RenderComponent::PlayAnimation(lowerFrakjaw, TeleportInAnimation); self->SetVar(LowerFrakjawVariable, lowerFrakjaw->GetObjectID()); auto* combatAI = lowerFrakjaw->GetComponent(); @@ -401,7 +402,7 @@ void NjMonastryBossInstance::TeleportPlayer(Entity* player, uint32_t position) { void NjMonastryBossInstance::SummonWave(Entity* self, Entity* frakjaw) { GameMessages::SendNotifyClientObject(self->GetObjectID(), PlayCinematicNotification, 0, 0, LWOOBJID_EMPTY, LedgeFrakSummon, UNASSIGNED_SYSTEM_ADDRESS); - GameMessages::SendPlayAnimation(frakjaw, SummonAnimation); + RenderComponent::PlayAnimation(frakjaw, SummonAnimation); // Stop the music for the first, fourth and fifth wave const auto wave = self->GetVar(WaveNumberVariable); @@ -425,7 +426,7 @@ void NjMonastryBossInstance::LowerFrakjawSummon(Entity* self, Entity* frakjaw) { GameMessages::SendNotifyClientObject(self->GetObjectID(), PlayCinematicNotification, 0, 0, LWOOBJID_EMPTY, BottomFrakSummon, UNASSIGNED_SYSTEM_ADDRESS); ActivityTimerStart(self, SpawnWaveTimer, 2.0f, 2.0f); - GameMessages::SendPlayAnimation(frakjaw, SummonAnimation); + RenderComponent::PlayAnimation(frakjaw, SummonAnimation); } void NjMonastryBossInstance::RemovePoison(Entity* self) { @@ -444,7 +445,7 @@ void NjMonastryBossInstance::RemovePoison(Entity* self) { } void NjMonastryBossInstance::LowerFrakjaw(Entity* self, Entity* frakjaw) { - GameMessages::SendPlayAnimation(frakjaw, TeleportOutAnimation); + RenderComponent::PlayAnimation(frakjaw, TeleportOutAnimation); ActivityTimerStart(self, LowerFrakjawCamTimer, 2.0f, 2.0f); GameMessages::SendNotifyClientObject(frakjaw->GetObjectID(), StopMusicNotification, 0, 0, diff --git a/dScripts/BaseConsoleTeleportServer.cpp b/dScripts/BaseConsoleTeleportServer.cpp index d0162e9c..073b7826 100644 --- a/dScripts/BaseConsoleTeleportServer.cpp +++ b/dScripts/BaseConsoleTeleportServer.cpp @@ -1,6 +1,8 @@ #include "BaseConsoleTeleportServer.h" #include "GameMessages.h" #include "Player.h" +#include "RenderComponent.h" +#include "EntityManager.h" void BaseConsoleTeleportServer::BaseOnUse(Entity* self, Entity* user) { auto* player = user; @@ -31,13 +33,12 @@ void BaseConsoleTeleportServer::BaseOnMessageBoxResponse(Entity* self, Entity* s } const auto& teleIntroAnim = self->GetVar(u"teleportAnim"); - + Game::logger->Log("BaseConsoleTeleportServer", "%s",GeneralUtils::UTF16ToWTF8(teleIntroAnim).c_str()); + auto animTime = 3.32999992370605f; if (!teleIntroAnim.empty()) { - GameMessages::SendPlayAnimation(player, teleIntroAnim); + animTime = RenderComponent::PlayAnimation(player, teleIntroAnim); } - const auto animTime = 3.32999992370605f; - UpdatePlayerTable(self, player, true); const auto playerID = player->GetObjectID(); diff --git a/dScripts/ai/AG/AgFans.cpp b/dScripts/ai/AG/AgFans.cpp index e05fe68d..aaff9c0d 100644 --- a/dScripts/ai/AG/AgFans.cpp +++ b/dScripts/ai/AG/AgFans.cpp @@ -5,6 +5,8 @@ #include "PhantomPhysicsComponent.h" #include "RenderComponent.h" #include "eReplicaComponentType.h" +#include "RenderComponent.h" +#include "Entity.h" void AgFans::OnStartup(Entity* self) { self->SetVar(u"alive", true); @@ -34,7 +36,7 @@ void AgFans::ToggleFX(Entity* self, bool hit) { if (fanVolumes.size() == 0 || !self->GetVar(u"alive")) return; if (self->GetVar(u"on")) { - GameMessages::SendPlayAnimation(self, u"fan-off"); + RenderComponent::PlayAnimation(self, u"fan-off"); renderComponent->StopEffect("fanOn"); self->SetVar(u"on", false); @@ -46,11 +48,11 @@ void AgFans::ToggleFX(Entity* self, bool hit) { EntityManager::Instance()->SerializeEntity(volume); if (!hit) { Entity* fxObj = EntityManager::Instance()->GetEntitiesInGroup(fanGroup + "fx")[0]; - GameMessages::SendPlayAnimation(fxObj, u"trigger"); + RenderComponent::PlayAnimation(fxObj, u"trigger"); } } } else if (!self->GetVar(u"on") && self->GetVar(u"alive")) { - GameMessages::SendPlayAnimation(self, u"fan-on"); + RenderComponent::PlayAnimation(self, u"fan-on"); renderComponent->PlayEffect(495, u"fanOn", "fanOn"); self->SetVar(u"on", true); @@ -62,7 +64,7 @@ void AgFans::ToggleFX(Entity* self, bool hit) { EntityManager::Instance()->SerializeEntity(volume); if (!hit) { Entity* fxObj = EntityManager::Instance()->GetEntitiesInGroup(fanGroup + "fx")[0]; - GameMessages::SendPlayAnimation(fxObj, u"idle"); + RenderComponent::PlayAnimation(fxObj, u"idle"); } } } diff --git a/dScripts/ai/AG/AgJetEffectServer.cpp b/dScripts/ai/AG/AgJetEffectServer.cpp index 9546bc4d..37e2e573 100644 --- a/dScripts/ai/AG/AgJetEffectServer.cpp +++ b/dScripts/ai/AG/AgJetEffectServer.cpp @@ -3,6 +3,7 @@ #include "EntityManager.h" #include "SkillComponent.h" #include "eReplicaComponentType.h" +#include "RenderComponent.h" void AgJetEffectServer::OnUse(Entity* self, Entity* user) { if (inUse) { @@ -54,7 +55,7 @@ void AgJetEffectServer::OnRebuildComplete(Entity* self, Entity* target) { const auto group = groups[0]; - GameMessages::SendPlayAnimation(effect, u"jetFX"); + RenderComponent::PlayAnimation(effect, u"jetFX"); self->AddTimer("PlayEffect", 2.5f); diff --git a/dScripts/ai/AG/AgSalutingNpcs.cpp b/dScripts/ai/AG/AgSalutingNpcs.cpp index 4e4d8b2c..d3bbe9ab 100644 --- a/dScripts/ai/AG/AgSalutingNpcs.cpp +++ b/dScripts/ai/AG/AgSalutingNpcs.cpp @@ -1,11 +1,10 @@ #include "AgSalutingNpcs.h" -#include "GameMessages.h" - +#include "RenderComponent.h" void AgSalutingNpcs::OnEmoteReceived(Entity* self, const int32_t emote, Entity* target) { if (emote != 356) { return; } - GameMessages::SendPlayAnimation(self, u"salutePlayer"); + RenderComponent::PlayAnimation(self, u"salutePlayer"); } diff --git a/dScripts/ai/AG/AgShipPlayerShockServer.cpp b/dScripts/ai/AG/AgShipPlayerShockServer.cpp index 2bed8152..0eb1d9c8 100644 --- a/dScripts/ai/AG/AgShipPlayerShockServer.cpp +++ b/dScripts/ai/AG/AgShipPlayerShockServer.cpp @@ -1,5 +1,7 @@ #include "AgShipPlayerShockServer.h" #include "GameMessages.h" +#include "RenderComponent.h" +#include "Entity.h" void AgShipPlayerShockServer::OnUse(Entity* self, Entity* user) { GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); @@ -7,7 +9,7 @@ void AgShipPlayerShockServer::OnUse(Entity* self, Entity* user) { return; } active = true; - GameMessages::SendPlayAnimation(user, shockAnim); + RenderComponent::PlayAnimation(user, shockAnim); GameMessages::SendKnockback(user->GetObjectID(), self->GetObjectID(), self->GetObjectID(), 0, NiPoint3(-20, 10, -20)); GameMessages::SendPlayFXEffect(self, 1430, u"create", "console_sparks", LWOOBJID_EMPTY, 1.0, 1.0, true); diff --git a/dScripts/ai/AG/AgSpaceStuff.cpp b/dScripts/ai/AG/AgSpaceStuff.cpp index 30929ebf..0887608e 100644 --- a/dScripts/ai/AG/AgSpaceStuff.cpp +++ b/dScripts/ai/AG/AgSpaceStuff.cpp @@ -3,6 +3,8 @@ #include "GeneralUtils.h" #include "GameMessages.h" #include "EntityManager.h" +#include "RenderComponent.h" +#include "Entity.h" void AgSpaceStuff::OnStartup(Entity* self) { self->AddTimer("FloaterScale", 5.0f); @@ -27,13 +29,13 @@ void AgSpaceStuff::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "FloaterScale") { int scaleType = GeneralUtils::GenerateRandomNumber(1, 5); - GameMessages::SendPlayAnimation(self, u"scale_0" + GeneralUtils::to_u16string(scaleType)); + RenderComponent::PlayAnimation(self, u"scale_0" + GeneralUtils::to_u16string(scaleType)); self->AddTimer("FloaterPath", 0.4); } else if (timerName == "FloaterPath") { int pathType = GeneralUtils::GenerateRandomNumber(1, 4); int randTime = GeneralUtils::GenerateRandomNumber(20, 25); - GameMessages::SendPlayAnimation(self, u"path_0" + (GeneralUtils::to_u16string(pathType))); + RenderComponent::PlayAnimation(self, u"path_0" + (GeneralUtils::to_u16string(pathType))); self->AddTimer("FloaterScale", randTime); } else if (timerName == "ShipShakeExplode") { DoShake(self, true); @@ -76,16 +78,16 @@ void AgSpaceStuff::DoShake(Entity* self, bool explodeIdle) { auto* shipFxObject2 = GetEntityInGroup(ShipFX2); if (shipFxObject2) - GameMessages::SendPlayAnimation(shipFxObject2, u"explosion"); + RenderComponent::PlayAnimation(shipFxObject2, u"explosion"); } else { auto* shipFxObject = GetEntityInGroup(ShipFX); auto* shipFxObject2 = GetEntityInGroup(ShipFX2); if (shipFxObject) - GameMessages::SendPlayAnimation(shipFxObject, u"idle"); + RenderComponent::PlayAnimation(shipFxObject, u"idle"); if (shipFxObject2) - GameMessages::SendPlayAnimation(shipFxObject2, u"idle"); + RenderComponent::PlayAnimation(shipFxObject2, u"idle"); } } diff --git a/dScripts/ai/FV/FvDragonSmashingGolemQb.cpp b/dScripts/ai/FV/FvDragonSmashingGolemQb.cpp index a9d38aa5..d46173fd 100644 --- a/dScripts/ai/FV/FvDragonSmashingGolemQb.cpp +++ b/dScripts/ai/FV/FvDragonSmashingGolemQb.cpp @@ -1,6 +1,8 @@ #include "FvDragonSmashingGolemQb.h" #include "GameMessages.h" #include "EntityManager.h" +#include "RenderComponent.h" +#include "Entity.h" void FvDragonSmashingGolemQb::OnStartup(Entity* self) { self->AddTimer("GolemBreakTimer", 10.5f); @@ -14,7 +16,7 @@ void FvDragonSmashingGolemQb::OnTimerDone(Entity* self, std::string timerName) { void FvDragonSmashingGolemQb::OnRebuildNotifyState(Entity* self, eRebuildState state) { if (state == eRebuildState::REBUILD_COMPLETED) { - GameMessages::SendPlayAnimation(self, u"dragonsmash"); + RenderComponent::PlayAnimation(self, u"dragonsmash"); const auto dragonId = self->GetVar(u"Dragon"); diff --git a/dScripts/ai/FV/FvFlyingCreviceDragon.cpp b/dScripts/ai/FV/FvFlyingCreviceDragon.cpp index 16eda512..cb0fe3d0 100644 --- a/dScripts/ai/FV/FvFlyingCreviceDragon.cpp +++ b/dScripts/ai/FV/FvFlyingCreviceDragon.cpp @@ -3,6 +3,7 @@ #include "EntityManager.h" #include "SkillComponent.h" #include "GeneralUtils.h" +#include "RenderComponent.h" void FvFlyingCreviceDragon::OnStartup(Entity* self) { self->AddTimer("waypoint", 5); @@ -67,10 +68,10 @@ void FvFlyingCreviceDragon::OnArrived(Entity* self) { auto point = self->GetVar(u"waypoint"); if (point == 4) { - GameMessages::SendPlayAnimation(self, u"attack1", 2); + RenderComponent::PlayAnimation(self, u"attack1", 2.0f); self->AddTimer("platform1attack", 1.75f); } else if (point == 12) { - GameMessages::SendPlayAnimation(self, u"attack2", 2); + RenderComponent::PlayAnimation(self, u"attack2", 2.0f); const auto& group2 = EntityManager::Instance()->GetEntitiesInGroup("dragonFireballs2"); @@ -101,7 +102,7 @@ void FvFlyingCreviceDragon::OnArrived(Entity* self) { } } } else if (point == 16) { - GameMessages::SendPlayAnimation(self, u"attack3", 2); + RenderComponent::PlayAnimation(self, u"attack3", 2.0f); self->AddTimer("platform3attack", 0.5f); } } diff --git a/dScripts/ai/FV/FvNinjaGuard.cpp b/dScripts/ai/FV/FvNinjaGuard.cpp index 58267999..c487f5cc 100644 --- a/dScripts/ai/FV/FvNinjaGuard.cpp +++ b/dScripts/ai/FV/FvNinjaGuard.cpp @@ -1,6 +1,8 @@ #include "FvNinjaGuard.h" #include "GameMessages.h" #include "MissionComponent.h" +#include "RenderComponent.h" +#include "EntityManager.h" void FvNinjaGuard::OnStartup(Entity* self) { if (self->GetLOT() == 7412) { @@ -12,24 +14,24 @@ void FvNinjaGuard::OnStartup(Entity* self) { void FvNinjaGuard::OnEmoteReceived(Entity* self, const int32_t emote, Entity* target) { if (emote != 392) { - GameMessages::SendPlayAnimation(self, u"no"); + RenderComponent::PlayAnimation(self, u"no"); return; } - GameMessages::SendPlayAnimation(self, u"scared"); + RenderComponent::PlayAnimation(self, u"scared"); if (self->GetLOT() == 7412) { auto* rightGuard = EntityManager::Instance()->GetEntity(m_RightGuard); if (rightGuard != nullptr) { - GameMessages::SendPlayAnimation(rightGuard, u"laugh_rt"); + RenderComponent::PlayAnimation(rightGuard, u"laugh_rt"); } } else if (self->GetLOT() == 11128) { auto* leftGuard = EntityManager::Instance()->GetEntity(m_LeftGuard); if (leftGuard != nullptr) { - GameMessages::SendPlayAnimation(leftGuard, u"laugh_lt"); + RenderComponent::PlayAnimation(leftGuard, u"laugh_lt"); } } } diff --git a/dScripts/ai/GENERAL/LegoDieRoll.cpp b/dScripts/ai/GENERAL/LegoDieRoll.cpp index 89819271..add3cd06 100644 --- a/dScripts/ai/GENERAL/LegoDieRoll.cpp +++ b/dScripts/ai/GENERAL/LegoDieRoll.cpp @@ -2,6 +2,7 @@ #include "Entity.h" #include "GameMessages.h" #include "MissionComponent.h" +#include "RenderComponent.h" #include "eMissionState.h" void LegoDieRoll::OnStartup(Entity* self) { @@ -17,23 +18,23 @@ void LegoDieRoll::OnTimerDone(Entity* self, std::string timerName) { switch (dieRoll) { case 1: - GameMessages::SendPlayAnimation(self, u"roll-die-1"); + RenderComponent::PlayAnimation(self, u"roll-die-1"); break; case 2: - GameMessages::SendPlayAnimation(self, u"roll-die-2"); + RenderComponent::PlayAnimation(self, u"roll-die-2"); break; case 3: - GameMessages::SendPlayAnimation(self, u"roll-die-3"); + RenderComponent::PlayAnimation(self, u"roll-die-3"); break; case 4: - GameMessages::SendPlayAnimation(self, u"roll-die-4"); + RenderComponent::PlayAnimation(self, u"roll-die-4"); break; case 5: - GameMessages::SendPlayAnimation(self, u"roll-die-5"); + RenderComponent::PlayAnimation(self, u"roll-die-5"); break; case 6: { - GameMessages::SendPlayAnimation(self, u"roll-die-6"); + RenderComponent::PlayAnimation(self, u"roll-die-6"); // tracking the It's Truly Random Achievement auto* owner = self->GetOwner(); auto* missionComponent = owner->GetComponent(); diff --git a/dScripts/ai/GF/GfOrgan.cpp b/dScripts/ai/GF/GfOrgan.cpp index 372ed3a2..3184aa82 100644 --- a/dScripts/ai/GF/GfOrgan.cpp +++ b/dScripts/ai/GF/GfOrgan.cpp @@ -1,5 +1,7 @@ #include "GfOrgan.h" #include "GameMessages.h" +#include "Entity.h" +#include "RenderComponent.h" void GfOrgan::OnUse(Entity* self, Entity* user) { if (self->GetBoolean(u"bIsInUse")) { @@ -11,7 +13,7 @@ void GfOrgan::OnUse(Entity* self, Entity* user) { self->SetBoolean(u"bIsInUse", true); self->AddTimer("reset", 5.0f); - GameMessages::SendPlayAnimation(user, u"jig"); + RenderComponent::PlayAnimation(user, u"jig"); } void GfOrgan::OnTimerDone(Entity* self, std::string timerName) { diff --git a/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp b/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp index 703c6bbd..a62f6ee5 100644 --- a/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp +++ b/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp @@ -15,6 +15,7 @@ #include "InventoryComponent.h" #include "eMissionTaskType.h" #include "eReplicaComponentType.h" +#include "RenderComponent.h" void SGCannon::OnStartup(Entity* self) { Game::logger->Log("SGCannon", "OnStartup"); @@ -508,17 +509,17 @@ void SGCannon::RecordPlayerScore(Entity* self) { void SGCannon::PlaySceneAnimation(Entity* self, const std::u16string& animationName, bool onCannon, bool onPlayer, float_t priority) { for (auto* cannon : EntityManager::Instance()->GetEntitiesInGroup("cannongroup")) { - GameMessages::SendPlayAnimation(cannon, animationName, priority); + RenderComponent::PlayAnimation(cannon, animationName, priority); } if (onCannon) { - GameMessages::SendPlayAnimation(self, animationName, priority); + RenderComponent::PlayAnimation(self, animationName, priority); } if (onPlayer) { auto* player = EntityManager::Instance()->GetEntity(self->GetVar(PlayerIDVariable)); if (player != nullptr) { - GameMessages::SendPlayAnimation(player, animationName, priority); + RenderComponent::PlayAnimation(player, animationName, priority); } } } diff --git a/dScripts/ai/NS/NsConcertInstrument.cpp b/dScripts/ai/NS/NsConcertInstrument.cpp index c7478a05..08464e5a 100644 --- a/dScripts/ai/NS/NsConcertInstrument.cpp +++ b/dScripts/ai/NS/NsConcertInstrument.cpp @@ -9,6 +9,7 @@ #include "MissionComponent.h" #include "eMissionState.h" #include "eMissionTaskType.h" +#include "RenderComponent.h" // Constants are at the bottom @@ -122,7 +123,7 @@ void NsConcertInstrument::StartPlayingInstrument(Entity* self, Entity* player) { player->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendPlayCinematic(player->GetObjectID(), cinematics.at(instrumentLot), UNASSIGNED_SYSTEM_ADDRESS); self->AddCallbackTimer(1.0f, [player, instrumentLot]() { - GameMessages::SendPlayAnimation(player, animations.at(instrumentLot), 2.0f); + RenderComponent::PlayAnimation(player, animations.at(instrumentLot), 2.0f); }); for (auto* soundBox : EntityManager::Instance()->GetEntitiesInGroup("Audio-Concert")) { @@ -153,7 +154,7 @@ void NsConcertInstrument::StopPlayingInstrument(Entity* self, Entity* player) { } GameMessages::SendEndCinematic(player->GetObjectID(), cinematics.at(instrumentLot), UNASSIGNED_SYSTEM_ADDRESS, 1.0f); - GameMessages::SendPlayAnimation(player, smashAnimations.at(instrumentLot), 2.0f); + RenderComponent::PlayAnimation(player, smashAnimations.at(instrumentLot), 2.0f); GameMessages::SendNotifyClientObject(self->GetObjectID(), u"stopCheckingMovement", 0, 0, player->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS); } diff --git a/dScripts/ai/NS/WhFans.cpp b/dScripts/ai/NS/WhFans.cpp index 44354127..8500e824 100644 --- a/dScripts/ai/NS/WhFans.cpp +++ b/dScripts/ai/NS/WhFans.cpp @@ -4,6 +4,8 @@ #include "GameMessages.h" #include "EntityManager.h" #include "PhantomPhysicsComponent.h" +#include "RenderComponent.h" +#include "Entity.h" void WhFans::OnStartup(Entity* self) { self->SetVar(u"alive", true); @@ -30,7 +32,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) { if (fanVolumes.size() == 0 || !self->GetVar(u"alive")) return; if (self->GetVar(u"on")) { - GameMessages::SendPlayAnimation(self, u"fan-off"); + RenderComponent::PlayAnimation(self, u"fan-off"); renderComponent->StopEffect("fanOn"); self->SetVar(u"on", false); @@ -42,7 +44,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) { EntityManager::Instance()->SerializeEntity(volume); } } else if (!self->GetVar(u"on") && self->GetVar(u"alive")) { - GameMessages::SendPlayAnimation(self, u"fan-on"); + RenderComponent::PlayAnimation(self, u"fan-on"); self->SetVar(u"on", true); diff --git a/dScripts/ai/WILD/WildAmbients.cpp b/dScripts/ai/WILD/WildAmbients.cpp index 16dfa043..c21b6d76 100644 --- a/dScripts/ai/WILD/WildAmbients.cpp +++ b/dScripts/ai/WILD/WildAmbients.cpp @@ -1,6 +1,7 @@ #include "WildAmbients.h" #include "GameMessages.h" +#include "RenderComponent.h" void WildAmbients::OnUse(Entity* self, Entity* user) { - GameMessages::SendPlayAnimation(self, u"interact"); + RenderComponent::PlayAnimation(self, u"interact"); }