Project Zomboid

Project Zomboid

B42/41 Dragon Radar v2.4
Voder 5 Apr, 2024 @ 10:24am
"clean map" issue
I looked into code, found disabled clean map button and comment about fixing it. After some research found the underlying problem. Map symbol index is mostly useless, at least because it changes when you manually remove symbols from map. Fixed removeAll function by completely disregarding stored indices and searching by mark coordinates only. Works good, but most likely you have to remove indices everywhere, and store coordinate list persistently instead of indices. Searching through all map markers could be somewhat worse for performance, which, however, does not matter because it is very unfrequent operation. Coordinates are still not stored in persistent mod data, so my fix is not complete by itself, only enough for reliably removing mod markers from current session. Here is new code
function DR_MapMarker:removeAll() local sym_count = self.symbolsAPI:getSymbolCount() local sym_indices = {} for i = 0, sym_count-1 do local sym = self.symbolsAPI:getSymbolByIndex(i) local sym_worldX = sym:getWorldX() local sym_worldY = sym:getWorldY() for sq,_ in pairs(self.marked:getIterable()) do local sqX = sq:getX() local sqY = sq:getY() if sym_worldX == sqX and sym_worldY==sqY then table.insert(sym_indices, i) end end end table.sort (sym_indices, function (a, b) return (a > b) end) for k,v in ipairs(sym_indices) do self.symbolsAPI:removeSymbolByIndex(v) end for sq,_ in pairs(self.marked:getIterable()) do self.marked:remove(sq) end self.indexedSymbols = {} -- rudimentary end
Here I firstly store all map symbols which have same coordinates as in self.marked set (could be improved), then sorting found indices from max to min to work around map indices shifting while removing (by arranging from end to beginning), then actually removing from map and clearing the set
Last edited by Voder; 5 Apr, 2024 @ 10:42am
< >
Showing 1-1 of 1 comments
Voder 5 Apr, 2024 @ 11:02am 
Also mod window opens only on second press of associated key. It is easy fix in DR_ItemSearchPanel file in local function onCustomUIKeyPressed to
if DR.ui == nil then createDR_ItemSearchPanel() end DR_ItemSearchPanel.toggleItemSearchPanel()
Not tested a lot, of course.
< >
Showing 1-1 of 1 comments
Per page: 1530 50