1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
bool CArea::OnLoad(char* File) {
char TilesetFile[260];
char MapFile[255];
char DecorFile[255];
FILE* FileHandle = fopen(File, "r"); //open the file
if(FileHandle == NULL) {
return false;
}
fscanf(FileHandle, "%s\n", TilesetFile); //Image file path
if((Surf_Tileset = CSurface::OnLoad(TilesetFile))==NULL){//Try to load the image to a SDL Surface
return false; //Fails here
}
//Not important stuff concerning my problem
fscanf(FileHandle, "%dx%d,%d\n", &Map_Rows, &Map_Cols,&Tile_Size);
CTilePicker::CTilePickerControl.OnLoad(Surf_Tileset,Tile_Size);
fscanf(FileHandle, "%s ", MapFile);
fscanf(FileHandle, "%s\n", DecorFile);
fclose(FileHandle);
FILE* MapFileHandle = fopen(MapFile, "r");
FILE* DecorFileHandle = fopen(DecorFile, "r");
if(MapFileHandle == NULL || DecorFileHandle == NULL) {
return false;
}
for(int X = 0;X < Map_Rows;X++) {
for(int Y = 0;Y < Map_Cols;Y++) {
fscanf(MapFileHandle, "%d:%d ", &Map_Tiles_ID[X][Y], &Map_Tiles_Type[X][Y]);
fscanf(DecorFileHandle, "%d:%d ", &Decor_Tiles_ID[X][Y], &Decor_Tiles_Type[X][Y]);
}
fscanf(MapFileHandle, "\n");
fscanf(DecorFileHandle, "\n");
}
fclose(MapFileHandle);
fclose(DecorFileHandle);
return true;
}
|