Skip to content

Commit

Permalink
Merge pull request #455 from ElunaLuaEngine/multistate
Browse files Browse the repository at this point in the history
Multistate implementation
  • Loading branch information
Foereaper authored Jan 26, 2024
2 parents 7fc7e01 + dc9e571 commit b6838d5
Show file tree
Hide file tree
Showing 68 changed files with 7,568 additions and 6,673 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
with:
submodules: false
repository: ElunaLuaEngine/ElunaTrinityWotlk
ref: multistate
- uses: actions/checkout@v3
with:
path: src/server/game/LuaEngine
Expand Down
29 changes: 14 additions & 15 deletions BattleGroundHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ using namespace Hooks;
return;\
auto key = EventKey<BGEvents>(EVENT);\
if (!BGEventBindings->HasBindingsFor(key))\
return;\
LOCK_ELUNA
return;

void Eluna::OnBGStart(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId)
{
START_HOOK(BG_EVENT_ON_START);
Push(bg);
Push(bgId);
Push(instanceId);
HookPush(bg);
HookPush(bgId);
HookPush(instanceId);
CallAllFunctions(BGEventBindings, key);
}

Expand All @@ -36,27 +35,27 @@ void Eluna::OnBGEnd(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId
#endif
{
START_HOOK(BG_EVENT_ON_END);
Push(bg);
Push(bgId);
Push(instanceId);
Push(winner);
HookPush(bg);
HookPush(bgId);
HookPush(instanceId);
HookPush(winner);
CallAllFunctions(BGEventBindings, key);
}

void Eluna::OnBGCreate(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId)
{
START_HOOK(BG_EVENT_ON_CREATE);
Push(bg);
Push(bgId);
Push(instanceId);
HookPush(bg);
HookPush(bgId);
HookPush(instanceId);
CallAllFunctions(BGEventBindings, key);
}

void Eluna::OnBGDestroy(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId)
{
START_HOOK(BG_EVENT_ON_PRE_DESTROY);
Push(bg);
Push(bgId);
Push(instanceId);
HookPush(bg);
HookPush(bgId);
HookPush(instanceId);
CallAllFunctions(BGEventBindings, key);
}
14 changes: 1 addition & 13 deletions BindingMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extern "C"
* A set of bindings from keys of type `K` to Lua references.
*/
template<typename K>
class BindingMap : public ElunaUtil::Lockable
class BindingMap
{
private:
lua_State* L;
Expand Down Expand Up @@ -78,8 +78,6 @@ class BindingMap : public ElunaUtil::Lockable
*/
uint64 Insert(const K& key, int ref, uint32 shots)
{
Guard guard(GetLock());

uint64 id = (++maxBindingID);
BindingList& list = bindings[key];
list.push_back(std::unique_ptr<Binding>(new Binding(L, id, ref, shots)));
Expand All @@ -92,8 +90,6 @@ class BindingMap : public ElunaUtil::Lockable
*/
void Clear(const K& key)
{
Guard guard(GetLock());

if (bindings.empty())
return;

Expand All @@ -118,8 +114,6 @@ class BindingMap : public ElunaUtil::Lockable
*/
void Clear()
{
Guard guard(GetLock());

if (bindings.empty())
return;

Expand All @@ -134,8 +128,6 @@ class BindingMap : public ElunaUtil::Lockable
*/
void Remove(uint64 id)
{
Guard guard(GetLock());

auto iter = id_lookup_table.find(id);
if (iter == id_lookup_table.end())
return;
Expand Down Expand Up @@ -163,8 +155,6 @@ class BindingMap : public ElunaUtil::Lockable
*/
bool HasBindingsFor(const K& key)
{
Guard guard(GetLock());

if (bindings.empty())
return false;

Expand All @@ -181,8 +171,6 @@ class BindingMap : public ElunaUtil::Lockable
*/
void PushRefsFor(const K& key)
{
Guard guard(GetLock());

if (bindings.empty())
return;

Expand Down
Loading

0 comments on commit b6838d5

Please sign in to comment.