IRC logs for #openttd on OFTC at 2024-11-02
⏴ go to previous day
00:01:41 *** Tirili has quit IRC (Remote host closed the connection)
00:50:48 *** Wolf01 has quit IRC (Quit: Once again the world is quick to bury me.)
01:38:35 *** Wormnest has quit IRC (Quit: Leaving)
03:37:18 *** debdog has quit IRC (Ping timeout: 480 seconds)
04:47:26 <DorpsGek> - Update: Translations from eints (by translators)
09:05:28 *** mindlesstux has joined #openttd
10:17:57 <xarick> how do I use unordered_map
10:37:08 <xarick> ```std::unordered_map<TileIndex, WaterClass> wc;
10:37:08 <xarick> for (TileIndex t : ta) {
10:37:08 <xarick> wc[t] = HasTileWaterClass(t) ? GetWaterClass(t) : WATER_CLASS_INVALID;
10:42:14 <peter1138> You can't using a StrongType as the key of an unordered_map.
10:50:10 <xarick> not sure how to fix it
10:54:12 <peter1138> Either implement std::hash for a strong type (not impossible, but probably not your strong point (...))
10:54:36 <peter1138> Or use `TileIndex::BaseType` and `wc[t.base()] = ...`
10:56:37 <xarick> wondering if i could get away without TileIndex
10:56:53 <xarick> just a list of WaterClasses
10:56:55 <kuhnovic> We do that in several places. It's a bit ugly but not terrible.
11:06:07 <xarick> objects are not prepared
11:12:33 <xarick> oh snap, I've entered the newgrf territory
11:12:43 <xarick> this code is unreadable
11:13:30 <xarick> only scope resolves and variables and hex numbers
11:25:25 <xarick> So now that objects can get the correct waterclass, and they're told to draw water, they draw this.
11:34:24 <xarick> let's try HasTileWaterGround
11:38:57 <xarick> tile is already Object
11:47:06 <xarick> but it's probably the wrong check
11:50:01 <xarick> river slopes also water but not flat
11:59:23 <_glx_> Objects already have a water class on each tile
12:00:32 <_glx_> And when built they keep the class of the underlying tile
12:01:15 <xarick> objects handle water class in a very weird way, it's very compromised from CmdBuildObject
12:02:39 <xarick> when they run a clear landscape command, the water that was there becomes clear land, and thus invalid water class. Once it BuildObject, it gets the waterclass of a now clear land
12:03:19 <_glx_> It's because clear land skips them
12:03:34 <_glx_> Not related to build or remove object
12:04:37 <_glx_> Only one tile of the object is fully clear
12:06:00 <xarick> for me it's a buggy behaviour, but also feels like a compromise because the drawing code is also built upon the buggy behavioir
12:06:25 <xarick> let me show you where it is
12:19:16 <peter1138> An object on a slope doesn't have a water class, like a house on a slope doesn't have a water class.
12:19:28 <peter1138> The coast is no longer a coast, it's an object tile.
12:21:08 <xarick> oh line 273 in the original code
12:24:03 <xarick> or 299 where it actually executes
12:24:42 <peter1138> Can we close this PR before it's even a PR? :p
12:24:53 <peter1138> Because you are just making up problems that don't exist.
12:28:07 <xarick> what was my goal? I remember I wanted to do something that lead me there
12:33:33 <xarick> goal was to make GetFloodingBehaviour exclusively used in water_cmd.cpp to see if it would speed up anything. That lead me to remove it from rail_cmd.cpp, but that means replacing it with a one fit all approach wouldn't work because object tiles were not maintaining original waterclass
12:33:38 <xarick> yeah, something like that, afk lunch
13:17:12 *** asasnat has joined #openttd
13:17:12 <asasnat> I hope this is the correct channel for this, very hacky proof of concept for fractional currency exchange rates (don't mind the glitched custom currency window)
13:18:03 <asasnat> I probably won't be contributing this to the main OpenTTD since I cba to make sure it's up to snuff with the coding style guidelines, make sure existing NewGRFs aren't broken by this etc
13:24:07 *** reldred has joined #openttd
13:52:11 <xarick> how to Dry Up objects :p
14:07:12 *** gelignite has joined #openttd
14:16:29 <peter1138> IIRC, drying up is only for replacing shore tiles with regular dirt tiles. Nothing else.
14:19:10 <xarick> ah, so it needs to do something
14:21:58 <xarick> dang, feels like I'm reinventing the wheel
14:29:15 <johnfranklin> Transfer between Newark Castle and Newark Northgate is fun.
14:30:10 <johnfranklin> I used 18 minutes, including time for photography.
14:49:15 <andythenorth> johnfranklin: That’s about the most English thing you could ever do
14:57:27 <xarick> new problem... autoslope 🙂
15:17:09 <xarick> oh wow, there's already glitches in current master
15:19:25 *** virtualrandomnumber has joined #openttd
15:19:53 <_glx_> it allows this layout on this steep slope
15:20:31 *** virtualrandomnumber has quit IRC ()
15:20:55 <_glx_> and even provides the sprite for it
15:22:11 <peter1138> Yes, there's a lot of badly coded object GRFs.
15:28:35 *** Wormnest has joined #openttd
15:38:05 <xarick> i thought it was perfect for testing
15:53:36 *** kunet_android has quit IRC (Quit: User went offline on Discord a while ago)
15:58:54 <xarick> placing objects and terraforming
16:01:41 <xarick> is it NewGRF fault or openttd that it doesn't clear it?
16:03:24 <ahyangyi> I don't get it, what is the problem? The behavior looks consistent to me.
16:04:14 <xarick> the object has no foundation, so logic dictates it should clear the tile
16:05:31 <peter1138> Objects are special. They are basically useless eye-candy.
16:08:26 <ahyangyi> I think I understand Xarick's concern now, though I don't have much of an opinion -- I can see the benefit either way, and sometimes depending on the nature of object.
16:08:26 <ahyangyi> For example, terraforming should definitely *not* clear those "floating cloud" objects...
16:10:43 <_glx_> everything is fine in the video, works as expected
16:12:59 <ahyangyi> peter1138: Except those indestructible objects, they aren't useless 😄
16:13:27 <peter1138> The original immovable objects, purchased tiles and the HQ...
16:13:33 <_glx_> imagine if big cats were immovable
16:13:46 <peter1138> Just place a box near them.
16:16:30 <xarick> i think it's openttd's bug
16:19:33 <xarick> `spec->flags = OBJECT_FLAG_AUTOREMOVE | OBJECT_FLAG_BUILT_ON_WATER | OBJECT_FLAG_HAS_NO_FOUNDATION | OBJECT_FLAG_DRAW_WATER | OBJECT_FLAG_ALLOW_UNDER_BRIDGE | OBJECT_FLAG_SCALE_BY_WATER (11308)`
16:24:24 *** SigHunter has joined #openttd
16:47:45 <xarick> I guess it's wanted behaviour
16:55:24 <xarick> there is a bug in the landscape_grid
16:55:47 <xarick> may be peter's fault, let me check
16:56:45 <xarick> nop, master also wrong
16:57:37 <asasnat> asasnat: fixed custom currency window\
16:58:02 <asasnat> I'll need to do more testing before I even entertain the possibility of contributing this to the main repo though
16:58:48 <xarick> objects should be moved 2 times to the right
16:59:52 <asasnat> asasnat: one concern I have is that fractional currency conversions could possibly lead to situations where financial operations cause money to magically vanish or appear
17:00:05 <peter1138> Probably by fault, those rowspans are a c...
17:01:15 <peter1138> (Needs an extra key)
17:03:44 <LordAro> depends what it indicates :p
17:03:55 <LordAro> not immediately clear from the graph
17:04:39 <asasnat> asasnat: on the bright side at least, it appears that older save games still have correct money values with my proposed new currency system
17:05:24 <asasnat> it appears that the developers did a good job of not making financial operations currency-dependent, if that makes sense
17:05:27 <asasnat> I have to applaud them for that
17:06:11 <LordAro> transactions based on the currency currently in use would be hilarious
17:07:43 <asasnat> it would indeed be a very stupid mistake to make, but I myself am prone to making very stupid mistakes
17:14:06 <peter1138> LordAro: Just transported, not %age.
17:14:17 <peter1138> Transported and produced.
17:15:28 <peter1138> Currency is almost purely visual. You could use fixed-point maths if you wanted to support fractions.
17:15:48 <peter1138> (Floats would work but are likely to lead to Excel-style rounding errors...)
17:16:57 <peter1138> Fixed-point just means treating "1000" as 1 and always dividing by 1000. Or similar.
17:17:35 <peter1138> On the other hand, I think we moved to floats for units conversion.
17:17:58 <asasnat> I know what fixed point maths are but I've only ever seen them used in Amiga-era 3D games
17:18:48 <peter1138> It's all visual except for a few places when the game conversions from visual to native currency, which is pretty rare.
17:18:49 <LordAro> only ever *noticed* them ;)
17:19:16 <peter1138> NewGRF has fixed-point decimals.
17:19:41 <peter1138> Well, decimals isn't quite right, the one I'm thinking of uses 256 = 1.
17:20:07 <_glx_> 256 based percentages 🙂
17:24:49 <asasnat> the two main modifications I did to make this possible was:
17:24:49 <asasnat> - change line 512 in `strings.cpp` from `number *= spec->rate;` to `number = Money((float)(number * spec->rate / 10));`
17:24:49 <asasnat> - in the `origin_currency_specs` array in `currency.cpp`, multiply all exchange rates by 10 so built-in currencies remain the same
17:25:11 <asasnat> I am personally not a fan of how I did the first change and am willing to accept suggestions on how to make it better
17:25:58 <peter1138> So you made it fixed point math without realising it 😉
17:26:30 <asasnat> I felt like the `(float)` in there would surely invalidate any argument that it's fixed-point math
17:26:40 <peter1138> And yeah, casting money to float and back is going to cause issues when the values get big.
17:27:13 <peter1138> You've done the math before converting it to float.
17:27:24 <peter1138> So it's fixed-point math and a pointless conversion to float and back.
17:28:07 <asasnat> without that (apparently pointless) conversion it wasn't working quite right for me
17:28:32 <asasnat> but, alas, the only thing I know is that I know nothing, so I have to assume you are right
17:29:06 <xarick> `(float)(number) * spec->rate / 10`
17:29:40 <asasnat> I ended up doing `number = number * spec->rate / 10;`
17:30:19 <asasnat> although it might still be doing a hidden conversion to floating point somewhere
17:30:28 <asasnat> I have no idea at this point
17:30:52 <peter1138> There's never any implicit conversion to float.
17:31:10 <asasnat> my knowledge on all this floating point bullsh... is very spotty
17:31:10 <peter1138> Well, unless you changed spec->rate to be a float I guess.
17:31:22 <asasnat> spec rate is still an int
17:31:33 <asasnat> just the way it is used has changed
17:32:42 <xarick> so i terraformed a halftile with water
17:33:14 <asasnat> my mind keeps telling me that what I'm trying to do is very stupid and a pointless endeavour
17:33:52 <peter1138> It has issues with larger values.
17:33:53 <asasnat> in return, I keep telling myself that what I'm trying to do is nowhere near as stupid as the magic airboats feature that someone wanted to contribute a while back
17:34:24 <peter1138> Values which, normally we wouldn't care about, but then it's those values that are the entire reason Money has its own data type.
17:35:06 <xarick> my object kept the initial waterclass sea, but since terraforming did not clear it, it just leveled it
17:35:40 <peter1138> Someone™ will complain when their save with £9,223,372,036,854,775,807 shows it incorrectly...
17:39:58 <asasnat> should've looked into how OpenRCT2 (which was the sole inspiration behind this endeavour) does it first...
17:46:54 <xarick> do you know any newgrf object that only allows to be built on water
17:56:00 <Guest7968> ISR/DWE objects has piers and things
17:56:13 <Guest7968> probably some beach set stuff?
18:02:29 <asasnat> peter1138: do you happen to have a save file with that much money?
18:02:35 <asasnat> I'm eager for some bug swatting
18:08:25 <xarick> this layout is ... meh
18:08:39 <xarick> i wanted to resize the left pane
18:12:18 <xarick> got a 14.1 crash with one of these newgrfs
18:13:40 <xarick> i guess it's solved already, got no crash on my build
18:26:53 <xarick> time to give up on objects with water class
18:48:11 <asasnat> asasnat: I know this is a mega necro but that does appear to be a case
18:48:23 <asasnat> I downloaded a save game that is pretty much all maglevs
18:48:55 <asasnat> they seem to glide effortlessly through all turns, even the 90's
18:49:34 <asasnat> meanwhile one tile up a slope slows them down to a crawl...
18:51:28 <asasnat> Tell me, O Chris Sawyer, what were Thou smoking when Thou were working on train physics for Transport Tycoon Deluxe?
18:59:36 <peter1138> Well it provides a better challenge than being able go up & down slopes willynilly
19:07:03 <johnfranklin> andythenorth: what does this mean?
19:21:08 *** gelignite has quit IRC (Read error: Connection reset by peer)
19:33:31 *** gelignite has joined #openttd
19:35:23 <andythenorth> Newark is the epitome of English Midlands
19:35:51 <andythenorth> And the trip from Northgate to Castle is very England
19:36:10 <andythenorth> Also, such a small town, but has two stations
19:36:36 * andythenorth much Newark experience
19:45:19 <peter1138> Never been there, nor heard of it.
19:46:28 <peter1138> Hmm, would a separate graph window be better...
20:40:34 <Borg> howdy.. is there a way to get current currency via GameScript?
20:41:04 <xarick> how do i test for a MP_VOID tile
20:42:14 <_glx_> currency is just a visual setting, every client can use it's own
20:51:24 *** SigHunter has joined #openttd
21:07:29 <Borg> _glx_: and no hack using GSGameSetting.GetValue() ?
21:08:08 *** nielsm has quit IRC (Ping timeout: 480 seconds)
21:10:09 <Borg> I want to display Loan as Goal
21:11:38 <Borg> yeah, but they are sent to client for display
21:11:38 <_glx_> use {CURRENCY_LONG} or {CURRENCY_SHORT} in your string
21:11:48 <Borg> yeah.. thats what I tough about
21:11:56 <Borg> those only works via GSText() right?
21:14:18 <_glx_> GSText() is better to format numbers
21:14:35 <Borg> okey.. lets create language file then
21:14:40 <asasnat> peter1138: that value doesn't even seem to fit in a `Money`
21:15:23 <asasnat> I made a program to try and see when calculation imprecision could occur and it's giving me this
21:17:26 <_glx_> add 1 and it will become -1
21:17:26 <asasnat> _glx_: when I try to set it as a variable in my program it just segfaults when I try to run it
21:18:00 <asasnat> wait no that's an unrelated issue
21:20:52 <asasnat> well, now it's cutting off the last digit when given that value
21:20:56 <asasnat> which I guess I should've expected
21:21:59 <asasnat> fractional currencies was an interesting experiment, but the changes required to make it happen in OpenTTD are just too fundamental
21:22:10 <asasnat> glad to be done with it
21:26:03 <Borg> _glx_: okey works, thx..
21:26:09 <Borg> I wonder how it is saved tho :D
21:26:38 <Borg> I should save GSText() result? or I can generate it every time I need?
21:29:17 <Borg> hmm Save()/Load() works too
21:32:07 <Borg> _glx_: thx a lot :) works like a charm
21:32:48 <asasnat> asasnat: I mean, it only affects values above 922337203685477580 which I think is not too bad, but as peter said, you can't just assume no one will be pissed off by it
21:40:05 <xarick> my pursuit for performance bears no fruits
21:50:36 *** SigHunter has joined #openttd
21:51:16 <xarick> what about transported per company? 😛
21:52:18 *** ChanServ sets mode: +v tokai
21:59:16 *** tokai|noir has quit IRC (Ping timeout: 480 seconds)
22:00:20 <xarick> I made a mostly useless change:
22:00:42 <xarick> it improved performance in 0%
22:04:15 <xarick> oh, it fails to build yet again
22:05:35 <xarick> i don't understand the inlining things...
22:11:38 *** SigHunter has joined #openttd
22:12:51 <xarick> switch/case is slow apparently?
22:29:29 *** Borg has quit IRC (Quit: leaving)
23:06:04 *** keikoz has quit IRC (Ping timeout: 480 seconds)
23:13:03 *** SigHunter has joined #openttd
23:26:49 <xarick> have you considered casting TileType as uint8_t?
23:27:04 <xarick> enum TileType : uint8_t
23:27:17 <peter1138> That isn't casting.
23:27:24 <xarick> enumerating or whatever
23:31:06 <xarick> I'm trying weird stuff
23:31:24 <xarick> ```inline bool HasTileWaterClass(Tile t)
23:31:24 <xarick> static constexpr int WITH_WATERCLASS_MASK = (1 << MP_INDUSTRY) | (1 << MP_OBJECT) | (1 << MP_STATION) | (1 << MP_TREES) | (1 << MP_WATER);
23:31:24 <xarick> return HasBit(WITH_WATERCLASS_MASK, GetTileType(t));
23:43:09 <xarick> well, there were only gains when compared against GetFloodingBehaviour != FLOOD_NONE
23:43:27 <xarick> but master doesn't do that in the WaterTile_Loop
23:43:42 <xarick> so... overall, a net of 0% improvements
23:45:10 *** Wolf01 has quit IRC (Quit: Once again the world is quick to bury me.)
23:58:59 *** Tirili has quit IRC (Quit: Leaving)
continue to next day ⏵