1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

[PLATFORM] MinGW support added

* disabled features unsupported by MinGW
* fixed issues with DLL_LINKAGE
! BOOST_THREAD_VERSION in now 3 workaround for existing code added, consider refactoring.
* some small tweaks ("-fpedantic" warnings)
This commit is contained in:
alexvins 2012-09-15 19:16:16 +00:00
parent 7087be1f02
commit 369f0ae9c6
19 changed files with 259 additions and 236 deletions

View File

@ -51,6 +51,9 @@
//The only available version is 3, as of Boost 1.50
#define BOOST_FILESYSTEM_VERSION 3
#define BOOST_THREAD_VERSION 3
#define BOOST_THREAD_DONT_PROVIDE_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE 1
//#define BOOST_SYSTEM_NO_DEPRECATED 1
#include <boost/algorithm/string.hpp>
#include <boost/assert.hpp>
@ -97,7 +100,11 @@ typedef boost::int8_t si8; //signed int 8 bits (1 byte)
// Import + Export macro declarations
#ifdef _WIN32
#ifdef __GNUC__
#define DLL_EXPORT __attribute__((dllexport))
#else
#define DLL_EXPORT __declspec(dllexport)
#endif
#else
#if defined(__GNUC__) && GCC_VERSION >= 400
#define DLL_EXPORT __attribute__ ((visibility("default")))
@ -107,7 +114,11 @@ typedef boost::int8_t si8; //signed int 8 bits (1 byte)
#endif
#ifdef _WIN32
#ifdef __GNUC__
#define DLL_IMPORT __attribute__((dllimport))
#else
#define DLL_IMPORT __declspec(dllimport)
#endif
#else
#if defined(__GNUC__) && GCC_VERSION >= 400
#define DLL_IMPORT __attribute__ ((visibility("default")))

View File

@ -29,7 +29,7 @@ struct BattleResult;
struct BattleSpellCast;
struct CObstacleInstance;
template <typename T> struct CondSh;
struct SetStackEffect;;
struct SetStackEffect;
struct BattleAction;
class CGTownInstance;
struct CatapultAttack;

View File

@ -27,4 +27,4 @@ namespace BitmapHandler
SDL_Surface * loadBitmapFromDir(std::string path, std::string fname, bool setKey=true);
//Load file from any LODs
SDL_Surface * loadBitmap(std::string fname, bool setKey=true);
};
}

View File

@ -351,7 +351,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const BMPPal
Uint32 keycol = SDL_MapRGBA(ret->format, ttcol.r, ttcol.b, ttcol.g, ttcol.unused);
SDL_SetColorKey(ret, SDL_SRCCOLORKEY, keycol);
return ret;
};
}
CDefEssential * CDefHandler::essentialize()
{

View File

@ -69,7 +69,7 @@ namespace boost
{
class mutex;
class recursive_mutex;
};
}
enum
{

View File

@ -124,7 +124,7 @@ public:
CPicture *playerListBg;
CHighlightableButtonsGroup *difficulty;
CDefHandler *sizes, *sFlags;;
CDefHandler *sizes, *sFlags;
void changeSelection(const CMapInfo *to);
void showAll(SDL_Surface * to);

View File

@ -142,11 +142,14 @@ bool CBIKHandler::open(std::string name)
tlog1 << "BIK handler: failed to open " << name << std::endl;
goto checkErrorAndClean;
}
//GCC wants scope of waveout to dont cross labels/swith/goto
{
void *waveout = GetProcAddress(dll,"_BinkOpenWaveOut@4");
if(waveout)
binkSetSoundSystem(waveout,NULL);
}
hBink = binkOpen(hBinkFile, 0x8a800000);
if(!hBink)
{

View File

@ -123,7 +123,7 @@ struct SSetCaptureState
namespace Colors
{
};
}
#define OBJ_CONSTRUCTION SObjectConstruction obj__i(this)
#define OBJ_CONSTRUCTION_CAPTURING_ALL defActions = 255; SSetCaptureState obj__i1(true, 255); SObjectConstruction obj__i(this)

View File

