Added compiler schema letter "m" which makes the value a symbol, refactored many PBS file compilers, removed support for old PBS formats/properties

This commit is contained in:
Maruno17
2022-11-16 22:03:12 +00:00
parent bbe654028c
commit 5d439de87d
18 changed files with 887 additions and 1193 deletions

View File

@@ -14,15 +14,15 @@ module GameData
DATA_FILENAME = "types.dat"
SCHEMA = {
"Name" => [0, "s"],
"InternalName" => [0, "s"],
"IsSpecialType" => [0, "b"],
"IsPseudoType" => [0, "b"],
"Flags" => [0, "*s"],
"Weaknesses" => [0, "*s"],
"Resistances" => [0, "*s"],
"Immunities" => [0, "*s"],
"IconPosition" => [0, "u"]
"SectionName" => [:id, "m"],
"Name" => [:real_name, "s"],
"IsSpecialType" => [:special_type, "b"],
"IsPseudoType" => [:pseudo_type, "b"],
"Flags" => [:flags, "*s"],
"Weaknesses" => [:weaknesses, "*m"],
"Resistances" => [:resistances, "*m"],
"Immunities" => [:immunities, "*m"],
"IconPosition" => [:icon_position, "u"]
}
extend ClassMethodsSymbols
@@ -30,7 +30,7 @@ module GameData
def initialize(hash)
@id = hash[:id]
@real_name = hash[:name] || "Unnamed"
@real_name = hash[:real_name] || "Unnamed"
@special_type = hash[:special_type] || false
@pseudo_type = hash[:pseudo_type] || false
@flags = hash[:flags] || []

View File

@@ -12,15 +12,16 @@ module GameData
include InstanceMethods
SCHEMA = {
"Name" => [:name, "s"],
"Description" => [:description, "q"],
"SectionName" => [:id, "m"],
"Name" => [:real_name, "s"],
"Description" => [:real_description, "q"],
"Flags" => [:flags, "*s"]
}
def initialize(hash)
@id = hash[:id]
@real_name = hash[:name] || "Unnamed"
@real_description = hash[:description] || "???"
@real_name = hash[:real_name] || "Unnamed"
@real_description = hash[:real_description] || "???"
@flags = hash[:flags] || []
end

View File

@@ -19,7 +19,8 @@ module GameData
DATA_FILENAME = "moves.dat"
SCHEMA = {
"Name" => [:name, "s"],
"SectionName" => [:id, "m"],
"Name" => [:real_name, "s"],
"Type" => [:type, "e", :Type],
"Category" => [:category, "e", ["Physical", "Special", "Status"]],
"Power" => [:base_damage, "u"],
@@ -30,10 +31,7 @@ module GameData
"FunctionCode" => [:function_code, "s"],
"Flags" => [:flags, "*s"],
"EffectChance" => [:effect_chance, "u"],
"Description" => [:description, "q"],
# All properties below here are old names for some properties above.
# They will be removed in v21.
"BaseDamage" => [:base_damage, "u"]
"Description" => [:real_description, "q"]
}
extend ClassMethodsSymbols
@@ -42,7 +40,7 @@ module GameData
def initialize(hash)
convert_move_data(hash)
@id = hash[:id]
@real_name = hash[:name] || "Unnamed"
@real_name = hash[:real_name] || "Unnamed"
@type = hash[:type] || :NONE
@category = hash[:category] || 2
@base_damage = hash[:base_damage] || 0
@@ -54,7 +52,7 @@ module GameData
@flags = hash[:flags] || []
@flags = [@flags] if !@flags.is_a?(Array)
@effect_chance = hash[:effect_chance] || 0
@real_description = hash[:description] || "???"
@real_description = hash[:real_description] || "???"
end
# @return [String] the translated name of this move

View File

