Exemple #1
0
char *unparse_object( dbref player, dbref target, int obey_myopic ) {
    char *buf, *fp, *bp;

    int exam;

    buf = alloc_lbuf( "unparse_object" );
    if( target == NOTHING ) {
        strcpy( buf, "*NOTHING*" );
    } else if( target == HOME ) {
        strcpy( buf, "*HOME*" );
    } else if( target == AMBIGUOUS ) {
        strcpy( buf, "*VARIABLE*" );
    } else if( isGarbage( target ) ) {
        fp = unparse_flags( player, target );
        bp = buf;
        safe_sprintf( buf, &bp, "*GARBAGE*(#%d%s)", target, fp );
        free_sbuf( fp );
    } else if( !Good_obj( target ) ) {
        sprintf( buf, "*ILLEGAL*(#%d)", target );
    } else {
        if( obey_myopic ) {
            exam = MyopicExam( player, target );
        } else {
            exam = Examinable( player, target );
        }
        if( exam ||
                ( Flags( target ) & ( CHOWN_OK | JUMP_OK | LINK_OK |
                                      DESTROY_OK ) ) || ( Flags2( target ) & ABODE ) ) {

            /*
             * show everything
             */
            fp = unparse_flags( player, target );
            bp = buf;
            safe_sprintf( buf, &bp, "%s(#%d%s)", Name( target ), target, fp );
            free_sbuf( fp );
        } else {
            /*
             * show only the name.
             */
            strcpy( buf, Name( target ) );
        }
    }
    return buf;
}
Exemple #2
0
static bool match_exit_internal(dbref loc, dbref baseloc, int local)
{
    if (  !Good_obj(loc)
       || !Has_exits(loc))
    {
        return true;
    }

    dbref exit;
    bool result = false;
    int key;

    DOLIST(exit, Exits(loc))
    {
        if (exit == md.absolute_form)
        {
            key = 0;
            if (Examinable(md.player, loc))
            {
                key |= VE_LOC_XAM;
            }
            if (Dark(loc))
            {
                key |= VE_LOC_DARK;
            }
            if (Dark(baseloc))
            {
                key |= VE_BASE_DARK;
            }
            if (exit_visible(exit, md.player, key))
            {
                promote_match(exit, CON_DBREF | local);
                return true;
            }
        }
        if (matches_exit_from_list(md.string, PureName(exit)))
        {
            promote_match(exit, CON_COMPLETE | local);
            result = true;
        }
    }
    return result;
}
Exemple #3
0
void
do_zone(dbref player, dbref cause, int key, char *tname, char *pname)
{
  dbref thing, zonemaster;

  switch( key ) {
    case ZONE_ADD: /* or default */
      if( *tname && !*pname ) {
        init_match(player, tname, NOTYPE);
        match_everything(0);
        thing = noisy_match_result();
        if( thing == NOTHING )
          return;
        if( !Examinable(player, thing) ) {
          notify_quiet(player, "You can't do that.");
          return;
        }
        viewzonelist(player, thing);
        return;
      }
       
      if( !*tname || !*pname ) {
        notify_quiet(player, "This switch expects two arguments.");
        return;
      }
     
      init_match(player, tname, NOTYPE);
      match_everything(0);
      thing = noisy_match_result();
      if( thing == NOTHING )
        return;

      /* Make sure we can do it */

      if ( (NoMod(thing) && !WizMod(player)) ||
           (Backstage(player) && NoBackstage(thing)) ) {
        notify_quiet(player, "Permission denied.");
        return;
      }
      if (!Controls(player, thing)) {
        notify_quiet(player, "Permission denied.");
        return;
      }

      if( ZoneMaster(thing) ) {
        notify_quiet(player, "You can't zone a Zone Master.");
        return;
      }
      /* Find out what the new zone is */

      init_match(player, pname, NOTYPE);
      match_everything(0);
      zonemaster = noisy_match_result();
      if (zonemaster == NOTHING)
        return;
 
      if( !ZoneMaster(zonemaster) ) {
        notify_quiet(player, "That's not a Zone Master.");
        return;
      }

      if(!Controls(player, zonemaster) && 
        !could_doit(player, zonemaster, A_LZONETO, 0, 0) &&
        !could_doit(player, zonemaster, A_LZONEWIZ, 0, 0)) {
        notify_quiet(player, "Permission denied.");
        return;
      }

      if( zlist_inlist(thing, zonemaster) ) {
        notify_quiet(player, "Object is already in that zone.");
        return;
      }

      zlist_add(thing, zonemaster);
      zlist_add(zonemaster, thing);

      notify_quiet(player, "Zone Master added to object.");
      break;
    case ZONE_DELETE:
      if( !*tname || !*pname ) {
        notify_quiet(player, "This switch expects two arguments.");
        return;
      }
      /* Find out what the zone is */

      init_match(player, pname, NOTYPE);
      match_everything(0);
      zonemaster = noisy_match_result();
      if (zonemaster == NOTHING)
        return;
     
      init_match(player, tname, NOTYPE);
      match_everything(0);
      thing = noisy_match_result();
      if( thing == NOTHING )
        return;

      if(!zlist_inlist(thing, zonemaster)) {
        notify_quiet(player, "That is not one of this object's Zone Masters.");
        return;
      }

      /* only need to control zmo or be zonewiz to delete 
         or control object */

      if(!Controls(player, thing) &&
         !Controls(player, zonemaster) && 
         !could_doit(player, zonemaster, A_LZONEWIZ, 0, 0)
         ) {
        notify_quiet(player, "Permission denied.");
        return;
      }

      if ( (NoMod(thing) && !WizMod(player)) ||
           (Backstage(player) && NoBackstage(thing)) ) {
        notify_quiet(player, "Permission denied.");
        return;
      }

      zlist_del(thing, zonemaster);
      zlist_del(zonemaster, thing);

      notify_quiet(player, "Deleted.");
      break;
    case ZONE_PURGE:
      if( !*tname || *pname) {
        notify_quiet(player, "This switch expects one argument.");
        return;
      }
      /* Find out what the zone is */

      init_match(player, tname, NOTYPE);
      match_everything(0);
      thing = noisy_match_result();
      if (thing == NOTHING)
        return;

      if( ZoneMaster(thing) ) {
        if(!Controls(player, thing) && 
          !could_doit(player, thing, A_LZONEWIZ, 0, 0)) {
          notify_quiet(player, "Permission denied.");
          return;
        }
        if ( (NoMod(thing) && !WizMod(player)) ||
             (Backstage(player) && NoBackstage(thing)) ) {
          notify_quiet(player, "Permission denied.");
          return;
        }
        zlist_destroy(thing);
        notify_quiet(player, "All objects removed from zone.");
      }
      else {
        if(!Controls(player, thing)) {
          notify_quiet(player, "Permission denied.");
          return;
        }
        if ( (NoMod(thing) && !WizMod(player)) ||
             (Backstage(player) && NoBackstage(thing)) ) {
          notify_quiet(player, "Permission denied.");
          return;
        }
        zlist_destroy(thing);

        notify_quiet(player, "Object removed from all zones.");
      }
      break;
    default:
      notify_quiet(player, "Unknown switch!");
      break;
  }
  return;
}
Exemple #4
0
/*
 * ---------------------------------------------------------------------------
 * * Return an lbuf pointing to the object name and possibly the db# and flags
 */
