Config
Log for #openttd on 8th December 2023:
Times are UTC Toggle Colours
05:59:10  *** D-HUND has joined #openttd
06:30:08  *** Smedles has quit IRC
06:31:52  *** Smedles has joined #openttd
07:30:00  *** tokai has joined #openttd
07:30:01  *** ChanServ sets mode: +v tokai
07:36:41  *** tokai|noir has quit IRC
07:37:23  *** Wolf01 has joined #openttd
10:33:42  <xarick> KDTree for airport noise?
10:41:56  <xarick> I had a weird idea... towns that are classified as Cities should have a higher noise tolerance
10:58:46  <xarick> locosage: Can you ask that user for the savegame? I've been trying to find a way to trigger that bug, but got nowhere yet.
11:12:16  <xarick> found something that looks like a bug to me, but I'm not familiar with NewGRF code... must ask
11:13:21  <xarick> https://github.com/OpenTTD/OpenTTD/blob/master/src/newgrf_town.cpp#L49 this is a uint16
11:14:10  <xarick> https://github.com/OpenTTD/OpenTTD/blob/master/src/town.h#L42 this is a uint32
11:14:32  <xarick> aren't they referring to the same 'population' ?
11:15:47  <Eddi|zuHause> that's not a bug, that's just legacy behaviour.
11:16:26  <xarick> ok
11:17:23  <Eddi|zuHause> NewGRFs won't be able to distinguish sizes of really large towns. it'll be capped at 64k
11:17:54  <Eddi|zuHause> but you cannot simply extend that range without breaking old NewGRFs
11:18:22  <Eddi|zuHause> so clamping to the uint16 range is much safer
11:20:34  <Eddi|zuHause> if you have a use case for a NewGRF that needs to know about large town sizes, you can propose adding a new variable that takes a full DWORD
11:21:38  <xarick> just trying to find where the noise tolerance goes wrong...
11:22:32  <xarick> the limit is based on town population
11:22:46  <xarick> so, i thought that piece of code strange
11:22:51  <Eddi|zuHause> probably not in the newgrf code...
11:27:23  <peter1138> Most likely is AirportGetNearestTown() returning a different town for some reason.
11:28:56  <Eddi|zuHause> i haven't ever looked at that code, but maybe it broke with airport rotation?
11:31:36  <peter1138> https://github.com/OpenTTD/OpenTTD/pull/7424 < might be that.
11:33:19  <xarick> when placing a new town, it doesn't take into consideration whether there's a noisy airport around
11:33:24  <peter1138> _kd_tree is not stable, it is not impossible (although unlikely) for that function to return a different town.
11:33:57  <peter1138> Or simply that, yes. If you place a town in game, the nearest town might change.
11:34:12  <peter1138> I'd forgotten that founding towns is a thing.
11:34:37  <xarick> i tested it, and it works fine enough
11:34:47  <LordAro> i'm curious why #7424 was necessary in the first place
11:34:50  <peter1138> Did you test all possibilities.
11:35:00  *** APTX_ has joined #openttd
11:35:04  <LordAro> surely the existing calculation can't have been a bottleneck
11:35:14  <xarick> the old town that had the noise gets the limit adjusted and the newly placed town gets the new noise
11:35:37  <xarick> even when it surpasses the new town's limit, it just accepts the noise
11:36:03  <peter1138> That is handled? Surprising.
11:36:25  *** APTX has quit IRC
11:36:36  <peter1138> Ah, of course, when a town is creating UpdateAirportsNoise() is called.
11:37:19  <xarick> 7424 was for.... if I recall, lowering cpu usage during AI testing placing airports
11:37:36  <xarick> testing all possible locations
11:40:42  <peter1138> This is why you should always follow the PR template, and include a motivation.
11:42:05  <xarick> there was no template in 2019
11:44:03  <peter1138> Excuses. But including a motivation was still possible.
11:46:02  <peter1138> I'm2023-12-08T22:44:44  <peter1138> Words eh?
22:46:07  *** virtualrandomnumber has joined #openttd
22:46:15  <xarick> test and exec could differ, is that what you mean?
22:46:35  <DorpsGek> [OpenTTD/OpenTTD] PeterN commented on pull request #11564: Fix: Prevent under/over flow when calculating town noise https://github.com/OpenTTD/OpenTTD/pull/11564#issuecomment-1847936375
22:47:34  <talltyler> I agree with Peter. Reproducing the bug is the first step to fixing it, because how can you know if you’ve solved it unless you can test it?
22:48:20  <xarick> well, I guess I need that savegame
22:48:43  <talltyler> That could be a useful starting place
22:51:16  <peter1138> This command will first be executed without DC_EXEC, if EnsureNoVehicleOnGround fails, then the command will be aborted, before anything happens with DC_EXEC
22:51:45  <peter1138> It's then run a second time with DC_EXEC, but that shouldn't fail because it's just done a pass without DC_EXEC.
22:52:10  <xarick> what about in multiplayer?
22:52:44  <peter1138> So that is the thing, I can't remember if servers do a test run first or not.
22:53:09  <peter1138> Annoyingly I remember this came up in topic a couple of months ago, but I don't remember the answer.
22:55:33  <xarick> It's still better to have the calculation done after
22:55:37  <xarick> just to be safe
22:56:00  <peter1138> Actually I think it's better to move the EnsureNoVehicleOnGround test earlier.
22:56:38  *** virtualrandomnumber has quit IRC
22:58:27  <peter1138> (I'm just compiling, then I'll push something.)
22:58:46  <peter1138> But it still needs replication, tbh.
22:59:58  <peter1138> https://github.com/PeterN/OpenTTD/commit/df951e36f3ccfe11eabc2e68f798dd1bb8de96fd
23:01:35  *** keikoz has quit IRC
23:07:56  <xarick> we got save! https://drive.google.com/file/d/1Cd6bAB0sQNDK5RgzEZW8gR9NvGnDWGgM/view
23:10:24  <xarick> oh, his airport is already removed 😐
23:20:20  <peter1138> Heh
23:20:43  <peter1138> There are two towns pretty close though...
23:28:27  <xarick> okay, something i found...
23:29:08  <xarick> rotating the airport placement gives a different town disallowing its placement
23:29:16  <xarick> that is very.... strange
23:29:23  <xarick> it's a 6 * 6 airport
23:31:42  <xarick> kdtree is buggy?
23:34:58  <peter1138> That's because it iterates the tiles in a different order.
23:40:04  <xarick> AirportGetNearestTown seems to be the problem... 😦
23:40:16  <xarick> or the iterator?
23:47:01  <Eddi|zuHause> isn
23:47:09  <Eddi|zuHause> 't that what i said in the very beginning?
23:48:01  <Eddi|zuHause> i mean, suspecting airport rotation
23:49:01  <xarick> 🙂
23:50:47  <peter1138> Okay, so an issue is that when building it uses a different way of iterating, because the airport doesn't exist -- it uses the airport spec iterator.
23:51:10  <peter1138> That iterates through the airport tile table, which could actually be in in any order.
23:51:44  <peter1138> Once built, it uses the airport iterator, which just covers the times on the map from the top corner to the bottom corner.
23:54:06  <peter1138> But then again that shouldn't matter.
23:55:16  *** Flygon has quit IRC
23:57:13  <peter1138> station_cmd.cpp:L2330 means if two towns have the same distance it will pick one with the lowest index, so it's stable either way.
23:57:53  <xarick> AirportGetNearestTown 2324 seems to be the problem
23:58:10  <xarick> the iteration order 😦
23:59:36  <xarick> got no time now, tomorrow I'll check this better
23:59:49  <peter1138> Changing the iteration order doesn't affect which town is closer.

Powered by YARRSTE version: svn-trunk