fodev.net

FOnline Development => Questions and Answers => Topic started by: SEGA_RUS on November 02, 2015, 01:49:27 pm

Title: [2238] Again index out of bounds
Post by: SEGA_RUS on November 02, 2015, 01:49:27 pm
Code: [Select]
[01:00:448] Context<Critter::ProcessVisibleCritters : Npc (all_brahmin_herdsman, 5001610)>, state<Exception>, call stack<2>:
[01:00:448]   1) main : int TraceWall(uint16, uint16, uint16, uint16, Map&inout, int) : 5216, 3.
[01:00:448]   0) main : bool check_look(Map&inout, Critter&inout, Critter&inout) : 5196, 3.
[01:00:448] Script exception: Index out of bounds : main : int TraceWall(uint16, uint16, uint16, uint16, Map&inout, int) : 5216, 3 : Critter::ProcessVisibleCritters : Npc (all_brahmin_herdsman, 5001610).
[01:00:448] Execution of script stopped due to exception.

Code: [Select]
int TraceWall(uint16 hx, uint16 hy, uint16 tx, uint16 ty, Map& map, int dist)
{
    array<uint8> Lookup;
    int dx = tx - hx;
    int dy = ty - hy;
    if ((ABS(dx) >= MAX_TRACE) || (ABS(dy) >= MAX_TRACE)) return 0;
    int idx = (SIZE_LIN * (dy + MAX_TRACE) + dx + MAX_TRACE) * MAX_ARR;
    uint16 maxX = 0; uint16 maxY = 0;
    for(maxX = 0; maxX < map.GetWidth(); maxX++)
    for(maxY = 0; maxY < map.GetHeight(); maxY++)
    for (int i = 0; i < dist; i++)
    {
        Move(hx,hy,Lookup[idx++]);       
        if ((hx >= maxX) || (hy >= maxY)) return i;
        if(!map.IsHexRaked(hx, hy)) return i;
}
    return dist;
}
Title: Re: [2238] Again index out of bounds
Post by: Wipe on November 12, 2015, 07:08:16 pm
Lookup is never filled