@@ -9,26 +9,27 @@ module GameData
attr_reader :real_description
attr_reader :field_use
attr_reader :battle_use
attr_reader :consumable
attr_reader :flags
attr_reader :consumable
attr_reader :move
DATA = {}
DATA_FILENAME = "items.dat"
SCHEMA = {
"Name" => [:name, "s"],
"NamePlural" => [:name_plural, "s"],
"SectionName" => [:id, "m"],
"Name" => [:real_name, "s"],
"NamePlural" => [:real_name_plural, "s"],
"Pocket" => [:pocket, "v"],
"Price" => [:price, "u"],
"SellPrice" => [:sell_price, "u"],
"Description" => [:description, "q"],
"Description" => [:real_description, "q"],
"FieldUse" => [:field_use, "e", { "OnPokemon" => 1, "Direct" => 2, "TM" => 3,
"HM" => 4, "TR" => 5 }],
"BattleUse" => [:battle_use, "e", { "OnPokemon" => 1, "OnMove" => 2, "OnBattler" => 3,
"OnFoe" => 4, "Direct" => 5 }],
"Consumable" => [:consumable, "b"],
"Flags" => [:flags, "*s"],
"Consumable" => [:consumable, "b"],
"Move" => [:move, "e", :Move]
}
@@ -82,12 +83,12 @@ module GameData
def initialize(hash)
@id = hash[:id]
@real_name = hash[:name] || "Unnamed"
@real_name_plural = hash[:name_plural] || "Unnamed"
@real_name = hash[:real_name] || "Unnamed"
@real_name_plural = hash[:real_name_plural] || "Unnamed"
@pocket = hash[:pocket] || 1
@price = hash[:price] || 0
@sell_price = hash[:sell_price] || (@price / 2)
@real_description = hash[:description] || "???"
@real_description = hash[:real_description] || "???"
@field_use = hash[:field_use] || 0
@battle_use = hash[:battle_use] || 0
@flags = hash[:flags] || []

View File

