Re: [dgscripts] pl8 real_trigger()

From: Yoram Harmelin (yoram.harmelin@WANADOO.FR)
Date: 08/04/02


I had the same problem, it happens when real_trigger is used to find the
rnum of a trigger which has a vnum superior of the last zone you have on
your mud. For example, If you have a zone 12 on your mud, you should be able
to use real_trigger to locate any trigger from vnum 0 to vnum 1299, but not
triggers with higher vnums.

My fix:

> /* returns the real number of the trigger with given virtual number */
> int real_trigger(int vnum)
> {
>   int bot = 0, mid;
>   int top = top_of_trigt;

>   /* perform binary search on trigger-table */
>   for (;;) {
>     mid = (bot + top) / 2;

>     /* put this first check before, so we avoid having mid equal to
>        top_of_trigt        */
++    if (top == top_of_trigt && bot == top_of_trigt)
++      return(NOTHING);
>     if (trig_index[mid]->vnum == vnum)
>       return (mid);
>     if (bot >= top)
>       return (NOTHING);
>     if (trig_index[mid]->vnum > vnum)
>       top = mid - 1;
>     else
>       bot = mid + 1;
>   }
> }

Good luck.
    Y. Harmelin

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