Merge lp:~widelands-dev/widelands/add-xdg-support into lp:widelands

Proposed by Lucki
Status: Merged
Merged at revision: 9187
Proposed branch: lp:~widelands-dev/widelands/add-xdg-support
Merge into: lp:widelands
Diff against target: 2598 lines (+670/-270)
73 files modified
CMakeLists.txt (+6/-0)
compile.sh (+27/-2)
src/CMakeLists.txt (+3/-2)
src/editor/CMakeLists.txt (+1/-1)
src/editor/editorinteractive.cc (+3/-2)
src/editor/ui_menus/main_menu_map_options.cc (+2/-1)
src/editor/ui_menus/main_menu_new_map.cc (+2/-1)
src/editor/ui_menus/main_menu_random_map.cc (+2/-1)
src/editor/ui_menus/main_menu_save_map.cc (+2/-1)
src/editor/ui_menus/player_menu.cc (+3/-5)
src/game_io/CMakeLists.txt (+1/-1)
src/game_io/game_preload_packet.cc (+1/-1)
src/io/CMakeLists.txt (+15/-0)
src/io/filesystem/filesystem.cc (+99/-0)
src/io/filesystem/filesystem.h (+8/-0)
src/io/profile.cc (+1/-3)
src/io/profile.h (+4/-4)
src/logic/CMakeLists.txt (+3/-2)
src/logic/ai_dna_handler.cc (+1/-1)
src/logic/game.cc (+3/-2)
src/logic/save_handler.cc (+5/-6)
src/logic/single_player_game_controller.cc (+2/-2)
src/map_io/CMakeLists.txt (+1/-1)
src/map_io/coords_profile.cc (+1/-1)
src/map_io/map_allowed_building_types_packet.cc (+1/-1)
src/map_io/map_allowed_worker_types_packet.cc (+1/-1)
src/map_io/map_elemental_packet.cc (+1/-1)
src/map_io/map_objective_packet.cc (+1/-1)
src/map_io/map_player_names_and_tribes_packet.cc (+1/-1)
src/map_io/map_player_position_packet.cc (+1/-1)
src/map_io/map_players_messages_packet.cc (+1/-1)
src/map_io/map_port_spaces_packet.cc (+1/-1)
src/map_io/map_version_packet.cc (+1/-1)
src/network/CMakeLists.txt (+0/-1)
src/network/gameclient.cc (+4/-4)
src/network/gamehost.cc (+6/-6)
src/profile/CMakeLists.txt (+0/-14)
src/scripting/CMakeLists.txt (+2/-1)
src/scripting/lua_bases.cc (+1/-1)
src/scripting/lua_game.cc (+2/-1)
src/sound/CMakeLists.txt (+1/-1)
src/sound/sound_handler.cc (+15/-19)
src/ui_basic/CMakeLists.txt (+0/-1)
src/ui_basic/panel.cc (+2/-2)
src/ui_fsmenu/CMakeLists.txt (+5/-5)
src/ui_fsmenu/campaign_select.cc (+0/-1)
src/ui_fsmenu/campaigns.cc (+1/-1)
src/ui_fsmenu/internet_lobby.cc (+6/-9)
src/ui_fsmenu/launch_mpg.cc (+1/-1)
src/ui_fsmenu/loadgame.cc (+3/-4)
src/ui_fsmenu/multiplayer.cc (+8/-10)
src/ui_fsmenu/netsetup_lan.cc (+5/-7)
src/ui_fsmenu/options.cc (+3/-2)
src/ui_fsmenu/scenario_select.cc (+1/-1)
src/wlapplication.cc (+89/-90)
src/wlapplication.h (+10/-0)
src/wlapplication_options.cc (+151/-0)
src/wlapplication_options.h (+118/-0)
src/wui/CMakeLists.txt (+4/-4)
src/wui/chat_overlay.cc (+2/-3)
src/wui/economy_options_window.cc (+1/-1)
src/wui/game_main_menu_save_game.cc (+2/-1)
src/wui/interactive_base.cc (+0/-1)
src/wui/interactive_base.h (+1/-1)
src/wui/interactive_gamebase.cc (+0/-1)
src/wui/interactive_gamebase.h (+1/-1)
src/wui/interactive_player.cc (+0/-1)
src/wui/interactive_player.h (+1/-1)
src/wui/interactive_spectator.cc (+0/-1)
src/wui/interactive_spectator.h (+1/-1)
src/wui/login_box.cc (+14/-18)
src/wui/mapview.cc (+2/-2)
src/wui/watchwindow.cc (+2/-2)
To merge this branch: bzr merge lp:~widelands-dev/widelands/add-xdg-support
Reviewer Review Type Date Requested Status
kaputtnik (community) Needs Fixing
Toni Förster Approve
Klaus Halfmann code review Approve
GunChleoc Needs Fixing
Review via email: mp+347652@code.launchpad.net

Commit message

Add basic XDG support.
Use 'XDG_DATA_HOME/widelands' as a replacement for '~/.widelands' if '-DUSE_XDG=ON' is used as an argument for cmake.
'~/.widelands' will be used as a fallback if the folder already exists.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3597. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/389472179.
Appveyor build 3400. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_lucki1_widelands_add_xdg_support-3400.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Hello Luki, thanks for your support!

I was no ware about that spec. But on OSX such Files should e.g. be found
at ~/Library/Application Support/Wesnoth<Version>/...

OK just found "NOT APPLE". Sound Like I have to do this on a seperate branch,
and it can be tested on *nix only.

Gun: I am not sure if this should make it into R20 it may break some tescases
and documentation. So I would suggets to put this in at the begin of R21,
once R20 is on the road to be relased.

I will try to check how this beaves on OSX perhaps on Sunday.
Not sure If I will be able to unpack that Linux Box in my corner soon.

One nit inline, code looks so far so good.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3600. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/389861151.
Appveyor build 3403. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_lucki1_widelands_add_xdg_support-3403.

Revision history for this message
GunChleoc (gunchleoc) wrote :

There are still some trailing whitespaces that need fixing.

Maybe we can have this for Build 20 already; I'll need to take a look and to some testing when I get back home.

/home/travis/build/widelands/widelands/src/io/filesystem/filesystem.cc:271: Trailing whitespace at end of line
/home/travis/build/widelands/widelands/src/io/filesystem/filesystem.cc:280: Trailing whitespace at end of line
/home/travis/build/widelands/widelands/src/io/filesystem/filesystem.cc:285: Trailing whitespace at end of line
/home/travis/build/widelands/widelands/src/io/filesystem/filesystem.cc:290: Trailing whitespace at end of line
+echo 'You have codecheck warnings (see above) Please fix.'

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3612. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/393153455.
Appveyor build 3414. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_lucki1_widelands_add_xdg_support-3414.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Lucki: On a normal build this will never be enabled.

e.g. I use compile.sh which does not know about that flag, yet.

I will compile this on OSX now.
Once with default and once with -DUSE_XDG=ON
It shoud not make any difference though.

As of the code this will only come into effect for completely new installations,
as long as there is a ~/.widelands directory this still will be used.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

I added cmake .. -DUSE_XDG=ON to compile.sh, but still that code is not executed?

please help me with that cmake stuff ...

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

OK must remove that "AND NOT APPLE" stuff, too

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

The Code works as expected.

Please check my inline comment. (I cannot commit to your branch)

Gun: I think this could become a default.

Lucki: Do you intend to enable this in some Ubuntu repository?

review: Approve (compile, debug)
Revision history for this message
Lucki (lucki1) wrote :

 I'm sorry I confused you.

I wasn't aware that there was a 'compile.sh'. I have now adjusted them additionally.

A little more explanation:
Because the general acceptance of this change in the linked bug report was rather low, this setting must be explicitly activated. This can now be done with './compile.sh --with-xdg' or 'cmake .. -DUSE_XDG=ON'.
These changes only affect Linux, so Apple and Windows should be excluded in the 'CMakeLists.txt'. I cannot test this part due to a lack of operating systems. If the option is activated on Apple or Windows against expectation, the filter in the 'CMakeLists.txt' should still prevent the option from being activated on the wrong operating systems. These changes should have no effect on Apple and Windows. Hopefully.
You are right that these changes only affect complete new installations or require a manual move of the relevant folder. In addition, this option must be activated separately. This was chosen because, as I said, acceptance of these changes was rather low.
If the option is enabled and no folder '$HOME/.widelands' exists, the folder is created or used in '$XDG_DATA_HOME/widelands'. If the variable '$XDG_DATA_HOME' is not set, '$HOME/.local/share/widelands' is used as fallback. If the variable '$HOME' is not available or an error occurs in the query, the current working folder './.widelands' is used - this is another fallback I took from the above function.

Hopefully this option will be used by the package maintainers in the future. :)

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Thanks Lucki for your changes, this is 100% OK for me now:

> ./compile.sh --help

--with-xdg Enable support for the XDG Base Directory Specification.

> ./compile.sh --with-xdg

Basic XDG Base Directory Specification will be used on Linux
if no existing $HOME/.widelands folder is found.
The widelands user data can be found in $XDG_DATA_HOME/widelands
and defaults to $HOME/.local/share/widelands.
See https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
for more information.

I dont have a Linux PC around for testing by now.

Lets have another automated tests, can go in in once those have passed.

review: Needs Resubmitting (review, compile, manual test)
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Gun: any idea why bunnybot did not pick up this one?

Revision history for this message
GunChleoc (gunchleoc) wrote :

I have added some comments for more code improvements. Thanks for taking this on :)

To comply with the standard, we still need another directory defined, which is $XDG_CONFIG_HOME and where "config" should sit.

At the moment, we have const std::string kConfigFile = "config"; defined in src/logic/filesystem_constants.h

The file is read/written in src/ui_fsmenu/options.cc and src/wlapplication.cc

review: Needs Fixing
Revision history for this message
GunChleoc (gunchleoc) wrote :

It's been a while since you have merged trunk - please use bzr merge after implementing the in-line comments.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Lucki, will you care for the XDG_CONFIG_HOME?

I revived that Ubuntu Machine, but currently cannot
acces it (mut reduce sons screen time ...)

Not sure If I will have time to activly care for this one.

Revision history for this message
Lucki (lucki1) wrote :

I'm afraid I can't.
I've played a bit around and nothing worked out.
This should be done by a person more capable than me in a different pull request.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I have added you to widelands-dev. Can you change the branch owner? Then anybody can pick this up - I don't think we should merge this without having the config file fixed.

In theory, it should work just like the other directory. Search the codebase for "g_options" to see how the file is loaded and saved.

Revision history for this message
Lucki (lucki1) wrote :

Done

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3656. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/402322192.
Appveyor build 3455. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_add_xdg_support-3455.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks!

I'm concentrating on Build 20 targeted bugs at the moment, so it will be a while before I get around to it.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4711. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/519023146.
Appveyor build 4497. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_add_xdg_support-4497.

Revision history for this message
Lucki (lucki1) wrote :

This works now in my little testing.

There are two little warnings (not errors) I'm not sure why they're present:
* Compiling without USE_XDG gives me an -Wundef warning in wlapplication.cc:307, but that's actually what I'm testing for in that line so I'm a bit confused.
* In debug mode, compiled with USE_XDG I get "could not open file for reading:" instead of the nice "There's no configuration file, using default values." message. This should be catched in profile.cc.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Sorry I currently have no Linux/Ubuntu around for easy testing

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4718. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/519915979.
Appveyor build 4504. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_add_xdg_support-4504.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Hi Lucki,

I apologize for taking so long to get back to you.

I have pushed a commit with a code review - please have a look. I have also moved the profile.h to a different directory, because it has bothered me for a long time and it sort of fits thematically.

I am getting this crash when starting a game:

 Reading Player Message Data ... There's no configuration file, using default values.
WidelandsMapLoader::load_map_complete() for 'Golden Peninsula' took 168ms
Fatal exception: messages for player 1: [../src/io/profile.cc:559] in "" section [global] not found

I think the way to go here is to move everything related to g_options into a new file wlapplication_options.h/cc and make sure that it will read/write itself. Would you enjoy working on that? If not, just let me know and I can take care of it.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

I managed to boot my Mac from some stick into Xubuntu,
so I will pick up on this one.

Can you suggest some graphic frontend for GDB for me?

Revision history for this message
Lucki (lucki1) wrote :

I'm not sure how I could miss that error on map loading… The filename the game is searching for is somehow empty but I couldn't get the reason yet.
Reading and writing the config file itself works fine in the menu.

I think the error should be located before we're moving stuff around.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Agreed, we'll need to find the error first.

I have only ever used GDB on the command line. Looks like there are some graphical frontends available though https://duckduckgo.com/?q=gdb+gui&t=lm&ia=web

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Hmm, I found those XDG variables on this Xubuntu:

declare -x XDG_CONFIG_DIRS="/etc/xdg/xdg-xubuntu:/etc/xdg:/etc/xdg"
declare -x XDG_CURRENT_DESKTOP="XFCE"
declare -x XDG_DATA_DIRS="/usr/share/xubuntu:/usr/share/xfce4:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/usr/share"
declare -x XDG_GREETER_DATA_DIR="/var/lib/lightdm-data/klaus"
declare -x XDG_MENU_PREFIX="xfce-"
declare -x XDG_RUNTIME_DIR="/run/user/1000"
declare -x XDG_SEAT="seat0"
declare -x XDG_SEAT_PATH="/org/freedesktop/DisplayManager/Seat0"
declare -x XDG_SESSION_CLASS="user"
declare -x XDG_SESSION_DESKTOP="xubuntu"
declare -x XDG_SESSION_ID="c2"
declare -x XDG_SESSION_PATH="/org/freedesktop/DisplayManager/Session0"
declare -x XDG_SESSION_TYPE="x11"
declare -x XDG_VTNR="7"

But no:
$XDG_DATA_HOME or $XDG_CONFIG_HOME/

Shall we extend this to use $XDG_CONFIG_DIRS / $XDG_DATA_DIRS ?

Revision history for this message
Lucki (lucki1) wrote :

That added FileError catch was the cause of the error. Removed it but now there's the uncatched error message again if no config file is at the expected location.

For XDG_DATA_DIRS: Right now there's WL_INSTALL_DATADIR which gets hardcoded into the binary.

Revision history for this message
Lucki (lucki1) wrote :

I'm not sure if it's necessary to care for XDG_CONFIG_DIRS as the configuration file always gets written and needs write access.

XDG_DATA_DIRS looks doable, I'm testing a bit around.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I could start a game now, both with and without ~/.widelands present :)

It would be good to have some log output that will describe where the directories are when Widelands starts. Otherwise, it will be hard to help with support queries from players in the future.

Revision history for this message
Lucki (lucki1) wrote :

Added a log entry for the configuration file if it's outside the home directory.

The homedir already gets logged and if a folder gets added through XDG_DATA_DIRS it's mentioned as "Adding directory: /usr/share/widelands".

The argument --homedir overrides the configuration directory and sets it to the given homedir.
The argument --datadir takes precedence over XDG_DATA_DIRS while the environment variable itself takes precedence over the INSTALL_DATADIR path given at compile time.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

I now got:

Set home directory: /home/klaus/.local/share/widelands
Set configuration: /home/klaus/.config/widelands/config
[] config:0: RealFSImpl::load: could not open file for reading: /home/klaus/.config/widelands/config
Widelands executable directory: /home/klaus/develop/widelands/add-xdg-support/
Adding directory: /home/klaus/develop/widelands/add-xdg-support/data

Looks ok for me.

Will do a code-review on the OS-X side of this hardware

review: Approve (compile, short test)
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

OK for me.

Now:
 * how can make this a default for *nix builds?
 * Who could check if this really matches the specs?

review: Approve (code review)
Revision history for this message
GunChleoc (gunchleoc) wrote :

I have done more testing and it all works as expected.

Since it falls back to the old scheme when a .widelands directory is present (which is more convenient for me when developing), I think we could make this the default now.

I'd also still like to see the refactoring done to get rid of the code duplication.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I had a look at the spec - we have a "temp" dir now for map backups that are used to make saveloading of games stable. If we want to be strict, those files should go to:

"There is a single base directory relative to which user-specific runtime files and other file objects should be placed. This directory is defined by the environment variable $XDG_RUNTIME_DIR."

Revision history for this message
Lucki (lucki1) wrote :

XDG_RUNTIME_DIR is meant for sockets, named pipes, ... as later described. I don't think that's the right place for temporary files. The specification isn't clear about temporary files.

A quick search point up this blog, I don't know anything about them but it looks logical what they're describing: http://0pointer.net/blog/projects/tmp.html

1. You need a place to put your socket (or other communication primitive) and your code runs privileged: use a subdirectory beneath /run. (Or beneath /var/run for extra compatibility.)
2. You need a place to put your socket (or other communication primitive) and your code runs unprivileged: use a subdirectory beneath $XDG_RUNTIME_DIR.
3. You need a place to put your larger downloads and downloads in progress and run unprivileged: use $XDG_DOWNLOAD_DIR.
4. You need a place to put cache files which should be persistent and run unprivileged: use $XDG_CACHE_HOME.
5. Nothing of the above applies and you need to place a small file that needs no persistency: use $TMPDIR with a fallback on /tmp. And use mkstemp(), and mkdtemp() and nothing homegrown.
6. Otherwise use $TMPDIR with a fallback on /var/tmp. Also use mkstemp()/mkdtemp().

This would probably go into 6. because the temporary files don't have to be persistence so they don't fit in 4.?

They're also pointing this out: "One thing we'd like to stress is that /tmp and /var/tmp more often than not are actually not the right choice for your usecase. There are valid uses of these directories, but quite often another directory might actually be the better place. So, be careful, consider the other options, but if you do go for /tmp or /var/tmp then at least make sure to use mkstemp()/mkdtemp()."

About the refactoring: I think klaus-halfmann wanted to pick that up and that's probably a good idea because you know every related bit in the code.

Revision history for this message
GunChleoc (gunchleoc) wrote :

6. Sounds good.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5269. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/560245541.
Appveyor build 5045. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_add_xdg_support-5045.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks for sticking with this!

I have added 2 comments to the diff.

Revision history for this message
Lucki (lucki1) :
Revision history for this message
Toni Förster (stonerl) wrote :

Is there any particular reason why this hasn't been merged already?

review: Approve
Revision history for this message
kaputtnik (franku) wrote :

There are some text conflicts in this branch:

Text conflict in src/wui/interactive_base.h
Text conflict in src/wui/interactive_gamebase.h
Text conflict in src/wui/interactive_player.h

They must be fixed before merging.

review: Needs Fixing
Revision history for this message
kaputtnik (franku) wrote :

I get a crash with these steps:

1. Open Editor
2. Click 'Save Map'
3. In this view click 'Map Options'
4. Change the mapname
5. Click 'OK'

Although i used a debug build i get no debug information.

review: Needs Fixing
Revision history for this message
kaputtnik (franku) wrote :

Just found that the crash happens also if just open the Map Options menu and clicking OK, without opening the save map menu prior

Revision history for this message
Lucki (lucki1) wrote :

Well, that was dumb…

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5344. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/577306923.
Appveyor build 5114. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_add_xdg_support-5114.

Revision history for this message
kaputtnik (franku) wrote :

The crash is gone, thanks :-)

But the behavior is different from trunk, don't know if this is intended:

In Trunk:
1. Open Save map view
2. In that view click Map options
3. Change map name and click on ok

