summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-12-19 20:50:21 +0000
committertruebrain <truebrain@openttd.org>2011-12-19 20:50:21 +0000
commit561b25d0319674716b51d63594e146132d0a33e3 (patch)
tree9329a875bcf71cf40becc5b8a254db8ddfdcf05e /src/network
parentbcbdc3933c4aeff90692a1059375b1f590e7c904 (diff)
downloadopenttd-561b25d0319674716b51d63594e146132d0a33e3.tar.xz
(svn r23601) -Fix: fix the conflict in window number
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network.cpp2
-rw-r--r--src/network/network_client.cpp26
-rw-r--r--src/network/network_content.cpp4
-rw-r--r--src/network/network_content_gui.cpp22
-rw-r--r--src/network/network_gui.cpp29
5 files changed, 43 insertions, 40 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index dd47be172..52c6cb464 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -791,7 +791,7 @@ void NetworkDisconnect(bool blocking, bool close_admins)
if (_settings_client.network.server_advertise) NetworkUDPRemoveAdvertise(blocking);
- DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+ DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
NetworkClose(close_admins);
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index fd133dc54..0c7ef4536 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -181,7 +181,7 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res)
this->CloseConnection(res);
_networking = false;
- DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+ DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
return;
}
@@ -314,7 +314,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendCompanyInformationQuery()
{
my_client->status = STATUS_COMPANY_INFO;
_network_join_status = NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO;
- SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
+ SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
Packet *p = new Packet(PACKET_CLIENT_COMPANY_INFO);
my_client->SendPacket(p);
@@ -326,7 +326,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendJoin()
{
my_client->status = STATUS_JOIN;
_network_join_status = NETWORK_JOIN_STATUS_AUTHORIZING;
- SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
+ SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
Packet *p = new Packet(PACKET_CLIENT_JOIN);
p->Send_string(_openttd_revision);
@@ -531,7 +531,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_FULL(Packet *p)
{
/* We try to join a server which is full */
ShowErrorMessage(STR_NETWORK_ERROR_SERVER_FULL, INVALID_STRING_ID, WL_CRITICAL);
- DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+ DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
return NETWORK_RECV_STATUS_SERVER_FULL;
}
@@ -540,7 +540,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_BANNED(Packet *
{
/* We try to join a server where we are banned */
ShowErrorMessage(STR_NETWORK_ERROR_SERVER_BANNED, INVALID_STRING_ID, WL_CRITICAL);
- DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+ DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
return NETWORK_RECV_STATUS_SERVER_BANNED;
}
@@ -578,7 +578,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_COMPANY_INFO(Pa
p->Recv_string(company_info->clients, sizeof(company_info->clients));
- SetWindowDirty(WC_NETWORK_WINDOW, 0);
+ SetWindowDirty(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
return NETWORK_RECV_STATUS_OKAY;
}
@@ -675,7 +675,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_ERROR(Packet *p
ShowErrorMessage(STR_NETWORK_ERROR_LOSTCONNECTION, INVALID_STRING_ID, WL_CRITICAL);
}
- DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+ DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
return NETWORK_RECV_STATUS_SERVER_ERROR;
}
@@ -770,7 +770,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_WAIT(Packet *p)
/* But... only now we set the join status to waiting, instead of requesting. */
_network_join_status = NETWORK_JOIN_STATUS_WAITING;
_network_join_waiting = p->Recv_uint8();
- SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
+ SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
return NETWORK_RECV_STATUS_OKAY;
}
@@ -790,7 +790,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_BEGIN(Packe
_network_join_bytes_total = 0;
_network_join_status = NETWORK_JOIN_STATUS_DOWNLOADING;
- SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
+ SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
return NETWORK_RECV_STATUS_OKAY;
}
@@ -801,7 +801,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_SIZE(Packet
if (this->savegame == NULL) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
_network_join_bytes_total = p->Recv_uint32();
- SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
+ SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
return NETWORK_RECV_STATUS_OKAY;
}
@@ -815,7 +815,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DATA(Packet
this->savegame->AddPacket(p);
_network_join_bytes = (uint32)this->savegame->written_bytes;
- SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
+ SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
return NETWORK_RECV_STATUS_OKAY;
}
@@ -826,7 +826,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet
if (this->savegame == NULL) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
_network_join_status = NETWORK_JOIN_STATUS_PROCESSING;
- SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
+ SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
/*
* Make sure everything is set for reading.
@@ -847,7 +847,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet
this->last_packet = _realtime_tick;
if (!load_success) {
- DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+ DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
ShowErrorMessage(STR_NETWORK_ERROR_SAVEGAMEERROR, INVALID_STRING_ID, WL_CRITICAL);
return NETWORK_RECV_STATUS_SAVEGAME;
}
diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp
index 6499e5274..0e08cb705 100644
--- a/src/network/network_content.cpp
+++ b/src/network/network_content.cpp
@@ -475,7 +475,7 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_CONTENT(Packet *p)
/* We have a file opened, thus are downloading internal content */
size_t toRead = (size_t)(p->size - p->pos);
if (fwrite(p->buffer + p->pos, 1, toRead, this->curFile) != toRead) {
- DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+ DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD);
ShowErrorMessage(STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD, STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD_FILE_NOT_WRITABLE, WL_ERROR);
this->Close();
fclose(this->curFile);
@@ -509,7 +509,7 @@ bool ClientNetworkContentSocketHandler::BeforeDownload()
const char *filename = GetFullFilename(this->curInfo, true);
if (filename == NULL || (this->curFile = fopen(filename, "wb")) == NULL) {
/* Unless that fails ofcourse... */
- DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+ DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD);
ShowErrorMessage(STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD, STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD_FILE_NOT_WRITABLE, WL_ERROR);
return false;
}
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index a4981124a..4eef3e502 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -55,7 +55,7 @@ BaseNetworkContentDownloadStatusWindow::BaseNetworkContentDownloadStatusWindow(c
_network_content_client.AddCallback(this);
_network_content_client.DownloadSelectedContent(this->total_files, this->total_bytes);
- this->InitNested(desc, 0);
+ this->InitNested(desc, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD);
}
BaseNetworkContentDownloadStatusWindow::~BaseNetworkContentDownloadStatusWindow()
@@ -117,7 +117,7 @@ public:
*/
NetworkContentDownloadStatusWindow() : BaseNetworkContentDownloadStatusWindow(&_network_content_download_status_window_desc)
{
- this->parent = FindWindowById(WC_NETWORK_WINDOW, 1);
+ this->parent = FindWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST);
}
/** Free whatever we've allocated */
@@ -163,17 +163,17 @@ public:
case CONTENT_TYPE_BASE_GRAPHICS:
BaseGraphics::FindSets();
- SetWindowDirty(WC_GAME_OPTIONS, 0);
+ SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS);
break;
case CONTENT_TYPE_BASE_SOUNDS:
BaseSounds::FindSets();
- SetWindowDirty(WC_GAME_OPTIONS, 0);
+ SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS);
break;
case CONTENT_TYPE_BASE_MUSIC:
BaseMusic::FindSets();
- SetWindowDirty(WC_GAME_OPTIONS, 0);
+ SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS);
break;
case CONTENT_TYPE_NEWGRF:
@@ -193,7 +193,7 @@ public:
}
/* Always invalidate the download window; tell it we are going to be gone */
- InvalidateWindowData(WC_NETWORK_WINDOW, 1, 2);
+ InvalidateWindowData(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST, 2);
}
virtual void OnClick(Point pt, int widget, int click_count)
@@ -205,7 +205,7 @@ public:
} else {
/* If downloading succeeded, close the online content window. This will close
* the current window as well. */
- DeleteWindowById(WC_NETWORK_WINDOW, 1);
+ DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST);
}
}
}
@@ -357,7 +357,7 @@ public:
{
this->CreateNestedTree(desc);
this->vscroll = this->GetScrollbar(WID_NCL_SCROLLBAR);
- this->FinishInitNested(desc, 1);
+ this->FinishInitNested(desc, WN_NETWORK_WINDOW_CONTENT_LIST);
this->GetWidget<NWidgetStacked>(WID_NCL_SEL_ALL_UPDATE)->SetDisplayedPlane(select_all);
@@ -658,7 +658,7 @@ public:
break;
case WID_NCL_DOWNLOAD:
- if (BringWindowToFrontById(WC_NETWORK_STATUS_WINDOW, 0) == NULL) new NetworkContentDownloadStatusWindow();
+ if (BringWindowToFrontById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD) == NULL) new NetworkContentDownloadStatusWindow();
break;
}
}
@@ -801,7 +801,7 @@ public:
}
/* If data == 2 then the status window caused this OnInvalidate */
- this->SetWidgetDisabledState(WID_NCL_DOWNLOAD, this->filesize_sum == 0 || (FindWindowById(WC_NETWORK_STATUS_WINDOW, 0) != NULL && data != 2));
+ this->SetWidgetDisabledState(WID_NCL_DOWNLOAD, this->filesize_sum == 0 || (FindWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD) != NULL && data != 2));
this->SetWidgetDisabledState(WID_NCL_UNSELECT, this->filesize_sum == 0);
this->SetWidgetDisabledState(WID_NCL_SELECT_ALL, !show_select_all);
this->SetWidgetDisabledState(WID_NCL_SELECT_UPDATE, !show_select_upgrade);
@@ -915,7 +915,7 @@ void ShowNetworkContentListWindow(ContentVector *cv, ContentType type)
_network_content_client.RequestContentList(cv, true);
}
- DeleteWindowById(WC_NETWORK_WINDOW, 1);
+ DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST);
new NetworkContentListWindow(&_network_content_list_desc, cv != NULL);
#else
ShowErrorMessage(STR_CONTENT_NO_ZLIB, STR_CONTENT_NO_ZLIB_SUB, WL_ERROR);
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 3d84bd373..82d74bb2f 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -74,7 +74,7 @@ void SortNetworkLanguages()
*/
void UpdateNetworkGameWindow(bool unselect)
{
- InvalidateWindowData(WC_NETWORK_WINDOW, 0, unselect ? 1 : 0);
+ InvalidateWindowData(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME, unselect ? 1 : 0);
}
typedef GUIList<NetworkGameList*> GUIGameServerList;
@@ -425,7 +425,7 @@ public:
{
this->CreateNestedTree(desc);
this->vscroll = this->GetScrollbar(WID_NG_SCROLLBAR);
- this->FinishInitNested(desc, 0);
+ this->FinishInitNested(desc, WN_NETWORK_WINDOW_GAME);
ttd_strlcpy(this->edit_str_buf, _settings_client.network.client_name, this->edit_str_size);
this->afilter = CS_ALPHANUMERAL;
@@ -651,7 +651,7 @@ public:
this->field = widget;
switch (widget) {
case WID_NG_CANCEL: // Cancel button
- DeleteWindowById(WC_NETWORK_WINDOW, 0);
+ DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
break;
case WID_NG_CONN_BTN: // 'Connection' droplist
@@ -980,7 +980,8 @@ static const WindowDesc _network_game_window_desc(
void ShowNetworkGameWindow()
{
static bool first = true;
- DeleteWindowById(WC_NETWORK_WINDOW, 0);
+ DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_LOBBY);
+ DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_START);
/* Only show once */
if (first) {
@@ -1000,7 +1001,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
NetworkStartServerWindow(const WindowDesc *desc) : QueryStringBaseWindow(NETWORK_NAME_LENGTH)
{
- this->InitNested(desc, 0);
+ this->InitNested(desc, WN_NETWORK_WINDOW_START);
ttd_strlcpy(this->edit_str_buf, _settings_client.network.server_name, this->edit_str_size);
@@ -1316,7 +1317,8 @@ static const WindowDesc _network_start_server_window_desc(
static void ShowNetworkStartServerWindow()
{
- DeleteWindowById(WC_NETWORK_WINDOW, 0);
+ DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
+ DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_LOBBY);
new NetworkStartServerWindow(&_network_start_server_window_desc);
}
@@ -1332,7 +1334,7 @@ struct NetworkLobbyWindow : public Window {
{
this->CreateNestedTree(desc);
this->vscroll = this->GetScrollbar(WID_NL_SCROLLBAR);
- this->FinishInitNested(desc, 0);
+ this->FinishInitNested(desc, WN_NETWORK_WINDOW_LOBBY);
this->OnResize();
}
@@ -1608,7 +1610,8 @@ static const WindowDesc _network_lobby_window_desc(
*/
static void ShowNetworkLobbyWindow(NetworkGameList *ngl)
{
- DeleteWindowById(WC_NETWORK_WINDOW, 0);
+ DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_START);
+ DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
NetworkTCPQueryServer(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port)); // company info
NetworkUDPQueryServer(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port)); // general data
@@ -1623,7 +1626,7 @@ static void ShowNetworkLobbyWindow(NetworkGameList *ngl)
*/
NetworkCompanyInfo *GetLobbyCompanyInfo(CompanyID company)
{
- NetworkLobbyWindow *lobby = dynamic_cast<NetworkLobbyWindow*>(FindWindowById(WC_NETWORK_WINDOW, 0));
+ NetworkLobbyWindow *lobby = dynamic_cast<NetworkLobbyWindow*>(FindWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_LOBBY));
return (lobby != NULL && company < MAX_COMPANIES) ? &lobby->company_info[company] : NULL;
}
@@ -1990,8 +1993,8 @@ struct NetworkJoinStatusWindow : Window {
NetworkJoinStatusWindow(const WindowDesc *desc) : Window()
{
- this->parent = FindWindowById(WC_NETWORK_WINDOW, 0);
- this->InitNested(desc, 0);
+ this->parent = FindWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
+ this->InitNested(desc, WN_NETWORK_STATUS_WINDOW_JOIN);
}
virtual void DrawWidget(const Rect &r, int widget) const
@@ -2100,13 +2103,13 @@ static const WindowDesc _network_join_status_window_desc(
void ShowJoinStatusWindow()
{
- DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+ DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
new NetworkJoinStatusWindow(&_network_join_status_window_desc);
}
void ShowNetworkNeedPassword(NetworkPasswordType npt)
{
- NetworkJoinStatusWindow *w = (NetworkJoinStatusWindow *)FindWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+ NetworkJoinStatusWindow *w = (NetworkJoinStatusWindow *)FindWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
if (w == NULL) return;
w->password_type = npt;