Skip to content

Commit

Permalink
[cleanup]: Run clang-format source files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed Aug 15, 2024
1 parent f167643 commit bbf2fe0
Show file tree
Hide file tree
Showing 90 changed files with 353 additions and 352 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 src/dedicatedserver/dedicatedserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include "defines.h"
#include "settings.h"
#include "utility/listhelpers.h"
#include "utility/string/toNumber.h"
#include "utility/os.h"
#include "utility/string/toNumber.h"

#include <algorithm>
#include <iostream>
Expand Down
62 changes: 31 additions & 31 deletions src/lib/SDLutility/partialsurface.h
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
/***************************************************************************
* Mechanized Assault and Exploration Reloaded Projectfile *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/

#ifndef SDLutility_partialsurfaceH
#define SDLutility_partialsurfaceH

#include <SDL.h>

struct sPartialSurface
{
SDL_Surface* surface = nullptr;
SDL_Rect rect{};
};

#endif
/***************************************************************************
* Mechanized Assault and Exploration Reloaded Projectfile *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/

#ifndef SDLutility_partialsurfaceH
#define SDLutility_partialsurfaceH

#include <SDL.h>

struct sPartialSurface
{
SDL_Surface* surface = nullptr;
SDL_Rect rect{};
};

#endif
12 changes: 6 additions & 6 deletions src/lib/SDLutility/sdlversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@

#include "sdlversion.h"

#include "utility/log.h"

#include <SDL.h>
#include <SDL_mixer.h>
#include <SDL_net.h>

#include "utility/log.h"

namespace
{
//--------------------------------------------------------------------------
std::string to_string(const SDL_version& version)
std::string to_string (const SDL_version& version)
{
return std::to_string (version.major) + "." + std::to_string (version.minor) + "." + std::to_string (version.patch);
}

//--------------------------------------------------------------------------
bool are_equal (const SDL_version& v1, const SDL_version& v2)
{
auto as_tuple = [](const auto& v) { return std::tuple (v.major, v.minor, v.patch); };
return as_tuple(v1) == as_tuple(v2);
auto as_tuple = [] (const auto& v) { return std::tuple (v.major, v.minor, v.patch); };
return as_tuple (v1) == as_tuple (v2);
}

//--------------------------------------------------------------------------
Expand Down Expand Up @@ -105,7 +105,7 @@ namespace
return version;
}

}
} // namespace

//------------------------------------------------------------------------------
void logSDLVersions()
Expand Down
2 changes: 1 addition & 1 deletion src/lib/SDLutility/sdlversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
***************************************************************************/

#ifndef SDLutility_sdlversionH
# define SDLutility_sdlversionH
#define SDLutility_sdlversionH

void logSDLVersions();

Expand Down
8 changes: 4 additions & 4 deletions src/lib/chatcommand/chatcommandarguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#ifndef chatcommand_chatcommandargumentsH
#define chatcommand_chatcommandargumentsH

#include "utility/string/toNumber.h"

#include <exception>
#include <iostream>
#include <limits>
Expand All @@ -29,8 +31,6 @@
#include <string>
#include <vector>

#include "utility/string/toNumber.h"

size_t getNextWordLength (std::string_view s, size_t position);

class cPlayer;
Expand Down Expand Up @@ -65,8 +65,8 @@ class cChatCommandArgumentInt
public:
using ValueType = T;

explicit cChatCommandArgumentInt (std::string&& name, bool isOptional = false, ValueType defaultValue = 0)
: isOptional (isOptional),
explicit cChatCommandArgumentInt (std::string&& name, bool isOptional = false, ValueType defaultValue = 0) :
isOptional (isOptional),
name (std::move (name)),
defaultValue (std::move (defaultValue))
{}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/chatcommand/chatcommandparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//------------------------------------------------------------------------------
void skipWhiteSpace (std::string_view command, size_t& position)
{
while (position < command.size() && std::isspace (static_cast<unsigned char>(command[position])))
while (position < command.size() && std::isspace (static_cast<unsigned char> (command[position])))
{
++position;
}
Expand Down
9 changes: 6 additions & 3 deletions src/lib/crashreporter/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ void CR_INIT_CRASHREPORTING();

#else

inline void CR_ENABLE_CRASH_RPT_CURRENT_THREAD() {}
inline void CR_EMULATE_CRASH() {}
inline void CR_INIT_CRASHREPORTING() {}
inline void CR_ENABLE_CRASH_RPT_CURRENT_THREAD()
{}
inline void CR_EMULATE_CRASH()
{}
inline void CR_INIT_CRASHREPORTING()
{}

#endif

Expand Down
Loading

0 comments on commit bbf2fe0

Please sign in to comment.