diff options
Diffstat (limited to 'advtrains/path.lua')
0 files changed, 0 insertions, 0 deletions
/*
Minetest
Copyright (C) 2010-2015 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2013-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
Copyright (C) 2015-2017 paramat
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "mapgen.h"
#include "voxel.h"
#include "noise.h"
#include "gamedef.h"
#include "mg_biome.h"
#include "mapblock.h"
#include "mapnode.h"
#include "map.h"
#include "content_sao.h"
#include "nodedef.h"
#include "emerge.h"
#include "voxelalgorithms.h"
#include "porting.h"
#include "profiler.h"
#include "settings.h"
#include "treegen.h"
#include "serialization.h"
#include "util/serialize.h"
#include "util/numeric.h"
#include "filesys.h"
#include "log.h"
#include "mapgen_flat.h"
#include "mapgen_fractal.h"
#include "mapgen_v5.h"
#include "mapgen_v6.h"
#include "mapgen_v7.h"
#include "mapgen_valleys.h"
#include "mapgen_singlenode.h"
#include "cavegen.h"
#include "dungeongen.h"
FlagDesc flagdesc_mapgen[] = {
{"caves", MG_CAVES},
{"dungeons", MG_DUNGEONS},
{"light", MG_LIGHT},
{"decorations", MG_DECORATIONS},
{NULL, 0}
};
FlagDesc flagdesc_gennotify[] = {
{"dungeon", 1 << GENNOTIFY_DUNGEON},
{"temple", 1 << GENNOTIFY_TEMPLE},
{"cave_begin", 1 << GENNOTIFY_CAVE_BEGIN},
{"cave_end", 1 << GENNOTIFY_CAVE_END},
{"large_cave_begin", 1 << GENNOTIFY_LARGECAVE_BEGIN},
{"large_cave_end", 1 << GENNOTIFY_LARGECAVE_END},
{"decoration", 1 << GENNOTIFY_DECORATION},
{NULL, 0}
};
struct MapgenDesc {
const char *name;
bool is_user_visible;
};
////
//// Built-in mapgens
////
static MapgenDesc g_reg_mapgens[] = {
{"v5", true},
{"v6", true},
{"v7", true},
{"flat", true},
{"fractal", true},
{"valleys", true},
{"singlenode", true},
};
STATIC_ASSERT(
ARRLEN(g_reg_mapgens) == MAPGEN_INVALID,
registered_mapgens_is_wrong_size);
////
//// Mapgen
////
Mapgen::Mapgen()
{
generating = false;
id = -1;
seed = 0;
water_level = 0;
mapgen_limit = 0;
flags = 0;
vm = NULL;
ndef = NULL;
biomegen = NULL;
biomemap = NULL;
heightmap = NULL;
}
Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge) :
gennotify(emerge->gen_notify_on, &emerge->gen_notify_on_deco_ids)
{
generating = false;
id = mapgenid;
water_level = params->water_level;
mapgen_limit = params->mapgen_limit;
flags = params->flags;
csize = v3s16(1, 1, 1) * (params->chunksize * MAP_BLOCKSIZE);
/*
We are losing half our entropy by doing this, but it is necessary to
preserve reverse compatibility. If the top half of our current 64 bit
seeds ever starts getting used, existing worlds will break due to a
different hash outcome and no way to differentiate between versions.
A solution could be to add a new bit to designate that the top half of
the seed value should be used, essentially a 1-bit version code, but
this would require increasing the total size of a seed to 9 bytes (yuck)
It's probably okay if this never gets fixed. 4.2 billion possibilities
ought to be enough for anyone.
*/
seed = (s32)params->seed;
vm = NULL;
ndef = emerge->ndef;
biomegen = NULL;
biomemap = NULL;
heightmap = NULL;
}
Mapgen::~Mapgen()
{
}
MapgenType Mapgen::getMapgenType(const std::string &mgname)
{
for (size_t i = 0; i != ARRLEN(g_reg_mapgens); i++) {
if (mgname == g_reg_mapgens[i].name)
return (MapgenType)i;
}
return MAPGEN_INVALID;
}
const char *Mapgen::getMapgenName(MapgenType mgtype)
{
size_t index = (size_t)mgtype;
if (index == MAPGEN_INVALID || index >= ARRLEN(g_reg_mapgens))
return "invalid";
return g_reg_mapgens[index].name;
}
Mapgen *Mapgen::createMapgen(MapgenType mgtype, int mgid,
MapgenParams *params, EmergeManager *emerge)
{
switch (mgtype) {
case MAPGEN_FLAT:
return new MapgenFlat(mgid, (MapgenFlatParams *)params, emerge);
case MAPGEN_FRACTAL:
return new MapgenFractal(mgid, (MapgenFractalParams *)params, emerge);
case MAPGEN_SINGLENODE:
return new MapgenSinglenode(mgid, (MapgenSinglenodeParams *)params, emerge);
case MAPGEN_V5:
return new MapgenV5(mgid, (MapgenV5Params *)params, emerge);
case MAPGEN_V6:
return new MapgenV6(mgid, (MapgenV6Params *)params, emerge);
case MAPGEN_V7:
return new MapgenV7(mgid, (MapgenV7Params *)params, emerge);
case MAPGEN_VALLEYS:
return new MapgenValleys(mgid, (MapgenValleysParams *)params, emerge);
default:
return NULL;
}
}
MapgenParams *Mapgen::createMapgenParams(MapgenType mgtype)
{