happyleavesaoc / aoc-mgz

Age of Empires II recorded game parsing and summarization in Python 3.
MIT License
197 stars 41 forks source link

WiC mod support? #2

Closed coffenbacher closed 8 years ago

coffenbacher commented 8 years ago

Hi HappyLeaves,

Do you know if there's something about WiC mod that breaks this parser? I was trying to parse the Clan Masters recs here (for example: http://aoczone.net/viewtopic.php?f=1342&t=123008) and they're all crashing near the end with:

/root/miniconda3/envs/mgz/lib/python2.7/site-packages/construct/core.pyc in _read_stream(stream, length)
    303     data = stream.read(length)
    304     if len(data) != length:
--> 305         raise FieldError("expected %d, found %d" % (length, len(data)))
    306     return data
    307 

FieldError: expected 1512, found 4

I'm guessing it may be something to do with achievements since I can't get that action to extract no matter what I do, but I'm not sure exactly.

happyleavesaoc commented 8 years ago

I know I have successfully parsed WiC mod recs with this module, but that was back during WiC itself. It is possible the mod has changed, or something else has changed in AoC, or that there is something unique to these recs that is hitting a previously-unknown bug.

coffenbacher commented 8 years ago

Sounds good, I'll see if I can figure it out.

happyleavesaoc commented 8 years ago

If you solve it, a PR would be welcome!

coffenbacher commented 8 years ago

Of course! I'm going to be parsing a lot of recs soon so I'll try to PR anything useful I come up with. Although this is rather out of my wheelhouse, so don't hold your breath 11. I'm amazed that you + others were able to figure this format out at all in the first place. Really well done.

happyleavesaoc commented 8 years ago

What's your project? I might be able to find some time to look at this.

coffenbacher commented 8 years ago

I'm attempting to parse many, many games (gb scale) to try to generate interesting stats. For example, I was going to look at the effect of slinging in the current Clan Masters tournament.

Here's a toy example that I made yesterday using Arabia 1v1 recs: https://www.reddit.com/r/aoe2/comments/50ck09/feudal_times_in_the_arabia_1v1_invitational/?st=isi7cxex&sh=f60288b1

happyleavesaoc commented 8 years ago

I did some investigating. The problem is in the postgame achievements parsing. The quick fix is to comment out this line. You'll still get a parse error, but it will be after the postgame action is parsed, which is the last action anyway.

Those last bytes are actually of variable length. From the games I checked, it could be 0, 504, or 1512. Those with 504 or 0 were failing for you. The next step would be to figure out what influences those extra bytes. I suspect it is something in the postgame structure. That whole section is a bit odd, since I think userpatch hacked it in, rather than being a planned part of the rec from Ensemble.

Cool project. I thought about doing something roughly along those lines, but never had time. Good luck!

coffenbacher commented 8 years ago

Awesome! Thanks happyleaves. Should be good enough for now.

happyleavesaoc commented 8 years ago

Fixed in https://github.com/happyleavesaoc/aoc-mgz/commit/cc496d2f44ab433cda28eec912f2beac1ca7af89