From 1d40804cee7633e7d394e520e091922874bbcdfb Mon Sep 17 00:00:00 2001 From: Drulikar Date: Tue, 7 Jan 2025 05:30:25 -0600 Subject: [PATCH] Overly complicated bash script --- maps/~map_system/_map_selection.dm | 2 +- .../nanomap-renderer-invoker.sh | 63 ++++++++++++++++--- 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/maps/~map_system/_map_selection.dm b/maps/~map_system/_map_selection.dm index 879f058f545..b942f1fb844 100644 --- a/maps/~map_system/_map_selection.dm +++ b/maps/~map_system/_map_selection.dm @@ -1,4 +1,4 @@ -#ifndef CITESTING +#if !defined(CITESTING) && !defined(SPACEMAN_DMM) /*********************/ /* MAP SELECTION */ diff --git a/tools/github-actions/nanomap-renderer-invoker.sh b/tools/github-actions/nanomap-renderer-invoker.sh index dc35825ee1f..22a89e83d4f 100755 --- a/tools/github-actions/nanomap-renderer-invoker.sh +++ b/tools/github-actions/nanomap-renderer-invoker.sh @@ -7,14 +7,23 @@ mapdirs=( "maps/tether" "maps/offmap_vr/talon" ) +#Put a define file to include. One per line matching mapdirs. +#If the same define is reused it will be batched if in sequence. +mapdefines=( + "maps/groundbase/groundbase.dm" + "maps/stellar_delight/stellar_delight.dm" + "maps/tether/tether.dm" + "maps/tether/tether.dm" +) +dme="vorestation.dme" RED='\033[0;31m' GREEN="\033[0;32m" -#DO NOT TOUCH THIS VARIABLE. It will automatically fill with any maps in mapdirs that are form MAPNAMEn.dmm. +#This will automatically fill with any maps in mapdirs that are form MAPNAMEn.dmm. map_files=() #Fill up mapfiles list for mapdir in ${mapdirs[@]}; do - echo "Scanning $mapdir..." + echo "Scanning $mapdir..." FULLMAPDIR=$BASEDIR/$mapdir map_files+=($FULLMAPDIR/*[0-9]*.dmm) done @@ -24,20 +33,54 @@ echo "Full map list:" for map in ${map_files[@]}; do echo $map done - printf "\n\n\n" -echo "Rendering maps..." -#Render maps to initial images -~/dmm-tools minimap "${map_files[@]}" --disable smart-cables,overlays,pretty +#Duplicate stdout because dmm-tools doesn't return an error code for bad icons or bad path so we need to capture it +exec 5>&1 -if [ $1 == "--testing" ]; then - if [ $? -eq 0 ]; then - #Errors occured during test +#Now render per group to initial images +any_errors=0 +map_files=() +index=0 +for mapdir in ${mapdirs[@]}; do + FULLMAPDIR=$BASEDIR/$mapdir + map_files+=($FULLMAPDIR/*[0-9]*.dmm) + cur_define=${mapdefines[index++]} + + if [[ (index -lt ${#mapdefines[@]}) && ("${cur_define}" == "${mapdefines[$index]}") ]]; then + # Next iteration uses the same define so batch it + echo "Batching next iteration..." + continue + fi + + #Insert the define file into the dme if needed + if [[ "${cur_define}" != "" ]]; then + echo "Injecting ${cur_define} into ${dme}..." + echo "#include \"${cur_define}\"" >> ${dme} + fi + + #Render maps to initial images ignoring some tg specific icon_state handling + result=$(~/dmm-tools minimap "${map_files[@]}" --disable smart-cables,overlays,pretty | tee /dev/fd/5) + + #Check if anything errored + if [[ ($? -ne 0) || ("${result}" =~ ("bad icon"|"bad path")) ]]; then + any_errors=1 + fi + + #Undo changes for next iteration + map_files=() + if [[ "${cur_define}" != "" ]]; then + sed -i '$ d' ${dme} + fi + printf "\n" +done + +#Give results if we're just testing +if [[ $1 == "--testing" ]]; then + if [[ any_errors -ne 0 ]]; then echo -e "${RED}Errors occured during testing!" exit 1 fi - #Testing passed echo -e "${GREEN}Maps were successfully rendered." exit 0 fi