OpenTTD Source: ContentInfo Struct Reference

OpenTTD Source 15.0-RC2

Public Types | Public Member Functions | Data Fields
ContentInfo Struct Reference

Container for all important information about a piece of content. More...

`#include <tcp_content_type.h>`

## Public Types
enum class | State : uint8_t { Unselected , Selected , Autoselected , AlreadyHere , DoesNotExist , Invalid }
| The state the content can be in. More...

## Public Member Functions
bool | IsSelected () const
| Is the state either selected or autoselected?
bool | IsValid () const
| Is the information from this content info valid?
std::optional< std::string > | GetTextfile (TextfileType type) const
| Search a textfile file next to this file in the content list.

## Data Fields
ContentType | type = INVALID_CONTENT_TYPE
| Type of content.
ContentID | id = INVALID_CONTENT_ID
| Unique (server side) ID for the content.
uint32_t | 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_t | unique_id = 0
| Unique ID; either GRF ID or shortname.
MD5Hash | md5sum
| 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.

## Detailed Description

Container for all important information about a piece of content.

Definition at line 56 of file tcp_content_type.h.

## Member Enumeration Documentation

## ◆ State

enum class ContentInfo::State : uint8_t
| strong

The state the content can be in.

Enumerator
Unselected | The content has not been selected.
Selected | The content has been manually selected.
Autoselected | The content has been selected as dependency.
AlreadyHere | The content is already at the client side.
DoesNotExist | The content does not exist in the content system.
Invalid | The content's invalid.

Definition at line 58 of file tcp_content_type.h.

## Member Function Documentation

## ◆ GetTextfile()

std::optional< std::string > ContentInfo::GetTextfile | ( | TextfileType | type | ) | const

Search a textfile file next to this file in the content list.

Parameters

  type | The type of the textfile to search for.

Returns
  The filename for the textfile.

Definition at line 59 of file tcp_content.cpp.

References CONTENT_TYPE_AI, CONTENT_TYPE_AI_LIBRARY, CONTENT_TYPE_BASE_GRAPHICS, CONTENT_TYPE_BASE_MUSIC, CONTENT_TYPE_BASE_SOUNDS, CONTENT_TYPE_GAME, CONTENT_TYPE_GAME_LIBRARY, CONTENT_TYPE_HEIGHTMAP, CONTENT_TYPE_NEWGRF, CONTENT_TYPE_SCENARIO, FGCM_EXACT, GRFConfig::filename, FindGRFConfig(), ScriptScanner::FindMainScript(), FindScenario(), BaseMedia< GraphicsSet >::GetAvailableSets(), BaseMedia< SoundsSet >::GetAvailableSets(), BaseMedia< MusicSet >::GetAvailableSets(), GetContentInfoSubDir(), AI::GetScannerInfo(), Game::GetScannerInfo(), AI::GetScannerLibrary(), Game::GetScannerLibrary(), Invalid, md5sum, state, TryGetBaseSetFile(), type, and unique_id.

## ◆ IsSelected()

bool ContentInfo::IsSelected | ( |  | ) | const

Is the state either selected or autoselected?

Returns
  true iff that's the case

Definition at line 32 of file tcp_content.cpp.

References AlreadyHere, Autoselected, Selected, and state.

Referenced by ClientNetworkContentSocketHandler::CheckDependencyState(), NetworkContentListWindow::DrawDetails(), NetworkContentListWindow::OnReceiveContentInfo(), and ClientNetworkContentSocketHandler::Unselect().

## ◆ IsValid()

bool ContentInfo::IsValid | ( |  | ) | const

Is the information from this content info valid?

Returns
  true iff it's valid

Definition at line 49 of file tcp_content.cpp.

References CONTENT_TYPE_BEGIN, CONTENT_TYPE_END, Invalid, state, and type.

## Field Documentation

## ◆ dependencies

std::vector<ContentID> ContentInfo::dependencies

The dependencies (unique server side ids)

Definition at line 77 of file tcp_content_type.h.

Referenced by ClientNetworkContentSocketHandler::CheckDependencyState(), and NetworkContentListWindow::DrawDetails().

## ◆ description

std::string ContentInfo::description

Description of the content.

Definition at line 74 of file tcp_content_type.h.

Referenced by NetworkContentListWindow::DrawDetails().

## ◆ filename

std::string ContentInfo::filename

Filename (for the .tar.gz; only valid on download)

Definition at line 70 of file tcp_content_type.h.

Referenced by GetFullFilename(), and BaseNetworkContentDownloadStatusWindow::OnDownloadProgress().

