mirror of
https://github.com/ncblakely/GiantsTools
synced 2024-11-01 13:15:38 +01:00
Compare commits
No commits in common. "80343ee84b5f73660fac3cd33094b7ef6e9464eb" and "9a751ddc64c8fd60dc0ae496f023bb8b4fc80997" have entirely different histories.
80343ee84b
...
9a751ddc64
@ -19,7 +19,7 @@
|
||||
private readonly IHttpContextAccessor httpContextAccessor;
|
||||
private readonly ILogger<CrashReportsController> logger;
|
||||
private readonly IConfiguration configuration;
|
||||
private const long MaximumSizeInBytes = 10485760; // 10MB
|
||||
private const long MaximumSizeInBytes = 5242880; // 5MB
|
||||
|
||||
public CrashReportsController(
|
||||
ICrashReportService crashReportService,
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<UserSecretsId>155c5645-8bf7-4515-88d4-9ef801fdc47e</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace ConfigSections
|
||||
{
|
||||
const char* const Network = "network";
|
||||
};
|
||||
|
||||
namespace ConfigKeys
|
||||
{
|
||||
// Network
|
||||
const char* const MasterServerHostName = "masterServerHostName";
|
||||
const char* const BannedPlayers = "bannedPlayers";
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/// <summary>
|
||||
/// Event types for <see cref="IConfig">.
|
||||
/// </summary>
|
||||
enum class ConfigEventType
|
||||
{
|
||||
None = 0,
|
||||
|
||||
ConfigLoaded,
|
||||
ConfigSaving
|
||||
};
|
||||
|
||||
struct ConfigEvent
|
||||
{
|
||||
public:
|
||||
virtual ~ConfigEvent() = default;
|
||||
ConfigEvent(ConfigEventType type) noexcept { this->type = type; }
|
||||
|
||||
private:
|
||||
ConfigEventType type;
|
||||
};
|
||||
|
||||
struct ConfigLoadedEvent : ConfigEvent
|
||||
{
|
||||
ConfigLoadedEvent(struct IConfig& config) noexcept
|
||||
: ConfigEvent(ConfigEventType::ConfigLoaded),
|
||||
config(config)
|
||||
{
|
||||
}
|
||||
|
||||
struct IConfig& config;
|
||||
};
|
||||
|
||||
struct ConfigSavingEvent : ConfigEvent
|
||||
{
|
||||
ConfigSavingEvent(struct IConfig& config) noexcept
|
||||
: ConfigEvent(ConfigEventType::ConfigSaving),
|
||||
config(config)
|
||||
{
|
||||
}
|
||||
|
||||
struct IConfig& config;
|
||||
};
|
@ -3,7 +3,7 @@
|
||||
#include <Unknwn.h>
|
||||
|
||||
// {779CF758-3E3F-4FEE-9513-60106522686A}
|
||||
inline const GUID IID_IComponent = { 0x779cf758, 0x3e3f, 0x4fee, 0x95, 0x13, 0x60, 0x10, 0x65, 0x22, 0x68, 0x6a };
|
||||
DEFINE_GUID(IID_IComponent, 0x779cf758, 0x3e3f, 0x4fee, 0x95, 0x13, 0x60, 0x10, 0x65, 0x22, 0x68, 0x6a);
|
||||
|
||||
/// <summary>
|
||||
/// Base interface for a game COM component.
|
||||
|
@ -7,7 +7,8 @@ template<typename T>
|
||||
using ComPtr = Microsoft::WRL::ComPtr<T>;
|
||||
|
||||
// {C942AA9B-C576-4D3F-A54F-B135B500E611}
|
||||
inline const GUID IID_IComponentContainer = { 0xc942aa9b, 0xc576, 0x4d3f, 0xa5, 0x4f, 0xb1, 0x35, 0xb5, 0x0, 0xe6, 0x11 };
|
||||
DEFINE_GUID(IID_IComponentContainer,
|
||||
0xc942aa9b, 0xc576, 0x4d3f, 0xa5, 0x4f, 0xb1, 0x35, 0xb5, 0x0, 0xe6, 0x11);
|
||||
|
||||
template<typename T>
|
||||
struct TypedGet
|
||||
@ -17,24 +18,19 @@ struct TypedGet
|
||||
{
|
||||
ComPtr<TGet> temp;
|
||||
ComPtr<IComponent> pComponent = ((T*)this)->Get(__uuidof(TGet));
|
||||
if (pComponent)
|
||||
HRESULT hr = pComponent.As<TGet>(&temp);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
HRESULT hr = pComponent.As<TGet>(&temp);
|
||||
if (FAILED(hr))
|
||||
if (hr == E_NOINTERFACE)
|
||||
{
|
||||
if (hr == E_NOINTERFACE)
|
||||
{
|
||||
throw std::invalid_argument("The interface is not supported.");
|
||||
}
|
||||
|
||||
throw std::invalid_argument(fmt::format("Unknown exception {0:x} querying interface.", hr));
|
||||
throw std::invalid_argument("The interface is not supported.");
|
||||
}
|
||||
|
||||
pComponent.Detach();
|
||||
return temp;
|
||||
throw std::invalid_argument(fmt::format("Unknown exception {0:x} querying interface.", hr));
|
||||
}
|
||||
|
||||
return ComPtr<TGet>(); // Null
|
||||
pComponent.Detach();
|
||||
return temp;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,44 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <IComponent.h>
|
||||
#include <IEventSource.h>
|
||||
#include <ConfigEvents.h>
|
||||
#include <ConfigConstants.h>
|
||||
|
||||
// {599E6624-694C-41B6-B354-62EEA1132041}
|
||||
inline const GUID IID_IConfig = { 0x599e6624, 0x694c, 0x41b6, 0xb3, 0x54, 0x62, 0xee, 0xa1, 0x13, 0x20, 0x41 };
|
||||
|
||||
struct IConfig : IComponent, IEventSource<ConfigEventType, ConfigEvent>
|
||||
{
|
||||
virtual ~IConfig() = default;
|
||||
|
||||
virtual void STDMETHODCALLTYPE Read() = 0;
|
||||
|
||||
virtual void STDMETHODCALLTYPE Save() = 0;
|
||||
|
||||
virtual float STDMETHODCALLTYPE GetFloat(const tstring_view& section, const tstring_view& setting) const = 0;
|
||||
|
||||
virtual std::vector<float> STDMETHODCALLTYPE GetFloatArray(const tstring_view& section, const tstring_view& setting) const = 0;
|
||||
|
||||
virtual int STDMETHODCALLTYPE GetInteger(const tstring_view& section, const tstring_view& setting) const = 0;
|
||||
|
||||
virtual std::vector<int> STDMETHODCALLTYPE GetIntegerArray(const tstring_view& section, const tstring_view& setting) const = 0;
|
||||
|
||||
virtual tstring STDMETHODCALLTYPE GetString(const tstring_view& section, const tstring_view& setting) const = 0;
|
||||
|
||||
virtual std::vector<tstring> STDMETHODCALLTYPE GetStringArray(const tstring_view& section, const tstring_view& setting) const = 0;
|
||||
|
||||
virtual void STDMETHODCALLTYPE SetFloat(const tstring_view& section, const tstring_view& setting, float value) = 0;
|
||||
|
||||
virtual void STDMETHODCALLTYPE SetFloatArray(const tstring_view& section, const tstring_view& setting, std::vector<float>&& values) = 0;
|
||||
|
||||
virtual void STDMETHODCALLTYPE SetInteger(const tstring_view& section, const tstring_view& setting, int value) = 0;
|
||||
|
||||
virtual void STDMETHODCALLTYPE SetIntegerArray(const tstring_view& section, const tstring_view& setting, std::vector<int>&& values) = 0;
|
||||
|
||||
virtual void STDMETHODCALLTYPE SetString(const tstring_view& section, const tstring_view& setting, tstring_view value) = 0;
|
||||
|
||||
virtual void STDMETHODCALLTYPE SetStringArray(const tstring_view& section, const tstring_view& setting, std::vector<tstring>&& values) = 0;
|
||||
};
|
||||
|
||||
struct DECLSPEC_UUID("{599E6624-694C-41B6-B354-62EEA1132041}") IConfig;
|
@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
template<typename TEventType, typename TEvent>
|
||||
struct IEventSource
|
||||
{
|
||||
virtual ~IEventSource() = default;
|
||||
|
||||
virtual UUID STDMETHODCALLTYPE Listen(TEventType event, std::function<void(const TEvent&)> function) noexcept = 0;
|
||||
virtual void STDMETHODCALLTYPE Unlisten(TEventType event, UUID uuid) noexcept = 0;
|
||||
};
|
@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <IComponent.h>
|
||||
|
||||
// {9C4C8F9C-D4C1-4749-A073-D710548D3154}
|
||||
inline const GUID IID_IExceptionHandler = { 0x9c4c8f9c, 0xd4c1, 0x4749, 0xa0, 0x73, 0xd7, 0x10, 0x54, 0x8d, 0x31, 0x54 };
|
||||
struct IExceptionHandler : IComponent
|
||||
{
|
||||
virtual ~IExceptionHandler() = default;
|
||||
|
||||
virtual void STDMETHODCALLTYPE AttachToCurrentThread() = 0;
|
||||
virtual void STDMETHODCALLTYPE DetachFromCurrentThread() = 0;
|
||||
virtual void STDMETHODCALLTYPE Initialize() = 0;
|
||||
virtual void STDMETHODCALLTYPE PostLoad() = 0;
|
||||
virtual void STDMETHODCALLTYPE Shutdown() = 0;
|
||||
};
|
||||
|
||||
struct DECLSPEC_UUID("{9C4C8F9C-D4C1-4749-A073-D710548D3154}") IExceptionHandler;
|
@ -4,18 +4,18 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <IComponent.h>
|
||||
#include <IEventSource.h>
|
||||
|
||||
#include "GameServerEvents.h"
|
||||
#include "NetCommon.h"
|
||||
|
||||
// {B2D67EE7-8063-488F-B3B9-E7DA675CB752}
|
||||
inline const GUID IID_IGameServer = { 0xb2d67ee7, 0x8063, 0x488f, 0xb3, 0xb9, 0xe7, 0xda, 0x67, 0x5c, 0xb7, 0x52 };
|
||||
DEFINE_GUID(IID_IGameServer,
|
||||
0xb2d67ee7, 0x8063, 0x488f, 0xb3, 0xb9, 0xe7, 0xda, 0x67, 0x5c, 0xb7, 0x52);
|
||||
|
||||
/// <summary>
|
||||
/// Defines an API for communicating with the game server.
|
||||
/// </summary>
|
||||
struct IGameServer : IComponent, IEventSource<GameServerEventType, GameServerEvent>
|
||||
struct IGameServer : IComponent
|
||||
{
|
||||
virtual ~IGameServer() = default;
|
||||
|
||||
@ -32,6 +32,10 @@ struct IGameServer : IComponent, IEventSource<GameServerEventType, GameServerEve
|
||||
virtual void STDMETHODCALLTYPE ChangeGameOption(GameOption option) = 0;
|
||||
|
||||
virtual NetGameDetails STDMETHODCALLTYPE GetGameDetails() = 0;
|
||||
|
||||
virtual UUID STDMETHODCALLTYPE Listen(GameServerEventType event, std::function<void(const GameServerEvent&)> function) noexcept = 0;
|
||||
|
||||
virtual void STDMETHODCALLTYPE Unlisten(GameServerEventType event, UUID uuid) noexcept = 0;
|
||||
};
|
||||
|
||||
struct DECLSPEC_UUID("{B2D67EE7-8063-488F-B3B9-E7DA675CB752}") IGameServer;
|
@ -5,7 +5,8 @@
|
||||
#include <string>
|
||||
|
||||
// {3B2D43AC-2557-4C28-991D-A456B59D76CB}
|
||||
inline const GUID IID_IGameServerConsole = { 0x3b2d43ac, 0x2557, 0x4c28, 0x99, 0x1d, 0xa4, 0x56, 0xb5, 0x9d, 0x76, 0xcb };
|
||||
DEFINE_GUID(IID_IGameServerConsole,
|
||||
0x3b2d43ac, 0x2557, 0x4c28, 0x99, 0x1d, 0xa4, 0x56, 0xb5, 0x9d, 0x76, 0xcb);
|
||||
|
||||
/// <summary>
|
||||
/// Interface for dedicated server consoles.
|
||||
|
@ -7,7 +7,8 @@ enum class NetPlayerState;
|
||||
enum class GameTeam;
|
||||
|
||||
// {770DEBD3-165D-4340-829D-5262F473FBE3}
|
||||
inline const GUID IID_ITextLookupService = { 0x770debd3, 0x165d, 0x4340, 0x82, 0x9d, 0x52, 0x62, 0xf4, 0x73, 0xfb, 0xe3 };
|
||||
DEFINE_GUID(IID_ITextLookupService,
|
||||
0x770debd3, 0x165d, 0x4340, 0x82, 0x9d, 0x52, 0x62, 0xf4, 0x73, 0xfb, 0xe3);
|
||||
|
||||
/// <summary>
|
||||
/// Service providing localization of text placeholders and friendly-name mappings of common enums.
|
||||
|
@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <json/json.hpp>
|
||||
|
||||
#include <MasterServer/PlayerInfoResponse.h>
|
||||
#include <MasterServer/ServerInfoResponse.h>
|
||||
|
||||
using njson = nlohmann::json;
|
||||
|
||||
typedef std::future<std::vector<ServerInfoResponse>> ServerInfoFuture;
|
||||
|
||||
// {EE129A81-0A86-49C4-8D23-A771A7350952}
|
||||
inline const GUID IID_IGiantsApiClient = { 0xee129a81, 0xa86, 0x49c4, 0x8d, 0x23, 0xa7, 0x71, 0xa7, 0x35, 0x9, 0x52 };
|
||||
|
||||
struct IGiantsApiClient : IComponent
|
||||
{
|
||||
virtual ~IGiantsApiClient() = default;
|
||||
|
||||
virtual void STDMETHODCALLTYPE DeleteServerInformationAsync() = 0;
|
||||
virtual ServerInfoFuture STDMETHODCALLTYPE GetServerInformationAsync() = 0;
|
||||
virtual void STDMETHODCALLTYPE PostServerInformationAsync(const njson& requestBody) = 0;
|
||||
};
|
||||
|
||||
struct DECLSPEC_UUID("{EE129A81-0A86-49C4-8D23-A771A7350952}") IGiantsApiClient;
|
@ -1,21 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
using njson = nlohmann::json;
|
||||
|
||||
struct PlayerInfoResponse
|
||||
{
|
||||
explicit PlayerInfoResponse(const njson& playerInfoResponse)
|
||||
{
|
||||
index = playerInfoResponse["index"];
|
||||
name = playerInfoResponse["name"];
|
||||
frags = playerInfoResponse["frags"];
|
||||
deaths = playerInfoResponse["deaths"];
|
||||
teamName = playerInfoResponse["teamName"];
|
||||
}
|
||||
|
||||
int index;
|
||||
std::string name;
|
||||
int frags;
|
||||
int deaths;
|
||||
std::string teamName;
|
||||
};
|
@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <Version.h>
|
||||
|
||||
using njson = nlohmann::json;
|
||||
|
||||
struct ServerInfoResponse
|
||||
{
|
||||
explicit ServerInfoResponse(const njson& serverInfoResponse)
|
||||
{
|
||||
hostIp = serverInfoResponse["hostIpAddress"];
|
||||
gameName = serverInfoResponse["gameName"];
|
||||
|
||||
njson versionJson = serverInfoResponse["version"];
|
||||
version.build = versionJson["build"];
|
||||
version.major = versionJson["major"];
|
||||
version.minor = versionJson["minor"];
|
||||
version.revision = versionJson["revision"];
|
||||
|
||||
sessionName = serverInfoResponse["sessionName"];
|
||||
port = serverInfoResponse["port"];
|
||||
mapName = serverInfoResponse["mapName"];
|
||||
gameType = serverInfoResponse["gameType"];
|
||||
numPlayers = serverInfoResponse["numPlayers"];
|
||||
gameState = serverInfoResponse["gameState"];
|
||||
timeLimit = serverInfoResponse["timeLimit"];
|
||||
fragLimit = serverInfoResponse["fragLimit"];
|
||||
teamFragLimit = serverInfoResponse["teamFragLimit"];
|
||||
firstBaseComplete = serverInfoResponse["firstBaseComplete"];
|
||||
|
||||
for (const auto& playerInfoResponse : serverInfoResponse["playerInfo"])
|
||||
{
|
||||
playerInfo.emplace_back(PlayerInfoResponse(playerInfoResponse));
|
||||
}
|
||||
}
|
||||
|
||||
std::string hostIp;
|
||||
std::string gameName;
|
||||
Version version;
|
||||
std::string sessionName;
|
||||
int port = 0;
|
||||
std::string mapName;
|
||||
std::string gameType;
|
||||
int numPlayers = 0;
|
||||
std::string gameState;
|
||||
int timeLimit = 0;
|
||||
int fragLimit = 0;
|
||||
int teamFragLimit = 0;
|
||||
bool firstBaseComplete = false;
|
||||
std::vector<PlayerInfoResponse> playerInfo;
|
||||
};
|
@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
struct Version
|
||||
{
|
||||
int major;
|
||||
int minor;
|
||||
int build;
|
||||
int revision;
|
||||
};
|
Loading…
Reference in New Issue
Block a user