Language: 
To browser these website, it's necessary to store cookies on your computer.
The cookies contain no personal information, they are required for program control.
  the storage of cookies while browsing this website, on Login and Register.

Author Topic:  ITERATIVE_BROWSE_NORMAL_INVENTORY  (Read 16 times)

0 Members and 1 Guest are viewing this topic.

Dolfo

« on: 04, February 2025, 17:23:02 »
Code: [Select]
#define ITERATIVE_BROWSE_NORMAL_INVENTORY(_CR_, _OC_, _OP_, _ON_) \
    if ((_CR_) == NULL) \
    { \
        if (!QUERY_FLAG((_OC_), FLAG_REMOVED) && \
            (_OC_)->type == CONTAINER && \
            (_OC_)->inv && \
            ((_OP_) == NULL || \
             (_OC_)->slaying == NULL || \
             ((_OC_)->subtype < SUBTYPE_CONTAINER_NORMAL_player && \
              door_find_key((_OP_), (_OC_))) || \
             ((_OP_)->type == PLAYER && \
              (((_OC_)->subtype >= SUBTYPE_CONTAINER_NORMAL_clan && \
                0) || \
               ((_OC_)->subtype >= SUBTYPE_CONTAINER_NORMAL_group && \
                CONTR((_OP_))->group_id == (_OC_)->stats.maxhp) || \
               ((_OC_)->subtype >= SUBTYPE_CONTAINER_NORMAL_player && \
                (_OC_)->slaying == (_OP_)->name))))) \
        { \
            (_CR_) = (_OC_); \
            (_OC_) = (_CR_)->inv; \
            (_ON_) = ((_OC_)->below) ? (_OC_)->below : (_CR_); \
        } \
    } \
    else if ((_CR_)->type == CONTAINER) \
    { \
        if ((_OC_) == (_CR_)) \
        { \
            (_CR_) = NULL; \
        } \
        else if ((_ON_) == NULL) \
        { \
            (_ON_) = (_CR_); \
        } \
    } \
    if (QUERY_FLAG((_OC_), FLAG_REMOVED)) \
    { \
        continue; \
    }

what a lovely macro. it needs to be also in a core loop like
Code: [Select]
FOREACH_OBJECT_IN_OBJECT(this, who, next)

Then it "hacks" the core loop and browse also in containers when allowed. It uses one value for its own init and reinit itself, to trigger this nice initial container checking again for next container.

It also checks containers from all point of view, if we are allowed to open this. This goes up to another call to find a key first to open a key locked container.

This is an example of a massiv overloaded logic, wants to handle all in one and fails at the end in speed and readability.

We call this 4 times, to search for keys, for inv checkers, for quest item checker and for the identify logic.

I think in 99%  our call scenarios we loop player/monster inventory.

Can we id items in floor chest?
Can we have keylocked containers in player/monster inv?
Can we have clan, group, player stamped single/group containers in our inv?
Why we need the check if a container is ours, when in our inv?

Its really hard to speed up the key find process when this is done mainly in inv checkers, but also on some few chests with findkey logic and this is nested in a "superman" macro used also to find quest items and to id objects.

Beside that our mapmakers can not simple add a door with a key in a map, because someone defined that an open door can be passed by other players at the moment he replaced the locked door with an open door object. So mapmakers need always add a inv checker to a door, if they want only this one player pass through.

Did we use somewhere doors other players can pass when opened?
« Last Edit: 04, February 2025, 17:34:40 by Dolfo »
Don't believe the shit, you hear in mainstream. Believe your own body. Your body is speaking always the true to you. But you need to understand your body. Hear to your body, not to your ego. And when body is calling to you: "Hey something is wrong!" find the reason(s) for that. Man in White don't go for that, they don't want to heal you. They want earn money and sell you medicine, you should take rest of your life. You are not the patient, you are their customer. Never forget this!

Tags: