happyleavesaoc / aoc-mgz

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

support parsing of which item is being cancelled #64

Closed santolucito closed 3 years ago

santolucito commented 3 years ago

the full parser did not support extracting which item is being cancelled when the action is an order to cancel production (building_id = -1). It seems this is a single byte that was being treated as padding. Not sure if this byte has a role when the order is not to cancel production, but since it was treated as padding prior to this pull request, this should not break anything.

Interestingly, the queue is grouped by unit/research type, excepting the current item in production. The current item in production is always 0. The next "group" (e.g. multiple vills) is 1, then the next group would be 2 (even if there are, for example, 10 vill queued ahead of that. As an example, if you have the queue:

villA -> villB-> villC -> loom

cancelling villA will have "cancelOrder" = 0. cancelling villC will have "cancelOrder" = 1. cancelling villB will have "cancelOrder" = 1. cancelling loom will have "cancelOrder" = 2.

happyleavesaoc commented 3 years ago

Hi @santolucito, thanks for the contribution. A few recommended changes:

  1. Rename field to cancel_order to maintain naming convention.
  2. Change type to Byte (Int8ub is just an alias -- and then there's no need for an extra import -- which is currently missing -- see the failed build).
santolucito commented 3 years ago

Good points, fixed in most recent commit

happyleavesaoc commented 3 years ago

Thanks, merged!