Commit Graph

129 Commits

Author SHA1 Message Date
SmallJoker
7832b6843e
Server-side authority for attached players ()
The server must have authority about attachments. This commit ignores any player movement packets as long they're attached.
2021-02-15 20:41:19 +01:00
sfan5
674d67f312 Encode high codepoints as surrogates to safely transport wchar_t over network
fixes 
2021-02-02 20:46:08 +01:00
sfan5
c834d2ab25 Drop wide/narrow conversion functions
The only valid usecase for these is interfacing with OS APIs
that want a locale/OS-specific multibyte encoding.
But they weren't used for that anywhere, instead UTF-8 is pretty
much assumed when it comes to that.
Since these are only a potential source of bugs and do not fulfil
their purpose at all, drop them entirely.
2021-02-02 20:46:08 +01:00
SmallJoker
7ebd5da9cd Server GotBlocks(): Lock clients to avoid multithreading issues 2021-02-02 19:10:35 +01:00
sfan5
112a6adb10
Cache client IP in RemoteClient so it can always be retrieved ()
specifically: after the peer has already disappeared
2021-01-31 20:36:47 +01:00
sfan5
74762470b2 Fix some minor code issues all over the place 2020-12-24 13:44:54 +01:00
sfan5
ad58ece180 serverpackethandler: Minor log message fixes
closes 
2020-11-12 21:08:26 +01:00
rubenwardy
7589cbe086
Fix object interaction distance not being checked () 2020-11-09 11:55:15 +01:00
SmallJoker
0d128ab344
Inventory: Protect Craft and Drop actions ()
Change dangerous pointer to unique_ptr for automated deletion.
2020-09-07 21:19:38 +02:00
Lejo
6dcc9e6331
Prevent interacting with items out of the hotbar () 2020-09-04 20:50:33 +02:00
HybridDog
f5df70764d
[2] Code cleanup in serverpackethandler ()
* Code cleanup in serverpackethandler

* do not define p_under unless a node is pointed
* use switch-case and reduce indentation
2020-09-01 08:08:18 +02:00
Lars Müller
3693b6871e
Prevent players accessing inventories of other players () 2020-08-29 16:41:03 +01:00
ANAND
291a6b70d6 Allow binding dig, place actions to keys; remove LMB/RMB hardcoding
Co-authored-by: Sam Caulfield <sam@samcaulfield.com>
2020-08-15 12:19:20 +03:00
Lars Müller
e7e065f553
Exposing the zoom key to Lua API ()
Co-authored-by: Raul Ferriz <raul.ferriz@gmail.com>
2020-06-13 22:46:20 +02:00
sorcerykid
15ba75e4cf Add on_authplayer callback and 'last_login' to on_joinplayer ()
Replace on_auth_fail callback with more versatile on_authplayer
    Better clarify account login process in Lua API documentation
    Change initial timestamp for newly registered accounts to -1
2020-05-23 13:25:29 +02:00
sfan5
a08251a61e Log protocol ver on mismatched client connect too 2020-05-16 12:03:36 +02:00
Loïc Blot
454dbf83a9
Server class code cleanups ()
* Server::overrideDayNightRatio doesn't require to return bool
There is no sense to sending null player, the caller should send a valid object

* Server::init: make private & cleanup
This function is always called before start() and loads some variables which can be loaded in constructor directly.
Make it private and call it directly in start

* Split Server inventory responsibility to a dedicated object

This splits permit to found various historical issues:
* duplicate lookups on player connection
* sending inventory to non related player when a player connects
* non friendly lookups on detached inventories ownership

This reduce the detached inventory complexity and also increased the
lookup performance in a quite interesting way for servers with thousands
of inventories.
2020-05-07 22:38:41 +02:00
sfan5
d1c6cc72cc
Server: Improve some log messages () 2020-05-05 17:05:11 +02:00
EvidenceB Kidscode
cee3c5e73d
Add server side translations capability ()
* Add server side translations capability
2020-04-25 07:20:00 +02:00
HybridDog
7b57d3f613
serverpackethandler: Reduce pkt->getPeerId() invocations and more () 2020-04-18 17:19:53 +02:00
Loic Blot
894a34aef4 Move PlayerSAO to dedicated files 2020-04-11 16:07:17 +02:00
sfan5
e774d8ca2f Fixes around ServerActiveObject on_punch handling 2020-03-05 22:04:23 +01:00
sfan5
4d668f32a6 Call on_secondary_use when object is right-clicked 2019-11-10 13:12:31 +01:00
sfan5
d77ea76476
Fix broken build
The variable name changed but this didn't cause merge conflicts, so it wasn't caught before.
2019-09-23 00:28:26 +02:00
sfan5
70f9e1aafa
Punchwear (improved) () 2019-09-22 22:12:21 +02:00
SmallJoker
5fa614d97e
Wieldhand: Specify which ItemStack to use ()
Makes 'get_wield_item' to return the "main" ItemStack
2019-09-21 11:44:24 +02:00
sfan5
5c9983400f Remove incorrect MutexAutoLock
The line declared a variable "m_con" instead of locking m_con.
getClient() doesn't need this anyway, so remove it.
2019-09-19 16:46:41 +02:00
ANAND
81c7f0ae04 Send ActiveObjects once right after Init2 2019-09-14 20:16:55 +02:00
SmallJoker
9acd36bf99 Formspecs: Introduce formspec_version to mods 2019-09-14 19:43:08 +02:00
SmallJoker
fae6242d4e Send cumulated inventory changes only each step ()
Applies to player and detached inventories
2019-09-09 19:19:54 +02:00
SmallJoker
0b4f424f41
Inventory: Send dirty lists where appropriate ()
This change reduces the amount of sent data towards clients. Inventory lists that are already known to the player are skipped, saving quite some data over time.

