mirror of https://github.com/OpenTTD/OpenTTD
Cleanup: remove unneeded labels and gotos.
The window list supports deletion of arbitrary windows, while iterating over it.pull/9261/head
parent
ba193f2e23
commit
95abdfdef9
|
@ -1168,14 +1168,10 @@ void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
|
||||||
*/
|
*/
|
||||||
void DeleteWindowByClass(WindowClass cls)
|
void DeleteWindowByClass(WindowClass cls)
|
||||||
{
|
{
|
||||||
restart_search:
|
/* Note: the container remains stable, even when deleting windows. */
|
||||||
/* When we find the window to delete, we need to restart the search
|
|
||||||
* as deleting this window could cascade in deleting (many) others
|
|
||||||
* anywhere in the z-array */
|
|
||||||
for (Window *w : Window::IterateFromBack()) {
|
for (Window *w : Window::IterateFromBack()) {
|
||||||
if (w->window_class == cls) {
|
if (w->window_class == cls) {
|
||||||
delete w;
|
delete w;
|
||||||
goto restart_search;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1188,14 +1184,10 @@ restart_search:
|
||||||
*/
|
*/
|
||||||
void DeleteCompanyWindows(CompanyID id)
|
void DeleteCompanyWindows(CompanyID id)
|
||||||
{
|
{
|
||||||
restart_search:
|
/* Note: the container remains stable, even when deleting windows. */
|
||||||
/* When we find the window to delete, we need to restart the search
|
|
||||||
* as deleting this window could cascade in deleting (many) others
|
|
||||||
* anywhere in the z-array */
|
|
||||||
for (Window *w : Window::IterateFromBack()) {
|
for (Window *w : Window::IterateFromBack()) {
|
||||||
if (w->owner == id) {
|
if (w->owner == id) {
|
||||||
delete w;
|
delete w;
|
||||||
goto restart_search;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3325,10 +3317,7 @@ void CallWindowGameTickEvent()
|
||||||
*/
|
*/
|
||||||
void DeleteNonVitalWindows()
|
void DeleteNonVitalWindows()
|
||||||
{
|
{
|
||||||
restart_search:
|
/* Note: the container remains stable, even when deleting windows. */
|
||||||
/* When we find the window to delete, we need to restart the search
|
|
||||||
* as deleting this window could cascade in deleting (many) others
|
|
||||||
* anywhere in the z-array */
|
|
||||||
for (const Window *w : Window::IterateFromBack()) {
|
for (const Window *w : Window::IterateFromBack()) {
|
||||||
if (w->window_class != WC_MAIN_WINDOW &&
|
if (w->window_class != WC_MAIN_WINDOW &&
|
||||||
w->window_class != WC_SELECT_GAME &&
|
w->window_class != WC_SELECT_GAME &&
|
||||||
|
@ -3338,7 +3327,6 @@ restart_search:
|
||||||
(w->flags & WF_STICKY) == 0) { // do not delete windows which are 'pinned'
|
(w->flags & WF_STICKY) == 0) { // do not delete windows which are 'pinned'
|
||||||
|
|
||||||
delete w;
|
delete w;
|
||||||
goto restart_search;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3355,14 +3343,10 @@ void DeleteAllNonVitalWindows()
|
||||||
/* Delete every window except for stickied ones, then sticky ones as well */
|
/* Delete every window except for stickied ones, then sticky ones as well */
|
||||||
DeleteNonVitalWindows();
|
DeleteNonVitalWindows();
|
||||||
|
|
||||||
restart_search:
|
/* Note: the container remains stable, even when deleting windows. */
|
||||||
/* When we find the window to delete, we need to restart the search
|
|
||||||
* as deleting this window could cascade in deleting (many) others
|
|
||||||
* anywhere in the z-array */
|
|
||||||
for (const Window *w : Window::IterateFromBack()) {
|
for (const Window *w : Window::IterateFromBack()) {
|
||||||
if (w->flags & WF_STICKY) {
|
if (w->flags & WF_STICKY) {
|
||||||
delete w;
|
delete w;
|
||||||
goto restart_search;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3384,14 +3368,10 @@ void DeleteAllMessages()
|
||||||
*/
|
*/
|
||||||
void DeleteConstructionWindows()
|
void DeleteConstructionWindows()
|
||||||
{
|
{
|
||||||
restart_search:
|
/* Note: the container remains stable, even when deleting windows. */
|
||||||
/* When we find the window to delete, we need to restart the search
|
|
||||||
* as deleting this window could cascade in deleting (many) others
|
|
||||||
* anywhere in the z-array */
|
|
||||||
for (const Window *w : Window::IterateFromBack()) {
|
for (const Window *w : Window::IterateFromBack()) {
|
||||||
if (w->window_desc->flags & WDF_CONSTRUCTION) {
|
if (w->window_desc->flags & WDF_CONSTRUCTION) {
|
||||||
delete w;
|
delete w;
|
||||||
goto restart_search;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue