summaryrefslogtreecommitdiff
path: root/src/environment.cpp
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2014-09-11 18:22:05 -0400
committerShadowNinja <shadowninja@minetest.net>2014-09-21 14:39:35 -0400
commit6bc4cad0eddd7a7cf593ca1471599e2d75727379 (patch)
treed05d5f039648d18f49fc0cf56132b2e9a5c88e09 /src/environment.cpp
parent2ae5d3f3abc7ac5ee96c4dfc7eeead045fdc775e (diff)
downloadminetest-6bc4cad0eddd7a7cf593ca1471599e2d75727379.tar.gz
minetest-6bc4cad0eddd7a7cf593ca1471599e2d75727379.tar.bz2
minetest-6bc4cad0eddd7a7cf593ca1471599e2d75727379.zip
Split settings into seperate source and header files
This also cleans up settings a bit
Diffstat (limited to 'src/environment.cpp')
-rw-r--r--src/environment.cpp33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/environment.cpp b/src/environment.cpp
index c8af72f6b..66898f012 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -508,38 +508,29 @@ void ServerEnvironment::loadMeta()
// Open file and deserialize
std::ifstream is(path.c_str(), std::ios_base::binary);
- if(is.good() == false)
- {
- infostream<<"ServerEnvironment::loadMeta(): Failed to open "
- <<path<<std::endl;
+ if (!is.good()) {
+ infostream << "ServerEnvironment::loadMeta(): Failed to open "
+ << path << std::endl;
throw SerializationError("Couldn't load env meta");
}
Settings args;
-
- for(;;)
- {
- if(is.eof())
- throw SerializationError
- ("ServerEnvironment::loadMeta(): EnvArgsEnd not found");
- std::string line;
- std::getline(is, line);
- std::string trimmedline = trim(line);
- if(trimmedline == "EnvArgsEnd")
- break;
- args.parseConfigLine(line);
+
+ if (!args.parseConfigLines(is, "EnvArgsEnd")) {
+ throw SerializationError("ServerEnvironment::loadMeta(): "
+ "EnvArgsEnd not found!");
}
-
- try{
+
+ try {
m_game_time = args.getU64("game_time");
- }catch(SettingNotFoundException &e){
+ } catch (SettingNotFoundException &e) {
// Getting this is crucial, otherwise timestamps are useless
throw SerializationError("Couldn't load env meta game_time");
}
- try{
+ try {
m_time_of_day = args.getU64("time_of_day");
- }catch(SettingNotFoundException &e){
+ } catch (SettingNotFoundException &e) {
// This is not as important
m_time_of_day = 9000;
}