Difference between revisions of "Source talk:NetHack 3.4.3/include/obj.h"

From NetHackWiki
Jump to navigation Jump to search
(I would have put a char* in the struct and allocated the name string separately.)
 
Line 1: Line 1:
 +
Why all the gratuitous "to code multiplayer nethack is difficult, because..." sentences?
 +
 +
 
An [[object]] is normally allocated to have extra space after the end of the struct. Using <tt>ONAME(thing)</tt> retrieves some text from this extra space. I think that ONAME probably contains the name left with the #[[name]] command (such as "cursed" or "REAL", if you ever have a "yellow potion named cursed" or an "Amulet of Yendor named REAL"), however I would have to examine [[do_name.c]] more carefully to learn the details. I find this approach difficult to understand.
 
An [[object]] is normally allocated to have extra space after the end of the struct. Using <tt>ONAME(thing)</tt> retrieves some text from this extra space. I think that ONAME probably contains the name left with the #[[name]] command (such as "cursed" or "REAL", if you ever have a "yellow potion named cursed" or an "Amulet of Yendor named REAL"), however I would have to examine [[do_name.c]] more carefully to learn the details. I find this approach difficult to understand.
  
 
When you give a longer #name to an object, you would have to reallocate it, thus possibly making invalid any pointers to that object. It appears that in [[do_name.c]], do_oname calls oname which calls realloc_obj to do this. This process feels all unnecessary to me because I would have put a char* in the struct and allocated the name string separately. --[[User:Kernigh|Kernigh]] 20:07, 19 June 2006 (UTC)
 
When you give a longer #name to an object, you would have to reallocate it, thus possibly making invalid any pointers to that object. It appears that in [[do_name.c]], do_oname calls oname which calls realloc_obj to do this. This process feels all unnecessary to me because I would have put a char* in the struct and allocated the name string separately. --[[User:Kernigh|Kernigh]] 20:07, 19 June 2006 (UTC)

Revision as of 08:59, 16 August 2006

Why all the gratuitous "to code multiplayer nethack is difficult, because..." sentences?


An object is normally allocated to have extra space after the end of the struct. Using ONAME(thing) retrieves some text from this extra space. I think that ONAME probably contains the name left with the #name command (such as "cursed" or "REAL", if you ever have a "yellow potion named cursed" or an "Amulet of Yendor named REAL"), however I would have to examine do_name.c more carefully to learn the details. I find this approach difficult to understand.

When you give a longer #name to an object, you would have to reallocate it, thus possibly making invalid any pointers to that object. It appears that in do_name.c, do_oname calls oname which calls realloc_obj to do this. This process feels all unnecessary to me because I would have put a char* in the struct and allocated the name string separately. --Kernigh 20:07, 19 June 2006 (UTC)