0001 void readLaby ( char* labyFile ) { //Թ 0002 FILE* fp; 0003 if ( ! ( fp = fopen ( labyFile, "r" ) ) ) 0004 { cout << "can't open " << labyFile << endl; exit ( -1 ); } 0005 fscanf ( fp, "Laby Size = %d\n", &labySize ); 0006 if ( LABY_MAX < labySize ) 0007 { cout << "Laby size " << labySize << " > " << LABY_MAX << endl; exit ( -1 ); } 0008 int startX, startY; fscanf ( fp, "Start = (%d, %d)\n", &startX, &startY ); 0009 startCell = &laby[startX][startY]; 0010 int goalX, goalY; fscanf ( fp, "Goal = (%d, %d)\n", &goalX, &goalY ); 0011 goalCell = &laby[goalX][goalY]; 0012 for ( int j = 0; j < labySize; j ++ ) 0013 for ( int i = 0; i < labySize; i ++ ) { 0014 laby[i][j].x = i; 0015 laby[i][j].y = j; 0016 int type; fscanf ( fp, "%d", &type ); 0017 switch ( type ) { 0018 case 1: laby[i][j].status = WALL; break; 0019 case 0: laby[i][j].status = AVAILABLE; break; 0020 default: exit ( -1 ); 0021 } 0022 laby[i][j].incoming = 0023 laby[i][j].outgoing = UNKNOWN; 0024 } 0025 fclose ( fp ); 0026 }