-
-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object sync - fixes and improvements #3405
base: master
Are you sure you want to change the base?
Conversation
// Sync properties | ||
if (pData->ucFlags & 0x40) | ||
pObject->SetMass(pData->fMass); | ||
if (pData->ucFlags & 0x80) | ||
pObject->SetTurnMass(pData->fTurnMass); | ||
if (pData->ucFlags & 0x100) | ||
pObject->SetAirResistance(pData->fAirResistance); | ||
if (pData->ucFlags & 0x200) | ||
pObject->SetElasticity(pData->fElasticity); | ||
if (pData->ucFlags & 0x400) | ||
pObject->SetBuoyancyConstant(pData->fBuoyancyConstant); | ||
if (pData->ucFlags & 0x800) | ||
pObject->SetCenterOfMass(pData->vecCenterOfMass); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need to sync static data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data is only sent if it has changed. If the object is created on the server side, you must first get its properties, which are available on the client side, otherwise the properties on the server and client side would be different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why do we need that?
If you create object on server, you should change properties on server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is illogical. When creating an object on the server side, its properties will be default (-1, zero vector), and on the client side the properties will have some values.
When we create a vehicle on the server side, it also has handling, plate and other data just like on the client side. It's as if upgrades were only on the client side by default, and there were no upgrades on the server side because they had to be set on the server side as well.
This is strange behavior imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When creating an object on the server side, its properties will be default (-1, zero vector)
So server should have a config. All object properties should be available for a new object immediately.
When we create a vehicle on the server side, it also has handling, plate and other data just like on the client side.
Server has configs for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GTA has 160 physical groups. You can store them on server and add a hashmap modelId
-> groupId
You can use engineGetObjectGroupPhysicalProperty
and engineGetModelPhysicalPropertiesGroup
to generate data.
Horewer, I have no idea what we should return for objects without a physical group. Does gta use some default parameters for them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires a lot of additional work for the same effect, which is not profitable. Why waste time doing something in a more complex way when the current way works well and doesn't cause problems? I see no reason to waste time doing the same thing in a more difficult way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, your solution adds uninitialized state for server objects. So it's much complex, that the solution with serverside config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is normal behavior. The object has its properties set at the time of synchronization and this is normal, because on the client side if the object is not streamed, its properties are also default (-1, zero vector). The properties have the appropriate values when the object is streamed, and if the object is streamed, there is a good chance that it is also synchronized. I don't understand why you should complicate such a trivial thing as object properties. If this is really such a bad way, then I will remove access to the server-side properties, because implementing the same in a more difficult way requires investigation and a lot of work for the same effect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not normal and unnecessary complex
Ok, this is quite a large PR, so I decided to split it into several smaller PRs to make the review easier. |
I undertook the repair and improvement of object synchronization, which has been disabled since 2011.
I was unable to reproduce the bugs described in #460
I realize that this is quite a big PR, so I will be very grateful for any kind of feedback and reliable tests to eliminate any bugs and to safely merge this PR. I tested everything myself on the local server and I don't have the opportunity to test it with other players, so I'm not sure if all the problems have been eliminated.
Changes
Fixes
air_resistance
property on the client side.New events
onObjectDamage
event based on synchronizationonObjectBreak
event based on synchronizationonObjectMoveStart
eventonObjectMoveStop
event based on synchronizationChanges
setObjectProperty
,getObjectProperty
getElementVelocity
&getElementAngularVeloity
functions for objects on the server-sideisElementInWater
function for objects (shared)eObjectProperty
enum to the sharedResolved issues: #460, #2752, #386 (probably)
Parts of this PR: #3450