Deprecated methods intended to work around filenames with accents, fixed crash when the Compiler wants to rewrite PBS files if they don't exist

This commit is contained in:
Maruno17
2023-05-20 22:10:11 +01:00
parent 276c052822
commit 167155c67d
17 changed files with 130 additions and 158 deletions

View File

@@ -1018,7 +1018,7 @@ module Compiler
Console.echo_li(_INTL("Saving messages..."))
Translator.gather_script_and_event_texts
MessageTypes.save_default_messages
MessageTypes.load_default_messages if safeExists?("Data/messages_core.dat")
MessageTypes.load_default_messages if FileTest.exist?("Data/messages_core.dat")
Console.echo_done(true)
Console.echoln_li_done(_INTL("Successfully compiled all game data"))
end
@@ -1026,6 +1026,14 @@ module Compiler
def main
return if !$DEBUG
begin
mustCompile = false
# If no PBS file, create one and fill it, then recompile
if !FileTest.directory?("PBS")
Dir.mkdir("PBS") rescue nil
GameData.load_all
write_all
mustCompile = true
end
# Get all data files and PBS files to be checked for their last modified times
data_files = GameData.get_all_data_filenames
data_files += [ # Extra .dat files for data that isn't a GameData class
@@ -1036,19 +1044,11 @@ module Compiler
text_files = get_all_pbs_files_to_compile
latestDataTime = 0
latestTextTime = 0
mustCompile = false
# Should recompile if new maps were imported
mustCompile |= import_new_maps
# If no PBS file, create one and fill it, then recompile
if !safeIsDirectory?("PBS")
Dir.mkdir("PBS") rescue nil
GameData.load_all
write_all
mustCompile = true
end
# Check data files for their latest modify time
data_files.each do |filename| # filename = [string, boolean (whether mandatory)]
if safeExists?("Data/" + filename[0])
if FileTest.exist?("Data/" + filename[0])
begin
File.open("Data/#{filename[0]}") do |file|
latestDataTime = [latestDataTime, file.mtime.to_i].max
@@ -1080,7 +1080,7 @@ module Compiler
if mustCompile
data_files.each do |filename|
begin
File.delete("Data/#{filename[0]}") if safeExists?("Data/#{filename[0]}")
File.delete("Data/#{filename[0]}") if FileTest.exist?("Data/#{filename[0]}")
rescue SystemCallError
end
end
@@ -1093,7 +1093,7 @@ module Compiler
pbPrintException(e)
data_files.each do |filename|
begin
File.delete("Data/#{filename[0]}") if safeExists?("Data/#{filename[0]}")
File.delete("Data/#{filename[0]}") if FileTest.exist?("Data/#{filename[0]}")
rescue SystemCallError
end
end

View File

@@ -3,7 +3,7 @@ module Compiler
def compile_PBS_file_generic(game_data, *paths)
if game_data.const_defined?(:OPTIONAL) && game_data::OPTIONAL
return if paths.none? { |p| safeExists?(p) }
return if paths.none? { |p| FileTest.exist?(p) }
end
game_data::DATA.clear
schema = game_data.schema
@@ -947,7 +947,7 @@ module Compiler
"Pokemon" => [1, "s"],
"Challenges" => [2, "*s"]
}
if !safeExists?(path)
if !FileTest.exist?(path)
File.open(path, "wb") do |f|
f.write(0xEF.chr)
f.write(0xBB.chr)
@@ -987,12 +987,12 @@ module Compiler
rsection[3] = rsection[0]
rsection[4] = rsection[1]
rsection[5] = (name == "DefaultTrainerList")
if safeExists?("PBS/" + rsection[0])
if FileTest.exist?("PBS/" + rsection[0])
rsection[0] = compile_battle_tower_trainers("PBS/" + rsection[0])
else
rsection[0] = []
end
if safeExists?("PBS/" + rsection[1])
if FileTest.exist?("PBS/" + rsection[1])
filename = "PBS/" + rsection[1]
rsection[1] = []
pbCompilerEachCommentedLine(filename) do |line, _lineno|
@@ -1027,7 +1027,7 @@ module Compiler
beginspeech = []
endspeechwin = []
endspeechlose = []
if safeExists?(filename)
if FileTest.exist?(filename)
File.open(filename, "rb") do |f|
FileLineData.file = filename
pbEachFileSection(f) do |section, name|