hasufell-repository/packages/games-strategy/zod-engine/files/zod-engine-20110906-proper-linux-support.patch

1391 lines
40 KiB
Diff
Raw Normal View History

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 <windows.h>
#include <time.h>
#include <direct.h>
+
+#define OSPATH_SEP '\\'
+
#else
#include <sys/stat.h>
#include <unistd.h>
#include <sys/time.h>
+
+#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<MAX_ANGLE_TYPES;j++)
{
sprintf(filename_c, "assets/units/cannons/gatling/empty_r%03d.png", ROTATION[j]);
- temp_surface = IMG_Load(filename_c);
+ temp_surface = ZSDL_IMG_Load(filename_c, false);
fire[0][j].LoadBaseImage(temp_surface, false);
passive[0][j].LoadBaseImage(temp_surface, false);
//fire[0][j] = passive[0][j] = IMG_Load_Error(filename_c);
diff -burN zod_engine/zod_src/common.cpp zod_engine.new/zod_src/common.cpp
--- zod_engine/zod_src/common.cpp 2011-09-06 17:35:10.000000000 +0200
+++ zod_engine.new/zod_src/common.cpp 2012-05-06 03:00:00.000000000 +0200
@@ -3,12 +3,16 @@
#include <ctype.h>
#include <math.h>
#include <string.h>
+#include <algorithm>
#include "common.h"
#ifdef _WIN32
#include <windows.h>
#include <time.h>
#include <direct.h>
+
+#define OSPATH_SEP '\\'
+
#else
#include <sys/stat.h>
#include <unistd.h>
@@ -16,20 +20,257 @@
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
+
+#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<string> scan_folder(string foldername)
+{
+ vector<string> 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(&lt);
- 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<string> directory_filelist(string foldername)
{
- vector<string> filelist;
+ vector<string> list;
+ vector<string> base;
+ vector<string> 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<list.size(); i++) printf("list found:%s\n", list[i].c_str());
+ // for (size_t i=0;i<base.size(); i++) printf("base found:%s\n", base[i].c_str());
- hFind = FindFirstFile(foldername.c_str(), &ffd);
+ // add unique entries for each file
+ sort(list.begin(), list.end(), sort_string_func);
+ merged = list;
+ for (size_t i = 0; i < base.size(); i++) {
+ vector<string>::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.size(); i++) printf("filelist found:%s\n", filelist[i].c_str());
+ // for (size_t i=0;i<merged.size(); i++) printf("merged found:%s\n", merged[i].c_str());
- return filelist;
+ return merged;
}
void parse_filelist(vector<string> &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 <stdio.h>
#include <string>
#include <vector>
#include <stdlib.h>
@@ -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;i<MAX_PLANET_TYPES;i++)
{
filename = "assets/other/map_items/hut_" + planet_type_string[i] + ".png";
- render_img[i].LoadBaseImage(filename);// = ZSDL_IMG_Load(filename);
+ render_img[i].LoadBaseImage(filename);// = ZSDL_IMG_Load(filename, true);
}
}
diff -burN zod_engine/zod_src/omapobject.cpp zod_engine.new/zod_src/omapobject.cpp
--- zod_engine/zod_src/omapobject.cpp 2011-09-06 17:35:11.000000000 +0200
+++ zod_engine.new/zod_src/omapobject.cpp 2012-05-05 17:22:19.000000000 +0200
@@ -42,7 +42,7 @@
for(i=0;i<MAP_ITEMS_AMOUNT;i++)
{
sprintf(filename_c, "assets/other/map_items/map_object%d.png", i);
- render_img[i].LoadBaseImage(filename_c);// = ZSDL_IMG_Load(filename_c);
+ render_img[i].LoadBaseImage(filename_c);// = ZSDL_IMG_Load(filename_c, true);
}
}
diff -burN zod_engine/zod_src/orock.cpp zod_engine.new/zod_src/orock.cpp
--- zod_engine/zod_src/orock.cpp 2011-09-06 17:35:11.000000000 +0200
+++ zod_engine.new/zod_src/orock.cpp 2012-05-05 17:27:26.000000000 +0200
@@ -70,7 +70,7 @@
for(i=0;i<MAX_PLANET_TYPES;i++)
{
filename = "assets/planets/rocks_" + planet_type_string[i] + ".png";
- rock_pal[i].LoadBaseImage(filename);// = ZSDL_IMG_Load(filename);
+ rock_pal[i].LoadBaseImage(filename);// = ZSDL_IMG_Load(filename, true);
if(rock_pal[i].GetBaseSurface())
{
diff -burN zod_engine/zod_src/tile_info_editor.cpp zod_engine.new/zod_src/tile_info_editor.cpp
--- zod_engine/zod_src/tile_info_editor.cpp 2011-09-06 17:35:11.000000000 +0200
+++ zod_engine.new/zod_src/tile_info_editor.cpp 2012-05-05 16:20:57.000000000 +0200
@@ -76,6 +76,8 @@
//seed
srand(time(0));
+ //init filesystem search paths
+ COMMON::init_file_paths(argv[0]);
//init SDL
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
@@ -94,8 +96,18 @@
//TTF
TTF_Init();
- ttf_font = TTF_OpenFont("assets/arial.ttf",10);
+ FILE *fp = COMMON::open_file_read("assets/arial.ttf",true);
+ if (fp)
+ {
+ SDL_RWops *rw = SDL_RWFromFP(fp,1);
+
+ ttf_font = TTF_OpenFontRW(rw,1,10);
if (!ttf_font) printf("could not load arial.ttf\n");
+ }
+ else
+ {
+ printf("cannot find arial.ttf\n");
+ }
//init map class
ZMap::Init();
diff -burN zod_engine/zod_src/zcore.cpp zod_engine.new/zod_src/zcore.cpp
--- zod_engine/zod_src/zcore.cpp 2011-09-06 17:35:11.000000000 +0200
+++ zod_engine.new/zod_src/zcore.cpp 2012-05-05 16:25:45.000000000 +0200
@@ -111,7 +111,7 @@
//clients and servers on different threads may use this function
SDL_LockMutex(check_mutex);
- fp = fopen("registration.zkey", "r");
+ fp = COMMON::open_file_read("registration.zkey", false);
if(!fp)
{
diff -burN zod_engine/zod_src/zfont.cpp zod_engine.new/zod_src/zfont.cpp
--- zod_engine/zod_src/zfont.cpp 2011-09-06 17:35:11.000000000 +0200
+++ zod_engine.new/zod_src/zfont.cpp 2012-05-05 17:29:09.000000000 +0200
@@ -16,7 +16,7 @@
for(i=0;i<MAX_CHARACTERS;i++)
{
sprintf(filename_c, "assets/fonts/%s/char_%03d.png", font_type_string[type].c_str(), i);
- char_img[i] = IMG_Load(filename_c);
+ char_img[i] = ZSDL_IMG_Load(filename_c, false);
}
finished_init = true;
diff -burN zod_engine/zod_src/zgfile.cpp zod_engine.new/zod_src/zgfile.cpp
--- zod_engine/zod_src/zgfile.cpp 2011-09-06 17:35:11.000000000 +0200
+++ zod_engine.new/zod_src/zgfile.cpp 2012-05-05 16:24:41.000000000 +0200
@@ -16,7 +16,7 @@
{
FILE *fp;
- fp = fopen(ZGFILE_NAME, "rb");
+ fp = COMMON::open_file_read(ZGFILE_NAME, true);
if(!fp)
{
@@ -90,7 +90,7 @@
return;
}
- fp = fopen(ZGFILE_NAME, "ab");
+ fp = COMMON::open_file_write(ZGFILE_NAME, true, true);
if(!fp)
{
@@ -166,7 +166,7 @@
return NULL;
}
- fp = fopen(ZGFILE_NAME, "rb");
+ fp = COMMON::open_file_read(ZGFILE_NAME, true);
if(!fp)
{
diff -burN zod_engine/zod_src/zmap.cpp zod_engine.new/zod_src/zmap.cpp
--- zod_engine/zod_src/zmap.cpp 2011-09-06 17:35:11.000000000 +0200
+++ zod_engine.new/zod_src/zmap.cpp 2012-05-05 17:18:57.000000000 +0200
@@ -69,7 +69,7 @@
//load BMP palette
filename = "assets/planets/" + planet_type_string[i] + ".bmp";
- planet_template[i].LoadBaseImage(filename);// = SDL_LoadBMP ( filename.c_str() );
+ planet_template[i].LoadBaseImage(filename);// = ZSDL_LoadBMP ( filename.c_str() );
//if(!planet_template[i])
// printf("unable to load:%s\n", filename.c_str());
@@ -124,7 +124,7 @@
SDL_LockMutex(init_mutex);
filename = "assets/planets/" + planet_type_string[i] + ".tileinfo";
- fp = fopen(filename.c_str(), "rb");
+ fp = COMMON::open_file_read(filename.c_str(), true);
if(!fp)
{
@@ -195,7 +195,7 @@
filename = "assets/planets/" + planet_type_string[palette] + ".tileinfo";
- fp = fopen(filename.c_str(), "wb");
+ fp = COMMON::open_file_write(filename.c_str(), true, false);
if(!fp) return 0;
@@ -216,7 +216,7 @@
{
filename = "assets/planets/" + planet_type_string[i] + ".tileinfo";
- fp = fopen(filename.c_str(), "wb");
+ fp = COMMON::open_file_write(filename.c_str(), true, false);
if(!fp)
{
@@ -979,7 +979,7 @@
if(!filename) return 0;
if(!filename[0]) return 0;
- fp = fopen(filename, "rb");
+ fp = COMMON::open_file_read(filename, true);
if(!fp) return 0;
@@ -1075,7 +1075,7 @@
if(!filename) return 0;
if(!filename[0]) return 0;
- fp = fopen(filename, "wb");
+ fp = COMMON::open_file_write(filename, true, false);
if(!fp) return 0;
diff -burN zod_engine/zod_src/zmap_crater_graphics.cpp zod_engine.new/zod_src/zmap_crater_graphics.cpp
--- zod_engine/zod_src/zmap_crater_graphics.cpp 2011-09-06 17:35:11.000000000 +0200
+++ zod_engine.new/zod_src/zmap_crater_graphics.cpp 2012-05-05 17:20:54.000000000 +0200
@@ -33,7 +33,7 @@
sprintf(filename, "assets/planets/craters/crater_small_%s_t%02d_n%02d.png", planet_type_string[p].c_str(), t, n);
- surface = IMG_Load(filename);
+ surface = ZSDL_IMG_Load(filename, false);
//not loaded?
if(!surface) break;
@@ -60,7 +60,7 @@
sprintf(filename, "assets/planets/craters/crater_large_%s_t%02d_n%02d.png", planet_type_string[p].c_str(), t, n);
- surface = IMG_Load(filename);
+ surface = ZSDL_IMG_Load(filename, false);
//not loaded?
if(!surface) break;
diff -burN zod_engine/zod_src/zplayer.cpp zod_engine.new/zod_src/zplayer.cpp
--- zod_engine/zod_src/zplayer.cpp 2011-09-06 17:35:12.000000000 +0200
+++ zod_engine.new/zod_src/zplayer.cpp 2012-05-05 21:47:14.000000000 +0200
@@ -367,12 +367,13 @@
Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */
int audio_channels = 2;
int audio_buffers = 4096;
+ char font_path[FILENAME_MAX];
//init SDL
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
//some stuff that just has to be right after init
- game_icon = IMG_Load("assets/icon.png");
+ game_icon = ZSDL_IMG_Load("assets/icon.png", false);
//ffuts
if(game_icon) SDL_WM_SetIcon(game_icon, NULL);
@@ -436,13 +437,18 @@
//TTF
TTF_Init();
- ttf_font = TTF_OpenFont("assets/arial.ttf",10);
- ttf_font_7 = TTF_OpenFont("assets/arial.ttf",7);
+ ttf_font = NULL;
+ if (COMMON::get_os_path("assets/arial.ttf", true, font_path))
+ {
+ ttf_font = TTF_OpenFont(font_path,10);
+ ttf_font_7 = TTF_OpenFont(font_path,7);
+ }
+
if (!ttf_font) printf("could not load assets/arial.ttf\n");
//splash sound best loaded here
//splash_music = MUS_Load_Error("assets/sounds/ABATTLE.mp3");
- splash_screen.LoadBaseImage("assets/splash.bmp");// = IMG_Load("assets/splash.bmp");
+ splash_screen.LoadBaseImage("assets/splash.bmp");// = ZSDL_IMG_Load("assets/splash.bmp", false);
splash_screen.UseDisplayFormat(); //Regular needs this to do fading
// if(splash_screen)
diff -burN zod_engine/zod_src/zplayer_events.cpp zod_engine.new/zod_src/zplayer_events.cpp
--- zod_engine/zod_src/zplayer_events.cpp 2011-09-06 17:35:12.000000000 +0200
+++ zod_engine.new/zod_src/zplayer_events.cpp 2012-05-05 16:30:09.000000000 +0200
@@ -1402,7 +1402,7 @@
FILE *fp;
int ret;
- fp = fopen("registration.zkey", "w");
+ fp = COMMON::open_file_write("registration.zkey", false, false);
if(!fp)
{
diff -burN zod_engine/zod_src/zpsettings.cpp zod_engine.new/zod_src/zpsettings.cpp
--- zod_engine/zod_src/zpsettings.cpp 2011-09-06 17:35:12.000000000 +0200
+++ zod_engine.new/zod_src/zpsettings.cpp 2012-05-05 16:36:55.000000000 +0200
@@ -35,7 +35,7 @@
{
FILE *fp;
- fp = fopen(filename.c_str(), "r");
+ fp = COMMON::open_file_read(filename.c_str(), false);
if(!fp)
{
@@ -106,7 +106,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/zrobot.cpp zod_engine.new/zod_src/zrobot.cpp
--- zod_engine/zod_src/zrobot.cpp 2011-09-06 17:35:12.000000000 +0200
+++ zod_engine.new/zod_src/zrobot.cpp 2012-05-05 17:23:22.000000000 +0200
@@ -168,7 +168,7 @@
SDL_Surface *temp_surface;
strcpy(filename_c, "assets/units/robots/null.png");
- temp_surface = IMG_Load(filename_c);
+ temp_surface = ZSDL_IMG_Load(filename_c, false);
for(j=0;j<MAX_ANGLE_TYPES;j++)
stand[0][j].LoadBaseImage(temp_surface, false);
diff -burN zod_engine/zod_src/zsdl.cpp zod_engine.new/zod_src/zsdl.cpp
--- zod_engine/zod_src/zsdl.cpp 2011-09-06 17:35:12.000000000 +0200
+++ zod_engine.new/zod_src/zsdl.cpp 2012-05-05 21:58:47.000000000 +0200
@@ -442,26 +442,53 @@
return src;
}
-SDL_Surface *ZSDL_IMG_Load(string filename)
+SDL_Surface *ZSDL_IMG_Load(string filename, bool to_display_format)
{
+ char path[FILENAME_MAX];
SDL_Surface *ret;
- ret = IMG_Load(filename.c_str());
+ if(!COMMON::get_os_path(filename.c_str(), true, path))
+ return NULL;
- if(!ret) printf("could not load:%s\n", filename.c_str());
+ ret = IMG_Load(path);
+ if (to_display_format)
ret = ZSDL_ConvertImage(ret);
- //SDL_DisplayFormat
-
return ret;
}
+bool ZSDL_SaveBMP(SDL_Surface *src, string filename)
+{
+ char path[FILENAME_MAX];
+
+ if (!COMMON::get_os_path(filename.c_str(), false, path))
+ {
+ printf("could not save:%s\n", filename.c_str());
+ return false;
+ }
+
+ return (SDL_SaveBMP(src, path) == 0);
+}
+
+SDL_Surface *ZSDL_LoadBMP(string filename)
+{
+ char path[FILENAME_MAX];
+
+ if (!COMMON::get_os_path(filename.c_str(), true, path))
+ {
+ printf("could not load:%s\n", filename.c_str());
+ return NULL;
+ }
+
+ return SDL_LoadBMP(path);
+}
+
SDL_Surface *IMG_Load_Error(string filename)
{
SDL_Surface *ret;
- if(!(ret = ZSDL_IMG_Load(filename.c_str()))) printf("could not load:%s\n", filename.c_str());
+ if(!(ret = ZSDL_IMG_Load(filename.c_str(), true))) printf("could not load:%s\n", filename.c_str());
//SDL_DisplayFormat
@@ -470,18 +497,24 @@
Mix_Music *MUS_Load_Error(string filename)
{
+ char path[FILENAME_MAX];
Mix_Music *ret;
- if(!(ret = Mix_LoadMUS(filename.c_str()))) printf("could not load:%s\n", filename.c_str());
+ if (!COMMON::get_os_path(filename.c_str(), true, path)) printf("could not open:%s\n", filename.c_str());
+
+ if (!(ret = Mix_LoadMUS(path))) printf("could not load:%s\n", filename.c_str());
return ret;
}
Mix_Chunk *MIX_Load_Error(string filename)
{
+ char path[FILENAME_MAX];
Mix_Chunk *ret;
- if(!(ret = Mix_LoadWAV(filename.c_str()))) printf("could not load:%s\n", filename.c_str());
+ if (!COMMON::get_os_path(filename.c_str(), true, path)) printf("could not open:%s\n", filename.c_str());
+
+ if (!(ret = Mix_LoadWAV(path))) printf("could not load:%s\n", filename.c_str());
return ret;
}
diff -burN zod_engine/zod_src/zsdl.h zod_engine.new/zod_src/zsdl.h
--- zod_engine/zod_src/zsdl.h 2011-09-06 17:35:09.000000000 +0200
+++ zod_engine.new/zod_src/zsdl.h 2012-05-05 17:34:05.000000000 +0200
@@ -64,8 +64,10 @@
};
SDL_Surface *ZSDL_ConvertImage(SDL_Surface *src);
-SDL_Surface *ZSDL_IMG_Load(string filename);
+SDL_Surface *ZSDL_IMG_Load(string filename, bool to_display_format);
SDL_Surface *IMG_Load_Error(string filename);
+bool ZSDL_SaveBMP(SDL_Surface *src, string filename);
+SDL_Surface *ZSDL_LoadBMP(string filename);
Mix_Music *MUS_Load_Error(string filename);
Mix_Chunk *MIX_Load_Error(string filename);
SDL_Surface *CopyImage(SDL_Surface *original);
diff -burN zod_engine/zod_src/zsdl_opengl.cpp zod_engine.new/zod_src/zsdl_opengl.cpp
--- zod_engine/zod_src/zsdl_opengl.cpp 2011-09-06 17:35:12.000000000 +0200
+++ zod_engine.new/zod_src/zsdl_opengl.cpp 2012-05-05 17:32:31.000000000 +0200
@@ -107,7 +107,7 @@
//set this for later debugging purposes
image_filename = filename;
- SDL_Surface *surface = IMG_Load(filename.c_str());
+ SDL_Surface *surface = ZSDL_IMG_Load(filename.c_str(), false);
LoadBaseImage(surface);
}
diff -burN zod_engine/zod_src/zserver.cpp zod_engine.new/zod_src/zserver.cpp
--- zod_engine/zod_src/zserver.cpp 2011-09-06 17:35:12.000000000 +0200
+++ zod_engine.new/zod_src/zserver.cpp 2012-05-06 02:44:12.000000000 +0200
@@ -270,7 +270,7 @@
//if we can't read in the official list
//and we can't make one
//then just use the regular map list
- if(!ReadSelectableMapList() && !ReadSelectableMapListFromFolder())
+ if(!ReadSelectableMapList() && !ReadSelectableMapListFromFolder("."))
selectable_map_list = map_list;
}
@@ -454,7 +454,7 @@
map_list.clear();
- fp = fopen(map_list_name.c_str(), "r");
+ fp = COMMON::open_file_read(map_list_name.c_str(), false);
if(!fp)
{
@@ -496,7 +496,7 @@
selectable_map_list.clear();
- fp = fopen(psettings.selectable_map_list.c_str(), "r");
+ fp = COMMON::open_file_read(psettings.selectable_map_list.c_str(), false);
if(!fp)
{
diff -burN zod_engine/zod_src/zserver_events.cpp zod_engine.new/zod_src/zserver_events.cpp
--- zod_engine/zod_src/zserver_events.cpp 2011-09-06 17:35:07.000000000 +0200
+++ zod_engine.new/zod_src/zserver_events.cpp 2012-05-05 16:32:42.000000000 +0200
@@ -164,7 +164,7 @@
{
FILE *fp;
- fp = fopen(p->map_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()