IRC logs for #openttd on OFTC at 2025-03-26
β΄ go to previous day
00:19:02 *** WormnestAndroid has quit IRC (Remote host closed the connection)
00:19:04 *** WormnestAndroid has joined #openttd
02:54:39 *** Wormnest has quit IRC (Quit: Leaving)
03:00:08 *** herms has quit IRC (Quit: bye)
03:09:24 *** geizeskrank has quit IRC (Ping timeout: 480 seconds)
03:10:04 *** akimoto has quit IRC (Remote host closed the connection)
03:12:55 *** geizeskrank has joined #openttd
03:55:49 *** debdog has quit IRC (Ping timeout: 480 seconds)
04:44:27 <DorpsGek> - Update: Translations from eints (by translators)
05:24:45 <pickpacket> Rubidium, frosch123: thank you muchly for helping me with my PR π and also SamuXarick
06:25:31 *** keikoz has quit IRC (Ping timeout: 480 seconds)
06:50:19 *** akimoto has joined #openttd
07:13:09 *** reldred has quit IRC (Quit: User went offline on Discord a while ago)
08:30:01 *** mindlesstux has joined #openttd
08:35:53 *** mindlesstux has joined #openttd
09:25:14 <xarick> hmm, i wonder something
09:27:06 <xarick> if the instance isn't started... the saved data goes poof!
09:52:32 <xarick> i suspect there might be a problem with AI's too, let me test
09:55:08 <pickpacket> What's the current release plan for 15.0-beta2 or 15.0?
09:55:45 <LordAro> gets pushed back a week any time someone asks
10:01:13 <pickpacket> LordAro: so what is it now?
10:21:09 <xarick> strange that im not getting a crash on AIs
10:21:17 <xarick> possibly depends on the ai?
10:21:46 <xarick> it's doing the exact same thing
10:27:33 <peter1138> /usr/include/c++/12/bits/unique_ptr.h:93:23: error: invalid application of βsizeofβ to incomplete type βGRFConfigβ
10:28:35 <peter1138> So there's a unique_ptr with an incomplete type, but the class containing that has a non-inlined constructor so it shouldn't matter.
10:29:04 <kuhnovic> It's probably the destructor
10:31:56 <peter1138> Non-inline destructor too.
10:32:21 <xarick> what's the difference in behaviour between Game::GameLoop() and AI::GameLoop()
10:32:37 <xarick> why is AI::GameLoop() paused
10:32:49 <xarick> but Game::GameLoop() always running even when paused
10:36:04 * pickpacket looks at peter1138 and decides to wobble
10:36:07 <xarick> nevermind, it's not running in scenario editor... then what the heck is wrong? Where does it go wrong?
10:36:31 <peter1138> Game script is able to run somewhere.
10:38:09 <peter1138> Got it. It's `= nullptr;`
10:38:38 <peter1138> So we've default initialised it, and that breaks it.
10:38:52 <xarick> ah line 1224 in openttd.cpp
10:39:03 <xarick> I think this is it, let's see...
10:39:05 <peter1138> The annoying C++ rules on when things should and shouldn't be initialised.
10:41:14 <peter1138> We blanket initialised things when moving away from ZeroedMemoryAllocator.
10:45:01 <xarick> Game::GameLoop() is called but AI::GameLoop() isn't, in scenario editor, but only sometimes! very strange
10:49:43 <xarick> sometimes this is true, sometimes this is false
10:50:05 <xarick> this dictates whether Game::GameLoop() is called or not
10:50:21 <xarick> if it is called, changing a GS will end up crashing openttd
10:50:32 <xarick> but it also depends on the GS
10:52:24 <xarick> what is possibly defining _pause_mode?
10:56:40 <xarick> enum bitset stuff hard for debugging
10:57:02 <xarick> i need a breakpoint in _pause_mode detecting a change
11:04:38 <xarick> what does _pause_mode == 2 mean?
11:05:49 <peter1138> It's a bitmask, so a value of 2 means bit 1 is set.
11:05:52 <kuhnovic> xarick: Assuming you are running Visual Studio: while debugging, right click _pause_mode and choose "Add Watch". In the watch window, right click the watch and click "Break when value changes".
11:08:09 <xarick> _pause_mode is also stored in savegames, interesting
11:11:03 <xarick> line 1140 in openttd.cpp - cancel the saveload pausing.
11:12:44 <xarick> _pause_mode on the crash prone savegame from #10179 we get a 3
11:12:58 <xarick> it cancels the saveload pausing, remaining a value of 1
11:13:49 <xarick> 1 != 0 is true, meaning it will call Game::GameLoop() in line 1224 openttd.cpp
11:14:21 <xarick> changing the GS in this circumstance will crash openttd
11:14:49 *** toktik has quit IRC (Remote host closed the connection)
11:20:30 <peter1138> Anyway, your fix for the gamescript running in scenario editor seems correct at least.
11:20:48 <peter1138> I was querying if anything similar needed to happen for AIs.
11:22:46 <xarick> my fix is bad... because if I don't change the GS, I want the save data to remain once I save the scenario again
11:23:34 <xarick> I have a different idea
11:24:47 <xarick> let it start the instance
11:24:53 <xarick> but don't run gameloop
11:35:07 <xarick> well, changing to something else other than none
11:35:21 <xarick> will still keep the save data of the previous script
11:35:42 <xarick> the new script load function will be trying to load the data of the other script
11:36:32 <xarick> not an openttd crash at least
11:46:56 <_glx_> If you load a running save game in scenario editor you should expect some weird things with script saved data
11:55:05 <_glx_> xarick: But if you change the script it's supposed to start a new VM, and to_load data is discarded in this case
11:57:29 <_glx_> Unless some steps are missing
12:00:10 <peter1138> 1) It shouldn't run any script
12:00:31 <peter1138> 2) I think it shouldn't discard anything, unless you make changes to the configuration.
12:46:03 *** WormnestAndroid has quit IRC (Remote host closed the connection)
12:46:15 *** WormnestAndroid has joined #openttd
12:56:57 *** WormnestAndroid has quit IRC (Remote host closed the connection)
12:57:01 *** WormnestAndroid has joined #openttd
13:19:54 *** pickpacket6 has joined #openttd
13:23:16 *** pickpacket has quit IRC (Ping timeout: 480 seconds)
13:23:16 *** pickpacket6 is now known as pickpacket
15:08:40 *** Wormnest has joined #openttd
15:08:48 *** WormnestAndroid has quit IRC (Read error: Connection reset by peer)
15:08:49 *** WormnestAndroid has joined #openttd
15:12:29 <peter1138> Hmm, nice race condition.
15:34:07 *** WormnestAndroid has quit IRC (Read error: Connection reset by peer)
15:34:08 *** WormnestAndroid has joined #openttd
15:34:10 *** WormnestAndroid has quit IRC (Read error: Connection reset by peer)
15:34:12 *** WormnestAndroid has joined #openttd
15:34:14 *** WormnestAndroid has quit IRC (Read error: Connection reset by peer)
15:37:18 *** WormnestAndroid has joined #openttd
15:41:25 <xarick> AIs are harder to deal now, with 2 configs around
15:43:31 <_glx_> not really, if it's started it's in Company else it's in GameSettings
15:45:19 <_glx_> and AIConfig::GetConfig() exists to get the right one
15:47:12 <peter1138> So, `delete this->x; (destructor of x does stuff that accesses this->x); this->x = nullptr;`
15:47:28 <peter1138> Turns out this breaks when x becomes a unique_ptr.
15:48:31 <peter1138> I'm not sure if that's undefined behaviour or not.
15:52:36 <xarick> I'm in the scenario editor, I wanna change an AI to another. There are quite some possibilities:
15:52:36 <xarick> - AI was started (company exists), uses company config
15:52:36 <xarick> - AI was not started (company doesn't exist), uses array config
15:53:20 <xarick> what I'm now trying to do is StopAI when i change the config
15:54:03 <xarick> - AI not started (but company exists), what config should I deal with?
15:55:55 <xarick> stopping an AI... calls the c->ai_config.reset(), but the config I just changed seems to be the one on c->ai_config.reset()
16:00:43 <_glx_> AI is started, but not really running so changing it "works" except the saved data which still calls old AI Save()
16:01:41 <_glx_> but also stores new info, so it starts the correct one on load with wrong saved data
16:04:05 <xarick> wondering if what I did the other day solves this
16:15:32 <_glx_> I think a solution would be to call StartNew() without calling Stop(), but there's an assert in AI:StartNew() (not present in Game::StartNew())
16:16:04 <_glx_> ah it's replaced by an early return
16:17:53 <_glx_> so actually a partial stop is needed
16:18:43 <xarick> this new unique ptr stuff is in my way π¦
16:20:34 <_glx_> that's not a problem, it works as before without requiring manual delete
16:21:01 <xarick> it does not like this: *config = std::make_unique<AIConfig>(c->ai_config);
16:25:58 <exceptik> xarick: doesn't work this way, show the whole line
16:27:14 <exceptik> w... why do you have a raw pointer to a unique pointer π
16:27:31 <xarick> i don't know anything about pointers
16:28:23 <peter1138> AIConfig's constructor was recently changed to accept a reference instead of a raw pointer.
16:28:34 <peter1138> Therefore, you need to pass the object itself, not a pointer to the object.
16:30:06 <peter1138> exceptik, it should be a reference but the logic doesn't allow that (references can't be changed, pointers can.)
16:30:27 <xarick> `*c->ai_config.get()` okay, this works
16:30:35 <peter1138> I thinK i can reorganise that to make it make more sense, though.
16:39:06 <exceptik> also wouldn't the .reset work better here? if i understand correctly assigning a new u_pointer would leak the old one
16:39:41 <peter1138> Assigning to a unique_ptr does not leak its old pointer.
16:40:24 <exceptik> hmm, according to cppreference it does not call the destructor on the old object π€
16:41:12 <peter1138> The object is disposed of, using the associated deleter, when either of the following happens:
16:41:15 <peter1138> the managing unique_ptr object is destroyed. the managing unique_ptr object is assigned another pointer via operator= or reset().
16:41:31 <peter1138> Maybe you're reading a different cppreference :)
16:42:21 <exceptik> or me eyes got blurry, ye i see
16:44:40 <exceptik> yeah i guess no more code for today :P
16:46:49 *** ufo-piloot has quit IRC (Ping timeout: 480 seconds)
16:48:09 <_glx_> yeah main goal for unique_ptr is to not manually handle deletion π
16:49:08 *** gelignite has joined #openttd
17:27:10 <xarick> i'd like to do a 2 stones with 1 bird thing
17:27:46 <xarick> solve the reload ai while at it
17:33:10 <_glx_> but the reload is not really a bug, it works as intended (maybe not like you would want it to work)
17:43:02 <xarick> let me check StartNew approach
17:44:01 <_glx_> it's like start/stop but without resetting the config
17:45:32 <_glx_> I guess it could also work for your restart ai using current config
17:47:57 <_glx_> current way is actually restart slot, while you want to restart the running AI ignoring slot config
17:50:31 <_glx_> that's something CTRL and the new StartNew could do I think
17:52:02 <_glx_> but it would bypass the commands, and that's bad
17:53:27 <_glx_> also means the stuff already built by AI would still be there
17:54:14 <xarick> keep the infrastructure
17:55:04 <xarick> not ideal but... if you're already going that far
17:55:27 <_glx_> not touching it π just thinking
17:58:59 <_glx_> but it's a possible way to restart the AI without any saved data, useful if using dev version and the new one doesn't understand saved data from older version (and crashes)
18:00:03 <xarick> I selected RandomAi, it picked it up immediately... not good
18:00:36 <_glx_> company exists, so a new script is launched
18:01:29 <_glx_> RandomAI is only true for not started slots
18:01:53 <_glx_> here we are modifying config of companies
18:02:23 <_glx_> and a company always has a real script
18:03:24 <_glx_> if you change a not yet started company it will stay random
18:19:25 <xarick> oops, ai debug window requires the instance->engine to not be null
18:32:19 *** ufo-piloot has joined #openttd
18:34:09 <xarick> I'm setting my PR ready to review
18:34:31 <xarick> don't think i can solve the load problem easily today
18:34:47 <xarick> but that part at least is okay, according to you
18:41:49 <xarick> AI events are triggering crashes in openttd... this is complex
18:42:07 *** ChanServ sets mode: +v tokai
18:42:27 <xarick> apparently the instance must exist if the company exists
18:43:15 <xarick> so my PR is still fine for that, it doesn't remove the instance, it just doesn't let it loop
18:49:10 *** tokai|noir has quit IRC (Ping timeout: 480 seconds)
20:36:22 <xarick> what the difference between config == nullptr and config.empty()
20:43:15 <xarick> i forgot how to detect current ai is random
21:00:40 <xarick> error C2102: '&' requires l-value
21:07:52 <_glx_> what you are writing makes no sense π
21:09:09 <xarick> yeah, the probability of making no sense was high
21:09:15 <xarick> I have no idea what to write
21:09:29 <xarick> I was trying to replace `std::unique_ptr<AIConfig> *new_config = &GetGameSettings().script_config.ai[company];`
21:09:44 <_glx_> first it's `std::unique_ptr<XXX> name`
21:12:16 <_glx_> and writing code without understanding what you are doing is silly π
21:20:24 <peter1138> If it works and has the same behaviour, yeah.
21:32:24 <xarick> the new_config went into the trash bin
21:32:34 <xarick> should have gone to the array
21:33:49 <xarick> the code which makes no sense should work
21:34:29 <xarick> but requires an L value
21:34:41 *** nielsm has quit IRC (Ping timeout: 480 seconds)
21:38:03 <peter1138> Is that a comment about #13900?
21:38:53 <xarick> it's about my pointers failing
21:39:57 <xarick> clang gives me a better error:
21:45:17 <peter1138> Hmm, so -Wundefined-var-template.
21:45:42 <peter1138> Seems users disable the warning because it's a pain, but the author that added the warning says it's correct.
21:47:12 <peter1138> (users of the compiler that is :))
21:50:05 <xarick> I can only make it work with this code π¦
21:50:58 <xarick> AI::Config::GetConfig etc... can't make it work
21:52:05 <xarick> let me look at your code
22:08:34 <xarick> I asked Mr Copilot about... #13900
22:10:15 <_glx_> xarick: this compile but the code clearly won't work
22:14:12 <_glx_> you just need to do something similar to AIConfig::GetConfig (ie use references)
22:19:48 <xarick> the new version of AIConfig? or the old?
22:19:58 <_glx_> the new one, it's simpler
22:20:47 *** keikoz has quit IRC (Ping timeout: 480 seconds)
22:39:19 <xarick> this compiled, let's see if it does what I want
22:42:16 <_glx_> you are writing silly overcomplicated things
22:42:24 <xarick> nope, doesn't do what i want
22:43:55 <xarick> it's treating new_config as not being part of the array of configs
22:44:23 *** gelignite has quit IRC (Quit: Stay safe!)
22:44:26 <_glx_> auto &new_config = GetGameSettings().script_config.ai[company];
22:44:26 <_glx_> if (new_config.GetInfo() != nullptr) {
22:44:26 <_glx_> new_config = std::make_unique<AIConfig>(*current_config);
22:45:24 <xarick> hmm, there's no way around GetGameSettings() ?
22:45:48 *** WormnestAndroid has quit IRC (Read error: Connection reset by peer)
22:45:52 *** WormnestAndroid has joined #openttd
22:46:21 <_glx_> you want to modify the storage, AIConfig::GetConfig returns the content
22:49:29 <_glx_> but you can replace `GetGameSettings()` with `_settings_game` since it's a running game anyway
22:49:42 <xarick> pointers are my downfall ^-_-^
22:49:58 <_glx_> pointers and references are basic stuff
23:00:37 *** Wolf01 has quit IRC (Quit: Once again the world is quick to bury me.)
23:47:34 *** Flygon has quit IRC (Read error: Connection reset by peer)
continue to next day β΅