Re: [Newbie] [DG Scripts] Few questions for anyone.

From: Thomas Arp (t_arp@stofanet.dk)
Date: 06/27/02


----- Original Message -----
From: "Mathew Earle Reuther" <graymere@zipcon.net>
>
> First off, the one I'm most concerned about.  dg_comm.c uses get_obj,
> which is fine if I add if to handler.h like so:
>
> struct obj_data *get_obj(char *name);
>

<snip of object identification routine from dg_comm.c>

> The version of get_obj in dg_scripts.c looks like this:
>
> obj_data *get_obj(char *name)
>
obj_data is a previously defined structure. having 'struct' inthere or
not, the prototype will function properly.

> My question is, essentially, how do I handle making sure that the function
> get_obj is called correctly?  Leaving the prototype in handler.h
> alleviates compile errors, but if the actual function is in dg_scripts.c,
> and called in dg_comm.c, is this really the place to prototype it?
>
I'd suggest you put the prototype in dg_scripts.h since this is
dealing with all the other prototypes 'internal' to dg scripts.

> DG scripts uses the number function in order to generate a result between
> two numbers. For example: 1, 100 or 5, 25 and so on.  This function
> doesn't exist anywhere in the DG code as near as I can tell, and as such
> I replaced every instance (quite a few) of the number function with the
> rand_number function call.  Can anyone see if this is a bad idea for some
> reason I may have missed?  (Example of the call is below:)
>
<snip of example>

The number() function is renamed to rand_number in bpl21.
You are doing it right.

> ***
>
> I ran into a number of send_to_char calls which looked similar to this:
>
> send_to_char(buf, d->character)
>
> Which I then changed to:
>
> send_to_char(d->character, buf)
>

This will work. The variables have been switched around in bpl21.

> Is that the correct method of writing those, or should d->character be
> simply ch as such:
>
> send_to_char(ch, buf)
>
> If someone could give a quick explanation of what the difference between
> the two is, I'd greatly appreciate it!

struct descriptor_data *d points to a descriptor structure.

d->character              is the char_data structure pointed to by
                          the descriptors'(d) 'character' pointer.
struct char_data *ch      points to a char_data structure

So, you can write:

struct char_data *ch = d->character;
and
struct descriptor_data *d = ch->desc;

The two are intertwined, but in general, the descriptor_data is used for
information pertaining connection, write buffer, output buffer, etc.
while char_data pertains to the ingame representation of the character.
This means stats, descriptions, title, and so on. If, in a function,
you aren't passed a char_data pointer but a descriptor_data pointer,
you can find the appropriate char_data by dereferencing the 'character'
pointer. Mobs don't have descriptor data, and 'ch->desc' is NULL,
unless the mob is switched into.

> ***
>
> There were conflicting defines for top_of_zone_table, so I used the one
> from db.h, assuming that it would handle things better that way.  Any
> reason this is incorrect?
>
> from db.h: extern zone_rnum top_of_zone_table;
> from dg_wldcmd.c: extern int top_of_zone_table;

This is due to the fact that previous bpl's used ints. In bpl 20+ this has
been changed, so expansion into longs or unsigned ints is easier.
The db.h declaration is the correct one.
>
> ***
>
> Last, I know I'm repeating myself here, but does anyone have a clue why in
> medit.c I'm getting this error:
>
> medit.c: In function `medit_disp_menu':
> medit.c:468: warning: array subscript has type `char'
>
> Relevant code:
>
>           "%sQ%s) Quit\r\n"
>           "Enter choice : ",
>
>           grn, nrm, yel, position_types[(int)GET_POS(mob)],
>           grn, nrm, yel, position_types[(int)GET_DEFAULT_POS(mob)],
> here->    grn, nrm, yel, attack_hit_text[GET_ATTACK(mob)].singular,
>           grn, nrm, cyn, buf1,
>           grn, nrm, cyn, buf2,
> #if CONFIG_OASIS_MPROG
>           grn, nrm, cyn, (OLC_MPROGL(d) ? "Set." : "Not Set."),
> #endif
>
GET_ATTACK() gives a type char output. To correct this, cast to int:

            grn, nrm, yel, attack_hit_text[(int)GET_ATTACK(mob)].singular,

Welcor

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT