-----Original Message----- From: Ron Martin <rmartin@cps.cmich.edu> Date: Sun, 19 Mar 2000 21:24:28 -0500 Subject: Re: [CIRCLE] NEWBIE[CODE] making a new macro for spell types > > --<SNIP>-- > > #define GET_LEVEL(ch) ((ch)->player.level) > > > > What i don't get is where does ch come in? i know it is a structure > of > --<SNIP>-- > > #defines simply tell the preprocessor to expand certain text to other > things. I'm sure that clears it up, so later. > > Just kidding!!!! The above example tells the computer to change all > instances of "GET_LEVEL(ch)" to "((ch)->player.level)". The "ch" > could > be replaced by "x" or "character_player". It just acts as a place > holder, in a way. Whenever you put in your code > > some_integer = GET_LEVEL(some_character); > > it turns into: > > some_integer = ((some_character)->player.level); I looked up structure pointer operators in my C book and it said that the value to the left of the operator was a pointer declared to point to a structure, and the value on the right was actually a name of a member of that structure.... I know i'm missing something, but there are no structures named ch...there is no member called player...and i would think that if ch was somehow initialized to point to struct char_data you could just write ch->level... I know i'm wrong, but i can't for the life of me figure out how... i'm sure once i get it, the code will become that much clearer... Any help would be appreciated... Snaga ASk one question and all of a sudden you got ten new ones, and you're 11 behind :) +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/10/01 PDT