random things/tricks/tips

Generating a “gallery” image from a texture wad:

$ wad -x --nomip quake.wad
$ rename + _+ *.pcx
$ montage -geometry 64x64>+1+1 -tile 16 -background black -title “quake.wad” -fill white *.pcx quake.wad.png

results in a 8 textures per row at 64px per texture, small textures are not upscaled but bigger ones are downscaled.

edit: This writes a full color PNG. I had no luck with 8 bit PNGs in imagemagick. PNG8:filename.out.png gave big loss of colors. -color 256 altered the input images instead of the whole montage.

This is better:

montage -geometry 64x64>+1+1 -tile 16 -background black -title “quake.wad” -fill white *.pcx quake.wad.png && convert -quality 90 quake.wad.png quake.wad.jpg && rm quake.wad.png

Yes, JPEG. Looks good and is as small as a proper 256 color PNG (which I could not create in decent quality on the command line; GIMP is fine however…)

for wad in *.wad; do /home/hannes/spiele/quake/quakeforge/bin/bin/wad -x --nomip ${wad} && rename + _+ *.pcx && montage -geometry 64x64>+1+1 -tile 16 -background black -title “${wad}” -fill white *.pcx ${wad}.png && convert -quality 90 ${wad}.png ${wad}.jpg && rm ${wad}.png *.pcx; done

wad to average color:

wad -x --nomip file.wad
for i in *.pcx; do pcxtoppm ${i} > ${i}.ppm; done
for i in *.ppm; do ppmhist -noheader ${i} >> colorcounts ; done #creates a file with R G B and counts, not summarized but with one line per occurance per image file.

TODO making the actual average…

Downloading all files of a sourceforge project:

download all the pages on which direct download links are

wget -np -m -A download http://sourceforge.net/projects/fteqw/files/

extract those links

grep -Rh direct-download sourceforge.net/ | grep -Eo '“.*” ’ | sed ‘s/"//g’ > somefile

remove temporary files, unless you want to keep them for some reason

rm -r sourceforge.net/

download each of the extracted URLs, put into $projectname/

while read url; do wget --content-disposition -x -nH --cut-dirs=1 “${url}”; done < somefile

see https://github.com/SpiritQuaddicted/sourceforge-file-download

Recording a own3d.tv livestream to a file or stream it live with VLC or mplayer or any other media player.

ngrep -q GET > somefile

then find the equivalent values for the parameters like in:

rtmpdump -r “rtmp://owned.fc.llnwd.net:1935/owned?h=0d7fcacf42a447eb4520bd76f59e3870&r=1323626133” -W “http://static.ec.own3d.tv/player/Own3dPlayerV2_74.swf” -y “tastyspleentv_113?h=0d7fcacf42a447eb4520bd76f59e3870&r=1323626133” --live

To save to a file add -o output.flv
To stream directly add a pipe and use your favourite media player, eg: | mplayer -

Trying this for mirroring a SMF forum at the moment:
wget -m -nv -nH --append-output=my.log --no-parent --no-clobber --continue --timeout=10 --adjust-extension --convert-links --page-requisites --keep-session-cookies --user-agent=“Spirit at quaddicted.com archiving this great piece of Quake/id history” http://url

–header=“accept-encoding: gzip” does NOT work with -m since wget cannot READ the downloaded gzipped files. :frowning:

Download non-live videos from twitch.tv:

Just use youtube-dl instead of the mess below.

ngrep the packet that contains the username of the account whose video(s) you want, eg this random one:

http://de.twitch.tv/mortiii/b/310740011

GET /archives/2012-3-5/live_user_mortiii_1330984547.flv HTTP/1.1…Accept: /…Accept-Language: de-DE…Referer: http://www-cdn.jtvnw.net/widgets/archive_site_player.r5767dac721dacd775716df6ee5c543f2c8814530.swf..x-flash-version: 11,1,102,63…Accept-Encoding: gzip, deflate…User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)…Host: media18.justin.tv…Connection: Keep-Alive…Cookie: language=en…

And there you have the host and the path. The download URL for this random example is http://media18.justin.tv/archives/2012-3-5/live_user_mortiii_1330984547.flv

Straight BSP to image with each byte treated as greyscale value. Silly? Yes.

$ od --address=n -t u1 --width=1024 gmsp3tw.bsp > gmsp3tw.bsp.8bit.1024.pgm

“-t d1” means each 1 byte as decimal value (unsigned integer)
–width is the column width of the output

Then check how many lines you got and create an actual PGM file just by adding three lines to the file (as first lines), eg:

[quote]
P2
1024 5478
255[/quote]
P2 is the PGM format. 1024 the width, 5478 the length. 255 the color depth.

You can open the file in GIMP then.

Adding screenshot triggers to a demo:

Keygrip is the easiest tool I could find. Runs well with Wine.

Open the block editor to find the block you want to edit. Then select it in the thumbnail list. “Insert” → “New Message”, “stufftext” “screenshot”.
Save as demo. Done!

edit: I can only insert to every 16th block, what the hell.

Playing random maps from your id1/maps/ directory on Linux:

id1maps=/path/to/your/quake/id1/maps
while true
do
	file=$(ls -1 "${id1maps}"/*.bsp | sort --random-sort | head -1) && \
	echo "Current random map is $file" && \
	ln --symbolic --force "${file}" "${id1maps}/randommap.bsp" && \
	inotifywait --event open "${id1maps}/randommap.bsp"
done

Needs inotify-tools for inotifywatch.

Works well in combination with

bind m "map randommap"

Markdown lets you embed images in the comments section.

Example code:

alt text

The path must be a valid internet adress to an image file. I only tested it with .jpg so far.

Beware of oversized pictures like in http://www.quaddicted.com/reviews/func_mapjam2.html:

And use it with care, i see Spirit tearing his hair out already:)