Result: The filename in 'Save Map' view get overwritten to fit with the name given in 'Map Options'.

In this branch the filename stays at it is.

Can you also take a look at the codecheck warnings reported by travis?

Revision history for this message
kaputtnik (franku) wrote :

The use of the XDG specifications looks good so far. Tested with and without an existing ~/.widelands directory. Also the option --without-xdg in the compile script. All fine here on archlinux!

:-)

Revision history for this message
Lucki (lucki1) wrote :

> In this branch the filename stays at it is.

I can't verify this behavior on my end. It behaves exactly as you described: "The filename in 'Save Map' view get overwritten to fit with the name given in 'Map Options'."

Travis errors I can't solve:
* apt-get install failed
* E: Unable to locate package clang-7

Not sure why I didn't got the codecheck warnings locally…

Revision history for this message
kaputtnik (franku) wrote :

You just grabbed the travis report which i didn't watched :D

The reports i mean complains about such codecheck warnings:

/home/travis/build/widelands/widelands/src/ui_fsmenu/CMakeLists.txt:68: ui_fsmenu_loading_common misses DEPENDS on widelands_ball_of_mud, because it includes wlapplication_options.h
...

See e.g.: https://travis-ci.org/widelands/widelands/jobs/577306934

I have to test again the thing with the filename...

Revision history for this message
kaputtnik (franku) wrote :

Hm, ok, i can't reproduce the filename behavior again. Maybe i am messed up due to the hot day :-D

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5349. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/577512579.
Appveyor build 5119. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_add_xdg_support-5119.

Revision history for this message
kaputtnik (franku) wrote :

Great!

@bunnybot merge

Revision history for this message
GunChleoc (gunchleoc) wrote :

The codecheck warnings about the CMakeLists stopped working on my machine too.

Sorry for dragging my feet on the final review.

@Lucki: How do you want to be credited, nickname only, or nick + real name?

Revision history for this message
Lucki (lucki1) wrote :

