Beispiel #1
0
WORLDPTR worldfactory::convert_to_world(std::string origin_path)
{
    // prompt for worldname? Nah, just make a worldname... the user can fix it later if they really don't want this as a name...
    std::string worldname = get_next_valid_worldname();

    // check and loop on validity

    // create world informations
    WORLDPTR newworld = new WORLD();
    newworld->world_name = worldname;

    std::stringstream path;
    path << FILENAMES["savedir"] << worldname;
    newworld->world_path = path.str();

    // save world as conversion world
    if (save_world(newworld, true)) {
        // move files from origin_path into new world path
        for( auto &origin_file : get_files_from_path(".", origin_path, false) ) {
            std::string filename = origin_file.substr( origin_file.find_last_of( "/\\" ) );

            rename( origin_file.c_str(), std::string( newworld->world_path + filename ).c_str() );
        }

        DebugLog( D_INFO, DC_ALL ) << "worldfactory::convert_to_world -- World Converted Successfully!";
        return newworld;
    } else {
        // something horribly wrong happened
        DebugLog( D_ERROR, DC_ALL ) << "worldfactory::convert_to_world -- World Conversion Failed!";
        return NULL;
    }
}
WORLDPTR worldfactory::convert_to_world(std::string origin_path)
{
    // prompt for worldname? Nah, just make a worldname... the user can fix it later if they really don't want this as a name...
    std::string worldname = get_next_valid_worldname("ConvWorld", this);

    // check and loop on validity

    // create world informations
    WORLDPTR newworld = new WORLD();
    newworld->world_name = worldname;

    std::stringstream path;
    path << SAVE_DIR << PATH_SEPARATOR << worldname;
    newworld->world_path = path.str();

    // save world as conversion world
    if (save_world(newworld, true)) {
        // move files from origin_path into new world path
        std::vector<std::string> origin_files = file_finder::get_files_from_path(".", origin_path, false);
        for (unsigned i = 0; i < origin_files.size(); ++i) {
            std::string filename = origin_files[i].substr(origin_files[i].find_last_of("/\\"));

            rename(origin_files[i].c_str(), std::string(newworld->world_path + filename).c_str());
        }

        DebugLog() << "worldfactory::convert_to_world -- World Converted Successfully!\n";
        return newworld;
    } else {
        // something horribly wrong happened
        DebugLog() << "worldfactory::convert_to_world -- World Conversion Failed!\n";
        return NULL;
    }
}
WORLD::WORLD()
{
    world_name = get_next_valid_worldname();
    std::stringstream path;
    path << FILENAMES["savedir"] << world_name;
    world_path = path.str();
    world_options.clear();
    for (auto it = OPTIONS.begin(); it != OPTIONS.end(); ++it) {
        if (it->second.getPage() == "world_default") {
            world_options[it->first] = it->second;
        }
    }
    world_saves.clear();
    active_mod_order = world_generator->get_mod_manager()->get_default_mods();
}
WORLD::WORLD()
{
    world_name = get_next_valid_worldname();
    std::stringstream path;
    path << SAVE_DIR << PATH_SEPARATOR << world_name;
    world_path = path.str();
    world_options.clear();
    for (std::map<std::string, cOpt>::iterator it = OPTIONS.begin(); it != OPTIONS.end(); ++it) {
        if (it->second.getPage() == "world_default") {
            world_options[it->first] = it->second;
        }
    }
    world_saves.clear();
    active_mod_order = world_generator->get_mod_manager()->get_default_mods();
}
Beispiel #5
0
WORLD::WORLD()
{
    world_name = get_next_valid_worldname();
    std::stringstream path;
    path << FILENAMES["savedir"] << world_name;
    world_path = path.str();
    world_options.clear();

    for( auto &elem : OPTIONS ) {
        if( elem.second.getPage() == "world_default" ) {
            world_options[elem.first] = elem.second;
        }
    }

    world_saves.clear();
    active_mod_order = world_generator->get_mod_manager()->get_default_mods();
}
Beispiel #6
0
std::string worldfactory::pick_random_name()
{
    // TODO: add some random worldname parameters to name generator
    return get_next_valid_worldname();
}