Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USE_HOME_FOR_STATE_DIR option added #490

Merged
merged 1 commit into from Nov 5, 2018
Merged

USE_HOME_FOR_STATE_DIR option added #490

merged 1 commit into from Nov 5, 2018

Conversation

ghost
Copy link

@ghost ghost commented Oct 6, 2018

USE_HOME_FOR_STATE_DIR option was added to CMakeLists.txt.

Fully consistent with my pull request to nixpkgs upstream.

@ghost ghost mentioned this pull request Oct 6, 2018
Copy link
Contributor

@AquariusPower AquariusPower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good,

so cmake option can have the same identifier used as cxxflag? I mean, it wont conflict or cause confusion right?

now looking at GetStateDir() I guess the generated code will have 2 returns when that flag is used and it didnt cause a compilation warning for all platforms by travis-ci. As at travis-ci none uses such flag, it didnt errored!

it is fun to learn a bit more about CMakeLists :)

@ghost
Copy link
Author

ghost commented Oct 13, 2018

If I understand you correctly, everything is fine. 😎
At least everything works in the package I made.

In addition, the CMakeLists.txt has other options, such as option(BUILD_MAC_APP "Build standalone application for MacOS" OFF).
As well as other definitions such as add_definitions(-DIVAN_VERSION="${PROJECT_VERSION}" -DUSE_SDL), add_definitions(-DUNIX), add_definitions(-DMAC_APP), add_definitions(-DDATADIR="${CMAKE_INSTALL_FULL_DATADIR}" -DLOCAL_STATE_DIR="${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/ivan") , add_definitions(-DWIN32), add_definitions(-D_USE_32BIT_TIME_T).
If they are not a problem, I guess my option is not either. 👽

Or you suggest making changes to the .travis.yml file to test the build with this option?

@ghost
Copy link
Author

ghost commented Nov 4, 2018

@AquariusPower @fejoa @andrewtweber
I also added a new option to the .travis.yml file. But I'm not entirely sure I added the flags correctly to env. However, it seems that Travis has successfully built everything. 🎉
Could you check my pull request? Is it acceptable to merge? 👽

@@ -5191,6 +5191,9 @@ festring game::GetDataDir()

festring game::GetStateDir()
{
#ifdef FORCE_HOME_AS_STATE_DIR
return GetHomeDir()+"/.ivan/";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return GetHomeDir()+"/.ivan/";
return GetHomeDir();

Please check the definition of game::GetHomeDir(). "/.ivan" is already included there.

Copy link
Author

@ghost ghost Nov 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the code.

festring game::GetHomeDir()
{
#ifdef UNIX
  festring Dir;
  Dir << getenv("HOME");
#ifdef MAC_APP
  Dir << "/Library/Application Support/IVAN/";
#else
  Dir << "/.ivan/";
#endif
#ifdef DBGMSG
  dbgmsg::SetDebugLogPath(Dir.CStr());
#endif
  return Dir;
#endif

I think that /.ivan/ will be added only in case of non-UNIX system (i.e. Windows). While there is an option for UNIX systems. I roughly explained the situation here. In my Nix package everything is located inside ~/.ivan/ as expected. There is no additional nested /.ivan directory. It is already available on the unstable NixOS channel.You can check (for Linux). 👽

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, non-UNIX system for IVAN is only Windows. And the executable for Windows is expected to run inside the game folder, so in that case Dir is an empty string meaning the current working directory, then /.ivan/ is inappropriate.

Where is your high score file? Shouldn't it be in ~/.ivan/.ivan now?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, you were right. Fixed. 😐

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetHomeDir is also a confusing function name on unix systems. :p The files reside there also store some "states" (config, saves, debug info). Maybe we should merge GetHomeDir() and GetStateDir() because it is so easy to cheat and there is currently no safe method to share high score files and bone files among multiple users and limit file access. (Then I will propose removing -DLOCAL_STATE_DIR="${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/ivan"), which is the only hard-coded path for dynamic game data now. Another pull request will do.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iology Thanks for merging! 🎉
I think I agree with you. In addition, a new class of operating systems that take a new approach to managing system configuration and packages, such as NixOS, GuixSD, Fedora Silverblue, do not allow applications to write data to random paths.
Although it was an old tradition to have a shared highscores and bones files in old roguelikes, but the new reality changes everything.
The new pull request is here!

CMakeLists.txt Outdated
@@ -13,10 +13,14 @@ set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
add_definitions(-DIVAN_VERSION="${PROJECT_VERSION}" -DUSE_SDL)

option(BUILD_MAC_APP "Build standalone application for MacOS" OFF)
option(FORCE_HOME_AS_STATE_DIR "Statedir will be /.ivan/ in current user's homedir" OFF)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

USE_HOME_FOR_STATE_DIR is a better name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you wish. I changed that. 😎
Besides, I have reverted the changes to the .travis.yml file (I wasn't sure they were okay).

@jakwings jakwings mentioned this pull request Nov 4, 2018
@ghost ghost changed the title FORCE_HOME_AS_STATE_DIR option added USE_HOME_FOR_STATE_DIR option added Nov 5, 2018
@jakwings jakwings merged commit 2b27cea into Attnam:master Nov 5, 2018

if(UNIX)
add_definitions(-DUNIX)
include(GNUInstallDirs)
if(USE_HOME_FOR_STATE_DIR)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LOCAL_STATE_DIR define below should be enclosed in if(USE_HOME_FOR_STATE_DIR).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid that this PR is already merged. But you can take a look at the new one.

@@ -5191,6 +5191,9 @@ festring game::GetDataDir()

festring game::GetStateDir()
{
#ifdef USE_HOME_FOR_STATE_DIR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would have been cleaner to put this in the #else of the #ifdef MAC_APP, as it's only relevant for non-OSX Unixes, as OSX and Windows already default to GetHomeDir().

@ghost ghost mentioned this pull request Dec 21, 2018
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants