Skip to content

Commit fe47a5d

Browse files
authored
(PlayerMethods): Taxi Node Improvements (#357)
1 parent a9bc344 commit fe47a5d

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

src/LuaEngine/LuaFunctions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ ALERegister<Player> PlayerMethods[] =
707707
{ "IsAtLootRewardDistance", &LuaPlayer::IsAtLootRewardDistance },
708708
{ "CanTeleport", &LuaPlayer::CanTeleport },
709709
{ "IsSpectator", &LuaPlayer::IsSpectator },
710+
{ "HasKnownTaxiNode", &LuaPlayer::HasKnownTaxiNode },
710711
// { "HasSpellMod", &LuaPlayer::HasSpellMod },
711712

712713
// Gossip

src/LuaEngine/methods/PlayerMethods.h

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,18 +1634,20 @@ namespace LuaPlayer
16341634
ByteBuffer data;
16351635
player->m_taxi.AppendTaximaskTo(data, false);
16361636

1637+
uint32 idx = 1;
1638+
16371639
for (uint8 i = 0; i < TaxiMaskSize; i++)
16381640
{
16391641
uint32 mask;
16401642
data >> mask;
16411643

16421644
for (uint8 bit = 0; bit < 32; bit++)
16431645
{
1644-
if (mask & (1 << bit))
1646+
if (mask & (1u << bit))
16451647
{
16461648
uint32 nodeId = (i * 32) + bit + 1;
16471649
lua_pushinteger(L, nodeId);
1648-
lua_rawseti(L, -2, lua_rawlen(L, -2) + 1);
1650+
lua_rawseti(L, -2, idx++);
16491651
}
16501652
}
16511653
}
@@ -4981,6 +4983,32 @@ namespace LuaPlayer
49814983
player->ApplyRatingMod(CombatRating(stat), value, apply);
49824984
return 0;
49834985
}
4986+
4987+
/**
4988+
* Returns `true` if the [Player] knows the given taxi node, `false` otherwise.
4989+
*
4990+
* @param uint32 nodeId
4991+
* @return bool known
4992+
*/
4993+
int HasKnownTaxiNode(lua_State* L, Player* player)
4994+
{
4995+
if (!player)
4996+
{
4997+
ALE::Push(L, false);
4998+
return 1;
4999+
}
5000+
5001+
uint32 nodeId = ALE::CHECKVAL<uint32>(L, 2);
5002+
5003+
if (nodeId == 0)
5004+
{
5005+
ALE::Push(L, false);
5006+
return 1;
5007+
}
5008+
5009+
ALE::Push(L, player->m_taxi.IsTaximaskNodeKnown(nodeId));
5010+
return 1;
5011+
}
49845012
};
49855013
#endif
49865014

0 commit comments

Comments
 (0)