Skip to content

Commit

Permalink
PT.5
Browse files Browse the repository at this point in the history
It compiles and runs!
  • Loading branch information
Niam5 committed Jul 14, 2024
1 parent 220617f commit 7e63340
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
19 changes: 10 additions & 9 deletions LuaEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ ItemEventBindings(NULL),
ItemGossipBindings(NULL),
PlayerGossipBindings(NULL),
MapEventBindings(NULL),
InstanceEventBindings(NULL),

CreatureUniqueBindings(NULL)
InstanceEventBindings(NULL)
//CreatureUniqueBindings(NULL)
{
OpenLua();
eventMgr = new EventMgr(this);
Expand Down Expand Up @@ -194,7 +193,7 @@ void Eluna::CreateBindStores()
MapEventBindings = new BindingMap< EntryKey<Hooks::InstanceEvents> >(L);
InstanceEventBindings = new BindingMap< EntryKey<Hooks::InstanceEvents> >(L);

CreatureUniqueBindings = new BindingMap< UniqueObjectKey<Hooks::CreatureEvents> >(L);
//CreatureUniqueBindings = new BindingMap< UniqueObjectKey<Hooks::CreatureEvents> >(L);
}

void Eluna::DestroyBindStores()
Expand All @@ -218,7 +217,7 @@ void Eluna::DestroyBindStores()
delete MapEventBindings;
delete InstanceEventBindings;

delete CreatureUniqueBindings;
//delete CreatureUniqueBindings;

ServerEventBindings = NULL;
PlayerEventBindings = NULL;
Expand All @@ -239,7 +238,7 @@ void Eluna::DestroyBindStores()
MapEventBindings = NULL;
InstanceEventBindings = NULL;

CreatureUniqueBindings = NULL;
//CreatureUniqueBindings = NULL;
}

void Eluna::RunScripts()
Expand Down Expand Up @@ -802,7 +801,7 @@ int Eluna::Register(uint8 regtype, uint32 entry, ObjectGuid guid, uint32 instanc
return 1; // Stack: callback
}
break;

#ifndef RETAIL
case Hooks::REGTYPE_CREATURE:
if (event_id < Hooks::CREATURE_EVENT_COUNT)
{
Expand Down Expand Up @@ -835,6 +834,7 @@ int Eluna::Register(uint8 regtype, uint32 entry, ObjectGuid guid, uint32 instanc
return 1; // Stack: callback
}
break;
#endif

case Hooks::REGTYPE_CREATURE_GOSSIP:
if (event_id < Hooks::GOSSIP_EVENT_COUNT)
Expand Down Expand Up @@ -961,7 +961,7 @@ int Eluna::Register(uint8 regtype, uint32 entry, ObjectGuid guid, uint32 instanc
}
luaL_unref(L, LUA_REGISTRYINDEX, functionRef);
std::ostringstream oss;
oss << "regtype " << static_cast<uint32>(regtype) << ", event " << event_id << ", entry " << entry << ", guid " << guid.GetRawValue() << ", instance " << instanceId;
oss << "regtype " << static_cast<uint32>(regtype) << ", event " << event_id << ", entry " << entry << ", guid " << guid.ToHexString() << ", instance " << instanceId;
luaL_error(L, "Unknown event type (%s)", oss.str().c_str());
return 0;
}
Expand Down Expand Up @@ -1023,7 +1023,7 @@ int Eluna::CallOneFunction(int number_of_functions, int number_of_arguments, int

return functions_top + 1; // Return the location of the first result (if any exist).
}

#ifndef RETAIL
CreatureAI* Eluna::GetAI(Creature* creature)
{
for (int i = 1; i < Hooks::CREATURE_EVENT_COUNT; ++i)
Expand All @@ -1040,6 +1040,7 @@ CreatureAI* Eluna::GetAI(Creature* creature)

return NULL;
}
#endif

