started debugging
void FindPath(int Startx, int Startz, int Endx, int Endz)
{
for(int i =0; i < 50; i++)
{
TrunkList[i].cold = false;
TrunkList[i].weight = 10;
}
bool exists = false;
bool exit = false;
bool firstrun = true;
PathTile BestNode;
while(!exit)
{
if(firstrun)
{
TrunkListCount++;
TrunkList[TrunkListCount].x = Startx;
TrunkList[TrunkListCount].z = Startz;
TrunkList[TrunkListCount].index = TrunkListCount;
firstrun = false;
}
int bestweight = 1000;
int indexofbw = -1;
for(int i =0; i < TrunkListCount; i ++)
{
if(!TrunkList[i].cold)
{
if(TrunkList[i].weight < bestweight)
{
bestweight = TrunkList[i].weight;
indexofbw = i;
}
}
}
BestNode.x = TrunkList[indexofbw].x;
BestNode.z = TrunkList[indexofbw].z;
BestNode.index = TrunkList[indexofbw].index;
if((BestNode.x != Endx)||(BestNode.z != Endz))
{
int x = BestNode.x;
int z = BestNode.z;
if(NodeCoord(x,z+1).access)//n
{
exists = false;
for(int i =0; i < TrunkListCount; i++)
{
if((TrunkList[i].x == NodeCoord(x,z+1).x)&&(TrunkList[i].z == NodeCoord(x,z+1).z))
{
exists = true;
}
}
if(!exists)
{
TrunkListCount++;
TrunkList[TrunkListCount].x = NodeCoord(x,z+1).x;
TrunkList[TrunkListCount].z = NodeCoord(x,z+1).z;
TrunkList[TrunkListCount].index = TrunkListCount;
NodeCoord(x,z+1,TrunkListCount);
TrunkList[TrunkListCount].Parent = NodeCoord(x,z).tileindex;
StringCchPrintfA(IGmessage,1024,"x %d",TrunkList[TrunkListCount].x);
MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);
StringCchPrintfA(IGmessage,1024,"z %d",TrunkList[TrunkListCount].z);
MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);
StringCchPrintfA(IGmessage,1024,"i %d",TrunkList[TrunkListCount].index);
MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);
}
}
if(NodeCoord(x+1,z+1).access)//ne
{
exists = false;
for(int i =0; i < TrunkListCount; i++)
{
if((TrunkList[i].x == NodeCoord(x+1,z+1).x)&&(TrunkList[i].z == NodeCoord(x+1,z+1).z))
{
exists = true;
}
}
if(!exists)
{
TrunkListCount++;
TrunkList[TrunkListCount].x = NodeCoord(x+1,z+1).x;
TrunkList[TrunkListCount].z = NodeCoord(x+1,z+1).z;
TrunkList[TrunkListCount].index = TrunkListCount;
NodeCoord(x+1,z+1,TrunkListCount);
TrunkList[TrunkListCount].Parent = NodeCoord(x,z).tileindex;
StringCchPrintfA(IGmessage,1024,"x %d",TrunkList[TrunkListCount].x);
MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);
StringCchPrintfA(IGmessage,1024,"z %d",TrunkList[TrunkListCount].z);
MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);
StringCchPrintfA(IGmessage,1024,"i %d",TrunkList[TrunkListCount].index);
MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);
}
}
if(NodeCoord(x+1,z).access)//e
{
exists = false;
for(int i =0; i < TrunkListCount; i++)
{
if((TrunkList[i].x == NodeCoord(x+1,z).x)&&(TrunkList[i].z == NodeCoord(x+1,z).z))
{
exists = true;
}
}
if(!exists)
{
TrunkListCount++;
TrunkList[TrunkListCount].x = NodeCoord(x+1,z).x;
TrunkList[TrunkListCount].z = NodeCoord(x+1,z).z;
TrunkList[TrunkListCount].index = TrunkListCount;
NodeCoord(x+1,z,TrunkListCount);
TrunkList[TrunkListCount].Parent = NodeCoord(x,z).tileindex;
StringCchPrintfA(IGmessage,1024,"x %d",TrunkList[TrunkListCount].x);
MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);
StringCchPrintfA(IGmessage,1024,"z %d",TrunkList[TrunkListCount].z);
MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);
StringCchPrintfA(IGmessage,1024,"i %d",TrunkList[TrunkListCount].index);
MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);
}
}
if(NodeCoord(x+1,z-1).access)//se
{
exists = false;
for(int i =0; i < TrunkListCount; i++)
{
if((TrunkList[i].x == NodeCoord(x+1,z-1).x)&&(TrunkList[i].z == NodeCoord(x+1,z-1).z))
{
exists = true;
}
}
if(!exists)
{
TrunkListCount++;
TrunkList[TrunkListCount].x = NodeCoord(x+1,z-1).x;
TrunkList[TrunkListCount].z = NodeCoord(x+1,z-1).z;
TrunkList[TrunkListCount].index = TrunkListCount;
NodeCoord(x+1,z-1,TrunkListCount);
TrunkList[TrunkListCount].Parent = NodeCoord(x,z).tileindex;
StringCchPrintfA(IGmessage,1024,"x %d",TrunkList[TrunkListCount].x);
MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);
StringCchPrintfA(IGmessage,1024,"z %d",TrunkList[TrunkListCount].z);
MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);
StringCchPrintfA(IGmessage,1024,"i %d",TrunkList[TrunkListCount].index);
MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);
} }
if(NodeCoord(x,z-1).access)//s
{
exists = false;
for(int i =0; i < TrunkListCount; i++)
{
if((TrunkList[i].x == NodeCoord(x,z-1).x)&&(TrunkList[i].z == NodeCoord(x,z-1).z))
{
exists = true;
}
}
if(!exists)
{
TrunkListCount++;
TrunkList[TrunkListCount].x = NodeCoord(x,z-1).x;
TrunkList[TrunkListCount].z = NodeCoord(x,z-1).z;
TrunkList[TrunkListCount].index = TrunkListCount;
NodeCoord(x,z-1,TrunkListCount);
TrunkList[TrunkListCount].Parent = NodeCoord(x,z).tileindex;
StringCchPrintfA(IGmessage,1024,"x %d",TrunkList[TrunkListCount].x);
}
}
if(NodeCoord(x-1,z-1).access)//sw
{
exists = false;
for(int i =0; i < TrunkListCount; i++)
{
if((TrunkList[i].x == NodeCoord(x-1,z-1).x)&&(TrunkList[i].z == NodeCoord(x-1,z-1).z))
{
exists = true;
}
}
if(!exists)
{
TrunkListCount++;
TrunkList[TrunkListCount].x = NodeCoord(x-1,z-1).x;
TrunkList[TrunkListCount].z = NodeCoord(x-1,z-1).z;
TrunkList[TrunkListCount].index = TrunkListCount;
NodeCoord(x-1,z-1,TrunkListCount);
TrunkList[TrunkListCount].Parent = NodeCoord(x,z).tileindex;
} }
if(NodeCoord(x-1,z).access)//w
{
exists = false;
for(int i =0; i < TrunkListCount; i++)
{
if((TrunkList[i].x == NodeCoord(x+1,z-1).x)&&(TrunkList[i].z == NodeCoord(x+1,z-1).z))
{
exists = true;
}
}
if(!exists)
{
TrunkListCount++;
TrunkList[TrunkListCount].x = NodeCoord(x+1,z-1).x;
TrunkList[TrunkListCount].z = NodeCoord(x+1,z-1).z;
TrunkList[TrunkListCount].index = TrunkListCount;
NodeCoord(x+1,z-1,TrunkListCount);
TrunkList[TrunkListCount].Parent = NodeCoord(x,z).tileindex;
}}
if(NodeCoord(x-1,z+1).access)//nw
{
exists = false;
for(int i =0; i < TrunkListCount; i++)
{
if((TrunkList[i].x == NodeCoord(x-1,z+1).x)&&(TrunkList[i].z == NodeCoord(x-1,z+1).z))
{
exists = true;
}
}
if(!exists)
{
TrunkListCount++;
TrunkList[TrunkListCount].x = NodeCoord(x-1,z+1).x;
TrunkList[TrunkListCount].z = NodeCoord(x-1,z+1).z;
TrunkList[TrunkListCount].index = TrunkListCount;
NodeCoord(x-1,z+1,TrunkListCount);
TrunkList[TrunkListCount].Parent = NodeCoord(x,z).tileindex;
} }
TrunkList[BestNode.index].cold = true;
}
else
{
exit = true;
}
}
/*StringCchPrintfA(IGmessage,1024,"Closest %d",Closest);
MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);*/
}