Page 1 of 1

World creation array (WRITE error) problems

PostPosted: Sun Jun 24, 2012 1:20 pm
by savvy
Ok, I'm working on sandbox loading scripts and level creating, my issue is currently in the creating; I have this script:
Code: Select all
if(type==1)
    {
        //RANDOMIZE!!!!!!
        k=rand(30);
        tracker=30+k;
        //ground levels
        for(j=0;j<16000;j++)
        {
            for(i=0;i<rand(3)+2;i++)
            {
            world[((tracker+i)*16000)+j][1]=2; //LINE 42
            }
            for(i=0;i<120-tracker;i++)
            {
                world[(tracker+i)*16000][1]=1; //LINE 46
            }
            k=rand(2);
            if(k==0)
            {
                k=rand(2);
            if(k==0)tracker-=1;
            if(k==1)tracker+=1;
            }
            if(k==1)
            {
                k=rand(2);
                if(k==0)tracker-=rand(5);
                if(k==1)tracker+=rand(5);
            }
        }
    }

the array I am using is a large one of 'world[1920000][10];'.

When I run this script (it's part of a void function) I have the error:
"view -> Create Actor, in makeworld function, line 42: WRITE attempt before allowed access area"

It also happens if I remove line 42 to line 46.

I have labelled lines 42 and 46 in the script above with comments,
any suggestions?

Thanks, savvy.

EDIT:

Here is some assistance with my issue actually :)
On line 42 the largest sum that can happen IS ((60+3)*16000)+16000 which comes out as 1024000, LOWER than the array limit.
Surely a WRITE error such as the above is going out of the array?

Re: World creation array (WRITE error) problems

PostPosted: Sun Jun 24, 2012 3:44 pm
by savvy
Sorry, unthoughtful error was made here, I found the problem.

problem: tracker was going up and out of bounds.

Solution: Always make sure you put limiters on things to keep them IN bounds of the array.

savvy