diff --git a/code/__DEFINES/__starfly.dm b/code/__DEFINES/__starfly.dm index 5c49118a1c..5e09fd3b44 100644 --- a/code/__DEFINES/__starfly.dm +++ b/code/__DEFINES/__starfly.dm @@ -44,4 +44,5 @@ #define STARFLY13_MODULE_ROSEUS_GALACTIC_ENABLED #define STARFLY13_MODULE_SINTA_UNATHI_ENABLED #define STARFLY13_MODULE_STARFLY_BRANDING_ENABLED +#define STARFLY13_MODULE_STARFLY_SHIPS_ENABLED #define STARFLY13_MODULE_YEOSA_UNATHI_ENABLED diff --git a/modular_starfly/modules/starfly_ships/README.md b/modular_starfly/modules/starfly_ships/README.md new file mode 100644 index 0000000000..bf95782192 --- /dev/null +++ b/modular_starfly/modules/starfly_ships/README.md @@ -0,0 +1,38 @@ +# Starfly-13 Ships + +Module ID: `STARFLY_SHIPS` + +## Description + +Removes non-lore ships and ship configurations in a modular way. New ships will appear in thier own modules. + +## TG Proc/File Changes + +- N/A + + +## Modular Overrides + +- N/A + + +## Defines + +- N/A + + +## Included files that are not contained in this module + +- N/A + + +## Credits + +- Patrick Meade created this module. diff --git a/modular_starfly/modules/starfly_ships/_maps/configs/srm_elder.json b/modular_starfly/modules/starfly_ships/_maps/configs/srm_elder.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/modular_starfly/modules/starfly_ships/_maps/configs/srm_sojourner.json b/modular_starfly/modules/starfly_ships/_maps/configs/srm_sojourner.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/modular_starfly/modules/starfly_ships/maps.sh b/modular_starfly/modules/starfly_ships/maps.sh new file mode 100755 index 0000000000..c1226a0b29 --- /dev/null +++ b/modular_starfly/modules/starfly_ships/maps.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# maps.sh + +set -euo pipefail + +# if this module isn't enabled, just bail out here (no error) +if ! grep -q '^#define STARFLY13_MODULE_STARFLY_SHIPS_ENABLED$' code/__DEFINES/__starfly.dm; then + exit 0 +fi + +# define some useful stuff +dest_maps="_maps" +modules_root="modular_starfly/modules" +starfly_maps="$modules_root/starfly_ships/_maps" + +# if _maps doesn't exist, just bail out here (error) +[[ -d "$dest_maps" ]] || { echo "ERROR: $dest_maps not found" >&2; exit 1; } + +# otherwise, its time to build up the custom maps staging directory +export STARFLY_MAPS_DIR=".staging/_maps" + +# ensure staging directory exists and is clean +rm -rf "$STARFLY_MAPS_DIR" +mkdir -p "$STARFLY_MAPS_DIR" + +# copy the original maps into our staging directory +echo "Copying: $dest_maps -> $STARFLY_MAPS_DIR/" +cp -a "$dest_maps"/. "$STARFLY_MAPS_DIR"/ + +# copy the custom maps provided by every other module +shopt -s nullglob +for module_dir in "$modules_root"/*/; do + [[ "${module_dir%/}" == "$modules_root/starfly_ships" ]] && continue + maps_dir="${module_dir%/}/_maps" + + [[ -d "$maps_dir" ]] || continue + + echo "Merging: $maps_dir -> $STARFLY_MAPS_DIR/" + cp -a "$maps_dir"/. "$STARFLY_MAPS_DIR"/ +done + +# remove all the maps specified by this module +if [[ -d "$starfly_maps" ]]; then + ( + cd "$starfly_maps" + find . -type f -mindepth 1 -depth -print0 + ) | while IFS= read -r -d '' relpath; do + echo "Removing: $STARFLY_MAPS_DIR/$relpath" + rm -rf "$STARFLY_MAPS_DIR/$relpath" + done +fi diff --git a/tgui/packages/tgui/starfly.ts b/tgui/packages/tgui/starfly.ts index f996d83bba..f6f8e70d00 100644 --- a/tgui/packages/tgui/starfly.ts +++ b/tgui/packages/tgui/starfly.ts @@ -31,5 +31,6 @@ export const STARFLY13 = { MODULE_ROSEUS_GALACTIC_ENABLED: true, MODULE_SINTA_UNATHI_ENABLED: true, MODULE_STARFLY_BRANDING_ENABLED: true, + MODULE_STARFLY_SHIPS_ENABLED: true, MODULE_YEOSA_UNATHI_ENABLED: true, }; diff --git a/tools/build/build b/tools/build/build index 0e202e1bba..f6af20fdcc 100755 --- a/tools/build/build +++ b/tools/build/build @@ -1,4 +1,5 @@ #!/bin/sh set -e +modular_starfly/modules/starfly_ships/maps.sh cd "$(dirname "$0")" exec ../bootstrap/node build.js "$@" diff --git a/tools/build/build.js b/tools/build/build.js index 51198c716b..6624c566bd 100755 --- a/tools/build/build.js +++ b/tools/build/build.js @@ -26,6 +26,24 @@ Juke.setup({ file: import.meta.url }).then((code) => { const DME_NAME = "shiptest"; +//--------------------------------------------------------------------------------------------------------------------- +// STARFLY EDIT - ADDITION BEGIN +// #ifdef STARFLY13_MODULE_STARFLY_SHIPS_ENABLED +//--------------------------------------------------------------------------------------------------------------------- +const DEFAULT_MAPS_DIR = "_maps"; +const STAGED_MAPS_DIR = process.env.STARFLY_MAPS_DIR; // e.g. ".staging/_maps" + +// Use staged maps dir if provided AND it exists; otherwise normal _maps +const MAPS_DIR = + STAGED_MAPS_DIR && fs.existsSync(STAGED_MAPS_DIR) ? STAGED_MAPS_DIR : DEFAULT_MAPS_DIR; + +const mapsPath = (p) => `${MAPS_DIR}/${p}`; +const stripMapsPrefix = (p) => p.replace(`${MAPS_DIR}/`, ""); +//--------------------------------------------------------------------------------------------------------------------- +// #endif // #ifdef STARFLY13_MODULE_ADMIN_VERB_FREEZE_ENABLED +// STARFLY EDIT - ADDITION END +//--------------------------------------------------------------------------------------------------------------------- + export const DefineParameter = new Juke.Parameter({ type: "string[]", alias: "D", @@ -62,7 +80,7 @@ export const DmMapsIncludeTarget = new Juke.Target({ ]; const content = folders - .map((file) => file.replace("_maps/", "")) + .map(stripMapsPrefix) .map((file) => `#include "${file}"`) .join("\n") + "\n"; fs.writeFileSync("_maps/templates.dm", content); @@ -80,7 +98,7 @@ export const DmTarget = new Juke.Target({ get(DefineParameter).includes("ALL_MAPS") && DmMapsIncludeTarget, ], inputs: [ - "_maps/map_files/**", + mapsPath("map_files/**"), "code/**", "html/**", "icons/**",