The International Simutrans Forum

Simutrans Extended => Simutrans-Extended development => Simutrans-Extended bug reports => Topic started by: Matthew on February 22, 2022, 07:10:18 AM

Title: [BUG] Line colours depend on SDL2 (was: Command line server build failed)
Post by: Matthew on February 22, 2022, 07:10:18 AM
Bridgewater-Brunel did not restart after this morning's reset. The datestamp of the Command Line Server Build (http://bridgewater-brunel.me.uk/downloads/nightly/linux-x64/command-line-server-build/) indicates that compilation of the latest headless nightly failed. The SDL2 build works fine.

GitHub Actions also reported that headless compilation failed because of a linking problem:

[100%] Linking CXX executable simutrans/simutrans-extended
/usr/bin/ld: CMakeFiles/simutrans-extended.dir/gui/line_color_gui.cc.o: in function `line_color_gui_t::line_color_gui_t(quickstone_tpl<simline_t>)':
line_color_gui.cc:(.text+0x6d6): undefined reference to `line_color_idx_to_rgb(unsigned char)'
/usr/bin/ld: CMakeFiles/simutrans-extended.dir/gui/line_color_gui.cc.o: in function `line_color_gui_t::init()':
line_color_gui.cc:(.text+0xf48): undefined reference to `line_color_idx_to_rgb(unsigned char)'
/usr/bin/ld: line_color_gui.cc:(.text+0xffb): undefined reference to `line_color_idx_to_rgb(unsigned char)'
/usr/bin/ld: CMakeFiles/simutrans-extended.dir/gui/line_color_gui.cc.o: in function `line_color_gui_t::line_color_gui_t(quickstone_tpl<simline_t>)':
line_color_gui.cc:(.text+0x1a76): undefined reference to `line_color_idx_to_rgb(unsigned char)'
/usr/bin/ld: CMakeFiles/simutrans-extended.dir/gui/line_color_gui.cc.o: in function `line_color_gui_t::action_triggered(gui_action_creator_t*, value_t)':
line_color_gui.cc:(.text+0x2632): undefined reference to `line_color_idx_to_rgb(unsigned char)'
/usr/bin/ld: CMakeFiles/simutrans-extended.dir/gui/line_color_gui.cc.o:line_color_gui.cc:(.text+0x26d0): more undefined references to `line_color_idx_to_rgb(unsigned char)' follow
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [CMakeFiles/simutrans-extended.dir/build.make:5909: simutrans/simutrans-extended] Error 1
make[2]: *** [CMakeFiles/Makefile2:118: CMakeFiles/simutrans-extended.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:125: CMakeFiles/simutrans-extended.dir/rule] Error 2
make: *** [Makefile:189: simutrans-extended] Error 2


The two things are not necessarily related because I believe B-B uses the traditional Makefile while GitHub Actions uses CMake, but it seems plausible. The Command Line Server wouldn't necessarily know about colours.

The first commit where GitHub Actions reports a headless build failure is this change to the Japanese help texts (http://8c84df49da484ff991d842d58ab7d953b4a03b97), which makes no sense to me. I guess it's a quirk of the order in which the rosen-color-2202 patches were merged?

EDIT: Yes, it looks as though line_color_idx_to_rgb() calls get_system_color(), which calls code from SDL2:

(https://i.imgur.com/DbdaW3s.png)

And line_color_idx_to_rgb() is called in simline.cc, which is part of command line server builds:

(https://i.imgur.com/7fyLlT3.png)

I guess that might explain why GitHub's GDI builds for Windows are failing too?
Title: Re: [BUG] Line colours depend on SDL2 (was: Command line server build failed)
Post by: Ranran on February 22, 2022, 08:55:44 AM
SimutransSourceList.cmake doesn't have a simgraph so it doesn't have a link. But I can't think of a workaround for this as it doesn't seem to intentionally list it for graphics.  :-[
Title: Re: [BUG] Line colours depend on SDL2 (was: Command line server build failed)
Post by: Roboron on February 22, 2022, 09:30:56 AM
The backend-specific sources are not included in SimutransSourceList.cmake but in the top CMakeLists.txt. Specifically, for headless server, in this line https://github.com/jamespetts/simutrans-extended/blob/master/CMakeLists.txt#L171
Title: Re: [BUG] Line colours depend on SDL2 (was: Command line server build failed)
Post by: jamespetts on February 22, 2022, 06:00:53 PM
Apologies for this difficulty. I do not think that I am familiar enough with the line colour system easily to be able to fix this.

Ranran, why does the command line only version need to know about the colours - is this in order to save them? If so, we probably need to find a way to separate the references to the colours from the actual processing/displaying of the colours, so that the command line server builds can retain the referencing of the colours without actually having to have all the code for displaying the colours. Do you think that you would be able to modify the system so as to provide for this?
Title: Re: [BUG] Line colours depend on SDL2 (was: Command line server build failed)
Post by: TurfIt on February 22, 2022, 06:18:08 PM
Headless server uses simgraph0.cc, not simgraph16.cc.
Stub function for line_color_idx_to_rgb() was not added to simgraph0.cc...
Title: Re: [BUG] Line colours depend on SDL2 (was: Command line server build failed)
Post by: Ranran on February 22, 2022, 07:30:27 PM
Quote from: TurfIt on February 22, 2022, 06:18:08 PMStub function for line_color_idx_to_rgb() was not added to simgraph0.cc...
Ah, yes. It was just the usual careless mistake I had made several times...
That will be fixed in the pull request #512. I apologize for the inconvenience.
Title: Re: [BUG] Line colours depend on SDL2 (was: Command line server build failed)
Post by: jamespetts on February 22, 2022, 07:58:49 PM
Excellent, thank you: now incorporated.