mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-18 05:18:08 +00:00
switch cppscripts to references and unique_ptrs
This commit is contained in:
@@ -1499,7 +1499,7 @@ void Entity::RequestActivityExit(Entity* sender, LWOOBJID player, bool canceled)
|
||||
|
||||
CppScripts::Script* const Entity::GetScript() {
|
||||
auto* scriptComponent = GetComponent<ScriptComponent>();
|
||||
auto* script = scriptComponent ? scriptComponent->GetScript() : CppScripts::GetInvalidScript();
|
||||
auto* script = scriptComponent ? scriptComponent->GetScript() : &CppScripts::GetInvalidScript();
|
||||
DluAssert(script != nullptr);
|
||||
return script;
|
||||
}
|
||||
@@ -2175,7 +2175,7 @@ void Entity::SetRespawnRot(const NiQuaternion& rotation) {
|
||||
|
||||
int32_t Entity::GetCollisionGroup() const {
|
||||
for (const auto* component : m_Components | std::views::values) {
|
||||
auto* compToCheck = dynamic_cast<const PhysicsComponent*>(component);
|
||||
auto* compToCheck = dynamic_cast<const PhysicsComponent*>(component);
|
||||
if (compToCheck) {
|
||||
return compToCheck->GetCollisionGroup();
|
||||
}
|
||||
|
@@ -913,11 +913,8 @@ void InventoryComponent::EquipScripts(Item* equippedItem) {
|
||||
if (scriptComponentID > -1) {
|
||||
CDScriptComponentTable* scriptCompTable = CDClientManager::GetTable<CDScriptComponentTable>();
|
||||
CDScriptComponent scriptCompData = scriptCompTable->GetByID(scriptComponentID);
|
||||
auto* itemScript = CppScripts::GetScript(m_Parent, scriptCompData.script_name);
|
||||
if (!itemScript) {
|
||||
LOG("null script?");
|
||||
}
|
||||
itemScript->OnFactionTriggerItemEquipped(m_Parent, equippedItem->GetId());
|
||||
auto& itemScript = CppScripts::GetScript(m_Parent, scriptCompData.script_name);
|
||||
itemScript.OnFactionTriggerItemEquipped(m_Parent, equippedItem->GetId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -928,11 +925,8 @@ void InventoryComponent::UnequipScripts(Item* unequippedItem) {
|
||||
if (scriptComponentID > -1) {
|
||||
CDScriptComponentTable* scriptCompTable = CDClientManager::GetTable<CDScriptComponentTable>();
|
||||
CDScriptComponent scriptCompData = scriptCompTable->GetByID(scriptComponentID);
|
||||
auto* itemScript = CppScripts::GetScript(m_Parent, scriptCompData.script_name);
|
||||
if (!itemScript) {
|
||||
LOG("null script?");
|
||||
}
|
||||
itemScript->OnFactionTriggerItemUnequipped(m_Parent, unequippedItem->GetId());
|
||||
auto& itemScript = CppScripts::GetScript(m_Parent, scriptCompData.script_name);
|
||||
itemScript.OnFactionTriggerItemUnequipped(m_Parent, unequippedItem->GetId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -48,5 +48,5 @@ CppScripts::Script* const ScriptComponent::GetScript() {
|
||||
void ScriptComponent::SetScript(const std::string& scriptName) {
|
||||
// Scripts are managed by the CppScripts class and are effecitvely singletons
|
||||
// and they may also be used by other script components so DON'T delete them.
|
||||
m_Script = CppScripts::GetScript(m_Parent, scriptName);
|
||||
m_Script = &CppScripts::GetScript(m_Parent, scriptName);
|
||||
}
|
||||
|
Reference in New Issue
Block a user