Fix previous commits to be more efficient overall and have better logic. Also try fix clang error.

This commit is contained in:
Rochet2
2014-12-19 14:19:00 +02:00
parent 2c694bb4d4
commit 88dcea9cb7
3 changed files with 131 additions and 377 deletions

View File

@@ -51,17 +51,7 @@ using namespace HookMgr;
const char* _LuaBindType = this->BINDMAP->groupName; \
uint32 _LuaEvent = EVENT; \
int _LuaStackTop = lua_gettop(L); \
bool _LuaTemporariesDied = false; \
for (size_t i = 0; i < this->BINDMAP->Bindings[_LuaEvent].size(); ++i) \
{ \
if (this->BINDMAP->Bindings[_LuaEvent][i].isTemporary) \
{ \
this->BINDMAP->Bindings[_LuaEvent][i].remainingShots--; \
if (this->BINDMAP->Bindings[_LuaEvent][i].remainingShots == 0) \
_LuaTemporariesDied = true; \
} \
lua_rawgeti(L, LUA_REGISTRYINDEX, (this->BINDMAP->Bindings[_LuaEvent][i].functionReference)); \
} \
this->BINDMAP->PushFuncRefs(L, _LuaEvent); \
int _LuaFuncTop = lua_gettop(L); \
int _LuaFuncCount = _LuaFuncTop-_LuaStackTop; \
Eluna::Push(L, _LuaEvent);
@@ -95,17 +85,7 @@ using namespace HookMgr;
const char* _LuaBindType = _LuaBind->groupName; \
uint32 _LuaEvent = EVENT; \
int _LuaStackTop = lua_gettop(L); \
bool _LuaTemporariesDied = false; \
for (size_t i = 0; i < this->BINDMAP->Bindings[ENTRY][_LuaEvent].size(); ++i) \
{ \
if (this->BINDMAP->Bindings[ENTRY][_LuaEvent][i].isTemporary) \
{ \
this->BINDMAP->Bindings[ENTRY][_LuaEvent][i].remainingShots--; \
if (this->BINDMAP->Bindings[ENTRY][_LuaEvent][i].remainingShots == 0) \
_LuaTemporariesDied = true; \
} \
lua_rawgeti(L, LUA_REGISTRYINDEX, (this->BINDMAP->Bindings[ENTRY][_LuaEvent][i].functionReference)); \
} \
this->BINDMAP->PushFuncRefs(L, _LuaEvent, ENTRY); \
int _LuaFuncTop = lua_gettop(L); \
int _LuaFuncCount = _LuaFuncTop-_LuaStackTop; \
Eluna::Push(L, _LuaEvent);
@@ -141,8 +121,6 @@ using namespace HookMgr;
ELUNA_LOG_ERROR("[Eluna]: Ending event %u for %s, stack top was %i and was supposed to be between %i and %i. Report to devs", _LuaEvent, _LuaBindType, lua_gettop(L), _LuaStackTop, _LuaStackTop + _LuaFuncCount * _LuaReturnValues); \
} \
lua_settop(L, _LuaStackTop); \
if (_LuaTemporariesDied) \
_LuaBind->UpdateTemporaryBindings(); \
if (!this->event_level) \
this->InvalidateObjects(); // Invalidate objects on outermost hook call