#!/bin/bash # A simple script using SED to make map configs # compatible with the new layout. # HELP file: if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "" ]; then echo "Usage: "$0" MAP_CONFIG_FILE(S)" echo "This script will make a backup of specified map CFG files (into their existing" echo "directory), then using SED it will modify the original map CFG file to be" echo "compatible with the new packaging layout for AssaultCube." echo "" echo "This script can accept multiple map CFG files at once, as well as wild cards, as" echo "well as files in different directories. For example:" echo " sh "$0" ../packages/maps/yourmap.cfg ../../mapfolder/*.cfg" echo "" echo "Options (must be placed before the CFG filenames):" echo -e " -h, --help This help message." echo -e " -r, --revert Revert specified config file(s) to the current \".BAK\" file." exit # REVERT command: elif [ "$1" = "-r" ] || [ "$1" = "--revert" ]; then for file in $*; do if [ "$file" = "-r" ] || [ "$file" = "--revert" ]; then continue elif [[ -w "$file" && "$file" = *.cfg && -r "$file".BAK ]]; then mv -fv "$file".BAK "$file" else echo -e "\a\E[31m\033[1mERROR:\E[0m "$file" was unwriteable (or not a \".CFG\"), or "$file".BAK file was unreadable." exit fi done exit fi # Alias to define if anything failed (but the script continued). CONTFAILED="0" for file in $*; do if [[ -r "$file" && -w "$file" && "$file" = *.cfg ]]; then # Backup files first: cp "$file" "$file".BAK if [ -r "$file".BAK ]; then echo "A successful backup of "$file" has been made to "$file".BAK" echo "Now converting "$file" to a compatible map config file..." else echo -e "\a\E[31m\033[1mERROR:\E[0m Backup of "$file" failed. Please check files can be written in the \"`dirname $file`\" directory." echo -e "Please note, because backing up of "$file" failed, it was NOT converted.\n" CONTFAILED="1" continue fi echo "Converting mapmodels..." sed -i '/^mapmodel/s/\/jcdpc\/laptop/g' $file sed -i '/^mapmodel/s/\/jcdpc\/cardboardbox/g' $file sed -i '/^mapmodel/s/\/jcdpc\/hanginglamp/g' $file sed -i '/^mapmodel/s/\/jcdpc\/ventflap/g' $file sed -i '/^mapmodel/s/\/ratboy\/toca_milkcrate_blue/g' $file sed -i '/^mapmodel/s/\/ratboy\/toca_milkcrate_red/g' $file sed -i '/^mapmodel/s/\/makke\/aardapple_enginebox/g' $file sed -i '/toxic/!s/\/makke\/barrel/g' $file sed -i '/^mapmodel/s/\/makke\/barrel_fallen/g' $file sed -i '/^mapmodel/s/\/makke\/barrel_toxic/g' $file sed -i '/^mapmodel/s/\/makke\/barrel_newsteel/g' $file sed -i '/^mapmodel/s/\/makke\/barrel_newsteel_fallen/g' $file sed -i '/^mapmodel/s/\/makke\/bench_seat/g' $file sed -i '/^mapmodel/s/\/makke\/platform/g' $file sed -i '/^mapmodel/s/\/makke\/platform_shine/g' $file sed -i '/^mapmodel/s/\/makke\/lightbulb/g' $file sed -i '/^mapmodel/s/\/makke\/coke_can/g' $file sed -i '/^mapmodel/s/\/makke\/coke_can_fallen/g' $file sed -i '/^mapmodel/s/\/makke\/office_chair/g' $file sed -i '/^mapmodel/s/\/makke\/coffee_mug/g' $file sed -i '/^mapmodel/s/\/makke\/platform_bridge/g' $file sed -i '/^mapmodel/s/\/makke\/drainpipe/g' $file sed -i '/^mapmodel/s/\/makke\/dumpster/g' $file sed -i '/^mapmodel/s/\/makke\/electric_meter/g' $file sed -i '/^mapmodel/s/\/makke\/pallet/g' $file sed -i '/^mapmodel/s/\/makke\/cigarette/g' $file sed -i '/^mapmodel/s/\/makke\/fence_chainlink/g' $file sed -i '/^mapmodel/s/\/makke\/fence_chainlink_closed_gate/g' $file sed -i '/^mapmodel/s/\/makke\/fence_chainlink_no_gate/g' $file sed -i '/^mapmodel/s/\/makke\/fence_chainlink_post/g' $file sed -i '/^mapmodel/s/\/makke\/flyer_propaganda/g' $file sed -i '/^mapmodel/s/\/makke\/flyer_environmental/g' $file sed -i '/^mapmodel/s/\/makke\/fuel_tank/g' $file sed -i '/^mapmodel/s/\/makke\/icicle/g' $file sed -i '/^mapmodel/s/\/makke\/hook/g' $file sed -i '/^mapmodel/s/\/makke\/locker/g' $file sed -i '/^mapmodel/s/\/makke\/fluorescent_lamp/g' $file sed -i '/^mapmodel/s/\/makke\/broken_wood/g' $file sed -i '/^mapmodel/s/\/makke\/wrench/g' $file sed -i '/^mapmodel/s/\/makke\/wall_spotlight/g' $file sed -i '/floppy/!s/\/makke\/street_light/g' $file sed -i '/^mapmodel/s/\/makke\/ladder_1x/g' $file sed -i '/^mapmodel/s/\/makke\/ladder_7x/g' $file sed -i '/^mapmodel/s/\/makke\/ladder_8x/g' $file sed -i '/^mapmodel/s/\/makke\/ladder_10x/g' $file sed -i '/^mapmodel/s/\/makke\/ladder_11x/g' $file sed -i '/^mapmodel/s/\/makke\/ladder_15x/g' $file sed -i '/^mapmodel/s/\/makke\/ladder_15x_offset/g' $file sed -i '/^mapmodel/s/\/makke\/grate_hor/g' $file sed -i '/^mapmodel/s/\/makke\/grate_vert/g' $file sed -i '/^mapmodel/s/\/makke\/mine-shaft_elevator/g' $file sed -i '/^mapmodel/s/\/makke\/bolt_nut/g' $file sed -i '/^mapmodel/s/\/makke\/sail/g' $file sed -i '/^mapmodel/s/\/makke\/sail_snow/g' $file sed -i '/^mapmodel/s/\/makke\/wires\/2x8/g' $file sed -i '/^mapmodel/s/\/makke\/wires\/3x8/g' $file sed -i '/^mapmodel/s/\/makke\/wires\/4x8/g' $file sed -i '/^mapmodel/s/\/makke\/wires\/4x8a/g' $file sed -i '/^mapmodel/s/\/makke\/signs\/wanted/g' $file sed -i '/^mapmodel/s/\/makke\/signs\/arab/g' $file sed -i '/toca/!s/\/makke\/signs\/biohazard/g' $file sed -i '/^mapmodel/s/\/makke\/signs\/caution_voltage/g' $file sed -i '/^mapmodel/s/\/makke\/signs\/caution_maintainence/g' $file sed -i '/^mapmodel/s/\/makke\/signs\/flammable/g' $file sed -i '/^mapmodel/s/\/makke\/signs\/speed/g' $file sed -i '/^mapmodel/s/\/makke\/signs\/no_camping/g' $file sed -i '/^mapmodel/s/\/makke\/roadblock/g' $file sed -i '/^mapmodel/s/\/makke\/roadblock_graffiti/g' $file sed -i '/^mapmodel/s/\/makke\/nothing_clip/g' $file sed -i '/^mapmodel/s/\/makke\/picture/g' $file sed -i '/^mapmodel/s/\/makke\/plant_leafy/g' $file sed -i '/^mapmodel/s/\/makke\/plant_leafy_dry/g' $file sed -i '/^mapmodel/s/\/makke\/plant_leafy_snow/g' $file sed -i '/^mapmodel/s/\/makke\/grass_short/g' $file sed -i '/^mapmodel/s/\/makke\/grass_short_dry/g' $file sed -i '/^mapmodel/s/\/makke\/grass_short_snow/g' $file sed -i '/^mapmodel/s/\/makke\/grass_long/g' $file sed -i '/^mapmodel/s/\/makke\/grass_long_dry/g' $file sed -i '/^mapmodel/s/\/makke\/grass_long_snow/g' $file echo "Converting textures..." sed -i '/^texture/s/\/..\/models\/mapmodels\/wotwot\/makke_drainpipe_gritty\/skin.jpg/g' $file sed -i '/^texture/s/\/..\/models\/mapmodels\/wotwot\/toca_commrack_dull\/skin.jpg/g' $file sed -i '/^texture/s/\/..\/models\/mapmodels\/wotwot\/toca_monitor_dull\/skin.jpg/g' $file sed -i '/^texture/s/\/..\/models\/mapmodels\/wotwot\/toca_milkcarton_dull\/skin.jpg/g' $file sed -i '/^texture/s/\/..\/models\/mapmodels\/wotwot\/toca_guardrail2_dull\/skin.jpg/g' $file sed -i '/^texture/s/\/zastrow\/metal_overlaps.jpg/g' $file sed -i '/^texture/s/\/zastrow\/metal_plate_fill.jpg/g' $file sed -i '/^texture/s/\/zastrow\/metal_siding_kinksb.jpg/g' $file sed -i '/^texture/s/\/zastrow\/metal_siding_kinks.jpg/g' $file sed -i '/^texture/s/\/zastrow\/sub_doors512A10.jpg/g' $file sed -i '/^texture/s/\/zastrow\/sub_doors512A16.jpg/g' $file sed -i '/^texture/s/\/zastrow\/sub_doors512B05.jpg/g' $file sed -i '/^texture/s/\/zastrow\/sub_window31.jpg/g' $file sed -i '/^texture/s/\/zastrow\/sub_window33.jpg/g' $file sed -i '/^texture/s/\/zastrow\/sub_sand.jpg/g' $file sed -i '/^texture/s/\/zastrow\/brick_wall_08.jpg/g' $file sed -i '/^texture/s/\/zastrow\/brick_wall_09.jpg/g' $file sed -i '/^texture/s/\/zastrow\/sub_window23.jpg/g' $file sed -i '/^texture/s/\/zastrow\/vent_cap.jpg/g' $file sed -i '/^texture/s/\/zastrow\/sub_window38.jpg/g' $file sed -i '/^texture/s/\/zastrow\/sub_doors256nf_01.jpg/g' $file sed -i '/^texture/s/\/zastrow\/rb_box_07.jpg/g' $file sed -i '/^texture/s/\/golgotha\/elecpanelstwo.jpg/g' $file sed -i '/^texture/s/\/golgotha\/metal_bumps2.jpg/g' $file sed -i '/^texture/s/\/golgotha\/tunnel_ceiling.jpg/g' $file sed -i '/^texture/s/\/golgotha\/hhroofgray.jpg/g' $file sed -i '/^texture/s/\/golgotha\/metal_bumps3.jpg/g' $file sed -i '/^texture/s/\/golgotha\/tunnel_ceiling_b.jpg/g' $file sed -i '/^texture/s/\/golgotha\/5sqtunnelroad.jpg/g' $file sed -i '/^texture/s/\/3dcafe\/door07_a.jpg/g' $file sed -i '/^texture/s/\/3dcafe\/door07.jpg/g' $file sed -i '/^texture/s/\/3dcafe\/door10_a.jpg/g' $file sed -i '/^texture/s/\/3dcafe\/door10.jpg/g' $file sed -i '/^texture/s/\/3dcafe\/door12.jpg/g' $file sed -i '/^texture/s/\/3dcafe\/door15.jpg/g' $file sed -i '/^texture/s/\/3dcafe\/objects08.jpg/g' $file sed -i '/^texture/s/\/3dcafe\/objects09_a.jpg/g' $file sed -i '/^texture/s/\/3dcafe\/stone18.jpg/g' $file sed -i '/^texture/s/\/grsites\/brick051.jpg/g' $file sed -i '/^texture/s/\/grsites\/brick065.jpg/g' $file sed -i '/^texture/s/\/grsites\/wood060.jpg/g' $file sed -i '/^texture/s/\/grsites\/metal020.jpg/g' $file sed -i '/^texture/s/\/grsites\/metal026.jpg/g' $file sed -i '/^texture/s/\/lemog\/036metal.jpg/g' $file sed -i '/^texture/s/\/lemog\/006metal.jpg/g' $file sed -i '/^texture/s/\/lemog\/063bois.jpg/g' $file sed -i '/^texture/s/\/lemog\/063bois_b.jpg/g' $file sed -i '/^texture/s/\/lemog\/027metal.jpg/g' $file echo -e "Successfully finished converting: "$file"\n" else echo -e "\a\E[31m\033[1mERROR:\E[0m "$file" is an incorrect filename or path, or it is not a \".cfg\" file, or it may be non-readable and/or non-writeable.\n" CONTFAILED="1" fi done if [ "$CONTFAILED" = "1" ]; then echo -e "\aConversion finished, HOWEVER, \E[31m\033[1msome files were NOT converted\E[0m!" echo "Please check the output of this script for their errors!" echo "It is suggested to check your map config files carefully for any inconsistencies, using the \"diff\" command." else echo -e "\aConversion succeessfully completed with NO errors!" echo "It is suggested to check your map config files carefully for any inconsistencies, using the \"diff\" command." fi