TheExDeus
|
|
Posted on: October 31, 2012, 09:18:37 am |
|
|
Joined: Apr 2008
Posts: 1860
|
Hello! Some time ago one good man added working_directory+ to every file io function. This is correct way to do this if working_directory is not the same as the exe directory. This is only true when debugging (which is all we can do in ENIGMA because the lack of the fuc*ing COMPILE BUTTON) as you want the source (gmk, gm6, egm etc.) directory for the program to feel like the exe directory (not the /temp in which it actually is in). The problem is that as the only way to get exe is to copy it out of the temp directory. That means the gmk's position is hard coded in directory and so breaks the shit out of everything. I tried using parameter_string(0), but that isn't implemented (which it should). Here is a topic showing how it could be done: http://forums.devshed.com/c-programming-42/winmain-and-argv-argc-474770.htmlI wasn't able to do that because I didn't try bothering how to convert unicode string to regular char. Then I noticed temp_directory and program_directory are not set either. The default behavior for POSIX file functions is to have them relative to the file anyway, so deleting the addition of "working_directory+" returns the correct behavior. So basically what these variables should return: "Debug or Run" working_directory = directory of gmk (works correctly now) or exe if launched separately from LGM program_directory = directory of exe no mater where launched from or in what mode. Should be the same as parameter_string(0) temp_directory = temporary directory. Should be the same as exe directory. "Clean build (Compile button)" working_directory = directory of exe program_directory = directory of exe no mater where launched from or in what mode. Should be the same as parameter_string(0) temp_directory = temporary directory So either FINALLY make the "Compile" button work that automatically sets working_directory to exe directory on runtime. Or make the "Debug" and "Run" buttons pass an argument to the exe which would basically tell the exe that it is run from LGM and then set working_directory to the gmk directory. Anyone willing to do anything?
|
|
|
Logged
|
|
|
|
Josh @ Dreamland
|
|
Reply #1 Posted on: October 31, 2012, 11:59:09 am |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
Hi, - The working directory is handled by the operating system. It is the exe directory by default. It should not be prepended to filenames under any circumstance, as it is not a variable owned by ENIGMA.
- "The fucking compile button" works fine, last I checked; you just need to add .exe to the end of the name on Windows. If this has changed, talk to Ism so she can dismiss you formally.
- Let me once again emphasize that the working directory belongs to the operating system. You should not be storing it or manipulating it in any way.
What I'm going to do is close my eyes and pretend no one prefixed `get_working_directory()` to the given filename. When I open them, sometime after I graduate, I'm hoping it will be gone.
|
|
« Last Edit: October 31, 2012, 12:12:00 pm by Josh @ Dreamland »
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
polygone
|
|
Reply #2 Posted on: October 31, 2012, 01:08:26 pm |
|
|
Location: England Joined: Mar 2009
Posts: 794
|
Why should it not be prepended to filenames? I don't see any downsides.
|
|
|
Logged
|
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
|
|
|
Josh @ Dreamland
|
|
Reply #3 Posted on: October 31, 2012, 02:06:28 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
If the implementation of get_working_directory is correct, the only thing you are doing is risking formatting problems with the underlying operating system.
So, technically, your solution does nothing. Especially on Linux, where \ is a valid character in filenames. The only thing your "fix" does is waste time. First, time to call the function. Then, time to poll the operating system for the path. Then, time to concatenate strings. Then, time to parse the path that it already had parsed as the working directory.
Your solution also confuses HaRRi, who now apparently misunderstands the concept of a working directory.
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
TheExDeus
|
|
Reply #4 Posted on: October 31, 2012, 03:07:20 pm |
|
|
Joined: Apr 2008
Posts: 1860
|
Josh, the reason working_directory HAS to change when launched from LGM is because the working directory should be the one for the source files (just like in GM it has been since the beginning of time). So you don't have to put your .dll files or your .ini files in the temp directory, but they can safely stay with the source. So you must change working_directory via hard coded path and add that to all IO functions when launched from LGM (just like its done now) or change it on runtime with LGM passing the argument. You can't leave the IO functions without the working_directory prefix unless you are changing the working_directory internally for the POSIX functions. Though I think when you launch a program from another programs directory you do change its working directory... now sure why this doesn't work in this case with LGM. And the "The fucking compile button" shows this: http://pastebin.com/nnaPG6vVedit: And I do get the concept of working directory, as I showed what all of the three values should be for the two cases. Another way which seems the best, could be the easiest, and is basically what I mean with "launch a program from another programs directory" is by making LGM do something like this: "cd c:/source/dir c:/tmp/compiled_game.tmp" One of these things is how GM does it.
|
|
« Last Edit: October 31, 2012, 03:17:22 pm by HaRRiKiRi »
|
Logged
|
|
|
|
polygone
|
|
Reply #5 Posted on: October 31, 2012, 03:15:58 pm |
|
|
Location: England Joined: Mar 2009
Posts: 794
|
The implement works fine on Windows, obviously it needs to be catered to other operating systems but whatever that can be sorted but not being on other operating systems I'm not going to be doing that.
|
|
« Last Edit: October 31, 2012, 08:54:17 pm by polygone »
|
Logged
|
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
|
|
|
Josh @ Dreamland
|
|
Reply #6 Posted on: October 31, 2012, 03:23:35 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
You've missed the point.
Your. Solution. Does. Nothing. Useful.
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
polygone
|
|
Reply #7 Posted on: October 31, 2012, 08:49:20 pm |
|
|
Location: England Joined: Mar 2009
Posts: 794
|
It does useful on Windows, just need macro it for other platforms.
|
|
« Last Edit: October 31, 2012, 08:54:05 pm by polygone »
|
Logged
|
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
|
|
|
Josh @ Dreamland
|
|
Reply #8 Posted on: October 31, 2012, 09:24:36 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
What is it you believe this accomplishes on Windows?
Oh, I see. You people take turns destroying ENIGMA.
The correct implementation of get_working_directory is NOT [snip]{ return working_directory; }[/snip]. The correct implementation of working_directory is [snip]#define working_directory get_working_directory()[/snip] (actually, the correct implementation would move the macro EDL-side, but I digress). The correct implementation of get_working_directory, on Windows, is as follows:
string get_working_directory() { char wd[MAX_PATH]; size_t len = GetCurrentDirectory(MAX_PATH, wd); return string(wd, len); } So, with the proper implementation of that function, and not DatZach's ass-backwards hard-coded path value for the working directory, your code is useless.
In other words, while your code presently holds a function, it is wrong that it should do so.
And now I'm twice as pissed off by this whole scenario.
|
|
« Last Edit: October 31, 2012, 09:40:05 pm by Josh @ Dreamland »
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
|
Josh @ Dreamland
|
|
Reply #10 Posted on: November 01, 2012, 02:18:59 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
ENIGMA launches the game. You can change the working directory from which the game is launched by editing the environment ENIGMA creates for it in better_system. You should probably be able to do this without editing better_system.cpp.
I do not recommend defaulting the working directory to the GM6 folder due to the number of novices (and even overconfident experienced users) who end up accidentally scrubbing the contents of the game's working directory while using the file manipulation functions.
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
|
Josh @ Dreamland
|
|
Reply #12 Posted on: November 01, 2012, 06:14:25 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
What I am suggesting is that you talk to Ism about adding a "workbench" setting to LGM. So your folder will be in ~/Games, and your DLLs will be in ~/ENIGMA/Workbench, or just ~/Workbench, or whatever.
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
|
polygone
|
|
Reply #14 Posted on: November 02, 2012, 10:18:40 am |
|
|
Location: England Joined: Mar 2009
Posts: 794
|
I personally prefer the GM way of just putting the source directory as the working directory.
This.
|
|
|
Logged
|
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
|
|
|
|