Commit Graph

928 Commits

Author SHA1 Message Date
Loic Blot 95ce5583a9
ServerEnvironment::loadDefaultMeta: Loading default meta is only possible for ServerEnv itself 2018-03-16 08:52:42 +01:00
Loic Blot 858c95630f
Forgot to remove obsolete Server::m_mods 2018-03-16 08:44:57 +01:00
Loïc Blot 6c184947c3
Server: delegate mod management & config to ServerModConfiguration (#7131)
* Server: delegate mod management & config to ServerModConfiguration (rename it to ServerModManager)

* Use c++11 range based loops
* Add unittests + experimental/default mod as a test case to permit testing mod loading in future tests
2018-03-16 08:41:33 +01:00
Loic Blot 6036f865cb Drop less performant Server::setBlockNotSent for ClientInterface::markBlockposAsNotSent 2018-03-09 23:27:26 +01:00
Loic Blot c7c03ad7a6 Cleanup & bugfix
* ObjectRef::set_local_animation: fix wrong lua return (should push a boolean, currently returns nil)
* ObjectRef::set_eye_offset: fix wrong lua return (should push a boolean, currently returns nil)
* Fix various Server functions which depends on RemotePlayer objet and return true/false when player object is nil whereas it's a caller implementation error. Change those bool functions to void and add sanitize_check call instead. Current callers are always checking player object validity
* Optimize Server::setClouds : use CloudParams object ref instead of attribute deserialization from structure & perform RemotePlayer::setCloudParams directly in server class like many other calls
* Optimize Server::SendCloudParams: use CloudParams object ref instead of deserialized attributes
2018-03-08 23:00:17 +01:00
Loic Blot c7656edaa5 Cleanup: drop Server::hudGetHotbarSelectedImage()
Call directly accessible RemotePlayer::getHotbarSelectedImage() from server api
2018-03-08 23:00:17 +01:00
Loic Blot 4be46aeeb1 Cleanup: drop Server::hudGetHotbarImage()
Call directly accessible RemotePlayer::getHotbarImage() from server api & make it const ref
2018-03-08 23:00:17 +01:00
Loic Blot 373f1bfb4a Cleanup: drop Server::hudGetHotbarItemcount()
Call directly accessible RemotePlayer::getHotbarItemcount() from server api
2018-03-08 23:00:17 +01:00
red-001 4bb41a19dc Mitigate formspec exploits by verifying that the formspec was shown to the user by the server. (#6878)
This doesn't check the fields in anyway whatsoever so it should only be seen as a way to mitigate exploits, a last line of defense to make it harder to exploit bugs in mods, not as a reason to not do all the usually checks.
2018-02-18 22:33:42 +01:00
Dániel Juhász 3face01a20 Node definition manager refactor (#7016)
* Rename IWritableNodeDefManager to NodeDefManager
* Make INodeDefManager functions const
* Use "const *NodeDefManager" instead of "*INodeDefManager"
* Remove unused INodeDefManager class
* Merge NodeDefManager and CNodeDefManager
* Document NodeDefManager
2018-02-10 21:04:16 +01:00
red-001 4c0d4e4105 Load a texturepack from the 'textures' subfolder of a game 2018-01-16 08:45:17 +00:00
raymoo 83b12ed481 Shut down mapgen threads before other shutdown tasks (#6689)
Solves some issues with ModStorage functionality in mapgen threads
that occurred when mapgen threads continued to run after the main
server thread had stopped. Also shuts down mapgen threads before
shutdown callbacks are called.
2017-12-03 10:28:35 +01:00
number Zero 05d93c7fa1 Load files from subfolders in texturepacks
Updated and rebased version of a PR by red-001
2017-11-17 19:23:08 +00:00
Vitaliy 20a85d76d9 Move files to subdirectories (#6599)
* Move files around
2017-11-08 23:56:20 +01:00
Loïc Blot be10c0893e Make Player::peer_id server-side only and add getters and setters (#6478)
* Make Player::peer_id server-side only and add getters and setters

Player::peer_id has no sense client side, move it to server, make it private and add setter and getter
Also add some PEER_ID_INEXISTENT instead of harcoded 0
2017-09-30 12:00:05 +02:00
Loïc Blot 2afe62952c Server: affect bind_addr on constructor instead of start() (#6474)
bind_addr is already ready when using constructor as we read is.IPv6 from it, instead pass the whole address
2017-09-28 13:47:30 +02:00
Loic Blot 27eeb3581f
Fix some forgotten u16 -> session_t in ad7daf7b52 2017-09-27 23:48:12 +02:00
Loïc Blot ad7daf7b52 Add session_t typedef + remove unused functions (#6470)
* Add session_t typedef + remove unused functions

u16 peer_id is used everywhere, to be more consistent and permit some evolutions on this type in the future (i'm working on a PoC), uniformize u16 peer_id to SessionId peer_id
2017-09-27 19:47:36 +02:00
Loïc Blot 6f1c907204 Implement mod communication channels (#6351)
Implement network communication for channels

* Implement ModChannel manager server side to route incoming messages from clients to other clients
* Add signal handler switch on client & ModChannelMgr on client to handle channels
* Add Lua API bindings + client packet sending + unittests
* Implement server message sending
* Add callback from received message handler to Lua API using registration method
2017-09-26 00:11:20 +02:00
SmallJoker edbc533414 Customizeable max breath for players (#6411)
* Customizeable maximal breath for players
2017-09-15 12:18:47 +02:00
SmallJoker ee9a442ecc Network: Remove large parts of deprecated legacy code (#6404)
Also remove the setting 'send_pre_v25_init'
Keep old enum entries for obsolete commands
2017-09-12 19:48:09 +02:00
SmallJoker 745a90dc84 Server: Calculate maximal total block sends dynamically (#6393)
The block sends per client is 1/2 when reaching the maximal player count.
2017-09-09 00:36:48 +02:00
Loïc Blot bd6b90359c Remove DSTACK support (#6346)
Debugstacks is not useful, we don't really use it, the DebugStack is not pertinent, gdb and lldb are better if we really want to debug.
2017-08-30 08:09:41 +02:00
Loïc Blot 1d4a2a6ea7 Network proto handlers/container fixes (#6334)
* Fix HP transport + some double <-> float problems

TOCLIENT_HP transport u16 hp as a u8, use u16 HP, this prevent HP over 255 to overflow across network

* Fix more double/float problem in serverpackethandler & remove implicit struct type for TileAnimationParams

* Fix connection unittests container
2017-08-29 20:37:54 +02:00
Ekdohibs b24e6433df Add clientside translations. 2017-08-24 17:54:10 +02:00
Loïc Blot c7160cb629 Network cleanup (#6302)
* Cleanup network headers

* Move peerhandler to a specific header to reduce compilation times
* Move socket.cpp/h to network folder

* More work

* Network code cleanups

* Move socket.{cpp,h} to network folder
* Move Address object to network/address.{cpp,h}
* Move network exceptions to network/networkexceptions.h
* Client: use unique_ptr for Connection
* Server/ClientIface: use shared_ptr for Connection

* Format fixes

* Remove socket.cpp socket.h from clang-format whitelist

* Also fix NetworkPacket code style & make it under clang-format
2017-08-24 08:28:54 +02:00
SmallJoker f7d50a8078 Respect object property hp_max field for players (#6287)
* Respect object property hp_max field for players
This allows modders to configure the maximal HP per player

* Statbars: Downscale bar to full 20 HP when exceeding this value
Add default max HP for players and breath constants to builtin
Document the constants

* Rename PLAYER_MAX_HP -> PLAYER_MAX_HP_DEFAULT
2017-08-23 22:32:10 +02:00
Loïc Blot 7528986e44 Code modernization: src/p*, src/q*, src/r*, src/s* (partial) (#6282)
* Code modernization: src/p*, src/q*, src/r*, src/s* (partial)

* empty function
* default constructor/destructor
* for range-based loops
* use emplace_back instead of push_back
* C++ STL header style
* Spelling: vertice -> vertex
2017-08-19 14:25:35 +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 fb196be8cf server.cpp: unroll setting when sending mapblocks (#6265)
* server.cpp: unroll setting when sending mapblocks

* Improve a little bit performance when sending mapblocks massively
* Use a range based for
* Code style fixes
2017-08-18 12:17:30 +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
Loic Blot 342e9336ae
server.cpp: code modernization
* Use more for range based loops
* Simplify some tests
* Code style fixes
* connection.h: better PeerChange constructor instead of creating uninitalized object and then affect variables
2017-08-15 09:30:31 +02:00
Loic Blot 182bd6ab45
Various server.cpp cleanups
* Modernize many for loops
* Use constness on many loops
* use empty function on many strings tests
* various code style fixes
2017-08-14 01:06:12 +02:00
Loic Blot 5d06ecb366
Server::AsyncRunStep + Server::sendAddNode: modernize code
* Use various modern for loops
* Make some loop iterator constants, whereas there weren't
* Use empty on some size() > 0 tests
* Various little codestyle fixes
* Fix an hidden scope variable in Server::SendBlockNoLock
2017-08-14 00:44:45 +02:00
Loic Blot c8faee4eda
Remove one unused variable in Server::Receive function 2017-07-27 00:16:20 +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
Loïc Blot 7ddf67aa14 Chat protocol rewrite (#5117)
* New TOCLIENT_CHAT_MESSAGE packet

* Rename old packet to TOCLIENT_CHAT_MESSAGE_OLD for compat
* Handle TOCLIENT_CHAT_MESSAGE new structure client side
* Client chat queue should use a specific object
* SendChatMessage: use the right packet depending on protocol version (not complete yet)
* Add chatmessage(type) objects and handle them client side (partially)
* Use ChatMessage instead of std::wstring server side

* Update with timestamp support
2017-07-16 10:47:31 +02:00
Loïc Blot 4faaadc8d5 Cpp11 patchset 11: continue working on constructor style migration (#6004) 2017-06-18 19:55:15 +02:00
Loïc Blot ddcd026344 Remove legacy content_abm.{cpp,h} 2017-06-14 16:23:08 +02:00
Loïc Blot 65819f3b9f Use thread_local instead from some static settings (#5955)
thread_local permits to limit variable lifetime to thread duration. Use it on each setting place which uses static to cache variable result only for thread lifetime. This permits to keep the same performance level & reconfigure server from MT gui in those various variables places.

Add thread_local to undersampling calculation too.
2017-06-11 13:58:43 +02:00
Rui ff73c7a5da Sound: Add pitch option (#5960)
* Sound: Add pitch option
2017-06-11 13:58:26 +02:00
paramat 842acbfad2 (Re)spawn players within 'mapgen_limit'
Previously, findSpawnPos() did not take the 'mapgen_limit' setting into account,
a small limit often resulted in a spawn out in the void.
Use the recently added 'calcMapgenEdges()' to get max spawn range through a new
mapgenParams function 'getSpawnRangeMax()'.

Previously, when a player respawned into a world, 'objectpos_over_limit()' was
used as a check, which was inaccurate.
Use the recently added 'saoPosOverLimit()' to get exact mapgen edges.

Also fix default value of 'm_sao_limit_min'.
2017-06-11 02:11:08 +01:00
red-001 25ae0739ed Add a server-sided way to remove color codes from incoming chat messages (#5948)
These code be generated by CSM, a modded client or just copy and pasted by the player.

Changes
- Update configuration example and setting translation file.
- Remove colour codes before logging chat.
- Add setting to remove colour codes before processing the chat.
2017-06-10 13:49:44 +02:00
red-001 740b4bec07 Fix sending color codes to clients that don't support them. (#5950)
Also remove `disable_escape_sequences` since it's not needed anymore.
2017-06-09 21:39:25 +02:00
red-001 4221c1b441 Have the server send the player list to the client (#5924)
* Have the server send the player list to the client

Currently the client generates the player list based on the Client active object list, the issue with this is that we can't be sure all player active objects will be sent to the client, so this could result in players showing up when someone run `/status` but auto complete not working with their nick and CSM not being aware of the player
2017-06-08 15:30:09 +02:00
Loïc Blot 8bdde45895 Revert "Remove deprecated code segments (#5891)"
This reverts commit 599e13e95e.
2017-06-06 16:19:04 +02:00
Thomas--S 599e13e95e Remove deprecated code segments (#5891) 2017-06-04 21:42:32 +02:00
Loïc Blot a98baef5e4 C++11 patchset 2: remove util/cpp11.h and util/cpp11_container.h (#5821) 2017-06-04 21:00:04 +02:00
Loïc Blot 90808a4f34 Real control fix (#5787)
* Allow enabling and disabling mods.

* Re-fix 605599b6f1

This breaks some chars like € in chat.

Instead verify is char is a non control char -> iswcntrl
2017-05-20 22:29:15 +02:00
SmallJoker 674400523e Mainmenu: Fix issues while trying to enable all mods (#5770) 2017-05-19 07:45:47 +02:00
Paramat 0443620c5e Particles: Do not send single particles to distant clients (#5760)
Previously, every individual particle on a server is sent to, and rendered by
(even if not actually visible), every client regardless of distance. This
significantly reduces client FPS and creates unnecessary network traffic.
Maximum distance is set by 'max block send distance' as this determines how far
a client is able to see.
2017-05-17 10:37:28 +02:00
paramat ad9fcf859e Set sky API: Add bool for clouds in front of custom skybox
Default true.
Add 'm_clouds_enabled' bool to sky.h, set from new bool in 'set sky' API.
Make 'getCloudsVisible()' depend on 'm_clouds_enabled' instead of
'm_visible' (whether normal sky is visible).
2017-05-02 20:42:35 -07:00
Brandon bd921a7916 Sound API: Add fading sounds 2017-05-03 03:12:45 +01:00
Ben Deutsch f1d7a26b7c Add clouds API 2017-04-30 00:06:13 +01:00
ShadowNinja 2818d3f224 Rename Scripting API files for consistency 2017-04-25 13:41:36 -04:00
Loïc Blot 29ab20c272 Player data to Database (#5475)
* Player data to Database

Add player data into databases (SQLite3 & PG only)

PostgreSQL & SQLite: better POO Design for databases

Add --migrate-players argument to server + deprecation warning

* Remove players directory if empty
2017-04-23 14:35:08 +02:00
Auke Kok cca58fe0fd Add on_flood() callback.
This callback is called if a liquid definitely floods a non-air
node on the map. The callback arguments are (pos, oldnode, newnode)
and can return a `bool` value indicating whether flooding the
node should be cancelled (`return true` will prevent the node
from flooding).

Documentation is added, the callback function was tested with a
modified minetest_game.

Note that `return true` will likely cause the node's `on_flood()`
callback to be called every second until the node gets removed,
so care must be taken to prevent many callbacks from using this
return value. The current default liquid update interval is 1.0
seconds, which isn't unmanageable.

The larger aim of this patch is to remove the lava cooling ABM,
which is a significant cost to idle servers that have lava on their
map. This callback will be much more efficient.
2017-04-22 01:23:51 +01:00
orwell96 f151b23220 Fix #5617 - respect message and reconnect parameters when shutting down immediately (#5621) 2017-04-21 19:31:59 +02:00
SmallJoker 6120251320 Fix MSVC build broken by 34d32ce
`round` -> `myround`
Remove superflous `floor` calls
2017-04-17 14:02:26 +02:00
Loïc Blot 34d32ce55a Implement delayed server shutdown with cancelation (#4664) 2017-04-15 23:19:18 +02:00
Loïc Blot b0be7ab61e ClientIface::sendToAll: honor packet configuration (#5590) 2017-04-14 15:34:01 +02:00
red-001 d4e9dd4643 Move chat command handling code from C++ to Lua (#5528) 2017-04-08 20:03:57 +02:00
presstabstart 351cc2e79a Fix multiple death messages (#5305)
Fix multiple death messages (#3565) and damage server logs after death.
2017-04-06 20:32:50 -07:00
sfan5 525d2a0d51 Fix /shutdown or ^C no longer causing server exit
Broken since b8484ef24e
2017-03-19 18:21:18 +01:00
Loïc Blot f8ad01ab7c Update server min protocol version to v24 (#5411)
* Update server min protocol version to v24

It's based on @sfan5 stats. See https://kitsunemimi.pw/tmp/serverlist_stats_2017-03-17.txt

v24 was bumped 25/08/14 and 0.4.11 was released 25/12/14

* Drop protocol v23 and lesser code
2017-03-19 08:44:29 +01:00
ShadowNinja b8484ef24e Server list cleanup
This removes the hacky server_dedicated pseudo-setting.
2017-03-18 12:37:57 +01:00
Loic Blot ba66fce833 [CSM] storage + fixes 2017-03-13 23:56:05 +01:00
Loïc Blot 92b45b2a18 [CSM] implement client side mod loading (#5123)
* client side mods are located in clientmods/
* move builtin/preview.lua to clientmods/preview/init.lua as a preview mod
* refactor ModConfiguration class to work properly with client and server using child objects
* move some Server constructor mod load code to ModConfiguration to reduce code duplication between client and server
* remove mods.{cpp,h} unused functions
* use UNORDERED_SET instead of std::set in some modspec storages
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
Loïc Blot ef6feca501 Add ModMetadata API (#5131)
* mod can create a ModMetadata object where store its values and retrieve it.
* Modmetadata object can only be fetched at mod loading
* Save when modified using same time as map interval or at server stop
* add helper function to get mod storage path
* ModMetadata has exactly same calls than all every other Metadata
2017-02-08 00:15:55 +01:00
rubenwardy 08911160aa Block spam messages before calling on_chatmessage callbacks (#4805)
Fixes #4799
2017-01-25 10:57:33 +01:00
sfan5 43822de5c6 Fix potential crash in chat handling (since 2f56a00d9e) 2017-01-22 20:17:13 +01:00
Loïc Blot 6d5a407133 Add show_statusline_on_connect setting (#5084)
Add show_statusline_on_connect setting
2017-01-21 19:30:42 +01:00
Loïc Blot bc29e03b59 Revert "Detach the player from entities on death." (#5087) 2017-01-21 17:30:55 +01:00
red-001 72535d3328 Detach the player from entities on death. (#5077) 2017-01-21 16:11:55 +01:00
red-001 0dada51a55 Remove `mathconstants.h` and use the correct way to get `M_PI` in MSVC. (#5072) 2017-01-20 23:19:41 +01:00
sfan5 7279f0b373 Add particle animation, glow
This is implemented by reusing and extending the
TileAnimation code for the methods used by particles.
2017-01-18 23:21:01 +01:00
red-001 2f56a00d9e Remove client-side chat prediction. (#5055)
Network lag isn't really a big issue with chat and chat prediction makes writing mods harder.
2017-01-17 00:09:47 +01:00
sapier f5070b4454 Added lua tracebacks to some errors where you have been blind to what… (#5043)
* Added lua tracebacks to some errors where you have been blind to what actually went wrong
2017-01-15 13:36:53 +01:00
Ner'zhul 8e7449e092 Environment & IGameDef code refactoring (#4985)
* Environment code refactoring
* Cleanup includes & class declarations in client & server environment to improve build speed
* ServerEnvironment::m_gamedef is now a pointer to Server instead of IGameDef, permitting to cleanup many casts.
* Cleanup IGameDef
  * Move ITextureSource* IGameDef::getTextureSource() to Client only.
  * Also move ITextureSource *IGameDef::tsrc() helper
  * drop getShaderSource, getSceneManager, getSoundManager & getCamera abstract call
  * drop unused emerge() call
  * cleanup server unused functions (mentionned before)
* Drop one unused parameter from ContentFeatures::updateTextures
* move checkLocalPrivilege to Client
* Remove some unnecessary casts
* create_formspec_menu: remove IWritableTextureSource pointer, as client already knows it
* Fix some comments
* Change required IGameDef to Server/Client pointers
* Previous change that game.cpp sometimes calls functions with Client + InventoryManager + IGameDef in same functions but it's the same objects
* Remove duplicate Client pointer in GUIFormSpecMenu::GUIFormSpecMenu
* drop ClientMap::sectorWasDrawn which is unused
2017-01-09 20:39:22 +01:00
Loic Blot 52ba1f867e Breath cheat fix: server side
Breath is now handled server side. Changing this behaviour required some modifications to core:

* Ignore TOSERVER_BREATH package, marking it as obsolete
* Clients doesn't send the breath to server anymore
* Use PlayerSAO pointer instead of peer_id in Server::SendPlayerBreath to prevent a useless lookup (little perf gain)
* drop a useless static_cast in emergePlayer
2017-01-01 23:11:26 +01:00
sfan5 b16252dcae Various anticheat improvements
* Calculate maximum interact distance from wielded tool
* New "interacted_while_dead" cheat_type for the Lua API
* Disallow dropping items while dead
* Move player to spawn before resurrecting them
2016-12-26 22:34:29 +01:00
lhofhansl 5dc6198878 Optimize/adjust blocks/ActiveObjects sent at the server based on client settings. (#4811)
Optimize/adjust blocks and active blocks sent at the server based on client settings.
2016-11-30 18:13:14 +10:00
sfan5 c38985825f Allow restricting detached inventories to one player
This combats the problem of sending the hundreds of
"creative" / "armor" or whatever detached invs that
exist on popular servers to each and every player
on join or on change of said invs.
2016-11-28 13:41:19 +01:00
orwell96 0d1c9598a0 Make supplying empty formspec strings close the formspec (#4737)
This will only happen if the formname matches or if formname is "".
2016-11-23 02:15:22 +10:00
sfan5 5fd1ef9b58 Revert "Adding particle blend, glow and animation (#4705)"
This reverts commit 93e3555eae.
2016-11-14 15:28:06 +01:00
Foghrye4 93e3555eae Adding particle blend, glow and animation (#4705) 2016-11-15 00:09:59 +10:00
Ner'zhul 66bb295436 PlayerSAO saving fix (#4734)
PlayerSAO::disconnected() function was historical and remove the link between SAO and RemotePlayer session. With previous attributes linked to RemotePlayer saving was working. But now attributes are read from SAO not RemotePlayer and the current serialize function verify SAO exists to save the player attributes.

Because PlayerSAO::disconnected marks playersao for removal, only mark playerSAO for removal and let PlayerSAO::removingFromEnvironment do the correct saving behaviour and all the disconnection process instead of doing a partial removal and let the server loop doing the RemotePlayer cleanup and remove some saved attributes...
2016-11-05 10:25:30 +01:00
Ner'zhul 9d25242c5c PlayerSAO/LocalPlayer refactor: (#4612)
* Create UnitSAO, a common part between PlayerSAO & LuaEntitySAO
* Move breath to PlayerSAO & LocalPlayer
* Migrate m_yaw from (Remote)Player & LuaEntitySAO to UnitSAO
* Migrate m_yaw from Player to LocalPlayer for client
* Move some functions outside of player class to PlayerSAO/RemotePlayer or LocalPlayer depending on which class needs it
* Move pitch to LocalPlayer & PlayerSAO
* Move m_position from Player to LocalPlayer
* Move camera_barely_in_ceiling to LocalPlayer as it's used only there
* use PlayerSAO::m_base_position for Server side positions
* remove a unused variable
* ServerActiveObject::setPos now uses const ref
* use ServerEnv::loadPlayer unconditionnaly as it creates RemotePlayer only if it's not already loaded
* Move hp from Player to LocalPlayer
* Move m_hp from LuaEntitySAO to UnitSAO
* Use m_hp from PlayerSAO/UnitSAO instead of RemotePlayer
2016-10-30 14:53:26 +01:00
raymoo c9e7a27eeb Attached particle spawners 2016-10-13 17:33:16 +02:00
Loic Blot 569b89b36f Move RemotePlayer code to its own cpp/header 2016-10-08 22:27:44 +02:00
Loic Blot 7bbd716426 RemotePlayer/LocalPlayer Player base class proper separation (code cleanup) (patch 3 of X)
* remove IGameDef from Player class, only LocalPlayer has it now
* move many attributes/functions only used by LocalPlayer from Player to LocalPlayer
* move many attributes/functions only used by RemotePlayer from Player to RemotePlayer
* make some functions const
* hudGetHotbarSelectedImage now returns const ref
* RemotePlayer getHotbarSelectedImage now returns const ref
* various code style fixes
2016-10-08 22:27:44 +02:00
Loic Blot edba6e50d9 Optimize ClientIface::getPlayerNames(): return const ref instead a copy of all names 2016-10-08 22:27:44 +02:00
Loic Blot fd5a130b86 More code cleanup (UNORDERED + RemotePlayer/LocalPlayer)
* ClientEnvironment now uses UNORDERED MAP for active objects
* Use RemotePlayer and LocalPlayer everywhere it's possible
* Minor code style fixes
* Drop Client::getBreath() unused function
2016-10-08 22:27:44 +02:00
Loic Blot 656faf7373 Player/LocalPlayer/RemotePlayer inheritance cleanup (part 2 on X)
* Server/Client Environments now have an helper to cast Player object in the right type to use it
* Server: use RemotePlayer everywhere and remove previous added casts
* Client: use LocalPlayer where needed
* Environment: remove unused functions (getPlayers(), getRandomConnectedPlayer(), getNearestConnectedPlayer())
2016-10-08 15:57:50 +02:00
Loic Blot 09cefc3dfd Remove some unused attributes/class functions in server.cpp/h 2016-10-08 11:36:28 +02: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
Loic Blot 155288ee98 use unordered containers where possible (patch 4 on X)
Also remove some unused parameters/functions
2016-10-06 22:37:26 +02:00
SmallJoker b66a5d2f88 Fix narrow string compiling issue on MSVC2010 2016-10-06 13:57:40 +02:00
Loic Blot 667975fe3a Use more unordered_maps to improve performance in c++11 builds 2016-10-06 12:33:35 +02:00
est31 de83c29ba0 Fix crash regression when chatting in the ncurses console
Fixes #4579, a regression introduced by commit

d4c76258e3 "Chat: new settings to prevent spam"
2016-10-06 07:45:50 +02:00
Loic Blot 613797a304 Replace various std::map with UNORDERED_MAP + various cleanups
This is part 2 for 5f084cd98d

Other improvements:

* Use the defined ItemGroupList when used
* make Client::checkPrivilege const
* inline some trivial functions
* Add ActiveObjectMap typedef
* Add SettingsEntries typedef
2016-10-05 10:53:19 +02:00
Loic Blot d4c76258e3 Chat: new settings to prevent spam
Added the following chat coreside features
* Chat messages length limit
* Message rate limiting
* Message rate kicking

Note:
* handleChat now takes RemotePlayer pointer instead of u16 to remove useless
  lookups
2016-10-05 00:13:37 +02:00
Xunto 0b0075e6ad Move on join and on leave messages to lua (#4460) 2016-08-22 20:21:48 +02:00
kwolekr 3c63c3044d Add MapSettingsManager and new mapgen setting script API functions
This commit refactors the majority of the Mapgen settings system.
- MapgenParams is now owned by MapSettingsManager, itself a part of ServerMap,
  instead of the EmergeManager.
- New Script API functions added:
    core.get_mapgen_setting
    core.get_mapgen_setting_noiseparams,
    core.set_mapgen_setting, and
    core.set_mapgen_setting_noiseparams.
- minetest.get/set_mapgen_params are deprecated by the above new functions.
- It is now possible to view and modify any arbitrary mapgen setting from a mod,
  rather than the base MapgenParams structure.
- MapgenSpecificParams has been removed.
2016-07-03 15:38:36 -04:00
Diego Martinez dac40af6ee Server: Add reason for leave to `on_leaveplayer` callbacks 2016-06-11 04:17:04 +01:00
Auke Kok d499ec4838 Particles: Add option to remove particles on collision
Adds the particle option `collision_removal = bool`

Some particles are hard to use right now since they either go through
solid blocks (without collision detection), and with collision
detection enabled they (e.g. raindrops) would just stop dead on the
floor and sit there until they expire, or worse, scrape along a wall
or ceiling.

We can solve the problem by adding a boolean flag that tells the
particle to be removed if it ever collides with something. This will
make it easier to add rain that doesn't fall through your roof or stick
on the top of it. Or clouds and smoke that don't go through trees.

Particles that collide with this flag are marked expired
unconditionally, causing them to be treated like normal expired
particles and cleaned up normally.

Documentation is adjusted accordingly.

An added bonus of this patch is that particles can potentially collide
many times with nodes, and this reduces the amount of collisions to 1
(max), which may end up reducing particle load on the client.
2016-05-28 00:08:23 -04:00
gregorycu b8aed9dfc2 Fixes #4098 ce8a9ed didn't quite go far enough, and left this bug in 2016-05-08 19:03:09 +10:00
obneq 6278da296b Handle particle spawners in env and delete expired ids
Rebased by Zeno (2016-04-2016)
2016-04-28 02:09:36 +10:00
Auke Kok e737b1c271 Nodebox: Allow nodeboxes to "connect"
We introduce a new nodebox type "connected", and allow these nodes to
have optional nodeboxes that connect it to other connecting nodeboxes.

This is all done at scenedraw time in the client. The client will
inspect the surrounding nodes and if they are to be connected to,
it will draw the appropriate connecting nodeboxes to make those
connections.

In the node_box definition, we have to specify separate nodeboxes for
each valid connection. This allows us to make nodes that connect only
horizontally (the common case) by providing optional nodeboxes for +x,
-x, +z, -z directions. Or this allows us to make wires that can connect
up and down, by providing nodeboxes that connect it up and down (+y,
-y) as well.

The optional nodeboxes can be arrays. They are named "connect_top,
"connect_bottom", "connect_front", "connect_left", "connect_back" and
"connect_right". Here, "front" means the south facing side of the node
that has facedir = 0.

Additionally, a "fixed" nodebox list present will always be drawn,
so one can make a central post, for instance. This "fixed" nodebox
can be omitted, or it can be an array of nodeboxes.

Collision boxes are also updated in exactly the same fashion, which
allows you to walk over the upper extremities of the individual
node boxes, or stand really close to them. You can also walk up
node noxes that are small in height, all as expected, and unlike the
NDT_FENCELIKE nodes.

I've posted a screenshot demonstrating the flexibility at
    http://i.imgur.com/zaJq8jo.png
In the screenshot, all connecting nodes are of this new subtype.

Transparent textures render incorrectly, Which I don't think is
related to this text, as other nodeboxes also have issues with this.

A protocol bump is performed in order to be able to send older clients
a nodeblock that is usable for them. In order to avoid abuse of users
we send older clients a "full-size" node, so that it's impossible for
them to try and walk through a fence or wall that's created in this
fashion. This was tested with a pre-bump client connected against a
server running the new protocol.

These nodes connect to other nodes, and you can select which ones
those are by specifying node names (or group names) in the
connects_to string array:
      connects_to = { "group:fence", "default:wood" }
By default, nodes do not connect to anything, allowing you to create
nodes that always have to be paired in order to connect. lua_api.txt
is updated to reflect the extension to the node_box API.

Example lua code needed to generate these nodes can be found here:
    https://gist.github.com/sofar/b381c8c192c8e53e6062
2016-03-12 12:08:17 -05:00
orwell96 0d2df732e5 Fix ask_reconnect_on_crash option being ignored
Since commit

3b50b2766a "Optional reconnect functionality"

there is a config option named ask_reconnect_on_crash.
It asks the client to reconnect to the server if the server crashed.
It has been implemeted and works, but due to a function parameter not
being passed it never showed effect. This patch adds the parameter
and fixes the bug.

Also fixes the `reconnect` option of minetest.request_shutdown being ignored.
2016-03-11 23:43:37 +01:00
est31 d494733839 Add minetest.register_lbm() to run code on block load only 2016-03-07 19:54:26 +01:00
rubenwardy 4efb7eb734 Cache some settings 2016-02-26 00:50:39 +00:00
paramat 4adbd69a37 FindSpawnPos: Let mapgens decide what spawn altitude is suitable
To avoid spawn search failing in new specialised mapgens
Increase spawn search range to 4000 nodes
Add getSpawnLevelAtPoint() functions to EmergeManager, class Mapgen
and all mapgens
Remove getGroundLevelAtPoint() functions from all mapgens except mgv6
(possibly to be re-added later in the correct form to return actual
ground level)
Make mgvalleys flag names consistent with other mapgens
Remove now unused 'vertical spawn range' setting
2016-02-09 07:14:45 +00:00
est31 a4e3ed0136 Update HUD flags on server like on client
Fixes bug for which commit

6c37e89f08 "Fix old client showing duplicated health bar on new server"
by @sapier

laid the groundwork, where the server has
updated its copy of the hud flags without
respecting the mask.

Fixes #3395.
2015-11-22 16:49:20 +01:00
est31 657a16d90c Only allow players with shout to chat
Fix regression of commit

5e507c9829 "Add server side ncurses terminal"

which allowed all players, even those without a shout priv, to chat.

Fixes #3362.
2015-11-13 02:35:02 +01:00
est31 63e7137e3b Put ChatEvent handler into own function
Comply with line limit.
2015-11-09 06:04:24 +01:00
est31 4ae6e509ff Write new line character sequence at end of print()
Fix regression of commit

5e507c9829 "Add server side ncurses terminal"

where no line termination character was printed after a
lua print outside of terminal mode.

Fixes #3350.
2015-11-08 22:56:56 +01:00
est31 5e507c9829 Add server side ncurses terminal
This adds a chat console the server owner can use for administration
or to talk with players.
It runs in its own thread, which makes the user interface immune to
the server's lag, behaving just like a client, except timeout.
As it uses the same console code as the f10 console, things like nick
completion or a scroll buffer basically come for free.
The terminal itself is written in a general way so that adding a
client version later on is just about implementing an interface.

Fatal errors are printed after the console exists and the ncurses
terminal buffer gets cleaned up with endwin(), so that the error still
remains visible.

The server owner can chose their username their entered text will
have in chat and where players can send PMs to.
Once the username is secured with a password to prevent anybody to
take over the server, the owner can execute admin tasks over the
console.

This change includes a contribution by @kahrl who has improved ncurses
library detection.
2015-11-06 08:51:14 +01:00
est31 f9b09368f0 Time: Remove serverside getter, and use atomic operations
It isn't possible to use atomic operations for floats, so don't use them there.

Having a lock is good out of other reasons too, because this way the float time
and the integer time both match, and can't get different values in a race,
e.g. when two setTimeofDay() get executed simultaneously.
2015-11-03 19:07:45 +01:00
ShadowNinja 9269a0ecc7 Fix server crashing on Lua errors
Previously, the server called FATAL_ERROR when a Lua error occured.
This caused a (mostly useless) core dump.
The server now simply throws an exception, which is caught and printed before
exiting with a non-zero return value.
This also fixes a number of instances where errors were logged multiple times.
2015-10-31 13:28:58 -04:00
paramat c0a7c670a4 findSpawnPos: Add setting for max height above water level
Increase default from 6 to 16 to help with mgv7 and mgfractal
Large-scale or alternative mapgens can result in a lowland spawn point not
being found, causing a spawn at (0, 0, 0) possibly buried underground
The max height is now settable to allow correct player spawn
in any mapgen or when using custom noise parameters
2015-10-29 20:03:15 +00:00
est31 ca8e56c15a Environment: Time of day fixes and add serverside getter
-> Put access to time variables under the time lock.
-> Merge both time locks, there is no point to have two locks.
-> Fix the lock being released too early in Environment::setTimeOfDay
-> Add serverside getter so that you don't have to get
	the environment if you only have the server
2015-10-27 23:19:17 +01:00
ShadowNinja 6f2d785d0f Rename macros with two leading underscores
These names are reserved for the compiler/library implementations.
2015-10-14 02:39:37 -04:00
ShadowNinja 6f4d6cb574 Always use errorstream for DEBUG_EXCEPTION_HANDLER 2015-10-14 02:33:30 -04:00
ShadowNinja 96cc5b34fe Use warningstream for log messages with WARNING
Remove DTIME macro and its uses, too
2015-10-14 01:36:48 -04:00
kwolekr f0cd5da687 Define and use limit constants for Irrlicht fixed-width types 2015-10-04 04:00:16 -04:00
est31 2a7d01b833 Some map border related fixes
1. Check for entity addition success in spawn_item implementation
2. Check for success in item_drop callback, so that the player
doesn't lose the item if they are outside bounds and try to drop it.
3. When existing player joins game, check that their position is inside
map bounds. If not, set their position to the return value of findSpawnPos().
4. Make findSpawnPos() respect the border

2 fixes a lua crash if a player drops an item outside map bounds.
3 fixes an assertion crash if a player leaves when being outside map bounds,
and then rejoins.
2015-09-29 23:06:15 +02:00
Loic Blot 9c635f28ac Little optimization on getAdded/Removed activeobjects per player loop.
Use std::queue instead of std::set, we don't need such a heavy container.
Don't convert position to int to convert it back to float in the next function.
2015-09-19 20:57:07 +02:00
est31 94f1e5d9bd Send proper block to old clients for swap_node calls
The legacy code added in commit

d879a539cd - "Add minetest.swap_node"

for sending the whole mapblock to older clients on the case of a node
modification with swap_node, had the problem that the block chosen to be
sent to the client was referenced with node coordinates and not with
block coordinates, resulting in getting the wrong block sent to the client.
2015-09-17 20:23:31 +02:00
David Jones 34b7a147dc Change i++ to ++i 2015-08-25 18:33:52 -04:00
ShadowNinja e4bff8be94 Clean up threading
* 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.
2015-08-23 22:04:06 -04:00
est31 a8e238ed06 Add count based unload limit for mapblocks 2015-08-13 07:56:07 +02:00
rubenwardy a953ff4dfc Fix segfaults caused by the Environment not being initialized yet 2015-08-09 23:36:55 +02:00
Břetislav Štec a5e5aa5be9 Prepend "Lua: " before lua exceptions
src/server.cpp
src/emerge.cpp
2015-08-02 02:17:37 -04:00
Loic Blot 05fe9ab2d4 Small SendableMediaAnnouncement cleanup
-> Remove the SendableMediaAnnouncement struct
-> Forge the packet directly in the m_media loop, spare one loop and the construction of a vector
-> Use preincrement to spare iterator copies
2015-07-31 01:01:00 +02:00
Loic Blot 4e6971e593 Cleanup server addparticle(spawner) by merge two identical functions. 2015-07-25 12:24:28 +02:00
est31 3b50b2766a Optional reconnect functionality
Enable the server to request the client to reconnect.

This can be done with the now extended minetest.request_shutdown([reason], [reconnect]) setting.
2015-07-23 07:38:13 +02:00
est31 bf7174f3f9 Server kicks: make messages configurable, cache wstring 2015-07-17 06:37:16 +02:00
nerzhul f9dbec6edf Kick players when shutting down server and there is a crash due to a Lua stack exception 2015-07-16 20:27:42 +02:00
kwolekr 1a1774a105 Fix damage flash when damage disabled 2015-07-10 15:58:57 -04:00
est31 b0784ba871 Use UTF-8 instead of narrow
Use wide_to_utf8 and utf8_to_wide instead of wide_to_narrow and narrow_to_wide at almost all places.
Only exceptions: test functions for narrow conversion, and chat, which is done in a separate commit.
2015-07-08 10:12:44 +02:00
kwolekr 7b171ea2be Fix code style from recent commits and add misc. optimizations 2015-07-02 23:14:30 -04:00
rubenwardy 0d65ee878c Add Lua errors to error dialog 2015-06-29 04:47:35 +02:00
est31 3d43df99f1 Return to ignore 2015-06-24 22:47:41 +02:00
TeTpaAka 17ba584fe2 Fix bug when craft input isn't replaced 2015-06-22 19:30:35 +02:00
TeTpaAka c0335f7d13 Add some missing getter functions to the lua API
ObjectRef:
get_properties
get_armor_groups
get_animation
get_attach
get_bone_position

Players:
get_physics_override
hud_get_hotbar_itemcount
hud_get_hotbar_image
hud_get_hotbar_selected_image
get_sky
get_day_night_ratio
get_local_animation
get_eye_offset

Global:
minetest.get_gen_notify
minetest.get_noiseparams
2015-05-28 16:46:35 +02:00
rubenwardy 603297cc35 Add texture overriding 2015-05-19 21:27:07 +02:00
est31 497299afd6 Lower log level for unexpected behaviour
Its a possible mistake to log in to a server with twice the same name.
Before, it triggered a server wide error message, now it logs to actionstream.
2015-05-19 00:55:58 +02:00
ShadowNinja 3a8c788880 Add mod security
Due to compatibility concerns, this is temporarily disabled.
2015-05-16 18:32:31 -04:00
est31 82e35edff5 Make early protocol auth mechanism generic, and add SRP
Adds everything needed for SRP (and everything works too),
but still deactivated, as protocol v25 init packets aren't final yet.
Can be activated by changing the LATEST_PROTOCOL_VERSION header to 25
inside networkprotocol.h.
2015-05-11 18:40:27 +02:00
est31 33c11415bf Gracefully handle PacketErrors 2015-05-08 06:51:03 +02:00
est31 ccc09abc2d Protocol 25: wstring -> string for custom access denial reasons
Also fix std::logic_error when server::DenyAccess() is used with only two arguments.
2015-04-22 14:10:39 +02:00
kwolekr 479f38973e Schematics: Refactor NodeResolver and add NodeResolveMethod
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.
2015-04-16 16:27:05 -04:00
Ner'zhul ce8a9ed94b Fix a rare crash case un SendPlayerHP
If the player is disconnected while Lua API is doing a l_punch call, for example, the playersao is NULL and the server crash. Fix it.
2015-04-11 10:07:23 +02:00
Loic Blot 5132908f4b TOCLIENT_ACTIVE_OBJECT_MESSAGES: channel must be 1 for unreliable message 2015-04-07 14:28:36 +02:00
Loic Blot 8804c47e59 TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD can be unreliable, catch PacketError exception.
Also set the packet size at creation not when pushing rawString, no functional change
2015-04-05 11:39:38 +02:00
est31 334e70455b Crafting speedup
This greatly increases crafting performance, especially in worlds with many mods.

Approved by @kwolekr.

Introduces a hash-type-layered fall-through mechanism, where every layer specifies one hash algorithm,
and the "deeper the fall", the more collisions to expect for the algorithm. One Craft definition
only resides at one layer, which improves speed for lower layers (and a complete fail), due to most
craft definitions residing at high layers.

Due to the fall-through design, the undocumented behaviour that later craft recipes
override older ones had to be weaked up a bit, but craft recipes with the same hash and layer
will still override.
2015-04-05 09:25:46 +02:00
Loic Blot 470de10de3 Fix players spawned at (0,0,0) in some rare cases instead of static_spawnpoint, if set
Approved by: @kwoelkr
2015-04-03 09:44:36 +02:00
Craig Robbins 9527984dbc Move globals from main.cpp to more sane locations
Move debug streams to log.cpp|h

Move GUI-related globals to clientlauncher

Move g_settings and g_settings_path to settings.cpp|h

Move g_menuclouds to clouds.cpp|h

Move g_profiler to profiler.cpp|h
2015-04-01 23:04:25 +10:00
Loic Blot 1fe4256462 Connection::Receive(): receive Network Packet instead of SharedBuffer<u8>.
Because we get a Buffer<u8> from ConnectionEvent, don't convert it to SharedBuffer<u8> and return it to Server/Client::Receive which will convert it to NetworkPacket
Instead, put the Buffer<u8> directly to NetworkPacket and return it to packet processing
This remove a long existing memory copy
Also check the packet size directly into Connection::Receive instead of packet processing
2015-03-31 11:01:08 +02:00
ShadowNinja 93fcab952b Clean up and tweak build system
* Combine client and server man pages.
  * Update unit test options and available databases in man page.
  * Add `--worldname` to man page.
  * Fix a bunch of places where `"Minetest"` was used directly instead of `PROJECT_NAME`.
  * Disable server build by default on all operating systems.
  * Make `ENABLE_FREETYPE` not fail if FreeType isn't found.
  * Enable LevelDB, Redis, and FreeType detection by default.
  * Remove the `VERSION_PATCH_ORIG` hack.
  * Add option to search for and use system JSONCPP.
  * Remove broken LuaJIT version detection.
  * Rename `DISABLE_LUAJIT` to `ENABLE_LUAJIT`.
  * Rename `minetest_*` variables in `version.{h,cpp}` to `g_*`.
  * Clean up style of CMake files.
2015-03-27 15:00:48 -04:00
Loic Blot 7851c4f7a2 Don't send an InventoryAction at each setInventoryModified, we only need one SendInventory per inventory modification
Client doesn't like to receive multiples SendInventory for one action, this can trigger glitches on clients (sometimes due to incorrect UDP packet ordering due to UDP protocol)

This fix issue #2544
2015-03-24 14:13:17 +01:00
est31 538036d004 Fix game minetest.conf default settings
This was a regression introduced by f6e4c5d9cf .
2015-03-18 13:03:02 -04:00
Loic Blot 7685969274 Server::step throw is never catched in minetestserver
Replace it with an errorstream + assert for server

This throw can be trigger by LuaError exception or ConnectionBindFailed exception in the following functions:
* EmergeThread::Thread()
* ScriptApiEnv::environment_Step()
* ScriptApiEnv::player_event()
* ServerThread::Thread()
2015-03-17 15:26:20 +01:00
Loic Blot bfc4652c66 Fix a little regression on SendActiveObjectMessages which send all TOCLIENT_ACTIVE_OBJECT_MESSAGES as reliable 2015-03-17 09:16:39 +01:00
kwolekr 699d42efc6 Revert "Server::step throw is never catched. Replace it with an errorstream + assert"
This reverts commit 5f8e48c63b.
2015-03-16 21:17:27 -04:00
Loic Blot 5f8e48c63b Server::step throw is never catched. Replace it with an errorstream + assert
This throw can be trigger by LuaError exception or ConnectionBindFailed exception in the following functions:
* EmergeThread::Thread()
* ScriptApiEnv::environment_Step()
* ScriptApiEnv::player_event()
* ServerThread::Thread()
2015-03-16 20:25:35 +01:00
Loic Blot e7736ffdd6 Move TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD and TOCLIENT_ACTIVE_OBJECT_MESSAGES to private functions 2015-03-16 12:01:40 +01:00
Loic Blot b2801d8127 SendPlayerHPOrDie everytime at client connection, damage enabled or not, this will fix the player which stay dead at connection 2015-03-15 19:09:26 +01:00
Loic Blot 083c8c734e Replace NetworkPacket pointers to references 2015-03-13 22:01:49 +01:00
Loic Blot 74d34da6cb Prepare Protocol v25 init & authentication.
* TOSERVER_INIT and TOCLIENT_INIT renamed to _LEGACY
* TOSERVER_PASSWORD merged from dev-0.5, can use protocol v24 and v25
* TOCLIENT_ACCESS_DENIED merged from dev-0.5, can use protocol v24 and v25, with normalized strings an a custom id for custom errors
* new TOSERVER_INIT packet only send MT version, supported compressions, protocols and serialization, this permit to rework everything later without break the _INIT packet
* new TOSERVER_AUTH packet which auth the client
* new TOCLIENT_HELLO packet which send server serialization version atm
* new TOCLIENT_AUTH_ACCEPTED which is send when TOCLIENT_AUTH was okay. After this packet, the client load datas from servers, like after TOCLIENT_INIT_LEGACY packet
2015-03-13 20:23:03 +01:00
Loic Blot 126f36c2e6 Rename some packet and handlers to <packet>_Legacy name for compat layer between new network changes and old network clients 2015-03-13 13:40:48 +01:00
Loic Blot 4e63c977c7 Use the new Player::isDead function when it's the case 2015-03-13 08:57:58 +01:00
ngosang f6e4c5d9cf Respect game mapgen flags and save world noise params 2015-03-07 15:53:39 -05: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
Loic Blot aa474e4501 Server.cpp Use std::list instead of std::vector for playSound, fillMediaCache, sendRequestedMedia, sendMediaAnnouncement and related functions 2015-03-05 11:40:04 +01:00
Loic Blot 82482ecd9d Server::AsyncRunStep: buffered_messages now uses std::vector instead of std::list. * sendRemoveNode and sendAddNodes are also converted as a side effect 2015-03-05 11:23:54 +01:00
Loic Blot 365e4ae0fa Performance improvement: Use std::list instead of std::vector for request_media, Server::getModNames, Environment::m_simple_objects.
* Also remove unused Server::m_modspaths
2015-03-05 10:44:48 +01:00
Loic Blot b214cde5b4 Remove Queue class which uses std::list and use native std::queue 2015-03-05 16:49:51 +10:00
Loic Blot 2066655aae ClientInterface::getClientIDs doesn't need a std::list. Use a std::vector for better perfs 2015-03-04 16:30:24 +01:00
Loic Blot 7e088fdfe3 We always know playerSAO when calling SendInventory. Using it instead of searching it via peer_id 2015-03-04 15:28:33 +01:00
Loic Blot 40bf1d7b5f Send Position packet on event, don't check it at each AsyncRunStep.
* This permit to cleanup the player checking loop
2015-03-04 12:19:26 +01:00
Loic Blot 7f8f9785d7 ASyncRunStep doesn't need to lock when do setTimeOfDaySpeed.
* setTimeOfDaySpeed already lock a mutex when modify the value, we don't need to lock all environment.
* add a fine grain lock for getTimeOfDay and setTimeOfDay to solve environment multithread modifications on this value
2015-03-04 11:46:31 +01:00
Loic Blot 1b2f64473e Send Inventory packet on event, don't check it at each AsyncRunStep.
* Call UpdateCrafting into SendInventory because this functions is only called before SendInventory
* Use Player* instead of peer_id for UpdateCrafting because SendInventory already has the Player* pointer, then don't loop for searching Player* per peer_id
* m_env_mutex don't need to be used with this modification because it's already locked before the calls
2015-03-04 11:29:39 +01:00
Loic Blot 038d3a31df Remove unused m_wielded_item_not_sent 2015-03-03 17:36:54 +01:00
Loic Blot 7e56637ed0 Send Breath packet on event, don't check it at each AsyncRunStep 2015-03-03 16:33:20 +01:00
Loic Blot 64ff966bae Send Player HP when setHP (or a setHP caller) is called instead of looping and testing the state change. 2015-03-03 16:06:04 +01:00
Loic Blot 009149a073 Fix some memory leaks on packet sending. 2015-02-21 17:27:31 +01:00
Loic Blot 5a5854ea9d Move hex.h to util/ 2015-02-21 14:32:35 +01:00
Loic Blot 3998a1f8f9 Move sha1.hpp and base64.hpp to util/ 2015-02-21 14:03:27 +01:00
Loic Blot 27d4e89d32 Fix unused (and so, broken) enable_rollback_recording. This option must be reloaded at server loop but loaded when server starts, for data consistency (not a hot load variable)
ok @ShadowNinja
2015-02-18 09:28:39 +01:00
Loic Blot ed04e8e9e4 [Patch 2/4] Network rework: packet writing, sending and cleanups
NetworkPacket.cpp:
* Remove some deprecated functions, we must use streaming interface
* m_data converted from u8* to std::vector<u8>
* Add an exporter to forge packet to Connection object
* implement operator << std::wstring. n
* implement operator << std::string
* dynamic resize when write packet content.
* fix string writing and performances.
* create ServerCommandFactory, used by client to get useful informations about packet processing (sending).
  * Reliability
  * Transmit channel
* Implement putRawString for some ugly char (_INIT packet), and use it.
* Many packet read and write migrated
* Implement oldForgePacket to interface writing with current connection
* fix U8/char/bool writing
* fix string writing and performances.
* add some missing functions
* Use v3s16 read instead of reading x,y,z separately
* Add irr::video::SColor support into packets
* Add some missing handlers
* Add a template function to increase offset
* Throw a serialization error on packet reading (must be improved)

PacketFactories:
* Create ServerCommandFactory, used by client to get useful informations about packet processing (sending).
* Create ClientCommandFactory, used by server to get useful informations about packet processing (sending).

Client.cpp:
* implement NetworkPacket ::Send interface.
* Move packet handlers to a dedicated file
* Remove Client::Send(SharedBuffer)

Server.cpp:
* implement NetworkPacket ::Send interface.
* Rewrite all packets using NetworkPacket
* Move packet handlers to a dedicated file
* Remove Server::Send(SharedBuffer)

ClientIface.cpp:
* Remove sendToAll(SharedBuffer<u8>)

Connection.hpp rework:
* Remove duplicate include
* Remove duplicate negation
* Remove a useless variable
* Improve code performance by using a m_peers_list instead of scanning m_peers map
* Remove Connection::Send(SharedBuffer)
* Fix useafterfree into NetworkPacket Sending
* Remove unused Connection::sendToAll

Test.cpp:
* Remove dead code
* Update tests to use NetworkPackets

Misc:
* add new wrappers to Send packets in client, using NetworkPacket
* Add NetworkPacket methods for Connection
* coding style fix
* dead code since changes cleanup
* Use v3s16 read instead of reading x,y,z separately in some packets
* Use different files to handle packets received by client and server
* Cleanup: Remove useless includes

ok @Zeno-
Tested by @Zeno- @VanessaE and @nerzhul on running servers
2015-02-16 11:00:55 +01:00
Loic Blot bb59a8543d Replace getPlayer(playername) by getPlayer(peer_id) in some possible cases. ok @Zeno- 2015-02-10 16:03:16 +01:00
Loic Blot a704c04f00 Network Layer 7 rework (Packet handling)
* Move networkcode to a dedicated directory
* Rename clientserver.h to network/networkprotocol.h (Better name) and sanitize some includes
* Create object NetworkPacket
  * It stores command (opcode) and data separated
  * It also stores peer_id
  * Data reading can be done by using a streaming interface
* Change packet routing analysis
  * Remove old conditional analysis
  * Now uses function pointed analysis and add connection state ({Client,Server}::handlers)
  * Connection state permit to categorize condition to handle before analyze packets
  * Create a handler for depreciated messages, instead of duplicating code
2015-02-10 20:04:08 +10:00
SmallJoker 929e0b0ad8 Give full breath after death 2015-02-05 17:33:08 +10:00
Loic Blot 80a7408e4d Fix a crash (assert) when client set serial version < 24 in INIT
When SER_FMT_VER_LOWEST is set to zero, then the test is stupid in INIT because all client works. In mapblock we check if client's serialization version is < 24, but if client sent serialization version < 24 (15 for example) the server set it and tried to send nodes, then BOOM

To resolve the problem:
* Create a different CLIENT_MIN_VERSION to handle this problem
* Remove the exception
* Use an assert in case of bad developer code
2015-01-27 16:55:25 +01:00
Kahrl f8bd1f3563 Fix uninitialized variable Server::m_next_sound_id 2015-01-24 06:44:41 +01:00
ShadowNinja a9f81b729b Send real port to server list 2015-01-23 21:38:34 +10:00
onkrot 0fd1ee0380 Performance fixes. 2015-01-13 23:48:56 +10:00
kwolekr cd4d213ae0 NodeResolver: Perform callback immediately if node registration phase finished
Also add NodeResolver callbacks on the client
2015-01-04 16:32:31 -05:00
kwolekr a3d7203be5 Fix map parameter load order 2014-12-30 12:30:42 -05:00
kwolekr 5e2753c712 Expose mapgen parameters on scripting init
Add minetest.get_mapgen_params()
Deprecate minetest.register_on_mapgen_init()
2014-12-29 12:59:59 -05:00
Craig Robbins 3993102e88 Fix -Wtype-limits warnings and remove disabling of -Wtype-limits 2014-12-29 23:56:40 +10:00
kwolekr b67f37f27e Redefine NodeResolver interface and replace with callback mechanism 2014-12-27 02:12:21 -05:00
Anton 10e0cf8b2c Use std::string::empty() instead of size() where applicable 2014-12-12 15:16:24 -05:00
Craig Robbins 9f65fd6819 Fix typo in mapblock.h 2014-12-12 20:46:37 +10:00
Muhammad Rifqi Priyo Susanto 5ffddc94c0 Add space between client names in status text (client)
Before:
Server: version=0.4.10, uptime=190.5, max_lag=0.001, clients={user1,user2,user3,user4,user5,foobar,userplayedminetestthismorning}

After:
Server: version=0.4.10, uptime=190.5, max_lag=0.001, clients={user1, user2, user3, user4, user5, foobar, userplayedminetestthismorning}
2014-12-07 21:32:08 +10:00
ShadowNinja b1965ac209 Clean up rollback 2014-11-19 16:21:59 -05:00
Craig Robbins 5b8855e83c Remove most exceptions from getNode() (and variants) 2014-11-14 18:05:34 +10:00
Kahrl 0adadba218 Serverlist: announce mg_name from map_meta.txt instead of minetest.conf 2014-11-10 22:27:10 +01:00
SmallJoker c40e993ce4 Replace setting unlimited_player_transfer_distance with player_transfer_distance 2014-11-08 14:56:09 +01:00
kwolekr 9e811a92e7 Split up mapgen.cpp 2014-11-01 13:16:23 -04:00
kwolekr d274cbfce6 Add NodeResolver and clean up node name -> content ID resolution system 2014-10-26 23:55:45 -04:00
RealBadAngel d221917170 Recalculate normals for cached meshes.
Check if mesh is here before adding to meshcollector.

Fix deleting the meshes.
2014-10-21 18:43:29 +02:00
ShadowNinja e9c9b66ae9 Make players check inventory modification properly 2014-10-01 18:44:36 -04:00
ShadowNinja cd0df0d5e7 Simplify player modification checks 2014-10-01 18:44:36 -04:00
ShadowNinja c061bdd37f Fix locking bugs and make inventory deserialization errors more specific 2014-09-21 14:39:36 -04:00
sapier dec8c43de3 Fix to to too two times 2014-08-22 21:51:20 +02:00
sapier d7d8aa1039 Add player name length checks 2014-08-22 21:18:43 +02:00
sapier 8e9d896f2d Fix "ghost" blocks if block update is "on wire" while player digs nodes 2014-08-22 20:56:16 +02:00
sapier 2a5c88bde1 Don't call a player event without having player to do a event for 2014-08-21 17:29:26 +02:00
sapier d38f6ebb9b Fix error handling on inconsistent client ready message
Fix android makefile to provide a correct dummy githash if detection fails
2014-07-16 20:01:00 +02:00
ShadowNinja 9afeb97fc6 Fix serverlist code style, const-correctness, and types 2014-06-30 13:26:02 -04:00
sapier ff36071d93 Don't spam server console on player/playersao error but just drop the affected client 2014-06-29 17:55:21 +02:00
sapier ebf7ea5019 Add formspec api versioning 2014-06-29 12:13:55 +02:00
kwolekr c91f8b1d25 Add prefixes to enum values and fix style issues 2014-06-28 02:02:38 -04:00
ShadowNinja 7e6db1b803 Only keep players loaded while they're connected 2014-06-23 15:45:59 -04:00
sapier a0097c6bfa Fix uncought deserialization error on receiving data 2014-06-22 00:05:41 +02:00
sapier f8522d50e7 Fix server assert in case of invalid message from client, just kick that client. 2014-06-21 23:56:46 +02:00
sapier d76b8c6e7c Small cleanup of hud add/remove code 2014-05-31 22:32:44 +02:00
sapier 73e5bc9c01 Add joining player to printed player list 2014-05-20 18:09:32 +02:00
sapier 6c37e89f08 Fix old client showing duplicated health bar on new server
Fix client not showing hearts and bubbles on connecting to old server
Fix server not remembering hud flags correctly
2014-05-11 22:34:44 +02:00
sapier f76b9d724b Fix possible deadlock in error conditions 2014-05-11 00:14:57 +02:00
ShadowNinja 1cd512913e Organize builtin into subdirectories 2014-05-07 17:14:23 -04:00
sapier d3ee617f37 Fix heart + bubble bar size on different texture packs
Add DPI support for statbar
Move heart+bubble bar to Lua HUD
Add statbar size (based upon an idea by blue42u)
Add support for customizing breath and statbar
2014-05-07 21:46:27 +02:00
sapier 555dc86343 Add missing ip address to player join log entry 2014-04-21 22:28:52 +02:00
sapier a0dd2d89f3 Reduce log level for incoming crap packets
Add log entry for peer timeout
2014-04-19 22:12:01 +02:00
BlockMen 8b02a015eb Use integers instead of float values 2014-04-12 20:04:12 +02:00
BlockMen c0ab09af74 Add player:set_eye_offset() by @MirceaKitsune and clean up 2014-04-12 17:44:20 +02:00
BlockMen a1db9242ec Add third person view 2014-04-12 17:44:15 +02:00
Kahrl 6090e95cdc Infer ipv6_server from bind_address; fix client connect to IN(6)ADDR_ANY 2014-04-10 22:03:42 +02:00
sapier edcad09dee Add support for named threads (atm linux only) 2014-04-09 21:32:21 +02:00
sapier 142e2d3b74 Cleanup client init states by bumping protocol version
Don't use TOSERVER_RECEIVED_MEDIA but TOSERVER_CLIENT_READY as indicatio for client ready
Handle clients with protocol version < 23 (almost) same way as before
Make client tell server about it's version
Add client state to not send bogus player position updates prior init complete
Add access to statistics information (peer connction time,rtt,version)
Fix clients standing stalled in world while preloading item visuals (new clients only)
Add get_player_information to read client specific information from lua
2014-04-08 21:12:20 +02:00
Selat 7cac34c807 Pass arguments by reference 2014-03-12 17:34:48 -04:00
ShadowNinja 9a3b7715e2 Remove "Server -!- " prefix from player messages 2014-02-27 00:00:22 -05:00
kwolekr 3570f3e396 Add minetest.set_noiseparam_defaults() Lua API 2014-02-15 19:13:14 -05:00
sapier ded5f8b1a6 Fix possible missing unlock of env_lock 2014-02-12 19:47:27 +01:00
kwolekr 89f7dc1efd ServerEnvironment: Remove direct dependency on EmergeManager 2014-02-09 16:36:30 -05:00
ShadowNinja 85fe75d1cb Add the option to bind to a specific address 2014-02-05 21:24:46 +01:00