summaryrefslogtreecommitdiff
path: root/src/environment.cpp
diff options
context:
space:
mode:
authorAuke Kok <sofar@foo-projects.org>2016-03-07 20:23:34 -0800
committerest31 <MTest31@outlook.com>2016-03-09 01:45:23 +0100
commitdc8bf4e9284bdc0b9367dc8dc23c394e7b5bde34 (patch)
treea94340a54f046b23c2cd3266a74dc5fc4d2a5b78 /src/environment.cpp
parent4e59fcf5c1e40dee764317a1190dceadc3a77829 (diff)
downloadminetest-dc8bf4e9284bdc0b9367dc8dc23c394e7b5bde34.tar.gz
minetest-dc8bf4e9284bdc0b9367dc8dc23c394e7b5bde34.tar.bz2
minetest-dc8bf4e9284bdc0b9367dc8dc23c394e7b5bde34.zip
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.
Diffstat (limited to 'src/environment.cpp')
-rw-r--r--src/environment.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/environment.cpp b/src/environment.cpp
index 0d00ed170..1de44e755 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -776,19 +776,13 @@ void ServerEnvironment::loadMeta()
throw SerializationError("Couldn't load env meta game_time");
}
- try {
- setTimeOfDay(args.getU64("time_of_day"));
- } catch (SettingNotFoundException &e) {
- // This is not as important
- setTimeOfDay(9000);
- }
+ setTimeOfDay(args.exists("time_of_day") ?
+ // set day to morning by default
+ args.getU64("time_of_day") : 9000);
- try {
- m_last_clear_objects_time = args.getU64("last_clear_objects_time");
- } catch (SettingNotFoundException &e) {
+ m_last_clear_objects_time = args.exists("last_clear_objects_time") ?
// 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 = "";
try {
@@ -804,12 +798,8 @@ void ServerEnvironment::loadMeta()
}
m_lbm_mgr.loadIntroductionTimes(lbm_introduction_times, m_gamedef, m_game_time);
- try {
- m_day_count = args.getU64("day_count");
- } catch (SettingNotFoundException &e) {
- // If missing, start the day counter
- m_day_count = 0;
- }
+ m_day_count = args.exists("day_count") ?
+ args.getU64("day_count") : 0;
}
void ServerEnvironment::loadDefaultMeta()