ddnet / ddnet

DDraceNetwork, a free cooperative platformer game
https://ddnet.org
Other
510 stars 381 forks source link

Fix `goto_tele` not finding all teleporters #8338

Open ChillerDragon opened 3 weeks ago

ChillerDragon commented 3 weeks ago

I noticed that on the current master the goto_tele feature was skipping one tele.

https://github.com/ddnet/ddnet/assets/20344300/afface81-7199-4419-be2a-9e80d8ada79b

I did not want to debug the code because it looked so complex. So I refactored it and it also fixed the bug. As you can see it now finds one more tele in the same map:

https://github.com/ddnet/ddnet/assets/20344300/49dc9ed3-d1f6-43db-a80a-9ca71d86b6b2

Also the performance should be much better. Since now the worst case is only iterating as many times as there are teleporters of that type in the map. Before in the worst case it would iterate over every single tile in the tele layer (including empty tiles).

Checklist

heinrich5991 commented 3 weeks ago

I find it hard to see which tele got added in the "new" video.

The old code tried to ensure that teles that are jumped to are a bit apart, is that why it missed one?

ChillerDragon commented 3 weeks ago

I find it hard to see which tele got added in the "new" video.

The old code tried to ensure that teles that are jumped to are a bit apart, is that why it missed one?

Those were both missing. It still does the distance check. But it did never come near this area in the old code.

image