summaryrefslogtreecommitdiff
path: root/src/network/network_content.cpp
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/network/network_content.cpp
parent052c957a94149bc79a46720a8724fed29bb524d6 (diff)
downloadopenttd-ff328bf68b2ff38489e9bc4d49282f6edcfe61fa.tar.xz
(svn r15178) -Change: rename 'update' to 'upgrade' as that's a bit more clear
Diffstat (limited to 'src/network/network_content.cpp')
-rw-r--r--src/network/network_content.cpp25
1 files changed, 18 insertions, 7 deletions
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);
}