Skip to content

Commit

Permalink
Merge pull request #262 from Bestride/icc
Browse files Browse the repository at this point in the history
Fixes: #261 - Fixes index error when for mount on target
  • Loading branch information
DanSheps committed Oct 11, 2023
2 parents 82bcd13 + b10dfee commit 4b9e436
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 45 deletions.
15 changes: 15 additions & 0 deletions Versions/Common/bestride.lua
Expand Up @@ -173,6 +173,21 @@ function BeStride:ChatCommand(input)
LibStub("AceConfigDialog-3.0"):Open("BeStride-Debug")
elseif command == "about" then
LibStub("AceConfigDialog-3.0"):Open("BeStride")
elseif command == "simulate" then
if args == "ground" then
print("Ground:")
local status, err = pcall(BeStride_Mount:Ground())
BeStride_Mount:Ground()
print(err.code)
elseif args == "flying" then
print("Flying:")
local status, err = pcall(BeStride_Mount:Flying())
print(err.code)
else
print("Regular:")
local status, err = pcall(BeStride_Mount:Regular())
print(err.code)
end
else
print("/br - Open Main Configuration Dialog and print help")
print("/br options - Open options Dialog")
Expand Down
63 changes: 23 additions & 40 deletions Versions/Wrath/bestride.lua
Expand Up @@ -16,59 +16,42 @@ function BeStride:IsMainline()
end

function BeStride:GetMountInfoBySpellID(id)
for i=1, GetNumCompanions("MOUNT") do
mount = self:GetMountInfoByIndex(i)
if mount.spellID == id then
return mount
end
end
local mountID = C_MountJournal.GetMountFromSpell(id)
if mountID then
return self:GetMountInfoByMountID(mountID)
end
end

function BeStride:GetMountInfoByMountID(id)
for i=1, GetNumCompanions("MOUNT") do
mount = self:GetMountInfoByIndex(i)
if mount.mountID == id then
return mount
end
end
end

function BeStride:GetMountInfoByIndex(index)
local mountID,creatureName,spellID,icon,isSummoned = GetCompanionInfo("MOUNT", index)
local creatureName,spellID,icon,active,isUsable,sourceType,isFavorite,isFactionSpecific,faction,hideOnChar,isCollected,mountID,isForDragonriding = C_MountJournal.GetMountInfoByID(id)
return {
creatureName = creatureName,
spellID = spellID,
mountID = mountID,
icon = icon,
active = nil,
isUsable = nil,
sourceType = nil,
isFavorite = nil,
isFactionSpecific = nil,
faction = nil,
hideOnChar = nil,
isCollected = true,
isForDragonriding = nil
active = active,
isUsable = isUsable,
sourceType = sourceType,
isFavorite = isFavorite,
isFactionSpecific = isFactionSpecific,
faction = faction,
hideOnChar = hideOnChar,
isCollected = isCollected,
isForDragonriding = isForDragonriding
}
end

function BeStride:OverrideConstants()
BeStride_Constants.Riding.Flight.Restricted.Continents[113] = {}
BeStride_Constants.Riding.Flight.Restricted.Continents[113].requires = 54197
function BeStride:GetMountInfoByIndex(index)
return nil
end

function BeStride:GetKnownMountFromTarget()
local mountIdBySpellId = {}
for i=1,GetNumCompanions("MOUNT"),1 do
local mountID,name,spellID,icon,isSummoned = GetCompanionInfo("MOUNT", i)
mountIdBySpellId[spellID] = mountID
end
-- look for unit aura that matches known AND usable mount ID
for i=1,40,1 do
local spellId = select(10,UnitBuff("target",i))
for i=1,40,1 do
local spellId = select(10, UnitBuff("target", i))
if not spellId then return end
if mountIdBySpellId[spellId] ~= nil then
return spellId, mountIdBySpellId[spellId], true
end
end
local mountId = C_MountJournal.GetMountFromSpell(spellId)
if mountId ~= nil then
return self:isMountUsable(mountId)
end
end
end
8 changes: 3 additions & 5 deletions Versions/Wrath/logic.lua
@@ -1,11 +1,9 @@
BeStride_Game = "Wrath"


function BeStride:isMountUsable(mountId)
--print("isMountUsable: " .. mountId)
spellID = mountTable["master"][mountId].spellID
function BeStride:isMountUsable(mount)
local name,spellID,icon,isActive,isUsable,sourceType,isFavorite,isFactionSpecific,faction,shouldHideOnChar,isCollected,mountID = C_MountJournal.GetMountInfoByID(mount)

return spellID,mountID,true
return spellID,mountID,isUsable
end

function BeStride:isZoneMount(mountId)
Expand Down

0 comments on commit 4b9e436

Please sign in to comment.