Back to Home / #openttd / 2021 / 06 / Prev Day | Next Day
#openttd IRC Logs for 2021-06-06

---Logopened Sun Jun 06 00:00:16 2021
01:50-!-tokai|noir [] has joined #openttd
01:50-!-tokai|noir is "Christian Rosentreter" on #openttd
01:50-!-mode/#openttd [+v tokai|noir] by ChanServ
01:57-!-tokai [] has quit [Ping timeout: 480 seconds]
03:15-!-gelignite [] has joined #openttd
03:15-!-gelignite is "gelignite" on #debian #llvm #openttd
03:16-!-andythenorth [] has joined #openttd
03:16-!-andythenorth is "andythenorth" on #openttd
03:18<andythenorth>if I have 255 permanent register available to me
03:18<andythenorth>and a set of flags, covering maybe 16 different bool values
03:18<andythenorth>do I 'waste' a register on each flag?
03:19<andythenorth>or do I piss around with bitmasks?
03:20-!-Progman [] has joined #openttd
03:20-!-Progman is "Peter Henschel" on #openttd
03:21<@peter1138>Is it like memory where having free memory is the real waste?
03:22<andythenorth>[shrug macro]
03:22<andythenorth>I guess I just use a register per flag
03:23<andythenorth>bitmasks require me to be a better programmer than I am
03:26<andythenorth>if the number of flags exceeds the first bitmask size, I'd have to start managing which flag is in which register
03:27<@DorpsGek>[OpenTTD/nml] andythenorth updated pull request #211: Feature: support for vehicle var 4E, date_of_last_station_departure
03:39<TrueBrain>premature optimizations is the worst kind of optimization
03:42<andythenorth>T-shirt time
03:42<TrueBrain>they already exist
03:42<TrueBrain>for years
03:42<andythenorth>also meh
03:42<andythenorth>I had a nice idea to try and make some towns have a type, e.g. 'farm town', 'mine town'
03:43<andythenorth>and then prevent some other industries locating in those towns
03:43<andythenorth>so the map has nice flavour
03:43<andythenorth>but it will deadlock if player has town count < number of my town types
03:43<andythenorth>preventing deadlocks in newgrf is a cluster fuck :D
03:44<andythenorth>lots of ideas have to be discarded due to 'but player might set some really corner case settings'
03:44<andythenorth>or I could just stop reading any of the social sites for this game, which would 'solve' the problem for me
03:44<andythenorth>no more reddit, steam or forums
03:45<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain updated pull request #9333: Codechange: merge guiflags and flags in settings .ini files
03:45<andythenorth>I could try and add a var for number of towns
03:46<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain updated pull request #9335: Codechange: make [Save|Load]Settings() behave more like other Save/Load code
03:46<andythenorth>maybe it's just length of towns array or something
03:46<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain updated pull request #9322: Add: store table header for each chunk in savegame
03:46<TrueBrain>sorry for the spam, had to rebase the lot :)
03:46<andythenorth>such rebase spammer
03:46<andythenorth>goes it temp kban?
03:46<TrueBrain>poor DorpsGek
03:55-!-tokai [] has joined #openttd
03:55-!-tokai is "Christian Rosentreter" on #openttd
03:55-!-mode/#openttd [+v tokai] by ChanServ
03:56*andythenorth wonders if grf design would be improved by never ever ever reading the OpenTTD internet :D
03:58<andythenorth>ha maybe I just found an interesting exploit
03:58<andythenorth>industries can read parent town vars in CB 28, even though industry doesn't exist
03:59*andythenorth wonders if town registers can be written/read in CB 28
03:59<TrueBrain>owh boy
04:01*andythenorth tests it
04:01<andythenorth>'wondering' achieves pretty much FA
04:02-!-tokai|noir [] has quit [Ping timeout: 480 seconds]
04:06<andythenorth>can't seem to write to town register in CB 28
04:06<andythenorth>I guess certain specific vars have been exposed to that CB
04:11<andythenorth>oh the town register display doesn't update when written to
04:11<andythenorth>have to use windowshade to get the display to update
04:20*andythenorth still trying to circumvent grf industry having no global storage, and limited view of the map / game state
04:27<andythenorth>are town indexes [random | somewhat random | predictable] with respect to map position
04:28<andythenorth>so lower indexed towns are not more likely to be in north, or some similar pattern?
04:28*andythenorth has ideas
04:28<andythenorth>town index never changes, even if more towns are built?
04:29<TrueBrain>in general, an index doesn't change ... as otherwise .. it wouldn't be an index :P
04:29<andythenorth>these are things I hoped
04:29<andythenorth>my dreams aren't shattered
04:36-!-iSoSyS [] has joined #openttd
04:36-!-iSoSyS is "realname" on #/r/openttd #openttd
04:36<@peter1138>Why would that be an exploit? It should be the nearest town of the industry... if it did exist.
04:37-!-iSoSyS [] has quit []
04:38<@peter1138>Blooddy gate springs.
04:38<@peter1138>I guess there's a reason they cost about 50p.
04:38<@peter1138>Okay, £2.79.
04:41<andythenorth>it broke?
04:41<andythenorth>or the mounting to the post broke?
04:42<@peter1138>One of these type things. The little dowels at the top and bottom that make it work just fall out, cos stupid design.
04:43<andythenorth>yeah we have one, it breaks every few years iirc
04:43<@peter1138>It needs tension to keep the dowels in, but if you give it enough tension the spring itself buckles.
04:44<andythenorth>exploit is doing something in grf that I'm supposed to do in GS
04:44<andythenorth>but it's moot because the exploit doesn't exist
04:44<@peter1138>Might work better but... unavailable. Hmm.
04:45-!-tokai|noir [] has joined #openttd
04:45-!-mode/#openttd [+v tokai|noir] by ChanServ
04:45-!-tokai|noir is "Christian Rosentreter" on +#openttd
04:48-!-nielsm [] has quit [Ping timeout: 480 seconds]
04:52-!-tokai [] has quit [Ping timeout: 480 seconds]
04:53<@DorpsGek>[OpenTTD/OpenTTD] PeterN updated pull request #9289: Change: Shortcut varaction chains for callbacks.
05:01-!-jottyfan [] has joined #openttd
05:01-!-jottyfan is "jottyfan" on #openttd
05:23<@peter1138>My vacuum cleaner is sucking at suckinbg.
05:30<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain opened pull request #9338: Several code refactors of the SaveLoad code
05:32<TrueBrain>oops, forgot to drag in the dependency ..
05:33<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain updated pull request #9338: Several code refactors of the SaveLoad code
05:33<andythenorth>I thought I had a nice idea to use town registers to set a town as 'coal mining' or whatever
05:33<andythenorth>and co-locate other industries
05:34<andythenorth>but it's same as industry_town_count
05:34<andythenorth>le oof
05:36-!-Wolf01 [] has joined #openttd
05:36-!-Wolf01 is "Wolf01" on #openttd
05:36<@peter1138>Hmm, there's a bench mark thing isn't there...
05:37<TrueBrain>for a vacuum cleaner?
05:37<@peter1138>But also for sprite resolvers.
05:39<@peter1138>Ah but it's per grf. Hmm.
05:44<TrueBrain>saveload/saveload.cpp:1392:42: error: template template argument has different template parameters than its corresponding template template parameter
05:45<TrueBrain>and MSVC / GCC are fine with it, just clang that is being a little bitch
05:51-!-Samu [] has joined #openttd
05:51-!-Samu is "realname" on #openttd
05:57<TrueBrain>anyone any clue why clang doesn't like that?
06:03-!-WormnestAndroid [~WormnestA@] has quit [Remote host closed the connection]
06:03-!-WormnestAndroid [~WormnestA@] has joined #openttd
06:03-!-WormnestAndroid is "WormnestAndroid" on #openttd
06:13<@Rubidium>because std::list has two template parameters?
06:14<TrueBrain>well, an "allocator", which is assigned a default value
06:14<TrueBrain>its weird that only clang doesn't appreciate this ..
06:15<@Rubidium>maybe you need to pass the type of element in the list too?
06:15<@Rubidium>return SlStorageHelper<std::list<void *>, void*>::SlCalcLen(...)
06:16<TrueBrain>that requires some more changes than just that, but it is just weird that clang doesn't accept something that both GCC and MSVC do
06:16<TrueBrain>that is a rather unusual combination
06:24<TrueBrain>okay, it is the allocator being an issue
06:24<TrueBrain>funny ..
06:24<TrueBrain>even latest clang doesn't work
06:26<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain updated pull request #9338: Several code refactors of the SaveLoad code
06:44<andythenorth>hmm, can't write town storage in CB 28, can I read it?
06:44-!-sla_ro|master [] has joined #openttd
06:44-!-sla_ro|master is "slamaster" on #sla #openttd
06:44-!-Progman [] has quit [Remote host closed the connection]
06:45-!-sla_ro|master [] has quit []
06:49-!-sla_ro|master [] has joined #openttd
06:49-!-sla_ro|master is "slamaster" on #sla #openttd
06:52<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain updated pull request #9322: Add: store table header for each chunk in savegame
06:53<TrueBrain>I need to change 2 RIFFs into ARRAYs, and 6 (+2) ARRAYs into TABLEs
06:53<TrueBrain>out of the 79
06:53<TrueBrain>so .. 90% of the work is done :P
06:54<michi_cc>andythenorth: IndustriesResolverObject::GetTown() seems to read to me that reading should be possible, while writing can only be done for existing industries.
06:55<andythenorth>that helps :)
06:55*andythenorth going to test having 'farming towns' and 'heavy industry towns'
06:56<andythenorth>strictly I can do it without town registers by counting industries
06:56<andythenorth>but this will be an interesting test of town registers
06:56<michi_cc>During CB 28, the related town should be whatever town is closest to the proposed tile index.
06:56<andythenorth>good :)
06:56*andythenorth is hoping we might extend 'town' to 'region' also, if a use case is presented
06:57<andythenorth>'region' could just be a town designated as regional capital
07:13-!-andythenorth [] has quit [Quit: andythenorth]
07:50-!-Speedyn [] has joined #openttd
07:50-!-Speedyn is "Speedy's my name." on #openttd #sd
07:54-!-Speedy` [] has quit [Ping timeout: 480 seconds]
08:01-!-frosch123 [] has joined #openttd
08:01-!-frosch123 is "frosch" on #openttd
08:07<Samu>wow, you created about 1100 commits in such a small amount of time
08:16<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain updated pull request #9322: Add: store table header for each chunk in savegame
08:16<TrueBrain>okay, cheat-chunk done .. that was a special one :P
08:16<TrueBrain>now it is a lot easier to see what cheats were used in a savegame, without loading it in :)
08:17<@DorpsGek>[OpenTTD/OpenTTD] SamuXarick updated pull request #7918: Fix 3c047b1: AIGroup.GetProfitLastYear could get values different than those displayed in gui
08:18<TrueBrain>.env/bin/python -m savegame_reader Unnamed,\ 2nd\ Jan\ 1950.sav --export-json | jq .CHTS
08:18<TrueBrain>to be exact :P
08:19-!-Progman [] has joined #openttd
08:19-!-Progman is "Peter Henschel" on #openttd
08:23-!-andythenorth [] has joined #openttd
08:23-!-andythenorth is "andythenorth" on #openttd
08:30<frosch123>nice, i did not know jq
08:30<TrueBrain>it has passed by this channel many times before ;)
08:31<TrueBrain>too bad it only does JSON and not YAML .. the YAML variant is not pre-installed on most OSes :)
08:31<TrueBrain>you can do crazy complex shit with jq btw .. it is really powerful
08:33<TrueBrain>who wrote linkgraph SaveLoad .. hmm
08:33<TrueBrain>it is so different from everything else
08:35<TrueBrain>it is worse than stations :P
08:36<TrueBrain>right, lets tackle it .. first, I need a savegame with linkgraphs .. lets see if I have one :)
08:37<TrueBrain>yeah, I do, w00p
08:42<frosch123>i guess you have plenty of tools to look for certain chunks in savegames now :)
08:52-!-sla_ro|master [] has quit []
08:56<andythenorth>am about to learn how little I know about set theory
08:56<andythenorth>experimenting with 'farming towns' and 'heavy industry towns'
08:56<andythenorth>where industries of one type can't co-locate in the same town with industries of the other type
09:06-!-tokai [] has joined #openttd
09:06-!-tokai is "Christian Rosentreter" on #openttd
09:06-!-mode/#openttd [+v tokai] by ChanServ
09:12<andythenorth>any possibility reading a town register clears it?
09:12*andythenorth has an odd result
09:12-!-tokai|noir [] has quit [Ping timeout: 480 seconds]
09:13<TrueBrain>frosch123: only after conversion, which is the issue :P :P
09:14*andythenorth finds local error
09:15<TrueBrain>the human?
09:19<frosch123>it's always the mammals
09:24<andythenorth>I see
09:24<andythenorth>never the slugs?
09:27<andythenorth>in which andythenorth tries to learn how to write bitmasks from nml + python
09:28-!-Progman [] has quit [Remote host closed the connection]
09:30<andythenorth>I can use hasbit() to read them
09:30<andythenorth>but how do I set bits?
09:33<andythenorth>nvm, there's a better way
09:34<TrueBrain>there always is :D
09:38<Samu>#7918 autoreplace group statistics copying is so confusing
09:45<Samu>From the proposed 2 methods, I still prefer the first
09:46<Samu>doesn't touch autoreplace code
09:47<Samu>there's a misconception on what "profit_last_year" actually means
09:47<Samu>the comment describing it is not clear enough
09:54<Samu>hey peter1138, #7918 is actually about your code
09:54<Samu>wanna review?
10:06<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain updated pull request #9338: Several code refactors of the SaveLoad code
10:07-!-Progman [] has joined #openttd
10:07-!-Progman is "Peter Henschel" on #openttd
10:08<TrueBrain>right .. now to find a way to have a struct in a struct ... hmmm
10:09<TrueBrain>not difficult how to store it in the savegame .. difficult part is figuring out how to neatly deal with the variables in the code itself :D
10:13<andythenorth>town registers are quite neat
10:13<@DorpsGek>[OpenTTD/OpenTTD] SamuXarick updated pull request #8390: Add: [AI/GS] Missing water related functions and objects
10:13<andythenorth>I'm using them for things I could do with industry count and distance checks
10:14<andythenorth>but I'm assuming reading a register once is much faster than recursively checking distance and counts to a list of n industry types
10:14<TrueBrain>are you a wizzard? :D
10:14<andythenorth>double z?
10:14<Samu>testing regression ai is giving me some unrelated output comparisons
10:15<frosch123>yeah, i see some parallels between andy and rincewind
10:16<andythenorth>I don't have any luggage
10:16<frosch123>TrueBrain: discworld stuff
10:16<andythenorth>is it the way I can _nearly_ program, but not quite?
10:16<andythenorth>like RW can nearly do magic?
10:17<TrueBrain>oh-oh, CI is ratting out that I didn't run it locally
10:17<frosch123>TrueBrain: there are many wizards in discworld, but only one wizzard
10:17<frosch123>andythenorth: rincewind knows that he is faster than horses on short distances
10:19<andythenorth>anyway I now have towns being 'claimed' as farming, extractive, or heavy industry
10:19<andythenorth>or unclaimed
10:19<andythenorth>and I have industries which will refuse to locate in some of those
10:19<andythenorth>and some which are happy to locate anywhere
10:19<andythenorth>but I haven't tried on small maps
10:19<andythenorth>low town maps
10:20<andythenorth>low industry or hight industry map
10:20<andythenorth>mountainous maps
10:20<andythenorth>high water % maps
10:20<andythenorth>high desert %
10:20<andythenorth>or low snowline
10:20<andythenorth>nor for performance on very large maps
10:21<andythenorth>writing industry placement rules is lol
10:21<andythenorth>did we go through something related to that recently? :P
10:22<Samu>my regression run comparison
10:22<Samu>seems weird
10:28<Samu>well, it passed over there, so i guess it's fine
10:28<andythenorth>hmm town types
10:28<andythenorth>so .... town subtypes also? o_O
10:39<TrueBrain>hmm .. that moment some savegames load fine, others crash and burn
10:39<TrueBrain>annoying :D
10:40<TrueBrain>ah .. lol
10:41<TrueBrain>it helps to fix pointers correctly after loading :P
10:41<TrueBrain>no clue why :D
10:42<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain updated pull request #9338: Several code refactors of the SaveLoad code
10:45<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain updated pull request #9338: Several code refactors of the SaveLoad code
10:46<@DorpsGek>[OpenTTD/OpenTTD] SamuXarick updated pull request #8398: Change: Distribute left over cargo to stations according to the highest remainder
10:47-!-glx [] has joined #openttd
10:47-!-glx is "Loïc GUILLOUX" on #openttd
10:47-!-mode/#openttd [+v glx] by ChanServ
10:48<+glx>Samu: you need to manually delete notperfectai-1.3 because it has same internal version as 1.5
10:50<+glx>same for silicon_valley-35944, you have it in global content_download and in a local folder too
10:50<+glx>probably in bin
10:52<Samu>i see
10:57<@DorpsGek>[OpenTTD/team] ilyabakhlin opened issue #226: [es_ES] Translator access request
11:02<@DorpsGek>[OpenTTD/OpenTTD] SamuXarick updated pull request #8492: Fix: Don't allow towns to terraform certain floodable tiles
11:09-!-virtualrandomnumber [] has joined #openttd
11:09-!-virtualrandomnumber is "virtualrandomnumber" on #openttd #/r/openttd
11:09-!-virtualrandomnumber [] has quit [Remote host closed the connection]
11:09<@DorpsGek>[OpenTTD/OpenTTD] SamuXarick updated pull request #8514: Change: Allow to build dock on clearable watered object tiles
11:20<andythenorth>hmm I really should use a bitmask
11:20<andythenorth>I have NFI how to write one in code
11:21<andythenorth>I need to set a specific bit in a town register, without over-writing any existing bits
11:21<andythenorth>looks like nml bitmask() might be for that case?
11:22<andythenorth>isn't this just AND of a specific bit with the existing value?
11:24<@DorpsGek>[OpenTTD/OpenTTD] SamuXarick updated pull request #8517: Codechange: Make void tiles flood edge tiles, instead of edge tiles flooding themselves
11:25<FLHerne>You just want `old_value & (1 << n)`
11:25<FLHerne>Or just precalculate 1 << n and use that
11:25<FLHerne>`old_value & bitmask(n)` would work too
11:26<FLHerne>Should be OR, so |
11:26<FLHerne>`old_value | (1 << n)`
11:27<+glx>yeah & is for testing :)
11:29<+glx>and unseting in combination with ~
11:32<andythenorth>and n is the bit number I want to set yes?
11:32<andythenorth>and if I wanted to unset it, (0 << n)?
11:32<+glx>to unset it's old & ~(1<<n)
11:33<andythenorth>thanks :)
11:34*andythenorth wonders how many bits are in a town register :P
11:34<andythenorth>can probably google that
11:34<andythenorth>32 bit registers
11:53<andythenorth>old_value | bitmask(n) would work also?
11:57<+glx>only to set
11:58*andythenorth needs a bitmask for up to 64 cargos, but registers only support 32 bit :P
11:59<+glx>2 registers
11:59<andythenorth>yeah, not sure how I'd split across them yet
11:59<andythenorth>I guess I know the bit number
11:59<andythenorth>so I just split on that
11:59<@DorpsGek>[OpenTTD/OpenTTD] SamuXarick updated pull request #8609: Fix: Equalise the number of frames needed for road vehicles to traverse different radius curves
12:02*andythenorth is setting some flags in town registers when industry is constructed
12:02<andythenorth>but industries can also be removed :P
12:02<andythenorth>there's no callback I can use to cleanup
12:02<andythenorth>lol also
12:03<andythenorth>these are the problems that cause GS to be the recommended solution
12:03<andythenorth>except for the small issue that's it not recommended to make a GS for a specific industry grf
12:04<andythenorth>no way to unset flags
12:04<andythenorth>kills this idea stone dead :)
12:04<andythenorth>oh dear
12:06<+glx>it's possible to make a GS for a specific industry grf, but there's no way to ensure the correct industry grf is loaded
12:06<+glx>(well you can always check industry names)
12:07<_dp_>there is a waya
12:07<_dp_>run a server :p
12:07<andythenorth>it's a route
12:07<andythenorth>but no
12:08<andythenorth>if I set a flag for 'is farming town'
12:08<andythenorth>and the player magic bulldozes all the farms
12:08<andythenorth>there's no way to unset the flag
12:08<andythenorth>there's no town callback than can run e.g. monthly and run a census of industry types and ask them what flags to set
12:09<andythenorth>I can't use the industry monthly cb to clean up because it won't run if the industry is deleted
12:10<andythenorth>I could have one industry do the clean up for all the others, but if the town has no industry...
12:10-!-tokai|noir [] has joined #openttd
12:10-!-tokai|noir is "Christian Rosentreter" on #openttd
12:10-!-mode/#openttd [+v tokai|noir] by ChanServ
12:10<andythenorth>GS can't do it, because GS is blind to industry town registers, and that seems to be non-negotiable
12:11<andythenorth>I could not use a bitmask, and instead use a register for each flag
12:11<andythenorth>I could store the date last set, and update that monthly
12:12<andythenorth>then if the date > 1 month ago when reading it, assume the flag is unset
12:12<andythenorth>that breaks if date cheat is used
12:12<andythenorth>and I don't know what daylength will do with it
12:12<andythenorth>and it leaves a 1 month window where an industry might have been deleted
12:14<andythenorth>OpenTTD modding: 'lol'
12:17-!-tokai [] has quit [Ping timeout: 480 seconds]
12:19<andythenorth>well...some of this I can do without using town registers
12:20<andythenorth>I can pre-compose a set of checks in python, and rely on var for industry counts per town
12:20<andythenorth>and create nml procedures for each check
12:21<andythenorth>just town registers holding flags would be a neat solution, where the 'check' is just read a bit
12:21<andythenorth>and I wanted to try out town registers also :P
12:30<michi_cc>Why does magic bulldozer needs to reset any flags? Somebody who bulldozers and manually places everything doesn't seem like target audience for this.
12:31<michi_cc>If you'd want to be somewhat nice, you could ignore any flag checks if an industry is manually built by the player and use this to potentially reset the flags.
12:34<andythenorth>it's more that industry removal might need to unset flags
12:34<andythenorth>I suspect it's a sign that the idea is generally bad :)
12:35<andythenorth>some industries I only want to build in a town where there is another industry producing or accepting cargo x
12:35<andythenorth>that would have been nice to have in a flag
12:36<andythenorth>but I can work it all out in the python compile instead
12:36<andythenorth>and just use the industry counts by id
12:37<andythenorth>I was hoping to use town flags because I'm hoping we can do regions
12:37<andythenorth>and there's no var for industry counts by region
12:37<andythenorth>only by town
12:43<@peter1138>Add one
12:54-!-nielsm [] has joined #openttd
12:54-!-nielsm is "Niels Martin Hansen" on #openttd
13:05-!-Webster [] has quit [Read error: Connection reset by peer]
13:06-!-Webster [] has joined #openttd
13:06-!-Webster is "Supybot" on #openttd @#coopetition
13:17-!-Wormnest [~Wormnest@] has joined #openttd
13:17-!-Wormnest is "Wormnest" on #openttd
13:25<TrueBrain>frosch123: <- I was thinking of doing something like this for "lists of structs" .. at top, a diff (that doesn't compile) and at the bottom the important bits of town_sl.cpp
13:25<TrueBrain>opinions? :D
13:30-!-sla_ro|master [] has joined #openttd
13:30-!-sla_ro|master is "slamaster" on #sla #openttd
13:31<TrueBrain>ugh, we should change chunk-handlers into classes .. so you can just overload the function you implement
13:31<TrueBrain>removes all the weird table-stuff we now have
13:32<TrueBrain>hmm, would allow per-chunk-storage which I kinda need for the step after this .. so it is not even a terrible idea ..
13:34-!-tokai [] has joined #openttd
13:34-!-tokai is "Christian Rosentreter" on #openttd
13:34-!-mode/#openttd [+v tokai] by ChanServ
13:34<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain approved pull request #9180: Codechange: Remove FOR_ALL_CHUNK_HANDLERS
13:35<@DorpsGek>[OpenTTD/OpenTTD] glx22 merged pull request #9180: Codechange: Remove FOR_ALL_CHUNK_HANDLERS
13:35<+glx>have fun with rebase :)
13:35<TrueBrain>tnx :D
13:36<+glx>and yeah a ChunkHandler class could be a good idea
13:37<+glx>well there's already one :)
13:37<+glx>but it's basic
13:37<michi_cc>It is a class. I mean a struct is just a class that defaults to public.
13:37<+glx>yeah I know
13:38<TrueBrain>michi_cc: okay mister-nitpicking, I meant a class with overloadable functions instead of function-pointer-variables :)
13:38<andythenorth>wtf is a region anyway
13:40-!-tokai|noir [] has quit [Ping timeout: 480 seconds]
13:41<frosch123>TrueBrain: i don't know enough of the saveload code to follow your example. but did you consider using template specialisation to map structures to saveload descs, instead of all the enums?
13:42<TrueBrain>frosch123: I do not understand what you are showing me there :D
13:42<TrueBrain>so let me first explain a bit what my diff is about
13:42<TrueBrain>then you can explain yours ;)
13:42<TrueBrain>my diff, the bottom part mostly
13:42<TrueBrain>(the town_sl.cpp)
13:42<TrueBrain>I need a way that the sub-list can be in the _desc[]
13:42<+glx>I like the idea of replacing pointers with virtual functions
13:42<TrueBrain>but has all the freedoms of implementing it
13:43<TrueBrain>so I made a small callback system for each sub-list
13:43<TrueBrain>that calls a function with the object and enum value
13:43<TrueBrain>so you can do what-ever-the-fuck-you-want with it
13:43<TrueBrain>static void Load_TOWN_sub(TownSubChunk id, Town *t) <- that one
13:43<frosch123>yes, but instead of using a callback with an enum, you could put the callback functions directly into the SaveLoad desc?
13:44<TrueBrain>not easily, as there is not much
13:44<TrueBrain>the only way to do that, is to abuse the pointer that is in there
13:44<TrueBrain>which is meant for "destination object"
13:44<+glx>I may try to do the conversion
13:45<TrueBrain>the other issue is that save and load have different code
13:45<TrueBrain>glx: already working on it, sorry :P
13:45<michi_cc>Has the destination object the proper type?
13:45<TrueBrain>void *
13:45<frosch123>TrueBrain: currently there is "address_proc" in SaveLoad. couldn't there be a "load_proc" and "save_proc" instead?
13:45<TrueBrain>but that doesn't fit 2 pointers, basically :D
13:45-!-Speedyn [] has quit [Read error: Connection reset by peer]
13:46<TrueBrain>frosch123: that proc returns the offset of the variable in the object
13:46<TrueBrain>I could always just add 2 pointers, ofc
13:46<TrueBrain>not the worst and most difficult
13:47<frosch123>yes, and then someone takes that pointer, casts it to some integer types matching the SLE_... and then reads or writes that adress
13:47<TrueBrain>frosch123: don't follow, sorry
13:49<frosch123>so, currently there are ReadValue and WriteValue in saveload.cpp, which support a number of trivial types
13:50-!-Flygon [~Flygon@2001:44b8:411e:4e00:c1e6:a4a9:3d86:5f18] has quit [Quit: A toaster's basically a soldering iron designed to toast bread]
13:50<frosch123>for list of structs you essentially want these two functions to support structs in addition to the trivial types, right?
13:50<TrueBrain>was not the route I was on ;)
13:51<TrueBrain>SaveLoad is just stuff on stuff on stuff, basically
13:51<TrueBrain>Read/Write Value only works for SL_VAR
13:51<TrueBrain>not for any other type
13:52<TrueBrain>for examples, it cannot write strings
13:52<TrueBrain>for that SL_STR exists
13:54<frosch123>SlArray and Deque also use Read/WriteValue for each item
13:54<frosch123>so, imagine for a second that Read/WriteValue could handle all types
13:54<frosch123>also strings and structs
13:54<TrueBrain>the thing is .. I have to find the depth I am willing to let this rabbit hole go :D
13:54<TrueBrain>what you propose is possibly a good idea, but is a rather large refactor
13:55<frosch123>it could do that, if the SLE_VAR_ things were not enums, but rather function pointers to read/write methods
13:55<TrueBrain>but lets first draw what happens if we put the functions in the table
13:55<frosch123>TrueBrain: fine, do you have an idea how to store the substructs on disk in the schema?
13:55<TrueBrain>yeah, that is easy
13:56<TrueBrain>ironically, of all the problems I have, that is not one of them :D
13:56<frosch123>i think that would make it easier for me to understand your diff
13:56<TrueBrain>having readable code is my struggle :(
13:56<TrueBrain>and this words-only stuff is also not helping
13:56<TrueBrain>let me draft some text
13:57<TrueBrain>ps, glx, if you still like to, go for it :)
13:57<TrueBrain>seems I am taking a detour here :P
13:57<frosch123>TrueBrain: i don't consider my function pointers that different to your enums. you put an enum into SaveLoad that tells you which function to call for reading writing. i suggest to skip the enum, and directly put the function pointers into SaveLoad
13:58<TrueBrain>yeah, I am drafting that now
13:58<TrueBrain>give me a sec
13:58<TrueBrain>I am fast, just not that fast :)
13:59<TrueBrain>very function-heavy
14:02<andythenorth>should I be concerned about performance of var 67 (when used as town industry count)?
14:02<andythenorth>I am about to start calling it repeatedly for different industry types
14:02<frosch123>no, the var does not count them
14:02<frosch123>there is a persistent statistic of present industries
14:04<frosch123>hmm, actually, for towns it does recount them
14:04<frosch123>well, measure it :)
14:07<andythenorth>this sounds like 'do not be concerned' to me :P
14:07<frosch123>TrueBrain: i would have expected SLEG_SUBLST(Town, received, Save_TOWN_RECEIVED, Load_TOWN_RECEIVED), i.e. some "name" to identify the field in the savegame, and Save/Load_TOWN_RECEIVED would get a TransportedCargoStat* instead of a Town*
14:07<TrueBrain>frosch123: this is pre-header patch
14:08<TrueBrain>owh, wait, I misread you
14:08<TrueBrain>that doesn't work, sadly
14:08<TrueBrain>as Town is a "positive" example for this
14:08<TrueBrain>most others are not part of the main struct
14:08<TrueBrain>take Station for example, it recreates Flow on-the-fly
14:09<TrueBrain>so I kinda want to have a generic thing, where possible
14:09<TrueBrain>acceptance-matrix in Town is an example of this
14:09<TrueBrain>it goes to nowhere
14:13<TrueBrain>so it is "easier" in that sense to send the main-object again, and let the function pick the right thing from there
14:13<TrueBrain>similar why it has to send the length
14:14<frosch123>didn't the cargoflow also have list of list of struct?
14:14<TrueBrain>basically, the issue here is that those "lists" are not really lists, in some cases
14:14<TrueBrain>if they were all iteratable, it would be easier ..
14:14<frosch123>if you always pass the top-level struct, you cannot nest your functions
14:15<TrueBrain>well, "top-level" is not the right word
14:15<TrueBrain>it is what-ever object was called with SlObject
14:15<TrueBrain>so you can still nest :)
14:15<TrueBrain>if _town_received_desc would have another SL_SUBLST, it would be called with "t->received[i]"
14:16<frosch123>maybe i lost sight of the rabbit hole entry, but isn't the point of list of structs to have a single schema for the whole object?
14:16<TrueBrain>yes it is!
14:16<TrueBrain>updated the gist btw with something that actually compiles
14:16<frosch123>so in the end you would only have a single SlObject with the main object
14:17<TrueBrain>there are two things happening:
14:17<TrueBrain>1) a scan for the headers
14:17<TrueBrain>2) the translation to items
14:17<TrueBrain>for the first, I only need the main desc
14:17<TrueBrain>well, the first SlObject, but who is counting
14:18<TrueBrain>SaveLoad is created as such that you can walk the full tree and gather all info
14:18<TrueBrain>just a lot of bookkeeping
14:18<TrueBrain>not sure that made any sense :D
14:19<TrueBrain>ideally, the line would read something like: SLE_SUBLST(Town, supplied, _town_supplied_desc)
14:19<TrueBrain>but that only works for a handful of instances
14:19<TrueBrain>sometimes the "Town, supplied" pair is not a const
14:19<TrueBrain>sometimes the _desc is not a const
14:21<frosch123>i think i like your gist better than the current code in master/main. it moves the logic out of the Load_TOWN into the _desc, which i consider better. but i have no idea how this helps you with the schema-in-file stuff :)
14:22<TrueBrain>or reload
14:22<TrueBrain>that would work for me
14:22<TrueBrain>I just added another proc, called Header_NNN
14:23<frosch123>ok, that works
14:23<TrueBrain>just a bit of code
14:23<TrueBrain>I can put those 3 functions in a class
14:23<frosch123>kind of tempted to put the 3 functions Header/Load/Save into a shared namespace/lcass :p
14:23<TrueBrain>so what was your dpaste about?
14:24<TrueBrain>owh, you wanted to abstract it even further away
14:24<frosch123>i am not sure whether my paste is flexible enough
14:24<frosch123>in particular with the CONDNULL stuff, it may hurt
14:25<TrueBrain>we have no more CONDNULL after my work :D
14:25<TrueBrain>as you can just remove any field freely :P
14:25<frosch123>i was hoping we could deduce the SLE_VAR_xxx from the storage variable's type at some point, but that falls flat for CONDNULL
14:26<TrueBrain>so that is no longer an issue :)
14:27<TrueBrain>but yeah, if we start using classes for chunks, we can do some more magic to make things easier to read and maintain
14:27<TrueBrain>most chunks are now:
14:27<TrueBrain>for () { SlSetArrayIndex(i); SlObject(<object>, desc) }
14:27<TrueBrain>really dull
14:27<frosch123>then the main difference is that in your gist, you have one save/header/load function per struct instance (received + supplied). in my paste there is a save/header/load function per struct class
14:28<frosch123>so they would be shared if the same struct is used in different places
14:28<TrueBrain>which is never :(
14:28<frosch123>but, it also makes it more restrictive :)
14:28<frosch123>TrueBrain: if you consider std::string, std::vector as structs, it becomes "all of the time" suddenly
14:29<TrueBrain>owh, you are there with your head
14:29<TrueBrain>you want to save/load proc those things too
14:29<frosch123>and "supplied" and "received" are only different "by accident"?
14:29<frosch123>both could have been <uint32>
14:29<TrueBrain>well, if we do that, we add the procs for those default things via SLE macros honestly :P
14:30<TrueBrain>supplied is a total of 64 bites
14:30<TrueBrain>not sure I completely follow :)
14:30<TrueBrain>owh, one is 32bit
14:30<TrueBrain>other is 16bit
14:30<TrueBrain>per entry
14:30<TrueBrain>that is .. subtle
14:31<frosch123>Save_TOWN_SUPPLIED and Save_TOWN_RECEIVED are 90% identical code :)
14:31<TrueBrain>yeah .. but there are many more odd things I have found :D
14:32<TrueBrain>I also wonder if there is a way to get ride of the macros
14:32<TrueBrain>but the address_proc is tricky
14:36<TrueBrain> <- class-based variant
14:39<TrueBrain>okay, now to wire it in to check if it can actually work .. won't be fully trivial ..
14:48-!-Yexo [] has quit [Ping timeout: 480 seconds]
14:49-!-V453000 [] has quit [Ping timeout: 480 seconds]
14:49-!-^Spike^ [] has quit [Ping timeout: 480 seconds]
14:49-!-Ammler [] has quit [Ping timeout: 480 seconds]
14:49-!-Hirundo [] has quit [Ping timeout: 480 seconds]
14:49-!-tneo [] has quit [Ping timeout: 480 seconds]
14:49-!-avdg [] has quit [Ping timeout: 480 seconds]
14:49-!-planetmaker [] has quit [Ping timeout: 480 seconds]
14:49-!-Hazzard [] has quit [Ping timeout: 480 seconds]
14:52-!-XeryusTC [] has quit [Ping timeout: 480 seconds]
14:52-!-Osai [] has quit [Ping timeout: 480 seconds]
14:52<frosch123> <- it's possible to get rid of the address_proc by using member pointers
14:52-!-Terkhen [] has quit [Ping timeout: 480 seconds]
14:52-!-fonsinchen [] has quit [Ping timeout: 480 seconds]
14:52-!-SmatZ [] has quit [Ping timeout: 480 seconds]
14:54<TrueBrain>how to read that ...
14:55<TrueBrain>does that also work for struct in struct members, like Town.location.x etc?
14:57<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain updated pull request #9322: Add: store table header for each chunk in savegame
14:57<TrueBrain>right, rebased my work .. now lets tackle sublst ..
14:57<frosch123>hmm, current code already uses lambas for the address_proc
14:58<frosch123>why do we still need the SLE_VAR_xyz then :p
14:58<TrueBrain>well, I would like to get rid of the macros
14:58<TrueBrain>SLE_VAR_xxx is pretty useful
14:58<TrueBrain>as the code validates that the storage is of equal size
14:59<TrueBrain>this prevents stupid mistakes :)
14:59<TrueBrain>(like someone changing the size of a member in the savegame without realising he did that :P)
14:59<frosch123>why do you want to get rid of the macros? except for getting rid of macros in general?
14:59<TrueBrain>because we keep on increasing it with new fields
14:59<TrueBrain>which basically means many are now {}, 0, nullptr, etc
14:59<TrueBrain>it is getting slightly out of hand, and is rather unreadable
15:00<TrueBrain>but mostly
15:00<TrueBrain>I want optional fields
15:00<TrueBrain>deducing the name based on the variable is MOSTLY okay
15:00<TrueBrain>just sometimes it is not
15:00<frosch123>there are varidatic macros :)
15:00<TrueBrain>yeah ... and I want to keep my sanity, thank you very much :)
15:00<TrueBrain>we now also have SLE_VAR and SLE_CONDVAR
15:01<TrueBrain>which solves the "optional" param issue for those
15:01<TrueBrain>but you see a lot of SL_MAX_VERSION because of that
15:01<TrueBrain>which is .. not useful :P
15:01<TrueBrain>but yeah, I only want it for code hygiene :)
15:01<frosch123>there are designated initializers for structs: SaveLoad{ .length=5, .version_to=7 }
15:02<frosch123>they are supported by gcc/clang for years inofficially, and officially in msvc with c++20
15:02<TrueBrain>and .. we are back to C++20 :P
15:02<frosch123>they allow something like optional parameters
15:02<frosch123>you probably also can turn some of the macros into different SaveLoad constructors
15:03<frosch123>but to create those fancy lambas, you have to use macros :)
15:03<TrueBrain>well, I guess that can stay a macro
15:03<TrueBrain>up to 15 commits over 4 PRs :D
15:04<TrueBrain>right, focus TrueBrain , lets do SUBLST
15:10-!-tneo [] has joined #openttd
15:10-!-tneo is "tneo" on #openttd
15:12-!-Ammler [] has joined #openttd
15:12-!-Osai [] has joined #openttd
15:12-!-Ammler is "Marcel Gmür" on #openttd
15:12-!-Osai is "Osai" on #openttd
15:12-!-SmatZ [] has joined #openttd
15:12-!-SmatZ is "Zdenek Sojka" on #openttd.notice #openttd.noai #openttd
15:13-!-^Spike^ [] has joined #openttd
15:13-!-^Spike^ is "I Don't Care!" on #openttd
15:13-!-Terkhen [] has joined #openttd
15:13-!-Terkhen is "Terkhen" on #openttdcoop.nightly #openttd
15:13-!-mode/#openttd [+o Terkhen] by ChanServ
15:13-!-V453000 [] has joined #openttd
15:13-!-XeryusTC [] has joined #openttd
15:13-!-V453000 is "Vaclav Benc" on #openttd #nuts @#mashinky @#V453000
15:13-!-XeryusTC is "XeryusTC" on #openttd #debian-next #debian #coopetition
15:14-!-Yexo [] has joined #openttd
15:14-!-Yexo is "Yexo" on #openttdcoop.nightly #openttd.notice #openttd.noai #openttd #coopetition
15:15-!-avdg [] has joined #openttd
15:15-!-avdg is "Anthony Van de Gejuchte" on #openttd
15:15-!-fonsinchen [] has joined #openttd
15:15-!-fonsinchen is "Ulf Hermann" on #openttd #/r/openttd
15:15<TrueBrain> <- "description" variable is the most used form of this, but sometimes GetDescription() is used
15:16<TrueBrain>is there an easy way to have the parent implement the default "return description"?
15:16-!-planetmaker [] has joined #openttd
15:16-!-planetmaker is "Ingo von Borstel" on #openttd #oftc
15:16-!-mode/#openttd [+o planetmaker] by ChanServ
15:17-!-Hirundo [] has joined #openttd
15:17-!-Hirundo is "Hirundo" on #openttd
15:21-!-Hazzard [] has joined #openttd
15:21-!-Hazzard is "Mingwei Samuel" on #openttd #nuts @#freerct #coopetition #/r/openttd #hazzard
15:22<nielsm>TrueBrain: make the description variable protected, and a simple pointer, the children then have to assign that pointer in their constructor
15:23<TrueBrain>means the child still needs to assign something, meh
15:23<TrueBrain>sorry, trying to reduce the lines of code you need :P
15:23<TrueBrain>sometimes a bit silly thing to do, I know :D
15:24<nielsm>another one is perhaps the curiously recurring template pattern
15:24<nielsm>probably via an intermediate base class
15:24<nielsm>(ref: )
15:25<TrueBrain>that might work
15:26<TrueBrain>looks a lot nicer, tnx
15:27<TrueBrain>glx: if you are working on making the Chunks a class, our work might collide at some point :P But we will figure that out when that happens :)
15:28<nielsm>remember you might want to make it SaveLoadHandler <- DefaultSaveLoadHandler<SpecificSaveLoadHandler> <- SpecificSaveLoadHandler
15:28<+glx>I'm just starting, will first use a wrapper around the current pointers
15:28<nielsm>to allow for SaveLoadHandler to be a true polymorphic superclass
15:28<TrueBrain>does that matter .. hmm
15:29<nielsm>you can't have a vector of SaveLoadHandler<T> with different T for each element, unless you make it a vector of void*
15:29<nielsm>and you wouldn't be able to use those for anything then
15:29<@DorpsGek>[OpenTTD/OpenTTD] rubidium42 updated pull request #9314: Codechange: let the setting name be std::string
15:29<TrueBrain>there is currently no storage in those classes
15:30<TrueBrain>well, a vtable
15:30<TrueBrain>so I am wondering if we ever want to iterate them or anythnig .. I guess we do
15:32<TrueBrain>glx: <- my current SaveLoadHandler .. if anything remotely like that would be possible for all chunks, would be nice
15:33<+glx>yeah that's the intention
15:34<TrueBrain>small update
15:34<TrueBrain>Ptrs need a better name :D
15:34<TrueBrain>but okay :)
15:34<TrueBrain>tnx nielsm !
15:35<nielsm>TrueBrain: the idea is that the DefaultSaveLoadHandler can avoid declaring the description member variable entirely, and implement GetDescription() as return static_cast<T *>(this)->description
15:35<+glx>oh I named it Pointers
15:35<TrueBrain>nielsm: hmm .. sure, why not
15:35<TrueBrain>I initially had it =0
15:35<TrueBrain>but that is not useful
15:35<+glx>Save, Load, Pointers, LoadCheck
15:35<TrueBrain>glx: FixPointers?
15:36<+glx>but yeah naming can be improved :)
15:36<nielsm>that's the entire point of the CRT pattern, that you have a base class that knows the identity of the derived class and can access members of the derived class without vtable polymorphism
15:36<TrueBrain>well, lets figure it out now, to avoid having to rename N things later :P
15:36<TrueBrain>nielsm: the page you linked showed a nice example of "= 0" on the variable :D
15:37<TrueBrain>which has as advantage, that if you use the DefaultSaveLoadHandler, you have to define it
15:37<TrueBrain>but I guess now it just fails compiling too
15:38<@DorpsGek>[OpenTTD/OpenTTD] DorpsGek pushed 1 commits to master
15:38<@DorpsGek> - Update: Translations from eints (by translators)
15:38<TrueBrain>error: ‘const SaveLoad SlTownSupplied::description [4]’ is protected within this context
15:38<nielsm>yeah the specific handlers will have to make it public
15:38<TrueBrain>which is ... not ideal ;)
15:39<TrueBrain>the whole point is to keep it private :P
15:39<nielsm>if it's static const data I don't see the issue
15:39<TrueBrain>protected/public has little to do with the type
15:39<TrueBrain>but everything with the human behind the keyboard :D
15:39<nielsm>that's why we have code reviews isn't it?
15:40<TrueBrain>like they are going to spot those things
15:40<TrueBrain>I have now seen what people did with the SaveLoad stuff
15:40<TrueBrain>a good portion was people not understanding how it works :P
15:41<@Rubidium>maybe something along the lines of might work?
15:42<frosch123>that looks like a dangling pointer
15:42<@DorpsGek>[OpenTTD/OpenTTD] rubidium42 approved pull request #9333: Codechange: merge guiflags and flags in settings .ini files
15:42<frosch123>the table has to be static to make the span work
15:44<TrueBrain>nobody is now the owner of that list, I think
15:44<nielsm>more like it disappears after the constructor returns
15:45<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain merged pull request #9333: Codechange: merge guiflags and flags in settings .ini files
15:45<nielsm>and now you have an invalid pointer stored in the member
15:45<nielsm>invalid span
15:45<TrueBrain>well, I would guess the data is in .data
15:45<TrueBrain>so I would guess "it just works" :P
15:45<TrueBrain>not saying it is the right thing, btw
15:45<nielsm>anyone got a language lawyer on standby? need to check it for UB
15:46<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain updated pull request #9335: Codechange: make [Save|Load]Settings() behave more like other Save/Load code
15:46<TrueBrain>nielsm: lol
15:47<TrueBrain>that would be so awesome, if you could call a hotline
15:47<TrueBrain>we have this code
15:47<TrueBrain>and he just rants at you for 5 minutes straight
15:47<TrueBrain>no matter what code it is
15:49<@Rubidium>nielsm: it's not that UB is the biggest problem for OpenTTD ;) It's that it makes assumptions that simply do not hold, or that the defined behaviour is different from what OpenTTD's code expects
15:50<TrueBrain> <- will have to do for now
15:52<TrueBrain>euh, that "static inline" shouldn't be there ofc
15:53-!-gelignite [] has quit [Quit: Stay safe!]
16:00<+glx> <-- first step (at least it still builds)
16:02-!-jottyfan [] has quit [Quit: jottyfan]
16:02<TrueBrain>shall we rename "Pointers" to "FixPointers" while we still can with little effort? :D
16:02<TrueBrain>at least, that is the internal name in SaveLoad
16:03<+glx>hmm yes FixPointers seems better
16:05<nielsm>does that mean "repair the pointers" or "fixate the pointers so they don't move again"?
16:06<@Rubidium>mostly "convert pool indices to pointers" (IIRC)
16:06<TrueBrain>int -> void*
16:07<TrueBrain>it is a bit odd, but on Load() it puts an (int32) in the (void *) of the destination
16:07<TrueBrain>FixPointers then picks up those values, and makes it into the real (void *)
16:07<TrueBrain>ugly hacks being ugly :)
16:08<nielsm>uh yeah that sounds like actual UB, storing random integer values that are probably not valid as pointers to objects into void*
16:08<TrueBrain>void* is at least 32bits
16:08<nielsm>even if you never dereference them I don't think that's defined
16:08<TrueBrain>so it works :P
16:09<TrueBrain>and sanitizers don't pick up on it yet
16:09<TrueBrain>so sssttttt
16:11<+glx>SlXxxChunk functions are annoying, they check for nullptr
16:12<nielsm>I think there might be CPU architectures where storing a pointer value in a register is different from storing an integer value in a register (or pointers even have separate registers), and loading an unaligned or otherwise invalid pointer might cause a trap... I really have no idea but I think I recall reading about such a thing before
16:12<TrueBrain>nielsm: on the other side, this code has been running on the weirdest machines for 17 years ..
16:12<TrueBrain>clearly it works for many many architectures just fine :D
16:12<TrueBrain>not saying it is weird and we shouldn't be doing it, btw
16:13<@Rubidium>nielsm: if you want to go that way, then also consider both int and char being 16 bits ;)
16:13<TrueBrain>*(void **)ptr = IntToReference(*(size_t *)ptr, (SLRefType)conv); <- it is so beautiful
16:13<michi_cc>nielsm: point 3) seems to say we are good.
16:14<michi_cc>Technically, we'd have to use reinterpret_cast instead of a c-style cast, tough :)
16:15<frosch123>let's make a strawpoll whether it has to be size_t, intptr_t or uintptr_t :p
16:15<TrueBrain>can I just opt-out?
16:15<michi_cc>"A pointer can be converted to any integral type large enough to hold all values of its type (e.g. to std::uintptr_t)"
16:15-!-Hirundo [] has quit [Ping timeout: 480 seconds]
16:15-!-XeryusTC [] has quit [Ping timeout: 480 seconds]
16:15-!-V453000 [] has quit [Ping timeout: 480 seconds]
16:15-!-^Spike^ [] has quit [Ping timeout: 480 seconds]
16:15-!-planetmaker [] has quit [Ping timeout: 480 seconds]
16:15-!-Osai [] has quit [Ping timeout: 480 seconds]
16:15-!-Ammler [] has quit [Ping timeout: 480 seconds]
16:15-!-Hazzard [] has quit [Ping timeout: 480 seconds]
16:15-!-avdg [] has quit [Ping timeout: 480 seconds]
16:15-!-Yexo [] has quit [Ping timeout: 480 seconds]
16:16<TrueBrain>owh, hmm .. C++ isn't Python .. I cannot store the class itself .. only instances ..
16:16<TrueBrain>owh well, "new handler()" it is in SLEG_SUBLST :P
16:16<@Rubidium>frosch123: practically it shouldn't be size_t ;)
16:19-!-Hazzard [] has joined #openttd
16:19-!-Hazzard is "Mingwei Samuel" on #openttd #nuts @#freerct #coopetition #/r/openttd #hazzard
16:22<TrueBrain> /* Don't run when savegame version lower than 161. */
16:22<TrueBrain> if (IsSavegameVersionBefore(SLV_161)) return;
16:22<TrueBrain>I am always happy with comments that ... explain ... the code?!
16:26<frosch123>i think the language lawyer would say, all three options are wrong :p
16:26<frosch123>(u)intptr_t make guarantees about pointers fitting into integers
16:26<frosch123>but we acutally need the reverse: integers fitting into pointers
16:26<frosch123>i don't think there is such thing :p
16:26-!-Terkhen [] has quit [Ping timeout: 480 seconds]
16:26-!-SmatZ [] has quit [Ping timeout: 480 seconds]
16:26-!-tneo [] has quit [Ping timeout: 480 seconds]
16:26-!-fonsinchen [] has quit [Ping timeout: 480 seconds]
16:28<+glx> <-- will need a huge rewrite, function pointers are deep in the code
16:29<TrueBrain>what needs a rewrite, sorry?
16:29<+glx>most functions test the pointers for nullptr and do different stuff
16:30<+glx>like SlSaveChunk() has an early return
16:31<TrueBrain>yeah, but what I was thinking about, make a class per type, so a ChunkRiff, etc
16:31<+glx>SlLoadCheckChunk() skips data if no load_check function
16:32<TrueBrain>Broken savegame - Invalid chunk size
16:32<TrueBrain>that is still the most pointless error it can throw
16:32<TrueBrain>no indication what-so-ever what goes wrong :D
16:34<TrueBrain> vs
16:34<TrueBrain>sometimes our code makes me laugh :)
16:35<andythenorth>sometimes our chat makes me laugh :)
16:36<Samu>one says TE_END the other says NUM_TE
16:36<+glx>lucky NUM_TE = TE_END :)
16:37<frosch123>TrueBrain: nice :)
16:37<TrueBrain>glx: well, that is no luck ofc
16:37<TrueBrain>but .. yeah :)
16:37<+glx>anyway loops should use END, not NUM
16:37<TrueBrain>no, if you use BEGIN you should use END :P
16:38<Samu>NUM_TE = TE_END, guess it doesn't matter
16:38<+glx>it works, but it's bad ;)
16:40<TrueBrain>yippie, my code works :D
16:40<TrueBrain>the ugliest part is the "new handler()" hidden in a macro :P
16:41<TrueBrain>and the "list" doesn't write its size yet, that is to come :)
16:48<nielsm>I don't have any reference or anything, but there is some argument that you should strive for formats that don't use size/length fields but instead terminator markers
16:48<andythenorth>lol FIRS max coastal distance parameter doesn't work
16:49<andythenorth>probably hasn't for years
16:49<TrueBrain>nielsm: that only works if you have something to do a terminator
16:49<TrueBrain>in this case it is a random struct
16:49<TrueBrain>even a full-zero wouldn't be a good marker
16:49<nielsm>because that makes classes of invalid data forms impossible, and forces you to handle allocations for the incoming data correctly
16:49<TrueBrain>so what you end up with is adding a byte just for the marker, to every entry in the list :)
16:50<nielsm>yeah you'd have to use tagged entries of some kind then
16:50<TrueBrain>and how much people would like to, I am not going to rewrite our SaveLoad completely :)
16:50<TrueBrain>there are limits to my willfulness :)
16:52-!-Terkhen [] has joined #openttd
16:52-!-Terkhen is "Terkhen" on #openttdcoop.nightly #openttd
16:52-!-mode/#openttd [+o Terkhen] by ChanServ
16:59-!-Hazzard [] has quit [Ping timeout: 480 seconds]
17:00<frosch123>c++ is going in the opposite direction :)
17:00<frosch123>c has terminators everywhere, in strings, in arrays, ...
17:01<frosch123>c++ has all these start+length things
17:01<nielsm>that rule of thumb is specifically for transfer formats where data might come from an untrusted third party
17:02-!-Terkhen [] has quit [Ping timeout: 480 seconds]
17:13-!-Samu [] has quit [Quit: Leaving]
17:20<TrueBrain>it is weird, on-save, the chunk-size is not validated (as in: a check that what you indicate is actual what you wrote)
17:20<TrueBrain>but on load it is
17:20<TrueBrain>on-save can do it just fine .. it just doesn't :P
17:20<TrueBrain>more things to fix
17:21<frosch123>hmm, that would mean, if the save code is broken, you cannot save at all :p
17:21-!-tneo [] has joined #openttd
17:21-!-tneo is "tneo" on #openttd
17:21<TrueBrain>now you can save, and nobody can ever load it again
17:21<TrueBrain>not sure what is worse :P
17:21<frosch123>the latter may allow debugging
17:22<TrueBrain>I can tell you, it is frustrating
17:22<TrueBrain>as "debugging" ... not .... easy
17:22<TrueBrain>well, with my PRs it becomes easy
17:22<TrueBrain>as than you have headers :)
17:25<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain updated pull request #9338: Several code refactors of the SaveLoad code
17:25<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain updated pull request #9322: Add: store table header for each chunk in savegame
17:25<TrueBrain>okay ... tomorrow I fiddle with how to store the headers on disk
17:25<TrueBrain>but mainly: how to load them from disk
17:26<TrueBrain>I need some nice way to tell the SubHandlers about the order the fields are in
17:27<TrueBrain>pretty content with the sublists solution like this frosch123 ; it feels smooth
17:27<TrueBrain>will see if I can translate all chunks into this, but I think it won't be a problem
17:27<frosch123>yay :)
17:28<TrueBrain>if it works, it solves 5 more chunks
17:28<TrueBrain>leaving .. 5 more to look into
17:28<TrueBrain>of which 3 are linkgraph
17:28<TrueBrain>(the other two gamescript and gamelog)
17:28<TrueBrain>but I think .. with the exception of the MAP chunks .. this will give us a header for all chunks :D
17:32<@DorpsGek>[OpenTTD/OpenTTD] TrueBrain updated pull request #9322: Add: store table header for each chunk in savegame
17:32<+glx>Oh a nice comment " * Do something of which I have no idea what it is :P"
17:32<frosch123>haha, i think tb posted that one 2 days ago :p
17:33<TrueBrain>btw, frosch123 , this also means a migration to SQLite is absolutely possible, given we can solve the MAP-chunks :D
17:33<frosch123>is it? the substructlists would need some normalisation :p
17:34<frosch123>so it requires more magic
17:34<TrueBrain>owh, it is not 2 minutes work
17:34<TrueBrain>but the structure is there
17:34<TrueBrain>well, more magic .. I think it would require more strict rules
17:35<TrueBrain>when you use a `CH_TABLE`, you are now free to use SlSetArrayIndex() or not, as example
17:35<TrueBrain>you would have to take that control away
17:36<TrueBrain>well, that "freedom"
17:37-!-V453000 [] has joined #openttd
17:37-!-XeryusTC [] has joined #openttd
17:37-!-V453000 is "Vaclav Benc" on #openttd #nuts @#mashinky @#V453000
17:37-!-XeryusTC is "XeryusTC" on #openttd #debian-next #debian #coopetition
17:37<TrueBrain>as if the sublst would also do that, as example, normalisation is trivial from that point
17:37<TrueBrain>not going to do that for now btw :P
17:38<TrueBrain>right, enough for today. Night!
17:44-!-fonsinchen [] has joined #openttd
17:44-!-fonsinchen is "Ulf Hermann" on #openttd #/r/openttd
17:44-!-frosch123 [] has quit [Quit: be yourself, except: if you have the opportunity to be a unicorn, then be a unicorn]
17:47-!-andythenorth [] has quit [Quit: andythenorth]
17:48-!-Hazzard [] has joined #openttd
17:48-!-Hazzard is "Mingwei Samuel" on #openttd #nuts @#freerct #coopetition #/r/openttd #hazzard
17:49-!-Wolf01 [] has quit [Quit: Once again the world is quick to bury me.]
17:50-!-planetmaker [] has joined #openttd
17:50-!-Hirundo [] has joined #openttd
17:50-!-planetmaker is "Ingo von Borstel" on #openttd #oftc
17:50-!-Hirundo is "Hirundo" on #openttd
17:50-!-mode/#openttd [+o planetmaker] by ChanServ
17:52-!-^Spike^ [] has joined #openttd
17:52-!-^Spike^ is "I Don't Care!" on #openttd
17:52-!-Ammler [] has joined #openttd
17:52-!-Osai [] has joined #openttd
17:52-!-SmatZ [] has joined #openttd
17:52-!-Ammler is "Marcel Gmür" on #openttd
17:52-!-Osai is "Osai" on #openttd
17:52-!-SmatZ is "Zdenek Sojka" on #openttd.notice #openttd.noai #openttd
17:52-!-sla_ro|master [] has quit []
18:01-!-Yexo [] has joined #openttd
18:01-!-Yexo is "Yexo" on #openttdcoop.nightly #openttd.notice #openttd.noai #openttd #coopetition
18:03<+glx>oups full water
18:04-!-Terkhen [] has joined #openttd
18:04-!-avdg [] has joined #openttd
18:04-!-Terkhen is "Terkhen" on #openttdcoop.nightly #openttd
18:04-!-mode/#openttd [+o Terkhen] by ChanServ
18:04-!-avdg is "Anthony Van de Gejuchte" on #openttd
18:06<_dp_>and I thought zstd has bad docs...
18:06<_dp_>liblzma just links to zlib docs xD
18:14-!-iSoSyS [] has joined #openttd
18:14-!-iSoSyS is "realname" on #/r/openttd #openttd
18:16-!-iSoSyS [] has quit []
18:26<TrueBrain>glx: I have seen so much water lately ... so muuuucccchhhhhh :D
18:27<+glx>for some reason it doesn't use override
18:27<TrueBrain>I am relieved every time I see the titlegame :p
18:32<TrueBrain>Not overriding a static function I hope :D
18:32<TrueBrain>I might have tried that earlier today :p
18:32<+glx>no they are virtual
18:32<+glx>and not static
18:33<+glx>but it's probably because it's in a ChunkHandler[]
18:37-!-XeryusTC [] has quit [Ping timeout: 480 seconds]
18:42-!-XeryusTC [] has joined #openttd
18:42-!-XeryusTC is "XeryusTC" on #openttd #debian-next #debian #coopetition
18:48-!-avdg [] has quit [Ping timeout: 480 seconds]
18:48-!-V453000 [] has quit [Ping timeout: 480 seconds]
18:48-!-tneo [] has quit [Ping timeout: 480 seconds]
18:48-!-Yexo [] has quit [Ping timeout: 480 seconds]
18:48-!-Hirundo [] has quit [Ping timeout: 480 seconds]
18:48-!-Osai [] has quit [Ping timeout: 480 seconds]
18:48-!-Ammler [] has quit [Ping timeout: 480 seconds]
18:53-!-Progman [] has quit [Remote host closed the connection]
18:56-!-planetmaker [] has quit [Ping timeout: 480 seconds]
18:56-!-Hazzard [] has quit [Ping timeout: 480 seconds]
18:56-!-^Spike^ [] has quit [Ping timeout: 480 seconds]
19:03-!-nielsm [] has quit [Ping timeout: 480 seconds]
19:03-!-Ammler [] has joined #openttd
19:03-!-Ammler is "Marcel Gmür" on #openttd
19:04-!-^Spike^ [] has joined #openttd
19:04-!-^Spike^ is "I Don't Care!" on #openttd @#myownchannel
19:04-!-V453000 [] has joined #openttd
19:04-!-V453000 is "Vaclav Benc" on #openttd #nuts @#mashinky @#V453000
19:07-!-tneo [] has joined #openttd
19:07-!-tneo is "tneo" on #openttd
19:11-!-Osai [] has joined #openttd
19:11-!-Yexo [] has joined #openttd
19:11-!-Osai is "Osai" on #openttd
19:11-!-Yexo is "Yexo" on #openttdcoop.nightly #openttd.notice #openttd.noai #openttd #coopetition
19:18-!-Hazzard [] has joined #openttd
19:18-!-Hazzard is "Mingwei Samuel" on #openttd #nuts @#freerct #coopetition #/r/openttd #hazzard
19:25-!-tneo [] has quit [Ping timeout: 480 seconds]
19:25-!-Ammler [] has quit [Ping timeout: 480 seconds]
19:25-!-V453000 [] has quit [Ping timeout: 480 seconds]
19:25-!-XeryusTC [] has quit [Ping timeout: 480 seconds]
19:25-!-Osai [] has quit [Ping timeout: 480 seconds]
19:25-!-^Spike^ [] has quit [Ping timeout: 480 seconds]
19:26-!-Yexo [] has quit [Ping timeout: 480 seconds]
19:27-!-SmatZ [] has quit [Ping timeout: 480 seconds]
19:27-!-Terkhen [] has quit [Ping timeout: 480 seconds]
19:27-!-fonsinchen [] has quit [Ping timeout: 480 seconds]
19:30-!-Hazzard [] has quit [Ping timeout: 480 seconds]
19:43-!-tneo [] has joined #openttd
19:43-!-tneo is "tneo" on #openttd
19:49-!-Osai [] has joined #openttd
19:49-!-SmatZ [] has joined #openttd
19:49-!-Osai is "Osai" on #openttd
19:49-!-SmatZ is "Zdenek Sojka" on #openttd.notice #openttd.noai #openttd
19:58-!-avdg [] has joined #openttd
19:58-!-fonsinchen [] has joined #openttd
19:58-!-avdg is "Anthony Van de Gejuchte" on #openttd
19:58-!-fonsinchen is "Ulf Hermann" on #openttd #/r/openttd
20:58-!-Webster [] has quit [Remote host closed the connection]
20:59-!-V453000 [] has joined #openttd
20:59-!-Yexo [] has joined #openttd
20:59-!-V453000 is "Vaclav Benc" on #openttd #nuts @#mashinky @#V453000
20:59-!-Yexo is "Yexo" on @#openttdcoop.nightly #openttd.notice #openttd.noai #openttd @#coopetition
21:00-!-Webster [] has joined #openttd
21:00-!-Webster is "Supybot" on #openttd @#coopetition
21:03-!-Hirundo [] has joined #openttd
21:03-!-Hirundo is "Hirundo" on #openttd
21:04-!-^Spike^ [] has joined #openttd
21:04-!-^Spike^ is "I Don't Care!" on #openttd
21:05-!-Terkhen [] has joined #openttd
21:05-!-XeryusTC [] has joined #openttd
21:05-!-Terkhen is "Terkhen" on #openttdcoop.nightly #openttd
21:05-!-XeryusTC is "XeryusTC" on #openttd #debian-next #debian #coopetition
21:05-!-mode/#openttd [+o Terkhen] by ChanServ
21:07-!-Hazzard [] has joined #openttd
21:07-!-Hazzard is "Mingwei Samuel" on #openttd #nuts @#freerct #coopetition #/r/openttd #hazzard
21:07-!-Ammler [] has joined #openttd
21:07-!-Ammler is "Marcel Gmür" on #openttd
21:08-!-planetmaker [] has joined #openttd
21:08-!-planetmaker is "Ingo von Borstel" on #openttd #oftc
21:08-!-mode/#openttd [+o planetmaker] by ChanServ
21:20-!-tneo [] has quit [Ping timeout: 480 seconds]
21:20-!-XeryusTC [] has quit [Ping timeout: 480 seconds]
21:20-!-^Spike^ [] has quit [Ping timeout: 480 seconds]
21:20-!-Yexo [] has quit [Ping timeout: 480 seconds]
21:20-!-V453000 [] has quit [Ping timeout: 480 seconds]
21:20-!-Hazzard [] has quit [Ping timeout: 480 seconds]
21:23-!-tneo [] has joined #openttd
21:23-!-tneo is "tneo" on #openttd
21:23-!-Wormnest [~Wormnest@] has quit [Quit: Leaving]
21:33-!-Eddi|zuHause2 [] has joined #openttd
21:33-!-Eddi|zuHause2 is "Johannes E. Krause" on #openttd
21:33-!-Eddi|zuHause [] has quit [Read error: Connection reset by peer]
21:37-!-planetmaker [] has quit [Ping timeout: 480 seconds]
21:37-!-tneo [] has quit [Ping timeout: 480 seconds]
21:40-!-Netsplit <-> quits: Xaroth, @Terkhen
21:40-!-SmatZ [] has quit [Ping timeout: 480 seconds]
21:40-!-fonsinchen [] has quit [Ping timeout: 480 seconds]
21:40-!-Hirundo [] has quit [Ping timeout: 480 seconds]
21:40-!-Osai [] has quit [Ping timeout: 480 seconds]
21:40-!-Ammler [] has quit [Ping timeout: 480 seconds]
21:40-!-avdg [] has quit [Ping timeout: 480 seconds]
21:49-!-Hazzard [] has joined #openttd
21:49-!-Hazzard is "Mingwei Samuel" on #openttd #nuts @#freerct #coopetition #/r/openttd #hazzard
22:00-!-Yexo [] has joined #openttd
22:00-!-avdg [] has joined #openttd
22:00-!-Yexo is "Yexo" on #openttdcoop.nightly #openttd.notice #openttd.noai #openttd #coopetition
22:00-!-avdg is "Anthony Van de Gejuchte" on #openttd
22:05-!-Hirundo [] has joined #openttd
22:05-!-Ammler [] has joined #openttd
22:05-!-Osai [] has joined #openttd
22:05-!-Hirundo is "Hirundo" on #openttd
22:05-!-Ammler is "Marcel Gmür" on #openttd
22:05-!-Osai is "Osai" on #openttd
22:11-!-avdg [] has quit [Ping timeout: 480 seconds]
22:12-!-Hazzard [] has quit [Ping timeout: 480 seconds]
22:18-!-Osai [] has quit [Ping timeout: 480 seconds]
22:19-!-Hirundo [] has quit [Ping timeout: 480 seconds]
22:20-!-Yexo [] has quit [Ping timeout: 480 seconds]
22:21-!-Ammler [] has quit [Ping timeout: 480 seconds]
22:46-!-^Spike^ [] has joined #openttd
22:46-!-^Spike^ is "I Don't Care!" on #openttd
22:47-!-Terkhen [] has joined #openttd
22:47-!-V453000 [] has joined #openttd
22:47-!-XeryusTC [] has joined #openttd
22:47-!-Terkhen is "Terkhen" on #openttdcoop.nightly #openttd
22:47-!-V453000 is "Vaclav Benc" on #openttd #nuts @#mashinky @#V453000
22:47-!-XeryusTC is "XeryusTC" on #openttd #debian-next #debian #coopetition
22:47-!-mode/#openttd [+o Terkhen] by ChanServ
22:50-!-glx [] has quit []
22:55-!-XeryusTC [] has quit [Ping timeout: 480 seconds]
22:55-!-^Spike^ [] has quit [Ping timeout: 480 seconds]
23:00-!-V453000 [] has quit [Ping timeout: 480 seconds]
23:04-!-planetmaker [] has joined #openttd
23:04-!-planetmaker is "Ingo von Borstel" on #openttd #oftc
23:04-!-mode/#openttd [+o planetmaker] by ChanServ
23:04-!-Hazzard [] has joined #openttd
23:04-!-Hazzard is "Mingwei Samuel" on #openttd #nuts #kubuntu #hazzard @#freerct @#factoriocoop #coopetition #/r/openttd #supybot @#soaptest
23:05-!-Hirundo [] has joined #openttd
23:05-!-Hirundo is "Hirundo" on #openttd
23:06-!-SmatZ [] has joined #openttd
23:06-!-Osai [] has joined #openttd
23:06-!-Ammler [] has joined #openttd
23:06-!-SmatZ is "Zdenek Sojka" on #openttd.notice #openttd.noai #openttd
23:06-!-Osai is "Osai" on #openttd
23:06-!-Ammler is "Marcel Gmür" on #openttd
23:06-!-^Spike^ [] has joined #openttd
23:06-!-^Spike^ is "I Don't Care!" on #openttd @#myownchannel
23:06-!-V453000 [] has joined #openttd
23:06-!-V453000 is "Vaclav Benc" on #openttd #nuts @#mashinky @#V453000
23:07-!-XeryusTC [] has joined #openttd
23:07-!-XeryusTC is "XeryusTC" on #openttd #debian-next #debian #coopetition
23:07-!-avdg [] has joined #openttd
23:07-!-Yexo [] has joined #openttd
23:07-!-avdg is "Anthony Van de Gejuchte" on #openttd
23:07-!-Yexo is "Yexo" on #openttdcoop.nightly #openttd.notice #openttd.noai #openttd #coopetition
23:07-!-tneo [] has joined #openttd
23:07-!-tneo is "tneo" on #openttd
23:08-!-fonsinchen [] has joined #openttd
23:08-!-fonsinchen is "Ulf Hermann" on #openttd #/r/openttd
---Logclosed Mon Jun 07 00:00:18 2021