From 1e8e8213a785c84a1834c22070cf04f56c48546a Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Tue, 20 Jun 2023 22:19:25 +0200 Subject: [PATCH] Cosmetic: apply clang-format --- src/decblupi.cxx | 10 +++++----- src/decmap.cxx | 4 ++-- src/decor.cxx | 10 ++++------ src/decor.h | 4 ++-- src/event.cxx | 4 ++-- src/event.h | 6 +++--- src/pixmap.cxx | 17 +++++++---------- src/pixmap.h | 14 +++++++++----- src/platform.h | 4 ++-- src/platform/platform_js.cxx | 6 +++--- src/platform/platform_sdl.cxx | 6 +++--- src/sound.cxx | 2 +- src/sound.h | 2 +- src/text.cxx | 10 ++++++---- src/text.h | 2 +- 15 files changed, 51 insertions(+), 50 deletions(-) diff --git a/src/decblupi.cxx b/src/decblupi.cxx index d79a9e4..f10a0e5 100644 --- a/src/decblupi.cxx +++ b/src/decblupi.cxx @@ -2850,7 +2850,7 @@ CDecor::BlupiNextGoal (Sint32 rank) this->m_pSound->StopSound (true, rank); BlupiSound (rank, SOUND_TRAP, pos); PutObject (cel, CHOBJECT, 96); // araignée piégée - BlupiDelete (rank, SDL_TRUE); // supprime araignée + BlupiDelete (rank, SDL_TRUE); // supprime araignée return; } } @@ -2948,7 +2948,7 @@ CDecor::BlupiNextGoal (Sint32 rank) this->m_pSound->StopSound (true, rank); BlupiSound (rank, SOUND_TRAP, pos); PutObject (cel, CHOBJECT, 97); // tracks piégé - BlupiDelete (rank, SDL_TRUE); // supprime tracks + BlupiDelete (rank, SDL_TRUE); // supprime tracks return; } @@ -3029,7 +3029,7 @@ CDecor::BlupiNextGoal (Sint32 rank) this->m_pSound->StopSound (true, rank); BlupiSound (rank, SOUND_TRAP, pos); PutObject (cel, CHOBJECT, 98); // robot piégé - BlupiDelete (rank, SDL_TRUE); // supprime robot + BlupiDelete (rank, SDL_TRUE); // supprime robot return; } @@ -3076,7 +3076,7 @@ CDecor::BlupiNextGoal (Sint32 rank) this->m_pSound->StopSound (true, rank); BlupiSound (rank, SOUND_TRAP, pos); PutObject (cel, CHOBJECT, 114); // bombe piégée - BlupiDelete (rank, SDL_TRUE); // supprime bombe + BlupiDelete (rank, SDL_TRUE); // supprime bombe return; } } @@ -3121,7 +3121,7 @@ CDecor::BlupiNextGoal (Sint32 rank) this->m_pSound->StopSound (true, rank); BlupiSound (rank, SOUND_TRAP, pos); PutObject (cel, CHOBJECT, 19); // électro piégée - BlupiDelete (rank, SDL_TRUE); // supprime électro + BlupiDelete (rank, SDL_TRUE); // supprime électro return; } } diff --git a/src/decmap.cxx b/src/decmap.cxx index 1366582..681e4ca 100644 --- a/src/decmap.cxx +++ b/src/decmap.cxx @@ -57,7 +57,7 @@ void CDecor::MapInitColors () { // FIXME: add big-endian support - const auto MapRGB = [](Uint8 r, Uint8 g, Uint8 b) { + const auto MapRGB = [] (Uint8 r, Uint8 g, Uint8 b) { return r << 16 | g << 8 | b << 0; }; @@ -515,7 +515,7 @@ CDecor::GenerateMap () Point pos, cel; Sint32 dx, rank, i; - auto DrawMap = [&]() -> bool { + auto DrawMap = [&] () -> bool { if (!m_SurfaceMap) return true; diff --git a/src/decor.cxx b/src/decor.cxx index a6ba4b6..9d21b42 100644 --- a/src/decor.cxx +++ b/src/decor.cxx @@ -1915,9 +1915,8 @@ CDecor::CelOkForAction ( cel.x--; cel.y--; - if ( - !bStrong || bTransport || bVehicule || - m_blupi[rank].perso == 8) // disciple ? + if (!bStrong || bTransport || bVehicule || m_blupi[rank].perso == 8) // disciple + // ? { error = Errors::MISC; // pas assez fort } @@ -1970,9 +1969,8 @@ CDecor::CelOkForAction ( cel.x--; cel.y--; - if ( - !bStrong || bTransport || bVehicule || - m_blupi[rank].perso == 8) // disciple ? + if (!bStrong || bTransport || bVehicule || m_blupi[rank].perso == 8) // disciple + // ? { error = Errors::MISC; // pas assez fort } diff --git a/src/decor.h b/src/decor.h index f665694..a7b9dff 100644 --- a/src/decor.h +++ b/src/decor.h @@ -206,7 +206,7 @@ public: bool IsFreeCelEmbarque (Point cel, Sint32 rank, Sint32 & action, Point & limit); bool - IsFreeCelDebarque (Point cel, Sint32 rank, Sint32 & action, Point & limit); + IsFreeCelDebarque (Point cel, Sint32 rank, Sint32 & action, Point & limit); bool IsFreeJump (Point cel, Sint32 direct, Sint32 rank, Sint32 & action); bool IsFreeGlisse (Point cel, Sint32 direct, Sint32 rank, Sint32 & action); Sint32 DirectSearch (Point cel, Point goal); @@ -349,7 +349,7 @@ public: // DecIO.cpp bool Write (Sint32 rank, bool bUser, Sint32 world, Sint32 time, Sint32 total); bool - Read (Sint32 rank, bool bUser, Sint32 & world, Sint32 & time, Sint32 & total); + Read (Sint32 rank, bool bUser, Sint32 & world, Sint32 & time, Sint32 & total); bool FileExist ( Sint32 rank, bool bUser, Sint32 & world, Sint32 & time, Sint32 & total); void Flush (); diff --git a/src/event.cxx b/src/event.cxx index f3dc03e..c423749 100644 --- a/src/event.cxx +++ b/src/event.cxx @@ -2878,7 +2878,7 @@ CEvent::DrawButtons () DrawText (m_pPixmap, pos, text); text = gettext ("We hope you have had as much fun playing the game as we " - "had making it !"); + "had making it !"); lg = GetTextWidth (text); lg = IsRightReading () ? -lg : lg; pos.x = LXIMAGE () / 2 - lg / 2; @@ -2913,7 +2913,7 @@ CEvent::DrawButtons () } text = gettext ("This game is an original creation of Epsitec SA, CH-1400 " - "Yverdon-les-Bains"); + "Yverdon-les-Bains"); lg = GetTextWidth (text); lg = IsRightReading () ? -lg : lg; pos.x = LXIMAGE () / 2 - lg / 2; diff --git a/src/event.h b/src/event.h index 59ecc29..f334c38 100644 --- a/src/event.h +++ b/src/event.h @@ -102,7 +102,7 @@ public: bool IsDemoPlaying (); Point GetMousePos (); void - Create (CPixmap * pPixmap, CDecor * pDecor, CSound * pSound, CMovie * pMovie); + Create (CPixmap * pPixmap, CDecor * pDecor, CSound * pSound, CMovie * pMovie); void SetFullScreen (bool bFullScreen, double prevScale = 1); Sint32 GetWorld (); Sint32 GetPhysicalWorld (); @@ -182,7 +182,7 @@ protected: void BuildFloor (Point cel, Sint32 insIcon); void BuildWater (Point cel, Sint32 insIcon); bool - BuildDown (Point pos, Uint16 mod, const SDL_Event * event, bool bMix = true); + BuildDown (Point pos, Uint16 mod, const SDL_Event * event, bool bMix = true); bool BuildMove (Point pos, Uint16 mod, const SDL_Event & event); void PrivateLibelle (); @@ -195,7 +195,7 @@ protected: bool DemoPlayStart (const std::string * demoFile = nullptr); void DemoPlayStop (); static void - WinToSDLEvent (Uint32 msg, WParam wParam, LParam lParam, SDL_Event & event); + WinToSDLEvent (Uint32 msg, WParam wParam, LParam lParam, SDL_Event & event); void DemoRecEvent (const SDL_Event & event); protected: diff --git a/src/pixmap.cxx b/src/pixmap.cxx index 11bcdad..f8c1ced 100644 --- a/src/pixmap.cxx +++ b/src/pixmap.cxx @@ -125,10 +125,11 @@ CPixmap::CreateMainTexture () Sint32 CPixmap::Blit ( - Sint32 dstCh, SDL_Texture * src, const SDL_Rect & dstRect, double angle, SDL_RendererFlip flip) + Sint32 dstCh, SDL_Texture * src, const SDL_Rect & dstRect, double angle, + SDL_RendererFlip flip) { Sint32 res; - auto target = SDL_GetRenderTarget (g_renderer); + auto target = SDL_GetRenderTarget (g_renderer); if (dstCh < 0) { @@ -150,8 +151,7 @@ CPixmap::Blit ( if (this->mainTexture) SDL_SetRenderTarget (g_renderer, target ? target : this->mainTexture); res = SDL_RenderCopyEx ( - g_renderer, src, nullptr, &dstRect, angle, - nullptr, flip); + g_renderer, src, nullptr, &dstRect, angle, nullptr, flip); if (this->mainTexture) SDL_SetRenderTarget (g_renderer, target); } @@ -159,8 +159,7 @@ CPixmap::Blit ( { SDL_SetRenderTarget (g_renderer, m_SDLTextureInfo[dstCh].texture); res = SDL_RenderCopyEx ( - g_renderer, src, nullptr, &dstRect, angle, - nullptr, flip); + g_renderer, src, nullptr, &dstRect, angle, nullptr, flip); SDL_SetRenderTarget (g_renderer, target); } @@ -436,8 +435,7 @@ CPixmap::Cache ( switch (mode) { case FIX: - case FIX_REVERSABLE: - { + case FIX_REVERSABLE: { if (channel == CHBACK && (ow < LXIMAGE () || oh < LYIMAGE ())) { if (!wideName.empty ()) @@ -467,8 +465,7 @@ CPixmap::Cache ( } case EXPAND: - case EXPAND_REVERSABLE: - { + case EXPAND_REVERSABLE: { auto isFlipped = flip == SDL_FLIP_HORIZONTAL; SDL_Rect src, dst; diff --git a/src/pixmap.h b/src/pixmap.h index 5635fc8..0b07992 100644 --- a/src/pixmap.h +++ b/src/pixmap.h @@ -106,7 +106,9 @@ public: void FromGameToDisplay (Sint32 & x, Sint32 & y); Sint32 Blit ( - Sint32 dstCh, SDL_Texture * src, const SDL_Rect & dstRect, double angle, SDL_RendererFlip flip); + Sint32 dstCh, SDL_Texture * src, const SDL_Rect & dstRect, double angle, + SDL_RendererFlip flip); + protected: Sint32 BltFast ( Sint32 dstCh, size_t srcCh, Rect dstR, Rect srcR, @@ -133,11 +135,13 @@ protected: CEvent * event; - SDL_Cursor * m_lpCurrentCursor; - SDL_Cursor * m_lpSDLCursors[MAXCURSORS]; - SDL_Surface * m_lpSDLBlupi; + SDL_Cursor * m_lpCurrentCursor; + SDL_Cursor * m_lpSDLCursors[MAXCURSORS]; + SDL_Surface * m_lpSDLBlupi; + public: - SDL_Texture * mainTexture; + SDL_Texture * mainTexture; + protected: std::unordered_map m_SDLTextureInfo; }; diff --git a/src/platform.h b/src/platform.h index 51fa9ca..07d79d5 100644 --- a/src/platform.h +++ b/src/platform.h @@ -24,7 +24,7 @@ class Platform { private: - static std::function handleEvent; + static std::function handleEvent; private: static void timer (void *); @@ -33,5 +33,5 @@ public: enum Type { JS, SDL }; static Platform::Type getType (); - static void run (std::function handleEvent); + static void run (std::function handleEvent); }; diff --git a/src/platform/platform_js.cxx b/src/platform/platform_js.cxx index 2917967..111423b 100644 --- a/src/platform/platform_js.cxx +++ b/src/platform/platform_js.cxx @@ -24,7 +24,7 @@ #include "../event.h" #include "../platform.h" -std::function Platform::handleEvent; +std::function Platform::handleEvent; Platform::Type Platform::getType () @@ -33,12 +33,12 @@ Platform::getType () } void -Platform::run (std::function handleEvent) +Platform::run (std::function handleEvent) { Platform::handleEvent = handleEvent; Platform::timer (nullptr); emscripten_set_main_loop ( - []() { + [] () { SDL_Event event; while (SDL_PollEvent (&event)) { diff --git a/src/platform/platform_sdl.cxx b/src/platform/platform_sdl.cxx index b0b44cb..63b5058 100644 --- a/src/platform/platform_sdl.cxx +++ b/src/platform/platform_sdl.cxx @@ -21,7 +21,7 @@ #include "../event.h" #include "../platform.h" -std::function Platform::handleEvent; +std::function Platform::handleEvent; Platform::Type Platform::getType () @@ -30,11 +30,11 @@ Platform::getType () } void -Platform::run (std::function handleEvent) +Platform::run (std::function handleEvent) { SDL_TimerID updateTimer = SDL_AddTimer ( g_timerInterval, - [](Uint32 interval, void * param) -> Uint32 { + [] (Uint32 interval, void * param) -> Uint32 { CEvent::PushUserEvent (EV_UPDATE); return interval; }, diff --git a/src/sound.cxx b/src/sound.cxx index bdab2c1..f6c9229 100644 --- a/src/sound.cxx +++ b/src/sound.cxx @@ -127,7 +127,7 @@ CSound::Create () Mix_AllocateChannels (MAXSOUND); - Mix_HookMusicFinished ([]() { CEvent::PushUserEvent (EV_MUSIC_STOP); }); + Mix_HookMusicFinished ([] () { CEvent::PushUserEvent (EV_MUSIC_STOP); }); return true; } diff --git a/src/sound.h b/src/sound.h index b2f6edb..e0c0b11 100644 --- a/src/sound.h +++ b/src/sound.h @@ -61,7 +61,7 @@ public: Sint32 channel, Sint32 volume = 0, Uint8 panLeft = 255, Uint8 panRight = 255); bool - PlayImage (Sounds channel, Point pos, Sint32 rank = -1, bool stop = false); + PlayImage (Sounds channel, Point pos, Sint32 rank = -1, bool stop = false); bool PlayMusic (const std::string & lpszMIDIFilename); bool RestartMusic (); void SuspendMusic (); diff --git a/src/text.cxx b/src/text.cxx index 9aedec4..31c77e3 100644 --- a/src/text.cxx +++ b/src/text.cxx @@ -145,7 +145,11 @@ public: TTF_SetFontDirection (this->font, TTF_DIRECTION_RTL); } - ~Font () { this->cache.Clear (); TTF_CloseFont (this->font); } + ~Font () + { + this->cache.Clear (); + TTF_CloseFont (this->font); + } TTF_Font * GetFont () { return this->font; } @@ -390,9 +394,7 @@ public: TTF_SetFontScriptName (this->arabicWhite->GetFont (), "Arab"); } - ~Fonts () - { - } + ~Fonts () {} void Clear () { diff --git a/src/text.h b/src/text.h index 59edaf1..30b7c10 100644 --- a/src/text.h +++ b/src/text.h @@ -30,7 +30,7 @@ class Fonts; Fonts * GetFonts (); -void DisposeFonts (); +void DisposeFonts (); void DrawText ( CPixmap * pPixmap, Point pos, const char * pText, Sint32 font = 0,