Sometimes you have been looking at your own code for so long you just can't see past it, and the simplest mistakes become invisible to you no matter how much experience you have... Has this ever happened to you? Well I'm completely stuck. I have even tried reducing the function to basically do NOTHING and I still can't find my error...

I have the feeling the problem is so simple and obvious it is probably even embarrasing, but I am just blind to to my own code?



The function used to be usefull, but I reduced it to a bare minimum. Now it does nothing and I still cant figure ouut what is wrong...
Code:
#include <acknex.h>
#include <default.c>

int testi;

void world_waterORland()
{
   testi++;//1
   
	int Bwater[1000][500];
	int tx,ty;
	
	testi++;//2
	
	int temp_alpha;
	
	testi++;//3
	
	for(tx=0;tx<1000;tx++)
	{
		for(ty=0;ty<500;ty++)
		{
		   testi=4;//4
		   wait(1);
			if(temp_alpha<10)
			{
				Bwater[tx][ty]=1;//yes=water
			}
			else
			{
				Bwater[tx][ty]=0;//no=land
			}
		}
	}
	
	testi=5;//5
}

void main()
{
	fps_max=60;
	level_load(NULL);
	wait(1);
	
	
	world_waterORland();
	
	while(1)
	{
		wait(1);
	}
}



"testi" is just an integer I put in there to find out where it stops.
-(this code usually produces an E1513) testi reaches 3, but not 4... So that would indicate the declaration of the "for" loops are causing the problem? Because it reaches them but never enters?
-(when I remove the "wait(1);" right after "testi=4;" my code sometimes just crashes with no error message) When this happens testi reaches 4 but not 5, which would indicate a crash inside the loops...


The original code was trying to retrieve information from an image file (map), that has a heightmap "hidden" in it's alpha values, to later create a randomized level based on it...
Click to reveal..
Code:
#include <acknex.h>
#include <default.c>

BMAP* earth_water = "earthnuclearC.tga";
int testi;

void world_waterORland()
{
   testi++;
	int Bwater[1000][500];
	int tx,ty;
	
	testi++;
	var format; var pixel;
	var t_alpha;
	COLOR* t_color;
	format = bmap_lock(earth_water,0);
	testi++;
	
	for(tx=0;tx<1000;tx++)
	{
		for(ty=0;ty<500;ty++)
		{
		   testi++;
		   wait(1);
			pixel = pixel_for_bmap(earth_water,x,y);
			t_color=pixel_to_vec(NULL,t_alpha,format,pixel);
			if(t_alpha<10)
			{
				Bwater[tx][ty]=1;//yes=water
			}
			else
			{
				Bwater[tx][ty]=0;//no=land
			}
		}
	}
	bmap_unlock(earth_water);
	testi++;
}

void main()
{
	fps_max=60;
	level_load(NULL);
	wait(3);
	
	
	world_waterORland();
	
	while(1)
	{
		wait(1);
	}
}



I must add, even though the problem is probably so simple it is even embarrasing... I do have alot of experience in programming in general and Lite-C. As many of you know, I have been messing around with 3DGS for a few years already, but I just cannot seem to look past my own code, my brain is just blocked on this one.


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1