## ◆ filesize

uint32_t ContentInfo::filesize = 0

Size of the file.

Definition at line 69 of file tcp_content_type.h.

Referenced by NetworkContentListWindow::DrawDetails(), and NetworkContentListWindow::OnInvalidateData().

## ◆ id

ContentID ContentInfo::id = INVALID_CONTENT_ID

Unique (server side) ID for the content.

Definition at line 68 of file tcp_content_type.h.

Referenced by ClientNetworkContentSocketHandler::CheckDependencyState(), NetworkContentListWindow::DrawDetails(), BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(), BootstrapAskForDownloadWindow::OnReceiveContentInfo(), OutputContentState(), ClientNetworkContentSocketHandler::RequestQueuedContentInfo(), ClientNetworkContentSocketHandler::ReverseLookupDependency(), and ClientNetworkContentSocketHandler::ToggleSelectedState().

## ◆ md5sum

MD5Hash ContentInfo::md5sum

The MD5 checksum.

Definition at line 76 of file tcp_content_type.h.

Referenced by FindScenario(), GetTextfile(), HasGRFConfig(), IsSameScript(), NetworkContentListWindow::OpenExternalSearch(), OutputContentState(), and TryGetBaseSetFile().

## ◆ name

std::string ContentInfo::name

Name of the content.

Definition at line 71 of file tcp_content_type.h.

Referenced by NetworkContentListWindow::DrawDetails(), NetworkContentListWindow::DrawMatrix(), ContentTextfileWindow::GetWidgetString(), NetworkContentListWindow::NameSorter(), and OutputContentState().

## ◆ state

State ContentInfo::state = State::Unselected

Whether the content info is selected (for download)

Definition at line 79 of file tcp_content_type.h.

Referenced by NetworkContentListWindow::BuildContentList(), ClientNetworkContentSocketHandler::CheckDependencyState(), NetworkContentListWindow::DrawDetails(), NetworkContentListWindow::DrawMatrix(), GetTextfile(), IsSelected(), IsValid(), NetworkContentListWindow::OnClick(), ClientNetworkContentSocketHandler::OnDownloadComplete(), NetworkContentListWindow::OnInvalidateData(), NetworkContentListWindow::OpenExternalSearch(), OutputContentState(), ClientNetworkContentSocketHandler::Select(), NetworkContentListWindow::StateSorter(), ClientNetworkContentSocketHandler::ToggleSelectedState(), and ClientNetworkContentSocketHandler::Unselect().

## ◆ tags

StringList ContentInfo::tags

Tags associated with the content.

Definition at line 78 of file tcp_content_type.h.

Referenced by NetworkContentListWindow::DrawDetails().

## ◆ type

ContentType ContentInfo::type = INVALID_CONTENT_TYPE

Type of content.

Definition at line 67 of file tcp_content_type.h.

Referenced by NetworkContentListWindow::DrawDetails(), NetworkContentListWindow::DrawMatrix(), GetFullFilename(), GetTextfile(), IsValid(), NetworkContentDownloadStatusWindow::OnDownloadProgress(), OutputContentState(), and NetworkContentListWindow::TypeSorter().

## ◆ unique_id

uint32_t ContentInfo::unique_id = 0

Unique ID; either GRF ID or shortname.

Definition at line 75 of file tcp_content_type.h.

Referenced by FindScenario(), GetTextfile(), HasGRFConfig(), IsSameScript(), NetworkContentListWindow::OpenExternalSearch(), OutputContentState(), and TryGetBaseSetFile().

## ◆ upgrade

bool ContentInfo::upgrade = false

This item is an upgrade.

Definition at line 80 of file tcp_content_type.h.

Referenced by NetworkContentListWindow::DrawDetails(), and NetworkContentListWindow::OnInvalidateData().

## ◆ url

std::string ContentInfo::url

URL related to the content.

Definition at line 73 of file tcp_content_type.h.

Referenced by NetworkContentListWindow::DrawDetails(), NetworkContentListWindow::OnClick(), and NetworkContentListWindow::OnInvalidateData().

## ◆ version

std::string ContentInfo::version

Version of the content.

Definition at line 72 of file tcp_content_type.h.

Referenced by NetworkContentListWindow::DrawDetails(), NetworkContentListWindow::DrawMatrix(), and NetworkContentListWindow::NameSorter().

The documentation for this struct was generated from the following files:

- src/network/core/tcp_content_type.h
- src/network/core/tcp_content.cpp