Skip to content

Commit

Permalink
support loading from tradegoods.txt aswell
Browse files Browse the repository at this point in the history
  • Loading branch information
Lizzie841 authored Jan 20, 2025
1 parent 69bfd2b commit 58b9351
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/gamestate/system_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1905,15 +1905,21 @@ void state::load_scenario_data(parsers::error_handler& err, sys::year_month_day
auto money_id = world.create_commodity();
assert(money_id.index() == 0);
}
auto goods = open_file(common, NATIVE("goods.txt"));
if(goods) {
if(auto goods = open_file(common, NATIVE("goods.txt")); goods) {
auto content = view_contents(*goods);
err.file_name = "goods.txt";
parsers::token_generator gen(content.data, content.data + content.file_size);
parsers::parse_goods_file(gen, err, context);
} else {
err.fatal = true;
err.accumulated_errors += "File common/goods.txt could not be opened\n";
if(auto goods = open_file(common, NATIVE("tradegoods")); goods) {
auto content = view_contents(*goods);
err.file_name = "tradegoods.txt";
parsers::token_generator gen(content.data, content.data + content.file_size);
parsers::parse_goods_file(gen, err, context);
} else {
err.fatal = true;
err.accumulated_errors += "File common/goods.txt nor common/tradegoods.txt could not be opened\n";
}
}
}
// read buildings.text
Expand Down

0 comments on commit 58b9351

Please sign in to comment.