aboutsummaryrefslogtreecommitdiff
path: root/src/mg_biome.h
Commit message (Collapse)AuthorAge
* Biome API: Add per-biome riverbed material and depthparamat2016-06-05
| | | | | | Mgvalleys: Remove riverbed sand placement from base terrain generation Riverbed material placement moved to MapgenBasic::generateBiomes() Document fields and add note that the biome API is still unstable
* Biomes: Define and use biome_t for biome IDskwolekr2016-06-04
|
* Change internal type for seeds to s32kwolekr2016-06-04
| | | | | This fixes value truncation (and therefore incompatibility) on platforms with an LP32 data model, such as VAX or MS-DOS.
* Fix MgStoneType and BiomeType enum nameskwolekr2016-05-27
|
* Move biome calculation to BiomeGenkwolekr2016-05-27
| | | | | | | BiomeGen defines an interface that, given a set of BiomeParams, computes biomes for a given area using the algorithm implemented by that specific BiomeGen. This abstracts away the old system where each mapgen supplied the noises required for biome generation.
* Split ObjDef/ObjDefManager out to objdef.cppkwolekr2015-05-18
|
* Biome API: Add biome-specific river waterparamat2015-04-19
|
* Schematics: Remove referenced schematics from Decorations on clearkwolekr2015-04-17
|
* Biomes: Remove referenced biomes from Decorations on clearkwolekr2015-04-16
|
* Schematics: Refactor NodeResolver and add NodeResolveMethodkwolekr2015-04-16
| | | | | | | | | NodeResolver name lists now belong to the NodeResolver object instead of the associated NodeDefManager. In addition to minimizing unnecessary abstraction and overhead, this move permits NodeResolvers to look up nodes that they had previously set pending for resolution. So far, this functionality has been used in the case of schematics for serialization/deserialization.
* ObjDefManager, Mapgen SAPI: Huge refactoringkwolekr2015-03-31
| | | | | | | - General code cleanup - Unified object creation and loading - Specifying objects in APIs is now orthogonal (i.e. anything can take an ID, name string, or the raw table definition (and automatically registers if present
* GenElementManager: Pass opaque handles to Lua and rename to ObjDefManagerkwolekr2015-03-31
| | | | Add core.clear_registered_schematics() and refactor schematics somewhat
* Biome API: Re-calculate biome at every surface in a mapchunk columnparamat2015-02-26
|
* Replace instances of height_min/height_max with y_min/y_max to remove ambiguitykwolekr2014-12-30
|
* Biome API: Add shore top and shore filler nodes, underwater node, water top ↵paramat2014-12-28
| | | | node. Add water top depth and shore height parameters. Remove water dust node
* Redefine NodeResolver interface and replace with callback mechanismkwolekr2014-12-27
|
* Add minetest.clear_registered_decorations() and clear_registered_ores()kwolekr2014-12-12
|
* Biomes: Make biome heat and humidity noise parameters user-configurablekwolekr2014-12-09
|
* Add minetest.clear_registered_biomes() apikwolekr2014-12-06
|
* Add definable node_stone to biome API, mgv5, mgv7. Reduce and correct depth ↵paramat2014-12-03
| | | | of mgv7 biomes. l_mapgen.cpp: add '#include mapgen_v5.h' because '#include mapgen_v7' is there. Improve underwater grass hack
* Fix warnings and other misc. minor changeskwolekr2014-11-14
|
* Add Generator Element Management frameworkkwolekr2014-11-12
| | | | Add BiomeManager, OreManager, DecorationManager, and SchematicManager
* Split up mapgen.cppkwolekr2014-11-01
class="hl esc">\n" "mt_user should have CREATE TABLE, INSERT, SELECT, UPDATE and " "DELETE rights on the database.\n" "Don't create mt_user as a SUPERUSER!"); } connectToDatabase(); } Database_PostgreSQL::~Database_PostgreSQL() { PQfinish(m_conn); } void Database_PostgreSQL::connectToDatabase() { m_conn = PQconnectdb(m_connect_string.c_str()); if (PQstatus(m_conn) != CONNECTION_OK) { throw DatabaseException(std::string( "PostgreSQL database error: ") + PQerrorMessage(m_conn)); } m_pgversion = PQserverVersion(m_conn); /* * We are using UPSERT feature from PostgreSQL 9.5 * to have the better performance, * set the minimum version to 90500 */ if (m_pgversion < 90500) { throw DatabaseException("PostgreSQL database error: " "Server version 9.5 or greater required."); } infostream << "PostgreSQL Database: Version " << m_pgversion << " Connection made." << std::endl; createDatabase(); initStatements(); } void Database_PostgreSQL::verifyDatabase() { if (PQstatus(m_conn) == CONNECTION_OK) return; PQreset(m_conn); ping(); } void Database_PostgreSQL::ping() { if (PQping(m_connect_string.c_str()) != PQPING_OK) { throw DatabaseException(std::string( "PostgreSQL database error: ") + PQerrorMessage(m_conn)); } } bool Database_PostgreSQL::initialized() const { return (PQstatus(m_conn) == CONNECTION_OK); } void Database_PostgreSQL::initStatements() { prepareStatement("read_block", "SELECT data FROM blocks " "WHERE posX = $1::int4 AND posY = $2::int4 AND " "posZ = $3::int4"); prepareStatement("write_block", "INSERT INTO blocks (posX, posY, posZ, data) VALUES " "($1::int4, $2::int4, $3::int4, $4::bytea) " "ON CONFLICT ON CONSTRAINT blocks_pkey DO " "UPDATE SET data = $4::bytea"); prepareStatement("delete_block", "DELETE FROM blocks WHERE " "posX = $1::int4 AND posY = $2::int4 AND posZ = $3::int4"); prepareStatement("list_all_loadable_blocks", "SELECT posX, posY, posZ FROM blocks"); } PGresult *Database_PostgreSQL::checkResults(PGresult *result, bool clear) { ExecStatusType statusType = PQresultStatus(result); switch (statusType) { case PGRES_COMMAND_OK: case PGRES_TUPLES_OK: break; case PGRES_FATAL_ERROR: default: throw DatabaseException( std::string("PostgreSQL database error: ") + PQresultErrorMessage(result)); } if (clear) PQclear(result); return result; } void Database_PostgreSQL::createDatabase() { PGresult *result = checkResults(PQexec(m_conn, "SELECT relname FROM pg_class WHERE relname='blocks';"), false); // If table doesn't exist, create it if (!PQntuples(result)) { static const char* dbcreate_sql = "CREATE TABLE blocks (" "posX INT NOT NULL," "posY INT NOT NULL," "posZ INT NOT NULL," "data BYTEA," "PRIMARY KEY (posX,posY,posZ)" ");"; checkResults(PQexec(m_conn, dbcreate_sql)); } PQclear(result); infostream << "PostgreSQL: Game Database was inited." << std::endl; } void Database_PostgreSQL::beginSave() { verifyDatabase(); checkResults(PQexec(m_conn, "BEGIN;")); } void Database_PostgreSQL::endSave() { checkResults(PQexec(m_conn, "COMMIT;")); } bool Database_PostgreSQL::saveBlock(const v3s16 &pos, const std::string &data) { // Verify if we don't overflow the platform integer with the mapblock size if (data.size() > INT_MAX) { errorstream << "Database_PostgreSQL::saveBlock: Data truncation! " << "data.size() over 0xFFFF (== " << data.size() << ")" << std::endl; return false; } verifyDatabase(); s32 x, y, z; x = htonl(pos.X); y = htonl(pos.Y); z = htonl(pos.Z); const void *args[] = { &x, &y, &z, data.c_str() }; const int argLen[] = { sizeof(x), sizeof(y), sizeof(z), (int)data.size() }; const int argFmt[] = { 1, 1, 1, 1 }; execPrepared("write_block", ARRLEN(args), args, argLen, argFmt); return true; } void Database_PostgreSQL::loadBlock(const v3s16 &pos, std::string *block) { verifyDatabase(); s32 x, y, z; x = htonl(pos.X); y = htonl(pos.Y); z = htonl(pos.Z); const void *args[] = { &x, &y, &z }; const int argLen[] = { sizeof(x), sizeof(y), sizeof(z) }; const int argFmt[] = { 1, 1, 1 }; PGresult *results = execPrepared("read_block", ARRLEN(args), args, argLen, argFmt, false); *block = ""; if (PQntuples(results)) { *block = std::string(PQgetvalue(results, 0, 0), PQgetlength(results, 0, 0)); } PQclear(results); } bool Database_PostgreSQL::deleteBlock(const v3s16 &pos) { verifyDatabase(); s32 x, y, z; x = htonl(pos.X); y = htonl(pos.Y); z = htonl(pos.Z); const void *args[] = { &x, &y, &z }; const int argLen[] = { sizeof(x), sizeof(y), sizeof(z) }; const int argFmt[] = { 1, 1, 1 }; execPrepared("read_block", ARRLEN(args), args, argLen, argFmt); return true; } void Database_PostgreSQL::listAllLoadableBlocks(std::vector<v3s16> &dst) { verifyDatabase(); PGresult *results = execPrepared("list_all_loadable_blocks", 0, NULL, NULL, NULL, false, false); int numrows = PQntuples(results); for (int row = 0; row < numrows; ++row) { dst.push_back(pg_to_v3s16(results, 0, 0)); } PQclear(results); } #endif // USE_POSTGRESQL