ddnet/src/engine/favorites.h
heinrich5991 6600024f24 Allow multiple addresses per server in the serverbrowser
Support is incomplete for `leak_ip_address_to_all_servers` (will only
ping the first address of each server) and for the `leak_ip` setting
(which will also only ping the first address of each server).
2022-07-10 16:52:07 +02:00

46 lines
1.2 KiB
C++

#ifndef ENGINE_FAVORITES_H
#define ENGINE_FAVORITES_H
#include <memory>
#include <base/types.h>
#include <engine/shared/protocol.h>
#include "kernel.h"
class IConfigManager;
class IFavorites : public IInterface
{
MACRO_INTERFACE("favorites", 0)
protected:
virtual void OnConfigSave(IConfigManager *pConfigManager) = 0;
public:
class CEntry
{
public:
int m_NumAddrs;
NETADDR m_aAddrs[MAX_SERVER_ADDRESSES];
bool m_AllowPing;
};
virtual ~IFavorites() {}
virtual TRISTATE IsFavorite(const NETADDR *pAddrs, int NumAddrs) const = 0;
// Only considers the addresses that are actually favorites.
virtual TRISTATE IsPingAllowed(const NETADDR *pAddrs, int NumAddrs) const = 0;
virtual void Add(const NETADDR *pAddrs, int NumAddrs) = 0;
// Only considers the addresses that are actually favorites.
virtual void AllowPing(const NETADDR *pAddrs, int NumAddrs, bool AllowPing) = 0;
virtual void Remove(const NETADDR *pAddrs, int NumAddrs) = 0;
virtual void AllEntries(const CEntry **ppEntries, int *pNumEntries) = 0;
// Pass the `IFavorites` instance as callback.
static void ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserData);
};
std::unique_ptr<IFavorites> CreateFavorites();
#endif // ENGINE_FAVORITES_H