openmultiplayer / open.mp

Open Multiplayer, a multiplayer mod fully backwards compatible with SA-MP
https://open.mp
Mozilla Public License 2.0
453 stars 92 forks source link

Train carriage bug/crash #894

Closed dimmyi closed 1 month ago

dimmyi commented 6 months ago

It appears that the client automatically adds carriages with IDs in exact sequence, for example, if the main train is ID 365, the client (internally) will create carriages with IDs 366,367 and 368.

In openMP, carriages are only stored in available slots, and not necessarily in sequence, for example:

Slots: 365 - Ocuppied 366 - 367 - 368 - Ocuppied 369 - 370 -

openMP will create the main train in slot 366, and the carriages in slots 367, 369 and 370, that is, it is not in sequence and the ID that will be created for the client will be occupied by another vehicle or a non-existent one.

In SA-MP I noticed that when you create a train, it will look for 4 available slots in sequence, so in the example above, sa-mp will create the main train in slot: 369 and the carriages in slots 370, 371 and 372

How to reproduce the bug: https://www.youtube.com/watch?v=RADMmGx1LyQ

In the video you can see that the client internally removed a vehicle that was already created (NRG-500) and caused a warning.

How to fix? Apparently, just do the same as SA-MP and only create the train if you find 4 available slots in sequence.

AmyrAhmady commented 1 month ago

This happens in samp server as well, the problem is within samp client, not server side https://streamable.com/dn3mbv