mirror of
https://github.com/ncblakely/GiantsTools
synced 2024-11-01 05:15:36 +01:00
Compare commits
2 Commits
9a751ddc64
...
80343ee84b
Author | SHA1 | Date | |
---|---|---|---|
|
80343ee84b | ||
|
6dbcc6452e |
@ -19,7 +19,7 @@
|
|||||||
private readonly IHttpContextAccessor httpContextAccessor;
|
private readonly IHttpContextAccessor httpContextAccessor;
|
||||||
private readonly ILogger<CrashReportsController> logger;
|
private readonly ILogger<CrashReportsController> logger;
|
||||||
private readonly IConfiguration configuration;
|
private readonly IConfiguration configuration;
|
||||||
private const long MaximumSizeInBytes = 5242880; // 5MB
|
private const long MaximumSizeInBytes = 10485760; // 10MB
|
||||||
|
|
||||||
public CrashReportsController(
|
public CrashReportsController(
|
||||||
ICrashReportService crashReportService,
|
ICrashReportService crashReportService,
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
<UserSecretsId>155c5645-8bf7-4515-88d4-9ef801fdc47e</UserSecretsId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
13
Sdk/Include/ConfigConstants.h
Normal file
13
Sdk/Include/ConfigConstants.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace ConfigSections
|
||||||
|
{
|
||||||
|
const char* const Network = "network";
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace ConfigKeys
|
||||||
|
{
|
||||||
|
// Network
|
||||||
|
const char* const MasterServerHostName = "masterServerHostName";
|
||||||
|
const char* const BannedPlayers = "bannedPlayers";
|
||||||
|
}
|
44
Sdk/Include/ConfigEvents.h
Normal file
44
Sdk/Include/ConfigEvents.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#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>
|
#include <Unknwn.h>
|
||||||
|
|
||||||
// {779CF758-3E3F-4FEE-9513-60106522686A}
|
// {779CF758-3E3F-4FEE-9513-60106522686A}
|
||||||
DEFINE_GUID(IID_IComponent, 0x779cf758, 0x3e3f, 0x4fee, 0x95, 0x13, 0x60, 0x10, 0x65, 0x22, 0x68, 0x6a);
|
inline const GUID IID_IComponent = { 0x779cf758, 0x3e3f, 0x4fee, 0x95, 0x13, 0x60, 0x10, 0x65, 0x22, 0x68, 0x6a };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Base interface for a game COM component.
|
/// Base interface for a game COM component.
|
||||||
|
@ -7,8 +7,7 @@ template<typename T>
|
|||||||
using ComPtr = Microsoft::WRL::ComPtr<T>;
|
using ComPtr = Microsoft::WRL::ComPtr<T>;
|
||||||
|
|
||||||
// {C942AA9B-C576-4D3F-A54F-B135B500E611}
|
// {C942AA9B-C576-4D3F-A54F-B135B500E611}
|
||||||
DEFINE_GUID(IID_IComponentContainer,
|
inline const GUID IID_IComponentContainer = { 0xc942aa9b, 0xc576, 0x4d3f, 0xa5, 0x4f, 0xb1, 0x35, 0xb5, 0x0, 0xe6, 0x11 };
|
||||||
0xc942aa9b, 0xc576, 0x4d3f, 0xa5, 0x4f, 0xb1, 0x35, 0xb5, 0x0, 0xe6, 0x11);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct TypedGet
|
struct TypedGet
|
||||||
@ -18,19 +17,24 @@ struct TypedGet
|
|||||||
{
|
{
|
||||||
ComPtr<TGet> temp;
|
ComPtr<TGet> temp;
|
||||||
ComPtr<IComponent> pComponent = ((T*)this)->Get(__uuidof(TGet));
|
ComPtr<IComponent> pComponent = ((T*)this)->Get(__uuidof(TGet));
|
||||||
HRESULT hr = pComponent.As<TGet>(&temp);
|
if (pComponent)
|
||||||
if (FAILED(hr))
|
|
||||||
{
|
{
|
||||||
if (hr == E_NOINTERFACE)
|
HRESULT hr = pComponent.As<TGet>(&temp);
|
||||||
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
throw std::invalid_argument("The interface is not supported.");
|
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(fmt::format("Unknown exception {0:x} querying interface.", hr));
|
pComponent.Detach();
|
||||||
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
pComponent.Detach();
|
return ComPtr<TGet>(); // Null
|
||||||
return temp;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
44
Sdk/Include/IConfig.h
Normal file
44
Sdk/Include/IConfig.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#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;
|
10
Sdk/Include/IEventSource.h
Normal file
10
Sdk/Include/IEventSource.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#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;
|
||||||
|
};
|
18
Sdk/Include/IExceptionHandler.h
Normal file
18
Sdk/Include/IExceptionHandler.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#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 <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <IComponent.h>
|
#include <IComponent.h>
|
||||||
|
#include <IEventSource.h>
|
||||||
|
|
||||||
#include "GameServerEvents.h"
|
#include "GameServerEvents.h"
|
||||||
#include "NetCommon.h"
|
#include "NetCommon.h"
|
||||||
|
|
||||||
// {B2D67EE7-8063-488F-B3B9-E7DA675CB752}
|
// {B2D67EE7-8063-488F-B3B9-E7DA675CB752}
|
||||||
DEFINE_GUID(IID_IGameServer,
|
inline const GUID IID_IGameServer = { 0xb2d67ee7, 0x8063, 0x488f, 0xb3, 0xb9, 0xe7, 0xda, 0x67, 0x5c, 0xb7, 0x52 };
|
||||||
0xb2d67ee7, 0x8063, 0x488f, 0xb3, 0xb9, 0xe7, 0xda, 0x67, 0x5c, 0xb7, 0x52);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines an API for communicating with the game server.
|
/// Defines an API for communicating with the game server.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct IGameServer : IComponent
|
struct IGameServer : IComponent, IEventSource<GameServerEventType, GameServerEvent>
|
||||||
{
|
{
|
||||||
virtual ~IGameServer() = default;
|
virtual ~IGameServer() = default;
|
||||||
|
|
||||||
@ -32,10 +32,6 @@ struct IGameServer : IComponent
|
|||||||
virtual void STDMETHODCALLTYPE ChangeGameOption(GameOption option) = 0;
|
virtual void STDMETHODCALLTYPE ChangeGameOption(GameOption option) = 0;
|
||||||
|
|
||||||
virtual NetGameDetails STDMETHODCALLTYPE GetGameDetails() = 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;
|
struct DECLSPEC_UUID("{B2D67EE7-8063-488F-B3B9-E7DA675CB752}") IGameServer;
|
@ -5,8 +5,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// {3B2D43AC-2557-4C28-991D-A456B59D76CB}
|
// {3B2D43AC-2557-4C28-991D-A456B59D76CB}
|
||||||
DEFINE_GUID(IID_IGameServerConsole,
|
inline const GUID IID_IGameServerConsole = { 0x3b2d43ac, 0x2557, 0x4c28, 0x99, 0x1d, 0xa4, 0x56, 0xb5, 0x9d, 0x76, 0xcb };
|
||||||
0x3b2d43ac, 0x2557, 0x4c28, 0x99, 0x1d, 0xa4, 0x56, 0xb5, 0x9d, 0x76, 0xcb);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interface for dedicated server consoles.
|
/// Interface for dedicated server consoles.
|
||||||
|
@ -7,8 +7,7 @@ enum class NetPlayerState;
|
|||||||
enum class GameTeam;
|
enum class GameTeam;
|
||||||
|
|
||||||
// {770DEBD3-165D-4340-829D-5262F473FBE3}
|
// {770DEBD3-165D-4340-829D-5262F473FBE3}
|
||||||
DEFINE_GUID(IID_ITextLookupService,
|
inline const GUID IID_ITextLookupService = { 0x770debd3, 0x165d, 0x4340, 0x82, 0x9d, 0x52, 0x62, 0xf4, 0x73, 0xfb, 0xe3 };
|
||||||
0x770debd3, 0x165d, 0x4340, 0x82, 0x9d, 0x52, 0x62, 0xf4, 0x73, 0xfb, 0xe3);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Service providing localization of text placeholders and friendly-name mappings of common enums.
|
/// Service providing localization of text placeholders and friendly-name mappings of common enums.
|
||||||
|
24
Sdk/Include/MasterServer/IGiantsApiClient.h
Normal file
24
Sdk/Include/MasterServer/IGiantsApiClient.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#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;
|
21
Sdk/Include/MasterServer/PlayerInfoResponse.h
Normal file
21
Sdk/Include/MasterServer/PlayerInfoResponse.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#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;
|
||||||
|
};
|
51
Sdk/Include/MasterServer/ServerInfoResponse.h
Normal file
51
Sdk/Include/MasterServer/ServerInfoResponse.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#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;
|
||||||
|
};
|
9
Sdk/Include/Version.h
Normal file
9
Sdk/Include/Version.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
struct Version
|
||||||
|
{
|
||||||
|
int major;
|
||||||
|
int minor;
|
||||||
|
int build;
|
||||||
|
int revision;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user