The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
map_generator.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[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  * Map-generator, with standalone testprogram.
18  */
19 
20 #include "global.hpp"
21 #include "map_generator.hpp"
22 
23 #include "config.hpp"
24 #include "gettext.hpp"
25 #include "log.hpp"
26 
27 static lg::log_domain log_mapgen("mapgen");
28 #define ERR_NG LOG_STREAM(err, log_mapgen)
29 #define LOG_NG LOG_STREAM(info, log_mapgen)
30 
31 config map_generator::create_scenario(boost::optional<boost::uint32_t> randomseed)
32 {
33  config res;
34  res["map_data"] = create_map(randomseed);
35  return res;
36 }
37 /**
38  by default we don't allow user configs.
39 */
41 {
42  return false;
43 }
44 
46 {
47 }
48 
49 #ifdef TEST_MAPGEN
50 
51 /** Standalone testprogram for the mapgenerator. */
52 int main(int argc, char** argv)
53 {
54  int x = 50, y = 50, iterations = 50,
55  hill_size = 50, lakes=3,
56  nvillages = 25, nplayers = 2;
57  if(argc >= 2) {
58  x = std::stoi(argv[1]);
59  }
60 
61  if(argc >= 3) {
62  y = std::stoi(argv[2]);
63  }
64 
65  if(argc >= 4) {
66  iterations = std::stoi(argv[3]);
67  }
68 
69  if(argc >= 5) {
70  hill_size = std::stoi(argv[4]);
71  }
72 
73  if(argc >= 6) {
74  lakes = std::stoi(argv[5]);
75  }
76 
77  if(argc >= 7) {
78  nvillages = std::stoi(argv[6]);
79  }
80 
81  if(argc >= 8) {
82  nplayers = std::stoi(argv[7]);
83  }
84 
85  srand(time(nullptr));
86  std::cout << generate_map(x,y,iterations,hill_size,lakes,nvillages,nplayers) << "\n";
87 }
88 
89 #endif
virtual bool allow_user_config() const
Returns true if the map generator has an interactive screen, which allows the user to modify how the ...
Definition: video.hpp:58
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1220
virtual config create_scenario(boost::optional< boost::uint32_t > randomseed=boost::none)
Definitions for the interface to Wesnoth Markup Language (WML).
virtual std::string create_map(boost::optional< boost::uint32_t > randomseed=boost::none)=0
Creates a new map and returns it.
GLuint res
Definition: glew.h:9258
GLint GLint GLint GLint GLint x
Definition: glew.h:1220
int main(int argc, char **argv)
static lg::log_domain log_mapgen("mapgen")
Standard logging facilities (interface).
virtual void user_config(CVideo &v)
Display the interactive screen, which allows the user to modify how the generator behaves...
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83