Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upFilenames #6225
Conversation
kevingranade
reviewed
Feb 21, 2014
| //system(std::string("cp -r * " + FILENAMES["base_path"])); | ||
| #endif // __linux__ | ||
|
|
||
| FILENAMES.insert(std::pair<std::string,std::string>("base_path", "")); |
This comment has been minimized.
This comment has been minimized.
kevingranade
Feb 21, 2014
Member
any particular reason you didn't write these as:
FILENAMES["base_path"] = "/home/" + USERNAME + "/.cataclysm-dda";
Also, the defaults should be relative paths, I don't want us writing outside the expanded archive by default.
We could have a single command line flag to "use a cataclysm home directory" so it's convinient.
This comment has been minimized.
This comment has been minimized.
PyroLagus
Feb 21, 2014
Author
Contributor
Yeah. I did it like that before. But that would overwrite cli options. I could have used ifs but that would have been even worse.
kevingranade
reviewed
Feb 21, 2014
| @@ -0,0 +1,9 @@ | |||
| #ifndef GLOBALS_H_INCLUDED | |||
This comment has been minimized.
This comment has been minimized.
kevingranade
Feb 21, 2014
Member
How about "file_paths.h"? I thought you had gone and stashed a bunch of global definitions in here or something :D
This comment has been minimized.
This comment has been minimized.
PyroLagus
Feb 21, 2014
Author
Contributor
The username is also in there. Didn't want to confuse anyone. I could change it to path_info.h or something like that.
This comment has been minimized.
This comment has been minimized.
kevingranade
Feb 22, 2014
Member
Path_info is fine too, it's just that "globals" is particularly confusing.
kevingranade
reviewed
Feb 21, 2014
| @@ -440,16 +440,16 @@ void cata_tiles::create_rotation_cache() | |||
| 3 is a West rotation | |||
| These rotations are stored in a map<tile number, vector<SDL_Surface*> > with 3 values relating to east, south, and west in that order | |||
| */ | |||
| for (tile_iterator it = tile_values->begin(); it != tile_values->end(); ++it) { | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PyroLagus
Feb 21, 2014
Author
Contributor
I had some debug code there and removed it. It seems that I accidentally changed the indention. I would have removed that one if Github had a cherrypick function for pushing/pull requests.
kevingranade
reviewed
Feb 21, 2014
| @@ -50,10 +50,10 @@ | |||
| <Linker> | |||
| <Add library="libSDL.dll" /> | |||
| <Add library="SDL_ttf" /> | |||
| <Add library="WinDepend\SDLttf\SDL_ttf-2.0.11\lib\x86\SDL_ttf.lib" /> | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PyroLagus
Feb 21, 2014
Author
Contributor
I don't remember changing those. I think Code::Blocks did. I guess you could remove that one.
This comment has been minimized.
This comment has been minimized.
|
Cool stuff, my nitpicky things aside, I really appreciate this. Can we get confirmation that we're ok on windows? |
kevingranade
reviewed
Feb 21, 2014
| @@ -599,7 +599,7 @@ int curses_start_color(void) | |||
| windowsPalette = new RGBQUAD[16]; | |||
|
|
|||
| //Load the console colors from colors.json | |||
| std::ifstream colorfile("data/raw/colors.json", std::ifstream::in | std::ifstream::binary); | |||
| std::ifstream colorfile(FILENAMES["colors"], std::ifstream::in | std::ifstream::binary); | |||
This comment has been minimized.
This comment has been minimized.
kevingranade
Feb 21, 2014
Member
According to KA101, Code::Blocks/mingw has issues compiling this on his system, doing s/FILENAME["colors"]/FILENAME["colors"].c_str()/ seems to fix it.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Related to issue #5829 but not fix it. Btw, FILENAME mapping is good idea. Before begin one little thing:
It's wrong. You need to get homedir from environment($HOME). You need to get username from environment($USER). It will work on MAC OSX too. On Windows %HOMEPATH% and %USERNAME% You chose wrong way to make packaging support.
You need to change scheme. Code must be splitted by small functions with OS related checks:
Binary should run the small jobs without worrying about OS on witch it's running. IMHO we don't need all these command line parameters except for "--basedir". This is useful param. May be "--userdir" is fine too. Makefile must be changed too. $PREFIX variable(prefix of all shared data) must be added into all files related functions. On Linux and MAC prefix should be set /usr/{local} on default. On Windows %PROGRAMFILES%. We need to add "make install" option. This option should create userdata dir and fills it. This option should copy shaded data to $SHAREDDIR only. User related files should be created on first run(if not exist).
That's the way to packaging. |
This comment has been minimized.
This comment has been minimized.
|
Well. I started doing that filename thing to get it working with dgamelaunch, so I didn't think that packaging stuff through. Dgamelaunch is also the reason why I chose the cli options I added, I wanted to make it as flexible as possible for use with multiple users (for example every user might want to have his own options file, autopickup file, and so on). (Putting the parsing of the cli options in an extra function sounds like a good idea though so I'm going to do that.) <- not sure how it's going to work with the non-global variables. I'm also going to use the environment variables to set the homedir and username. |
This comment has been minimized.
This comment has been minimized.
|
Ok. I understand you. I think, i need to contact you when i begin adding packaging support. |
This comment has been minimized.
This comment has been minimized.
|
Sounds like a good idea. It also seems that the recent pulls made it unmergeable :P Seems like I'll have to add them by hand so this might take some time. EDIT: Seems like it wasn't that hard ^^ |
This comment has been minimized.
This comment has been minimized.
|
Thefuck oO what the hell happened? I only wanted to commit catalua.cpp ... |
This comment has been minimized.
This comment has been minimized.
|
Yes, making new modules is a good thing. I took a poke at merging it, mostly clean, but I'm not totally confident of the Makefile, so I'll PR it back her for checking. |
This comment has been minimized.
This comment has been minimized.
|
I made second PR with merge. @c0dehero I did't see place where username can be used. May be in default charname. But if you need username var, it can be easy to implement now(by you). |
This comment has been minimized.
This comment has been minimized.
|
Yeah, default character name is where I'm going to use it for map sharing, I'm also not sure how exactly the normal build and the server build are going to be separated so if you have any suggestions I'd be happy to know ^^ |
This comment has been minimized.
This comment has been minimized.
|
On compile time you need to specify PREFIX. Let's on other example. |
kevingranade
reviewed
Mar 21, 2014
| dir = std::string(user_dir) + "/cataclysm-dda/"; | ||
| #else | ||
| user_dir = getenv("HOME"); | ||
| dir = std::string(user_dir) + "/.cataclysm-dda/"; |
This comment has been minimized.
This comment has been minimized.
kevingranade
Mar 21, 2014
Member
If you do a no arguments make and run the program, it should not write outside the source directory, in other words it should preserve the current behavior. Automatically writing outside the build directory with no instructions from the user is bad form from what I understand, it's definitely not what I'd expect. Needs some kind of "use home directory" argument to the makefile to enable this behavior.
Possibly trigger this with the --userdir argument?
This comment has been minimized.
This comment has been minimized.
|
It's can be done. To disable this feature you need to comment line 60:
and add to first argc, argv while loop this before "user-dir":
|
This comment has been minimized.
This comment has been minimized.
|
Because it's rude to write outside your source directory unless you've been |
This comment has been minimized.
This comment has been minimized.
Again. All software do like that. This only one way to give a possibility to several users run same distribution of game without conflicts. Should all of these users worry about file permissions and special arguments of command line? NO! We, developers, must care about this.
This be granted by OS. And OS controls this very well. All real users have own home dir and have read/write permissions in this dir. Why should any user data be stored in outside of his home dir?
For archive, it may be acceptable(it's not). But what about packets? deb, rpm and msi packets store all date in /usr/ or prorgam files. Writing into these dir requires Administrator rights. How can users store their own data in these dirs? Adding special var to Makefile can be done easily. Anyone can do it now. I won't do it because it's wrong of my opinion. |
This comment has been minimized.
This comment has been minimized.
|
Deb. Rpm etc assume system integration, so they will of course not restrict |
This comment has been minimized.
This comment has been minimized.
SSH is what I'm planning. The problem is that on a shared server, every player should only be able to access his own saves (this would be easiest implemented by just using the username as default character name and hide the other user saves (or just deny access to those). Users also shouldn't be able to cheat so the debug menu would have to be disabled and some settings (like initial starting points) should be world based which fits better any ways imo. This behavior should be separated from the default behavior. Separating the user files is what I added the args for which also fit well in the standard build. To the home directory writing thing. I think we should add another "Packaging" build, that will make writing to the home directory default and maybe even build various packages automatically if that's possible, I don't know how to do that so someone else would have to do that. If someone could also add a "Server" build that would be awesome :P |
This comment has been minimized.
This comment has been minimized.
.
I was wrong. It's not easy now. It's possibly to adapt file paths to Makefile RELEASE var. But this will add a LOT of confused code in main.cpp. Price is too high.I understand what you need, but still don't understand why. |
This comment has been minimized.
This comment has been minimized.
|
@c0dehero About your server...
You can(as root or as user) remove read permissions from home dir with:
or for cataclysm only:
Otherwise, other users can read( not write ) saves and configs of other users. I thinks it's save. Disabling debug will be very hard to do. But on Linux i can write path for you to use hard-coded optinons.txt. This file will be read only(write by root) and shared to all users. You just need to create this file. But every try to write options by any user will cause error =(. And if you are familiar with dev-tools you will able to build it. I like this idea and can make PR later. |
kevingranade
merged commit 0fd8d30
into
CleverRaven:master
Mar 23, 2014
1 check failed
This comment has been minimized.
This comment has been minimized.
|
Thank you! |
This comment has been minimized.
This comment has been minimized.
|
@VlasovVitaly Without map sharing it's quite easy because every user has his own set of files, but with map sharing many users will be sharing one map. To make map sharing fair, users shouldn't be able to have advantages over others, so certain options should depend on the map played. Like online games where you can play on certain worlds with different options, that's how it should work. UI options and that sort of stuff should still be per user though. Map sharing will most likely require some extensive change for it to work in a manner that would be acceptable for an official server. I might start working on this next week. Now with dynamic filename handling the basic functionality should be easy to implement ^^ |
This comment has been minimized.
This comment has been minimized.
|
All per-user data can be controlled by OS except cheating menu. Disabling cheat menu can be changed by adding compilation flag or may be with RELEASE=1. In couple days i can realize my test VPS with "kiosk" mode. I give you several logins and you tell me what is wrong in such configuration. See you in IRC. |
This comment has been minimized.
This comment has been minimized.
|
I already got map-sharing to work, sort of. In a previous version. I'd just have to find the code. Users |
This comment has been minimized.
This comment has been minimized.
|
So will we be getting a SSH server for Cata? |
This comment has been minimized.
This comment has been minimized.
|
@VlasovVitaly Okay. I found my previous code thanks to git ^^ and implemented basic map sharing functionality how it should work -> https://github.com/C0DEHERO/Cataclysm-DDA/tree/mapsharing The only thing that's really missing is making sure that certain options can't be edited by normal users, and that some (like the starting points, city size, item density, monster spawn rate, dynamic spawn) are per world, to allow for easy, medium, difficult, and hardcore maps. Maybe even some "special maps" (not defense/tutorial maps), depending on the settings. Special maps would probably be implemented through mods though, so that would work already as those are set at map creation. I'm going to create a script for automatically setting up dgamelaunch and installing Cataclysm-DDA, so it'd be cool if you could try it, as you happen to have a VPS ^^ Dgamelaunch only needs one login, and the usernames will be set with the "--username" cli option. It would also work with separate ssh logins (without dgamelaunch), but I guess that dgamelaunch might be a bit easier for setting up the folder structure. Unless you can come up with a script for that, of course :) |
This comment has been minimized.
This comment has been minimized.
|
Okay. most of those options are already per world I found out '^^ Debug options are locked down. If people want to play with more starting points or without skill rust, it should be easy to just host an other instance with different options. Should be easy to implement with dgamelaunch. |
This comment has been minimized.
This comment has been minimized.
|
@c0dehero |
This comment has been minimized.
This comment has been minimized.
|
@Zireael07 Yes, why not =) |
PyroLagus commentedFeb 20, 2014
Unified the filenames in one place and made cataclysm-dda ready for linux packaging.