mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Fix push and taxi crashes and add new taxi changes
This commit is contained in:
@@ -1986,6 +1986,7 @@ namespace LuaGlobalFunctions
|
|||||||
uint32 price = Eluna::CHECKVAL<uint32>(L, 4, 0);
|
uint32 price = Eluna::CHECKVAL<uint32>(L, 4, 0);
|
||||||
uint32 pathId = Eluna::CHECKVAL<uint32>(L, 5, 0);
|
uint32 pathId = Eluna::CHECKVAL<uint32>(L, 5, 0);
|
||||||
lua_pushvalue(L, 1);
|
lua_pushvalue(L, 1);
|
||||||
|
// Stack: {nodes}, mountA, mountH, price, pathid, {nodes}
|
||||||
|
|
||||||
std::list<TaxiPathNodeEntry> nodes;
|
std::list<TaxiPathNodeEntry> nodes;
|
||||||
|
|
||||||
@@ -1993,53 +1994,57 @@ namespace LuaGlobalFunctions
|
|||||||
int end = start;
|
int end = start;
|
||||||
|
|
||||||
Eluna::Push(L);
|
Eluna::Push(L);
|
||||||
|
// Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, nil
|
||||||
while (lua_next(L, -2) != 0)
|
while (lua_next(L, -2) != 0)
|
||||||
{
|
{
|
||||||
|
// Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, key, value
|
||||||
luaL_checktype(L, -1, LUA_TTABLE);
|
luaL_checktype(L, -1, LUA_TTABLE);
|
||||||
Eluna::Push(L);
|
Eluna::Push(L);
|
||||||
|
// Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, key, value, nil
|
||||||
while (lua_next(L, -2) != 0)
|
while (lua_next(L, -2) != 0)
|
||||||
{
|
{
|
||||||
|
// Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, key, value, key2, value2
|
||||||
lua_insert(L, end++);
|
lua_insert(L, end++);
|
||||||
|
// Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, value2, key, value, key2
|
||||||
}
|
}
|
||||||
|
// Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, value2, key, value
|
||||||
if (start == end)
|
if (start == end)
|
||||||
continue;
|
continue;
|
||||||
if (end - start < 4) // no mandatory args, dont add
|
if (end - start < 4) // no mandatory args, dont add
|
||||||
{
|
return luaL_argerror(L, 1, "all waypoints do not have mandatory arguments");
|
||||||
while (end != start)
|
|
||||||
if (!lua_isnone(L, --end))
|
|
||||||
lua_remove(L, end);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (end - start < 8) // fill optional args with 0
|
while (end - start < 8) // fill optional args with 0
|
||||||
{
|
{
|
||||||
Eluna::Push(L, 0);
|
Eluna::Push(L, 0);
|
||||||
lua_insert(L, end++);
|
lua_insert(L, end++);
|
||||||
|
// Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, node, key, value
|
||||||
}
|
}
|
||||||
TaxiPathNodeEntry* entry = new TaxiPathNodeEntry();
|
TaxiPathNodeEntry entry;
|
||||||
// mandatory
|
// mandatory
|
||||||
entry->mapid = Eluna::CHECKVAL<uint32>(L, start);
|
entry.mapid = Eluna::CHECKVAL<uint32>(L, start);
|
||||||
entry->x = Eluna::CHECKVAL<float>(L, start + 1);
|
entry.x = Eluna::CHECKVAL<float>(L, start + 1);
|
||||||
entry->y = Eluna::CHECKVAL<float>(L, start + 2);
|
entry.y = Eluna::CHECKVAL<float>(L, start + 2);
|
||||||
entry->z = Eluna::CHECKVAL<float>(L, start + 3);
|
entry.z = Eluna::CHECKVAL<float>(L, start + 3);
|
||||||
// optional
|
// optional
|
||||||
entry->actionFlag = Eluna::CHECKVAL<uint32>(L, start + 4, 0);
|
entry.actionFlag = Eluna::CHECKVAL<uint32>(L, start + 4, 0);
|
||||||
entry->delay = Eluna::CHECKVAL<uint32>(L, start + 5, 0);
|
entry.delay = Eluna::CHECKVAL<uint32>(L, start + 5, 0);
|
||||||
|
|
||||||
nodes.push_back(*entry);
|
nodes.push_back(entry);
|
||||||
|
|
||||||
while (end != start) // remove args
|
while (end != start) // remove args
|
||||||
if (!lua_isnone(L, --end))
|
if (!lua_isnone(L, --end))
|
||||||
lua_remove(L, end);
|
lua_remove(L, end);
|
||||||
|
// Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, key, value
|
||||||
|
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
// Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, key
|
||||||
}
|
}
|
||||||
|
// Stack: {nodes}, mountA, mountH, price, pathid, {nodes}
|
||||||
|
lua_pop(L, 1);
|
||||||
|
// Stack: {nodes}, mountA, mountH, price, pathid
|
||||||
|
|
||||||
if (nodes.size() < 2)
|
if (nodes.size() < 2)
|
||||||
{
|
|
||||||
Eluna::Push(L);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
if (!pathId)
|
if (!pathId)
|
||||||
pathId = sTaxiPathNodesByPath.size();
|
pathId = sTaxiPathNodesByPath.size();
|
||||||
if (sTaxiPathNodesByPath.size() <= pathId)
|
if (sTaxiPathNodesByPath.size() <= pathId)
|
||||||
@@ -2049,9 +2054,9 @@ namespace LuaGlobalFunctions
|
|||||||
static uint32 nodeId = 500;
|
static uint32 nodeId = 500;
|
||||||
uint32 startNode = nodeId;
|
uint32 startNode = nodeId;
|
||||||
uint32 index = 0;
|
uint32 index = 0;
|
||||||
for (std::list<TaxiPathNodeEntry>::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
|
for (std::list<TaxiPathNodeEntry>::iterator it = nodes.begin(); it != nodes.end(); ++it)
|
||||||
{
|
{
|
||||||
TaxiPathNodeEntry entry = *it;
|
TaxiPathNodeEntry& entry = *it;
|
||||||
entry.path = pathId;
|
entry.path = pathId;
|
||||||
TaxiNodesEntry* nodeEntry = new TaxiNodesEntry();
|
TaxiNodesEntry* nodeEntry = new TaxiNodesEntry();
|
||||||
nodeEntry->ID = index;
|
nodeEntry->ID = index;
|
||||||
@@ -2063,14 +2068,17 @@ namespace LuaGlobalFunctions
|
|||||||
nodeEntry->z = entry.z;
|
nodeEntry->z = entry.z;
|
||||||
sTaxiNodesStore.SetEntry(nodeId, nodeEntry);
|
sTaxiNodesStore.SetEntry(nodeId, nodeEntry);
|
||||||
entry.index = nodeId++;
|
entry.index = nodeId++;
|
||||||
sTaxiPathNodesByPath[pathId].set(index++, TaxiPathNodePtr(new TaxiPathNodeEntry(entry)));
|
sTaxiPathNodesByPath[pathId].set(index++, new TaxiPathNodeEntry(entry));
|
||||||
}
|
}
|
||||||
if (startNode >= nodeId)
|
if (startNode >= nodeId)
|
||||||
{
|
|
||||||
Eluna::Push(L);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
sTaxiPathSetBySource[startNode][nodeId - 1] = TaxiPathBySourceAndDestination(pathId, price);
|
sTaxiPathSetBySource[startNode][nodeId - 1] = TaxiPathBySourceAndDestination(pathId, price);
|
||||||
|
TaxiPathEntry* pathEntry = new TaxiPathEntry();
|
||||||
|
pathEntry->from = startNode;
|
||||||
|
pathEntry->to = nodeId - 1;
|
||||||
|
pathEntry->ID = pathId;
|
||||||
|
pathEntry->price = price;
|
||||||
|
sTaxiPathStore.SetEntry(pathId, pathEntry);
|
||||||
Eluna::Push(L, pathId);
|
Eluna::Push(L, pathId);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -656,11 +656,11 @@ void Eluna::Push(lua_State* luastate, const char* str)
|
|||||||
}
|
}
|
||||||
void Eluna::Push(lua_State* luastate, Pet const* pet)
|
void Eluna::Push(lua_State* luastate, Pet const* pet)
|
||||||
{
|
{
|
||||||
Push(luastate, pet->ToCreature());
|
Push<Creature>(luastate, pet);
|
||||||
}
|
}
|
||||||
void Eluna::Push(lua_State* luastate, TempSummon const* summon)
|
void Eluna::Push(lua_State* luastate, TempSummon const* summon)
|
||||||
{
|
{
|
||||||
Push(luastate, summon->ToCreature());
|
Push<Creature>(luastate, summon);
|
||||||
}
|
}
|
||||||
void Eluna::Push(lua_State* luastate, Unit const* unit)
|
void Eluna::Push(lua_State* luastate, Unit const* unit)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3027,19 +3027,7 @@ namespace LuaPlayer
|
|||||||
{
|
{
|
||||||
uint32 pathId = Eluna::CHECKVAL<uint32>(L, 2);
|
uint32 pathId = Eluna::CHECKVAL<uint32>(L, 2);
|
||||||
|
|
||||||
if (pathId >= sTaxiPathNodesByPath.size())
|
player->ActivateTaxiPathTo(pathId);
|
||||||
return 0;
|
|
||||||
|
|
||||||
TaxiPathNodeList const& path = sTaxiPathNodesByPath[pathId];
|
|
||||||
if (path.size() < 2)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
std::vector<uint32> nodes;
|
|
||||||
nodes.resize(2);
|
|
||||||
nodes[0] = path[0].index;
|
|
||||||
nodes[1] = path[path.size() - 1].index;
|
|
||||||
|
|
||||||
player->ActivateTaxiPathTo(nodes);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user