Merge branch 'master' of https://github.com/atmaxinger/OpenRCT2 into atmaxinger-master

This commit is contained in:
IntelOrca 2014-05-26 13:54:58 +01:00
commit 17a567292d
5 changed files with 40 additions and 6 deletions

View File

@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -216,20 +216,21 @@ void config_save()
*/
void config_init()
{
TCHAR path[MAX_PATH];
char *path = osinterface_get_orct2_homefolder();
FILE* fp;
memcpy(&gGeneral_config, &gGeneral_config_default, sizeof(general_configuration_t));
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, path))) { // find home folder
strcat(path, "\\OpenRCT2");
if (strcmp(path, "") != 0){
DWORD dwAttrib = GetFileAttributes(path);
if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { // folder does not exist
if (!CreateDirectory(path, NULL)) {
config_error("Could not create config file (do you have write access to your documents folder?)");
}
}
strcat(path, "\\config.ini");
sprintf(path, "%s%c%s", path, osinterface_get_path_separator(), "config.ini");
fp = fopen(path, "r");
if (!fp) {
config_create_default(path);
@ -242,6 +243,8 @@ void config_init()
fclose(fp);
}
free(path);
}
/**

View File

@ -428,3 +428,26 @@ char* osinterface_open_directory_browser(char *title) {
CoUninitialize();
return outPath;
}
char* osinterface_get_orct2_homefolder()
{
char *path=NULL;
path = malloc(sizeof(char) * MAX_PATH);
if (path == NULL){
osinterface_show_messagebox("Error allocating memory!");
exit(EXIT_FAILURE);
}
path[0] = '\0';
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, path))) { // find home folder
strcat(path, "\\OpenRCT2");
}
return path;
}
char osinterface_get_path_separator()
{
return '\\';
}

View File

@ -50,4 +50,7 @@ int osinterface_open_common_file_dialog(int type, char *title, char *filename, c
void osinterface_show_messagebox(char* message);
char* osinterface_open_directory_browser(char *title);
char* osinterface_get_orct2_homefolder();
char osinterface_get_path_separator();
#endif

View File

@ -21,6 +21,7 @@
#include <lodepng.h>
#include <stdio.h>
#include <windows.h>
#include "osinterface.h"
#include "addresses.h"
#include "config.h"
#include "gfx.h"
@ -59,17 +60,21 @@ void screenshot_check()
static int screenshot_get_next_path(char *path, char *extension)
{
char *homePath = osinterface_get_orct2_homefolder();
int i;
for (i = 1; i < 1000; i++) {
RCT2_GLOBAL(0x013CE952, uint16) = i;
// Glue together path and filename
sprintf(path, "%sSCR%d%s", RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH_SLASH, char), i, extension);
sprintf(path, "%s%cSCR%d%s", homePath, osinterface_get_path_separator(), i, extension);
if (GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES && GetLastError() == ERROR_FILE_NOT_FOUND)
return i;
}
free(homePath);
return -1;
}