Bgl2xml v Bgl2xml_GUI

#1
I am trying to write a program to find in which files a certain library object is defined and placed. To do this I call Bgl2xml V1.3.1.0 12th Jan 2011 to decompile bgls and then scan the output for model GUIDs.

In most cases it works very well, but, for a particular library, the GUID is output without the "-" dividing the fields (I am expecting these to be present).

Using Bgl2Xml_GUI.exe 1.4.0.0 12th July 2011, it doesn't output the GUID at all :eek:

Example:

Bgl2Xml.exe V1.3.1.0 12th Jan 2011

<ModelData
name="911f7b004d66fa908e6a5a9c6fe2f7ef"
sourceFile="ramp_light_dual.mdl"
fileOffset="0"/>

Bgl2Xml_GUI.exe 1.4.0.0 12th July 2011

<ModelData
sourceFile="ramp_light_dual.mdl"
fileOffset="0"/>

Is there any way I can convert the unhyphenated GUID to hyphenated?
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#4
Hi,

If the modeldata command has a guid defined, it's a fs2004 object. So then the format without dashes is as expected. For fsx objects the guid is not in the modeldata command anymore, but in the mdl itself.
 

scruffyduck

Administrator
Staff member
FSDevConf team
Resource contributor
#5
I think Arno is correct on this. The libraries probably contain FS9 models. I have not checked this yet though............
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#7
I don't think so. Actually at the binary level in the bgl file there is no difference how the guid is stored. Only in the XML file there is a difference.

You can convert between the two, I do that in modelconverterx as well. I'll dig up my code tomorrow.
 
#11
I think I have figured it out.

If the unhypenated GUID has the bytes in order 0 to 15, the hyphenated GUID will be:

(3, 2, 1, 0) - (5, 4) - (7, 6) - (8, 9) - (10, 11, 12, 13, 14, 15)

It seems to work on my system.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#12
Yes, that sounds right. Sorry, did have the time to look up the code.
 

scruffyduck

Administrator
Staff member
FSDevConf team
Resource contributor
#13
This is the code from my library (in C#)

/// <summary>
/// Used to convert an FS9 style GUID to the FSX/registry standard
/// </summary>
/// <param name="input">Input GUID. Can be in old or new format. If in new format it is just returned</param>
/// <returns>GUID in FSX/registry format</returns>
public static string ConvertOldGuid2New(string input)
{

if (input.Length == 32 || input.Length == 36 || input.Length == 38)
{

if (input.Contains("-"))
{
return input; // in new format just send it back
}

var output = new StringBuilder();
var bytes = new string[16];

for (int i = 0; i < 32; i += 2)
{
int j = i / 2;
bytes[j] = input.Substring(i, 2);
}

output.Append(bytes[0] + bytes[1] + bytes[2] + bytes[3] + "-");
output.Append(bytes[6] + bytes[7] + "-");
output.Append(bytes[4] + bytes[5] + "-");
output.Append(bytes[11] + bytes[10] + "-");
output.Append(bytes[9] + bytes[8] + bytes[15] + bytes[14] + bytes[13] + bytes[12]);
return output.ToString();
}

throw new Exception("Guid Converter input not 32 or 36 characters");
}
The output lines are assembling the byes in order
 
#14
Thanks Jon.

In the end, I created new code which allowed me to find placement bgls containing references to undefined GUIDs.

Given a 32 character string containing an FS9 format GUID as created by Bgl2Xml, FS9[0-31], to convert to a 36 character FSX format GUID, FSX[0-35]:

Code:
 FSX = FS9[0];
 FSX += FS9[1];
 FSX += FS9[2];
 FSX += FS9[3];
 FSX += FS9[4];
 FSX += FS9[5];
 FSX += FS9[6];
 FSX += FS9[7];
 FSX += "-";
 FSX += FS9[12];
 FSX += FS9[13];
 FSX += FS9[14];
 FSX += FS9[15];
 FSX += "-";
 FSX += FS9[8];
 FSX += FS9[9];
 FSX += FS9[10];
 FSX += FS9[11];
 FSX += "-";
 FSX += FS9[22];
 FSX += FS9[23];
 FSX += FS9[20];
 FSX += FS9[21];
 FSX += "-";
 FSX += FS9[18];
 FSX += FS9[19];
 FSX += FS9[16];
 FSX += FS9[17];
 FSX += FS9[30];
 FSX += FS9[31];
 FSX += FS9[28];
 FSX += FS9[29];
 FSX += FS9[26];
 FSX += FS9[27];
 FSX += FS9[24];
 FSX += FS9[25];
 
Last edited:
Top