@ -1313,13 +1313,13 @@ void CBoundedLabel::recalculateLines(const std::string &Txt)
CLabelGroup::CLabelGroup(EFonts Font, EAlignment Align, const SDL_Color &Color):
font(Font), align(Align), color(Color)
{};
{}
void CLabelGroup::add(int x, int y, const std::string &text)
{
OBJ_CONSTRUCTION_CAPTURING_ALL;
new CLabel(x, y, font, align, color, text);
};
}
CTextBox::CTextBox(std::string Text, const Rect &rect, int SliderStyle, EFonts Font /*= FONT_SMALL*/, EAlignment Align /*= TOPLEFT*/, const SDL_Color &Color /*= Colors::Cornsilk*/)
:CBoundedLabel(rect.x, rect.y, Font, Align, Color, Text), sliderStyle(SliderStyle), slider(NULL)

View File

@ -193,4 +193,4 @@ namespace CSDL_Ext
void applyEffect(SDL_Surface * surf, const SDL_Rect * rect, int mode); //mode: 0 - sepia, 1 - grayscale
std::string trimToFit(std::string text, int widthLimit, EFonts font);
};
}

View File

@ -575,7 +575,7 @@ void CArtHandler::makeItCreatureArt (int aid, bool onlyCreature /*=true*/)
a->possibleSlots[ArtBearer::COMMANDER].clear();
}
a->possibleSlots[ArtBearer::CREATURE].push_back(ArtifactPosition::CREATURE_SLOT);
};
}
void CArtHandler::makeItCommanderArt (int aid, bool onlyCommander /*=true*/)
{
@ -587,7 +587,7 @@ void CArtHandler::makeItCommanderArt (int aid, bool onlyCommander /*=true*/)
}
for (int i = ArtifactPosition::COMMANDER1; i <= ArtifactPosition::COMMANDER6; ++i)
a->possibleSlots[ArtBearer::COMMANDER].push_back(i);
};
}
void CArtHandler::addBonuses()
{

View File

@ -25,9 +25,10 @@
#else
#define WIN32_LEAN_AND_MEAN //excludes rarely used stuff from windows headers - delete this line if something is missing
#include <windows.h>
#ifndef __MINGW32__
#include <dbghelp.h>
#pragma comment(lib, "dbghelp.lib")
#endif
typedef WORD TColor;
HANDLE handleIn;
HANDLE handleOut;
@ -114,6 +115,7 @@ LONG WINAPI onUnhandledException(EXCEPTION_POINTERS* exception)
const DWORD threadId = ::GetCurrentThreadId();
tlog1 << "Thread ID: " << threadId << " [" << std::dec << std::setw(0) << threadId << "]\n";
#ifndef __MINGW32__
//exception info to be placed in the dump
MINIDUMP_EXCEPTION_INFORMATION meinfo = {threadId, exception, TRUE};
@ -132,6 +134,7 @@ LONG WINAPI onUnhandledException(EXCEPTION_POINTERS* exception)
HANDLE dfile = CreateFileA(mname, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0);
tlog1 << "Crash info will be put in " << mname << std::endl;
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), dfile, MiniDumpWithDataSegs, &meinfo, 0, 0);
#endif
MessageBoxA(0, "VCMI has crashed. We are sorry. File with information about encountered problem has been created.", "VCMI Crashhandler", MB_OK | MB_ICONERROR);
return EXCEPTION_EXECUTE_HANDLER;
}

View File

