MP: fix ambiguous case of config attribute used as bool

It's honestly not entirely clear what the right behavior is here. The way it is, to_bool is implicitly being invoked, which, given that this is supposed to hold an int, would always return false. And checking the int value doesn't seem to make sense either, since that would only exclude turns=0 (which would be a dumb value, but I'm not sure that's what this is for. So I figured a 'has attribute' check is best.
This commit is contained in:
Charles Dang 2024-07-31 22:47:01 -04:00
parent 18b9bf7c23
commit 159998b80c

View file

@ -762,7 +762,7 @@ void start_local_game_commandline(const commandline_options& cmdline_opts)
state.expand_mp_options();
// Should number of turns be determined from scenario data?
if(parameters.use_map_settings && state.get_starting_point()["turns"]) {
if(parameters.use_map_settings && state.get_starting_point().has_attribute("turns")) {
DBG_MP << "setting turns from scenario data: " << state.get_starting_point()["turns"];
parameters.num_turns = state.get_starting_point()["turns"];
}