IRC logs for #openttd on OFTC at 2025-11-14
⏴ go to previous day
02:27:29 *** Wormnest has quit IRC (Quit: Leaving)
03:58:14 *** gnu_jj_ has quit IRC (Ping timeout: 480 seconds)
04:23:06 *** Zathras_4 has joined #openttd
04:23:15 *** Zathras has joined #openttd
04:26:31 *** Zathras_1 has quit IRC (Ping timeout: 480 seconds)
04:26:36 *** Zathras_11 has quit IRC (Ping timeout: 480 seconds)
04:39:26 <DorpsGek> - Update: Translations from eints (by translators)
05:25:16 *** ChanServ sets mode: +v tokai
05:32:25 *** tokai|noir has quit IRC (Ping timeout: 480 seconds)
07:02:08 *** Flygon has quit IRC (Remote host closed the connection)
07:18:03 *** robinsonmanane has joined #openttd
07:18:03 <robinsonmanane> I'll help the first 20 people interested on how to start earning $100k or more within a week, but you will reimburse me 10% of your profits when you receive it. Note: only interested people should send a friend request or send me a dm! ask me (HOW) via Telegram username
07:18:03 <robinsonmanane> @Robinsonmanae_0
07:18:03 <robinsonmanane> Or use the telegram link in my bio
10:17:54 *** wensimehrp has joined #openttd
10:52:38 <peter1138> do re mi fa so la ti do
12:37:32 <mmtunligit> im working on implementing the user-defined groups aspect of [#14443 ](<https://github.com/OpenTTD/OpenTTD/discussions/14443>) and im a bit stuck right now trying to figure out how to get the number of groups. i think i'm missing something in my struct but im not sure what, could i please get some help?
12:37:32 <mmtunligit> ```struct PickerGroup {
12:37:33 <mmtunligit> std::set<PickerItem> saved;
12:37:35 <mmtunligit> * Retrieve group details for the given picker group
12:37:35 <mmtunligit> * @param index index of picker group
12:37:37 <mmtunligit> * @pre index is a valid group
12:37:39 <mmtunligit> static inline PickerGroup *Get(size_t index)
12:37:41 <mmtunligit> return &PickerGroup::array[index];
12:37:43 <mmtunligit> static PickerGroup array[256]; ///< Array holding all PickerGroups.
12:37:45 <mmtunligit> and in PickerCallbacks i have
12:37:47 <mmtunligit> ```inline int GetGroupCount(PickerTypes type) const
12:37:49 <mmtunligit> return std::ranges::count_if(, , type);
12:46:15 <peter1138> Using a fixed length C-style array there definitely seems wrong.
12:48:35 <mmtunligit> i was copying from elsewhere in the code because i needed the Get() function, what would you reccomend instead?
12:50:21 <mmtunligit> and since i have index as a uint8_t i thought i couldnt have it any bigger anyway, though maybe im doing something wrong there too?
12:58:48 <peter1138> Why do you think you need that?
13:05:57 <mmtunligit> well the index i need because i need to have some way to find the group, and i put it as a uint8_t because i thought that would be plenty big?
13:07:08 <mmtunligit> i could really see a single player creating more than 256 groups, even across all the different picker windows, but maybe im underestimating players
13:08:35 <peter1138> I think you're over-complicating it, and you think you need to borrow from some existing unrelated systems.
13:09:33 <peter1138> Something like replacing `std::set<PickerItem> saved` with `std::map<std::string, std::set<PickerItem>> saved` gives you named groups, without needing to down the route of making up an index system, adding static arrays, etc...
13:11:17 <mmtunligit> that is an issue ill probably repeatedly run into on my journey, learning by taking things apart means im not nessecarily aware of all the tools in my toolbox
13:26:38 <xarick> do i do sudo apt autoremove before continuing or after?
13:27:31 <rito12_51026> it doesn't matter
13:34:48 <xarick> nice, now i get vs code doing some different errors
13:47:11 <_glx_> install dev package for sdl
13:51:40 <xarick> wowowow, it's building
13:52:12 <_glx_> ideally you also want dev packages for png and zlib
13:56:27 <_glx_> expected, you need sudo to install
13:57:25 <_glx_> no need to install anyway
13:58:36 <xarick> [build] 1: + Error: Failed to find a graphics set. Please acquire a graphics set for OpenTTD. See section 1.4 of README.md.
14:07:55 <xarick> dont know how to do it
14:11:02 <xarick> why doesn't it ask to download?
14:15:37 <peter1138> If you built without some of the required dependencies then bootstrap isn't built either.
14:23:38 <kaji_kaede> forgot lzma package, unbelievable
14:24:05 <xarick> how did it load the opntitle ?
14:24:34 <kaji_kaede> ...It doesn't use the legacy one, does it?
14:26:24 <kaji_kaede> okay so yeah no you just don't have the lzma package
14:28:07 <kaji_kaede> then sudo apt install... probably whatever first comes up as 'liblzma'?
14:33:39 <xarick> missing PNG and CURL now
14:35:44 <kaji_kaede> > content downloads
14:38:49 <xarick> but i downloaded opengfx2 classic fine
14:39:11 <xarick> i can't run the debugger though
14:40:30 <kaji_kaede> That's because CMake wants GDB, because otherwise it has no debugging tool to use right now.
14:43:18 <xarick> Command 'gdb' not found, but can be installed with:
15:05:45 <xarick> i can finally check what SwapList is doing on linux
15:14:15 <xarick> oh, it's different code
15:26:16 <_jgr_> Those are functionally the same
15:37:48 <xarick> I can't locate the item_iter on the linux side
15:53:17 <xarick> this is where they diverged
15:58:47 <xarick> now i wonder what item will linux get
16:00:34 <xarick> it's getting an item from the other list!
16:01:36 <xarick> this belongs to the other list
16:05:34 <_glx_> no it respects the spec about iterators
16:06:35 <_glx_> continuing iteration after swap is asking for troubles
16:07:19 <_jgr_> Still, poorly written scripts should not be able to cause UB in the real game
16:07:30 <_glx_> unless a lot of care is done to make it safe
16:08:44 <peter1138> _glx_, Retarget() should invalidate everything then. It's already virtual.
16:12:49 <_jgr_> Looking more closely, the sorter instances themselves are swapped, so it doesn't look like UB
16:14:02 <_jgr_> Iteration will resume from wherever the other list was, how this is useful I'm not sure though
16:14:58 <xarick> `this->list->items.end()` vs `std::end(this->list->items)` would this make a difference?
16:16:21 <_jgr_> Though looking at the spec, swap does invalidate the end iterator, which makes sense as it likely points at the root rather than some node which will happily get swapped
16:17:24 <_jgr_> So just resetting all the iteration state would be sensible
16:21:59 <_glx_> an option could be to store the distance before swap, then reset iterator and restore the distance
16:24:16 <peter1138> Trying to maintain iterations increases maintenance burden.
16:25:48 <_jgr_> If it was useful to preserve the iterator, std::distance is a quite expensive way to do that
16:27:46 *** WormnestAndroid has quit IRC (Ping timeout: 480 seconds)
16:30:42 *** WormnestAndroid has joined #openttd
17:55:51 *** kuka_lie has joined #openttd
19:24:06 *** WormnestAndroid has quit IRC (Read error: Connection reset by peer)
19:24:34 *** WormnestAndroid has joined #openttd
19:34:33 *** Wormnest has joined #openttd
20:02:22 <xarick> what if the sorter wasn't a unique_ptr
20:12:09 <_glx_> then you'll have to manage it manually
20:13:22 <Borg> heh I "like" this code...
20:13:44 <Borg> uint x = TileX(tile) * TILE_SIZE + SignalPositions[side][pos].x;
20:14:03 <Borg> C++ should bark at you for this ;)
20:15:01 <xarick> 687829fa14cd019f031e2e410a6bb8073ce19557
20:16:29 <xarick> error C3861: 'Swap': identifier not found, what was the older Swap like?
20:19:56 <peter1138> Borg, well, don't do it then.
20:29:56 <Borg> peter1138: hows your minimap zoom plan? :)
20:30:03 <Borg> im happy w/ my results... w/o rewrite
20:32:59 <xarick> the old Swaper made no difference
20:33:38 <xarick> this seems to be std:🗺️:iterator
20:39:59 <Borg> xarick: what IRC client are you using?
20:41:28 <Borg> ugh... that is mistake :P
20:55:22 <mmtunligit> oh my god thats really funny
20:55:51 <mmtunligit> discord parsed \🗺️ as an emoticon
20:59:28 <mmtunligit> ok so ive gotten farther since this morning but i need help clearing something up for this struct
20:59:28 <mmtunligit> ```struct PickerGroup {
20:59:28 <mmtunligit> std::map<std::string, std::set<PickerItem>> saved;```
20:59:30 <mmtunligit> does this function actually get the number of groups or does it just always return 1 or does it do something else entirely
20:59:30 <mmtunligit> ```inline int GetGroupCount() const
20:59:32 <mmtunligit> PickerGroup group;
20:59:33 <mmtunligit> return group.saved.size();
21:00:17 <mmtunligit> not mapped (heh) to anything in particular
21:00:29 <mmtunligit> and id suspect the bridge santizes that stuff anywway
21:01:12 <_jgr_> mmtunligit: That is always going to return 0. This is likely not the right place to create your PickerGroup instance?
21:01:51 <mmtunligit> GetGroupCount is in PickerCallbacks, not PickerGroup
21:02:25 <_jgr_> Yes, but in your method you're creating a PickerGroup instance, which is presumably empty, and then immediately destructing it
21:03:00 <_jgr_> Also `size_t` is probably a better return type than `int`
21:03:51 *** Borg has quit IRC (Quit: leaving)
21:05:12 <_jgr_> It's probably worth considering where your data is actually going to "live" for back of a better term, and what its lifetime should be
21:06:09 <mmtunligit> PickerGroups should be saved clientside and per map
21:07:02 <rito12_51026> Why not per company?
21:07:35 <_jgr_> So is PickerGroup a singleton with one global instance, or is it a zero-size thing with static fields, or something else?
21:09:04 <mmtunligit> rito12_51026: because it shouldnt matter what someone else in the same company thinks is a useful group of PickerItems, plus you dont have to go through command scope
21:10:59 <mmtunligit> _jgr_: each PickerGroup should have a static type and index but the name and the PickerItems in it can be changed. the player should eb able to define as many PickerGroups as they please
21:15:37 <_jgr_> That suggests that your map is in the wrong place then?
21:16:49 <mmtunligit> im just going off what peter suggested this morning
21:16:53 <_jgr_> If each PickerGroup has a name and a set of PickerItems, then the map should be from name to PickerGroup, not inside each PickerGroup
21:17:29 <mmtunligit> ok yeah that makes sense
21:20:50 <peter1138> No need for PickerGroup at all, I meant you can just just placed the existing `std::set<PickerItem> saved`
21:23:37 <peter1138> No need to faff about with extra static storage -- `saved` is already correct for that.
21:28:19 <xarick> List 1 Next: 1 => -5 (true) on both
21:28:37 <xarick> linux was supposed to say false
21:29:22 <xarick> let me try a debug build
21:38:32 <xarick> let me copy paste from regression.nut directly
21:46:36 <xarick> btw, linux gcc complains about something
21:51:10 <xarick> `List 1 Next: 3 >= 6 (false)` vs `List 1 Next: 3 >= 6 (true)`
21:52:08 <xarick> what would Next come up with
22:02:11 <xarick> neither lists have item 6, how does it come up with such
22:24:00 <_glx_> broken iterators after swap
22:24:59 <xarick> seems to be only about std::end
22:25:23 <_glx_> yes and `end` is used to detect the end
22:28:45 <xarick> list 3 doesn't exhibit any problem
22:28:56 <xarick> it was not at the end before it swaped
22:32:24 <xarick> what is the mac crash complaining about?
22:32:54 <xarick> do i have to wait for 14774 merge to know?
22:33:23 <_glx_> you can cherry pick and add to your PR
22:49:15 <_glx_> and indeed the crash is inside `std::map`
22:50:01 <xarick> "reason": "Segmentation fault: 11"
22:50:44 *** keikoz has quit IRC (Ping timeout: 480 seconds)
22:51:08 <_glx_> yes invalid memory access with iterators
22:52:10 <xarick> oh apple compiler is clang
22:52:22 <xarick> if only clang worked for me
23:02:00 *** kuka_lie has quit IRC (Quit: Lost terminal)
continue to next day ⏵