Codechange: make explicit when a TileIndex is cast to its basetype (#11190)

This prevents people accidentially assigning a TileIndex to a Date
or any other type they shouldn't.
This commit is contained in:
Patric Stout
2023-08-15 18:12:05 +02:00
committed by GitHub
parent 5d3f7939e2
commit 07730584d7
31 changed files with 120 additions and 105 deletions

View File

@@ -13,12 +13,19 @@
#include "window_type.h"
#include "company_type.h"
#include "core/geometry_type.hpp"
#include "core/strong_typedef_type.hpp"
Window *FindWindowById(WindowClass cls, WindowNumber number);
Window *FindWindowByClass(WindowClass cls);
Window *GetMainWindow();
void ChangeWindowOwner(Owner old_owner, Owner new_owner);
template<typename T, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::value, int> = 0>
Window *FindWindowById(WindowClass cls, T number)
{
return FindWindowById(cls, static_cast<typename T::BaseType>(number));
}
void ResizeWindow(Window *w, int x, int y, bool clamp_to_screen = true);
int PositionMainToolbar(Window *w);
int PositionStatusbar(Window *w);
@@ -37,6 +44,12 @@ void InputLoop();
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data = 0, bool gui_scope = false);
void InvalidateWindowClassesData(WindowClass cls, int data = 0, bool gui_scope = false);
template<typename T, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::value, int> = 0>
void InvalidateWindowData(WindowClass cls, T number, int data = 0, bool gui_scope = false)
{
InvalidateWindowData(cls, static_cast<typename T::BaseType>(number), data, gui_scope);
}
void CloseNonVitalWindows();
void CloseAllNonVitalWindows();
void DeleteAllMessages();
@@ -54,9 +67,21 @@ void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, byte widget_inde
void SetWindowDirty(WindowClass cls, WindowNumber number);
void SetWindowClassesDirty(WindowClass cls);
template<typename T, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::value, int> = 0>
void SetWindowDirty(WindowClass cls, T number)
{
SetWindowDirty(cls, static_cast<typename T::BaseType>(number));
}
void CloseWindowById(WindowClass cls, WindowNumber number, bool force = true);
void CloseWindowByClass(WindowClass cls);
template<typename T, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::value, int> = 0>
void CloseWindowById(WindowClass cls, T number, bool force = true)
{
CloseWindowById(cls, static_cast<typename T::BaseType>(number), force);
}
bool EditBoxInGlobalFocus();
bool FocusedWindowIsConsole();
Point GetCaretPosition();