Code format

This commit is contained in:
2025-05-15 20:37:50 +02:00
parent 9e6432d0b0
commit 69d1f9fd93
105 changed files with 24069 additions and 28084 deletions

View File

@@ -1,6 +1,60 @@
local cc =
{
"Gnaw", "Hungering Cold", "Bash", "Cyclone", "Entangling Roots", "Hibernate", "Maim", "Pounce", "Entrapment", "Freezing Trap", "Pin", "Scare Beast", "Scatter Shot", "Intimidation", "Ravage", "Sonic Blast", "Wyvern Sting", "Deep Freeze", "Dragon's Breath", "Frost Nova", "Polymorph", "Shattered Barrier", "Slow", "Frostbolt", "Hammer of Justice", "Holy Wrath", "Repentance", "Seal of Justice", "Turn Evil", "Mind Control", "Psychic Horror", "Psychic Scream", "Shackle Undead", "Holy Word: Chastise", "Sin and Punishment", "Blind", "Cheap Shot", "Gouge", "Kidney Shot", "Sap", "Earthbind Totem", "Stoneclaw Totem", "Hex", "Banish", "Death Coil", "Fear", "Howl of Terror", "Intercept", "Seduction", "Shadowfury", "Charge", "Concussion Blow", "Hamstring", "Improved Hamstring", "Intimidating Shout", "Shockwave"
local cc = {
"Gnaw",
"Hungering Cold",
"Bash",
"Cyclone",
"Entangling Roots",
"Hibernate",
"Maim",
"Pounce",
"Entrapment",
"Freezing Trap",
"Pin",
"Scare Beast",
"Scatter Shot",
"Intimidation",
"Ravage",
"Sonic Blast",
"Wyvern Sting",
"Deep Freeze",
"Dragon's Breath",
"Frost Nova",
"Polymorph",
"Shattered Barrier",
"Slow",
"Frostbolt",
"Hammer of Justice",
"Holy Wrath",
"Repentance",
"Seal of Justice",
"Turn Evil",
"Mind Control",
"Psychic Horror",
"Psychic Scream",
"Shackle Undead",
"Holy Word: Chastise",
"Sin and Punishment",
"Blind",
"Cheap Shot",
"Gouge",
"Kidney Shot",
"Sap",
"Earthbind Totem",
"Stoneclaw Totem",
"Hex",
"Banish",
"Death Coil",
"Fear",
"Howl of Terror",
"Intercept",
"Seduction",
"Shadowfury",
"Charge",
"Concussion Blow",
"Hamstring",
"Improved Hamstring",
"Intimidating Shout",
"Shockwave",
}
local hashtable = {}
local spellarray = {}
@@ -78,7 +132,7 @@ end
local function findcollision(hash_table, array)
local collisions = 0
for k,v in ipairs(hash_table) do
for k, v in ipairs(hash_table) do
for i = 1, table.getn(hash_table) do
if i ~= k then
if hash_table[i] == hash_table[k] then
@@ -98,7 +152,7 @@ local function tohash(tempvar)
charTable[#charTable + 1] = char
hash = hash + tonum(char)
hash = hash / table.getn(charTable)
end
end
hash = math.floor(hash * 10000)
return hash
--print(spellarray[hash], hash)
@@ -109,9 +163,9 @@ local function checkbase(spell)
if spellarray[tohash(spell)] == spell then return 1 end
end
for k,v in ipairs(cc) do
for k, v in ipairs(cc) do
local hash = tohash(v)
hashtable[#hashtable] = hash
spellarray[hash] = v
end
findcollision(hashtable, cc)
findcollision(hashtable, cc)

View File

@@ -1,51 +1,46 @@
-- TODO: Make this not suck
function TomTom:AddWaypoint(x, y, desc, persistent, minimap, world, silent)
local c,z = GetCurrentMapContinent(), GetCurrentMapZone()
local c, z = GetCurrentMapContinent(), GetCurrentMapZone()
if not c or not z or c < 1 then
--self:Print("Cannot find a valid zone to place the coordinates")
return
end
if not c or not z or c < 1 then
--self:Print("Cannot find a valid zone to place the coordinates")
return
end
return self:AddZWaypoint(c, z, x, y, desc, persistent, minimap, world, nil, silent)
return self:AddZWaypoint(c, z, x, y, desc, persistent, minimap, world, nil, silent)
end
function TomTom:AddZWaypoint(c, z, x, y, desc, persistent, minimap, world, callbacks, silent, crazy)
-- Convert the c,z,x,y tuple to m,f,x,y and pass the work off to AddMFWaypoint()
local mapId, floor = hbd:GetMapIDFromCZ(c, z)
if not mapId then
return
end
-- Convert the c,z,x,y tuple to m,f,x,y and pass the work off to AddMFWaypoint()
local mapId, floor = hbd:GetMapIDFromCZ(c, z)
if not mapId then return end
return self:AddMFWaypoint(mapId, floor, x/100, y/100, {
title = desc,
persistent = persistent,
minimap = minimap,
world = world,
callbacks = callbacks,
silent = silent,
crazy = crazy,
})
return self:AddMFWaypoint(mapId, floor, x / 100, y / 100, {
title = desc,
persistent = persistent,
minimap = minimap,
world = world,
callbacks = callbacks,
silent = silent,
crazy = crazy,
})
end
function TomTom:AddWaypointToCurrentZone(x, y, desc)
local m, f = TomTom:GetCurrentPlayerPosition()
if not m then
return
end
local m, f = TomTom:GetCurrentPlayerPosition()
if not m then return end
return self:AddMFWaypoint(m, f, x/100, y/100, {
title = desc,
})
return self:AddMFWaypoint(m, f, x / 100, y / 100, {
title = desc,
})
end
function TomTom:SetCustomWaypoint(c,z,x,y,callback,minimap,world,silent)
return self:AddZWaypoint(c, z, x, y, nil, false, minimap, world, callback, silent)
function TomTom:SetCustomWaypoint(c, z, x, y, callback, minimap, world, silent)
return self:AddZWaypoint(c, z, x, y, nil, false, minimap, world, callback, silent)
end
function TomTom:SetCustomMFWaypoint(m, f, x, y, opts)
opts.persistent = false
opts.persistent = false
return self:AddMFWaypoint(m, f, x, y, opts)
end
return self:AddMFWaypoint(m, f, x, y, opts)
end

View File

@@ -2,67 +2,57 @@ function TomTom:AddMFWaypoint(m, f, x, y, opts)
opts = opts or {}
-- Default values
if opts.persistent == nil then opts.persistent = self.profile.persistence.savewaypoints end
if opts.minimap == nil then opts.minimap = self.profile.minimap.enable end
if opts.world == nil then opts.world = self.profile.worldmap.enable end
if opts.crazy == nil then opts.crazy = self.profile.arrow.autoqueue end
if opts.persistent == nil then opts.persistent = self.profile.persistence.savewaypoints end
if opts.minimap == nil then opts.minimap = self.profile.minimap.enable end
if opts.world == nil then opts.world = self.profile.worldmap.enable end
if opts.crazy == nil then opts.crazy = self.profile.arrow.autoqueue end
if opts.cleardistance == nil then opts.cleardistance = self.profile.persistence.cleardistance end
if opts.arrivaldistance == nil then opts.arrivaldistance = self.profile.arrow.arrival end
if not opts.callbacks then
opts.callbacks = TomTom:DefaultCallbacks(opts)
if not opts.callbacks then opts.callbacks = TomTom:DefaultCallbacks(opts) end
local zoneName = hbd:GetLocalizedMap(m)
-- Get the default map floor, if necessary
if not f then
local floors = hbd:GetNumFloors(m)
f = floors == 0 and 0 or 1
end
local zoneName = hbd:GetLocalizedMap(m)
-- Ensure there isn't already a waypoint at this location
local key = self:GetKey({ m, f, x, y, title = opts.title })
if waypoints[m] and waypoints[m][key] then return waypoints[m][key] end
-- Get the default map floor, if necessary
if not f then
local floors = hbd:GetNumFloors(m)
f = floors == 0 and 0 or 1
end
-- uid is the 'new waypoint' called this for historical reasons
local uid = { m, f, x, y, title = opts.title }
-- Ensure there isn't already a waypoint at this location
local key = self:GetKey({m, f, x, y, title = opts.title})
if waypoints[m] and waypoints[m][key] then
return waypoints[m][key]
end
-- Copy over any options, so we have em
for k, v in pairs(opts) do
if not uid[k] then uid[k] = v end
end
-- uid is the 'new waypoint' called this for historical reasons
local uid = {m, f, x, y, title = opts.title}
-- No need to convert x and y because they're already 0-1 instead of 0-100
self:SetWaypoint(uid, opts.callbacks, opts.minimap, opts.world)
if opts.crazy then self:SetCrazyArrow(uid, opts.arrivaldistance, opts.title) end
-- Copy over any options, so we have em
for k,v in pairs(opts) do
if not uid[k] then
uid[k] = v
end
end
waypoints[m] = waypoints[m] or {}
waypoints[m][key] = uid
-- No need to convert x and y because they're already 0-1 instead of 0-100
self:SetWaypoint(uid, opts.callbacks, opts.minimap, opts.world)
if opts.crazy then
self:SetCrazyArrow(uid, opts.arrivaldistance, opts.title)
end
-- If this is a persistent waypoint, then add it to the waypoints table
if opts.persistent then self.waypointprofile[m][key] = uid end
waypoints[m] = waypoints[m] or {}
waypoints[m][key] = uid
-- If this is a persistent waypoint, then add it to the waypoints table
if opts.persistent then
self.waypointprofile[m][key] = uid
end
if not opts.silent and self.profile.general.announce then
local ctxt = RoundCoords(x, y, 2)
local desc = opts.title and opts.title or ""
local sep = opts.title and " - " or ""
local msg = string.format(L["|cffffff78TomTom:|r Added a waypoint (%s%s%s) in %s"], desc, sep, ctxt, zoneName)
ChatFrame1:AddMessage(msg)
end
return uid
if not opts.silent and self.profile.general.announce then
local ctxt = RoundCoords(x, y, 2)
local desc = opts.title and opts.title or ""
local sep = opts.title and " - " or ""
local msg = string.format(L["|cffffff78TomTom:|r Added a waypoint (%s%s%s) in %s"], desc, sep, ctxt, zoneName)
ChatFrame1:AddMessage(msg)
end
return uid
end
local coord_fmt = "%%.%df, %%.%df"
function RoundCoords(x,y,prec)
local fmt = coord_fmt:format(prec, prec)
return fmt:format(x*100, y*100)
end
function RoundCoords(x, y, prec)
local fmt = coord_fmt:format(prec, prec)
return fmt:format(x * 100, y * 100)
end

File diff suppressed because it is too large Load Diff