#!/bin/sh CWD="$(pwd)" ent_for_mod() { # don't bother if we don't have sources if ! [ -f "$CWD/$1/src/progs.src" ]; then exit fi mkdir -p "$CWD/$1/scripts" ENT_OUTFILE="$CWD/$1/scripts/entities.def" echo '' > "$ENT_OUTFILE" echo "Scanning for definitions inside the game directory." find "$CWD/src/" -type f \( -iname \*.qc \) | while read EDEF_N; do echo "... $EDEF_N" sed -n '/\/*QUAKED/,/*\//p' $EDEF_N >> "$ENT_OUTFILE" done; echo "Scanning for definitions inside the game directory." find "$CWD/$1/src/" -type f \( -iname \*.qc \) | while read EDEF_N; do echo "... $EDEF_N" sed -n '/\/*QUAKED/,/*\//p' $EDEF_N >> "$ENT_OUTFILE" done; cat "$CWD/Tools/base_entities.def" >> $ENT_OUTFILE } # first dump all the general purpose entities BASE_ENT="$CWD/Tools/base_entities.def" echo '' > "$BASE_ENT" echo "Scanning for definitions inside the general entity codebase." find "$CWD/src/entities/" -type f \( -iname \*.qc \) | while read EDEF_N; do echo "... $EDEF_N" sed -n '/\/*!QUAKED/,/*\//p' $EDEF_N >> "$BASE_ENT" # fix doxygen markup done; sed -i 's/*!QUAKED/*QUAKED/g' "$BASE_ENT" # each game gets its own ents + general purpose ents appended at the end if [ $# -gt 0 ]; then ent_for_mod $1 fi