mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Split metadata.txt into metadata.txt and map_metadata.txt, fixed bug when writing certain PBS files
This commit is contained in:
@@ -1397,22 +1397,22 @@ module Compiler
|
||||
#=============================================================================
|
||||
def compile_metadata(path = "PBS/metadata.txt")
|
||||
GameData::Metadata::DATA.clear
|
||||
GameData::MapMetadata::DATA.clear
|
||||
GameData::PlayerMetadata::DATA.clear
|
||||
# Read from PBS file
|
||||
File.open(path, "rb") { |f|
|
||||
FileLineData.file = path # For error reporting
|
||||
# Read a whole section's lines at once, then run through this code.
|
||||
# contents is a hash containing all the XXX=YYY lines in that section, where
|
||||
# the keys are the XXX and the values are the YYY (as unprocessed strings).
|
||||
pbEachFileSectionNumbered(f) { |contents, map_id|
|
||||
schema = (map_id == 0) ? GameData::Metadata::SCHEMA : GameData::MapMetadata::SCHEMA
|
||||
pbEachFileSectionNumbered(f) { |contents, section_id|
|
||||
schema = (section_id == 0) ? GameData::Metadata::SCHEMA : GameData::PlayerMetadata::SCHEMA
|
||||
# Go through schema hash of compilable data and compile this section
|
||||
for key in schema.keys
|
||||
FileLineData.setSection(map_id, key, contents[key]) # For error reporting
|
||||
FileLineData.setSection(section_id, key, contents[key]) # For error reporting
|
||||
# Skip empty properties, or raise an error if a required property is
|
||||
# empty
|
||||
if contents[key].nil?
|
||||
if map_id == 0 && ["Home", "PlayerA"].include?(key)
|
||||
if section_id == 0 && ["Home"].include?(key)
|
||||
raise _INTL("The entry {1} is required in {2} section 0.", key, path)
|
||||
end
|
||||
next
|
||||
@@ -1422,10 +1422,10 @@ module Compiler
|
||||
value = nil if value.is_a?(Array) && value.length == 0
|
||||
contents[key] = value
|
||||
end
|
||||
if map_id == 0 # Global metadata
|
||||
if section_id == 0 # Metadata
|
||||
# Construct metadata hash
|
||||
metadata_hash = {
|
||||
:id => map_id,
|
||||
:id => section_id,
|
||||
:home => contents["Home"],
|
||||
:wild_battle_BGM => contents["WildBattleBGM"],
|
||||
:trainer_battle_BGM => contents["TrainerBattleBGM"],
|
||||
@@ -1433,51 +1433,90 @@ module Compiler
|
||||
:trainer_victory_ME => contents["TrainerVictoryME"],
|
||||
:wild_capture_ME => contents["WildCaptureME"],
|
||||
:surf_BGM => contents["SurfBGM"],
|
||||
:bicycle_BGM => contents["BicycleBGM"],
|
||||
:player_A => contents["PlayerA"],
|
||||
:player_B => contents["PlayerB"],
|
||||
:player_C => contents["PlayerC"],
|
||||
:player_D => contents["PlayerD"],
|
||||
:player_E => contents["PlayerE"],
|
||||
:player_F => contents["PlayerF"],
|
||||
:player_G => contents["PlayerG"],
|
||||
:player_H => contents["PlayerH"]
|
||||
:bicycle_BGM => contents["BicycleBGM"]
|
||||
}
|
||||
# Add metadata's data to records
|
||||
GameData::Metadata.register(metadata_hash)
|
||||
else # Map metadata
|
||||
else # Player metadata
|
||||
# Construct metadata hash
|
||||
metadata_hash = {
|
||||
:id => map_id,
|
||||
:outdoor_map => contents["Outdoor"],
|
||||
:announce_location => contents["ShowArea"],
|
||||
:can_bicycle => contents["Bicycle"],
|
||||
:always_bicycle => contents["BicycleAlways"],
|
||||
:teleport_destination => contents["HealingSpot"],
|
||||
:weather => contents["Weather"],
|
||||
:town_map_position => contents["MapPosition"],
|
||||
:dive_map_id => contents["DiveMap"],
|
||||
:dark_map => contents["DarkMap"],
|
||||
:safari_map => contents["SafariMap"],
|
||||
:snap_edges => contents["SnapEdges"],
|
||||
:random_dungeon => contents["Dungeon"],
|
||||
:battle_background => contents["BattleBack"],
|
||||
:wild_battle_BGM => contents["WildBattleBGM"],
|
||||
:trainer_battle_BGM => contents["TrainerBattleBGM"],
|
||||
:wild_victory_ME => contents["WildVictoryME"],
|
||||
:trainer_victory_ME => contents["TrainerVictoryME"],
|
||||
:wild_capture_ME => contents["WildCaptureME"],
|
||||
:town_map_size => contents["MapSize"],
|
||||
:battle_environment => contents["Environment"],
|
||||
:flags => contents["Flags"]
|
||||
:id => section_id,
|
||||
:trainer_type => contents["TrainerType"],
|
||||
:walk_charset => contents["WalkCharset"],
|
||||
:run_charset => contents["RunCharset"],
|
||||
:cycle_charset => contents["CycleCharset"],
|
||||
:surf_charset => contents["SurfCharset"],
|
||||
:dive_charset => contents["DiveCharset"],
|
||||
:fish_charset => contents["FishCharset"],
|
||||
:surf_fish_charset => contents["SurfFishCharset"]
|
||||
}
|
||||
# Add metadata's data to records
|
||||
GameData::MapMetadata.register(metadata_hash)
|
||||
GameData::PlayerMetadata.register(metadata_hash)
|
||||
end
|
||||
}
|
||||
}
|
||||
if !GameData::PlayerMetadata.exists?(1)
|
||||
raise _INTL("Metadata for player character 1 in {1} is not defined but should be.", path)
|
||||
end
|
||||
# Save all data
|
||||
GameData::Metadata.save
|
||||
GameData::PlayerMetadata.save
|
||||
Graphics.update
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
# Compile map metadata
|
||||
#=============================================================================
|
||||
def compile_map_metadata(path = "PBS/map_metadata.txt")
|
||||
GameData::MapMetadata::DATA.clear
|
||||
# Read from PBS file
|
||||
File.open(path, "rb") { |f|
|
||||
FileLineData.file = path # For error reporting
|
||||
# Read a whole section's lines at once, then run through this code.
|
||||
# contents is a hash containing all the XXX=YYY lines in that section, where
|
||||
# the keys are the XXX and the values are the YYY (as unprocessed strings).
|
||||
schema = GameData::MapMetadata::SCHEMA
|
||||
pbEachFileSectionNumbered(f) { |contents, map_id|
|
||||
# Go through schema hash of compilable data and compile this section
|
||||
for key in schema.keys
|
||||
FileLineData.setSection(map_id, key, contents[key]) # For error reporting
|
||||
# Skip empty properties
|
||||
next if contents[key].nil?
|
||||
# Compile value for key
|
||||
value = pbGetCsvRecord(contents[key], key, schema[key])
|
||||
value = nil if value.is_a?(Array) && value.length == 0
|
||||
contents[key] = value
|
||||
end
|
||||
# Construct map metadata hash
|
||||
metadata_hash = {
|
||||
:id => map_id,
|
||||
:outdoor_map => contents["Outdoor"],
|
||||
:announce_location => contents["ShowArea"],
|
||||
:can_bicycle => contents["Bicycle"],
|
||||
:always_bicycle => contents["BicycleAlways"],
|
||||
:teleport_destination => contents["HealingSpot"],
|
||||
:weather => contents["Weather"],
|
||||
:town_map_position => contents["MapPosition"],
|
||||
:dive_map_id => contents["DiveMap"],
|
||||
:dark_map => contents["DarkMap"],
|
||||
:safari_map => contents["SafariMap"],
|
||||
:snap_edges => contents["SnapEdges"],
|
||||
:random_dungeon => contents["Dungeon"],
|
||||
:battle_background => contents["BattleBack"],
|
||||
:wild_battle_BGM => contents["WildBattleBGM"],
|
||||
:trainer_battle_BGM => contents["TrainerBattleBGM"],
|
||||
:wild_victory_ME => contents["WildVictoryME"],
|
||||
:trainer_victory_ME => contents["TrainerVictoryME"],
|
||||
:wild_capture_ME => contents["WildCaptureME"],
|
||||
:town_map_size => contents["MapSize"],
|
||||
:battle_environment => contents["Environment"],
|
||||
:flags => contents["Flags"]
|
||||
}
|
||||
# Add map metadata's data to records
|
||||
GameData::MapMetadata.register(metadata_hash)
|
||||
}
|
||||
}
|
||||
# Save all data
|
||||
GameData::MapMetadata.save
|
||||
Graphics.update
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user