mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Added debug option to properly erase invalid tiles from maps
This commit is contained in:
@@ -208,6 +208,8 @@ def pbDebugMenuCommands(showall=true)
|
|||||||
_INTL("Fully compile all data."))
|
_INTL("Fully compile all data."))
|
||||||
commands.add("othermenu","debugconsole",_INTL("Debug Console"),
|
commands.add("othermenu","debugconsole",_INTL("Debug Console"),
|
||||||
_INTL("Open the Debug Console."))
|
_INTL("Open the Debug Console."))
|
||||||
|
commands.add("othermenu","invalidtiles",_INTL("Fix Invalid Tiles"),
|
||||||
|
_INTL("Scans all maps and erases non-existent tiles."))
|
||||||
|
|
||||||
return commands
|
return commands
|
||||||
end
|
end
|
||||||
@@ -795,6 +797,8 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
|
|||||||
pbDisposeMessageWindow(msgwindow)
|
pbDisposeMessageWindow(msgwindow)
|
||||||
when "debugconsole"
|
when "debugconsole"
|
||||||
Console::setup_console
|
Console::setup_console
|
||||||
|
when "invalidtiles"
|
||||||
|
pbDebugFixInvalidTiles
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -796,6 +796,76 @@ def pbImportAllAnimations
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Properly erases all non-existent tiles in maps (including event graphics)
|
||||||
|
#===============================================================================
|
||||||
|
def pbDebugFixInvalidTiles
|
||||||
|
num_errors = 0
|
||||||
|
num_error_maps = 0
|
||||||
|
@tilesets = pbLoadRxData("Data/Tilesets")
|
||||||
|
mapData = MapData.new
|
||||||
|
t = Time.now.to_i
|
||||||
|
Graphics.update
|
||||||
|
for id in mapData.mapinfos.keys.sort
|
||||||
|
if Time.now.to_i - t >= 5
|
||||||
|
Graphics.update
|
||||||
|
t = Time.now.to_i
|
||||||
|
end
|
||||||
|
changed = false
|
||||||
|
map = mapData.getMap(id)
|
||||||
|
next if !map || !mapData.mapinfos[id]
|
||||||
|
Win32API.SetWindowText(_INTL("Processing map {1} ({2})", id, mapData.mapinfos[id].name))
|
||||||
|
passages = mapData.getTilesetPassages(map, id)
|
||||||
|
# Check all tiles in map for non-existent tiles
|
||||||
|
for x in 0...map.data.xsize
|
||||||
|
for y in 0...map.data.ysize
|
||||||
|
for i in 0...map.data.zsize
|
||||||
|
tile_id = map.data[x, y, i]
|
||||||
|
next if pbCheckTileValidity(tile_id, map, @tilesets, passages)
|
||||||
|
map.data[x, y, i] = 0
|
||||||
|
changed = true
|
||||||
|
num_errors += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# Check all events in map for page graphics using a non-existent tile
|
||||||
|
for key in map.events.keys
|
||||||
|
event = map.events[key]
|
||||||
|
for page in event.pages
|
||||||
|
next if page.graphic.tile_id <= 0
|
||||||
|
next if pbCheckTileValidity(page.graphic.tile_id, map, @tilesets, passages)
|
||||||
|
page.graphic.tile_id = 0
|
||||||
|
changed = true
|
||||||
|
num_errors += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
next if !changed
|
||||||
|
# Map was changed; save it
|
||||||
|
num_error_maps += 1
|
||||||
|
mapData.saveMap(id)
|
||||||
|
end
|
||||||
|
if num_error_maps == 0
|
||||||
|
pbMessage(_INTL("No invalid tiles were found."))
|
||||||
|
else
|
||||||
|
pbMessage(_INTL("{1} error(s) were found across {2} map(s) and fixed.", num_errors, num_error_maps))
|
||||||
|
pbMessage(_INTL("Close RPG Maker XP to ensure the changes are applied properly."))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def pbCheckTileValidity(tile_id, map, tilesets, passages)
|
||||||
|
return false if !tile_id
|
||||||
|
if tile_id > 0 && tile_id < 384
|
||||||
|
# Check for defined autotile
|
||||||
|
autotile_id = tile_id / 48 - 1
|
||||||
|
autotile_name = tilesets[map.tileset_id].autotile_names[autotile_id]
|
||||||
|
return true if autotile_name && autotile_name != ""
|
||||||
|
else
|
||||||
|
# Check for tileset data
|
||||||
|
return true if passages[tile_id]
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user