Re: [CODE] do_mobcopy Xual at "Oct 13, 98 10:13:04 pm"

From: Christian Loth (sg618lo@UNIDUI.UNI-DUISBURG.DE)
Date: 10/15/98


Greetings,

Xual wrote:
> Hi all,
>
>         I wrote this command, which is supposed to copy one mobile to
> another pre-existing prototype.  Everything seems to work okay until I try
> to edit the mob, load it and purge it, or vstat it a couple of times.  I
> am using bpl14, and the dg_pl5a_with_oasis system.  gdb tells me that

Don't know too much about the oasis stuff...but I try to look at your
code with some common sense...

> whatever I try to do to the prototype is responsible for the crash, but
> I'm positive I just forgot something stupid in the command...
>
> ACMD(do_mobcopy)
> {
>   extern struct char_data *mob_proto;
>   int from, to, t_rnum, f_rnum;
>   char arg1[20];
>   char arg2[20];

Careful here! Buffer overruns easily possible. Take MAX_INPUT_LENGTH.

>
>   argument = two_arguments(argument, arg1, arg2);
>
>   if ((!*arg1 || !*arg1) || (!is_number(arg1) || !is_number(arg2))) {

           arg1 and arg2 you mean here

>     send_to_char("Useage:  mobcopy <from vnum> <to vnum>\r\n", ch);
>     return;
>   }
>
>   from = atoi(arg1);
>   to = atoi(arg2);
>   f_rnum = real_mobile(from);
>   t_rnum = real_mobile(to);
>
>   if (from <= 0 || to <=0) {
>     send_to_char("No negative numbers please!\r\n", ch);
>     return;
>   }
>   if ((!(mob_proto + t_rnum)) || (!(mob_proto + f_rnum))) {
>     send_to_char("There are no mobs with that number\r\n", ch);
>     return;
>   }
>   copy_mobile((mob_proto + t_rnum), (mob_proto + f_rnum));
>   mob_index[t_rnum].vnum = to;
>   olc_add_to_save_list((to/100), OLC_SAVE_MOB);
>
>   send_to_char("Okay.\r\n", ch);
>   return;
> }

Hmm...guess the rest looks ok. However can't tell more about
olc_add_to_save_list and copy_mobile...they seem to be oasis, which
I don't know.

- Chris

--
/----------------------------------------------------------------------------\
| Christian Loth, chris@rom.mud.de    |           REALM OF MAGIC             |
| http://rom.mud.de/~chris            | telnet rom.mud.de 4000               |
|                                     | http://rom.mud.de/                   |
\----------------------------------------------------------------------------/


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



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