Nickname, if possible also give a hug to Holarse.de

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2019-07-18 17:30:34 +0000
+++ CMakeLists.txt 2019-08-27 19:00:46 +0000
@@ -50,6 +50,12 @@
50option(OPTION_BUILD_TRANSLATIONS "Build translations" ON)50option(OPTION_BUILD_TRANSLATIONS "Build translations" ON)
51option(OPTION_BUILD_TESTS "Build tests" ON)51option(OPTION_BUILD_TESTS "Build tests" ON)
5252
53option(USE_XDG "Follow XDG-Basedir specification" ON) # Enabled by default
54IF(USE_XDG AND NOT APPLE AND NOT WIN32)
55 ADD_DEFINITIONS(-DUSE_XDG)
56 message(STATUS "Building with XDG support")
57ENDIF(USE_XDG AND NOT APPLE AND NOT WIN32)
58
53if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)59if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
54 message(FATAL_ERROR "Build directory and source directory must not be the same.")60 message(FATAL_ERROR "Build directory and source directory must not be the same.")
55endif (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)61endif (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
5662
=== modified file 'compile.sh'
--- compile.sh 2019-06-15 09:13:13 +0000
+++ compile.sh 2019-08-27 19:00:46 +0000
@@ -45,6 +45,8 @@
45 echo " Release builds are created without AddressSanitizer"45 echo " Release builds are created without AddressSanitizer"
46 echo " by default."46 echo " by default."
47 echo " "47 echo " "
48 echo "--without-xdg Disable support for the XDG Base Directory Specification."
49 echo " "
48 echo "Compiler options:"50 echo "Compiler options:"
49 echo " "51 echo " "
50 echo "-j <number> or --cores <number>"52 echo "-j <number> or --cores <number>"
@@ -88,6 +90,7 @@
88BUILD_TYPE="Debug"90BUILD_TYPE="Debug"
89USE_ASAN="ON"91USE_ASAN="ON"
90COMPILER="default"92COMPILER="default"
93USE_XDG="ON"
9194
92if [ "$(uname)" = "Darwin" ]; then95if [ "$(uname)" = "Darwin" ]; then
93 CORES="$(expr $(sysctl -n hw.ncpu) - 1)"96 CORES="$(expr $(sysctl -n hw.ncpu) - 1)"
@@ -154,6 +157,10 @@
154 fi157 fi
155 shift158 shift
156 ;;159 ;;
160 --without-xdg)
161 USE_XDG="OFF"
162 shift
163 ;;
157 *)164 *)
158 # unknown option165 # unknown option
159 ;;166 ;;
@@ -202,6 +209,18 @@
202else209else
203 echo "Will build without AddressSanitizer."210 echo "Will build without AddressSanitizer."
204fi211fi
212if [ $USE_XDG = "ON" ]; then
213 echo " "
214 echo "Basic XDG Base Directory Specification will be used on Linux"
215 echo "if no existing \$HOME/.widelands folder is found."
216 echo "The widelands user data can be found in \$XDG_DATA_HOME/widelands"
217 echo "and defaults to \$HOME/.local/share/widelands."
218 echo "The widelands user configuration can be found in \$XDG_CONFIG_HOME/widelands"
219 echo "and defaults to \$HOME/.config/widelands."
220 echo "See https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html"
221 echo "for more information."
222 echo " "
223fi
205echo " "224echo " "
206echo "###########################################################"225echo "###########################################################"
207echo " "226echo " "
@@ -260,9 +279,9 @@
260 # Compile Widelands279 # Compile Widelands
261 compile_widelands () {280 compile_widelands () {
262 if [ $buildtool = "ninja" ] || [ $buildtool = "ninja-build" ] ; then281 if [ $buildtool = "ninja" ] || [ $buildtool = "ninja-build" ] ; then
263 cmake -G Ninja .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOPTION_BUILD_WEBSITE_TOOLS=$BUILD_WEBSITE -DOPTION_BUILD_TRANSLATIONS=$BUILD_TRANSLATIONS -DOPTION_BUILD_TESTS=$BUILD_TESTS -DOPTION_ASAN=$USE_ASAN282 cmake -G Ninja .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOPTION_BUILD_WEBSITE_TOOLS=$BUILD_WEBSITE -DOPTION_BUILD_TRANSLATIONS=$BUILD_TRANSLATIONS -DOPTION_BUILD_TESTS=$BUILD_TESTS -DOPTION_ASAN=$USE_ASAN -DUSE_XDG=$USE_XDG
264 else283 else
265 cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOPTION_BUILD_WEBSITE_TOOLS=$BUILD_WEBSITE -DOPTION_BUILD_TRANSLATIONS=$BUILD_TRANSLATIONS -DOPTION_BUILD_TESTS=$BUILD_TESTS -DOPTION_ASAN=$USE_ASAN284 cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOPTION_BUILD_WEBSITE_TOOLS=$BUILD_WEBSITE -DOPTION_BUILD_TRANSLATIONS=$BUILD_TRANSLATIONS -DOPTION_BUILD_TESTS=$BUILD_TESTS -DOPTION_ASAN=$USE_ASAN -DUSE_XDG=$USE_XDG
266 fi285 fi
267286
268 $buildtool -j $CORES287 $buildtool -j $CORES
@@ -360,6 +379,12 @@
360 echo "# - No tests #"379 echo "# - No tests #"
361fi380fi
362381
382if [ $USE_XDG = "ON" ]; then
383 echo "# - With support for the XDG Base Directory Specification #"
384else
385 echo "# - Without support for the XDG Base Directory #"
386 echo "# Specification #"
387fi
363if [ $BUILD_WEBSITE = "ON" ]; then388if [ $BUILD_WEBSITE = "ON" ]; then
364 echo "# - Website-related executables #"389 echo "# - Website-related executables #"
365else390else
366391
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2019-05-27 14:28:34 +0000
+++ src/CMakeLists.txt 2019-08-27 19:00:46 +0000
@@ -73,7 +73,6 @@
73add_subdirectory(map_io)73add_subdirectory(map_io)
74add_subdirectory(network)74add_subdirectory(network)
75add_subdirectory(notifications)75add_subdirectory(notifications)
76add_subdirectory(profile)
77add_subdirectory(random)76add_subdirectory(random)
78add_subdirectory(scripting)77add_subdirectory(scripting)
79add_subdirectory(sound)78add_subdirectory(sound)
@@ -93,6 +92,8 @@
93 wlapplication.h92 wlapplication.h
94 wlapplication_messages.cc93 wlapplication_messages.cc
95 wlapplication_messages.h94 wlapplication_messages.h
95 wlapplication_options.cc
96 wlapplication_options.h
96 USES_SDL297 USES_SDL2
97 USES_SDL2_IMAGE98 USES_SDL2_IMAGE
98 USES_SDL2_TTF99 USES_SDL2_TTF
@@ -108,6 +109,7 @@
108 graphic_fonthandler109 graphic_fonthandler
109 graphic_text110 graphic_text
110 io_filesystem111 io_filesystem
112 io_profile
111 logic113 logic
112 logic_exceptions114 logic_exceptions
113 logic_filesystem_constants115 logic_filesystem_constants
@@ -117,7 +119,6 @@
117 logic_single_player_game_settings119 logic_single_player_game_settings
118 map_io_map_loader120 map_io_map_loader
119 network121 network
120 profile
121 random122 random
122 sound123 sound
123 ui_basic124 ui_basic
124125
=== modified file 'src/editor/CMakeLists.txt'
--- src/editor/CMakeLists.txt 2019-06-01 14:16:25 +0000
+++ src/editor/CMakeLists.txt 2019-08-27 19:00:46 +0000
@@ -110,12 +110,12 @@
110 map_io110 map_io
111 map_io_map_loader111 map_io_map_loader
112 notifications112 notifications
113 profile
114 random113 random
115 scripting_coroutine114 scripting_coroutine
116 scripting_lua_interface115 scripting_lua_interface
117 scripting_lua_table116 scripting_lua_table
118 ui_basic117 ui_basic
118 widelands_ball_of_mud
119 wui119 wui
120 wui_common_mapdetails120 wui_common_mapdetails
121 wui_mapview_pixelfunctions121 wui_mapview_pixelfunctions
122122
=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc 2019-08-10 16:38:15 +0000
+++ src/editor/editorinteractive.cc 2019-08-27 19:00:46 +0000
@@ -67,6 +67,7 @@
67#include "scripting/lua_table.h"67#include "scripting/lua_table.h"
68#include "ui_basic/messagebox.h"68#include "ui_basic/messagebox.h"
69#include "ui_basic/progresswindow.h"69#include "ui_basic/progresswindow.h"
70#include "wlapplication_options.h"
70#include "wui/game_tips.h"71#include "wui/game_tips.h"
71#include "wui/interactive_base.h"72#include "wui/interactive_base.h"
7273
@@ -82,7 +83,7 @@
82} // namespace83} // namespace
8384
84EditorInteractive::EditorInteractive(Widelands::EditorGameBase& e)85EditorInteractive::EditorInteractive(Widelands::EditorGameBase& e)
85 : InteractiveBase(e, g_options.pull_section("global")),86 : InteractiveBase(e, get_config_section()),
86 need_save_(false),87 need_save_(false),
87 realtime_(SDL_GetTicks()),88 realtime_(SDL_GetTicks()),
88 is_painting_(false),89 is_painting_(false),
@@ -908,7 +909,7 @@
908 egbase.world(), 64, 64, 0,909 egbase.world(), 64, 64, 0,
909 /** TRANSLATORS: Default name for new map */910 /** TRANSLATORS: Default name for new map */
910 _("No Name"),911 _("No Name"),
911 g_options.pull_section("global").get_string(912 get_config_string(
912 "realname",913 "realname",
913 /** TRANSLATORS: Map author name when it hasn't been set yet */914 /** TRANSLATORS: Map author name when it hasn't been set yet */
914 pgettext("author_name", "Unknown")));915 pgettext("author_name", "Unknown")));
915916
=== modified file 'src/editor/ui_menus/main_menu_map_options.cc'
--- src/editor/ui_menus/main_menu_map_options.cc 2019-08-10 16:38:15 +0000
+++ src/editor/ui_menus/main_menu_map_options.cc 2019-08-27 19:00:46 +0000
@@ -33,6 +33,7 @@
33#include "ui_basic/editbox.h"33#include "ui_basic/editbox.h"
34#include "ui_basic/multilineeditbox.h"34#include "ui_basic/multilineeditbox.h"
35#include "ui_basic/textarea.h"35#include "ui_basic/textarea.h"
36#include "wlapplication_options.h"
36#include "wui/map_tags.h"37#include "wui/map_tags.h"
3738
38inline EditorInteractive& MainMenuMapOptions::eia() {39inline EditorInteractive& MainMenuMapOptions::eia() {
@@ -194,7 +195,7 @@
194void MainMenuMapOptions::clicked_ok() {195void MainMenuMapOptions::clicked_ok() {
195 eia().egbase().mutable_map()->set_name(name_.text());196 eia().egbase().mutable_map()->set_name(name_.text());
196 eia().egbase().mutable_map()->set_author(author_.text());197 eia().egbase().mutable_map()->set_author(author_.text());
197 g_options.pull_section("global").set_string("realname", author_.text());198 set_config_string("realname", author_.text());
198 eia().egbase().mutable_map()->set_description(descr_->get_text());199 eia().egbase().mutable_map()->set_description(descr_->get_text());
199 eia().egbase().mutable_map()->set_hint(hint_->get_text());200 eia().egbase().mutable_map()->set_hint(hint_->get_text());
200201
201202
=== modified file 'src/editor/ui_menus/main_menu_new_map.cc'
--- src/editor/ui_menus/main_menu_new_map.cc 2019-06-25 08:03:30 +0000
+++ src/editor/ui_menus/main_menu_new_map.cc 2019-08-27 19:00:46 +0000
@@ -36,6 +36,7 @@
36#include "logic/map_objects/world/terrain_description.h"36#include "logic/map_objects/world/terrain_description.h"
37#include "logic/map_objects/world/world.h"37#include "logic/map_objects/world/world.h"
38#include "ui_basic/progresswindow.h"38#include "ui_basic/progresswindow.h"
39#include "wlapplication_options.h"
3940
40inline EditorInteractive& MainMenuNewMap::eia() {41inline EditorInteractive& MainMenuNewMap::eia() {
41 return dynamic_cast<EditorInteractive&>(*get_parent());42 return dynamic_cast<EditorInteractive&>(*get_parent());
@@ -108,7 +109,7 @@
108 map->create_empty_map(109 map->create_empty_map(
109 egbase.world(), map_size_box_.selected_width(), map_size_box_.selected_height(),110 egbase.world(), map_size_box_.selected_width(), map_size_box_.selected_height(),
110 list_.get_selected(), _("No Name"),111 list_.get_selected(), _("No Name"),
111 g_options.pull_section("global").get_string("realname", pgettext("author_name", "Unknown")));112 get_config_string("realname", pgettext("author_name", "Unknown")));
112113
113 egbase.postload();114 egbase.postload();
114 egbase.load_graphics(loader_ui);115 egbase.load_graphics(loader_ui);
115116
=== modified file 'src/editor/ui_menus/main_menu_random_map.cc'
--- src/editor/ui_menus/main_menu_random_map.cc 2019-08-10 16:38:15 +0000
+++ src/editor/ui_menus/main_menu_random_map.cc 2019-08-27 19:00:46 +0000
@@ -39,6 +39,7 @@
39#include "random/random.h"39#include "random/random.h"
40#include "ui_basic/messagebox.h"40#include "ui_basic/messagebox.h"
41#include "ui_basic/progresswindow.h"41#include "ui_basic/progresswindow.h"
42#include "wlapplication_options.h"
4243
43namespace {44namespace {
44// The map generator can't find starting positions for too many players45// The map generator can't find starting positions for too many players
@@ -486,7 +487,7 @@
486 MapGenerator gen(*map, map_info, egbase);487 MapGenerator gen(*map, map_info, egbase);
487 map->create_empty_map(488 map->create_empty_map(
488 egbase.world(), map_info.w, map_info.h, 0, _("No Name"),489 egbase.world(), map_info.w, map_info.h, 0, _("No Name"),
489 g_options.pull_section("global").get_string("realname", pgettext("author_name", "Unknown")),490 get_config_string("realname", pgettext("author_name", "Unknown")),
490 sstrm.str().c_str());491 sstrm.str().c_str());
491 loader_ui.step(_("Generating random map…"));492 loader_ui.step(_("Generating random map…"));
492493
493494
=== modified file 'src/editor/ui_menus/main_menu_save_map.cc'
--- src/editor/ui_menus/main_menu_save_map.cc 2019-08-10 16:38:15 +0000
+++ src/editor/ui_menus/main_menu_save_map.cc 2019-08-27 19:00:46 +0000
@@ -40,6 +40,7 @@
40#include "map_io/map_saver.h"40#include "map_io/map_saver.h"
41#include "map_io/widelands_map_loader.h"41#include "map_io/widelands_map_loader.h"
42#include "ui_basic/messagebox.h"42#include "ui_basic/messagebox.h"
43#include "wlapplication_options.h"
43#include "wui/mapdetails.h"44#include "wui/mapdetails.h"
44#include "wui/maptable.h"45#include "wui/maptable.h"
4546
@@ -148,7 +149,7 @@
148 filename.substr(0, filename_size - 4) :149 filename.substr(0, filename_size - 4) :
149 filename);150 filename);
150 }151 }
151 if (save_map(filename, !g_options.pull_section("global").get_bool("nozip", false))) {152 if (save_map(filename, !get_config_bool("nozip", false))) {
152 die();153 die();
153 } else {154 } else {
154 table_.focus();155 table_.focus();
155156
=== modified file 'src/editor/ui_menus/player_menu.cc'
--- src/editor/ui_menus/player_menu.cc 2019-08-10 16:38:15 +0000
+++ src/editor/ui_menus/player_menu.cc 2019-08-27 19:00:46 +0000
@@ -32,9 +32,9 @@
32#include "logic/map.h"32#include "logic/map.h"
33#include "logic/map_objects/tribes/tribe_basic_info.h"33#include "logic/map_objects/tribes/tribe_basic_info.h"
34#include "logic/widelands.h"34#include "logic/widelands.h"
35#include "profile/profile.h"
36#include "ui_basic/checkbox.h"35#include "ui_basic/checkbox.h"
37#include "ui_basic/multilinetextarea.h"36#include "ui_basic/multilinetextarea.h"
37#include "wlapplication_options.h"
3838
39namespace {39namespace {
40constexpr int kMargin = 4;40constexpr int kMargin = 4;
@@ -101,8 +101,7 @@
101101
102 void write_option() {102 void write_option() {
103 if (reminder_choice_.get_state()) {103 if (reminder_choice_.get_state()) {
104 g_options.pull_section("global").set_bool(104 set_config_bool("editor_player_menu_warn_too_many_players", false);
105 "editor_player_menu_warn_too_many_players", false);
106 }105 }
107 }106 }
108107
@@ -255,8 +254,7 @@
255254
256 // Display a warning if there are too many players255 // Display a warning if there are too many players
257 if (nr_players > kMaxRecommendedPlayers) {256 if (nr_players > kMaxRecommendedPlayers) {
258 if (g_options.pull_section("global").get_bool(257 if (get_config_bool("editor_player_menu_warn_too_many_players", true)) {
259 "editor_player_menu_warn_too_many_players", true)) {
260 EditorPlayerMenuWarningBox warning(get_parent());258 EditorPlayerMenuWarningBox warning(get_parent());
261 if (warning.run<UI::Panel::Returncodes>() == UI::Panel::Returncodes::kBack) {259 if (warning.run<UI::Panel::Returncodes>() == UI::Panel::Returncodes::kBack) {
262 // Abort setting of players260 // Abort setting of players
263261
=== modified file 'src/game_io/CMakeLists.txt'
--- src/game_io/CMakeLists.txt 2019-05-05 18:53:14 +0000
+++ src/game_io/CMakeLists.txt 2019-08-27 19:00:46 +0000
@@ -33,6 +33,7 @@
33 graphic_minimap_renderer33 graphic_minimap_renderer
34 io_fileread34 io_fileread
35 io_filesystem35 io_filesystem
36 io_profile
36 logic37 logic
37 logic_commands38 logic_commands
38 logic_exceptions39 logic_exceptions
@@ -42,7 +43,6 @@
42 logic_widelands_geometry_io43 logic_widelands_geometry_io
43 map_io44 map_io
44 map_io_map_loader45 map_io_map_loader
45 profile
46 scripting_lua_interface46 scripting_lua_interface
47 scripting_lua_table47 scripting_lua_table
48 wui48 wui
4949
=== modified file 'src/game_io/game_preload_packet.cc'
--- src/game_io/game_preload_packet.cc 2019-02-23 11:00:49 +0000
+++ src/game_io/game_preload_packet.cc 2019-08-27 19:00:46 +0000
@@ -28,11 +28,11 @@
28#include "build_info.h"28#include "build_info.h"
29#include "graphic/image_io.h"29#include "graphic/image_io.h"
30#include "graphic/minimap_renderer.h"30#include "graphic/minimap_renderer.h"
31#include "io/profile.h"
31#include "logic/game.h"32#include "logic/game.h"
32#include "logic/game_data_error.h"33#include "logic/game_data_error.h"
33#include "logic/map.h"34#include "logic/map.h"
34#include "logic/playersmanager.h"35#include "logic/playersmanager.h"
35#include "profile/profile.h"
36#include "scripting/lua_interface.h"36#include "scripting/lua_interface.h"
37#include "scripting/lua_table.h"37#include "scripting/lua_table.h"
38#include "wui/interactive_player.h"38#include "wui/interactive_player.h"
3939
=== modified file 'src/io/CMakeLists.txt'
--- src/io/CMakeLists.txt 2018-05-16 13:51:48 +0000
+++ src/io/CMakeLists.txt 2019-08-27 19:00:46 +0000
@@ -23,3 +23,18 @@
23 io_filesystem23 io_filesystem
24 io_stream24 io_stream
25)25)
26
27wl_library(io_profile
28 SRCS
29 profile.h
30 profile.cc
31 DEPENDS
32 base_exceptions
33 base_geometry
34 base_i18n
35 base_log
36 base_macros
37 build_info
38 io_fileread
39 io_filesystem
40 )
2641
=== modified file 'src/io/filesystem/filesystem.cc'
--- src/io/filesystem/filesystem.cc 2019-05-27 21:04:13 +0000
+++ src/io/filesystem/filesystem.cc 2019-08-27 19:00:46 +0000
@@ -312,6 +312,105 @@
312 return homedir;312 return homedir;
313}313}
314314
315#ifdef USE_XDG
316/**
317 * Return $XDG_DATA_HOME/widelands. Falls back to $HOME/.local/share/widelands
318 * https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
319 * Prioritises $HOME/.widelands if it exists.
320 */
321std::string FileSystem::get_userdatadir() {
322 std::string userdatadir = get_homedir();
323
324 // Use dotfolder for backwards compatibility if it exists.
325 RealFSImpl dot(userdatadir);
326 if (dot.is_directory(".widelands")) {
327 userdatadir = userdatadir + "/.widelands";
328 }
329#ifdef HAS_GETENV
330 else {
331 if (char const* const datahome = getenv("XDG_DATA_HOME")) {
332 userdatadir = std::string(datahome) + "/widelands";
333 }
334 else {
335 // If XDG_DATA_HOME is not set, the default path is used.
336 userdatadir = userdatadir + "/.local/share/widelands";
337 }
338 }
339#else
340 else {
341 // Fallback to not dump all files into the current working dir.
342 userdatadir = userdatadir + "/.widelands";
343 }
344#endif
345
346 // Unlike the homedir function, this function includes the program name.
347 // This is handled in 'src/wlapplication.cc'.
348 return userdatadir;
349}
350
351/**
352 * Return $XDG_CONFIG_HOME/widelands. Falls back to $HOME/.config/widelands
353 * https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
354 * Prioritises $HOME/.widelands if it exists.
355 */
356std::string FileSystem::get_userconfigdir() {
357 std::string userconfigdir = get_homedir();
358
359 // Use dotfolder for backwards compatibility if it exists.
360 RealFSImpl dot(userconfigdir);
361 if (dot.is_directory(".widelands")) {
362 userconfigdir = userconfigdir + "/.widelands";
363 }
364#ifdef HAS_GETENV
365 else {
366 if (char const* const confighome = getenv("XDG_CONFIG_HOME")) {
367 userconfigdir = std::string(confighome) + "/widelands";
368 }
369 else {
370 // If XDG_CONFIG_HOME is not set, the default path is used.
371 userconfigdir = userconfigdir + "/.config/widelands";
372 }
373 }
374#else
375 else {
376 // Fallback to not dump all files into the current working dir.
377 userconfigdir = userconfigdir + "/.widelands";
378 }
379#endif
380
381 // Unlike the homedir function, this function includes the program name.
382 // This is handled in 'src/wlapplication.cc'.
383 return userconfigdir;
384}
385
386/**
387 * Return $XDG_DATA_DIRS. Falls back to /usr/local/share:/usr/share
388 * https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
389 */
390std::vector<std::string> FileSystem::get_xdgdatadirs() {
391 std::vector<std::string> xdgdatadirs;
392 std::string environment;
393#ifdef HAS_GETENV
394 environment = getenv("XDG_DATA_DIRS");
395#endif
396 if (environment.empty()) {
397 environment = "/usr/local/share:/usr/share";
398 }
399
400 // https://stackoverflow.com/a/14266139
401 std::string token;
402 std::string delimiter = ":";
403 size_t pos = 0;
404 while ((pos = environment.find(delimiter)) != std::string::npos) {
405 token = environment.substr(0, pos);
406 xdgdatadirs.push_back(token);
407 environment.erase(0, pos + delimiter.length());
408 }
409 xdgdatadirs.push_back(environment);
410 return xdgdatadirs;
411}
412#endif
413
315// Returning a vector rather than a set because animations need the indices414// Returning a vector rather than a set because animations need the indices
316std::vector<std::string> FileSystem::get_sequential_files(const std::string& directory,415std::vector<std::string> FileSystem::get_sequential_files(const std::string& directory,
317 const std::string& basename,416 const std::string& basename,
318417
=== modified file 'src/io/filesystem/filesystem.h'
--- src/io/filesystem/filesystem.h 2019-05-27 21:04:13 +0000
+++ src/io/filesystem/filesystem.h 2019-08-27 19:00:46 +0000
@@ -132,6 +132,14 @@
132 static std::string filename_without_ext(const char* n);132 static std::string filename_without_ext(const char* n);
133 static std::string get_homedir();133 static std::string get_homedir();
134134
135#ifdef USE_XDG
136 // Get XDG dirs for Linux
137 // https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
138 static std::string get_userdatadir();
139 static std::string get_userconfigdir();
140 static std::vector<std::string> get_xdgdatadirs();
141#endif
142
135 /// Return the files in the given 'directory' that match the condition in 'test', i.e. 'test'143 /// Return the files in the given 'directory' that match the condition in 'test', i.e. 'test'
136 /// returned 'true' for their filenames.144 /// returned 'true' for their filenames.
137 template <class UnaryPredicate>145 template <class UnaryPredicate>
138146
=== renamed file 'src/profile/profile.cc' => 'src/io/profile.cc'
--- src/profile/profile.cc 2019-02-23 11:00:49 +0000
+++ src/io/profile.cc 2019-08-27 19:00:46 +0000
@@ -17,7 +17,7 @@
17 *17 *
18 */18 */
1919
20#include "profile/profile.h"20#include "io/profile.h"
2121
22#include <algorithm>22#include <algorithm>
23#include <cctype>23#include <cctype>
@@ -63,8 +63,6 @@
63 /** TRANSLATORS: Needs to be consistent with the translations in widelands-console */63 /** TRANSLATORS: Needs to be consistent with the translations in widelands-console */
64 _("off"), "0"};64 _("off"), "0"};
6565
66Profile g_options(Profile::err_log);
67
68Section::Value::Value(const std::string& nname, const char* const nval)66Section::Value::Value(const std::string& nname, const char* const nval)
69 : used_(false), name_(nname) {67 : used_(false), name_(nname) {
70 set_string(nval);68 set_string(nval);
7169
=== renamed file 'src/profile/profile.h' => 'src/io/profile.h'
--- src/profile/profile.h 2019-02-23 11:00:49 +0000
+++ src/io/profile.h 2019-08-27 19:00:46 +0000
@@ -17,8 +17,8 @@
17 *17 *
18 */18 */
1919
20#ifndef WL_PROFILE_PROFILE_H20#ifndef WL_IO_PROFILE_H
21#define WL_PROFILE_PROFILE_H21#define WL_IO_PROFILE_H
2222
23#include <cstring>23#include <cstring>
24#include <memory>24#include <memory>
@@ -31,7 +31,7 @@
31// TODO(unknown): as soon as g_fs is not needed anymore,31// TODO(unknown): as soon as g_fs is not needed anymore,
32// include "filesystem.h" instead of layered_filesystem.h.32// include "filesystem.h" instead of layered_filesystem.h.
3333
34extern class Profile g_options;34class Profile;
35class FileSystem;35class FileSystem;
3636
37/**37/**
@@ -224,4 +224,4 @@
224 DISALLOW_COPY_AND_ASSIGN(Profile);224 DISALLOW_COPY_AND_ASSIGN(Profile);
225};225};
226226
227#endif // end of include guard: WL_PROFILE_PROFILE_H227#endif // end of include guard: WL_IO_PROFILE_H
228228
=== modified file 'src/logic/CMakeLists.txt'
--- src/logic/CMakeLists.txt 2019-08-09 17:29:40 +0000
+++ src/logic/CMakeLists.txt 2019-08-27 19:00:46 +0000
@@ -62,8 +62,8 @@
62 logic62 logic
63 logic_commands63 logic_commands
64 logic_game_settings64 logic_game_settings
65 profile
66 ui_basic65 ui_basic
66 widelands_ball_of_mud
67 wui67 wui
68)68)
6969
@@ -234,6 +234,7 @@
234 graphic_playercolor234 graphic_playercolor
235 io_fileread235 io_fileread
236 io_filesystem236 io_filesystem
237 io_profile
237 io_stream238 io_stream
238 logic_commands239 logic_commands
239 logic_constants240 logic_constants
@@ -250,7 +251,6 @@
250 map_io_map_loader251 map_io_map_loader
251 note_sound252 note_sound
252 notifications253 notifications
253 profile
254 random254 random
255 scripting_logic # TODO(GunChleoc): Circular dependency255 scripting_logic # TODO(GunChleoc): Circular dependency
256 scripting_lua_interface256 scripting_lua_interface
@@ -258,6 +258,7 @@
258 sound258 sound
259 sound_constants259 sound_constants
260 ui_basic260 ui_basic
261 widelands_ball_of_mud
261 wui # TODO(GunChleoc): Circular dependency262 wui # TODO(GunChleoc): Circular dependency
262)263)
263264
264265
=== modified file 'src/logic/ai_dna_handler.cc'
--- src/logic/ai_dna_handler.cc 2019-02-23 11:00:49 +0000
+++ src/logic/ai_dna_handler.cc 2019-08-27 19:00:46 +0000
@@ -24,8 +24,8 @@
24#include "base/time_string.h"24#include "base/time_string.h"
25#include "base/wexception.h"25#include "base/wexception.h"
26#include "io/filesystem/layered_filesystem.h"26#include "io/filesystem/layered_filesystem.h"
27#include "io/profile.h"
27#include "logic/filesystem_constants.h"28#include "logic/filesystem_constants.h"
28#include "profile/profile.h"
2929
30namespace Widelands {30namespace Widelands {
3131
3232
=== modified file 'src/logic/game.cc'
--- src/logic/game.cc 2019-06-28 15:05:22 +0000
+++ src/logic/game.cc 2019-08-27 19:00:46 +0000
@@ -66,6 +66,7 @@
66#include "scripting/lua_table.h"66#include "scripting/lua_table.h"
67#include "sound/sound_handler.h"67#include "sound/sound_handler.h"
68#include "ui_basic/progresswindow.h"68#include "ui_basic/progresswindow.h"
69#include "wlapplication_options.h"
69#include "wui/game_tips.h"70#include "wui/game_tips.h"
70#include "wui/interactive_player.h"71#include "wui/interactive_player.h"
7172
@@ -245,7 +246,7 @@
245 }246 }
246 win_condition_displayname_ = "Scenario";247 win_condition_displayname_ = "Scenario";
247248
248 set_ibase(new InteractivePlayer(*this, g_options.pull_section("global"), 1, false));249 set_ibase(new InteractivePlayer(*this, get_config_section(), 1, false));
249250
250 loader_ui.step(_("Loading map…"));251 loader_ui.step(_("Loading map…"));
251 maploader->load_map_complete(*this, Widelands::MapLoader::LoadType::kScenario);252 maploader->load_map_complete(*this, Widelands::MapLoader::LoadType::kScenario);
@@ -409,7 +410,7 @@
409 }410 }
410 loader_ui.set_background(background);411 loader_ui.set_background(background);
411 player_nr = gpdp.get_player_nr();412 player_nr = gpdp.get_player_nr();
412 set_ibase(new InteractivePlayer(*this, g_options.pull_section("global"), player_nr, false));413 set_ibase(new InteractivePlayer(*this, get_config_section(), player_nr, false));
413414
414 loader_ui.step(_("Loading…"));415 loader_ui.step(_("Loading…"));
415 gl.load_game();416 gl.load_game();
416417
=== modified file 'src/logic/save_handler.cc'
--- src/logic/save_handler.cc 2019-02-23 11:00:49 +0000
+++ src/logic/save_handler.cc 2019-08-27 19:00:46 +0000
@@ -37,6 +37,7 @@
37#include "logic/game.h"37#include "logic/game.h"
38#include "logic/game_controller.h"38#include "logic/game_controller.h"
39#include "logic/generic_save_handler.h"39#include "logic/generic_save_handler.h"
40#include "wlapplication_options.h"
40#include "wui/interactive_base.h"41#include "wui/interactive_base.h"
4142
42SaveHandler::SaveHandler()43SaveHandler::SaveHandler()
@@ -198,15 +199,13 @@
198 if (initialized_)199 if (initialized_)
199 return;200 return;
200201
201 Section& global = g_options.pull_section("global");202 fs_type_ = get_config_bool("nozip", false) ? FileSystem::DIR : FileSystem::ZIP;
202203
203 fs_type_ = global.get_bool("nozip", false) ? FileSystem::DIR : FileSystem::ZIP;204 autosave_interval_in_ms_ = get_config_int("autosave", kDefaultAutosaveInterval * 60) * 1000;
204
205 autosave_interval_in_ms_ = global.get_int("autosave", kDefaultAutosaveInterval * 60) * 1000;
206205
207 next_save_realtime_ = realtime + autosave_interval_in_ms_;206 next_save_realtime_ = realtime + autosave_interval_in_ms_;
208207
209 number_of_rolls_ = global.get_int("rolling_autosave", 5);208 number_of_rolls_ = get_config_int("rolling_autosave", 5);
210209
211 initialized_ = true;210 initialized_ = true;
212}211}
213212
=== modified file 'src/logic/single_player_game_controller.cc'
--- src/logic/single_player_game_controller.cc 2019-05-01 07:20:25 +0000
+++ src/logic/single_player_game_controller.cc 2019-08-27 19:00:46 +0000
@@ -24,7 +24,7 @@
24#include "logic/player.h"24#include "logic/player.h"
25#include "logic/playercommand.h"25#include "logic/playercommand.h"
26#include "logic/playersmanager.h"26#include "logic/playersmanager.h"
27#include "profile/profile.h"27#include "wlapplication_options.h"
2828
29SinglePlayerGameController::SinglePlayerGameController(Widelands::Game& game,29SinglePlayerGameController::SinglePlayerGameController(Widelands::Game& game,
30 bool const useai,30 bool const useai,
@@ -33,7 +33,7 @@
33 use_ai_(useai),33 use_ai_(useai),
34 lastframe_(SDL_GetTicks()),34 lastframe_(SDL_GetTicks()),
35 time_(game_.get_gametime()),35 time_(game_.get_gametime()),
36 speed_(g_options.pull_section("global").get_natural("speed_of_new_game", 1000)),36 speed_(get_config_natural("speed_of_new_game", 1000)),
37 paused_(false),37 paused_(false),
38 player_cmdserial_(0),38 player_cmdserial_(0),
39 local_(local) {39 local_(local) {
4040
=== modified file 'src/map_io/CMakeLists.txt'
--- src/map_io/CMakeLists.txt 2019-05-26 01:45:17 +0000
+++ src/map_io/CMakeLists.txt 2019-08-27 19:00:46 +0000
@@ -105,6 +105,7 @@
105 graphic_surface105 graphic_surface
106 io_fileread106 io_fileread
107 io_filesystem107 io_filesystem
108 io_profile
108 logic109 logic
109 logic_constants110 logic_constants
110 logic_exceptions111 logic_exceptions
@@ -113,6 +114,5 @@
113 logic_objectives114 logic_objectives
114 logic_widelands_geometry115 logic_widelands_geometry
115 logic_widelands_geometry_io116 logic_widelands_geometry_io
116 profile
117 scripting_logic117 scripting_logic
118)118)
119119
=== modified file 'src/map_io/coords_profile.cc'
--- src/map_io/coords_profile.cc 2019-02-23 11:00:49 +0000
+++ src/map_io/coords_profile.cc 2019-08-27 19:00:46 +0000
@@ -25,8 +25,8 @@
25#include <string>25#include <string>
2626
27#include "base/wexception.h"27#include "base/wexception.h"
28#include "io/profile.h"
28#include "logic/widelands_geometry.h"29#include "logic/widelands_geometry.h"
29#include "profile/profile.h"
3030
31namespace Widelands {31namespace Widelands {
3232
3333
=== modified file 'src/map_io/map_allowed_building_types_packet.cc'
--- src/map_io/map_allowed_building_types_packet.cc 2019-02-23 11:00:49 +0000
+++ src/map_io/map_allowed_building_types_packet.cc 2019-08-27 19:00:46 +0000
@@ -22,11 +22,11 @@
22#include <boost/format.hpp>22#include <boost/format.hpp>
2323
24#include "base/macros.h"24#include "base/macros.h"
25#include "io/profile.h"
25#include "logic/game.h"26#include "logic/game.h"
26#include "logic/game_data_error.h"27#include "logic/game_data_error.h"
27#include "logic/map_objects/tribes/tribe_descr.h"28#include "logic/map_objects/tribes/tribe_descr.h"
28#include "logic/player.h"29#include "logic/player.h"
29#include "profile/profile.h"
3030
31namespace Widelands {31namespace Widelands {
3232
3333
=== modified file 'src/map_io/map_allowed_worker_types_packet.cc'
--- src/map_io/map_allowed_worker_types_packet.cc 2019-02-23 11:00:49 +0000
+++ src/map_io/map_allowed_worker_types_packet.cc 2019-08-27 19:00:46 +0000
@@ -22,11 +22,11 @@
22#include <boost/format.hpp>22#include <boost/format.hpp>
2323
24#include "base/macros.h"24#include "base/macros.h"
25#include "io/profile.h"
25#include "logic/game.h"26#include "logic/game.h"
26#include "logic/game_data_error.h"27#include "logic/game_data_error.h"
27#include "logic/map_objects/tribes/tribe_descr.h"28#include "logic/map_objects/tribes/tribe_descr.h"
28#include "logic/player.h"29#include "logic/player.h"
29#include "profile/profile.h"
3030
31namespace Widelands {31namespace Widelands {
3232
3333
=== modified file 'src/map_io/map_elemental_packet.cc'
--- src/map_io/map_elemental_packet.cc 2019-02-27 19:00:36 +0000
+++ src/map_io/map_elemental_packet.cc 2019-08-27 19:00:46 +0000
@@ -22,10 +22,10 @@
22#include <boost/algorithm/string.hpp>22#include <boost/algorithm/string.hpp>
23#include <boost/format.hpp>23#include <boost/format.hpp>
2424
25#include "io/profile.h"
25#include "logic/editor_game_base.h"26#include "logic/editor_game_base.h"
26#include "logic/game_data_error.h"27#include "logic/game_data_error.h"
27#include "logic/map.h"28#include "logic/map.h"
28#include "profile/profile.h"
2929
30namespace Widelands {30namespace Widelands {
3131
3232
=== modified file 'src/map_io/map_objective_packet.cc'
--- src/map_io/map_objective_packet.cc 2019-02-23 11:00:49 +0000
+++ src/map_io/map_objective_packet.cc 2019-08-27 19:00:46 +0000
@@ -21,11 +21,11 @@
2121
22#include <memory>22#include <memory>
2323
24#include "io/profile.h"
24#include "logic/editor_game_base.h"25#include "logic/editor_game_base.h"
25#include "logic/game_data_error.h"26#include "logic/game_data_error.h"
26#include "logic/map.h"27#include "logic/map.h"
27#include "logic/objective.h"28#include "logic/objective.h"
28#include "profile/profile.h"
2929
30namespace Widelands {30namespace Widelands {
3131
3232
=== modified file 'src/map_io/map_player_names_and_tribes_packet.cc'
--- src/map_io/map_player_names_and_tribes_packet.cc 2019-02-27 19:00:36 +0000
+++ src/map_io/map_player_names_and_tribes_packet.cc 2019-08-27 19:00:46 +0000
@@ -22,11 +22,11 @@
22#include <boost/algorithm/string/trim.hpp>22#include <boost/algorithm/string/trim.hpp>
23#include <boost/format.hpp>23#include <boost/format.hpp>
2424
25#include "io/profile.h"
25#include "logic/editor_game_base.h"26#include "logic/editor_game_base.h"
26#include "logic/game_data_error.h"27#include "logic/game_data_error.h"
27#include "logic/map.h"28#include "logic/map.h"
28#include "logic/map_objects/world/world.h"29#include "logic/map_objects/world/world.h"
29#include "profile/profile.h"
3030
31namespace Widelands {31namespace Widelands {
3232
3333
=== modified file 'src/map_io/map_player_position_packet.cc'
--- src/map_io/map_player_position_packet.cc 2019-02-27 19:00:36 +0000
+++ src/map_io/map_player_position_packet.cc 2019-08-27 19:00:46 +0000
@@ -21,11 +21,11 @@
2121
22#include <boost/format.hpp>22#include <boost/format.hpp>
2323
24#include "io/profile.h"
24#include "logic/editor_game_base.h"25#include "logic/editor_game_base.h"
25#include "logic/game_data_error.h"26#include "logic/game_data_error.h"
26#include "logic/map.h"27#include "logic/map.h"
27#include "map_io/coords_profile.h"28#include "map_io/coords_profile.h"
28#include "profile/profile.h"
2929
30namespace Widelands {30namespace Widelands {
3131
3232
=== modified file 'src/map_io/map_players_messages_packet.cc'
--- src/map_io/map_players_messages_packet.cc 2019-02-23 11:00:49 +0000
+++ src/map_io/map_players_messages_packet.cc 2019-08-27 19:00:46 +0000
@@ -23,13 +23,13 @@
2323
24#include <boost/format.hpp>24#include <boost/format.hpp>
2525
26#include "io/profile.h"
26#include "logic/game_data_error.h"27#include "logic/game_data_error.h"
27#include "logic/message.h"28#include "logic/message.h"
28#include "logic/player.h"29#include "logic/player.h"
29#include "map_io/coords_profile.h"30#include "map_io/coords_profile.h"
30#include "map_io/map_object_loader.h"31#include "map_io/map_object_loader.h"
31#include "map_io/map_object_saver.h"32#include "map_io/map_object_saver.h"
32#include "profile/profile.h"
3333
34namespace Widelands {34namespace Widelands {
3535
3636
=== modified file 'src/map_io/map_port_spaces_packet.cc'
--- src/map_io/map_port_spaces_packet.cc 2019-03-24 13:13:34 +0000
+++ src/map_io/map_port_spaces_packet.cc 2019-08-27 19:00:46 +0000
@@ -24,11 +24,11 @@
24#include <boost/algorithm/string.hpp>24#include <boost/algorithm/string.hpp>
2525
26#include "base/log.h"26#include "base/log.h"
27#include "io/profile.h"
27#include "logic/editor_game_base.h"28#include "logic/editor_game_base.h"
28#include "logic/game_data_error.h"29#include "logic/game_data_error.h"
29#include "logic/map.h"30#include "logic/map.h"
30#include "map_io/coords_profile.h"31#include "map_io/coords_profile.h"
31#include "profile/profile.h"
3232
33namespace Widelands {33namespace Widelands {
3434
3535
=== modified file 'src/map_io/map_version_packet.cc'
--- src/map_io/map_version_packet.cc 2019-06-23 10:30:26 +0000
+++ src/map_io/map_version_packet.cc 2019-08-27 19:00:46 +0000
@@ -22,10 +22,10 @@
22#include "build_info.h"22#include "build_info.h"
23#include "io/fileread.h"23#include "io/fileread.h"
24#include "io/filewrite.h"24#include "io/filewrite.h"
25#include "io/profile.h"
25#include "logic/editor_game_base.h"26#include "logic/editor_game_base.h"
26#include "logic/game_data_error.h"27#include "logic/game_data_error.h"
27#include "logic/map.h"28#include "logic/map.h"
28#include "profile/profile.h"
2929
30namespace Widelands {30namespace Widelands {
3131
3232
=== modified file 'src/network/CMakeLists.txt'
--- src/network/CMakeLists.txt 2019-05-04 15:37:33 +0000
+++ src/network/CMakeLists.txt 2019-08-27 19:00:46 +0000
@@ -55,7 +55,6 @@
55 logic_game_settings55 logic_game_settings
56 logic_tribe_basic_info56 logic_tribe_basic_info
57 map_io_map_loader57 map_io_map_loader
58 profile
59 random58 random
60 scripting_lua_interface59 scripting_lua_interface
61 scripting_lua_table60 scripting_lua_table
6261
=== modified file 'src/network/gameclient.cc'
--- src/network/gameclient.cc 2019-06-24 21:59:24 +0000
+++ src/network/gameclient.cc 2019-08-27 19:00:46 +0000
@@ -53,6 +53,7 @@
53#include "ui_basic/progresswindow.h"53#include "ui_basic/progresswindow.h"
54#include "ui_fsmenu/launch_mpg.h"54#include "ui_fsmenu/launch_mpg.h"
55#include "wlapplication.h"55#include "wlapplication.h"
56#include "wlapplication_options.h"
56#include "wui/game_tips.h"57#include "wui/game_tips.h"
57#include "wui/interactive_player.h"58#include "wui/interactive_player.h"
58#include "wui/interactive_spectator.h"59#include "wui/interactive_spectator.h"
@@ -163,9 +164,9 @@
163 (boost::format("%s_netclient%u") % kAutosavePrefix % static_cast<unsigned int>(pn)).str());164 (boost::format("%s_netclient%u") % kAutosavePrefix % static_cast<unsigned int>(pn)).str());
164 InteractiveGameBase* igb;165 InteractiveGameBase* igb;
165 if (pn > 0) {166 if (pn > 0) {
166 igb = new InteractivePlayer(*game, g_options.pull_section("global"), pn, true);167 igb = new InteractivePlayer(*game, get_config_section(), pn, true);
167 } else {168 } else {
168 igb = new InteractiveSpectator(*game, g_options.pull_section("global"), true);169 igb = new InteractiveSpectator(*game, get_config_section(), true);
169 }170 }
170 game->set_ibase(igb);171 game->set_ibase(igb);
171 igb->set_chat_provider(*parent);172 igb->set_chat_provider(*parent);
@@ -264,9 +265,8 @@
264265
265 d->server_is_waiting = true;266 d->server_is_waiting = true;
266267
267 bool write_sync_streams = g_options.pull_section("global").get_bool("write_syncstreams", true);
268 Widelands::Game game;268 Widelands::Game game;
269 game.set_write_syncstream(write_sync_streams);269 game.set_write_syncstream(get_config_bool("write_syncstreams", true));
270270
271 try {271 try {
272 std::unique_ptr<UI::ProgressWindow> loader_ui(new UI::ProgressWindow());272 std::unique_ptr<UI::ProgressWindow> loader_ui(new UI::ProgressWindow());
273273
=== modified file 'src/network/gamehost.cc'
--- src/network/gamehost.cc 2019-06-24 21:59:24 +0000
+++ src/network/gamehost.cc 2019-08-27 19:00:46 +0000
@@ -58,11 +58,11 @@
58#include "network/network_lan_promotion.h"58#include "network/network_lan_promotion.h"
59#include "network/network_player_settings_backend.h"59#include "network/network_player_settings_backend.h"
60#include "network/network_protocol.h"60#include "network/network_protocol.h"
61#include "profile/profile.h"
62#include "scripting/lua_interface.h"61#include "scripting/lua_interface.h"
63#include "ui_basic/progresswindow.h"62#include "ui_basic/progresswindow.h"
64#include "ui_fsmenu/launch_mpg.h"63#include "ui_fsmenu/launch_mpg.h"
65#include "wlapplication.h"64#include "wlapplication.h"
65#include "wlapplication_options.h"
66#include "wui/game_tips.h"66#include "wui/game_tips.h"
67#include "wui/interactive_player.h"67#include "wui/interactive_player.h"
68#include "wui/interactive_spectator.h"68#include "wui/interactive_spectator.h"
@@ -632,9 +632,9 @@
632 broadcast(packet);632 broadcast(packet);
633633
634 Widelands::Game game;634 Widelands::Game game;
635 game.set_ai_training_mode(g_options.pull_section("global").get_bool("ai_training", false));635 game.set_ai_training_mode(get_config_bool("ai_training", false));
636 game.set_auto_speed(g_options.pull_section("global").get_bool("auto_speed", false));636 game.set_auto_speed(get_config_bool("auto_speed", false));
637 game.set_write_syncstream(g_options.pull_section("global").get_bool("write_syncstreams", true));637 game.set_write_syncstream(get_config_bool("write_syncstreams", true));
638638
639 try {639 try {
640 std::unique_ptr<UI::ProgressWindow> loader_ui;640 std::unique_ptr<UI::ProgressWindow> loader_ui;
@@ -668,9 +668,9 @@
668 }668 }
669669
670 if ((pn > 0) && (pn <= UserSettings::highest_playernum())) {670 if ((pn > 0) && (pn <= UserSettings::highest_playernum())) {
671 igb = new InteractivePlayer(game, g_options.pull_section("global"), pn, true);671 igb = new InteractivePlayer(game, get_config_section(), pn, true);
672 } else {672 } else {
673 igb = new InteractiveSpectator(game, g_options.pull_section("global"), true);673 igb = new InteractiveSpectator(game, get_config_section(), true);
674 }674 }
675 igb->set_chat_provider(d->chat);675 igb->set_chat_provider(d->chat);
676 game.set_ibase(igb);676 game.set_ibase(igb);
677677
=== removed directory 'src/profile'
=== removed file 'src/profile/CMakeLists.txt'
--- src/profile/CMakeLists.txt 2015-11-28 22:29:26 +0000
+++ src/profile/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
1wl_library(profile
2 SRCS
3 profile.h
4 profile.cc
5 DEPENDS
6 base_exceptions
7 base_geometry
8 base_i18n
9 base_log
10 base_macros
11 build_info
12 io_fileread
13 io_filesystem
14 )
150
=== modified file 'src/scripting/CMakeLists.txt'
--- src/scripting/CMakeLists.txt 2019-05-05 18:53:14 +0000
+++ src/scripting/CMakeLists.txt 2019-08-27 19:00:46 +0000
@@ -108,6 +108,7 @@
108 economy108 economy
109 io_fileread109 io_fileread
110 io_filesystem110 io_filesystem
111 io_profile
111 logic112 logic
112 logic_commands113 logic_commands
113 logic_constants114 logic_constants
@@ -120,7 +121,6 @@
120 logic_tribe_basic_info121 logic_tribe_basic_info
121 logic_widelands_geometry122 logic_widelands_geometry
122 map_io123 map_io
123 profile
124 scripting_base124 scripting_base
125 scripting_coroutine125 scripting_coroutine
126 scripting_errors126 scripting_errors
@@ -129,6 +129,7 @@
129 scripting_luna129 scripting_luna
130 third_party_eris130 third_party_eris
131 ui_basic131 ui_basic
132 widelands_ball_of_mud
132 wui133 wui
133 wui_mapview_pixelfunctions134 wui_mapview_pixelfunctions
134)135)
135136
=== modified file 'src/scripting/lua_bases.cc'
--- src/scripting/lua_bases.cc 2019-04-09 16:43:49 +0000
+++ src/scripting/lua_bases.cc 2019-08-27 19:00:46 +0000
@@ -24,6 +24,7 @@
2424
25#include "economy/economy.h"25#include "economy/economy.h"
26#include "io/filesystem/layered_filesystem.h"26#include "io/filesystem/layered_filesystem.h"
27#include "io/profile.h"
27#include "logic/filesystem_constants.h"28#include "logic/filesystem_constants.h"
28#include "logic/map_objects/checkstep.h"29#include "logic/map_objects/checkstep.h"
29#include "logic/map_objects/tribes/tribe_descr.h"30#include "logic/map_objects/tribes/tribe_descr.h"
@@ -31,7 +32,6 @@
31#include "logic/map_objects/tribes/ware_descr.h"32#include "logic/map_objects/tribes/ware_descr.h"
32#include "logic/map_objects/world/world.h"33#include "logic/map_objects/world/world.h"
33#include "logic/player.h"34#include "logic/player.h"
34#include "profile/profile.h"
35#include "scripting/factory.h"35#include "scripting/factory.h"
36#include "scripting/globals.h"36#include "scripting/globals.h"
37#include "scripting/lua_map.h"37#include "scripting/lua_map.h"
3838
=== modified file 'src/scripting/lua_game.cc'
--- src/scripting/lua_game.cc 2019-08-10 16:38:15 +0000
+++ src/scripting/lua_game.cc 2019-08-27 19:00:46 +0000
@@ -37,6 +37,7 @@
37#include "scripting/globals.h"37#include "scripting/globals.h"
38#include "scripting/lua_interface.h"38#include "scripting/lua_interface.h"
39#include "scripting/lua_map.h"39#include "scripting/lua_map.h"
40#include "wlapplication_options.h"
40#include "wui/interactive_player.h"41#include "wui/interactive_player.h"
41#include "wui/story_message_box.h"42#include "wui/story_message_box.h"
4243
@@ -1069,7 +1070,7 @@
1069 Objective& o = get(L, get_game(L));1070 Objective& o = get(L, get_game(L));
1070 o.set_done(luaL_checkboolean(L, -1));1071 o.set_done(luaL_checkboolean(L, -1));
10711072
1072 const int32_t autosave = g_options.pull_section("global").get_int("autosave", 0);1073 const int32_t autosave = get_config_int("autosave", 0);
1073 if (autosave <= 0) {1074 if (autosave <= 0) {
1074 return 0;1075 return 0;
1075 }1076 }
10761077
=== modified file 'src/sound/CMakeLists.txt'
--- src/sound/CMakeLists.txt 2019-04-08 13:32:28 +0000
+++ src/sound/CMakeLists.txt 2019-08-27 19:00:46 +0000
@@ -32,7 +32,7 @@
32 io_fileread32 io_fileread
33 io_filesystem33 io_filesystem
34 logic_exceptions34 logic_exceptions
35 profile
36 random35 random
37 sound_constants36 sound_constants
37 widelands_ball_of_mud
38)38)
3939
=== modified file 'src/sound/sound_handler.cc'
--- src/sound/sound_handler.cc 2019-05-12 12:08:33 +0000
+++ src/sound/sound_handler.cc 2019-08-27 19:00:46 +0000
@@ -30,7 +30,7 @@
3030
31#include "base/i18n.h"31#include "base/i18n.h"
32#include "base/log.h"32#include "base/log.h"
33#include "profile/profile.h"33#include "wlapplication_options.h"
3434
35namespace {35namespace {
36constexpr int kDefaultMusicVolume = 64;36constexpr int kDefaultMusicVolume = 64;
@@ -190,28 +190,26 @@
190}190}
191191
192/**192/**
193 * Load the sound options from g_options. If an option is not available, use the defaults set by the193 * Load the sound options from cached config. If an option is not available, use the defaults set by the
194 * constructor.194 * constructor.
195 */195 */
196void SoundHandler::read_config() {196void SoundHandler::read_config() {
197 // TODO(GunChleoc): Compatibility code to avoid getting bug reports about unread sections. Remove197 // TODO(GunChleoc): Compatibility code to avoid getting bug reports about unread sections. Remove
198 // after Build 21.198 // after Build 21.
199 if (g_options.get_section("sound") == nullptr) {199 if (get_config_section_ptr("sound") == nullptr) {
200 Section& global = g_options.pull_section("global");
201
202 for (auto& option : sound_options_) {200 for (auto& option : sound_options_) {
203 switch (option.first) {201 switch (option.first) {
204 case SoundType::kMusic:202 case SoundType::kMusic:
205 option.second.volume = global.get_int("music_volume", option.second.volume);203 option.second.volume = get_config_int("music_volume", option.second.volume);
206 option.second.enabled = !global.get_bool("disable_music", !option.second.enabled);204 option.second.enabled = !get_config_bool("disable_music", !option.second.enabled);
207 break;205 break;
208 case SoundType::kChat:206 case SoundType::kChat:
209 option.second.volume = global.get_int("fx_volume", option.second.volume);207 option.second.volume = get_config_int("fx_volume", option.second.volume);
210 option.second.enabled = global.get_bool("sound_at_message", option.second.enabled);208 option.second.enabled = get_config_bool("sound_at_message", option.second.enabled);
211 break;209 break;
212 default:210 default:
213 option.second.volume = global.get_int("fx_volume", option.second.volume);211 option.second.volume = get_config_int("fx_volume", option.second.volume);
214 option.second.enabled = !global.get_bool("disable_fx", !option.second.enabled);212 option.second.enabled = !get_config_bool("disable_fx", !option.second.enabled);
215 break;213 break;
216 }214 }
217 }215 }
@@ -219,32 +217,30 @@
219 }217 }
220218
221 // This is the code that we want to keep219 // This is the code that we want to keep
222 Section& sound = g_options.pull_section("sound");
223 for (auto& option : sound_options_) {220 for (auto& option : sound_options_) {
224 option.second.volume =221 option.second.volume =
225 sound.get_int(("volume_" + option.second.name).c_str(), option.second.volume);222 get_config_int("sound", ("volume_" + option.second.name).c_str(), option.second.volume);
226 option.second.enabled =223 option.second.enabled =
227 sound.get_bool(("enable_" + option.second.name).c_str(), option.second.enabled);224 get_config_bool("sound", ("enable_" + option.second.name).c_str(), option.second.enabled);
228 }225 }
229}226}
230227
231/// Save the current sound options to g_options228/// Save the current sound options to config cache
232void SoundHandler::save_config() {229void SoundHandler::save_config() {
233 Section& sound = g_options.pull_section("sound");
234 for (auto& option : sound_options_) {230 for (auto& option : sound_options_) {
235 const int volume = option.second.volume;231 const int volume = option.second.volume;
236 const std::string& name = option.second.name;232 const std::string& name = option.second.name;
237 const bool enabled = option.second.enabled;233 const bool enabled = option.second.enabled;
238234
239 const std::string enable_name = "enable_" + name;235 const std::string enable_name = "enable_" + name;
240 sound.set_bool(enable_name.c_str(), enabled);236 set_config_bool("sound", enable_name.c_str(), enabled);
241237
242 const std::string volume_name = "volume_" + name;238 const std::string volume_name = "volume_" + name;
243 sound.set_int(volume_name.c_str(), volume);239 set_config_int("sound", volume_name.c_str(), volume);
244 }240 }
245}241}
246242
247/// Read the sound options from g_options and apply them243/// Read the sound options from the cache and apply them
248void SoundHandler::load_config() {244void SoundHandler::load_config() {
249 read_config();245 read_config();
250 for (auto& option : sound_options_) {246 for (auto& option : sound_options_) {
251247
=== modified file 'src/ui_basic/CMakeLists.txt'
--- src/ui_basic/CMakeLists.txt 2019-05-03 19:24:19 +0000
+++ src/ui_basic/CMakeLists.txt 2019-08-27 19:00:46 +0000
@@ -71,7 +71,6 @@
71 graphic_wordwrap71 graphic_wordwrap
72 io_filesystem72 io_filesystem
73 notifications73 notifications
74 profile
75 scripting_lua_interface74 scripting_lua_interface
76 scripting_lua_table75 scripting_lua_table
77 sound76 sound
7877
=== modified file 'src/ui_basic/panel.cc'
--- src/ui_basic/panel.cc 2019-07-28 08:46:47 +0000
+++ src/ui_basic/panel.cc 2019-08-27 19:00:46 +0000
@@ -25,9 +25,9 @@
25#include "graphic/rendertarget.h"25#include "graphic/rendertarget.h"
26#include "graphic/text/font_set.h"26#include "graphic/text/font_set.h"
27#include "graphic/text_layout.h"27#include "graphic/text_layout.h"
28#include "profile/profile.h"
29#include "sound/sound_handler.h"28#include "sound/sound_handler.h"
30#include "wlapplication.h"29#include "wlapplication.h"
30#include "wlapplication_options.h"
3131
32namespace UI {32namespace UI {
3333
@@ -165,7 +165,7 @@
165165
166 // With the default of 30FPS, the game will be drawn every 33ms.166 // With the default of 30FPS, the game will be drawn every 33ms.
167 const uint32_t draw_delay =167 const uint32_t draw_delay =
168 1000 / std::max(5, g_options.pull_section("global").get_int("maxfps", 30));168 1000 / std::max(5, get_config_int("maxfps", 30));
169169
170 static InputCallback input_callback = {Panel::ui_mousepress, Panel::ui_mouserelease,170 static InputCallback input_callback = {Panel::ui_mousepress, Panel::ui_mouserelease,
171 Panel::ui_mousemove, Panel::ui_key,171 Panel::ui_mousemove, Panel::ui_key,
172172
=== modified file 'src/ui_fsmenu/CMakeLists.txt'
--- src/ui_fsmenu/CMakeLists.txt 2019-05-26 01:58:59 +0000
+++ src/ui_fsmenu/CMakeLists.txt 2019-08-27 19:00:46 +0000
@@ -17,7 +17,6 @@
17 scripting_lua_table17 scripting_lua_table
18 ui_basic18 ui_basic
19 ui_fsmenu_base19 ui_fsmenu_base
20 profile
21 sound20 sound
22 widelands_ball_of_mud21 widelands_ball_of_mud
23 wui_sound_options22 wui_sound_options
@@ -77,12 +76,12 @@
77 base_i18n76 base_i18n
78 graphic77 graphic
79 io_filesystem78 io_filesystem
80 profile
81 network79 network
82 random80 random
83 ui_basic81 ui_basic
84 ui_fsmenu_base82 ui_fsmenu_base
85 ui_fsmenu_main_menu83 ui_fsmenu_main_menu
84 widelands_ball_of_mud
86 wui_common_mapdetails85 wui_common_mapdetails
87 wui86 wui
88)87)
@@ -104,6 +103,7 @@
104 graphic_playercolor103 graphic_playercolor
105 helper104 helper
106 io_filesystem105 io_filesystem
106 io_profile
107 logic107 logic
108 logic_game_controller108 logic_game_controller
109 logic_game_settings109 logic_game_settings
@@ -111,7 +111,6 @@
111 logic_map_objects111 logic_map_objects
112 logic_tribe_basic_info112 logic_tribe_basic_info
113 map_io_map_loader113 map_io_map_loader
114 profile
115 scripting_lua_interface114 scripting_lua_interface
116 scripting_lua_table115 scripting_lua_table
117 ui_basic116 ui_basic
@@ -119,6 +118,7 @@
119 ui_fsmenu_helpwindow118 ui_fsmenu_helpwindow
120 ui_fsmenu_loading_common119 ui_fsmenu_loading_common
121 ui_fsmenu_maploading120 ui_fsmenu_maploading
121 widelands_ball_of_mud
122 wui122 wui
123 wui_chat_ui123 wui_chat_ui
124 wui_common_gamedetails124 wui_common_gamedetails
@@ -147,12 +147,12 @@
147 graphic_fonthandler147 graphic_fonthandler
148 graphic_surface148 graphic_surface
149 io_filesystem149 io_filesystem
150 io_profile
150 logic_filesystem_constants151 logic_filesystem_constants
151 logic_game_controller152 logic_game_controller
152 logic_game_settings153 logic_game_settings
153 logic_tribe_basic_info154 logic_tribe_basic_info
154 map_io_map_loader155 map_io_map_loader
155 profile
156 scripting_lua_interface156 scripting_lua_interface
157 scripting_lua_table157 scripting_lua_table
158 ui_basic158 ui_basic
@@ -173,11 +173,11 @@
173 base_macros173 base_macros
174 graphic174 graphic
175 network175 network
176 profile
177 random176 random
178 sound177 sound
179 ui_basic178 ui_basic
180 ui_fsmenu_base179 ui_fsmenu_base
180 widelands_ball_of_mud
181 wui_chat_ui181 wui_chat_ui
182)182)
183183
184184
=== modified file 'src/ui_fsmenu/campaign_select.cc'
--- src/ui_fsmenu/campaign_select.cc 2019-05-26 17:21:15 +0000
+++ src/ui_fsmenu/campaign_select.cc 2019-08-27 19:00:46 +0000
@@ -27,7 +27,6 @@
27#include "base/wexception.h"27#include "base/wexception.h"
28#include "graphic/graphic.h"28#include "graphic/graphic.h"
29#include "logic/filesystem_constants.h"29#include "logic/filesystem_constants.h"
30#include "profile/profile.h"
31#include "scripting/lua_interface.h"30#include "scripting/lua_interface.h"
32#include "scripting/lua_table.h"31#include "scripting/lua_table.h"
3332
3433
=== modified file 'src/ui_fsmenu/campaigns.cc'
--- src/ui_fsmenu/campaigns.cc 2019-07-31 16:33:35 +0000
+++ src/ui_fsmenu/campaigns.cc 2019-08-27 19:00:46 +0000
@@ -25,9 +25,9 @@
25#include "base/log.h"25#include "base/log.h"
26#include "graphic/graphic.h"26#include "graphic/graphic.h"
27#include "io/filesystem/filesystem.h"27#include "io/filesystem/filesystem.h"
28#include "io/profile.h"
28#include "logic/filesystem_constants.h"29#include "logic/filesystem_constants.h"
29#include "logic/map_objects/tribes/tribe_basic_info.h"30#include "logic/map_objects/tribes/tribe_basic_info.h"
30#include "profile/profile.h"
31#include "scripting/lua_interface.h"31#include "scripting/lua_interface.h"
3232
33namespace {33namespace {
3434
=== modified file 'src/ui_fsmenu/internet_lobby.cc'
--- src/ui_fsmenu/internet_lobby.cc 2019-08-10 16:38:15 +0000
+++ src/ui_fsmenu/internet_lobby.cc 2019-08-27 19:00:46 +0000
@@ -30,10 +30,10 @@
30#include "network/gameclient.h"30#include "network/gameclient.h"
31#include "network/gamehost.h"31#include "network/gamehost.h"
32#include "network/internet_gaming.h"32#include "network/internet_gaming.h"
33#include "profile/profile.h"
34#include "random/random.h"33#include "random/random.h"
35#include "sound/sound_handler.h"34#include "sound/sound_handler.h"
36#include "ui_basic/messagebox.h"35#include "ui_basic/messagebox.h"
36#include "wlapplication_options.h"
3737
38namespace {38namespace {
3939
@@ -128,15 +128,13 @@
128 boost::bind(&FullscreenMenuInternetLobby::clicked_back, boost::ref(*this)));128 boost::bind(&FullscreenMenuInternetLobby::clicked_back, boost::ref(*this)));
129129
130 // Set the texts and style of UI elements130 // Set the texts and style of UI elements
131 Section& s = g_options.pull_section("global"); // for playername
132
133 title.set_font_scale(scale_factor());131 title.set_font_scale(scale_factor());
134132
135 opengames_.set_font_scale(scale_factor());133 opengames_.set_font_scale(scale_factor());
136 clients_.set_font_scale(scale_factor());134 clients_.set_font_scale(scale_factor());
137 servername_.set_font_scale(scale_factor());135 servername_.set_font_scale(scale_factor());
138136
139 std::string server = s.get_string("servername", "");137 std::string server = get_config_string("servername", "");
140 edit_servername_.set_font_scale(scale_factor());138 edit_servername_.set_font_scale(scale_factor());
141 edit_servername_.set_text(server);139 edit_servername_.set_text(server);
142 edit_servername_.changed.connect(140 edit_servername_.changed.connect(
@@ -222,10 +220,9 @@
222220
223/// connects Widelands with the metaserver221/// connects Widelands with the metaserver
224void FullscreenMenuInternetLobby::connect_to_metaserver() {222void FullscreenMenuInternetLobby::connect_to_metaserver() {
225 Section& s = g_options.pull_section("global");223 const std::string& metaserver = get_config_string("metaserver", INTERNET_GAMING_METASERVER.c_str());
226 const std::string& metaserver = s.get_string("metaserver", INTERNET_GAMING_METASERVER.c_str());224 uint32_t port = get_config_natural("metaserverport", kInternetGamingPort);
227 uint32_t port = s.get_natural("metaserverport", kInternetGamingPort);225 std::string auth = is_registered_ ? password_ : get_config_string("uuid", nullptr);
228 std::string auth = is_registered_ ? password_ : s.get_string("uuid");
229 assert(!auth.empty());226 assert(!auth.empty());
230 InternetGaming::ref().login(nickname_, auth, is_registered_, metaserver, port);227 InternetGaming::ref().login(nickname_, auth, is_registered_, metaserver, port);
231}228}
@@ -451,7 +448,7 @@
451 }448 }
452 }449 }
453450
454 g_options.pull_section("global").set_string("servername", servername_ui);451 set_config_string("servername", servername_ui);
455452
456 // Set up the game453 // Set up the game
457 InternetGaming::ref().set_local_servername(servername_ui);454 InternetGaming::ref().set_local_servername(servername_ui);
458455
=== modified file 'src/ui_fsmenu/launch_mpg.cc'
--- src/ui_fsmenu/launch_mpg.cc 2019-05-28 17:01:30 +0000
+++ src/ui_fsmenu/launch_mpg.cc 2019-08-27 19:00:46 +0000
@@ -28,6 +28,7 @@
28#include "graphic/graphic.h"28#include "graphic/graphic.h"
29#include "graphic/playercolor.h"29#include "graphic/playercolor.h"
30#include "io/filesystem/layered_filesystem.h"30#include "io/filesystem/layered_filesystem.h"
31#include "io/profile.h"
31#include "logic/game.h"32#include "logic/game.h"
32#include "logic/game_controller.h"33#include "logic/game_controller.h"
33#include "logic/game_settings.h"34#include "logic/game_settings.h"
@@ -36,7 +37,6 @@
36#include "logic/map_objects/tribes/tribe_basic_info.h"37#include "logic/map_objects/tribes/tribe_basic_info.h"
37#include "logic/player.h"38#include "logic/player.h"
38#include "map_io/map_loader.h"39#include "map_io/map_loader.h"
39#include "profile/profile.h"
40#include "scripting/lua_interface.h"40#include "scripting/lua_interface.h"
41#include "scripting/lua_table.h"41#include "scripting/lua_table.h"
42#include "ui_basic/messagebox.h"42#include "ui_basic/messagebox.h"
4343
=== modified file 'src/ui_fsmenu/loadgame.cc'
--- src/ui_fsmenu/loadgame.cc 2019-05-26 17:21:15 +0000
+++ src/ui_fsmenu/loadgame.cc 2019-08-27 19:00:46 +0000
@@ -22,7 +22,7 @@
22#include <memory>22#include <memory>
2323
24#include "base/i18n.h"24#include "base/i18n.h"
25#include "profile/profile.h"25#include "wlapplication_options.h"
26#include "wui/gamedetails.h"26#include "wui/gamedetails.h"
2727
28FullscreenMenuLoadGame::FullscreenMenuLoadGame(Widelands::Game& g,28FullscreenMenuLoadGame::FullscreenMenuLoadGame(Widelands::Game& g,
@@ -101,8 +101,7 @@
101 if (is_replay_) {101 if (is_replay_) {
102 show_filenames_->changed.connect(102 show_filenames_->changed.connect(
103 boost::bind(&FullscreenMenuLoadGame::toggle_filenames, boost::ref(*this)));103 boost::bind(&FullscreenMenuLoadGame::toggle_filenames, boost::ref(*this)));
104 show_filenames_->set_state(104 show_filenames_->set_state(get_config_bool("display_replay_filenames", true));
105 g_options.pull_section("global").get_bool("display_replay_filenames", true));
106 }105 }
107106
108 fill_table();107 fill_table();
@@ -125,7 +124,7 @@
125124
126void FullscreenMenuLoadGame::toggle_filenames() {125void FullscreenMenuLoadGame::toggle_filenames() {
127 showing_filenames_ = show_filenames_->get_state();126 showing_filenames_ = show_filenames_->get_state();
128 g_options.pull_section("global").set_bool("display_replay_filenames", showing_filenames_);127 set_config_bool("display_replay_filenames", showing_filenames_);
129128
130 // Remember selection129 // Remember selection
131 const std::set<uint32_t> selected = load_or_save_.table().selections();130 const std::set<uint32_t> selected = load_or_save_.table().selections();
132131
=== modified file 'src/ui_fsmenu/multiplayer.cc'
--- src/ui_fsmenu/multiplayer.cc 2019-05-26 17:21:15 +0000
+++ src/ui_fsmenu/multiplayer.cc 2019-08-27 19:00:46 +0000
@@ -22,9 +22,9 @@
22#include "base/i18n.h"22#include "base/i18n.h"
23#include "graphic/graphic.h"23#include "graphic/graphic.h"
24#include "network/internet_gaming.h"24#include "network/internet_gaming.h"
25#include "profile/profile.h"
26#include "random/random.h"25#include "random/random.h"
27#include "ui_basic/messagebox.h"26#include "ui_basic/messagebox.h"
27#include "wlapplication_options.h"
28#include "wui/login_box.h"28#include "wui/login_box.h"
2929
30FullscreenMenuMultiPlayer::FullscreenMenuMultiPlayer()30FullscreenMenuMultiPlayer::FullscreenMenuMultiPlayer()
@@ -96,11 +96,9 @@
96 * This fullscreen menu ends it's modality.96 * This fullscreen menu ends it's modality.
97 */97 */
98void FullscreenMenuMultiPlayer::internet_login() {98void FullscreenMenuMultiPlayer::internet_login() {
99 Section& s = g_options.pull_section("global");99 nickname_ = get_config_string("nickname", "");
100100 password_ = get_config_string("password_sha1", "no_password_set");
101 nickname_ = s.get_string("nickname", "");101 register_ = get_config_bool("registered", false);
102 password_ = s.get_string("password_sha1", "no_password_set");
103 register_ = s.get_bool("registered", false);
104102
105 // Checks can be done directly in editbox' by using valid_username().103 // Checks can be done directly in editbox' by using valid_username().
106 // This is just to be on the safe side, in case the user changed the password in the config file.104 // This is just to be on the safe side, in case the user changed the password in the config file.
@@ -111,9 +109,9 @@
111 }109 }
112110
113 // Try to connect to the metaserver111 // Try to connect to the metaserver
114 const std::string& meta = s.get_string("metaserver", INTERNET_GAMING_METASERVER.c_str());112 const std::string& meta = get_config_string("metaserver", INTERNET_GAMING_METASERVER.c_str());
115 uint32_t port = s.get_natural("metaserverport", kInternetGamingPort);113 uint32_t port = get_config_natural("metaserverport", kInternetGamingPort);
116 std::string auth = register_ ? password_ : s.get_string("uuid");114 std::string auth = register_ ? password_ : get_config_string("uuid", nullptr);
117 assert(!auth.empty());115 assert(!auth.empty());
118 InternetGaming::ref().login(nickname_, auth, register_, meta, port);116 InternetGaming::ref().login(nickname_, auth, register_, meta, port);
119117
@@ -128,7 +126,7 @@
128126
129 // Reset InternetGaming and passwort and show internet login again127 // Reset InternetGaming and passwort and show internet login again
130 InternetGaming::ref().reset();128 InternetGaming::ref().reset();
131 s.set_string("password_sha1", "no_password_set");129 set_config_string("password_sha1", "no_password_set");
132 auto_log_ = true;130 auto_log_ = true;
133 show_internet_login();131 show_internet_login();
134 }132 }
135133
=== modified file 'src/ui_fsmenu/netsetup_lan.cc'
--- src/ui_fsmenu/netsetup_lan.cc 2019-05-26 17:21:15 +0000
+++ src/ui_fsmenu/netsetup_lan.cc 2019-08-27 19:00:46 +0000
@@ -25,7 +25,7 @@
25#include "network/constants.h"25#include "network/constants.h"
26#include "network/internet_gaming.h"26#include "network/internet_gaming.h"
27#include "network/network.h"27#include "network/network.h"
28#include "profile/profile.h"28#include "wlapplication_options.h"
2929
30FullscreenMenuNetSetupLAN::FullscreenMenuNetSetupLAN()30FullscreenMenuNetSetupLAN::FullscreenMenuNetSetupLAN()
31 : FullscreenMenuBase(),31 : FullscreenMenuBase(),
@@ -110,13 +110,11 @@
110 loadlasthost.sigclicked.connect(110 loadlasthost.sigclicked.connect(
111 boost::bind(&FullscreenMenuNetSetupLAN::clicked_lasthost, boost::ref(*this)));111 boost::bind(&FullscreenMenuNetSetupLAN::clicked_lasthost, boost::ref(*this)));
112112
113 Section& s = g_options.pull_section("global"); // for playername
114
115 playername.set_font_scale(scale_factor());113 playername.set_font_scale(scale_factor());
116 hostname.set_font_scale(scale_factor());114 hostname.set_font_scale(scale_factor());
117115
118 hostname.changed.connect(boost::bind(&FullscreenMenuNetSetupLAN::change_hostname, this));116 hostname.changed.connect(boost::bind(&FullscreenMenuNetSetupLAN::change_hostname, this));
119 playername.set_text(s.get_string("nickname", (_("nobody"))));117 playername.set_text(get_config_string("nickname", (_("nobody"))));
120 playername.changed.connect(boost::bind(&FullscreenMenuNetSetupLAN::change_playername, this));118 playername.changed.connect(boost::bind(&FullscreenMenuNetSetupLAN::change_playername, this));
121 opengames.add_column(listw_ * 2 / 5, _("Host"));119 opengames.add_column(listw_ * 2 / 5, _("Host"));
122 opengames.add_column(listw_ * 2 / 5, _("Map"));120 opengames.add_column(listw_ * 2 / 5, _("Map"));
@@ -264,12 +262,12 @@
264 joingame.set_enabled(true);262 joingame.set_enabled(true);
265 }263 }
266264
267 g_options.pull_section("global").set_string("nickname", playername.text());265 set_config_string("nickname", playername.text());
268}266}
269267
270void FullscreenMenuNetSetupLAN::clicked_joingame() {268void FullscreenMenuNetSetupLAN::clicked_joingame() {
271 // Save selected host so users can reload it for reconnection.269 // Save selected host so users can reload it for reconnection.
272 g_options.pull_section("global").set_string("lasthost", hostname.text());270 set_config_string("lasthost", hostname.text());
273271
274 end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kJoingame);272 end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kJoingame);
275}273}
@@ -279,7 +277,7 @@
279}277}
280278
281void FullscreenMenuNetSetupLAN::clicked_lasthost() {279void FullscreenMenuNetSetupLAN::clicked_lasthost() {
282 Section& s = g_options.get_safe_section("global");280 Section& s = get_config_safe_section();
283 std::string const host = s.get_string("lasthost", "");281 std::string const host = s.get_string("lasthost", "");
284 hostname.set_text(host);282 hostname.set_text(host);
285 if (host.size())283 if (host.size())
286284
=== modified file 'src/ui_fsmenu/options.cc'
--- src/ui_fsmenu/options.cc 2019-06-25 08:03:30 +0000
+++ src/ui_fsmenu/options.cc 2019-08-27 19:00:46 +0000
@@ -37,13 +37,14 @@
37#include "graphic/text/font_set.h"37#include "graphic/text/font_set.h"
38#include "graphic/text_layout.h"38#include "graphic/text_layout.h"
39#include "helper.h"39#include "helper.h"
40#include "io/filesystem/disk_filesystem.h"
40#include "io/filesystem/layered_filesystem.h"41#include "io/filesystem/layered_filesystem.h"
41#include "logic/filesystem_constants.h"42#include "logic/filesystem_constants.h"
42#include "profile/profile.h"
43#include "scripting/lua_interface.h"43#include "scripting/lua_interface.h"
44#include "scripting/lua_table.h"44#include "scripting/lua_table.h"
45#include "sound/sound_handler.h"45#include "sound/sound_handler.h"
46#include "wlapplication.h"46#include "wlapplication.h"
47#include "wlapplication_options.h"
4748
48namespace {49namespace {
4950
@@ -679,5 +680,5 @@
679 g_sh->save_config();680 g_sh->save_config();
680681
681 // Now write to file682 // Now write to file
682 g_options.write(kConfigFile.c_str(), true);683 write_config(WLApplication::get());
683}684}
684685
=== modified file 'src/ui_fsmenu/scenario_select.cc'
--- src/ui_fsmenu/scenario_select.cc 2019-05-26 17:21:15 +0000
+++ src/ui_fsmenu/scenario_select.cc 2019-08-27 19:00:46 +0000
@@ -26,9 +26,9 @@
26#include "base/i18n.h"26#include "base/i18n.h"
27#include "base/wexception.h"27#include "base/wexception.h"
28#include "graphic/graphic.h"28#include "graphic/graphic.h"
29#include "io/profile.h"
29#include "logic/filesystem_constants.h"30#include "logic/filesystem_constants.h"
30#include "map_io/widelands_map_loader.h"31#include "map_io/widelands_map_loader.h"
31#include "profile/profile.h"
32#include "scripting/lua_interface.h"32#include "scripting/lua_interface.h"
33#include "scripting/lua_table.h"33#include "scripting/lua_table.h"
34#include "ui_basic/scrollbar.h"34#include "ui_basic/scrollbar.h"
3535
=== modified file 'src/wlapplication.cc'
--- src/wlapplication.cc 2019-05-27 21:04:13 +0000
+++ src/wlapplication.cc 2019-08-27 19:00:46 +0000
@@ -73,7 +73,6 @@
73#include "network/gameclient.h"73#include "network/gameclient.h"
74#include "network/gamehost.h"74#include "network/gamehost.h"
75#include "network/internet_gaming.h"75#include "network/internet_gaming.h"
76#include "profile/profile.h"
77#include "random/random.h"76#include "random/random.h"
78#include "sound/sound_handler.h"77#include "sound/sound_handler.h"
79#include "ui_basic/messagebox.h"78#include "ui_basic/messagebox.h"
@@ -93,6 +92,7 @@
93#include "ui_fsmenu/scenario_select.h"92#include "ui_fsmenu/scenario_select.h"
94#include "ui_fsmenu/singleplayer.h"93#include "ui_fsmenu/singleplayer.h"
95#include "wlapplication_messages.h"94#include "wlapplication_messages.h"
95#include "wlapplication_options.h"
96#include "wui/game_tips.h"96#include "wui/game_tips.h"
97#include "wui/interactive_player.h"97#include "wui/interactive_player.h"
98#include "wui/interactive_spectator.h"98#include "wui/interactive_spectator.h"
@@ -234,6 +234,11 @@
234 // We don't have a destination dir for the logger yet234 // We don't have a destination dir for the logger yet
235 std::cout << "Adding home directory: " << commandline_["homedir"].c_str() << std::endl;235 std::cout << "Adding home directory: " << commandline_["homedir"].c_str() << std::endl;
236 homedir_ = commandline_["homedir"];236 homedir_ = commandline_["homedir"];
237#ifdef USE_XDG
238 // This commandline option should probably also affect the
239 // configuration file.
240 userconfigdir_ = commandline_["homedir"];
241#endif
237 commandline_.erase("homedir");242 commandline_.erase("homedir");
238 }243 }
239244
@@ -318,6 +323,11 @@
318 should_die_(false),323 should_die_(false),
319#ifdef _WIN32324#ifdef _WIN32
320 homedir_(FileSystem::get_homedir() + "\\.widelands"),325 homedir_(FileSystem::get_homedir() + "\\.widelands"),
326#elif defined USE_XDG
327 // To enable backwards compatibility, the program name is passed with the
328 // path.
329 homedir_(FileSystem::get_userdatadir()),
330 userconfigdir_(FileSystem::get_userconfigdir()),
321#else331#else
322 homedir_(FileSystem::get_homedir() + "/.widelands"),332 homedir_(FileSystem::get_homedir() + "/.widelands"),
323#endif333#endif
@@ -347,8 +357,6 @@
347 cleanup_temp_files();357 cleanup_temp_files();
348 cleanup_temp_backups();358 cleanup_temp_backups();
349359
350 Section& config = g_options.pull_section("global");
351
352 // Start the SDL core360 // Start the SDL core
353 if (SDL_Init(SDL_INIT_VIDEO) == -1)361 if (SDL_Init(SDL_INIT_VIDEO) == -1)
354 throw wexception("Failed to initialize SDL, no valid video driver: %s", SDL_GetError());362 throw wexception("Failed to initialize SDL, no valid video driver: %s", SDL_GetError());
@@ -363,9 +371,9 @@
363 &g_gr->images(), i18n::get_locale()); // This will create the fontset, so loading it first.371 &g_gr->images(), i18n::get_locale()); // This will create the fontset, so loading it first.
364372
365 g_gr->initialize(373 g_gr->initialize(
366 config.get_bool("debug_gl_trace", false) ? Graphic::TraceGl::kYes : Graphic::TraceGl::kNo,374 get_config_bool("debug_gl_trace", false) ? Graphic::TraceGl::kYes : Graphic::TraceGl::kNo,
367 config.get_int("xres", DEFAULT_RESOLUTION_W), config.get_int("yres", DEFAULT_RESOLUTION_H),375 get_config_int("xres", DEFAULT_RESOLUTION_W), get_config_int("yres", DEFAULT_RESOLUTION_H),
368 config.get_bool("fullscreen", false));376 get_config_bool("fullscreen", false));
369377
370 g_sh = new SoundHandler();378 g_sh = new SoundHandler();
371379
@@ -385,7 +393,7 @@
385 std::srand(time(nullptr));393 std::srand(time(nullptr));
386394
387 // Make sure we didn't forget to read any global option395 // Make sure we didn't forget to read any global option
388 g_options.check_used();396 check_config_used();
389}397}
390398
391/**399/**
@@ -435,7 +443,7 @@
435 replay();443 replay();
436 } else if (game_type_ == LOADGAME) {444 } else if (game_type_ == LOADGAME) {
437 Widelands::Game game;445 Widelands::Game game;
438 game.set_ai_training_mode(g_options.pull_section("global").get_bool("ai_training", false));446 game.set_ai_training_mode(get_config_bool("ai_training", false));
439 try {447 try {
440 game.run_load_game(filename_, script_to_run_);448 game.run_load_game(filename_, script_to_run_);
441 } catch (const Widelands::GameDataError& e) {449 } catch (const Widelands::GameDataError& e) {
@@ -569,7 +577,7 @@
569 last_resolution_change_ = time;577 last_resolution_change_ = time;
570 bool value = !g_gr->fullscreen();578 bool value = !g_gr->fullscreen();
571 g_gr->set_fullscreen(value);579 g_gr->set_fullscreen(value);
572 g_options.pull_section("global").set_bool("fullscreen", value);580 set_config_bool("fullscreen", value);
573 }581 }
574 return true;582 return true;
575 }583 }
@@ -743,14 +751,12 @@
743}751}
744752
745void WLApplication::refresh_graphics() {753void WLApplication::refresh_graphics() {
746 Section& s = g_options.pull_section("global");
747
748 g_gr->change_resolution(754 g_gr->change_resolution(
749 s.get_int("xres", DEFAULT_RESOLUTION_W), s.get_int("yres", DEFAULT_RESOLUTION_H));755 get_config_int("xres", DEFAULT_RESOLUTION_W), get_config_int("yres", DEFAULT_RESOLUTION_H));
750 g_gr->set_fullscreen(s.get_bool("fullscreen", false));756 g_gr->set_fullscreen(get_config_bool("fullscreen", false));
751757
752 // does only work with a window758 // does only work with a window
753 set_input_grab(s.get_bool("inputgrab", false));759 set_input_grab(get_config_bool("inputgrab", false));
754}760}
755761
756/**762/**
@@ -760,13 +766,12 @@
760bool WLApplication::init_settings() {766bool WLApplication::init_settings() {
761767
762 // Read in the configuration file768 // Read in the configuration file
763 g_options.read(kConfigFile.c_str(), "global");769 read_config(this);
764 Section& s = g_options.pull_section("global");
765770
766 // Then parse the commandline - overwrites conffile settings771 // Then parse the commandline - overwrites conffile settings
767 handle_commandline_parameters();772 handle_commandline_parameters();
768773
769 set_mouse_swap(s.get_bool("swapmouse", false));774 set_mouse_swap(get_config_bool("swapmouse", false));
770775
771 // TODO(unknown): KLUDGE!776 // TODO(unknown): KLUDGE!
772 // Without this the following config options get dropped by check_used().777 // Without this the following config options get dropped by check_used().
@@ -774,79 +779,73 @@
774 // sensible way779 // sensible way
775780
776 // Some of the options listed here are documented in wlapplication_messages.cc781 // Some of the options listed here are documented in wlapplication_messages.cc
777 s.get_bool("ai_training");782 get_config_bool("ai_training", false);
778 s.get_bool("auto_speed");783 get_config_bool("auto_speed", false);
779 s.get_bool("fullscreen");784 get_config_bool("fullscreen", false);
780 s.get_bool("animate_map_panning");785 get_config_bool("animate_map_panning", false);
781 s.get_int("xres");786 get_config_int("xres", 0);
782 s.get_int("yres");787 get_config_int("yres", 0);
783 s.get_int("border_snap_distance");788 get_config_int("border_snap_distance", 0);
784 s.get_int("maxfps");789 get_config_int("maxfps", 0);
785 s.get_int("panel_snap_distance");790 get_config_int("panel_snap_distance", 0);
786 s.get_int("autosave");791 get_config_int("autosave", 0);
787 s.get_int("rolling_autosave");792 get_config_int("rolling_autosave", 0);
788 // Undocumented on command line, appears in game options793 // Undocumented on command line, appears in game options
789 s.get_bool("single_watchwin");794 get_config_bool("single_watchwin", false);
790 s.get_bool("auto_roadbuild_mode");795 get_config_bool("auto_roadbuild_mode", false);
791 // Undocumented on command line, appears in game options796 // Undocumented on command line, appears in game options
792 s.get_bool("nozip");797 get_config_bool("nozip", false);
793 s.get_bool("snap_windows_only_when_overlapping");798 get_config_bool("snap_windows_only_when_overlapping", false);
794 s.get_bool("dock_windows_to_edges");799 get_config_bool("dock_windows_to_edges", false);
795 s.get_bool("write_syncstreams");800 get_config_bool("write_syncstreams", false);
796 // Undocumented on command line, appears in game options801 // Undocumented on command line, appears in game options
797 s.get_bool("transparent_chat");802 get_config_bool("transparent_chat", false);
798 // Undocumented. Unique ID used to allow the metaserver to recognize players803 // Undocumented. Unique ID used to allow the metaserver to recognize players
799 s.get_string("uuid");804 get_config_string("uuid", "");
800 // Undocumented, appears in online login box805 // Undocumented, appears in online login box
801 // Whether the used metaserver login is for a registered user806 // Whether the used metaserver login is for a registered user
802 s.get_string("registered");807 get_config_string("registered", "");
803 // Undocumented, appears in online login box and LAN lobby808 // Undocumented, appears in online login box and LAN lobby
804 // The nickname used for LAN and online games809 // The nickname used for LAN and online games
805 s.get_string("nickname");810 get_config_string("nickname", "");
806 // Undocumented. The plaintext password for online logins811 // Undocumented. The plaintext password for online logins
807 // TODO(Notabilis): Remove next line after build 20.812 // TODO(Notabilis): Remove next line after build 20.
808 // Currently left in to avoid removing stored passwords for users of both build 19 and trunk813 // Currently left in to avoid removing stored passwords for users of both build 19 and trunk
809 s.get_string("password");814 get_config_string("password", "");
810 // Undocumented, appears in online login box. The hashed password for online logins815 // Undocumented, appears in online login box. The hashed password for online logins
811 s.get_string("password_sha1");816 get_config_string("password_sha1", "");
812 // Undocumented, appears in online login box. Whether to automatically use the stored login817 // Undocumented, appears in online login box. Whether to automatically use the stored login
813 s.get_string("auto_log");818 get_config_string("auto_log", "");
814 // Undocumented, appears in LAN lobby. The last host connected to819 // Undocumented, appears in LAN lobby. The last host connected to
815 s.get_string("lasthost");820 get_config_string("lasthost", "");
816 // Undocumented, appears in online lobby. The name of the last hosted game821 // Undocumented, appears in online lobby. The name of the last hosted game
817 s.get_string("servername");822 get_config_string("servername", "");
818 // Undocumented, appears in editor. Name of map author823 // Undocumented, appears in editor. Name of map author
819 s.get_string("realname");824 get_config_string("realname", "");
820 s.get_string("metaserver");825 get_config_string("metaserver", "");
821 s.get_natural("metaserverport");826 get_config_natural("metaserverport", 0);
822 // Undocumented, checkbox appears on "Watch Replay" screen827 // Undocumented, checkbox appears on "Watch Replay" screen
823 s.get_bool("display_replay_filenames");828 get_config_bool("display_replay_filenames", false);
824 s.get_bool("editor_player_menu_warn_too_many_players");829 get_config_bool("editor_player_menu_warn_too_many_players", false);
825 // KLUDGE!830 // KLUDGE!
826831
827 long int last_start = s.get_int("last_start", 0);832 long int last_start = get_config_int("last_start", 0);
828 if (last_start + 12 * 60 * 60 < time(nullptr) || !s.get_string("uuid")) {833 if (last_start + 12 * 60 * 60 < time(nullptr) || !get_config_string("uuid", "").empty()) {
829 // First start of the game or not started for 12 hours. Create a (new) UUID.834 // First start of the game or not started for 12 hours. Create a (new) UUID.
830 // For the use of the UUID, see network/internet_gaming_protocol.h835 // For the use of the UUID, see network/internet_gaming_protocol.h
831 s.set_string("uuid", generate_random_uuid());836 get_config_string("uuid", generate_random_uuid().c_str());
832 }837 }
833 s.set_int("last_start", time(nullptr));838 get_config_int("last_start", time(nullptr));
834839
835 // Replace the stored plaintext password with its SHA-1 hashed version840 // Replace the stored plaintext password with its SHA-1 hashed version
836 // Used to upgrade the stored password when upgrading widelands841 // Used to upgrade the stored password when upgrading widelands
837 if (strlen(s.get_string("password", "")) > 0 && strlen(s.get_string("password_sha1", "")) == 0) {842 if (get_config_string("password", "").length() > 0 && get_config_string("password_sha1", "").length() == 0) {
838 s.set_string("password_sha1", crypto::sha1(s.get_string("password")));843 get_config_string("password_sha1", crypto::sha1(get_config_string("password", "")).c_str());
839 }844 }
840845
841 // Save configuration now. Otherwise, the UUID is not saved846 // Save configuration now. Otherwise, the UUID is not saved
842 // when the game crashes, loosing part of its advantage847 // when the game crashes, losing part of its advantage
843 try {848 write_config(this);
844 g_options.write("config", false);
845 } catch (const std::exception& e) {
846 log("WARNING: could not save configuration: %s\n", e.what());
847 } catch (...) {
848 log("WARNING: could not save configuration");
849 }
850849
851 return true;850 return true;
852}851}
@@ -855,9 +854,6 @@
855 * Initialize language settings854 * Initialize language settings
856 */855 */
857void WLApplication::init_language() {856void WLApplication::init_language() {
858 // retrieve configuration settings
859 Section& s = g_options.pull_section("global");
860
861 // Initialize locale and grab "widelands" textdomain857 // Initialize locale and grab "widelands" textdomain
862 i18n::init_locale();858 i18n::init_locale();
863859
@@ -865,7 +861,7 @@
865 i18n::grab_textdomain("widelands");861 i18n::grab_textdomain("widelands");
866862
867 // Set locale corresponding to selected language863 // Set locale corresponding to selected language
868 std::string language = s.get_string("language", "");864 std::string language = get_config_string("language", "");
869 i18n::set_locale(language);865 i18n::set_locale(language);
870}866}
871867
@@ -876,13 +872,7 @@
876 // To be proper, release our textdomain872 // To be proper, release our textdomain
877 i18n::release_textdomain();873 i18n::release_textdomain();
878874
879 try { // overwrite the old config file875 write_config(this);
880 g_options.write(kConfigFile.c_str(), true);
881 } catch (const std::exception& e) {
882 log("WARNING: could not save configuration: %s\n", e.what());
883 } catch (...) {
884 log("WARNING: could not save configuration");
885 }
886}876}
887877
888void WLApplication::shutdown_hardware() {878void WLApplication::shutdown_hardware() {
@@ -962,7 +952,7 @@
962 commandline_.erase("nosound");952 commandline_.erase("nosound");
963 }953 }
964 if (commandline_.count("nozip")) {954 if (commandline_.count("nozip")) {
965 g_options.pull_section("global").create_val("nozip", "true");955 set_config_bool("nozip", true);
966 commandline_.erase("nozip");956 commandline_.erase("nozip");
967 }957 }
968958
@@ -973,6 +963,16 @@
973 datadir_ = is_absolute_path(INSTALL_DATADIR) ?963 datadir_ = is_absolute_path(INSTALL_DATADIR) ?
974 INSTALL_DATADIR :964 INSTALL_DATADIR :
975 get_executable_directory() + FileSystem::file_separator() + INSTALL_DATADIR;965 get_executable_directory() + FileSystem::file_separator() + INSTALL_DATADIR;
966#ifdef USE_XDG
967 // Overwrite with first folder found in XDG_DATA_DIRS
968 for (const auto& datadir: FileSystem::get_xdgdatadirs()) {
969 RealFSImpl dir(datadir);
970 if (dir.is_directory(datadir + "/widelands")) {
971 datadir_ = datadir + "/widelands";
972 break;
973 }
974 }
975#endif
976 }976 }
977 if (!is_absolute_path(datadir_)) {977 if (!is_absolute_path(datadir_)) {
978 try {978 try {
@@ -1046,17 +1046,17 @@
10461046
1047 // Following is used for training of AI1047 // Following is used for training of AI
1048 if (commandline_.count("ai_training")) {1048 if (commandline_.count("ai_training")) {
1049 g_options.pull_section("global").create_val("ai_training", "true");1049 set_config_bool("ai_training", true);
1050 commandline_.erase("ai_training");1050 commandline_.erase("ai_training");
1051 } else {1051 } else {
1052 g_options.pull_section("global").create_val("ai_training", "false");1052 set_config_bool("ai_training", false);
1053 }1053 }
10541054
1055 if (commandline_.count("auto_speed")) {1055 if (commandline_.count("auto_speed")) {
1056 g_options.pull_section("global").create_val("auto_speed", "true");1056 set_config_bool("auto_speed", true);
1057 commandline_.erase("auto_speed");1057 commandline_.erase("auto_speed");
1058 } else {1058 } else {
1059 g_options.pull_section("global").create_val("auto_speed", "false");1059 set_config_bool("auto_speed", false);
1060 }1060 }
10611061
1062 // If it hasn't been handled yet it's probably an attempt to1062 // If it hasn't been handled yet it's probably an attempt to
@@ -1070,7 +1070,7 @@
1070 // TODO(unknown): barf here on unknown option; the list of known options1070 // TODO(unknown): barf here on unknown option; the list of known options
1071 // needs to be centralized1071 // needs to be centralized
10721072
1073 g_options.pull_section("global").create_val(it->first.c_str(), it->second.c_str());1073 set_config_string(it->first.c_str(), it->second.c_str());
1074 }1074 }
10751075
1076 if (commandline_.count("help") || commandline_.count("version")) {1076 if (commandline_.count("help") || commandline_.count("version")) {
@@ -1118,7 +1118,7 @@
1118 replay();1118 replay();
1119 break;1119 break;
1120 case FullscreenMenuBase::MenuTarget::kOptions: {1120 case FullscreenMenuBase::MenuTarget::kOptions: {
1121 Section& s = g_options.pull_section("global");1121 Section& s = get_config_section();
1122 OptionsCtrl om(s);1122 OptionsCtrl om(s);
1123 break;1123 break;
1124 }1124 }
@@ -1248,11 +1248,10 @@
1248 std::string password(mp.get_password());1248 std::string password(mp.get_password());
1249 bool registered = mp.registered();1249 bool registered = mp.registered();
12501250
1251 Section& s = g_options.pull_section("global");1251 get_config_string("nickname", playername);
1252 s.set_string("nickname", playername);
1253 // Only change the password if we use a registered account1252 // Only change the password if we use a registered account
1254 if (registered) {1253 if (registered) {
1255 s.set_string("password_sha1", password);1254 get_config_string("password_sha1", password);
1256 }1255 }
12571256
1258 // reinitalise in every run, else graphics look strange1257 // reinitalise in every run, else graphics look strange
@@ -1318,7 +1317,7 @@
13181317
1319 Widelands::Game game;1318 Widelands::Game game;
13201319
1321 game.set_ai_training_mode(g_options.pull_section("global").get_bool("ai_training", false));1320 game.set_ai_training_mode(get_config_bool("ai_training", false));
13221321
1323 if (code == FullscreenMenuBase::MenuTarget::kScenarioGame) { // scenario1322 if (code == FullscreenMenuBase::MenuTarget::kScenarioGame) { // scenario
1324 try {1323 try {
@@ -1333,7 +1332,7 @@
1333 try {1332 try {
1334 // Game controller needs the ibase pointer to init1333 // Game controller needs the ibase pointer to init
1335 // the chat1334 // the chat
1336 game.set_ibase(new InteractivePlayer(game, g_options.pull_section("global"), pn, false));1335 game.set_ibase(new InteractivePlayer(game, get_config_section(), pn, false));
1337 std::unique_ptr<GameController> ctrl(new SinglePlayerGameController(game, true, pn));1336 std::unique_ptr<GameController> ctrl(new SinglePlayerGameController(game, true, pn));
1338 UI::ProgressWindow loader_ui;1337 UI::ProgressWindow loader_ui;
1339 std::vector<std::string> tipstext;1338 std::vector<std::string> tipstext;
@@ -1370,7 +1369,7 @@
1370 Widelands::Game game;1369 Widelands::Game game;
1371 std::string filename;1370 std::string filename;
13721371
1373 game.set_ai_training_mode(g_options.pull_section("global").get_bool("ai_training", false));1372 game.set_ai_training_mode(get_config_bool("ai_training", false));
1374 SinglePlayerGameSettingsProvider sp;1373 SinglePlayerGameSettingsProvider sp;
1375 FullscreenMenuLoadGame ssg(game, &sp);1374 FullscreenMenuLoadGame ssg(game, &sp);
13761375
@@ -1457,7 +1456,7 @@
14571456
1458 loader_ui.step(_("Loading…"));1457 loader_ui.step(_("Loading…"));
14591458
1460 game.set_ibase(new InteractiveSpectator(game, g_options.pull_section("global")));1459 game.set_ibase(new InteractiveSpectator(game, get_config_section()));
1461 game.set_write_replay(false);1460 game.set_write_replay(false);
1462 ReplayGameController rgc(game, filename_);1461 ReplayGameController rgc(game, filename_);
14631462
14641463
=== modified file 'src/wlapplication.h'
--- src/wlapplication.h 2019-02-23 11:00:49 +0000
+++ src/wlapplication.h 2019-08-27 19:00:46 +0000
@@ -196,6 +196,13 @@
196 void replay();196 void replay();
197 static void emergency_save(Widelands::Game&);197 static void emergency_save(Widelands::Game&);
198198
199#ifdef USE_XDG
200 // this is only for src/wlapplication_options.cc
201 std::string get_userconfigdir() {
202 return userconfigdir_;
203 }
204#endif
205
199private:206private:
200 WLApplication(int argc, char const* const* argv);207 WLApplication(int argc, char const* const* argv);
201208
@@ -259,6 +266,9 @@
259 bool should_die_;266 bool should_die_;
260267
261 std::string homedir_;268 std::string homedir_;
269#ifdef USE_XDG
270 std::string userconfigdir_;
271#endif
262272
263 /// flag indicating if stdout and stderr have been redirected273 /// flag indicating if stdout and stderr have been redirected
264 bool redirected_stdio_;274 bool redirected_stdio_;
265275
=== added file 'src/wlapplication_options.cc'
--- src/wlapplication_options.cc 1970-01-01 00:00:00 +0000
+++ src/wlapplication_options.cc 2019-08-27 19:00:46 +0000
@@ -0,0 +1,151 @@
1/*
2 * Copyright (C) 2012-2019 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#include "wlapplication_options.h"
21
22#include "base/log.h"
23#include "io/filesystem/disk_filesystem.h"
24#include "io/profile.h"
25#include "logic/filesystem_constants.h"
26#include "wlapplication.h"
27
28Profile g_options(Profile::err_log);
29
30void check_config_used() {
31 g_options.check_used();
32}
33
34Section& get_config_section() {
35 return g_options.pull_section("global");
36}
37
38Section& get_config_section(const std::string& section) {
39 return g_options.pull_section(section.c_str());
40}
41
42Section* get_config_section_ptr(const std::string& section) {
43 return g_options.get_section(section.c_str());
44}
45
46bool get_config_bool(const std::string& name, const bool dflt) {
47 return g_options.pull_section("global").get_bool(name.c_str(), dflt);
48}
49
50bool get_config_bool(const std::string& section,
51 const std::string& name,
52 const bool dflt) {
53 return g_options.pull_section(section.c_str()).get_bool(name.c_str(), dflt);
54}
55
56int32_t get_config_int(const std::string& name, const int32_t dflt) {
57 return g_options.pull_section("global").get_int(name.c_str(), dflt);
58}
59
60int32_t get_config_int(const std::string& section,
61 const std::string& name,
62 const int32_t dflt) {
63 return g_options.pull_section(section.c_str()).get_int(name.c_str(), dflt);
64}
65
66uint32_t get_config_natural(const std::string& name, const uint32_t dflt) {
67 return g_options.pull_section("global").get_natural(name.c_str(), dflt);
68}
69
70uint32_t get_config_natural(const std::string& section,
71 const std::string& name,
72 uint32_t dflt) {
73 return g_options.pull_section(section.c_str()).get_natural(name.c_str(), dflt);
74}
75
76std::string get_config_string(const std::string& name,
77 const std::string& dflt) {
78 return g_options.pull_section("global").get_string(name.c_str(), dflt.c_str());
79}
80
81std::string get_config_string(const std::string& section,
82 const std::string& name,
83 const std::string& dflt) {
84 return g_options.pull_section(section.c_str()).get_string(name.c_str(), dflt.c_str());
85}
86
87Section& get_config_safe_section() {
88 return g_options.get_safe_section("global");
89}
90
91Section& get_config_safe_section(const std::string& section) {
92 return g_options.get_safe_section(section.c_str());
93}
94
95void set_config_bool(const std::string& name, const bool value) {
96 g_options.pull_section("global").set_bool(name.c_str(), value);
97}
98
99void set_config_bool(const std::string& section,
100 const std::string& name,
101 const bool value) {
102 g_options.pull_section(section.c_str()).set_bool(name.c_str(), value);
103}
104
105void set_config_int(const std::string& name, int32_t value) {
106 g_options.pull_section("global").set_int(name.c_str(), value);
107}
108
109void set_config_int(const std::string& section,
110 const std::string& name,
111 const int32_t value) {
112 g_options.pull_section(section.c_str()).set_int(name.c_str(), value);
113}
114
115void set_config_string(const std::string& name, const std::string& value) {
116 g_options.pull_section("global").set_string(name.c_str(), value.c_str());
117}
118
119void set_config_string(const std::string& section,
120 const std::string& name,
121 const std::string& value) {
122 g_options.pull_section(section.c_str()).set_string(name.c_str(), value.c_str());
123}
124
125void read_config(WLApplication* wlapplication) {
126#ifdef USE_XDG
127 RealFSImpl dir(wlapplication->get_userconfigdir());
128 dir.ensure_directory_exists(".");
129 log("Set configuration file: %s/%s\n",
130 wlapplication->get_userconfigdir().c_str(),
131 kConfigFile.c_str());
132 g_options.read(kConfigFile.c_str(), "global", dir);
133#else
134 g_options.read(kConfigFile.c_str(), "global");
135#endif
136}
137
138void write_config(WLApplication* wlapplication) {
139 try { // overwrite the old config file
140#ifdef USE_XDG
141 RealFSImpl dir(wlapplication->get_userconfigdir());
142 g_options.write(kConfigFile.c_str(), true, dir);
143#else
144 g_options.write(kConfigFile.c_str(), true);
145#endif
146 } catch (const std::exception& e) {
147 log("WARNING: could not save configuration: %s\n", e.what());
148 } catch (...) {
149 log("WARNING: could not save configuration");
150 }
151}
0152
=== added file 'src/wlapplication_options.h'
--- src/wlapplication_options.h 1970-01-01 00:00:00 +0000
+++ src/wlapplication_options.h 2019-08-27 19:00:46 +0000
@@ -0,0 +1,118 @@
1/*
2 * Copyright (C) 2012-2019 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#ifndef WL_WLAPPLICATION_OPTIONS_H
21#define WL_WLAPPLICATION_OPTIONS_H
22
23#include "io/profile.h"
24#include "wlapplication.h"
25
26/*
27 * Further explanations for all functions and its return values
28 * can be found in io/profile.cc
29 */
30class Section;
31
32/*
33 * Check if all options has been read.
34 */
35void check_config_used();
36
37/*
38 * Get config values from the config settings cache.
39 * If the section parameter is omitted the global section will be used.
40 * Values are available after read_config() is called.
41 */
42Section& get_config_section();
43Section& get_config_section(const std::string&);
44Section* get_config_section_ptr(const std::string&);
45bool get_config_bool(const std::string& name, bool dflt);
46bool get_config_bool(const std::string& section,
47 const std::string& name,
48 const bool dflt);
49int32_t get_config_int(const std::string& name, const int32_t dflt = 0);
50int32_t get_config_int(const std::string& section,
51 const std::string& name,
52 const int32_t dflt);
53uint32_t get_config_natural(const std::string& name, uint32_t dflt);
54uint32_t get_config_natural(const std::string& section,
55 const std::string& name,
56 const uint32_t dflt);
57std::string get_config_string(const std::string& name,
58 const std::string& dflt);
59std::string get_config_string(const std::string& section,
60 const std::string& name,
61 const std::string& dflt);
62
63/*
64 * Get config values from the config settings cache.
65 * Throws an exception if the value doesn't exist.
66 * If the section parameter is omitted the global section will be used.
67 * Values are available after read_config() is called.
68 */
69Section& get_config_safe_section();
70Section& get_config_safe_section(const std::string&);
71
72/*
73 * Set config values to the config settings cache.
74 * If the section parameter is omitted the global section will be used.
75 * Values will be written to the config file once write_config() is called.
76 */
77void set_config_bool(const std::string& name, bool value);
78void set_config_bool(const std::string& section,
79 const std::string& name,
80 bool value);
81void set_config_int(const std::string& name, int32_t value);
82void set_config_int(const std::string& section,
83 const std::string& name,
84 const int32_t value);
85void set_config_string(const std::string& name, const std::string& value);
86void set_config_string(const std::string& section,
87 const std::string& name,
88 const std::string& value);
89
90/*
91 * Reads the configuration from kConfigFile.
92 * Defaults to $XDG_CONFIG_HOME/widelands/config on Unix.
93 * Defaults to homedir/config everywhere else, if homedir is set manually or if
94 * built without XDG-support.
95 *
96 * This function needs access to the WLApplication object to distinguish
97 * between multiple possible states.
98 * While we could use WLApplication::get() this would get us in an infinite loop
99 * because this function will be called in the constructor of said object and
100 * WLApplication::get() spawns another object if there isn't one yet.
101 */
102void read_config(WLApplication*);
103
104/*
105 * Writes the configuration to kConfigFile.
106 * Defaults to $XDG_CONFIG_HOME/widelands/config on Unix.
107 * Defaults to homedir/config everywhere else, if homedir is set manually or if
108 * built without XDG-support.
109 *
110 * This function needs access to the WLApplication object to distinguish
111 * between multiple possible states.
112 * While we could use WLApplication::get() this would get us in an infinite loop
113 * because this function will be called in the constructor of said object and
114 * WLApplication::get() spawns another object if there isn't one yet.
115 */
116void write_config(WLApplication*);
117
118#endif // end of include guard: WL_WLAPPLICATION_OPTIONS_H
0119
=== modified file 'src/wui/CMakeLists.txt'
--- src/wui/CMakeLists.txt 2019-07-11 08:38:29 +0000
+++ src/wui/CMakeLists.txt 2019-08-27 19:00:46 +0000
@@ -31,9 +31,9 @@
31 graphic_text31 graphic_text
32 graphic_text_layout32 graphic_text_layout
33 logic33 logic
34 profile
35 sound34 sound
36 ui_basic35 ui_basic
36 widelands_ball_of_mud
37 wui37 wui
38)38)
3939
@@ -49,7 +49,7 @@
49 logic_filesystem_constants49 logic_filesystem_constants
50 logic_map_objects50 logic_map_objects
51 notifications51 notifications
52 profile52 io_profile
53 ui_basic53 ui_basic
54 wui_waresdisplay54 wui_waresdisplay
55)55)
@@ -152,7 +152,6 @@
152 graphic_game_renderer152 graphic_game_renderer
153 logic_map153 logic_map
154 logic_widelands_geometry154 logic_widelands_geometry
155 profile
156 ui_basic155 ui_basic
157 widelands_ball_of_mud156 widelands_ball_of_mud
158 wui_mapview_pixelfunctions157 wui_mapview_pixelfunctions
@@ -294,6 +293,7 @@
294 graphic_toolbar_imageset293 graphic_toolbar_imageset
295 io_fileread294 io_fileread
296 io_filesystem295 io_filesystem
296 io_profile
297 logic297 logic
298 logic_constants298 logic_constants
299 logic_commands299 logic_commands
@@ -309,12 +309,12 @@
309 network309 network
310 note_sound310 note_sound
311 notifications311 notifications
312 profile
313 scripting_coroutine312 scripting_coroutine
314 scripting_lua_interface313 scripting_lua_interface
315 scripting_lua_table314 scripting_lua_table
316 sound315 sound
317 ui_basic316 ui_basic
317 widelands_ball_of_mud
318 wui_chat_ui318 wui_chat_ui
319 wui_common_gamedetails319 wui_common_gamedetails
320 wui_economy_options320 wui_economy_options
321321
=== modified file 'src/wui/chat_overlay.cc'
--- src/wui/chat_overlay.cc 2019-05-26 17:21:15 +0000
+++ src/wui/chat_overlay.cc 2019-08-27 19:00:46 +0000
@@ -31,7 +31,7 @@
31#include "graphic/rendertarget.h"31#include "graphic/rendertarget.h"
32#include "graphic/style_manager.h"32#include "graphic/style_manager.h"
33#include "graphic/text/rt_errors.h"33#include "graphic/text/rt_errors.h"
34#include "profile/profile.h"34#include "wlapplication_options.h"
35#include "wui/chat_msg_layout.h"35#include "wui/chat_msg_layout.h"
36#include "wui/logmessage.h"36#include "wui/logmessage.h"
3737
@@ -85,8 +85,7 @@
85ChatOverlay::ChatOverlay(85ChatOverlay::ChatOverlay(
86 UI::Panel* const parent, int32_t const x, int32_t const y, int32_t const w, int32_t const h)86 UI::Panel* const parent, int32_t const x, int32_t const y, int32_t const w, int32_t const h)
87 : UI::Panel(parent, x, y, w, h), m(new Impl()) {87 : UI::Panel(parent, x, y, w, h), m(new Impl()) {
88 Section& s = g_options.pull_section("global");88 m->transparent_ = get_config_bool("transparent_chat", true);
89 m->transparent_ = s.get_bool("transparent_chat", true);
9089
91 set_thinks(true);90 set_thinks(true);
92}91}
9392
=== modified file 'src/wui/economy_options_window.cc'
--- src/wui/economy_options_window.cc 2019-08-13 11:22:26 +0000
+++ src/wui/economy_options_window.cc 2019-08-27 19:00:46 +0000
@@ -24,13 +24,13 @@
24#include <boost/lexical_cast.hpp>24#include <boost/lexical_cast.hpp>
2525
26#include "graphic/graphic.h"26#include "graphic/graphic.h"
27#include "io/profile.h"
27#include "logic/editor_game_base.h"28#include "logic/editor_game_base.h"
28#include "logic/filesystem_constants.h"29#include "logic/filesystem_constants.h"
29#include "logic/map_objects/tribes/ware_descr.h"30#include "logic/map_objects/tribes/ware_descr.h"
30#include "logic/map_objects/tribes/worker_descr.h"31#include "logic/map_objects/tribes/worker_descr.h"
31#include "logic/player.h"32#include "logic/player.h"
32#include "logic/playercommand.h"33#include "logic/playercommand.h"
33#include "profile/profile.h"
34#include "ui_basic/messagebox.h"34#include "ui_basic/messagebox.h"
3535
36static const char pic_tab_wares[] = "images/wui/buildings/menu_tab_wares.png";36static const char pic_tab_wares[] = "images/wui/buildings/menu_tab_wares.png";
3737
=== modified file 'src/wui/game_main_menu_save_game.cc'
--- src/wui/game_main_menu_save_game.cc 2019-04-18 08:32:25 +0000
+++ src/wui/game_main_menu_save_game.cc 2019-08-27 19:00:46 +0000
@@ -36,6 +36,7 @@
36#include "logic/generic_save_handler.h"36#include "logic/generic_save_handler.h"
37#include "logic/playersmanager.h"37#include "logic/playersmanager.h"
38#include "ui_basic/messagebox.h"38#include "ui_basic/messagebox.h"
39#include "wlapplication_options.h"
39#include "wui/interactive_gamebase.h"40#include "wui/interactive_gamebase.h"
4041
41InteractiveGameBase& GameMainMenuSaveGame::igbase() {42InteractiveGameBase& GameMainMenuSaveGame::igbase() {
@@ -162,7 +163,7 @@
162 }163 }
163164
164 std::string filename = filename_editbox_.text();165 std::string filename = filename_editbox_.text();
165 if (save_game(filename, !g_options.pull_section("global").get_bool("nozip", false))) {166 if (save_game(filename, !get_config_bool("nozip", false))) {
166 die();167 die();
167 } else {168 } else {
168 load_or_save_.table_.focus();169 load_or_save_.table_.focus();
169170
=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc 2019-08-10 16:38:15 +0000
+++ src/wui/interactive_base.cc 2019-08-27 19:00:46 +0000
@@ -45,7 +45,6 @@
45#include "logic/maptriangleregion.h"45#include "logic/maptriangleregion.h"
46#include "logic/player.h"46#include "logic/player.h"
47#include "logic/widelands_geometry.h"47#include "logic/widelands_geometry.h"
48#include "profile/profile.h"
49#include "scripting/lua_interface.h"48#include "scripting/lua_interface.h"
50#include "sound/sound_handler.h"49#include "sound/sound_handler.h"
51#include "wui/game_chat_menu.h"50#include "wui/game_chat_menu.h"
5251
=== modified file 'src/wui/interactive_base.h'
--- src/wui/interactive_base.h 2019-08-10 16:38:15 +0000
+++ src/wui/interactive_base.h 2019-08-27 19:00:46 +0000
@@ -26,10 +26,10 @@
26#include <SDL_keycode.h>26#include <SDL_keycode.h>
2727
28#include "graphic/toolbar_imageset.h"28#include "graphic/toolbar_imageset.h"
29#include "io/profile.h"
29#include "logic/editor_game_base.h"30#include "logic/editor_game_base.h"
30#include "logic/map.h"31#include "logic/map.h"
31#include "notifications/notifications.h"32#include "notifications/notifications.h"
32#include "profile/profile.h"
33#include "sound/note_sound.h"33#include "sound/note_sound.h"
34#include "ui_basic/box.h"34#include "ui_basic/box.h"
35#include "ui_basic/dropdown.h"35#include "ui_basic/dropdown.h"
3636
=== modified file 'src/wui/interactive_gamebase.cc'
--- src/wui/interactive_gamebase.cc 2019-08-13 11:12:56 +0000
+++ src/wui/interactive_gamebase.cc 2019-08-27 19:00:46 +0000
@@ -34,7 +34,6 @@
34#include "logic/map_objects/tribes/ship.h"34#include "logic/map_objects/tribes/ship.h"
35#include "logic/player.h"35#include "logic/player.h"
36#include "network/gamehost.h"36#include "network/gamehost.h"
37#include "profile/profile.h"
38#include "wui/constructionsitewindow.h"37#include "wui/constructionsitewindow.h"
39#include "wui/dismantlesitewindow.h"38#include "wui/dismantlesitewindow.h"
40#include "wui/game_chat_menu.h"39#include "wui/game_chat_menu.h"
4140
=== modified file 'src/wui/interactive_gamebase.h'
--- src/wui/interactive_gamebase.h 2019-08-10 16:38:15 +0000
+++ src/wui/interactive_gamebase.h 2019-08-27 19:00:46 +0000
@@ -23,8 +23,8 @@
23#include <map>23#include <map>
24#include <memory>24#include <memory>
2525
26#include "io/profile.h"
26#include "logic/game.h"27#include "logic/game.h"
27#include "profile/profile.h"
28#include "ui_basic/dropdown.h"28#include "ui_basic/dropdown.h"
29#include "ui_basic/unique_window.h"29#include "ui_basic/unique_window.h"
30#include "wui/general_statistics_menu.h"30#include "wui/general_statistics_menu.h"
3131
=== modified file 'src/wui/interactive_player.cc'
--- src/wui/interactive_player.cc 2019-08-13 11:12:56 +0000
+++ src/wui/interactive_player.cc 2019-08-27 19:00:46 +0000
@@ -39,7 +39,6 @@
39#include "logic/map_objects/tribes/tribe_descr.h"39#include "logic/map_objects/tribes/tribe_descr.h"
40#include "logic/message_queue.h"40#include "logic/message_queue.h"
41#include "logic/player.h"41#include "logic/player.h"
42#include "profile/profile.h"
43#include "ui_basic/unique_window.h"42#include "ui_basic/unique_window.h"
44#include "wui/building_statistics_menu.h"43#include "wui/building_statistics_menu.h"
45#include "wui/debugconsole.h"44#include "wui/debugconsole.h"
4645
=== modified file 'src/wui/interactive_player.h'
--- src/wui/interactive_player.h 2019-08-10 16:38:15 +0000
+++ src/wui/interactive_player.h 2019-08-27 19:00:46 +0000
@@ -25,9 +25,9 @@
2525
26#include <SDL_keyboard.h>26#include <SDL_keyboard.h>
2727
28#include "io/profile.h"
28#include "logic/message_id.h"29#include "logic/message_id.h"
29#include "logic/note_map_options.h"30#include "logic/note_map_options.h"
30#include "profile/profile.h"
31#include "ui_basic/button.h"31#include "ui_basic/button.h"
32#include "wui/interactive_gamebase.h"32#include "wui/interactive_gamebase.h"
3333
3434
=== modified file 'src/wui/interactive_spectator.cc'
--- src/wui/interactive_spectator.cc 2019-04-26 06:35:15 +0000
+++ src/wui/interactive_spectator.cc 2019-08-27 19:00:46 +0000
@@ -24,7 +24,6 @@
24#include "chat/chat.h"24#include "chat/chat.h"
25#include "logic/game_controller.h"25#include "logic/game_controller.h"
26#include "logic/player.h"26#include "logic/player.h"
27#include "profile/profile.h"
28#include "ui_basic/textarea.h"27#include "ui_basic/textarea.h"
29#include "ui_basic/unique_window.h"28#include "ui_basic/unique_window.h"
30#include "wui/fieldaction.h"29#include "wui/fieldaction.h"
3130
=== modified file 'src/wui/interactive_spectator.h'
--- src/wui/interactive_spectator.h 2019-04-26 06:35:15 +0000
+++ src/wui/interactive_spectator.h 2019-08-27 19:00:46 +0000
@@ -22,7 +22,7 @@
2222
23#include <SDL_keyboard.h>23#include <SDL_keyboard.h>
2424
25#include "profile/profile.h"25#include "io/profile.h"
26#include "ui_basic/button.h"26#include "ui_basic/button.h"
27#include "wui/interactive_gamebase.h"27#include "wui/interactive_gamebase.h"
2828
2929
=== modified file 'src/wui/login_box.cc'
--- src/wui/login_box.cc 2019-06-01 11:29:24 +0000
+++ src/wui/login_box.cc 2019-08-27 19:00:46 +0000
@@ -23,9 +23,9 @@
23#include "graphic/font_handler.h"23#include "graphic/font_handler.h"
24#include "network/crypto.h"24#include "network/crypto.h"
25#include "network/internet_gaming.h"25#include "network/internet_gaming.h"
26#include "profile/profile.h"
27#include "ui_basic/button.h"26#include "ui_basic/button.h"
28#include "ui_basic/messagebox.h"27#include "ui_basic/messagebox.h"
28#include "wlapplication_options.h"
2929
30LoginBox::LoginBox(Panel& parent)30LoginBox::LoginBox(Panel& parent)
31 : Window(&parent, "login_box", 0, 0, 500, 280, _("Online Game Settings")) {31 : Window(&parent, "login_box", 0, 0, 500, 280, _("Online Game Settings")) {
@@ -67,13 +67,12 @@
67 eb_nickname->changed.connect(boost::bind(&LoginBox::change_playername, this));67 eb_nickname->changed.connect(boost::bind(&LoginBox::change_playername, this));
68 cb_register->clickedto.connect(boost::bind(&LoginBox::clicked_register, this));68 cb_register->clickedto.connect(boost::bind(&LoginBox::clicked_register, this));
6969
70 Section& s = g_options.pull_section("global");70 eb_nickname->set_text(get_config_string("nickname", _("nobody")));
71 eb_nickname->set_text(s.get_string("nickname", _("nobody")));71 cb_register->set_state(get_config_bool("registered", false));
72 cb_register->set_state(s.get_bool("registered", false));
73 eb_password->set_password(true);72 eb_password->set_password(true);
7473
75 if (registered()) {74 if (registered()) {
76 eb_password->set_text(s.get_string("password_sha1", ""));75 eb_password->set_text(get_config_string("password_sha1", ""));
77 loginbtn->set_enabled(false);76 loginbtn->set_enabled(false);
78 } else {77 } else {
79 eb_password->set_can_focus(false);78 eb_password->set_can_focus(false);
@@ -92,17 +91,16 @@
92 * called, if "login" is pressed.91 * called, if "login" is pressed.
93 */92 */
94void LoginBox::clicked_ok() {93void LoginBox::clicked_ok() {
95 Section& s = g_options.pull_section("global");
96 if (cb_register->get_state()) {94 if (cb_register->get_state()) {
97 if (check_password()) {95 if (check_password()) {
98 s.set_string("nickname", eb_nickname->text());96 set_config_string("nickname", eb_nickname->text());
99 s.set_bool("registered", true);97 set_config_bool("registered", true);
100 end_modal<UI::Panel::Returncodes>(UI::Panel::Returncodes::kOk);98 end_modal<UI::Panel::Returncodes>(UI::Panel::Returncodes::kOk);
101 }99 }
102 } else {100 } else {
103 s.set_string("nickname", eb_nickname->text());101 set_config_string("nickname", eb_nickname->text());
104 s.set_bool("registered", false);102 set_config_bool("registered", false);
105 s.set_string("password_sha1", "");103 set_config_string("password_sha1", "");
106 end_modal<UI::Panel::Returncodes>(UI::Panel::Returncodes::kOk);104 end_modal<UI::Panel::Returncodes>(UI::Panel::Returncodes::kOk);
107 }105 }
108}106}
@@ -171,12 +169,11 @@
171 loginbtn->set_enabled(false);169 loginbtn->set_enabled(false);
172 }170 }
173171
174 Section& s = g_options.pull_section("global");172 if (eb_password->has_focus() && eb_password->text() == get_config_string("password_sha1", "")) {
175 if (eb_password->has_focus() && eb_password->text() == s.get_string("password_sha1", "")) {
176 eb_password->set_text("");173 eb_password->set_text("");
177 }174 }
178175
179 if (cb_register->get_state() && eb_password->text() == s.get_string("password_sha1", "")) {176 if (cb_register->get_state() && eb_password->text() == get_config_string("password_sha1", "")) {
180 loginbtn->set_enabled(false);177 loginbtn->set_enabled(false);
181 }178 }
182}179}
@@ -184,9 +181,8 @@
184/// Check password against metaserver181/// Check password against metaserver
185bool LoginBox::check_password() {182bool LoginBox::check_password() {
186 // Try to connect to the metaserver183 // Try to connect to the metaserver
187 Section& s = g_options.pull_section("global");184 const std::string& meta = get_config_string("metaserver", INTERNET_GAMING_METASERVER.c_str());
188 const std::string& meta = s.get_string("metaserver", INTERNET_GAMING_METASERVER.c_str());185 uint32_t port = get_config_natural("metaserverport", kInternetGamingPort);
189 uint32_t port = s.get_natural("metaserverport", kInternetGamingPort);
190 std::string password = crypto::sha1(eb_password->text());186 std::string password = crypto::sha1(eb_password->text());
191187
192 if (!InternetGaming::ref().check_password(get_nickname(), password, meta, port)) {188 if (!InternetGaming::ref().check_password(get_nickname(), password, meta, port)) {
@@ -208,7 +204,7 @@
208 // be copied to another system and used to log in as the user on the metaserver. Further note:204 // be copied to another system and used to log in as the user on the metaserver. Further note:
209 // SHA-1 is considered broken and shouldn't be used anymore. But since the passwords on the205 // SHA-1 is considered broken and shouldn't be used anymore. But since the passwords on the
210 // server are protected by SHA-1 we have to use it here, too206 // server are protected by SHA-1 we have to use it here, too
211 s.set_string("password_sha1", password);207 set_config_string("password_sha1", password);
212 InternetGaming::ref().logout();208 InternetGaming::ref().logout();
213 return true;209 return true;
214}210}
215211
=== modified file 'src/wui/mapview.cc'
--- src/wui/mapview.cc 2019-08-10 16:38:15 +0000
+++ src/wui/mapview.cc 2019-08-27 19:00:46 +0000
@@ -24,8 +24,8 @@
24#include "base/macros.h"24#include "base/macros.h"
25#include "base/math.h"25#include "base/math.h"
26#include "graphic/rendertarget.h"26#include "graphic/rendertarget.h"
27#include "profile/profile.h"
28#include "wlapplication.h"27#include "wlapplication.h"
28#include "wlapplication_options.h"
29#include "wui/mapviewpixelfunctions.h"29#include "wui/mapviewpixelfunctions.h"
3030
31namespace {31namespace {
@@ -296,7 +296,7 @@
296MapView::MapView(296MapView::MapView(
297 UI::Panel* parent, const Widelands::Map& map, int32_t x, int32_t y, uint32_t w, uint32_t h)297 UI::Panel* parent, const Widelands::Map& map, int32_t x, int32_t y, uint32_t w, uint32_t h)
298 : UI::Panel(parent, x, y, w, h),298 : UI::Panel(parent, x, y, w, h),
299 animate_map_panning_(g_options.pull_section("global").get_bool("animate_map_panning", true)),299 animate_map_panning_(get_config_bool("animate_map_panning", true)),
300 map_(map),300 map_(map),
301 view_(),301 view_(),
302 last_mouse_pos_(Vector2i::zero()),302 last_mouse_pos_(Vector2i::zero()),
303303
=== modified file 'src/wui/watchwindow.cc'
--- src/wui/watchwindow.cc 2019-04-26 06:35:15 +0000
+++ src/wui/watchwindow.cc 2019-08-27 19:00:46 +0000
@@ -30,7 +30,7 @@
30#include "logic/map.h"30#include "logic/map.h"
31#include "logic/map_objects/bob.h"31#include "logic/map_objects/bob.h"
32#include "logic/player.h"32#include "logic/player.h"
33#include "profile/profile.h"33#include "wlapplication_options.h"
34#include "wui/interactive_gamebase.h"34#include "wui/interactive_gamebase.h"
35#include "wui/interactive_player.h"35#include "wui/interactive_player.h"
36#include "wui/mapviewpixelconstants.h"36#include "wui/mapviewpixelconstants.h"
@@ -305,7 +305,7 @@
305===============305===============
306*/306*/
307WatchWindow* show_watch_window(InteractiveGameBase& parent, const Widelands::Coords& coords) {307WatchWindow* show_watch_window(InteractiveGameBase& parent, const Widelands::Coords& coords) {
308 if (g_options.pull_section("global").get_bool("single_watchwin", false)) {308 if (get_config_bool("single_watchwin", false)) {
309 if (!g_watch_window) {309 if (!g_watch_window) {
310 g_watch_window = new WatchWindow(parent, 250, 150, 200, 200, true);310 g_watch_window = new WatchWindow(parent, 250, 150, 200, 200, true);
311 }311 }

Subscribers

People subscribed via source and target branches

to status/vote changes: