From b44a3edfe9363163ab129594cba51a989c042644 Mon Sep 17 00:00:00 2001 From: Johan Althoff Date: Sun, 18 Nov 2007 22:06:41 +0000 Subject: [PATCH] fixed so it compiles under windows. --- default.bam | 1 + src/engine/engine.c | 2 +- src/engine/system.c | 19 ++++++++++++++++--- src/game/client/cl_skin.cpp | 2 +- src/game/client/cl_skin.h | 2 +- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/default.bam b/default.bam index 0d7a43f51..ab4a4773f 100644 --- a/default.bam +++ b/default.bam @@ -170,6 +170,7 @@ function build(settings) settings.linker.libs:add("user32.lib") settings.linker.libs:add("ws2_32.lib") settings.linker.libs:add("ole32.lib") + settings.linker.libs:add("shell32.lib") end -- build glfw diff --git a/src/engine/engine.c b/src/engine/engine.c index f3bee450a..4ec67da16 100644 --- a/src/engine/engine.c +++ b/src/engine/engine.c @@ -9,7 +9,7 @@ static char application_save_path[512] = {0}; const char *engine_savepath(const char *filename, char *buffer, int max) { - snprintf(buffer, max, "%s/%s", application_save_path, filename); + sprintf(buffer, "%s/%s", application_save_path, filename); return buffer; } diff --git a/src/engine/system.c b/src/engine/system.c index e0fcc0b58..4a7670ebf 100644 --- a/src/engine/system.c +++ b/src/engine/system.c @@ -31,7 +31,10 @@ #include #include #include + #include // for SHGetFolderPathAndSubDir #include + #include + #include #define EWOULDBLOCK WSAEWOULDBLOCK #else @@ -650,13 +653,19 @@ int fs_listdir(const char *dir, fs_listdir_callback cb, void *user) int fs_storage_path(const char *appname, char *path, int max) { #if defined(CONF_FAMILY_WINDOWS) - #error not implement + HRESULT r; + char home[MAX_PATH]; + r = SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, home); + if(r != 0) + return 1; + _snprintf(path, max, "%s/%s", home, appname); + return 0; #else char *home = getenv("HOME"); int i; if(!home) return 0; - + snprintf(path, max, "%s/.%s", home, appname); for(i = strlen(home)+2; path[i]; i++) path[i] = tolower(path[i]); @@ -668,7 +677,11 @@ int fs_storage_path(const char *appname, char *path, int max) int fs_makedir(const char *path) { #if defined(CONF_FAMILY_WINDOWS) - #error not implement + if(_mkdir(path) == 0) + return 0; + if(errno == EEXIST) + return 0; + return 1; #else if(mkdir(path, 0755) == 0) return 0; diff --git a/src/game/client/cl_skin.cpp b/src/game/client/cl_skin.cpp index 292b0a993..fcdd0207e 100644 --- a/src/game/client/cl_skin.cpp +++ b/src/game/client/cl_skin.cpp @@ -10,7 +10,7 @@ enum MAX_SKINS=256, }; -static skin skins[MAX_SKINS] = {{-1, -1, {0}, {0}}}; +static skin skins[MAX_SKINS] = {0}; static int num_skins = 0; static void skinscan(const char *name, int is_dir, void *user) diff --git a/src/game/client/cl_skin.h b/src/game/client/cl_skin.h index 0b5875b34..a114789db 100644 --- a/src/game/client/cl_skin.h +++ b/src/game/client/cl_skin.h @@ -6,7 +6,7 @@ typedef struct int org_texture; int color_texture; char name[31]; - const char term[1]; + char term[1]; } skin; vec4 skin_get_color(int v);