home *** CD-ROM | disk | FTP | other *** search
/ Quark 3 / Quark3.iso / KATALOG / ARCHIV / TOOL / T026.ZIP / Q3LOG.TXT < prev    next >
Encoding:
Text File  |  2000-03-23  |  13.7 KB  |  263 lines

  1. /* q3log - A quark III Arena log parser/analyzer
  2. "What's the point of playing if you don't keep score?"
  3. Feedback to: dante@island.net
  4. Current version is 1.0 */
  5.  
  6. ========
  7. Contents
  8. ========
  9. Introduction
  10. Quick Start
  11. Installation
  12. Running q3log
  13. Notes
  14. Technical Notes
  15.  
  16. ============
  17. Introduction
  18. ============
  19. Hi Mom!
  20.  
  21. With that out of the way, let's talk logs. If you're thinking of something
  22. sexual or scatological at this point - ha ha, let's move on now. We're
  23. talking about quark3 logs, and what this program will do with them.
  24.  
  25. q3log will read logs written by quark III Arena and tally all kills and
  26. suicides by each player. These stats will be stored in a database for future
  27. viewing and analysis. These stats will be displayed within 3 graphs:
  28. Lifetime totals/Current totals/Game stats. What precisely is displayed and what
  29. it means will be discussed in the "Running q3log" section.
  30.  
  31. In summary, if you want to keep track of who you killed, who killed you, and
  32. what weapon was used, this program will do so nicely.
  33.  
  34. By the way, this is freeware, so please don't hassle me about features that it
  35. absolutely must have. Ask nicely, and I'll see what I can do.
  36.  
  37.  
  38. ===========
  39. Quick Start
  40. ===========
  41. Run q3log.
  42. Enter your name and where your logs will be located.
  43. Select parse log.
  44. View your stats.
  45.  
  46. The basic operation is pretty much that simple. Honest.
  47.  
  48.  
  49. ============
  50. Installation
  51. ============
  52. I didn't include an installer or anything, because I really don't think it's
  53. necessary. If there's a big demand, I might do something about that later, but
  54. it'll probably just amount to a self-extracting zipfile. But I digress.
  55.  
  56. Personally, I keep the program in its own directory. It doesn't matter where
  57. it is, because you're going to tell it where to find the logs, and it writes all
  58. its own files in the directory that it's in. So, just create a directory, copy
  59. the q3log.exe file into it, and you're set. If you want a shortcut to it, that's
  60. entirely up to you. Make sure the shortcut's properties include the program's
  61. directory, or the program might have a problem finding its configuration and
  62. database files.
  63.  
  64.  
  65. =============
  66. Running q3log
  67. =============
  68. First off, you need to produce some logs. Q3 will do this quite happily, and
  69. all you need to do is run it with the following extra parameters.
  70. +set logfile 2
  71. If you understand what I mean by this and you know how to do it, you can move
  72. to the next thing. If you just use the "Play quark III Arena" shortcut, you need
  73. to alter it a little. In the "Target" box of the shortcut Properties, just add
  74.  +set logfile 2 to the end of what's already there. If you use GameSpy, go to
  75. "Games and Filters". Scroll down until you find the settings for quark3. Change
  76. the command line from "quark3.exe" to "quark3.exe +set logfile 1".
  77. When all that's done, Q3 should write a log of all its activity, and that's
  78. what we're after.
  79.  
  80. The first time you run q3log, the setup dialog will open. You need to show q3log
  81. where your log files will be. If you know where that is, move on. They are
  82. written in  a sub-directory of your quark III Arena directory called "baseq3".
  83. Browse to this directory. In the file list box, you should see (among other
  84. things) pak3.pk3. If that file is there, you're in the right spot.
  85.  
  86. After that, you simply need to enter the name you use in Q3 - and this has to
  87. be exact, or the individual stats will simply all read zero. A good way to find
  88. the exact text of your name is to look in your q3config.cfg file. This will also
  89. be in the directory I mentioned in the last paragraph. You're looking for an
  90. entry that looks like this:
  91. seta name "Dante"
  92. Yours won't say "Dante" of course, but you get the idea.
  93.  
  94. Once those two things are done, you're pretty much ready to go. Select
  95. "Parse Log" from the menu. If your machine is relatively fast (and it should be
  96. if you're playing Q3) the parsing will be finished before you realize it's
  97. started. If you've been keeping a log for weeks and it's 100MB or something,
  98. it'll take a little longer. At any rate, it'll be pretty quick.
  99.  
  100. When it's done, assuming there was at least one frag in the log, you will see
  101. the numbers at the bottom of the screen change from "0/0" to well, something
  102. else. These numbers tell you:
  103. which game in the database is currently selected/total games in the database
  104. You can browse through the database will the arrow buttons.
  105. Now, if you did any fragging yourself, the totals will have changed as well.
  106. The top grids show your lifetime stats - basically the total of all stats for
  107. you in the database, and the bottom grids show your stats for the currently
  108. selected game.
  109.  
  110. You can click on the "Game Stats" tab to get to the nitty-gritty of the currently
  111. selected game. The top grid will show everybody who played in that particular
  112. game, and their totals for that game. The bottom grid shows who fragged who.
  113. Here's how this grid works: The names in the left column are who did the fragging
  114. and the names along the top row are whom they fragged. So if you want to know just
  115. how many times you nailed any particular person, find your name in the left
  116. column and highlight that row. Now just line up the totals with the names. If
  117. you want to scroll around, no problem - the names will remain visible.
  118.  
  119. Keeping score is "A Good Thing", as Martha would say.
  120.  
  121.  
  122. =====
  123. Notes
  124. =====
  125. First off, if your desktop resolution is any lower than 800x600, I'm sorry, but
  126. you're going to be doing A LOT of scrolling around to see everything. Mine's
  127. 1024x768, but I did basically design the interface for 800x600. You'll see what
  128. I mean.
  129.  
  130. q3log will rename your logfiles. I did that so that people wouldn't be
  131. accidentally parsing the same file a whole bunch of times. The logfiles will be
  132. renamed qconsole000.log, qconsole001.log, qconsole002.log, and so on up to
  133. qconsole999.log, at which point it will simply stop renaming them. If you want
  134. to keep more than 1000 logs, you need to get out more. Seriously though, I was
  135. originally going to just delete them, but folks might have another program that
  136. they want to run the logs through, or just want to keep them for a while for
  137. whatever reason. I also didn't really want to see people's hard drives filling up
  138. with files, so this seemed to be somewhere in the middle. If you want to ditch
  139. the old logs, by all means, ditch them. Future feedback will likely decide if
  140. this "feature" changes.
  141.  
  142. If you're interested, q3log creates three files:
  143. q3log.ini - this just stores your name and the location of your logs
  144. totals.dat - stores your lifetime totals, and is updated whenever you
  145. parse new logs
  146. games.dat - stores all game stats, and is updated whenever you parse new logs
  147. (obviously)
  148.  
  149. Don't ask me why I used separate files for the game stats and lifetime totals,
  150. I must have been half-asleep when I wrote that code. I might fix it one day.
  151.  
  152. I don't really know (I don't even have a good guess) how well the program will
  153. scale up as your database grows. During testing I had about 175 games in the
  154. database and it didn't really get noticeably slower - the size of the games.dat
  155. file was just under 500K. However, I realize that folks will likely have thousands
  156. of games in there after a while, and I can't make any promises. The database is
  157. pretty much as compact as it can be, and the only way to make it smaller would be
  158. to get rid of the individual game stats. I don't really want to do that, but it
  159. might be necessary if the database file grows to 5 Gigs and it takes 20 minutes
  160. to browse to the last entry. For those who have a little programming knowledge and
  161. may have some ideas as to how I might make this scale better, I'm all ears. You
  162. can read the technical notes at the end of this file and I'll explain how the
  163. database is set up - assuming I still understand it myself.
  164.  
  165. I'm considering adding a function to remove older games from the database, and
  166. while it would be very easy to write the actual code, I'm fairly sure it would be
  167. a VERY SLOW process with large database files. Another angle might be to have a
  168. maximum number of games per file and simply use multiple database files. That might
  169. get a little hairy after a while, especially if people play a lot of games. However,
  170. if a thousand games in a file isn't too slow, I think it might be the best answer.
  171. We'll see.
  172.  
  173. I'm a CTF guy - that's why capture totals are seen here. However, please don't
  174. write to me asking for your favorite mod to be represented - it's not gonna
  175. happen. There's just too much to track, and the data portion of the program would
  176. quickly get out of hand and exceedingly difficult to manage. Only out-of-the-box
  177. DM/CTF. That's it. Don't ask. Writing the extra code doesn't bother me, but
  178. each individual frag string has to be included to get an accurate total, and I've
  179. seen mods that have 10 or more different strings for each weapon. While some think
  180. that's real nice and keeps everything fresh, it's a nightmare when you're the one
  181. who has to make sure that they have every single one of them exactly right. It's
  182. not hard when you have the source code, but mod authors tend not to release that to
  183. other programmers. So, let me say this once more, just so we're clear. No mods,
  184. no way. Not now, not ever.
  185.  
  186.  
  187. ===============
  188. Technical Notes
  189. ===============
  190. If you understand C++ and you're interested in (basically) how the program
  191. works, here it is. I'm not going to explain how each individual function works,
  192. but hopefully by the time I'm done, you'll have the general idea of what I did
  193. here.
  194.  
  195. The way the frags are initially identified is not particularly magic. The program
  196. searches for strings that are common to each particular type of frag. The way that
  197. Q3 does its logging makes this very easy - once the client's graphics, sound, etc
  198. are set up, game events make up the lion's share of the remaining file.
  199.  
  200. When a line in the log is identified as a frag/capture/suicide or whatever, the text
  201. is parsed to identify attacker, target, and weapon used. Once those things have been
  202. established, this information is added to a binary tree. Each node of the tree
  203. contains the player's name, a couple of structures representing total frags of each
  204. type, and another binary tree containing all the other's players names and how many
  205. times that player has fragged each of them.
  206.  
  207. The math is pretty simple here. The main tree contains X squared objects, X being
  208. the total number of people in the game. While I admit that this would not scale up
  209. very well, the average number of players in any given game is somewhere between
  210. six and twelve, so we're only dealing with about 144 objects max on average. I wrote
  211. a similar program for quark2 and ran it on my 486DX2/66 and it ate through 100
  212. game log files in less than a minute and wrote html files for every game. Now that
  213. we're in Pentium3 country, there's really no problem.
  214.  
  215. The actual mechanics of how all that is done is pretty lightweight stuff, and I'm
  216. going to leave it up to the user to figure out how they would do it. A first year
  217. computer science student could manage it - and in fact one did. Yes, that would be
  218. me. I wrote the previously mentioned program for Q2 during my first year, and once
  219. you have a working knowledge of linked lists and binary trees, it shouldn't be too
  220. difficult to figure out what I did.
  221.  
  222. Ok, let's move on. The program has reached the end of the level, and it's time to
  223. do something useful with this tree we've built. We kick it over to a function that
  224. opens up our database. The first thing in the file is the number of records (games)
  225. contained in the file. We read that, add one, and then write that number back to
  226. the file. We then simply go to the end of the file, and we're ready to write the
  227. stats for this game.
  228.  
  229. Each record is written like so:
  230. We write the number of players in this particular record.
  231. We do an inorder traversal of our player tree, and write the stats for each player
  232. along the way. Player's name, the contents of the kill/suicide structures, then an
  233. individual total for each other player in the tree (we don't need their names here,
  234. because everything is sorted, and their names will come up when we reach their node).
  235.  
  236. Once that's done, we go back up to the top of the file. We then have to go through
  237. each record, searching for our designated player name so that we can update his/her
  238. lifetime stats. All that we need is the kill/suicide structures, and once the player's
  239. name is found within the record, the structure is read and the program moves to the
  240. next record. My hunch is that this will probably be the most time-consuming task when
  241. the file starts to get really large, but I haven't done any real analysis (and if the
  242. truth were known, I probably won't).
  243.  
  244. So when it's time to display a particular game in the grids, the function that
  245. retrieves the stats is fed the record number of the game that the user wants to see.
  246. The program just searches through the file until it finds the desired record. It then
  247. re-builds the tree and that tree is used to fill in the grids. I know, I know. I should
  248. have just used a linked list here, since the records are already sorted. I didn't feel
  249. like going back and changing it by the time I'd reached that stage of the program. With
  250. the tests I've done to this point, it actually reads the records pretty quickly. I'm
  251. hoping that people's systems will be able to keep up with the growing databases to
  252. a certain point. What I'm actually hoping is that the databases will grow too large
  253. for people's hard drives before that happens...
  254.  
  255. I do have a fairly workable idea to make navigation faster, and if it looks like it's
  256. going to bog down fairly quickly, I will implement it. Tallying the lifetime totals
  257. will not get any faster without sacrificing the program's ability to calculate totals
  258. for any named player. Life's a trade-off.
  259.  
  260.  
  261. That's it. Hope it's everything you need.
  262. -Dante
  263.