diff --git a/CClmReader.cpp b/CClmReader.cpp index 4b7042f..6f01dfe 100644 --- a/CClmReader.cpp +++ b/CClmReader.cpp @@ -60,8 +60,14 @@ HRESULT CClmReader::get_FileName(int index, BSTR *fileName) // Allocate space for the string SysReAllocStringLen(fileName, NULL, stringLength); // Convert the string to Unicode - MultiByteToWideChar(CP_ACP, 0, indexTable[index].fileName, - stringLength, *fileName, stringLength); + MultiByteToWideChar( + CP_ACP, + 0, + indexTable[index].fileName, + stringLength, + *fileName, + stringLength + ); return S_OK; } @@ -112,9 +118,11 @@ HRESULT CClmReader::OpenStreamRead(BSTR fileName, StreamReader **stream) // CLM file much less memory intensive. // Create a memory stream reading with the file contents - memStream = new CMemoryStreamReader(indexTable[fileIndex].size, - (char*)(dataBuffer[fileIndex]), - bAttachToBuffer); + memStream = new CMemoryStreamReader( + indexTable[fileIndex].size, + (char*)(dataBuffer[fileIndex]), + bAttachToBuffer + ); if (memStream == NULL) { // Check if buffer is discardable diff --git a/CFileStreamReader.cpp b/CFileStreamReader.cpp index dadfeb8..8701ce3 100644 --- a/CFileStreamReader.cpp +++ b/CFileStreamReader.cpp @@ -113,16 +113,15 @@ CFileStreamReader::CFileStreamReader(BSTR fileName) : m_cRef(1) status = 0; // Open the file - hFile = CreateFileW(fileName, // lpFileName - GENERIC_READ, // dwDesired access - FILE_SHARE_READ,// dwShareMode - NULL, // lpSecurityAttributes - OPEN_EXISTING, // dwCreationDisposition - FILE_ATTRIBUTE_NORMAL | - FILE_FLAG_SEQUENTIAL_SCAN, - // dwFlagsAndAttributes - NULL // hTemplate - ); + hFile = CreateFileW( + fileName, // lpFileName + GENERIC_READ, // dwDesired access + FILE_SHARE_READ,// dwShareMode + NULL, // lpSecurityAttributes + OPEN_EXISTING, // dwCreationDisposition + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, // dwFlagsAndAttributes + NULL // hTemplate + ); // Check if the file was opened successfully if (hFile == INVALID_HANDLE_VALUE) @@ -141,16 +140,15 @@ CFileStreamReader::CFileStreamReader(BSTR fileName) : m_cRef(1) WideCharToMultiByte(CP_ACP, 0, fileName, stringLength, tempString, stringLength, 0, 0); // Try to open the file with ANSI version of CreateFile - hFile = CreateFileA(tempString, // lpFileName - GENERIC_READ, // dwDesired access - FILE_SHARE_READ,// dwShareMode - NULL, // lpSecurityAttributes - OPEN_EXISTING, // dwCreationDisposition - FILE_ATTRIBUTE_NORMAL | - FILE_FLAG_SEQUENTIAL_SCAN, - // dwFlagsAndAttributes - NULL // hTemplate - ); + hFile = CreateFileA( + tempString, // lpFileName + GENERIC_READ, // dwDesired access + FILE_SHARE_READ,// dwShareMode + NULL, // lpSecurityAttributes + OPEN_EXISTING, // dwCreationDisposition + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, // dwFlagsAndAttributes + NULL // hTemplate + ); // Check for errors if (hFile == INVALID_HANDLE_VALUE) diff --git a/CFileStreamWriter.cpp b/CFileStreamWriter.cpp index 1bf8fc1..ec07bf5 100644 --- a/CFileStreamWriter.cpp +++ b/CFileStreamWriter.cpp @@ -44,16 +44,15 @@ CFileStreamWriter::CFileStreamWriter(BSTR fileName) : m_cRef(1) status = 0; // Open the file - hFile = CreateFileW(fileName, // lpFileName - GENERIC_WRITE, // dwDesired access - 0, // dwShareMode - NULL, // lpSecurityAttributes - CREATE_ALWAYS, // dwCreationDisposition - FILE_ATTRIBUTE_NORMAL | - FILE_FLAG_SEQUENTIAL_SCAN, - // dwFlagsAndAttributes - NULL // hTemplate - ); + hFile = CreateFileW( + fileName, // lpFileName + GENERIC_WRITE, // dwDesired access + 0, // dwShareMode + NULL, // lpSecurityAttributes + CREATE_ALWAYS, // dwCreationDisposition + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, // dwFlagsAndAttributes + NULL // hTemplate + ); // Check if the file was opened successfully if (hFile == INVALID_HANDLE_VALUE) @@ -72,16 +71,15 @@ CFileStreamWriter::CFileStreamWriter(BSTR fileName) : m_cRef(1) WideCharToMultiByte(CP_ACP, 0, fileName, stringLength, tempString, stringLength, 0, 0); // Try to open the file with ANSI version of CreateFile - hFile = CreateFileA(tempString, // lpFileName - GENERIC_WRITE, // dwDesired access - 0, // dwShareMode - NULL, // lpSecurityAttributes - CREATE_ALWAYS, // dwCreationDisposition - FILE_ATTRIBUTE_NORMAL | - FILE_FLAG_SEQUENTIAL_SCAN, - // dwFlagsAndAttributes - NULL // hTemplate - ); + hFile = CreateFileA( + tempString, // lpFileName + GENERIC_WRITE, // dwDesired access + 0, // dwShareMode + NULL, // lpSecurityAttributes + CREATE_ALWAYS, // dwCreationDisposition + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, // dwFlagsAndAttributes + NULL // hTemplate + ); // Check for errors if (hFile == INVALID_HANDLE_VALUE) diff --git a/CMapFile.cpp b/CMapFile.cpp index cee4902..234fb6e 100644 --- a/CMapFile.cpp +++ b/CMapFile.cpp @@ -808,8 +808,14 @@ HRESULT CMapFile::get_TileGroupName(int tileGroupIndex, BSTR *tileGroupName) int nameLen = tileGroupInfo[tileGroupIndex].nameLen; SysReAllocStringLen(tileGroupName, NULL, nameLen); // Convert the name to unicode - MultiByteToWideChar(CP_ACP, 0, tileGroupInfo[tileGroupIndex].name, nameLen, - *tileGroupName, nameLen); + MultiByteToWideChar( + CP_ACP, + 0, + tileGroupInfo[tileGroupIndex].name, + nameLen, + *tileGroupName, + nameLen + ); return S_OK; } @@ -1130,7 +1136,7 @@ HRESULT CMapFile::InterfaceSupportsErrorInfo(REFIID riid) // *********************** CMapFile::CMapFile(TileSetSource *tileSetSource, int width, int height) : - m_cRef(1) + m_cRef(1) { // Round width up to the next power of 2 width = RoundUpPowerOf2(width); @@ -1188,8 +1194,12 @@ CMapFile::CMapFile(TileSetSource *tileSetSource, int width, int height) : g_cLocks++; } -CMapFile::CMapFile(TileSetSource *tileSetSource, StreamReader *stream, - enum MapLoadSaveFormat loadFlags) : m_cRef(1) +CMapFile::CMapFile( + TileSetSource *tileSetSource, + StreamReader *stream, + enum MapLoadSaveFormat loadFlags +) : + m_cRef(1) { // Initialize variables tileData = NULL; diff --git a/CTileSet.cpp b/CTileSet.cpp index e1576b3..7d38cf7 100644 --- a/CTileSet.cpp +++ b/CTileSet.cpp @@ -570,7 +570,7 @@ int CTileSet::SaveTileSet(StreamWriter *stream) // Write the file header "PBMP" section sectHead.tag = 'PMBP'; // PBMP tag sectHead.size = sizeof(sectHead)*4 + sizeOfPixelData + sizeof(headInfo) + 8 + - bmInfo->bmiHeader.biClrUsed*sizeof(RGBQUAD); + bmInfo->bmiHeader.biClrUsed*sizeof(RGBQUAD); numSectionsLeft = 2; // Number of sections (palette, and pixel data) // Check if palette section is needed if (bmInfo->bmiHeader.biClrUsed == 0) @@ -593,7 +593,7 @@ int CTileSet::SaveTileSet(StreamWriter *stream) // Write the Palette section sectHead.tag = 'LAPP'; // PPAL tag sectHead.size = bmInfo->bmiHeader.biClrUsed*sizeof(RGBQUAD) + - sizeof(sectHead)*2 + 8; + sizeof(sectHead)*2 + 8; stream->Write(sizeof(sectHead), (int)§Head, &numBytesWritten); // Write the "head" section of the "PPAL" section sectHead.tag = 'daeh'; // head tag @@ -615,8 +615,11 @@ int CTileSet::SaveTileSet(StreamWriter *stream) destPal->rgbBlue = srcPal->rgbRed; destPal->rgbReserved = srcPal->rgbReserved; } - stream->Write(bmInfo->bmiHeader.biClrUsed*sizeof(RGBQUAD), - (int)&tempPal, &numBytesWritten); + stream->Write( + bmInfo->bmiHeader.biClrUsed*sizeof(RGBQUAD), + (int)&tempPal, + &numBytesWritten + ); } // Write the "data" section of the "PBMP" section @@ -685,7 +688,7 @@ int CTileSet::SaveBitmapFile(StreamWriter *stream) // Preapre the bitmap file header bmFileHeader.bfType = 'MB'; // "BM" bmFileHeader.bfSize = sizeof(bmFileHeader) + sizeof(bmInfo->bmiHeader) + - sizeof(RGBQUAD)*bmInfo->bmiHeader.biClrUsed + sizeOfPixelData; + sizeof(RGBQUAD)*bmInfo->bmiHeader.biClrUsed + sizeOfPixelData; bmFileHeader.bfReserved1 = 0; bmFileHeader.bfReserved2 = 0; bmFileHeader.bfOffBits = bmFileHeader.bfSize - sizeOfPixelData; @@ -729,8 +732,8 @@ void CTileSet::CalcMiniMapColors(int startTile, int endTile) { // Add the color components of this pixel pixelDataOffset = tileNum*tileByteSize + - y*scanlineByteWidth + - ((x*headInfo.bitDepth) >> 3); + y*scanlineByteWidth + + ((x*headInfo.bitDepth) >> 3); switch(headInfo.bitDepth) { case 8: diff --git a/CTileSetManager.cpp b/CTileSetManager.cpp index fdab4e9..cb4b4ad 100644 --- a/CTileSetManager.cpp +++ b/CTileSetManager.cpp @@ -1193,8 +1193,14 @@ int CTileSetManager::Load(StreamReader *stream) // Allocate space for a BSTR to hold the name tileSetInfo[i].wideTileSetName = SysAllocStringLen(NULL, temp); // Convert the name to unicode - MultiByteToWideChar(CP_ACP, 0, tileSetInfo[i].tileSetName, temp, - tileSetInfo[i].wideTileSetName, temp); + MultiByteToWideChar( + CP_ACP, + 0, + tileSetInfo[i].tileSetName, + temp, + tileSetInfo[i].wideTileSetName, + temp + ); // Load the associated tile set tileSource->LoadTileSet(tileSetInfo[i].wideTileSetName, &tileSet->tileSet); // Make sure the tile set was found diff --git a/CTileSetManager.h b/CTileSetManager.h index 76dfe9c..f2a4c1d 100644 --- a/CTileSetManager.h +++ b/CTileSetManager.h @@ -295,8 +295,9 @@ class CTileSetManager : public TileSetManager, public ISupportErrorInfo short numTileReplacements; short cycleDelay; }; - struct TerrainTypeItemTable // Holds sets of related tiles - // LavaWalls/MicrobeWalls/NormalWalls/DamagedWalls/ReallyDamagedWalls/Tubes + // Holds sets of related tiles + // LavaWalls/MicrobeWalls/NormalWalls/DamagedWalls/ReallyDamagedWalls/Tubes + struct TerrainTypeItemTable { short tile[0x10]; // tile for each direction facing }; diff --git a/CTileSetSource.cpp b/CTileSetSource.cpp index 23f7cb2..d15ca2b 100644 --- a/CTileSetSource.cpp +++ b/CTileSetSource.cpp @@ -39,9 +39,10 @@ CTileSetSource::CTileSetSource(IResourceManager *resourceManager) : m_cRef(1) { head = NULL; // Initialize linked list of loaded files to empty - resManager = resourceManager; // CTileSetSource is owned by IResourceManager - // so the reference count should not be incremented - // (Don't want circular references) + // CTileSetSource is owned by IResourceManager + // so the reference count should not be incremented + // (Don't want circular references) + resManager = resourceManager; g_cLocks++; } diff --git a/CVolReader.cpp b/CVolReader.cpp index bdd42ba..d068b69 100644 --- a/CVolReader.cpp +++ b/CVolReader.cpp @@ -58,8 +58,14 @@ HRESULT CVolReader::get_FileName(int index, BSTR *fileName) // Allocate space for the string SysReAllocStringLen(fileName, NULL, stringLength); // Convert the string to Unicode - MultiByteToWideChar(CP_ACP, 0, string, stringLength, - *fileName, stringLength); + MultiByteToWideChar( + CP_ACP, + 0, + string, + stringLength, + *fileName, + stringLength + ); return S_OK; } @@ -133,9 +139,11 @@ HRESULT CVolReader::OpenStreamRead(BSTR fileName, StreamReader **stream) // Copy the data into a memory stream CMemoryStreamReader *rawStream; - rawStream = new CMemoryStreamReader(indexTable[fileIndex].fileSize, - (char*)buffer, - bAttachToBuffer); + rawStream = new CMemoryStreamReader( + indexTable[fileIndex].fileSize, + (char*)buffer, + bAttachToBuffer + ); if (rawStream == NULL) { if (bAttachToBuffer == 1) @@ -399,9 +407,11 @@ int CVolReader::GetFileIndex(BSTR fileName) // Get the midpoint middleIndex = (startIndex + endIndex) >> 1; // Check if strings match - result = strncmp((char*)stringBuffer + indexTable[middleIndex].fileNameOffset, - tempString, - stringLength); + result = strncmp( + (char*)stringBuffer + indexTable[middleIndex].fileNameOffset, + tempString, + stringLength + ); if (result == 0) { // String match diff --git a/OP2Editor.cpp b/OP2Editor.cpp index 0a9df29..8af7969 100644 --- a/OP2Editor.cpp +++ b/OP2Editor.cpp @@ -70,15 +70,17 @@ STDAPI DllRegisterServer(void) int retVal; pathLen = GetModuleFileName(g_hInstance, path, MAX_PATH); - retVal = RegCreateKeyEx(HKEY_CLASSES_ROOT, - TEXT("CLSID\\{C8DE4CDE-4554-4fe9-8688-A90D91EBCA0B}\\InprocServer32"), - 0, - TEXT(""), - REG_OPTION_NON_VOLATILE, - KEY_ALL_ACCESS, - NULL, - &hSubKey, - &creationDisposition); + retVal = RegCreateKeyEx( + HKEY_CLASSES_ROOT, + TEXT("CLSID\\{C8DE4CDE-4554-4fe9-8688-A90D91EBCA0B}\\InprocServer32"), + 0, + TEXT(""), + REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, + NULL, + &hSubKey, + &creationDisposition + ); if (retVal != ERROR_SUCCESS) return HRESULT_FROM_WIN32(retVal); retVal = RegSetValueEx(hSubKey, TEXT(""), 0, REG_SZ, (BYTE*)path, pathLen); @@ -92,10 +94,14 @@ STDAPI DllUnregisterServer(void) { int retVal; - retVal = RegDeleteKey(HKEY_CLASSES_ROOT, - TEXT("CLSID\\{C8DE4CDE-4554-4fe9-8688-A90D91EBCA0B}\\InprocServer32")); - retVal = RegDeleteKey(HKEY_CLASSES_ROOT, - TEXT("CLSID\\{C8DE4CDE-4554-4fe9-8688-A90D91EBCA0B}")); + retVal = RegDeleteKey( + HKEY_CLASSES_ROOT, + TEXT("CLSID\\{C8DE4CDE-4554-4fe9-8688-A90D91EBCA0B}\\InprocServer32") + ); + retVal = RegDeleteKey( + HKEY_CLASSES_ROOT, + TEXT("CLSID\\{C8DE4CDE-4554-4fe9-8688-A90D91EBCA0B}") + ); - return HRESULT_FROM_WIN32(retVal); + return HRESULT_FROM_WIN32(retVal); }