Skip to content

Commit

Permalink
[cleanup]: Run clang-format on resintaller files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed Aug 15, 2024
1 parent 9b38c48 commit 7d5a99f
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 40 deletions.
18 changes: 8 additions & 10 deletions resinstaller/src/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ void cImage::resampleFile()
int iMaxHotX = 0, iMaxHotY = 0, iMaxRight = 0, iMaxBottom = 0;
for (const auto& image : Images)
{
iMaxHotX = std::max(iMaxHotX, (int)image.sUHotX);
iMaxHotX = std::max (iMaxHotX, (int) image.sUHotX);
iMaxHotY = std::max (iMaxHotY, (int) image.sUHotY);
iMaxRight = std::max(iMaxRight, image.sWidth - image.sUHotX);
iMaxBottom = std::max(iMaxBottom, image.sHeight - image.sUHotY);
iMaxRight = std::max (iMaxRight, image.sWidth - image.sUHotX);
iMaxBottom = std::max (iMaxBottom, image.sHeight - image.sUHotY);
}
sWidth = iMaxHotX + iMaxRight;
sHeight = iMaxHotY + iMaxBottom;
Expand Down Expand Up @@ -220,7 +220,7 @@ bool cImage::decodeSimpleImage()

Images[0].data.resize (sLocWidth * sLocHeight);
SDL_RWread (res, Images[0].data.data(), sizeof (unsigned char), sLocWidth * sLocHeight);
Images[0].alpha.resize(sLocWidth * sLocHeight, 0);
Images[0].alpha.resize (sLocWidth * sLocHeight, 0);

