commit b81f58ad
Some changes to make it crosscompile with MXE. Might fail on travis since this changes a sdl2-config call that did not work for SDL1
Changed files
diff --git a/README.md b/README.md
index 1cb9689..9b90f6c 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ A Tetris Attack Clone under the GPL.
# Dependencies
* A version of g++ with C++11 support. Tested on g++-4.9
- * libSDL
+ * libSDL2
* libSDL2_image
* libSDL2_mixer
* libSDL2_ttf
diff --git a/source/code/Makefile b/source/code/Makefile
index f6f228a..99e464c 100644
--- a/source/code/Makefile
+++ b/source/code/Makefile
@@ -18,7 +18,7 @@ ifndef BUILDDIR
BUILDDIR=build
endif
-BASE_LIBS=$(shell $(CROSS)sdl2-config --libs) -lSDL2_ttf $(shell $(CROSS)pkg-config SDL2_image SDL2_mixer --libs) $(SAGO_BASE_LIBS)
+BASE_LIBS=$(shell $(CROSS)sdl2-config --libs) $(shell $(CROSS)pkg-config SDL2_image SDL2_mixer SDL2_ttf --libs) $(SAGO_BASE_LIBS)
#For developement only
ifndef DEBUG
@@ -43,11 +43,16 @@ else
BASE_CFLAGS += -DNETWORK=0
endif
+ifeq ($(CROSS),i686-w64-mingw32.static-)
+BASE_LIBS += -lws2_32
+endif
+
+
BASE_LIBS += -lphysfs
OFILES=main.o highscore.o ReadKeyboard.o joypad.o listFiles.o common.o stats.o Libs/NFont.o Libs/SDL_FontCache.o MenuSystem.o menudef.o puzzlehandler.o ${SAGO_O_FILES}
-ifeq ($(CROSS),i686-pc-mingw32-)
+ifeq ($(CROSS),i686-w64-mingw32.static-)
OFILES += winicon.res
BINARY := $(BINARY).exe
endif
@@ -73,7 +78,7 @@ run: $(BINARY)
cd $(GAMEDIR) && ./blockattack
clean:
- rm *.o *.P Libs/*.o Libs/*.P ; true
+ rm *.o *.P Libs/*.o Libs/*.P sago/*.o sago/*.P ; true
SOURCE_FILES = $(OFILES:.o=.cpp)
diff --git a/source/code/common.cpp b/source/code/common.cpp
index f67e43e..6dea098 100644
--- a/source/code/common.cpp
+++ b/source/code/common.cpp
@@ -92,7 +92,7 @@ int str2int(const string& str2parse) {
}
}
-#ifdef WIN32
+#ifdef _WIN32
//Returns path to "my Documents" in windows:
string getMyDocumentsPath() {
TCHAR pszPath[MAX_PATH];
@@ -123,7 +123,7 @@ string getMyDocumentsPath() {
string getPathToSaveFiles() {
#ifdef __unix__
return (string)getenv("HOME")+(string)"/.gamesaves/"+GAMENAME;
-#elif WIN32
+#elif _WIN32
return getMyDocumentsPath()+(string)"/My Games/"+GAMENAME;
#else
return ".";
diff --git a/source/code/common.h b/source/code/common.h
index ca985c8..d1dc9e7 100644
--- a/source/code/common.h
+++ b/source/code/common.h
@@ -44,7 +44,7 @@ http://blockattack.sf.net
#include <stdlib.h>
#include <libintl.h>
#include <boost/format.hpp>
-#ifdef WIN32
+#if defined(_WIN32)
#include "windows.h"
#include "shlobj.h"
#endif
@@ -83,8 +83,8 @@ void dieOnNullptr(bool, const char* msg);
*/
double str2double(const std::string &str2parse) __attribute__((const));
-#ifdef WIN32
-string getMyDocumentsPath();
+#if defined(_WIN32)
+std::string getMyDocumentsPath();
#endif
class TimeHandler
diff --git a/source/code/highscore.cpp b/source/code/highscore.cpp
index 9296673..a438203 100644
--- a/source/code/highscore.cpp
+++ b/source/code/highscore.cpp
@@ -25,7 +25,7 @@ http://blockattack.sf.net
using namespace std;
-#ifdef WIN32
+#ifdef _WIN32
//Returns path to "my Documents" in windows:
string getMyDocumentsPath1() {
diff --git a/source/code/listFiles.cpp b/source/code/listFiles.cpp
index cf2bbd0..1ccbcae 100644
--- a/source/code/listFiles.cpp
+++ b/source/code/listFiles.cpp
@@ -40,11 +40,9 @@ void ListFiles::setDirectory(const string& directory) {
cout << "Invalid file handle. Error is " << GetLastError() << endl;
}
else {
- nrOfFiles=0;
filenames.push_back(FindFileData.cFileName);
cout << "File: " << FindFileData.cFileName << endl;
- while ((FindNextFile(hFind, &FindFileData) != 0) && FindFileData.cFileName[0]!='.' && (nrOfFiles<MAX_NR_OF_FILES-1)) {
- nrOfFiles++;
+ while ((FindNextFile(hFind, &FindFileData) != 0) && FindFileData.cFileName[0]!='.') {
filenames.push_back(FindFileData.cFileName);
cout << "File: " << FindFileData.cFileName << endl;
}
diff --git a/source/code/main.cpp b/source/code/main.cpp
index 311713b..78a1425 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -56,7 +56,6 @@ http://blockattack.sf.net
#include <vector>
#include <SDL/SDL_timer.h>
#include <SDL/SDL_video.h>
-#include <SDL/SDL_ttf.h>
#include "MenuSystem.h"
#include "puzzlehandler.hpp"
#include <memory>
@@ -270,14 +269,15 @@ void NFont_Write(SDL_Renderer* target, int x, int y, const string& text) {
}
void ResetFullscreen() {
-#if defined(WIN32)
- if (bFullscreen) {
+#if defined(_WIN32)
+/* if (bFullscreen) {
screen=SDL_SetVideoMode(xsize,ysize,32,SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ANYFORMAT);
}
else {
screen=SDL_SetVideoMode(xsize,ysize,32,SDL_SWSURFACE|SDL_ANYFORMAT);
}
DrawIMG(background, screen, 0, 0);
+*/
#else
//TODO: Find SDL2 alternative
//SDL_WM_ToggleFullScreen(screen); //Will only work in Linux
@@ -1748,12 +1748,7 @@ void changePuzzleLevels() {
PuzzleSetSavePath(home+"/.gamesaves/blockattack/"+PuzzleGetName()+".save");
#elif defined(_WIN32)
string home = getMyDocumentsPath();
- if (&home!=nullptr) {
- PuzzleSetSavePath(home+"/My Games/blockattack/"+PuzzleGetName()+".save");
- }
- else {
- PuzzleSetSavePath(PuzzleGetName()+".save");
- }
+ PuzzleSetSavePath(home+"/My Games/blockattack/"+PuzzleGetName()+".save");
#else
PuzzleSetSavePath(PuzzleGetName()+".save");
#endif
diff --git a/source/code/sago/SagoDataHolder.cpp b/source/code/sago/SagoDataHolder.cpp
index e049df2..bfceb0f 100644
--- a/source/code/sago/SagoDataHolder.cpp
+++ b/source/code/sago/SagoDataHolder.cpp
@@ -29,7 +29,7 @@
#include <vector>
#include <physfs.h>
#include <memory>
-#include <SDL/SDL_mixer.h>
+#include <SDL_mixer.h>
namespace sago {
@@ -43,10 +43,6 @@ struct SagoDataHolder::SagoDataHolderData {
SDL_Renderer* renderer = nullptr;
};
-namespace {
-std::mutex mutex_texture_load;
-} //anonymous namespace
-
SagoDataHolder::SagoDataHolder(SDL_Renderer* renderer) {
data = new SagoDataHolderData();
data->renderer = renderer;
@@ -74,7 +70,6 @@ SagoDataHolder::~SagoDataHolder() {
}
SDL_Texture* SagoDataHolder::getTexturePtr(const std::string& textureName) const {
- std::lock_guard<std::mutex> guard(mutex_texture_load);
SDL_Texture* ret = data->textures[textureName];
if (ret) {
return ret;
@@ -117,7 +112,6 @@ SDL_Texture* SagoDataHolder::getTexturePtr(const std::string& textureName) const
}
TTF_Font* SagoDataHolder::getFontPtr(const std::string& fontName, int ptsize) const {
- std::lock_guard<std::mutex> guard(mutex_texture_load);
TTF_Font* ret = data->fonts[fontName][ptsize];
if (ret) {
return ret;
@@ -159,7 +153,6 @@ TTF_Font* SagoDataHolder::getFontPtr(const std::string& fontName, int ptsize) co
}
Mix_Music* SagoDataHolder::getMusicPtr(const std::string& musicName) const {
- std::lock_guard<std::mutex> guard(mutex_texture_load);
Mix_Music* ret = data->music[musicName];
if (ret) {
return ret;
@@ -200,7 +193,6 @@ Mix_Music* SagoDataHolder::getMusicPtr(const std::string& musicName) const {
Mix_Chunk* SagoDataHolder::getSoundPtr(const std::string& soundName) const {
- std::lock_guard<std::mutex> guard(mutex_texture_load);
Mix_Chunk* ret = data->sounds[soundName];
if (ret) {
return ret;
diff --git a/source/code/sago/SagoSpriteHolder.cpp b/source/code/sago/SagoSpriteHolder.cpp
index 0c805ee..18bc229 100644
--- a/source/code/sago/SagoSpriteHolder.cpp
+++ b/source/code/sago/SagoSpriteHolder.cpp
@@ -26,7 +26,11 @@
#include "SagoMisc.hpp"
#include <memory>
#include <unordered_map>
+#ifndef _WIN32
#include <jsoncpp/json/json.h>
+#else
+#include <json/json.h>
+#endif
#include <iostream>
#include <string.h>
#include <boost/algorithm/string/predicate.hpp>
@@ -123,4 +127,4 @@ const SagoDataHolder& SagoSpriteHolder::GetDataHolder() const {
return *data->tex;
}
-}
\ No newline at end of file
+}