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

From: Mathew Earle Reuther (graymere@zipcon.net)
Date: 06/27/02

I just spent a few more hours this morning working on getting DG Scripts
to compile with the current CVS+OLC.  I've actually managed to get it back
up and running again and it doesn't crash the moment I enter OLC or access
the script editing functions.  However, in the process of modifying the
code to deal with compile errors, I've run across some things that I'm not
sure how to fix, or if I've made a correct fix.  Questions are separated
below for ease of reading and answering.


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);

However, I am not sure this actually does what it's supposed to for the
relevant section in dg_comm.:

case '`':
    /* get obj_data, move to next token */
    type[i] = *p;
    *s = '\0';
    p = any_one_name(++p, name);
    (obj_data *)otokens[i] =
        find_invis ? (obj = get_obj(name)) :
            ((obj = get_obj_in_list_vis(ch, name, NULL,
                        world[IN_ROOM(ch)].contents)) ? obj :
             (obj = get_obj_in_equip_vis(ch, name,
                                            &tmp, ch->equipment )) ?
             obj :
             (obj = get_obj_in_list_vis(ch, name, NULL, ch->carrying)));
    (obj_data *)otokens[i] = obj;
    tokens[++i] = ++s;

The version of get_obj in dg_scripts.c looks like this:

obj_data *get_obj(char *name)

Which we can see is the same as how it was formerly defined in handler.h
(and still is in bpl21 even.)

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?

Sorry for what I am sure is a foolish question, but I'd like to get the DG
Scripts working with as little possibility of ugly destruction as
possible!  Now, on to more. :)


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:)

          if (type == MOB_TRIGGER) {
            ch = (char_data *) go;
            for (c = world[IN_ROOM(ch)].people; c; c = c->next_in_room)
              if (!PRF_FLAGGED(c, PRF_NOHASSLE) && (c != ch) &&
                  CAN_SEE(ch, c)) {
        /*      if (!number(0, count))  <-- what it used to look like*/
                if (!rand_number(0, count)) /* <-- my change */
                  rndm = c;


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)

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!


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;


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,
          grn, nrm, cyn, (OLC_MPROGL(d) ? "Set." : "Not Set."),


Thanks again for all the assistance.  The answers I've been give have made
it much easier to see why I've been having some of these issues!


   | 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