forked from Mirrors/openclonk
Fix crash when building with g++ 4.3 or newer
This adds a true copy constructor to StdBuf and StdStrBuf. Unfortunately, this constructor is sometimes prefered to the move constructor when it wasn't with older compilers, always referencing the original instead of copying makes the engine crash, and omitting the copy constructor just creates an implicit one which also causes crashes.
parent
e6d1eca02e
commit
77dabef7c7
|
@ -3,7 +3,7 @@ Requirements
|
|||
|
||||
To build on Linux you need the following packages (Debian names given):
|
||||
|
||||
make gcc-4.1 g++-4.1
|
||||
make gcc g++
|
||||
automake autoconf
|
||||
libc6-dev libx11-dev libxxf86vm-dev libxpm-dev libglew1.5-dev libgl1-mesa-dev
|
||||
libpng12-dev libssl-dev libsdl1.2-dev libsdl-mixer1.2-dev libssl-dev
|
||||
|
@ -20,6 +20,8 @@ To build from tarball, run this:
|
|||
|
||||
./configure 'CXX=g++-4.1' && make
|
||||
|
||||
Alternatively, you can use 'CXX=g++ -std=gnu++0x' if you have g++ version 4.3 or newer.
|
||||
|
||||
If you want a debug build, pass --enable-debug to configure, for the developer mode
|
||||
--with-gtk. Other options are listed by ./configure --help.
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@ You can build on Windows using either:
|
|||
plus MSYS (or any other shell that can run configure and make)
|
||||
plus DXSDK 9 (if you want DirectX support)
|
||||
this is currently only tested by crosscompiling from Linux.
|
||||
only g++-4.1 and older can compile clonk, g++-4.2 and newer are incompatible.
|
||||
|
||||
|
||||
NoNetwork
|
||||
=========
|
||||
|
@ -39,37 +37,31 @@ To build using MinGW, you need from http://www.mingw.org/:
|
|||
With MinGW-*.exe, install from the "current" distribution the MinGW base tools
|
||||
and g++, the C++ compiler. Then install msys.
|
||||
|
||||
If you want to edit the build files (for example for a new source file), you
|
||||
need the MSYS DTK, Autoconf 2.6x and Automake 1.10.x. You might need to build
|
||||
the last two from source.
|
||||
You also need the MSYS DTK, Autoconf 2.6x and Automake 1.10.x. You might need
|
||||
to build the last two from source.
|
||||
|
||||
If you want DirectX support, get a DirectX 9 SDK from Microsoft. Copy the
|
||||
contents of it's include dir to the include dir of your MinGW installation,
|
||||
contents of its include dir to the include dir of your MinGW installation,
|
||||
and pass --with-directx to configure below.
|
||||
|
||||
Open a shell (the MSYS one under windows), cd to this directory, and execute:
|
||||
|
||||
./configure && make
|
||||
autoreconf -i && ./configure && make
|
||||
|
||||
If you want a debugbuild, pass --enable-debug to configure. Other options are
|
||||
listed by configure --help.
|
||||
To use g++ version 4.3 or newer, you need to pass 'CXX=g++ -std=gnu++0x'
|
||||
to configure. g++ version 4.2 is not able to compile Clonk.
|
||||
|
||||
If you get an error like "directx/dxfile.h:240: stray '\32' in program", then
|
||||
delete that char from that file (Whyever someone would want an ASCII 32 in a
|
||||
header is beyond me). Some editors (SciTE for example) display such unusual
|
||||
characters instead of representing them with space.
|
||||
To compile a debugbuild, pass --enable-debug to configure. Other options are
|
||||
listed by ./configure --help.
|
||||
|
||||
On subsequent build runs, you only have to execute make.
|
||||
|
||||
If you want to edit the build files, pass --enable-maintainer-mode to configure.
|
||||
When you do that, make will automatically update the build system.
|
||||
|
||||
If you want to separate the source directory and the output files, you can call
|
||||
configure from another directory. You can call configure by it's relative path,
|
||||
but using the full path helps gdb find the source files. Example:
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
/path/to/clonksource/configure --with-directx CXXFLAGS='-Os'
|
||||
make
|
||||
mkdir build
|
||||
cd build
|
||||
/path/to/clonksource/configure --with-directx CXXFLAGS='-Os'
|
||||
make
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ AC_DEFUN([AX_PROG_CXX_REFTOTEMP],
|
|||
struct Foo {
|
||||
operator Foo & () { return *this; }
|
||||
};
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
|
||||
void frobnicate(Foo &&) { }
|
||||
#else
|
||||
void frobnicate(Foo &) { }
|
||||
|
|
|
@ -93,6 +93,9 @@ namespace {
|
|||
class ImplicitStrBuf: public StdStrBuf {
|
||||
public:
|
||||
ImplicitStrBuf(StdStrBuf RREF Buf2): StdStrBuf(Buf2, false) { }
|
||||
ImplicitStrBuf(const StdStrBuf & Buf2): StdStrBuf(Buf2) { }
|
||||
ImplicitStrBuf(ImplicitStrBuf RREF Buf2): StdStrBuf(Buf2) { }
|
||||
ImplicitStrBuf(const ImplicitStrBuf & Buf2): StdStrBuf(Buf2) { }
|
||||
operator const char *() const { return getData(); }
|
||||
};
|
||||
|
||||
|
|
|
@ -2145,7 +2145,7 @@ void C4NetIOUDP::OnPacket(const C4NetIOPacket &Packet, C4NetIO *pNetIO)
|
|||
// ping? answer without creating a connection
|
||||
if((Packet.getStatus() & 0x7F) == IPID_Ping)
|
||||
{
|
||||
PacketHdr PingPacket = { IPID_Ping | (Packet.getStatus() & 0x80), 0 };
|
||||
PacketHdr PingPacket = { int8_t(IPID_Ping | (Packet.getStatus() & 0x80)), 0 };
|
||||
SendDirect(C4NetIOPacket(&PingPacket, sizeof(PingPacket), false, Packet.getAddr()));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1709,7 +1709,7 @@ bool C4PlayerInfoList::SetAsRestoreInfos(C4PlayerInfoList &rFromPlayers, bool fS
|
|||
for (int ch = 128; ch < 256; ++ch)
|
||||
{
|
||||
const char* hexChars = "0123456789abcdef";
|
||||
char old[] = { ch, 0 };
|
||||
char old[] = { char(ch), 0 };
|
||||
char safe[] = { '%', 'x', 'x', 0 };
|
||||
safe[1] = hexChars[ch / 16];
|
||||
safe[2] = hexChars[ch % 16];
|
||||
|
|
|
@ -253,10 +253,10 @@ bool C4Record::Rec(int iFrame, const StdBuf &sBuf, C4RecordChunkType eType)
|
|||
while(iFrame > iLastFrame + 0xff)
|
||||
Rec(iLastFrame + 0xff, StdBuf(), RCT_Frame);
|
||||
// get frame difference
|
||||
uint32_t iFrameDiff = Max<uint32_t>(0, iFrame - iLastFrame);
|
||||
uint8_t iFrameDiff = Max<uint8_t>(0, iFrame - iLastFrame);
|
||||
iLastFrame += iFrameDiff;
|
||||
// create head
|
||||
C4RecordChunkHead Head = { iFrameDiff, eType };
|
||||
// create head
|
||||
C4RecordChunkHead Head = { iFrameDiff, uint8_t(eType) };
|
||||
// pack
|
||||
CtrlRec.Write(&Head, sizeof(Head));
|
||||
CtrlRec.Write(sBuf.getData(), sBuf.getSize());
|
||||
|
|
|
@ -38,7 +38,7 @@ void C4StartupOptionsDlg::SmallButton::DrawElement(C4TargetFacet &cgo)
|
|||
// draw the button
|
||||
CStdFont &rUseFont = C4Startup::Get()->Graphics.BookFont;
|
||||
// get text pos
|
||||
int32_t x0 = cgo.TargetX + rcBounds.x, y0 = cgo.TargetY + rcBounds.y, x1 = cgo.TargetX + rcBounds.x + rcBounds.Wdt, y1 = cgo.TargetY + rcBounds.y + rcBounds.Hgt;
|
||||
float x0 = cgo.TargetX + rcBounds.x, y0 = cgo.TargetY + rcBounds.y, x1 = cgo.TargetX + rcBounds.x + rcBounds.Wdt, y1 = cgo.TargetY + rcBounds.y + rcBounds.Hgt;
|
||||
int32_t iTextHgt = rUseFont.GetLineHeight();
|
||||
// draw frame
|
||||
uint32_t dwClrHigh = C4StartupBtnBorderColor1, dwClrLow = C4StartupBtnBorderColor2;
|
||||
|
|
|
@ -81,20 +81,24 @@ typedef __int32 intptr_t;
|
|||
#error Could not find integer datatypes!
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 3))
|
||||
// Temporary-To-Reference-Fix
|
||||
#define ALLOW_TEMP_TO_REF(ClassName) operator ClassName & () { return *this; }
|
||||
#if defined(__GNUC__)
|
||||
// Allow checks for correct printf-usage
|
||||
#define GNUC_FORMAT_ATTRIBUTE __attribute__ ((format (printf, 1, 2)))
|
||||
#define GNUC_FORMAT_ATTRIBUTE_O __attribute__ ((format (printf, 2, 3)))
|
||||
#define GNUC_ALWAYS_INLINE inline __attribute__ ((always_inline))
|
||||
#else
|
||||
#define ALLOW_TEMP_TO_REF(ClassName)
|
||||
#define GNUC_FORMAT_ATTRIBUTE
|
||||
#define GNUC_FORMAT_ATTRIBUTE_O
|
||||
#define GNUC_ALWAYS_INLINE inline
|
||||
#endif
|
||||
|
||||
// Temporary-To-Reference-Fix
|
||||
#if defined(__GNUC__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 3))
|
||||
#define ALLOW_TEMP_TO_REF(ClassName) operator ClassName & () { return *this; }
|
||||
#else
|
||||
#define ALLOW_TEMP_TO_REF(ClassName)
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
|
||||
// Another temporary-to-reference-fix: this time using C++0x's rvalue references
|
||||
#define RREF &&
|
||||
|
|
|
@ -53,6 +53,14 @@ public:
|
|||
else
|
||||
Ref(Buf2);
|
||||
}
|
||||
StdBuf(const StdBuf & Buf2, bool fCopy = true)
|
||||
: fRef(true), pData(NULL), iSize(0)
|
||||
{
|
||||
if(fCopy)
|
||||
Copy(Buf2);
|
||||
else
|
||||
Ref(Buf2);
|
||||
}
|
||||
|
||||
// Set by constant data. Copies data if desired.
|
||||
StdBuf(const void *pData, size_t iSize, bool fCopy = false)
|
||||
|
@ -377,6 +385,9 @@ public:
|
|||
StdStrBuf(StdStrBuf RREF Buf2, bool fCopy = false)
|
||||
: StdBuf(Buf2, fCopy)
|
||||
{ }
|
||||
StdStrBuf(const StdStrBuf & Buf2, bool fCopy = true)
|
||||
: StdBuf(Buf2, fCopy)
|
||||
{ }
|
||||
|
||||
// Set by constant data. References data by default, copies if specified.
|
||||
explicit StdStrBuf(const char *pData, bool fCopy = false)
|
||||
|
|
Loading…
Reference in New Issue