InstanceData* Eluna::GetInstanceData(Map* map)
{
Expand Down
2 changes: 1 addition & 1 deletion LuaEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class ELUNA_GAME_API Eluna
BindingMap< EntryKey<Hooks::InstanceEvents> >* MapEventBindings;
BindingMap< EntryKey<Hooks::InstanceEvents> >* InstanceEventBindings;

BindingMap< UniqueObjectKey<Hooks::CreatureEvents> >* CreatureUniqueBindings;
//BindingMap< UniqueObjectKey<Hooks::CreatureEvents> >* CreatureUniqueBindings;

static int StackTrace(lua_State* _L);
static void Report(lua_State* _L);
Expand Down
3 changes: 2 additions & 1 deletion hooks/CreatureHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "ElunaTemplate.h"

using namespace Hooks;

#ifndef RETAIL
#define START_HOOK(EVENT, CREATURE) \
auto entry_key = EntryKey<CreatureEvents>(EVENT, CREATURE->GetEntry());\
auto unique_key = UniqueObjectKey<CreatureEvents>(EVENT, CREATURE->GET_GUID(), CREATURE->GetInstanceId());\
Expand Down Expand Up @@ -325,3 +325,4 @@ bool Eluna::OwnerAttacked(Creature* me, Unit* target)
}

#endif // TRINITY
#endif
5 changes: 3 additions & 2 deletions methods/TrinityCore/GlobalMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -2741,7 +2741,7 @@ namespace LuaGlobalFunctions
}
return 0;
}

#ifndef RETAIL
/**
* Unbinds event handlers for either all of a [Creature]'s events, or one type of event.
*
Expand Down Expand Up @@ -2779,6 +2779,7 @@ namespace LuaGlobalFunctions
}
return 0;
}
#endif

/**
* Unbinds event handlers for either all of a [Creature]'s gossip events, or one type of event.
Expand Down Expand Up @@ -3216,7 +3217,7 @@ namespace LuaGlobalFunctions

{ "ClearBattleGroundEvents", &LuaGlobalFunctions::ClearBattleGroundEvents },
{ "ClearCreatureEvents", &LuaGlobalFunctions::ClearCreatureEvents },
{ "ClearUniqueCreatureEvents", &LuaGlobalFunctions::ClearUniqueCreatureEvents },
//{ "ClearUniqueCreatureEvents", &LuaGlobalFunctions::ClearUniqueCreatureEvents },
{ "ClearCreatureGossipEvents", &LuaGlobalFunctions::ClearCreatureGossipEvents },
{ "ClearGameObjectEvents", &LuaGlobalFunctions::ClearGameObjectEvents },
{ "ClearGameObjectGossipEvents", &LuaGlobalFunctions::ClearGameObjectGossipEvents },
Expand Down
17 changes: 10 additions & 7 deletions methods/TrinityCore/ObjectMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace LuaObject
E->Push(obj->IsInWorld());
return 1;
}

#ifndef RETAIL
/**
* Returns the data at the specified index, casted to a signed 32-bit integer.
*
Expand Down Expand Up @@ -123,6 +123,7 @@ namespace LuaObject
E->Push(obj->GetUInt16Value(index, offset));
return 1;
}
#endif

/**
* Returns the scale/size of the [Object].
Expand Down Expand Up @@ -209,6 +210,7 @@ namespace LuaObject
return 1;
}

#ifndef RETAIL
/**
* Returns the data at the specified index, casted to an unsigned 64-bit integer.
*
Expand All @@ -221,6 +223,7 @@ namespace LuaObject
E->Push(obj->GetUInt64Value(index));
return 1;
}
#endif

/**
* Sets the specified flag in the data value at the specified index.
Expand Down Expand Up @@ -460,12 +463,12 @@ namespace LuaObject
{ "GetEntry", &LuaObject::GetEntry },
{ "GetGUID", &LuaObject::GetGUID },
{ "GetGUIDLow", &LuaObject::GetGUIDLow },
{ "GetInt32Value", &LuaObject::GetInt32Value },
{ "GetUInt32Value", &LuaObject::GetUInt32Value },
{ "GetFloatValue", &LuaObject::GetFloatValue },
{ "GetByteValue", &LuaObject::GetByteValue },
{ "GetUInt16Value", &LuaObject::GetUInt16Value },
{ "GetUInt64Value", &LuaObject::GetUInt64Value },
//{ "GetInt32Value", &LuaObject::GetInt32Value },
//{ "GetUInt32Value", &LuaObject::GetUInt32Value },
//{ "GetFloatValue", &LuaObject::GetFloatValue },
//{ "GetByteValue", &LuaObject::GetByteValue },
//{ "GetUInt16Value", &LuaObject::GetUInt16Value },
//{ "GetUInt64Value", &LuaObject::GetUInt64Value },
{ "GetScale", &LuaObject::GetScale },
{ "GetTypeId", &LuaObject::GetTypeId },

Expand Down

0 comments on commit 7e63340

Please sign in to comment.