Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

Commit f17dc0f

Browse files
committed
Patch 3.1
1 parent 4ee238e commit f17dc0f

6 files changed

Lines changed: 170 additions & 100 deletions

File tree

Core/MultiBot.lua

Lines changed: 113 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ local STRATA_LEVEL_MIGRATION_VERSION = 1
164164
local MAIN_VISIBLE_MIGRATION_VERSION = 1
165165
local QUICK_FRAME_POSITIONS_MIGRATION_VERSION = 1
166166
local HUNTER_PET_STANCE_MIGRATION_VERSION = 1
167+
local FAVORITES_MIGRATION_VERSION = 1
168+
local GLOBAL_BOT_STORE_MIGRATION_VERSION = 1
167169

168170
local function getUiMigrationStore()
169171
local profile = MultiBot.db and MultiBot.db.profile
@@ -194,6 +196,109 @@ local function markLegacyUiStateMigrated(versionKey, targetVersion)
194196
migrations[versionKey] = targetVersion
195197
end
196198

199+
function MultiBot.GetProfileMigrationStore()
200+
return getUiMigrationStore()
201+
end
202+
203+
function MultiBot.ShouldSyncLegacyState(versionKey, targetVersion)
204+
return shouldSyncLegacyUiState(versionKey, targetVersion)
205+
end
206+
207+
function MultiBot.MarkLegacyStateMigrated(versionKey, targetVersion)
208+
markLegacyUiStateMigrated(versionKey, targetVersion)
209+
end
210+
211+
local function getLegacyGlobalBotStore()
212+
local _, globalSave = ensureSavedVariables()
213+
return globalSave
214+
end
215+
216+
local function isGlobalBotRosterEntry(value)
217+
if type(value) ~= "string" then
218+
return false
219+
end
220+
return value:match("^[^,]+,%[[^%]]+%],[^,]*,%d+/%d+/%d+,[^,]+,%-?%d+,%-?%d+$") ~= nil
221+
end
222+
223+
local function sanitizeGlobalBotStore(store)
224+
if type(store) ~= "table" then
225+
return
226+
end
227+
for botName, value in pairs(store) do
228+
if type(botName) ~= "string" or not isGlobalBotRosterEntry(value) then
229+
store[botName] = nil
230+
end
231+
end
232+
end
233+
234+
local function migrateLegacyGlobalBotStoreIfNeeded(store, legacyStore)
235+
if not store or not shouldSyncLegacyUiState("globalBotStoreVersion", GLOBAL_BOT_STORE_MIGRATION_VERSION) then
236+
return
237+
end
238+
239+
for botName, value in pairs(legacyStore or {}) do
240+
if store[botName] == nil and isGlobalBotRosterEntry(value) then
241+
store[botName] = value
242+
end
243+
end
244+
245+
markLegacyUiStateMigrated("globalBotStoreVersion", GLOBAL_BOT_STORE_MIGRATION_VERSION)
246+
end
247+
248+
function MultiBot.GetGlobalBotStore()
249+
local profile = MultiBot.db and MultiBot.db.profile
250+
local legacyStore = getLegacyGlobalBotStore()
251+
if profile then
252+
profile.bots = profile.bots or {}
253+
migrateLegacyGlobalBotStoreIfNeeded(profile.bots, legacyStore)
254+
sanitizeGlobalBotStore(profile.bots)
255+
return profile.bots
256+
end
257+
258+
return legacyStore
259+
end
260+
261+
function MultiBot.SetGlobalBotEntry(name, value)
262+
if type(name) ~= "string" or name == "" then
263+
return nil
264+
end
265+
if not isGlobalBotRosterEntry(value) then
266+
return nil
267+
end
268+
269+
local store = MultiBot.GetGlobalBotStore and MultiBot.GetGlobalBotStore() or getLegacyGlobalBotStore()
270+
store[name] = value
271+
272+
if shouldSyncLegacyUiState("globalBotStoreVersion", GLOBAL_BOT_STORE_MIGRATION_VERSION) then
273+
local legacyStore = getLegacyGlobalBotStore()
274+
legacyStore[name] = value
275+
end
276+
277+
return value
278+
end
279+
280+
function MultiBot.ClearGlobalBotStore()
281+
local store = MultiBot.GetGlobalBotStore and MultiBot.GetGlobalBotStore() or getLegacyGlobalBotStore()
282+
if wipe then
283+
wipe(store)
284+
else
285+
for key in pairs(store) do
286+
store[key] = nil
287+
end
288+
end
289+
290+
if shouldSyncLegacyUiState("globalBotStoreVersion", GLOBAL_BOT_STORE_MIGRATION_VERSION) then
291+
local legacyStore = getLegacyGlobalBotStore()
292+
if wipe then
293+
wipe(legacyStore)
294+
else
295+
for key in pairs(legacyStore) do
296+
legacyStore[key] = nil
297+
end
298+
end
299+
end
300+
end
301+
197302
local MINIMAP_CONFIG_DEFAULTS = {
198303
hide = false,
199304
angle = 220,
@@ -989,13 +1094,17 @@ local function getFavoritesStore()
9891094
if profile then
9901095
profile.favorites = profile.favorites or {}
9911096

992-
for name, isFavorite in pairs(savedVars.Favorites) do
993-
if profile.favorites[name] == nil then
994-
profile.favorites[name] = isFavorite
1097+
if shouldSyncLegacyUiState("favoritesVersion", FAVORITES_MIGRATION_VERSION) then
1098+
for name, isFavorite in pairs(savedVars.Favorites) do
1099+
if profile.favorites[name] == nil then
1100+
profile.favorites[name] = isFavorite
1101+
end
9951102
end
1103+
1104+
savedVars.Favorites = profile.favorites
1105+
markLegacyUiStateMigrated("favoritesVersion", FAVORITES_MIGRATION_VERSION)
9961106
end
9971107

998-
savedVars.Favorites = profile.favorites
9991108
return profile.favorites
10001109
end
10011110

Core/MultiBotEngine.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,10 @@ MultiBot.RaidPool = function(pUnit, oWho)
423423
if(tLocalClass == nil) then tLocalClass = tClass end
424424
if(tLocalRace == nil) then tLocalRace = tRace end
425425

426-
MultiBotGlobalSave[tName] = tLocalRace .. "," .. tGender .. "," .. tSpecial .. "," .. tTabs[1] .. "/" .. tTabs[2] .. "/" .. tTabs[3] .. "," .. tLocalClass .. "," .. tLevel .. "," .. tScore
426+
local botValue = tLocalRace .. "," .. tGender .. "," .. tSpecial .. "," .. tTabs[1] .. "/" .. tTabs[2] .. "/" .. tTabs[3] .. "," .. tLocalClass .. "," .. tLevel .. "," .. tScore
427+
if MultiBot.SetGlobalBotEntry then
428+
MultiBot.SetGlobalBotEntry(tName, botValue)
429+
end
427430
end
428431

429432
--[[MultiBot.ItemLevel = function(pUnit)

Core/MultiBotHandler.lua

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ MultiBot:SetScript("OnUpdate", function(_, pElapsed)
7272

7373
local MAINBAR_MIGRATION_VERSION = 1
7474
local LAYOUT_MIGRATION_VERSION = 1
75+
local MAINBAR_MIGRATION_KEY = "mainBarStateVersion"
76+
local LAYOUT_MIGRATION_KEY = "layoutStateVersion"
7577

7678
local MAINBAR_STATE_KEYS = {
7779
"AttackButton",
@@ -105,31 +107,6 @@ local function getLegacyStateStore()
105107
return MultiBotSave
106108
end
107109

108-
local function getProfileMigrationStore()
109-
local profile = MultiBot.db and MultiBot.db.profile
110-
if not profile then return nil end
111-
profile.migrations = profile.migrations or {}
112-
return profile.migrations
113-
end
114-
115-
local function shouldSyncLegacyState(versionKey, targetVersion)
116-
local migrations = getProfileMigrationStore()
117-
if not migrations then
118-
return true
119-
end
120-
121-
local version = migrations[versionKey]
122-
return type(version) ~= "number" or version < targetVersion
123-
end
124-
125-
local function markLegacyStateMigrated(versionKey, targetVersion)
126-
local migrations = getProfileMigrationStore()
127-
if not migrations then
128-
return
129-
end
130-
migrations[versionKey] = targetVersion
131-
end
132-
133110
local function getMainBarProfileStore()
134111
local profile = MultiBot.db and MultiBot.db.profile
135112
if not profile then return nil end
@@ -139,7 +116,7 @@ local function getMainBarProfileStore()
139116
end
140117

141118
local function migrateLegacyMainBarStateIfNeeded(profileStore)
142-
if not profileStore or not shouldSyncLegacyState("mainBarStateVersion", MAINBAR_MIGRATION_VERSION) then
119+
if not profileStore or not MultiBot.ShouldSyncLegacyState(MAINBAR_MIGRATION_KEY, MAINBAR_MIGRATION_VERSION) then
143120
return
144121
end
145122

@@ -150,7 +127,7 @@ local function migrateLegacyMainBarStateIfNeeded(profileStore)
150127
end
151128
end
152129

153-
markLegacyStateMigrated("mainBarStateVersion", MAINBAR_MIGRATION_VERSION)
130+
MultiBot.MarkLegacyStateMigrated(MAINBAR_MIGRATION_KEY, MAINBAR_MIGRATION_VERSION)
154131
end
155132

156133
local function getSavedMainBarValue(key)
@@ -161,7 +138,7 @@ local function getSavedMainBarValue(key)
161138
end
162139

163140
local value = profileStore and profileStore[key] or legacy[key]
164-
if profileStore and value == nil and shouldSyncLegacyState("mainBarStateVersion", MAINBAR_MIGRATION_VERSION) then
141+
if profileStore and value == nil and MultiBot.ShouldSyncLegacyState(MAINBAR_MIGRATION_KEY, MAINBAR_MIGRATION_VERSION) then
165142
value = legacy[key]
166143
if value ~= nil then
167144
profileStore[key] = value
@@ -177,7 +154,7 @@ local function setSavedMainBarValue(key, value)
177154
profileStore[key] = value
178155
end
179156

180-
if shouldSyncLegacyState("mainBarStateVersion", MAINBAR_MIGRATION_VERSION) then
157+
if MultiBot.ShouldSyncLegacyState(MAINBAR_MIGRATION_KEY, MAINBAR_MIGRATION_VERSION) then
181158
local legacy = getLegacyStateStore()
182159
legacy[key] = value
183160
end
@@ -193,7 +170,7 @@ local function getLayoutProfileStore()
193170
end
194171

195172
local function migrateLegacyLayoutStateIfNeeded(profileStore)
196-
if not profileStore or not shouldSyncLegacyState("layoutStateVersion", LAYOUT_MIGRATION_VERSION) then
173+
if not profileStore or not MultiBot.ShouldSyncLegacyState(LAYOUT_MIGRATION_KEY, LAYOUT_MIGRATION_VERSION) then
197174
return
198175
end
199176

@@ -204,7 +181,7 @@ local function migrateLegacyLayoutStateIfNeeded(profileStore)
204181
end
205182
end
206183

207-
markLegacyStateMigrated("layoutStateVersion", LAYOUT_MIGRATION_VERSION)
184+
MultiBot.MarkLegacyStateMigrated(LAYOUT_MIGRATION_KEY, LAYOUT_MIGRATION_VERSION)
208185
end
209186

210187
local function getSavedLayoutValue(key)
@@ -215,7 +192,7 @@ local function getSavedLayoutValue(key)
215192
end
216193

217194
local value = profileStore and profileStore[key] or legacy[key]
218-
if profileStore and value == nil and shouldSyncLegacyState("layoutStateVersion", LAYOUT_MIGRATION_VERSION) then
195+
if profileStore and value == nil and MultiBot.ShouldSyncLegacyState(LAYOUT_MIGRATION_KEY, LAYOUT_MIGRATION_VERSION) then
219196
value = legacy[key]
220197
if value ~= nil then
221198
profileStore[key] = value
@@ -231,7 +208,7 @@ local function setSavedLayoutValue(key, value)
231208
profileStore[key] = value
232209
end
233210

234-
if shouldSyncLegacyState("layoutStateVersion", LAYOUT_MIGRATION_VERSION) then
211+
if MultiBot.ShouldSyncLegacyState(LAYOUT_MIGRATION_KEY, LAYOUT_MIGRATION_VERSION) then
235212
local legacy = getLegacyStateStore()
236213
legacy[key] = value
237214
end

Core/MultiBotInit.lua

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,16 +1936,35 @@ function MultiBot.BuildGmUI(tMultiBar)
19361936
button1 = YES,
19371937
button2 = NO,
19381938
OnAccept = function()
1939-
if wipe then wipe(MultiBotGlobalSave)
1940-
else for k in pairs(MultiBotGlobalSave) do MultiBotGlobalSave[k]=nil end end
1939+
if MultiBot.ClearGlobalBotStore then
1940+
MultiBot.ClearGlobalBotStore()
1941+
elseif wipe then
1942+
wipe(MultiBotGlobalSave)
1943+
else
1944+
for k in pairs(MultiBotGlobalSave) do MultiBotGlobalSave[k]=nil end
1945+
end
19411946
ReloadUI()
19421947
end,
19431948
timeout = 0, whileDead=true, hideOnEscape=true,
19441949
}
19451950

1951+
function MultiBot.ShowDeleteSVPrompt()
1952+
if MultiBot.GM == false then
1953+
SendChatMessage(MultiBot.info.rights, "SAY")
1954+
return
1955+
end
1956+
StaticPopup_Show("MULTIBOT_DELETE_SV")
1957+
end
1958+
19461959
tMasters.addButton("DelSV", 0, 204, "ability_golemstormbolt",
19471960
MultiBot.tips.game.delsv, "ActionButtonTemplate")
1948-
.doLeft = function() StaticPopup_Show("MULTIBOT_DELETE_SV") end
1961+
.doLeft = function() MultiBot.ShowDeleteSVPrompt() end
1962+
1963+
MultiBot.RegisterCommandAliases("MULTIBOTDELSV", function()
1964+
if MultiBot.ShowDeleteSVPrompt then
1965+
MultiBot.ShowDeleteSVPrompt()
1966+
end
1967+
end, { "mbdelsv" })
19491968
end
19501969

19511970
-- Calling the function
@@ -6603,9 +6622,6 @@ end
66036622
-- SHAMAN TOTEMS QUICK BAR --
66046623
if not MultiBot.InitShamanQuick then
66056624
function MultiBot.InitShamanQuick()
6606-
-- SavedVariables
6607-
MultiBotSaved = MultiBotSaved or {}
6608-
66096625
local MBS = MultiBot.ShamanQuick or {}
66106626
MultiBot.ShamanQuick = MBS
66116627

Features/MultiBotRaidus.lua

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ end
188188

189189
local RAIDUS_LAYOUT_SLOT_MAX = 8
190190
local RAIDUS_LAYOUT_MIGRATION_VERSION = 1
191+
local RAIDUS_LAYOUT_MIGRATION_KEY = "raidusLayoutsVersion"
191192

192193
-- Forward declaration keeps a local upvalue even if helpers are reordered later.
193194
local getRaidusLayoutKey
@@ -208,34 +209,12 @@ getRaidusLayoutKey = function(slot)
208209
return "Raidus" .. (slot or "")
209210
end
210211

211-
local function getRaidusLayoutMigrationStore()
212-
local profile = MultiBot.db and MultiBot.db.profile
213-
if not profile then
214-
return nil
215-
end
216-
217-
profile.migrations = profile.migrations or {}
218-
return profile.migrations
219-
end
220-
221-
local function shouldSyncLegacyRaidusLayouts()
222-
local migrationStore = getRaidusLayoutMigrationStore()
223-
if not migrationStore then
224-
return true
225-
end
226-
227-
local version = migrationStore.raidusLayoutsVersion
228-
return type(version) ~= "number" or version < RAIDUS_LAYOUT_MIGRATION_VERSION
229-
end
230-
231212
local function migrateLegacyRaidusLayoutsIfNeeded(store)
232-
local migrationStore = getRaidusLayoutMigrationStore()
233-
if not migrationStore then
213+
if not MultiBot.GetProfileMigrationStore() then
234214
return
235215
end
236216

237-
local version = migrationStore.raidusLayoutsVersion
238-
if type(version) == "number" and version >= RAIDUS_LAYOUT_MIGRATION_VERSION then
217+
if not MultiBot.ShouldSyncLegacyState(RAIDUS_LAYOUT_MIGRATION_KEY, RAIDUS_LAYOUT_MIGRATION_VERSION) then
239218
return
240219
end
241220

@@ -248,7 +227,7 @@ local function migrateLegacyRaidusLayoutsIfNeeded(store)
248227
end
249228
end
250229

251-
migrationStore.raidusLayoutsVersion = RAIDUS_LAYOUT_MIGRATION_VERSION
230+
MultiBot.MarkLegacyStateMigrated(RAIDUS_LAYOUT_MIGRATION_KEY, RAIDUS_LAYOUT_MIGRATION_VERSION)
252231
end
253232

254233
local function getRaidusLayoutValue(slot)
@@ -261,7 +240,8 @@ local function getRaidusLayoutValue(slot)
261240
return value
262241
end
263242

264-
if shouldSyncLegacyRaidusLayouts() then
243+
local shouldSyncLegacy = MultiBot.ShouldSyncLegacyState(RAIDUS_LAYOUT_MIGRATION_KEY, RAIDUS_LAYOUT_MIGRATION_VERSION)
244+
if shouldSyncLegacy then
265245
MultiBotSave = MultiBotSave or {}
266246
value = MultiBotSave[key]
267247
if value ~= nil then
@@ -278,7 +258,8 @@ local function setRaidusLayoutValue(slot, value)
278258
migrateLegacyRaidusLayoutsIfNeeded(store)
279259
store[key] = value
280260

281-
if shouldSyncLegacyRaidusLayouts() then
261+
local shouldSyncLegacy = MultiBot.ShouldSyncLegacyState(RAIDUS_LAYOUT_MIGRATION_KEY, RAIDUS_LAYOUT_MIGRATION_VERSION)
262+
if shouldSyncLegacy then
282263
MultiBotSave = MultiBotSave or {}
283264
MultiBotSave[key] = value
284265
end
@@ -705,6 +686,9 @@ end
705686
-- SETTER --
706687

707688
local function getRaidusGlobalBotStore()
689+
if MultiBot.GetGlobalBotStore then
690+
return MultiBot.GetGlobalBotStore()
691+
end
708692
MultiBotGlobalSave = MultiBotGlobalSave or {}
709693
return MultiBotGlobalSave
710694
end

0 commit comments

Comments
 (0)