games/megaglest: Fix code to allow Clang to build it again

Not only was the previous commit unsavory, it didn't work due to conflict
between libc++ and libstdc++.  The added patch from miniz upstream fixes
the breakage.

Suggested by:	jbeich
This commit is contained in:
John Marino 2015-04-13 07:06:08 +00:00
parent 2a61f4fbe1
commit ad62adf904
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=383899
2 changed files with 22 additions and 6 deletions

View File

@ -3,7 +3,7 @@
PORTNAME= megaglest
PORTVERSION= 3.9.0.4
PORTREVISION= 6
PORTREVISION= 7
CATEGORIES= games
MASTER_SITES= SF/${PORTNAME}/${PORTNAME}_3.9.0/
DISTNAME= ${PORTNAME}-source-${PORTVERSION}
@ -23,11 +23,8 @@ RUN_DEPENDS= ${DATADIR}/tutorials/2_basic_tutorial/2_basic_tutorial.xml:${PORTSD
SUB_FILES= pkg-message
# Clang catches a c++11 violation that older GCC misses, so until the
# code is fixed, remove USES+=compiler:c++11-lib and set USE_GCC=yes
USES= cmake display:build dos2unix lua openal:al,alut pkgconfig \
tar:xz
USE_GCC= yes
USES= cmake compiler:c++11-lib display:build dos2unix lua \
openal:al,alut pkgconfig tar:xz
USE_GL= glew gl glu
USE_SDL= yes
USE_WX= 3.0

View File

@ -0,0 +1,19 @@
--- source/shared_lib/sources/miniz/miniz.c.orig 2015-04-13 04:50:02 UTC
+++ source/shared_lib/sources/miniz/miniz.c
@@ -2765,6 +2765,7 @@ mz_uint tdefl_create_comp_flags_from_zip
// http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/.
void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out)
{
+ static const mz_uint8 chans[] = {0x00, 0x00, 0x04, 0x02, 0x06};
tdefl_compressor *pComp = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); tdefl_output_buffer out_buf; int i, bpl = w * num_chans, y, z; mz_uint32 c; *pLen_out = 0;
if (!pComp) return NULL;
MZ_CLEAR_OBJ(out_buf); out_buf.m_expandable = MZ_TRUE; out_buf.m_capacity = 57+MZ_MAX(64, (1+bpl)*h); if (NULL == (out_buf.m_pBuf = (mz_uint8*)MZ_MALLOC(out_buf.m_capacity))) { MZ_FREE(pComp); return NULL; }
@@ -2778,7 +2779,7 @@ void *tdefl_write_image_to_png_file_in_m
*pLen_out = out_buf.m_size-41;
{
mz_uint8 pnghdr[41]={0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
- 0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8,"\0\0\04\02\06"[num_chans],0,0,0,0,0,0,0,
+ 0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8,chans[num_chans],0,0,0,0,0,0,0,
(mz_uint8)(*pLen_out>>24),(mz_uint8)(*pLen_out>>16),(mz_uint8)(*pLen_out>>8),(mz_uint8)*pLen_out,0x49,0x44,0x41,0x54};
c=(mz_uint32)mz_crc32(MZ_CRC32_INIT,pnghdr+12,17); for (i=0; i<4; ++i, c<<=8) ((mz_uint8*)(pnghdr+29))[i]=(mz_uint8)(c>>24);
memcpy(out_buf.m_pBuf, pnghdr, 41);