Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit edb5d32

Browse files
committed
Changed GetSupportedScriptFunctionNames to preprocessor macros so it's easier to find and use
1 parent e3bc4fc commit edb5d32

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

Entities/Actor.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class Actor:
7272

7373
// Concrete allocation and cloning definitions
7474
ENTITYALLOCATION(Actor)
75+
ADD_SCRIPT_FUNCTION_NAMES(MOSRotating, "UpdateAI")
7576

7677

7778
//////////////////////////////////////////////////////////////////////////////////////////
@@ -1534,12 +1535,6 @@ ENTITYALLOCATION(Actor)
15341535
// Timer for measuring interval between height checks
15351536
Timer m_FallTimer;
15361537

1537-
/// <summary>
1538-
/// Gets a vector containing the script function names this class supports.
1539-
/// </summary>
1540-
/// <returns>A vector containing the script function names this class supports.</returns>
1541-
virtual const std::vector<std::string> GetSupportedScriptFunctionNames() const override { auto functionNames = MOSRotating::GetSupportedScriptFunctionNames(); functionNames.insert(functionNames.end(), {"UpdateAI"}); return functionNames; }
1542-
15431538
//////////////////////////////////////////////////////////////////////////////////////////
15441539
// Private member variable and method declarations
15451540

Entities/Attachable.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class Attachable:
4242

4343
// Concrete allocation and cloning definitions
4444
ENTITYALLOCATION(Attachable)
45+
ADD_SCRIPT_FUNCTION_NAMES(MOSRotating, "OnAttach", "OnDetach")
4546

4647

4748
//////////////////////////////////////////////////////////////////////////////////////////
@@ -700,12 +701,6 @@ ENTITYALLOCATION(Attachable)
700701
// Whether this attachable currently has terrain collisions enabled while it's attached to a parent.
701702
bool m_IsCollidingWithTerrainWhileAttached;
702703

703-
/// <summary>
704-
/// Gets a vector containing the script function names this class supports.
705-
/// </summary>
706-
/// <returns>A vector containing the script function names this class supports.</returns>
707-
virtual const std::vector<std::string> GetSupportedScriptFunctionNames() const override { auto functionNames = MOSRotating::GetSupportedScriptFunctionNames(); functionNames.insert(functionNames.end(), {"OnAttach", "OnDetach"}); return functionNames; }
708-
709704

710705
//////////////////////////////////////////////////////////////////////////////////////////
711706
// Private member variable and method declarations

Entities/MovableObject.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ struct BITMAP;
2626
namespace RTE
2727
{
2828

29+
30+
#pragma region Global Macro Definitions
31+
#define SCRIPT_FUNCTION_NAMES(...) \
32+
virtual std::vector<std::string> GetSupportedScriptFunctionNames() const { return {__VA_ARGS__}; }
33+
34+
#define ADD_SCRIPT_FUNCTION_NAMES(PARENT, ...) \
35+
virtual std::vector<std::string> GetSupportedScriptFunctionNames() const override { \
36+
std::vector<std::string> functionNames = PARENT::GetSupportedScriptFunctionNames(); \
37+
functionNames.insert(functionNames.end(), {__VA_ARGS__}); \
38+
return functionNames; \
39+
}
40+
#pragma endregion
41+
2942
struct HitData;
3043

3144

@@ -46,6 +59,7 @@ friend class LuaMan;
4659
// Public member variable, method and friend function declarations
4760

4861
public:
62+
SCRIPT_FUNCTION_NAMES("Create", "Destroy", "Update", "OnScriptRemoveOrDisable", "OnScriptEnable", "OnPieMenu", "OnCollideWithTerrain", "OnCollideWithMO")
4963

5064
enum MOType
5165
{
@@ -1778,13 +1792,6 @@ ENTITYALLOCATION(MovableObject)
17781792
// Protected member variable and method declarations
17791793

17801794
protected:
1781-
1782-
/// <summary>
1783-
/// Gets a vector containing the script function names this class supports.
1784-
/// </summary>
1785-
/// <returns>A vector containing the script function names this class supports.</returns>
1786-
virtual const std::vector<std::string> GetSupportedScriptFunctionNames() const { return std::vector<std::string> {"Create", "Destroy", "Update", "OnScriptRemoveOrDisable", "OnScriptEnable", "OnPieMenu", "OnCollideWithTerrain", "OnCollideWithMO"}; }
1787-
17881795
/// <summary>
17891796
/// Does necessary work to setup a script object name for this object, allowing it to be accessed in Lua, then runs all of the MO's scripts' Create functions in Lua.
17901797
/// </summary>

cpp.hint

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
#define CLASSINFOGETTERS const Entity::ClassInfo & GetClass() const { return m_sClass; } const std::string & GetClassName() const { return m_sClass.GetName(); }
66
#define ABSTRACTCLASSINFO(TYPE, PARENT) Entity::ClassInfo TYPE::m_sClass(#TYPE, &PARENT::m_sClass);
77
#define CONCRETECLASSINFO(TYPE, PARENT, BLOCKCOUNT) Entity::ClassInfo TYPE::m_sClass(#TYPE, &PARENT::m_sClass, TYPE::Allocate, TYPE::Deallocate, TYPE::NewInstance, BLOCKCOUNT);
8+
#define SCRIPT_FUNCTION_NAMES(...) virtual std::vector<std::string> GetSupportedScriptFunctionNames() const { return {__VA_ARGS__}; }
9+
#define ADD_SCRIPT_FUNCTION_NAMES(PARENT, ...) virtual std::vector<std::string> GetSupportedScriptFunctionNames() const override { std::vector<std::string> functionNames = PARENT::GetSupportedScriptFunctionNames(); functionNames.insert(functionNames.end(), {__VA_ARGS__}); return functionNames; }

0 commit comments

Comments
 (0)