summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-01-20 21:05:13 +0000
committerrubidium <rubidium@openttd.org>2009-01-20 21:05:13 +0000
commitff328bf68b2ff38489e9bc4d49282f6edcfe61fa (patch)
tree22fb93915d8e91a7f522f54378a99954ea007ef4 /src
parent052c957a94149bc79a46720a8724fed29bb524d6 (diff)
downloadopenttd-ff328bf68b2ff38489e9bc4d49282f6edcfe61fa.tar.xz
(svn r15178) -Change: rename 'update' to 'upgrade' as that's a bit more clear
Diffstat (limited to 'src')
-rw-r--r--src/lang/english.txt4
-rw-r--r--src/network/core/tcp_content.h4
-rw-r--r--src/network/network_content.cpp25
-rw-r--r--src/network/network_content.h4
-rw-r--r--src/network/network_content_gui.cpp19
5 files changed, 30 insertions, 26 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 711b1320e..6b89e7609 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -3725,8 +3725,8 @@ STR_CONTENT_NAME_CAPTION_TIP :{BLACK}Name of
STR_CONTENT_MATRIX_TIP :{BLACK}Click on a line to see the details{}Click on the checkbox to select it for downloading
STR_CONTENT_SELECT_ALL_CAPTION :{BLACK}Select all
STR_CONTENT_SELECT_ALL_CAPTION_TIP :{BLACK}Mark all content to be downloaded
-STR_CONTENT_SELECT_UPDATES_CAPTION :{BLACK}Select updates
-STR_CONTENT_SELECT_UPDATES_CAPTION_TIP :{BLACK}Mark all content that is an update for existing content to be downloaded
+STR_CONTENT_SELECT_UPDATES_CAPTION :{BLACK}Select upgrades
+STR_CONTENT_SELECT_UPDATES_CAPTION_TIP :{BLACK}Mark all content that is an upgrade for existing content to be downloaded
STR_CONTENT_UNSELECT_ALL_CAPTION :{BLACK}Unselect all
STR_CONTENT_UNSELECT_ALL_CAPTION_TIP :{BLACK}Mark all content to be not downloaded
STR_CONTENT_DOWNLOAD_CAPTION :{BLACK}Download
diff --git a/src/network/core/tcp_content.h b/src/network/core/tcp_content.h
index e084f5fc7..4d304017a 100644
--- a/src/network/core/tcp_content.h
+++ b/src/network/core/tcp_content.h
@@ -71,7 +71,7 @@ struct ContentInfo {
uint8 tag_count; ///< Number of tags
char (*tags)[32]; ///< Malloced array of tags (strings)
State state; ///< Whether the content info is selected (for download)
- bool update; ///< This item is an update
+ bool upgrade; ///< This item is an upgrade
/** Clear everything in the struct */
ContentInfo();
@@ -103,7 +103,7 @@ class NetworkContentSocketHandler : public NetworkTCPSocketHandler {
protected:
struct sockaddr_in client_addr; ///< The address we're connected to.
NetworkRecvStatus CloseConnection();
- void Close();
+ virtual void Close();
/**
* Client requesting a list of content info:
diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp
index 978f9b9e9..66c2c2d5d 100644
--- a/src/network/network_content.cpp
+++ b/src/network/network_content.cpp
@@ -100,7 +100,7 @@ DEF_CONTENT_RECEIVE_COMMAND(Client, PACKET_CONTENT_SERVER_INFO)
ci->state = ContentInfo::ALREADY_HERE;
} else {
ci->state = ContentInfo::UNSELECTED;
- if (proc(ci, false)) ci->update = true;
+ if (proc(ci, false)) ci->upgrade = true;
}
} else {
ci->state = ContentInfo::UNSELECTED;
@@ -116,6 +116,7 @@ DEF_CONTENT_RECEIVE_COMMAND(Client, PACKET_CONTENT_SERVER_INFO)
memcmp(ci->md5sum, ici->md5sum, sizeof(ci->md5sum)) == 0) {
/* Preserve the name if possible */
if (StrEmpty(ci->name)) strecpy(ci->name, ici->name, lastof(ci->name));
+ if (ici->IsSelected()) ci->state = ici->state;
delete ici;
*iter = ci;
@@ -145,6 +146,14 @@ DEF_CONTENT_RECEIVE_COMMAND(Client, PACKET_CONTENT_SERVER_INFO)
void ClientNetworkContentSocketHandler::RequestContentList(ContentType type)
{
+ if (type == CONTENT_TYPE_END) {
+ this->RequestContentList(CONTENT_TYPE_BASE_GRAPHICS);
+ this->RequestContentList(CONTENT_TYPE_AI);
+ this->RequestContentList(CONTENT_TYPE_NEWGRF);
+ this->RequestContentList(CONTENT_TYPE_AI_LIBRARY);
+ return;
+ }
+
this->Connect();
Packet *p = new Packet(PACKET_CONTENT_CLIENT_INFO_LIST);
@@ -457,10 +466,12 @@ void ClientNetworkContentSocketHandler::Connect()
/**
* Disconnect from the content server.
*/
-void ClientNetworkContentSocketHandler::Disconnect()
+void ClientNetworkContentSocketHandler::Close()
{
if (this->sock == INVALID_SOCKET) return;
- this->Close();
+ NetworkContentSocketHandler::Close();
+
+ this->OnDisconnect();
}
/**
@@ -532,7 +543,7 @@ ContentInfo *ClientNetworkContentSocketHandler::GetContent(ContentID cid)
void ClientNetworkContentSocketHandler::Select(ContentID cid)
{
ContentInfo *ci = this->GetContent(cid);
- if (ci->state != ContentInfo::UNSELECTED) return;
+ if (ci == NULL || ci->state != ContentInfo::UNSELECTED) return;
ci->state = ContentInfo::SELECTED;
this->CheckDependencyState(ci);
@@ -545,7 +556,7 @@ void ClientNetworkContentSocketHandler::Select(ContentID cid)
void ClientNetworkContentSocketHandler::Unselect(ContentID cid)
{
ContentInfo *ci = this->GetContent(cid);
- if (!ci->IsSelected()) return;
+ if (ci == NULL || !ci->IsSelected()) return;
ci->state = ContentInfo::UNSELECTED;
this->CheckDependencyState(ci);
@@ -564,11 +575,11 @@ void ClientNetworkContentSocketHandler::SelectAll()
}
/** Select everything that's an update for something we've got */
-void ClientNetworkContentSocketHandler::SelectUpdate()
+void ClientNetworkContentSocketHandler::SelectUpgrade()
{
for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) {
ContentInfo *ci = *iter;
- if (ci->state == ContentInfo::UNSELECTED && ci->update) {
+ if (ci->state == ContentInfo::UNSELECTED && ci->upgrade) {
ci->state = ContentInfo::SELECTED;
this->CheckDependencyState(ci);
}
diff --git a/src/network/network_content.h b/src/network/network_content.h
index a566dafc4..ac169313f 100644
--- a/src/network/network_content.h
+++ b/src/network/network_content.h
@@ -90,7 +90,7 @@ public:
void Connect();
void SendReceive();
- void Disconnect();
+ void Close();
void RequestContentList(ContentType type);
void RequestContentList(uint count, const ContentID *content_ids);
@@ -101,7 +101,7 @@ public:
void Select(ContentID cid);
void Unselect(ContentID cid);
void SelectAll();
- void SelectUpdate();
+ void SelectUpgrade();
void UnselectAll();
void ToggleSelectedState(const ContentInfo *ci);
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index fa8b80d04..8b930168a 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -225,7 +225,7 @@ public:
/* To sum all the bytes we intend to download */
uint filesize = 0;
bool show_select_all = false;
- bool show_select_update = false;
+ bool show_select_upgrade = false;
for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) {
const ContentInfo *ci = *iter;
switch (ci->state) {
@@ -236,7 +236,7 @@ public:
case ContentInfo::UNSELECTED:
show_select_all = true;
- show_select_update |= ci->update;
+ show_select_upgrade |= ci->upgrade;
break;
default:
@@ -247,7 +247,7 @@ public:
this->SetWidgetDisabledState(NCLWW_DOWNLOAD, filesize == 0);
this->SetWidgetDisabledState(NCLWW_UNSELECT, filesize == 0);
this->SetWidgetDisabledState(NCLWW_SELECT_ALL, !show_select_all);
- this->SetWidgetDisabledState(NCLWW_SELECT_UPDATE, !show_select_update);
+ this->SetWidgetDisabledState(NCLWW_SELECT_UPDATE, !show_select_upgrade);
this->DrawWidgets();
@@ -292,7 +292,7 @@ public:
const uint max_y = this->widget[NCLWW_DETAILS].bottom - 15;
y = this->widget[NCLWW_DETAILS].top + 55;
- if (this->selected->update) {
+ if (this->selected->upgrade) {
SetDParam(0, STR_CONTENT_TYPE_BASE_GRAPHICS + this->selected->type - CONTENT_TYPE_BASE_GRAPHICS);
y += DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, y, STR_CONTENT_DETAIL_UPDATE, this->widget[NCLWW_DETAILS].right - this->widget[NCLWW_DETAILS].left - 5, max_y - y);
y += 11;
@@ -413,7 +413,7 @@ public:
break;
case NCLWW_SELECT_UPDATE:
- _network_content_client.SelectUpdate();
+ _network_content_client.SelectUpgrade();
this->SetDirty();
break;
@@ -565,14 +565,7 @@ void ShowNetworkContentListWindow(ContentVector *cv, ContentType type)
{
#if defined(WITH_ZLIB)
if (cv == NULL) {
- if (type == CONTENT_TYPE_END) {
- _network_content_client.RequestContentList(CONTENT_TYPE_BASE_GRAPHICS);
- _network_content_client.RequestContentList(CONTENT_TYPE_AI);
- _network_content_client.RequestContentList(CONTENT_TYPE_NEWGRF);
- _network_content_client.RequestContentList(CONTENT_TYPE_AI_LIBRARY);
- } else {
- _network_content_client.RequestContentList(type);
- }
+ _network_content_client.RequestContentList(type);
} else {
_network_content_client.RequestContentList(cv, true);
}