1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-17 12:03:07 +01:00

Make more methods const

This commit is contained in:
Ted John
2019-05-12 00:57:56 +01:00
parent 5e94f6385d
commit dd20ebad49
4 changed files with 22 additions and 22 deletions

View File

@@ -152,7 +152,7 @@ void ServerList::Clear()
_serverEntries.clear();
}
std::vector<ServerListEntry> ServerList::ReadFavourites()
std::vector<ServerListEntry> ServerList::ReadFavourites() const
{
log_verbose("server_list_read(...)");
std::vector<ServerListEntry> entries;
@@ -197,7 +197,7 @@ void ServerList::ReadAndAddFavourites()
AddRange(entries);
}
void ServerList::WriteFavourites()
void ServerList::WriteFavourites() const
{
// Save just favourite servers
std::vector<ServerListEntry> favouriteServers;
@@ -207,7 +207,7 @@ void ServerList::WriteFavourites()
WriteFavourites(favouriteServers);
}
bool ServerList::WriteFavourites(const std::vector<ServerListEntry>& entries)
bool ServerList::WriteFavourites(const std::vector<ServerListEntry>& entries) const
{
log_verbose("server_list_write(%d, 0x%p)", entries.size(), entries.data());
@@ -234,7 +234,7 @@ bool ServerList::WriteFavourites(const std::vector<ServerListEntry>& entries)
}
}
std::future<std::vector<ServerListEntry>> ServerList::FetchLocalServerListAsync(const INetworkEndpoint& broadcastEndpoint)
std::future<std::vector<ServerListEntry>> ServerList::FetchLocalServerListAsync(const INetworkEndpoint& broadcastEndpoint) const
{
auto broadcastAddress = broadcastEndpoint.GetHostname();
return std::async(std::launch::async, [broadcastAddress] {
@@ -293,7 +293,7 @@ std::future<std::vector<ServerListEntry>> ServerList::FetchLocalServerListAsync(
});
}
std::future<std::vector<ServerListEntry>> ServerList::FetchLocalServerListAsync()
std::future<std::vector<ServerListEntry>> ServerList::FetchLocalServerListAsync() const
{
return std::async(std::launch::async, [&] {
// Get all possible LAN broadcast addresses
@@ -325,7 +325,7 @@ std::future<std::vector<ServerListEntry>> ServerList::FetchLocalServerListAsync(
});
}
std::future<std::vector<ServerListEntry>> ServerList::FetchOnlineServerListAsync()
std::future<std::vector<ServerListEntry>> ServerList::FetchOnlineServerListAsync() const
{
# ifdef DISABLE_HTTP
return {};

View File

@@ -44,9 +44,9 @@ private:
std::vector<ServerListEntry> _serverEntries;
void Sort();
std::vector<ServerListEntry> ReadFavourites();
bool WriteFavourites(const std::vector<ServerListEntry>& entries);
std::future<std::vector<ServerListEntry>> FetchLocalServerListAsync(const INetworkEndpoint& broadcastEndpoint);
std::vector<ServerListEntry> ReadFavourites() const;
bool WriteFavourites(const std::vector<ServerListEntry>& entries) const;
std::future<std::vector<ServerListEntry>> FetchLocalServerListAsync(const INetworkEndpoint& broadcastEndpoint) const;
public:
ServerListEntry& GetServer(size_t index);
@@ -56,10 +56,10 @@ public:
void Clear();
void ReadAndAddFavourites();
void WriteFavourites();
void WriteFavourites() const;
std::future<std::vector<ServerListEntry>> FetchLocalServerListAsync();
std::future<std::vector<ServerListEntry>> FetchOnlineServerListAsync();
std::future<std::vector<ServerListEntry>> FetchLocalServerListAsync() const;
std::future<std::vector<ServerListEntry>> FetchOnlineServerListAsync() const;
uint32_t GetTotalPlayerCount() const;
};

View File

@@ -216,12 +216,12 @@ public:
CloseSocket();
}
SOCKET_STATUS GetStatus() override
SOCKET_STATUS GetStatus() const override
{
return _status;
}
const char* GetError() override
const char* GetError() const override
{
return _error.empty() ? nullptr : _error.c_str();
}
@@ -583,12 +583,12 @@ public:
CloseSocket();
}
SOCKET_STATUS GetStatus() override
SOCKET_STATUS GetStatus() const override
{
return _status;
}
const char* GetError() override
const char* GetError() const override
{
return _error.empty() ? nullptr : _error.c_str();
}
@@ -739,12 +739,12 @@ private:
}
// Turn off IPV6_V6ONLY so we can accept both v4 and v6 connections
if (!SetOption(_socket, IPPROTO_IPV6, IPV6_V6ONLY, false))
if (!SetOption(sock, IPPROTO_IPV6, IPV6_V6ONLY, false))
{
log_warning("IPV6_V6ONLY failed. %d", LAST_SOCKET_ERROR());
}
if (!SetOption(_socket, SOL_SOCKET, SO_REUSEADDR, true))
if (!SetOption(sock, SOL_SOCKET, SO_REUSEADDR, true))
{
log_warning("SO_REUSEADDR failed. %d", LAST_SOCKET_ERROR());
}

View File

@@ -52,8 +52,8 @@ interface ITcpSocket
public:
virtual ~ITcpSocket() = default;
virtual SOCKET_STATUS GetStatus() abstract;
virtual const char* GetError() abstract;
virtual SOCKET_STATUS GetStatus() const abstract;
virtual const char* GetError() const abstract;
virtual const char* GetHostName() const abstract;
virtual void Listen(uint16_t port) abstract;
@@ -78,8 +78,8 @@ interface IUdpSocket
public:
virtual ~IUdpSocket() = default;
virtual SOCKET_STATUS GetStatus() abstract;
virtual const char* GetError() abstract;
virtual SOCKET_STATUS GetStatus() const abstract;
virtual const char* GetError() const abstract;
virtual const char* GetHostName() const abstract;
virtual void Listen(uint16_t port) abstract;