The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
settings.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * @file
17  * General settings and defaults for scenarios.
18  */
19 
20 #include "global.hpp"
21 
22 #include "settings.hpp"
23 
25 #include "util.hpp"
26 
27 namespace settings {
28 
30 {
31  // Special case, -1 is also allowed, which means unlimited turns
32  int val = lexical_cast_default<int>(value);
33 
34  if(val == -1) {
35  return turns_max;
36  }
37 
38  return lexical_cast_in_range<int>
40 }
41 
43 {
44  return lexical_cast_in_range<int>(value, ((classification && !classification->is_normal_mp_game()) ? 1 : 2), 1, 5);
45 }
46 
48 {
49  return lexical_cast_in_range<int>(value, 1, 0, 4);
50 }
51 
53 {
54  return lexical_cast_in_range<int>(value, 70, 30, 200);
55 }
56 
57 } // end namespace settings
58 
const int turns_max
maximum number of turns
Definition: settings.hpp:46
game_classification * classification
Definition: resources.cpp:37
int get_village_gold(const std::string &value, const game_classification *classification)
Gets the village gold.
Definition: settings.cpp:42
GLuint const GLfloat * val
Definition: glew.h:2614
const int turns_default
default number of turns
Definition: settings.hpp:47
int get_village_support(const std::string &value)
Gets the village unit level support.
Definition: settings.cpp:47
General settings and defaults for scenarios.
GLsizei const GLfloat * value
Definition: glew.h:1817
Templates and utility-routines for strings and numbers.
Contains the general settings which have a default.
Definition: settings.cpp:27
int get_xp_modifier(const std::string &value)
Gets the xp modifier.
Definition: settings.cpp:52
const int turns_min
minimum number of turns
Definition: settings.hpp:45
int get_turns(const std::string &value)
Gets the number of turns.
Definition: settings.cpp:29
GLsizei const GLcharARB ** string
Definition: glew.h:4503