mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Cached MapInfos.rxdata and map_connections.dat, reduced usage of load_data
This commit is contained in:
@@ -416,11 +416,7 @@ module MapFactoryHelper
|
||||
def self.getMapConnections
|
||||
if !@@MapConnections
|
||||
@@MapConnections = []
|
||||
begin
|
||||
conns = load_data("Data/map_connections.dat")
|
||||
rescue
|
||||
conns = []
|
||||
end
|
||||
conns = pbLoadMapConnections
|
||||
for i in 0...conns.length
|
||||
conn = conns[i]
|
||||
v = getMapEdge(conn[0],conn[1])
|
||||
|
||||
@@ -153,7 +153,7 @@ def createMinimap2(mapid)
|
||||
bitmap=BitmapWrapper.new(map.width*4,map.height*4)
|
||||
black=Color.new(0,0,0)
|
||||
bigmap=(map.width>40 && map.height>40)
|
||||
tilesets=load_data("Data/Tilesets.rxdata")
|
||||
tilesets=$data_tilesets
|
||||
tileset=tilesets[map.tileset_id]
|
||||
return bitmap if !tileset
|
||||
helper=TileDrawingHelper.fromTileset(tileset)
|
||||
@@ -181,7 +181,7 @@ def createMinimap(mapid)
|
||||
return BitmapWrapper.new(32,32) if !map
|
||||
bitmap=BitmapWrapper.new(map.width*4,map.height*4)
|
||||
black=Color.new(0,0,0)
|
||||
tilesets=load_data("Data/Tilesets.rxdata")
|
||||
tilesets=$data_tilesets
|
||||
tileset=tilesets[map.tileset_id]
|
||||
return bitmap if !tileset
|
||||
helper=TileDrawingHelper.fromTileset(tileset)
|
||||
|
||||
@@ -179,7 +179,7 @@ end
|
||||
# and matching mount points added through System.mount
|
||||
def pbRgssExists?(filename)
|
||||
filename = canonicalize(filename)
|
||||
if safeExists?("./Game.rgssad") || safeExists?("./Game.rgss2a")
|
||||
if safeExists?("./Game.rgssad")
|
||||
return pbGetFileChar(filename)!=nil
|
||||
else
|
||||
return safeExists?(filename)
|
||||
@@ -193,7 +193,7 @@ end
|
||||
# and matching mount points added through System.mount
|
||||
def pbRgssOpen(file,mode=nil)
|
||||
#File.open("debug.txt","ab") { |fw| fw.write([file,mode,Time.now.to_f].inspect+"\r\n") }
|
||||
if !safeExists?("./Game.rgssad") && !safeExists?("./Game.rgss2a")
|
||||
if !safeExists?("./Game.rgssad")
|
||||
if block_given?
|
||||
File.open(file,mode) { |f| yield f }
|
||||
return nil
|
||||
@@ -216,7 +216,7 @@ end
|
||||
# encrypted archives.
|
||||
def pbGetFileChar(file)
|
||||
file = canonicalize(file)
|
||||
if !safeExists?("./Game.rgssad") && !safeExists?("./Game.rgss2a")
|
||||
if !safeExists?("./Game.rgssad")
|
||||
return nil if !safeExists?(file)
|
||||
begin
|
||||
File.open(file,"rb") { |f| return f.read(1) } # read one byte
|
||||
@@ -245,7 +245,7 @@ end
|
||||
# and matching mount points added through System.mount
|
||||
def pbGetFileString(file)
|
||||
file = canonicalize(file)
|
||||
if !(safeExists?("./Game.rgssad") || safeExists?("./Game.rgss2a"))
|
||||
if !safeExists?("./Game.rgssad")
|
||||
return nil if !safeExists?(file)
|
||||
begin
|
||||
File.open(file,"rb") { |f| return f.read } # read all data
|
||||
|
||||
@@ -96,7 +96,7 @@ def pbSetTextMessages
|
||||
choices|=[]
|
||||
items.concat(choices)
|
||||
MessageTypes.setMapMessagesAsHash(0,items)
|
||||
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||
mapinfos = pbLoadMapInfos
|
||||
mapnames=[]
|
||||
for id in mapinfos.keys
|
||||
mapnames[id]=mapinfos[id].name
|
||||
|
||||
@@ -343,7 +343,7 @@ end
|
||||
#===============================================================================
|
||||
def pbGetBasicMapNameFromId(id)
|
||||
begin
|
||||
map = load_data("Data/MapInfos.rxdata")
|
||||
map = pbLoadMapInfos
|
||||
return "" if !map
|
||||
return map[id].name
|
||||
rescue
|
||||
|
||||
@@ -8,6 +8,8 @@ class PokemonTemp
|
||||
attr_accessor :speciesShadowMovesets
|
||||
attr_accessor :moveToAnim
|
||||
attr_accessor :battleAnims
|
||||
attr_accessor :mapInfos
|
||||
attr_accessor :mapConnections
|
||||
end
|
||||
|
||||
def pbClearData
|
||||
@@ -18,15 +20,14 @@ def pbClearData
|
||||
$PokemonTemp.speciesShadowMovesets = nil
|
||||
$PokemonTemp.moveToAnim = nil
|
||||
$PokemonTemp.battleAnims = nil
|
||||
$PokemonTemp.mapInfos = nil
|
||||
$PokemonTemp.mapConnections = nil
|
||||
end
|
||||
MapFactoryHelper.clear
|
||||
$PokemonEncounters.setup($game_map.map_id) if $game_map && $PokemonEncounters
|
||||
if pbRgssExists?("Data/Tilesets.rxdata")
|
||||
$data_tilesets = load_data("Data/Tilesets.rxdata")
|
||||
end
|
||||
if pbRgssExists?("Data/Tilesets.rvdata")
|
||||
$data_tilesets = load_data("Data/Tilesets.rvdata")
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
@@ -95,3 +96,25 @@ def pbLoadBattleAnimations
|
||||
end
|
||||
return $PokemonTemp.battleAnims
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Method relating to map connections data.
|
||||
#===============================================================================
|
||||
def pbLoadMapConnections
|
||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||
if !$PokemonTemp.mapConnections
|
||||
$PokemonTemp.mapConnections = load_data("Data/map_connections.dat") || []
|
||||
end
|
||||
return $PokemonTemp.mapConnections
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Method relating to map infos data.
|
||||
#===============================================================================
|
||||
def pbLoadMapInfos
|
||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||
if !$PokemonTemp.mapInfos
|
||||
$PokemonTemp.mapInfos = load_data("Data/MapInfos.rxdata")
|
||||
end
|
||||
return $PokemonTemp.mapInfos
|
||||
end
|
||||
|
||||
@@ -405,7 +405,7 @@ Events.onMapChanging += proc { |_sender, e|
|
||||
next if new_map_ID == 0
|
||||
old_map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
next if !old_map_metadata || !old_map_metadata.weather
|
||||
map_infos = load_data("Data/MapInfos.rxdata")
|
||||
map_infos = pbLoadMapInfos
|
||||
if $game_map.name == map_infos[new_map_ID].name
|
||||
new_map_metadata = GameData::MapMetadata.try_get(new_map_ID)
|
||||
next if new_map_metadata && new_map_metadata.weather
|
||||
@@ -425,7 +425,7 @@ Events.onMapChange += proc { |_sender, e|
|
||||
$PokemonGlobal.visitedMaps[$game_map.map_id] = true
|
||||
next if old_map_ID == 0 || old_map_ID == $game_map.map_id
|
||||
next if !new_map_metadata || !new_map_metadata.weather
|
||||
map_infos = load_data("Data/MapInfos.rxdata")
|
||||
map_infos = pbLoadMapInfos
|
||||
if $game_map.name == map_infos[old_map_ID].name
|
||||
old_map_metadata = GameData::MapMetadata.try_get(old_map_ID)
|
||||
next if old_map_metadata && old_map_metadata.weather
|
||||
@@ -470,7 +470,7 @@ Events.onMapSceneChange += proc { |_sender, e|
|
||||
Settings::NO_SIGNPOSTS[2 * i] == $game_map.map_id
|
||||
break if nosignpost
|
||||
end
|
||||
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||
mapinfos = pbLoadMapInfos
|
||||
oldmapname = mapinfos[$PokemonGlobal.mapTrail[1]].name
|
||||
nosignpost = true if $game_map.name == oldmapname
|
||||
end
|
||||
|
||||
@@ -96,7 +96,7 @@ end
|
||||
Events.onMapChange += proc { |_sender,e|
|
||||
oldMapID = e[0]
|
||||
# Get and compare map names
|
||||
mapInfos = load_data("Data/MapInfos.rxdata")
|
||||
mapInfos = pbLoadMapInfos
|
||||
next if mapInfos && oldMapID>0 && mapInfos[oldMapID] &&
|
||||
mapInfos[oldMapID].name && $game_map.name==mapInfos[oldMapID].name
|
||||
# Make roaming Pokémon roam
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# exists, the real file is deleted to ensure that the file is loaded from the
|
||||
# encrypted archive.
|
||||
def pbSafeLoad(file)
|
||||
if (safeExists?("./Game.rgssad") || safeExists?("./Game.rgss2a")) && safeExists?(file)
|
||||
if safeExists?("./Game.rgssad") && safeExists?(file)
|
||||
File.delete(file) rescue nil
|
||||
end
|
||||
return load_data(file)
|
||||
|
||||
@@ -422,7 +422,7 @@ class SpriteWindow_DebugRoamers < Window_DrawableCommand
|
||||
# roaming
|
||||
curmap = $PokemonGlobal.roamPosition[index]
|
||||
if curmap
|
||||
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||
mapinfos = pbLoadMapInfos
|
||||
status = "[ROAMING][#{curmap}: #{mapinfos[curmap].name}]"
|
||||
else
|
||||
status = "[ROAMING][map not set]"
|
||||
@@ -771,7 +771,7 @@ end
|
||||
def pbDebugFixInvalidTiles
|
||||
num_errors = 0
|
||||
num_error_maps = 0
|
||||
@tilesets = load_data("Data/Tilesets.rxdata")
|
||||
@tilesets = $data_tilesets
|
||||
mapData = MapData.new
|
||||
t = Time.now.to_i
|
||||
Graphics.update
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# Main editor method for editing wild encounters. Lists all defined encounter
|
||||
# sets, and edits them.
|
||||
def pbEncountersEditor
|
||||
map_infos = load_data("Data/MapInfos.rxdata")
|
||||
map_infos = pbLoadMapInfos
|
||||
commands = []
|
||||
maps = []
|
||||
list = pbListWindow([])
|
||||
@@ -122,7 +122,7 @@ end
|
||||
# Lists the map ID, version number and defined encounter types for the given
|
||||
# encounter data (a GameData::Encounter instance), and edits them.
|
||||
def pbEncounterMapVersionEditor(enc_data)
|
||||
map_infos = load_data("Data/MapInfos.rxdata")
|
||||
map_infos = pbLoadMapInfos
|
||||
commands = []
|
||||
enc_types = []
|
||||
list = pbListWindow([])
|
||||
@@ -720,7 +720,7 @@ def pbMetadataScreen(map_id = 0)
|
||||
end
|
||||
|
||||
def pbEditMetadata(map_id = 0)
|
||||
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||
mapinfos = pbLoadMapInfos
|
||||
data = []
|
||||
if map_id == 0 # Global metadata
|
||||
map_name = _INTL("Global Metadata")
|
||||
|
||||
@@ -59,7 +59,7 @@ def pbAllocateAnimation(animations,name)
|
||||
end
|
||||
|
||||
def pbMapTree
|
||||
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||
mapinfos = pbLoadMapInfos
|
||||
maplevels = []
|
||||
retarray = []
|
||||
for i in mapinfos.keys
|
||||
|
||||
@@ -285,6 +285,7 @@ class MapScreenScene
|
||||
def serializeConnectionData
|
||||
conndata=generateConnectionData()
|
||||
save_data(conndata, "Data/map_connections.dat")
|
||||
$PokemonTemp.mapConnections = nil
|
||||
Compiler.write_connections
|
||||
@mapconns=conndata
|
||||
end
|
||||
@@ -330,7 +331,7 @@ class MapScreenScene
|
||||
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(_INTL("F: Help"),
|
||||
0, 600 - 64, 800, 64, @viewport)
|
||||
@sprites["title"].z = 2
|
||||
@mapinfos=load_data("Data/MapInfos.rxdata")
|
||||
@mapinfos=pbLoadMapInfos
|
||||
conns=MapFactoryHelper.getMapConnections
|
||||
@mapconns=[]
|
||||
for c in conns
|
||||
|
||||
@@ -69,12 +69,10 @@ module Compiler
|
||||
record.push(csvInt!(thisline,lineno))
|
||||
record.push(csvEnumFieldOrInt!(thisline,hashenum,"",sprintf("(line %d)",lineno)))
|
||||
record.push(csvInt!(thisline,lineno))
|
||||
if !pbRgssExists?(sprintf("Data/Map%03d.rxdata",record[0])) &&
|
||||
!pbRgssExists?(sprintf("Data/Map%03d.rvdata",record[0]))
|
||||
if !pbRgssExists?(sprintf("Data/Map%03d.rxdata",record[0]))
|
||||
print _INTL("Warning: Map {1}, as mentioned in the map connection data, was not found.\r\n{2}",record[0],FileLineData.linereport)
|
||||
end
|
||||
if !pbRgssExists?(sprintf("Data/Map%03d.rxdata",record[3])) &&
|
||||
!pbRgssExists?(sprintf("Data/Map%03d.rvdata",record[3]))
|
||||
if !pbRgssExists?(sprintf("Data/Map%03d.rxdata",record[3]))
|
||||
print _INTL("Warning: Map {1}, as mentioned in the map connection data, was not found.\r\n{2}",record[3],FileLineData.linereport)
|
||||
end
|
||||
case record[1]
|
||||
@@ -1530,6 +1528,7 @@ module Compiler
|
||||
rescue
|
||||
pbanims = PBAnimations.new
|
||||
end
|
||||
changed = false
|
||||
move2anim = [[],[]]
|
||||
=begin
|
||||
anims = load_data("Data/Animations.rxdata")
|
||||
@@ -1550,16 +1549,20 @@ module Compiler
|
||||
if pbanims[i].name[/^OppMove\:\s*(.*)$/]
|
||||
if GameData::Move.exists?($~[1])
|
||||
moveid = GameData::Move.get($~[1]).id_number
|
||||
changed = true if !move2anim[0][moveid] || move2anim[1][moveid] != i
|
||||
move2anim[1][moveid] = i
|
||||
end
|
||||
elsif pbanims[i].name[/^Move\:\s*(.*)$/]
|
||||
if GameData::Move.exists?($~[1])
|
||||
moveid = GameData::Move.get($~[1]).id_number
|
||||
changed = true if !move2anim[0][moveid] || move2anim[0][moveid] != i
|
||||
move2anim[0][moveid] = i
|
||||
end
|
||||
end
|
||||
end
|
||||
save_data(move2anim,"Data/move2anim.dat")
|
||||
save_data(pbanims,"Data/PkmnAnimations.rxdata")
|
||||
if changed
|
||||
save_data(move2anim,"Data/move2anim.dat")
|
||||
save_data(pbanims,"Data/PkmnAnimations.rxdata")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -69,9 +69,9 @@ module Compiler
|
||||
end
|
||||
|
||||
def write_connections
|
||||
conndata = load_data("Data/map_connections.dat") rescue nil
|
||||
conndata = pbLoadMapConnections
|
||||
return if !conndata
|
||||
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||
mapinfos = pbLoadMapInfos
|
||||
File.open("PBS/connections.txt","wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
f.write("\#-------------------------------\r\n")
|
||||
@@ -518,7 +518,7 @@ module Compiler
|
||||
# Save wild encounter data to PBS file
|
||||
#=============================================================================
|
||||
def write_encounters
|
||||
map_infos = load_data("Data/MapInfos.rxdata")
|
||||
map_infos = pbLoadMapInfos
|
||||
File.open("PBS/encounters.txt", "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
GameData::Encounter.each do |encounter_data|
|
||||
@@ -735,7 +735,7 @@ module Compiler
|
||||
f.write("\r\n")
|
||||
end
|
||||
# Write map metadata
|
||||
map_infos = load_data("Data/MapInfos.rxdata")
|
||||
map_infos = pbLoadMapInfos
|
||||
schema = GameData::MapMetadata::SCHEMA
|
||||
keys = schema.keys.sort {|a, b| schema[a][0] <=> schema[b][0] }
|
||||
GameData::MapMetadata.each do |map_data|
|
||||
|
||||
@@ -14,7 +14,7 @@ module Compiler
|
||||
mapfiles[$1.to_i(10)] = true if map[/map(\d+)\.rxdata/i]
|
||||
end
|
||||
}
|
||||
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||
mapinfos = pbLoadMapInfos
|
||||
maxOrder = 0
|
||||
# Exclude maps found in mapinfos
|
||||
for id in mapinfos.keys
|
||||
@@ -38,6 +38,7 @@ module Compiler
|
||||
end
|
||||
if imported
|
||||
save_data(mapinfos,"Data/MapInfos.rxdata")
|
||||
$PokemonTemp.mapInfos = nil
|
||||
pbMessage(_INTL("{1} new map(s) copied to the Data folder were successfully imported.",count))
|
||||
end
|
||||
return imported
|
||||
@@ -239,7 +240,7 @@ module Compiler
|
||||
attr_reader :mapinfos
|
||||
|
||||
def initialize
|
||||
@mapinfos = load_data("Data/MapInfos.rxdata")
|
||||
@mapinfos = pbLoadMapInfos
|
||||
@system = load_data("Data/System.rxdata")
|
||||
@tilesets = load_data("Data/Tilesets.rxdata")
|
||||
@mapxy = []
|
||||
|
||||
Reference in New Issue
Block a user