Commit Graph

72 Commits

Author SHA1 Message Date
Loïc Blot 1c1c97cbd1 Modernize source code: last part (#6285)
* Modernize source code: last par

* Use empty when needed
* Use emplace_back instead of push_back when needed
* For range-based loops
* Initializers fixes
* constructors, destructors default
* c++ C stl includes
2017-08-20 13:30:50 +02:00
Loïc Blot 88b436e6a9 Code modernization: subfolders (#6283)
* Code modernization: subfolders

Modernize various code on subfolders client, network, script, threading, unittests, util

* empty function
* default constructor/destructor
* for range-based loops
* use emplace_back instead of push_back
* C++ STL header style
* Make connection.cpp readable in a pointed place + typo
2017-08-19 22:23:47 +02:00
Loïc Blot fd3afbced5 Optimize headers (part 2) (#6272)
* Optimize headers (part 2)

* less debug.h in headers
* less remoteplayer.h for everybody

* Cleanup (part 2)

* camera.h: mesh.h
* mapgen.h: mapnode.h
* serverenvironment.h: mapblock.h
* nodedef.h: shader.h
2017-08-18 19:25:07 +02:00
Loïc Blot 85511a642f Cleanup various headers to reduce compilation times (#6255)
* Cleanup various headers to reduce compilation times
2017-08-16 22:11:45 +02:00
Loïc Blot 79f19b8369 [CSM] Add flavour limits controlled by server (#5930)
* [CSM] Add flavour limits controlled by server

Server send flavour limits to client permitting to disable or limit some Lua calls

* Add limits for reading nodedefs and itemdefs

* flavour: Add lookup node limits

* Merge get_node_or_nil into get_node.

Sending fake node doesn't make sense in CSM, just return nil if node is not available for any reason

* Add node range customization when noderange flavour is enabled (default 8 nodes)

* Limit nodes range & disable chat message sending by default

* Bump protocol version
2017-07-18 21:39:55 +02:00
Dániel Juhász 3caad3f3c9 Expose getPointedThing to Lua
This commit introduces Raycast, a Lua user object, which can be
used to perform a raycast on the map. The ray is continuable, so one can
also get hidden nodes (for example to see trough glass).
2017-07-07 22:28:23 +01:00
SmallJoker 6eb03c135f find_nodes_in_area: Extend maximal count to U32_MAX (#5277)
Extend documentation, limit area volume
Remove u16 count limitation

* Prevent integer overflow, replace minp/maxp with pos1/pos2
2017-06-19 16:30:26 +02:00
ShadowNinja 77597c4ff3 Clean up numeric.h and split FacePositionCache from it
I also optiized FacePositionCache a bit: I removed a map
lookup and vector copy from both branches of getFacePosition.
2017-05-06 16:09:45 -04:00
red-001 d6cf5450a8 Add option to also check the center to `find_node_near` (#5255)
* Add option to also check the center to `find_node_near`
2017-05-04 22:52:58 +02:00
ShadowNinja 2818d3f224 Rename Scripting API files for consistency 2017-04-25 13:41:36 -04:00
Loïc Blot a7e131f53e Fix various points reported by cppcheck (#5656)
* Fix various performance issues reported by cppcheck + code style (CI)

* Make CI happy with code style on master
* guiFileSelectMenu: remove useless includes
* some performance fixes pointed by cppcheck
* remove some useless casts
* TextDest: remove unused setFormSpec function

* Fix various iterator post-increment reported by cppcheck
2017-04-25 10:21:42 +02:00
Dániel Juhász 57e5aa6628 Light update for map blocks
This is not really different from the light update of a voxel
manipulator. This update does not assume that the lighting was correct
before, therefore it is useful for correction.

Also expose this function to the Lua API for light correction, and
allow voxel manipulators not to update the light.
2017-04-20 05:39:14 +02:00
Loïc Blot 0891975ad6 [CSM] Add core.get_timeofday & core.get_day_count env calls (#5401)
* [CSM] Add core.get_timeofday & core.get_day_count env calls

* [CSM] Add core.get_node_level, core.get_node_max_level, core.find_node_near
2017-03-17 07:48:29 +01:00
red-001 88df9fb5b6 Add `get_wielded_item` 2017-03-13 23:56:05 +01:00
Loic Blot 2efae3ffd7 [CSM] Client side modding
* rename GameScripting to ServerScripting
* Make getBuiltinLuaPath static serverside
* Add on_shutdown callback
* Add on_receiving_chat_message & on_sending_chat_message callbacks
* ScriptApiBase: use IGameDef instead of Server
  This permits to share common attribute between client & server
* Enable mod security in client side modding without conditions
2017-03-13 23:56:05 +01:00
rubenwardy f2aa2c6a98 Add ItemStack key-value meta storage 2017-02-04 22:07:55 +00:00
Rui ec30d49e02 Add staticdata parameter to add_entity (#5009)
* Add staticdata parameter to add_entity
* Add add_entity_with_staticdata to core.features
2017-01-09 20:39:45 +01:00
Rogier 4b17105dc4 Emergeblocks: Fix occasional crash
Modification of the emergeblocks internal state was not protected
by a lock, causing a race condition.
This can be reproduced by repeatedly running emergeblocks for an
already-generated section of the map (with multiple emerge threads).
2016-10-16 01:13:16 +01:00
Loic Blot 8bcd10b872 Player/LocalPlayer/RemotePlayer inheritance cleanup (part 1 on X)
* LocalPlayer take ownership of maxHudId as it's the only caller
* RemotePlayer take ownership of day night ratio as it's the only user
* Pass getPlayerControl as const reference to prevent object copy on each call (perf improvement in ObjectRef::l_get_player_control call)
* getPlayerSAO is now only RemotePlayer call
* get/setHotbarItemCount is now RemotePlayer owned
* Server: Use RemotePlayer instead of Player object on concerned call to properly fix the object type
* PlayerSAO now uses RemotePlayer instead of Player because it's only server side
* ObjectRef::getplayer also returns RemotePlayer as it's linked with PlayerSAO
2016-10-08 11:36:28 +02:00
kwolekr dfbdb5bcd7 Change internal type for seeds to s32
This fixes value truncation (and therefore incompatibility) on platforms
with an LP32 data model, such as VAX or MS-DOS.
2016-06-04 01:51:44 -04:00
est31 ac8bb457aa Pathfinder: Fix style
* Fix naming style for methods and classes:
	Use camelCase for methods and PascalCase for classes as
	code style demands it. And use sneak_case for methods that
	are not member of a class.
* Replace "* " with " *" for Pointers
* Same for references
* Put function body opening braces on new line
* Other misc minor non functional style improvements
2016-05-01 15:32:02 +02:00
Auke Kok 4e59fcf5c1 Add consistent monotonic day counter - get_day_count()
I've written several experimental bits of code that revolve around the
need for a consistent calendar, but implementing one is extremely hard
in mods due to time changes and mods overriding core.get_timeofday(),
which will conflict.

The second part of the problem is that doing this from a mod requires
constant maintenance of a settings file.

An implementation in core is trivial, however, and solves all of
these problems at virtually no cost: No extra branches in server
steps, and a single branch when minetest.set_time_of_day(), which is
entirely reasonable.

We store the day_count value in env_meta.txt.

The use case is obvious: This change allows mods to create an actual
virtual calendar, or properly account for seasonal changes, etc..

We add a "/days" chatcommand that displays the current day count. No
permissions are needed. It can only retrieve the day count, not
modify it.
2016-03-09 01:45:23 +01:00
est31 d494733839 Add minetest.register_lbm() to run code on block load only 2016-03-07 19:54:26 +01:00
Kahrl b1428ab4bb Add '/clearobjects quick' 2016-02-11 04:22:58 +00:00
kwolekr c2b5da735e Add callback parameter for core.emerge_area() 2015-11-02 18:43:09 -05:00
kwolekr 306b067091 SAPI: Move core.get_us_time() to Util module 2015-10-26 03:46:36 -04:00
kwolekr 54f1267c2c SAPI: Mark all Lua API functions requiring envlock 2015-10-25 23:06:48 -04:00
kwolekr f062bbd7a1 Add /emergeblocks command and core.emerge_area() Lua API 2015-09-23 15:56:24 -04:00
Kahrl 3304e1e517 Push error handler afresh each time lua_pcall is used
Fixes "double fault" / "error in error handling" messages
(issue #1423) and instead shows a complete backtrace.
2015-08-27 01:56:06 +02:00
kwolekr bcf38a2ad1 SEnv: Remove static_exists from ActiveObjects in deleted blocks 2015-08-16 15:55:07 -04:00
kwolekr 2b04ab874d SAPI: Track last executed mod and include in error messages 2015-08-12 23:56:12 -04:00
kwolekr bcf47bc67c Improve Script CPP API diagnostics 2015-08-05 21:13:03 -04:00
TeTpaAka e50aa4ed06 Add return list of individual counts to find_node_in_area 2015-06-13 19:39:18 +02:00
kwolekr b785577f03 Add core.find_nodes_with_meta() script API 2015-05-05 16:21:59 -04:00
Loic Blot 0c634a9719 Use std::vector instead of std::set for Environment::getObjectsInsideRadius
We are only iterating sequentially, we don't need a set here
Also use a vector reference instead of a copy
2015-04-16 18:37:29 +02:00
Craig Robbins ced6d20295 For usages of assert() that are meant to persist in Release builds (when NDEBUG is defined), replace those usages with persistent alternatives 2015-03-07 22:41:47 +10:00
Craig Robbins fdb9140825 Change find_surface_nodes_in_area to find_nodes_in_area_under_air 2015-02-27 21:42:00 +10:00
Loic Blot 0f556d0c7f Add find_surface_nodes_in_area LUA call which permit to only get the nodes which touch air. This permit to massively improve performance for mods like plantlife 2015-02-27 21:34:33 +10:00
Loic Blot f8d5af7536 SAO work: ActiveObject types & SAO cleanup * Replace u8 types with ActiveObjectType. * Merge content_object.h into activeobject.h * Remove DummyLoadSAO, it's now unused. * Remove ItemSAO, it's also unused 2015-02-17 09:09:50 +01:00
Loic Blot 7c8793cbea Performance Improvement: Use a cache which caches result for getFacePositions.
This greatly reduce the number of std::list generated by caching the result, which is always constant for each radius selected.
In the callgrind map, you will see original:
  * 3.3M calls to std::list for 9700 calls to getFacePositions
In the modified version, you will see:
  * 3.3K calls to std::list for 6900 call to getFacePositions
Callgrind map is here: #2321

it's a huge performance improvement to l_find_node_near
2015-02-16 11:27:44 +01:00
kwolekr 9736548720 Add ability to delete MapBlocks from map
Also add a Lua API and chatcommand for this
2015-01-15 16:48:56 -05:00
kwolekr cc3ab5efa5 LuaVoxelManip: Remove blank allocator 2014-12-29 01:31:37 -05:00
kwolekr 8334100fe1 LuaVoxelManip: Add option to allocate blank data 2014-12-27 23:09:36 -05:00
kwolekr 2b8180a417 Add support for NoiseParams in minetest.get_perlin() and add docs on NoiseParams to lua_api.txt 2014-12-12 02:02:44 -05:00
kwolekr 2fd3d52020 Add flags and lacunarity as new noise parameters
Add 'absolute value' option to noise map functions
Extend persistence modulation to 3D noise
Extend 'eased' option to noise2d_perlin* functions
Some noise.cpp formatting fixups
2014-12-07 21:59:32 -05:00
Craig Robbins 5b8855e83c Remove most exceptions from getNode() (and variants) 2014-11-14 18:05:34 +10:00
ShadowNinja 741df993ff Fix object reference pushing functions when called from coroutines 2014-10-07 16:37:45 -04:00
kwolekr f3eefeb794 Add LuaVoxelManip methods: get_node_at() and set_node_at() 2014-09-01 17:33:21 -04:00
Craig Robbins f33d31693e Fix seg fault if popping from empty stack (L-system trees)
See: https://github.com/minetest/minetest/issues/1525

Background
Wuzzy2: If you attempt to spawn a L-system tree with minetest.spawn_tree, you can make Minetest crash if it is attempted to pop an empty stack.

ShadowNinja: This shouldn't cause a segmentation fault, but it should throw a Lua error

Commit Description
This commit throws a Lua error instead of causing a segmentation fault. The server will still "crash" but will include a Lua backtrace.

L-Systems fix randomness
Unless a random seed is provided (via Lua treedef) seed the PRNG with a different seed for each tree
Resolves: https://github.com/minetest/minetest/issues/1469

Fix l-system crash when treedef random_level not set by Lua
2014-08-23 06:40:27 +02:00
sapier c24e0753fc Mod profiling support
Config settings:
profiling = true/false (gather statistics)
detailed_profiling = true/false (break mod times to callbacks)

Chat commands:
save_mod_profile saves current statistics in debug.txt and shows on console (on default loglevel)
2014-08-19 22:22:57 +02:00