From: Thomas Debesse Date: Sun, 19 Apr 2020 09:49:36 +0000 (+0200) Subject: q3map2: generate unvanquished minimap sidecar file X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=commitdiff_plain;h=a50c860b2393f0fb9ecab4f2c1ddc79ba69e62e5 q3map2: generate unvanquished minimap sidecar file also enable the option for work-in-progress smokinguns port on dæmon --- diff --git a/tools/quake3/q3map2/game__null.h b/tools/quake3/q3map2/game__null.h index a92544b2..a4a7441d 100644 --- a/tools/quake3/q3map2/game__null.h +++ b/tools/quake3/q3map2/game__null.h @@ -84,6 +84,7 @@ qfalse, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ NULL, /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ NULL, /* bsp file prefix */ 0, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_darkplaces.h b/tools/quake3/q3map2/game_darkplaces.h index 492dd2d2..b697deb9 100644 --- a/tools/quake3/q3map2/game_darkplaces.h +++ b/tools/quake3/q3map2/game_darkplaces.h @@ -75,6 +75,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_dq.h b/tools/quake3/q3map2/game_dq.h index b4963345..66f1cd83 100644 --- a/tools/quake3/q3map2/game_dq.h +++ b/tools/quake3/q3map2/game_dq.h @@ -75,6 +75,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_ef.h b/tools/quake3/q3map2/game_ef.h index 03c9301f..bcb35b22 100644 --- a/tools/quake3/q3map2/game_ef.h +++ b/tools/quake3/q3map2/game_ef.h @@ -134,6 +134,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_etut.h b/tools/quake3/q3map2/game_etut.h index de7fad75..f02fdb0a 100644 --- a/tools/quake3/q3map2/game_etut.h +++ b/tools/quake3/q3map2/game_etut.h @@ -169,6 +169,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 47, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_ja.h b/tools/quake3/q3map2/game_ja.h index cce3260a..6265ba3c 100644 --- a/tools/quake3/q3map2/game_ja.h +++ b/tools/quake3/q3map2/game_ja.h @@ -88,6 +88,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "RBSP", /* bsp file prefix */ 1, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_jk2.h b/tools/quake3/q3map2/game_jk2.h index a667777d..52e1c993 100644 --- a/tools/quake3/q3map2/game_jk2.h +++ b/tools/quake3/q3map2/game_jk2.h @@ -85,6 +85,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "RBSP", /* bsp file prefix */ 1, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_nexuiz.h b/tools/quake3/q3map2/game_nexuiz.h index b6fee7f9..d91b1ae6 100644 --- a/tools/quake3/q3map2/game_nexuiz.h +++ b/tools/quake3/q3map2/game_nexuiz.h @@ -84,6 +84,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "../gfx/%s_mini.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_prophecy.h b/tools/quake3/q3map2/game_prophecy.h index 4a156a8f..e446057b 100644 --- a/tools/quake3/q3map2/game_prophecy.h +++ b/tools/quake3/q3map2/game_prophecy.h @@ -75,6 +75,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_qfusion.h b/tools/quake3/q3map2/game_qfusion.h index 49506129..1348724b 100644 --- a/tools/quake3/q3map2/game_qfusion.h +++ b/tools/quake3/q3map2/game_qfusion.h @@ -136,6 +136,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "../minimaps/%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "FBSP", /* bsp file prefix */ 1, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_quake3.h b/tools/quake3/q3map2/game_quake3.h index 2b3302ab..e20493a5 100644 --- a/tools/quake3/q3map2/game_quake3.h +++ b/tools/quake3/q3map2/game_quake3.h @@ -133,6 +133,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_quakelive.h b/tools/quake3/q3map2/game_quakelive.h index b4f876fb..d2995704 100644 --- a/tools/quake3/q3map2/game_quakelive.h +++ b/tools/quake3/q3map2/game_quakelive.h @@ -97,6 +97,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 47, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_reaction.h b/tools/quake3/q3map2/game_reaction.h index 6163b391..8974556e 100644 --- a/tools/quake3/q3map2/game_reaction.h +++ b/tools/quake3/q3map2/game_reaction.h @@ -105,6 +105,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_smokinguns.h b/tools/quake3/q3map2/game_smokinguns.h index 296803cc..6f6a5947 100644 --- a/tools/quake3/q3map2/game_smokinguns.h +++ b/tools/quake3/q3map2/game_smokinguns.h @@ -90,6 +90,7 @@ content and surface flags - also uses defines from game_quake3.h qtrue, /* minimap keep aspect */ MINIMAP_MODE_WHITE, /* minimap mode */ "../minimaps/%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_UNVANQUISHED, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_sof2.h b/tools/quake3/q3map2/game_sof2.h index fcceb0f9..2ca335ac 100644 --- a/tools/quake3/q3map2/game_sof2.h +++ b/tools/quake3/q3map2/game_sof2.h @@ -160,6 +160,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "RBSP", /* bsp file prefix */ 1, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_tenebrae.h b/tools/quake3/q3map2/game_tenebrae.h index f9ba57ad..debe6c1c 100644 --- a/tools/quake3/q3map2/game_tenebrae.h +++ b/tools/quake3/q3map2/game_tenebrae.h @@ -133,6 +133,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_tremulous.h b/tools/quake3/q3map2/game_tremulous.h index a91b4c52..be0da88e 100644 --- a/tools/quake3/q3map2/game_tremulous.h +++ b/tools/quake3/q3map2/game_tremulous.h @@ -91,6 +91,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_unvanquished.h b/tools/quake3/q3map2/game_unvanquished.h index 20c935e6..b3cb4f57 100644 --- a/tools/quake3/q3map2/game_unvanquished.h +++ b/tools/quake3/q3map2/game_unvanquished.h @@ -93,6 +93,7 @@ game_t struct qtrue, /* minimap keep aspect */ MINIMAP_MODE_WHITE, /* minimap mode */ "../minimaps/%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_UNVANQUISHED, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_wolf.h b/tools/quake3/q3map2/game_wolf.h index a29fde2d..81e2c22a 100644 --- a/tools/quake3/q3map2/game_wolf.h +++ b/tools/quake3/q3map2/game_wolf.h @@ -150,6 +150,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 47, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_wolfet.h b/tools/quake3/q3map2/game_wolfet.h index 46746c37..ee520627 100644 --- a/tools/quake3/q3map2/game_wolfet.h +++ b/tools/quake3/q3map2/game_wolfet.h @@ -87,6 +87,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "%s.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 47, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/game_xonotic.h b/tools/quake3/q3map2/game_xonotic.h index 5ffb30fb..97ccff22 100644 --- a/tools/quake3/q3map2/game_xonotic.h +++ b/tools/quake3/q3map2/game_xonotic.h @@ -84,6 +84,7 @@ qtrue, /* minimap keep aspect */ MINIMAP_MODE_GRAY, /* minimap mode */ "../gfx/%s_mini.tga", /* minimap name format */ + MINIMAP_SIDECAR_NONE, /* minimap sidecar format */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ qfalse, /* cod-style lump len/ofs order */ diff --git a/tools/quake3/q3map2/minimap.c b/tools/quake3/q3map2/minimap.c index 204e396c..7b582ee1 100644 --- a/tools/quake3/q3map2/minimap.c +++ b/tools/quake3/q3map2/minimap.c @@ -282,10 +282,9 @@ static void MiniMapBrightnessContrast( int y ){ } } -void MiniMapMakeMinsMaxs( vec3_t mins_in, vec3_t maxs_in, float border, qboolean keepaspect ){ - vec3_t mins, maxs, extend; - VectorCopy( mins_in, mins ); - VectorCopy( maxs_in, maxs ); +// modify maxs and mins in place, copy them before calling this! +void MiniMapMakeMinsMaxs( vec3_t mins, vec3_t maxs, float border, qboolean keepaspect ){ + vec3_t extend; // line compatible to nexuiz mapinfo Sys_Printf( "size %f %f %f %f %f %f\n", mins[0], mins[1], mins[2], maxs[0], maxs[1], maxs[2] ); @@ -601,7 +600,10 @@ int MiniMapBSPMain( int argc, char **argv ){ } } - MiniMapMakeMinsMaxs( mins, maxs, border, keepaspect ); + vec3_t mins_out, maxs_out; + VectorCopy( mins, mins_out ); + VectorCopy( maxs, maxs_out ); + MiniMapMakeMinsMaxs( mins_out, maxs_out, border, keepaspect ); if ( !*minimapFilename ) { ExtractFileBase( source, basename ); @@ -773,6 +775,55 @@ int MiniMapBSPMain( int argc, char **argv ){ Sys_Printf( " done.\n" ); + switch ( game->miniMapSidecarFormat ) + { + case MINIMAP_SIDECAR_UNVANQUISHED: + { + char minimapPathWithoutExt[ 1024 ]; + char minimapSidecarFilename[ 1024 ]; + char *minimapSidecarExtension = ".minimap"; + char *minimapSidecarFormat = "" + "{\n" + "\tbackgroundColor 0.0 0.0 0.0 0.333\n" + "\tzone {\n" + "\t\tbounds 0 0 0 0 0 0\n" + "\t\timage \"minimaps/%s\" %f %f %f %f\n" + "\t}\n" + "}\n"; + + strcpy( minimapPathWithoutExt, minimapFilename ); + StripExtension( minimapPathWithoutExt ); + snprintf( minimapSidecarFilename, + 1024 - strlen(minimapSidecarExtension), + "%s%s", + minimapPathWithoutExt, + minimapSidecarExtension ); + + Sys_Printf( "Writing minimap sidecar to %s...", minimapSidecarFilename ); + + FILE *file = fopen( minimapSidecarFilename, "w" ); + if ( file == NULL ) { + Sys_FPrintf( SYS_WRN, "WARNING: Unable to open minimap sidecarr file %s for writing\n", minimapSidecarFilename ); + break; + } + + fprintf( file, + minimapSidecarFormat, + basename, + mins_out[0], mins_out[1], + maxs_out[0], maxs_out[1] ); + + fflush( file ); + fclose( file ); + + Sys_Printf( " done.\n" ); + + break; + } + case MINIMAP_SIDECAR_NONE: + break; + } + /* return to sender */ return 0; } diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index dfc971a9..fecbf5f6 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -548,6 +548,13 @@ typedef enum } miniMapMode_t; +typedef enum +{ + MINIMAP_SIDECAR_NONE, + MINIMAP_SIDECAR_UNVANQUISHED +} +miniMapSidecarFormat_t; + typedef struct game_s { char *arg; /* -game matches this */ @@ -584,6 +591,7 @@ typedef struct game_s qboolean miniMapKeepAspect; /* minimap keep aspect ratio by letterboxing */ miniMapMode_t miniMapMode; /* minimap mode */ char *miniMapNameFormat; /* minimap name format */ + miniMapSidecarFormat_t miniMapSidecarFormat; /* minimap sidecar format */ char *bspIdent; /* 4-letter bsp file prefix */ int bspVersion; /* bsp version to use */ qboolean lumpSwap; /* cod-style len/ofs order */