int _tmain(int argc, TCHAR** argv) { int iFirstParam = 1; // Turn on the "termination on heap corruption" flag. (void)HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); // generate output for HTML Help format BOOL fHTMLFormat = FALSE; // <include.h> filename to be copied const TCHAR *pszIncludeFilename = NULL; // additional include path const TCHAR *pszIncludePath = NULL; if( argc > 1 && _tcsicmp(argv[1], _T("/h")) == 0 ) { fHTMLFormat = TRUE; iFirstParam++; if( ( argc > 3 ) && _tcsicmp(argv[2], _T("/a")) == 0 ) // copy file operation { pszIncludeFilename = argv[3]; iFirstParam += 2; if( argc > 5 && _tcsicmp(argv[4], _T("/i")) == 0 ) { pszIncludePath = argv[5]; iFirstParam += 2; } } } // add symbol mappings to the map. BOOL fAddedToMap = FALSE; int i; for (i = iFirstParam; i < argc && _tcschr(argv[i], _T(',')) != NULL; i++) { AddToMap(argv[i]); fAddedToMap = TRUE; } // must only have 1-2 parms left on command line. if (!fAddedToMap || i < argc-2 || i > argc-1) { UsageErr(NULL, NULL); ASSERT(FALSE); } // open input file. CLineFile fileIn; fileIn.SafeOpen(argv[i], CLineFile::modeRead); // open/hook up output file. CLineFile fileOut; if (i+1 < argc) fileOut.SafeOpen(argv[i+1], CLineFile::modeWrite | CLineFile::modeCreate); else fileOut.m_pStream = stdout; // process the file. CString strLine; while (fileIn.ReadLine(strLine)) { if (MapLine(strLine, fHTMLFormat)) { fileOut.WriteLine(strLine); } } // close input file. fileIn.Close(); if( pszIncludeFilename != NULL ) { CString strIncludeFilePath = FindIncludeFile( pszIncludeFilename, pszIncludePath ); if( strIncludeFilePath.IsEmpty() ) { _ftprintf(stderr, _T("Error: Additional include file %s not found\n\n"), pszIncludeFilename ); fileOut.Close(); exit(1); } fileIn.SafeOpen(strIncludeFilePath, CLineFile::modeRead); while (fileIn.ReadLine(strLine)) { fileOut.WriteLine(strLine); } } // close output file. fileOut.Close(); return 0; }
QVector<MapData> PriorityMap::loadMap() const { QVector<MapData> priorityMap; QFile file(PLUGINS_DIR "/rules"); file.open(QIODevice::ReadOnly); QTextStream in(&file); while (!in.atEnd()) { const float priority = in.readLine().toFloat(); QPoint current; MapType map; for (int row = 0;; ++row) { const QString& line = in.readLine(); if (line[0] == '/') break; const QStringList& cells = line.split(' '); map.push_back(MapLine(cells.size())); MapLine& lastRow = map.back(); for (int column = 0; column < cells.size(); ++column) { const MapElement type = MAP_ELEMENT_TO_STR.right.at(cells[column]); lastRow[column] = type; if (type == MapElement::CU) current = {column, row}; } } priorityMap.push_back(MapData(std::move(map), current, priority)); } priorityMap.reserve(priorityMap.size() * 16); for (int i = 0, max = priorityMap.size(); i < max; ++i) { const MapData& data = priorityMap[i]; priorityMap.push_back(opposite(data)); const MapData& invertedData = inverse(data); priorityMap.push_back(invertedData); priorityMap.push_back(opposite(invertedData)); MapData newData = data; for (int j = 0; j < 3; ++j) { newData = rotate(newData); priorityMap.push_back(newData); priorityMap.push_back(opposite(newData)); const MapData& invertedMap = inverse(newData); priorityMap.push_back(invertedMap); priorityMap.push_back(opposite(invertedMap)); } } return priorityMap; }