make_mapdef.sh: parse entityDef files in the game directory

This commit is contained in:
Marco Cawthorne 2023-05-27 15:57:43 -07:00
parent bd8351db58
commit dbe394fa28
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
1 changed files with 97 additions and 0 deletions

View File

@ -1,5 +1,99 @@
#!/bin/sh
# takes one argument: path to .def file
ed_for_def()
{
printf -- "" > "/tmp/def_name"
printf -- "" > "/tmp/def_color"
printf -- "" > "/tmp/def_mins"
printf -- "" > "/tmp/def_mins"
printf -- "" > "/tmp/def_maxs"
printf -- "" > "/tmp/def_usage"
printf -- "" > "/tmp/def_model"
{ cat "$1"; echo; } | while read LINE
do
SEG1=$(echo "$LINE" | awk '{ print $1 }')
SEG2=$(echo "$LINE" | awk '{ print $2 }')
KEY=$(echo "$LINE" | awk -F"\"" '{ print $2 }')
VAL=$(echo "$LINE" | awk -F"\"" '{ print $4 }')
if [ "$KEY" == "entityDef" ]
then
printf -- "$VAL" > "/tmp/def_name"
fi
if [ "$SEG1" == "entityDef" ]
then
printf -- "$SEG2" > "/tmp/def_name"
fi
if [ "$KEY" == "editor_color" ]
then
printf -- "$VAL" > "/tmp/def_color"
fi
if [ "$KEY" == "editor_mins" ]
then
printf -- "$VAL" > "/tmp/def_mins"
fi
if [ "$KEY" == "editor_maxs" ]
then
printf -- "$VAL" > "/tmp/def_maxs"
fi
if [ "$KEY" == "editor_usage" ]
then
printf -- "$VAL" > "/tmp/def_usage"
fi
if [ "$KEY" == "model" ]
then
printf -- "$VAL" > "/tmp/def_model"
fi
if [ "$SEG1" == "}" ]
then
KEY_NAME=$(cat "/tmp/def_name")
KEY_COLOR=$(cat "/tmp/def_color")
KEY_MINS=$(cat "/tmp/def_mins")
KEY_MAXS=$(cat "/tmp/def_maxs")
KEY_USAGE=$(cat "/tmp/def_usage")
KEY_MODEL=$(cat "/tmp/def_model")
if [ -z "$KEY_NAME" ]
then
exit 0
fi
if [ -z "$KEY_COLOR" ]
then
exit 0
fi
# no mins/maxs
if [ -z "$KEY_MINS" ]
then
printf "/*QUAKED $KEY_NAME ($KEY_COLOR) ?\n"
else
printf "/*QUAKED $KEY_NAME ($KEY_COLOR) ($KEY_MINS) ($KEY_MAXS)\n"
fi
printf "$KEY_USAGE\n"
# no model
if [ ! -z "$KEY_MODEL" ]
then
printf -- "-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY --------\n"
printf "model=\"$KEY_MODEL\"\n"
fi
printf "*/\n"
fi
done
}
ent_for_mod()
{
# don't bother if we don't have sources
@ -17,6 +111,9 @@ ent_for_mod()
# fix doxygen markup
sed -i 's/*!QUAKED/*QUAKED/g' "$ENT_OUTFILE"
done;
find ./$1/ -type f \( -iname \*.def \) | while read EDEF_N; do
ed_for_def "$EDEF_N" >> "$ENT_OUTFILE"
done;
cat ./platform/entities.def >> $ENT_OUTFILE
}