Parsing the color of the players

Mar 22, 2010 at 10:12 PM

Does anyone have any clue?

According to this post, the color is in the format "Alpha, Red, Green, Blue" but the length of the array can vary (12 or 13 bytes).

Mar 26, 2010 at 11:26 PM

As all serialized strings, it is prefixed with it's length

Mar 27, 2010 at 12:43 AM

I already solved it. The problem was much easier than I thought. Basically it's stored as a string like "aa,rr,gg,bb" using 12/14 bytes instead of just 4 bytes.

Weird. :)

Apr 4, 2010 at 4:29 AM
Edited Apr 4, 2010 at 4:30 AM

Hey Kralizek! Good work there with this project!!


Let me ask your something. This replay viewer just read from a file path of the rep file. It is ok for using local, but in server, how would I read the client rep file if I cant save it on server? It is possible to send the file content (bytes) instead of file path in load method?





Apr 9, 2010 at 12:15 AM

Hey! This last version is not working in some maps... I just saw whats the problem. Some maps like Desert Oasis and Steppes of War for example, dont have the string length before the proper data (dunno why).
Lost temple do (dont know why), but some of them dont. I made some change here, its not so beautiful, but I tested in 16 replays mines with different maps and seems to work so far!!

What I made was to try to find a pattern that all .sc2reps follow, and that 5 null bytes that you searched, have in all reps... After that, just search for the first A-Z caracter (30-60), and after that reads until 0x00!!
// Your Code.....
     long pos = SeekSequence(bReplayInfo, ms.Position, new byte[] { 0x73, 0x32, 0x6d, 0x61 }, 6);
                    ms.Seek(pos, SeekOrigin.Begin);
                    pos = SeekSequence(bReplayInfo, ms.Position, new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0 });
                    ms.Seek(pos, SeekOrigin.Begin);
// Your Code.....
// MyCode.....(made to read the map proprely)
                    while (reader.PeekChar() < 30)
                    string mapName = "";
                    while (reader.PeekChar() != 0x0)
                        mapName += reader.ReadChar();
// MyCode.....        

//And continues with you code ....
  //string mapName = new string(reader.ReadString().ToCharArray());
                    Map = new MapInfo { Name = mapName, Thumbnail = image };
                    pos = SeekSequence(bReplayInfo, ms.Position, new byte[] { 0x0, 0x10, 0x0, 0x0, 0x0 });
                    ms.Seek(pos, SeekOrigin.Begin);
                    // Skip the header

Apr 9, 2010 at 11:55 AM

Hey! Nice snippet!

Thank for your contribution and sorry for not answering before... Looks like CodePlex mail was marked as spam.

About your first post, as you can see, the problem is how the MpqLib works, since it only accepts a file path, not a stream (weird indeed).

For the second post, I tried your code and I had to comment out the "ms.Position--;" line.

I tried the code on 3 replays taken from 3 different maps: Blistered Sands, Desert Oasis and Twilight Fortress. I cannot understand why the pattern used for every string (length + string) is not followed here.

Apr 9, 2010 at 11:56 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Apr 10, 2010 at 3:44 AM
Edited Apr 10, 2010 at 3:46 AM

Your right, thats crazy... And I tried to understand what were that different bytes before the map name, but I couldnt find out :/ That length string pattern just happen on lost temple!

But commenting that line, worked now on all maps for you?


That stuff that mpqLib dosent accept stream, just path, will be boring for me to put the system working on my team site ( :( I will try more later. It worked local, but on server impossible (cant save files on server)!

C ya

Apr 10, 2010 at 3:49 AM
Edited Apr 10, 2010 at 3:59 AM

Another question, I never used this web source control system! Its cool, I can check in too? Its just click that link "Upload Patch" with the zip of the updated version?

And I think I just got this project to late to help more! There is still any information to extract from the binary? Im seeing here and think you got all informations already.