// Constructor CityIO::CityIO(string file) { string line; vector<string> citySpecs; ifstream cityFile(file); if(cityFile.is_open()) { while(getline(cityFile, line)) { line = ModelIO::RemoveLeadingWS(line); if(line.length() > 0 && line.at(0) != '#') { citySpecs.push_back(line); } } } cityFile.close(); name = citySpecs[0]; for( int i = 2; i < 2 + ModelIO::StringToInt(citySpecs[1]); i++ ) { building tmp; string fileLoc; stringstream ss(citySpecs[i]); ss >> fileLoc; tmp.model = ModelIO(fileLoc); ss >> tmp.sx; ss >> tmp.sy; ss >> tmp.sz; ss >> tmp.rx; ss >> tmp.ry; ss >> tmp.rz; ss >> tmp.tx; ss >> tmp.ty; ss >> tmp.tz; buildings.push_back(tmp); } }
Map::Map(const GameObject & gameObject, std::string fileName) :GameObject(gameObject),schedule(new Schedule()) { std::ifstream cityFile(fileName); if (cityFile.is_open()) { while (!cityFile.eof()) { std::string textureName, cityName, connectionsListFile, productsFileName; Vector2 pos, size; cityFile >> pos >> size >> textureName >> cityName >> connectionsListFile >> productsFileName; try { mapElements.push_back(new City(MapElement(GameObject(pos, size, 0, Textures::getTexture(textureName)), cityName, connectionsListFile), productsFileName)); } catch (GameError & gameError) { gameError.generateErrorLog(errorFile); } } } else throw GameError(fileName + ":file not found(Cities)");