mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Merge new_bindings, closes #151
Refer to 6194ddb43c for new C++11 required changes for mangos based cores
This commit is contained in:
@@ -14,18 +14,15 @@
|
||||
* Sets up the stack so that event handlers can be called.
|
||||
*
|
||||
* Returns the number of functions that were pushed onto the stack.
|
||||
*
|
||||
* Use the simpler overloads for just EventBind or EntryBind instead of this overload in hooks.
|
||||
*/
|
||||
template<typename T>
|
||||
int Eluna::SetupStack(EventBind<T>* event_bindings, EntryBind<T>* entry_bindings, UniqueBind<T>* guid_bindings, T event_id, uint32 entry, uint64 guid, uint32 instanceId, int number_of_arguments)
|
||||
template<typename K1, typename K2>
|
||||
int Eluna::SetupStack(BindingMap<K1>* bindings1, BindingMap<K2>* bindings2, const K1& key1, const K2& key2, int number_of_arguments)
|
||||
{
|
||||
// Ensure that if `entry_bindings` is not NULL, a valid entry is supplied.
|
||||
ASSERT(!entry_bindings || (entry_bindings && entry > 0));
|
||||
ASSERT(number_of_arguments == this->push_counter);
|
||||
ASSERT(key1.event_id == key2.event_id);
|
||||
// Stack: [arguments]
|
||||
|
||||
Push(event_id);
|
||||
Push(key1.event_id);
|
||||
this->push_counter = 0;
|
||||
++number_of_arguments;
|
||||
// Stack: [arguments], event_id
|
||||
@@ -37,14 +34,9 @@ int Eluna::SetupStack(EventBind<T>* event_bindings, EntryBind<T>* entry_bindings
|
||||
lua_insert(L, first_argument_index);
|
||||
// Stack: event_id, [arguments]
|
||||
|
||||
if (event_bindings)
|
||||
event_bindings->PushFuncRefs(L, (int)event_id);
|
||||
|
||||
if (entry_bindings)
|
||||
entry_bindings->PushFuncRefs(L, (int)event_id, entry);
|
||||
|
||||
if (guid_bindings)
|
||||
guid_bindings->PushFuncRefs(L, (int)event_id, guid, instanceId);
|
||||
bindings1->PushRefsFor(key1);
|
||||
if (bindings2)
|
||||
bindings2->PushRefsFor(key2);
|
||||
// Stack: event_id, [arguments], [functions]
|
||||
|
||||
int number_of_functions = lua_gettop(L) - arguments_top;
|
||||
@@ -70,13 +62,13 @@ void Eluna::ReplaceArgument(T value, uint8 index)
|
||||
/*
|
||||
* Call all event handlers registered to the event ID/entry combination and ignore any results.
|
||||
*/
|
||||
template<typename T>
|
||||
void Eluna::CallAllFunctions(EventBind<T>* event_bindings, EntryBind<T>* entry_bindings, UniqueBind<T>* guid_bindings, T event_id, uint32 entry, uint64 guid, uint32 instanceId)
|
||||
template<typename K1, typename K2>
|
||||
void Eluna::CallAllFunctions(BindingMap<K1>* bindings1, BindingMap<K2>* bindings2, const K1& key1, const K2& key2)
|
||||
{
|
||||
int number_of_arguments = this->push_counter;
|
||||
// Stack: [arguments]
|
||||
|
||||
int number_of_functions = SetupStack(event_bindings, entry_bindings, guid_bindings, event_id, entry, guid, instanceId, number_of_arguments);
|
||||
int number_of_functions = SetupStack(bindings1, bindings2, key1, key2, number_of_arguments);
|
||||
// Stack: event_id, [arguments], [functions]
|
||||
|
||||
while (number_of_functions > 0)
|
||||
@@ -96,15 +88,15 @@ void Eluna::CallAllFunctions(EventBind<T>* event_bindings, EntryBind<T>* entry_b
|
||||
* and returns `default_value` if ALL event handlers returned `default_value`,
|
||||
* otherwise returns the opposite of `default_value`.
|
||||
*/
|
||||
template<typename T>
|
||||
bool Eluna::CallAllFunctionsBool(EventBind<T>* event_bindings, EntryBind<T>* entry_bindings, UniqueBind<T>* guid_bindings, T event_id, uint32 entry, uint64 guid, uint32 instanceId, bool default_value)
|
||||
template<typename K1, typename K2>
|
||||
bool Eluna::CallAllFunctionsBool(BindingMap<K1>* bindings1, BindingMap<K2>* bindings2, const K1& key1, const K2& key2, bool default_value/* = false*/)
|
||||
{
|
||||
bool result = default_value;
|
||||
// Note: number_of_arguments here does not count in eventID, which is pushed in SetupStack
|
||||
int number_of_arguments = this->push_counter;
|
||||
// Stack: [arguments]
|
||||
|
||||
int number_of_functions = SetupStack(event_bindings, entry_bindings, guid_bindings, event_id, entry, guid, instanceId, number_of_arguments);
|
||||
int number_of_functions = SetupStack(bindings1, bindings2, key1, key2, number_of_arguments);
|
||||
// Stack: event_id, [arguments], [functions]
|
||||
|
||||
while (number_of_functions > 0)
|
||||
|
||||
Reference in New Issue
Block a user