id numbers

Discuss almost anything about RailWorks.

id numbers

Unread postby HankySpanky » Tue Feb 25, 2014 1:22 pm

As I am trying to learn a little about the programming of various assets, I often come across id numbers. Here is an example -

<cSceneryRenderBlueprint-sProjectedLight d:id="68883312">

Could someone please help me understand what these id numbers are? Much appreciated.
"Manny - I need shoes!"
User avatar
HankySpanky
 
Posts: 322
Joined: Mon Jul 15, 2013 2:50 pm
Location: Ft. Lauderdale

Re: id numbers

Unread postby Chacal » Tue Feb 25, 2014 4:14 pm

They provide a unique identification of one entry among many.

For example, you could have these two nodes in a blueprint:
Code: Select all
<cSceneryRenderBlueprint-sProjectedLight d:id="68883312">
    <blah>
          ...
    </blah>
</cSceneryRenderBlueprint-sProjectedLight>

<cSceneryRenderBlueprint-sProjectedLight d:id="74569267">
    <blah>
          ...
    </blah>
</cSceneryRenderBlueprint-sProjectedLight>

So here this asset would have two different projected lights.

The id attribute, which is commonly used in XML processing, allows a program (like the TS game engine) to select one specific node out of several.

For the example above, if I want the first node, I would program a Xpath query that basically says "fetch me the "cSceneryRenderBlueprint-sProjectedLight" node whose id is '68883312".
It would look like this:
Code: Select all
 rootNode.SelectNodes("cSceneryRenderBlueprint-sProjectedLight [@d:id='68883312']");

And the result of this query would be:
Code: Select all
<cSceneryRenderBlueprint-sProjectedLight d:id="68883312">
    <blah>
          ...
    </blah>
</cSceneryRenderBlueprint-sProjectedLight>


Then my program would do something with the contents of the node, like turn some light on with the correct angle, colour, etc.
Any unique attribute would do, it doesn't have to be "id", that's just a convention. They could have any value, as long as they are unique in the xml document. They don't even need to be numbers, it could be "George" and "Mary". The numbers you see in the TS blueprints are generated automatically by the TS blueprint editor when you create a new node.

See a better explanation about this technique here.

My own RWDBRepair script uses this technique extensively. I'm sure Mike Simpson also uses it a lot in RW-Tools.

You, as a player/hacker, will never use this, with the exception of sound proxy blueprints (proxyxml files), where the id number is used as a direct reference for sound samples, loops and modifier chains in the blueprint.
Over the hill and gathering speed
Chacal
Site Admin
 
Posts: 6515
Joined: Tue Jul 05, 2011 1:11 pm
Location: Quebec, Canada

Re: id numbers

Unread postby buzz456 » Tue Feb 25, 2014 6:08 pm

Au contraire, my friend. Bin files are full of these references.
Buzz
39 and holding.
"Some people find fault like there's a reward for it."- Zig Ziglar
"If you can dream it you can do it."- Walt Disney
Image
User avatar
buzz456
Site Admin
 
Posts: 21011
Joined: Sun Mar 21, 2010 8:30 am
Location: SW Florida

Re: id numbers

Unread postby Chacal » Tue Feb 25, 2014 7:10 pm

We must not be talking about the same thing, because I work with blueprints every day and the only place I remember id numbers being referenced is in proxyxml files.
Like this:

blueprint.jpg


Otherwise they show up like in the examples above.
You do not have the required permissions to view the files attached to this post.
Over the hill and gathering speed
Chacal
Site Admin
 
Posts: 6515
Joined: Tue Jul 05, 2011 1:11 pm
Location: Quebec, Canada

Re: id numbers

Unread postby buzz456 » Tue Feb 25, 2014 7:32 pm

I think he's asking about the ones that are not used as a reference. What are they?
Buzz
39 and holding.
"Some people find fault like there's a reward for it."- Zig Ziglar
"If you can dream it you can do it."- Walt Disney
Image
User avatar
buzz456
Site Admin
 