return true;
}
Expand All @@ -242,7 +242,7 @@ bool cImage::decodeMultiShadow()
{
return false;
}
std::vector <Sint32> lBounds (sCount);
std::vector<Sint32> lBounds (sCount);
for (Sint32 iPicIndex = 0; iPicIndex < sCount; iPicIndex++)
{
SDL_RWseek (res, lPos + 2 + iPicIndex * 4, SEEK_SET);
Expand Down Expand Up @@ -288,7 +288,7 @@ bool cImage::decodeMultiShadow()
Images[iPicIndex].sUHotY = sLocHotY;

Images[iPicIndex].data.resize (sLocWidth * sLocHeight, 0);
Images[iPicIndex].alpha.resize(sLocWidth * sLocHeight, 255);
Images[iPicIndex].alpha.resize (sLocWidth * sLocHeight, 255);

if (lBegin + 8 + sLocHeight * 4 > lEnd)
{
Expand Down Expand Up @@ -397,7 +397,7 @@ bool cImage::decodeMultiImage()
Images[iPicIndex].sUHotY = sLocHotY;

Images[iPicIndex].data.resize (sLocWidth * sLocHeight, 0);
Images[iPicIndex].alpha.resize(sLocWidth * sLocHeight, 255);
Images[iPicIndex].alpha.resize (sLocWidth * sLocHeight, 255);

if (lBegin + 8 + sLocHeight * 4 > lEnd)
{
Expand Down Expand Up @@ -454,7 +454,6 @@ bool cImage::decodeMultiImage()
//------------------------------------------------------------------------------
bool cImage::decodeBigImage()
{

if (lLenght < 776)
{
return false;
Expand Down Expand Up @@ -650,7 +649,7 @@ void saveAllFiles()
Image.lLenght = (Sint32) SDL_ReadLE32 (res);

//copy color table
Image.palette.assign(std::begin(orig_palette), std::end(orig_palette));
Image.palette.assign (std::begin (orig_palette), std::end (orig_palette));

//extract image
Image.decodeFile();
Expand Down Expand Up @@ -722,7 +721,6 @@ void copyImageFromFLC (const std::filesystem::path& fileName, const std::filesys
//------------------------------------------------------------------------------
void resizeSurface (SDL_Surface*& surface, int x, int y, int h, int w)
{

if (surface->format->BitsPerPixel != 8)
return;

Expand Down
1 change: 0 additions & 1 deletion resinstaller/src/converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class cImage
short sHotY = 0;

public:

bool bDecoded = false;
char name[9]{};
Sint32 lPos = 0;
Expand Down
2 changes: 1 addition & 1 deletion resinstaller/src/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void copyFile (const std::filesystem::path& source, const std::filesystem::path&
auto lower_path = source.parent_path() / toLower (source.filename().string());
auto upper_path = source.parent_path() / toUpper (source.filename().string());

std::filesystem::create_directories(dest.parent_path());
std::filesystem::create_directories (dest.parent_path());
if (std::filesystem::exists (lower_path))
{
std::filesystem::copy_file (lower_path, dest, std::filesystem::copy_options::skip_existing);
Expand Down
2 changes: 1 addition & 1 deletion resinstaller/src/ogg_encode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace
{
constexpr auto READ = 1024;
constexpr auto VORBIS_QUALITY = 0.4f;
}
} // namespace

void encodeWAV (std::filesystem::path fileName, cWaveFile& waveFile)
{
Expand Down
2 changes: 1 addition & 1 deletion resinstaller/src/palette.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ constexpr sPixel orig_palette[] =
{
{0, 0, 0},
{255, 0, 0},
{0, 255, 0},
{0, 255, 0},
{0, 0, 255},
{255, 255, 0},
{255, 171, 0},
Expand Down
2 changes: 1 addition & 1 deletion resinstaller/src/pcx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include <SDL.h>
#include <algorithm>
#include <array>
#include <iterator>
#include <fstream>
#include <iterator>
#include <string>
#include <vector>

Expand Down
20 changes: 11 additions & 9 deletions resinstaller/src/resinstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#if MAC
# include "mac/sources/resinstallerGUI.h"

# include <thread>
#elif WIN32
# include <Shlobj.h>
Expand Down Expand Up @@ -2927,12 +2928,12 @@ static void installGfx()

// and now the ugly hud_stuff.pcx :|
#define COPY_GRAPHIC(name, _x, _y) \
surface = getImageFromRes (name); \
setColor (surface, backgroundIndex, 255, 0, 255); \
dst_rect.x = (_x); \
dst_rect.y = (_y); \
SDL_BlitSurface (surface, nullptr, output, &dst_rect); \
SDL_FreeSurface (surface);
surface = getImageFromRes (name); \
setColor (surface, backgroundIndex, 255, 0, 255); \
dst_rect.x = (_x); \
dst_rect.y = (_y); \
SDL_BlitSurface (surface, nullptr, output, &dst_rect); \
SDL_FreeSurface (surface);

try
{
Expand Down Expand Up @@ -4402,7 +4403,7 @@ static std::filesystem::path getVoicePathFromUser()
}
// ask the user, which language to install
#if MAC
switch (askForLanguage(bGerman, bItalian, bFrench))
switch (askForLanguage (bGerman, bItalian, bFrench))
{
default: // default - but should not happen
case 0: return sMAXPath; // english
Expand Down Expand Up @@ -4468,7 +4469,8 @@ static std::filesystem::path getVoicePathFromUser()
auto it = std::find (vectorLanguages.begin(), vectorLanguages.end(), input);
if (it != vectorLanguages.end())
{
if (bUppercase) {
if (bUppercase)
{
transform (input.begin(), input.end(), input.begin(), ::toupper);
}
return sMAXPath / input;
Expand Down Expand Up @@ -4577,7 +4579,7 @@ int main (int argc, char* argv[])
#if MAC
// on MAC the installation has to happen in a separate thread to allow displaying and updating a progress window
gFinishedInstalling = false;
std::thread installThread([&]() { installEverything (sVoicePath); });
std::thread installThread ([&]() { installEverything (sVoicePath); });
displayProgressWindow (gFinishedInstalling);
installThread.join();
#else
Expand Down
28 changes: 14 additions & 14 deletions resinstaller/src/resinstaller.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ class InstallException
// makes all necessary actions after a successful
// or unsuccessful attempt to install a file
#define END_INSTALL_FILE(file) \
catch (const InstallException& e) \
{ \
writeLog ("Error while installing file '" + std::filesystem::path (file).u8string() + "'" + TEXT_FILE_LF + e.message); \
iErrors++; \
wasError = true; \
} \
catch (const std::exception& e) \
{ \
writeLog ("Error while installing file '" + std::filesystem::path (file).u8string() + "'" + TEXT_FILE_LF + e.what() + TEXT_FILE_LF); \
iErrors++; \
wasError = true; \
} \
iInstalledFiles++; \
updateProgressbar();
catch (const InstallException& e) \
{ \
writeLog ("Error while installing file '" + std::filesystem::path (file).u8string() + "'" + TEXT_FILE_LF + e.message); \
iErrors++; \
wasError = true; \
} \
catch (const std::exception& e) \
{ \
writeLog ("Error while installing file '" + std::filesystem::path (file).u8string() + "'" + TEXT_FILE_LF + e.what() + TEXT_FILE_LF); \
iErrors++; \
wasError = true; \
} \
iInstalledFiles++; \
updateProgressbar();

#endif // ResinstallerH
2 changes: 1 addition & 1 deletion resinstaller/src/wave.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class cWaveFile
{
public:
cWaveFile() = default;
cWaveFile(const cWaveFile&) = delete;
cWaveFile (const cWaveFile&) = delete;
~cWaveFile();
cWaveFile& operator= (const cWaveFile&) = delete;

Expand Down
2 changes: 1 addition & 1 deletion tests/tests/game/resourcesdistributor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ OStream& operator<< (OStream& os, const sMiningResource& res)
}

//------------------------------------------------------------------------------
bool operator<(eResourceType lhs, eResourceType rhs)
bool operator< (eResourceType lhs, eResourceType rhs)
{
return int (lhs) < int (rhs);
}
Expand Down

0 comments on commit 7d5a99f

Please sign in to comment.