Siafoo is here to make coding less frustrating and to save you time. Join Siafoo Now or Learn More


over 7 years ago

I'm a little bit stuck and having trouble getting through what I'm trying to wrap my mind around, so it's time to do what my friends like to call 'Codespew'... the following passages may not make any sense whatsoever, but the simple act of making the attempt to somehow define them helps me to figure out a problem.

It's actually hard to define where precisely this new problem is. I have the core of the GUI set up - there's still the analysis panel to create, but that'll just be a bunch of boxes with variables in them. Shouldn't be too much trouble to make. I haven't made it yet because I don't have the variables to put into it yet - and to have the variables, I need calculations to actually be done. Therein lies my problem - I'm not sure where to start with actually doing the calculations, especially considering my 'replay' feature.

The replay feature will be essential to the program, so I should probably figure out how precisely that is going to work before I do anything else. Okay, here's the premise.

The program first needs a way to distinguish between opening a file for stamping and opening a file for replaying. Stamping is the act of placing timestamps on the lines fed in from an original log file as it is being written by the LOTRO program. Replaying is the act of loading a previously stamped file and 'playing' the file's contents based on the timestamps, so it looks like the fight is happening in real time.

When stamping, the original logfile is constantly being read from and when the program catches a line that isn't empty, it processes it.

When replaying, the entire file is loaded into memory, processed into arrays/objects, and the program decides when to display each line based on the difference in timestamps between the 'next' line and the current line.

So how to differentiate? Do we do it based only on the presence of timestamps? The idea is flimsy at best. I think that the best way to do this would be to have two different 'load' menu options - 'stamp logfile' and 'replay logfile.' Each option should be able to call an event loop in the application, unless I'm terribly mistaken, so that we don't always have two loops running, and there isn't even one loop running if a file simply isn't loaded.

So, even when we've let the user specify what type of file we're messing with, how does the program know what to do with the contents of the file? This will require liberal use of regexps and arrays. I will need to define a number of different regexps (or perhaps One Regexp To Rule Them All, if I can manage it) that will be able to pull apart each line and stuff the important parts of it into an array for each line.

But what to do with those arrays? Where to put them? Each section of the log that spans a single stream of uninterrupted combat will be considered a subsession. A subsession is an object with a multidimensional array of data pulled from lines from the log file. Where do we put the subsession? It can go into an array inside a 'root' Session object.

So a Session object has an array which lists the subsessions which list the data from the lines.

Once I create this structure and am able to fill it with data, I will be able to proceed with the other things I mentioned earlier.


over 7 years ago (24 Jun 2009 at 01:58 AM) by Stou S.
You should probably start building the GUI even if you don't have any actual data for it, just use fake numbers / strings whatever the normal format is. This will let you plugin real data as it becomes available giving you feedback. Also the earlier you start prototyping the gui components the easier it would be to figure out what works and what doesn't (design wise).

Also I disagree, you shouldn't make the user tell you what file type their loading. Think about an image editing program that made you tell it what image format you are loading... most will autodetect the image format and if they can't... will ask the user. Try for an approach like that (an option to select what file type the user loaded might be a good idea... for example in the status bar you can have an icon that distinguished between "replaying" and "stamping" and if the user clicked it a menu would popup....).

Oh and if you are already processing this log file by adding your own timestamps can you not put a custom header at the top that will let you know if the file has been stamped.
over 7 years ago (24 Jun 2009 at 08:06 AM) by Jenifer Irwin
Thanks for the advice - the custom header is something I hadn't thought of! I did consider making my own file extension but I'm not sure how appropriate it would be to do so. Any thoughts on that?

Good point on the GUI aspect as well. I'll go ahead and keep working on the analysis panel for now, and then work on my Session/subsession objects.
over 7 years ago (24 Jun 2009 at 12:36 PM) by Stou S.
I would think a custom extension is in order because it would distinguish your processed files from the raw logs and might prevent confusion if people are using your program and some other log analyzer at the same time. Also as you develop this you will probably end up adding more pre-processing (beyound timestamps) to the log file making it deviate even more from the raw form

As far as the header you could probably use something as simple as a magic number (http://en.wikipedia.org/wiki/File_format#Magic_number)