Re: Sorry to bug you again

From: Brian Pape (
Date: 06/29/96

> Heres the deal.  I despritly need a function to tell me the number of any given mob
> in a room and in a zone
> num_mob_room(1302, 1312)
> would return an int with the number of vnum 1302 mobs in room 1312

assuming 1302 and 1312 are vnums.....

int num_mob_room(int mobnum, int roomnum){
  int cnt=0;
  struct char_data *mob;
  while (mob){
    if (mob->nr==real_mobile(mobnum))

this code was written on the fly so no guarantees.  Incidentally, as a
comment to all the whiners out there, there may have been some typos in
his post, but it was completely understandable  :-)

> I have received a few sugestions but they havent really worked.  Normaly this
> would be somthing i could do on my own but for loops are really sorta somthing
> i dont know to well.  And i cant figure it out.  If anyone could send me

hmm, you probably know me as Mr-Go-Buy-A-Book-On-C, but I'll reiterate...
If you don't have one, get one...  :-)  The above flow control structure
of a while loop could be re-written as a for loop, but the way I did it is
much clearer...  Just because a lot of people like to write obfuscated
code, doesn't mean that you have to, or that it is any more efficient.
Not to mention that when you have multiple people coding on a muds,
self-documentation is very helpful.  (i.e. code that is written clearly
enough you don't have to comment it for someone to easily see what it

> Second i work at a computer store and just had to share this:
> We build new computers
> so the phone wrings and i pick up

That was hilarious...  The only problem is that I find people like this
all the time, they won't believe ANYBODY, but if Micro$loth tells them
something, they praise them as being gods and go do it  *gag*  See my
second (valid) email address for what I think of Bill Gates  :-)

Brian Pape

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