Re: Pointers and obj_proto

From: Akuma/Chris Baggett/DOOMer (doomer@BAYOU.COM)
Date: 10/09/97


>>GET_OBJ_SHORT(obj) != GET_OBJ_SHORT(obj_proto[i])
>
>Pretty close, you just need an & in there, I think.  ie:
>
>GET_OBJ_SHORT(obj) != GET_OBJ_SHORT(&(obj_proto[i]))
>
>I'm not sure if the extra parens are needed or not, I always forget the
>precedence...

  heh, i would have responded back sooner, but i played with the
print  command (with &'s and *'s) in
GDB a bit before i rushed to work, and figured out how to do it
before i got a reply back.
here's how i did it.

if (GET_OBJ_SHORT(obj) &&
   &(*(GET_OBJ_SHORT(obj))) !=
&(*(obj_proto[GET_OBJ_RNUM(obj)].short_description)))
   { FREE(GET_OBJ_SHORT(obj)); }
GET_OBJ_SHORT(obj) = str_dup(arg4);

that's basically how i did it.
i checked to see if the address (&) of
the pointer to the FIRST character in the short_desc (*) is
== to the address (&) of the pointer to the FIRST character in the proto
short_desc (*)
if it IS NOT, then it's a newly created one, so it's safe to free it and give
it a new pointer.
otherwise, it IS the proto, so DO NOT free it, just give it a new pointer.

this along with ASCII ObjSave files is pretty kewl.
i've added the ability to change the type, weight (i remove the object,
 change the weight, and THEN give the object BACK to char),
cost, long desc, alias, Values 1-4, and Action Descriptions,
and Extra Descriptions are coming soon. :-)

with the vehicle code, i was able to create a vehicle just
out of the stock BUG item (Vnum: 0) :-P
it's pretty kewl. :-P

thanks anyway for your help Ron.  Least i know you were paying attention :-P

Code On
Akuma the Raging Coder

  +------------------------------------------------------------+
  | "The poets talk about love, but what I talk about is DOOM, |
  |      because in the end, DOOM is all that counts." -       |
  |   Alex Machine/George Stark/Stephen King, The Dark Half    |
  |        "Nothing is IMPOSSIBLE, Just IMPROBABLE"            |
  |   "Easier Said Than Done, But Better Done Than Said..."    |
  +------------------------------------------------------------+


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST