PennMUSH Community

Changeset 1240

Show
Ignore:
Timestamp:
07/14/08 08:31:14 (2 months ago)
Author:
walker
Message:

Optimized entrances() and removed find_cost from it.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 1.8.3/branches/devel/game/txt/hlp/pennfunc.hlp

    r1226 r1240  
    12251225  You can also limit the range of the dbrefs searched by giving <begin> 
    12261226  and <end>. 
    1227  
    1228   This function is computationally expensive and costs the same as 
    1229   @find. You must control the object in order to perform entrances() 
    1230   on it.          
    12311227& EQ() 
    12321228  eq(<number1>, <number2>) 
  • 1.8.3/branches/devel/src/fundb.c

    r1226 r1240  
    838838  int exd, td, pd, rd;          /* what we're looking for */ 
    839839  char *p; 
     840  int controlswhere = 0; 
    840841 
    841842  if (!command_check_byname(executor, "@entrances")) { 
     
    914915    high = db_top - 1; 
    915916 
    916   if (!controls(executor, where) && !Search_All(executor)) { 
    917     safe_str(T(e_perm), buff, bp); 
    918     return; 
    919   } 
    920   if (!payfor(executor, FIND_COST)) { 
    921     notify_format(executor, T("You don't have %d %s to do that."), 
    922                   FIND_COST, ((FIND_COST == 1) ? MONEY : MONIES)); 
    923     safe_str("#-1", buff, bp); 
     917  controlswhere = controls(executor, where); 
     918  if (!controlswhere && !Search_All(executor)) { 
     919    safe_str(T(e_perm), buff, bp); 
    924920    return; 
    925921  } 
     
    927923  found = 0; 
    928924  for (counter = low; counter <= high; counter++) { 
    929     if (controls(executor, where) || controls(executor, counter)) { 
     925    if (GoodObject(counter)) { 
    930926      if ((exd && IsExit(counter)) || 
    931927          (td && IsThing(counter)) || 
     
    936932          entrance = Location(counter); 
    937933        if (entrance == where) { 
    938           if (!found) 
    939             found = 1; 
    940           else 
    941             safe_chr(' ', buff, bp); 
    942           safe_dbref(counter, buff, bp); 
     934          if (controlswhere || controls(executor, counter)) { 
     935            if (!found) 
     936              found = 1; 
     937            else 
     938              safe_chr(' ', buff, bp); 
     939            safe_dbref(counter, buff, bp); 
     940          } 
    943941        } 
    944942      }