PLAYER/mcl_playerplus: send player object props only if changed #147
No reviewers
Labels
No Label
blocker
bug
code quality
confirmed
critical
discussion
high priority
incompatibility
incomplete feature
invalid
low priority
missing feauture
needs testing
packet spam
performance
project
regression
translations
unconfirmed
in review
ready for review
No Milestone
No project
No Assignees
2 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Mineclonia/Mineclonia#147
Loading…
Reference in New Issue
No description provided.
Delete Branch "fix-active-object-message-spam"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
TRACKING ISSUE: #128
Mineclonia sends a huge amount of TOCLIENT_ACTIVE_OBJECT_MESSAGE even if none of the target properties have changed. This (or at least to like 99%) is caused by the globalstep function in PLAYER/mcl_playerplus/init.lua which in turn performs a set of player:set_bone_position() and player:set_properties() - these minetest functions send the data over network regardless if it was changed even though it is also stored in the player object.
Solution
Since the engine does not check if properties have changed we're going to have to do it ourselves.
Details
This PR implements two wrapper functions for player:set_bone_position() and player:set_properties.
These functions perform the corresponding get_, compare the new values with the already stored ones and only send the packet when they differ (enough).
The values for some player properties seem to be adjusted minimally by the engine so that the numbers have to be rounded to two decimal places before comparing.
Testing Steps
Reproducing and testing the fix
Regression tests
To Do
Figure out the set_properties part - doesn't seem to work correctly rn.
write proper testing instructions
@ -22,0 +48,4 @@
local function set_properties_conditional(player,props)
local oldprops=player:get_properties()
local p={}
local changed=false
this obviously isn't needed^^
WIP: mcl_playerplus: only send object props if changedto WIP: mcl_playerplus: send player object props only if changed76ce59417c
to2015815351
2015815351
toc85892db92
c85892db92
to7199060eaf
7199060eaf
to8086d060b2
8086d060b2
tofa68e01b93
WIP: mcl_playerplus: send player object props only if changedto mcl_playerplus: send player object props only if changedmcl_playerplus: send player object props only if changedto PLAYER/mcl_playerplus: send player object props only if changedfa68e01b93
tod19efef53e
d19efef53e
to7db083cfe2
@ -24,0 +40,4 @@
return rt
end
local function set_properties_conditional(player,props)
Why did you not overwrite the
set_properties
function of the player so that the real one is never called from the code below?I suppose i liked it better that way. It didn't seem necessary to overwrite it for this. Everything happens in one file (in one function to be exact).
This patch breaks eye level adjustment on sneaking.
The following code prints
1.35 1.65 true
:@ -24,0 +42,4 @@
local function set_properties_conditional(player,props)
local oldprops=player:get_properties()
local changed=true
Changed is always true. Why?
cause i dum
It also breaks eye level adjustment on entering a boat and swimming fast.
PLAYER/mcl_playerplus: send player object props only if changedto WIP: PLAYER/mcl_playerplus: send player object props only if changed@ -23,1 +25,4 @@
return math.floor(n * m + 0.5) / m
end
local function close_enough(a,b)
Suggestion: Add a few asserts to show how this function works correctly.
yes i did that in this case
@ -24,0 +44,4 @@
local oldprops=player:get_properties()
local changed=true
local p={}
for k,v in pairs(props) do
Suggestion: Add a few asserts to show how this function works correctly.
I think it makes the whole thing a lot more complex and harder to understand but ... sure i'll even make uselessly long variable names.
you're right there's a simple mistake. i'll push in a second.
7db083cfe2
to95bff518cf
c3fdd25f51
to9600823d74
9600823d74
todb43d87788
db43d87788
to875583cd45
WIP: PLAYER/mcl_playerplus: send player object props only if changedto PLAYER/mcl_playerplus: send player object props only if changed875583cd45
to5deaabdb47
I have updated the commit messages so future software archaeologists have an easier time following the twisted logic of this patchset.
Testing
Verify bug
Verify patch
I got 47 to 125 bytes per second with commit
5deaabdb47
.Good job!
Regression tests
I also tested sitting in a boat, as the eye level should be lower there too (it was).
Multiplayer
Log in with a second client
Verify that with the other client you can see the following:
Useful performance fix with a big impact. Thank you!