Skip to content

Commit 8d66dd0

Browse files
committed
Use default member initializers
1 parent 90d5e46 commit 8d66dd0

File tree

8 files changed

+35
-61
lines changed

8 files changed

+35
-61
lines changed

source/audio.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ static constexpr Sound RollOverSound(VOICE_MONO16, std::span{button_rollover_raw
2121
/**
2222
* Constructor for the Audio class.
2323
*/
24-
Audio::Audio() :
25-
Paused(false)
24+
Audio::Audio()
2625
{
2726
AESND_Init();
2827
AESND_Pause(false);

source/audio.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class Audio
2626
void PlaySoundScreenChange(u16 Volume);
2727
void PlaySoundButton(u16 Volume);
2828
private:
29-
bool Paused;
30-
Voice *ScreenVoice;
31-
Voice *ButtonVoice;
29+
bool Paused{false};
30+
Voice *ScreenVoice{nullptr};
31+
Voice *ButtonVoice{nullptr};
3232
};
3333
//---------------------------------------------------------------------------
3434
#endif

source/button.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@
1313
* @param[in] NewType Button type.
1414
*/
1515
Button::Button(buttonType NewType) : Object(),
16-
Focused(false),
17-
Selected(false),
18-
Caption(""),
19-
Font(nullptr),
20-
TextWidth(100), // random value
21-
TextHeight(14),
22-
TextTop(0),
23-
TextLeft(0),
24-
TextColor(0x000000FF),
2516
Type(NewType)
2617
{
2718
switch(Type)

source/button.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ enum class buttonType : u8 {
2828
class Button : public Object
2929
{
3030
public:
31-
Button(buttonType = buttonType::StdMenu);
31+
Button() = default;
32+
Button(buttonType NewType);
3233
Button(Button const&) = delete;
3334
~Button() = default;
3435
Button& operator=(Button const&) = delete;
@@ -40,16 +41,16 @@ class Button : public Object
4041
void SetTextColor(u32 NewColor);
4142
void SetTextHeight(unsigned int NewHeight);
4243
private:
43-
bool Focused;
44-
bool Selected;
45-
std::string Caption;
46-
GRRLIB_ttfFont *Font;
47-
unsigned int TextWidth;
48-
unsigned int TextHeight;
49-
unsigned int TextTop;
50-
unsigned int TextLeft;
51-
u32 TextColor;
52-
buttonType Type;
44+
bool Focused{false};
45+
bool Selected{false};
46+
std::string Caption{};
47+
GRRLIB_ttfFont *Font{nullptr};
48+
unsigned int TextWidth{100}; // random default value
49+
unsigned int TextHeight{14};
50+
unsigned int TextTop{0};
51+
unsigned int TextLeft{0};
52+
u32 TextColor{0x000000FF};
53+
buttonType Type{buttonType::StdMenu};
5354
std::unique_ptr<Texture> ButtonImgOn;
5455
std::unique_ptr<Texture> ButtonImgOff;
5556
std::unique_ptr<Texture> ButtonSelected;

source/object.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
#include "object.h"
22

3-
/**
4-
* Constructor for the Object class.
5-
*/
6-
Object::Object() :
7-
Left(0),
8-
Top(0),
9-
Width(0),
10-
Height(0),
11-
Angle(0.0),
12-
Visible(true),
13-
Color(0xFFFFFFFF)
14-
{
15-
}
16-
173
/**
184
* Get the left position of the object.
195
* @see SetLeft()

source/object.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
class Object
1717
{
1818
public:
19-
Object();
19+
/**
20+
* Constructor for the Object class.
21+
*/
22+
Object() = default;
2023
Object(Object const&) = delete;
2124
virtual ~Object() = default;
2225
Object& operator=(Object const&) = delete;
@@ -42,13 +45,13 @@ class Object
4245
protected:
4346
virtual void Paint() = 0; /**< Draw an image on screen. */
4447

45-
float Left; /**< Specifies the x-coordinate of the upper-left corner of the object. */
46-
float Top; /**< Specifies the y-coordinate of the upper-left corner of the object. */
47-
unsigned int Width; /**< The width of the object. */
48-
unsigned int Height;/**< The height of the object. */
49-
float Angle; /**< The angle in degree of the object. */
50-
bool Visible; /**< Control the visibility of the object. If Visible is true, the object appears. If Visible is false, the object is not visible. */
51-
u32 Color; /**< Color of the object (RGBA). */
48+
float Left{0.0f}; /**< Specifies the x-coordinate of the upper-left corner of the object. */
49+
float Top{0.0f}; /**< Specifies the y-coordinate of the upper-left corner of the object. */
50+
unsigned int Width{0}; /**< The width of the object. */
51+
unsigned int Height{0}; /**< The height of the object. */
52+
float Angle{0.0f}; /**< The angle in degree of the object. */
53+
bool Visible{true}; /**< Control the visibility of the object. If Visible is true, the object appears. If Visible is false, the object is not visible. */
54+
u32 Color{0xFFFFFFFF}; /**< Color of the object (RGBA). */
5255
//char *Name;
5356
//void *Parent;
5457
};

source/player.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
#include "player.h"
22

3-
/**
4-
* Constructor for the Player class.
5-
*/
6-
Player::Player() :
7-
Score(0),
8-
Type(playerType::Human)
9-
{
10-
}
11-
123
/**
134
* Set the player name.
145
* @param[in] AName Give a name to the player.

source/player.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ enum class playerType : u8 {
2525
class Player
2626
{
2727
public:
28-
Player();
28+
/**
29+
* Constructor for the Player class.
30+
*/
31+
Player() = default;
2932
Player(Player const&) = delete;
3033
~Player() = default;
3134
Player& operator=(Player const&) = delete;
@@ -39,10 +42,10 @@ class Player
3942
void SetType(playerType AType);
4043
[[nodiscard]] playerType GetType();
4144
private:
42-
u16 Score;
43-
std::string Name;
44-
u8 Sign;
45-
playerType Type;
45+
u16 Score{0};
46+
std::string Name{};
47+
u8 Sign{0};
48+
playerType Type{playerType::Human};
4649
};
4750
//---------------------------------------------------------------------------
4851
#endif

0 commit comments

Comments
 (0)