Thomas Buck 10 роки тому
джерело
коміт
129604f2cf

+ 9
- 0
CMakeLists.txt Переглянути файл

@@ -70,6 +70,15 @@ add_subdirectory (src)
70 70
 
71 71
 #################################################################
72 72
 
73
+if (${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles")
74
+
75
+	# Target for running the setup
76
+    add_custom_target (setup "${PROJECT_SOURCE_DIR}/cmake/setup_win.bat"
77
+        WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
78
+    )
79
+
80
+endif (${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles") 
81
+
73 82
 if (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
74 83
 
75 84
     # Target for running the setup

+ 5
- 0
ChangeLog.md Переглянути файл

@@ -2,6 +2,11 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+	[ 20140702 ]
6
+	* Compiled successfully in Windows 7 using MinGW
7
+	* Added Windows setup script
8
+	* FontTRLE lps parser no longer using std::stoi
9
+
5 10
     [ 20140626 ]
6 11
     * ColorMode enum now global
7 12
     * Entities setAngles now sets all three angles

+ 17
- 0
cmake/setup_win.bat Переглянути файл

@@ -0,0 +1,17 @@
1
+@echo off
2
+
3
+if not exist "%UserProfile%\.OpenRaider" (
4
+	echo Setting up for %UserName%...
5
+	mkdir "%UserProfile%\.OpenRaider"
6
+	copy data\OpenRaider.ini %UserProfile%\.OpenRaider
7
+	mkdir %UserProfile%\.OpenRaider\paks
8
+	mkdir %UserProfile%\.OpenRaider\music
9
+	mkdir %UserProfile%\.OpenRaider\data
10
+	mkdir %UserProfile%\.OpenRaider\sshots
11
+	copy data\*.tga %UserProfile%\.OpenRaider\data
12
+	copy data\*.ttf %UserProfile%\.OpenRaider\data
13
+	copy data\*.pc %UserProfile%\.OpenRaider\data
14
+	echo Done!
15
+) else (
16
+	echo Already done
17
+)

+ 0
- 1
include/WindowSDL.h Переглянути файл

@@ -9,7 +9,6 @@
9 9
 #define _WINDOW_SDL_H_
10 10
 
11 11
 #include "SDL.h"
12
-#include "SDL_ttf.h"
13 12
 
14 13
 #include "Window.h"
15 14
 

+ 1
- 0
include/global.h Переглянути файл

@@ -102,6 +102,7 @@ KeyboardButton stringToKeyboardButton(const char *key);
102 102
 #include <windows.h>
103 103
 #endif
104 104
 #include <GL/gl.h>
105
+#include <GL/glext.h>
105 106
 #endif
106 107
 
107 108
 // If available, use our own assert that prints the call stack

+ 4
- 1
src/FontManager.cpp Переглянути файл

@@ -9,9 +9,12 @@
9 9
 #include "utils/strings.h"
10 10
 #include "FontManager.h"
11 11
 #include "Font.h"
12
-#include "FontSDL.h"
13 12
 #include "FontTRLE.h"
14 13
 
14
+#ifdef USING_SDL_FONT
15
+#include "FontSDL.h"
16
+#endif
17
+
15 18
 FontManager::FontManager() {
16 19
     add(new FontTRLE(), ".pc");
17 20
 

+ 2
- 0
src/FontSDL.cpp Переглянути файл

@@ -5,6 +5,8 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
+#include <stdio.h>
9
+
8 10
 #include "global.h"
9 11
 #include "FontSDL.h"
10 12
 

+ 17
- 26
src/FontTRLE.cpp Переглянути файл

@@ -72,32 +72,23 @@ void FontTRLE::loadLPS(const char *f) {
72 72
 
73 73
     for (std::string line; std::getline(file, line);) {
74 74
         std::istringstream stream(line);
75
-        std::string tok1, tok2;
76
-        std::getline(stream, tok1, '=');
77
-        std::getline(stream, tok2);
78
-
79
-        // we are only interested in lines starting with
80
-        // xxx=
81
-        // Where xxx is a 3 digit number
82
-        try {
83
-            int index = std::stoi(tok1);
84
-            if ((index >= 0) && (index <= 105)) {
85
-                std::istringstream row(tok2);
86
-                std::string a, b, c, d, e;
87
-                std::getline(row, a, ',');
88
-                std::getline(row, b, ',');
89
-                std::getline(row, c, ',');
90
-                std::getline(row, d, ',');
91
-                std::getline(row, e);
92
-                offsets[index][0] = std::stoi(a);
93
-                offsets[index][1] = std::stoi(b);
94
-                offsets[index][2] = std::stoi(c);
95
-                offsets[index][3] = std::stoi(d);
96
-                offsets[index][4] = std::stoi(e);
97
-            }
98
-        } catch (std::invalid_argument) {
99
-
100
-        }
75
+		int index;
76
+		stream >> index;
77
+		if (stream.get() != '=')
78
+			return;
79
+		stream >> offsets[index][0];
80
+		if (stream.get() != ',')
81
+			return;
82
+		stream >> offsets[index][1];
83
+		if (stream.get() != ',')
84
+			return;
85
+		stream >> offsets[index][2];
86
+		if (stream.get() != ',')
87
+			return;
88
+		stream >> offsets[index][3];
89
+		if (stream.get() != ',')
90
+			return;
91
+		stream >> offsets[index][4];
101 92
     }
102 93
 }
103 94
 

+ 1
- 1
src/Menu.cpp Переглянути файл

@@ -17,7 +17,7 @@
17 17
 #if defined(HAVE_DIRENT_H) && defined(HAVE_OPENDIR) && defined(HAVE_READDIR_R) && defined(HAVE_CLOSEDIR) && defined(HAVE_DT_DIR)
18 18
 #include <dirent.h>
19 19
 #define USE_DIRENT
20
-#elif defined(HAVE_WINDOWS_H) && defined(HAVE_FINDFIRSTFILE) && defined(HAVE_FINDNEXTFILE) && defined(HAVE_FINDCLOSE)
20
+#elif (defined(HAVE_WINDOWS_H) && defined(HAVE_FINDFIRSTFILE) && defined(HAVE_FINDNEXTFILE) && defined(HAVE_FINDCLOSE)) || defined (_WIN32)
21 21
 #include <windows.h>
22 22
 #define USE_FINDFILE
23 23
 #else

+ 7
- 1
src/TextureManager.cpp Переглянути файл

@@ -45,7 +45,7 @@ int TextureManager::initialize() {
45 45
     delete [] image;
46 46
 
47 47
     //! \fixme Temporary
48
-    char *filename = bufferString("%s/tr2/TITLE.PCX", getOpenRaider().mPakDir);
48
+    char *filename;// = bufferString("%s/tr2/TITLE.PCX", getOpenRaider().mPakDir);
49 49
     if (loadPCX(filename) < 0) {
50 50
         delete [] filename;
51 51
         //! \fixme Error Checking. Return negative error code, check in calling place too
@@ -72,16 +72,20 @@ int TextureManager::getTextureCount() {
72 72
 void TextureManager::disableMultiTexture() {
73 73
     mFlags &= ~fUseMultiTexture;
74 74
 
75
+#ifdef MULTITEXTURE
75 76
     glDisable(GL_TEXTURE_2D);
76 77
     glActiveTextureARB(GL_TEXTURE0_ARB);
78
+#endif
77 79
 }
78 80
 
79 81
 void TextureManager::useMultiTexture(float aU, float aV, float bU, float bV) {
80 82
     if (!(mFlags & fUseMultiTexture))
81 83
         return;
82 84
 
85
+#ifdef MULTITEXTURE
83 86
     glMultiTexCoord2fARB(GL_TEXTURE0_ARB, aU, aV);
84 87
     glMultiTexCoord2fARB(GL_TEXTURE1_ARB, bU, bV);
88
+#endif
85 89
 }
86 90
 
87 91
 void TextureManager::bindMultiTexture(int texture0, int texture1) {
@@ -92,6 +96,7 @@ void TextureManager::bindMultiTexture(int texture0, int texture1) {
92 96
 
93 97
     mFlags |= fUseMultiTexture;
94 98
 
99
+#ifdef MULTITEXTURE
95 100
     glActiveTextureARB(GL_TEXTURE0_ARB);
96 101
     glEnable(GL_TEXTURE_2D);
97 102
     glBindTexture(GL_TEXTURE_2D, mTextureIds.at(texture0));
@@ -99,6 +104,7 @@ void TextureManager::bindMultiTexture(int texture0, int texture1) {
99 104
     glActiveTextureARB(GL_TEXTURE1_ARB);
100 105
     glEnable(GL_TEXTURE_2D);
101 106
     glBindTexture(GL_TEXTURE_2D, mTextureIds.at(texture1));
107
+#endif
102 108
 }
103 109
 
104 110
 int TextureManager::loadBufferSlot(unsigned char *image,

+ 2
- 2
src/WindowSDL.cpp Переглянути файл

@@ -25,7 +25,7 @@ WindowSDL::WindowSDL() {
25 25
     mWindow = NULL;
26 26
     mGLContext = NULL;
27 27
 
28
-#ifdef WIN32
28
+#ifdef _WIN32
29 29
     setDriver("libGL32.dll");
30 30
 #elif !defined(__APPLE__)
31 31
     setDriver("/usr/lib/libGL.so.1");
@@ -84,7 +84,7 @@ int WindowSDL::initialize() {
84 84
         return -1;
85 85
     }
86 86
 
87
-#ifndef __APPLE__
87
+#if !(defined(__APPLE__) || defined(_WIN32))
88 88
     assert(mDriver != NULL);
89 89
     assert(mDriver[0] != '\0');
90 90
 

+ 11
- 9
src/utils/strings.cpp Переглянути файл

@@ -12,7 +12,7 @@
12 12
 
13 13
 #if defined(unix) || defined(__APPLE__) || defined(__linux__)
14 14
 #include <wordexp.h>
15
-#elif defined(WIN32)
15
+#elif defined(_WIN32)
16 16
 #include <Windows.h>
17 17
 #include <shlobj.h>
18 18
 #ifndef va_copy
@@ -171,16 +171,18 @@ char *fullPath(const char *path, char end) {
171 171
         }
172 172
 
173 173
         wordfree(&word);
174
-#elif defined(WIN32)
175
-        WCHAR newPath[MAX_PATH];
176
-        if (SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, newPath) == S_OK) {
177
-            lenPath = strlen((const char *)newPath);
174
+#elif defined(_WIN32)
175
+        char newPath[MAX_PATH];
176
+        if (SHGetFolderPath(NULL, CSIDL_PROFILE, NULL, 0, newPath) == S_OK) {
177
+            lenPath = strlen(newPath);
178 178
             unsigned int lenPath2 = strlen(path);
179 179
             dir = new char[lenPath + lenPath2 + 2]; // space for end char
180
-            strncpy(dir, (const char *)newPath, lenPath);
181
-            dir[lenPath] = '\\';
182
-            strncpy((dir + lenPath + 1), (path + 1), lenPath2 - 1);
183
-            lenPath += lenPath2;
180
+            strncpy(dir, newPath, lenPath);
181
+            strncpy((dir + lenPath), (path + 1), lenPath2 - 1);
182
+            lenPath += lenPath2 - 1;
183
+			for (unsigned int i = 0; i < lenPath; i++)
184
+				if(dir[i] == '\\')
185
+					dir[i] = '/';
184 186
         } else {
185 187
             printf("WARNING: Could not get home folder location for tilde expansion!\n");
186 188
             lenPath = strlen(path);

+ 1
- 1
src/utils/time.cpp Переглянути файл

@@ -26,7 +26,7 @@ void systemTimerReset() {
26 26
     gettimeofday(&system_timer_start, &system_timer_zone);
27 27
 }
28 28
 
29
-#elif defined(WIN32)
29
+#elif defined(_WIN32)
30 30
 
31 31
 #include <Windows.h>
32 32
 

Завантаження…
Відмінити
Зберегти