From c1c3c66ec062438e1a99266751122557517d708d Mon Sep 17 00:00:00 2001 From: Aleksandr Palamar Date: Thu, 24 Mar 2016 20:29:16 +0200 Subject: [PATCH] Working NetRadiant and q3map2 on MSYS2 (both x86, x86_64), fixed problems with out of bounds and got rid of unneeded warning messages. Optimisations for MSYS2 were disabled as they are causing crashes. Added specific MSYS2 shell scripts for installing DLLs and GTK themes. --- Makefile | 26 +++++++++++++-- install-dlls-msys2-mingw32.sh | 38 ++++++++++++++++++++++ install-dlls-msys2-mingw64.sh | 38 ++++++++++++++++++++++ libs/os/file.h | 10 ++++++ tools/quake2/common/inout.c | 16 ++++----- tools/quake2/q2map/qbsp.c | 2 +- tools/quake2/qdata_heretic2/common/inout.c | 16 ++++----- tools/quake3/common/inout.c | 16 ++++----- tools/quake3/common/vfs.h | 2 ++ tools/quake3/q3map2/bsp.c | 2 +- tools/quake3/q3map2/light_bounce.c | 4 +-- tools/quake3/q3map2/light_ydnar.c | 2 +- tools/quake3/q3map2/q3map2.h | 2 +- tools/quake3/q3map2/surface_meta.c | 3 +- 14 files changed, 144 insertions(+), 33 deletions(-) create mode 100644 install-dlls-msys2-mingw32.sh create mode 100644 install-dlls-msys2-mingw64.sh diff --git a/Makefile b/Makefile index a68f3c61..1005c026 100644 --- a/Makefile +++ b/Makefile @@ -109,11 +109,11 @@ ifeq ($(OS),Windows_NT) OS = Win32 endif -CFLAGS_COMMON = -MMD -W -Wall -Wcast-align -Wcast-qual -Wno-unused-parameter -fno-strict-aliasing +CFLAGS_COMMON = -MMD -W -Wall -Wcast-align -Wno-cast-qual -Wno-unused-parameter -Wno-unknown-pragmas -Wno-empty-body -Wno-maybe-uninitialized -Wno-write-strings -fno-strict-aliasing CPPFLAGS_COMMON = LDFLAGS_COMMON = LIBS_COMMON = -CXXFLAGS_COMMON = -Wno-non-virtual-dtor -Wreorder -fno-exceptions -fno-rtti +CXXFLAGS_COMMON = -Wno-non-virtual-dtor -Wno-reorder -Wno-unknown-pragmas -Wno-empty-body -Wno-maybe-uninitialized -Wno-write-strings -fno-exceptions -fno-rtti ifeq ($(BUILD),debug) ifeq ($(findstring $(CFLAGS),-g),) @@ -240,6 +240,28 @@ endif endif endif +# MSYS2 +UNAME_S := $(shell uname -s) +UNAME_O := $(shell uname -o) + +ifneq "$(filter MINGW32_NT%,$(UNAME_S))" "" + OS = Win32 + ifeq ($(UNAME_O),Msys) + DLLINSTALL = install-dlls-msys2-mingw32.sh + CFLAGS_COMMON += -O0 + CPPFLAGS_COMMON += -O0 + endif +endif + +ifneq "$(filter MINGW64_NT%,$(UNAME_S))" "" + OS = Win32 + ifeq ($(UNAME_O),Msys) + DLLINSTALL = install-dlls-msys2-mingw64.sh + CFLAGS_COMMON += -O0 + CPPFLAGS_COMMON += -O0 + endif +endif + # VERSION! RADIANT_VERSION_NUMBER = 1.5.0 RADIANT_VERSION = $(RADIANT_VERSION_NUMBER)n diff --git a/install-dlls-msys2-mingw32.sh b/install-dlls-msys2-mingw32.sh new file mode 100644 index 00000000..aa02331c --- /dev/null +++ b/install-dlls-msys2-mingw32.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +MINGWDIR='/mingw64' +INSTALLDIR=$(pwd)/install + +function dependencies { + local EXECUATABLEDIR=$1 + local EXECUATABLE=$2 + local MINGWDIRBIN=$3 + + local DEPENDENCY="| grep 'DLL Name' | sed -r 's/\s+DLL\s+Name\:\s+//' | xargs -i{} which {} | grep $MINGWDIRBIN" + + local DEPENDENCIES="$DEPENDENCY" + + for I in `seq 1 3`; + do + local COMMAND="objdump -x $EXECUATABLE $DEPENDENCIES | xargs -i{} cp -v {} $EXECUATABLEDIR" + eval "$COMMAND" + + local DEPENDENCIES="$DEPENDENCIES | xargs -i{} objdump -x {} $DEPENDENCY" + done +} + +dependencies './install' './install/q2map.exe' "$MINGWDIR/bin" +dependencies './install' './install/q3data.exe' "$MINGWDIR/bin" +dependencies './install' './install/q3map2.exe' "$MINGWDIR/bin" +dependencies './install' './install/qdata3.exe' "$MINGWDIR/bin" +dependencies './install' './install/radiant.exe' "$MINGWDIR/bin" + +cd $MINGWDIR + +for EXTRAPATH in \ + './lib/gtk-2.0/2.10.0/engines/*.dll' \ + './lib/gtk-2.0/modules/*.dll' \ + './share/themes' \ +; do + cp --parent -v `find $EXTRAPATH -type f` "$INSTALLDIR" +done diff --git a/install-dlls-msys2-mingw64.sh b/install-dlls-msys2-mingw64.sh new file mode 100644 index 00000000..aa02331c --- /dev/null +++ b/install-dlls-msys2-mingw64.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +MINGWDIR='/mingw64' +INSTALLDIR=$(pwd)/install + +function dependencies { + local EXECUATABLEDIR=$1 + local EXECUATABLE=$2 + local MINGWDIRBIN=$3 + + local DEPENDENCY="| grep 'DLL Name' | sed -r 's/\s+DLL\s+Name\:\s+//' | xargs -i{} which {} | grep $MINGWDIRBIN" + + local DEPENDENCIES="$DEPENDENCY" + + for I in `seq 1 3`; + do + local COMMAND="objdump -x $EXECUATABLE $DEPENDENCIES | xargs -i{} cp -v {} $EXECUATABLEDIR" + eval "$COMMAND" + + local DEPENDENCIES="$DEPENDENCIES | xargs -i{} objdump -x {} $DEPENDENCY" + done +} + +dependencies './install' './install/q2map.exe' "$MINGWDIR/bin" +dependencies './install' './install/q3data.exe' "$MINGWDIR/bin" +dependencies './install' './install/q3map2.exe' "$MINGWDIR/bin" +dependencies './install' './install/qdata3.exe' "$MINGWDIR/bin" +dependencies './install' './install/radiant.exe' "$MINGWDIR/bin" + +cd $MINGWDIR + +for EXTRAPATH in \ + './lib/gtk-2.0/2.10.0/engines/*.dll' \ + './lib/gtk-2.0/modules/*.dll' \ + './share/themes' \ +; do + cp --parent -v `find $EXTRAPATH -type f` "$INSTALLDIR" +done diff --git a/libs/os/file.h b/libs/os/file.h index 43381c63..41c20c15 100644 --- a/libs/os/file.h +++ b/libs/os/file.h @@ -28,9 +28,19 @@ #if defined( WIN32 ) #define S_ISDIR( mode ) ( mode & _S_IFDIR ) #include // _access() + +#ifndef F_OK #define F_OK 0x00 +#endif + +#ifndef W_OK #define W_OK 0x02 +#endif + +#ifndef R_OK #define R_OK 0x04 +#endif + #define access( path, mode ) _access( path, mode ) #else #include // access() diff --git a/tools/quake2/common/inout.c b/tools/quake2/common/inout.c index 30ae39df..67be39e4 100644 --- a/tools/quake2/common/inout.c +++ b/tools/quake2/common/inout.c @@ -67,7 +67,7 @@ xmlNodePtr xml_NodeForVec( vec3_t v ){ sprintf( buf, "%f %f %f", v[0], v[1], v[2] ); ret = xmlNewNode( NULL, "point" ); - xmlNodeSetContent( ret, buf ); + xmlNodeAddContent( ret, buf ); return ret; } @@ -145,14 +145,14 @@ void xml_Select( char *msg, int entitynum, int brushnum, qboolean bError ){ // now build a proper "select" XML node sprintf( buf, "Entity %i, Brush %i: %s", entitynum, brushnum, msg ); node = xmlNewNode( NULL, "select" ); - xmlNodeSetContent( node, buf ); + xmlNodeAddContent( node, buf ); level[0] = (int)'0' + ( bError ? SYS_ERR : SYS_WRN ) ; level[1] = 0; xmlSetProp( node, "level", (char *)&level ); // a 'select' information sprintf( buf, "%i %i", entitynum, brushnum ); select = xmlNewNode( NULL, "brush" ); - xmlNodeSetContent( select, buf ); + xmlNodeAddContent( select, buf ); xmlAddChild( node, select ); xml_SendNode( node ); @@ -172,14 +172,14 @@ void xml_Point( char *msg, vec3_t pt ){ char level[2]; node = xmlNewNode( NULL, "pointmsg" ); - xmlNodeSetContent( node, msg ); + xmlNodeAddContent( node, msg ); level[0] = (int)'0' + SYS_ERR; level[1] = 0; xmlSetProp( node, "level", (char *)&level ); // a 'point' node sprintf( buf, "%g %g %g", pt[0], pt[1], pt[2] ); point = xmlNewNode( NULL, "point" ); - xmlNodeSetContent( point, buf ); + xmlNodeAddContent( point, buf ); xmlAddChild( node, point ); xml_SendNode( node ); @@ -196,7 +196,7 @@ void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die ){ int i; node = xmlNewNode( NULL, "windingmsg" ); - xmlNodeSetContent( node, msg ); + xmlNodeAddContent( node, msg ); level[0] = (int)'0' + SYS_ERR; level[1] = 0; xmlSetProp( node, "level", (char *)&level ); @@ -213,7 +213,7 @@ void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die ){ } winding = xmlNewNode( NULL, "winding" ); - xmlNodeSetContent( winding, buf ); + xmlNodeAddContent( winding, buf ); xmlAddChild( node, winding ); xml_SendNode( node ); @@ -282,7 +282,7 @@ void FPrintf( int flag, char *buf ){ bGotXML = true; } node = xmlNewNode( NULL, "message" ); - xmlNodeSetContent( node, buf ); + xmlNodeAddContent( node, buf ); level[0] = (int)'0' + flag; level[1] = 0; xmlSetProp( node, "level", (char *)&level ); diff --git a/tools/quake2/q2map/qbsp.c b/tools/quake2/q2map/qbsp.c index 128fb7ab..e5486bce 100644 --- a/tools/quake2/q2map/qbsp.c +++ b/tools/quake2/q2map/qbsp.c @@ -242,7 +242,7 @@ void ProcessWorldModel( void ){ Sys_FPrintf( SYS_NOXML, "**********************\n" ); polyline = LeakFile( tree ); leaknode = xmlNewNode( NULL, "message" ); - xmlNodeSetContent( leaknode, "MAP LEAKED\n" ); + xmlNodeAddContent( leaknode, "MAP LEAKED\n" ); xmlAddChild( leaknode, polyline ); level[0] = (int) '0' + SYS_ERR; level[1] = 0; diff --git a/tools/quake2/qdata_heretic2/common/inout.c b/tools/quake2/qdata_heretic2/common/inout.c index 30ae39df..67be39e4 100644 --- a/tools/quake2/qdata_heretic2/common/inout.c +++ b/tools/quake2/qdata_heretic2/common/inout.c @@ -67,7 +67,7 @@ xmlNodePtr xml_NodeForVec( vec3_t v ){ sprintf( buf, "%f %f %f", v[0], v[1], v[2] ); ret = xmlNewNode( NULL, "point" ); - xmlNodeSetContent( ret, buf ); + xmlNodeAddContent( ret, buf ); return ret; } @@ -145,14 +145,14 @@ void xml_Select( char *msg, int entitynum, int brushnum, qboolean bError ){ // now build a proper "select" XML node sprintf( buf, "Entity %i, Brush %i: %s", entitynum, brushnum, msg ); node = xmlNewNode( NULL, "select" ); - xmlNodeSetContent( node, buf ); + xmlNodeAddContent( node, buf ); level[0] = (int)'0' + ( bError ? SYS_ERR : SYS_WRN ) ; level[1] = 0; xmlSetProp( node, "level", (char *)&level ); // a 'select' information sprintf( buf, "%i %i", entitynum, brushnum ); select = xmlNewNode( NULL, "brush" ); - xmlNodeSetContent( select, buf ); + xmlNodeAddContent( select, buf ); xmlAddChild( node, select ); xml_SendNode( node ); @@ -172,14 +172,14 @@ void xml_Point( char *msg, vec3_t pt ){ char level[2]; node = xmlNewNode( NULL, "pointmsg" ); - xmlNodeSetContent( node, msg ); + xmlNodeAddContent( node, msg ); level[0] = (int)'0' + SYS_ERR; level[1] = 0; xmlSetProp( node, "level", (char *)&level ); // a 'point' node sprintf( buf, "%g %g %g", pt[0], pt[1], pt[2] ); point = xmlNewNode( NULL, "point" ); - xmlNodeSetContent( point, buf ); + xmlNodeAddContent( point, buf ); xmlAddChild( node, point ); xml_SendNode( node ); @@ -196,7 +196,7 @@ void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die ){ int i; node = xmlNewNode( NULL, "windingmsg" ); - xmlNodeSetContent( node, msg ); + xmlNodeAddContent( node, msg ); level[0] = (int)'0' + SYS_ERR; level[1] = 0; xmlSetProp( node, "level", (char *)&level ); @@ -213,7 +213,7 @@ void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die ){ } winding = xmlNewNode( NULL, "winding" ); - xmlNodeSetContent( winding, buf ); + xmlNodeAddContent( winding, buf ); xmlAddChild( node, winding ); xml_SendNode( node ); @@ -282,7 +282,7 @@ void FPrintf( int flag, char *buf ){ bGotXML = true; } node = xmlNewNode( NULL, "message" ); - xmlNodeSetContent( node, buf ); + xmlNodeAddContent( node, buf ); level[0] = (int)'0' + flag; level[1] = 0; xmlSetProp( node, "level", (char *)&level ); diff --git a/tools/quake3/common/inout.c b/tools/quake3/common/inout.c index 14e9eaaf..827bdceb 100644 --- a/tools/quake3/common/inout.c +++ b/tools/quake3/common/inout.c @@ -70,7 +70,7 @@ xmlNodePtr xml_NodeForVec( vec3_t v ){ sprintf( buf, "%f %f %f", v[0], v[1], v[2] ); ret = xmlNewNode( NULL, (xmlChar*)"point" ); - xmlNodeSetContent( ret, (xmlChar*)buf ); + xmlNodeAddContent( ret, (xmlChar*)buf ); return ret; } @@ -148,14 +148,14 @@ void xml_Select( char *msg, int entitynum, int brushnum, qboolean bError ){ // now build a proper "select" XML node sprintf( buf, "Entity %i, Brush %i: %s", entitynum, brushnum, msg ); node = xmlNewNode( NULL, (xmlChar*)"select" ); - xmlNodeSetContent( node, (xmlChar*)buf ); + xmlNodeAddContent( node, (xmlChar*)buf ); level[0] = (int)'0' + ( bError ? SYS_ERR : SYS_WRN ) ; level[1] = 0; xmlSetProp( node, (xmlChar*)"level", (xmlChar *)&level ); // a 'select' information sprintf( buf, "%i %i", entitynum, brushnum ); select = xmlNewNode( NULL, (xmlChar*)"brush" ); - xmlNodeSetContent( select, (xmlChar*)buf ); + xmlNodeAddContent( select, (xmlChar*)buf ); xmlAddChild( node, select ); xml_SendNode( node ); @@ -175,14 +175,14 @@ void xml_Point( char *msg, vec3_t pt ){ char level[2]; node = xmlNewNode( NULL, (xmlChar*)"pointmsg" ); - xmlNodeSetContent( node, (xmlChar*)msg ); + xmlNodeAddContent( node, (xmlChar*)msg ); level[0] = (int)'0' + SYS_ERR; level[1] = 0; xmlSetProp( node, (xmlChar*)"level", (xmlChar *)&level ); // a 'point' node sprintf( buf, "%g %g %g", pt[0], pt[1], pt[2] ); point = xmlNewNode( NULL, (xmlChar*)"point" ); - xmlNodeSetContent( point, (xmlChar*)buf ); + xmlNodeAddContent( point, (xmlChar*)buf ); xmlAddChild( node, point ); xml_SendNode( node ); @@ -199,7 +199,7 @@ void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die ){ int i; node = xmlNewNode( NULL, (xmlChar*)"windingmsg" ); - xmlNodeSetContent( node, (xmlChar*)msg ); + xmlNodeAddContent( node, (xmlChar*)msg ); level[0] = (int)'0' + SYS_ERR; level[1] = 0; xmlSetProp( node, (xmlChar*)"level", (xmlChar *)&level ); @@ -216,7 +216,7 @@ void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die ){ } winding = xmlNewNode( NULL, (xmlChar*)"winding" ); - xmlNodeSetContent( winding, (xmlChar*)buf ); + xmlNodeAddContent( winding, (xmlChar*)buf ); xmlAddChild( node, winding ); xml_SendNode( node ); @@ -287,7 +287,7 @@ void FPrintf( int flag, char *buf ){ node = xmlNewNode( NULL, (xmlChar*)"message" ); { gchar* utf8 = g_locale_to_utf8( buf, -1, NULL, NULL, NULL ); - xmlNodeSetContent( node, (xmlChar*)utf8 ); + xmlNodeAddContent( node, (xmlChar*)utf8 ); g_free( utf8 ); } level[0] = (int)'0' + flag; diff --git a/tools/quake3/common/vfs.h b/tools/quake3/common/vfs.h index 51ac6ddd..8efab146 100644 --- a/tools/quake3/common/vfs.h +++ b/tools/quake3/common/vfs.h @@ -39,7 +39,9 @@ #else #include #include +#ifndef R_OK #define R_OK 04 +#endif #define S_ISDIR( mode ) ( mode & _S_IFDIR ) #define PATH_MAX 260 #endif diff --git a/tools/quake3/q3map2/bsp.c b/tools/quake3/q3map2/bsp.c index da737460..8327b228 100644 --- a/tools/quake3/q3map2/bsp.c +++ b/tools/quake3/q3map2/bsp.c @@ -345,7 +345,7 @@ void ProcessWorldModel( void ){ Sys_FPrintf( SYS_NOXML, "**********************\n" ); polyline = LeakFile( tree ); leaknode = xmlNewNode( NULL, (xmlChar*)"message" ); - xmlNodeSetContent( leaknode, (xmlChar*)"MAP LEAKED\n" ); + xmlNodeAddContent( leaknode, (xmlChar*)"MAP LEAKED\n" ); xmlAddChild( leaknode, polyline ); level[0] = (int) '0' + SYS_ERR; level[1] = 0; diff --git a/tools/quake3/q3map2/light_bounce.c b/tools/quake3/q3map2/light_bounce.c index 37d8c4e5..ac00431b 100644 --- a/tools/quake3/q3map2/light_bounce.c +++ b/tools/quake3/q3map2/light_bounce.c @@ -288,7 +288,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, /* multiply by texture color */ if ( !RadSampleImage( si->lightImage->pixels, si->lightImage->width, si->lightImage->height, rw->verts[ samples ].st, textureColor ) ) { VectorCopy( si->averageColor, textureColor ); - textureColor[ 4 ] = 255.0f; + textureColor[ 3 ] = 255.0f; } for ( i = 0; i < 3; i++ ) color[ i ] = ( textureColor[ i ] / 255 ) * ( rw->verts[ samples ].color[ lightmapNum ][ i ] / 255.0f ); @@ -372,7 +372,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, /* multiply by texture color */ if ( !RadSampleImage( si->lightImage->pixels, si->lightImage->width, si->lightImage->height, st, textureColor ) ) { VectorCopy( si->averageColor, textureColor ); - textureColor[ 4 ] = 255; + textureColor[ 3 ] = 255; } for ( i = 0; i < 3; i++ ) color[ i ] = ( textureColor[ i ] / 255 ) * ( radLuxel[ i ] / 255 ); diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index 91f5e047..3bfa9ca7 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -1806,7 +1806,7 @@ static void SubsampleRawLuxel_r( rawLightmap_t *lm, trace_t *trace, vec3_t sampl int b, samples, mapped, lighted; int cluster[ 4 ]; vec4_t luxel[ 4 ]; - vec3_t deluxel[ 3 ]; + vec3_t deluxel[ 4 ]; vec3_t origin[ 4 ], normal[ 4 ]; float biasDirs[ 4 ][ 2 ] = { { -1.0f, -1.0f }, { 1.0f, -1.0f }, { -1.0f, 1.0f }, { 1.0f, 1.0f } }; vec3_t color, direction = { 0, 0, 0 }, total; diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 705f3517..1499a37e 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -788,7 +788,7 @@ typedef struct shaderInfo_s sun_t *sun; /* ydnar */ vec3_t color; /* normalized color */ - vec3_t averageColor; + vec4_t averageColor; byte lightStyle; /* vortex: per-surface floodlight */ diff --git a/tools/quake3/q3map2/surface_meta.c b/tools/quake3/q3map2/surface_meta.c index 8d4f3c36..453b7531 100644 --- a/tools/quake3/q3map2/surface_meta.c +++ b/tools/quake3/q3map2/surface_meta.c @@ -952,7 +952,8 @@ void MakeEntityMetaTriangles( entity_t *e ){ typedef struct edge_s { - vec3_t origin, edge; + vec3_t origin; + vec4_t edge; vec_t length, kingpinLength; int kingpin; vec4_t plane; -- 2.39.2