alliedmodders / amxmodx

AMX Mod X - Half-Life 1 Scripting and Administration
http://www.amxmodx.org/
499 stars 203 forks source link

"Warning 225: unreachable code" in amxmisc.inc #782

Closed FEDERICOMB96 closed 4 years ago

FEDERICOMB96 commented 5 years ago

This error appears from some version of AMX [1.8.3] (that I don't remember now 😅) to latest build 1.9/1.10

Problematic Code (or Steps to Reproduce)

https://github.com/alliedmodders/amxmodx/blob/76378fd5d0083986bf1328cd3b9afdd8c885c9b5/plugins/include/amxmisc.inc#L755-L770

Logs

amxmisc.inc(769) : warning 225: unreachable code

Fix

stock constraint_offset(low, high, seed, offset)
{
    new numElements = high - low + 1;
    offset += seed - low;

    if (offset >= 0)
    {
        return low + (offset % numElements);
    }

    return high - (abs(offset) % numElements) + 1;
}
Reshiramboy commented 5 years ago

close the orto kpo