Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void genMapWay::saveToFile(char *fileName) const{
- using std::ofstream;
- std::string nameOfFile;
- if (fileName == nullptr){
- char downRegSymbs[] = "qwertyuiopasdfghjklzxcvbnm";
- char upRgSymbs[] = "QWERTYUIOPASDFGHJKLZXCVBNM";
- char numbs[] = "1234567890";
- std::ostringstream ostr;
- ostr << m_mapHeight << 'x' << m_mapWidth << '_';
- nameOfFile += ostr.str();
- unsigned short randd;
- srand(time(NULL));
- for (int i = 0; i < rand()%15; i++){
- srand(time(0));
- randd = rand()%3;
- if (randd == 0)
- nameOfFile += downRegSymbs[rand()%26];
- if (randd == 1)
- nameOfFile += upRgSymbs[rand()%26];
- if (randd == 2)
- nameOfFile += numbs[rand()%10];
- }
- } else {
- nameOfFile = fileName;
- }
- nameOfFile += ".txt";
- ofstream save(nameOfFile.c_str());
- for (GMW_USI i = 0; i < m_mapHeight; i++){
- for (GMW_USI j = 0; j < m_mapWidth; j++){
- save << m_map[i][j] << ",";
- }
- save << std::endl;
- }
- save.close();
- std::cout << std::endl << "Saved to file: " << nameOfFile << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement