Difference between revisions of "Source talk:NetHack 3.4.3/include/obj.h"
(I would have put a char* in the struct and allocated the name string separately.) |
m (moved Source talk:Obj.h to Source talk:NetHack 3.4.3/include/obj.h: Moving src to subdirs) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | Why all the gratuitous "to code multiplayer nethack is difficult, because..." sentences? {{unsigned|62.148.103.224|16 August 2006}} | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | |||
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) |
Latest revision as of 19:19, 31 January 2011
Why all the gratuitous "to code multiplayer nethack is difficult, because..." sentences? — Preceding unsigned comment added by 62.148.103.224 (talk • contribs) 16 August 2006
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)