[Circle] BUG: castle.c + bit of replace CODE

From: Ric Klaren (j.klaren@student.utwente.nl)
Date: 08/01/96


Hi,

When toying with a malloc debugger I found the following:

in castle.c the following macro is used:

#define C_MOB_SPEC(zone,mob) \
 (mob_index[real_mobile(((zone)*100)+(mob))].func)

It doesn't check on real_mobile returning -1.... so it writes happily 
outside the array (in minimud mode).

The fix:

Get rid of the above macro  and add this one in stead:

#define MOB_NUM(zone,mob)  ( ((zone)*100)+(mob) )

And replace assign_kings_castle with this:

void assign_kings_castle(void)
{
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 0), CastleGuard );   /* Gwydion */
   /* Added the previous line -- Furry */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 1), king_welmar );   /* Our dear friend, 
the King */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 3), CastleGuard); /* Jim */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 4), CastleGuard); /* Brian */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 5), CastleGuard); /* Mick */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 6), CastleGuard); /* Matt */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 7), CastleGuard); /* Jochem */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 8), CastleGuard); /* Anne */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 9), CastleGuard); /* Andrew */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 10), CastleGuard);   /* Bertram */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 11), CastleGuard);   /* Jeanette */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 12), peter);   /* Peter */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 13), training_master);     /* The 
training master */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 16), James);   /* James the Butler */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 17), cleaning);   /* Ze Cleaning Fomen */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 20), tim);     /* Tim, Tom's twin */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 21), tom);     /* Tom, Tim's twin */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 24), DicknDavid); /* Dick, guard of the
                                                * Treasury */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 25), DicknDavid); /* David, Dicks 
brother */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 26), jerry);   /* Jerry, the Gambler */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 27), CastleGuard);   /* Michael */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 28), CastleGuard);   /* Hans */
   ASSIGNMOB( MOB_NUM(Z_KINGS_C, 29), CastleGuard);   /* Boris */
}

Don't forget the prototype for ASSIGNMOB.....

Greets and enjoy

GrimReaper of Realms of Frustration (beta testing at 130.89.230.13)

-----+++++*****************************************************+++++++++-------
- Ric Klaren - j.klaren@student.utwente.nl - ia_ric@cs.utwente.nl -------------
-----+++++*****************************************************+++++++++-------
``Why don't we just invite them to dinner and massacre them all when
they're drunk?''
``You heard the man. There's seven hundred thousand of them.''
``Ah? So it'd have to be something simple with pasta, then.''
-------------------------------------------------------------------------------
From: Interesting Times by Terry Pratchet
-----+++++*****************************************************+++++++++-------

+-----------------------------------------------------------+
| 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/07/00 PST