UTF8 *unparse_object(dbref player, dbref target, bool obey_myopic, bool bAddColor)
{
    UTF8 *buf = alloc_lbuf("unparse_object");
    if (NOPERM <= target && target < 0)
    {
        mux_strncpy(buf, aszSpecialDBRefNames[-target], LBUF_SIZE-1);
    }
    else if (!Good_obj(target))
    {
        mux_sprintf(buf, LBUF_SIZE, T("*ILLEGAL*(#%d)"), target);
    }
    else
    {
        bool exam;
        if (obey_myopic)
        {
            exam = MyopicExam(player, target);
        }
        else
        {
            exam = Examinable(player, target);
        }

        // Leave and extra 100 bytes for the dbref and flags at the end and
        // color at the beginning if necessary..
        //
        mux_field fldName = StripTabsAndTruncate( Moniker(target), buf,
                                                  LBUF_SIZE-100, LBUF_SIZE-100);
        UTF8 *bp = buf + fldName.m_byte;

#if defined(FIRANMUX)
        if (  fldName.m_column == fldName.m_byte
           && bAddColor)
        {
            // There is no color in the name, so look for @color, or highlight.
            //
            UTF8 *buf2 = alloc_lbuf("unparse_object.color");
            UTF8 *bp2  = buf2;

            UTF8 *pLetters = AcquireColorLetters(player, target);
            if (NULL != pLetters)
            {
                safe_str(LettersToBinary(pLetters), buf2, &bp2);
                free_lbuf(pLetters);
                pLetters = NULL;
            }
            else
            {
                safe_str((UTF8 *)COLOR_INTENSE, buf2, &bp2);
            }

            *bp = '\0';
            safe_str(buf, buf2, &bp2);
            safe_str((UTF8 *)COLOR_RESET, buf2, &bp2);

            // Swap buffers.
            //
            free_lbuf(buf);
            buf = buf2;
            bp  = bp2;
        }
#else
        UNUSED_PARAMETER(bAddColor);
#endif // FIRANMUX

        if (  exam
           || (Flags(target) & (CHOWN_OK | JUMP_OK | LINK_OK | DESTROY_OK))
           || (Flags2(target) & ABODE))
        {
            // Show everything.
            //
            UTF8 *fp = decode_flags(player, &(db[target].fs));

            safe_str(T("(#"), buf, &bp);
            safe_ltoa(target, buf, &bp);
            safe_str(fp, buf, &bp);
            safe_chr(')', buf, &bp);

            free_sbuf(fp);
        }
        *bp = '\0';
    }
    return buf;
}