Updated: January 25, 1998
=====================================================================
Title                   : Q2toWad
Filenames               : q2towad.exe, q2pal.lmp
Version                 : 1.3

Author                  : Tim Wright
Net Nick                : Argh!
Email Address           : argh@ntplx.net
WWW                     : yeah, still workin on it... ;)

Description             : Utility to extract Quake2 wal textures 
                          from a pak into a specfied number of wad2 
                          files.
                          * Includes the ability to convert to a new 
                            palette, like for Quake or Hexen2
                          * Can include Quake2 dir names in textures
                            so that most any editor can compile the
                            level for Quake2
                          * Works on any standard Quake2 pak files

Requirements            : A Win32 operating system, about twice the
                          HD space that the textures take up (around 
                          35Mb for Quake2's pak)

Additional Credits to   : id Software for Quake and Quake2, Mattias 
                          "Preacher" Konradsson and David "Kevlar"
                          Kelvin for help with testing, the 
                          Unofficial Quake Specs at:
          http://www.gamers.org/dEngine/quake/spec/quake-spec32.html,
                          and everyone who sent me constructive
                          feedback.
 
Other Works by Author   : ArghLite - enhanced bsp lighting utility

=====================================================================
* Usage *

Put q2towad.exe and q2pal.lmp in the same dir as the Quake2 pak0.pak 
and run the executable with whatever options you wish.

Remember, any textures extracted and/or converted from Quake2 remain 
the property of id software.


Command-line options
--------------------
-?                - Lists command line options.

-pak filename     - Use specified pak file.  Can be used for custom
                     pak files, or to q2towad from any location by 
                     specifing a full pathname to pak0.pak.  Default 
                     is "pak0.pak". (see *notes*)

-palette filename - Convert textures to specified palette (must be 
                     in palette.lmp format).  Default is no new 
                     palette. (see *notes*)

-wad filename     - Uses this filename for the output wad.  Default 
                     is "quake2.wad".

-brights #        - Specifies number of fullbrights at the end of the
                     new palette, these colors will be ignored in 
                     palette conversions.  Default is 32.

-split #          - Splits the output into specified number of wads.
                     Simply splits into similar-sized parts, no
                     attempt is made to organize the textures in any 
                     way.  Successive letters, starting with "a", are
                     appended to the filename.

-dirname          - Adds Quake2 texture dir names to the texture's 
                     names.  Allows most editors to use this wad to 
                     compile levels for Quake2.  Default is no dir
                     names.

-nogray           - Turns OFF special processing for pure gray 
                     values (only use if the destination palette 
                     does not contain many pure grays).  Default is 
                     ON.


* Examples *

>Q2TOWAD.EXE

   Extracts all textures into quake2.wad, no palette conversion.

>Q2TOWAD.EXE -palette palette.lmp

   Extracts all textures into quake2.wad, converting them to the 
   new palette. (see *notes*)

>Q2TOWAD.EXE -split 5 -wad Q2.wad

   Extracts textures into 5 wads: Q2a.wad, Q2b.wad, Q2c,wad, 
   Q2d.wad, and Q2e.wad, no palette conversion.

>Q2TOWAD.EXE -dirname

   Extracts textures into quake2.wad, includes the Quake2 texture 
   dir names on the textures, no palette conversion.

>Q2TOWAD.EXE -pak mypak.pak -wad mywad.wad

   Extracts textures from mypak.pak into mywad.wad, no palette 
   conversion.


* Notes *

For palette conversions you need to use a pak utility to extract the 
"palette.lmp" from the (Quake, Hexen2, etc) pak.  Put this in the 
same dir with the q2towad files and use the -palette command line 
option.

For custom paks, be sure texture dir names are included in the wal 
files themselves (like Quake2).  Also, keep the total 
dirname/texturename length 16 characters or less, or they will be 
truncated and possibly made unusable.


* Technical *

For the curious...  

Pak file operations are done in-place, relatively little is loaded 
into memory at a time.  Considering the size of the Quake2 pak, this 
is a very good thing. ;)

To convert to other palettes, I used a basic nearest-color-matching 
algorithm.  Distance ties are broken by examining the difference in 
green values, then if still tied examining the difference in red 
values, then if still tied examining the difference in blue values, 
then if still tied it picks the brighter color.  Also, by default, 
pure grays are only remapped to other pure grays (this can be turned 
off with command-line option: -nogray).

To eliminate duplicates, I first check for duplicate names (without
the Quake2 directory), then I do a CRC32 check on that.  I do this 
because Quake2 has some textures with the same name, but the textures 
themselves are different.  If it's a different texture, and -dirname
isn't used, then I append a "_" to the texture name so editors wont
get confused.

=====================================================================
* History *

Version 1.3 (Jan 25, 1998):
   * added support for custom pak files
   * fixed version number error in output header :}

Version 1.2 (Dec 16, 1997):
   * added -split command line option

Version 1.1:
   * added -dirname command line option
   * added CRC checking to duplicate texture removing formula

Version 1.0 (Dec 9, 1997):
   * first official release

=====================================================================
* Construction *

Compiler used           : Microsoft VC++ 4.0
Construction time       : Couple hours a day for a couple days?
Known Issues            : ?

=====================================================================
* Copyright / Permissions *

Any textures extracted and/or converted from Quake2 remain the 
property of id software.

You MAY distribute this EXE, provided you include this file, with no
modifications.  You may distribute this file in any electronic format
(BBS, Diskette, CD, etc.) as long as you include this file intact.

* Disclaimer *

Usage of Q2toWad is at your own risk.  I accept NO responsibility
for any form of damage incurred through the usage of this program.

=====================================================================
* Where to get this Utility *

ftp://ftp.cdrom.com/pub/quake2/utils/graphics_edit/texture_utils/
   q2towad.zip 
(or http://www.cdrom.com...; and all mirrors)

