rvpacker-txt 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e7d7d8c4329390fb8ffd7bf1f8cf3edaf6f8cd19319ab64d10731a84f021d4b
4
- data.tar.gz: d9db81d1f003f20ce10fb1cb064c60cab274980f26c8931e1c98bbfdf4042b58
3
+ metadata.gz: b723edca892d423ad6b4dcd7800a904244fddfa8e7a68bfc823db6be676c0c82
4
+ data.tar.gz: 2acde66ea3d5f6643ed0e5a81ab12f66ec066952f8bc797d13337d0499db764d
5
5
  SHA512:
6
- metadata.gz: 9ec02c23d5fe3b8a66bc8b858607028d54f04119c4fb1ffa73d947eebf4bcc738d4b7c952e4e107d0783271790282f19b0262f9bfebe0738cd02813edcbae86c
7
- data.tar.gz: 2396ac744536f2fc268fa98dd503d81c58df20cc797ef0cbfb77b793a89137828224a834c67b56697d7527d7de82c016cf6d9b87fb89d0bb0c0914284529a83f
6
+ metadata.gz: 7ba34d8ca913bc93073b322cf3c19d2492438e57cac203161df3c9332176f7b4078e8f229607986a109f4baa3d72470c6491b87825e6f0baf86d927bd3fc4209
7
+ data.tar.gz: 3e3f67a08e881777ea7057d7545253262746d9875f3bef1c2bd7ac21db52f4b7862881223405ca304dc794b369402f4726747a73bd984e2b11c3ac535733ca28
data/bin/rvpacker-txt CHANGED
@@ -45,7 +45,8 @@ def self.parse_options
45
45
  options[:force] = true
46
46
  end
47
47
 
48
- cmd.on('-a', '--append', 'When you update the rvpacker-txt, you probably should re-read', 'your files with append, as some new text might be added to parser', 'Cannot be used with --force') do
48
+ cmd.on('-a', '--append', 'When you update the rvpacker-txt, you probably should re-read',
49
+ 'your files with append, as some new text might be added to parser', 'Cannot be used with --force') do
49
50
  raise '--append cannot be used beside --force.' if options[:force]
50
51
  options[:append] = true
51
52
  end
@@ -83,7 +84,7 @@ disable_processing = options[:disable_processing]
83
84
  force = options[:force]
84
85
  append = options[:append]
85
86
 
86
- extensions = { xp: '.rxdata', vx: 'rvdata', ace: 'rvdata2' }
87
+ extensions = { xp: 'rxdata', vx: 'rvdata', ace: 'rvdata2' }
87
88
 
88
89
  original_directory = Dir.glob(File.join(input_dir, '{data,original}'), File::FNM_CASEFOLD).first
89
90
  raise '"Data" or "original" directory not found within input directory.' unless original_directory
@@ -94,11 +95,11 @@ other_path = File.join(input_dir, 'translation', 'other')
94
95
  FileUtils.mkdir_p(maps_path)
95
96
  FileUtils.mkdir_p(other_path)
96
97
 
97
- engine = extensions.find do |_symbol, extension|
98
- File.exist?(File.join(original_directory, "System.#{extension}"))
98
+ engine = extensions.each do |symbol, extension|
99
+ break symbol if File.exist?(File.join(original_directory, "System.#{extension}"))
99
100
  end || (raise "Couldn't determine project engine.")
100
101
 
101
- files = Dir.glob("#{original_directory}/*#{extensions[engine[0]]}")
102
+ files = Dir.glob("#{original_directory}/*#{extensions[engine]}")
102
103
 
103
104
  maps_files_paths = []
104
105
  other_files_paths = []
@@ -107,7 +108,7 @@ scripts_file_path = nil
107
108
 
108
109
  files.each do |file|
109
110
  basename = File.basename(file)
110
- next unless basename.end_with?(extensions[engine[0]])
111
+ next unless basename.end_with?(extensions[engine])
111
112
 
112
113
  if basename.start_with?(/Map[0-9]/)
113
114
  maps_files_paths.push(file)
@@ -132,9 +133,9 @@ processing_type = if force
132
133
  exit unless gets.chomp == 'Y'
133
134
 
134
135
  wait_time = Time.now - wait_time_start
135
- 'force'
136
+ :force
136
137
  else
137
- append ? 'append' : 'default'
138
+ append ? :append : :default
138
139
  end
139
140
 
140
141
  puts 'Custom processing for this game is enabled. Use --disable-custom-processing to disable it.' unless game_type.nil?
data/lib/classes.rb CHANGED
@@ -113,6 +113,69 @@ class IndexSet
113
113
  end
114
114
 
115
115
  module RPG
116
+ class Map
117
+ attr_accessor :display_name, :events
118
+ end
119
+
120
+ class Event
121
+ attr_accessor :pages
122
+
123
+ class Page
124
+ attr_accessor :list
125
+ end
126
+ end
127
+
128
+ class EventCommand
129
+ attr_accessor :code, :parameters
130
+ end
131
+
132
+ class Actor
133
+ attr_accessor :name, :nickname, :description, :note
134
+ end
135
+
136
+ class Armor
137
+ attr_accessor :name, :nickname, :description, :note
138
+ end
139
+
140
+ class Class
141
+ attr_accessor :name, :nickname, :description, :note
142
+ end
143
+
144
+ class Enemy
145
+ attr_accessor :name, :nickname, :description, :note
146
+ end
147
+
148
+ class Item
149
+ attr_accessor :name, :nickname, :description, :note
150
+ end
151
+
152
+ class Skill
153
+ attr_accessor :name, :nickname, :description, :note
154
+ end
155
+
156
+ class State
157
+ attr_accessor :name, :nickname, :description, :note
158
+ end
159
+
160
+ class Weapon
161
+ attr_accessor :name, :nickname, :description, :note
162
+ end
163
+
164
+ class CommonEvent
165
+ attr_accessor :pages, :list
166
+ end
167
+
168
+ class Troop
169
+ attr_accessor :pages
170
+
171
+ class Page
172
+ attr_accessor :list
173
+ end
174
+ end
175
+
176
+ class System
177
+ attr_accessor :elements, :skill_types, :weapon_types, :armor_types, :currency_unit, :terms, :words, :game_title
178
+ end
116
179
  end
117
180
 
118
181
  module RGSS
