Author: unknown Upstream: yes Reason Fixes linux support diff -burN zod_engine/zod_launcher_src/common.cpp zod_engine.new/zod_launcher_src/common.cpp --- zod_engine/zod_launcher_src/common.cpp 2011-03-22 12:05:11.000000000 +0100 +++ zod_engine.new/zod_launcher_src/common.cpp 2012-05-05 22:50:56.000000000 +0200 @@ -9,24 +9,216 @@ #include #include #include + +#define OSPATH_SEP '\\' + #else #include #include #include + +#define OSPATH_SEP '/' + #endif namespace COMMON { -void create_folder(char *foldername) +//base data path for the engine +static char base_path[FILENAME_MAX]; +//home (user specific) data path for the engine +static char home_path[FILENAME_MAX]; + +static bool path_concat(const char *base, const char *file, char *dest) +{ + size_t i; + size_t len; + char c; + bool was_sep; + + // base path is an OS specific path + len = 0; + for (i = 0; len < (FILENAME_MAX - 1) && base[i] != '\0'; i++) + dest[len++] = base[i]; + + // this also catches base[i] != '\0' + if (len == (FILENAME_MAX - 1)) + return false; + + + // ensure base is terminated by OSPATH_SEP + if (len == 0 || dest[len - 1] != OSPATH_SEP) + dest[len++] = OSPATH_SEP; + + was_sep = true; + + // file name could have both '/' or '\\' for path separation + for (i = 0; len < (FILENAME_MAX - 1) && file[i] != '\0'; i++) { + char c = file[i]; + if (c == '/' || c == '\\') { + // ignore double separators + if (was_sep) + continue; + + c = OSPATH_SEP; + was_sep = true; + } else { + was_sep = false; + } + + dest[len++] = c; + } + + if (file[i] != '\0') + return false; + + dest[len] = '\0'; + return true; +} + +static bool file_exists(const char*filename) +{ +#ifdef _WIN32 + DWORD attrs = GetFileAttributes(filename); + return (attrs != INVALID_FILE_ATTRIBUTES); + +#else + + return (access(filename, R_OK) == 0); + +#endif + +} + +void init_file_paths(const char *bin_path) { -#ifdef WIN32 //if windows + base_path[0] = '\0'; + +#ifdef DATA_PATH + //compilation defined base path, ignore if too long + if (strlen(DATA_PATH) < FILENAME_MAX) + strcpy(base_path, DATA_PATH); +#endif + + if (base_path[0] == '\0' && bin_path && bin_path[0] != '\0') { + //default to binary path dirname + char dirname[FILENAME_MAX]; + size_t len; + + len = strlen(bin_path); + if (len < FILENAME_MAX) { + strcpy(base_path, bin_path); + //find the last separator + do len--; while (len > 0 && base_path[len] != OSPATH_SEP); + + base_path[len] = '\0'; + } + } + + // if no explicit directory is specified + // default to current working directory + if (base_path[0] == '\0') + strcpy(base_path, "."); + + // get home path + home_path[0] = '\0'; + +#ifdef _WIN32 + // on Windows home path is equivalent to base path + strcpy(home_path, base_path); + +#else + // on Unix platforms use a specific directory in home + const char *home = getenv("HOME"); + if (home && home[0] != '\0') { + if (path_concat(home, ".zod-engine", home_path)) + create_folder(home_path); + else + home_path[0] = '\0'; + } + +#endif + +} + +void create_folder(const char *foldername) +{ +#ifdef _WIN32 //if windows mkdir(foldername); #else mkdir(foldername,-1); #endif } +FILE *open_file_read(const char *filename, bool binary) +{ + char path[FILENAME_MAX]; + const char *mode; + FILE *fp; + + fp = NULL; + mode = (binary)? "rb" : "r"; + if (home_path[0] != '\0') { + // if home directory is available, pick the file from there, + // as there is where we can find user specific overrides + // of our files + if (path_concat(home_path, filename, path)) + fp = fopen(path, mode); + } + + if (!fp) { + // retrieve the file from the data directory + if (path_concat(base_path, filename, path)) + fp = fopen(path, mode); + } + + return fp; +} + +FILE *open_file_write(const char *filename, bool binary, bool append) +{ + FILE *fp = NULL; + if (home_path[0] != '\0') { + //files can only be created in home path + char path[FILENAME_MAX]; + + if (path_concat(home_path, filename, path)) { + // determine open mode + char mode[3]; + + mode[0] = (append)? 'a' : 'w'; + mode[1] = (binary)? 'b' : '\0'; + mode[2] = '\0'; + fp = fopen(path, mode); + } + } + + return fp; +} + +bool get_os_path(const char *filename, bool read_only, char *dest) +{ + + if (read_only) + { + if (home_path[0]) + { + if (path_concat(home_path, filename, dest) && file_exists(dest)) + return true; + } + + return path_concat(base_path, filename, dest) && file_exists(dest); + + } + else + { + if (home_path[0] != '\0') + return path_concat(home_path, filename, dest); + else + return false; + } +} + double current_time() { #ifdef WIN32 diff -burN zod_engine/zod_launcher_src/common.h zod_engine.new/zod_launcher_src/common.h --- zod_engine/zod_launcher_src/common.h 2011-03-22 12:05:11.000000000 +0100 +++ zod_engine.new/zod_launcher_src/common.h 2012-05-05 22:51:24.000000000 +0200 @@ -3,11 +3,16 @@ namespace COMMON { + + extern void init_file_paths(const char *bin_path); + extern bool get_os_path(const char *filename, bool read_only, char *dest); + extern void create_folder(const char *foldername); + extern FILE *open_file_read(const char *filename, bool binary); + extern FILE *open_file_write(const char *filename, bool binary, bool append); extern void split(char *dest, char *message, char split, int *initial, int d_size, int m_size); extern void clean_newline(char *message, int size); extern void lcase(char *message, int m_size); extern double current_time(); - extern void create_folder(char *foldername); extern void uni_pause(int m_sec); extern char *wtoc_s(const wchar_t *input); extern char *wtoc(const wchar_t *input, char *dest, int size); diff -burN zod_engine/zod_launcher_src/store_settings.cpp zod_engine.new/zod_launcher_src/store_settings.cpp --- zod_engine/zod_launcher_src/store_settings.cpp 2011-03-22 12:05:11.000000000 +0100 +++ zod_engine.new/zod_launcher_src/store_settings.cpp 2012-05-06 16:14:49.000000000 +0200 @@ -11,7 +11,7 @@ { FILE *fp; - fp = fopen("zod_launcher_settings.txt", "w"); + fp = open_file_write("zod_launcher_settings.txt", false, false); if(!fp) return; @@ -45,7 +45,7 @@ { FILE *fp; - fp = fopen("zod_launcher_settings.txt", "r"); + fp = open_file_read("zod_launcher_settings.txt", false); if(!fp) return; I file binari zod_engine/zod_launcher_src/zod_launcher e zod_engine.new/zod_launcher_src/zod_launcher sono diversi diff -burN zod_engine/zod_launcher_src/zod_launcherApp.cpp zod_engine.new/zod_launcher_src/zod_launcherApp.cpp --- zod_engine/zod_launcher_src/zod_launcherApp.cpp 2011-03-22 12:05:11.000000000 +0100 +++ zod_engine.new/zod_launcher_src/zod_launcherApp.cpp 2012-05-05 22:32:45.000000000 +0200 @@ -9,11 +9,17 @@ #include "zod_launcherApp.h" #include "zod_launcherFrm.h" +#include "common.h" IMPLEMENT_APP(zod_launcherFrmApp) bool zod_launcherFrmApp::OnInit() { + // initialize file system + wxString bin_path(argv[0]); + COMMON::init_file_paths(bin_path.mb_str(wxConvUTF8)); + + // create form zod_launcherFrm* frame = new zod_launcherFrm(NULL); SetTopWindow(frame); frame->Show(); diff -burN zod_engine/zod_launcher_src/zod_launcherFrm.cpp zod_engine.new/zod_launcher_src/zod_launcherFrm.cpp --- zod_engine/zod_launcher_src/zod_launcherFrm.cpp 2011-03-22 12:35:01.000000000 +0100 +++ zod_engine.new/zod_launcher_src/zod_launcherFrm.cpp 2012-05-06 16:16:19.000000000 +0200 @@ -10,6 +10,7 @@ #include "zod_launcherFrm.h" #include "store_settings.h" +#include "common.h" //Do not add custom headers between //Header Include Start and Header Include End @@ -215,7 +216,7 @@ #ifdef _WIN32 message = wxT("zod_engine.exe"); #else - message = wxT("./zod"); + message = wxT("zod"); #endif if(WxEdit1->GetValue().length()) diff -burN zod_engine/zod_src/cgatling.cpp zod_engine.new/zod_src/cgatling.cpp --- zod_engine/zod_src/cgatling.cpp 2011-09-06 17:35:10.000000000 +0200 +++ zod_engine.new/zod_src/cgatling.cpp 2012-05-05 17:26:16.000000000 +0200 @@ -53,7 +53,7 @@ for(j=0;j #include #include +#include #include "common.h" #ifdef _WIN32 #include #include #include + +#define OSPATH_SEP '\\' + #else #include #include @@ -16,20 +20,257 @@ #include #include #include + +#define OSPATH_SEP '/' + #endif namespace COMMON { -void create_folder(char *foldername) +//base data path for the engine +static char base_path[FILENAME_MAX]; +//home (user specific) data path for the engine +static char home_path[FILENAME_MAX]; + +static bool path_concat(const char *base, const char *file, char *dest) +{ + size_t i; + size_t len; + char c; + bool was_sep; + + // base path is an OS specific path + len = 0; + for (i = 0; len < (FILENAME_MAX - 1) && base[i] != '\0'; i++) + dest[len++] = base[i]; + + // this also catches base[i] != '\0' + if (len == (FILENAME_MAX - 1)) + return false; + + + // ensure base is terminated by OSPATH_SEP + if (len == 0 || dest[len - 1] != OSPATH_SEP) + dest[len++] = OSPATH_SEP; + + was_sep = true; + + // file name could have both '/' or '\\' for path separation + for (i = 0; len < (FILENAME_MAX - 1) && file[i] != '\0'; i++) { + char c = file[i]; + if (c == '/' || c == '\\') { + // ignore double separators + if (was_sep) + continue; + + c = OSPATH_SEP; + was_sep = true; + } else { + was_sep = false; + } + + dest[len++] = c; + } + + if (file[i] != '\0') + return false; + + dest[len] = '\0'; + return true; +} + +static vector scan_folder(string foldername) +{ + vector list; + +#ifdef _WIN32 + + HANDLE hFind = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA ffd; + + foldername += "*"; + + hFind = FindFirstFile(foldername.c_str(), &ffd); + + if(INVALID_HANDLE_VALUE == hFind) return filelist; + + do + { + if(!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + list.push_back((char*)ffd.cFileName); + } + while (FindNextFile(hFind, &ffd) != 0); + + FindClose(hFind); + +#else + + DIR *dp; + struct dirent *dirp; + + dp = opendir(foldername.c_str()); + + if (dp) { + + while ((dirp = readdir(dp)) != NULL) + { + if(dirp->d_type == DT_REG) + list.push_back(dirp->d_name); + } + + closedir(dp); + } + +#endif + + return list; +} + +static bool file_exists(const char*filename) +{ +#ifdef _WIN32 + + DWORD attrs = GetFileAttributes(filename); + return (attrs != INVALID_FILE_ATTRIBUTES); + +#else + + return (access(filename, R_OK) == 0); + +#endif + +} + +void init_file_paths(const char *bin_path) +{ + base_path[0] = '\0'; + +#ifdef DATA_PATH + //compilation defined base path, ignore if too long + if (strlen(DATA_PATH) < FILENAME_MAX) + strcpy(base_path, DATA_PATH); +#endif + + if (base_path[0] == '\0' && bin_path && bin_path[0] != '\0') { + //default to binary path dirname + char dirname[FILENAME_MAX]; + size_t len; + + len = strlen(bin_path); + if (len < FILENAME_MAX) { + strcpy(base_path, bin_path); + //find the last separator + do len--; while (len > 0 && base_path[len] != OSPATH_SEP); + + base_path[len] = '\0'; + } + } + + // if no explicit directory is specified + // default to current working directory + if (base_path[0] == '\0') + strcpy(base_path, "."); + + // get home path + home_path[0] = '\0'; + +#ifdef _WIN32 + // on Windows home path is equivalent to base path + strcpy(home_path, base_path); + +#else + // on Unix platforms use a specific directory in home + const char *home = getenv("HOME"); + if (home && home[0] != '\0') { + if (path_concat(home, ".zod-engine", home_path)) + create_folder(home_path); + else + home_path[0] = '\0'; + } + +#endif + +} + +void create_folder(const char *foldername) { -#ifdef WIN32 //if windows +#ifdef _WIN32 //if windows mkdir(foldername); #else mkdir(foldername,-1); #endif } +bool get_os_path(const char *filename, bool read_only, char *dest) +{ + + if (read_only) + { + if (home_path[0]) + { + if (path_concat(home_path, filename, dest) && file_exists(dest)) + return true; + } + + return path_concat(base_path, filename, dest) && file_exists(dest); + + } + else + { + if (home_path[0] != '\0') + return path_concat(home_path, filename, dest); + else + return false; + } +} + +FILE *open_file_read(const char *filename, bool binary) +{ + char path[FILENAME_MAX]; + const char *mode; + FILE *fp; + + fp = NULL; + mode = (binary)? "rb" : "r"; + if (home_path[0] != '\0') { + // if home directory is available, pick the file from there, + // as there is where we can find user specific overrides + // of our files + if (path_concat(home_path, filename, path)) + fp = fopen(path, mode); + } + + if (!fp) { + // retrieve the file from the data directory + if (path_concat(base_path, filename, path)) + fp = fopen(path, mode); + } + + return fp; +} + +FILE *open_file_write(const char *filename, bool binary, bool append) +{ + FILE *fp = NULL; + if (home_path[0] != '\0') { + //files can only be created in home path + char path[FILENAME_MAX]; + + if (path_concat(home_path, filename, path)) { + // determine open mode + char mode[3]; + + mode[0] = (append)? 'a' : 'w'; + mode[1] = (binary)? 'b' : '\0'; + mode[2] = '\0'; + fp = fopen(path, mode); + } + } + + return fp; +} + double current_time() { #ifdef WIN32 @@ -139,7 +380,18 @@ #ifdef _WIN32 //if windows Sleep(m_sec); //win version #else - usleep(m_sec * 1000); //lin version + struct timespec ts; //use nanosleep() + int secs; + int mills; + int res; + + secs = m_sec / 1000; + mills = m_sec - secs * 1000; + ts.tv_sec = secs; + ts.tv_nsec = mills * 1000000L; + + do res = nanosleep(&ts, &ts); while (res == -1 && errno == EINTR); + #endif } @@ -229,7 +481,7 @@ lt = time(NULL); ptr = localtime(<); - ofp = fopen("reg_log.txt","a"); + ofp = open_file_write("reg_log.txt",false,true); strcpy(timebuf, asctime(ptr)); clean_newline(timebuf, 100); @@ -259,7 +511,7 @@ { FILE *fp; - fp = fopen(filename, "a"); + fp = open_file_write(filename, false, true); if(!fp) return false; @@ -270,51 +522,37 @@ vector directory_filelist(string foldername) { - vector filelist; + vector list; + vector base; + vector merged; + char path[FILENAME_MAX]; -#ifdef _WIN32 + // scan both base and home folders + if (path_concat(home_path, foldername.c_str(), path)) + list = scan_folder(path); - HANDLE hFind = INVALID_HANDLE_VALUE; - WIN32_FIND_DATA ffd; + if (path_concat(base_path, foldername.c_str(), path)) + base = scan_folder(path); - foldername += "*"; + // for (size_t i=0;i::iterator el; - if(INVALID_HANDLE_VALUE == hFind) return filelist; + el = lower_bound(list.begin(), list.end(), base[i], sort_string_func); + if (el != list.end() && *el == base[i]) + continue; - do - { - if(!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - filelist.push_back((char*)ffd.cFileName); + merged.push_back(base[i]); } - while (FindNextFile(hFind, &ffd) != 0); - - FindClose(hFind); - -#else - DIR *dp; - struct dirent *dirp; - - if(!foldername.size()) foldername = "."; - - dp = opendir(foldername.c_str()); - - if(!dp) return filelist; - - while ((dirp = readdir(dp)) != NULL) - { - if(dirp->d_type == DT_REG) - filelist.push_back(dirp->d_name); - } - - closedir(dp); - -#endif - //for(int i=0;i &filelist, string extension) diff -burN zod_engine/zod_src/common.h zod_engine.new/zod_src/common.h --- zod_engine/zod_src/common.h 2011-09-06 17:35:07.000000000 +0200 +++ zod_engine.new/zod_src/common.h 2012-05-05 20:39:00.000000000 +0200 @@ -1,6 +1,7 @@ #ifndef _COMMON_H_ #define _COMMON_H_ +#include #include #include #include @@ -19,12 +20,16 @@ int x, y; }; + extern void init_file_paths(const char *bin_path); + extern bool get_os_path(const char *filename, bool read_only, char*dest); + extern FILE *open_file_read(const char *filename, bool binary); + extern FILE *open_file_write(const char *filename, bool binary, bool append); extern void split(char *dest, char *message, char split, int *initial, int d_size, int m_size); extern void clean_newline(char *message, int size); extern void lcase(char *message, int m_size); extern void lcase(string &message); extern double current_time(); - extern void create_folder(char *foldername); + extern void create_folder(const char *foldername); extern void uni_pause(int m_sec); extern char *wtoc_s(const wchar_t *input); extern char *wtoc(const wchar_t *input, char *dest, int size); diff -burN zod_engine/zod_src/cursor.cpp zod_engine.new/zod_src/cursor.cpp --- zod_engine/zod_src/cursor.cpp 2011-09-06 17:35:10.000000000 +0200 +++ zod_engine.new/zod_src/cursor.cpp 2012-05-05 17:31:02.000000000 +0200 @@ -24,56 +24,56 @@ cursor[CURSOR_C][0][j].LoadBaseImage(filename_c); sprintf(filename_c, "assets/cursors/placed_n%02d.png", j); - temp_surface = IMG_Load(filename_c); + temp_surface = ZSDL_IMG_Load(filename_c, false); cursor[PLACED_C][0][j].LoadBaseImage(temp_surface, false); cursor[PLACE_C][0][j].LoadBaseImage(temp_surface); //cursor[PLACED_C][0][j] = IMG_Load_Error(filename_c); //cursor[PLACE_C][0][j] = cursor[PLACED_C][0][j]; sprintf(filename_c, "assets/cursors/attacked_n%02d.png", j); - temp_surface = IMG_Load(filename_c); + temp_surface = ZSDL_IMG_Load(filename_c, false); cursor[ATTACKED_C][0][j].LoadBaseImage(temp_surface, false); cursor[ATTACK_C][0][j].LoadBaseImage(temp_surface); //cursor[ATTACKED_C][0][j] = IMG_Load_Error(filename_c); //cursor[ATTACK_C][0][j] = cursor[ATTACKED_C][0][j]; sprintf(filename_c, "assets/cursors/grabbed_n%02d.png", j); - temp_surface = IMG_Load(filename_c); + temp_surface = ZSDL_IMG_Load(filename_c, false); cursor[GRABBED_C][0][j].LoadBaseImage(temp_surface, false); cursor[GRAB_C][0][j].LoadBaseImage(temp_surface); //cursor[GRABBED_C][0][j] = IMG_Load_Error(filename_c); //cursor[GRAB_C][0][j] = cursor[GRABBED_C][0][j]; sprintf(filename_c, "assets/cursors/grenaded_n%02d.png", j); - temp_surface = IMG_Load(filename_c); + temp_surface = ZSDL_IMG_Load(filename_c, false); cursor[GRENADED_C][0][j].LoadBaseImage(temp_surface, false); cursor[GRENADE_C][0][j].LoadBaseImage(temp_surface); //cursor[GRENADED_C][0][j] = IMG_Load_Error(filename_c); //cursor[GRENADE_C][0][j] = cursor[GRENADED_C][0][j]; sprintf(filename_c, "assets/cursors/repaired_n%02d.png", j); - temp_surface = IMG_Load(filename_c); + temp_surface = ZSDL_IMG_Load(filename_c, false); cursor[REPAIRED_C][0][j].LoadBaseImage(temp_surface, false); cursor[REPAIR_C][0][j].LoadBaseImage(temp_surface); //cursor[REPAIRED_C][0][j] = IMG_Load_Error(filename_c); //cursor[REPAIR_C][0][j] = cursor[REPAIRED_C][0][j]; sprintf(filename_c, "assets/cursors/entered_n%02d.png", j); - temp_surface = IMG_Load(filename_c); + temp_surface = ZSDL_IMG_Load(filename_c, false); cursor[ENTERED_C][0][j].LoadBaseImage(temp_surface, false); cursor[ENTER_C][0][j].LoadBaseImage(temp_surface); //cursor[ENTERED_C][0][j] = IMG_Load_Error(filename_c); //cursor[ENTER_C][0][j] = cursor[ENTERED_C][0][j]; sprintf(filename_c, "assets/cursors/exited_n%02d.png", j); - temp_surface = IMG_Load(filename_c); + temp_surface = ZSDL_IMG_Load(filename_c, false); cursor[EXITED_C][0][j].LoadBaseImage(temp_surface, false); cursor[EXIT_C][0][j].LoadBaseImage(temp_surface); //cursor[EXITED_C][0][j] = IMG_Load_Error(filename_c); //cursor[EXIT_C][0][j] = cursor[EXITED_C][0][j]; sprintf(filename_c, "assets/cursors/cannoned_n%02d.png", j); - temp_surface = IMG_Load(filename_c); + temp_surface = ZSDL_IMG_Load(filename_c, false); cursor[CANNONED_C][0][j].LoadBaseImage(temp_surface, false); cursor[CANNON_C][0][j].LoadBaseImage(temp_surface); //cursor[CANNONED_C][0][j] = IMG_Load_Error(filename_c); diff -burN zod_engine/zod_src/main.cpp zod_engine.new/zod_src/main.cpp --- zod_engine/zod_src/main.cpp 2011-09-06 17:35:11.000000000 +0200 +++ zod_engine.new/zod_src/main.cpp 2012-05-05 17:49:03.000000000 +0200 @@ -42,7 +42,7 @@ printf("Welcome to the Zod Engine\n"); - if(argc<=1) starting_conditions.setdefaults(); + if(argc==1) starting_conditions.setdefaults(); //read in the arguments starting_conditions.getoptions(argc, argv); @@ -51,6 +51,9 @@ //like we are trying to make a dedicated server that is supposed to connect to another server starting_conditions.checkoptions(); + //init engine search paths + COMMON::init_file_paths(argv[0]); + //init this for the bots ZCore::CreateRandomBotBypassData(bot_bypass_data, bot_bypass_size); diff -burN zod_engine/zod_src/map_editor.cpp zod_engine.new/zod_src/map_editor.cpp --- zod_engine/zod_src/map_editor.cpp 2011-09-06 17:35:11.000000000 +0200 +++ zod_engine.new/zod_src/map_editor.cpp 2012-05-05 21:50:20.000000000 +0200 @@ -270,6 +270,8 @@ //check if args ok if(!checkargs(argv[0])) return 0; + //init filesystem search paths + COMMON::init_file_paths(argv[0]); //init SDL SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO); screen = SDL_SetVideoMode(800,600,32,SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE); @@ -287,8 +289,15 @@ ZSDL_Surface::SetHasHud(false); //TTF + char path[FILENAME_MAX]; + TTF_Init(); - ttf_font = TTF_OpenFont("assets/arial.ttf",10); + ttf_font = NULL; + if (COMMON::get_os_path("assets/arial.ttf", true, path)) + { + ttf_font = TTF_OpenFont(path,10); + } + if (!ttf_font) printf("could not load arial.ttf\n"); //init stuff @@ -499,10 +508,8 @@ //save the map { bmp_filename = filename + ".bmp"; - printf("saving map screenshot: '%s'\n", bmp_filename.c_str()); - - SDL_SaveBMP(print_surface, bmp_filename.c_str()); + ZSDL_SaveBMP(print_surface, filename); } SDL_FreeSurface(print_surface); diff -burN zod_engine/zod_src/map_merger.cpp zod_engine.new/zod_src/map_merger.cpp --- zod_engine/zod_src/map_merger.cpp 2011-09-06 17:35:11.000000000 +0200 +++ zod_engine.new/zod_src/map_merger.cpp 2012-05-05 16:17:15.000000000 +0200 @@ -16,6 +16,9 @@ return 0; } + //init filesystem paths + COMMON::init_file_paths(argv[0]); + printf("argc:%d\n", argc); printf("output_map:'%s'\n", argv[1]); printf("direction:'%s'\n", argv[2]); diff -burN zod_engine/zod_src/ogrenades.cpp zod_engine.new/zod_src/ogrenades.cpp --- zod_engine/zod_src/ogrenades.cpp 2011-09-06 17:35:11.000000000 +0200 +++ zod_engine.new/zod_src/ogrenades.cpp 2012-05-05 17:28:25.000000000 +0200 @@ -24,7 +24,7 @@ void OGrenades::Init() { - render_img.LoadBaseImage("assets/other/map_items/grenades.png");// = ZSDL_IMG_Load("assets/other/map_items/grenades.png"); + render_img.LoadBaseImage("assets/other/map_items/grenades.png");// = ZSDL_IMG_Load("assets/other/map_items/grenades.png", true); } void OGrenades::DoRender(ZMap &the_map, SDL_Surface *dest, int shift_x, int shift_y) diff -burN zod_engine/zod_src/ohut.cpp zod_engine.new/zod_src/ohut.cpp --- zod_engine/zod_src/ohut.cpp 2011-09-06 17:35:11.000000000 +0200 +++ zod_engine.new/zod_src/ohut.cpp 2012-05-05 17:28:13.000000000 +0200 @@ -42,7 +42,7 @@ for(i=0;imap_name.c_str(), "rb"); + fp = COMMON::open_file_read(p->map_name.c_str(), true); if(fp) { diff -burN zod_engine/zod_src/zsettings.cpp zod_engine.new/zod_src/zsettings.cpp --- zod_engine/zod_src/zsettings.cpp 2011-09-06 17:35:08.000000000 +0200 +++ zod_engine.new/zod_src/zsettings.cpp 2012-05-05 16:31:45.000000000 +0200 @@ -393,7 +393,7 @@ { FILE *fp; - fp = fopen(filename.c_str(), "r"); + fp = COMMON::open_file_read(filename.c_str(), false); if(!fp) { @@ -555,7 +555,7 @@ { FILE *fp; - fp = fopen(filename.c_str(), "w"); + fp = COMMON::open_file_write(filename.c_str(), false, false); if(!fp) { diff -burN zod_engine/zod_src/zteam.cpp zod_engine.new/zod_src/zteam.cpp --- zod_engine/zod_src/zteam.cpp 2011-09-06 17:35:07.000000000 +0200 +++ zod_engine.new/zod_src/zteam.cpp 2012-05-05 17:31:56.000000000 +0200 @@ -113,7 +113,7 @@ } //save surface - SDL_SaveBMP(src, filename.c_str()); + ZSDL_SaveBMP(src, filename); //free surface SDL_FreeSurface(src); @@ -264,7 +264,7 @@ if(team == ZTEAM_BASE_TEAM) return; filename = "assets/teams/" + team_type_string[team] + "_palette.bmp"; - surface = IMG_Load(filename.c_str()); + surface = ZSDL_IMG_Load(filename.c_str(), false); if(!surface) { @@ -294,7 +294,7 @@ team_palette[team].SaveSurfacePalette(filename); - //SDL_SaveBMP(team_palette[team], filename.c_str()); + //ZSDL_SaveBMP(team_palette[team], filename); } void ZTeam::SaveAllPalettes()