Merge branch 'master' of github.com:ElunaLuaEngine/Eluna into Elmsroth-rename-defines

This commit is contained in:
Rochet2
2020-11-15 23:27:16 +02:00
19 changed files with 350 additions and 101 deletions

View File

@@ -51,6 +51,24 @@ namespace LuaGlobalFunctions
return 1;
}
/**
* Returns emulator .conf RealmID
*
* - for MaNGOS returns the realmID as it is stored in the core.
* - for TrinityCore returns the realmID as it is in the conf file.
* @return uint32 realm ID
*/
int GetRealmID(lua_State* L)
{
#ifdef MANGOS
Eluna::Push(L, realmID);
#else
Eluna::Push(L, sConfigMgr->GetIntDefault("RealmID", 1));
#endif
return 1;
}
/**
* Returns emulator version
*
@@ -181,7 +199,7 @@ namespace LuaGlobalFunctions
#else
{
#ifdef TRINITY
boost::shared_lock<boost::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
#elif defined(AZEROTHCORE)
ACORE_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
#else
@@ -477,7 +495,11 @@ namespace LuaGlobalFunctions
if (!areaEntry)
return luaL_argerror(L, 1, "valid Area or Zone ID expected");
#if defined(TRINITY)
Eluna::Push(L, areaEntry->AreaName[locale]);
#else
Eluna::Push(L, areaEntry->area_name[locale]);
#endif
return 1;
}
@@ -1029,7 +1051,7 @@ namespace LuaGlobalFunctions
* CREATURE_EVENT_ON_REACH_WP = 6, // (event, creature, type, id) - Can return true to stop normal action
* CREATURE_EVENT_ON_AIUPDATE = 7, // (event, creature, diff) - Can return true to stop normal action
* CREATURE_EVENT_ON_RECEIVE_EMOTE = 8, // (event, creature, player, emoteid) - Can return true to stop normal action
* CREATURE_EVENT_ON_DAMAGE_TAKEN = 9, // (event, creature, attacker, damage) - Can return new damage
* CREATURE_EVENT_ON_DAMAGE_TAKEN = 9, // (event, creature, attacker, damage) - Can return true to stop normal action, can return new damage as second return value.
* CREATURE_EVENT_ON_PRE_COMBAT = 10, // (event, creature, target) - Can return true to stop normal action
* // UNUSED
* CREATURE_EVENT_ON_OWNER_ATTACKED = 12, // (event, creature, target) - Can return true to stop normal action // Not on mangos
@@ -1046,7 +1068,7 @@ namespace LuaGlobalFunctions
* CREATURE_EVENT_ON_RESET = 23, // (event, creature)
* CREATURE_EVENT_ON_REACH_HOME = 24, // (event, creature) - Can return true to stop normal action
* // UNUSED = 25, // (event, creature)
* CREATURE_EVENT_ON_CORPSE_REMOVED = 26, // (event, creature, respawndelay) - Can return true, newRespawnDelay
* CREATURE_EVENT_ON_CORPSE_REMOVED = 26, // (event, creature, respawndelay) - Can return true to stop normal action, can return new respawndelay as second return value
* CREATURE_EVENT_ON_MOVE_IN_LOS = 27, // (event, creature, unit) - Can return true to stop normal action. Does not actually check LOS, just uses the sight range
* // UNUSED = 28, // (event, creature)
* // UNUSED = 29, // (event, creature)
@@ -1091,7 +1113,7 @@ namespace LuaGlobalFunctions
* CREATURE_EVENT_ON_REACH_WP = 6, // (event, creature, type, id) - Can return true to stop normal action
* CREATURE_EVENT_ON_AIUPDATE = 7, // (event, creature, diff) - Can return true to stop normal action
* CREATURE_EVENT_ON_RECEIVE_EMOTE = 8, // (event, creature, player, emoteid) - Can return true to stop normal action
* CREATURE_EVENT_ON_DAMAGE_TAKEN = 9, // (event, creature, attacker, damage) - Can return new damage
* CREATURE_EVENT_ON_DAMAGE_TAKEN = 9, // (event, creature, attacker, damage) - Can return true to stop normal action, can return new damage as second return value.
* CREATURE_EVENT_ON_PRE_COMBAT = 10, // (event, creature, target) - Can return true to stop normal action
* // UNUSED
* CREATURE_EVENT_ON_OWNER_ATTACKED = 12, // (event, creature, target) - Can return true to stop normal action // Not on mangos
@@ -1108,7 +1130,7 @@ namespace LuaGlobalFunctions
* CREATURE_EVENT_ON_RESET = 23, // (event, creature)
* CREATURE_EVENT_ON_REACH_HOME = 24, // (event, creature) - Can return true to stop normal action
* // UNUSED = 25, // (event, creature)
* CREATURE_EVENT_ON_CORPSE_REMOVED = 26, // (event, creature, respawndelay) - Can return true, newRespawnDelay
* CREATURE_EVENT_ON_CORPSE_REMOVED = 26, // (event, creature, respawndelay) - Can return true to stop normal action, can return new respawndelay as second return value
* CREATURE_EVENT_ON_MOVE_IN_LOS = 27, // (event, creature, unit) - Can return true to stop normal action. Does not actually check LOS, just uses the sight range
* // UNUSED = 28, // (event, creature)
* // UNUSED = 29, // (event, creature)
@@ -1148,9 +1170,9 @@ namespace LuaGlobalFunctions
* {
* GAMEOBJECT_EVENT_ON_AIUPDATE = 1, // (event, go, diff)
* GAMEOBJECT_EVENT_ON_SPAWN = 2, // (event, go)
* GAMEOBJECT_EVENT_ON_DUMMY_EFFECT = 3, // (event, caster, spellid, effindex, go)
* GAMEOBJECT_EVENT_ON_QUEST_ACCEPT = 4, // (event, player, go, quest) - Can return true
* GAMEOBJECT_EVENT_ON_QUEST_REWARD = 5, // (event, player, go, quest, opt) - Can return true
* GAMEOBJECT_EVENT_ON_DUMMY_EFFECT = 3, // (event, caster, spellid, effindex, go) - Can return true to stop normal action
* GAMEOBJECT_EVENT_ON_QUEST_ACCEPT = 4, // (event, player, go, quest) - Can return true to stop normal action
* GAMEOBJECT_EVENT_ON_QUEST_REWARD = 5, // (event, player, go, quest, opt) - Can return true to stop normal action
* GAMEOBJECT_EVENT_ON_DIALOG_STATUS = 6, // (event, player, go)
* GAMEOBJECT_EVENT_ON_DESTROYED = 7, // (event, go, attacker)
* GAMEOBJECT_EVENT_ON_DAMAGED = 8, // (event, go, attacker)
@@ -1159,7 +1181,7 @@ namespace LuaGlobalFunctions
* // UNUSED = 11, // (event, gameobject)
* GAMEOBJECT_EVENT_ON_ADD = 12, // (event, gameobject)
* GAMEOBJECT_EVENT_ON_REMOVE = 13, // (event, gameobject)
* GAMEOBJECT_EVENT_ON_USE = 14, // (event, go, player)
* GAMEOBJECT_EVENT_ON_USE = 14, // (event, go, player) - Can return true to stop normal action
* GAMEOBJECT_EVENT_COUNT
* };
* </pre>
@@ -2302,10 +2324,10 @@ namespace LuaGlobalFunctions
TaxiPathNodeEntry entry;
#ifdef TRINITY
// mandatory
entry.MapID = Eluna::CHECKVAL<uint32>(L, start);
entry.LocX = Eluna::CHECKVAL<float>(L, start + 1);
entry.LocY = Eluna::CHECKVAL<float>(L, start + 2);
entry.LocZ = Eluna::CHECKVAL<float>(L, start + 3);
entry.ContinentID = Eluna::CHECKVAL<uint32>(L, start);
entry.Loc.X = Eluna::CHECKVAL<float>(L, start + 1);
entry.Loc.Y = Eluna::CHECKVAL<float>(L, start + 2);
entry.Loc.Z = Eluna::CHECKVAL<float>(L, start + 3);
// optional
entry.Flags = Eluna::CHECKVAL<uint32>(L, start + 4, 0);
entry.Delay = Eluna::CHECKVAL<uint32>(L, start + 5, 0);
@@ -2353,10 +2375,10 @@ namespace LuaGlobalFunctions
entry.PathID = pathId;
entry.NodeIndex = nodeId;
nodeEntry->ID = index;
nodeEntry->map_id = entry.MapID;
nodeEntry->x = entry.LocX;
nodeEntry->y = entry.LocY;
nodeEntry->z = entry.LocZ;
nodeEntry->ContinentID = entry.ContinentID;
nodeEntry->Pos.X = entry.Loc.X;
nodeEntry->Pos.Y = entry.Loc.Y;
nodeEntry->Pos.Z = entry.Loc.Z;
nodeEntry->MountCreatureID[0] = mountH;
nodeEntry->MountCreatureID[1] = mountA;
sTaxiNodesStore.SetEntry(nodeId++, nodeEntry);
@@ -2383,10 +2405,16 @@ namespace LuaGlobalFunctions
return 1;
sTaxiPathSetBySource[startNode][nodeId - 1] = TaxiPathBySourceAndDestination(pathId, price);
TaxiPathEntry* pathEntry = new TaxiPathEntry();
#ifdef TRINITY
pathEntry->FromTaxiNode = startNode;
pathEntry->ToTaxiNode = nodeId - 1;
pathEntry->Cost = price;
#else
pathEntry->from = startNode;
pathEntry->to = nodeId - 1;
pathEntry->ID = pathId;
pathEntry->price = price;
#endif
pathEntry->ID = pathId;
sTaxiPathStore.SetEntry(pathId, pathEntry);
Eluna::Push(L, pathId);
return 1;