move high-level map-creation utility functions out of mapgen
This commit is contained in:
parent
b08827faf8
commit
ebea6ceb28
6 changed files with 7 additions and 50 deletions
|
@ -65,6 +65,7 @@ wesnoth_SOURCES = \
|
|||
leader_list.cpp \
|
||||
log.cpp \
|
||||
map.cpp \
|
||||
map_create.cpp \
|
||||
map_label.cpp \
|
||||
mapgen.cpp \
|
||||
mapgen_dialog.cpp \
|
||||
|
@ -154,6 +155,7 @@ wesnoth_SOURCES = \
|
|||
leader_list.hpp \
|
||||
log.hpp \
|
||||
map.hpp \
|
||||
map_create.hpp \
|
||||
map_label.hpp \
|
||||
mapgen.hpp \
|
||||
mapgen_dialog.hpp \
|
||||
|
@ -249,6 +251,7 @@ wesnoth_editor_SOURCES = \
|
|||
key.cpp \
|
||||
language.cpp \
|
||||
log.cpp \
|
||||
map_create.cpp \
|
||||
map_label.cpp \
|
||||
map.cpp \
|
||||
mapgen.cpp \
|
||||
|
@ -329,6 +332,7 @@ wesnoth_editor_SOURCES = \
|
|||
key.hpp \
|
||||
language.hpp \
|
||||
log.hpp \
|
||||
map_create.hpp \
|
||||
map_label.hpp \
|
||||
map.hpp \
|
||||
mapgen.hpp \
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "../language.hpp"
|
||||
#include "../game_config.hpp"
|
||||
#include "../mapgen.hpp"
|
||||
#include "../map_create.hpp"
|
||||
#include "../filesystem.hpp"
|
||||
#include "../font.hpp"
|
||||
#include "../events.hpp"
|
||||
|
|
|
@ -11,11 +11,9 @@
|
|||
#include <ctime>
|
||||
#include <vector>
|
||||
|
||||
#include "cavegen.hpp"
|
||||
#include "language.hpp"
|
||||
#include "log.hpp"
|
||||
#include "mapgen.hpp"
|
||||
#include "mapgen_dialog.hpp"
|
||||
#include "pathfind.hpp"
|
||||
#include "race.hpp"
|
||||
#include "scoped_resource.hpp"
|
||||
|
@ -25,38 +23,6 @@
|
|||
#define ERR_CF lg::err(lg::config)
|
||||
#define LOG_NG lg::info(lg::engine)
|
||||
|
||||
//function to generate a random map, from a string which describes
|
||||
//the generator to use and its arguments
|
||||
std::string random_generate_map(const std::string& parms, const config* cfg)
|
||||
{
|
||||
//the first token is the name of the generator, tokens after
|
||||
//that are arguments to the generator
|
||||
std::vector<std::string> parameters = utils::split(parms, ' ');
|
||||
util::scoped_ptr<map_generator> generator(create_map_generator(parameters.front(),cfg));
|
||||
if(generator == NULL) {
|
||||
ERR_CF << "could not find map generator '" << parameters.front() << "'\n";
|
||||
return std::string();
|
||||
}
|
||||
|
||||
parameters.erase(parameters.begin());
|
||||
return generator.get()->create_map(parameters);
|
||||
}
|
||||
|
||||
config random_generate_scenario(const std::string& parms, const config* cfg)
|
||||
{
|
||||
//the first token is the name of the generator, tokens after
|
||||
//that are arguments to the generator
|
||||
std::vector<std::string> parameters = utils::split(parms, ' ');
|
||||
util::scoped_ptr<map_generator> generator(create_map_generator(parameters.front(),cfg));
|
||||
if(generator == NULL) {
|
||||
ERR_CF << "could not find map generator '" << parameters.front() << "'\n";
|
||||
return config();
|
||||
}
|
||||
|
||||
parameters.erase(parameters.begin());
|
||||
return generator->create_scenario(parameters);
|
||||
}
|
||||
|
||||
config map_generator::create_scenario(const std::vector<std::string>& args)
|
||||
{
|
||||
config res;
|
||||
|
@ -1205,17 +1171,6 @@ generator_map generators;
|
|||
|
||||
}
|
||||
|
||||
map_generator* create_map_generator(const std::string& name, const config* cfg)
|
||||
{
|
||||
if(name == "default" || name == "") {
|
||||
return new default_map_generator(cfg);
|
||||
} else if(name == "cave") {
|
||||
return new cave_map_generator(cfg);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEST_MAPGEN
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
|
|
@ -6,9 +6,6 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
std::string random_generate_map(const std::string& parms, const config* cfg);
|
||||
config random_generate_scenario(const std::string& parms, const config* cfg);
|
||||
|
||||
class map_generator
|
||||
{
|
||||
public:
|
||||
|
@ -34,8 +31,6 @@ public:
|
|||
virtual config create_scenario(const std::vector<std::string>& args);
|
||||
};
|
||||
|
||||
map_generator* create_map_generator(const std::string& name, const config* cfg);
|
||||
|
||||
std::string default_generate_map(size_t width, size_t height, size_t island_size, size_t island_off_center,
|
||||
size_t iterations, size_t hill_size,
|
||||
size_t max_lakes, size_t nvillages, size_t nplayers,
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "global.hpp"
|
||||
#include "show_dialog.hpp"
|
||||
#include "map_create.hpp"
|
||||
#include "multiplayer_create.hpp"
|
||||
#include "filesystem.hpp"
|
||||
#include "preferences.hpp"
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "language.hpp"
|
||||
#include "log.hpp"
|
||||
#include "mapgen.hpp"
|
||||
#include "map_create.hpp"
|
||||
#include "network.hpp"
|
||||
#include "playlevel.hpp"
|
||||
#include "playturn.hpp"
|
||||
|
|
Loading…
Add table
Reference in a new issue