IRC logs for #openttd on OFTC at 2024-05-31
⏴ go to previous day
01:41:11 *** Wormnest has quit IRC (Quit: Leaving)
02:08:52 *** tokai|noir has joined #openttd
02:08:52 *** ChanServ sets mode: +v tokai|noir
02:15:41 *** tokai has quit IRC (Ping timeout: 480 seconds)
02:31:36 *** debdog has quit IRC (Ping timeout: 480 seconds)
02:53:41 *** gnu_jj_ has joined #openttd
02:57:11 *** gnu_jj has quit IRC (Ping timeout: 480 seconds)
03:00:06 *** herms6 has quit IRC (Quit: bye)
04:43:43 <DorpsGek> - Update: Translations from eints (by translators)
05:16:31 *** keikoz has quit IRC (Ping timeout: 480 seconds)
06:03:45 <locosage> andriydohniak: fyi, it wasn't Spiff that did the coding and that fork is still very unstable, it may not be noticeable in the video but in the event game server was down for about as long as it was up.
06:04:07 *** jinks has quit IRC (Remote host closed the connection)
06:09:32 *** jinks has quit IRC (Remote host closed the connection)
06:23:26 <andriydohniak> locosage: I know he didn't do the coding, but thanks for the stability comments, I will rely on it's code less
06:25:34 <andythenorth> LordAro: they are 🙂 Especially the forked ones by Electric Imp 🙂
06:25:47 <andythenorth> downside is that Squirrel 2.2 isn't Squirrel 3 😛
07:21:18 <LordAro> fairly close as long as you don't try to use <- ?
07:24:04 <andriydohniak> Can somebody explain to me how saveload mechanism works in this game, and how can I extend it to also be able to store bitfields
07:25:52 <peter1138> Have a look at the specialisations for SL_VECTOR
07:29:54 <peter1138> std::bitset is pretty awkward though, as it doesn't provide a sensible way to serialise its contents. Conversion to string is not sensible.
07:30:45 <peter1138> You need to loop for each bit do anything else.
07:34:42 <peter1138> If it fits in a uint64_t you're better off using a uint64_t 🙂
07:34:46 <peter1138> So definitely more.
07:35:12 <LordAro> i'm thinking a generic solution :p
07:36:34 <peter1138> The answer from 13 years ago is still relevant...
07:37:17 <peter1138> Might be better off not with a custom bitfield implementation which allows more convenient access.
07:37:53 <peter1138> We already have some use-case specific bits that do that. They need to resize though so std::bitset was never an option.
07:38:32 <andriydohniak> peter1138: I am soooo tempted to just store it as cstr
07:38:46 <andriydohniak> why did you show me the easy way out?
07:39:44 <andriydohniak> bitset has a method size(), which returns byte allingned size, so all the template magic is not usefull
07:40:12 <andriydohniak> I can just reinterpret it as an array of bytes with the size of CompanyMask::size()
07:40:55 <peter1138> There's nothing to reinterpret.
07:40:56 <andriydohniak> Ok, I was wrong
07:41:17 <andriydohniak> size only works on objects, not just the typedef
07:41:52 <andriydohniak> peter1138: static cast, sorry I am not a C++ dev
07:42:07 <peter1138> There's nothing to static cast either.
07:42:43 <andriydohniak> ok then, gona go read the source code for the vec :)
07:42:52 <andriydohniak> and also string
07:44:50 <andriydohniak> peter1138: Hmm, I thought to just convert the whole bitset object to bytes, not to convert it to an array 1 bit at a time
07:45:03 <andriydohniak> but I guess if doing that way, there is really no need to cast
07:45:17 <peter1138> You can't because you don't know the internal representation of the bitset, that is implementation defined.
07:45:32 <andriydohniak> peter1138: its not stable?
07:45:55 <andriydohniak> Also, does OpenTTD use saveload code for networking?
07:46:05 <LordAro> converting the whole object to an array of bytes is what the SO post above is doing
07:46:07 <andriydohniak> or is there something separate that I also have to fix?
07:46:18 <LordAro> there's no way of "casting"/"reinterpreting" it that will work
07:46:44 <andriydohniak> LordAro: noted!
07:48:17 <peter1138> An entire savegame is sent from the server to the client on first connection, so as long as the savegame is done correct there's nothing more to do there.
07:48:19 <LordAro> (there's all sorts of horrendous black magic you could probably do to actually reinterpret the types ( think something like *(float *)&x ), but the result will be complete garbage)
07:49:19 <peter1138> Sending a bitset over the network protocol might be assistance though.
07:49:29 <peter1138> We have various serializers for things.
07:50:04 <peter1138> I don't immediately see any network commands that take a CompanyMask though.
07:50:31 <andriydohniak> LordAro: That what I was thinking, like
07:50:31 <andriydohniak> std::bitset<10>a;
07:50:31 <andriydohniak> *byte b = (byte *)(void *)a;
07:51:00 <peter1138> By the way, have you considered if maybe 64 companies is more than enough?
07:51:29 <andriydohniak> peter1138: Honestly I am thinking that 240 is not enough, I want to go to 512 :)
07:51:49 <peter1138> (Or 63, allowing that town owner thing.
07:51:59 <andriydohniak> peter1138: but you take in arrays, and vecs, I can probably do something to support it
07:52:02 <peter1138> Christ, what kind of supercomputer are you going to run this on?
07:52:20 <andriydohniak> peter1138: I reeeaaally liked the spiffing brit video
07:52:31 <andriydohniak> That kind of mass multiplayer just seams super fun
07:54:20 <andriydohniak> My hope is to eventually merge that in (no matter how slim the chance of that happening is), but not with 512, but something like 100 or so. I want to make it easily adjustable, so when there is a need for a LARGE game, it's just 1 number change, not a whole patch set
07:55:29 <peter1138> Given any increase requires changes to the map array, I don't think you'll achieve that.
07:56:10 <peter1138> Some tiles store 3 different owners. That's feasible with 15 companies as it's 12 bits.
07:56:27 <peter1138> With 240 companies you need 24 bits.
07:56:49 <peter1138> WIth 500 companies you need 27 bits
07:57:34 <peter1138> The number of bits is hardly massive, but it's not something that can just be changed without consideration.
07:59:18 <andriydohniak> So each tile has to have enough size to be able to store up to 3 owners?
07:59:59 <peter1138> The type of tile that needs to be able to store 3 owners needs to large enough.
08:00:14 <peter1138> And then all tiles are the same size.
08:00:21 <andriydohniak> so the map is not just a flat array
08:00:39 <peter1138> It is just a flat array.
08:00:55 <LordAro> have a read of landscape_grid.html
08:01:09 <peter1138> But how the bits are used within the array vary depending on the tile type.
08:01:11 <andriydohniak> LordAro: very briefly late at night, need to read again
08:01:27 <andriydohniak> peter1138: and rn 1 tile is 32 bits, correct?
08:01:53 <peter1138> No, right now 1 tile is 12 bytes - 96 bits.
08:02:18 <andriydohniak> peter1138: Thanks! Now I know what to read / search for
08:02:59 <peter1138> The considerations are that different tiles use bits for different things. That's simple enough.
08:03:11 <peter1138> But also, different tiles also *share* some bits for similar things.
08:03:39 <peter1138> Those shared bits need to be in the same place for the different tile types.
08:03:56 <peter1138> There is standard that are mostly the same for all tile types.
08:04:16 <peter1138> landscape.html and landscape_grid.html has it all.
08:04:55 <peter1138> That reminds me, I was going to fix landscape_grid at some point.
08:05:08 <andriydohniak> Are there errors
08:05:46 <peter1138> It was originally laid out in nibbles, always XXXX XXXX XXX X XXXX.
08:05:52 <peter1138> Someone didn't understand that.
08:06:17 <peter1138> So, e.g. trees are OOOO OOOXXX XX XXXX
08:06:35 <peter1138> Which should be OOOO OOOX XXXX XXXX
08:06:55 <peter1138> I even typoed my first line somehow ;D
08:08:16 <peter1138> I think someone has tried to split it in to groups of bits based on how they are used.
08:08:30 <peter1138> Which would be fine but it is not consistently done that way.
08:08:57 <LordAro> add some js so it changes if you hover over it ;)
08:12:25 <peter1138> Add some bootstrap and jquery so everyone hates it.
08:13:13 *** virtualrandomnumber has joined #openttd
08:18:04 <andythenorth> And github can warn about jquery vulns then
08:19:01 <andriydohniak> In the landscape_map the type is split like this: `XXXX XX XX` and in landscape, it says that the upper 4 bits are used for types. Am I correct to assume that landscape_map is talking about memory, and landscape is talking about integers in lsb
08:19:42 <andriydohniak> Ok, no I am confusing myself
08:20:56 <andriydohniak> And when it says bits 7..4 does it mean starting from the right or the left (because of lsb) and should it be reversed?
08:21:27 <andriydohniak> I rarely read docs about binary layouts, so this is entirely on me
08:23:56 <andriydohniak> And why does landscape.html use 2 digits of hex, when talking about 4 bits, with the first one being always 0
08:24:06 <andriydohniak> I am beyond confused
08:25:08 <andriydohniak> Ahhhh, Finally! I noticed the bit counter in the landscape_map! Now It makes total sence
08:25:26 <andriydohniak> Still don't know why the bits are counted in reverse, but at least it makes sence
08:25:57 <peter1138> Bits are counted from right to left.
08:26:02 <_glx_> They are in the natural order
08:26:21 <andriydohniak> peter1138: why?
08:26:45 <peter1138> Because that's how numbers are written 🙂
08:27:05 <peter1138> In decimal, 1s, 10s, 100s, 1000s are right to left as well.
08:27:51 <peter1138> 1234 is 'one thousand, two hundred and thirty four', not 'four thousand, three hundred and twenty one'.
08:28:34 <andriydohniak> So let me get this straight: When talking about bytes, we count from left to rigth, because it's memory, so why not, when but when talking about numbers with more then 1 byte, sometimes we swap the order because of lsb/msb, buuuut when talking about bits, cmon they are numbers, so lets count from right to lef
08:29:37 <peter1138> little-endian vs big-endiand. "lsb/msb" is ambigous between bit and byte.,
08:29:43 <andriydohniak> _glx_: when talking about bytes?
08:29:59 <andriydohniak> peter1138: Are there least significant bits???
08:30:24 <peter1138> Of course? The least significant bit in a byte is bit 0.
08:31:05 <andriydohniak> peter1138: yea, but thats just the least significant bit, not least significant bit first layout
08:31:25 <peter1138> Anyway, each map tile is not a flat array of bytes.
08:32:10 <peter1138> it is a flat array of structs.
08:32:15 <peter1138> Not variably sized.
08:32:44 <peter1138> In landscape_grid, there are column headers, those are the member names (roughly) of the struct.
08:32:53 <peter1138> There are actually 2 arrays... but that's just a detail.
08:33:01 *** virtualrandomnumber has quit IRC (Quit: virtualrandomnumber)
08:33:13 <_glx_> But that's for alignment mainly
08:33:17 <andriydohniak> peter1138: Where is the second array?
08:33:29 <peter1138> So we have two members which are uint16_t, the rest are uint8_t.
08:33:39 <andriydohniak> _glx_: So no info is stored there (nothing usefull to me when changing the owner size)
08:34:03 <andriydohniak> (except to reallign)
08:34:04 <_glx_> Doc mention only the members of the arrays
08:34:40 <peter1138> It's a detail that isn't really important. type, height, m1, m2, m3 ,m4 and m5 are part of the first array. That's 8 bytes.
08:34:44 <_glx_> Implementation is hidden because it's not important
08:34:48 <peter1138> m6, m7 and m8 are part of the second array. That's 4 bytes.
08:34:54 <peter1138> That means each tile takes up 12 bytes.
08:35:39 <peter1138> `* 8` or `* 4` is a bit simpler for computers than `* 12`.
08:35:58 <andriydohniak> So faster array indexing?
08:36:31 <andriydohniak> _glx_: because it wouldn't byte allign them
08:37:23 <peter1138> Anyywa, this detail is not particularly relevant 🙂
08:37:24 <kuhnovic> And therefore also more cache friendly, which might translate to better performance
08:37:52 <andriydohniak> peter1138: It is, because I will have to change the size of some of the members the "struct"
08:38:01 <peter1138> It might also be less cache friendly depending on what it is doing.
08:38:26 <peter1138> I'm not sure you have to change the size of members.
08:38:32 <peter1138> In fact, you can't change the size of members.
08:38:50 <peter1138> But if necessary you could add another member to the second array.
08:39:03 <peter1138> There may be enough free bits (I don't know)
08:39:32 <andriydohniak> Now my hope of making a clean and mergable solution is basically 0
08:42:45 <peter1138> It's not 0, but it is way more a task than your initial commit 🙂
08:44:08 <andriydohniak> Son, I was a naive fool back then. Those were different times
08:46:34 <andriydohniak> I still probably don't know 80% of the work I will have to do to make this work
08:46:56 <peter1138> It's an interesting learning experience for sure.
08:47:11 <peter1138> You have an itch and want to scratch it, which is a good way to get stuck in.
08:47:23 <andriydohniak> peter1138: the lesson being don't touch a 20 yo c++ code base
08:51:34 <reldred> and the data structures in a lot of areas are still compatible to a certain extent with the original TTD...
08:52:36 <reldred> Does OTTD still have TTD save compatibility or did that get ditched already?
08:53:02 <reldred> The NewGRF format is still somewhat compatible with TTDPatch
08:54:02 <andriydohniak> My current Idea here is to put ff in every owner field, and create m9 with `3 * company_size_in_bits` size, and access it with some sort of order
08:56:05 <andriydohniak> or even put the index of the owner in my 3 sized array in m9 in every owner field
08:56:26 <peter1138> reldred: It's TTDPatch that is incompatible now :p
08:56:39 <reldred> Fair, kinda sad, but fair.
08:56:55 <peter1138> Well the source code is there...
08:57:11 <reldred> Nah, I'm not that attached to it.
08:57:22 <reldred> Still, lot of fond memories of the ttdpatch days.
08:58:48 <andriydohniak> Is this tile array(s) stored in save files too, or only for networking?
08:59:44 <peter1138> It's stored in the map, yes.
09:00:02 <peter1138> Otherwise you would have a very... blank savegame.
09:00:19 <andriydohniak> And I can probably add a function to convert from the old format to the new one in afterload.cpp
09:00:38 <andriydohniak> peter1138: I was asking mb there was a different data structure for saves
09:00:46 <peter1138> There's an interesting set of dependencies when converting old savegames.
09:01:12 <peter1138> There will already be places where owner information is moved around, so that needs to be done in the correct order.
09:01:29 <peter1138> Saves basically store the bare arrays as they are.
09:01:42 <peter1138> It's "efficient" but not very flexible for sure.
09:02:11 <andriydohniak> peter1138: Yea, I noticed, this will not be fun. I think my current approach (in the prev commit) is also flawed, and I will have to rework the old file loading
09:03:24 <andriydohniak> e.g we are loading a file from super_old_version, and we convert company id to the new format, then we also execute code that converts fro old_version, and that code expects the old format
09:04:36 <andriydohniak> So I should probably just not touch the existing conversion code, and do not touch it's constants (rename them to OLD_*), and after its done just have another function converting to the new format
09:06:36 <peter1138> Yeah, you need to make sure that all the old conversion code avoids using map accessors that use the new information.
09:07:12 <peter1138> "NewMapArray" has been a bit of meme for OpenTTD for about 20 years too...
09:08:04 <andriydohniak> If I understand correctly, the current size of a 1024 by 1024 map is ~12 mb
09:08:21 <andriydohniak> peter1138: Will have to look into it
09:08:31 <peter1138> Refactor *everything* so that the dream of changing one constant works 😄
09:08:36 <peter1138> Don't look into it, there's nothing there.
09:09:32 <andriydohniak> peter1138: 1. I can't, not a C++ dev
09:09:32 <andriydohniak> 2. If I do that, we will have to version EVERYTHING
09:09:32 <andriydohniak> 3. If I do that, this will never get merged
09:09:59 <reldred> pfft, item 1) hasn't stopped people before
09:10:12 <peter1138> Nor us. Which is why some of the C++ is questionable.
09:10:20 <peter1138> A lot of it is C-style C++.
09:10:27 <peter1138> Like, say, the map array.
09:10:52 <peter1138> But yes, that's a reason for a 1024x1024 map using only 12MB (for the bare map).
09:10:55 <andriydohniak> peter1138: the map array is kinda cool, its simple
09:11:22 <andriydohniak> peter1138: The downside, is that it's hard to load map in chunks
09:11:32 <andriydohniak> you have to load everything all at once
09:11:41 <peter1138> Of course, the largest map size is 4096x4096.
09:11:47 <reldred> I think for anything large like this it comes down to communication, and collaboration. You certainly would be pushing shit uphill if you just disappeared for 6mo, and came back with a 100k line diff and expected it to just get merged.
09:11:47 <peter1138> And that is "only 4x bigger" right...
09:11:55 <andriydohniak> If miecraft stored it's map in an array .........
09:12:05 <andriydohniak> peter1138: Oh no no
09:12:09 <peter1138> 12MB -> 192MB is quite a jump.
09:12:32 <peter1138> For modern computers it's not that much memory, but it's quite a lot of data to be constantly processing.
09:12:44 <andriydohniak> peter1138: Also has to be sent over the network
09:12:57 <peter1138> That's compressed at least.
09:13:48 <andriydohniak> How does this work?
09:14:41 <peter1138> It 1) uses a lot more memory 2) you can't go over an absolute map area limit.
09:15:04 <reldred> select 1048576 and see wht the other dimension does
09:15:08 <peter1138> If your X is super large, your Y will be constrained.
09:15:19 <reldred> turns red in the dropdown
09:16:07 <andriydohniak> reldred: That's not on my pc, that's a screenshot
09:16:25 <reldred> well, anyway, that's what it does
09:16:45 <reldred> but in any one dimension it can go up to a max of 1048576
09:17:12 <peter1138> 1048576 x 64 is probably not fun.
09:17:28 <andriydohniak> ok, so no clever minecraft-like dynamic chunk generation / loading
09:18:35 <andriydohniak> peter1138: I think it would be a fun chellange, a speedrun to get to one of the ends as fast as possible
09:18:49 <andriydohniak> with a train from the start
09:18:49 <peter1138> 4096x64 is bad enough.
09:19:03 <andriydohniak> peter1138: true
09:19:18 <andriydohniak> now that I remember how big 1024 is with rails
09:19:31 <andriydohniak> 1048576 is insane
09:20:42 <andriydohniak> What is company_mask used for, and where and when is it stored / sent over the wire
09:20:55 <_jgr_> I don't expect people to actually play at the top end of the sizes, it's more a novelty thing
09:21:13 <peter1138> I consider 4096 a novelty thing.
09:21:31 <andriydohniak> peter1138: Or a spiffing brit video
09:21:42 <ahyangyi> "Play" can mean different things
09:21:46 <peter1138> That was a novelty 🙂
09:21:57 <ahyangyi> is the "legends mode" of Dwarf Fortress "playing"?
09:22:37 <ahyangyi> well, bad example -- *any* mode of dwarf fortress features a map larger than 4096x4096
09:23:07 <reldred> I play 4k x 1k, 4k x 2k, even 8k x 2k pretty often.
09:23:31 <andriydohniak> Where are the m1 -m8 defined?
09:25:24 <peter1138> `uint32_t m9; ///< lol`
09:27:13 <andriydohniak> uint32_t owners; ///< Stores the actuall ownership situation in the new format
09:27:28 <andriydohniak> and we keep the allignment
09:27:42 <andriydohniak> and we get up to 10 bits per company index
09:28:07 <andriydohniak> sooooo 1024 companies when? 😈
09:29:07 <andriydohniak> I would also have to make OWNER `uint16_t`
09:31:31 <peter1138> Savegame conversion from uint8_t to uint16_t is much simpler that the changes required for the map array, but you're getting ahead of yourself 🙂
09:39:17 <peter1138> Forums are nice & fast today.
10:25:27 <LordAro> reldred: yeah, but you are wrong
11:26:38 <andriydohniak> What is going on with m8? is it a recent addition? Some code only knows about m1-m7 some knows about m8
11:27:18 <peter1138> Relatively. If something doesn't need to use it, it's not going to use it.
11:27:51 <andriydohniak> peter1138: but for example function MakeVoid, and just doesn't set m8 to 0, but sets EVERYTHING else
11:27:52 <peter1138> 5 tiletypes use it.
11:28:18 <peter1138> Ah, well... it probably should.
11:30:16 *** SigHunter has quit IRC (Ping timeout: 480 seconds)
11:31:50 <andriydohniak> And chunk handlers for loading/saving count from 0
11:32:44 <andriydohniak> ok, its not even counting
11:32:47 <peter1138> It's not Visual Basic...
11:34:10 <andriydohniak> It goes MAP0 MAP2 MAP3L M3LO M3HI ..
11:34:16 <andriydohniak> Not even concistent in 1 file
11:34:32 <peter1138> Those are the old names that were used.
11:34:43 <andriydohniak> then MAP5 then MAPE, which I have no Idea what it means
11:35:17 <andriydohniak> then MAP7, MAP8, and MAP9 (I decided to just call it m9)
11:35:19 <peter1138> Because obviously we'd never add more in the future...
11:35:24 *** SigHunter has joined #openttd
11:35:41 <andriydohniak> how hard is it to rename a function
11:35:44 <peter1138> The chunk tags as fixed forever more because those are saved in the savegame.
11:36:18 <andriydohniak> peter1138: Ok, but we can at least rename the functions, and add a comment that explains what the hell has happened
11:36:24 <peter1138> The chunk label can't be changed, and the name of the chunk handler matches the chunk name here.
11:37:03 <andriydohniak> So how are those labels stored in the savefile
11:37:13 <andriydohniak> I thought it was just a bunch of arrays, without names
11:37:21 <andriydohniak> so where do the names come in?
11:37:33 <peter1138> The names come from the code you are looking at.
11:37:48 <andriydohniak> yes, but where are they used except in code
11:37:56 <peter1138> They're used in the savegame.
11:38:03 <andriydohniak> why do chunk labels need to be stored in the savegame
11:38:18 <peter1138> So that the game knows what's in the savegame.
11:38:29 <andriydohniak> I there a lookup table with adress offsets in the savefile
11:38:31 <peter1138> Are you aware of say the RIFF file format?
11:39:10 <peter1138> (This isn't RIFF, of course)
11:39:33 <andriydohniak> Ok, just looked it up
11:40:12 <andriydohniak> But doesn't the game just crash if one of the chunks is missing?
11:40:52 <andriydohniak> what else can it do? without 1 of the chunks the savefile is corrupted
11:41:12 <peter1138> Okay, what's your point here? 🙂
11:41:22 <andriydohniak> That I don't get, if the chunks memory positions can be calculated wit hthe information in the header, why the names
11:41:34 <andriydohniak> The header contains grid size (log)
11:41:53 <peter1138> This is basic file format stuff, nothing about memory positions.
11:42:12 <andriydohniak> not memory positions, file offsets
11:43:18 <andriydohniak> if version 1 of the program is reading the save file of version 1 of the same program, first it always parses the header, but then instead of just reading the chunks it needs to lookup where are those chunks and if they are present? That's what the version in the header is for
11:44:04 <peter1138> Okay, and how do you look up those chunks?
11:44:12 <peter1138> What defines if they are present or not?
11:44:22 <peter1138> Could it be... the chunk tag?
11:44:45 <andriydohniak> peter1138: They always are present, we control the app, and the chunks are always there in the correct version
11:45:27 <andriydohniak> we know the size of chunk by multiplying the size of grid x size of element of chunk, and we just start from somewhere after the header, and copy that memory
11:45:50 <andriydohniak> then for the next chunk, we skip to the byte alligned boundary, and read the next chunk
11:46:03 <andriydohniak> all this info is already in the header
11:46:32 <andriydohniak> and this tags are not something you can or want to turn off, its just how we store a struct
11:47:20 <peter1138> What about the other chunks?
11:47:46 <andriydohniak> you start where you ended on the previous chunk, calc the size of the next chunk, and read it
11:47:59 <andriydohniak> just an "array" of chunks
11:48:11 <andriydohniak> not an array because the chunks are differently sized
11:48:15 <andriydohniak> but you get the point
11:48:23 <peter1138> And when you finish reading that chunk, what tells you what the next chunk is?
11:48:38 <_jgr_> andriydohniak: I hope I never have to debug any problems with file formats that you've designed...
11:48:49 <peter1138> Is it the GRPS chunk or the LEAE chunk?
11:49:09 <peter1138> Early savegames don't have an LEAE chunk.
11:49:18 <peter1138> Much earlier savegames don't have a GRPS chunk.
11:50:15 <andriydohniak> I am not sure what GRPS or LEAE is, I am talking about type, m1, m2 ...
11:50:34 <peter1138> They're savegame chunks, just like all the MAP* chunks.
11:51:09 <peter1138> Some savegames don't have MAPE, MAP7 or MAP8 chunk.
11:51:26 <andriydohniak> But it depends on the version, right
11:52:03 <andriydohniak> Ok, I see the point in the tags, it is possible to do it without, but I see how it makes it simpler, so you don't have to create another parser per update
11:52:28 <peter1138> It's better and more reliable to depend on whether the chunk exists than to use versioning.
11:52:46 <andriydohniak> I guess that's true
11:55:12 <andriydohniak> What is oldloader_sl.cpp
11:55:29 <LordAro> there are comments that will tell you
11:55:36 <LordAro> usually somewhere near the top of the file
11:55:43 <LordAro> oldloader is TT(D) saves
11:57:39 <andriydohniak> I need a clarfication: Can openTTD only load old formats, or can it also save to old formats
11:58:43 <LordAro> saving to old formats would be... impossible
11:59:09 <andriydohniak> LordAro: I was REALLY scared for a second
12:02:48 <peter1138> A new chunk handler for maps might make things simpler.
12:03:00 <peter1138> Instead of treating it as 8 separate chunks.
12:03:52 <peter1138> The as the layout changes depending on the tile type, could get awkward. Certainly less efficient, but that might be an acceptable trade-off.
12:06:01 <andriydohniak> peter1138: now that I think about it, it's so much easyer to add a chunk handler for m9, and a couple of ifs on weather it exists or not, then to make sure you are using the right parser for the version that you are parsing. So anytime you want a change in the layout, you got to change your parser, but keep the old one too for old saves
12:13:50 <_glx_> Now we have nice handlers
12:14:47 <peter1138> Oh, and the reason why the map has several chunk handlers...
12:15:00 <peter1138> Each member of that struct was originally a separate array.
12:17:41 <andriydohniak> Tecnically struct of arrays is more efficient, then array of structs, but it's so much easyer to use
12:32:08 <Eddi|zuHause> i remember the time we tried to introduce "map accessors"
12:33:28 <Eddi|zuHause> also, "struct of arrays" might have terrible locality
12:33:50 <peter1138> We have map accessors.
12:33:58 <peter1138> But it didn't go beyond that.
12:34:05 <Eddi|zuHause> we have map accessors NOW :p
12:34:17 <Eddi|zuHause> but there was a time when we didn't
12:35:15 <peter1138> Well, "tried to" implies "didn't"
12:40:27 <Eddi|zuHause> well, it took a few attempts, i think.
12:41:06 <Eddi|zuHause> "the new map array" was quite a meme back then
12:43:06 <LordAro> it was back then, and it is now too
12:48:29 <andriydohniak> From function GetRoadOwner, I think we only need 1 owner, but we have space for 3, because we didn't take the space properly
12:48:43 <andriydohniak> Soooo, mb we only need 1 owner after all?
12:48:59 <andriydohniak> Ok, no I am dumb
12:50:13 <Eddi|zuHause> road, tram and station can each have different owners
12:50:27 <Eddi|zuHause> (or road, tram and rail for crossings)
12:51:26 <andriydohniak> Ok, I don't get how 1 piece of road has 3 owners
12:51:30 <andriydohniak> at the same time
12:52:12 <Eddi|zuHause> town builds a road, player 1 builds a rail line, player 2 builds a tram line
12:52:36 <andriydohniak> yea, but when do you need to store all that together in a single tile
12:52:39 <andriydohniak> at the same time
12:52:52 <Eddi|zuHause> where else would you store that?
12:53:09 <Eddi|zuHause> should player 2 be able to remove player 1's rail?
12:53:34 <andriydohniak> Ahhh, tram line can cross with rail line
12:53:44 <andriydohniak> So this tile needs to store all of them
12:53:52 <andriydohniak> Intersections...
12:53:58 <andriydohniak> Hmm, makes sence
12:54:40 <Eddi|zuHause> same for bus/tram stops, but they might be station tiles, not road tiles
12:54:47 <LordAro> there's the additional edgecase of two diagonal rail pieces on the same tile of different types (and owners?) that you can't do
12:54:57 <LordAro> iirc jgrpp has partially solved it?
12:55:08 <andythenorth> JGRPP solves two railtypes on the same tile
12:55:13 <andythenorth> not sure about owners, maybe
12:55:27 <Eddi|zuHause> ... until you allow road crossing with diagonal rails :p
12:55:51 <Eddi|zuHause> then you suddenly need 4 owners :p
12:56:25 <andriydohniak> I was thinking that the road and the lines will be different tiles with the same coords, but that's not how this game works
12:56:39 <andythenorth> I think the bug in 9850 was a candidate for closing as "works as expected"
12:56:52 <andythenorth> was it lunch yet?
12:57:05 <Eddi|zuHause> andriydohniak: that was a possibility that was discussed, but never actually implemented
12:57:37 <andriydohniak> Eddi|zuHause: How would you go about implementing it in the current map-is-1-array setup?
12:58:35 <andriydohniak> Or you create a separate array where tiles have coordinates, where you only put tiles that overlap
12:58:42 <Eddi|zuHause> andriydohniak: "it's complicated"?
12:58:57 <andriydohniak> Eddi|zuHause: I would imagine so
12:59:30 <andriydohniak> andriydohniak: And then if you need to remove a tile, do you shift all the array, or do you create a "tombstone"
12:59:38 <andriydohniak> and when do you clean tombstones
12:59:45 <andriydohniak> or do you use a hash_set
12:59:54 <andriydohniak> but that would be VERY slow at big maps
12:59:54 <andythenorth> oh, is it us that broke Squirrel?
13:00:08 <andythenorth> allegedly table keys can be any type that is hashable, including string
13:00:17 <andythenorth> but string cannot be used as a table key in GS
13:00:21 <Eddi|zuHause> two candidate implementations were "pointer to tile" or "blocks of supertiles" (like 16x16 areas) that can be dynamically allocated
13:00:22 <tabytac> andythenorth: you cant share owners with rail in jgrpp
13:00:34 <LordAro> andythenorth: you should file a bug
13:00:35 <andythenorth> table key = "slot id" in the stupid squirrel language, sometimes
13:00:43 <andythenorth> squirrel is so fucked 🙂
13:01:31 <andriydohniak> Eddi|zuHause: that is cool!, So the pointer-to-tile would be like a linked list of tiles pointing to the next tile sitting on the same tile
13:01:46 <andriydohniak> That is VERY clever, I would have never came up with this solution
13:02:06 <andriydohniak> And the blocks-of-supertiles, I don't get how that would work
13:02:49 <Eddi|zuHause> essentially the same, just less pointers involved, and better locality for cache stuff
13:03:24 <Eddi|zuHause> each "supertile" is like the current map array, just you have lots of them
13:03:30 <andythenorth> unless strings can be used
13:03:52 <andriydohniak> But with my implementation, it would be trivial to add another owner, so mb we will se that fixed someday
13:04:00 <andythenorth> I can't tell, nor can GPT
13:05:02 <andythenorth> my best understanding is that those slot ids can't be strings
13:05:42 <andythenorth> but if they're keyword identifiers (i.e. drop the quotes) then the squirrel goes looking for them as indexes and doesn't find them
13:06:31 <Eddi|zuHause> andriydohniak: with the current map array, it's fairly easy to add more storage space, but you simultaneously add that to all tile types, which may be wasteful. that's why we're very carefull with that
13:07:25 <andythenorth> yeah they can't be strings
13:07:32 <andriydohniak> Eddi|zuHause: it is, and the problem is that owners are not stored in 1 area, but they are scattered with different conditions as legacy code is piling up
13:07:50 <andriydohniak> And I see that its more efficient, but it's impossible to extend, like I am trying to do rn
13:08:06 <andriydohniak> I am trying to make the owners at least 8 bits long for now
13:08:20 <andythenorth> can anyone figure out if Squirrel 2.2 is *supposed* to support string keys?
13:08:29 <peter1138> Not legacy code, just scatted with different conditions because different tiles have different requirements.
13:08:31 <andythenorth> or whatever squirrel is choosing to call them today
13:09:08 <peter1138> Maybe we have give tiles a 4-character tag 😉
13:11:31 <andriydohniak> 4 ** (26 * 2 (for lowercase) + 10 (digits)) = 21267647932558653966460912964485513216
13:12:20 <LordAro> andythenorth: there must be a "vanilla" squirrel you could run?
13:12:22 <andriydohniak> only 14776336 cells
13:12:42 <locosage> peter1138: don't they already have one? ;)
13:12:45 <andythenorth> LordAro: for local testing?
13:13:09 <andythenorth> not sure how I'd get 2.2 built on a current mac
13:13:20 <andythenorth> I'd likely have to find some source repo for it and build myself
13:13:32 <Eddi|zuHause> andriydohniak: there is a certain logic to the current map storage locations, but that is broken in a few places.
13:13:50 <andriydohniak> Eddi|zuHause: do continue
13:13:58 <andythenorth> it's quite hard to find much online for Squirrel the language
13:14:00 <andythenorth> it's pretty dead
13:14:15 <andythenorth> and most of google is for various SQL projects or other Squirrels
13:14:36 <Eddi|zuHause> andriydohniak: in the docs, there's an overview
13:14:37 <andythenorth> every time I touch GS I end up closing the laptop in frustration and walking away
13:14:47 <Timberwo1f> I kept finding something useful and then realising 10 minutes after I'd used it that it was for the wrong version of Squirrel.
13:15:12 <andythenorth> even debugging is hard because my compiler puts a stupid GPL notice into every compiled file
13:15:19 <andythenorth> so the line numbers bear no resemblance to source
13:15:28 <Timberwo1f> iirc (where there's a good chance I don't properly), v3 has a bunch of different/new list comprehensions to v2
13:16:25 <andythenorth> my GPT assistant was going reasonable well, but it can't find enough online to learn from about Squirrel 2.2, so it's guessing based on Squirrel 3
13:16:59 <andythenorth> it's now trying to write test scripts to find out what OpenTTD actually does by trying things and logging them
13:19:00 <andythenorth> src/3rdpary/squirrel/sqtable.h suggests that strings can be keys, if I read line 18 correctly?
13:21:00 *** Timberwo1f is now known as Timberwolf
13:22:15 <andythenorth> confirmed, strings can't be used as squirrel table keys, at least not for declaration using {}
13:24:36 <andriydohniak> andythenorth: It's pretty big, but if you read it, you will be an expert 😄
13:33:16 <andythenorth> those are the docs I already gave it
13:33:28 <andythenorth> I'm not sure why Squirrel is so broken, but eh
13:34:04 <andythenorth> there's zero chance of us upgrading it afaik
13:35:02 <peter1138> v3 is incompatible with v2.
13:35:20 <andriydohniak> So the issue is not that you don't know how to code in Squirrel, it's that chatGPT cant?
13:35:24 <andriydohniak> What did you expect
13:39:04 <andriydohniak> Chatgpt is trash at large context, and "large" means small, it can't properly recall code from 2 messages up accuratelly
13:39:26 <andriydohniak> cmon, just learn the basics yourself
13:40:21 *** SigHunter has quit IRC (Ping timeout: 480 seconds)
13:41:16 <talltyler> “Just be better, bro” isn’t the most helpful advice 🙂
13:41:54 <andriydohniak> talltyler: Yea, but in this case rather then teaching chatgpt how to code, you might as well save some time and learn yourself
13:42:38 *** SigHunter has joined #openttd
13:43:48 <andythenorth> I am trying to teach GPT because coding squirrel 2.2 is absolutely fucking dreadful
13:44:01 <andythenorth> and GPT can generate an entire file of classes and methods for me
13:44:13 <andythenorth> but it runs into *exactly* the same problems I have
13:44:21 <andriydohniak> andythenorth: What is worse is trying to work with chatgpt on anything complex / obscure, and this is definitelly it
13:44:33 <talltyler> I am terrible at Blender and have been periodically bashing my head against the wall for years trying to learn. I’m about to try again. Sometimes certain skills are just mismatched with one’s abilities, and trying harder does not help 🙂
13:44:47 <andythenorth> the point was never that GPT should be able to do this
13:44:54 <andythenorth> the point is that Squirrel 2.2 is fucked
13:45:10 <andythenorth> it's 13 years dead and terrible, and this surprises no-one
13:45:33 <andriydohniak> talltyler: No, but in your case, starting with a tutorial would be a good place, in andy's chatGPT is about the worst strategy, when the reference exists
13:45:55 <andythenorth> no, GPT was much better able to generate test cases to find out what the API actually is
13:46:16 <andythenorth> we have extra complexity because we have an embedded fork of Squirrel 2.2
13:46:24 <andythenorth> and it's not always clear if the problem is Squirrel or OpenTTD
13:46:44 <andriydohniak> Damm! I am so happy neovim chose lua
13:46:56 <andythenorth> for example, there's nothing in the Squirrel 2.2 docs that says table keys ('slot ids') can't be strings
13:50:03 <andriydohniak> Yea, but the example shows it being an identifier not a string
13:50:27 <andriydohniak> And click on Table Constructor
13:51:34 <andythenorth> it's lolz that this works
13:51:34 <andythenorth> local test_table = {
13:51:48 <andythenorth> that results in a key as integer 10
13:52:14 <andythenorth> probably due to some array comprehension syntax I don't understand
13:52:52 <andriydohniak> This is probably not intended :)
13:52:56 <andythenorth> local test_table = {
13:52:56 <andythenorth> ["cabbage"]="foo"
13:52:56 <andythenorth> results in a string key
13:53:09 <andythenorth> or at least according to the representation in OpenTTD GS log
13:53:16 <andythenorth> but I don't know what type conversion it might be doing
13:53:34 <andythenorth> usually if it's an array it just prints "Array" and a hash for the array UID
13:53:35 <andriydohniak> The spec says its an identifier
13:53:44 <andriydohniak> and you shouldn't be able to convert anything to identifier
13:53:56 <andriydohniak> this is probably a bug
13:54:26 <andriydohniak> I think I know what happened lol
13:54:36 <andriydohniak> can you try a name with an astrisk in the end?
13:55:09 <andriydohniak> local test_table = {
13:55:09 <andriydohniak> test_name*="foo"
13:55:10 <LordAro> it's not entirely clear why both forms are supported
13:55:22 <LordAro> probably some amount of parser disambiguation
13:55:38 <andriydohniak> andriydohniak: Can you try this?
13:56:04 <andriydohniak> ok, I thought I knew what the parser but was
13:56:57 <andriydohniak> andythenorth: I think it says string because of the quotes, so it just interpretes quotes as string, even though it might be a bugged literal
13:57:01 <LordAro> that looks like it actually, yeah - `local my_var = "flibble"; local a_table = { my_var = "something" }` vs `local b_table = { ["flibble"] = "something" }`
13:57:59 <andythenorth> the filename was an elaborate troll
13:58:08 <andythenorth> (default file extension is .nut)
13:58:42 <andythenorth> clearly definitely lunch
13:59:37 <peter1138> It's probably FIRS' fault.
14:04:26 *** D-HUND is now known as debdog
14:04:45 <debdog> a typo. It's supposed to be "lynch"
14:08:19 <peter1138> Is that what happens when I break cargo types?
14:16:06 <johnfranklin> Hello. I want to ask a question about makefile:
14:16:06 <johnfranklin> Bulk conversion from .md to .txt, since currently BaNaNaS does not support .md docs
14:17:45 <johnfranklin> According to current resources on Internet, it could not be done by "mv"
14:17:45 <johnfranklin> after "mv \*.md \*.txt", the .md file gone, but the .txt file did not appear. Luckily I have git repos...
14:18:48 <andythenorth> GPT can probably do it 😛
14:20:10 <peter1138> Does it not support that?
14:20:15 <peter1138> OpenTTD supports it... Hmm.
14:20:39 <peter1138> Better to change BaNaNaS to allow it?
14:24:35 <andriydohniak> johnfranklin: So you just want to rename all the files from .md to .txt?
14:24:48 <andriydohniak> Or do you want to actually convert them
14:28:22 <LordAro> %.txt: %.md\n\tcp $< $@
14:28:53 <LordAro> `mv` has no idea what wildcards are, only your shell knows that
14:29:37 <LordAro> and your shell probably expanded that into `mv foo1.md foo2.md bar.txt` , which i'm actually surprised if it would work
14:29:45 <LordAro> s/work/actually do anything/
14:30:08 <johnfranklin> Oh... Just very simple
14:30:12 <wensimehrp> andythenorth: True
14:30:53 <johnfranklin> I didn't know cp can automatically detect whether the last input is a directory or a file name
14:32:10 <andriydohniak> `for file in *.md; do bn=$(basename -s .md "$file"); mv "$file" "$bn.txt"; done`
14:32:41 <andriydohniak> When testing I accidentally renamed all the files in my openttd test repo 🤣
14:33:18 <andriydohniak> If you want an explination, plop that into chatGPT, it should handle that
14:37:01 <johnfranklin> And another problem is, in the current situation, the "*.md" is replaced by $(DOC_FILES), which is defined by the users, and may contain files other than md
14:37:29 <johnfranklin> Will this still work?
14:37:33 <andriydohniak> johnfranklin: You want this to be a script?
14:38:11 <andriydohniak> Do you want this to be used by somebody else?
14:38:52 <andriydohniak> No, this won't work,
14:39:09 <andriydohniak> If it only contains .md it will work
14:39:16 <andriydohniak> if not, I should add some check
14:39:19 <johnfranklin> Add some "ifeq"?
14:39:54 <Eddi|zuHause> well, it'll also "work" if there is no .md file, it just does nothing
14:40:48 <andriydohniak> Eddi|zuHause: yea, but if you put NON md files in the list it will just add .txt to the end
14:41:23 <johnfranklin> Eddi|zuHause: "for every 4 < x < 2, I live on Mars" thing
14:41:50 <Eddi|zuHause> "for file in *.md" with no .md file will just never execute anything in the loop
14:41:51 <andriydohniak> Actually the current script won't work for files with nested dirs
14:42:25 <andriydohniak> Eddi|zuHause: Yea, but if you put non md files in the list, it will execute, because *.md is replaced by an env variable
14:42:31 <Eddi|zuHause> and it will skip all other files
14:43:00 <andriydohniak> Eddi|zuHause: take a look at the makefile screenshot
14:43:55 <Eddi|zuHause> can't do that right now
14:44:15 <johnfranklin> LordAro: Can this work?
14:45:38 *** Wormnest has joined #openttd
14:48:48 <johnfranklin> Is "\n\t" some weird conversion of new line and indent between IRC and discord?
14:50:54 <LordAro> it's me writing it out because i can't put newlines or tabs in a message
14:52:02 <LordAro> obviously whatever requires/uses DOC_FILES needs updating to use the .md version
14:53:38 <andriydohniak> for file in $(YOUR_VAR) ;do
14:53:38 <andriydohniak> if [[ "$file" = *.md ]] then
14:53:38 <andriydohniak> bn="$(basename -s .md "$file")"
14:53:39 <andriydohniak> path="$(dirname "$file")" mv "$file" "$path$bn.txt"
14:54:03 <LordAro> not especially makefile friendly
14:54:13 <andriydohniak> It is, just copy it
14:54:19 <andriydohniak> Copy the for loop
14:54:24 <johnfranklin> andriydohniak: Thanks ❤️
14:54:44 <LordAro> let me rephrase, it's not the way makefiles are supposed to work
14:55:11 <andriydohniak> LordAro: Idk, I am a noob
14:55:19 <LordAro> makefiles work on a "output file depends on X other files"
14:55:42 <LordAro> hence my original rule
14:55:56 <LordAro> %.txt: %.md\n\tcp $< $@
14:55:56 <andriydohniak> LordAro: I don't understand it
14:56:18 <andriydohniak> LordAro: yea, but what if the md files are in different dirs
14:56:35 <LordAro> that's covered by the pattern rule (%)
14:56:47 <andriydohniak> and what is the weird \n\tcp?
14:57:06 <LordAro> i'm just writing the escape codes
14:57:20 <andriydohniak> That is AMAZING
14:57:52 <andriydohniak> For you it's a lol, for me this is the peak of genious
14:58:32 <johnfranklin> And how to limit to only convert %.md in $(DOC_FILES)?
14:58:52 <johnfranklin> Sorry, I am noob
14:59:20 <LordAro> you probably need to change the md files in DOC_FILES to be txt files instead
14:59:35 <LordAro> then, when something asks for foo.txt, it'll go and make it (by copying foo.md)
15:00:54 <johnfranklin> hmm, just because GitHub repo pages are generally with a Markdown readme of the repo
15:02:11 <andriydohniak> johnfranklin: No, the markdown rules just work in a weird way
15:02:44 <andriydohniak> so when you have a rule that can make any txt file, it's not run by default, unless some other rule requires it.
15:03:06 <andriydohniak> so you can make a variable with all the .md names that you want to be converted
15:03:41 <andriydohniak> substitute .md names to .txt automatically, and make a rule that requires all the names in that variable
15:04:59 <andriydohniak> But I should be working, not doing makefile challenges
15:05:15 <andriydohniak> Just do what LordAro said with that insanelly small rule
15:05:40 <andriydohniak> it will create some extra .txt files, but it's fine
15:06:13 <andriydohniak> And replace \n with `<Enter>` and \t with `<Tab>` key
15:06:42 <andriydohniak> btw if you want to share something like LordAro wanted without discord mangling it, you can use 3 backticks like this:
15:07:26 <andriydohniak> so this would be the whole rule
15:07:53 <peter1138> Proper makefile usage, yes.
15:08:23 <andriydohniak> peter1138: Not mine, all the credit goes straight to LordAro
15:08:24 <peter1138> Doesn't that assume ALL required .txt files are sourced from .md files?
15:08:39 <andriydohniak> peter1138: they are
15:09:01 <andriydohniak> because make just expands this into a bunch of tiny rules
15:09:06 <peter1138> Hmm, 7 people on voice chat, wonder what event is going oin.
15:09:07 <andriydohniak> only based on the .md files
15:09:26 <LordAro> only if they don't exist and have a matching .md file
15:09:31 <LordAro> (or are older than it)
15:10:21 <andriydohniak> Nothing is more impressive to me then knowing sed, makefile, and awk well
15:11:03 <Eddi|zuHause> of those, makefile is definitely the worst
15:11:17 <andriydohniak> and the most important
15:11:24 <andriydohniak> awk is a whole programming language
15:11:37 <andriydohniak> there are ppl solving advent of code in awk
15:19:10 <peter1138> awk '{print $1'} is my usual limit
15:19:32 <LordAro> anything else requires googling
15:21:13 <Eddi|zuHause> i've certainly written more complex things in awk
15:21:21 <Eddi|zuHause> but i'd have to google that all over again
15:22:58 <_jgr_> Once you're getting to that point you're probably better off ditching sed and awk in favour of a proper language
15:23:32 <Eddi|zuHause> awk is great if your input is vaguely table-like
15:23:41 <andriydohniak> Eddi|zuHause: I know how to cut by columns or select a row, but thats it
15:23:49 <andriydohniak> Or even select multiple rows
15:24:00 <andriydohniak> but I have no idea how to make a variable in awk
15:24:17 <andriydohniak> and `sed` I just don't know how to use at all
15:24:34 <Eddi|zuHause> sed is just "simple" regex
15:24:57 <andriydohniak> except it supports "extended" regex too, and operate on files
15:25:00 <Eddi|zuHause> awk is likely a strict superset of sed
15:25:04 <andriydohniak> and it can change a file
15:25:23 <andriydohniak> Eddi|zuHause: well it's a turing complete programming language
15:25:38 <andriydohniak> but if you know how to use sed, it's extreamly usefull
15:26:10 <andriydohniak> What is going on with all the Cats in this chat! I don't look at the names, and now there are just cats swapping each other! I don't know who is who
15:29:31 <peter1138> If your regex is simple 🙂
15:29:55 <andriydohniak> I just launched `perl -pi -e` 🤣
15:29:57 <Eddi|zuHause> are you the kind of person who just types everything in a shell that someone says? :p
15:30:03 <andriydohniak> I had never used perl
15:30:17 <Eddi|zuHause> that might be dangerous :p
15:30:23 <andriydohniak> Eddi|zuHause: No, but I didn't see any obfuscated ways to kill my system
15:30:45 <Eddi|zuHause> like, missing arguments?
15:30:46 <andriydohniak> I was pretty sure that perl doesn't have a command line switch to rm -rf my home dir
15:31:07 <andriydohniak> Eddi|zuHause: That's not dangerous
15:31:22 <andriydohniak> Especeially if not running crappy scripts
15:31:26 <Eddi|zuHause> maybe, but it could be.
15:31:45 <andriydohniak> perl is too big to have such a dumb problem
15:32:47 <andriydohniak> If you want to prove me wrong, you can give me different commands, and I will run all that I think will not destroy my system
15:32:55 <andriydohniak> will see if I slip up
15:50:21 <andythenorth> ach I'm going to stop including GPL notices on GS
15:50:30 <andythenorth> they make the line numbers unusable for errors
15:50:59 *** gelignite has joined #openttd
16:00:14 <andythenorth> they're pre-pended by the compile, they're not in the source files
16:00:52 <peter1138> Yes, don't do that. Just include it in the source files. It is the source that matters...
16:00:56 <andythenorth> 'seemed like a good idea at the time'
16:01:22 <andythenorth> can't abide them being in the source, it makes every file unusable
16:02:03 <LordAro> the short 3 line version would do
16:06:42 <andythenorth> wonder what the worst that can happen is if the GPL notice is missing
16:06:54 <andythenorth> it's not GPL compliant to omit them
16:07:03 <andythenorth> they must be in **every** source file
16:07:10 <LordAro> Richard Stallman turns up at your door and berates you
16:09:39 <debdog> I'd rather be afraid of some big corp snatching the code claiming copyright
16:11:05 <Eddi|zuHause> andythenorth: think of them like the watermarks on stock photos
16:11:28 <andythenorth> can I legally GPL something written by GPT?
16:13:23 <andriydohniak> andythenorth: I have seen a good solution for this problem: you make a 1 line comment at teh beginning of the file, something like:
16:13:23 <andriydohniak> // Copyright from 2024 Andrii Dokhniak, file licensed under GPL, see the end of this file
16:13:30 <andriydohniak> and then include GPL at the end
16:13:33 <andriydohniak> but not the full one
16:13:42 <andriydohniak> there are shorter ones
16:14:34 <andriydohniak> Eddi|zuHause: probably not, but nobody will ever do anything about it
16:15:12 <_glx_> andythenorth: based on how squirrel types work internally, I think the key can be any type
16:15:15 <andriydohniak> RN the AI companies say that anything you generate with AI is compleately yours
16:15:38 <andriydohniak> And if they are proven wrong, no blame will fall on you, because at the time this was ok
16:15:55 <andriydohniak> Copilot is way too big for courts to figure this out
16:16:05 <andythenorth> _glx_: the key can, but not if the slot declarations are made inside the {} operator
16:16:30 <_glx_> even with `[]` syntax ?
16:17:01 <andythenorth> it works with `local my_table = { ["some string"] = 10 };`
16:17:09 <andythenorth> but I won't use that because it's just too weird
16:17:28 <andythenorth> I don't know if that's an array, or a [] accessor for the local context
16:18:06 <_glx_> it's similar to my_table["some string"] <- 10
16:18:36 <andythenorth> but for readability it's bad 🙂
16:18:48 <andythenorth> if the slot value is then an array
16:18:50 <andythenorth> it's very confusing
16:19:57 <_glx_> why do you need a string as key ?
16:22:34 <andythenorth> it's not needed, I just keep tripping up on it
16:22:50 <andythenorth> and GPT couldn't understand it because the docs say any hashable type is valid Squirrel key
16:23:22 <andythenorth> I might declare all my squirrel tables as python inline, and let the code generator convert them
16:23:35 <andythenorth> but I don't know if GPT will learn how to do that
16:40:40 <andriydohniak> Can somebody explain a bit about how SLE_VAR_* and SLE_FILE_* work
16:41:17 <_glx_> var is type/size in memory, file is type/size in savegame
16:41:23 <andriydohniak> when and how is it encoded/ decoded
16:41:50 <andriydohniak> How would I go about introducing my own new combination of file/var
16:41:54 <andriydohniak> and it's encoders
16:44:29 <_glx_> ReadValue and WriteValue in saveload.cpp for reading and writing, there's also some functions for the sizes
16:44:59 <andriydohniak> so read is to go savefile -> memory, write the other way
16:46:01 <_glx_> well ReadValue and WriteValue are on memory side, the savegame uses SlSaveLoadConv
16:46:32 <andriydohniak> Now this I don't get
16:46:54 <andriydohniak> What exactly does ReadValue do?
16:48:38 <andriydohniak> I am more interested how SLObjectMember works
16:48:50 <andriydohniak> but I will get there eventually
16:49:30 <_glx_> SlObject is the high level part, all SLE_ stuff is used at low level
16:50:22 <andriydohniak> Hmm, I need an SLObject then
16:51:38 <andythenorth> I already wrote something to convert python structures to GS tables 😛
16:52:22 <andythenorth> don't think strings will work there either 😄
16:57:11 <andriydohniak> I decided I want to use Arrays of bytes as a representation of bitfields for sending over the wire, and savegames, and use a custom type for in memory usage
16:57:51 <andriydohniak> But I still don't understand, when what function is called, and how would I go about doing that (converting 1 type to another)
16:58:00 <andriydohniak> Any help is greatly apriciated
17:08:20 <andriydohniak> I think I got how the saveload mechanism works:
17:08:20 <andriydohniak> 1. There are tables of SaveLoad structs, which have pointers to variables that need to be read/written to
17:08:20 <andriydohniak> 2. When the game needs to save / load something, it calls the function (lambda) attached to the SaveLoad struct, with a pointer, and an instruction
17:08:20 <andriydohniak> 3. Depending on the instruction, it either reads form a global writes memory data to that pointer, or reads from it and writes to some global
17:08:47 <andriydohniak> 4. that global has a bunch of functions to make it easy to read / write from anywhere
17:09:24 <andriydohniak> I am not compeleately sure how the global + function works yet, but everything else seams clear
17:10:05 <andriydohniak> I also skipped a bunch of steps when it reads headers and figures out what to call
17:10:24 <andriydohniak> and some additional info is stored in the headers, like data types, sizes, etc
17:12:27 <andriydohniak> Corrections? Additions?
17:13:12 *** HerzogDeXtEr has joined #openttd
17:19:47 <LordAro> globals should be avoided if at all possible
17:19:49 <LordAro> but otherwise seems fine
17:20:02 <LordAro> i'd call it a "conversion function" :D
17:47:03 <andriydohniak> LordAro: That's not my code, I am just trying to understand the code already present
17:52:35 <peter1138> Hmm, I wonder what the difference is between all these Noto Sans CJK variants.
17:53:00 <peter1138> HK, JP, KR, SC and TC. I can render Korean glyphs with any of them selected.
18:01:40 <andriydohniak> peter1138: Do you have the .ttf files?
18:01:49 <andriydohniak> if so, you can use font forge to check
18:02:03 <andriydohniak> ttf/otf/something else
18:18:01 <andriydohniak> In c++, how would I div int by 8, and get the ceil of that division?
18:19:39 <wensimehrp> peter1138: There's a slight difference between the Chinese character regions are using, e.g. 没 and 沒, and to include every glyph that is in use is obviously unrealistic as doing so brings many compatibility problems, so the solution is to have font variants.
18:33:57 <peter1138> Hmm, well, that lot all displays fine in Discord, so in theory I can make it display fine in OpenTTD 🙂
18:40:01 <peter1138> Hmm, maybe making a pre-emptive list of available characters is a bit inefficient.
18:40:17 <peter1138> 14,680 available right now.
18:41:17 <peter1138> Might be better to 'search' for each glyph as its needed.
18:52:33 *** Flygon has quit IRC (Quit: A toaster's basically a soldering iron designed to toast bread)
19:18:12 <peter1138> Oh, I think I know.
19:19:22 <peter1138> The fallback font search looks for the substituted question mark.
19:26:28 <peter1138> Wow, that code was bad 😄
19:27:18 <andriydohniak> I WAS ALMOST DONE!!!
19:27:28 <andriydohniak> but what is newgrf_town.cpp
19:29:00 <andriydohniak> what is grf in general?
19:29:18 <peter1138> (New)GRFs are addon files.
19:29:25 *** binglunge has joined #openttd
19:29:25 <binglunge> Are there some legal problems to preset default fonts to built-in fonts in windows?
19:30:11 <binglunge> For example, for Japanese, we will use MS Mincho, Batang for Korean, SimSun for simp.Chinese, MingLiU for trad.Chinese.
19:30:31 <binglunge> (All of them have bitmap glyphs.)
19:30:44 <peter1138> We just search for a suitable font.
19:31:03 <andriydohniak> peter1138: For now I commented the problematic line out,
19:31:06 <peter1138> (Except I accidentally broke the code that searches last night :))
19:32:48 <binglunge> You means that store ttf or otf font files in grf file?
19:33:11 <peter1138> Different conversation.
19:34:19 <andriydohniak> I still have A LOT of backwards compatibility / QOL work to do, but IT WORKS 🎆
19:34:49 <andriydohniak> My first ever C++ project larger then 100 loc
19:35:04 <andriydohniak> I am at 35 companies with no crashes
19:37:46 <binglunge> Built-in Noto CJK fonts are not a good choice, they are too large. But it seems like that most of modern Linux desktop have them in fonts folder.
19:38:24 <_glx_> openttd just use fonts available on the system
19:38:50 <andriydohniak> peter1138: If you don't mind, can you take a look?
19:38:50 <_glx_> and we provide our own for latin-like languages
19:40:09 <andriydohniak> I am surprised how little code it actually is (still not complete). But all the work was in figuring out how everything works
19:40:38 <binglunge> _glx_: Indeed, and I think for most of players who don't have enough computer skills, it is good to select default fonts built-in in OS automatically.
20:11:07 *** gelignite has quit IRC (Quit: Stay safe!)
20:46:06 <andythenorth> pff GSList is annoying to work with
20:46:23 <andythenorth> maybe I could template python around all these GS structures to make them easier
20:52:44 <andythenorth> ` local town_list = GSTownList();
20:52:44 <andythenorth> local town_list_towns = [];
20:52:44 <andythenorth> foreach (town, _ in town_list) {
20:52:44 <andythenorth> town_list_towns.append(town);
20:52:50 <andythenorth> that's how I get a list of towns in GS
20:53:03 <andythenorth> but GSList is highly efficient
20:53:30 <andythenorth> but no Items() method
20:54:27 <_jgr_> Highly efficient is rather debatable
20:55:02 <andythenorth> so efficient I have to loop it and create another list
20:56:41 <peter1138> What do you do with town_list_towns that you can't do with town_list?
20:58:27 <andythenorth> I need to store the index in an array
20:58:33 <andythenorth> I mean...I could just store the GSList
20:58:40 <andythenorth> but I hate working with them, they make no sense
21:11:32 <andythenorth> do we know if GSList.AddItem() is append or prepend?
21:12:12 <andythenorth> fuck it, maybe I'll just convert this to a list as well
21:14:31 <andythenorth> `town_list.Valuate(GSBase.RandItem);` should randomise list order
21:14:59 <_jgr_> GSList is not really a list at all
21:16:14 <_glx_> yeah and it's not meant to be used as storage by scripts
21:16:43 <_jgr_> I expect that that is news to script authors
21:16:48 <_glx_> the workflow is get a list, valuate and filter, then make a decision
21:18:22 <andythenorth> I am not wanting to use it as storage 🙂
21:18:32 <andythenorth> it's just the only interface to things like towns
21:18:38 <_glx_> GSList is a kind of sorted map
21:18:54 <andythenorth> there's no public method for GSTownList.GiveMeAnActualArray()
21:19:07 <andythenorth> I could write something probably
21:19:22 <andythenorth> think there's a way to extend builtin classes?
21:19:43 <andythenorth> nobody writes GS 😛
21:20:32 <_jgr_> andythenorth: This will probably work as by default the list sorts by value instead of by key
21:21:02 <_jgr_> (Yes, that is silly, but that's how it is)
21:23:22 <andythenorth> GPT wrote most of this .pynut
21:23:31 <andythenorth> I had to fix it a lot, GPT is sloppy
21:28:07 <andythenorth> I am sure there are better ways to work with lists
21:32:41 *** keikoz has quit IRC (Ping timeout: 480 seconds)
22:05:53 *** Wolf01 has quit IRC (Quit: Once again the world is quick to bury me.)
22:13:50 *** wallaby2 has joined #openttd
22:15:46 *** wallabra has quit IRC (Ping timeout: 480 seconds)
22:20:03 *** alex2000ita has joined #openttd
22:40:27 *** felix_ has quit IRC (Read error: No route to host)
22:42:25 *** felix has quit IRC (Ping timeout: 480 seconds)
continue to next day ⏵