data/lib/read.rb CHANGED
@@ -25,7 +25,10 @@ def self.extract_quoted_strings(string)
25
25
  string.each_line do |line|
26
26
  stripped = line.strip
27
27
 
28
- next if stripped[0] == '#' || stripped.start_with?(/(Win|Lose)|_Fanfare/)
28
+ next if stripped[0] == '#' ||
29
+ !stripped.match?(/["']/) ||
30
+ stripped.start_with?(/(Win|Lose)|_Fanfare/) ||
31
+ stripped.match?(/eval\(/)
29
32
 
30
33
  skip_block = true if stripped.start_with?('=begin')
31
34
  skip_block = false if stripped.start_with?('=end')
@@ -34,7 +37,7 @@ def self.extract_quoted_strings(string)
34
37
 
35
38
  buffer.push('\#') if in_quotes
36
39
 
37
- line.each_char.each_with_index do |char, index|
40
+ line.each_char do |char|
38
41
  if %w[' "].include?(char)
39
42
  unless quote_type.nil? || char == quote_type
40
43
  buffer.push(char)
@@ -115,7 +118,7 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
115
118
  maps_trans_output_path = File.join(output_path, 'maps_trans.txt')
116
119
  names_trans_output_path = File.join(output_path, 'names_trans.txt')
117
120
 
118
- if processing_type == 'default' && (File.exist?(maps_trans_output_path) || File.exist?(names_trans_output_path))
121
+ if processing_type == :default && (File.exist?(maps_trans_output_path) || File.exist?(names_trans_output_path))
119
122
  puts 'maps_trans.txt or names_trans.txt file already exists. If you want to forcefully re-read all files, use --force flag, or --append if you want append new text to already existing files.'
120
123
  return
121
124
  end
@@ -130,7 +133,7 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
130
133
  maps_translation_map = nil
131
134
  names_translation_map = nil
132
135
 
133
- if processing_type == 'append'
136
+ if processing_type == :append
134
137
  if File.exist?(maps_trans_output_path)
135
138
  maps_translation_map = Hash[File.readlines(maps_output_path, chomp: true)
136
139
  .zip(File.readlines(maps_trans_output_path, chomp: true))]
@@ -138,95 +141,99 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
138
141
  .zip(File.readlines(names_trans_output_path, chomp: true))]
139
142
  else
140
143
  puts "Files aren't already parsed. Continuing as if --append flag was omitted."
141
- processing_type = 'default'
144
+ processing_type = :default
142
145
  end
143
146
  end
144
147
 
148
+ # 401 - dialogue lines
149
+ # 102 - dialogue choices array
150
+ # 402 - one of the dialogue choices from the array
151
+ # 356 - system lines/special texts (do they even exist before mv?)
152
+ allowed_codes = [401, 102, 402, 356].freeze
153
+
145
154
  maps_object_map.each do |filename, object|
146
- display_name = object.instance_variable_get(:@display_name)
155
+ display_name = object.display_name
147
156
 
148
157
  if display_name.is_a?(String)
149
158
  display_name = display_name.strip
150
159
 
151
160
  unless display_name.empty?
152
- names_translation_map.insert_at_index(names_lines.length, display_name, '') if processing_type == 'append' &&
161
+ names_translation_map.insert_at_index(names_lines.length, display_name, '') if processing_type == :append &&
153
162
  !names_translation_map.include?(display_name)
154
163
 
155
164
  names_lines.add(display_name)
156
165
  end
157
166
  end
158
167
 
159
- events = object.instance_variable_get(:@events)
168
+ events = object.events
160
169
  next if events.nil?
161
170
 
162
171
  events.each_value do |event|
163
- pages = event.instance_variable_get(:@pages)
172
+ pages = event.pages
164
173
  next if pages.nil?
165
174
 
166
175
  pages.each do |page|
167
- list = page.instance_variable_get(:@list)
176
+ list = page.list
168
177
  next if list.nil?
169
178
 
170
179
  in_sequence = false
171
180
  line = []
172
181
 
173
182
  list.each do |item|
174
- code = item.instance_variable_get(:@code)
175
- parameters = item.instance_variable_get(:@parameters)
183
+ code = item.code
184
+
185
+ unless allowed_codes.include?(code)
186
+ if in_sequence
187
+ joined = line.join('\#').strip
188
+ parsed = parse_parameter(401, joined, game_type)
189
+
190
+ maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
191
+ !maps_translation_map.include?(parsed)
192
+
193
+ maps_lines.add(parsed)
194
+
195
+ line.clear
196
+ in_sequence = false
197
+ end
198
+ next
199
+ end
176
200
 
201
+ parameters = item.parameters
177
202
  parameters.each do |parameter|
178
203
  if code == 401
179
204
  next unless parameter.is_a?(String) && !parameter.empty?
180
205
 
181
206
  in_sequence = true
182
207
  line.push(parameter)
183
- else
184
- if in_sequence
185
- joined = line.join('\#').strip
186
- parsed = parse_parameter(401, joined, game_type)
208
+ elsif code == 102 && parameter.is_a?(Array)
187
209
 
188
- maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == 'append' &&
189
- !maps_translation_map.include?(parsed)
210
+ parameter.each do |subparameter|
211
+ next unless subparameter.is_a?(String)
190
212
 
191
- maps_lines.add(parsed)
192
-
193
- line.clear
194
- in_sequence = false
195
- end
196
-
197
- if code == 102 && parameter.is_a?(Array)
198
- parameter.each do |subparameter|
199
- next unless subparameter.is_a?(String)
200
-
201
- subparameter = subparameter.strip
202
-
203
- next if subparameter.empty?
204
-
205
- parsed = parse_parameter(code, subparameter, game_type)
206
-
207
- next if parsed.nil?
208
-
209
- maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == 'append' &&
210
- !maps_translation_map.include?(parsed)
211
-
212
- maps_lines.add(parsed)
213
- end
214
- elsif code == 356 && parameter.is_a?(String)
215
- parameter = parameter.strip
216
-
217
- next if parameter.empty?
218
-
219
- parsed = parse_parameter(code, parameter, game_type)
213
+ subparameter = subparameter.strip
214
+ next if subparameter.empty?
220
215
 
216
+ parsed = parse_parameter(code, subparameter, game_type)
221
217
  next if parsed.nil?
222
218
 
223
- parsed = parsed.gsub(/\r?\n/, '\#')
224
-
225
- maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == 'append' &&
219
+ maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
226
220
  !maps_translation_map.include?(parsed)
227
221
 
228
222
  maps_lines.add(parsed)
229
223
  end
224
+ elsif code == 356 && parameter.is_a?(String)
225
+ parameter = parameter.strip
226
+ next if parameter.empty?
227
+
228
+ parsed = parse_parameter(code, parameter, game_type)
229
+ next if parsed.nil?
230
+
231
+ parsed = parsed.gsub(/\r?\n/, '\#')
232
+
233
+ maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
234
+ !maps_translation_map.include?(parsed)
235
+
236
+ maps_lines.add(parsed)
230
237
  end
231
238
  end
232
239
  end
@@ -239,7 +246,7 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
239
246
  maps_original_content,
240
247
  maps_translated_content,
241
248
  names_original_content,
242
- names_translated_content = if processing_type == 'append'
249
+ names_translated_content = if processing_type == :append
243
250
  [maps_translation_map.keys.join("\n"),
244
251
  maps_translation_map.values.join("\n"),
245
252
  names_translation_map.keys.join("\n"),
@@ -268,6 +275,12 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
268
275
  end]
269
276
 
270
277
  inner_processing_type = processing_type
278
+ # 401 - dialogue lines
279
+ # 405 - credits lines
280
+ # 102 - dialogue choices array
281
+ # 402 - one of the dialogue choices from the array
282
+ # 356 - system lines/special texts (do they even exist before mv?)
283
+ allowed_codes = [401, 405, 102, 402, 356].freeze
271
284
 
272
285
  other_object_array_map.each do |filename, other_object_array|
273
286
  processed_filename = File.basename(filename, '.*').downcase
@@ -275,7 +288,7 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
275
288
  other_output_path = File.join(output_path, "#{processed_filename}.txt")
276
289
  other_trans_output_path = File.join(output_path, "#{processed_filename}_trans.txt")
277
290
 
278
- if processing_type == 'default' && File.exist?(other_trans_output_path)
291
+ if processing_type == :default && File.exist?(other_trans_output_path)
279
292
  puts "#{processed_filename}_trans.txt file already exists. If you want to forcefully re-read all files, use --force flag, or --append if you want append new text to already existing files."
280
293
  next
281
294
  end
@@ -283,38 +296,38 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
283
296
  other_lines = IndexSet.new
284
297
  other_translation_map = nil
285
298
 
286
- if processing_type == 'append'
299
+ if processing_type == :append
287
300
  if File.exist?(other_trans_output_path)
288
- inner_processing_type == 'append'
301
+ inner_processing_type == :append
289
302
  other_translation_map = Hash[File.readlines(other_output_path, chomp: true)
290
303
  .zip(File.readlines(other_trans_output_path, chomp: true))]
291
304
  else
292
305
  puts "Files aren't already parsed. Continuing as if --append flag was omitted."
293
- inner_processing_type = 'default'
306
+ inner_processing_type = :default
294
307
  end
295
308
  end
296
309
 
297
310
  if !filename.start_with?(/Common|Troops/)
298
311
  other_object_array.each do |object|
299
- name = object.instance_variable_get(:@name)
300
- nickname = object.instance_variable_get(:@nickname)
301
- description = object.instance_variable_get(:@description)
302
- note = object.instance_variable_get(:@note)
312
+ next if object.nil?
313
+
314
+ name = object.name
315
+ nickname = object.nickname
316
+ description = object.description
317
+ note = object.note
303
318
 
304
319
  [name, nickname, description, note].each do |variable|
305
320
  next unless variable.is_a?(String)
306
321
 
307
322
  variable = variable.strip
308
-
309
323
  next if variable.empty?
310
324
 
311
325
  parsed = parse_variable(variable, game_type)
312
-
313
326
  next if parsed.nil?
314
327
 
315
328
  parsed = parsed.gsub(/\r?\n/, '\#')
316
329
 
317
- other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type == 'append' &&
330
+ other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type == :append &&
318
331
  !other_translation_map.include?(parsed)
319
332
 
320
333
  other_lines.add(parsed)
@@ -322,20 +335,37 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
322
335
  end
323
336
  else
324
337
  other_object_array.each do |object|
325
- pages = object.instance_variable_get(:@pages)
338
+ next if object.nil?
339
+
340
+ pages = object.pages
326
341
  pages_length = pages.nil? ? 1 : pages.length
327
342
 
328
343
  (0..pages_length).each do |i|
329
- list = pages.nil? ? object.instance_variable_get(:@list) : pages[i].instance_variable_get(:@list)
344
+ list = pages.nil? ? object.list : pages[i].instance_variable_get(:@list)
330
345
  next if list.nil?
331
346
 
332
347
  in_sequence = false
333
348
  line = []
334
349
 
335
350
  list.each do |item|
336
- code = item.instance_variable_get(:@code)
337
- parameters = item.instance_variable_get(:@parameters)
351
+ code = item.code
352
+
353
+ unless allowed_codes.include?(code)
354
+ if in_sequence
355
+ joined = line.join('\#').strip
356
+
357
+ other_translation_map.insert_at_index(other_lines.length, joined, '') if inner_processing_type == :append &&
358
+ !other_translation_map.include?(joined)
359
+
360
+ other_lines.add(joined)
361
+
362
+ line.clear
363
+ in_sequence = false
364
+ end
365
+ next
366
+ end
338
367
 
368
+ parameters = item.parameters
339
369
  parameters.each do |parameter|
340
370
  if [401, 405].include?(code)
341
371
  next unless parameter.is_a?(String) && !parameter.empty?
@@ -343,17 +373,6 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
343
373
  in_sequence = true
344
374
  line.push(parameter.gsub(/\r?\n/, '\#'))
345
375
  else
346
- if in_sequence
347
- joined = line.join('\#').strip
348
-
349
- other_translation_map.insert_at_index(other_lines.length, joined, '') if inner_processing_type == 'append' &&
350
- !other_translation_map.include?(joined)
351
-
352
- other_lines.add(joined)
353
-
354
- line.clear
355
- in_sequence = false
356
- end
357
376
 
358
377
  case code
359
378
  when 102
@@ -362,10 +381,9 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
362
381
  next unless subparameter.is_a?(String)
363
382
 
364
383
  subparameter = subparameter.strip
365
-
366
384
  next if subparameter.empty?
367
385
 
368
- other_translation_map.insert_at_index(other_lines.length, subparameter, '') if inner_processing_type == 'append' &&
386
+ other_translation_map.insert_at_index(other_lines.length, subparameter, '') if inner_processing_type == :append &&
369
387
  !other_translation_map.include?(subparameter)
370
388
 
371
389
  other_lines.add(subparameter)
@@ -375,12 +393,11 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
375
393
  next unless parameter.is_a?(String)
376
394
 
377
395
  parameter = parameter.strip
378
-
379
396
  next if parameter.empty?
380
397
 
381
398
  parameter = parameter.gsub(/\r?\n/, '\#')
382
399
 
383
- other_translation_map.insert_at_index(other_lines.length, parameter, '') if inner_processing_type == 'append' &&
400
+ other_translation_map.insert_at_index(other_lines.length, parameter, '') if inner_processing_type == :append &&
384
401
  !other_translation_map.include?(parameter)
385
402
 
386
403
  other_lines.add(parameter)
@@ -396,7 +413,7 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
396
413
 
397
414
  puts "Parsed #{filename}" if logging
398
415
 
399
- original_content, translated_content = if processing_type == 'append'
416
+ original_content, translated_content = if processing_type == :append
400
417
  [other_translation_map.keys.join("\n"),
401
418
  other_translation_map.values.join("\n")]
402
419
  else
@@ -413,7 +430,7 @@ end
413
430
  def self.read_ini_title(ini_file_path)
414
431
  file_lines = File.readlines(ini_file_path, chomp: true)
415
432
  file_lines.each do |line|
416
- if line.start_with?('title')
433
+ if line.downcase.start_with?('title')
417
434
  parts = line.partition('=')
418
435
  break parts[2].strip
419
436
  end
@@ -432,7 +449,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
432
449
  system_output_path = File.join(output_path, "#{system_basename}.txt")
433
450
  system_trans_output_path = File.join(output_path, "#{system_basename}_trans.txt")
434
451
 
435
- if processing_type == 'default' && File.exist?(system_trans_output_path)
452
+ if processing_type == :default && File.exist?(system_trans_output_path)
436
453
  puts 'system_trans.txt file already exists. If you want to forcefully re-read all files, use --force flag, or --append if you want append new text to already existing files.'
437
454
  return
438
455
  end
@@ -442,22 +459,22 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
442
459
  system_lines = IndexSet.new
443
460
  system_translation_map = nil
444
461
 
445
- if processing_type == 'append'
462
+ if processing_type == :append
446
463
  if File.exist?(system_trans_output_path)
447
464
  system_translation_map = Hash[File.readlines(system_output_path, chomp: true)
448
465
  .zip(File.readlines(system_trans_output_path, chomp: true))]
449
466
  else
450
467
  puts "Files aren't already parsed. Continuing as if --append flag was omitted."
451
- processing_type = 'default'
468
+ processing_type = :default
452
469
  end
453
470
  end
454
471
 
455
- elements = system_object.instance_variable_get(:@elements)
456
- skill_types = system_object.instance_variable_get(:@skill_types)
457
- weapon_types = system_object.instance_variable_get(:@weapon_types)
458
- armor_types = system_object.instance_variable_get(:@armor_types)
459
- currency_unit = system_object.instance_variable_get(:@currency_unit)
460
- terms = system_object.instance_variable_get(:@terms) || system_object.instance_variable_get(:@words)
472
+ elements = system_object.elements
473
+ skill_types = system_object.skill_types
474
+ weapon_types = system_object.weapon_types
475
+ armor_types = system_object.armor_types
476
+ currency_unit = system_object.currency_unit
477
+ terms = system_object.terms || system_object.words
461
478
 
462
479
  [elements, skill_types, weapon_types, armor_types].each do |array|
463
480
  next if array.nil?
@@ -469,7 +486,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
469
486
 
470
487
  next if string.empty?
471
488
 
472
- system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == 'append' &&
489
+ system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
473
490
  !system_translation_map.include?(string)
474
491
 
475
492
  system_lines.add(string)
@@ -480,7 +497,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
480
497
  currency_unit = currency_unit.strip
481
498
 
482
499
  unless currency_unit.empty?
483
- system_translation_map.insert_at_index(system_lines.length, currency_unit, '') if processing_type == 'append' &&
500
+ system_translation_map.insert_at_index(system_lines.length, currency_unit, '') if processing_type == :append &&
484
501
  !system_translation_map.include?(currency_unit)
485
502
 
486
503
  system_lines.add(currency_unit)
@@ -494,7 +511,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
494
511
  value = value.strip
495
512
 
496
513
  unless value.empty?
497
- system_translation_map.insert_at_index(system_lines.length, value, '') if processing_type == 'append' &&
514
+ system_translation_map.insert_at_index(system_lines.length, value, '') if processing_type == :append &&
498
515
  !system_translation_map.include?(value)
499
516
 
500
517
  system_lines.add(value)
@@ -510,7 +527,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
510
527
 
511
528
  next if string.empty?
512
529
 
513
- system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == 'append' &&
530
+ system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
514
531
  !system_translation_map.include?(string)
515
532
 
516
533
  system_lines.add(string)
@@ -519,17 +536,16 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
519
536
 
520
537
  # Game title from System file and ini file may differ, but requesting user request to determine which line do they want is LAME
521
538
  # So just throw that ini ass and continue
522
- _game_title = system_object.instance_variable_get(:@game_title)
523
539
  ini_game_title = read_ini_title(ini_file_path).strip
524
540
 
525
- system_translation_map.insert_at_index(system_lines.length, ini_game_title, '') if processing_type == 'append' &&
541
+ system_translation_map.insert_at_index(system_lines.length, ini_game_title, '') if processing_type == :append &&
526
542
  !system_translation_map.include?(ini_game_title)
527
543
 
528
544
  system_lines.add(ini_game_title)
529
545
 
530
546
  puts "Parsed #{system_filename}" if logging
531
547
 
532
- original_content, translated_content = if processing_type == 'append'
548
+ original_content, translated_content = if processing_type == :append
533
549
  [system_translation_map.keys.join("\n"),
534
550
  system_translation_map.values.join("\n")]
535
551
  else
@@ -553,7 +569,7 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
553
569
  scripts_output_path = File.join(output_path, "#{scripts_basename}.txt")
554
570
  scripts_trans_output_path = File.join(output_path, "#{scripts_basename}_trans.txt")
555
571
 
556
- if processing_type == 'default' && File.exist?(scripts_trans_output_path)
572
+ if processing_type == :default && File.exist?(scripts_trans_output_path)
557
573
  puts 'scripts_trans.txt file already exists. If you want to forcefully re-read all files, use --force flag, or --append if you want append new text to already existing files.'
558
574
  return
559
575
  end
@@ -563,21 +579,32 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
563
579
  scripts_lines = IndexSet.new
564
580
  scripts_translation_map = nil
565
581
 
566
- if processing_type == 'append'
582
+ if processing_type == :append
567
583
  if File.exist?(scripts_trans_output_path)
568
584
  scripts_translation_map = Hash[File.readlines(scripts_output_path, chomp: true)
569
585
  .zip(File.readlines(scripts_trans_output_path, chomp: true))]
570
586
  else
571
587
  puts "Files aren't already parsed. Continuing as if --append flag was omitted."
572
- processing_type = 'default'
588
+ processing_type = :default
573
589
  end
574
590
  end
575
591
 
576
592
  codes_content = []
577
593
 
594
+ # This code was fun before `that` game used Windows-1252 degree symbol
578
595
  script_entries.each do |script|
579
596
  code = Zlib::Inflate.inflate(script[2]).force_encoding('UTF-8')
580
- codes_content.push(code)
597
+ # we're fucking cloning because of encoding issue
598
+ codes_content.push(code.clone)
599
+
600
+ unless code.valid_encoding?
601
+ # who the fuck uses the degree symbol from FUCKING WINDOWS-1252 and NOT UTF-8
602
+ # also, String#encode does NOT FUCKING WORK and for some reason raises on the
603
+ # fucking degree symbol from windows-1252 when trying to encode
604
+ code.force_encoding('Windows-1252')
605
+ end
606
+
607
+ raise unless code.valid_encoding?
581
608
 
582
609
  extract_quoted_strings(code).each do |string|
583
610
  # Removes the U+3000 Japanese typographical space to check if string, when stripped, is truly empty
@@ -586,9 +613,12 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
586
613
  next if string.empty?
587
614
 
588
615
  # Maybe this mess will remove something that mustn't be removed, but it needs to be tested
589
-
590
616
  next if string.start_with?(/([#!?$@]|(\.\/)?(Graphics|Data|Audio|CG|Movies|Save)\/)/) ||
617
+ string.match(/^[^\p{L}]+$/) ||
591
618
  string.match?(/^\d+$/) ||
619
+ string.match?(/%.*(\d|\+|\*)d\]?:?$/) ||
620
+ string.match?(/^\[(ON|OFF)\]$/) ||
621
+ string.match?(/^\[\]$/) ||
592
622
  string.match?(/^(.)\1{2,}$/) ||
593
623
  string.match?(/^(false|true)$/) ||
594
624
  string.match?(/^[wr]b$/) ||
@@ -599,22 +629,17 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
599
629
  string.match?(/^Tile.*[A-Z]$/) ||
600
630
  string.match?(/^[a-zA-Z][a-z]+([A-Z][a-z]*)+$/) ||
601
631
  string.match?(/^Cancel Action$|^Invert$|^End$|^Individual$|^Missed File$|^Bitmap$|^Audio$/) ||
602
- string.match?(/\.(mp3|ogg|jpg|png|ini)$/) ||
632
+ string.match?(/\.(mp3|ogg|jpg|png|ini|txt)$/i) ||
603
633
  string.match?(/\/(\d.*)?$/) ||
604
634
  string.match?(/FILE$/) ||
605
635
  string.match?(/#\{/) ||
606
- string.match?(/(?<!\\)\\(?!\\|G|#)/) ||
636
+ string.match?(/(?<!\\)\\(?![\\G#])/) ||
607
637
  string.match?(/\+?=?=/) ||
608
638
  string.match?(/[}{_<>]/) ||
609
639
  string.match?(/r[vx]data/) ||
610
640
  string.match?(/No such file or directory/) ||
611
641
  string.match?(/level \*\*/) ||
612
- string.match?(/Courier New/) ||
613
- string.match?(/Comic Sans/) ||
614
- string.match?(/Lucida/) ||
615
- string.match?(/Verdana/) ||
616
- string.match?(/Tahoma/) ||
617
- string.match?(/Arial/) ||
642
+ string.match?(/Courier New|Comic Sans|Lucida|Verdana|Tahoma|Arial|Times New Roman/) ||
618
643
  string.match?(/Player start location/) ||
619
644
  string.match?(/Common event call has exceeded/) ||
620
645
  string.match?(/se-/) ||
@@ -627,7 +652,7 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
627
652
  string.match?(/Clear image/) ||
628
653
  string.match?(/Can Collapse/)
629
654
 
630
- scripts_translation_map.insert_at_index(scripts_lines.length, string, '') if processing_type == 'append' &&
655
+ scripts_translation_map.insert_at_index(scripts_lines.length, string, '') if processing_type == :append &&
631
656
  !scripts_translation_map.include?(string)
632
657
 
633
658
  scripts_lines.add(string)
@@ -638,7 +663,7 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
638
663
 
639
664
  File.binwrite(scripts_plain_output_path, codes_content.join("\n"))
640
665
 
641
- original_content, translated_content = if processing_type == 'append'
666
+ original_content, translated_content = if processing_type == :append
642
667
  [scripts_translation_map.keys.join("\n"),
643
668
  scripts_translation_map.values.join("\n")]
644
669
  else
data/lib/write.rb CHANGED
@@ -161,98 +161,95 @@ def self.write_map(original_files_paths, maps_path, output_path, shuffle_level,
161
161
  maps_translation_map = Hash[maps_original_text.zip(maps_translated_text)].freeze
162
162
  names_translation_map = Hash[names_original_text.zip(names_translated_text)].freeze
163
163
 
164
- allowed_codes = [401, 402, 356, 102].freeze
164
+ # 401 - dialogue lines
165
+ # 102 - dialogue choices array
166
+ # 402 - one of the dialogue choices from the array
167
+ # 356 - system lines/special texts (do they even exist before mv?)
168
+ allowed_codes = [401, 102, 402, 356].freeze
165
169
 
166
170
  maps_object_map.each do |filename, object|
167
- display_name = object.instance_variable_get(:@display_name)
171
+ display_name = object.display_name
168
172
  display_name_gotten = names_translation_map[display_name]
169
- object.instance_variable_set(:@display_name, display_name_gotten) unless display_name_gotten.nil?
173
+ object.display_name = display_name_gotten unless display_name_gotten.nil?
170
174
 
171
- events = object.instance_variable_get(:@events)
175
+ events = object.events
172
176
  next if events.nil?
173
177
 
174
178
  events.each_value do |event|
175
- pages = event.instance_variable_get(:@pages)
179
+ pages = event.pages
176
180
  next if pages.nil?
177
181
 
178
182
  pages.each do |page|
179
- list = page.instance_variable_get(:@list)
183
+ list = page.list
180
184
  next if list.nil?
181
185
 
182
186
  in_sequence = false
183
187
  line = []
184
188
  item_indices = []
185
- parameter_indices = []
186
189
 
187
190
  list.each_with_index do |item, it|
188
- code = item.instance_variable_get(:@code)
189
- next unless allowed_codes.include?(code)
191
+ code = item.code
190
192
 
191
- parameters = item.instance_variable_get(:@parameters)
193
+ unless allowed_codes.include?(code)
194
+ if in_sequence
195
+ joined = line.join('\#').strip
196
+ translated = get_parameter_translated(401, joined, maps_translation_map, game_type)
192
197
 
193
- parameters.each_with_index do |parameter, pr|
194
- if code == 401
195
- next unless parameter.is_a?(String) && !parameter.empty?
198
+ unless translated.nil? || translated.empty?
199
+ split = translated.split('\#')
196
200
 
197
- in_sequence = true
198
- line.push(parameter)
199
- item_indices.push(it)
200
- parameter_indices.push(pr)
201
- else
202
- if in_sequence
203
- joined = line.join('\#').strip
204
- translated = get_parameter_translated(401, joined, maps_translation_map, game_type)
205
-
206
- unless translated.nil? || translated.empty?
207
- split = translated.split('\#')
201
+ split_length = split.length
202
+ line_length = line.length
208
203
 
209
- (0..line.length - 1).each do |i|
210
- list[item_indices[i]].instance_variable_get(:@parameters)[parameter_indices[i]] = split[i]
211
- end
204
+ item_indices.each_with_index do |index, i|
205
+ list[index].parameters[0] = i < split_length ? split[i] : ''
212
206
  end
213
207
 
214
- line.clear
215
- item_indices.clear
216
- parameter_indices.clear
217
- in_sequence = false
208
+ list[item_indices.last].parameters[0] = split[line_length..].join("\n") if split_length > line_length
218
209
  end
210
+ end
211
+ next
212
+ end
219
213
 
220
- case code
221
- when 402
222
- next unless parameter.is_a?(String)
214
+ parameters = item.parameters
223
215
 
224
- parameter = parameter.strip
225
- next if parameter.empty?
216
+ if code == 401
217
+ next unless parameters[0].is_a?(String) && !parameters[0].empty?
226
218
 
227
- translated = get_parameter_translated(code, parameter, maps_translation_map, game_type)
228
- parameters[pr] = translated unless translated.nil? || translated.empty?
229
- when 102
230
- next unless parameter.is_a?(Array)
219
+ in_sequence = true
220
+ line.push(parameters[0])
221
+ item_indices.push(it)
222
+ elsif code == 356
223
+ parameter = parameters[0]
224
+ next unless parameter.is_a?(String)
231
225
 
232
- parameter.each_with_index do |subparameter, sp|
233
- next unless subparameter.is_a?(String)
226
+ parameter = parameter.strip
227
+ next if parameter.empty?
234
228
 
235
- subparameter = subparameter.strip
236
- next if subparameter.empty?
229
+ translated = get_parameter_translated(code, parameter, maps_translation_map, game_type)
230
+ parameters[0] = translated unless translated.nil? || translated.empty?
231
+ elsif code == 402
232
+ parameter = parameters[1]
233
+ next unless parameter.is_a?(String)
237
234
 
238
- translated = get_parameter_translated(code, subparameter, maps_translation_map, game_type)
239
- parameters[pr][sp] = translated unless translated.nil? || translated.empty?
240
- end
241
- when 356
242
- next unless parameter.is_a?(String)
235
+ parameter = parameter.strip
236
+ next if parameter.empty?
243
237
 
244
- parameter = parameter.strip
245
- next if parameter.empty?
238
+ translated = get_parameter_translated(code, parameter, maps_translation_map, game_type)
239
+ parameters[1] = translated unless translated.nil? || translated.empty?
240
+ elsif code == 102 && parameters[0].is_a?(Array)
241
+ parameters[0].each_with_index do |subparameter, sp|
242
+ next unless subparameter.is_a?(String)
246
243
 
247
- translated = get_parameter_translated(code, parameter, maps_translation_map, game_type)
248
- parameters[pr] = translated unless translated.nil? || translated.empty?
249
- else
250
- nil
251
- end
244
+ subparameter = subparameter.strip
245
+ next if subparameter.empty?
246
+
247
+ translated = get_parameter_translated(code, subparameter, maps_translation_map, game_type)
248
+ parameters[0][sp] = translated unless translated.nil? || translated.empty?
252
249
  end
253
250
  end
254
251
 
255
- item.instance_variable_set(:@parameters, parameters)
252
+ item.parameters = parameters
256
253
  end
257
254
  end
258
255
  end
@@ -277,7 +274,12 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
277
274
  [basename, object]
278
275
  end]
279
276
 
280
- allowed_codes = [401, 402, 405, 356, 102].freeze
277
+ # 401 - dialogue lines
278
+ # 405 - credits lines
279
+ # 102 - dialogue choices array
280
+ # 402 - one of the dialogue choices from the array
281
+ # 356 - system lines/special texts (do they even exist before mv?)
282
+ allowed_codes = [401, 405, 102, 402, 356].freeze
281
283
 
282
284
  other_object_array_map.each do |filename, other_object_array|
283
285
  other_filename = File.basename(filename, '.*').downcase
@@ -299,17 +301,12 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
299
301
  other_object_array.each do |object|
300
302
  next if object.nil?
301
303
 
302
- variables_symbols = %i[@name @nickname @description @note].freeze
304
+ name = object.name
305
+ nickname = object.nickname
306
+ description = object.description
307
+ note = object.note
303
308
 
304
- name = object.instance_variable_get(variables_symbols[0])
305
- nickname = object.instance_variable_get(variables_symbols[1])
306
- description = object.instance_variable_get(variables_symbols[2])
307
- note = object.instance_variable_get(variables_symbols[3])
308
-
309
- [[variables_symbols[0], name],
310
- [variables_symbols[1], nickname],
311
- [variables_symbols[2], description],
312
- [variables_symbols[3], note]].each do |symbol, variable|
309
+ [name, nickname, description, note].each_with_index do |variable, i|
313
310
  next unless variable.is_a?(String)
314
311
 
315
312
  variable = variable.strip
@@ -318,92 +315,96 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
318
315
  variable = variable.gsub(/\r\n/, "\n")
319
316
 
320
317
  translated = get_variable_translated(variable, other_translation_map, game_type)
321
- object.instance_variable_set(symbol, translated) unless translated.nil? || translated.empty?
318
+
319
+ if i.zero?
320
+ object.name = translated unless translated.nil? || translated.empty?
321
+ elsif i == 1
322
+ object.nickname = translated unless translated.nil? || translated.empty?
323
+ elsif i == 2
324
+ object.description = translated unless translated.nil? || translated.empty?
325
+ else
326
+ object.note = translated unless translated.nil? || translated.empty?
327
+ end
322
328
  end
323
329
  end
324
330
  else
325
331
  other_object_array.each do |object|
326
- pages = object.instance_variable_get(:@pages)
332
+ next if object.nil?
333
+
334
+ pages = object.pages
327
335
  pages_length = pages.nil? ? 1 : pages.length
328
336
 
329
337
  (0..pages_length).each do |pg|
330
- list = pages.nil? ? object.instance_variable_get(:@list) : pages[pg].instance_variable_get(:@list)
338
+ list = pages.nil? ? object.list : pages[pg].instance_variable_get(:@list) # for some reason .list access doesn't work (wtf?)
331
339
  next if list.nil?
332
340
 
333
341
  in_sequence = false
334
342
  line = []
335
343
  item_indices = []
336
- parameter_indices = []
337
344
 
338
345
  list.each_with_index do |item, it|
339
- code = item.instance_variable_get(:@code)
340
- next unless allowed_codes.include?(code)
341
-
342
- parameters = item.instance_variable_get(:@parameters)
343
-
344
- parameters.each_with_index do |parameter, pr|
345
- if [401, 405].include?(code)
346
- next unless parameter.is_a?(String) && !parameter.empty?
347
-
348
- in_sequence = true
349
- line.push(parameter)
350
- item_indices.push(it)
351
- parameter_indices.push(pr)
352
- else
353
- if in_sequence
354
- joined = line.join('\#').strip
355
- translated = get_parameter_translated(401, joined, other_translation_map, game_type)
356
-
357
- unless translated.nil? || translated.empty?
358
- split = translated.split('\#')
359
-
360
- (0..line.length - 1).each do |i|
361
- list[item_indices[i]].instance_variable_get(:@parameters)[parameter_indices[i]] = split[i]
362
- end
346
+ code = item.code
347
+
348
+ unless allowed_codes.include?(code)
349
+ if in_sequence
350
+ joined = line.join('\#').strip
351
+ translated = get_parameter_translated(401, joined, other_translation_map, game_type)
352
+
353
+ unless translated.nil? || translated.empty?
354
+ split = translated.split('\#')
355
+
356
+ split_length = split.length
357
+ line_length = line.length
358
+
359
+ item_indices.each_with_index do |index, i|
360
+ list[index].parameters[0] = i < split_length ? split[i] : ''
363
361
  end
364
362
 
365
- line.clear
366
- item_indices.clear
367
- parameter_indices.clear
368
- in_sequence = false
363
+ list[item_indices.last].parameters[0] = split[line_length..].join("\n") if split_length > line_length
369
364
  end
365
+ end
366
+ next
367
+ end
370
368
 
371
- case code
372
- when 402
373
- next unless parameter.is_a?(String)
369
+ parameters = item.parameters
374
370
 
375
- parameter = parameter.strip
376
- next if parameter.empty?
371
+ if [401, 405].include?(code)
372
+ next unless parameters[0].is_a?(String) && !parameters[0].empty?
377
373
 
378
- translated = get_parameter_translated(code, parameter, other_translation_map, game_type)
379
- parameters[pr] = translated unless translated.nil? || translated.empty?
380
- when 102
381
- next unless parameter.is_a?(Array)
374
+ in_sequence = true
375
+ line.push(parameters[0])
376
+ item_indices.push(it)
377
+ elsif code == 356
378
+ parameter = parameters[0]
379
+ next unless parameter.is_a?(String)
382
380
 
383
- parameter.each_with_index do |subparameter, sp|
384
- next unless subparameter.is_a?(String)
381
+ parameter = parameter.strip
382
+ next if parameter.empty?
385
383
 
386
- subparameter = subparameter.strip
387
- next if subparameter.empty?
384
+ translated = get_parameter_translated(code, parameter, other_translation_map, game_type)
385
+ parameters[0] = translated unless translated.nil? || translated.empty?
386
+ elsif code == 402
387
+ parameter = parameters[1]
388
+ next unless parameter.is_a?(String)
388
389
 
389
- translated = get_parameter_translated(code, subparameter, other_translation_map, game_type)
390
- parameters[pr][sp] = translated unless translated.nil? || translated.empty?
391
- end
392
- when 356
393
- next unless parameter.is_a?(String)
390
+ parameter = parameter.strip
391
+ next if parameter.empty?
394
392
 
395
- parameter = parameter.strip
396
- next if parameter.empty?
393
+ translated = get_parameter_translated(code, parameter, other_translation_map, game_type)
394
+ parameters[1] = translated unless translated.nil? || translated.empty?
395
+ elsif code == 102 && parameters[0].is_a?(Array)
396
+ parameters[0].each_with_index do |subparameter, sp|
397
+ next unless subparameter.is_a?(String)
397
398
 
398
- translated = get_parameter_translated(code, parameter, other_translation_map, game_type)
399
- parameters[pr] = translated unless translated.nil? || translated.empty?
400
- else
401
- nil
402
- end
399
+ subparameter = subparameter.strip
400
+ next if subparameter.empty?
401
+
402
+ translated = get_parameter_translated(code, subparameter, other_translation_map, game_type)
403
+ parameters[0][sp] = translated unless translated.nil? || translated.empty?
403
404
  end
404
405
  end
405
406
 
406
- item.instance_variable_set(:@parameters, parameters)
407
+ item.parameters = parameters
407
408
  end
408
409
  end
409
410
  end
@@ -420,7 +421,7 @@ end
420
421
  def self.write_ini_title(ini_file_path, translated)
421
422
  file_lines = File.readlines(ini_file_path, chomp: true)
422
423
  title_line_index = file_lines.each_with_index do |line, i|
423
- break i if line.start_with?('title')
424
+ break i if line.downcase.start_with?('title')
424
425
  end
425
426
 
426
427
  file_lines[title_line_index] = translated
@@ -451,14 +452,12 @@ def self.write_system(system_file_path, ini_file_path, other_path, output_path,
451
452
 
452
453
  system_translation_map = Hash[system_original_text.zip(system_translated_text)].freeze
453
454
 
454
- system_symbols = %i[@elements @skill_types @weapon_types @armor_types @currency_unit @terms @words @game_title].freeze
455
-
456
- elements = system_object.instance_variable_get(system_symbols[0])
457
- skill_types = system_object.instance_variable_get(system_symbols[1])
458
- weapon_types = system_object.instance_variable_get(system_symbols[2])
459
- armor_types = system_object.instance_variable_get(system_symbols[3])
460
- currency_unit = system_object.instance_variable_get(system_symbols[4])
461
- terms = system_object.instance_variable_get(system_symbols[5]) || system_object.instance_variable_get(system_symbols[6])
455
+ elements = system_object.elements
456
+ skill_types = system_object.skill_types
457
+ weapon_types = system_object.weapon_types
458
+ armor_types = system_object.armor_types
459
+ currency_unit = system_object.currency_unit
460
+ terms = system_object.terms || system_object.words
462
461
 
463
462
  [elements, skill_types, weapon_types, armor_types].each_with_index.each do |array, i|
464
463
  next unless array.is_a?(Array)
@@ -471,11 +470,19 @@ def self.write_system(system_file_path, ini_file_path, other_path, output_path,
471
470
  !translated.nil? && !translated.empty? ? translated : stripped
472
471
  end
473
472
 
474
- system_object.instance_variable_set(system_symbols[i], array)
473
+ if i.zero?
474
+ system_object.elements = array
475
+ elsif i == 1
476
+ system_object.skill_types = array
477
+ elsif i == 2
478
+ system_object.weapon_types = array
479
+ else
480
+ system_object.armor_types = array
481
+ end
475
482
  end
476
483
 
477
484
  currency_unit_translated = system_translation_map[currency_unit]
478
- system_object.instance_variable_set(system_symbols[4], currency_unit_translated) if currency_unit.is_a?(String) &&
485
+ system_object.currency_unit = currency_unit_translated if currency_unit.is_a?(String) &&
479
486
  (!currency_unit_translated.nil? && !currency_unit_translated.empty?)
480
487
 
481
488
  terms.instance_variables.each do |variable|
@@ -500,12 +507,12 @@ def self.write_system(system_file_path, ini_file_path, other_path, output_path,
500
507
  terms.instance_variable_set(variable, value)
501
508
  end
502
509
 
503
- system_object.instance_variable_defined?(system_symbols[5]) ?
504
- system_object.instance_variable_set(system_symbols[5], terms) :
505
- system_object.instance_variable_set(system_symbols[6], terms)
510
+ system_object.terms.nil? ?
511
+ system_object.words = terms :
512
+ system_object.terms = terms
506
513
 
507
514
  game_title_translated = system_translated_text[-1]
508
- system_object.instance_variable_set(system_symbols[7], game_title_translated)
515
+ system_object.game_title = game_title_translated
509
516
  write_ini_title(ini_file_path, game_title_translated)
510
517
 
511
518
  puts "Written #{system_basename}" if logging
@@ -531,9 +538,17 @@ def self.write_scripts(scripts_file_path, other_path, output_path, logging)
531
538
  # Shuffle can possibly break the game in scripts, so no shuffling
532
539
  codes = []
533
540
 
541
+ # This code was fun before `that` game used Windows-1252 degree symbol
534
542
  script_entries.each do |script|
535
543
  code = Zlib::Inflate.inflate(script[2]).force_encoding('UTF-8')
536
544
 
545
+ unless code.valid_encoding?
546
+ # who the fuck uses the degree symbol from FUCKING WINDOWS-1252 and NOT UTF-8
547
+ # also, String#encode does NOT FUCKING WORK and for some reason raises on the
548
+ # fucking degree symbol from windows-1252 when trying to encode
549
+ code.force_encoding('Windows-1252')
550
+ end
551
+
537
552
  # this shit finally works and requires NO further changes
538
553
  string_array, index_array = extract_quoted_strings(code)
539
554
 
@@ -551,6 +566,6 @@ def self.write_scripts(scripts_file_path, other_path, output_path, logging)
551
566
 
552
567
  puts "Written #{scripts_basename}" if logging
553
568
 
554
- File.binwrite(File.join(output_path, 'scripts_plain.txt'), codes.join("\n"))
569
+ # File.binwrite(File.join(output_path, 'scripts_plain.txt'), codes.join("\n")) - debug line
555
570
  File.binwrite(File.join(output_path, scripts_basename), Marshal.dump(script_entries))
556
571
  end
data/rvpacker-txt.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'rvpacker-txt'
5
- spec.version = '1.6.0'
5
+ spec.version = '1.7.0'
6
6
  spec.authors = ['Howard Jeng', 'Andrew Kesterson', 'Solistra', 'Darkness9724', 'savannstm']
7
7
  spec.email = ['savannstm@gmail.com']
8
8
  spec.summary = 'Reads or writes RPG Maker XP/VX/VXAce game text to .txt files'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rvpacker-txt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Howard Jeng
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2024-07-15 00:00:00.000000000 Z
15
+ date: 2024-07-16 00:00:00.000000000 Z
16
16
  dependencies: []
17
17
  description:
18
18
  email: