mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-10 08:00:05 +00:00
Codechange: Use dynamic_cast instead of C-cast after FindWindowById. (#12448)
dynamic_cast was used in most places, but not all.
This commit is contained in:
parent
4e6d4fcf32
commit
74e09abf76
@ -348,7 +348,7 @@ void ShowFirstError()
|
||||
*/
|
||||
void UnshowCriticalError()
|
||||
{
|
||||
ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0);
|
||||
ErrmsgWindow *w = dynamic_cast<ErrmsgWindow *>(FindWindowById(WC_ERRMSG, 0));
|
||||
if (_window_system_initialized && w != nullptr) {
|
||||
if (w->IsCritical()) _error_list.push_front(*w);
|
||||
_window_system_initialized = false;
|
||||
@ -414,7 +414,7 @@ void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel
|
||||
ErrorMessageData data(summary_msg, detailed_msg, is_critical, x, y, textref_stack_grffile, textref_stack_size, textref_stack, extra_msg);
|
||||
data.CopyOutDParams();
|
||||
|
||||
ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0);
|
||||
ErrmsgWindow *w = dynamic_cast<ErrmsgWindow *>(FindWindowById(WC_ERRMSG, 0));
|
||||
if (w != nullptr) {
|
||||
if (w->IsCritical()) {
|
||||
/* A critical error is currently shown. */
|
||||
@ -438,7 +438,7 @@ void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel
|
||||
*/
|
||||
bool HideActiveErrorMessage()
|
||||
{
|
||||
ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0);
|
||||
ErrmsgWindow *w = dynamic_cast<ErrmsgWindow *>(FindWindowById(WC_ERRMSG, 0));
|
||||
if (w == nullptr) return false;
|
||||
w->Close();
|
||||
return true;
|
||||
|
@ -1169,7 +1169,7 @@ void ShowCompanyGroupForVehicle(const Vehicle *v)
|
||||
*/
|
||||
static inline VehicleGroupWindow *FindVehicleGroupWindow(VehicleType vt, Owner owner)
|
||||
{
|
||||
return (VehicleGroupWindow *)FindWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_GROUP_LIST, vt, owner).Pack());
|
||||
return dynamic_cast<VehicleGroupWindow *>(FindWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_GROUP_LIST, vt, owner).Pack()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2234,7 +2234,7 @@ void ShowJoinStatusWindow()
|
||||
|
||||
void ShowNetworkNeedPassword(NetworkPasswordType npt, std::shared_ptr<NetworkAuthenticationPasswordRequest> request)
|
||||
{
|
||||
NetworkJoinStatusWindow *w = (NetworkJoinStatusWindow *)FindWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
|
||||
NetworkJoinStatusWindow *w = dynamic_cast<NetworkJoinStatusWindow *>(FindWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN));
|
||||
if (w == nullptr) return;
|
||||
w->request = request;
|
||||
|
||||
|
@ -1017,7 +1017,7 @@ static void ShowNewsMessage(NewsIterator ni)
|
||||
*/
|
||||
bool HideActiveNewsMessage()
|
||||
{
|
||||
NewsWindow *w = (NewsWindow*)FindWindowById(WC_NEWS_WINDOW, 0);
|
||||
NewsWindow *w = dynamic_cast<NewsWindow *>(FindWindowById(WC_NEWS_WINDOW, 0));
|
||||
if (w == nullptr) return false;
|
||||
w->Close();
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user