Posts: 21011
Joined: Sun Mar 21, 2010 8:30 am
Location: SW Florida

Re: id numbers

Unread postby HankySpanky » Tue Feb 25, 2014 8:27 pm

Awesome replies so far! Thank you!

I was originally asking about the non-referenced id numbers because it was appearing to me as if there was some proprietary "Master List" of objects, each with its own unique id number. Silly me. Now I know better.

But that leaves me with two follow-up questions, if I may. First, being that the id numbers are randomly generated, does that leave open the rare possibility of a conflict from two identical id numbers for different references created by two different databases? i.e. Tori makes a (blueprint?) of a pony and it is assigned the id 12345678. Meanwhile Mike makes a (blueprint?) of a headlight with id 12345678 also?

And second, where is the definition (blueprint?) of the id number found?

I enjoy learning about this stuff. And hey, if I can ever give you some programming tips on TRS-DOS just let me know. !*roll-laugh*!
"Manny - I need shoes!"
User avatar
HankySpanky
 
Posts: 322
Joined: Mon Jul 15, 2013 2:50 pm
Location: Ft. Lauderdale

Re: id numbers

Unread postby Chacal » Wed Feb 26, 2014 12:40 am

buzz456 wrote:I think he's asking about the ones that are not used as a reference. What are they?

These are the ones I explain in my first post, they are just unique ids for the blueprint nodes.
They may or may not be used by the game engine.

HankySpanky wrote:But that leaves me with two follow-up questions, if I may. First, being that the id numbers are randomly generated, does that leave open the rare possibility of a conflict from two identical id numbers for different references created by two different databases? i.e. Tori makes a (blueprint?) of a pony and it is assigned the id 12345678. Meanwhile Mike makes a (blueprint?) of a headlight with id 12345678 also?

That wouldn't be a problem. Being two different assets, they would each have its own blueprint.
Note: a blueprint (in TS2014 parlance) is a xml document.
For example, Assets\3DTrains\TrainPacks\Diesel\EMD_F7\ATSF\AUnit_36_37CF.bin is the engine blueprint for a 3DTrains F7.

You are right: it would not be reasonably possible to generate unique ids without conflict across all blueprints in the game.
But it is not needed. We just have to avoid conflicts for similar nodes in the same blueprint.

In the example I give in my first post, there are two nodes in the same document, and they have different ids, so no conflict.
There would be a problem if those two nodes had the same id number: there would be no way of selecting only one of them.

HankySpanky wrote:And second, where is the definition (blueprint?) of the id number found?


Not sure I understand your question.
The id number has no meaning, it is just a random value.
Over the hill and gathering speed
Chacal
Site Admin
 
Posts: 6515
Joined: Tue Jul 05, 2011 1:11 pm
Location: Quebec, Canada

Re: id numbers

Unread postby Chacal » Wed Feb 26, 2014 1:07 am

ABout the id numbers used as references in sound proxy blueprints, here's a better illustration.
This comes from the same blueprint as before: Assets\3DTrains\TrainPacks\Audio\Diesel\EMD\Cab\FUnit_Cab.proxybin
On this extract of the blueprint (with parts deleted so it fits on one screen) I show three such references, in blue, red and green.
I could not fit the node for the green arrow on the screen, but you get the idea.

Again, those specific ids (22774336, 22817088,21769880) are only useful inside this one blueprint. They are meaningless outside of it.

blueprint2.jpg
You do not have the required permissions to view the files attached to this post.
Over the hill and gathering speed
Chacal
Site Admin
 
Posts: 6515
Joined: Tue Jul 05, 2011 1:11 pm
Location: Quebec, Canada

Re: id numbers

Unread postby HankySpanky » Wed Feb 26, 2014 6:06 pm

Awesome Chacal! Nice explanation! That really makes things clear!
!*brav*!
"Manny - I need shoes!"
User avatar
HankySpanky
 
Posts: 322
Joined: Mon Jul 15, 2013 2:50 pm
Location: Ft. Lauderdale


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests