From 3ed0b2242650bace952072d62ddca8266dfb6d7a Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Tue, 24 May 2016 07:29:14 +0300 Subject: [PATCH] Make the function environment optional in entity callbacks. --- source/Entity/Blip.cpp | 5 +++++ source/Entity/Checkpoint.cpp | 5 +++++ source/Entity/Keybind.cpp | 5 +++++ source/Entity/Object.cpp | 5 +++++ source/Entity/Pickup.cpp | 5 +++++ source/Entity/Player.cpp | 5 +++++ source/Entity/Vehicle.cpp | 5 +++++ 7 files changed, 35 insertions(+) diff --git a/source/Entity/Blip.cpp b/source/Entity/Blip.cpp index df848431..14a10d7c 100644 --- a/source/Entity/Blip.cpp +++ b/source/Entity/Blip.cpp @@ -105,6 +105,11 @@ void CBlip::BindEvent(Int32 evid, Object & env, Function & func) const { event.Release(); // Then release the current callback } + // Does this function need a custom environment? + else if (env.IsNull()) + { + event = func; + } // Assign the specified environment and function else { diff --git a/source/Entity/Checkpoint.cpp b/source/Entity/Checkpoint.cpp index f41bc8cf..98f19c1e 100644 --- a/source/Entity/Checkpoint.cpp +++ b/source/Entity/Checkpoint.cpp @@ -118,6 +118,11 @@ void CCheckpoint::BindEvent(Int32 evid, Object & env, Function & func) const { event.Release(); // Then release the current callback } + // Does this function need a custom environment? + else if (env.IsNull()) + { + event = func; + } // Assign the specified environment and function else { diff --git a/source/Entity/Keybind.cpp b/source/Entity/Keybind.cpp index 92cdaab2..720e335d 100644 --- a/source/Entity/Keybind.cpp +++ b/source/Entity/Keybind.cpp @@ -105,6 +105,11 @@ void CKeybind::BindEvent(Int32 evid, Object & env, Function & func) const { event.Release(); // Then release the current callback } + // Does this function need a custom environment? + else if (env.IsNull()) + { + event = func; + } // Assign the specified environment and function else { diff --git a/source/Entity/Object.cpp b/source/Entity/Object.cpp index ce5bcf44..5a5ae983 100644 --- a/source/Entity/Object.cpp +++ b/source/Entity/Object.cpp @@ -118,6 +118,11 @@ void CObject::BindEvent(Int32 evid, Object & env, Function & func) const { event.Release(); // Then release the current callback } + // Does this function need a custom environment? + else if (env.IsNull()) + { + event = func; + } // Assign the specified environment and function else { diff --git a/source/Entity/Pickup.cpp b/source/Entity/Pickup.cpp index 7fa58fd1..d12c3f11 100644 --- a/source/Entity/Pickup.cpp +++ b/source/Entity/Pickup.cpp @@ -110,6 +110,11 @@ void CPickup::BindEvent(Int32 evid, Object & env, Function & func) const { event.Release(); // Then release the current callback } + // Does this function need a custom environment? + else if (env.IsNull()) + { + event = func; + } // Assign the specified environment and function else { diff --git a/source/Entity/Player.cpp b/source/Entity/Player.cpp index 92093809..dc1ba772 100644 --- a/source/Entity/Player.cpp +++ b/source/Entity/Player.cpp @@ -127,6 +127,11 @@ void CPlayer::BindEvent(Int32 evid, Object & env, Function & func) const { event.Release(); // Then release the current callback } + // Does this function need a custom environment? + else if (env.IsNull()) + { + event = func; + } // Assign the specified environment and function else { diff --git a/source/Entity/Vehicle.cpp b/source/Entity/Vehicle.cpp index d713407e..12f7ffbd 100644 --- a/source/Entity/Vehicle.cpp +++ b/source/Entity/Vehicle.cpp @@ -114,6 +114,11 @@ void CVehicle::BindEvent(Int32 evid, Object & env, Function & func) const { event.Release(); // Then release the current callback } + // Does this function need a custom environment? + else if (env.IsNull()) + { + event = func; + } // Assign the specified environment and function else {