summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-05-30 13:12:00 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-06-10 20:09:44 +0200
commite2417193c9dbe8a7ecf00521bed7bf6c3fb573fc (patch)
tree5632597877e85b751ef504a383bf101be20eb3ce /src/network
parente3717ae903cb770ae2ebc4abe45fa0cc77326409 (diff)
downloadopenttd-e2417193c9dbe8a7ecf00521bed7bf6c3fb573fc.tar.xz
Cleanup: [ContentInfo] Remove some functions that are not needed anymore
Diffstat (limited to 'src/network')
-rw-r--r--src/network/core/tcp_content.cpp27
-rw-r--r--src/network/core/tcp_content_type.h34
-rw-r--r--src/network/network_content.cpp3
3 files changed, 16 insertions, 48 deletions
diff --git a/src/network/core/tcp_content.cpp b/src/network/core/tcp_content.cpp
index fb726e2e7..84c82ead1 100644
--- a/src/network/core/tcp_content.cpp
+++ b/src/network/core/tcp_content.cpp
@@ -20,33 +20,6 @@
#include "../../safeguards.h"
-/** Clear everything in the struct */
-ContentInfo::ContentInfo()
- : /* Temporary... will be removed later in the PR. */
- type((ContentType)0), id((ContentID)0), filesize(0), filename(""), name(""), version(""),
- url(""), description(""), unique_id(0), md5sum(""),
- state((State)0), upgrade(false)
-{
-}
-
-/** Free everything allocated */
-ContentInfo::~ContentInfo()
-{
-}
-
-/**
- * Copy data from other #ContentInfo and take ownership of allocated stuff.
- * @param other Source to copy from. #dependencies and #tags will be NULLed.
- */
-void ContentInfo::TransferFrom(ContentInfo *other)
-{
- if (other != this) {
- *this = *other;
- other->dependencies.clear();
- other->tags.clear();
- }
-}
-
/**
* Is the state either selected or autoselected?
* @return true iff that's the case
diff --git a/src/network/core/tcp_content_type.h b/src/network/core/tcp_content_type.h
index 25097c3ab..5daae39dc 100644
--- a/src/network/core/tcp_content_type.h
+++ b/src/network/core/tcp_content_type.h
@@ -26,6 +26,7 @@ enum ContentType {
CONTENT_TYPE_GAME = 9, ///< The content consists of a game script
CONTENT_TYPE_GAME_LIBRARY = 10, ///< The content consists of a GS library
CONTENT_TYPE_END, ///< Helper to mark the end of the types
+ INVALID_CONTENT_TYPE = 0xFF, ///< Invalid/uninitialized content
};
/** Enum with all types of TCP content packets. The order MUST not be changed **/
@@ -57,25 +58,20 @@ struct ContentInfo {
INVALID, ///< The content's invalid
};
- ContentType type; ///< Type of content
- ContentID id; ///< Unique (server side) ID for the content
- uint32 filesize; ///< Size of the file
- std::string filename; ///< Filename (for the .tar.gz; only valid on download)
- std::string name; ///< Name of the content
- std::string version; ///< Version of the content
- std::string url; ///< URL related to the content
- std::string description; ///< Description of the content
- uint32 unique_id; ///< Unique ID; either GRF ID or shortname
- byte md5sum[16]; ///< The MD5 checksum
- std::vector<ContentID> dependencies; ///< The dependencies (unique server side ids)
- StringList tags; ///< Tags associated with the content
- State state; ///< Whether the content info is selected (for download)
- bool upgrade; ///< This item is an upgrade
-
- ContentInfo();
- ~ContentInfo();
-
- void TransferFrom(ContentInfo *other);
+ ContentType type = INVALID_CONTENT_TYPE; ///< Type of content
+ ContentID id = INVALID_CONTENT_ID; ///< Unique (server side) ID for the content
+ uint32 filesize = 0; ///< Size of the file
+ std::string filename; ///< Filename (for the .tar.gz; only valid on download)
+ std::string name; ///< Name of the content
+ std::string version; ///< Version of the content
+ std::string url; ///< URL related to the content
+ std::string description; ///< Description of the content
+ uint32 unique_id = 0; ///< Unique ID; either GRF ID or shortname
+ byte md5sum[16] = {0}; ///< The MD5 checksum
+ std::vector<ContentID> dependencies; ///< The dependencies (unique server side ids)
+ StringList tags; ///< Tags associated with the content
+ State state = State::UNSELECTED; ///< Whether the content info is selected (for download)
+ bool upgrade = false; ///< This item is an upgrade
bool IsSelected() const;
bool IsValid() const;
diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp
index f85c942af..eff54885d 100644
--- a/src/network/network_content.cpp
+++ b/src/network/network_content.cpp
@@ -150,9 +150,8 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p)
* As ici might be selected by the content window we cannot delete that.
* However, we want to keep most of the values of ci, except the values
* we (just) already preserved.
- * So transfer data and ownership of allocated memory from ci to ici.
*/
- ici->TransferFrom(ci);
+ *ici = *ci;
delete ci;
this->OnReceiveContentInfo(ici);