Skip to content

Commit 9e164e1

Browse files
authored
Add files via upload
1 parent 8d67207 commit 9e164e1

1 file changed

Lines changed: 49 additions & 40 deletions

File tree

Modules/RVData2Compiler.rb

Lines changed: 49 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,13 @@ def compile_common_events
243243
end
244244

245245
indent = $1.to_s.length / @indentation.length
246-
code = TARGETED_EVENT_COMMANDS.key($3)
247246
parameters = eval($4.to_s)
248247

249-
unless [355, 655].include?(code)
248+
code = TARGETED_EVENT_COMMANDS.key($3)
249+
if code.nil?
250+
STDERR.puts "Unknown Command at CommonEvent #{event_ind}, Command #{$2}."
251+
break
252+
elsif not [355, 655].include?(code)
250253
deserialize_parameters(parameters)
251254
end
252255

@@ -256,19 +259,16 @@ def compile_common_events
256259
when /(\d+)-(\D+?)\((.*)\)/
257260
parameters = eval($3.to_s)
258261

259-
begin
260-
code = TARGETED_EVENT_COMMANDS.key($2)
261-
@rvdata2_data[event_ind].list[$1.to_i].code = code
262-
rescue NoMethodError => e
262+
code = TARGETED_EVENT_COMMANDS.key($2)
263+
if code.nil?
263264
STDERR.puts "Unknown Command at CommonEvent #{event_ind}, Command #{$1}, #{$2}."
264-
STDERR.puts e
265265
break
266-
end
267-
268-
unless [355, 655].include?(code)
266+
elsif not [355, 655].include?(code)
269267
deserialize_parameters(parameters)
270268
end
271269

270+
@rvdata2_data[event_ind].list[$1.to_i].code = code
271+
272272
if $1.to_i >= @rvdata2_data[event_ind].list.length
273273
STDERR.puts "Command #{$1} is out of range at CommonEvent #{event_ind}."
274274
break
@@ -335,8 +335,11 @@ def compile_common_events_indexless
335335
code = TARGETED_EVENT_COMMANDS.key('Empty')
336336
parameters.clear
337337
end
338-
339-
unless [355, 655].include?(code)
338+
339+
if code.nil?
340+
STDERR.puts "Unknown Command at CommonEvent #{event_ind}, Command #{$2}."
341+
break
342+
elsif not [355, 655].include?(code)
340343
deserialize_parameters(parameters)
341344
end
342345

@@ -526,16 +529,19 @@ def compile_map(file_basename)
526529
when /(\s*)(\d+)-(\D+?)\((.*)\)\+$/
527530

528531
if $1.to_s.length % @indentation.length != 0 || $1.to_s.length < @indentation.length
529-
STDERR.puts "Error at CommonEvent #{event_ind}, Page #{page_ind}, Command #{$2} has incorrect indentation."
532+
STDERR.puts "Error at CommonEvent #{event_ind}, Page #{page_ind}, Command #{$2}, #{$3} has incorrect indentation."
530533
break
531534

532535
end
533536

534537
indent = $1.to_s.length / @indentation.length
535-
code = TARGETED_EVENT_COMMANDS.key($3)
536538
parameters = eval($4.to_s)
537539

538-
unless [355, 655].include?(code)
540+
code = TARGETED_EVENT_COMMANDS.key($3)
541+
if code.nil?
542+
STDERR.puts "Unknown Command at CommonEvent #{event_ind}, Page #{page_ind}, Command #{$2}, #{$3}."
543+
break
544+
elsif not [355, 655].include?(code)
539545
deserialize_parameters(parameters)
540546
end
541547

@@ -555,19 +561,16 @@ def compile_map(file_basename)
555561
break
556562
end
557563

558-
begin
559-
code = TARGETED_EVENT_COMMANDS.key($2)
560-
@rvdata2_data.events[event_ind].pages[page_ind].list[$1.to_i].code = code
561-
rescue NoMethodError => e
562-
STDERR.puts "Unknown Command at CommonEvent #{event_ind}, Page #{page_ind}, #{$1}, #{$2}"
563-
STDERR.puts e
564+
code = TARGETED_EVENT_COMMANDS.key($2)
565+
if code.nil?
566+
STDERR.puts "Unknown Command at CommonEvent #{event_ind}, Page #{page_ind}, Command #{$1}, #{$2}."
564567
break
565-
end
566-
567-
unless [355, 655].include?(code)
568+
elsif not [355, 655].include?(code)
568569
deserialize_parameters(parameters)
569570
end
570571

