File openbor-fix-build.patch of Package openbor

diff --git a/engine/source/utils.c b/engine/source/utils.c
index bf90c12..80b5eca 100644
--- a/engine/source/utils.c
+++ b/engine/source/utils.c
@@ -20,9 +20,7 @@
 #include "openbor.h"
 #include "packfile.h"
 
-#if !DC && !VITA
 #include <dirent.h>
-#endif
 
 #ifdef SDL
 #include <unistd.h>
@@ -34,29 +32,11 @@
 #include <sys/stat.h>
 #endif
 
-#ifdef DC
-#include "dcport.h"
-#endif
-
-#ifdef PSP
-#include "image.h"
-#endif
-
 #if WII
 #include "wiiport.h"
 #include "savepng.h"
 #endif
 
-#if VITA
-#include "vitaport.h"
-#include "savepng.h"
-#include <sys/stat.h>
-#include <psp2/io/dirent.h>
-typedef void DIR;
-#define opendir(X) ((DIR*)sceIoDopen(X))
-#define closedir(X) sceIoDclose((SceUID)(X))
-#endif
-
 #if ANDROID
 #include "sdlport.h"
 #include "savepng.h"
@@ -64,8 +44,6 @@ typedef void DIR;
 
 #ifdef WIN
 #define MKDIR(x) mkdir(x)
-#elif VITA
-#define MKDIR(x) sceIoMkdir(x, 0777)
 #else
 #define MKDIR(x) mkdir(x, 0777)
 #endif
@@ -77,13 +55,6 @@ typedef void DIR;
 #define READ_LOGFILE(type)   type ? fopen(getFullPath("Logs/OpenBorLog.txt"), "rt") : fopen(getFullPath("Logs/ScriptLog.txt"), "rt")
 #define COPY_ROOT_PATH(buf, name) strcpy(buf, rootDir); strcat(buf, name); strcat(buf, "/");
 #define COPY_PAKS_PATH(buf, name) strcpy(buf, paksDir); strcat(buf, "/"); strcat(buf, name);
-#elif VITA
-#define CHECK_LOGFILE(type)  type ? fileExists("ux0:/data/OpenBOR/Logs/OpenBorLog.txt") : fileExists("./Logs/ScriptLog.txt")
-#define OPEN_LOGFILE(type)   type ? fopen("ux0:/data/OpenBOR/Logs/OpenBorLog.txt", "wt") : fopen("ux0:/data/OpenBOR/Logs/ScriptLog.txt", "wt")
-#define APPEND_LOGFILE(type) type ? fopen("ux0:/data/OpenBOR/Logs/OpenBorLog.txt", "at") : fopen("ux0:/data/OpenBOR/Logs/ScriptLog.txt", "at")
-#define READ_LOGFILE(type)   type ? fopen("ux0:/data/OpenBOR/Logs/OpenBorLog.txt", "rt") : fopen("ux0:/data/OpenBOR/Logs/ScriptLog.txt", "rt")
-#define COPY_ROOT_PATH(buf, name) strcpy(buf, "ux0:/data/OpenBOR/"); strcat(buf, name); strcat(buf, "/");
-#define COPY_PAKS_PATH(buf, name) strcpy(buf, "ux0:/data/OpenBOR/Paks/"); strcat(buf, name);
 #elif ANDROID
 //msmalik681 now using AndroidRoot fuction from sdlport.c to update all android paths.
 #define Alog AndroidRoot("Logs/OpenBorLog.txt")
@@ -154,7 +125,6 @@ u32 debug_time = 0;
 
 void getBasePath(char *newName, char *name, int type)
 {
-#ifndef DC
     char buf[MAX_BUFFER_LEN] = {""};
     switch(type)
     {
@@ -166,14 +136,9 @@ void getBasePath(char *newName, char *name, int type)
         break;
     }
     strcpy(newName, buf);
-#else
-    strncpy(newName, name, MAX_LABEL_LEN - 1);
-#endif
 }
 
 
-
-#ifndef DC
 int dirExists(char *dname, int create)
 {
     char realName[MAX_LABEL_LEN] = {""};
@@ -241,18 +206,11 @@ CLOSE_AND_QUIT:
     fclose(handle);
     return buffer;
 }
-#endif
+
 
 void writeToLogFile(const char *msg, ...)
 {
     va_list arglist;
-
-#ifdef DC
-    va_start(arglist, msg);
-    vfprintf(stdout, msg, arglist);
-    va_end(arglist);
-    fflush(stdout);
-#else
     if(openborLog == NULL)
     {
         openborLog = OPEN_LOGFILE(OPENBOR_LOG);
@@ -265,12 +223,10 @@ void writeToLogFile(const char *msg, ...)
     vfprintf(openborLog, msg, arglist);
     va_end(arglist);
     fflush(openborLog);
-#endif
 }
 
 void writeToScriptLog(const char *msg)
 {
-#ifndef DC
     if(scriptLog == NULL)
     {
         scriptLog = OPEN_LOGFILE(SCRIPT_LOG);
@@ -281,7 +237,6 @@ void writeToScriptLog(const char *msg)
     }
     fwrite(msg, 1, strlen(msg), scriptLog);
     fflush(scriptLog);
-#endif
 }
 
 void debug_printf(char *format, ...)
@@ -303,10 +258,10 @@ void *checkAlloc(void *ptr, size_t size, const char *func, const char *file, int
                        "\n*            Shutting Down            *\n\n");
         writeToLogFile("Out of memory!\n");
         writeToLogFile("Allocation of size %i failed in function '%s' at %s:%i.\n", size, func, file, line);
-#ifndef WIN
-        writeToLogFile("Memory usage at exit: %u\n", mallinfo().arena);
-#elif LINUX
+#if LINUX && !DARWIN && !ANDROID
         writeToLogFile("Memory usage at exit: %u\n", mallinfo2().arena);
+#else
+        writeToLogFile("Memory usage at exit: %u\n", getUsedRam(BYTES));
 #endif
         borExit(2);
     }
