Beispiel #1
0
void SelectPrevItem (edict_t *ent, int itflags)
{
    gclient_t	*cl;
    int			i, index;
    gitem_t		*it;

    cl = ent->client;

    if (cl->chase_target) {
        ChasePrev(ent);
        return;
    }

    // scan  for the next valid one
    for (i=1 ; i<=MAX_ITEMS ; i++)
    {
        index = (cl->pers.selected_item + MAX_ITEMS - i)%MAX_ITEMS;
        if (!cl->pers.inventory[index])
            continue;
        it = &itemlist[index];
        if (!it->use)
            continue;
        if (!(it->flags & itflags))
            continue;

        cl->pers.selected_item = index;
        return;
    }

    cl->pers.selected_item = -1;
}
Beispiel #2
0
static void SelectPrevItem(edict_t *ent, int itflags)
{
    gclient_t   *cl;
    int         i, index;
    const gitem_t       *it;

    cl = ent->client;

    if (cl->layout == LAYOUT_MENU) {
        PMenu_Prev(ent);
        return;
    }
    if (cl->chase_target) {
        ChasePrev(ent);
        cl->chase_mode = CHASE_NONE;
        return;
    }

    // scan  for the next valid one
    for (i = 1; i <= ITEM_TOTAL; i++) {
        index = (cl->selected_item + ITEM_TOTAL - i) % ITEM_TOTAL;
        if (!cl->inventory[index])
            continue;
        it = INDEX_ITEM(index);
        if (!it->use)
            continue;
        if (!(it->flags & itflags))
            continue;

        cl->selected_item = index;
        return;
    }

    cl->selected_item = -1;
}