Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
LuaEngine.cpp
Go to the documentation of this file.
1/*
2* Copyright (C) 2010 - 2013 Eluna Lua Engine <http://emudevs.com/>
3* This program is free software licensed under GPL version 3
4* Please see the included DOCS/LICENSE.TXT for more information
5*/
6
7#include "LuaEngine.h"
8#include "LuaFunctions.h"
9#include "Config.h"
10#include "HookMgr.h"
11
12#define TC_LOG_INFO SF_LOG_INFO
13#define TC_LOG_ERROR SF_LOG_ERROR
14
15#if PLATFORM == PLATFORM_UNIX
16#include <dirent.h>
17#include <sys/stat.h>
18#endif
19
20template<typename T> const char* GetTName() { return NULL; }
21template<> const char* GetTName<Object>() { return "Object"; }
22template<> const char* GetTName<WorldObject>() { return "WorldObject"; }
23template<> const char* GetTName<Unit>() { return "Unit"; }
24template<> const char* GetTName<Player>() { return "Player"; }
25template<> const char* GetTName<Creature>() { return "Creature"; }
26template<> const char* GetTName<GameObject>() { return "GameObject"; }
27template<> const char* GetTName<Vehicle>() { return "Vehicle"; }
28template<> const char* GetTName<Group>() { return "Group"; }
29template<> const char* GetTName<Guild>() { return "Guild"; }
30template<> const char* GetTName<QueryResult>() { return "QueryResult"; }
31template<> const char* GetTName<Aura>() { return "Aura"; }
32template<> const char* GetTName<WorldPacket>() { return "WorldPacket"; }
33template<> const char* GetTName<Item>() { return "Item"; }
34template<> const char* GetTName<Spell>() { return "Spell"; }
35template<> const char* GetTName<Quest>() { return "Quest"; }
36template<> const char* GetTName<Map>() { return "Map"; }
37template<> const char* GetTName<Corpse>() { return "Corpse"; }
38template<> const char* GetTName<Weather>() { return "Weather"; }
39template<> const char* GetTName<AuctionHouseObject>() { return "AuctionHouse"; }
40
41void StartEluna(bool restart)
42{
43 if (restart)
44 {
45 sHookMgr->OnEngineRestart();
46 TC_LOG_INFO("server.loading", "[Eluna]: Restarting Lua Engine");
47
48 if (sEluna->L)
49 {
50 // Unregisters and stops all timed events
51 sEluna->m_EventMgr.RemoveEvents();
52
53 // Remove bindings
54 for (std::map<int, std::vector<int> >::iterator itr = sEluna->ServerEventBindings.begin(); itr != sEluna->ServerEventBindings.end(); ++itr)
55 {
56 for (std::vector<int>::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
57 luaL_unref(sEluna->L, LUA_REGISTRYINDEX, (*it));
58 itr->second.clear();
59 }
60
61 for (std::map<int, std::vector<int> >::iterator itr = sEluna->PlayerEventBindings.begin(); itr != sEluna->PlayerEventBindings.end(); ++itr)
62 {
63 for (std::vector<int>::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
64 luaL_unref(sEluna->L, LUA_REGISTRYINDEX, (*it));
65 itr->second.clear();
66 }
67
68 for (std::map<int, std::vector<int> >::iterator itr = sEluna->VehicleEventBindings.begin(); itr != sEluna->VehicleEventBindings.end(); ++itr)
69 {
70 for (std::vector<int>::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
71 luaL_unref(sEluna->L, LUA_REGISTRYINDEX, (*it));
72 itr->second.clear();
73 }
74
75 for (std::map<int, std::vector<int> >::iterator itr = sEluna->GuildEventBindings.begin(); itr != sEluna->GuildEventBindings.end(); ++itr)
76 {
77 for (std::vector<int>::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
78 luaL_unref(sEluna->L, LUA_REGISTRYINDEX, (*it));
79 itr->second.clear();
80 }
81
82 for (std::map<int, std::vector<int> >::iterator itr = sEluna->GroupEventBindings.begin(); itr != sEluna->GroupEventBindings.end(); ++itr)
83 {
84 for (std::vector<int>::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
85 luaL_unref(sEluna->L, LUA_REGISTRYINDEX, (*it));
86 itr->second.clear();
87 }
88 sEluna->CreatureEventBindings->Clear();
89 sEluna->CreatureGossipBindings->Clear();
90 sEluna->GameObjectEventBindings->Clear();
91 sEluna->GameObjectGossipBindings->Clear();
92 sEluna->ItemEventBindings->Clear();
93 sEluna->ItemGossipBindings->Clear();
94 sEluna->playerGossipBindings->Clear();
95
96 lua_close(sEluna->L);
97 }
98 }
99 else
101
102 sEluna->L = luaL_newstate();
103 TC_LOG_INFO("server.loading", "");
104 TC_LOG_INFO("server.loading", "[Eluna]: Lua Engine loaded.");
105 TC_LOG_INFO("server.loading", "");
106
107 std::string lua_folderpath = sConfigMgr->GetStringDefault("Eluna.ScriptPath", "lua_scripts");
108
109 LoadedScripts loadedScripts;
110 sEluna->LoadDirectory(lua_folderpath.c_str(), &loadedScripts);
111 luaL_openlibs(sEluna->L);
112 // Register functions here
114
115 uint32 count = 0;
116 char filename[200];
117 for (std::set<std::string>::const_iterator itr = loadedScripts.begin(); itr != loadedScripts.end(); ++itr)
118 {
119 strcpy(filename, itr->c_str());
120 if (luaL_loadfile(sEluna->L, filename) != 0)
121 {
122 TC_LOG_INFO("server.loading", "[Eluna]: Error loading file `%s`.", itr->c_str());
123 sEluna->report(sEluna->L);
124 }
125 else
126 {
127 int err = lua_pcall(sEluna->L, 0, 0, 0);
128 if (err != 0 && err == LUA_ERRRUN)
129 {
130 TC_LOG_INFO("server.loading", "[Eluna]: Error loading file `%s`.", itr->c_str());
131 sEluna->report(sEluna->L);
132 }
133 }
134 ++count;
135 }
136
137
138 TC_LOG_INFO("server.loading", "[Eluna]: Loaded %u Lua scripts..", count);
139 TC_LOG_INFO("server.loading", "");
140}
141
143{
144 static Eluna instance;
145 return &instance;
146}
147
148// Loads lua scripts from given directory
149void Eluna::LoadDirectory(const char* Dirname, LoadedScripts* lscr)
150{
151#ifdef WIN32
152 HANDLE hFile;
153 WIN32_FIND_DATA FindData;
154 memset(&FindData, 0, sizeof(FindData));
155 char SearchName[MAX_PATH];
156
157 strcpy(SearchName, Dirname);
158 strcat(SearchName, "\\*.*");
159
160 hFile = FindFirstFile(SearchName, &FindData);
161 if (hFile == INVALID_HANDLE_VALUE)
162 {
163 //TC_LOG_ERROR("server.loading", "[Eluna]: Error No `lua_scripts` directory found! Creating a 'lua_scripts' directory.");
164 CreateDirectory("lua_scripts", NULL);
165 return;
166 }
167
168 FindNextFile(hFile, &FindData);
169 while (FindNextFile(hFile, &FindData))
170 {
171 if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
172 {
173 strcpy(SearchName, Dirname);
174 strcat(SearchName, "\\");
175 strcat(SearchName, FindData.cFileName);
176 LoadDirectory(SearchName, lscr);
177 }
178 else
179 {
180 std::string fname = Dirname;
181 fname += "\\";
182 fname += FindData.cFileName;
183 size_t len = strlen(fname.c_str());
184 int i = 0;
185 char ext[MAX_PATH];
186 while (len > 0)
187 {
188 ext[i++] = fname[--len];
189 if (fname[len] == '.')
190 break;
191 }
192 ext[i++] = '\0';
193 if (!_stricmp(ext, "aul."))
194 {
195 //TC_LOG_DEBUG("server.loading", "[Eluna]: Load File: %s", fname.c_str());
196 lscr->insert(fname);
197 }
198 }
199 }
200 FindClose(hFile);
201#else
202 const char* dir = strrchr(Dirname, '/');
203 if (strcmp(Dirname, "..") == 0 || strcmp(Dirname, ".") == 0)
204 return;
205
206 if (dir && (strcmp(dir, "/..") == 0 || strcmp(dir, "/.") == 0 || strcmp(dir, "/.svn") == 0))
207 return;
208
209 struct dirent** list;
210 int fileCount = scandir(Dirname, &list, 0, 0);
211
212 if (fileCount <= 0 || !list)
213 return;
214
215 struct stat attributes;
216 bool error;
217 while (fileCount--)
218 {
219 char _path[200];
220 sprintf(_path, "%s/%s", Dirname, list[fileCount]->d_name);
221 if (stat(_path, &attributes) == -1)
222 {
223 error = true;
224 TC_LOG_ERROR("server.loading", "[Eluna]: Error opening `%s`", _path);
225 }
226 else
227 error = false;
228
229 if (!error && S_ISDIR(attributes.st_mode))
230 LoadDirectory((char*)_path, lscr);
231 else
232 {
233 char* ext = strrchr(list[fileCount]->d_name, '.');
234 if (ext && !strcmp(ext, ".lua"))
235 lscr->insert(_path);
236 }
237 free(list[fileCount]);
238 }
239 free(list);
240#endif
241}
242
244{
245 // Check define for eluna is enabled or disabled
246#ifdef ELUNA
247 StartEluna(false);
248#else
249 TC_LOG_ERROR("server.loading", "[Eluna]: LuaEngine is Disabled. (If you want to use it please enable in cmake)");
250#endif
251}
252
253void Eluna::report(lua_State* L)
254{
255 const char* msg = lua_tostring(L, -1);
256 while (msg)
257 {
258 lua_pop(L, -1);
259 printf("\t%s\n",msg);
260 msg = lua_tostring(L, -1);
261 }
262}
263
264void Eluna::BeginCall(int fReference)
265{
266 lua_settop(L, 0); // stack should be empty
267 lua_rawgeti(L, LUA_REGISTRYINDEX, (fReference));
268}
269
271{
272 bool ret = true;
273 int top = lua_gettop(L);
274
275 if (lua_type(L, top - params) == LUA_TFUNCTION) // is function
276 {
277 if (lua_pcall(L, params, res, 0))
278 {
279 report(L);
280 ret = false;
281 }
282 }
283 else
284 {
285 ret = false;
286 if (params > 0)
287 {
288 for (int i = top; i >= (top - params); i--)
289 {
290 if (!lua_isnone(L, i))
291 lua_remove(L, i);
292 }
293 }
294 }
295 return ret;
296}
297
299{
300 for (int i = res; i > 0; i--)
301 {
302 if (!lua_isnone(L, res))
303 lua_remove(L, res);
304 }
305}
306
307/* Pushes */
308void Eluna::Push(lua_State* L)
309{
310 lua_pushnil(L);
311}
312
313void Eluna::Push(lua_State* L, uint64 l)
314{
315 std::ostringstream ss;
316 ss << "0x" << std::hex << l;
317 sEluna->Push(L, ss.str());
318}
319
320void Eluna::Push(lua_State* L, int64 l)
321{
322 std::ostringstream ss;
323 if (l < 0)
324 ss << "-0x" << std::hex << -l;
325 else
326 ss << "0x" << std::hex << l;
327 sEluna->Push(L, ss.str());
328}
329
330void Eluna::Push(lua_State* L, uint32 u)
331{
332 lua_pushunsigned(L, u);
333}
334
335void Eluna::Push(lua_State* L, int32 i)
336{
337 lua_pushinteger(L, i);
338}
339
340void Eluna::Push(lua_State* L, double d)
341{
342 lua_pushnumber(L, d);
343}
344
345void Eluna::Push(lua_State* L, float f)
346{
347 lua_pushnumber(L, f);
348}
349
350void Eluna::Push(lua_State* L, bool b)
351{
352 lua_pushboolean(L, b);
353}
354
355void Eluna::Push(lua_State* L, std::string str)
356{
357 lua_pushstring(L, str.c_str());
358}
359
360void Eluna::Push(lua_State* L, const char* str)
361{
362 lua_pushstring(L, str);
363}
364
365Object* Eluna::CHECK_OBJECT(lua_State* L, int narg)
366{
367 return ElunaTemplate<Object>::check(L, narg);
368}
369
371{
373}
374
375Unit* Eluna::CHECK_UNIT(lua_State* L, int narg)
376{
377 WorldObject* obj = CHECK_WORLDOBJECT(L, narg);
378 if (!obj)
379 return NULL;
380 return obj->ToUnit();
381}
382
383Player* Eluna::CHECK_PLAYER(lua_State* L, int narg)
384{
385 WorldObject* obj = CHECK_WORLDOBJECT(L, narg);
386 if (!obj)
387 return NULL;
388 return obj->ToPlayer();
389}
390
391Creature* Eluna::CHECK_CREATURE(lua_State* L, int narg)
392{
393 WorldObject* obj = CHECK_WORLDOBJECT(L, narg);
394 if (!obj)
395 return NULL;
396 return obj->ToCreature();
397}
398
400{
401 WorldObject* obj = CHECK_WORLDOBJECT(L, narg);
402 if (!obj)
403 return NULL;
404 return obj->ToGameObject();
405}
406
407Corpse* Eluna::CHECK_CORPSE(lua_State* L, int narg)
408{
409 WorldObject* obj = CHECK_WORLDOBJECT(L, narg);
410 if (!obj)
411 return NULL;
412 return obj->ToCorpse();
413}
414
415Vehicle* Eluna::CHECK_VEHICLE(lua_State* L, int narg)
416{
417 return ElunaTemplate<Vehicle>::check(L, narg);
418}
419
420WorldPacket* Eluna::CHECK_PACKET(lua_State* L, int narg)
421{
423}
424
425Quest* Eluna::CHECK_QUEST(lua_State* L, int narg)
426{
427 return ElunaTemplate<Quest>::check(L, narg);
428}
429
430Spell* Eluna::CHECK_SPELL(lua_State* L, int narg)
431{
432 return ElunaTemplate<Spell>::check(L, narg);
433}
434
435uint64 Eluna::CHECK_ULONG(lua_State* L, int narg)
436{
437 const char* c_str = luaL_optstring(L, narg, "0x0");
438 return strtoul(c_str, NULL, 0);
439}
440
441int64 Eluna::CHECK_LONG(lua_State* L, int narg)
442{
443 const char* c_str = luaL_optstring(L, narg, "0x0");
444 return strtol(c_str, NULL, 0);
445}
446
447Item* Eluna::CHECK_ITEM(lua_State* L, int narg)
448{
449 return ElunaTemplate<Item>::check(L, narg);
450}
451
452// Saves the function reference ID given to the register type's store for given entry under the given event
453void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
454{
455 switch (regtype)
456 {
457 case REGTYPE_SERVER:
458 if (evt < SERVER_EVENT_COUNT)
459 {
460 ServerEventBindings[evt].push_back(functionRef);
461 return;
462 }
463 break;
464
465 case REGTYPE_PLAYER:
466 if (evt < PLAYER_EVENT_COUNT)
467 {
468 PlayerEventBindings[evt].push_back(functionRef);
469 return;
470 }
471 break;
472
473 case REGTYPE_VEHICLE:
474 if (evt < VEHICLE_EVENT_COUNT)
475 {
476 VehicleEventBindings[evt].push_back(functionRef);
477 return;
478 }
479 break;
480
481 case REGTYPE_GUILD:
482 if (evt < GUILD_EVENT_COUNT)
483 {
484 GuildEventBindings[evt].push_back(functionRef);
485 return;
486 }
487 break;
488
489 case REGTYPE_GROUP:
490 if (evt < GROUP_EVENT_COUNT)
491 {
492 GroupEventBindings[evt].push_back(functionRef);
493 return;
494 }
495 break;
496
497 case REGTYPE_CREATURE:
498 if (evt < CREATURE_EVENT_COUNT)
499 {
500 if (!sObjectMgr->GetCreatureTemplate(id))
501 {
502 luaL_error(L, "Couldn't find a creature with (ID: %d)!", id);
503 return;
504 }
505
506 sEluna->CreatureEventBindings->Insert(id, evt, functionRef);
507 return;
508 }
509 break;
510
512 if (evt < GOSSIP_EVENT_COUNT)
513 {
514 if (!sObjectMgr->GetCreatureTemplate(id))
515 {
516 luaL_error(L, "Couldn't find a creature with (ID: %d)!", id);
517 return;
518 }
519
520 sEluna->CreatureGossipBindings->Insert(id, evt, functionRef);
521 return;
522 }
523 break;
524
526 if (evt < GAMEOBJECT_EVENT_COUNT)
527 {
528 if (!sObjectMgr->GetGameObjectTemplate(id))
529 {
530 luaL_error(L, "Couldn't find a gameobject with (ID: %d)!", id);
531 return;
532 }
533
534 sEluna->GameObjectEventBindings->Insert(id, evt, functionRef);
535 return;
536 }
537 break;
538
540 if (evt < GOSSIP_EVENT_COUNT)
541 {
542 if (!sObjectMgr->GetGameObjectTemplate(id))
543 {
544 luaL_error(L, "Couldn't find a gameobject with (ID: %d)!", id);
545 return;
546 }
547
548 sEluna->GameObjectGossipBindings->Insert(id, evt, functionRef);
549 return;
550 }
551 break;
552
553 case REGTYPE_ITEM:
554 if (evt < ITEM_EVENT_COUNT)
555 {
556 if (!sObjectMgr->GetItemTemplate(id))
557 {
558 luaL_error(L, "Couldn't find a item with (ID: %d)!", id);
559 return;
560 }
561
562 sEluna->ItemEventBindings->Insert(id, evt, functionRef);
563 return;
564 }
565 break;
566
568 if (evt < GOSSIP_EVENT_COUNT)
569 {
570 if (!sObjectMgr->GetItemTemplate(id))
571 {
572 luaL_error(L, "Couldn't find a item with (ID: %d)!", id);
573 return;
574 }
575
576 sEluna->ItemGossipBindings->Insert(id, evt, functionRef);
577 return;
578 }
579 break;
580
582 if (evt < GOSSIP_EVENT_COUNT)
583 {
584 sEluna->playerGossipBindings->Insert(id, evt, functionRef);
585 return;
586 }
587 break;
588
589 default:
590 luaL_error(L, "Unknown register type (regtype %d, id %d, event %d)", regtype, id, evt);
591 return;
592 }
593 luaL_error(L, "Unknown event type (regtype %d, id %d, event %d)", regtype, id, evt);
594}
595
597{
598 for (ElunaEntryMap::iterator itr = Bindings.begin(); itr != Bindings.end(); ++itr)
599 {
600 for (ElunaBindingMap::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
601 luaL_unref(sEluna->L, LUA_REGISTRYINDEX, it->second);
602 itr->second.clear();
603 }
604 Bindings.clear();
605}
606
607void Eluna::ElunaBind::Insert(uint32 entryId, uint32 eventId, int funcRef)
608{
609 if (Bindings[entryId][eventId])
610 {
611 luaL_error(sEluna->L, "A function is already registered for entry (%d) event (%d)", entryId, eventId);
612 luaL_unref(sEluna->L, LUA_REGISTRYINDEX, funcRef); // free the unused ref
613 }
614 else
615 Bindings[entryId][eventId] = funcRef;
616}
617
618EventMgr::LuaEvent::LuaEvent(EventProcessor* _events, int _funcRef, uint32 _delay, uint32 _calls, Object* _obj) :
619 events(_events), funcRef(_funcRef), delay(_delay), calls(_calls), obj(_obj)
620{
621 hasObject = _obj;
622 if (_events)
623 sEluna->m_EventMgr.LuaEvents[_events].insert(this); // Able to access the event if we have the processor
624}
625
627{
628 if (events)
629 {
630 // Attempt to remove the pointer from LuaEvents
631 EventMgr::EventMap::const_iterator it = sEluna->m_EventMgr.LuaEvents.find(events); // Get event set
632 if (it != sEluna->m_EventMgr.LuaEvents.end())
633 sEluna->m_EventMgr.LuaEvents[events].erase(this); // Remove pointer
634 }
635 luaL_unref(sEluna->L, LUA_REGISTRYINDEX, funcRef); // Free lua function ref
636}
637
639{
640 if (hasObject && !obj) // interrupt event if object doesnt exist anymore and should exist.
641 return true;
642 if (calls != 1)
643 events->AddEvent(this, events->CalculateTime(delay)); // Reschedule before calling incase RemoveEvents used
644 sEluna->BeginCall(funcRef);
645 sEluna->Push(sEluna->L, funcRef);
646 sEluna->Push(sEluna->L, delay);
647 sEluna->Push(sEluna->L, calls);
648 sEluna->Push(sEluna->L, obj);
649 sEluna->ExecuteCall(4, 0);
650 return !(!calls || --calls); // Destory (true) event if not run
651}
652
653// Lua taxi helper functions
656{
657 if (pathid >= sTaxiPathNodesByPath.size())
658 return;
659
660 TaxiPathNodeList const& path = sTaxiPathNodesByPath[pathid];
661 if (path.size() < 2)
662 return;
663
664 std::vector<uint32> nodes;
665 nodes.resize(2);
666 nodes[0] = path[0].index;
667 nodes[1] = path[path.size() - 1].index;
668
669 player->ActivateTaxiPathTo(nodes);
670}
671
672uint32 LuaTaxiMgr::AddPath(std::list<TaxiPathNodeEntry> nodes, uint32 mountA, uint32 mountH, uint32 price, uint32 pathId)
673{
674 /*
675 if (nodes.size() < 2)
676 return 0;
677 if (!pathId)
678 pathId = sTaxiPathNodesByPath.size();
679 if (sTaxiPathNodesByPath.size() <= pathId)
680 sTaxiPathNodesByPath.resize(pathId + 1);
681 sTaxiPathNodesByPath[pathId].clear();
682 sTaxiPathNodesByPath[pathId].resize(nodes.size());
683 uint32 startNode = nodeId;
684 uint32 index = 0;
685 for (std::list<TaxiPathNodeEntry>::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
686 {
687 TaxiPathNodeEntry entry = *it;
688 entry.path = pathId;
689 TaxiNodesEntry* nodeEntry = new TaxiNodesEntry();
690 nodeEntry->ID = index;
691 nodeEntry->map_id = entry.mapid;
692 nodeEntry->MountCreatureID[0] = mountH;
693 nodeEntry->MountCreatureID[1] = mountA;
694 nodeEntry->x = entry.x;
695 nodeEntry->y = entry.y;
696 nodeEntry->z = entry.z;
697 sTaxiNodesStore.SetEntry(nodeId, nodeEntry);
698 entry.index = nodeId++;
699 sTaxiPathNodesByPath[pathId].set(index++, TaxiPathNodePtr(new TaxiPathNodeEntry(entry)));
700 }
701 if (startNode >= nodeId)
702 return 0;
703 sTaxiPathSetBySource[startNode][nodeId - 1] = TaxiPathBySourceAndDestination(pathId, price);
704 return pathId;
705 */
706 return 0;
707}
#define sConfigMgr
Definition Config.h:64
TaxiPathNodesByPath sTaxiPathNodesByPath
Path< TaxiPathNodePtr, TaxiPathNodeEntry const > TaxiPathNodeList
std::int32_t int32
Definition Define.h:73
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
std::uint64_t uint64
Definition Define.h:76
std::int64_t int64
Definition Define.h:72
void AddElunaScripts()
Definition HookMgr.cpp:1998
@ CREATURE_EVENT_COUNT
Definition HookMgr.h:225
@ REGTYPE_GUILD
Definition HookMgr.h:34
@ REGTYPE_PLAYER_GOSSIP
Definition HookMgr.h:43
@ REGTYPE_PLAYER
Definition HookMgr.h:33
@ REGTYPE_SERVER
Definition HookMgr.h:32
@ REGTYPE_VEHICLE
Definition HookMgr.h:37
@ REGTYPE_GROUP
Definition HookMgr.h:35
@ REGTYPE_GAMEOBJECT
Definition HookMgr.h:39
@ REGTYPE_ITEM_GOSSIP
Definition HookMgr.h:42
@ REGTYPE_CREATURE
Definition HookMgr.h:36
@ REGTYPE_GAMEOBJECT_GOSSIP
Definition HookMgr.h:40
@ REGTYPE_ITEM
Definition HookMgr.h:41
@ REGTYPE_CREATURE_GOSSIP
Definition HookMgr.h:38
@ GUILD_EVENT_COUNT
Definition HookMgr.h:170
@ ITEM_EVENT_COUNT
Definition HookMgr.h:252
@ PLAYER_EVENT_COUNT
Definition HookMgr.h:138
@ SERVER_EVENT_COUNT
Definition HookMgr.h:93
@ GROUP_EVENT_COUNT
Definition HookMgr.h:184
#define sHookMgr
Definition HookMgr.h:390
@ VEHICLE_EVENT_COUNT
Definition HookMgr.h:151
@ GAMEOBJECT_EVENT_COUNT
Definition HookMgr.h:242
@ GOSSIP_EVENT_COUNT
Definition HookMgr.h:263
const char * GetTName< Player >()
Definition LuaEngine.cpp:24
#define TC_LOG_INFO
Definition LuaEngine.cpp:12
const char * GetTName< Group >()
Definition LuaEngine.cpp:28
const char * GetTName< Object >()
Definition LuaEngine.cpp:21
const char * GetTName< GameObject >()
Definition LuaEngine.cpp:26
void StartEluna(bool restart)
Definition LuaEngine.cpp:41
const char * GetTName< WorldPacket >()
Definition LuaEngine.cpp:32
const char * GetTName< Weather >()
Definition LuaEngine.cpp:38
const char * GetTName< Map >()
Definition LuaEngine.cpp:36
const char * GetTName< Creature >()
Definition LuaEngine.cpp:25
const char * GetTName< Aura >()
Definition LuaEngine.cpp:31
const char * GetTName< Item >()
Definition LuaEngine.cpp:33
const char * GetTName()
Definition LuaEngine.cpp:20
const char * GetTName< Spell >()
Definition LuaEngine.cpp:34
const char * GetTName< Quest >()
Definition LuaEngine.cpp:35
const char * GetTName< QueryResult >()
Definition LuaEngine.cpp:30
const char * GetTName< Unit >()
Definition LuaEngine.cpp:23
const char * GetTName< Corpse >()
Definition LuaEngine.cpp:37
#define TC_LOG_ERROR
Definition LuaEngine.cpp:13
const char * GetTName< WorldObject >()
Definition LuaEngine.cpp:22
const char * GetTName< AuctionHouseObject >()
Definition LuaEngine.cpp:39
const char * GetTName< Guild >()
Definition LuaEngine.cpp:29
const char * GetTName< Vehicle >()
Definition LuaEngine.cpp:27
void StartEluna(bool restart)
Definition LuaEngine.cpp:41
std::set< std::string > LoadedScripts
Definition LuaEngine.h:23
#define sEluna
Definition LuaEngine.h:710
void RegisterFunctions(lua_State *L)
#define sObjectMgr
Definition ObjectMgr.h:1617
int64 CHECK_LONG(lua_State *L, int narg)
void Push(lua_State *)
lua_State * L
Definition LuaEngine.h:384
Quest * CHECK_QUEST(lua_State *L, int narg)
Corpse * CHECK_CORPSE(lua_State *L, int narg)
Spell * CHECK_SPELL(lua_State *L, int narg)
Item * CHECK_ITEM(lua_State *L, int narg)
void BeginCall(int fReference)
std::map< int, std::vector< int > > PlayerEventBindings
Definition LuaEngine.h:391
Eluna()
Definition LuaEngine.h:530
std::map< int, std::vector< int > > GuildEventBindings
Definition LuaEngine.h:393
Object * CHECK_OBJECT(lua_State *L, int narg)
std::map< int, std::vector< int > > VehicleEventBindings
Definition LuaEngine.h:392
void Register(uint8 reg, uint32 id, uint32 evt, int func)
std::map< int, std::vector< int > > ServerEventBindings
Definition LuaEngine.h:390
WorldObject * CHECK_WORLDOBJECT(lua_State *L, int narg)
static void report(lua_State *)
std::map< int, std::vector< int > > GroupEventBindings
Definition LuaEngine.h:394
Vehicle * CHECK_VEHICLE(lua_State *L, int narg)
Creature * CHECK_CREATURE(lua_State *L, int narg)
static Eluna * instance()
void LoadDirectory(const char *directory, LoadedScripts *scr)
void EndCall(uint8 res)
uint64 CHECK_ULONG(lua_State *L, int narg)
GameObject * CHECK_GAMEOBJECT(lua_State *L, int narg)
void Initialize()
Player * CHECK_PLAYER(lua_State *L, int narg)
WorldPacket * CHECK_PACKET(lua_State *L, int narg)
bool ExecuteCall(uint8 params, uint8 res)
Unit * CHECK_UNIT(lua_State *L, int narg)
static T * check(lua_State *L, int narg)
Definition LuaEngine.h:116
Definition Item.h:202
static void StartTaxi(Player *player, uint32 pathid)
static uint32 nodeId
Definition LuaEngine.h:715
static uint32 AddPath(std::list< TaxiPathNodeEntry > nodes, uint32 mountA, uint32 mountH, uint32 price=0, uint32 pathId=0)
Corpse * ToCorpse()
Definition Object.h:216
Player * ToPlayer()
Definition Object.h:204
GameObject * ToGameObject()
Definition Object.h:213
Creature * ToCreature()
Definition Object.h:207
Unit * ToUnit()
Definition Object.h:210
size_t size() const
Definition Path.h:23
bool ActivateTaxiPathTo(std::vector< uint32 > const &nodes, Creature *npc=NULL, uint32 spellid=0)
Definition Player.cpp:16547
Definition Spell.h:289
Definition Unit.h:1367
ElunaEntryMap Bindings
Definition LuaEngine.h:649
void Insert(uint32 entryId, uint32 eventId, int funcRef)
EventProcessor * events
Definition LuaEngine.h:251
LuaEvent(EventProcessor *_events, int _funcRef, uint32 _delay, uint32 _calls, Object *_obj)
bool Execute(uint64 time, uint32 diff)