   ____          __            
  / __ \ _____  / / ___  ____ _  ____
 / / / // ___/ / / / _ \/ __ `/ / __ \
/ /_/ // /__  / / /  __/ /_/ / / / / /
\___\_\\___/ /_/  \___/\__,_/ /_/ /_/
	"Quake Statistics Generator"			Version 1.1

	 	-----------------------------------------------
			By: M.Bell Copyright 1997
			     aka SkUnK-PuSsY
	    Web: http://www.geocities.com/TimesSquare/6712/quake.htm
 		         Email:  d45f45@msn.com
	 	-----------------------------------------------

 
Background
----------
Ever had a long frag-session with your mates/colleagues and then
wondered... Who's the fastest killer?  How many time did Mr-X kill 
Mr-Y?  Did I get most kills with my trusty shotguns?  Did I really 
suicide as often as I think I did?

If you're thinking yeah!  then read on.....
or if you're gagging to know the frag-on-frag skip to the section:
"Step-By-Step approach".



What's the Program for?
-----------------------
The program takes the log file generated when you play a quake session.
The log can either come from you when you are connected to a server i.e.
as a client or from the server itself.  It then generates all manner of
statistics on play in the format you most want them.....a html doc!



How do I get the log file from Quake?
-------------------------------------
Instead of typing quake to start... type quake -condebug (console-
debug).  Then all of the messages that appear on your console as you
play i.e. Mr-X was gibbed by Mr-Y will appear as a file called
qconsole.log in your ID1 directory by default.  If you're running a
game-patch i.e. grappling-hook you'd type quake -game hook -condebug
The logfile would then appear in the hook directory.




How to use the Program
----------------------
If you just attach to a server, play and leave then use the -condebug
option as mentioned above.  The qconsole.log file can then be thrown
straight into the Qclean program to generate your stats.

To get help:
	qclean /?

Basic use:
	qclean <logfilename.log>

This will produce some basic stats on the screen.  Note that if no
logfile name is given qclean will attempt to use a qconsole.log file in
the directory you're running in.

Advanced Use:

There are several extras that can be created with command-line switches.

	qclean <logfilename.log> -full

This will produce as many stats as possible from the logfile.

	qclean <logfilename.log> -html 

This will produce a .htm file for you to browse with Netscape or MSIE!
If the -full option is also specified the html file will have the full-
range of stats too.

	qclean <logfilename.log> -comma

This produces a comma-delimited datafile .dat for you to read-into
Excel, Dbase etc.  If the -full option is also specified the data file 
will have the full-range of stats too.


The options can all be used together e.g. for the all-singing, all-
dancing output:-

	qclean <logfilename.log> -html -comma -full




Extra-Features!
---------------
Ordinarily if you run a dedicated server it's console displays only odd
messages like Mr-X entered the game and... Mr-x Left with 8 frags.
I have included a small quake-c add-on that will route all other player-
messages i.e. Mr-X was nailed by Mr-Y to the dedicated server console.
When a player enters or leaves the server they are time-stamped too.
Thus, when the server is taken down afterwards the qconsole.log will
have some messages saying  Mr-X : joined at 23, and Mr-X :left at 654.
These are times in seconds and the difference 631 seconds above is the
time the player played-for.



So what's the optimum way of running all this?
----------------------------------------------
Step-By-Step approach: (dedicated server)
-----------------------------------------
(1) Make a new directory under quake i.e. c:\quake\qclean
(2) Put everything into there.
(3) Make a new directory called progs i.e. c:\quake\qclean\progs
(4) Move the .qc file(s) into there.
(5) Copy the extra .qc files required to compile the progs.dat file
(6) Run your QuakeC compiler i.e. qccdos.exe
(7) Start your dedicated server with:-
	quake -dedicated 16 -game qclean -condebug
(8) Sit back and play your game(s).........
(9) When all players have left and the game is dead, close down the
server (i.e. exit quake) and check out the qclean directory...
(10) You should have a qconsole.log file there! containing all the
commentary of the game!
(11) Run the qclean program i.e.
	qclean qconsole.log -full -html -comma
(12) Now distribute the .dat & .htm files to all the players so they can
view their performance with a WWWBrowser or a Spreadsheet!!!


Step-By-Step approach: (client connection)
-----------------------------------------
(1) Make a new directory under quake i.e. c:\quake\qclean
(2) Put everything into there.
(3) Join a server...let the Killing Commence!
	quake -condebug
(4) When all players have left and the game is dead, leave and check out 
the qclean directory...
(5) You should have a qconsole.log file there! containing all the
commentary of the game!
(6) Run the qclean program i.e.
	qclean qconsole.log -full -html -comma
(7) Sit back and look through the results in a WebBrowser or Spreadsheet!



How the Program Works (if you're interested)
--------------------------------------------
The input logfile generated by quake is first read-in along with the
config file (qclean.cfg).  This config file is required to be setup for
the players with names containing spaces.(see Program Limitations section 
below).  The logfile is read line-by-line and any offending player
names are hyphenated as specified in the config file.  

As the file is read it is also written back to disk in it's "cleaned"
form (this is the tmp.log file you may have noticed).  This file is then
read-back in and the work is begun.  The file is passed though once and
the number/name of players is determined.  If the dedicated-server patch
is also installed the player-times are now determined too.
The file is then read again and each line is parsed at a time.  i.e.
certain strings are associated with certain deaths. For example if a
line is read like:-
	Mr-X was nailed by Mr-Y.
	The parser concludes that Mr-Y's frag count should be raised by
	1.  His nailgun-kills should be raised by 1 and, Mr-X's death 
	count should be raised by 1 and his nail-deaths by one also. 
A frag-on-frag matrix is also calculated to show how many times a player
killer another player.
Once the file has been fully parsed some calculations are performed to
determine QuakeWorld'esque figures like Rank(=frags-deaths) and
Efficiency(=frags/(frags+deaths)), and also frags per minute.
Depending on which command-line options were requested the output is
then generated either in a basic(summary) guise or in full-advanced
mode.  The html and/or comma-delimited files are then produced.




Program Limitations
-------------------
OK.. it's good but it's not perfect ;-)
(1) It's done with an old-dos Pascal compiler..filenames are 8characters
or less.
(2) Players with names like "Suck My FaT-OnE" contain spaces.  For the
program to parse these names correctly YOU MUST INCLUDE THEM AND THEIR
REPLACEMENT NAMES IN THE QCLEAN.CFG FILE.
i.e.	Suck My FaT-OnE,Suck_My_FaT-OnE
Spaces simply don't work with the way the program's written. Not yet anyway!
(3) The screen display  is horrible....I know....can't be bothered to 
fix it though....I only use the html file which is fine! Someone please
fix this bit!!!!
(X) Probably loads more...let me know.




What you can/Can't do with all this!
------------------------------------
You are free to use/modify the source on one condition:- That you email
mail me a copy and give me credit in your release docs...
That's it.... hey you'll do what you damn well please anyway!



Where to get this?
------------------
Latest will ALWAYS be on my homepage at:-
http://www.geocities.com/TimesSquare/6712/quake.htm



What's should be included in the archive(qclean10.zip)
----------------------------------------------------
qclean.txt (this!)
qclean.exe
qclean.cfg (sample config file)
qclean.pas (the source-code in Pascal)
qcon.log (a sample log-file)
client.qc (QuakeC file for generating game-messages on dedicated servers)


