Aller au contenu

Photo

Bad Functions


  • Veuillez vous connecter pour répondre
9 réponses à ce sujet

#1
Karma

Karma
  • Members
  • 391 messages
I've read in a couple different places that certain functions can cause issues in-game. Is there a list of these functions anywhere?

#2
Sunjammer

Sunjammer
  • Members
  • 925 messages
I'm not aware of such a list but then I wasn't aware there were such dangerous functions. Could you give a couple of example?

#3
Karma

Karma
  • Members
  • 391 messages
I've seen GetObjectByTag() and DestroyObject() mentioned as potentially troublesome. I've used both without any noticeable problems, but the mention of it in a couple mod change logs made me wonder (a) how true it is and (B) if it is true, what other functions are potentially problematic.

#4
Challseus

Challseus
  • Members
  • 1 032 messages
I think for DestroyObject(), they suggest using Safe_Object_Destroy(), because the former doesn't respective the 'plot' and 'isImmortal' attributes of object to be destroyed.

Not sure about GetObjectByTag(). I use that all the time with no issues...

#5
Sunjammer

Sunjammer
  • Members
  • 925 messages
There are quite a few comments scattered through out the core includes that are intended for BioWare's Technical Designers rather than us. DestroyObject is probably one of those after all it shouldn't respect Immortal or Plot as they are, respectively, intended to prevent death by damage and any damage.

I think I know where the distrust of GetObjectByTag stems from. In the Party_GetFollowerByTag function (party_h) we find the following comment:
    // We have to retrieve the follower like this. Trying to do it with
    // GetObjectByTag proved to mess up lots of stuff. -- yaron.
However "mess up lots of stuff" isn't a particularly useful turn of phrase given as it is rather lacking in specifics so I'm not sure how much weight to give it.

Modifié par Sunjammer, 08 août 2011 - 06:43 .


#6
0x30A88

0x30A88
  • Members
  • 1 081 messages
I suspect GetObjectByTag() calls an iteration. Party_GetFollowerByTag() -- if I can judge it by the name -- seems to have fewer to iterate through as it looks in your list of followers. I have used GetObjectByTag() to get followers too, and it hasn't crapped out on me.

Modifié par Gisle Aune, 08 août 2011 - 09:57 .


#7
Sunjammer

Sunjammer
  • Members
  • 925 messages
GetObjectByTag is almost certainly not done by iteration. If memory serves GetObjectByTag was implemented as a hash table in NWN and it is unlikely BioWare would change it to make it less efficient. Conversely as Party_GetFollowerByTag is a derived function we know uses iteration and string comparison.

#8
0x30A88

0x30A88
  • Members
  • 1 081 messages
But it still have to iterate through that hash table, right? I am really interested to know how this can be done without iteration, if that's not the case.

#9
Sunjammer

Sunjammer
  • Members
  • 925 messages
I don't believe it does. The tag will be hashed to generate an index in the hash table that will point to the first object with that tag. Depending on the implementation of the hash table GetObjectByTag's Nth parameter will then point to the correct object id. However I'm pretty sure you weren't referring to the specific ADT implementation being used in your original statement so, while interesting, such a discussion is probably straying off-topic.

To return to the matter in hand I was always intending to compile a list of broken functions (i.e. those that don't work or, at least, don't work as advertised) for LEX/the Toolset Wiki. Is it worth also compiling a list of functions have "warnings" like the two mentioned above?

Modifié par Sunjammer, 09 août 2011 - 01:00 .


#10
Karma

Karma
  • Members
  • 391 messages

Sunjammer wrote...

To return to the matter in hand I was always intending to compile a list of broken functions (i.e. those that don't work or, at least, don't work as advertised) for LEX/the Toolset Wiki. Is it worth also compiling a list of functions have "warnings" like the two mentioned above?


Absolutely.