Re: Structures for player data and variables within

From: Claude Belisle (cbeli@pop.agri.ch)
Date: 03/20/00


Right.  ch is a pointer to a char_data structure.
char_data has a field called 'player' which is itself a
char_player_data structure with a field called 'level'.
So to access it, you use (ch)->player.level

Had ch been a char_data instead, you would've used
   ch.player.level

Or had player been a pointer to char_player_data in that
case
   ch.player->level

(ch)->level would result in an unknown variable compile
error because char_data has no field called 'level'.

Hope this helps.

Manwe
-----Ursprüngliche Nachricht-----
Von: Minturn.Del.PRC.Oceana <Del@PRCOceana.Corona.Navy.Mil>
An: CIRCLE@post.queensu.ca <CIRCLE@post.queensu.ca>
Datum: Montag, 20. März 2000 19:29
Betreff: [CIRCLE] Structures for player data and variables within


>The recent question on the understanding of (ch)->player.level
>was directed to me personally. However I was not 100 percent sure
>of my answer. (mostly terminology)
>
>The basic question was why (ch)->player.level was just that, instead of
>(ch)->level.
>
>I had never researched it before, and myself being inexperienced with
>structures, I followed the code through for this type of answer.
>
>Can the more experienced put the right labels on my answer or better
>explanation? or atleast let me know if my understanding is correct.
>
>structs.h:
>
>struct char_player_data {
><snip>
>   byte level;         /* PC / NPC's level                     */
><snip>
>
>struct char_data {
><snip>
>   struct char_player_data player;       /* Normal data
*/
><snip>
>
>
>NOTE: the variable name player.
>
>It was hiding in there and if I read it right..
>
>ch = char_data structure (in this scenerio)
>player = char_player_data structure
>level = the finial variable in the structure mess!
>
>
>     +------------------------------------------------------------+
>     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
>     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
>     +------------------------------------------------------------+


     +------------------------------------------------------------+
     | 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