Bug: UNID shortcuts and colliding UNIDs (v0.96a)

These are old bug reports that have been closed.
Locked
User avatar
Karl
Militia Lieutenant
Militia Lieutenant
Posts: 219
Joined: Fri Jul 14, 2006 11:47 pm

I think the unid @shortcut is a great feature. However, if the unidExtension of an extension file ends in anything other then 0000, it doesn't work properly. Today I kept getting "Duplicate UNID" messages with it and it was driving me crazy.

I think I figured out what is going on. It looks like the @numbers are being anded with the entire unidExtension of the file--rather then just the first half as expected. This leads to multiple @shortcuts being mapped to the same unid. For instance, if the file's unidExtension ends in 1, then the @shortcut pairs 0-1, 2-3, 4-5, 6-7, etc. will collide.

To see this for yourself, open an extension file, rename the unidExtension to 0xD999AB01 and rename two other unids to @2 and @3 respectively. You'll get the error message: "Duplicate UNID: 0xd999ab03".

Ex:

Code: Select all

<!ENTITY unidExtension   "0xD999AB01">
<!ENTITY itSomeItem1     "@2">
<!ENTITY itSomeItem2     "@3">
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Excellent detective work.

Much of the code assumes that the unidExtension ends with 0000. Thus the @shortcut just OR's the number with the extension UNID.

I'm not sure why you need to have an unidExtension that ends with anything other that 0000. Remember that no two extensions can have the same first four digits.

But if you want, I could fix it in one of two ways:

Method 1: Clear the lower 4 digits before OR'ing the shortcut. Thus:

unid = 0xD999AB01
@1 = 0xD9990001
@2 = 0xD9990002

Method 2: Add the shortcut to the whole unid. Thus:

unid = 0xD999AB01
@1 = 0xD999AB02
@2 = 0xD999AB03

I prefer the first method.
User avatar
Karl
Militia Lieutenant
Militia Lieutenant
Posts: 219
Joined: Fri Jul 14, 2006 11:47 pm

Wow, thanks for your quick response. I like the first method, too.
I'm not sure why you need to have an unidExtension that ends with anything other that 0000. Remember that no two extensions can have the same first four digits.
I'm not sure what you mean by "no two extensions can have the same first four digits". I notice that in the base game digits 2-4 are the module ID but in extensions digits 2-4 are the designer ID. Do you want modders to use the same "designer ID" for all of their mods or to use a different "module id" for each mod?

