DFN Speed?

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
Mindless Automaton
UOX3 Apprentice
Posts: 189
Joined: Wed May 10, 2006 3:48 am
Has thanked: 0
Been thanked: 1 time
Contact:

DFN Speed?

Post by Mindless Automaton »

Would it make a difference to make DFNs like this:

Code: Select all

// SWORDS

[0x1440]
{ facing West
get=base_item
name=cutlass
id=0x1440
weight=800
value=26,13
layer=1
lodamage=16
hidamage=18
hp=70
spd=44
str=25
restock=10
movable=1
decay=1
}

[0x1441]
{ facing North
get=base_item
name=cutlass
id=0x1441
weight=800
value=26,13
layer=1
lodamage=16
hidamage=18
hp=70
spd=44
str=25
restock=10
decay=1
}
into something more like:

Code: Select all

// SWORDS

[0x1440]
{ facing West
get=base_item
name=cutlass
id=0x1440
weight=800
value=26,13
layer=1
lodamage=16
hidamage=18
hp=70
spd=44
str=25
restock=10
movable=1
decay=1
}

[0x1441]
{ facing North
get=0x1440
id=0x1441
}
Or maybe that wouldn't work at all? I haven't tried any tests.

Or:

Code: Select all

[sword]
{ facing West
get=base_item
name=
id=
weight=
value=
layer=1
lodamage=
hidamage=
hp=
spd=
str=
restock=10
movable=1
decay=1
}

[0x1440]
{ facing West
get=sword
name=cutlass
id=0x1440
weight=800
value=26,13
lodamage=16
hidamage=18
hp=70
spd=44
str=25
}
Perhaps a better example would be clothes.dfn because a lot more of the fields are the same.
Mindless Automaton
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

You're spot on with this one:

Code: Select all

// SWORDS 

[0x1440] 
{ facing West 
get=base_item 
name=cutlass 
id=0x1440 
weight=800 
value=26,13 
layer=1 
lodamage=16 
hidamage=18 
hp=70 
spd=44 
str=25 
restock=10 
movable=1 
decay=1 
} 

[0x1441] 
{ facing North 
get=0x1440 
id=0x1441 
}
The only thing different between 0x1441 and 0x1440 is the ID, all other values are the same. Thus you can use get=0x1440 to get all values from that, and then override the id with id=0x1441 - since that's the only thing you need to be different.

Those weapon-dfns should've been changed to this format long ago. =P Not sure how much "speed" you gain by doing it, but it certainly makes the files themselves more manageable.
-= Ho Eyo He Hum =-
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

More manageable, but not really any quicker. It's no extra file IO (dfns in memory), just an extra function call/return. So incredibly marginally slower, but you'd need to be doing it thousands or millions of times for it to become a real issue. Call/returns are quick :) Though then you get into the argument that it consumes less memory, therefore is more cache friendly, etc etc, so it might end up quicker.
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

The main benefit is management of the scripts.

I sing the praises of GET when I need to change things like the weight of a piece of armor. In that scenario without the tag I'd be changing a value on possibly hundreds of script entries (and hoping I got them all). If all those entries are pulling their weight from some base entry, then I change it once and I'm done.

Also makes for a smaller file, which means (slightly)less waste when UOX3 slurps all of the scripts into memory.
Post Reply