summaryrefslogtreecommitdiff
path: root/src/network/core
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-05-30 12:53:42 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-06-10 20:09:44 +0200
commitdf181bb641a75e9fae557c683b790cfba961ec5a (patch)
tree959fbc29c976eb1f24471508f806e48c5bbefe26 /src/network/core
parent9c424ab741218238205e8d1f2644a3912fda250a (diff)
downloadopenttd-df181bb641a75e9fae557c683b790cfba961ec5a.tar.xz
Codechange: [ContentInfo] Use a vector for dependencies instead of custom allocation
Diffstat (limited to 'src/network/core')
-rw-r--r--src/network/core/tcp_content.cpp6
-rw-r--r--src/network/core/tcp_content_type.h3
2 files changed, 3 insertions, 6 deletions
diff --git a/src/network/core/tcp_content.cpp b/src/network/core/tcp_content.cpp
index 041e932e4..fb726e2e7 100644
--- a/src/network/core/tcp_content.cpp
+++ b/src/network/core/tcp_content.cpp
@@ -24,7 +24,7 @@
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(""), dependency_count(0), dependencies(nullptr),
+ url(""), description(""), unique_id(0), md5sum(""),
state((State)0), upgrade(false)
{
}
@@ -32,7 +32,6 @@ ContentInfo::ContentInfo()
/** Free everything allocated */
ContentInfo::~ContentInfo()
{
- free(this->dependencies);
}
/**
@@ -42,9 +41,8 @@ ContentInfo::~ContentInfo()
void ContentInfo::TransferFrom(ContentInfo *other)
{
if (other != this) {
- free(this->dependencies);
*this = *other;
- other->dependencies = nullptr;
+ other->dependencies.clear();
other->tags.clear();
}
}
diff --git a/src/network/core/tcp_content_type.h b/src/network/core/tcp_content_type.h
index 93367746d..2186997e8 100644
--- a/src/network/core/tcp_content_type.h
+++ b/src/network/core/tcp_content_type.h
@@ -67,8 +67,7 @@ struct ContentInfo {
char description[512]; ///< Description of the content
uint32 unique_id; ///< Unique ID; either GRF ID or shortname
byte md5sum[16]; ///< The MD5 checksum
- uint8 dependency_count; ///< Number of dependencies
- ContentID *dependencies; ///< Malloced array of dependencies (unique server side ids)
+ 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