Exemplo n.º 1
0
void CHSInterface::InvokeResponse(HS_DBREF dbCause,
                                  HS_DBREF dbTarget,
                                  const HS_INT8 * pcMessage,
                                  const HS_INT8 * pcOMessage,
                                  const HS_INT8 * pcAction,
                                  HS_DBREF dbLocation)
{
#ifdef PENNMUSH                 // No change in code between versions
    did_it(dbCause, dbTarget, pcMessage, NULL, pcOMessage, NULL, pcAction,
           dbLocation);
#endif

#if defined(TM3) || defined(MUX)
    ATTR *a_atr = NULL, *o_atr = NULL, *aa_atr = NULL;
    int anum, onum, aanum;

    anum = onum = aanum = 0;

    if (pcMessage != NULL)
    {
        a_atr = atr_str((char *) pcMessage);
        if (a_atr != NULL)
            anum = a_atr->number;
    }
    if (pcOMessage != NULL)
    {
        o_atr = atr_str((char *) pcOMessage);
        if (o_atr != NULL)
            onum = o_atr->number;
    }
    if (pcAction != NULL)
    {
        aa_atr = atr_str((char *) pcAction);
        if (aa_atr != NULL)
            aanum = aa_atr->number;
    }

#ifdef TM3
    did_it(dbCause, dbTarget, anum, NULL, onum,
           NULL, aanum, 0, (char **) NULL, 0, 0);
#endif
#ifdef MUX
    did_it(dbCause, dbTarget, anum, NULL, onum,
           NULL, aanum, (char **) NULL, 0);
#endif

#endif
}
Exemplo n.º 2
0
DESC_INFO *desclist_match(dbref player, dbref thing)
{
    static DESC_INFO descbuffer;

    descbuffer.n = 0;
    RLEVEL match = RxLevel(player) & TxLevel(thing);
    for (int i = 0; i < mudconf.no_levels; i++)
    {
        confdata::rlevel_def *rldef = &mudconf.reality_level[i];
        if ((match & rldef->value) == rldef->value)
        {
            ATTR *at = atr_str(rldef->attr);
            if (NULL != at)
            {
                bool bFound = false;
                for (int j = 0; j < descbuffer.n; j++)
                {
                    if (at->number == descbuffer.descs[j])
                    {
                        bFound = true;
                        break;
                    }
                }

                if (  !bFound
                   && descbuffer.n < NUM_DESC-1)
                {
                    descbuffer.descs[descbuffer.n] = at->number;
                    descbuffer.n++;
                }
            }
        }
    }
    return &descbuffer;
}
Exemplo n.º 3
0
// ---------------------------------------------------------------------------
// do_wait: Command interface to wait_que
//
void do_wait
(
    dbref executor,
    dbref caller,
    dbref enactor,
    int   eval,
    int key,
    char *event,
    char *cmd,
    char *cargs[],
    int ncargs
)
{
    CLinearTimeAbsolute ltaWhen;
    CLinearTimeDelta    ltd;

    // If arg1 is all numeric, do simple (non-sem) timed wait.
    //
    if (is_rational(event))
    {
        if (key & WAIT_UNTIL)
        {
            ltaWhen.SetSecondsString(event);
        }
        else
        {
            ltaWhen.GetUTC();
            ltd.SetSecondsString(event);
            ltaWhen += ltd;
        }
        wait_que(executor, caller, enactor, eval, true, ltaWhen, NOTHING, 0,
            cmd,
            ncargs, cargs,
            mudstate.global_regs);
        return;
    }

    // Semaphore wait with optional timeout.
    //
    char *what = parse_to(&event, '/', 0);
    init_match(executor, what, NOTYPE);
    match_everything(0);

    dbref thing = noisy_match_result();
    if (!Good_obj(thing))
    {
        return;
    }
    else if (!Controls(executor, thing) && !Link_ok(thing))
    {
        notify(executor, NOPERM_MESSAGE);
    }
    else
    {
        // Get timeout, default 0.
        //
        int atr = A_SEMAPHORE;
        bool bTimed = false;
        if (event && *event)
        {
            if (is_rational(event))
            {
                if (key & WAIT_UNTIL)
                {
                    ltaWhen.SetSecondsString(event);
                }
                else
                {
                    ltaWhen.GetUTC();
                    ltd.SetSecondsString(event);
                    ltaWhen += ltd;
                }
                bTimed = true;
            }
            else
            {
                ATTR *ap = atr_str(event);
                if (!ap)
                {
                    atr = mkattr(executor, event);
                    if (atr <= 0)
                    {
                        notify_quiet(executor, "Invalid attribute.");
                        return;
                    }
                    ap = atr_num(atr);
                }
                else
                {
                    atr = ap->number;
                }
                if (!bCanSetAttr(executor, thing, ap))
                {
                    notify_quiet(executor, NOPERM_MESSAGE);
                    return;
                }
            }
        }

        int num = add_to(thing, 1, atr);
        if (num <= 0)
        {
            // Thing over-notified, run the command immediately.
            //
            thing = NOTHING;
            bTimed = false;
        }
        wait_que(executor, caller, enactor, eval, bTimed, ltaWhen, thing, atr,
            cmd,
            ncargs, cargs,
            mudstate.global_regs);
    }
}