Avoid try/catch for settings.

We can just test for the presence of these settings nicely here,
no need to use a try / catch construct.
This commit is contained in:
Auke Kok 2016-03-07 20:23:34 -08:00 committed by est31
parent 4e59fcf5c1
commit dc8bf4e928

View File

@ -776,19 +776,13 @@ void ServerEnvironment::loadMeta()
throw SerializationError("Couldn't load env meta game_time"); throw SerializationError("Couldn't load env meta game_time");
} }
try { setTimeOfDay(args.exists("time_of_day") ?
setTimeOfDay(args.getU64("time_of_day")); // set day to morning by default
} catch (SettingNotFoundException &e) { args.getU64("time_of_day") : 9000);
// This is not as important
setTimeOfDay(9000);
}
try { m_last_clear_objects_time = args.exists("last_clear_objects_time") ?
m_last_clear_objects_time = args.getU64("last_clear_objects_time");
} catch (SettingNotFoundException &e) {
// If missing, do as if clearObjects was never called // If missing, do as if clearObjects was never called
m_last_clear_objects_time = 0; args.getU64("last_clear_objects_time") : 0;
}
std::string lbm_introduction_times = ""; std::string lbm_introduction_times = "";
try { try {
@ -804,12 +798,8 @@ void ServerEnvironment::loadMeta()
} }
m_lbm_mgr.loadIntroductionTimes(lbm_introduction_times, m_gamedef, m_game_time); m_lbm_mgr.loadIntroductionTimes(lbm_introduction_times, m_gamedef, m_game_time);
try { m_day_count = args.exists("day_count") ?
m_day_count = args.getU64("day_count"); args.getU64("day_count") : 0;
} catch (SettingNotFoundException &e) {
// If missing, start the day counter
m_day_count = 0;
}
} }
void ServerEnvironment::loadDefaultMeta() void ServerEnvironment::loadDefaultMeta()