I am using the stdio file functions and i am getting a buffer overrun error. It is reading the data correctly, and there are no error getting returned from ferror. here's the read code:
FILE*file = fopen("C:\\newmap.txt", "rb");
int bufferSize;
memset(pTileSet, 0, 256);
fread(&mapWidth, sizeof(int), 1, file);
fread(&mapHeight, sizeof(int), 1, file);
fread(&tileWidth, sizeof(int), 1, file);
fread(&tileHeight, sizeof(int), 1, file);
fread(&bufferSize, sizeof(int), 1, file);
if(bufferSize > 256)
return -1;
fread(pTileSet, sizeof(char), bufferSize, file);
for(int x = 0; x < mapWidth-1; ++x)
{
for(int y = 0; y < mapHeight-1; ++y)
{
fread(&tile[x][y].Spr, sizeof(int), 1, file);
fread(&tile[x][y].Solid, sizeof(bool), 1, file);
tile[x][y].x = x*tileWidth;
tile[x][y].y = y*tileHeight;
}
}
Anyone have any ideas? i know the file was saved the same way it is being loaded.
New Site! Check it out \/