Jump to content

Shortlist format revealed


DrBernhard

Recommended Posts

I got numerous requests about the shortlist format in FM, so I figured it out.

01.png

Every shortlist starts with 14 bytes, highlighted by the purple box.

Then 4 bytes indicating how many chars the shortlist-name will be (in this case: 3)

Then 2 bytes for each char describing the name of the shortlist (in this case 6 bytes) (light blue)

Then 2 bytes of bogus data

Then 4 bytes describing the number of items in the shortlist (in this case 2) (red)

Then 4 bytes for each element in the shortlist describing the player ID (blue/orange)

And 1 byte finally with the value of 0.

Good luck!

Link to post
Share on other sites

C# Code for creating shortlist

        private void Form1_Load(object sender, EventArgs e)
       {
           int[] players = new int[] {8443037, 35011612, 3301294 };
           string name = "Test";

           using (FileStream stream = new FileStream(@"C:\test.slf", FileMode.OpenOrCreate))
           {
               using (BinaryWriter sw = new BinaryWriter(stream))
               {
                   sw.Write(new byte[] { 0x02, 0x01, 0x66, 0x6C, 0x73, 0x2E, 0x01, 0x00, 0x00, 0x01, 0xC0, 0xD6, 0x64, 0x00 });
                   sw.Write(FromIntToHex(name.Length));
                   sw.Write(FromStringToHex(name));
                   sw.Write(new byte[] { 0x00, 0x00 });
                   sw.Write(FromIntToHex(players.Length));
                   foreach (int playerId in players)
                   {
                       sw.Write(FromIntToHex(playerId));
                   }
                   sw.Write(0x00);
               }
           }
       }

       private byte[] FromIntToHex(int value)
       {
           byte[] buffer = new byte[4];
           {
               buffer[0] = (byte)(value & 0xff);
               buffer[1] = (byte)((value & 0xff00) >> 8);
               buffer[2] = (byte)((value & 0xff0000) >> 0x10);
               buffer[3] = (byte)((value & 0xff000000L) >> 0x18);
           }
           return buffer;
       }

       private byte[] FromStringToHex(string value)
       {
           List<byte> bytes = new List<byte>();
           char[] chars = value.ToCharArray();
           foreach (char c in chars)
           {
               bytes.Add((byte)c);
               bytes.Add(0x00);
           }
           return bytes.ToArray();
       }

Link to post
Share on other sites

This is probably going to sound stupid but why would you need to code a shortlist using C# when the game creates them for you and so many new scouting tools are cropping up each day?

This is support information for anyone out there creating their scout-tools, and who can't get shortlists to work (f.e. the author of FMAgent). Now they can implement this feature with ease.

Link to post
Share on other sites

  • 1 month later...

I asked about this a while ago and didn't get an answer so I wondered whether it was something people weren't able to discuss, like fake teams etc, but could this coding be used to edit AI shortlists? My original example was santa cruz, parker, toure being wanted by man city instead of zhirkov, srna, hamsik etc? Sorry if this isn't supposed to be discussed, but if it is allowed, is this sort of thing possible using an editor ie FMRTE? I'm no coding genius, in fact I have no knowledge whatsoever, but I could fiddle about with an editing tool if its something that can be done?

Link to post
Share on other sites

  • 1 month later...

Shortlist Code example and addresses for 9.3 Shortlist file format

private void Form1_Load(object sender, EventArgs e)
       {
           int[] players = new int[] {8443037, 35011612, 3301294 };
           string name = "Test";

           using (FileStream stream = new FileStream(@"C:\test.slf", FileMode.OpenOrCreate))
           {
               using (BinaryWriter sw = new BinaryWriter(stream))
               {
                   sw.Write(new byte[] { 0x02, 0x01, 0x66, 0x6C, 0x73, 0x2E, 0x01, 0x00, 0x00, 0x01, 0x91, 0x52, 0x38, 0x00 });
                   sw.Write(FromIntToHex(name.Length));
                   sw.Write(FromStringToHex(name));
                   sw.Write(new byte[] { 0x00, 0x00 });
                   sw.Write(FromIntToHex(players.Length));
                   foreach (int playerId in players)
                   {
                       sw.Write(FromIntToHex(playerId));
                   }
                   sw.Write(0x00);
               }
           }
       }

       private byte[] FromIntToHex(int value)
       {
           byte[] buffer = new byte[4];
           {
               buffer[0] = (byte)(value & 0xff);
               buffer[1] = (byte)((value & 0xff00) >> 8);
               buffer[2] = (byte)((value & 0xff0000) >> 0x10);
               buffer[3] = (byte)((value & 0xff000000L) >> 0x18);
           }
           return buffer;
       }

       private byte[] FromStringToHex(string value)
       {
           List<byte> bytes = new List<byte>();
           char[] chars = value.ToCharArray();
           foreach (char c in chars)
           {
               bytes.Add((byte)c);
               bytes.Add(0x00);
           }
           return bytes.ToArray();
       }

Link to post
Share on other sites

  • 6 months later...

I have tested this code but I only get 3 players in the shortlist. The bit I have changed is in red and bold.

dgvShortlist = DataGridView with the players that will get transfered to the shortlist in it.

In cell(0) is the player's ID

private void Form1_Load(object sender, EventArgs e)
       {
           int[] players = new int[] {8443037, 35011612, 3301294 };
           string name = "Test";

           using (FileStream stream = new FileStream(@"C:\test.slf", FileMode.OpenOrCreate))
           {
               using (BinaryWriter sw = new BinaryWriter(stream))
               {
                   sw.Write(new byte[] { 0x02, 0x01, 0x66, 0x6C, 0x73, 0x2E, 0x01, 0x00, 0x00, 0x01, 0x91, 0x52, 0x38, 0x00 });
                   sw.Write(FromIntToHex(name.Length));
                   sw.Write(FromStringToHex(name));
                   sw.Write(new byte[] { 0x00, 0x00 });
                   sw.Write(FromIntToHex(players.Length));
   [b][color="Red"]foreach (DataGridViewRow row in dgvShortlist.Rows) {
       sw.Write(FromIntToHex(row.Cells(0).Value.ToString()));
                   }[/color][/b]

                   sw.Write(0x00);
               }
           }
       }

       private byte[] FromIntToHex(int value)
       {
           byte[] buffer = new byte[4];
           {
               buffer[0] = (byte)(value & 0xff);
               buffer[1] = (byte)((value & 0xff00) >> 8);
               buffer[2] = (byte)((value & 0xff0000) >> 0x10);
               buffer[3] = (byte)((value & 0xff000000L) >> 0x18);
           }
           return buffer;
       }

       private byte[] FromStringToHex(string value)
       {
           List<byte> bytes = new List<byte>();
           char[] chars = value.ToCharArray();
           foreach (char c in chars)
           {
               bytes.Add((byte)c);
               bytes.Add(0x00);
           }
           return bytes.ToArray();
       }

Thanks in advance

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...