settings.cpp

Go to the documentation of this file.
00001 /* $Id: settings.cpp 26358 2008-05-03 13:51:13Z mordante $ */
00002 /*
00003    Copyright (C) 2007 - 2008 by Mark de Wever <koraq@xs4all.nl>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License version 2
00008    or at your option any later version.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011 
00012    See the COPYING file for more details.
00013 */
00014 
00015 //! @file src/settings.cpp
00016 //! General settings and defaults for scenarios.
00017 
00018 #include "global.hpp"
00019 
00020 #include "settings.hpp"
00021 
00022 #include "serialization/string_utils.hpp"
00023 #include "util.hpp"
00024 
00025 namespace settings {
00026 
00027 int get_turns(const std::string& value)
00028 {
00029     // Special case, -1 is also allowed, which means unlimited turns
00030     int val = lexical_cast_default<int>(value);
00031 
00032     if(val == -1) {
00033         return turns_max;
00034     }
00035 
00036     return lexical_cast_in_range<int>
00037         (value, turns_default, turns_min, turns_max);
00038 }
00039 
00040 int get_village_gold(const std::string& value)
00041 {
00042     return lexical_cast_in_range<int>(value, 2, 1, 5);
00043 }
00044 
00045 int get_xp_modifier(const std::string& value)
00046 {
00047     return lexical_cast_in_range<int>(value, 70, 30, 200);
00048 }
00049 
00050 bool use_fog(const std::string& value)
00051 {
00052     return utils::string_bool(value, false);
00053 }
00054 
00055 bool use_random_start_time(const std::string& value)
00056 {
00057     return utils::string_bool(value, false);
00058 }
00059 
00060 bool use_shroud(const std::string& value)
00061 {
00062     return utils::string_bool(value, false);
00063 }
00064 
00065 } // end namespace settings
00066 

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs