mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use EnumBitSet instead of Vector to record received content types. (#14214)
parent
a46b885640
commit
2355d67e11
|
@ -33,6 +33,7 @@ enum ContentType : uint8_t {
|
||||||
CONTENT_TYPE_END, ///< Helper to mark the end of the types
|
CONTENT_TYPE_END, ///< Helper to mark the end of the types
|
||||||
INVALID_CONTENT_TYPE = 0xFF, ///< Invalid/uninitialized content
|
INVALID_CONTENT_TYPE = 0xFF, ///< Invalid/uninitialized content
|
||||||
};
|
};
|
||||||
|
using ContentTypes = EnumBitSet<ContentType, uint16_t, CONTENT_TYPE_END>;
|
||||||
|
|
||||||
/** Enum with all types of TCP content packets. The order MUST not be changed **/
|
/** Enum with all types of TCP content packets. The order MUST not be changed **/
|
||||||
enum PacketContentType : uint8_t {
|
enum PacketContentType : uint8_t {
|
||||||
|
|
|
@ -187,7 +187,7 @@ void BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(const ContentInf
|
||||||
/** Window for showing the download status of content */
|
/** Window for showing the download status of content */
|
||||||
struct NetworkContentDownloadStatusWindow : public BaseNetworkContentDownloadStatusWindow {
|
struct NetworkContentDownloadStatusWindow : public BaseNetworkContentDownloadStatusWindow {
|
||||||
private:
|
private:
|
||||||
std::vector<ContentType> receivedTypes{}; ///< Types we received so we can update their cache
|
ContentTypes received_types{}; ///< Types we received so we can update their cache
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -202,7 +202,7 @@ public:
|
||||||
void Close([[maybe_unused]] int data = 0) override
|
void Close([[maybe_unused]] int data = 0) override
|
||||||
{
|
{
|
||||||
TarScanner::Modes modes{};
|
TarScanner::Modes modes{};
|
||||||
for (auto ctype : this->receivedTypes) {
|
for (auto ctype : this->received_types) {
|
||||||
switch (ctype) {
|
switch (ctype) {
|
||||||
case CONTENT_TYPE_AI:
|
case CONTENT_TYPE_AI:
|
||||||
case CONTENT_TYPE_AI_LIBRARY:
|
case CONTENT_TYPE_AI_LIBRARY:
|
||||||
|
@ -236,7 +236,7 @@ public:
|
||||||
TarScanner::DoScan(modes);
|
TarScanner::DoScan(modes);
|
||||||
|
|
||||||
/* Tell all the backends about what we've downloaded */
|
/* Tell all the backends about what we've downloaded */
|
||||||
for (auto ctype : this->receivedTypes) {
|
for (auto ctype : this->received_types) {
|
||||||
switch (ctype) {
|
switch (ctype) {
|
||||||
case CONTENT_TYPE_AI:
|
case CONTENT_TYPE_AI:
|
||||||
case CONTENT_TYPE_AI_LIBRARY:
|
case CONTENT_TYPE_AI_LIBRARY:
|
||||||
|
@ -301,7 +301,7 @@ public:
|
||||||
void OnDownloadProgress(const ContentInfo &ci, int bytes) override
|
void OnDownloadProgress(const ContentInfo &ci, int bytes) override
|
||||||
{
|
{
|
||||||
BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(ci, bytes);
|
BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(ci, bytes);
|
||||||
include(this->receivedTypes, ci.type);
|
this->received_types.Set(ci.type);
|
||||||
|
|
||||||
/* When downloading is finished change cancel in ok */
|
/* When downloading is finished change cancel in ok */
|
||||||
if (this->downloaded_bytes == this->total_bytes) {
|
if (this->downloaded_bytes == this->total_bytes) {
|
||||||
|
|
Loading…
Reference in New Issue