Fractured: Paragon core hooks, mod-paragon, mod-ale, Docker build cap
- Track mod-paragon and mod-ale (un-ignore modules in .gitignore). - Ship docker-compose.override.yml with CMAKE_EXTRA_OPTIONS for LuaJIT (mod-ale). - Dockerfile: CBUILD_PARALLEL default to limit OOM under Docker/WSL2. - Core: CLASS_PARAGON sticky combo points (DetachComboTarget), selection rebind, Spell::CheckPower rune path for multi-resource Paragon. - spell_dk_death_rune: IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY) for Blood of the North / Reaping / DRM on Paragon. - Remove temporary Paragon CheckPower logging. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2025 Eluna Lua Engine <https://elunaluaengine.github.io/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef _HOOK_HELPERS_H
|
||||
#define _HOOK_HELPERS_H
|
||||
|
||||
#include "LuaEngine.h"
|
||||
#include "ALEUtility.h"
|
||||
|
||||
/*
|
||||
* Sets up the stack so that event handlers can be called.
|
||||
*
|
||||
* Returns the number of functions that were pushed onto the stack.
|
||||
*/
|
||||
template<typename K1, typename K2>
|
||||
int ALE::SetupStack(BindingMap<K1>* bindings1, BindingMap<K2>* bindings2, const K1& key1, const K2& key2, int number_of_arguments)
|
||||
{
|
||||
ASSERT(number_of_arguments == this->push_counter);
|
||||
ASSERT(key1.event_id == key2.event_id);
|
||||
// Stack: [arguments]
|
||||
|
||||
Push(key1.event_id);
|
||||
this->push_counter = 0;
|
||||
++number_of_arguments;
|
||||
// Stack: [arguments], event_id
|
||||
|
||||
int arguments_top = lua_gettop(L);
|
||||
int first_argument_index = arguments_top - number_of_arguments + 1;
|
||||
ASSERT(arguments_top >= number_of_arguments);
|
||||
|
||||
lua_insert(L, first_argument_index);
|
||||
// Stack: event_id, [arguments]
|
||||
|
||||
bindings1->PushRefsFor(key1);
|
||||
if (bindings2)
|
||||
bindings2->PushRefsFor(key2);
|
||||
// Stack: event_id, [arguments], [functions]
|
||||
|
||||
int number_of_functions = lua_gettop(L) - arguments_top;
|
||||
return number_of_functions;
|
||||
}
|
||||
|
||||
/*
|
||||
* Replace one of the arguments pushed before `SetupStack` with a new value.
|
||||
*/
|
||||
template<typename T>
|
||||
void ALE::ReplaceArgument(T value, uint8 index)
|
||||
{
|
||||
ASSERT(index < lua_gettop(L) && index > 0);
|
||||
// Stack: event_id, [arguments], [functions], [results]
|
||||
|
||||
ALE::Push(L, value);
|
||||
// Stack: event_id, [arguments], [functions], [results], value
|
||||
|
||||
lua_replace(L, index + 1);
|
||||
// Stack: event_id, [arguments and value], [functions], [results]
|
||||
}
|
||||
|
||||
/*
|
||||
* Call all event handlers registered to the event ID/entry combination and ignore any results.
|
||||
*/
|
||||
template<typename K1, typename K2>
|
||||
void ALE::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(bindings1, bindings2, key1, key2, number_of_arguments);
|
||||
// Stack: event_id, [arguments], [functions]
|
||||
|
||||
while (number_of_functions > 0)
|
||||
{
|
||||
CallOneFunction(number_of_functions, number_of_arguments, 0);
|
||||
--number_of_functions;
|
||||
// Stack: event_id, [arguments], [functions - 1]
|
||||
}
|
||||
// Stack: event_id, [arguments]
|
||||
|
||||
CleanUpStack(number_of_arguments);
|
||||
// Stack: (empty)
|
||||
}
|
||||
|
||||
/*
|
||||
* Call all event handlers registered to the event ID/entry combination,
|
||||
* and returns `default_value` if ALL event handlers returned `default_value`,
|
||||
* otherwise returns the opposite of `default_value`.
|
||||
*/
|
||||
template<typename K1, typename K2>
|
||||
bool ALE::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(bindings1, bindings2, key1, key2, number_of_arguments);
|
||||
// Stack: event_id, [arguments], [functions]
|
||||
|
||||
while (number_of_functions > 0)
|
||||
{
|
||||
int r = CallOneFunction(number_of_functions, number_of_arguments, 1);
|
||||
--number_of_functions;
|
||||
// Stack: event_id, [arguments], [functions - 1], result
|
||||
|
||||
if (lua_isboolean(L, r) && (lua_toboolean(L, r) == 1) != default_value)
|
||||
result = !default_value;
|
||||
|
||||
lua_pop(L, 1);
|
||||
// Stack: event_id, [arguments], [functions - 1]
|
||||
}
|
||||
// Stack: event_id, [arguments]
|
||||
|
||||
CleanUpStack(number_of_arguments);
|
||||
// Stack: (empty)
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // _HOOK_HELPERS_H
|
||||
Reference in New Issue
Block a user