@@ -260,11 +260,12 @@ function dcsbot.addMission(json)
260260 end
261261 net .missionlist_append (path )
262262 local current_missions = net .missionlist_get ()
263- local listStartIndex
263+ local listStartIndex = current_missions [ " listStartIndex" ]
264264 if json .autostart == true then
265265 listStartIndex = # current_missions [' missionList' ]
266- else
267- listStartIndex = current_missions [" listStartIndex" ]
266+ -- workaround DCS bug
267+ elseif # current_missions [' missionList' ] < listStartIndex then
268+ listStartIndex = 1
268269 end
269270 utils .saveSettings ({
270271 missionList = current_missions [" missionList" ],
@@ -277,9 +278,14 @@ function dcsbot.deleteMission(json)
277278 log .write (' DCSServerBot' , log .DEBUG , ' Mission: deleteMission()' )
278279 net .missionlist_delete (json .id )
279280 local current_missions = net .missionlist_get ()
281+ -- workaround DCS bug
282+ local listStartIndex = current_missions [" listStartIndex" ]
283+ if # current_missions [' missionList' ] < listStartIndex then
284+ listStartIndex = 1
285+ end
280286 utils .saveSettings ({
281287 missionList = current_missions [" missionList" ],
282- listStartIndex = current_missions [ " listStartIndex" ]
288+ listStartIndex = listStartIndex
283289 })
284290 dcsbot .listMissions (json )
285291end
@@ -291,8 +297,14 @@ function dcsbot.replaceMission(json)
291297 net .missionlist_append (json .path )
292298 net .missionlist_move (# current_missions [" missionList" ], tonumber (json .index ))
293299 current_missions = net .missionlist_get ()
300+ -- workaround DCS bug
301+ local listStartIndex = current_missions [" listStartIndex" ]
302+ if # current_missions [' missionList' ] < listStartIndex then
303+ listStartIndex = 1
304+ end
294305 utils .saveSettings ({
295- missionList = current_missions [" missionList" ]
306+ missionList = current_missions [" missionList" ],
307+ listStartIndex = listStartIndex
296308 })
297309 dcsbot .listMissions (json )
298310end
0 commit comments