Commit Graph

168 Commits

Author SHA1 Message Date
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
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
Auke Kok 6738c7e9a3 Do not increase breath if at full breath.
Prevents the server from sending TOCLIENT_BREATH packets
every 0.5seconds, if there is no reason to.
2017-03-11 17:00:40 -08:00
Ekdohibs d873545ac7 Fix anticheat resetting client position after the client is teleported
Previously, m_move_pool could accomodate the client moving from the new
position to the old one, and the server accepted the client to go back
to its old position. However, it couldn't then accomodate the client
moving from its old to its new position, and therefore would reset position
to the old position. Thus, by emptying m_move_pool after a teleport, the
server no longer accepts the client to go back to its old position. A
drawback is however that a laggy client *will* trigger a few
"moved_too_fast" anticheats before being told about its new position.

Don't report player cheated if caused by lag.

Fixes #5118
2017-02-01 15:03:57 +00:00
sapier 814ee971f7 Make entity on_punch have same signature and behaviour as player on_punch 2017-01-28 15:57:54 +01:00
Loïc Blot b7a98e9850 Implement player attribute backend (#4155)
* This backend permit mods to store extra players attributes to a common interface.
* Add the obj:set_attribute(attr, value) Lua call
* Add the obj:get_attribute(attr) Lua call

Examples:
* player:set_attribute("home:home", "10,25,-78")
* player:get_attribute("default:mana")

Attributes are saved as a json in the player file in extended_attributes
key

They are saved only if a modification on the attributes occurs and loaded
when emergePlayer is called (they are attached to PlayerSAO).
2017-01-27 08:59:30 +01:00
Loïc Blot bc29e03b59 Revert "Detach the player from entities on death." (#5087) 2017-01-21 17:30:55 +01:00
sapier c57b4ff9b5 Add Entity get_texture_mod() to Lua API
Send texture modifier to clients connecting later too
2017-01-21 17:01:02 +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
SmallJoker dd282e646c Fix MSVC build Build broken by 98e36d7 2017-01-19 20:19:53 +01:00
Loic Blot ef0aa7d5b5 Optimize SAO getStaticData by using std::string pointer instead of return copy
Signed-off-by: Loic Blot <loic.blot@unix-experience.fr>
2017-01-13 21:56:24 +01:00
Rogier e2dd96b432 Cleanup content_sao by factorizing similar code parts
Signed-off-by: Loic Blot <loic.blot@unix-experience.fr>
2017-01-13 21:56:24 +01:00
Rogier 6647939403 Performance fix + SAO factorization
Original credits goes to @Rogier-5

* Merge common attributes between LuaEntitySAO & PlayerSAO to UnitSAO
* Make some functions const
* Improve some lists performance by returning const ref

Signed-off-by: Loic Blot <loic.blot@unix-experience.fr>
2017-01-11 15:53:56 +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
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
TeTpaAka 785a9a6c1a Wieldhand: Allow overriding the hand 2016-11-26 03:49:30 +00:00
Rogier-5 7e17eaedb2 Fix mob deserialization errors in the client (#4743)
The problem was seen while using the mobf mod package.

The problem happens when the server serializes entity attachments.
Sometimes, such attachments no longer exist. The serialization code
skips those. However, the total number of attachments was serialized
earlier.  Therefore the client expects more than it gets, and logs a
serialization error.
2016-11-10 13:42:49 +01: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
Loic Blot 595932a860 Fix overloading problems mentioned by clang 2016-10-30 16:30:55 +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
Foghrye4 ad163ee5c3 Prevent attached models from disappearing during parent reload (#4128) 2016-10-08 14:51:25 +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 c0cd7aa351 Anticheat: Use the physics_override modifiers aswell 2016-09-09 01:03:36 -04:00
Rogier-5 35f47e5461 Add infotext containing entity type (e.g. mobs:cow) to unknown entities (#4431)
If a mod is disabled, or upgraded without sufficient backward compatibility,
then entities it has put into the world become unknown, and continue moving
around, but are completely unrecognisable.

This change allows the player to see their type, and therefore which mod is
or was responsible.
2016-08-11 00:22:32 +02:00
nerzhul fefa148d69 v2d & aabbox3d<f32> & sky cleanups
* Sky: rename Box => m_box and inline getBoundingBox
* Uniformize aabbox3d<f32> to aabb3f
2016-02-11 16:55:15 +01:00
est31 4e93ba06a7 Don't pass non-const references to collision methods
Non const references cause a lot of confusion with behaviour of code,
and are disallowed by minetest style guide.
2016-01-29 15:53:54 +01:00
Sapier 70ea5d552e Add support for limiting rotation of automatic face movement dir entitys 2015-12-19 17:00:36 +01:00
BlockMen 9eee3c3f46 Add option to give every object a nametag
or change the nametag text of players
2015-12-15 23:32:19 +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
Loic Blot 596484da4f Save and remove player by pointer
Why doing things simple ? Use pointer instead of strings to save players and remove them.
Saving players by name does a lookup to find pointer we already have ! Idem with removePlayer
Also remove unused removePlayer(peer_id), it's never called
2015-09-23 19:37:05 +02:00
Loic Blot fa7fe510d9 Remove profiler.h include where it's not needed. Remove some unreachable and very old code 2015-07-21 08:10:43 +02:00
TeTpaAka 8d03301138 Fix invisible player when the attached entity is removed 2015-07-18 07:41:43 +02:00
MirceaKitsune 660fa516bf Fix some issues with animations, and allow non-looped animations to be defined 2015-06-22 01:53:38 +02:00
SmallJoker bb5f830d16 Ignore punches with no damage in the actionstream 2015-06-15 00:10:13 +02:00
TeTpaAka aa13baa30a Add minetest.register_on_player_hpchange 2015-06-13 19:40:31 +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
est31 21878c9d5c Spare some string copies 2015-05-27 11:45:40 +02:00
TeTpaAka 18c2f16c13 Generalize core.get/set_nametag_color into core.get/set_nametag_attributes 2015-05-15 16:21:01 -04:00
Brandon c5b4e54174 Add minetest.register_on_punchplayer 2015-05-15 11:09:55 +02:00
TeTpaAka 86a963caca Add get and set functions for the nametag color 2015-05-15 11:03:27 +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 2676d289d9 Reset the old HP method on PlayerSAO::setHP 2015-03-19 07:47:45 +01: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 b214cde5b4 Remove Queue class which uses std::list and use native std::queue 2015-03-05 16:49:51 +10: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