572+
@rvdata2_data.events[event_ind].pages[page_ind].list[$1.to_i].code = code
573+
571574
if $2 == 'ShowText' && parameters[0].empty?
572575
@rvdata2_data.events[event_ind].pages[page_ind].list[$1.to_i].code = TARGETED_EVENT_COMMANDS.key('Empty')
573576
parameters.clear
@@ -628,7 +631,7 @@ def compile_map_indexless(file_basename)
628631
when /(\s+)(\D+?)\((\[.*\])\)/
629632

630633
if $1.to_s.length % @indentation.length != 0 || $1.to_s.length < @indentation.length
631-
STDERR.puts "Error at CommonEvent #{event_ind}, Page #{page_ind}, Command #{$1} has incorrect indentation."
634+
STDERR.puts "Error at CommonEvent #{event_ind}, Page #{page_ind}, Command #{$2} has incorrect indentation."
632635
break
633636

634637
end
@@ -642,7 +645,10 @@ def compile_map_indexless(file_basename)
642645
parameters.clear
643646
end
644647

645-
unless [355, 655].include?(code)
648+
if code.nil?
649+
STDERR.puts "Unknown Command at CommonEvent #{event_ind}, Page #{page_ind}, Command #{$2}."
650+
break
651+
elsif not [355, 655].include?(code)
646652
deserialize_parameters(parameters)
647653
end
648654

@@ -988,16 +994,19 @@ def compile_troops
988994
when /(\s*)(\d+)-(\D+?)\((.*)\)\+$/
989995

990996
if $1.to_s.length % @indentation.length != 0 || $1.to_s.length < @indentation.length
991-
STDERR.puts "Error at Troop #{troop_ind}, Page #{page_ind}, Command #{$2} has incorrect indentation."
997+
STDERR.puts "Error at Troop #{troop_ind}, Page #{page_ind}, Command #{$2}, #{$3} has incorrect indentation."
992998
break
993999

9941000
end
9951001

9961002
indent = $1.to_s.length / @indentation.length
997-
code = TARGETED_EVENT_COMMANDS.key($3)
9981003
parameters = eval($4.to_s)
9991004

1000-
unless [355, 655].include?(code)
1005+
code = TARGETED_EVENT_COMMANDS.key($3)
1006+
if code.nil?
1007+
STDERR.puts "Unknown Command at Troop #{troop_ind}, Page #{page_ind}, Command #{$2}, #{$3}."
1008+
break
1009+
elsif not [355, 655].include?(code)
10011010
deserialize_parameters(parameters)
10021011
end
10031012

@@ -1017,19 +1026,16 @@ def compile_troops
10171026
break
10181027
end
10191028

1020-
begin
1021-
code = TARGETED_EVENT_COMMANDS.key($2)
1022-
@rvdata2_data[troop_ind].pages[page_ind].list[$1.to_i].code = code
1023-
rescue NoMethodError => e
1024-
STDERR.puts "Unknown Command at Troop #{troop_ind}, Page #{page_ind}, #{$1}, #{$2}"
1025-
STDERR.puts e
1029+
code = TARGETED_EVENT_COMMANDS.key($2)
1030+
if code.nil?
1031+
STDERR.puts "Unknown Command at Troop #{troop_ind}, Page #{page_ind}, Command #{$1}, #{$2}."
10261032
break
1027-
end
1028-
1029-
unless [355, 655].include?(code)
1033+
elsif not [355, 655].include?(code)
10301034
deserialize_parameters(parameters)
10311035
end
10321036

1037+
@rvdata2_data[troop_ind].pages[page_ind].list[$1.to_i].code = code
1038+
10331039
if $2 == 'ShowText' && parameters[0].empty?
10341040
@rvdata2_data[troop_ind].pages[page_ind].list[$1.to_i].code = TARGETED_EVENT_COMMANDS.key('Empty')
10351041
parameters.clear
@@ -1084,7 +1090,7 @@ def compile_troops_indexless
10841090
when /(\s+)(\D+?)\((\[.*\])\)/
10851091

10861092
if $1.to_s.length % @indentation.length != 0 || $1.to_s.length < @indentation.length
1087-
STDERR.puts "Error at Troop #{troop_ind}, Page #{page_ind}, Command #{$1} has incorrect indentation."
1093+
STDERR.puts "Error at Troop #{troop_ind}, Page #{page_ind}, Command #{$2} has incorrect indentation."
10881094
break
10891095

10901096
end
@@ -1098,7 +1104,10 @@ def compile_troops_indexless
10981104
parameters.clear
10991105
end
11001106

1101-
unless [355, 655].include?(code)
1107+
if code.nil?
1108+
STDERR.puts "Unknown Command at Troop #{troop_ind}, Page #{page_ind}, Command #{$1}"
1109+
break
1110+
elsif not [355, 655].include?(code)
11021111
deserialize_parameters(parameters)
11031112
end
11041113

0 commit comments

Comments
 (0)