PDA

View Full Version : Logfile watcher



Trousermonkey
09-30-2001, 07:03
Hi,
I was wondering if anyone is interested in trying out an application I've written to help sort logfiles and screenshots as you play. I am interested in any input about enhancements and for feedback on how it runs on other systems.

This application came about after I decided to write my own maltz style war story at the prodding of a friend. The first few chapters went up with no problem but then I got into a frenzy of playing one weekend and beat the game. When I went back to my screenshots folder I had about 200 tga's and about 20-30 battles to document. I made a cursory stab at it but gave up when I realized it would take me a tremendous amount of time to untangle all the screenshots and match them to specific battles.

The logwatcher executable is a 246k zipped (493k unzipped) application that runs in the background as you play shogun. It monitors the logfile directory and starts working as soon as it see's a change (a new logfile has been written after completing a battle). When this happens, it creates a directory in the TGA's folder with the game type, date, time, and province it was in (ex. TGA's\historical campaign 09-06-01 182752 Mount Hiei\). The new logfile is copied to this new directory and any new screenshots (from the last battle for example) are moved into it. The result is a very organized /TGA's/ directory that can be easily browsed for battle information.

I can email the file to anyone interested or upload it to my homepage for general download.

Tm

Kraellin
09-30-2001, 09:02
TM,

ever think of using this as a battle recorder? we had a thread in here a while back and the first thing i thought of when you mentioned this thing was my earlier suggestion in that thread to make a simple battle recorder based on capturing tga's.

how do you keep track of which tga's in the tga folder belong to which game? you must keep track of which have already been recorded, yes? and if that's the way yer doing it then you'd have to be really careful about making other tga's manually.

K.


------------------
I'm sorry, but i never apologize.

Trousermonkey
09-30-2001, 10:17
When the application first starts it makes a list of current screenshots and logfiles. I then start a thread using the winapi function, FindFirstChangeNotification(), to check for any changes to the logfile directory. When there's a change, I get the new logfile directory file listing and compare it with the original list to determine which file to transfer(I assume only one file will be added at a time).
The same thing is done with TGA's. I create a base list when it starts and then compare the 'refreshed' list to this old list when a new logfile is created. Any differences in the list are moved to the new directory. One limitation is it can't discern between in-game screenshots and strategy map screenshots. Any new shot when the logfile directory changes is moved indiscriminately.

As for a battle recorder; sorting tga's as they are generated would be a trivial task. The only problem I see would be how to deal with these ~2Mb files as the game is running. Ideally a conversion to jpeg or something compressed would be good but I think to do that in real time would be difficult.

Kraellin
09-30-2001, 13:15
ok, i followed most of that. but i'm assuming since you didnt say anything about it, that one still has to take screenshots manually...at least like it is. would it be possible to set up an app that would force the program to take a screenshot based on a timer and do this automatically? or would you have to use the windows screenshot thing, the printscreen thing built into windows? a feature like that with an adjustable timer length would be nice and could substitute as a sort of battle recorder, at least a still shot sequence, which is better than nothing.

and btw, my in-game screenshots are only about 1.2 megs, not 2 megs. where you getting 2 meg shots?

K.


------------------
I'm sorry, but i never apologize.

tootee
09-30-2001, 15:22
Quote The only problem I see would be how to deal with these ~2Mb files as the game is running. Ideally a conversion to jpeg or something compressed would be good but I think to do that in real time would be difficult.[/B][/QUOTE]

Well, you can always just log the related files and not physically moving them during play time, which is relatively smaller (in range of < 1kbytes?). Once out of battle mode, you can always run a simpe script to read in the log, and move and organise the files offline.

------------------
tootee the toothless warrior (aka goldfish shimazu)
------------------

qwertyuiop
09-30-2001, 21:29
I like toote's idea. Just making a small text file for each battle loging pictures taken would suffice. Then you could add a button that copies all the pictures to their respective folders when the user is ready to organize.

Trousermonkey
10-01-2001, 00:43
Yeah, you still have to take the screenshots manually. I didn't think about having an automatic process to do that sort of thing. I remember seeing source code somewhere detailing how to take screenshots. I'll look into it. I don't know if taking a windows screenshot would be any better than using the in-game screenshot capability. To use the in-game screenshot recorder one would have to hack the game and determine where that function call resides (or maybe just automatically send a F2 keypress...hmmmm). Also, I imagine an external screenshot recorder would be better than using the in-game one because then you're not tieing up the game engine taking screenshots.
I'm running my game at a pretty high resolution and it affects the tga size. My strategy map is at an even higher resolution; those TGA's are about 3.6Mb each (but very pretty to look at).

Yeah, tootee's idea is good -it would help free up system resources and another bonus would be TGA file names would be different from battle to battle. The one drawback I've found using my app to write a warstory is that the TGA names are the same for each battle because the shogun app looks at the last file written to the root TGA directory and increments the filename number. By moving the TGA's into their own directories, I'm clearing the root TGA directory and the new screenshots are saved starting from the beginning for each battle (00000000.tga, 00000001.tga, 00000002.tga, ...). Putting this into an html page means manually renaming these files -which is a pain.

Also, T pointed out another minor problem in my code last night; it looks like the app still needs a little polishing, but I appreciate the input.

hecose
10-01-2001, 07:32
Hi Trousermonkey,

Where can I download the file?

Kraellin
10-01-2001, 07:54
TM,

yes, forcing an f2 shld work. asheron's call, which i used to play, can use a number of third party script files during game play. i dont recall what they all did, but surely the same could apply to shogun. you could do a number of practice routines with those scripts in asheron's call, which all forced key code commands upon the game, so i would think it could be done in stw/we/mi as well.

ah, hi res screens. k. that explains the larger file sizes. thanks.

and yes, putting off doing as much of this as possible while the game is running is a good idea. if you did wish to make this simple battle recorder it would be nice to have a variable rate of capture that could be adjusted either by changing the variable in the script or a simple button to set the time delay between captures. ostensibly one would start the script outside of the game, load the game, and whenever the game went into battle mode the script would already be monitoring to catch when this happened and then start its capture process. for the strat map captures i doubt if you would need the automaticity of capturing since this portion of the game is turn based and not real time.

K.


------------------
I'm sorry, but i never apologize.

qwertyuiop
10-01-2001, 09:28
to my knowlege TM, in windows 9x taking a screenshot of a directX window dosn't give you a very nice image:)

Kraellin you gave me an I idea with this:

"they all did, but surely the same could apply to shogun. you could do a number of practice routines with those scripts in asheron's call, which all forced key code commands upon the game, so i would think it could be done in stw/we/mi as well."

I can probably hook STW and force a F2 call depending on how they handle events! If its standardard it should be a cake walk:)