@ -133,7 +133,7 @@ public:
class DLL_LINKAGE CCreatureSet : public IArmyDescriptor //seven combined creatures
{
CCreatureSet(const CCreatureSet&);;
CCreatureSet(const CCreatureSet&);
CCreatureSet &operator=(const CCreatureSet&);
public:
TSlots stacks; //slots[slot_id]->> pair(creature_id,creature_quantity)

View File

@ -53,13 +53,13 @@ std::vector<const CArtifact *> CGTownInstance::merchantArtifacts;
std::vector<int> CGTownInstance::universitySkills;
void IObjectInterface::onHeroVisit(const CGHeroInstance * h) const
{};
{}
void IObjectInterface::onHeroLeave(const CGHeroInstance * h) const
{};
{}
void IObjectInterface::newTurn () const
{};
{}
IObjectInterface::~IObjectInterface()
{}

View File

@ -50,6 +50,7 @@ void CThreadHelper::processTasks()
void setThreadName(const std::string &name)
{
#ifdef _WIN32
#ifndef __GNUC__
//follows http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
const DWORD MS_VC_EXCEPTION=0x406D1388;
#pragma pack(push,8)
@ -67,6 +68,7 @@ void setThreadName(const std::string &name)
info.dwThreadID = -1;
info.dwFlags = 0;
__try
{
RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );
@ -74,6 +76,10 @@ void setThreadName(const std::string &name)
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
#else
//not supported
#endif
#else
prctl(PR_SET_NAME, name.c_str(), 0, 0, 0);
#endif

View File

@ -66,7 +66,7 @@ namespace boost
class basic_socket_acceptor;
}
class mutex;
};
}
enum SerializationLvl
{

View File

@ -641,7 +641,7 @@ namespace NBonus
//DLL_LINKAGE const HeroBonus * get(const CBonusSystemNode *obj, int from, int id );
DLL_LINKAGE void getModifiersWDescr(const CBonusSystemNode *obj, TModDescr &out, Bonus::BonusType type, int subtype = -1 ); //out: pairs<modifier value, modifier description>
DLL_LINKAGE int getCount(const CBonusSystemNode *obj, int from, int id);
};
}
/// generates HeroBonus from given data
inline Bonus makeFeatureVal(Bonus::BonusType type, ui8 duration, si16 subtype, si32 value, Bonus::BonusSource source, ui16 turnsRemain = 0, si32 additionalInfo = 0)

View File

@ -48,7 +48,7 @@ struct CPack
{
tlog1 << "CPack serialized... this should not happen!\n";
}
DLL_LINKAGE void applyGs(CGameState *gs)
void applyGs(CGameState *gs)
{};
};
@ -629,7 +629,7 @@ struct NewStructures : public CPackForClient //504
{
NewStructures(){type = 504;};
void applyCl(CClient *cl);
DLL_LINKAGE virtual void applyGs(CGameState *gs);
DLL_LINKAGE void applyGs(CGameState *gs);
si32 tid;
std::set<si32> bid;

View File

@ -25,7 +25,7 @@ namespace Res
#define scalarOperator(OPSIGN) \
DLL_LINKAGE ResourceSet operator OPSIGN(const TResource &rhs) const \
ResourceSet operator OPSIGN(const TResource &rhs) const \
{ \
ResourceSet ret = *this; \
for(int i = 0; i < size(); i++) \
@ -37,7 +37,7 @@ namespace Res
#define vectorOperator(OPSIGN) \
DLL_LINKAGE ResourceSet operator OPSIGN(const ResourceSet &rhs) const \
ResourceSet operator OPSIGN(const ResourceSet &rhs) const \
{ \
ResourceSet ret = *this; \
for(int i = 0; i < size(); i++) \
@ -48,7 +48,7 @@ namespace Res
#define opEqOperator(OPSIGN, RHS_TYPE) \
DLL_LINKAGE ResourceSet& operator OPSIGN ## =(const RHS_TYPE &rhs) \
ResourceSet& operator OPSIGN ## =(const RHS_TYPE &rhs) \
{ \
return *this = *this OPSIGN rhs; \
}
@ -70,7 +70,7 @@ namespace Res
#undef opEqOperator
//to be used for calculations of type "how many units of sth can I afford?"
DLL_LINKAGE int operator/(const ResourceSet &rhs)
int operator/(const ResourceSet &rhs)
{
int ret = INT_MAX;
for(int i = 0; i < size(); i++)
@ -80,7 +80,7 @@ namespace Res
return ret;
}
DLL_LINKAGE ResourceSet & operator=(const TResource &rhs)
ResourceSet & operator=(const TResource &rhs)
{
for(int i = 0; i < size(); i++)
at(i) = rhs;