I was under the impression that we were to use the same designer ID for all of our mods and to use our forum number in hex as the "designer ID". (As suggested here: http://s8.invisionfree.com/Transcendenc ... wtopic=569 ) This sounds like a logical system to me and makes sense and it prevents id conflicts.

However, currently, this system prevents the use of the "unidExtension ends in 0000" method. If someone wants to make more then one mod, or even just a mod that uses more then one file, and if they try to use the same unidExtension for more then one file, they get the error message: "Extension UNID xxxxxxxx already loaded".

OK, not a big deal. Just means that modders have to pick extensions unids like e414e001, e414e002, etc. for each extension file, and keep track of which unidExtensions we've already used. This seems to be what most modders are doing already. It's a bit of an annoyance, but not a huge one. However, it does explain why modders need to use unidExtensions that end in something other then 0000. (If I'm reading everything correctly.)
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Karl wrote:I'm not sure what you mean by "no two extensions can have the same first four digits". I notice that in the base game digits 2-4 are the module ID but in extensions digits 2-4 are the designer ID. Do you want modders to use the same "designer ID" for all of their mods or to use a different "module id" for each mod?
I apologize. You are completely right--I was getting confused because of something I saw in the code.

But if that's the case, wouldn't method 2 be better? In other words, if each of your extensions starts with some base UNID, you would want the @shortcut to ADD to the base UNID. Correct?
User avatar
Karl
Militia Lieutenant
Militia Lieutenant
Posts: 219
Joined: Fri Jul 14, 2006 11:47 pm

I think method 2 would cause strange collisions. Because, for instance, a base unid of xxxx0001 and a @shortcut of 2 would map to the same number as a base unid of xxxx0002 and a @shortcut of 1. I still like the first method, which seems like a simple and effective solution.

Question and observation: We are supposed to use a consistent designer ID for the first half of the unid, right? Then that leaves modders without a recommended method of distinguishing between modules created by the same author. (In this case, me.) If no method is used then it looks like I have to keep track of every unid created in every mod to prevent overlaps. Not fun. The current solution I've come up with is to improvise a module id by using the 5th digit, though this cramps things and means the typeID digit has to shift over one space. (I want to be as consistent as possible with the code formats established in the base module, if I can.) Do you think this "improvised personal mod id system" sounds like a good way of handling the issue?

Of course the ideal thing would be to have the unids automatically generated so we wouldn't have to worry about selecting unids and unid name formats and collisions at all. :-)
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

it would be very hard if not impossible to have the unids to be auto generated. They are the things that allow you to access things across mods and from the main. (you can even use different names in your different mods for the same thing and you don't have to worry about using the same name as a different mod.)

Things are getting cramped because even though there is plenty of room modders tend to think in hex digits. It might be better to expand it to oct that way it would give people more room (even if it doesn't really)
Crying is not a proper retort!
User avatar
dvlenk6
Militia Captain
Militia Captain
Posts: 519
Joined: Sun Mar 05, 2006 6:56 am
Location: Sanctuary and beyond
Contact:

Betelgeuse wrote:Things are getting cramped because even though there is plenty of room modders tend to think in hex digits. It might be better to expand it to oct that way it would give people more room (even if it doesn't really)
I don't understand that :?
"War is hell."
-William Tecumseh Sherman
http://dvlenk6.blackraven3d.com/transgals.html
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Karl wrote:Question and observation: We are supposed to use a consistent designer ID for the first half of the unid, right? Then that leaves modders without a recommended method of distinguishing between modules created by the same author. (In this case, me.) If no method is used then it looks like I have to keep track of every unid created in every mod to prevent overlaps. Not fun. The current solution I've come up with is to improvise a module id by using the 5th digit, though this cramps things and means the typeID digit has to shift over one space. (I want to be as consistent as possible with the code formats established in the base module, if I can.) Do you think this "improvised personal mod id system" sounds like a good way of handling the issue?
That's why I thought method 2 would be better.

You should assign a range in the lower four digits for each extension and use the @shortcuts within each extension. That way you only need to keep track of UNIDs for each extension, not for every item.

For example, if your designer ID is D999:

extension1: D9990000
item1: @1 = D9990001
item2: @2 = D9990002
...

extension2: D9990100
item1: @1 = D9990101
item2: @2 = D9990102
...

extension3: D9990200
item1: @1 = D9990201
item2: @2 = D9990202
...
User avatar
Karl
Militia Lieutenant
Militia Lieutenant
Posts: 219
Joined: Fri Jul 14, 2006 11:47 pm

George - Oh, I see your plan now! Ah that method does work, and is kinda cool, actually. I still think that it's more complex and dangerous then method 1, though. Hmmm, it is slightly more convenient though.

Let's see, with method 1:

extension1: D9990000
item1: @001 = D9990001
item2: @002 = D9990002
...

extension2: D9990100
item1: @101 = D9990101
item2: @102 = D9990102
...

extension3: D9990200
item1: @201 = D9990201
item2: @202 = D9990202
...

Ok, not quite as convenient as method 2, but 2 requires the modder to be a little more careful and know what's going on. Also unids from 2 are more difficult to use in other files, since you have to manually adjust for the base unid addition.

I guess both ways work. I think method 2 will cause headaches and collisions for people who don't don't fully understand it or aren't careful with their numbering while being is slightly more convenient for knowledgeable, well-organized modders. Method 1 has the simplicity and transparency factor while method 2 has the coolness and convenience factor. It's a toss up. *Flips a coin.*

Betelgeuse - Bleh, you're too pessimistic! Of course it's possible. :D Compilers do this sort of thing all the time with variables and multiple files. I could give a quick summary as to how to do it conceptually if you want. :twisted: As to how difficult it is to *implement*, only George can say for sure. I would want to hear his opinion on it before going further.
User avatar
Fossaman
Militia Captain
Militia Captain
Posts: 556
Joined: Tue Mar 07, 2006 12:56 am
Location: Traveling to the galactic core

One thing that might help is to start throwing out registered unids for people to use. The community is getting large enough, with enough people making mods that this might become necessary.
X-ray laser! Pew, pew pew!
> = = = = ۞
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Karl wrote:I guess both ways work.
I think you're right that both ways work. And I think we both agree that either method is better than the current implementation.

Basically, in method 1, @shortcuts are relative to the designer ID
In method 2, @shortcuts are relative to the extension ID.

I'm going to go with method 2. Another nice thing about method 2 is that it is easier to handle if a designer has multiple IDs.
User avatar
Karl
Militia Lieutenant
Militia Lieutenant
Posts: 219
Joined: Fri Jul 14, 2006 11:47 pm

Sounds good to me. You're the captain after all.
Locked