Codechange: explicitly initialise member variables of Windows

This commit is contained in:
Rubidium
2025-02-22 19:35:41 +01:00
committed by rubidium42
parent af32ce3710
commit c540c2bcf7
10 changed files with 110 additions and 135 deletions
+3 -5
View File
@@ -297,8 +297,8 @@ private:
/** Window to enter the chat message in. */
struct NetworkChatWindow : public Window {
DestType dtype; ///< The type of destination.
int dest; ///< The identifier of the destination.
DestType dtype{}; ///< The type of destination.
int dest = 0; ///< The identifier of the destination.
QueryString message_editbox; ///< Message editbox.
NetworkChatAutoCompletion chat_tab_completion; ///< Holds the state and logic of auto-completion of player names and towns on Tab press.
@@ -309,10 +309,8 @@ struct NetworkChatWindow : public Window {
* @param dest The actual destination index.
*/
NetworkChatWindow(WindowDesc &desc, DestType type, int dest)
: Window(desc), message_editbox(NETWORK_CHAT_LENGTH), chat_tab_completion(&message_editbox.text)
: Window(desc), dtype(type), dest(dest), message_editbox(NETWORK_CHAT_LENGTH), chat_tab_completion(&message_editbox.text)
{
this->dtype = type;
this->dest = dest;
this->querystrings[WID_NC_TEXTBOX] = &this->message_editbox;
this->message_editbox.cancel_button = WID_NC_CLOSE;
this->message_editbox.ok_button = WID_NC_SENDBUTTON;
+13 -16
View File
@@ -39,7 +39,7 @@ static bool _accepted_external_search = false;
/** Window for displaying the textfile of an item in the content list. */
struct ContentTextfileWindow : public TextfileWindow {
const ContentInfo *ci; ///< View the textfile of this ContentInfo.
const ContentInfo *ci = nullptr; ///< View the textfile of this ContentInfo.
ContentTextfileWindow(TextfileType file_type, const ContentInfo *ci) : TextfileWindow(file_type), ci(ci)
{
@@ -101,8 +101,7 @@ static WindowDesc _network_content_download_status_window_desc(
_nested_network_content_download_status_window_widgets
);
BaseNetworkContentDownloadStatusWindow::BaseNetworkContentDownloadStatusWindow(WindowDesc &desc) :
Window(desc), downloaded_bytes(0), downloaded_files(0), cur_id(UINT32_MAX)
BaseNetworkContentDownloadStatusWindow::BaseNetworkContentDownloadStatusWindow(WindowDesc &desc) : Window(desc)
{
_network_content_client.AddCallback(this);
_network_content_client.DownloadSelectedContent(this->total_files, this->total_bytes);
@@ -184,7 +183,7 @@ void BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(const ContentInf
/** Window for showing the download status of content */
struct NetworkContentDownloadStatusWindow : public BaseNetworkContentDownloadStatusWindow {
private:
std::vector<ContentType> receivedTypes; ///< Types we received so we can update their cache
std::vector<ContentType> receivedTypes{}; ///< Types we received so we can update their cache
public:
/**
@@ -330,16 +329,16 @@ class NetworkContentListWindow : public Window, ContentCallback {
static Filtering last_filtering; ///< The last filtering setting.
static const std::initializer_list<GUIContentList::SortFunction * const> sorter_funcs; ///< Sorter functions
static const std::initializer_list<GUIContentList::FilterFunction * const> filter_funcs; ///< Filter functions.
GUIContentList content; ///< List with content
bool auto_select; ///< Automatically select all content when the meta-data becomes available
ContentListFilterData filter_data; ///< Filter for content list
QueryString filter_editbox; ///< Filter editbox;
Dimension checkbox_size; ///< Size of checkbox/"blot" sprite
GUIContentList content{}; ///< List with content
bool auto_select = false; ///< Automatically select all content when the meta-data becomes available
ContentListFilterData filter_data{}; ///< Filter for content list
QueryString filter_editbox; ///< Filter editbox;
Dimension checkbox_size{}; ///< Size of checkbox/"blot" sprite
const ContentInfo *selected; ///< The selected content info
int list_pos; ///< Our position in the list
uint filesize_sum; ///< The sum of all selected file sizes
Scrollbar *vscroll; ///< Cache of the vertical scrollbar
const ContentInfo *selected = nullptr; ///< The selected content info
int list_pos = 0; ///< Our position in the list
uint filesize_sum = 0; ///< The sum of all selected file sizes
Scrollbar *vscroll = nullptr; ///< Cache of the vertical scrollbar
static std::string content_type_strs[CONTENT_TYPE_END]; ///< Cached strings for all content types.
@@ -539,9 +538,7 @@ public:
NetworkContentListWindow(WindowDesc &desc, bool select_all, const std::bitset<CONTENT_TYPE_END> &types) :
Window(desc),
auto_select(select_all),
filter_editbox(EDITBOX_MAX_SIZE),
selected(nullptr),
list_pos(0)
filter_editbox(EDITBOX_MAX_SIZE)
{
this->CreateNestedTree();
this->vscroll = this->GetScrollbar(WID_NCL_SCROLLBAR);
+6 -6
View File
@@ -17,13 +17,13 @@
/** Base window for showing the download status of content */
class BaseNetworkContentDownloadStatusWindow : public Window, ContentCallback {
protected:
uint total_bytes; ///< Number of bytes to download
uint downloaded_bytes; ///< Number of bytes downloaded
uint total_files; ///< Number of files to download
uint downloaded_files; ///< Number of files downloaded
uint total_bytes = 0; ///< Number of bytes to download
uint downloaded_bytes = 0; ///< Number of bytes downloaded
uint total_files = 0; ///< Number of files to download
uint downloaded_files = 0; ///< Number of files downloaded
uint32_t cur_id; ///< The current ID of the downloaded file
std::string name; ///< The current name of the downloaded file
uint32_t cur_id = UINT32_MAX; ///< The current ID of the downloaded file
std::string name{}; ///< The current name of the downloaded file
public:
/**
+26 -33
View File
@@ -182,17 +182,17 @@ protected:
static const std::initializer_list<GUIGameServerList::SortFunction * const> sorter_funcs;
static const std::initializer_list<GUIGameServerList::FilterFunction * const> filter_funcs;
NetworkGameList *server; ///< Selected server.
NetworkGameList *last_joined; ///< The last joined server.
GUIGameServerList servers; ///< List with game servers.
ServerListPosition list_pos; ///< Position of the selected server.
Scrollbar *vscroll; ///< Vertical scrollbar of the list of servers.
QueryString name_editbox; ///< Client name editbox.
QueryString filter_editbox; ///< Editbox for filter on servers.
NetworkGameList *server = nullptr; ///< Selected server.
NetworkGameList *last_joined = nullptr; ///< The last joined server.
GUIGameServerList servers{}; ///< List with game servers.
ServerListPosition list_pos = SLP_INVALID; ///< Position of the selected server.
Scrollbar *vscroll = nullptr; ///< Vertical scrollbar of the list of servers.
QueryString name_editbox; ///< Client name editbox.
QueryString filter_editbox; ///< Editbox for filter on servers.
bool searched_internet = false; ///< Did we ever press "Search Internet" button?
Dimension lock; /// Dimension of lock icon.
Dimension blot; /// Dimension of compatibility icon.
Dimension lock{}; /// Dimension of lock icon.
Dimension blot{}; /// Dimension of compatibility icon.
/**
* (Re)build the GUI network game list (a.k.a. this->servers) as some
@@ -433,9 +433,6 @@ protected:
public:
NetworkGameWindow(WindowDesc &desc) : Window(desc), name_editbox(NETWORK_CLIENT_NAME_LENGTH), filter_editbox(120)
{
this->list_pos = SLP_INVALID;
this->server = nullptr;
this->CreateNestedTree();
this->vscroll = this->GetScrollbar(WID_NG_SCROLLBAR);
this->FinishInitNested(WN_NETWORK_WINDOW_GAME);
@@ -967,8 +964,8 @@ void ShowNetworkGameWindow()
}
struct NetworkStartServerWindow : public Window {
WidgetID widget_id; ///< The widget that has the pop-up input menu
QueryString name_editbox; ///< Server name editbox.
WidgetID widget_id{}; ///< The widget that has the pop-up input menu
QueryString name_editbox; ///< Server name editbox.
NetworkStartServerWindow(WindowDesc &desc) : Window(desc), name_editbox(NETWORK_NAME_LENGTH)
{
@@ -1396,19 +1393,19 @@ using ClientButton = Button<ClientID>;
*/
struct NetworkClientListWindow : Window {
private:
ClientListWidgets query_widget; ///< During a query this tracks what widget caused the query.
ClientListWidgets query_widget{}; ///< During a query this tracks what widget caused the query.
ClientID dd_client_id; ///< During admin dropdown, track which client this was for.
CompanyID dd_company_id; ///< During admin dropdown, track which company this was for.
ClientID dd_client_id{}; ///< During admin dropdown, track which client this was for.
CompanyID dd_company_id = CompanyID::Invalid(); ///< During admin dropdown, track which company this was for.
Scrollbar *vscroll; ///< Vertical scrollbar of this window.
uint line_height; ///< Current lineheight of each entry in the matrix.
uint line_count; ///< Amount of lines in the matrix.
int hover_index; ///< Index of the current line we are hovering over, or -1 if none.
int player_self_index; ///< The line the current player is on.
int player_host_index; ///< The line the host is on.
Scrollbar *vscroll = nullptr; ///< Vertical scrollbar of this window.
uint line_height = 0; ///< Current lineheight of each entry in the matrix.
uint line_count = 0; ///< Amount of lines in the matrix.
int hover_index = -1; ///< Index of the current line we are hovering over, or -1 if none.
int player_self_index = -1; ///< The line the current player is on.
int player_host_index = -1; ///< The line the host is on.
std::map<uint, std::vector<std::unique_ptr<ButtonCommon>>> buttons; ///< Per line which buttons are available.
std::map<uint, std::vector<std::unique_ptr<ButtonCommon>>> buttons{}; ///< Per line which buttons are available.
/**
* Chat button on a Company is clicked.
@@ -1614,11 +1611,7 @@ private:
}
public:
NetworkClientListWindow(WindowDesc &desc, WindowNumber window_number) :
Window(desc),
hover_index(-1),
player_self_index(-1),
player_host_index(-1)
NetworkClientListWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc)
{
this->CreateNestedTree();
this->vscroll = this->GetScrollbar(WID_CL_SCROLLBAR);
@@ -2055,7 +2048,7 @@ uint32_t _network_join_bytes; ///< The number of bytes we already do
uint32_t _network_join_bytes_total; ///< The total number of bytes to download.
struct NetworkJoinStatusWindow : Window {
std::shared_ptr<NetworkAuthenticationPasswordRequest> request;
std::shared_ptr<NetworkAuthenticationPasswordRequest> request{};
NetworkJoinStatusWindow(WindowDesc &desc) : Window(desc)
{
@@ -2199,9 +2192,9 @@ void ShowNetworkNeedPassword(std::shared_ptr<NetworkAuthenticationPasswordReques
* Window used for asking the user if he is okay using a relay server.
*/
struct NetworkAskRelayWindow : public Window {
std::string server_connection_string; ///< The game server we want to connect to.
std::string relay_connection_string; ///< The relay server we want to connect to.
std::string token; ///< The token for this connection.
std::string server_connection_string{}; ///< The game server we want to connect to.
std::string relay_connection_string{}; ///< The relay server we want to connect to.
std::string token{}; ///< The token for this connection.
NetworkAskRelayWindow(WindowDesc &desc, Window *parent, const std::string &server_connection_string, const std::string &relay_connection_string, const std::string &token) :
Window(desc),