aboutsummaryrefslogtreecommitdiff
path: root/src/mg_decoration.h
Commit message (Collapse)AuthorAge
* Simple deco: Allow setting param2 value on placementAuke Kok2016-12-07
| | | | | | | | | | | | | Schematics can already be placed with a param2 value, but not simple 1-node plant decorations of the simple type. This adds a `param2` field to the simple deco type that is checked to be between 0 and 255, and put to the placed node at mapgen. This can be used to put a degrotate value in, or e.g. a fill value for leveltype nodes, or a place_param2 value at mapgen placement, or vary the shape of meshoptions plantlike drawtype.
* Decorations: Generalise 'spawn by' to be used by all decoration typesparamat2016-09-14
| | | | In lua_api.txt, make clear that 'place on' and 'spawn by' can be lists.
* Permit usage of std::unordered_map & std::unorderered_set on c++11 compilers ↵Ner'zhul2016-08-10
| | | | | | | | | (#4430) This fallback to std::map & std::set for older compilers Use UNORDERED_SET as an example in decoration and ore biome sets Use UNORDERED_MAP as an example in nameidmapping
* Convert usages of PseudoRandom to PcgRandom for ore and deco placementkwolekr2015-11-09
| | | | In addition to being a better random, this fixes #3228
* Decoration API: Add flag for placement on liquid surfaceparamat2015-10-23
| | | | | Add findLiquidSurface() function to mapgen.cpp Update lua_api.txt
* Clean up threadingShadowNinja2015-08-23
| | | | | | | | | | | | | | | | | | | | * Rename everything. * Strip J prefix. * Change UpperCamelCase functions to lowerCamelCase. * Remove global (!) semaphore count mutex on OSX. * Remove semaphore count getter (unused, unsafe, depended on internal API functions on Windows, and used a hack on OSX). * Add `Atomic<type>`. * Make `Thread` handle thread names. * Add support for C++11 multi-threading. * Combine pthread and win32 sources. * Remove `ThreadStarted` (unused, unneeded). * Move some includes from the headers to the sources. * Move all of `Event` into its header (allows inlining with no new includes). * Make `Event` use `Semaphore` (except on Windows). * Move some porting functions into `Thread`. * Integrate logging with `Thread`. * Add threading test.
* Split ObjDef/ObjDefManager out to objdef.cppkwolekr2015-05-18
|
* Schematics: Remove referenced schematics from Decorations on clearkwolekr2015-04-17
|
* 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
* mg_decoration: Raise highest allowed deco top to max edge of voxelmanipparamat2015-03-15
| | | | Remove max_y from functions, simplify code
* Biome API: Enable decorations placed on waterparamat2015-03-06
| | | | Add schematic decoration force placement flag
* Shorten ManualMapVoxelManipulator to MMVManipkwolekr2015-01-05
|
* Add minetest.generate_ores() and minetest.generate_decorations()kwolekr2015-01-04
|
* Replace instances of height_min/height_max with y_min/y_max to remove ambiguitykwolekr2014-12-30
|
* Decoration: Add height_min and height_max parameterskwolekr2014-12-28
| | | | | Also set default height_min/height_max to -31000 and 31000, respectively, for ore and biomes
* Redefine NodeResolver interface and replace with callback mechanismkwolekr2014-12-27
|
* Add minetest.clear_registered_decorations() and clear_registered_ores()kwolekr2014-12-12
|
* Remove get_noiseparams function. read_noiseparams should be used from now onkwolekr2014-12-10
|
* Fix struct vs. class in forward declarationsKahrl2014-12-08
|
* Rewrite generate notification mechanismkwolekr2014-12-06
| | | | | | | Add support for notify-on-decoration Clean up mapgen constructors Clean up mapgen.cpp code style somewhat Remove trailing whitespace from some files
* Add Generator Element Management frameworkkwolekr2014-11-12
| | | | Add BiomeManager, OreManager, DecorationManager, and SchematicManager
* Split up mapgen.cppkwolekr2014-11-01
urrent_player;craftpreview;7,1;1,1;]"; // Initialize movement settings at default values, so movement can work if the server fails to send them movement_acceleration_default = 3 * BS; movement_acceleration_air = 2 * BS; movement_acceleration_fast = 10 * BS; movement_speed_walk = 4 * BS; movement_speed_crouch = 1.35 * BS; movement_speed_fast = 20 * BS; movement_speed_climb = 2 * BS; movement_speed_jump = 6.5 * BS; movement_liquid_fluidity = 1 * BS; movement_liquid_fluidity_smooth = 0.5 * BS; movement_liquid_sink = 10 * BS; movement_gravity = 9.81 * BS; // Movement overrides are multipliers and must be 1 by default physics_override_speed = 1; physics_override_jump = 1; physics_override_gravity = 1; hud_flags = HUD_FLAG_HOTBAR_VISIBLE | HUD_FLAG_HEALTHBAR_VISIBLE | HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE | HUD_FLAG_BREATHBAR_VISIBLE; hud_hotbar_itemcount = HUD_HOTBAR_ITEMCOUNT_DEFAULT; } Player::~Player() { } // Horizontal acceleration (X and Z), Y direction is ignored void Player::accelerateHorizontal(v3f target_speed, f32 max_increase) { if(max_increase == 0) return; v3f d_wanted = target_speed - m_speed; d_wanted.Y = 0; f32 dl = d_wanted.getLength(); if(dl > max_increase) dl = max_increase; v3f d = d_wanted.normalize() * dl; m_speed.X += d.X; m_speed.Z += d.Z; #if 0 // old code if(m_speed.X < target_speed.X - max_increase) m_speed.X += max_increase; else if(m_speed.X > target_speed.X + max_increase) m_speed.X -= max_increase; else if(m_speed.X < target_speed.X) m_speed.X = target_speed.X; else if(m_speed.X > target_speed.X) m_speed.X = target_speed.X; if(m_speed.Z < target_speed.Z - max_increase) m_speed.Z += max_increase; else if(m_speed.Z > target_speed.Z + max_increase) m_speed.Z -= max_increase; else if(m_speed.Z < target_speed.Z) m_speed.Z = target_speed.Z; else if(m_speed.Z > target_speed.Z) m_speed.Z = target_speed.Z; #endif } // Vertical acceleration (Y), X and Z directions are ignored void Player::accelerateVertical(v3f target_speed, f32 max_increase) { if(max_increase == 0) return; f32 d_wanted = target_speed.Y - m_speed.Y; if(d_wanted > max_increase) d_wanted = max_increase; else if(d_wanted < -max_increase) d_wanted = -max_increase; m_speed.Y += d_wanted; #if 0 // old code if(m_speed.Y < target_speed.Y - max_increase) m_speed.Y += max_increase; else if(m_speed.Y > target_speed.Y + max_increase) m_speed.Y -= max_increase; else if(m_speed.Y < target_speed.Y) m_speed.Y = target_speed.Y; else if(m_speed.Y > target_speed.Y) m_speed.Y = target_speed.Y; #endif } v3s16 Player::getLightPosition() const { return floatToInt(m_position + v3f(0,BS+BS/2,0), BS); } void Player::serialize(std::ostream &os) { // Utilize a Settings object for storing values Settings args; args.setS32("version", 1); args.set("name", m_name); //args.set("password", m_password); args.setFloat("pitch", m_pitch); args.setFloat("yaw", m_yaw); args.setV3F("position", m_position); args.setS32("hp", hp); args.setS32("breath", m_breath); args.writeLines(os); os<<"PlayerArgsEnd\n"; inventory.serialize(os); } void Player::deSerialize(std::istream &is, std::string playername) { Settings args; for(;;) { if(is.eof()) throw SerializationError (("Player::deSerialize(): PlayerArgsEnd of player \"" + playername + "\" not found").c_str()); std::string line; std::getline(is, line); std::string trimmedline = trim(line); if(trimmedline == "PlayerArgsEnd") break; args.parseConfigLine(line); } //args.getS32("version"); // Version field value not used std::string name = args.get("name"); updateName(name.c_str()); setPitch(args.getFloat("pitch")); setYaw(args.getFloat("yaw")); setPosition(args.getV3F("position")); try{ hp = args.getS32("hp"); }catch(SettingNotFoundException &e){ hp = 20; } try{ m_breath = args.getS32("breath"); }catch(SettingNotFoundException &e){ m_breath = 11; } inventory.deSerialize(is); if(inventory.getList("craftpreview") == NULL) { // Convert players without craftpreview inventory.addList("craftpreview", 1); bool craftresult_is_preview = true; if(args.exists("craftresult_is_preview")) craftresult_is_preview = args.getBool("craftresult_is_preview"); if(craftresult_is_preview) { // Clear craftresult inventory.getList("craftresult")->changeItem(0, ItemStack()); } } // Set m_last_* checkModified(); } /* RemotePlayer */ void RemotePlayer::setPosition(const v3f &position) { Player::setPosition(position); if(m_sao) m_sao->setBasePosition(position); }