Raises protocol version to 38 to ensure correct backwards-compatible code.
2019-08-24 19:07:38 +02:00
Jozef Behran
86d7f84b89 Merge pull request from osjc/FixGetNode
Finish getNode cleanup
2019-08-10 19:45:44 +02:00
ANAND
e788ee283f Client::Interact: Use InteractAction enum instead of numeric constants
This replaces the magic numbers used as interaction modes both client-side and server-side, primarily for the sake of ease-of-readability.
2019-08-07 19:21:14 +02:00
SmallJoker
e462a9a5ef
Unify wield item handling ()
This moves the wield item functions to Player and the tool utils for range calculation
Also 'local_inventory' was removed due to redundancy in Client
2019-08-07 19:16:31 +02:00
SmallJoker
a687efa6df
Damage: Play no damage sound when immortal ()
Add isImmortal server-side for proper enable_damage handling
Rework log messages
2019-06-09 11:25:41 +02:00
Jozef Behran
007c8440d7 Optimize interaction distance checker ()
The "what" parameter is being passed by value, most likely by
accident as the type is "const std::string". Convert it to a
reference by adding the missing "&".
2019-03-07 08:19:13 +01:00
SmallJoker
ffb17f1c9a Consistent HP and damage types ()
Remove deprecated HUDs and chat message handling.
Remove unused m_damage variable (compat break).
HP: s32 for setter/calculations, u16 for getter.
2019-02-10 23:03:26 +00:00
SmallJoker
a122ba0ef4 Fix various bugs (Anticheat, Lua helpers) ()
* Fix various bugs (Anticheat, Lua helpers)

Anticheat: Use camera position instead of player position for shoot line calculations
Lua helpers: Increase 'i' to not overwrite earlier added table values

* Remove lag compensation

* * 1.5 for larger selection boxes
2019-01-06 10:24:44 +01:00
SmallJoker
3d66622772
Send only changed node metadata to clients instead of whole mapblock ()
Includes newer style changes and fixes by est31

Improve the block position de-serialization
Add type NodeMetadataMap
2018-12-04 20:37:48 +01:00
CoderForTheBetter
faa358e797 Add Lua methods 'set_rotation()' and 'get_rotation()' ()
* Adds Lua methods 'set_rotation()' and 'get_rotation'. Also changed some method names to be more clear. Instead of an f32 being sent over network for yaw, now a v3f is sent for rotation on xyz axes. Perserved Lua method set_yaw/setyaw so that old mods still work, other wise to set yaw they would need to switch to set_rotation(0, yaw, 0).
2018-11-28 09:38:50 +01:00
SmallJoker
f7a8e75765 Formspecs: Remove accidental empty 'quit' field 2018-07-10 18:27:03 +02:00
SmallJoker
db42542e27 Rename CSM flavours to restrictions
& Satisfy LINT
2018-06-26 15:38:42 +02:00
Loïc Blot
9a1d3584c2
Server: move shutdown parts to a specific shutdown state object ()
* Server: move shutdown parts to a specific shutdown state object
2018-06-13 21:58:34 +02:00
SmallJoker
bb4f0fd228 Formspec verification: Fix show_formspec inside callbacks () 2018-05-26 12:50:44 +02:00
Andrew Ward
dfc8198349
Add reasons to on_dieplayer and on_hpchange 2018-03-28 16:05:18 +01:00
Loic Blot
5e61f64ce2
Fix an alone if to be with a missing else 2018-03-16 08:40:21 +01:00
red-001
4bb41a19dc Mitigate formspec exploits by verifying that the formspec was shown to the user by the server. ()
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
red-001
338d645fcf Add on_auth_fail callback ()
Called when a client fails to supply the correct password for the account it's attempting to login as.
2018-02-15 21:18:54 +01:00
SmallJoker
990d0b0264 Inventory: Restrict access from too far away 2017-11-24 05:39:47 +00:00
raymoo
a637107a4e Allow overriding tool capabilities through itemstack metadata
This makes it possible to modify the tool capabilities of individual
itemstacks by calling a method on itemstack metadata references.
2017-10-29 11:57:38 +00:00