From a2656637e4648630c3b67d22400f91e7858d7199 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 31 Mar 2021 00:51:51 +0200 Subject: [PATCH] :art: Format source --- DiabloUI/diabloui.h | 10 +- Source/engine.h | 28 +++- Source/init.cpp | 6 +- Source/lighting.cpp | 2 +- Source/mpqapi.h | 1 - Source/pfile.cpp | 2 +- Source/render.cpp | 7 +- SourceS/file_util.h | 5 +- SourceS/paths.cpp | 51 ++++---- SourceS/sdl_compat.h | 8 +- SourceS/storm_full.h | 1 - SourceT/appfat_test.cpp | 25 ++-- SourceT/automap_test.cpp | 33 +++-- SourceT/codec_test.cpp | 6 +- SourceT/control_test.cpp | 6 +- SourceT/cursor_test.cpp | 3 +- SourceT/dead_test.cpp | 6 +- SourceT/doom_test.cpp | 6 +- SourceT/drlg_l1_test.cpp | 10 +- SourceT/drlg_l2_test.cpp | 3 +- SourceT/drlg_l3_test.cpp | 9 +- SourceT/drlg_l4_test.cpp | 6 +- SourceT/pack_test.cpp | 131 +++++++++---------- SourceT/player_test.cpp | 104 +++++++-------- SourceX/DiabloUI/diabloui.cpp | 3 +- SourceX/DiabloUI/fonts.cpp | 14 +- SourceX/DiabloUI/scrollbar.cpp | 8 +- SourceX/DiabloUI/selconn.h | 2 +- SourceX/DiabloUI/selgame.h | 2 +- SourceX/DiabloUI/selhero.cpp | 3 +- SourceX/DiabloUI/selok.h | 2 +- SourceX/DiabloUI/selyesno.h | 2 +- SourceX/DiabloUI/support_lines.cpp | 38 +++--- SourceX/controls/axis_direction.cpp | 78 +++++------ SourceX/controls/devices/game_controller.cpp | 14 +- SourceX/controls/devices/joystick.cpp | 40 +++--- SourceX/controls/game_controls.cpp | 64 +++++---- SourceX/controls/modifier_hints.cpp | 3 +- SourceX/controls/plrctrls.cpp | 6 +- SourceX/controls/remap_keyboard.h | 2 +- SourceX/dvlnet/frame_queue.cpp | 10 +- SourceX/dvlnet/loopback.cpp | 6 +- SourceX/dvlnet/loopback.h | 6 +- SourceX/dvlnet/tcp_server.cpp | 2 +- SourceX/dx.cpp | 12 +- SourceX/main.cpp | 4 +- SourceX/platform/ctr/keyboard.cpp | 5 +- SourceX/platform/ctr/keyboard.h | 2 +- SourceX/platform/ctr/system.cpp | 36 ++--- SourceX/platform/switch/docking.cpp | 16 +-- SourceX/soundsample.cpp | 2 +- SourceX/thread.cpp | 2 +- 52 files changed, 454 insertions(+), 399 deletions(-) diff --git a/DiabloUI/diabloui.h b/DiabloUI/diabloui.h index 4b0a53c3f..b4872a7e0 100644 --- a/DiabloUI/diabloui.h +++ b/DiabloUI/diabloui.h @@ -9,12 +9,12 @@ void UiTitleDialog(); void UiSetSpawned(BOOL bSpawned); void UiInitialize(); BOOL UiValidPlayerName(const char *name); /* check */ -void UiSelHeroMultDialog(BOOL(*fninfo)(BOOL(*fninfofunc)(_uiheroinfo *)), BOOL(*fncreate)(_uiheroinfo *), BOOL(*fnremove)(_uiheroinfo *), void(*fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, BOOL *hero_is_created, char (* name)[16]); -void UiSelHeroSingDialog(BOOL(*fninfo)(BOOL(*fninfofunc)(_uiheroinfo *)), BOOL(*fncreate)(_uiheroinfo *), BOOL(*fnremove)(_uiheroinfo *), void(*fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, char (* name)[16], int *difficulty); +void UiSelHeroMultDialog(BOOL (*fninfo)(BOOL (*fninfofunc)(_uiheroinfo *)), BOOL (*fncreate)(_uiheroinfo *), BOOL (*fnremove)(_uiheroinfo *), void (*fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, BOOL *hero_is_created, char (*name)[16]); +void UiSelHeroSingDialog(BOOL (*fninfo)(BOOL (*fninfofunc)(_uiheroinfo *)), BOOL (*fncreate)(_uiheroinfo *), BOOL (*fnremove)(_uiheroinfo *), void (*fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, char (*name)[16], int *difficulty); BOOL UiCreditsDialog(); BOOL UiSupportDialog(); -BOOL UiMainMenuDialog(const char *name, int *pdwResult, void(*fnSound)(const char *file), int attractTimeOut); -BOOL UiProgressDialog(const char *msg, int enable, int(*fnfunc)(), int rate); +BOOL UiMainMenuDialog(const char *name, int *pdwResult, void (*fnSound)(const char *file), int attractTimeOut); +BOOL UiProgressDialog(const char *msg, int enable, int (*fnfunc)(), int rate); const char **UiProfileGetString(); void UiProfileCallback(); void UiProfileDraw(); @@ -29,6 +29,6 @@ int UiSelectGame(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_in int UiSelectProvider(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, _SNETVERSIONDATA *file_info, int *type); BOOL UiCreatePlayerDescription(_uiheroinfo *info, Uint32 mode, char (*desc)[128]); void UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, Uint32 type); -} +} // namespace dvl #endif /* __DIABLOUI_H__ */ diff --git a/Source/engine.h b/Source/engine.h index ba3143b77..d3f6cd7d0 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -105,27 +105,43 @@ struct CelOutputBuffer { * * Only use this if the buffer owns its data. */ - void Free() { + void Free() + { SDL_FreeSurface(this->surface); this->surface = NULL; } - int w() const { return region.w; } - int h() const { return region.h; } + int w() const + { + return region.w; + } + int h() const + { + return region.h; + } BYTE *at(int x, int y) const { return static_cast(surface->pixels) + region.x + x + surface->pitch * (region.y + y); } - BYTE *begin() const { return at(0, 0); } - BYTE *end() const { return at(0, region.h); } + BYTE *begin() const + { + return at(0, 0); + } + BYTE *end() const + { + return at(0, region.h); + } /** * @brief Line width of the raw underlying byte buffer. * May be wider than its logical width (for power-of-2 alignment). */ - int pitch() { return surface->pitch; } + int pitch() + { + return surface->pitch; + } bool in_bounds(Sint16 x, Sint16 y) const { diff --git a/Source/init.cpp b/Source/init.cpp index 548244d2d..6ce8dd338 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -150,7 +150,8 @@ void init_archives() paths.reserve(5); paths.push_back(GetBasePath()); paths.push_back(GetPrefPath()); - if (paths[0] == paths[1]) paths.pop_back(); + if (paths[0] == paths[1]) + paths.pop_back(); #ifdef __linux__ paths.push_back("/usr/share/diasurgical/devilutionx/"); @@ -193,8 +194,7 @@ void init_archives() hfopt1_mpq = init_test_access(paths, "hfopt1.mpq", "DiabloInstall", 8600, FS_PC); hfopt2_mpq = init_test_access(paths, "hfopt2.mpq", "DiabloInstall", 8610, FS_PC); - if (gbIsHellfire && (hfmonk_mpq == NULL || hfmusic_mpq == NULL || hfvoice_mpq == NULL)) - { + if (gbIsHellfire && (hfmonk_mpq == NULL || hfmusic_mpq == NULL || hfvoice_mpq == NULL)) { UiErrorOkDialog("Some Hellfire MPQs are missing", "Not all Hellfire MPQs were found.\nPlease copy all the hf*.mpq files."); app_fatal(NULL); } diff --git a/Source/lighting.cpp b/Source/lighting.cpp index 6b6f0417b..014b012ff 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -1175,7 +1175,7 @@ void InitVision() int AddVision(int x, int y, int r, BOOL mine) { - int vid = -1; // BUGFIX: if numvision >= MAXVISION behavior is undefined (fixed) + int vid = -1; // BUGFIX: if numvision >= MAXVISION behavior is undefined (fixed) if (numvision < MAXVISION) { VisionList[numvision]._lx = x; diff --git a/Source/mpqapi.h b/Source/mpqapi.h index 76b64a4f6..5f6048734 100644 --- a/Source/mpqapi.h +++ b/Source/mpqapi.h @@ -40,7 +40,6 @@ typedef struct _BLOCKENTRY { Uint32 flags; } _BLOCKENTRY; - void mpqapi_remove_hash_entry(const char *pszName); void mpqapi_remove_hash_entries(BOOL (*fnGetName)(DWORD, char *)); BOOL mpqapi_write_file(const char *pszName, const BYTE *pbData, DWORD dwLen); diff --git a/Source/pfile.cpp b/Source/pfile.cpp index 74027d930..25fe75721 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -184,7 +184,7 @@ void pfile_write_hero() if (pfile_open_archive(save_num)) { PackPlayer(&pkplr, myplr, !gbIsMultiplayer); pfile_encode_hero(&pkplr); - if(!gbVanilla) + if (!gbVanilla) SaveHotkeys(); pfile_flush(!gbIsMultiplayer, save_num); } diff --git a/Source/render.cpp b/Source/render.cpp index 3e207dce1..30df94d12 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -395,8 +395,8 @@ inline void DoRenderLine(BYTE *dst, BYTE *src, int n, BYTE *tbl, DWORD mask) assert(n != 0 && n <= sizeof(DWORD) * CHAR_BIT); mask &= DWORD(-1) << ((sizeof(DWORD) * CHAR_BIT) - n); - if (sgOptions.Graphics.bBlendedTransparancy) { // Blended transparancy - if (light_table_index == lightmax) { // Complete darkness + if (sgOptions.Graphics.bBlendedTransparancy) { // Blended transparancy + if (light_table_index == lightmax) { // Complete darkness for (int i = 0; i < n; i++, mask <<= 1) { if (mask & 0x80000000) dst[i] = 0; @@ -431,7 +431,8 @@ inline void DoRenderLine(BYTE *dst, BYTE *src, int n, BYTE *tbl, DWORD mask) } DVL_ATTRIBUTE_ALWAYS_INLINE -inline void RenderLine(BYTE *dst_begin, BYTE *dst_end, BYTE **dst, BYTE **src, int n, BYTE *tbl, DWORD mask) { +inline void RenderLine(BYTE *dst_begin, BYTE *dst_end, BYTE **dst, BYTE **src, int n, BYTE *tbl, DWORD mask) +{ #ifdef NO_OVERDRAW if (*dst >= dst_begin && *dst <= dst_end) #endif diff --git a/SourceS/file_util.h b/SourceS/file_util.h index 56def8628..88851e45d 100644 --- a/SourceS/file_util.h +++ b/SourceS/file_util.h @@ -32,7 +32,8 @@ inline bool FileExists(const char *path) return ::access(path, F_OK) == 0; #else FILE *file = std::fopen(path, "rb"); - if (file == NULL) return false; + if (file == NULL) + return false; std::fclose(file); return true; #endif @@ -43,7 +44,7 @@ inline bool GetFileSize(const char *path, std::uintmax_t *size) #if defined(_WIN64) || defined(_WIN32) WIN32_FILE_ATTRIBUTE_DATA attr; int path_utf16_size = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0); - wchar_t* path_utf16 = new wchar_t[path_utf16_size]; + wchar_t *path_utf16 = new wchar_t[path_utf16_size]; if (MultiByteToWideChar(CP_UTF8, 0, path, -1, path_utf16, path_utf16_size) != path_utf16_size) { delete[] path_utf16; return false; diff --git a/SourceS/paths.cpp b/SourceS/paths.cpp index 1d7f6c9c4..dd60fcb52 100644 --- a/SourceS/paths.cpp +++ b/SourceS/paths.cpp @@ -24,42 +24,47 @@ std::string *configPath = NULL; std::string *ttfPath = NULL; std::string *ttfName = NULL; -void AddTrailingSlash(std::string *path) { +void AddTrailingSlash(std::string *path) +{ #ifdef _WIN32 - if (!path->empty() && path->back() != '\\') - *path += '\\'; + if (!path->empty() && path->back() != '\\') + *path += '\\'; #else - if (!path->empty() && path->back() != '/') - *path += '/'; + if (!path->empty() && path->back() != '/') + *path += '/'; #endif } -std::string *FromSDL(char *s) { - std::string *result = new std::string(s != NULL ? s : ""); - if (s != NULL) { - SDL_free(s); - } else { - SDL_Log("%s", SDL_GetError()); - SDL_ClearError(); - } - return result; +std::string *FromSDL(char *s) +{ + std::string *result = new std::string(s != NULL ? s : ""); + if (s != NULL) { + SDL_free(s); + } else { + SDL_Log("%s", SDL_GetError()); + SDL_ClearError(); + } + return result; } } // namespace const std::string &GetBasePath() { -#ifdef __vita__ - if (basePath == NULL) basePath = new std::string(GetPrefPath()); -#else - if (basePath == NULL) basePath = FromSDL(SDL_GetBasePath()); -#endif +#ifdef __vita__ + if (basePath == NULL) + basePath = new std::string(GetPrefPath()); +#else + if (basePath == NULL) + basePath = FromSDL(SDL_GetBasePath()); +#endif return *basePath; } const std::string &GetPrefPath() { - if (prefPath == NULL) prefPath = FromSDL(SDL_GetPrefPath("diasurgical", "devilution")); + if (prefPath == NULL) + prefPath = FromSDL(SDL_GetPrefPath("diasurgical", "devilution")); return *prefPath; } @@ -86,14 +91,16 @@ const std::string &GetTtfName() void SetBasePath(const char *path) { - if (basePath == NULL) basePath = new std::string; + if (basePath == NULL) + basePath = new std::string; *basePath = path; AddTrailingSlash(basePath); } void SetPrefPath(const char *path) { - if (prefPath == NULL) prefPath = new std::string; + if (prefPath == NULL) + prefPath = new std::string; *prefPath = path; AddTrailingSlash(prefPath); } diff --git a/SourceS/sdl_compat.h b/SourceS/sdl_compat.h index f4b63c33d..5dfc3d05f 100644 --- a/SourceS/sdl_compat.h +++ b/SourceS/sdl_compat.h @@ -73,10 +73,10 @@ inline int SDLC_SetSurfaceAndPaletteColors(SDL_Surface *surface, SDL_Palette *pa if (colors != (palette->colors + firstcolor)) SDL_memcpy(palette->colors + firstcolor, colors, ncolors * sizeof(*colors)); - #if SDL1_VIDEO_MODE_BPP == 8 - // When the video surface is 8bit, we need to set the output pallet as well. - SDL_SetColors(SDL_GetVideoSurface(), colors, firstcolor, ncolors); - #endif +#if SDL1_VIDEO_MODE_BPP == 8 + // When the video surface is 8bit, we need to set the output pallet as well. + SDL_SetColors(SDL_GetVideoSurface(), colors, firstcolor, ncolors); +#endif // In SDL1, the surface always has its own distinct palette, so we need to // update it as well. return SDL_SetPalette(surface, SDL_LOGPAL, colors, firstcolor, ncolors) - 1; diff --git a/SourceS/storm_full.h b/SourceS/storm_full.h index cc9db16cd..aecc541a8 100644 --- a/SourceS/storm_full.h +++ b/SourceS/storm_full.h @@ -4,6 +4,5 @@ namespace dvl { extern "C" { extern DWORD nLastError; - } } // namespace dvl diff --git a/SourceT/appfat_test.cpp b/SourceT/appfat_test.cpp index 860e8dbb8..a49af25d2 100644 --- a/SourceT/appfat_test.cpp +++ b/SourceT/appfat_test.cpp @@ -1,22 +1,27 @@ #include #include "all.h" -TEST(Appfat, app_fatal) { - EXPECT_EXIT(dvl::app_fatal("test"), ::testing::ExitedWithCode(1), "test"); +TEST(Appfat, app_fatal) +{ + EXPECT_EXIT(dvl::app_fatal("test"), ::testing::ExitedWithCode(1), "test"); } -TEST(Appfat, ErrDlg) { - EXPECT_EXIT(dvl::ErrDlg("Title", "Unknown error", "appfat.cpp", 7), ::testing::ExitedWithCode(1), "Unknown error\n\nThe error occurred at: appfat.cpp line 7"); +TEST(Appfat, ErrDlg) +{ + EXPECT_EXIT(dvl::ErrDlg("Title", "Unknown error", "appfat.cpp", 7), ::testing::ExitedWithCode(1), "Unknown error\n\nThe error occurred at: appfat.cpp line 7"); } -TEST(Appfat, FileErrDlg) { - EXPECT_EXIT(dvl::FileErrDlg("devilution/image.cl2"), ::testing::ExitedWithCode(1), "devilution/image.cl2"); +TEST(Appfat, FileErrDlg) +{ + EXPECT_EXIT(dvl::FileErrDlg("devilution/image.cl2"), ::testing::ExitedWithCode(1), "devilution/image.cl2"); } -TEST(Appfat, InsertCDDlg) { - EXPECT_EXIT(dvl::InsertCDDlg(), ::testing::ExitedWithCode(1), "diabdat.mpq"); +TEST(Appfat, InsertCDDlg) +{ + EXPECT_EXIT(dvl::InsertCDDlg(), ::testing::ExitedWithCode(1), "diabdat.mpq"); } -TEST(Appfat, DirErrorDlg) { - EXPECT_EXIT(dvl::DirErrorDlg("/"), ::testing::ExitedWithCode(1), "Unable to write to location:\n/"); +TEST(Appfat, DirErrorDlg) +{ + EXPECT_EXIT(dvl::DirErrorDlg("/"), ::testing::ExitedWithCode(1), "Unable to write to location:\n/"); } diff --git a/SourceT/automap_test.cpp b/SourceT/automap_test.cpp index afa5f6233..c1a25e880 100644 --- a/SourceT/automap_test.cpp +++ b/SourceT/automap_test.cpp @@ -1,7 +1,8 @@ #include #include "all.h" -TEST(Automap, InitAutomap) { +TEST(Automap, InitAutomap) +{ dvl::InitAutomapOnce(); EXPECT_EQ(dvl::automapflag, false); EXPECT_EQ(dvl::AutoMapScale, 50); @@ -12,14 +13,16 @@ TEST(Automap, InitAutomap) { EXPECT_EQ(dvl::AmLine4, 2); } -TEST(Automap, StartAutomap) { +TEST(Automap, StartAutomap) +{ dvl::StartAutomap(); EXPECT_EQ(dvl::AutoMapXOfs, 0); EXPECT_EQ(dvl::AutoMapYOfs, 0); EXPECT_EQ(dvl::automapflag, true); } -TEST(Automap, AutomapUp) { +TEST(Automap, AutomapUp) +{ dvl::AutoMapXOfs = 1; dvl::AutoMapYOfs = 1; dvl::AutomapUp(); @@ -27,7 +30,8 @@ TEST(Automap, AutomapUp) { EXPECT_EQ(dvl::AutoMapYOfs, 0); } -TEST(Automap, AutomapDown) { +TEST(Automap, AutomapDown) +{ dvl::AutoMapXOfs = 1; dvl::AutoMapYOfs = 1; dvl::AutomapDown(); @@ -35,7 +39,8 @@ TEST(Automap, AutomapDown) { EXPECT_EQ(dvl::AutoMapYOfs, 2); } -TEST(Automap, AutomapLeft) { +TEST(Automap, AutomapLeft) +{ dvl::AutoMapXOfs = 1; dvl::AutoMapYOfs = 1; dvl::AutomapLeft(); @@ -43,7 +48,8 @@ TEST(Automap, AutomapLeft) { EXPECT_EQ(dvl::AutoMapYOfs, 2); } -TEST(Automap, AutomapRight) { +TEST(Automap, AutomapRight) +{ dvl::AutoMapXOfs = 1; dvl::AutoMapYOfs = 1; dvl::AutomapRight(); @@ -51,7 +57,8 @@ TEST(Automap, AutomapRight) { EXPECT_EQ(dvl::AutoMapYOfs, 0); } -TEST(Automap, AutomapZoomIn) { +TEST(Automap, AutomapZoomIn) +{ dvl::AutoMapScale = 50; dvl::AutomapZoomIn(); EXPECT_EQ(dvl::AutoMapScale, 55); @@ -62,7 +69,8 @@ TEST(Automap, AutomapZoomIn) { EXPECT_EQ(dvl::AmLine4, 2); } -TEST(Automap, AutomapZoomIn_Max) { +TEST(Automap, AutomapZoomIn_Max) +{ dvl::AutoMapScale = 195; dvl::AutomapZoomIn(); dvl::AutomapZoomIn(); @@ -74,7 +82,8 @@ TEST(Automap, AutomapZoomIn_Max) { EXPECT_EQ(dvl::AmLine4, 8); } -TEST(Automap, AutomapZoomOut) { +TEST(Automap, AutomapZoomOut) +{ dvl::AutoMapScale = 200; dvl::AutomapZoomOut(); EXPECT_EQ(dvl::AutoMapScale, 195); @@ -85,7 +94,8 @@ TEST(Automap, AutomapZoomOut) { EXPECT_EQ(dvl::AmLine4, 7); } -TEST(Automap, AutomapZoomOut_Min) { +TEST(Automap, AutomapZoomOut_Min) +{ dvl::AutoMapScale = 55; dvl::AutomapZoomOut(); dvl::AutomapZoomOut(); @@ -97,7 +107,8 @@ TEST(Automap, AutomapZoomOut_Min) { EXPECT_EQ(dvl::AmLine4, 2); } -TEST(Automap, AutomapZoomReset) { +TEST(Automap, AutomapZoomReset) +{ dvl::AutoMapScale = 50; dvl::AutoMapXOfs = 1; dvl::AutoMapYOfs = 1; diff --git a/SourceT/codec_test.cpp b/SourceT/codec_test.cpp index d0255dc6d..603954441 100644 --- a/SourceT/codec_test.cpp +++ b/SourceT/codec_test.cpp @@ -1,10 +1,12 @@ #include #include "all.h" -TEST(Codec, codec_get_encoded_len) { +TEST(Codec, codec_get_encoded_len) +{ EXPECT_EQ(dvl::codec_get_encoded_len(50), 72); } -TEST(Codec, codec_get_encoded_len_eq) { +TEST(Codec, codec_get_encoded_len_eq) +{ EXPECT_EQ(dvl::codec_get_encoded_len(128), 136); } diff --git a/SourceT/control_test.cpp b/SourceT/control_test.cpp index b403f73a0..7d979b73a 100644 --- a/SourceT/control_test.cpp +++ b/SourceT/control_test.cpp @@ -1,7 +1,8 @@ #include #include "all.h" -TEST(Control, SetSpell) { +TEST(Control, SetSpell) +{ dvl::pnumlines = 1; dvl::pinfoflag = true; dvl::pSpell = dvl::SPL_FIREBOLT; @@ -15,7 +16,8 @@ TEST(Control, SetSpell) { EXPECT_EQ(dvl::force_redraw, 255); } -TEST(Control, ClearPanel) { +TEST(Control, ClearPanel) +{ dvl::pnumlines = 1; dvl::pinfoflag = true; dvl::ClearPanel(); diff --git a/SourceT/cursor_test.cpp b/SourceT/cursor_test.cpp index 43e8eae4c..60df03ab7 100644 --- a/SourceT/cursor_test.cpp +++ b/SourceT/cursor_test.cpp @@ -1,7 +1,8 @@ #include #include "all.h" -TEST(Cursor, SetCursor) { +TEST(Cursor, SetCursor) +{ int i = dvl::ICURS_SPIKED_CLUB + dvl::CURSOR_FIRSTITEM; dvl::SetCursor_(i); EXPECT_EQ(dvl::pcurs, i); diff --git a/SourceT/dead_test.cpp b/SourceT/dead_test.cpp index 8adb4fc49..965f7e762 100644 --- a/SourceT/dead_test.cpp +++ b/SourceT/dead_test.cpp @@ -1,12 +1,14 @@ #include #include "all.h" -TEST(Dead, AddDead) { +TEST(Dead, AddDead) +{ dvl::AddDead(21, 48, 8, dvl::DIR_W); EXPECT_EQ(dvl::dDead[21][48], 8 + (dvl::DIR_W << 5)); } -TEST(Dead, AddDead_OOB) { +TEST(Dead, AddDead_OOB) +{ dvl::AddDead(21, 48, MAXDEAD + 1, dvl::DIR_W); EXPECT_EQ(dvl::dDead[21][48], 0 + (dvl::DIR_W << 5)); } diff --git a/SourceT/doom_test.cpp b/SourceT/doom_test.cpp index ff410215e..1454bc92c 100644 --- a/SourceT/doom_test.cpp +++ b/SourceT/doom_test.cpp @@ -1,12 +1,14 @@ #include #include "all.h" -TEST(Doom, doom_get_frame_from_time) { +TEST(Doom, doom_get_frame_from_time) +{ dvl::DoomQuestState = 1200 * 8 + 548; EXPECT_EQ(dvl::doom_get_frame_from_time(), 8); } -TEST(Doom, doom_get_frame_from_time_max) { +TEST(Doom, doom_get_frame_from_time_max) +{ dvl::DoomQuestState = 1200 * 30 + 1; EXPECT_EQ(dvl::doom_get_frame_from_time(), 31); } diff --git a/SourceT/drlg_l1_test.cpp b/SourceT/drlg_l1_test.cpp index 9ee651554..56493753b 100644 --- a/SourceT/drlg_l1_test.cpp +++ b/SourceT/drlg_l1_test.cpp @@ -1,23 +1,25 @@ #include #include "all.h" -TEST(Drlg_l1, DRLG_Init_Globals_4flag) { +TEST(Drlg_l1, DRLG_Init_Globals_4flag) +{ dvl::lightflag = false; dvl::light4flag = true; dvl::DRLG_Init_Globals(); EXPECT_EQ(dvl::dLight[0][0], 3); } -TEST(Drlg_l1, DRLG_Init_Globals_noflag) { +TEST(Drlg_l1, DRLG_Init_Globals_noflag) +{ dvl::lightflag = false; dvl::light4flag = false; dvl::DRLG_Init_Globals(); EXPECT_EQ(dvl::dLight[0][0], 15); } -TEST(Drlg_l1, DRLG_Init_Globals) { +TEST(Drlg_l1, DRLG_Init_Globals) +{ dvl::lightflag = true; dvl::DRLG_Init_Globals(); EXPECT_EQ(dvl::dLight[0][0], 0); } - diff --git a/SourceT/drlg_l2_test.cpp b/SourceT/drlg_l2_test.cpp index 856e6e21d..2efe30df6 100644 --- a/SourceT/drlg_l2_test.cpp +++ b/SourceT/drlg_l2_test.cpp @@ -1,7 +1,8 @@ #include #include "all.h" -TEST(Drlg_l2, InitDungeon) { +TEST(Drlg_l2, InitDungeon) +{ dvl::InitDungeon(); EXPECT_EQ(dvl::predungeon[0][0], 32); EXPECT_EQ(dvl::dflags[0][0], 0); diff --git a/SourceT/drlg_l3_test.cpp b/SourceT/drlg_l3_test.cpp index 125e336a0..ee1f5f060 100644 --- a/SourceT/drlg_l3_test.cpp +++ b/SourceT/drlg_l3_test.cpp @@ -1,7 +1,8 @@ #include #include "all.h" -TEST(Drlg_l3, AddFenceDoors_x) { +TEST(Drlg_l3, AddFenceDoors_x) +{ memset(dvl::dungeon, 0, sizeof(dvl::dungeon)); dvl::dungeon[5][5] = 7; dvl::dungeon[5 - 1][5] = 130; @@ -10,7 +11,8 @@ TEST(Drlg_l3, AddFenceDoors_x) { EXPECT_EQ(dvl::dungeon[5][5], 146); } -TEST(Drlg_l3, AddFenceDoors_y) { +TEST(Drlg_l3, AddFenceDoors_y) +{ memset(dvl::dungeon, 0, sizeof(dvl::dungeon)); dvl::dungeon[5][5] = 7; dvl::dungeon[5][5 - 1] = 130; @@ -19,7 +21,8 @@ TEST(Drlg_l3, AddFenceDoors_y) { EXPECT_EQ(dvl::dungeon[5][5], 147); } -TEST(Drlg_l3, AddFenceDoors_no) { +TEST(Drlg_l3, AddFenceDoors_no) +{ memset(dvl::dungeon, 0, sizeof(dvl::dungeon)); dvl::dungeon[5][5] = 7; dvl::dungeon[5 - 1][5] = 130; diff --git a/SourceT/drlg_l4_test.cpp b/SourceT/drlg_l4_test.cpp index 067bf0699..b452160af 100644 --- a/SourceT/drlg_l4_test.cpp +++ b/SourceT/drlg_l4_test.cpp @@ -1,14 +1,16 @@ #include #include "all.h" -TEST(Drlg_l4, IsDURWall) { +TEST(Drlg_l4, IsDURWall) +{ EXPECT_EQ(dvl::IsDURWall(25), true); EXPECT_EQ(dvl::IsDURWall(28), true); EXPECT_EQ(dvl::IsDURWall(23), true); EXPECT_EQ(dvl::IsDURWall(20), false); } -TEST(Drlg_l4, IsDLLWall) { +TEST(Drlg_l4, IsDLLWall) +{ EXPECT_EQ(dvl::IsDLLWall(27), true); EXPECT_EQ(dvl::IsDLLWall(26), true); EXPECT_EQ(dvl::IsDLLWall(22), true); diff --git a/SourceT/pack_test.cpp b/SourceT/pack_test.cpp index 311c5d47b..a81802469 100644 --- a/SourceT/pack_test.cpp +++ b/SourceT/pack_test.cpp @@ -61,51 +61,50 @@ typedef struct TestItemStruct { static void CompareItems(const dvl::ItemStruct *item1, const TestItemStruct *item2) { - ASSERT_STREQ(item1->_iIName, item2->_iIName); - ASSERT_EQ(item1->_itype, item2->_itype); - ASSERT_EQ(item1->_iClass, item2->_iClass); - ASSERT_EQ(item1->_iCurs, item2->_iCurs); - ASSERT_EQ(item1->_iIvalue, item2->_iIvalue); - ASSERT_EQ(item1->_iMinDam, item2->_iMinDam); - ASSERT_EQ(item1->_iMaxDam, item2->_iMaxDam); - ASSERT_EQ(item1->_iAC, item2->_iAC); - ASSERT_EQ(item1->_iFlags, item2->_iFlags); - ASSERT_EQ(item1->_iMiscId, item2->_iMiscId); - ASSERT_EQ(item1->_iSpell, item2->_iSpell); - ASSERT_EQ(item1->_iCharges, item2->_iCharges); - ASSERT_EQ(item1->_iMaxCharges, item2->_iMaxCharges); - ASSERT_EQ(item1->_iDurability, item2->_iDurability); - ASSERT_EQ(item1->_iMaxDur, item2->_iMaxDur); - ASSERT_EQ(item1->_iPLDam, item2->_iPLDam); - ASSERT_EQ(item1->_iPLToHit, item2->_iPLToHit); - ASSERT_EQ(item1->_iPLAC, item2->_iPLAC); - ASSERT_EQ(item1->_iPLStr, item2->_iPLStr); - ASSERT_EQ(item1->_iPLMag, item2->_iPLMag); - ASSERT_EQ(item1->_iPLDex, item2->_iPLDex); - ASSERT_EQ(item1->_iPLVit, item2->_iPLVit); - ASSERT_EQ(item1->_iPLFR, item2->_iPLFR); - ASSERT_EQ(item1->_iPLLR, item2->_iPLLR); - ASSERT_EQ(item1->_iPLMR, item2->_iPLMR); - ASSERT_EQ(item1->_iPLMana, item2->_iPLMana); - ASSERT_EQ(item1->_iPLHP, item2->_iPLHP); - ASSERT_EQ(item1->_iPLDamMod, item2->_iPLDamMod); - ASSERT_EQ(item1->_iPLGetHit, item2->_iPLGetHit); - ASSERT_EQ(item1->_iPLLight, item2->_iPLLight); - ASSERT_EQ(item1->_iSplLvlAdd, item2->_iSplLvlAdd); - ASSERT_EQ(item1->_iUid, item2->_iUid); - ASSERT_EQ(item1->_iFMinDam, item2->_iFMinDam); - ASSERT_EQ(item1->_iFMaxDam, item2->_iFMaxDam); - ASSERT_EQ(item1->_iLMinDam, item2->_iLMinDam); - ASSERT_EQ(item1->_iLMaxDam, item2->_iLMaxDam); - ASSERT_EQ(item1->_iPrePower, item2->_iPrePower); - ASSERT_EQ(item1->_iSufPower, item2->_iSufPower); - ASSERT_EQ(item1->_iMinStr, item2->_iMinStr); - ASSERT_EQ(item1->_iMinMag, item2->_iMinMag); - ASSERT_EQ(item1->_iMinDex, item2->_iMinDex); - ASSERT_EQ(item1->IDidx, item2->IDidx); + ASSERT_STREQ(item1->_iIName, item2->_iIName); + ASSERT_EQ(item1->_itype, item2->_itype); + ASSERT_EQ(item1->_iClass, item2->_iClass); + ASSERT_EQ(item1->_iCurs, item2->_iCurs); + ASSERT_EQ(item1->_iIvalue, item2->_iIvalue); + ASSERT_EQ(item1->_iMinDam, item2->_iMinDam); + ASSERT_EQ(item1->_iMaxDam, item2->_iMaxDam); + ASSERT_EQ(item1->_iAC, item2->_iAC); + ASSERT_EQ(item1->_iFlags, item2->_iFlags); + ASSERT_EQ(item1->_iMiscId, item2->_iMiscId); + ASSERT_EQ(item1->_iSpell, item2->_iSpell); + ASSERT_EQ(item1->_iCharges, item2->_iCharges); + ASSERT_EQ(item1->_iMaxCharges, item2->_iMaxCharges); + ASSERT_EQ(item1->_iDurability, item2->_iDurability); + ASSERT_EQ(item1->_iMaxDur, item2->_iMaxDur); + ASSERT_EQ(item1->_iPLDam, item2->_iPLDam); + ASSERT_EQ(item1->_iPLToHit, item2->_iPLToHit); + ASSERT_EQ(item1->_iPLAC, item2->_iPLAC); + ASSERT_EQ(item1->_iPLStr, item2->_iPLStr); + ASSERT_EQ(item1->_iPLMag, item2->_iPLMag); + ASSERT_EQ(item1->_iPLDex, item2->_iPLDex); + ASSERT_EQ(item1->_iPLVit, item2->_iPLVit); + ASSERT_EQ(item1->_iPLFR, item2->_iPLFR); + ASSERT_EQ(item1->_iPLLR, item2->_iPLLR); + ASSERT_EQ(item1->_iPLMR, item2->_iPLMR); + ASSERT_EQ(item1->_iPLMana, item2->_iPLMana); + ASSERT_EQ(item1->_iPLHP, item2->_iPLHP); + ASSERT_EQ(item1->_iPLDamMod, item2->_iPLDamMod); + ASSERT_EQ(item1->_iPLGetHit, item2->_iPLGetHit); + ASSERT_EQ(item1->_iPLLight, item2->_iPLLight); + ASSERT_EQ(item1->_iSplLvlAdd, item2->_iSplLvlAdd); + ASSERT_EQ(item1->_iUid, item2->_iUid); + ASSERT_EQ(item1->_iFMinDam, item2->_iFMinDam); + ASSERT_EQ(item1->_iFMaxDam, item2->_iFMaxDam); + ASSERT_EQ(item1->_iLMinDam, item2->_iLMinDam); + ASSERT_EQ(item1->_iLMaxDam, item2->_iLMaxDam); + ASSERT_EQ(item1->_iPrePower, item2->_iPrePower); + ASSERT_EQ(item1->_iSufPower, item2->_iSufPower); + ASSERT_EQ(item1->_iMinStr, item2->_iMinStr); + ASSERT_EQ(item1->_iMinMag, item2->_iMinMag); + ASSERT_EQ(item1->_iMinDex, item2->_iMinDex); + ASSERT_EQ(item1->IDidx, item2->IDidx); } - const dvl::PkItemStruct PackedDiabloItems[] = { // clang-format off // iSeed, iCreateInfo, idx, bId, bDur, bMDur, bCh, bMCh, wValue, dwBuff @@ -233,39 +232,38 @@ TEST(pack, UnPackItem_diablo) } } - TEST(pack, UnPackItem_diablo_unique_bug) { dvl::PkItemStruct pkItemBug = { 6, 911, 14, 5, 60, 60, 0, 0, 0, 0 }; // Veil of Steel - with morph bug - dvl::PkItemStruct pkItem = { 6, 655, 14, 5, 60, 60, 0, 0, 0, 0 }; // Veil of Steel - fixed + dvl::PkItemStruct pkItem = { 6, 655, 14, 5, 60, 60, 0, 0, 0, 0 }; // Veil of Steel - fixed dvl::gbIsHellfire = false; dvl::gbIsHellfireSaveGame = false; dvl::gbIsMultiplayer = false; dvl::ItemStruct id; - dvl::UnPackItem(&pkItemBug, &id); - ASSERT_STREQ(id._iIName, "Veil of Steel"); - ASSERT_EQ(id._itype, dvl::ITYPE_HELM); - ASSERT_EQ(id._iClass, dvl::ICLASS_ARMOR); - ASSERT_EQ(id._iCurs, 85); - ASSERT_EQ(id._iIvalue, 63800); - ASSERT_EQ(id._iAC, 18); - ASSERT_EQ(id._iMiscId, dvl::IMISC_UNIQUE); - ASSERT_EQ(id._iPLAC, 60); - ASSERT_EQ(id._iPLStr, 15); - ASSERT_EQ(id._iPLVit, 15); - ASSERT_EQ(id._iPLFR, 50); - ASSERT_EQ(id._iPLLR, 50); - ASSERT_EQ(id._iPLMR, 50); - ASSERT_EQ(id._iPLMana, -1920); - ASSERT_EQ(id._iPLLight, -2); - ASSERT_EQ(id._iUid, 6); - ASSERT_EQ(id.IDidx, dvl::IDI_STEELVEIL); + dvl::UnPackItem(&pkItemBug, &id); + ASSERT_STREQ(id._iIName, "Veil of Steel"); + ASSERT_EQ(id._itype, dvl::ITYPE_HELM); + ASSERT_EQ(id._iClass, dvl::ICLASS_ARMOR); + ASSERT_EQ(id._iCurs, 85); + ASSERT_EQ(id._iIvalue, 63800); + ASSERT_EQ(id._iAC, 18); + ASSERT_EQ(id._iMiscId, dvl::IMISC_UNIQUE); + ASSERT_EQ(id._iPLAC, 60); + ASSERT_EQ(id._iPLStr, 15); + ASSERT_EQ(id._iPLVit, 15); + ASSERT_EQ(id._iPLFR, 50); + ASSERT_EQ(id._iPLLR, 50); + ASSERT_EQ(id._iPLMR, 50); + ASSERT_EQ(id._iPLMana, -1920); + ASSERT_EQ(id._iPLLight, -2); + ASSERT_EQ(id._iUid, 6); + ASSERT_EQ(id.IDidx, dvl::IDI_STEELVEIL); dvl::PkItemStruct is; - dvl::PackItem(&is, &id); - ComparePackedItems(&is, &pkItem); + dvl::PackItem(&is, &id); + ComparePackedItems(&is, &pkItem); } const dvl::PkItemStruct PackedDiabloMPItems[] = { @@ -466,13 +464,12 @@ TEST(pack, UnPackItem_empty) ASSERT_EQ(id._itype, dvl::ITYPE_NONE); } - TEST(pack, PackItem_empty) { dvl::PkItemStruct is; dvl::ItemStruct id; - id._itype = dvl::ITYPE_NONE; + id._itype = dvl::ITYPE_NONE; dvl::PackItem(&is, &id); diff --git a/SourceT/player_test.cpp b/SourceT/player_test.cpp index 98022b902..fa4ed0870 100644 --- a/SourceT/player_test.cpp +++ b/SourceT/player_test.cpp @@ -25,7 +25,7 @@ int RunBlockTest(bool hellfire, int frames, int flags) dvl::plr[pnum]._pAnimFrame++; } - return i; + return i; } #define NORM 0 @@ -41,66 +41,66 @@ int RunBlockTest(bool hellfire, int frames, int flags) #define SRC 8 int BlockData[][4] = { - { 6, false, WAR, NORM }, // D - { 7, false, ROU, NORM }, // D - { 8, false, SRC, NORM }, // D - { 6, true, WAR, NORM }, // HF - { 7, true, ROU, NORM }, // HF - { 8, true, SRC, NORM }, // HF + { 6, false, WAR, NORM }, // D + { 7, false, ROU, NORM }, // D + { 8, false, SRC, NORM }, // D + { 6, true, WAR, NORM }, // HF + { 7, true, ROU, NORM }, // HF + { 8, true, SRC, NORM }, // HF - { 5, false, WAR, BAL }, // D - { 6, false, ROU, BAL }, // D - { 7, false, SRC, BAL }, // D - { 5, true, WAR, BAL }, // HF - { 6, true, ROU, BAL }, // HF - { 7, true, SRC, BAL }, // HF + { 5, false, WAR, BAL }, // D + { 6, false, ROU, BAL }, // D + { 7, false, SRC, BAL }, // D + { 5, true, WAR, BAL }, // HF + { 6, true, ROU, BAL }, // HF + { 7, true, SRC, BAL }, // HF - { 4, false, WAR, STA }, // D - { 5, false, ROU, STA }, // D - { 6, false, SRC, STA }, // D - { 4, true, WAR, STA }, // HF - { 5, true, ROU, STA }, // HF - { 6, true, SRC, STA }, // HF + { 4, false, WAR, STA }, // D + { 5, false, ROU, STA }, // D + { 6, false, SRC, STA }, // D + { 4, true, WAR, STA }, // HF + { 5, true, ROU, STA }, // HF + { 6, true, SRC, STA }, // HF - { 3, false, WAR, HAR }, // D - { 4, false, ROU, HAR }, // D - { 5, false, SRC, HAR }, // D - { 3, true, WAR, HAR }, // HF - { 4, true, ROU, HAR }, // HF - { 5, true, SRC, HAR }, // HF + { 3, false, WAR, HAR }, // D + { 4, false, ROU, HAR }, // D + { 5, false, SRC, HAR }, // D + { 3, true, WAR, HAR }, // HF + { 4, true, ROU, HAR }, // HF + { 5, true, SRC, HAR }, // HF - { 4, false, WAR, BALSTA }, // D - { 5, false, ROU, BALSTA }, // D - { 6, false, SRC, BALSTA }, // D - { 4, true, WAR, BALSTA }, // HF - { 5, true, ROU, BALSTA }, // HF - { 6, true, SRC, BALSTA }, // HF + { 4, false, WAR, BALSTA }, // D + { 5, false, ROU, BALSTA }, // D + { 6, false, SRC, BALSTA }, // D + { 4, true, WAR, BALSTA }, // HF + { 5, true, ROU, BALSTA }, // HF + { 6, true, SRC, BALSTA }, // HF - { 3, false, WAR, BALHAR }, // D - { 4, false, ROU, BALHAR }, // D - { 5, false, SRC, BALHAR }, // D - { 3, true, WAR, BALHAR }, // HF - { 4, true, ROU, BALHAR }, // HF - { 5, true, SRC, BALHAR }, // HF + { 3, false, WAR, BALHAR }, // D + { 4, false, ROU, BALHAR }, // D + { 5, false, SRC, BALHAR }, // D + { 3, true, WAR, BALHAR }, // HF + { 4, true, ROU, BALHAR }, // HF + { 5, true, SRC, BALHAR }, // HF - { 3, false, WAR, STAHAR }, // D - { 4, false, ROU, STAHAR }, // D - { 5, false, SRC, STAHAR }, // D - { 3, true, WAR, STAHAR }, // HF - { 4, true, ROU, STAHAR }, // HF - { 5, true, SRC, STAHAR }, // HF + { 3, false, WAR, STAHAR }, // D + { 4, false, ROU, STAHAR }, // D + { 5, false, SRC, STAHAR }, // D + { 3, true, WAR, STAHAR }, // HF + { 4, true, ROU, STAHAR }, // HF + { 5, true, SRC, STAHAR }, // HF - { 2, false, WAR, ZEN }, // D - { 3, false, ROU, ZEN }, // D - { 4, false, SRC, ZEN }, // D - { 3, true, WAR, ZEN }, // HF - { 4, true, ROU, ZEN }, // HF - { 5, true, SRC, ZEN }, // HF + { 2, false, WAR, ZEN }, // D + { 3, false, ROU, ZEN }, // D + { 4, false, SRC, ZEN }, // D + { 3, true, WAR, ZEN }, // HF + { 4, true, ROU, ZEN }, // HF + { 5, true, SRC, ZEN }, // HF }; TEST(Player, PM_DoGotHit) { - for (size_t i = 0; i < sizeof(BlockData) / sizeof(*BlockData); i++) { - EXPECT_EQ(BlockData[i][0], RunBlockTest(BlockData[i][1], BlockData[i][2], BlockData[i][3])); - } + for (size_t i = 0; i < sizeof(BlockData) / sizeof(*BlockData); i++) { + EXPECT_EQ(BlockData[i][0], RunBlockTest(BlockData[i][1], BlockData[i][2], BlockData[i][3])); + } } diff --git a/SourceX/DiabloUI/diabloui.cpp b/SourceX/DiabloUI/diabloui.cpp index df7c79d1b..371798538 100644 --- a/SourceX/DiabloUI/diabloui.cpp +++ b/SourceX/DiabloUI/diabloui.cpp @@ -276,7 +276,8 @@ void UiFocusNavigation(SDL_Event *event) break; } - if (HandleMenuAction(GetMenuAction(*event))) return; + if (HandleMenuAction(GetMenuAction(*event))) + return; #ifndef USE_SDL1 if (event->type == SDL_MOUSEWHEEL) { diff --git a/SourceX/DiabloUI/fonts.cpp b/SourceX/DiabloUI/fonts.cpp index 546a1d0e3..178dcbe96 100644 --- a/SourceX/DiabloUI/fonts.cpp +++ b/SourceX/DiabloUI/fonts.cpp @@ -53,7 +53,8 @@ void UnloadArtFonts() FontTables[AFT_HUGE] = NULL; } -void LoadTtfFont() { +void LoadTtfFont() +{ if (!TTF_WasInit()) { if (TTF_Init() == -1) { SDL_Log("TTF_Init: %s", TTF_GetError()); @@ -64,8 +65,7 @@ void LoadTtfFont() { std::string ttf_font_path = GetTtfPath() + GetTtfName(); #ifdef __linux__ - if (!FileExists(ttf_font_path.c_str())) - { + if (!FileExists(ttf_font_path.c_str())) { ttf_font_path = "/usr/share/fonts/truetype/" + GetTtfName(); } #endif @@ -79,14 +79,16 @@ void LoadTtfFont() { TTF_SetFontHinting(font, TTF_HINTING_MONO); } -void UnloadTtfFont() { +void UnloadTtfFont() +{ if (font && TTF_WasInit()) TTF_CloseFont(font); font = NULL; } -void FontsCleanup() { - TTF_Quit(); +void FontsCleanup() +{ + TTF_Quit(); } } // namespace dvl diff --git a/SourceX/DiabloUI/scrollbar.cpp b/SourceX/DiabloUI/scrollbar.cpp index c5f767705..97069983c 100644 --- a/SourceX/DiabloUI/scrollbar.cpp +++ b/SourceX/DiabloUI/scrollbar.cpp @@ -6,16 +6,18 @@ Art ArtScrollBarBackground; Art ArtScrollBarThumb; Art ArtScrollBarArrow; -void LoadScrollBar() { +void LoadScrollBar() +{ LoadArt("ui_art\\sb_bg.pcx", &ArtScrollBarBackground); LoadArt("ui_art\\sb_thumb.pcx", &ArtScrollBarThumb); LoadArt("ui_art\\sb_arrow.pcx", &ArtScrollBarArrow, 4); } -void UnloadScrollBar() { +void UnloadScrollBar() +{ ArtScrollBarArrow.Unload(); ArtScrollBarThumb.Unload(); ArtScrollBarBackground.Unload(); } -} // namespace +} // namespace dvl diff --git a/SourceX/DiabloUI/selconn.h b/SourceX/DiabloUI/selconn.h index 105187ed1..063ca5232 100644 --- a/SourceX/DiabloUI/selconn.h +++ b/SourceX/DiabloUI/selconn.h @@ -4,4 +4,4 @@ void selconn_Esc(); void selconn_Focus(int value); void selconn_Select(int value); -} +} // namespace dvl diff --git a/SourceX/DiabloUI/selgame.h b/SourceX/DiabloUI/selgame.h index a19e50da9..33725c45c 100644 --- a/SourceX/DiabloUI/selgame.h +++ b/SourceX/DiabloUI/selgame.h @@ -19,4 +19,4 @@ void selgame_Password_Init(int value); void selgame_Password_Select(int value); void selgame_Password_Esc(); -} +} // namespace dvl diff --git a/SourceX/DiabloUI/selhero.cpp b/SourceX/DiabloUI/selhero.cpp index 8b908af89..996e62943 100644 --- a/SourceX/DiabloUI/selhero.cpp +++ b/SourceX/DiabloUI/selhero.cpp @@ -350,7 +350,8 @@ void selhero_ClassSelector_Focus(int value) selhero_SetStats(); } -static bool shouldPrefillHeroName() { +static bool shouldPrefillHeroName() +{ #if defined __3DS__ return false; #elif defined(PREFILL_PLAYER_NAME) diff --git a/SourceX/DiabloUI/selok.h b/SourceX/DiabloUI/selok.h index b0d0b3b8f..a5f433b09 100644 --- a/SourceX/DiabloUI/selok.h +++ b/SourceX/DiabloUI/selok.h @@ -8,4 +8,4 @@ void selok_Free(); void selok_Select(int value); void selok_Esc(); -} +} // namespace dvl diff --git a/SourceX/DiabloUI/selyesno.h b/SourceX/DiabloUI/selyesno.h index b63954c15..99d1d81c0 100644 --- a/SourceX/DiabloUI/selyesno.h +++ b/SourceX/DiabloUI/selyesno.h @@ -8,4 +8,4 @@ void selyesno_Free(); void selyesno_Select(int value); void selyesno_Esc(); -} +} // namespace dvl diff --git a/SourceX/DiabloUI/support_lines.cpp b/SourceX/DiabloUI/support_lines.cpp index 657a88590..fbda5323d 100644 --- a/SourceX/DiabloUI/support_lines.cpp +++ b/SourceX/DiabloUI/support_lines.cpp @@ -3,25 +3,25 @@ namespace dvl { const char *const SUPPORT_LINES[] = { - "", - "GOG.com maintains a web site at https://www.gog.com/forum/diablo", - "Follow the links to visit the discussion boards associated with Diablo.", - "and the Hellfire expansion.", - "", - "DevilutionX is maintained by Diasurgical, issues and bugs can be reported", - "at this address: https://github.com/diasurgical/devilutionX", - "To help us better serve you, please be sure to include the version number,", - "operating system, and the nature of the problem.", - "", - "", - "Disclaimer:", - " DevilutionX is not supported or maintained by Blizzard Entertainment,", - " nor GOG.com. Neither Blizzard Entertainment or GOG.com has not tested", - " or certified the quality or compatibility of DevilutionX. All inquiries", - " regarding DevilutionX should be directed to Diasurgical, not to Blizzard", - " Entertainment or GOG.com.", - "", - "", + "", + "GOG.com maintains a web site at https://www.gog.com/forum/diablo", + "Follow the links to visit the discussion boards associated with Diablo.", + "and the Hellfire expansion.", + "", + "DevilutionX is maintained by Diasurgical, issues and bugs can be reported", + "at this address: https://github.com/diasurgical/devilutionX", + "To help us better serve you, please be sure to include the version number,", + "operating system, and the nature of the problem.", + "", + "", + "Disclaimer:", + " DevilutionX is not supported or maintained by Blizzard Entertainment,", + " nor GOG.com. Neither Blizzard Entertainment or GOG.com has not tested", + " or certified the quality or compatibility of DevilutionX. All inquiries", + " regarding DevilutionX should be directed to Diasurgical, not to Blizzard", + " Entertainment or GOG.com.", + "", + "", }; const std::size_t SUPPORT_LINES_SIZE = sizeof(SUPPORT_LINES) / sizeof(SUPPORT_LINES[0]); diff --git a/SourceX/controls/axis_direction.cpp b/SourceX/controls/axis_direction.cpp index 55cafb420..28d621073 100644 --- a/SourceX/controls/axis_direction.cpp +++ b/SourceX/controls/axis_direction.cpp @@ -8,48 +8,48 @@ AxisDirection AxisDirectionRepeater::Get(AxisDirection axis_direction) { const int now = SDL_GetTicks(); switch (axis_direction.x) { - case AxisDirectionX_LEFT: - last_right_ = 0; - if (now - last_left_ < min_interval_ms_) { - axis_direction.x = AxisDirectionX_NONE; - } else { - last_left_ = now; - } - break; - case AxisDirectionX_RIGHT: - last_left_ = 0; - if (now - last_right_ < min_interval_ms_) { - axis_direction.x = AxisDirectionX_NONE; - } else { - last_right_ = now; - } - break; - case AxisDirectionX_NONE: - last_left_ = last_right_ = 0; - break; + case AxisDirectionX_LEFT: + last_right_ = 0; + if (now - last_left_ < min_interval_ms_) { + axis_direction.x = AxisDirectionX_NONE; + } else { + last_left_ = now; + } + break; + case AxisDirectionX_RIGHT: + last_left_ = 0; + if (now - last_right_ < min_interval_ms_) { + axis_direction.x = AxisDirectionX_NONE; + } else { + last_right_ = now; + } + break; + case AxisDirectionX_NONE: + last_left_ = last_right_ = 0; + break; } switch (axis_direction.y) { - case AxisDirectionY_UP: - last_down_ = 0; - if (now - last_up_ < min_interval_ms_) { - axis_direction.y = AxisDirectionY_NONE; - } else { - last_up_ = now; - } - break; - case AxisDirectionY_DOWN: - last_up_ = 0; - if (now - last_down_ < min_interval_ms_) { - axis_direction.y = AxisDirectionY_NONE; - } else { - last_down_ = now; - } - break; - case AxisDirectionY_NONE: - last_up_ = last_down_ = 0; - break; + case AxisDirectionY_UP: + last_down_ = 0; + if (now - last_up_ < min_interval_ms_) { + axis_direction.y = AxisDirectionY_NONE; + } else { + last_up_ = now; + } + break; + case AxisDirectionY_DOWN: + last_up_ = 0; + if (now - last_down_ < min_interval_ms_) { + axis_direction.y = AxisDirectionY_NONE; + } else { + last_down_ = now; + } + break; + case AxisDirectionY_NONE: + last_up_ = last_down_ = 0; + break; } return axis_direction; } -} // namespace +} // namespace dvl diff --git a/SourceX/controls/devices/game_controller.cpp b/SourceX/controls/devices/game_controller.cpp index 094f1daad..e35374cd5 100644 --- a/SourceX/controls/devices/game_controller.cpp +++ b/SourceX/controls/devices/game_controller.cpp @@ -198,13 +198,13 @@ GameController *GameController::Get(SDL_JoystickID instance_id) GameController *GameController::Get(const SDL_Event &event) { switch (event.type) { - case SDL_CONTROLLERAXISMOTION: - return Get(event.caxis.which); - case SDL_CONTROLLERBUTTONDOWN: - case SDL_CONTROLLERBUTTONUP: - return Get(event.jball.which); - default: - return NULL; + case SDL_CONTROLLERAXISMOTION: + return Get(event.caxis.which); + case SDL_CONTROLLERBUTTONDOWN: + case SDL_CONTROLLERBUTTONUP: + return Get(event.jball.which); + default: + return NULL; } } diff --git a/SourceX/controls/devices/joystick.cpp b/SourceX/controls/devices/joystick.cpp index fe2f63d93..752c80616 100644 --- a/SourceX/controls/devices/joystick.cpp +++ b/SourceX/controls/devices/joystick.cpp @@ -302,27 +302,27 @@ Joystick *Joystick::Get(const SDL_Event &event) { switch (event.type) { #ifndef USE_SDL1 - case SDL_JOYAXISMOTION: - return Get(event.jaxis.which); - case SDL_JOYBALLMOTION: - return Get(event.jball.which); - case SDL_JOYHATMOTION: - return Get(event.jhat.which); - case SDL_JOYBUTTONDOWN: - case SDL_JOYBUTTONUP: - return Get(event.jbutton.which); - return Get(event.jbutton.which); - default: - return NULL; + case SDL_JOYAXISMOTION: + return Get(event.jaxis.which); + case SDL_JOYBALLMOTION: + return Get(event.jball.which); + case SDL_JOYHATMOTION: + return Get(event.jhat.which); + case SDL_JOYBUTTONDOWN: + case SDL_JOYBUTTONUP: + return Get(event.jbutton.which); + return Get(event.jbutton.which); + default: + return NULL; #else - case SDL_JOYAXISMOTION: - case SDL_JOYBALLMOTION: - case SDL_JOYHATMOTION: - case SDL_JOYBUTTONDOWN: - case SDL_JOYBUTTONUP: - return joysticks_->empty() ? NULL : &(*joysticks_)[0]; - default: - return NULL; + case SDL_JOYAXISMOTION: + case SDL_JOYBALLMOTION: + case SDL_JOYHATMOTION: + case SDL_JOYBUTTONDOWN: + case SDL_JOYBUTTONUP: + return joysticks_->empty() ? NULL : &(*joysticks_)[0]; + default: + return NULL; #endif } } diff --git a/SourceX/controls/game_controls.cpp b/SourceX/controls/game_controls.cpp index 9f7d08461..90dd44ea2 100644 --- a/SourceX/controls/game_controls.cpp +++ b/SourceX/controls/game_controls.cpp @@ -79,7 +79,8 @@ bool HandleStartAndSelect(const ControllerButtonEvent &ctrl_event, GameAction *a if (in_game_menu && (start_is_down || select_is_down) && !ctrl_event.up) { // If both are down, do nothing because `both_received` will trigger soon. - if (start_is_down && select_is_down) return true; + if (start_is_down && select_is_down) + return true; *action = GameActionSendKey { DVL_VK_ESCAPE, ctrl_event.up }; return true; } @@ -122,14 +123,14 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrl_event, Gam case ControllerButton_BUTTON_LEFTSHOULDER: if ((select_modifier_active && !sgOptions.Controller.bSwapShoulderButtonMode) || (sgOptions.Controller.bSwapShoulderButtonMode && !select_modifier_active)) { if (!IsAutomapActive()) - *action = GameActionSendMouseClick{ GameActionSendMouseClick::LEFT, ctrl_event.up }; + *action = GameActionSendMouseClick { GameActionSendMouseClick::LEFT, ctrl_event.up }; return true; } break; case ControllerButton_BUTTON_RIGHTSHOULDER: if ((select_modifier_active && !sgOptions.Controller.bSwapShoulderButtonMode) || (sgOptions.Controller.bSwapShoulderButtonMode && !select_modifier_active)) { if (!IsAutomapActive()) - *action = GameActionSendMouseClick{ GameActionSendMouseClick::RIGHT, ctrl_event.up }; + *action = GameActionSendMouseClick { GameActionSendMouseClick::RIGHT, ctrl_event.up }; return true; } break; @@ -161,29 +162,27 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrl_event, Gam switch (ctrl_event.button) { case ControllerButton_BUTTON_DPAD_UP: if (IsControllerButtonPressed(ControllerButton_BUTTON_BACK)) - *action = GameActionSendKey{ DVL_VK_F6, ctrl_event.up }; + *action = GameActionSendKey { DVL_VK_F6, ctrl_event.up }; else - *action = GameActionSendKey{ DVL_VK_ESCAPE, ctrl_event.up }; + *action = GameActionSendKey { DVL_VK_ESCAPE, ctrl_event.up }; return true; case ControllerButton_BUTTON_DPAD_RIGHT: if (IsControllerButtonPressed(ControllerButton_BUTTON_BACK)) - *action = GameActionSendKey{ DVL_VK_F8, ctrl_event.up }; - else - if (!ctrl_event.up) - *action = GameAction(GameActionType_TOGGLE_INVENTORY); + *action = GameActionSendKey { DVL_VK_F8, ctrl_event.up }; + else if (!ctrl_event.up) + *action = GameAction(GameActionType_TOGGLE_INVENTORY); return true; case ControllerButton_BUTTON_DPAD_DOWN: if (IsControllerButtonPressed(ControllerButton_BUTTON_BACK)) - *action = GameActionSendKey{ DVL_VK_F7, ctrl_event.up }; + *action = GameActionSendKey { DVL_VK_F7, ctrl_event.up }; else - *action = GameActionSendKey{ DVL_VK_TAB, ctrl_event.up }; + *action = GameActionSendKey { DVL_VK_TAB, ctrl_event.up }; return true; case ControllerButton_BUTTON_DPAD_LEFT: if (IsControllerButtonPressed(ControllerButton_BUTTON_BACK)) - *action = GameActionSendKey{ DVL_VK_F5, ctrl_event.up }; - else - if (!ctrl_event.up) - *action = GameAction(GameActionType_TOGGLE_CHARACTER_INFO); + *action = GameActionSendKey { DVL_VK_F5, ctrl_event.up }; + else if (!ctrl_event.up) + *action = GameAction(GameActionType_TOGGLE_CHARACTER_INFO); return true; default: break; @@ -192,14 +191,14 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrl_event, Gam if (start_modifier_active) { switch (ctrl_event.button) { case ControllerButton_BUTTON_DPAD_UP: - *action = GameActionSendKey{ DVL_VK_ESCAPE, ctrl_event.up }; + *action = GameActionSendKey { DVL_VK_ESCAPE, ctrl_event.up }; return true; case ControllerButton_BUTTON_DPAD_RIGHT: if (!ctrl_event.up) *action = GameAction(GameActionType_TOGGLE_INVENTORY); return true; case ControllerButton_BUTTON_DPAD_DOWN: - *action = GameActionSendKey{ DVL_VK_TAB, ctrl_event.up }; + *action = GameActionSendKey { DVL_VK_TAB, ctrl_event.up }; return true; case ControllerButton_BUTTON_DPAD_LEFT: if (!ctrl_event.up) @@ -212,7 +211,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrl_event, Gam CalcViewportGeometry(); } #else - // Not mapped. Reserved for future use. + // Not mapped. Reserved for future use. #endif return true; case ControllerButton_BUTTON_B: // Right button @@ -241,7 +240,8 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrl_event, Gam // Bottom button: Closes menus or opens quick spell book if nothing is open. if (ctrl_event.button == ControllerButton_BUTTON_A) { // Bottom button - if (ctrl_event.up) return true; + if (ctrl_event.up) + return true; if (IsControllerButtonPressed(ControllerButton_BUTTON_BACK)) *action = GameActionSendKey { DVL_VK_F7, ctrl_event.up }; else if (invflag) @@ -264,7 +264,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrl_event, Gam case ControllerButton_BUTTON_B: // Right button if (!ctrl_event.up) { if (IsControllerButtonPressed(ControllerButton_BUTTON_BACK)) - *action = GameActionSendKey{ DVL_VK_F8, ctrl_event.up }; + *action = GameActionSendKey { DVL_VK_F8, ctrl_event.up }; else *action = GameAction(GameActionType_PRIMARY_ACTION); } @@ -272,7 +272,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrl_event, Gam case ControllerButton_BUTTON_Y: // Top button if (!ctrl_event.up) { if (IsControllerButtonPressed(ControllerButton_BUTTON_BACK)) - *action = GameActionSendKey{ DVL_VK_F6, ctrl_event.up }; + *action = GameActionSendKey { DVL_VK_F6, ctrl_event.up }; else *action = GameAction(GameActionType_SECONDARY_ACTION); } @@ -280,7 +280,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrl_event, Gam case ControllerButton_BUTTON_X: // Left button if (!ctrl_event.up) { if (IsControllerButtonPressed(ControllerButton_BUTTON_BACK)) - *action = GameActionSendKey{ DVL_VK_F5, ctrl_event.up }; + *action = GameActionSendKey { DVL_VK_F5, ctrl_event.up }; else *action = GameAction(GameActionType_CAST_SPELL); } @@ -309,24 +309,22 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrl_event, Gam } } - // DPad navigation is handled separately for these. - if (gmenu_is_active() || questlog || stextflag != STORE_NONE) - { + if (gmenu_is_active() || questlog || stextflag != STORE_NONE) { switch (ctrl_event.button) { - case ControllerButton_BUTTON_DPAD_UP: - case ControllerButton_BUTTON_DPAD_DOWN: - case ControllerButton_BUTTON_DPAD_LEFT: - case ControllerButton_BUTTON_DPAD_RIGHT: - return true; - default: - break; + case ControllerButton_BUTTON_DPAD_UP: + case ControllerButton_BUTTON_DPAD_DOWN: + case ControllerButton_BUTTON_DPAD_LEFT: + case ControllerButton_BUTTON_DPAD_RIGHT: + return true; + default: + break; } } // By default, map to a keyboard key. if (ctrl_event.button != ControllerButton_NONE) { - *action = GameActionSendKey{ translate_controller_button_to_key(ctrl_event.button), + *action = GameActionSendKey { translate_controller_button_to_key(ctrl_event.button), ctrl_event.up }; return true; } diff --git a/SourceX/controls/modifier_hints.cpp b/SourceX/controls/modifier_hints.cpp index a15fa63b9..e1414e003 100644 --- a/SourceX/controls/modifier_hints.cpp +++ b/SourceX/controls/modifier_hints.cpp @@ -123,8 +123,7 @@ void DrawSelectModifierMenu(CelOutputBuffer out) { if (!select_modifier_active) return; - if (sgOptions.Controller.bDpadHotkeys) - { + if (sgOptions.Controller.bDpadHotkeys) { static const CircleMenuHint kDpad(/*is_dpad=*/true, /*top=*/"F6", /*right=*/"F8", /*bottom=*/"F7", /*left=*/"F5"); DrawCircleMenuHint(out, kDpad, PANEL_LEFT + kCircleMarginX, PANEL_TOP - kCirclesTop); } diff --git a/SourceX/controls/plrctrls.cpp b/SourceX/controls/plrctrls.cpp index b6d96894d..bb677ec90 100644 --- a/SourceX/controls/plrctrls.cpp +++ b/SourceX/controls/plrctrls.cpp @@ -862,7 +862,8 @@ HandleLeftStickOrDPadFn GetLeftStickOrDPadGameUIHandler() return NULL; } -void ProcessLeftStickOrDPadGameUI() { +void ProcessLeftStickOrDPadGameUI() +{ HandleLeftStickOrDPadFn handler = GetLeftStickOrDPadGameUIHandler(); if (handler != NULL) handler(GetLeftStickOrDpadDirection(true)); @@ -1010,8 +1011,7 @@ void HandleRightStickMotion() // cursor position events. static int lastMouseSetTick = 0; const int now = SDL_GetTicks(); - if (now - lastMouseSetTick > 0) - { + if (now - lastMouseSetTick > 0) { SetCursorPos(x, y); lastMouseSetTick = now; } diff --git a/SourceX/controls/remap_keyboard.h b/SourceX/controls/remap_keyboard.h index 9a26f8abb..5ddd7a3e1 100644 --- a/SourceX/controls/remap_keyboard.h +++ b/SourceX/controls/remap_keyboard.h @@ -19,7 +19,7 @@ inline void remap_keyboard_key(SDL_Keycode *sym) SDL_Keycode from; SDL_Keycode to; }; - constexpr Mapping kMappings[] = {REMAP_KEYBOARD_KEYS}; + constexpr Mapping kMappings[] = { REMAP_KEYBOARD_KEYS }; for (std::size_t i = 0; i < sizeof(kMappings) / sizeof(kMappings[0]); ++i) { if (*sym == kMappings[i].from) { *sym = kMappings[i].to; diff --git a/SourceX/dvlnet/frame_queue.cpp b/SourceX/dvlnet/frame_queue.cpp index d273efc82..34d6be821 100644 --- a/SourceX/dvlnet/frame_queue.cpp +++ b/SourceX/dvlnet/frame_queue.cpp @@ -21,16 +21,16 @@ buffer_t frame_queue::read(framesize_t s) s -= buffer_deque.front().size(); current_size -= buffer_deque.front().size(); ret.insert(ret.end(), - buffer_deque.front().begin(), - buffer_deque.front().end()); + buffer_deque.front().begin(), + buffer_deque.front().end()); buffer_deque.pop_front(); } if (s > 0) { ret.insert(ret.end(), - buffer_deque.front().begin(), - buffer_deque.front().begin() + s); + buffer_deque.front().begin(), + buffer_deque.front().begin() + s); buffer_deque.front().erase(buffer_deque.front().begin(), - buffer_deque.front().begin() + s); + buffer_deque.front().begin() + s); current_size -= s; } return ret; diff --git a/SourceX/dvlnet/loopback.cpp b/SourceX/dvlnet/loopback.cpp index cbcfc4b65..02ef79121 100644 --- a/SourceX/dvlnet/loopback.cpp +++ b/SourceX/dvlnet/loopback.cpp @@ -59,12 +59,12 @@ int loopback::SNetGetProviderCaps(struct _SNETCAPS *caps) caps->latencyms = 0; // unused caps->defaultturnssec = 10; // ? caps->defaultturnsintransit = 1; // maximum acceptable number - // of turns in queue? + // of turns in queue? return 1; } bool loopback::SNetRegisterEventHandler(event_type evtype, - SEVTHANDLER func) + SEVTHANDLER func) { // not called in real singleplayer mode // not needed in pseudo multiplayer mode (?) @@ -72,7 +72,7 @@ bool loopback::SNetRegisterEventHandler(event_type evtype, } bool loopback::SNetUnregisterEventHandler(event_type evtype, - SEVTHANDLER func) + SEVTHANDLER func) { // not called in real singleplayer mode // not needed in pseudo multiplayer mode (?) diff --git a/SourceX/dvlnet/loopback.h b/SourceX/dvlnet/loopback.h index c84a1b7ce..6797b9ecc 100644 --- a/SourceX/dvlnet/loopback.h +++ b/SourceX/dvlnet/loopback.h @@ -26,13 +26,13 @@ public: virtual bool SNetReceiveMessage(int *sender, char **data, int *size); virtual bool SNetSendMessage(int dest, void *data, unsigned int size); virtual bool SNetReceiveTurns(char **data, unsigned int *size, - DWORD *status); + DWORD *status); virtual bool SNetSendTurn(char *data, unsigned int size); virtual int SNetGetProviderCaps(struct _SNETCAPS *caps); virtual bool SNetRegisterEventHandler(event_type evtype, - SEVTHANDLER func); + SEVTHANDLER func); virtual bool SNetUnregisterEventHandler(event_type evtype, - SEVTHANDLER func); + SEVTHANDLER func); virtual bool SNetLeaveGame(int type); virtual bool SNetDropPlayer(int playerid, DWORD flags); virtual bool SNetGetOwnerTurnsWaiting(DWORD *turns); diff --git a/SourceX/dvlnet/tcp_server.cpp b/SourceX/dvlnet/tcp_server.cpp index 4003eacbb..85c6d0d73 100644 --- a/SourceX/dvlnet/tcp_server.cpp +++ b/SourceX/dvlnet/tcp_server.cpp @@ -161,7 +161,7 @@ void tcp_server::start_accept() void tcp_server::handle_accept(scc con, const asio::error_code &ec) { - if(ec) + if (ec) return; if (next_free() == PLR_BROADCAST) { drop_connection(con); diff --git a/SourceX/dx.cpp b/SourceX/dx.cpp index dd64b310c..9dbce9811 100644 --- a/SourceX/dx.cpp +++ b/SourceX/dx.cpp @@ -38,11 +38,11 @@ SDL_Surface *pal_surface; static void dx_create_back_buffer() { pal_surface = SDL_CreateRGBSurfaceWithFormat( - /*flags=*/0, - /*width=*/BUFFER_BORDER_LEFT + gnScreenWidth + BUFFER_BORDER_RIGHT, - /*height=*/BUFFER_BORDER_TOP + gnScreenHeight + BUFFER_BORDER_BOTTOM, - /*depth=*/8, - SDL_PIXELFORMAT_INDEX8); + /*flags=*/0, + /*width=*/BUFFER_BORDER_LEFT + gnScreenWidth + BUFFER_BORDER_RIGHT, + /*height=*/BUFFER_BORDER_TOP + gnScreenHeight + BUFFER_BORDER_BOTTOM, + /*depth=*/8, + SDL_PIXELFORMAT_INDEX8); if (pal_surface == NULL) { ErrSdl(); } @@ -131,7 +131,7 @@ CelOutputBuffer GlobalBackBuffer() return CelOutputBuffer(); } - return CelOutputBuffer(pal_surface, SDL_Rect{BUFFER_BORDER_LEFT, BUFFER_BORDER_TOP, gnScreenWidth, gnScreenHeight}); + return CelOutputBuffer(pal_surface, SDL_Rect { BUFFER_BORDER_LEFT, BUFFER_BORDER_TOP, gnScreenWidth, gnScreenHeight }); } void dx_cleanup() diff --git a/SourceX/main.cpp b/SourceX/main.cpp index 0b1e867dd..ca355de18 100644 --- a/SourceX/main.cpp +++ b/SourceX/main.cpp @@ -21,8 +21,8 @@ extern "C" const char *__asan_default_options() int main(int argc, char **argv) { #ifdef RUN_TESTS - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); #endif #ifdef __SWITCH__ switch_enable_network(); diff --git a/SourceX/platform/ctr/keyboard.cpp b/SourceX/platform/ctr/keyboard.cpp index c2b832d26..f64f1e68e 100644 --- a/SourceX/platform/ctr/keyboard.cpp +++ b/SourceX/platform/ctr/keyboard.cpp @@ -3,7 +3,7 @@ #include "platform/ctr/keyboard.h" -const char* ctr_vkbdInput(const char *hintText, const char *inText, char *outText) +const char *ctr_vkbdInput(const char *hintText, const char *inText, char *outText) { SwkbdState swkbd; @@ -16,8 +16,7 @@ const char* ctr_vkbdInput(const char *hintText, const char *inText, char *outTex SwkbdButton button = swkbdInputText(&swkbd, mybuf, sizeof(mybuf)); - if (button == SWKBD_BUTTON_CONFIRM) - { + if (button == SWKBD_BUTTON_CONFIRM) { strcpy(outText, mybuf); return 0; } diff --git a/SourceX/platform/ctr/keyboard.h b/SourceX/platform/ctr/keyboard.h index 581584939..5a930f606 100644 --- a/SourceX/platform/ctr/keyboard.h +++ b/SourceX/platform/ctr/keyboard.h @@ -1,3 +1,3 @@ #include <3ds.h> -const char* ctr_vkbdInput(const char *title, const char *inText, char *outText); +const char *ctr_vkbdInput(const char *title, const char *inText, char *outText); diff --git a/SourceX/platform/ctr/system.cpp b/SourceX/platform/ctr/system.cpp index d50210608..794767ea7 100644 --- a/SourceX/platform/ctr/system.cpp +++ b/SourceX/platform/ctr/system.cpp @@ -10,22 +10,22 @@ aptHookCookie cookie; void aptHookFunc(APT_HookType hookType, void *param) { switch (hookType) { - case APTHOOK_ONSUSPEND: - ctr_lcd_backlight_on(); - break; - case APTHOOK_ONSLEEP: - break; - case APTHOOK_ONRESTORE: - ctr_lcd_backlight_off(); - break; - case APTHOOK_ONWAKEUP: - ctr_lcd_backlight_off(); - break; - case APTHOOK_ONEXIT: - ctr_lcd_backlight_on(); - break; - default: - break; + case APTHOOK_ONSUSPEND: + ctr_lcd_backlight_on(); + break; + case APTHOOK_ONSLEEP: + break; + case APTHOOK_ONRESTORE: + ctr_lcd_backlight_off(); + break; + case APTHOOK_ONWAKEUP: + ctr_lcd_backlight_off(); + break; + case APTHOOK_ONEXIT: + ctr_lcd_backlight_on(); + break; + default: + break; } } @@ -62,13 +62,13 @@ bool ctr_check_dsp() void ctr_sys_init() { - if( ctr_check_dsp() == false ) + if (ctr_check_dsp() == false) exit(0); aptHook(&cookie, aptHookFunc, NULL); APT_CheckNew3DS(&isN3DS); - if(isN3DS) + if (isN3DS) osSetSpeedupEnable(true); ctr_lcd_backlight_off(); diff --git a/SourceX/platform/switch/docking.cpp b/SourceX/platform/switch/docking.cpp index 311e01d2c..dc35c3928 100644 --- a/SourceX/platform/switch/docking.cpp +++ b/SourceX/platform/switch/docking.cpp @@ -14,14 +14,14 @@ void HandleDocking() { int docked; switch (appletGetOperationMode()) { - case AppletOperationMode_Handheld: - docked = 0; - break; - case AppletOperationMode_Console: - docked = 1; - break; - default: - docked = 0; + case AppletOperationMode_Handheld: + docked = 0; + break; + case AppletOperationMode_Console: + docked = 1; + break; + default: + docked = 0; } int display_width; diff --git a/SourceX/soundsample.cpp b/SourceX/soundsample.cpp index cbfc2a0a9..cf356b14b 100644 --- a/SourceX/soundsample.cpp +++ b/SourceX/soundsample.cpp @@ -117,7 +117,7 @@ int SoundSample::GetLength() bytePerSample = 1; } - Uint64 ms = 1000; // milliseconds, 64bit to avoid overflow when multiplied by alen + Uint64 ms = 1000; // milliseconds, 64bit to avoid overflow when multiplied by alen Uint32 bps = frequency * channels * bytePerSample; // bytes per second return (Uint32)(chunk->alen * ms / bps); }; diff --git a/SourceX/thread.cpp b/SourceX/thread.cpp index 0331a82db..2b536a39c 100644 --- a/SourceX/thread.cpp +++ b/SourceX/thread.cpp @@ -75,4 +75,4 @@ int WaitForEvent(event_emul *e) return ret; } -} +} // namespace dvl