Fixed symbol/string error in compiling TM compatibility data

This commit is contained in:
Maruno17
2020-12-12 21:34:57 +00:00
parent bc13517cb7
commit 9ceda78d37
2 changed files with 13 additions and 13 deletions

View File

@@ -564,13 +564,13 @@ module Compiler
def parseItem(item) def parseItem(item)
clonitem = item.upcase clonitem = item.upcase
clonitem.sub!(/^\s*/,"") clonitem.sub!(/^\s*/, "")
clonitem.sub!(/\s*$/,"") clonitem.sub!(/\s*$/, "")
itm = GameData::Item.try_get(clonitem) itm = GameData::Item.try_get(clonitem)
if !itm if !itm
raise _INTL("Undefined item constant name: {1}\r\nName must consist only of letters, numbers and\r\nunderscores, and can't begin with a number.\r\nMake sure the item is defined in\r\nPBS/items.txt.\r\n{2}", item, FileLineData.linereport) raise _INTL("Undefined item constant name: {1}\r\nName must consist only of letters, numbers and\r\nunderscores, and can't begin with a number.\r\nMake sure the item is defined in\r\nPBS/items.txt.\r\n{2}", item, FileLineData.linereport)
end end
return itm.id.to_s return itm.id
end end
def parseSpecies(item) def parseSpecies(item)
@@ -591,7 +591,7 @@ module Compiler
return nil if skip_unknown return nil if skip_unknown
raise _INTL("Undefined move constant name: {1}\r\nName must consist only of letters, numbers and\r\nunderscores, and can't begin with a number.\r\nMake sure the move is defined in\r\nPBS/moves.txt.\r\n{2}", move, FileLineData.linereport) raise _INTL("Undefined move constant name: {1}\r\nName must consist only of letters, numbers and\r\nunderscores, and can't begin with a number.\r\nMake sure the move is defined in\r\nPBS/moves.txt.\r\n{2}", move, FileLineData.linereport)
end end
return mov.id.to_s return mov.id
end end
# Unused # Unused
@@ -611,7 +611,7 @@ module Compiler
if !typ if !typ
raise _INTL("Undefined Trainer type constant name: {1}\r\nName must consist only of letters, numbers and\r\nunderscores, and can't begin with a number.\r\nMake sure the trainer type is defined in\r\ntrainertypes.txt.\r\n{2}", type, FileLineData.linereport) raise _INTL("Undefined Trainer type constant name: {1}\r\nName must consist only of letters, numbers and\r\nunderscores, and can't begin with a number.\r\nMake sure the trainer type is defined in\r\ntrainertypes.txt.\r\n{2}", type, FileLineData.linereport)
end end
return typ.id.to_s return typ.id
end end
#============================================================================= #=============================================================================

View File

@@ -191,7 +191,7 @@ module Compiler
if line[/^\s*(\w+)\s*=\s*(.*)$/] # Of the format XXX = YYY if line[/^\s*(\w+)\s*=\s*(.*)$/] # Of the format XXX = YYY
key = $1 key = $1
value = $2 value = $2
item_symbol = parseItem(key).to_sym item_symbol = parseItem(key)
item_number = GameData::Item.get(item_symbol).id_number item_number = GameData::Item.get(item_symbol).id_number
line = pbGetCsvRecord(value, line_no, [0, "vuuv"]) line = pbGetCsvRecord(value, line_no, [0, "vuuv"])
# Construct berry plant hash # Construct berry plant hash
@@ -992,7 +992,7 @@ module Compiler
def compile_move_compatibilities def compile_move_compatibilities
lineno = 1 lineno = 1
havesection = false havesection = false
sectionname = nil move_id = nil
sections = {} sections = {}
if safeExists?("PBS/tm.txt") if safeExists?("PBS/tm.txt")
f = File.open("PBS/tm.txt","rb") f = File.open("PBS/tm.txt","rb")
@@ -1004,21 +1004,21 @@ module Compiler
FileLineData.setLine(line,lineno) FileLineData.setLine(line,lineno)
if !line[/^\#/] && !line[/^\s*$/] if !line[/^\#/] && !line[/^\s*$/]
if line[/^\s*\[\s*(.*)\s*\]\s*$/] if line[/^\s*\[\s*(.*)\s*\]\s*$/]
sectionname = parseMove($~[1]) move_id = parseMove($~[1])
if sections[sectionname] if sections[move_id]
raise _INTL("TM section [{1}] is defined twice.\r\n{2}",sectionname,FileLineData.linereport) raise _INTL("TM section [{1}] is defined twice.\r\n{2}",move_id.to_s,FileLineData.linereport)
end end
sections[sectionname] = [] sections[move_id] = []
havesection = true havesection = true
else else
if sectionname==nil if !move_id
raise _INTL("Expected a section at the beginning of the file. This error may also occur if the file was not saved in UTF-8.\r\n{1}", raise _INTL("Expected a section at the beginning of the file. This error may also occur if the file was not saved in UTF-8.\r\n{1}",
FileLineData.linereport) FileLineData.linereport)
end end
specieslist = line.sub(/\s+$/,"").split(",") specieslist = line.sub(/\s+$/,"").split(",")
for species in specieslist for species in specieslist
next if !species || species=="" next if !species || species==""
sec = sections[sectionname] sec = sections[move_id]
sec[sec.length] = parseSpecies(species) sec[sec.length] = parseSpecies(species)
end end
end end