diff --git a/ElunaTemplate.h b/ElunaTemplate.h index a10e593..d6c4e02 100644 --- a/ElunaTemplate.h +++ b/ElunaTemplate.h @@ -27,11 +27,13 @@ template class ElunaTemplate { public: - static const char* tname; - static bool manageMemory; + static const char* tname = NULL; + static bool manageMemory = false; static int typeT(lua_State* L) { + ASSERT(tname); + lua_pushstring(L, tname); return 1; } @@ -42,6 +44,8 @@ public: // that will only be needed on lua side and will not be managed by TC/mangos/ static void Register(lua_State* L, const char* name, bool gc = false) { + ASSERT(!tname); + tname = name; manageMemory = gc; @@ -86,6 +90,8 @@ public: template static void SetMethods(lua_State* L, ElunaRegister* methodTable) { + ASSERT(tname); + if (!methodTable) return; @@ -120,6 +126,8 @@ public: // Remember special case ElunaTemplate::gcT static int gcT(lua_State* L) { + ASSERT(tname); + if (!manageMemory) return 0; @@ -132,6 +140,8 @@ public: static int push(lua_State* L, T const* obj) { + ASSERT(tname); + if (!obj) { lua_pushnil(L); @@ -186,6 +196,8 @@ public: static T* check(lua_State* L, int narg, bool error = true) { + ASSERT(tname); + T** ptrHold = static_cast(lua_touserdata(L, narg)); if (!ptrHold) { @@ -227,6 +239,8 @@ public: static int thunk(lua_State* L) { + ASSERT(tname); + T* obj = Eluna::CHECKOBJ(L, 1); // get self if (!obj) return 0; @@ -245,6 +259,8 @@ public: static int tostringT(lua_State* L) { + ASSERT(tname); + T* obj = Eluna::CHECKOBJ(L, 1); // get self if (obj) lua_pushfstring(L, "%s: (%p)", tname, obj); diff --git a/GlobalMethods.h b/GlobalMethods.h index d3a9677..2dfa4bc 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -152,9 +152,9 @@ namespace LuaGlobalFunctions if (Player* player = it->second->GetPlayer()) { #ifndef TRINITY - if (player->GetSession() && ((team >= TEAM_NEUTRAL || player->GetTeamId() == team) && (!onlyGM || player->isGameMaster()))) + if ((team == TEAM_NEUTRAL || player->GetTeamId() == team) && (!onlyGM || player->isGameMaster())) #else - if (player->GetSession() && ((team >= TEAM_NEUTRAL || player->GetTeamId() == team) && (!onlyGM || player->IsGameMaster()))) + if ((team == TEAM_NEUTRAL || player->GetTeamId() == team) && (!onlyGM || player->IsGameMaster())) #endif { ++i; @@ -1262,7 +1262,6 @@ namespace LuaGlobalFunctions item->SaveToDB(); #else item->SaveToDB(trans); - SQLTransaction trans = CharacterDatabase.BeginTransaction(); #endif draft.AddItem(item); ++addedItems;