Skip to content

Commit 29e3d43

Browse files
authored
VX Ace Translator v2.25.14.16
[Minor] -Added a new argument (--force-decrypt) that will force the translator to always decrypt the game before compiling/decompiling. [Tweaks] -Now ex related files will be removed only by the compiler. -Added more colors for translator outputs. [Bug Fixes] -Fixed a critical bug where the decompiler was ignoring event commands with empty parameters in indexless mode. -Fixed a bug in the translator output where the terminal cursor was pushed away and glitching. -Fixed a bug where the translator was reporting "Game Decrypted" even if it has not. -Fixed a critical bug where scripts compiler was not working correctly.
1 parent e166b9d commit 29e3d43

6 files changed

Lines changed: 77 additions & 39 deletions

File tree

Build.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
Dir.chdir(File.dirname(__FILE__))
44

5-
Dir.mkdir('Build') unless Dir.exist?('Build')
6-
FileUtils.cp_r('Resources', File.join('Build/Resources'))
5+
FileUtils.rm_r('Build') if Dir.exist?('Build')
6+
Dir.mkdir('Build')
77

8+
FileUtils.cp_r('Resources', File.join('Build/Resources'))
89
system("Builder.bat")
910

ChangeLog.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
VX Ace Translator v2.24.12.12:-
1+
VX Ace Translator v2.25.14.16:-
22

33
[Minor]
4-
-Significantly improved translator output format, using correct coloring and line overwriting techniques to
5-
report detailed info about progress.
4+
-Added a new argument (--force-decrypt) that will force the translator to always decrypt the game before compiling/decompiling.
65

7-
-Now the compiler will skip files that doesn't have a decompiled source available, rather than crashing.
6+
[Tweaks]
7+
-Now ex related files will be removed only by the compiler.
8+
-Added more colors for translator outputs.
9+
10+
[Bug Fixes]
11+
-Fixed a critical bug where the decompiler was ignoring event commands with empty parameters in indexless mode.
12+
-Fixed a bug in the translator output where the terminal cursor was pushed away and glitching.
13+
-Fixed a bug where the translator was reporting "Game Decrypted" even if it has not.
14+
-Fixed a critical bug where scripts compiler was not working correctly.

Modules/RVData2Compiler.rb

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ def initialize
1313
attr_accessor :rvdata2_data
1414
attr_accessor :indentation
1515

16-
def compile(game_path, input_path='', output_path='', target_basename='', indexless=true)
16+
def compile(game_path, input_path='', output_path='', target_basename='', indexless=true, force_decrypt=false)
1717
game_data_path = join(game_path, 'Data')
1818