@@ -397,48 +352,30 @@ void getPakName(char *name, int type)
 
 void screenshot(s_screen *vscreen, unsigned char *pal, int ingame)
 {
-#ifndef DC
     int	 shotnum = 0;
     char shotname[1024] = {""};
     char modname[MAX_FILENAME_LEN]  = {""};
 
     getPakName(modname, 99);
-#ifdef PSP
-    if(dirExists("ms0:/PICTURE/", 1) && dirExists("ms0:/PICTURE/Beats Of Rage/", 1))
+    do
     {
-#endif
-        do
-        {
-#if PSP
-            sprintf(shotname, "ms0:/PICTURE/Beats Of Rage/%s - ScreenShot - %02u.png", modname, shotnum);
-#elif SDL || WII
-            sprintf(shotname, "%s/%s - %04u.png", screenShotsDir, modname, shotnum);
+#if SDL || WII
+        sprintf(shotname, "%s/%s - %04u.png", screenShotsDir, modname, shotnum);
 #else
-            sprintf(shotname, "./ScreenShots/%s - %04u.png", modname, shotnum);
+        sprintf(shotname, "./ScreenShots/%s - %04u.png", modname, shotnum);
 #endif
-            ++shotnum;
-        }
-        while(fileExists(shotname) && shotnum < 10000);
+        ++shotnum;
+    }
+    while(fileExists(shotname) && shotnum < 10000);
 
-#ifdef PSP
-        if(shotnum < 10000)
-        {
-            saveImage(shotname);
-        }
-#else
-        if(shotnum < 10000)
-        {
-            savepng(shotname, vscreen, pal);
-        }
-#endif
-        if(ingame)
-        {
-            debug_printf("Saved %s", shotname);
-        }
-#ifdef PSP
+    if(shotnum < 10000)
+    {
+        savepng(shotname, vscreen, pal);
+    }
+    if(ingame)
+    {
+        debug_printf("Saved %s", shotname);
     }
-#endif
-#endif
 }
 
 unsigned readlsb32(const unsigned char *src)
@@ -550,8 +487,8 @@ char* multistrcatsp(char* buf, ...)
 char* safe_strncpy(char* dst, const char* src, size_t size)
 {
 	if (size > 0) {
-		register char *d = dst;
-		register const char *s = src;
+		char *d = dst;
+		const char *s = src;
 
 		do {
 			if ((*d++ = *s++) == 0) {
diff --git a/engine/source/utils.h b/engine/source/utils.h
index 6ac7d8b..9f17767 100644
--- a/engine/source/utils.h
+++ b/engine/source/utils.h
@@ -9,16 +9,16 @@
 #ifndef UTILS_H
 #define UTILS_H
 
-// *** INCLUDES ***
+// *** INCLUDES ***
 #include <time.h>
 #include "types.h"
 #include "stringptr.h"
 
 // *** TYPE DECLARATIONS ***
 #define SCRIPT_LOG 0
-#define OPENBOR_LOG 1
-#define TIMESTAMP_PATTERN "%Y-%m-%d %H:%M:%S"
-
+#define OPENBOR_LOG 1
+#define TIMESTAMP_PATTERN "%Y-%m-%d %H:%M:%S"
+
 // *** VARIABLE DECLARATIONS ***
 extern char debug_msg[2048];
 extern u32 debug_time;
@@ -26,22 +26,9 @@ extern u32 debug_time;
 // *** FUNCTIONS DECLARATIONS ***
 void writeToLogFile(const char *, ...);
 void writeToScriptLog(const char *msg);
-
-#ifndef DC
 int fileExists(char *fnam);
 int dirExists(char *dname, int create);
 stringptr *readFromLogFile(int which);
-#endif
-
-#ifdef DC
-typedef struct
-{
-    char filename[80];
-} s_filelist;
-s_filelist paklist[20];
-
-int findmods(void);
-#endif
 
 void lc(char *buf, size_t size);
 size_t getNewLineStart(char *buf);
@@ -57,11 +44,11 @@ unsigned readlsb32(const unsigned char *src);
 int searchList(const char *list[], const char *value, int length);
 //int searchListB(const char *list[], const char *value, int length);
 char *commaprint(u64 n);
-char* multistrcatsp(char* buf, ...);
-char* safe_strncpy(char* dst, const char* src, size_t size);
-int safe_stricmp(const char *s1, const char *s2);
-int safe_strnicmp(const char *s1, const char *s2, size_t n);
-void get_time_string(char buffer[], unsigned buffer_size, time_t timestamp, char* pattern); // pattern ex. "%Y-%m-%d %H:%M:%S"
+char* multistrcatsp(char* buf, ...);
+char* safe_strncpy(char* dst, const char* src, size_t size);
+int safe_stricmp(const char *s1, const char *s2);
+int safe_strnicmp(const char *s1, const char *s2, size_t n);
+void get_time_string(char buffer[], unsigned buffer_size, time_t timestamp, char* pattern); // pattern ex. "%Y-%m-%d %H:%M:%S"
 void get_now_string(char buffer[], unsigned buffer_size, char* pattern);
 
 void Array_Check_Size( const char *f_caller, char **array, int new_size, int *curr_size_allocated, int grow_step );
openSUSE Build Service is sponsored by