qwertyuiop
10-01-2001, 09:34
I am keeping TM's work here for now: http://24.150.62.244/trouser/

I was going to wait for him to tell you were to get it. I'm not sure why he didn't but I will give him a little kick by doing this http://www.totalwar.org/ubb/smile.gif

Very neat little program, try and spot the bugs http://www.totalwar.org/ubb/smile.gif

This his not his latest version of the log reader but it gives you a taste of what he is planning. I haven't seen the battle recorder yet, get to work! http://www.totalwar.org/ubb/smile.gif

qwertyuiop
10-01-2001, 09:37
You guys can upload all your beta programs for testing and what not there if you need to as well.
ftp://24.150.62.244
login: FTP_USER
pass: measshole

but only your own programs eh.

Trousermonkey
10-01-2001, 11:41
Sorry about not responding immediately I was out a large part of this afternoon. I just uploaded the logwatcher program to t's server. http://24.150.62.244/trouser/

I'll start researching how to send keystrokes to another running app. I vaguely remember seeing something like this a while back. I don't know of a simple way to determine when the game in running in battle mode and when it's at the strategy map but I suppose if the user has a means of modifying the speed of screen capture, they could also use a button to pause or start automatic F2 keypresses. The only other thing that concerns me at this point is how it will affect gameplay. I've got a tricked out gaming PC; 1.2GHz and GeForce video and there still is a noticible jump or lag in gameplay when I press the F2-key. I wonder if a battle will still be playable with a recorder going?

Kraellin
10-01-2001, 21:24
yup T,

a hook. or, like TM is saying, if stw/we/mi is 'on top', wouldnt a running script that 'pressed' the f2 key force that being applied to the app 'on top'? or is it done some other way?

at any rate, you guys are smokin!

K.


------------------
I'm sorry, but i never apologize.

Trousermonkey
10-02-2001, 01:28
From the little research I did last night, I should be able to send a keypress to a specific application regardless if it's on top or not (by finding and specifying the windows process id for shogun). I also found information about capturing system wide keystrokes regardless of which application has focus.

Both processes seem to be pretty involved and, not having done this sort of thing before, it might take me a bit to figure out how things work but I'll give it a shot

Kraellin
10-02-2001, 02:12
TM,

there ya go. outstanding :)

K.


------------------
I'm sorry, but i never apologize.

qwertyuiop
10-02-2001, 02:39
Yep, thats a windows hook. I have some basic ASM examples I can send you.

Also be sure to check out this page: http://spiff.tripnet.se/~iczelion/tut24.html

Even though there all assembly you use the api in the same way like the ReadFile problem a while back.