Remove: ENABLE_NETWORK switch
This switch has been a pain for years. Often disabling broke compilation, as no developer compiles OpenTTD without, neither do any of our official binaries. Additionaly, it has grown so hugely in our codebase, that it clearly shows that the current solution was a poor one. 350+ instances of "#ifdef ENABLE_NETWORK" were in the code, of which only ~30 in the networking code itself. The rest were all around the code to do the right thing, from GUI to NewGRF. A more proper solution would be to stub all the functions, and make sure the rest of the code can simply assume network is available. This was also partially done, and most variables were correct if networking was disabled. Despite that, often the #ifdefs were still used. With the recent removal of DOS, there is also no platform anymore which we support where networking isn't working out-of-the-box. All in all, it is time to remove the ENABLE_NETWORK switch. No replacement is planned, but if you feel we really need this option, we welcome any Pull Request which implements this in a way that doesn't crawl through the code like this diff shows we used to.
This commit is contained in:
@@ -158,11 +158,9 @@ public:
|
||||
int lock_offset = (bottom - top - lock_size.height) / 2;
|
||||
|
||||
DrawCompanyIcon(company, rtl ? right - this->icon_size.width - WD_FRAMERECT_RIGHT : left + WD_FRAMERECT_LEFT, top + icon_offset);
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (NetworkCompanyIsPassworded(company)) {
|
||||
DrawSprite(SPR_LOCK, PAL_NONE, rtl ? left + WD_FRAMERECT_LEFT : right - this->lock_size.width - WD_FRAMERECT_RIGHT, top + lock_offset);
|
||||
}
|
||||
#endif
|
||||
|
||||
SetDParam(0, company);
|
||||
SetDParam(1, company);
|
||||
@@ -223,7 +221,6 @@ static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0)
|
||||
|
||||
switch (widget) {
|
||||
case WID_TN_COMPANIES:
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (!_networking) break;
|
||||
|
||||
/* Add the client list button for the companies menu */
|
||||
@@ -234,7 +231,6 @@ static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0)
|
||||
} else {
|
||||
*list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, NetworkMaxSpectatorsReached());
|
||||
}
|
||||
#endif /* ENABLE_NETWORK */
|
||||
break;
|
||||
|
||||
case WID_TN_STORY:
|
||||
@@ -610,7 +606,6 @@ static CallBackFunction ToolbarCompaniesClick(Window *w)
|
||||
*/
|
||||
static CallBackFunction MenuClickCompany(int index)
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (_networking) {
|
||||
switch (index) {
|
||||
case CTMN_CLIENT_LIST:
|
||||
@@ -635,7 +630,6 @@ static CallBackFunction MenuClickCompany(int index)
|
||||
return CBF_NONE;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_NETWORK */
|
||||
ShowCompany((CompanyID)index);
|
||||
return CBF_NONE;
|
||||
}
|
||||
@@ -2076,9 +2070,7 @@ struct MainToolbarWindow : Window {
|
||||
case MTHK_CHEATS: if (!_networking) ShowCheatWindow(); break;
|
||||
case MTHK_TERRAFORM: ShowTerraformToolbar(); break;
|
||||
case MTHK_EXTRA_VIEWPORT: ShowExtraViewPortWindowForTileUnderCursor(); break;
|
||||
#ifdef ENABLE_NETWORK
|
||||
case MTHK_CLIENT_LIST: if (_networking) ShowClientList(); break;
|
||||
#endif
|
||||
case MTHK_SIGN_LIST: ShowSignList(); break;
|
||||
default: return ES_NOT_HANDLED;
|
||||
}
|
||||
@@ -2189,9 +2181,7 @@ static Hotkey maintoolbar_hotkeys[] = {
|
||||
Hotkey(WKC_CTRL | WKC_ALT | 'C', "cheats", MTHK_CHEATS),
|
||||
Hotkey('L', "terraform", MTHK_TERRAFORM),
|
||||
Hotkey('V', "extra_viewport", MTHK_EXTRA_VIEWPORT),
|
||||
#ifdef ENABLE_NETWORK
|
||||
Hotkey((uint16)0, "client_list", MTHK_CLIENT_LIST),
|
||||
#endif
|
||||
Hotkey((uint16)0, "sign_list", MTHK_SIGN_LIST),
|
||||
HOTKEY_LIST_END
|
||||
};
|
||||
|
Reference in New Issue
Block a user