From 76a7cc98b8754f90c9181c7b24f48651247cc8b8 Mon Sep 17 00:00:00 2001 From: atmaxinger Date: Tue, 27 May 2014 17:14:27 +0200 Subject: [PATCH] replaced WIN32 file i/o in config_load() --- src/config.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/config.c b/src/config.c index 8d99760217..0883849bd2 100644 --- a/src/config.c +++ b/src/config.c @@ -117,20 +117,21 @@ void config_reset_shortcut_keys() */ void config_load() { - HANDLE hFile; - DWORD bytesRead; + unsigned int bytesRead; + FILE *fp=NULL; char* path = get_file_path(PATH_ID_GAMECFG); - hFile = CreateFile(get_file_path(PATH_ID_GAMECFG), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, - FILE_FLAG_RANDOM_ACCESS | FILE_ATTRIBUTE_NORMAL, NULL); - if (hFile != INVALID_HANDLE_VALUE) { + + fp = fopen(path, "rb"); + + if (fp != NULL) { // Read and check magic number - ReadFile(hFile, RCT2_ADDRESS(0x013CE928, void), 4, &bytesRead, NULL); + fread(RCT2_ADDRESS(0x013CE928, void), 1, 4, fp); + if (RCT2_GLOBAL(0x013CE928, int) == MagicNumber) { // Read options - ReadFile(hFile, (void*)0x009AAC5C, 2155, &bytesRead, NULL); - CloseHandle(hFile); - + fread((void*)0x009AAC5C, 1, 2155, fp); + fclose(fp); //general configuration RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_EDGE_SCROLLING, sint8) = gGeneral_config.edge_scrolling;