@@ -9,6 +9,7 @@ module GameData
DATA_FILENAME = "berry_plants.dat"
SCHEMA = {
"SectionName" => [:id, "m"],
"HoursPerStage" => [:hours_per_stage, "v"],
"DryingPerHour" => [:drying_per_hour, "u"],
"Yield" => [:yield, "uv"]

View File

@@ -73,70 +73,50 @@ module GameData
def self.schema(compiling_forms = false)
ret = {
"FormName" => [0, "q"],
"Category" => [0, "s"],
"Pokedex" => [0, "q"],
"Types" => [0, "eE", :Type, :Type],
"BaseStats" => [0, "vvvvvv"],
"EVs" => [0, "*ev", :Stat],
"BaseExp" => [0, "v"],
"CatchRate" => [0, "u"],
"Happiness" => [0, "u"],
"Moves" => [0, "*ue", nil, :Move],
"TutorMoves" => [0, "*e", :Move],
"EggMoves" => [0, "*e", :Move],
"Abilities" => [0, "*e", :Ability],
"HiddenAbilities" => [0, "*e", :Ability],
"WildItemCommon" => [0, "*e", :Item],
"WildItemUncommon" => [0, "*e", :Item],
"WildItemRare" => [0, "*e", :Item],
"EggGroups" => [0, "*e", :EggGroup],
"HatchSteps" => [0, "v"],
"Height" => [0, "f"],
"Weight" => [0, "f"],
"Color" => [0, "e", :BodyColor],
"Shape" => [0, "e", :BodyShape],
"Habitat" => [0, "e", :Habitat],
"Generation" => [0, "i"],
"Flags" => [0, "*s"],
"BattlerPlayerX" => [0, "i"],
"BattlerPlayerY" => [0, "i"],
"BattlerEnemyX" => [0, "i"],
"BattlerEnemyY" => [0, "i"],
"BattlerAltitude" => [0, "i"],
"BattlerShadowX" => [0, "i"],
"BattlerShadowSize" => [0, "u"],
# All properties below here are old names for some properties above.
# They will be removed in v21.
"Type1" => [0, "e", :Type],
"Type2" => [0, "e", :Type],
"Rareness" => [0, "u"],
"Compatibility" => [0, "*e", :EggGroup],
"Kind" => [0, "s"],
"BaseEXP" => [0, "v"],
"EffortPoints" => [0, "*ev", :Stat],
"HiddenAbility" => [0, "*e", :Ability],
"StepsToHatch" => [0, "v"]
"FormName" => [:real_form_name, "q"],
"Category" => [:real_category, "s"],
"Pokedex" => [:real_pokedex_entry, "q"],
"Types" => [:types, "eE", :Type, :Type],
"BaseStats" => [:base_stats, "vvvvvv"],
"EVs" => [:evs, "*ev", :Stat],
"BaseExp" => [:base_exp, "v"],
"CatchRate" => [:catch_rate, "u"],
"Happiness" => [:happiness, "u"],
"Moves" => [:moves, "*ue", nil, :Move],
"TutorMoves" => [:tutor_moves, "*e", :Move],
"EggMoves" => [:egg_moves, "*e", :Move],
"Abilities" => [:abilities, "*e", :Ability],
"HiddenAbilities" => [:hidden_abilities, "*e", :Ability],
"WildItemCommon" => [:wild_item_common, "*e", :Item],
"WildItemUncommon" => [:wild_item_uncommon, "*e", :Item],
"WildItemRare" => [:wild_item_rare, "*e", :Item],
"EggGroups" => [:egg_groups, "*e", :EggGroup],
"HatchSteps" => [:hatch_steps, "v"],
"Height" => [:height, "f"],
"Weight" => [:weight, "f"],
"Color" => [:color, "e", :BodyColor],
"Shape" => [:shape, "e", :BodyShape],
"Habitat" => [:habitat, "e", :Habitat],
"Generation" => [:generation, "i"],
"Flags" => [:flags, "*s"]
}
if compiling_forms
ret["PokedexForm"] = [0, "u"]
ret["Offspring"] = [0, "*e", :Species]
ret["Evolutions"] = [0, "*ees", :Species, :Evolution, nil]
ret["MegaStone"] = [0, "e", :Item]
ret["MegaMove"] = [0, "e", :Move]
ret["UnmegaForm"] = [0, "u"]
ret["MegaMessage"] = [0, "u"]
ret["SectionName"] = [:id, "ev", :Species]
ret["PokedexForm"] = [:pokedex_form, "u"]
ret["Offspring"] = [:offspring, "*e", :Species]
ret["Evolutions"] = [:evolutions, "*ees", :Species, :Evolution, nil]
ret["MegaStone"] = [:mega_stone, "e", :Item]
ret["MegaMove"] = [:mega_move, "e", :Move]
ret["UnmegaForm"] = [:unmega_form, "u"]
ret["MegaMessage"] = [:mega_message, "u"]
else
ret["InternalName"] = [0, "n"]
ret["Name"] = [0, "s"]
ret["GrowthRate"] = [0, "e", :GrowthRate]
ret["GenderRatio"] = [0, "e", :GenderRatio]
ret["Incense"] = [0, "e", :Item]
ret["Offspring"] = [0, "*s"]
ret["Evolutions"] = [0, "*ses", nil, :Evolution, nil]
# All properties below here are old names for some properties above.
# They will be removed in v21.
ret["GenderRate"] = [0, "e", :GenderRatio]
ret["SectionName"] = [:id, "m"]
ret["Name"] = [:real_name, "s"]
ret["GrowthRate"] = [:growth_rate, "e", :GrowthRate]
ret["GenderRatio"] = [:gender_ratio, "e", :GenderRatio]
ret["Incense"] = [:incense, "e", :Item]
ret["Offspring"] = [:offspring, "*s"]
ret["Evolutions"] = [:evolutions, "*ses", nil, :Evolution, nil]
end
return ret
end
@@ -145,10 +125,10 @@ module GameData
@id = hash[:id]
@species = hash[:species] || @id
@form = hash[:form] || 0
@real_name = hash[:name] || "Unnamed"
@real_form_name = hash[:form_name]
@real_category = hash[:category] || "???"
@real_pokedex_entry = hash[:pokedex_entry] || "???"
@real_name = hash[:real_name] || "Unnamed"
@real_form_name = hash[:real_form_name]
@real_category = hash[:real_category] || "???"
@real_pokedex_entry = hash[:real_pokedex_entry] || "???"
@pokedex_form = hash[:pokedex_form] || @form
@types = hash[:types] || [:NORMAL]
@base_stats = hash[:base_stats] || {}

View File

@@ -13,11 +13,12 @@ module GameData
DATA_FILENAME = "species_metrics.dat"
SCHEMA = {
"BackSprite" => [0, "ii"],
"FrontSprite" => [0, "ii"],
"FrontSpriteAltitude" => [0, "i"],
"ShadowX" => [0, "i"],
"ShadowSize" => [0, "u"]
"SectionName" => [:id, "eV", :Species],
"BackSprite" => [:back_sprite, "ii"],
"FrontSprite" => [:front_sprite, "ii"],
"FrontSpriteAltitude" => [:front_sprite_altitude, "i"],
"ShadowX" => [:shadow_x, "i"],
"ShadowSize" => [:shadow_size, "u"]
}
extend ClassMethodsSymbols

View File

@@ -9,8 +9,9 @@ module GameData
DATA_FILENAME = "shadow_pokemon.dat"
SCHEMA = {
"SectionName" => [:id, "e", :Species],
"GaugeSize" => [:gauge_size, "v"],
"Moves" => [:moves, "*s"], # Not enumerated when compiled
"Moves" => [:moves, "*m"], # Not enumerated when compiled
"Flags" => [:flags, "*s"]
}
HEART_GAUGE_SIZE = 4000 # Default gauge size
@@ -20,8 +21,8 @@ module GameData
def initialize(hash)
@id = hash[:id]
@moves = hash[:moves] || []
@gauge_size = hash[:gauge_size] || HEART_GAUGE_SIZE
@moves = hash[:moves] || []
@flags = hash[:flags] || []
end

View File

@@ -10,9 +10,10 @@ module GameData
DATA_FILENAME = "ribbons.dat"
SCHEMA = {
"Name" => [:name, "s"],
"SectionName" => [:id, "m"],
"Name" => [:real_name, "s"],
"IconPosition" => [:icon_position, "u"],
"Description" => [:description, "q"],
"Description" => [:real_description, "q"],
"Flags" => [:flags, "*s"]
}
@@ -21,9 +22,9 @@ module GameData
def initialize(hash)
@id = hash[:id]
@real_name = hash[:name] || "Unnamed"
@real_name = hash[:real_name] || "Unnamed"
@icon_position = hash[:icon_position] || 0
@real_description = hash[:description] || "???"
@real_description = hash[:real_description] || "???"
@flags = hash[:flags] || []
end

View File

@@ -14,7 +14,8 @@ module GameData
DATA_FILENAME = "trainer_types.dat"
SCHEMA = {
"Name" => [:name, "s"],
"SectionName" => [:id, "m"],
"Name" => [:real_name, "s"],
"Gender" => [:gender, "e", { "Male" => 0, "male" => 0, "M" => 0, "m" => 0, "0" => 0,
"Female" => 1, "female" => 1, "F" => 1, "f" => 1, "1" => 1,
"Unknown" => 2, "unknown" => 2, "Other" => 2, "other" => 2,
@@ -81,7 +82,7 @@ module GameData
def initialize(hash)
@id = hash[:id]
@real_name = hash[:name] || "Unnamed"
@real_name = hash[:real_name] || "Unnamed"
@gender = hash[:gender] || 2
@base_money = hash[:base_money] || 30
@skill_level = hash[:skill_level] || @base_money

View File

@@ -17,17 +17,18 @@ module GameData
DATA_FILENAME = "metadata.dat"
SCHEMA = {
"StartMoney" => [1, "u"],
"StartItemStorage" => [2, "*e", :Item],
"Home" => [3, "vuuu"],
"StorageCreator" => [4, "s"],
"WildBattleBGM" => [5, "s"],
"TrainerBattleBGM" => [6, "s"],
"WildVictoryBGM" => [7, "s"],
"TrainerVictoryBGM" => [8, "s"],
"WildCaptureME" => [9, "s"],
"SurfBGM" => [10, "s"],
"BicycleBGM" => [11, "s"]
"SectionName" => [:id, "u"],
"StartMoney" => [:start_money, "u"],
"StartItemStorage" => [:start_item_storage, "*e", :Item],
"Home" => [:home, "vuuu"],
"StorageCreator" => [:real_storage_creator, "s"],
"WildBattleBGM" => [:wild_battle_BGM, "s"],
"TrainerBattleBGM" => [:trainer_battle_BGM, "s"],
"WildVictoryBGM" => [:wild_victory_BGM, "s"],
"TrainerVictoryBGM" => [:trainer_victory_BGM, "s"],
"WildCaptureME" => [:wild_capture_ME, "s"],
"SurfBGM" => [:surf_BGM, "s"],
"BicycleBGM" => [:bicycle_BGM, "s"]
}
extend ClassMethodsIDNumbers
@@ -58,7 +59,7 @@ module GameData
@start_money = hash[:start_money] || 3000
@start_item_storage = hash[:start_item_storage] || []
@home = hash[:home]
@real_storage_creator = hash[:storage_creator]
@real_storage_creator = hash[:real_storage_creator]
@wild_battle_BGM = hash[:wild_battle_BGM]
@trainer_battle_BGM = hash[:trainer_battle_BGM]
@wild_victory_BGM = hash[:wild_victory_BGM]

View File

@@ -9,15 +9,16 @@ module GameData
DATA_FILENAME = "player_metadata.dat"
SCHEMA = {
"TrainerType" => [1, "e", :TrainerType],
"WalkCharset" => [2, "s"],
"RunCharset" => [3, "s"],
"CycleCharset" => [4, "s"],
"SurfCharset" => [5, "s"],
"DiveCharset" => [6, "s"],
"FishCharset" => [7, "s"],
"SurfFishCharset" => [8, "s"],
"Home" => [9, "vuuu"]
"SectionName" => [:id, "u"],
"TrainerType" => [:trainer_type, "e", :TrainerType],
"WalkCharset" => [:walk_charset, "s"],
"RunCharset" => [:run_charset, "s"],
"CycleCharset" => [:cycle_charset, "s"],
"SurfCharset" => [:surf_charset, "s"],
"DiveCharset" => [:dive_charset, "s"],
"FishCharset" => [:fish_charset, "s"],
"SurfFishCharset" => [:surf_fish_charset, "s"],
"Home" => [:home, "vuuu"]
}
extend ClassMethodsIDNumbers

View File

@@ -28,28 +28,29 @@ module GameData
DATA_FILENAME = "map_metadata.dat"
SCHEMA = {
"Name" => [1, "s"],
"Outdoor" => [2, "b"],
"ShowArea" => [3, "b"],
"Bicycle" => [4, "b"],
"BicycleAlways" => [5, "b"],
"HealingSpot" => [6, "vuu"],
"Weather" => [7, "eu", :Weather],
"MapPosition" => [8, "uuu"],
"DiveMap" => [9, "v"],
"DarkMap" => [10, "b"],
"SafariMap" => [11, "b"],
"SnapEdges" => [12, "b"],
"Dungeon" => [13, "b"],
"BattleBack" => [14, "s"],
"WildBattleBGM" => [15, "s"],
"TrainerBattleBGM" => [16, "s"],
"WildVictoryBGM" => [17, "s"],
"TrainerVictoryBGM" => [18, "s"],
"WildCaptureME" => [19, "s"],
"MapSize" => [20, "us"],
"Environment" => [21, "e", :Environment],
"Flags" => [22, "*s"]
"SectionName" => [:id, "u"],
"Name" => [:real_name, "s"],
"Outdoor" => [:outdoor_map, "b"],
"ShowArea" => [:announce_location, "b"],
"Bicycle" => [:can_bicycle, "b"],
"BicycleAlways" => [:always_bicycle, "b"],
"HealingSpot" => [:teleport_destination, "vuu"],
"Weather" => [:weather, "eu", :Weather],
"MapPosition" => [:town_map_position, "uuu"],
"DiveMap" => [:dive_map_id, "v"],
"DarkMap" => [:dark_map, "b"],
"SafariMap" => [:safari_map, "b"],
"SnapEdges" => [:snap_edges, "b"],
"Dungeon" => [:random_dungeon, "b"],
"BattleBack" => [:battle_background, "s"],
"WildBattleBGM" => [:wild_battle_BGM, "s"],
"TrainerBattleBGM" => [:trainer_battle_BGM, "s"],
"WildVictoryBGM" => [:wild_victory_BGM, "s"],
"TrainerVictoryBGM" => [:trainer_victory_BGM, "s"],
"WildCaptureME" => [:wild_capture_ME, "s"],
"MapSize" => [:town_map_size, "us"],
"Environment" => [:battle_environment, "e", :Environment],
"Flags" => [:flags, "*s"]
}
extend ClassMethodsIDNumbers
@@ -84,7 +85,7 @@ module GameData
def initialize(hash)
@id = hash[:id]
@real_name = hash[:name]
@real_name = hash[:real_name]
@outdoor_map = hash[:outdoor_map]
@announce_location = hash[:announce_location]
@can_bicycle = hash[:can_bicycle]

View File

@@ -15,8 +15,8 @@ module GameData
DATA_FILENAME = "dungeon_tilesets.dat"
SCHEMA = {
"Autotile" => [:autotile, "us"],
"Tile" => [:tile, "us"],
"Autotile" => [:autotile, "um"],
"Tile" => [:tile, "um"],
"SnapToLargeGrid" => [:snap_to_large_grid, "b"],
"LargeVoidTiles" => [:large_void_tiles, "b"],
"LargeWallTiles" => [:large_wall_tiles, "b"],
@@ -56,7 +56,7 @@ module GameData
[hash[:autotile], hash[:tile]].each_with_index do |array, i|
array.each do |tile_info|
next if !tile_info
tile_type = tile_info[1].downcase.to_sym
tile_type = tile_info[1]
if tile_type == :walls
if @double_walls
if @large_wall_tiles

View File

@@ -30,12 +30,13 @@ module GameData
DATA_FILENAME = "dungeon_parameters.dat"
SCHEMA = {
"SectionName" => [:id, "mV"],
"DungeonSize" => [:dungeon_size, "vv"],
"CellSize" => [:cell_size, "vv"],
"MinRoomSize" => [:min_room_size, "vv"],
"MaxRoomSize" => [:max_room_size, "vv"],
"CorridorWidth" => [:corridor_width, "v"],
"ShiftCorridors" => [:shift_corridors, "b"],
"ShiftCorridors" => [:random_corridor_shift, "b"],
"NodeLayout" => [:node_layout, "s"],
"RoomLayout" => [:room_layout, "s"],
"RoomChance" => [:room_chance, "v"],
@@ -76,7 +77,7 @@ module GameData
@room_max_width = (hash[:max_room_size]) ? hash[:max_room_size][0] : @cell_width - 1
@room_max_height = (hash[:max_room_size]) ? hash[:max_room_size][1] : @cell_height - 1
@corridor_width = hash[:corridor_width] || 2
@random_corridor_shift = hash[:shift_corridors]
@random_corridor_shift = hash[:random_corridor_shift]
@node_layout = hash[:node_layout]&.downcase&.to_sym || :full
@room_layout = hash[:room_layout]&.downcase&.to_sym || :full
@room_chance = hash[:room_chance] || 70

View File

@@ -129,7 +129,10 @@ module Compiler
yield lastsection, sectionname if havesection
end
# Used for types.txt, pokemon.txt, battle_facility_lists.txt and Battle Tower trainers PBS files
# Used for types.txt, abilities.txt, moves.txt, items.txt, berry_plants.txt,
# pokemon.txt, pokemon_forms.txt, pokemon_metrics.txt, shadow_pokemon.txt,
# ribbons.txt, trainer_types.txt, battle_facility_lists.txt, Battle Tower
# trainers PBS files and dungeon_parameters.txt
def pbEachFileSection(f)
pbEachFileSectionEx(f) { |section, name|
yield section, name if block_given? && name[/^.+$/]
@@ -143,14 +146,7 @@ module Compiler
}
end
# Used for pokemon_forms.txt
def pbEachFileSectionPokemonForms(f)
pbEachFileSectionEx(f) { |section, name|
yield section, name if block_given? && name[/^\w+[-,\s]{1}\d+$/]
}
end
# Used for phone.txt
# Unused
def pbEachSection(f)
lineno = 1
havesection = false
@@ -193,7 +189,7 @@ module Compiler
}
end
# Used for many PBS files
# Used for town_map.txt and Battle Tower Pokémon PBS files
def pbCompilerEachCommentedLine(filename)
File.open(filename, "rb") { |f|
FileLineData.file = filename
@@ -226,7 +222,8 @@ module Compiler
}
end
# Used for map_connections.txt, abilities.txt, moves.txt, regional_dexes.txt
# Used for map_connections.txt, phone.txt, regional_dexes.txt, encounters.txt,
# trainers.txt and dungeon_tilesets.txt
def pbCompilerEachPreppedLine(filename)
File.open(filename, "rb") { |f|
FileLineData.file = filename
@@ -519,6 +516,21 @@ module Compiler
subrecord.push(rec)
rec = ""
end
when "m" # Symbol
field = csvfield!(rec)
if !field[/^(?![0-9])\w+$/]
raise _INTL("Field '{1}' must contain only letters, digits, and\r\nunderscores and can't begin with a number.\r\n{2}", field, FileLineData.linereport)
end
subrecord.push(field.to_sym)
when "M" # Optional symbol
field = csvfield!(rec)
if nil_or_empty?(field)
subrecord.push(nil)
elsif !field[/^(?![0-9])\w+$/]
raise _INTL("Field '{1}' must contain only letters, digits, and\r\nunderscores and can't begin with a number.\r\n{2}", field, FileLineData.linereport)
else
subrecord.push(field.to_sym)
end
when "e" # Enumerable
subrecord.push(csvEnumField!(rec, schema[2 + i - start], "", FileLineData.linereport))
when "E" # Optional enumerable
@@ -548,7 +560,7 @@ module Compiler
break if repeat && nil_or_empty?(rec)
break unless repeat
end
return (schema[1].length == 1) ? record[0] : record
return (!repeat && schema[1].length == 1) ? record[0] : record
end
#=============================================================================

File diff suppressed because it is too large Load Diff

View File

@@ -812,8 +812,7 @@ module Compiler
f.write("[0]\r\n")
metadata = GameData::Metadata.get
schema = GameData::Metadata::SCHEMA
keys = schema.keys.sort { |a, b| schema[a][0] <=> schema[b][0] }
keys.each do |key|
schema.keys.each do |key|
record = metadata.property_from_string(key)
next if record.nil? || (record.is_a?(Array) && record.empty?)
f.write(sprintf("%s = ", key))
@@ -822,11 +821,10 @@ module Compiler
end
# Write player metadata
schema = GameData::PlayerMetadata::SCHEMA
keys = schema.keys.sort { |a, b| schema[a][0] <=> schema[b][0] }
GameData::PlayerMetadata.each do |player_data|
f.write("\#-------------------------------\r\n")
f.write(sprintf("[%d]\r\n", player_data.id))
keys.each do |key|
schema.keys.each do |key|
record = player_data.property_from_string(key)
next if record.nil? || (record.is_a?(Array) && record.empty?)
f.write(sprintf("%s = ", key))
@@ -845,7 +843,6 @@ module Compiler
write_pbs_file_message_start(path)
map_infos = pbLoadMapInfos
schema = GameData::MapMetadata::SCHEMA
keys = schema.keys.sort { |a, b| schema[a][0] <=> schema[b][0] }
File.open(path, "wb") { |f|
idx = 0
add_PBS_header_to_file(f)
@@ -861,7 +858,7 @@ module Compiler
else
f.write(sprintf("[%03d]\r\n", map_data.id))
end
keys.each do |key|
schema.keys.each do |key|
record = map_data.property_from_string(key)
next if record.nil? || (record.is_a?(Array) && record.empty?)
f.write(sprintf("%s = ", key))