-
Notifications
You must be signed in to change notification settings - Fork 0
Resource transfer event
The resource transfer event has Type = 0x01 and Code = 0x[1-8]F where the first digit of the code maps to the player receiving the resources.
The first byte is always 0x84.
The rest of the body is made up by 4 resource blocks, each with the following format:
base = The first 3 bytes (big endian)
multiplier = 4th byte >> 4
remainder = 4th byte & 0x0F
The value of each block is then base*multiplier+remainder
- The first 4 bits of the code represent the target player.
- The first block is the minerals
- The second block is the gas
- The 3rd and 4th blocks are (always zero?) unkown
I need a sample pre-16561 game to know for sure, but this is the logic coded into the phpsc2replay project. It could turn out that this build uses the above format as well. I am not really sure why Blizzard would make changes to this (really simple) format.
Either way, until then, for release to 16561 builds:
event.minerals = bytes.getBigInt(1) << 20 | bytes.getBigInt(1) << 12 | bytes.getBigInt(1) << 4 | bytes.getBigInt(1) >> 4
event.gas = bytes.getBigInt(1) << 20 | bytes.getBigInt(1) << 12 | bytes.getBigInt(1) << 4 | bytes.getBigInt(1) >> 4
bytes.skip(2) #unknown extra stuff
Each of the two blocks are 4 bytes long where only the first 28 bits are used from each block.
Then there are 2 trailing bytes with an unknown purpose as well.