Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

3
Two-handed weapon and Headgear bug
Post Body

So I took some time to look at the source to see what was up and discovered that the stats doubling didn't only affect two-handed weapons. It also affected headgears that covered more than one slot. I found the perpetrator which is located in src\map\pc.c. The function:

bool pc_is_same_equip_index(enum equip_index eqi, int *equip_index, int8 index) {
    if (index < 0 || index >= ARRAYLENGTH(equip_index))
        return false;
    // Dual weapon checks
    if (eqi == EQI_HAND_R && equip_index[EQI_HAND_L] == index)
        return true;
    // Headgear with Mid & Low location
    else if (eqi == EQI_HEAD_MID && equip_index[EQI_HEAD_LOW] == index)
        return true;
    // Headgear with Top & Mid or Low location
    else if (eqi == EQI_HEAD_TOP && (equip_index[EQI_HEAD_MID] == index || equip_index[EQI_HEAD_LOW] == index))
        return true;
    // Headgear with Mid & Low location
    else if (eqi == EQI_COSTUME_MID && equip_index[EQI_COSTUME_LOW] == index)
        return true;
    // Headgear with Top & Mid or Low location
    else if (eqi == EQI_COSTUME_TOP && (equip_index[EQI_COSTUME_MID] == index || equip_index[EQI_COSTUME_LOW] == index))
        return true;
    return false;
}

has the check:

        if (index < 0 || index >= ARRAYLENGTH(equip_index))
            return false;

which causes the function to prematurely exit for some reason. Removing this check fixes the issue. I don't think we really need this check as the function will return false if none of the conditions are met anyways and it's not actually used to access the array.

edit Didn't catch this before, but now I can see why the check will cause the function to prematurely exit. ARRAYLENGTH(equip_index) is calculating the length of a pointer, which is a big no no.

Author
Account Strength
80%
Account Age
13 years
Verified Email
Yes
Verified Flair
No
Total Karma
156
Link Karma
23
Comment Karma
133
Profile updated: 2 days ago
Posts updated: 10 months ago
Not the Event guy

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
10 years ago