Exemple #1
0
/* Generate a radius packet id. */
static krb5_error_code
id_generate(krb5_context ctx, krad_packet_iter_cb cb, void *data, uchar *id)
{
    krb5_error_code retval;
    const krad_packet *tmp;
    idmap used;
    uchar i;

    retval = randomize(ctx, &i, sizeof(i));
    if (retval != 0) {
        if (cb != NULL)
            (*cb)(data, TRUE);
        return retval;
    }

    if (cb != NULL) {
        idmap_init(&used);
        for (tmp = (*cb)(data, FALSE); tmp != NULL; tmp = (*cb)(data, FALSE))
            idmap_set(&used, tmp->pkt.data[1]);

        retval = idmap_find(&used, &i);
        if (retval != 0)
            return retval;
    }

    *id = i;
    return 0;
}
Exemple #2
0
static void
_item_delay(struct game* self, struct room* ro, struct member* m, const struct item_tplt* titem, int delay) {
    sc_debug("char %u, use delay titem %u", m->detail.charid, titem->id);

    struct buff_delay* bdelay = idmap_find(m->delaymap, titem->id);
    if (bdelay == NULL) {
        bdelay = malloc(sizeof(*bdelay));
        bdelay->effect_time = 0;
        idmap_insert(m->delaymap, titem->id, bdelay);
    }
    bdelay->last_time = sc_timer_now() + delay;
    if (bdelay->effect_time == 0) {
        bdelay->effect_time = bdelay->last_time;
    }
}
Exemple #3
0
static void
_item_effect_member(struct game* self, struct room* ro, struct member* m, 
        const struct item_tplt* titem, int addtime) {
    struct buff_effect tmp[BUFF_EFFECT];
    struct buff_effect* effectptr = NULL;
    struct buff* b = NULL;
    
    if (titem->time > 0) {
        b = idmap_find(m->buffmap, titem->id);
        if (b == NULL) {
            b = malloc(sizeof(*b));
            idmap_insert(m->buffmap, titem->id, b);
            effectptr = b->effects;
        } else {
            if (b->time == 0) {
                effectptr = b->effects;
            } else {
                // has effect, just recal time
            }
        }
        b->time = sc_timer_now()/1000 + titem->time + addtime;
        sc_debug("insert time: %u, to char %u", b->time, m->detail.charid);
    } else {
        effectptr = tmp;
    }
    if (effectptr) {
#define FILL_EFFECT(n) \
        if (n <= BUFF_EFFECT) { \
            effectptr[n-1].type  = titem->effect##n; \
            effectptr[n-1].isper = titem->valuet##n; \
            effectptr[n-1].value = titem->value##n;  \
        }
        FILL_EFFECT(1);
        FILL_EFFECT(2);
        FILL_EFFECT(3);

        int i;
        for (i=0; i<BUFF_EFFECT; ++i) {
            effectptr[i].value = _item_effectone(m, &effectptr[i]);
            effectptr[i].isper = false;
        }

        _on_refresh_attri(m, ro);
        //dump(m->detail.charid, m->detail.name, &m->detail.attri);

    }
}