19-
print "#{GREEN_COLOR}Decrypting Game...#{RESET_COLOR}"
20-
decrypt_game(game_path)
21-
print "\r#{GREEN_COLOR}Game Decrypted.#{' ' * 10}#{RESET_COLOR}\n"
22-
19+
decrypt_game(game_path, forced=force_decrypt)
2320
if input_path.empty?
2421
@input_path = "Decompiled"
2522
else
@@ -42,7 +39,7 @@ def compile(game_path, input_path='', output_path='', target_basename='', indexl
4239
next unless file_basename.include?(target_basename)
4340
end
4441

45-
print "#{GREEN_COLOR}Reading #{filename}...#{RESET_COLOR}"
42+
print "#{BLUE_COLOR}Reading #{filename}...#{RESET_COLOR}"
4643

4744
File.open(join(game_data_path, filename), "rb") do |rvdata2_file|
4845
@rvdata2_data = Marshal.load(rvdata2_file.read)
@@ -121,16 +118,19 @@ def compile(game_path, input_path='', output_path='', target_basename='', indexl
121118
end
122119

123120
if done
124-
print "\r#{GREEN_COLOR}Compiling #{filename}...#{' ' * 10}#{RESET_COLOR}"
121+
clear_line
122+
print "\r#{BLUE_COLOR}Compiling #{filename}...#{RESET_COLOR}"
125123

126124
File.open(join(output_path, filename), "wb") do |rvdata2_file|
127125
rvdata2_file.write(Marshal.dump(@rvdata2_data))
128126
end
129127

130-
print "\r#{GREEN_COLOR}Compiled #{filename}.#{' ' * 10}#{RESET_COLOR}\n"
128+
clear_line
129+
print "\r#{GREEN_COLOR}Compiled #{filename}.#{RESET_COLOR}\n"
131130

132131
else
133-
print "\r#{RED_COLOR}Skipped #{filename}.#{' ' * 10}#{RESET_COLOR}\n"
132+
clear_line
133+
print "\r#{RED_COLOR}Skipped #{filename}.#{RESET_COLOR}\n"
134134

135135
end
136136

@@ -221,7 +221,6 @@ def compile_common_events
221221
return false unless Dir.exist?(join(@input_path, 'CommonEvents'))
222222
Dir.foreach(join(@input_path, 'CommonEvents')) do |common_event_filename|
223223
next if %w[. ..].include?(common_event_filename)
224-
next unless File.exist?(join(@input_path, 'CommonEvents', common_event_filename))
225224

226225
File.open(join(@input_path, 'CommonEvents', common_event_filename), 'r:UTF-8') do |common_event_file|
227226
added_event_commands = {}
@@ -300,7 +299,6 @@ def compile_common_events_indexless
300299
return false unless Dir.exist?(join(@input_path, 'CommonEvents'))
301300
Dir.foreach(join(@input_path, 'CommonEvents')) do |common_event_filename|
302301
next if %w[. ..].include?(common_event_filename)
303-
next unless File.exist?(join(@input_path, 'CommonEvents', common_event_filename))
304302

305303
File.open(join(@input_path, 'CommonEvents', common_event_filename), 'r:UTF-8') do |common_event_file|
306304

@@ -676,13 +674,12 @@ def compile_map_infos
676674

677675
def compile_scripts
678676

679-
return false unless File.exist?(join(@input_path, 'Scripts'))
677+
return false unless Dir.exist?(join(@input_path, 'Scripts'))
680678
@rvdata2_data.each_with_index do |script, i|
681679
script_path = join(@input_path, 'Scripts', "#{i} - #{File.basename(script[1])}.rb")
682680

683-
next unless File.exist?(script_path)
684681
File.open(script_path, 'rb') do |script_file|
685-
script << Zlib::Deflate.deflate(script_file.read)
682+
@rvdata2_data[i][2] = Zlib::Deflate.deflate(script_file.read)
686683
end
687684

688685
end

Modules/RVData2Decompiler.rb

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@ def initialize
1212
attr_accessor :rvdata2_data
1313
attr_accessor :indentation
1414

15-
def decompile(game_path, output_path='', target_basename='', indexless=true)
15+
def decompile(game_path, output_path='', target_basename='', indexless=true, force_decrypt=false)
1616
input_path = join(game_path, 'Data')
1717

18-
print "#{GREEN_COLOR}Decrypting Game...#{RESET_COLOR}"
19-
decrypt_game(game_path)
20-
print "\r#{GREEN_COLOR}Game Decrypted.#{' ' * 10}#{RESET_COLOR}\n"
21-
18+
decrypt_game(game_path, forced=force_decrypt, remove_ex=false)
2219
if output_path.empty?
2320
@output_path = "Decompiled"
2421
else
@@ -37,13 +34,14 @@ def decompile(game_path, output_path='', target_basename='', indexless=true)
3734
next unless file_basename.include?(target_basename)
3835
end
3936

40-
print "#{GREEN_COLOR}Reading #{filename}...#{RESET_COLOR}"
37+
print "#{BLUE_COLOR}Reading #{filename}...#{RESET_COLOR}"
4138

4239
File.open(join(input_path, filename), 'rb') do |rvdata2_file|
4340
@rvdata2_data = Marshal.load(rvdata2_file.read)
4441
end
4542

46-
print "\r#{GREEN_COLOR}Decompiling #{filename}...#{' ' * 10}#{RESET_COLOR}"
43+
clear_line
44+
print "\r#{BLUE_COLOR}Decompiling #{filename}...#{RESET_COLOR}"
4745

4846
Dir.mkdir(@output_path) unless Dir.exist?(@output_path)
4947
case file_basename
@@ -95,7 +93,8 @@ def decompile(game_path, output_path='', target_basename='', indexless=true)
9593

9694
end
9795

98-
print "\r#{GREEN_COLOR}Decompiled #{filename}.#{' ' * 10}#{RESET_COLOR}\n"
96+
clear_line
97+
print "\r#{GREEN_COLOR}Decompiled #{filename}.#{RESET_COLOR}\n"
9998

10099
end
101100

@@ -153,16 +152,19 @@ def decompile_common_events(indexless=true)
153152

154153
last_indentation = 0
155154
event.list.each_with_index do |event_command, j|
156-
event_code = event_command.code
157-
next unless TARGETED_EVENT_COMMANDS.keys.include?(event_code) && !event_command.parameters.empty?
155+
event_command_code = event_command.code
156+
157+
unless indexless
158+
next unless TARGETED_EVENT_COMMANDS.keys.include?(event_command_code) && !event_command.parameters.empty?
159+
end
158160

159161
if event_command.indent < last_indentation
160162
common_events_file.write("\n")
161163
end
162164

163165
last_indentation = event_command.indent
164166

165-
event_command_name = TARGETED_EVENT_COMMANDS[event_code]
167+
event_command_name = TARGETED_EVENT_COMMANDS[event_command_code]
166168
if event_command_name == 'ShowText' && event_command.parameters[0].empty?
167169
event_command.parameters[0] = ' '
168170
end
@@ -291,7 +293,10 @@ def decompile_map(filename, indexless=true)
291293

292294
page.list.each_with_index do |event_command, j|
293295
event_command_code = event_command.code
294-
next unless TARGETED_EVENT_COMMANDS.keys.include?(event_command_code) && !event_command.parameters.empty?
296+
297+
unless indexless
298+
next unless TARGETED_EVENT_COMMANDS.keys.include?(event_command_code) && !event_command.parameters.empty?
299+
end
295300

296301
if event_command.indent != last_indentation && event_command.indent == 0
297302
lines.append("\n")
@@ -565,7 +570,10 @@ def decompile_troops(indexless=true)
565570

566571
page.list.each_with_index do |event_command, k|
567572
event_command_code = event_command.code
568-
next unless TARGETED_EVENT_COMMANDS.keys.include?(event_command_code) && !event_command.parameters.empty?
573+
574+
unless indexless
575+
next unless TARGETED_EVENT_COMMANDS.keys.include?(event_command_code) && !event_command.parameters.empty?
576+
end
569577

570578
if event_command.indent != last_indentation && event_command.indent == 0
571579
lines.append("\n")

Modules/Utils.rb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@
134134
BLUE_COLOR = "\e[34m"
135135
RESET_COLOR = "\e[0m"
136136

137+
def clear_line
138+
print "\r#{' ' * 50}"
139+
end
140+
137141
# Convert an class attribute to a parsable string, along with unicode characters un-escaping.
138142
def textualize(attribute)
139143
# attribute.inspect.gsub(/\\u([\da-fA-F]{4})/) { [$1.to_i(16)].pack("U*") }
@@ -213,10 +217,11 @@ def deserialize_parameters(parameters)
213217

214218
end
215219

216-
def decrypt_game(game_path)
220+
def decrypt_game(game_path, forced=false, remove_ex=true)
217221
game_data_path = join(game_path, 'Data')
218222

219-
unless Dir.exist?(game_data_path) && !Dir.empty?(game_data_path)
223+
unless !forced && (Dir.exist?(game_data_path) && !Dir.empty?(game_data_path))
224+
print "#{BLUE_COLOR}Decrypting Game...#{RESET_COLOR}"
220225
rgss3a_path = join(game_path, 'Game.rgss3a')
221226

222227
if File.exist?(rgss3a_path + '.old')
@@ -225,14 +230,22 @@ def decrypt_game(game_path)
225230

226231
decrypter_path = join('Resources', 'Tools', 'RPGMakerDecrypter.exe')
227232

233+
if Dir.exist?(game_data_path)
234+
FileUtils.rm_r(game_data_path)
235+
end
236+
228237
system("\"#{decrypter_path}\" \"#{rgss3a_path}\"")
238+
File.rename(rgss3a_path, rgss3a_path + '.old')
229239

240+
clear_line
241+
print "\r#{GREEN_COLOR}Game Decrypted.#{RESET_COLOR}\n"
242+
end
243+
244+
if remove_ex
230245
File.delete(join(game_data_path, 'DataEx.rvdata2')) if File.exist?(join(game_data_path, 'DataEx.rvdata2'))
231246
File.delete(join(game_data_path, 'ExDataUpdate.rvdata2')) if File.exist?(join(game_data_path, 'ExDataUpdate.rvdata2'))
232247
File.delete(join(game_data_path, 'ExScriptUpdate.rvdata2')) if File.exist?(join(game_data_path, 'ExScriptUpdate.rvdata2'))
233248
File.delete(join(game_data_path, 'ExVersionID.rvdata2')) if File.exist?(join(game_data_path, 'ExVersionID.rvdata2'))
234-
235-
File.rename(rgss3a_path, rgss3a_path + '.old')
236249
end
237250

238251
end

VXAceTranslator.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
options[:input] = ''
1616
options[:output] = ''
1717
options[:indexless] = true
18+
options[:force_decrypt] = false
1819

1920
while (arg = ARGV.shift)
2021

@@ -31,6 +32,8 @@
3132
options[:output] = ARGV.shift
3233
when '--switch-indexless'
3334
options[:indexless] = false
35+
when '--force-decrypt'
36+
options[:force_decrypt] = true
3437
when '-h', '--help'
3538
print USAGE
3639
$stdout.flush
@@ -56,12 +59,21 @@
5659

5760
if not options[:decompile].nil?
5861
d = RVData2Decompiler.new
59-
d.decompile(options[:decompile], output_path=options[:output], target_basename=options[:target_basename], indexless=options[:indexless])
62+
d.decompile(options[:decompile],
63+
output_path=options[:output],
64+
target_basename=options[:target_basename],
65+
indexless=options[:indexless],
66+
force_decrypt=options[:force_decrypt])
6067

6168

6269
elsif not options[:compile].nil?
6370
c = RVData2Compiler.new
64-
c.compile(options[:compile], input_path=options[:input], output_path=options[:output], target_basename=options[:target_basename], indexless=options[:indexless])
71+
c.compile(options[:compile],
72+
input_path=options[:input],
73+
output_path=options[:output],
74+
target_basename=options[:target_basename],
75+
indexless=options[:indexless],
76+
force_decrypt=options[:force_decrypt])
6577

6678

6779
end

0 commit comments

Comments
 (0)