CODE problem. :(

From: Homer Simpson (fcolvin@metz.une.edu.au)
Date: 10/01/96


Hiya all,
         I'm trying to make a time prog for mobprogs, but I'm having some 
trouble. Below is the code I added to get it going. It compiles without 
an error, but when another_hour is called the mud crashes with a memory 
fault. Any ideas what I'm doing wrong?

Thanks in advance

Homer

aka Fionn Colvin :)

#############
# mobprog.c #
#############

const int time_mobs[] =
{
    33,
    -1
};

void mprog_time_trigger(int time)
{
   struct char_data *mob;
   MPROG_DATA *mprg;
   int r_num;
   int pos = 0;

   for (r_num = time_mobs[pos]; r_num != -1; r_num = time_mobs[pos++]) {
     mob = read_mobile(r_num, VIRTUAL);
     if (IS_NPC(mob) && (mob_index[mob->nr].progtypes & TIME_PROG))
       for (mprg = mob_index[mob->nr].mobprogs; mprg != NULL; mprg = mprg->next)
         if (mprg->type & TIME_PROG)
           if (time == atoi(mprg->arglist)) {
             mprog_driver(mprg->comlist, mob, NULL, NULL, NULL);
             break;
           }
   }
   return; 
}


#############
# weather.c #
#############

In extern declerations.

void mprog_time_trigger(int time);


In void another_hour(mode)

after time_info.hours++;

mprog_time_trigger(time_info.hours);


#############
# structs.h #
#############

#define TIME_PROG    2048


############
# mobcmd.c #
############

In the prog case section

case TIME_PROG               return "time_prog";


########
# db.c #
########

in int mprog_name_to_type (char *name)


if (!str_cmp(name, "time_prog"))        return TIME_PROG;


#########
# 0.mob #
#########

<stuff>
#33
<stuff>
>in_file_prog time.prg~
|
#34
<stuff>

############
# time.prg #
############

>time_prog 5~
shout Shops start opening in one hour.
~
|
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



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