diff options
Diffstat (limited to '')
| -rwxr-xr-x | project/scripts/create-brres-lists.sh | 256 | ||||
| -rw-r--r-- | project/scripts/distrib.list | 3 | ||||
| -rw-r--r-- | project/scripts/kcl/lower-walls.txt | 41 | ||||
| -rw-r--r-- | project/scripts/kcl/minimap.txt | 17 | ||||
| -rw-r--r-- | project/scripts/kcl/remove-face-down-roads.txt | 20 | ||||
| -rw-r--r-- | project/scripts/minimap.sh | 174 | ||||
| -rw-r--r-- | project/scripts/patch-all-messages.sh | 32 | ||||
| -rwxr-xr-x | project/scripts/test-wszst.sh | 99 | ||||
| -rw-r--r-- | project/scripts/test-wu8.sh | 96 |
9 files changed, 738 insertions, 0 deletions
diff --git a/project/scripts/create-brres-lists.sh b/project/scripts/create-brres-lists.sh new file mode 100755 index 0000000..2f6669a --- /dev/null +++ b/project/scripts/create-brres-lists.sh @@ -0,0 +1,256 @@ +#!/usr/bin/env bash + +# +#------------------------------------------------------------------------------ +echo "* setup" + +listdir=./_lists +[[ $1 = -t || $1 == --test ]] || rm -rf "$listdir" +mkdir -p "$listdir" + +filelist="$listdir/brres.flist" +listing="$listdir/brres.list" + +subfilelist="$listdir/sub-file.list" +submodelist="$listdir/sub-mode.list" +subcountlist="$listdir/sub-count.list" + +#subfilesummary="$listdir/sub-summary.txt" + +subfileflist="${subfilelist%.list}.flist" +submodeflist="${submodelist%.list}.flist" +subcountflist="${subcountlist%.list}.flist" + +info="$listdir/INFO.txt" + +# +#------------------------------------------------------------------------------ +echo "* create file list : $filelist" + +if [[ -s $filelist ]] +then + echo " -> skipped" +else + find . -type f -name '*.brres' | sort -f >"$filelist" +fi + +# +#------------------------------------------------------------------------------ +echo "* create brres listing : $listing" + +if [[ -s $listing ]] +then + echo " -> skipped" +else + wszst lll "@$filelist" >"$listing" +fi + +# +#------------------------------------------------------------------------------ +echo "* create sub file listing : $subfilelist" + +awk=' + BEGIN { file = "" } + END { print "" } + + $1 == "*" && $2 == "Files" { + file = "" + idx = index($0,":"); + if ( idx > 0 ) + { + file = substr($0,idx+1); + print ""; + } + #printf("FILE: %s\n",file); + } + + file != "" && $5+0 > 0 && $4 != "...." { + printf("%s %2u %s %s\n",$4,$5,file,$6); + } + +' + +if [[ -s $subfilelist ]] +then + echo " -> skipped" +else + awk "$awk" "$listing" >"$subfilelist" +fi + +# +#------------------------------------------------------------------------------ +echo "* create sub file listing : $subfileflist" + +awk_flist=' + $4 == "" { print; next } + { printf("%s %2u %s\n",$1,$2,$3) } +' + +if [[ -s $subfileflist ]] +then + echo " -> skipped" +else + awk "$awk_flist" "$subfilelist" | uniq >"$subfileflist" +fi + +# +#------------------------------------------------------------------------------ +echo "* create sub mode listing : $submodelist" + +awk=' + BEGIN { mode = "" } + END { print "" } + + $3 != "" { + newmode = $1 "." $2; + if ( mode != newmode ) + { + if ( mode == "" ) + print ""; + else + print "\f"; + mode = newmode; + } + printf("%s %2u %s %s\n",$1,$2,$3,$4); + } +' + +if [[ -s $submodelist ]] +then + echo " -> skipped" +else + sort -f "$subfilelist" | awk "$awk" >"$submodelist" +fi + +# +#------------------------------------------------------------------------------ +echo "* create sub mode listing : $submodeflist" + +if [[ -s $submodeflist ]] +then + echo " -> skipped" +else + awk "$awk_flist" "$submodelist" | uniq >"$submodeflist" +fi + +# +#------------------------------------------------------------------------------ +echo "* create sub count listings : $subcountlist $subcountflist" + +awk1=' + $3 != "" { printf("%s %2u\n",$1,$2); } +' + +awk2=' + BEGIN { mode = "" } + END { print "" } + + { + if ( mode != $2 ) + { + mode = $2; + print ""; + } + printf("%6u* %s %2u\n",$1,$2,$3); + } +' + +if [[ -s $subcountlist && -s $subcountflist ]] +then + echo " -> skipped" +else + awk "$awk1" "$submodelist" | uniq -c | awk "$awk2" >"$subcountlist" + awk "$awk1" "$submodeflist" | uniq -c | awk "$awk2" >"$subcountflist" +fi + +# +#------------------------------------------------------------------------------ +echo "* create info file : $info" + +cat <<- --EOT-- >"$info" + +OVERVIEW: +--------- + +The list files can be divided into 2 groups: + *.list files are the base listings with all BRRES sub files. + *.flist are reduced listings: + No more than one line for each BRRES and category. + +All files are machine readable, just ignore empty lines (inserted for human +readability) and lines containing only 1 formfeed (ASCII 12, inserted for +fast finding of sections). Columns are separated by multiple spaces (like +awk and other tools does). + + + +FILES: +------ + +${filelist##*/} + File list of all explored BRRES files. + +${listing##*/} + A sub listing of all explored BRRES files. + This listing was made with: wszst lll @${filelist##*/} + +${subfilelist##*/} + A list of sub files with for space separated columns: + MAGIC VERSION BRRES_FILE SUB_FILE + The file is sorted by the BRRES_FILE column. + +${subfileflist##*/} + Same as '${subfilelist##*/}', but reduced to BRRES file level. + A list of sub files with for space separated columns: + MAGIC VERSION BRRES_FILE + The file is sorted by the BRRES_FILE column. + +${submodelist##*/} + Same as '${subfilelist##*/}', but sorted by columns MAGIC and VERSION. + +${submodeflist##*/} + Same as '${subfileflist##*/}', but sorted by columns MAGIC and VERSION. + Same as '${submodelist##*/}', but reduced to BRRES file level. + +${subcountlist##*/} + This is a summary of '${subfilelist##*/}' or '${submodelist##*/}'. + Instead of filenames it contains exist counters. + COUNT* MAGIC VERSION + +${subcountflist##*/} + This is a summary of '${subfileflist##*/}' or '${submodeflist##*/}'. + Instead of filenames it contains exist counters. + COUNT* MAGIC VERSION + + + +STATISTICS: +----------- + +--EOT-- + +{ + printf "SZS files:" + sed 's+\.szs\.d/.*$++' "$filelist" | uniq | wc -l + + printf "BRRES files:" + cat "$filelist" | wc -l + + printf "BRRES sub files:" + grep -v '^$' "$submodelist" | wc -l + +} | awk -F: '{printf("%6u %s\n",$2,$1)}' >>"$info" + + +cat <<- --EOT-- >>"$info" + + + +Wiimm, $(date '+%F %T') + +--EOT-- + +# +#------------------------------------------------------------------------------ +echo "done" + diff --git a/project/scripts/distrib.list b/project/scripts/distrib.list new file mode 100644 index 0000000..11900fa --- /dev/null +++ b/project/scripts/distrib.list @@ -0,0 +1,3 @@ +scripts/kcl +scripts/test-wszst.sh +scripts/test-wu8.sh diff --git a/project/scripts/kcl/lower-walls.txt b/project/scripts/kcl/lower-walls.txt new file mode 100644 index 0000000..6ec281d --- /dev/null +++ b/project/scripts/kcl/lower-walls.txt @@ -0,0 +1,41 @@ +############################### +### (c) Wiimm, 2015-12-18 ### +############################### + +# Setup +@def start = mSec() # start time, for the status line +@def mod_count = 0 # modification counter + +# Get the value for lowering the walls. +# If 'lower' is defined as number by option --const => use it. +# Otherwise use the default of 30. +@def lower = isNumeric(lower) ? lower : 30 + +# Limit to walls with inclination <45 degree +# If 'degree' is defined by option --const as number >0 => use it. +# Otherwise use the default of 45 degrees. +@def degree = isNumeric(degree) && degree > 0 ? degree : 45 +@def sin_degree = sin(degree) + +# Define a function to test the KCL flag for walls +@function isWall # flag + @pdef t = $1 & 0x1f + @return t == 0x0c || t == 0x0d || t == 0x0f || t == 0x14 || t == 0x1e || t == 0x1f +@endfunction + +# Main loop: Iterate through all triangles +@for t=0;tri$n()-1 + @if isWall(tri$flag(t)) + @def norm = tri$normal(t,0) # get the first normal + @if abs(norm.y) < sin_degree + # it's a vertical wall -> lower the wall & increment counter + @def status = tri$shift(t,-vy(lower)) + @def mod_count = mod_count+1 + @endif + @endif +@endfor + +# Print a little status line +@echo " - " mod_count " of " tri$n() " triangles lowered by " lower + > " in " (mSec()-start) " msec." + diff --git a/project/scripts/kcl/minimap.txt b/project/scripts/kcl/minimap.txt new file mode 100644 index 0000000..a79ac08 --- /dev/null +++ b/project/scripts/kcl/minimap.txt @@ -0,0 +1,17 @@ + +@def start = mSec() # start time +@def mod_count = 0 # modification counter + +@function isRoad # flag + @pdef t = $1 & 0x1f + @return t <= 0x05 || t == 0x17 || t == 0x1d +@endfunction + +@for t=0;tri$n()-1 + @if !isRoad(tri$flag(t,2)) + @def status = tri$remove(t) + @endif +@endfor + +@echo " - " mod_count " of " tri$n() " triangles lowered in " (mSec()-start) " msec." + diff --git a/project/scripts/kcl/remove-face-down-roads.txt b/project/scripts/kcl/remove-face-down-roads.txt new file mode 100644 index 0000000..e21bddf --- /dev/null +++ b/project/scripts/kcl/remove-face-down-roads.txt @@ -0,0 +1,20 @@ + +#--- remove face down roads + +@def start = mSec() # start time, for the status line +@def rm_count = 0 # reset status counter + +@for t=0; tri$n()-1 # for each tirangle (index 0 based) + @pdef type = tri$flag(t) & 0x1f # get the KCL type + @if kcl$drive & (1<<type) # if it is a drivable KCL type + @def norm = tri$normal(t,0) # get the first normal + @if norm.y < 0 # if it is face down + @def stat = tri$remove(t) # remove the triangle + @def rm_count = rm_count + 1 # incremtent the counter + @endif # endif + @endif # endif +@endfor + +# print out a summary line +@echo " - " rm_count " face down road triangles removed in " (mSec()-start) " msec." + diff --git a/project/scripts/minimap.sh b/project/scripts/minimap.sh new file mode 100644 index 0000000..37ac857 --- /dev/null +++ b/project/scripts/minimap.sh @@ -0,0 +1,174 @@ +#!/bin/bash +# made by Wiimm, 2012-10-06 + +plusmode=0 +testmode= +kclmode=0 + +#------------------------------------------------------------------------------ + +function trim() +{ + echo "$1" | sed -r 's/[[:blank:]]+/ /; s/^ //; s/ $//' +} + +#------------------------------------------------------------------------------ + +function add_destname() +{ + local dest="$1" + local plus="$2" + local add="$3" + + if [[ ! $dest =~ $add ]] + then + + if ((plus)) + then + #--- add '+' + + local s1="${dest%%(*}" + local s2="${dest#*(}" + if [[ $s1 != $s2 ]] + then + s2="($s2" + else + s1="${dest%%\[*}" + s2="${dest#*\[}" + if [[ $s1 != $s2 ]] + then + s2="[$s2" + else + s2="" + fi + fi + s1=$( trim "$s1" ) + s2=$( trim "$s2" ) + dest="$s1+ $s2" + fi + + + #--- add '[+$add]' + + local s1="${dest%%]*}" + local s2="${dest#*]}" + if [[ $s1 != $s2 ]] + then + dest="$s1,+$add]$s2" + else + dest="$dest [+$add]" + fi + fi + echo "$dest" +} + +#------------------------------------------------------------------------------ + +while (($#)) +do + src="$1" + shift + + if [[ $src = + ]] + then + plusmode=1 + continue + fi + + if [[ $src = ++ ]] + then + plusmode=1 + kclmode=1 + continue + fi + + if [[ $src = -t || $src == --test ]] + then + testmode=--test + continue + fi + + if [[ $src = -k || $src == --kcl ]] + then + kclmode=1 + continue + fi + + if [[ ! -f $src ]] + then + printf "%s: Not found: %s\n" "${0##*/}" "$src" >&2 + continue + fi + + #--- extract ext + + ext="${src##*.}" + if [[ $ext = $src ]] + then + dest="$src" + ext="" + else + dest="${src%.*}" + ext=".$ext" + fi + + d=${dest%_d} + if [[ "$d" != "$dest" ]] + then + dest="$d" + ext="_d${ext}" + fi + + dest="$(add_destname "$dest" 1 minimap)" + + + #--- trim dest + + dest="$( trim "$dest" )$ext" + + if ((plusmode)) + then + idx="${dest:0:2}" + idx="${idx/[^0-9]/}" + let idx=10#0$idx + if (( idx % 10 < 4 )) + then + let idx=idx+1 + else + let idx=idx+7 + fi + dest="$idx ${dest:3}" + #echo "idx=$idx" + fi + + temp="$dest.temp" + echo "DEST=|$dest|" + + + #--- create temp, fix minimap, rename track + + ln -f "$src" "$temp" + wszst -q minimap -r --auto "$temp" $testmode + if ! diff -q "$src" "$temp" >/dev/null + then + ((plusmode)) || rm -f "$src" + mv "$temp" "$dest" + if ((kclmode)) + then + kcldest="$(add_destname "$dest" 0 kcl)" + echo "KCLDEST=|$kcldest|" + cp -p "$dest" "$kcldest" + wszst norm "$kcldest" --kcl new,drop + if diff -q "$dest" "$kcldest" >/dev/null + then + rm "$kcldest" + else + rm "$dest" + fi + fi + fi + + rm -f "$temp" + +done + diff --git a/project/scripts/patch-all-messages.sh b/project/scripts/patch-all-messages.sh new file mode 100644 index 0000000..845260c --- /dev/null +++ b/project/scripts/patch-all-messages.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +#--- pre definitions: enter your local settings + +# This is the directory with all message files (/Scene/UI) +SRC_UI_DIR="./ui" + +# and this is the destination directory. If it is the same as the source +# than all files are replaced by the patched version. +DEST_UI_DIR="$SRC_UI_DIR" + +# This is the path to the message file of above: +PATCH_FILE="bmg-patch.txt" + +# Remove the the hash ('#') of the second line for fast operation. +# This makes the file about 25-30% larger but the operation is much faster +FAST= +#FAST=--fast + +#--- more automated setup + +TEMP="$(mktemp -d)" || exit 1 + +#--- patch it in 3 steps: extract szs + patch bmg + create new szs + +wszst extract --quiet "$SRC_UI_DIR/"*_?.szs --dest "$TEMP/%N.d" +wbmgt patch --quiet "$TEMP/"*.d/message/*.bmg --patch "replace,$PATCH_FILE" +wszst create --quiet --remove "$TEMP/"*.d --dest "$DEST_UI_DIR" $FAST + +#--- clean up (remove temp dir) + +rm -rf "$TEMP" diff --git a/project/scripts/test-wszst.sh b/project/scripts/test-wszst.sh new file mode 100755 index 0000000..ca4a22e --- /dev/null +++ b/project/scripts/test-wszst.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash +# (c) Wiimm, 2012-11-11 + +export LC_ALL=POSIX + +SZS=wszst +[[ -x ./wszst ]] && SZS=./wszst +SZS0="$SZS -q" +SZS="$SZS0" +echo "SZS=$SZS" + +BMG=wbmgt +[[ -x ./wbmgt ]] && BMG=./wbmgt +BMG0="$BMG -q" +BMG="$BMG0" +echo "BMG=$BMG" + +if [[ $1 = -i || $1 = --ignore ]] +then + DIFF="diff -q -x wszst-setup.txt -x .string-pool.* -x .*.d" + echo "DIFF=$DIFF" + printf "\n!!! WARNING: '.string-pool.*' excluded !!!\n\n" + shift +else + DIFF="diff -q -x wszst-setup.txt" + echo "DIFF=$DIFF" +fi + +function error() +{ + echo "!! Test failed: $*" >&2 + exit 1 +} + +let count=0 +for src in "$@" +do + if [[ $src = -n || $src = --new ]] + then + echo ">> enabled: --NEW" + SZS="$SZS0 --NEW" + BMG="$BMG0 --NEW" + continue + fi + + if [[ $src = -o || $src = --old ]] + then + echo ">> enabled: --OLD" + SZS="$SZS0 --OLD" + BMG="$BMG0 --OLD" + continue + fi + + let count++ + printf "%5u. %s\n" $count "$src" + temp="$(mktemp -ut test-wszst-XXXXXXXX).tmp" || exit 1 + #echo "TEMP=$temp" + + $SZS decom "$src" -D "$temp/11.u8" || error 11 decompress + $SZS compr "$temp/11.u8" -D "$temp/12.szs" || error 12 compress + $SZS decom "$temp/12.szs" -D "$temp/13.u8" || error 13 decompress + $DIFF "$temp/11.u8" "$temp/13.u8" || error raw diff 11.u8 13.u8 + + $SZS extr "$src" -D "$temp/21.d" || error 21 extract + $SZS extr "$temp/11.u8" -D "$temp/22.d" || error 22 extract + $DIFF -r "$temp/21.d" "$temp/22.d" || error raw diff 21.d 22.d + + $SZS create "$temp/22.d" -D "$temp/23.u8" --noc || error 23 create + $SZS diff "$src" "$temp/23.u8" || error file diff src 23 + $SZS extr "$temp/23.u8" -D "$temp/24.d" || error 24 extract + $DIFF -r "$temp/21.d" "$temp/24.d" || error raw diff 21 24 + + $SZS extr "$src" -D "$temp/31.d" -a --no-check || error 31 extract --all + $SZS create "$temp/31.d" -D "$temp/32.u8" --noc || error 32 create + $SZS extr "$temp/32.u8" -D "$temp/33.d" -a --no-check || error 33 extract --all + $DIFF -r "$temp/31.d" "$temp/33.d" || error raw diff 31 33 + + $SZS compr "$src" -D "$temp/41.wbz" --wbz || error 41 to wbz + $SZS compr "$temp/41.wbz" -D "$temp/42.szs" --szs || error 42 to szs + $SZS diff "$src" "$temp/42.szs" || error file diff 41 42 + + find "$temp/24.d" -name '*.bmg' | while read f + do + [[ -f $f ]] || continue + echo " - ${f/*.d}" + + $BMG encode "$f" -d "$f.1.bmg" || error encode "$f" + $DIFF "$f" "$f.1.bmg" || error raw diff src 1 + + $BMG decode "$f" -d "$f.2.txt" || error decode "$f" + $BMG encode "$f.2.txt" -d "$f.3.bmg" || error encode "$f" + $DIFF "$f" "$f.3.bmg" || error raw diff src 3 + + done || exit 1 + rm -rf "$temp" + +done +echo "**OK**" + diff --git a/project/scripts/test-wu8.sh b/project/scripts/test-wu8.sh new file mode 100644 index 0000000..e3da22b --- /dev/null +++ b/project/scripts/test-wu8.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +# (c) Wiimm, 2012-10-26 + +export LC_ALL=POSIX +szsmode=0 +logfile= + +SZS=wszst +[[ -x ./wszst ]] && SZS=./wszst +SZS0="$SZS -q" +SZS="$SZS0" +echo "SZS=$SZS" + +DIFF="diff -q" +echo "DIFF=$DIFF" + +HAVE_DCC=0 +which -q dcc &>/dev/null && HAVE_DCC=1 + +function error() +{ + echo "!! Test failed: $*" >&2 + exit 1 +} + +let count=0 +for src in "$@" +do + if [[ $src = -n || $src = --new ]] + then + echo ">> enabled: --NEW" + SZS="$SZS0 --NEW" + continue + fi + + if [[ $src = -o || $src = --old ]] + then + echo ">> enabled: --OLD" + SZS="$SZS0 --OLD" + continue + fi + + if [[ $src = -s || $src = --szs ]] + then + echo ">> enabled: SZS mode" + szsmode=1 + continue + fi + + if [[ $src = -l || $src = --log ]] + then + szsmode=1 + logfile=./wu8-size.log + echo ">> SZS mode enabled, log to: $logfile" + { + echo + date +'--- %F %T ---' + echo + } >>"$logfile" + continue + fi + + let count++ + printf "%5u. %s\n" $count "$src" + temp="$(mktemp -ut test-wu8-XXXXXXXX).tmp" || exit 1 + #echo "TEMP=$temp" + + $SZS decompress "$src" -D "$temp/11.u8" || error 11 decompress + $SZS norm "$temp/11.u8" || error 11 norm + $SZS norm --wu8 "$temp/11.u8" -D "$temp/12.wu8" || error 12 decode WU8 + $SZS norm --u8 "$temp/12.wu8" -D "$temp/13.u8" || error 13 encode WU8 + $DIFF "$temp/11.u8" "$temp/13.u8" || error raw diff 11.u8 13.u8 + + if ((szsmode)) + then + $SZS norm "$src" -D "$temp/21.szs" || error 11 norm + $SZS norm --wu8 "$temp/21.szs" -D "$temp/22.wu8" || error 12 decode WU8 + $SZS norm --u8 "$temp/22.wu8" -D "$temp/23.szs" || error 13 encode WU8 + $DIFF "$temp/21.szs" "$temp/23.szs" || error raw diff 21.szs 23.szs + if [[ $logfile != "" ]] + then + s1=$(stat -c%s "$temp/21.szs") + s2=$(stat -c%s "$temp/22.wu8") + if ((HAVE_DCC)) + then + printf "%8u %8u %6.2f%% %s\n" $s1 $s2 $(dcc "100.0*$s2/$s1") "$src" >>"$logfile" + else + printf "%8u %8u %3d%% %s\n" $s1 $s2 $((100*s2/s1)) "$src" >>"$logfile" + fi + fi + fi + + rm -rf "$temp" +done +echo "**OK**" + |
