move high-level map-creation utility functions out of mapgen

This commit is contained in:
Yann Dirson 2005-03-05 16:07:54 +00:00
parent b08827faf8
commit ebea6ceb28
6 changed files with 7 additions and 50 deletions

View file

@ -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 \

View file

@ -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"

View file

@ -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)

View file

@ -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,

View file

@ -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"

View file

@ -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"