diff --git a/ConfigDebug/UniverseLAN.ini b/ConfigDebug/UniverseLAN.ini new file mode 100644 index 00000000..40805466 --- /dev/null +++ b/ConfigDebug/UniverseLAN.ini @@ -0,0 +1,96 @@ +; This is the base config file for both the Client AND the Server +; It is part of the UniverseLAN project located at https://github.com/grasmanek94/UniverseLAN +[Storage] + +; GameDataPath is used by the game/DLL +; +GameDataPath = UniverseLANData + +; ServerDataPath is user by UniverseLANServer executable +; +ServerDataPath = UniverseLANServerData + +[Authentication] + +; Client and server must have the same authentication key +; +; If a client doesn't have the right key, the server will refuse the connection +; +; Can be generated with OpenSSL: +; openssl rand -base64 64 | paste --delimiters '' --serial +; With PowerShell: +; powershell -command "[Convert]::ToBase64String((1..64|%{[byte](Get-Random -Max 256)}))" +; +; THIS IS NOT AN ENCRYPTION KEY! MERELY AN AUTHENTICATION KEY +; (so that random clients cannot willy-nilly connect to your server) +; +Key = 9g5tA53SLyiNkBTqsX3BmBgy/PPVTU6VGKWNNw3wUIY5nK1C2MOT4UsZ2pauCb8fm5UQSJRijid+w1t9WpDaKQ== + + +[Tracing] + +; Disable to improve performance +; +CallTracing = 1 + +; If we should handle unhandled exceptions? +; +UnhandledExceptionLogging = 1 + +; Create minidump when unhandled exception occurs +; +MiniDumpOnUnhandledException = 1 + +; 0 - Normal minidump +; 1 - More data, ram etc +; 2 - Almost everything possible +; +MiniDumpVerbosityLevel = 2 + +; Disable to improve tracing performance +; +AlwaysFlush = 1 + +; Which tracing flags to enable +; +; Combine with a pipe symbol | +; Like: CallTracingFlags = INFORMATIONAL | HIGH_FREQUENCY_CALLS | ARGUMENTS +; +; INFORMATIONAL (always enabled) +; HIGH_FREQUENCY_CALLS +; ARGUMENTS +; RETURN_VALUES +; DETAILED +; ICHAT +; NETCLIENT +; ICUSTOMNETWORKING +; IERROR +; IFRIENDS +; GALAXYDLL +; GALAXYDLL_GAMESERVERAPI +; LISTENERREGISTRAR +; ILOGGER +; IMATCHMAKING +; INETWORKING +; ISTATS +; ISTORAGE +; ITELEMETRY +; IUSER +; IUTILS +; IGAMESERVERAPI +; IGALAXYTHREAD +; IAPPS +; +; TRACE_ALL_FLAGS (this one will trace ALL of the above with a single option) +; +; (check Tracer.hxx for all possible flags) +; +; Prepending ! or ~ allows to disable a certain option +; Like: CallTracingFlags = TRACE_ALL_FLAGS | !HIGH_FREQUENCY_CALLS +; +CallTracingFlags = INFORMATIONAL | TRACE_ALL_FLAGS + +; Enables tracing to console (in addition to tracing to tracefiles) +; Can slow down the game extremely in some cases. +; +TraceToConsole = 0 diff --git a/ConfigDebug/UniverseLANData/Achievements.ini b/ConfigDebug/UniverseLANData/Achievements.ini new file mode 100644 index 00000000..04fc04d7 --- /dev/null +++ b/ConfigDebug/UniverseLANData/Achievements.ini @@ -0,0 +1,6 @@ +[ExampleAchievement001Name] +Description = Describes the achievement nr 1 +Unlocked = 0 +UnlockTime = 0 +Visible = 1 +VisibleWhileLocked = 1 diff --git a/ConfigDebug/UniverseLANData/Avatars/me.png b/ConfigDebug/UniverseLANData/Avatars/me.png new file mode 100644 index 00000000..ed5d89a2 Binary files /dev/null and b/ConfigDebug/UniverseLANData/Avatars/me.png differ diff --git a/ConfigDebug/UniverseLANData/Config.ini b/ConfigDebug/UniverseLANData/Config.ini new file mode 100644 index 00000000..1c05d17e --- /dev/null +++ b/ConfigDebug/UniverseLANData/Config.ini @@ -0,0 +1,72 @@ +[Settings] +Language = english + +; Enable all downloaded and installed DLC which you already own +EnableAllDLC = 0 + +; When enabled, client will save any requested DLC product IDs into UniverseLAN\DLC.ini +SaveUnknownDLCIDs = 1 + +SaveAchievementsAndStats = 1 + +EnableConsole = 1 + +[Storage] +AllowFileSharingDownload = 1 +AllowFileSharingUpload = 0 + +[Telemetry] +Store = 0 + +[Client] +ServerAddress = 127.0.0.1 +Port = 19486 + +[User] +; PersonaNameType can be: +; - @WindowsAccountName +; - @WindowsAccountNameHash +; - @ComputerName +; - @ComputerNameHash +; - @NetworkAdapterMACHash +; - @ProcessID +; - @Custom (allows you to specify your username in CustomPersonaName) +; +PersonaNameType = @ProcessID +CustomPersonaName = Player + +; If true (1) then CustomPersonaName will be appended to +; whatever option has been chosen for PersonaNameType. +; +; For example if +; "PersonaNameType = @ComputerName" +; and +; "CustomPersonaName = Player" +; then the resulting name will be +; "ComputerNamePlayer" +; +SuffixPersonaNameTypeResultWithCustomPersonaName = 1 + +; GalaxyIDType can be: +; - @WindowsAccountNameHash +; - @ComputerNameHash +; - @NetworkAdapterMACHash +; - @Custom +; +GalaxyIDType = @NetworkAdapterMACHash + +; 64bit unsigned integer +CustomGalaxyID = 1 + +; static offset that is applied to the custom or calculated GalaxyID +; Can be: +; - a literal / number +; - @ProcessID +; @ProcessID can be used to offset the GalaxyID with the ID value of the current process +; Useful when running multiple instances on a single computer (e.g. during tests) +GalaxyIDOffset = @ProcessID + +; filename of the avatar +Avatar = me.png + +SignedIn = 1 diff --git a/ConfigDebug/UniverseLANData/DLC.ini b/ConfigDebug/UniverseLANData/DLC.ini new file mode 100644 index 00000000..2f24667a --- /dev/null +++ b/ConfigDebug/UniverseLANData/DLC.ini @@ -0,0 +1,6 @@ +; This category is automatically updated +; when a game requests a check of a certain product ID +; productid = 0/1 +; If you wish to do so, you can disable or enable any DLC that you own and have installed +[DLC] +0 = 1 ; basegame diff --git a/ConfigDebug/UniverseLANData/Local/.gitkeep b/ConfigDebug/UniverseLANData/Local/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/ConfigDebug/UniverseLANData/Logging/.gitkeep b/ConfigDebug/UniverseLANData/Logging/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/ConfigDebug/UniverseLANData/Shared/.gitkeep b/ConfigDebug/UniverseLANData/Shared/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/ConfigDebug/UniverseLANData/Shared/mapper/__filename_to_id__/.gitkeep b/ConfigDebug/UniverseLANData/Shared/mapper/__filename_to_id__/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/ConfigDebug/UniverseLANData/Shared/mapper/__id_to_filename__/.gitkeep b/ConfigDebug/UniverseLANData/Shared/mapper/__id_to_filename__/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/ConfigDebug/UniverseLANData/Stats.ini b/ConfigDebug/UniverseLANData/Stats.ini new file mode 100644 index 00000000..8bcae742 --- /dev/null +++ b/ConfigDebug/UniverseLANData/Stats.ini @@ -0,0 +1,4 @@ +[Metadata] +PlayTime = 0 + +[Stats] diff --git a/ConfigDebug/UniverseLANData/Telemetry/.gitkeep b/ConfigDebug/UniverseLANData/Telemetry/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/ConfigDebug/UniverseLANData/Tracing/.gitkeep b/ConfigDebug/UniverseLANData/Tracing/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/ConfigDebug/UniverseLANData/UserData.ini b/ConfigDebug/UniverseLANData/UserData.ini new file mode 100644 index 00000000..8d5c7f4b --- /dev/null +++ b/ConfigDebug/UniverseLANData/UserData.ini @@ -0,0 +1 @@ +[UserData] diff --git a/ConfigDebug/UniverseLANServerData/Avatars/.gitkeep b/ConfigDebug/UniverseLANServerData/Avatars/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/ConfigDebug/UniverseLANServerData/Config.ini b/ConfigDebug/UniverseLANServerData/Config.ini new file mode 100644 index 00000000..3764ff14 --- /dev/null +++ b/ConfigDebug/UniverseLANServerData/Config.ini @@ -0,0 +1,11 @@ +[Storage] + +AllowFileSharingDownload = 1 +AllowFileSharingUpload = 1 + +[Server] + +BindAddress = 0.0.0.0 +Port = 19486 +MaxConnections = 1024 +MaxTickRate = 200 ; in Hz diff --git a/ConfigDebug/UniverseLANServerData/Local/.gitkeep b/ConfigDebug/UniverseLANServerData/Local/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/ConfigDebug/UniverseLANServerData/Logging/.gitkeep b/ConfigDebug/UniverseLANServerData/Logging/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/ConfigDebug/UniverseLANServerData/Shared/.gitkeep b/ConfigDebug/UniverseLANServerData/Shared/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/ConfigDebug/UniverseLANServerData/Telemetry/.gitkeep b/ConfigDebug/UniverseLANServerData/Telemetry/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/ConfigDebug/UniverseLANServerData/Tracing/.gitkeep b/ConfigDebug/UniverseLANServerData/Tracing/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/README.MD b/README.MD index b5f8fe6b..a4a36119 100644 --- a/README.MD +++ b/README.MD @@ -91,6 +91,7 @@ Debug (tracing) files can be found in `/tracing/< | Game | Status | Tested GOG Galaxy SDK Version | Notes | | :--------- | :-------: | :---------: | :---------: | +| SYNTHETIK: Legion Rising | :white_check_mark:(2) | 1.113.3 | Works since build 301 | | Aragami 1 | :white_check_mark:(2) | 1.121.2 | | | Forsaken Remastered | :white_check_mark:(3) | 1.124.0 | | | Guns, Gore & Cannoli 2 | :white_check_mark:(3) | 1.124.0 | | diff --git a/Source/Client/GalaxyDLL.cxx b/Source/Client/GalaxyDLL.cxx index 3d363354..fb7dc765 100644 --- a/Source/Client/GalaxyDLL.cxx +++ b/Source/Client/GalaxyDLL.cxx @@ -192,11 +192,11 @@ namespace galaxy::api { public: GalaxyImpl() { - Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; + //Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; } virtual ~GalaxyImpl() { - Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; + //Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; } #if GALAXY_BUILD_FEATURE_HAS_INITOPTIONS @@ -285,6 +285,12 @@ namespace galaxy::api } #endif +#if GALAXY_BUILD_FEATURE_HAS_ICHAT + virtual IChat* GetChat() const override { + return universelan::client::Chat(); + } +#endif + virtual IListenerRegistrar* GetListenerRegistrar() const override { return universelan::client::ListenerRegistrar(); } @@ -305,11 +311,11 @@ namespace galaxy::api class ErrorManager : public IErrorManager { public: virtual ~ErrorManager() override { - Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; + //Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; } ErrorManager() { - Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; + //Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; } virtual api::IError* GetLastError() override { @@ -322,7 +328,7 @@ namespace galaxy::api IGalaxy* GalaxyFactory::GetInstance() { if (instance == nullptr) { - Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; + //Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; instance = new GalaxyImpl(); } @@ -332,7 +338,7 @@ namespace galaxy::api IErrorManager* GalaxyFactory::GetErrorManager() { if (errorManager == nullptr) { - Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; + //Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; errorManager = new ErrorManager(); } @@ -342,7 +348,7 @@ namespace galaxy::api void GalaxyFactory::ResetInstance() { if (instance != nullptr) { - Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; + //Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; delete instance; instance = nullptr; @@ -351,7 +357,7 @@ namespace galaxy::api IGalaxy* GalaxyFactory::CreateInstance() { if (instance == nullptr) { - Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; + //Trace trace { nullptr, __FUNCTION__, tracer::Trace::GALAXYDLL }; instance = new GalaxyImpl(); } diff --git a/Source/Client/Impl/Friends.cxx b/Source/Client/Impl/Friends.cxx index e9865f90..f66f1f17 100644 --- a/Source/Client/Impl/Friends.cxx +++ b/Source/Client/Impl/Friends.cxx @@ -250,6 +250,7 @@ namespace universelan::client { &IFriendInvitationListRetrieveListener::OnFriendInvitationListRetrieveSuccess); } +#if GALAXY_BUILD_FEATURE_HAS_ISENTFRIENDINVITATIONLISTRETRIEVELISTENER void FriendsImpl::RequestSentFriendInvitationList( #if GALAXY_BUILD_FEATURE_IFRIENDS_INFORMATIONLISTENERS ISentFriendInvitationListRetrieveListener* const listener @@ -263,6 +264,7 @@ namespace universelan::client { #endif &ISentFriendInvitationListRetrieveListener::OnSentFriendInvitationListRetrieveSuccess); } +#endif uint32_t FriendsImpl::GetFriendInvitationCount() { tracer::Trace trace { nullptr, __FUNCTION__, tracer::Trace::IFRIENDS | tracer::Trace::HIGH_FREQUENCY_CALLS }; diff --git a/Source/Client/Impl/Friends.hxx b/Source/Client/Impl/Friends.hxx index 3eefbf40..0ccbcbe9 100644 --- a/Source/Client/Impl/Friends.hxx +++ b/Source/Client/Impl/Friends.hxx @@ -331,6 +331,7 @@ namespace universelan::client { #endif ) override; +#if GALAXY_BUILD_FEATURE_HAS_ISENTFRIENDINVITATIONLISTRETRIEVELISTENER /** * Performs a request for the user's list of outgoing friend invitations. * @@ -343,6 +344,7 @@ namespace universelan::client { ISentFriendInvitationListRetrieveListener* const listener = NULL #endif ) override; +#endif /** * Returns the number of retrieved friend invitations. diff --git a/Source/DLLs/1.113.3/Factory.cxx b/Source/DLLs/1.113.3/Factory.cxx new file mode 100644 index 00000000..69ae7fe2 --- /dev/null +++ b/Source/DLLs/1.113.3/Factory.cxx @@ -0,0 +1,234 @@ +#include + +namespace galaxy::api { + + /** + * Calls IGalaxy::Init() on the singleton instance of IGalaxy. + * + * @param clientID The ID of the client. + * @param clientSecret The secret of the client. + * @param throwExceptions Indicates if Galaxy should throw exceptions. + */ + GALAXY_DLL_EXPORT void GALAXY_CALLTYPE Init(const char* clientID, const char* clientSecret, bool throwExceptions = true) + { + GalaxyFactory::CreateInstance()->Init(clientID, clientSecret, throwExceptions); + } + + /** + * Calls IGalaxy::Init() on the singleton instance of IGalaxy. + * + * @param initOptions The group of the init options. + */ + GALAXY_DLL_EXPORT void GALAXY_CALLTYPE Init(const InitOptions& initOptions) + { + GalaxyFactory::CreateInstance()->Init(initOptions); + } + + /** + * Calls IGalaxy::InitLocal() on the singleton instance of IGalaxy. + * + * @param clientID The ID of the client. + * @param clientSecret The secret of the client. + * @param galaxyPeerPath Path to the galaxyPeer library location. + * @param throwExceptions indicates if Galaxy should throw exceptions. + */ + GALAXY_DLL_EXPORT void GALAXY_CALLTYPE InitLocal(const char* clientID, const char* clientSecret, const char* galaxyPeerPath = ".", bool throwExceptions = true) + { + GalaxyFactory::CreateInstance()->InitLocal(clientID, clientSecret, galaxyPeerPath, throwExceptions); + } + + /** + * Calls IGalaxy::Shutdown() on the singleton instance of IGalaxy and then frees the instance. + */ + GALAXY_DLL_EXPORT void GALAXY_CALLTYPE Shutdown() + { + if (!GalaxyFactory::GetInstance()) + return; + + GalaxyFactory::GetInstance()->Shutdown(); + GalaxyFactory::ResetInstance(); + } + + /** + * Calls IGalaxy::ProcessData() on the singleton instance of IGalaxy. + * + * This method should be called in a loop, preferably every frame, + * so that Galaxy is able to process input and output streams. + * + * @remark When this method is not called, any asynchronous calls to Galaxy API + * cannot be processed and any listeners will not be properly called. + */ + GALAXY_DLL_EXPORT void GALAXY_CALLTYPE ProcessData() + { + if (!GalaxyFactory::GetInstance()) + return; + + GalaxyFactory::GetInstance()->ProcessData(); + } + + /** + * Calls IGalaxy::GetUser() on the singleton instance of IGalaxy. + * + * @return An instance of IUser. + */ + GALAXY_DLL_EXPORT IUser* GALAXY_CALLTYPE User() + { + if (!GalaxyFactory::GetInstance()) + return nullptr; + + return GalaxyFactory::GetInstance()->GetUser(); + } + + /** + * Calls IGalaxy::GetFriends() on the singleton instance of IGalaxy. + * + * @return An instance of IFriends. + */ + GALAXY_DLL_EXPORT IFriends* GALAXY_CALLTYPE Friends() + { + if (!GalaxyFactory::GetInstance()) + return nullptr; + + return GalaxyFactory::GetInstance()->GetFriends(); + } + + /** + * Calls IGalaxy::GetMatchmaking() on the singleton instance of IGalaxy. + * + * @return An instance of IMatchmaking. + */ + GALAXY_DLL_EXPORT IMatchmaking* GALAXY_CALLTYPE Matchmaking() + { + if (!GalaxyFactory::GetInstance()) + return nullptr; + + return GalaxyFactory::GetInstance()->GetMatchmaking(); + } + + /** + * Calls IGalaxy::GetNetworking() on the singleton instance of IGalaxy. + * + * @return An instance of INetworking. + */ + GALAXY_DLL_EXPORT INetworking* GALAXY_CALLTYPE Networking() + { + if (!GalaxyFactory::GetInstance()) + return nullptr; + + return GalaxyFactory::GetInstance()->GetNetworking(); + } + + /** + * Calls IGalaxy::GetServerNetworking() on the singleton instance of IGalaxy. + * + * @return An instance of INetworking. + */ + GALAXY_DLL_EXPORT INetworking* GALAXY_CALLTYPE ServerNetworking() + { + if (!GalaxyFactory::GetInstance()) + return nullptr; + + return GalaxyFactory::GetInstance()->GetServerNetworking(); + } + + /** + * Calls IGalaxy::GetStats() on the singleton instance of IGalaxy. + * + * @return An instance of IStats. + */ + GALAXY_DLL_EXPORT IStats* GALAXY_CALLTYPE Stats() + { + if (!GalaxyFactory::GetInstance()) + return nullptr; + + return GalaxyFactory::GetInstance()->GetStats(); + } + + /** + * Calls IGalaxy::GetUtils() on the singleton instance of IGalaxy. + * + * @return An instance of IUtils. + */ + GALAXY_DLL_EXPORT IUtils* GALAXY_CALLTYPE Utils() + { + if (!GalaxyFactory::GetInstance()) + return nullptr; + + return GalaxyFactory::GetInstance()->GetUtils(); + } + + /** + * Calls IGalaxy::GetApps() on the singleton instance of IGalaxy. + * + * @return An instance of IApps. + */ + GALAXY_DLL_EXPORT IApps* GALAXY_CALLTYPE Apps() + { + if (!GalaxyFactory::GetInstance()) + return nullptr; + + return GalaxyFactory::GetInstance()->GetApps(); + } + + /** + * Calls IGalaxy::GetStorage() on the singleton instance of IGalaxy. + * + * @return An instance of IStorage. + */ + GALAXY_DLL_EXPORT IStorage* GALAXY_CALLTYPE Storage() + { + if (!GalaxyFactory::GetInstance()) + return nullptr; + + return GalaxyFactory::GetInstance()->GetStorage(); + } + + /** + * Calls IGalaxy::GetCustomNetworking() on the singleton instance of IGalaxy. + * + * @return An instance of ICustomNetworking. + */ + GALAXY_DLL_EXPORT ICustomNetworking* GALAXY_CALLTYPE CustomNetworking() + { + if (!GalaxyFactory::GetInstance()) + return nullptr; + + return GalaxyFactory::GetInstance()->GetCustomNetworking(); + } + + /** + * Calls IGalaxy::GetListenerRegistrar() on the singleton instance of IGalaxy. + * + * @return An instance of IListenerRegistrar. + */ + GALAXY_DLL_EXPORT IListenerRegistrar* GALAXY_CALLTYPE ListenerRegistrar() + { + if (!GalaxyFactory::GetInstance()) + return nullptr; + + return GalaxyFactory::GetInstance()->GetListenerRegistrar(); + } + + /** + * Calls IGalaxy::GetLogger() on the singleton instance of IGalaxy. + * + * @return An instance of ILogger. + */ + GALAXY_DLL_EXPORT ILogger* GALAXY_CALLTYPE Logger() + { + if (!GalaxyFactory::GetInstance()) + return nullptr; + + return GalaxyFactory::GetInstance()->GetLogger(); + } + + /** + * Calls IGalaxy::GetError() on singleton instance of IGalaxy. + * + * @return Either the last API call error or NULL if there was no error. + */ + GALAXY_DLL_EXPORT const IError* GALAXY_CALLTYPE GetError() + { + return GalaxyFactory::GetErrorManager()->GetLastError(); + } +} diff --git a/Source/DLLs/1.113.3/FactoryHost.cxx b/Source/DLLs/1.113.3/FactoryHost.cxx new file mode 100644 index 00000000..a9dd9c54 --- /dev/null +++ b/Source/DLLs/1.113.3/FactoryHost.cxx @@ -0,0 +1,37 @@ +#include + +#include +#include + +using namespace galaxy::api; +using namespace std::chrono; + +int main() +{ + auto galaxy = GalaxyFactory::GetInstance( + //0, 0 + ); + + galaxy->Init("",""); + + while (true) + { + galaxy->ProcessData(); + std::this_thread::sleep_for(milliseconds(5)); + } + + return 0; +} + +#ifdef _WIN32 +#include + +int +#ifndef _WIN64 +__stdcall +#endif +WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) +{ + return main(); +} +#endif \ No newline at end of file diff --git a/Source/DLLs/1.113.3/galaxy/Errors.h b/Source/DLLs/1.113.3/galaxy/Errors.h new file mode 100644 index 00000000..02a08ad1 --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/Errors.h @@ -0,0 +1,115 @@ +#ifndef GALAXY_ERRORS_H +#define GALAXY_ERRORS_H + +/** + * @file + * Contains classes representing exceptions. + */ + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + /** + * Base interface for exceptions. + */ + class IError + { + public: + + virtual ~IError() + { + } + + /** + * Returns the name of the error. + * + * @return The name of the error. + */ + virtual const char* GetName() const = 0; + + /** + * Returns the error message. + * + * @return The error message. + */ + virtual const char* GetMsg() const = 0; + + /** + * Type of error. + */ + enum Type + { + UNAUTHORIZED_ACCESS, + INVALID_ARGUMENT, + INVALID_STATE, + RUNTIME_ERROR + }; + + /** + * Returns the type of the error. + * + * @return The type of the error. + */ + virtual Type GetType() const = 0; + }; + + /** + * The exception thrown when calling IGalaxy or an interface it provides while + * the user is not signed in and thus not authorized for any interaction. + */ + class IUnauthorizedAccessError : public IError + { + }; + + /** + * The exception thrown to report that a method was called with an invalid argument. + */ + class IInvalidArgumentError : public IError + { + }; + + /** + * The exception thrown to report that a method was called while the callee is in + * an invalid state, i.e. should not have been called the way it was at that time. + */ + class IInvalidStateError : public IError + { + }; + + /** + * The exception thrown to report errors that can only be detected during runtime. + */ + class IRuntimeError : public IError + { + }; + + /** + * The interface of the error manager. Not to be used directly. + */ + class IErrorManager + { + public: + + virtual ~IErrorManager() + { + } + + /** + * Retrieves the stored last error. + * + * @return Either the stored last error or NULL if there is none. + */ + virtual api::IError* GetLastError() = 0; + }; + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/GalaxyApi.h b/Source/DLLs/1.113.3/galaxy/GalaxyApi.h new file mode 100644 index 00000000..2c4c1d23 --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/GalaxyApi.h @@ -0,0 +1,532 @@ +#ifndef GALAXY_API_H +#define GALAXY_API_H + +/** + * @file + * Includes all other files that are needed to work with the Galaxy library. + */ + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + /** + * + * @mainpage Introduction + * + * @tableofcontents + * + * @section getting-started Getting started + * + * Developing a game with Galaxy needs to start from linking your application + * to the following libraries: + * * Galaxy.lib on Windows + * * libGalaxy.dylib on MacOSX + * + * All libraries are loaded dynamically, so they have to be placed in the same + * folder as your executable. + * + * @section client-credentials Client credentials + * + * In order to use the Galaxy API, you should request special client credentials + * from GOG.com for each game you develop. You will be provided with a pair of + * Client ID and Client Secret that are to be used when calling IGalaxy::Init(). + * + * Client credentials identify your game within Galaxy. Only Galaxy Peers that + * use the same Client ID can interact with each other. + * + * @section overview Overview + * + * The Galaxy API is divided into multiple header files. You can either include + * only the header files with the data structures and interfaces you need, or + * simply include the file called GalaxyApi.h that includes all the other files. + * + * You can control your Galaxy Peer with an instance of the IGalaxy, that you + * can acquire by calling GalaxyFactory::GetInstance(). The IGalaxy interface + * lets you control your Galaxy Peer by providing interfaces for specific + * feature sets, e.g. IUser, IMatchmaking, INetworking, + * IFriends, IListenerRegistrar, ILogger. + * + * For your convenience, there are global functions called Matchmaking(), + * Networking(), ListenerRegistrar(), etc. What they do is call + * GalaxyFactory::GetInstance(), acquire appropriate interface from it, and + * return it. + * + * For every frame you should call IGalaxy::ProcessData() to process input + * and output streams. + * + * @section errors Error handling + * + * The Galaxy API has two ways of handling errors. + * + * The first one is by throwing errors as exceptions. This is the default. + * + * The second one is to check if there were any errors during last operation + * by calling IGalaxy::GetError(), which returns NULL if there was no error. + * Every call to an API method resets last stored error, therefore you should + * check for errors after each call. + * + * You can set the way of handling errors with the IGalaxy::Init() method. + * + * @section listeners Listeners + * + * Since many method calls are asynchronous, there is a mechanism for receiving + * responses within a callback that is based on implementing special interfaces + * called listeners that derive from the IGalaxyListener interface. + * + * Listeners need to be registered in the IListenerRegistrar in order to + * receive a notification via a callback when an event of specific type has + * occurred. For convenience, there is a basic implementation for each listener + * that registers and unregisters automatically. + * + * Listeners are called during the phase of processing data, i.e. during the + * call to IGalaxy::ProcessData(). + * + * @section authentication Authentication + * + * You need to initialize the Galaxy Peer by signing in the user. To do that, + * you need to get an instance of IUser from the IGalaxy and call + * IUser::SignIn(). + * + * As with any other asynchronous call, you will get the information about + * the result of your request via a dedicated listener. For that to happen, + * you already need to call IGalaxy::ProcessData() in a loop as mentioned earlier. + * + * In case of limited availability of Galaxy backend services it might happen + * that the user gets signed in within local Galaxy Service, yet still does not + * manage to log on to Galaxy backend services. In that case the Galaxy Peer + * offers only some of its functionality. + * + * Having successfully signed in the user, you may want to check that the user + * is logged on to Galaxy backend services by calling IUser::IsLoggedOn(). + * + * Information about being signed in or signed out, as well as information + * about being logged on or logged off, determine the operational state + * of Galaxy Peer and both come to the IOperationalStateChangeListener. + * + * @section matchmaking Matchmaking + * + * To play a match with other users, the users needs to join them in a so called + * lobby. The user can either join an existing lobby or create one. All this is + * done with the IMatchmaking interface. + * + * Typically you will set appropriate filters by calling e.g. + * IMatchmaking::AddRequestLobbyListStringFilter() or + * IMatchmaking::AddRequestLobbyListNumericalFilter(), then retrieve the list + * of available lobbies by calling IMatchmaking::RequestLobbyList(), and + * than make the user join one of the lobbies by calling + * IMatchmaking::JoinLobby(). Alternatively the user might want to create + * a lobby, in which case you will need to call + * IMatchmaking::CreateLobby(). + * + * @section lobbies Lobbies + * + * Users need to stay present in the lobby for the whole match, until it ends. + * + * When the user is the owner of a lobby, its Galaxy Peer needs to act as the + * game host. + * + * @subsection lobbies-messaging Messaging + * + * You can broadcast messages to all Galaxy Peers in the lobby by calling + * IMatchmaking::SendLobbyMessage(). Each recipient should be registered + * for notifications about incoming messages with dedicated listener, and on the + * occurrence of such notification call IMatchmaking::GetLobbyMessage(). + * + * @section networking P2P networking + * + * You can communicate with other Galaxy Peers that are in the same lobby using + * the INetworking interface. This way of communication is meant to be + * used for sending data that is directed to certain Galaxy Peers, especially + * for sending large amount of date in case of audio and video communication. + * Use it also for sending any other game data that is not crucial, yet needs to + * be delivered quickly. + * + * @subsection networking-sending Sending P2P packets + * + * To send a P2P packet call INetworking::SendP2PPacket(). + * + * You can send packets to specific users by explicitly providing their IDs, or + * implicitly to the lobby owner (game host) by providing the ID of the lobby as + * the recipient. + * + * @subsection networking-receiving Receiving P2P packets + * + * To receive the packets that come to your Galaxy Peer as a regular lobby + * member, get the instance of INetworking by calling + * IGalaxy::GetNetworking(). + * + * To receive the packets that come to your Galaxy Peer as a lobby owner, so + * that you can process them as the game host, get the instance o + * INetworking by calling IGalaxy::GetServerNetworking(). + * + * @section statistics Statistics, achievements and leaderboards + * + * The Galaxy API allows you to store information about statistic counters + * and unlocked achievements using the IStats interface. + * + * You can retrieve statistics and achievements of the user who is currently + * signed in, or other user that he interacts with, by calling + * IStats::RequestUserStatsAndAchievements(). + * + * Having retrieved statistics and achievement of your user, you can both read + * and update them. After making edits to statistics and achievements you will + * need to store them by calling IStats::StoreStatsAndAchievements(). + * + * You can retrieve leaderboards by calling IStats::RequestLeaderboards(). + * + * Having retrieved leaderboard definitions you can change user's score by using + * IStats::SetLeaderboardScore() and retrieve leaderboard entries with scores and + * ranks of competing users by calling IStats::RequestLeaderboardEntriesGlobal(), + * IStats::RequestLeaderboardEntriesAroundUser(), or IStats::RequestLeaderboardEntriesForUsers(). + * + * @section friends Friends + * + * The Galaxy API allows you to download the list of your friends by calling + * IFriends::RequestFriendList(). + * + * Having retrieved the friend list you can browse it by calling IFriends::GetFriendCount() + * and IFriends::GetFriendByIndex(). + * + * The Galaxy API allows you to browse information about other users. + * + * You can retrieve information about a specific user by calling IFriends::RequestUserInformation(). + * + * Having retrieved other user information you can read it by calling + * IFriends::GetFriendPersonaName() and IFriends::GetFriendAvatarUrl(). + * + * Some operations, e.g. entering a lobby or requesting for the friend list, automatically retrieve + * information about lobby members or friends accordingly. + * + * @subsection invites Inviting friends + * + * The Galaxy API allows you to invite your friends to play together by calling IFriends::ShowOverlayInviteDialog(). + * This require the connectionString which will allow other users to join your game. + + * Typically the connectionString looks like "-connect-lobby-". + + * After the invitation receiver gets the notification, he can click the JOIN button, which + * will fire IGameJoinRequestedListener with connectionString, or will start the game with + * connectionString as a parameter. + * + * @subsection rich-presence RichPresence + * + * The Galaxy API allows you to set the RichPresence "status" and "connect" keys. + * "status" key will be visible to your friends inside the Galaxy Client chat and friend list. + * "connect" key will be visible to your friends as a JOIN button, which works exactly the same way + * as like the player would receive the game invitation. + * + * @section storage Storage + * + * The Galaxy API allows you to store files in Galaxy's backend services. The files are automatically synchronized + * by the Galaxy Client application. You can access the stored files using the IStorage interface. + * + * @section dlc-discovery DLC discovery + * + * There is an easy way of checking if a DLC has been installed by calling + * IApps::IsDlcInstalled() with the Product ID of the particular DLC. + * This feature does not require the user to be online, or Galaxy Client + * to be installed, or even Galaxy API to be fully initialized, however + * you still need to call IGalaxy::Init() first. + * + * @section language Game language + * + * There is an easy way of retrieving game or DLC language by calling + * IApps::GetCurrentGameLanguage() with the Product ID of the game + * (0 can be used to retrieve base game language) or particular DLC. + * This feature does not require the user to be online, or Galaxy Client + * to be installed, or even Galaxy API to be fully initialized, however + * you still need to call IGalaxy::Init() first. + * + * @section thread-safety Thread-safety + * + * The Galaxy API is thread-safe in general, however there are some methods that return pointers and therefore + * cannot be used in multi-threaded environments. In order to address the issue the similar methods of names with + * a suffix of "Copy" were introduced, e.g. compare IFriends::GetPersonaName() and IFriends::GetPersonaNameCopy(). + * + */ + + /** @} */ + } +} + +#include "IGalaxy.h" +#include "IUser.h" +#include "IFriends.h" +#include "IChat.h" +#include "IMatchmaking.h" +#include "INetworking.h" +#include "IStats.h" +#include "IUtils.h" +#include "IApps.h" +#include "IStorage.h" +#include "ICustomNetworking.h" +#include "IListenerRegistrar.h" +#include "ILogger.h" +#include "Errors.h" +#include "GalaxyFactory.h" + +#include + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + /** + * Calls IGalaxy::Init() on the singleton instance of IGalaxy. + * + * @param [in] clientID The ID of the client. + * @param [in] clientSecret The secret of the client. + * @param [in] throwExceptions Indicates if Galaxy should throw exceptions. + */ + static void GALAXY_CALLTYPE Init(const char* clientID, const char* clientSecret, bool throwExceptions = true) + { + GalaxyFactory::CreateInstance()->Init(clientID, clientSecret, throwExceptions); + } + + /** + * Calls IGalaxy::Init() on the singleton instance of IGalaxy. + * + * @param [in] initOptions The group of the init options. + */ + static void GALAXY_CALLTYPE Init(const InitOptions& initOptions) + { + GalaxyFactory::CreateInstance()->Init(initOptions); + } + + /** + * Calls IGalaxy::InitLocal() on the singleton instance of IGalaxy. + * + * @param [in] clientID The ID of the client. + * @param [in] clientSecret The secret of the client. + * @param [in] galaxyPeerPath Path to the galaxyPeer library location. + * @param [in] throwExceptions indicates if Galaxy should throw exceptions. + */ + static void GALAXY_CALLTYPE InitLocal(const char* clientID, const char* clientSecret, const char* galaxyPeerPath = ".", bool throwExceptions = true) + { + GalaxyFactory::CreateInstance()->InitLocal(clientID, clientSecret, galaxyPeerPath, throwExceptions); + } + + /** + * Calls IGalaxy::Shutdown() on the singleton instance of IGalaxy and then frees the instance. + */ + static void GALAXY_CALLTYPE Shutdown() + { + if (!GalaxyFactory::GetInstance()) + return; + + GalaxyFactory::GetInstance()->Shutdown(); + GalaxyFactory::ResetInstance(); + } + + /** + * Calls IGalaxy::ProcessData() on the singleton instance of IGalaxy. + * + * This method should be called in a loop, preferably every frame, + * so that Galaxy is able to process input and output streams. + * + * @remark When this method is not called, any asynchronous calls to Galaxy API + * cannot be processed and any listeners will not be properly called. + */ + static void GALAXY_CALLTYPE ProcessData() + { + if (!GalaxyFactory::GetInstance()) + return; + + GalaxyFactory::GetInstance()->ProcessData(); + } + + /** + * Calls IGalaxy::GetUser() on the singleton instance of IGalaxy. + * + * @return An instance of IUser. + */ + static IUser* GALAXY_CALLTYPE User() + { + if (!GalaxyFactory::GetInstance()) + return NULL; + + return GalaxyFactory::GetInstance()->GetUser(); + } + + /** + * Calls IGalaxy::GetFriends() on the singleton instance of IGalaxy. + * + * @return An instance of IFriends. + */ + static IFriends* GALAXY_CALLTYPE Friends() + { + if (!GalaxyFactory::GetInstance()) + return NULL; + + return GalaxyFactory::GetInstance()->GetFriends(); + } + + /** + * Calls IGalaxy::GetChat() on the singleton instance of IGalaxy. + * + * @return An instance of IChat. + */ + static IChat* GALAXY_CALLTYPE Chat() + { + if (!GalaxyFactory::GetInstance()) + return NULL; + + return GalaxyFactory::GetInstance()->GetChat(); + } + + /** + * Calls IGalaxy::GetMatchmaking() on the singleton instance of IGalaxy. + * + * @return An instance of IMatchmaking. + */ + static IMatchmaking* GALAXY_CALLTYPE Matchmaking() + { + if (!GalaxyFactory::GetInstance()) + return NULL; + + return GalaxyFactory::GetInstance()->GetMatchmaking(); + } + + /** + * Calls IGalaxy::GetNetworking() on the singleton instance of IGalaxy. + * + * @return An instance of INetworking. + */ + static INetworking* GALAXY_CALLTYPE Networking() + { + if (!GalaxyFactory::GetInstance()) + return NULL; + + return GalaxyFactory::GetInstance()->GetNetworking(); + } + + /** + * Calls IGalaxy::GetServerNetworking() on the singleton instance of IGalaxy. + * + * @return An instance of INetworking. + */ + static INetworking* GALAXY_CALLTYPE ServerNetworking() + { + if (!GalaxyFactory::GetInstance()) + return NULL; + + return GalaxyFactory::GetInstance()->GetServerNetworking(); + } + + /** + * Calls IGalaxy::GetStats() on the singleton instance of IGalaxy. + * + * @return An instance of IStats. + */ + static IStats* GALAXY_CALLTYPE Stats() + { + if (!GalaxyFactory::GetInstance()) + return NULL; + + return GalaxyFactory::GetInstance()->GetStats(); + } + + /** + * Calls IGalaxy::GetUtils() on the singleton instance of IGalaxy. + * + * @return An instance of IUtils. + */ + static IUtils* GALAXY_CALLTYPE Utils() + { + if (!GalaxyFactory::GetInstance()) + return NULL; + + return GalaxyFactory::GetInstance()->GetUtils(); + } + + /** + * Calls IGalaxy::GetApps() on the singleton instance of IGalaxy. + * + * @return An instance of IApps. + */ + static IApps* GALAXY_CALLTYPE Apps() + { + if (!GalaxyFactory::GetInstance()) + return NULL; + + return GalaxyFactory::GetInstance()->GetApps(); + } + + /** + * Calls IGalaxy::GetStorage() on the singleton instance of IGalaxy. + * + * @return An instance of IStorage. + */ + static IStorage* GALAXY_CALLTYPE Storage() + { + if (!GalaxyFactory::GetInstance()) + return NULL; + + return GalaxyFactory::GetInstance()->GetStorage(); + } + + /** + * Calls IGalaxy::GetCustomNetworking() on the singleton instance of IGalaxy. + * + * @return An instance of ICustomNetworking. + */ + static ICustomNetworking* GALAXY_CALLTYPE CustomNetworking() + { + if (!GalaxyFactory::GetInstance()) + return NULL; + + return GalaxyFactory::GetInstance()->GetCustomNetworking(); + } + + /** + * Calls IGalaxy::GetListenerRegistrar() on the singleton instance of IGalaxy. + * + * @return An instance of IListenerRegistrar. + */ + static IListenerRegistrar* GALAXY_CALLTYPE ListenerRegistrar() + { + if (!GalaxyFactory::GetInstance()) + return NULL; + + return GalaxyFactory::GetInstance()->GetListenerRegistrar(); + } + + /** + * Calls IGalaxy::GetLogger() on the singleton instance of IGalaxy. + * + * @return An instance of ILogger. + */ + static ILogger* GALAXY_CALLTYPE Logger() + { + if (!GalaxyFactory::GetInstance()) + return NULL; + + return GalaxyFactory::GetInstance()->GetLogger(); + } + + /** + * Calls IGalaxy::GetError() on singleton instance of IGalaxy. + * + * @return Either the last API call error or NULL if there was no error. + */ + static const IError* GALAXY_CALLTYPE GetError() + { + return GalaxyFactory::GetErrorManager()->GetLastError(); + } + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/GalaxyExport.h b/Source/DLLs/1.113.3/galaxy/GalaxyExport.h new file mode 100644 index 00000000..8e7168a3 --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/GalaxyExport.h @@ -0,0 +1,25 @@ +#ifndef GALAXY_EXPORT_H +#define GALAXY_EXPORT_H + +/** + * @file + * Contains a macro used for DLL export. + */ + +#if defined(_WIN32) && !defined(__ORBIS__) && !defined(_XBOX_ONE) + #if defined(GALAXY_EXPORT) + #define GALAXY_DLL_EXPORT __declspec(dllexport) + #else + #define GALAXY_DLL_EXPORT __declspec(dllimport) + #endif +#else + #define GALAXY_DLL_EXPORT +#endif + +#if defined(_WIN32) && !defined(__ORBIS__) && !defined(_XBOX_ONE) + #define GALAXY_CALLTYPE __cdecl +#else + #define GALAXY_CALLTYPE +#endif + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/GalaxyFactory.h b/Source/DLLs/1.113.3/galaxy/GalaxyFactory.h new file mode 100644 index 00000000..1c89087a --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/GalaxyFactory.h @@ -0,0 +1,76 @@ +#ifndef GALAXY_GALAXY_FACTORY_H +#define GALAXY_GALAXY_FACTORY_H + +/** + * @file + * Contains GalaxyFactory, which creates an instance of IGalaxy that allows to + * control the Galaxy Peer. + */ + +#include "IGalaxy.h" +#include "Errors.h" +#include "GalaxyExport.h" + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + /** + * The singleton factory that creates an instance of IGalaxy that allows to + * control the Galaxy Peer. + */ + class GALAXY_DLL_EXPORT GalaxyFactory + { + public: + + /** + * Returns the created instance of IGalaxy. + * + * @remark Instead of using this method directly, you probably should use + * methods defined in GalaxyApi.h. + * + * @return The instance of IGalaxy or NULL if it has not been created yet. + */ + static IGalaxy* GALAXY_CALLTYPE GetInstance(); + + /** + * Returns the instance of error manager. Creates it if it does not exists yet. + * + * @return instance of error manager. + */ + static IErrorManager* GALAXY_CALLTYPE GetErrorManager(); + + /** + * Removes the created instance of IGalaxy. + * + * @remark Instead of using this method directly, you probably should use + * the Shutdown() method defined in GalaxyApi.h. + */ + static void GALAXY_CALLTYPE ResetInstance(); + + /** + * Returns the instance of IGalaxy. Creates it if it does not exist yet. + * + * @remark Instead of using this method directly, you probably should use + * methods defined in GalaxyApi.h. + * + * @return The instance of IGalaxy. + */ + static IGalaxy* GALAXY_CALLTYPE CreateInstance(); + + private: + + static IGalaxy* instance; ///< The instance of IGalaxy. + static IErrorManager* errorManager; ///< The instance of Error Manager. + }; + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/GalaxyID.h b/Source/DLLs/1.113.3/galaxy/GalaxyID.h new file mode 100644 index 00000000..90bf18ae --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/GalaxyID.h @@ -0,0 +1,196 @@ +#ifndef GALAXY_GALAXY_ID_H +#define GALAXY_GALAXY_ID_H + +/** + * @file + * Contains GalaxyID, which is the class that represents the ID of an entity + * used by Galaxy Peer. + */ + +#include "stdint.h" +#include + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + +#pragma pack( push, 1 ) + + /** + * Represents the ID of an entity used by Galaxy Peer. + * + * This can be the ID of either a lobby or a Galaxy user. + */ + class GalaxyID + { + public: + + /** + * The type of the ID. + */ + enum IDType { + ID_TYPE_UNASSIGNED = 0, + ID_TYPE_LOBBY = 1, + ID_TYPE_USER = 2 + }; + + /** + * The numerical value used when the instance of GalaxyID is not valid. + */ + static const uint64_t UNASSIGNED_VALUE = 0; + + /** + * Creates GalaxyID from real ID and type. + * + * @param [in] type The type of the ID. + * @param [in] value The real ID value. + * @return The GalaxyID. + */ + static GalaxyID FromRealID(IDType type, uint64_t value) + { + assert(type != ID_TYPE_UNASSIGNED); + assert(value != UNASSIGNED_VALUE); + assert(static_cast(value >> 56) == ID_TYPE_UNASSIGNED); + return GalaxyID(static_cast(type) << 56 | value); + } + + /** + * Default constructor. + * + * Creates an instance of GalaxyID that is invalid and of unknown kind. + */ + GalaxyID(void) : value(UNASSIGNED_VALUE) + { + } + + /** + * Creates an instance of GalaxyID of a specified value. + * + * @param [in] _value The numerical value of the ID. + */ + GalaxyID(uint64_t _value) : value(_value) + { + } + + /** + * Copy constructor. + * + * Creates a copy of another instance of GalaxyID. + * + * @param [in] galaxyID The instance of GalaxyID to copy from. + */ + GalaxyID(const GalaxyID& galaxyID) : value(galaxyID.value) + { + } + + /** + * The assignment operator. Makes the ID equal to another ID. + * + * @param [in] other The instance of GalaxyID to copy from. + * @return A reference to this ID. + */ + GalaxyID& operator=(const GalaxyID& other) + { + value = other.value; + return *this; + } + + /** + * The lower operator. It is supposed to be used to compare only valid + * instances of GalaxyID that are assigned to entities of the same type. + * + * @param [in] other Another instance of GalaxyID to compare to. + * @return true if this instance is lower, false otherwise. + */ + bool operator<(const GalaxyID& other) const + { + assert(IsValid() && other.IsValid()); + return value < other.value; + } + + /** + * The equality operator. Might be used to compare all sorts of GalaxyID. + * + * @param [in] other Another instance of GalaxyID to compare to. + * @return true if the instances are equal, false otherwise. + */ + bool operator==(const GalaxyID& other) const + { + return value == other.value; + } + + /** + * The inequality operator. The opposite to the equality operator. + * + * @param [in] other Another instance of GalaxyID to compare to. + * @return false if the instances are equal, true otherwise. + */ + bool operator!=(const GalaxyID& other) const + { + return !(*this == other); + } + + /** + * Checks if the ID is valid and is assigned to an entity. + * + * @return true if the ID is valid, false otherwise. + */ + bool IsValid() const + { + return value != UNASSIGNED_VALUE; + } + + /** + * Returns the numerical value of the ID. + * + * @remark The value comprises the real ID and possibly some extra flags that + * can be used e.g. for type-checking, which can be changed in the future. + * If you need the value in the same form as the one used in Galaxy web services, + * i.e. without any additional flags, use the GetRealID() method instead. + * + * @return The numerical value of the ID, valid only when the ID is valid. + */ + uint64_t ToUint64() const + { + return value; + } + + /** + * Returns the numerical value of the real ID, without any extra flags. + * + * @remark The value is of the same form as the one used in Galaxy web services. + * + * @return The numerical value of the ID, valid only when the ID is valid. + */ + uint64_t GetRealID() const + { + return value & 0xffffffffffffff; + } + + /** + * Returns the type of the ID. + * + * @return The type of the ID. + */ + IDType GetIDType() const + { + return static_cast(value >> 56); + } + + private: + + uint64_t value; ///< The numerical value of the ID. + }; + +#pragma pack( pop ) + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/IApps.h b/Source/DLLs/1.113.3/galaxy/IApps.h new file mode 100644 index 00000000..713cfc3f --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/IApps.h @@ -0,0 +1,70 @@ +#ifndef GALAXY_I_APPS_H +#define GALAXY_I_APPS_H + +/** + * @file + * Contains data structures and interfaces related to application activities. + */ + +#include "IListenerRegistrar.h" + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + /** + * The ID of the DLC. + */ + typedef uint64_t ProductID; + + /** + * The interface for managing application activities. + * + * @remark This interface is fully functional in any situation when + * IGalaxy::Init() reports an error. + */ + class IApps + { + public: + + virtual ~IApps() + { + } + + /** + * Checks if specified DLC is installed. + * + * @param [in] productID The ID of the DLC to check. + * @return true if specified DLC is installed, false otherwise. + */ + virtual bool IsDlcInstalled(ProductID productID) = 0; + + /** + * Returns current game language for given product ID. + * + * @param [in] productID The ID of the game or DLC to check. + * @return current game language for given product ID. + */ + virtual const char* GetCurrentGameLanguage(ProductID productID = 0) = 0; + + /** + * Copies the current game language for given product ID to a buffer. + * + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + * @param [in] productID The ID of the game or DLC to check. + * @return current game language for given product ID. + */ + virtual void GetCurrentGameLanguageCopy(char* buffer, uint32_t bufferLength, ProductID productID = 0) = 0; + }; + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/IChat.h b/Source/DLLs/1.113.3/galaxy/IChat.h new file mode 100644 index 00000000..4f9d213b --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/IChat.h @@ -0,0 +1,316 @@ +#ifndef GALAXY_I_CHAT_H +#define GALAXY_I_CHAT_H + +/** + * @file + * Contains data structures and interfaces related to chat communication + * with other Galaxy Users. + */ + +#include "IListenerRegistrar.h" +#include "GalaxyID.h" + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + /** + * The ID of a chat room. + */ + typedef uint64_t ChatRoomID; + + /** + * Global ID of a chat message. + */ + typedef uint64_t ChatMessageID; + + /** + * The type of a chat message. + */ + enum ChatMessageType + { + CHAT_MESSAGE_TYPE_UNKNOWN = 0, ///< Unknown message type. + CHAT_MESSAGE_TYPE_CHAT_MESSAGE = 1, ///< Chat message. + CHAT_MESSAGE_TYPE_GAME_INVITATION = 2 ///< Game invitation. + }; + + /** + * Listener for the event of retrieving a chat room with a specified user. + */ + class IChatRoomWithUserRetrieveListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of retrieving a chat room with a specified user. + * + * @param [in] userID The ID of the user with whom a chat room was requested. + * @param [in] chatRoomID The ID of the retrieved chat room. + */ + virtual void OnChatRoomWithUserRetrieveSuccess(GalaxyID userID, ChatRoomID chatRoomID) = 0; + + /** + * The reason of a failure in retrieving a chat room with a specified user. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED, ///< Unspecified error. + FAILURE_REASON_FORBIDDEN ///< Communication with a specified user is not allowed. + }; + + /** + * Notification for the event of a failure in retrieving a chat room with a specified user. + * + * @param [in] userID The ID of the user with whom a chat room was requested. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnChatRoomWithUserRetrieveFailure(GalaxyID userID, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of IChatRoomWithUserRetrieveListener. + */ + typedef SelfRegisteringListener GlobalChatRoomWithUserRetrieveListener; + + /** + * Listener for the event of sending a chat room message. + */ + class IChatRoomMessageSendListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of sending a chat room message. + * + * @param [in] chatRoomID The ID of the chat room. + * @param [in] sentMessageIndex The internal index of the sent message. + * @param [in] messageID The ID of the sent message. + * @param [in] sendTime The time at which the message was sent. + */ + virtual void OnChatRoomMessageSendSuccess(ChatRoomID chatRoomID, uint32_t sentMessageIndex, ChatMessageID messageID, uint32_t sendTime) = 0; + + /** + * The reason of a failure in sending a message to a chat room. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED, ///< Unspecified error. + FAILURE_REASON_FORBIDDEN ///< Sending messages to the chat room is forbidden for the user. + }; + + /** + * Notification for the event of a failure in sending a message to a chat room. + * + * @param [in] chatRoomID The ID of the chat room. + * @param [in] sentMessageIndex The internal index of the sent message. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnChatRoomMessageSendFailure(ChatRoomID chatRoomID, uint32_t sentMessageIndex, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of ILobbyMessageListener. + */ + typedef SelfRegisteringListener GlobalChatRoomMessageSendListener; + + /** + * Listener for the event of receiving chat room messages. + */ + class IChatRoomMessagesListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of receiving chat room messages. + * + * In order to read subsequent messages, call IChat::GetChatRoomMessageByIndex(). + * + * @remark First invocation of this notification initiates the dialog + * in the specified chat room on the receiving side. Chat room data is + * available at the time this notification comes. + * + * @param [in] chatRoomID The ID of the chat room. + * @param [in] messageCount The amount of messages received in the chat room. + * @param [in] longestMessageLenght The length of the longest message. + */ + virtual void OnChatRoomMessagesReceived(ChatRoomID chatRoomID, uint32_t messageCount, uint32_t longestMessageLenght) = 0; + }; + + /** + * Globally self-registering version of IChatRoomMessagesListener. + */ + typedef SelfRegisteringListener GlobalChatRoomMessagesListener; + + /** + * Listener for the event of retrieving chat room messages in a specified chat room. + */ + class IChatRoomMessagesRetrieveListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of retrieving chat room messages in a specified chat room. + * + * In order to read subsequent messages, call IChat::GetChatRoomMessageByIndex(). + * + * @param [in] chatRoomID The ID of the chat room. + * @param [in] messageCount The amount of messages received in the chat room. + * @param [in] longestMessageLenght The length of the longest message. + */ + virtual void OnChatRoomMessagesRetrieveSuccess(ChatRoomID chatRoomID, uint32_t messageCount, uint32_t longestMessageLenght) = 0; + + /** + * The reason of a failure in retrieving chat room messages in a specified chat room. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED, ///< Unspecified error. + FAILURE_REASON_FORBIDDEN ///< Retrieving messages from the chat room is forbidden for the user. + }; + + /** + * Notification for the event of a failure in retrieving chat room messages in a specified chat room. + * + * @param [in] chatRoomID The ID of the chat room. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnChatRoomMessagesRetrieveFailure(ChatRoomID chatRoomID, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of IChatRoomMessagesRetrieveListener. + */ + typedef SelfRegisteringListener GlobalChatRoomMessagesRetrieveListener; + + /** + * The interface for chat communication with other Galaxy Users. + */ + class IChat + { + public: + + virtual ~IChat() + { + } + + /** + * Creates new, or retrieves already existing one-on-one chat room with a specified user. + * + * This call is asynchronous. Response comes to the IChatRoomWithUserRetrieveListener, + * provided that the chat room was created successfully, in which case chat room data + * is immediately available. + * + * @param [in] userID The ID of the interlocutor user. + */ + virtual void RequestChatRoomWithUser(GalaxyID userID) = 0; + + /** + * Retrieves historical messages in a specified chat room. + * + * This call is asynchronous. Response comes to the IChatRoomMessagesRetrieveListener. + * + * The list of retrieved messages contains a limited number of the latest messages + * that were sent prior to the one specified as the optional reference message. + * + * @pre The user must be in the specified chat room in order to retrieve the messages. + * + * @param [in] chatRoomID The ID of the chat room. + * @param [in] limit The maximum number of messages to retrieve or 0 for using default. + * @param [in] referenceMessageID The ID of the oldest of the messages that were already retrieved. + */ + virtual void RequestChatRoomMessages(ChatRoomID chatRoomID, uint32_t limit, ChatMessageID referenceMessageID = 0) = 0; + + /** + * Sends a message to a chat room. + * + * This call is asynchronous. Result of sending message comes to the + * IChatRoomMessageSendListener. If message was sent successfully, + * for all the members in the chat room there comes a notification + * to the IChatRoomMessagesListener. + * + * @remark Internal message index returned by this method should only be used + * to identify sent messages in callbacks that come to the IChatRoomMessageSendListener. + * + * @pre The user needs to be in the chat room in order to send a message to its members. + * + * @param [in] chatRoomID The ID of the chat room. + * @param [in] msg The message to send. + * @return Internal message index. + */ + virtual uint32_t SendChatRoomMessage(ChatRoomID chatRoomID, const char* msg) = 0; + + /** + * Reads an incoming chat room message by index. + * + * This call is non-blocking and operates on the messages available + * in the IChatRoomMessagesListener, thus instantly finishes. + * + * If the buffer that is supposed to take the message is too small, + * the message will be truncated to its size. The size of the longest message + * is provided in the notification about an incoming message from + * IChatRoomMessagesListener::OnChatRoomMessagesReceived(). + * + * @remark This method can be used only inside of IChatRoomMessagesListener::OnChatRoomMessagesReceived(). + * + * @param [in] index Index of the incomming message as an integer in the range of [0, number of messages). + * @param [out] messageID Global ID of the message. + * @param [out] messageType The type of the message. + * @param [out] senderID The ID of the sender of the message. + * @param [out] sendTime The time when the message was sent. + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + * @return Actual message size in bytes. + */ + virtual uint32_t GetChatRoomMessageByIndex(uint32_t index, ChatMessageID& messageID, ChatMessageType& messageType, GalaxyID& senderID, uint32_t& sendTime, char* buffer, uint32_t bufferLength) = 0; + + /** + * Returns the number of users in a specified chat room. + * + * @param [in] chatRoomID The ID of the chat room. + * @return The number of users in the specified chat room. + */ + virtual uint32_t GetChatRoomMemberCount(ChatRoomID chatRoomID) = 0; + + /** + * Returns the GalaxyID of a user in a specified chat room. + * + * @pre The user must be in the specified chat room in order to retrieve the room members. + * + * @param [in] chatRoomID The ID of the chat room. + * @param [in] index Index as an integer in the range of [0, number of chat room members). + * @return The ID of the chat room member. + */ + virtual GalaxyID GetChatRoomMemberUserIDByIndex(ChatRoomID chatRoomID, uint32_t index) = 0; + + /** + * Returns the number of unread messages in a specified chat room. + * + * @pre The user must be in the specified chat room in order to retrieve the message count. + * + * @param [in] chatRoomID The ID of the chat room. + * @return The number of unread messages in the chat room. + */ + virtual uint32_t GetChatRoomUnreadMessageCount(ChatRoomID chatRoomID) = 0; + + /** + * Marks a specified chat room as read. + * + * Marks all the messages in the specified chat room up to the one received last as read. + * + * @remark The user should have read messages in the specified chat room in order to mark it as read. + * + * @param [in] chatRoomID The ID of the chat room. + */ + virtual void MarkChatRoomAsRead(ChatRoomID chatRoomID) = 0; + }; + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/ICustomNetworking.h b/Source/DLLs/1.113.3/galaxy/ICustomNetworking.h new file mode 100644 index 00000000..ea438ed4 --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/ICustomNetworking.h @@ -0,0 +1,195 @@ +#ifndef GALAXY_I_CUSTOM_NETWORKING_H +#define GALAXY_I_CUSTOM_NETWORKING_H + +/** + * @file + * Contains data structures and interfaces related to communicating with custom endpoints. + * @warning This API is experimental and can be changed or removed in following releases. + */ + +#include "IListenerRegistrar.h" + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + /** + * ID of a connection. + */ + typedef uint64_t ConnectionID; + + /** + * Listener for the events related to opening a connection. + */ + class IConnectionOpenListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of a success in opening a connection. + * + * @param [in] connectionString The connection string. + * @param [in] connectionID The ID if the connection. + */ + virtual void OnConnectionOpenSuccess(const char* connectionString, ConnectionID connectionID) = 0; + + /** + * The reason of a failure in opening a connection. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED ///< Unspecified error. + }; + + /** + * Notification for the event of a failure in opening a connection. + * + * @param [in] connectionString The connection string. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnConnectionOpenFailure(const char* connectionString, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of IConnectionOpenListener. + */ + typedef SelfRegisteringListener GlobalConnectionOpenListener; + + /** + * Listener for the event of closing a connection. + * + */ + class IConnectionCloseListener : public GalaxyTypeAwareListener + { + public: + + /** + * The reason of closing a connection. + */ + enum CloseReason + { + CLOSE_REASON_UNDEFINED ///< Unspecified reason. + }; + + /** + * Notification for the event of closing a connection. + * + * @param [in] connectionID The ID if the connection. + * @param [in] closeReason The reason why the connection is being closed. + */ + virtual void OnConnectionClosed(ConnectionID connectionID, CloseReason closeReason) = 0; + }; + + /** + * Globally self-registering version of IConnectionCloseListener. + */ + typedef SelfRegisteringListener GlobalConnectionCloseListener; + + /** + * Listener for the event of receiving data over the connection. + */ + class IConnectionDataListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of receiving data over the connection. + * + * @param [in] connectionID The ID if the connection. + * @param [in] dataSize The amount of new data received (in bytes). + */ + virtual void OnConnectionDataReceived(ConnectionID connectionID, uint32_t dataSize) = 0; + }; + + /** + * Globally self-registering version of IConnectionDataListener. + */ + typedef SelfRegisteringListener GlobalConnectionDataListener; + + /** + * The interface for communicating with a custom endpoint. + */ + class ICustomNetworking + { + public: + + virtual ~ICustomNetworking() + { + } + + /** + * Open a connection with a specific endpoint. + * + * This call is asynchronous. Responses come to the IConnectionOpenListener. + * + * @remark Currently only supported connection string is a WebSocket URL (e.g. ws://example.com:8000/path/to/ws). + * + * @param [in] connectionString The string which contains connection info. + */ + virtual void OpenConnection(const char* connectionString) = 0; + + /** + * Close a connection. + * + * This call is asynchronous. Responses come to the IConnectionCloseListener. + * + * @param [in] connectionID The ID of the connection. + */ + virtual void CloseConnection(ConnectionID connectionID) = 0; + + /** + * Send binary data over a specific connection. + * + * @param [in] connectionID The ID of the connection. + * @param [in] data The data to send. + * @param [in] dataSize The size of the data. + */ + virtual void SendData(ConnectionID connectionID, const void* data, uint32_t dataSize) = 0; + + /** + * Returns the number of bytes in a specific connection incoming buffer. + * + * @param [in] connectionID The ID of the connection. + * @return The number of bytes in the connection incomming buffer. + */ + virtual uint32_t GetAvailableDataSize(ConnectionID connectionID) = 0; + + /** + * Reads binary data received from a specific connection. + * The data that was read this way is left in the connection incomming buffer. + * + * @param [in] connectionID The ID of the connection. + * @param [in, out] dest The buffer to pass the data to. + * @param [in] dataSize The size of the data. + */ + virtual void PeekData(ConnectionID connectionID, void* dest, uint32_t dataSize) = 0; + + /** + * Reads binary data received from a specific connection. + * The data that was read this way is removed from the connection incomming buffer. + * + * @param [in] connectionID The ID of the connection. + * @param [in, out] dest The buffer to pass the data to. + * @param [in] dataSize The size of the data. + */ + virtual void ReadData(ConnectionID connectionID, void* dest, uint32_t dataSize) = 0; + + /** + * Removes a given number of bytes from a specific connection incomming buffer. + * + * @param [in] connectionID The ID of the connection. + * @param [in] dataSize The numbers of bytes to be removed from the buffer. + */ + virtual void PopData(ConnectionID connectionID, uint32_t dataSize) = 0; + }; + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/IFriends.h b/Source/DLLs/1.113.3/galaxy/IFriends.h new file mode 100644 index 00000000..189b0a3d --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/IFriends.h @@ -0,0 +1,878 @@ +#ifndef GALAXY_I_FRIENDS_H +#define GALAXY_I_FRIENDS_H + +/** + * @file + * Contains data structures and interfaces related to social activities. + */ + +#include "GalaxyID.h" +#include "IListenerRegistrar.h" + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + /** + * The type of avatar. + */ + enum AvatarType + { + AVATAR_TYPE_NONE = 0x0000, ///< No avatar type specified. + AVATAR_TYPE_SMALL = 0x0001, ///< Avatar resolution size: 32x32. + AVATAR_TYPE_MEDIUM = 0x0002, ///< Avatar resolution size: 64x64. + AVATAR_TYPE_LARGE = 0x0004 ///< Avatar resolution size: 184x184. + }; + + /** + * The state of the user + */ + enum PersonaState + { + PERSONA_STATE_OFFLINE = 0, ///< User is not currently logged on. + PERSONA_STATE_ONLINE = 1 ///< User is logged on. + }; + + /** + * Listener for the event of changing persona data. + */ + class IPersonaDataChangedListener : public GalaxyTypeAwareListener + { + public: + + /** + * Describes what has changed about a user. + */ + enum PersonaStateChange + { + PERSONA_CHANGE_NONE = 0x0000, ///< No information has changed. + PERSONA_CHANGE_NAME = 0x0001, ///< Persona name has changed. + PERSONA_CHANGE_AVATAR = 0x0002, ///< Avatar, i.e. its URL, has changed. + PERSONA_CHANGE_AVATAR_DOWNLOADED_IMAGE_SMALL = 0x0004, ///< Small avatar image has been downloaded. + PERSONA_CHANGE_AVATAR_DOWNLOADED_IMAGE_MEDIUM = 0x0008, ///< Medium avatar image has been downloaded. + PERSONA_CHANGE_AVATAR_DOWNLOADED_IMAGE_LARGE = 0x0010, ///< Large avatar image has been downloaded. + PERSONA_CHANGE_AVATAR_DOWNLOADED_IMAGE_ANY = PERSONA_CHANGE_AVATAR_DOWNLOADED_IMAGE_SMALL | PERSONA_CHANGE_AVATAR_DOWNLOADED_IMAGE_MEDIUM | PERSONA_CHANGE_AVATAR_DOWNLOADED_IMAGE_LARGE ///< Any avatar images have been downloaded. + }; + + /** + * Notification for the event of changing persona data. + * + * @param [in] userID The ID of the user. + * @param [in] personaStateChange The bit sum of the PersonaStateChange. + */ + virtual void OnPersonaDataChanged(GalaxyID userID, uint32_t personaStateChange) = 0; + }; + + /** + * Globally self-registering version of IPersonaDataChangedListener. + */ + typedef SelfRegisteringListener GlobalPersonaDataChangedListener; + + /** + * Listener for the event of retrieving requested list of friends. + */ + class IFriendListListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of a success in retrieving the user's list of friends. + * + * In order to read subsequent friend IDs, call IFriends::GetFriendCount() and IFriends::GetFriendByIndex(). + */ + virtual void OnFriendListRetrieveSuccess() = 0; + + /** + * The reason of a failure in retrieving the user's list of friends. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED ///< Unspecified error. + }; + + /** + * Notification for the event of a failure in retrieving the user's list of friends. + * + * @param [in] failureReason The cause of the failure. + */ + virtual void OnFriendListRetrieveFailure(FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of IFriendListListener. + */ + typedef SelfRegisteringListener GlobalFriendListListener; + + /** + * Listener for the event of sending a friend invitation. + */ + class IFriendInvitationSendListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of a success in sending a friend invitation. + * + * @param [in] userID The ID of the user to whom the invitation was being sent. + */ + virtual void OnFriendInvitationSendSuccess(GalaxyID userID) = 0; + + /** + * The reason of a failure in sending a friend invitation. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED, ///< Unspecified error. + FAILURE_REASON_USER_DOES_NOT_EXIST, ///< User does not exist. + FAILURE_REASON_USER_ALREADY_INVITED, ///< Friend invitation already sent to the user. + FAILURE_REASON_USER_ALREADY_FRIEND ///< User already on the friend list. + }; + + /** + * Notification for the event of a failure in sending a friend invitation. + * + * @param [in] userID The ID of the user to whom the invitation was being sent. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnFriendInvitationSendFailure(GalaxyID userID, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of IFriendInvitationSendListener. + */ + typedef SelfRegisteringListener GlobalFriendInvitationSendListener; + + /** + * Listener for the event of retrieving requested list of incoming friend invitations. + */ + class IFriendInvitationListRetrieveListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of a success in retrieving the user's list of incoming friend invitations. + * + * In order to read subsequent invitation IDs, call and IFriends::GetFriendInvitationByIndex(). + */ + virtual void OnFriendInvitationListRetrieveSuccess() = 0; + + /** + * The reason of a failure in retrieving the user's list of incoming friend invitations. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED ///< Unspecified error. + }; + + /** + * Notification for the event of a failure in retrieving the user's list of incoming friend invitations. + * + * @param [in] failureReason The cause of the failure. + */ + virtual void OnFriendInvitationListRetrieveFailure(FailureReason failureReason) = 0; + + }; + + /** + * Globally self-registering version of IFriendInvitationListRetrieveListener. + */ + typedef SelfRegisteringListener GlobalFriendInvitationListRetrieveListener; + + /** + * Listener for the event of receiving a friend invitation. + */ + class IFriendInvitationListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of receiving a friend invitation. + * + * @param [in] userID The ID of the user who sent the friend invitation. + * @param [in] sendTime The time at which the friend invitation was sent. + */ + virtual void OnFriendInvitationReceived(GalaxyID userID, uint32_t sendTime) = 0; + }; + + /** + * Globally self-registering version of IFriendInvitationListener. + */ + typedef SelfRegisteringListener GlobalFriendInvitationListener; + + /** + * Listener for the event of responding to a friend invitation. + */ + class IFriendInvitationRespondToListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of a success in responding to a friend invitation. + * + * @param [in] userID The ID of the user who sent the invitation. + * @param [in] accept True when accepting the invitation, false when declining. + */ + virtual void OnFriendInvitationRespondToSuccess(GalaxyID userID, bool accept) = 0; + + /** + * The reason of a failure in responding to a friend invitation. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED, ///< Unspecified error. + FAILURE_REASON_USER_DOES_NOT_EXIST, ///< User does not exist. + FAILURE_REASON_FRIEND_INVITATION_DOES_NOT_EXIST, ///< Friend invitation does not exist. + FAILURE_REASON_USER_ALREADY_FRIEND ///< User already on the friend list. + }; + + /** + * Notification for the event of a failure in responding to a friend invitation. + * + * @param [in] userID The ID of the user who sent the invitation. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnFriendInvitationRespondToFailure(GalaxyID userID, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of IFriendInvitationRespondToListener. + */ + typedef SelfRegisteringListener GlobalFriendInvitationRespondToListener; + + /** + * Listener for the event of a user being added to the friend list. + */ + class IFriendAddListener : public GalaxyTypeAwareListener + { + public: + + /** + * The direction of the invitation that initiated the change in the friend list. + */ + enum InvitationDirection { + INVITATION_DIRECTION_INCOMING, ///< The user indicated in the notification was the inviter. + INVITATION_DIRECTION_OUTGOING ///< The user indicated in the notification was the invitee. + }; + + /** + * Notification for the event of a user being added to the friend list. + * + * @param [in] userID The ID of the user who has just been added to the friend list. + * @param [in] invitationDirection The direction of the invitation that determines the inviter and the invitee. + */ + virtual void OnFriendAdded(GalaxyID userID, InvitationDirection invitationDirection) = 0; + }; + + /** + * Globally self-registering version of IFriendAddListener. + */ + typedef SelfRegisteringListener GlobalFriendAddListener; + + /** + * Listener for the event of removing a user from the friend list. + */ + class IFriendDeleteListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of a success in removing a user from the friend list. + * + * @param [in] userID The ID of the user requested to be removed from the friend list. + */ + virtual void OnFriendDeleteSuccess(GalaxyID userID) = 0; + + /** + * The reason of a failure in removing a user from the friend list. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED ///< Unspecified error. + }; + + /** + * Notification for the event of a failure in removing a user from the friend list. + * + * @param [in] userID The ID of the user requested to be removed from the friend list. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnFriendDeleteFailure(GalaxyID userID, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of IFriendDeleteListener. + */ + typedef SelfRegisteringListener GlobalFriendDeleteListener; + + /** + * Listener for the event of rich presence modification. + */ + class IRichPresenceChangeListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of successful rich presence change. + */ + virtual void OnRichPresenceChangeSuccess() = 0; + + /** + * The reason of a failure in rich presence modification. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED ///< Unspecified error. + }; + + /** + * Notification for the event of failure to modify rich presence. + * + * @param [in] failureReason The cause of the failure. + */ + virtual void OnRichPresenceChangeFailure(FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of IRichPresenceChangeListener. + */ + typedef SelfRegisteringListener GlobalRichPresenceChangeListener; + + /** + * Listener for the event of any user rich presence update. + */ + class IRichPresenceListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of successful rich presence update. + * + * @param [in] userID The ID of the user. + */ + virtual void OnRichPresenceUpdated(GalaxyID userID) = 0; + }; + + /** + * Globally self-registering version of IRichPresenceListener. + */ + typedef SelfRegisteringListener GlobalRichPresenceListener; + + /** + * Event of requesting a game join by user. + * + * This can be triggered by accepting a game invitation + * or by user's request to join a friend's game. + */ + class IGameJoinRequestedListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of accepting a game invitation. + * + * @param [in] userID The ID of the user who sent invitation. + * @param [in] connectionString The string which contains connection info. + */ + virtual void OnGameJoinRequested(GalaxyID userID, const char* connectionString) = 0; + }; + + /** + * Globally self-registering version of IGameJoinRequestedListener. + */ + typedef SelfRegisteringListener GlobalGameJoinRequestedListener; + + /** + * Event of receiving a game invitation. + * + * This can be triggered by receiving connection string. + */ + class IGameInvitationReceivedListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of receiving a game invitation. + * + * @param [in] userID The ID of the user who sent invitation. + * @param [in] connectionString The string which contains connection info. + */ + virtual void OnGameInvitationReceived(GalaxyID userID, const char* connectionString) = 0; + }; + + /** + * Globally self-registering version of IGameInvitationReceivedListener. + */ + typedef SelfRegisteringListener GlobalGameInvitationReceivedListener; + + /** + * Listener for the event of sending an invitation without using the overlay. + */ + class ISendInvitationListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of success in sending an invitation. + * + * @param [in] userID The ID of the user to whom the invitation was being sent. + * @param [in] connectionString The string which contains connection info. + */ + virtual void OnInvitationSendSuccess(GalaxyID userID, const char* connectionString) = 0; + + /** + * The reason of a failure in sending an invitation. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED, ///< Unspecified error. + FAILURE_REASON_USER_DOES_NOT_EXIST, ///< Receiver does not exist. + FAILURE_REASON_RECEIVER_DOES_NOT_ALLOW_INVITING, ///< Receiver does not allow inviting + FAILURE_REASON_SENDER_DOES_NOT_ALLOW_INVITING, ///< Sender does not allow inviting + FAILURE_REASON_RECEIVER_BLOCKED, ///< Receiver blocked by sender. + FAILURE_REASON_SENDER_BLOCKED ///< Sender blocked by receiver. Will also occur if both users blocked each other. + }; + + /** + * Notification for the event of a failure in sending an invitation. + * + * @param [in] userID The ID of the user to whom the invitation was being sent. + * @param [in] connectionString The string which contains connection info. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnInvitationSendFailure(GalaxyID userID, const char* connectionString, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of ISendInvitationListener. + */ + typedef SelfRegisteringListener GlobalSendInvitationListener; + + /** + * Listener for the event of searching a user. + */ + class IUserFindListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of success in finding a user. + * + * @param [in] userSpecifier The user specifier by which user search was performed. + * @param [in] userID The ID of the found user. + */ + virtual void OnUserFindSuccess(const char* userSpecifier, GalaxyID userID) = 0; + + /** + * The reason of a failure in searching a user. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED, ///< Unspecified error. + FAILURE_REASON_USER_NOT_FOUND ///< Specified user was not found. + }; + + /** + * Notification for the event of a failure in finding a user. + * + * @param [in] userSpecifier The user specifier by which user search was performed. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnUserFindFailure(const char* userSpecifier, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of IUserFindListener. + */ + typedef SelfRegisteringListener GlobalUserFindListener; + + /** + * The interface for managing social info and activities. + */ + class IFriends + { + public: + + virtual ~IFriends() + { + } + + /** + * Performs a request for information about specified user. + * + * This call is asynchronous. Responses come to the IPersonaDataChangedListener. + * + * @remark This call is performed automatically for friends (after requesting the list + * of friends) and fellow lobby members (after entering a lobby or getting a notification + * about some other user joining it), therefore in many cases there is no need for you + * to call it manually and all you should do is wait for the appropriate callback + * to come to the IPersonaDataChangedListener. + * + * @param [in] userID The ID of the user. + * @param [in] avatarCriteria The bit sum of the AvatarType. + */ + virtual void RequestUserInformation(GalaxyID userID, uint32_t avatarCriteria = AVATAR_TYPE_NONE) = 0; + + /** + * Checks if the information of specified user is available. + * + * @pre Retrieve the information by calling RequestUserInformation(). + * + * @param [in] userID The ID of the user. + * @return true if the information of the user is available, false otherwise. + */ + virtual bool IsUserInformationAvailable(GalaxyID userID) = 0; + + /** + * Returns the user's nickname. + * + * @remark This call is not thread-safe as opposed to GetPersonaNameCopy(). + * + * @return The nickname of the user. + */ + virtual const char* GetPersonaName() = 0; + + /** + * Copies the user's nickname to a buffer. + * + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + */ + virtual void GetPersonaNameCopy(char* buffer, uint32_t bufferLength) = 0; + + /** + * Returns the user's state. + * + * @return The state of the user. + */ + virtual PersonaState GetPersonaState() = 0; + + /** + * Returns the nickname of a specified user. + * + * @remark This call is not thread-safe as opposed to GetFriendPersonaNameCopy(). + * + * @pre You might need to retrieve the data first by calling RequestUserInformation(). + * + * @param [in] userID The ID of the user. + * @return The nickname of the user. + */ + virtual const char* GetFriendPersonaName(GalaxyID userID) = 0; + + /** + * Copies the nickname of a specified user. + * + * @pre You might need to retrieve the data first by calling RequestUserInformation(). + * + * @param [in] userID The ID of the user. + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + */ + virtual void GetFriendPersonaNameCopy(GalaxyID userID, char* buffer, uint32_t bufferLength) = 0; + + /** + * Returns the state of a specified user. + * + * @pre You might need to retrieve the data first by calling RequestUserInformation(). + * + * @param [in] userID The ID of the user. + * @return The state of the user. + */ + virtual PersonaState GetFriendPersonaState(GalaxyID userID) = 0; + + /** + * Returns the URL of the avatar of a specified user. + * + * @remark This call is not thread-safe as opposed to GetFriendAvatarUrlCopy(). + * + * @pre You might need to retrieve the data first by calling RequestUserInformation(). + * + * @param [in] userID The ID of the user. + * @param [in] avatarType The type of avatar. + * @return The URL of the avatar. + */ + virtual const char* GetFriendAvatarUrl(GalaxyID userID, AvatarType avatarType) = 0; + + /** + * Copies URL of the avatar of a specified user. + * + * @pre You might need to retrieve the data first by calling RequestUserInformation(). + * + * @param [in] userID The ID of the user. + * @param [in] avatarType The type of avatar. + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + */ + virtual void GetFriendAvatarUrlCopy(GalaxyID userID, AvatarType avatarType, char* buffer, uint32_t bufferLength) = 0; + + /** + * Returns the ID of the avatar of a specified user. + * + * @pre Retrieve the avatar image first by calling RequestUserInformation() + * with appropriate avatar criteria. + * + * @param [in] userID The ID of the user. + * @param [in] avatarType The type of avatar. + * @return The ID of the avatar image. + */ + virtual uint32_t GetFriendAvatarImageID(GalaxyID userID, AvatarType avatarType) = 0; + + /** + * Copies the avatar of a specified user. + * + * @pre Retrieve the avatar image first by calling RequestUserInformation() + * with appropriate avatar criteria. + * + * @pre The size of the output buffer should be 4 * height * width * sizeof(char). + * + * @param [in] userID The ID of the user. + * @param [in] avatarType The type of avatar. + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + */ + virtual void GetFriendAvatarImageRGBA(GalaxyID userID, AvatarType avatarType, unsigned char* buffer, uint32_t bufferLength) = 0; + + /** + * Checks if a specified avatar image is available. + * + * @param [in] userID The ID of the user. + * @param [in] avatarType The type of avatar. + * @return true if the specified avatar image is available, false otherwise. + */ + virtual bool IsFriendAvatarImageRGBAAvailable(GalaxyID userID, AvatarType avatarType) = 0; + + /** + * Performs a request for the user's list of friends. + * + * This call is asynchronous. Responses come to the IFriendListListener. + */ + virtual void RequestFriendList() = 0; + + /** + * Checks if a specified user is a friend. + * + * @pre Retrieve the list of friends first by calling RequestFriendList(). + * + * @param [in] userID The ID of the user. + * @return true if the specified user is a friend, false otherwise. + */ + virtual bool IsFriend(GalaxyID userID) = 0; + + /** + * Returns the number of retrieved friends in the user's list of friends. + * + * @pre Retrieve the list of friends first by calling RequestFriendList(). + * + * @return The number of retrieved friends, or 0 if failed. + */ + virtual uint32_t GetFriendCount() = 0; + + /** + * Returns the GalaxyID for a friend. + * + * @pre Retrieve the list of friends first by calling RequestFriendList(). + * + * @param [in] index Index as an integer in the range of [0, number of friends). + * @return The GalaxyID of the friend. + */ + virtual GalaxyID GetFriendByIndex(uint32_t index) = 0; + + /** + * Sends a friend invitation. + * + * This call is asynchronous. Responses come to the IFriendInvitationSendListener. + * + * @param [in] userID The ID of the user. + */ + virtual void SendFriendInvitation(GalaxyID userID) = 0; + + /** + * Performs a request for the user's list of incoming friend invitations. + * + * This call is asynchronous. Responses come to the IFriendInvitationsListRetrieveListener. + */ + virtual void RequestFriendInvitationList() = 0; + + /** + * Returns the number of retrieved friend invitations. + * + * @remark This function can be used only in IFriendInvitationListRetrieveListener callback. + * + * @return The number of retrieved friend invitations, or 0 if failed. + */ + virtual uint32_t GetFriendInvitationCount() = 0; + + /** + * Reads the details of the friend invitation. + * + * @remark This function can be used only in IFriendInvitationListRetrieveListener callback. + * + * @param [in] index Index as an integer in the range of [0, number of friend invitations). + * @param [out] userID The ID of the user who sent the invitation. + * @param [out] sendTime The time at which the friend invitation was sent. + */ + virtual void GetFriendInvitationByIndex(uint32_t index, GalaxyID& userID, uint32_t& sendTime) = 0; + + /** + * Responds to the friend invitation. + * + * This call is asynchronous. Responses come to the IFriendInvitationRespondToListener. + * + * @param [in] userID The ID of the user who sent the friend invitation. + * @param [in] accept True when accepting the invitation, false when declining. + */ + virtual void RespondToFriendInvitation(GalaxyID userID, bool accept) = 0; + + /** + * Removes a user from the friend list. + * + * This call in asynchronous. Responses come to the IFriendDeleteListener. + * + * @param [in] userID The ID of the user to be removed from the friend list. + */ + virtual void DeleteFriend(GalaxyID userID) = 0; + + /** + * Sets the variable value under a specified name. + * + * There are three keys that can be used: + * - "status" - The description visible in Galaxy Client with the limit of 3000 bytes. + * - "metadata" - The metadata that describes the status to other instances of the game with the limit of 2048 bytes. + * - "connect" - The string which contains connection info with the limit of 4095 bytes. + * It can be regarded as a passive version of IFriends::SendInvitation() because + * it allows friends that notice the rich presence to join a multiplayer game. + * + * Passing NULL value removes the entry. + * + * This call in asynchronous. Responses come to the IRichPresenceChangeListener. + * + * @param [in] key The name of the property of the user's rich presence. + * @param [in] value The value of the property to set. + */ + virtual void SetRichPresence(const char* key, const char* value) = 0; + + /** + * Removes the variable value under a specified name. + * + * If the variable doesn't exist method call has no effect. + * + * This call in asynchronous. Responses come to the IRichPresenceChangeListener. + * + * @param [in] key The name of the variable to be removed. + */ + virtual void DeleteRichPresence(const char* key) = 0; + + /** + * Removes all rich presence data for the user. + * + * This call in asynchronous. Responses come to the IRichPresenceChangeListener. + */ + virtual void ClearRichPresence() = 0; + + /** + * Performs a request for the user's rich presence. + * + * This call is asynchronous. Responses come to the IRichPresenceListener. + * + * @param [in] userID The ID of the user. + */ + virtual void RequestRichPresence(GalaxyID userID = GalaxyID()) = 0; + + /** + * Returns the rich presence of a specified user. + * + * @remark This call is not thread-safe as opposed to GetRichPresenceCopy(). + * + * @pre Retrieve the rich presence first by calling RequestRichPresence(). + * + * @param [in] userID The ID of the user. + * @param [in] key The name of the property of the user's rich presence. + * @return The rich presence of the user. + */ + virtual const char* GetRichPresence(const char* key, GalaxyID userID = GalaxyID()) = 0; + + /** + * Copies the rich presence of a specified user to a buffer. + * + * @pre Retrieve the rich presence first by calling RequestRichPresence(). + * + * @param [in] key The name of the property of the user's rich presence. + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + * @param [in] userID The ID of the user. + */ + virtual void GetRichPresenceCopy(const char* key, char* buffer, uint32_t bufferLength, GalaxyID userID = GalaxyID()) = 0; + + /** + * Returns the number of retrieved properties in user's rich presence. + * + * @param [in] userID The ID of the user. + * @return The number of retrieved keys, or 0 if failed. + */ + virtual uint32_t GetRichPresenceCount(GalaxyID userID = GalaxyID()) = 0; + + /** + * Returns a property from the rich presence storage by index. + * + * @pre Retrieve the rich presence first by calling RequestRichPresence(). + * + * @param [in] index Index as an integer in the range of [0, number of entries). + * @param [in, out] key The name of the property of the rich presence storage. + * @param [in] keyLength The length of the name of the property of the rich presence storage. + * @param [in, out] value The value of the property of the rich presence storage. + * @param [in] valueLength The length of the value of the property of the rich presence storage. + * @param [in] userID The ID of the user. + * @return true if succeeded, false when there is no such property. + */ + virtual bool GetRichPresenceByIndex(uint32_t index, char* key, uint32_t keyLength, char* value, uint32_t valueLength, GalaxyID userID = GalaxyID()) = 0; + + /** + * Shows game invitation dialog that allows to invite users to game. + * + * If invited user accepts the invitation, the connection string + * gets added to the command-line parameters for launching the game. + * If the game is already running, the connection string comes + * to the IGameJoinRequestedListener instead. + * + * @pre For this call to work, the overlay needs to be initialized first. + * To check whether the overlay is initialized, call IUtils::GetOverlayState(). + * + * @param [in] connectionString The string which contains connection info with the limit of 4095 bytes. + */ + virtual void ShowOverlayInviteDialog(const char* connectionString) = 0; + + /** + * Sends a game invitation without using the overlay. + * + * If invited user accepts the invitation, the connection string + * gets added to the command-line parameters for launching the game. + * If the game is already running, the connection string comes + * to the IGameJoinRequestedListener instead. + * + * @param [in] userID The ID of the user. + * @param [in] connectionString The string which contains connection info with the limit of 4095 bytes. + */ + virtual void SendInvitation(GalaxyID userID, const char* connectionString) = 0; + + /** + * Finds a specified user. + * + * This call is asynchronous. Responses come to the IUserSearchListener. + * + * Searches for the user given either a username or an email address. + * Only exact match will be returned. + * + * @param [in] userSpecifier The specifier of the user. + */ + virtual void FindUser(const char* userSpecifier) = 0; + }; + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/IGalaxy.h b/Source/DLLs/1.113.3/galaxy/IGalaxy.h new file mode 100644 index 00000000..0538b1b6 --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/IGalaxy.h @@ -0,0 +1,254 @@ +#ifndef GALAXY_I_GALAXY_H +#define GALAXY_I_GALAXY_H + +/** + * @file + * Contains IGalaxy, which is the main interface for controlling the Galaxy + * Peer. + */ + +#include "GalaxyExport.h" + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + class IUser; + class IFriends; + class IChat; + class IMatchmaking; + class INetworking; + class IStats; + class IUtils; + class IApps; + class IStorage; + class ICustomNetworking; + class IListenerRegistrar; + class ILogger; + class IError; + + /** + * The group of options used for Init configuration. + */ + struct InitOptions + { + /** + * InitOptions constructor. + * + * @param [in] _clientID The ID of the client. + * @param [in] _clientSecret The secret of the client. + * @param [in] _galaxyPeerPath Path to the galaxyPeer library location. + * @param [in] _throwExceptions Indicates if Galaxy should throw exceptions. + * @param [in] _configFilePath The path to folder which contains configuration files. + */ + InitOptions(const char* _clientID, const char* _clientSecret, const char* _galaxyPeerPath = "", bool _throwExceptions = true, const char* _configFilePath = ".") + : throwExceptions(_throwExceptions) + , clientID(_clientID) + , clientSecret(_clientSecret) + , galaxyPeerPath(_galaxyPeerPath) + , configFilePath(_configFilePath) + { + } + + const bool throwExceptions; ///< Indicates if Galaxy should throw exceptions. + const char* clientID; ///< The ID of the client. + const char* clientSecret; ///< The secret of the client. + const char* galaxyPeerPath; ///< Path to the galaxyPeer library location. + const char* configFilePath; ///< The path to folder which contains configuration files. + }; + + /** + * The main interface for controlling the Galaxy Peer. + */ + class GALAXY_DLL_EXPORT IGalaxy + { + public: + + virtual ~IGalaxy() + { + } + + /** + * Initializes the Galaxy Peer with specified credentials. + * + * @remark When you do not need the Galaxy Peer anymore, you should call + * Shutdown() in order to deactivate it and free its resources. + * + * @remark This method can succeed partially, in which case it leaves + * Galaxy Peer partially functional, hence even in case of an error, be + * sure to call Shutdown() when you do not need the Galaxy Peer anymore. + * See the documentation of specific interfaces on how they behave. + * + * @param [in] clientID The ID of the client. + * @param [in] clientSecret The secret of the client. + * @param [in] throwExceptions Indicates if Galaxy should throw exceptions. + */ + virtual void Init(const char* clientID, const char* clientSecret, bool throwExceptions = true) = 0; + + /** + * Initializes the Galaxy Peer with specified credentials. + * + * @remark When you do not need the Galaxy Peer anymore, you should call + * Shutdown() in order to deactivate it and free its resources. + * + * @remark This method can succeed partially, in which case it leaves + * Galaxy Peer partially functional, hence even in case of an error, be + * sure to call Shutdown() when you do not need the Galaxy Peer anymore. + * See the documentation of specific interfaces on how they behave. + * + * @param [in] initOptions The group of the init options. + */ + virtual void Init(const InitOptions& initOptions) = 0; + + /** + * Initializes the Galaxy Peer with specified credentials. + * + * @warning This method allows for using local Galaxy Peer library + * instead of the one provided by the desktop service Galaxy Client. + * In the future the method will be removed and loading of the library + * will rely solely on the desktop service. + * + * @remark When you do not need the Galaxy Peer anymore, you should call + * Shutdown() in order to deactivate it and free its resources. + * + * @remark This method can succeed partially, in which case it leaves + * Galaxy Peer partially functional, hence even in case of an error, be + * sure to call Shutdown() when you do not need the Galaxy Peer anymore. + * See the documentation of specific interfaces on how they behave. + * + * @param [in] clientID The ID of the client. + * @param [in] clientSecret The secret of the client. + * @param [in] galaxyPeerPath Path to the galaxyPeer library location. + * @param [in] throwExceptions indicates if Galaxy should throw exceptions. + */ + virtual void InitLocal(const char* clientID, const char* clientSecret, const char* galaxyPeerPath = ".", bool throwExceptions = true) = 0; + + /** + * Shuts down the Galaxy Peer. + * + * The Galaxy Peer is deactivated and brought to the state it had when it + * was created and before it was initialized. + * + * @pre Delete all self-registering listeners before calling Shutdown(). + */ + virtual void Shutdown() = 0; + + /** + * Returns an instance of IUser. + * + * @return An instance of IUser. + */ + virtual IUser* GetUser() const = 0; + + /** + * Returns an instance of IFriends. + * + * @return An instance of IFriends. + */ + virtual IFriends* GetFriends() const = 0; + + /** + * Returns an instance of IChat. + * + * @return An instance of IChat. + */ + virtual IChat* GetChat() const = 0; + + /** + * Returns an instance of IMatchmaking. + * + * @return An instance of IMatchmaking. + */ + virtual IMatchmaking* GetMatchmaking() const = 0; + + /** + * Returns an instance of INetworking that allows to communicate + * as a regular lobby member. + * + * @return An instance of INetworking. + */ + virtual INetworking* GetNetworking() const = 0; + + /** + * Returns an instance of INetworking that allows to communicate + * as the lobby host. + * + * @return An instance of INetworking. + */ + virtual INetworking* GetServerNetworking() const = 0; + + /** + * Returns an instance of IStats. + * + * @return An instance of IStats. + */ + virtual IStats* GetStats() const = 0; + + /** + * Returns an instance of IUtils. + * + * @return An instance of IUtils. + */ + virtual IUtils* GetUtils() const = 0; + + /** + * Returns an instance of IApps. + * + * @return An instance of IApps. + */ + virtual IApps* GetApps() const = 0; + + /** + * Returns an instance of IStorage. + * + * @return An instance of IStorage. + */ + virtual IStorage* GetStorage() const = 0; + + /** + * Returns an instance of ICustomNetworking. + * + * @return An instance of ICustomNetworking. + */ + virtual ICustomNetworking* GetCustomNetworking() const = 0; + + /** + * Returns an instance of IListenerRegistrar. + * + * @return An instance of IListenerRegistrar. + */ + virtual IListenerRegistrar* GetListenerRegistrar() const = 0; + + /** + * Returns an instance of ILogger. + * + * @return An instance of ILogger. + */ + virtual ILogger* GetLogger() const = 0; + + /** + * Makes the Galaxy Peer process its input and output streams. + * + * During the phase of processing data, Galaxy Peer recognizes specific + * events and casts notifications for callback listeners immediately. + */ + virtual void ProcessData() = 0; + + /** + * Retrieves error connected with the last API call. + * + * @return Either the last API call error or NULL if there was no error. + */ + virtual const IError* GetError() const = 0; + }; + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/IListenerRegistrar.h b/Source/DLLs/1.113.3/galaxy/IListenerRegistrar.h new file mode 100644 index 00000000..51e54564 --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/IListenerRegistrar.h @@ -0,0 +1,206 @@ +#ifndef GALAXY_I_LISTENER_REGISTRAR_H +#define GALAXY_I_LISTENER_REGISTRAR_H + +/** + * @file + * Contains data structures and interfaces related to callback listeners. + */ + +#include "GalaxyFactory.h" +#include "stdint.h" +#include + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + /** + * Listener type. Used when registering or unregistering instances of listeners. + * + * Specific listener interfaces are type-aware, i.e. they provide a convenience + * method that returns their type. + */ + enum ListenerType + { + LISTENER_TYPE_BEGIN, ///< Used for iterating over listener types. + LOBBY_LIST = LISTENER_TYPE_BEGIN, ///< Used by ILobbyListListener. + LOBBY_CREATED, ///< Used by ILobbyCreatedListener. + LOBBY_ENTERED, ///< Used by ILobbyEnteredListener. + LOBBY_LEFT, ///< Used by ILobbyLeftListener. + LOBBY_DATA, ///< Used by ILobbyDataListener. + LOBBY_MEMBER_STATE, ///< Used by ILobbyMemberStateListener. + LOBBY_OWNER_CHANGE, ///< Used by ILobbyOwnerChangeListener. + AUTH, ///< Used by IAuthListener. + LOBBY_MESSAGE, ///< Used by ILobbyMessageListener. + NETWORKING, ///< Used by INetworkingListener. + SERVER_NETWORKING, ///< Used by IServerNetworkingListener. + USER_DATA, ///< Used by IUserDataListener. + USER_STATS_AND_ACHIEVEMENTS_RETRIEVE, ///< Used by IUserStatsAndAchievementsRetrieveListener. + STATS_AND_ACHIEVEMENTS_STORE, ///< Used by IStatsAndAchievementsStoreListener. + ACHIEVEMENT_CHANGE, ///< Used by IAchievementChangeListener. + LEADERBOARDS_RETRIEVE, ///< Used by ILeaderboardsRetrieveListener. + LEADERBOARD_ENTRIES_RETRIEVE, ///< Used by ILeaderboardEntriesRetrieveListener. + LEADERBOARD_SCORE_UPDATE_LISTENER, ///< Used by ILeaderboardScoreUpdateListener. + PERSONA_DATA_CHANGED, ///< Used by IPersonaDataChangedListener. + RICH_PRESENCE_CHANGE_LISTENER, ///< Used by IRichPresenceChangeListener. + GAME_JOIN_REQUESTED_LISTENER, ///< Used by IGameJoinRequested. + OPERATIONAL_STATE_CHANGE, ///< Used by IOperationalStateChangeListener. + _OVERLAY_STATE_CHANGE, ///< Used by IOverlayStateChangeListener. @deprecated Replaced with OVERLAY_VISIBILITY_CHANGE + FRIEND_LIST_RETRIEVE, ///< Used by IFriendListListener. + ENCRYPTED_APP_TICKET_RETRIEVE, ///< Used by IEncryptedAppTicketListener. + ACCESS_TOKEN_CHANGE, ///< Used by IAccessTokenListener. + LEADERBOARD_RETRIEVE, ///< Used by ILeaderboardRetrieveListener. + SPECIFIC_USER_DATA, ///< Used by ISpecificUserDataListener. + INVITATION_SEND, ///< Used by ISendInvitationListener. + RICH_PRESENCE_LISTENER, ///< Used by IRichPresenceListener. + GAME_INVITATION_RECEIVED_LISTENER, ///< Used by IGameInvitationReceivedListener. + NOTIFICATION_LISTENER, ///< Used by INotificationListener. + LOBBY_DATA_RETRIEVE, ///< Used by ILobbyDataRetrieveListener. + USER_TIME_PLAYED_RETRIEVE, ///< Used by IUserTimePlayedRetrieveListener. + OTHER_SESSION_START, ///< Used by IOtherSessionStartListener. + _STORAGE_SYNCHRONIZATION, ///< Used by IStorageSynchronizationListener. @deprecated Synchronization is performed solely by Galaxy Client. + FILE_SHARE, ///< Used by IFileShareListener. + SHARED_FILE_DOWNLOAD, ///< Used by ISharedFileDownloadListener. + CUSTOM_NETWORKING_CONNECTION_OPEN, ///< Used by IConnectionOpenListener. + CUSTOM_NETWORKING_CONNECTION_CLOSE, ///< Used by IConnectionCloseListener. + CUSTOM_NETWORKING_CONNECTION_DATA, ///< Used by IConnectionDataListener. + OVERLAY_INITIALIZATION_STATE_CHANGE, ///< Used by IOverlayInitializationStateChangeListener. + OVERLAY_VISIBILITY_CHANGE, ///< Used by IOverlayVisibilityChangeListener. + CHAT_ROOM_WITH_USER_RETRIEVE_LISTENER, ///< Used by IChatRoomWithUserRetrieveListener. + CHAT_ROOM_MESSAGE_SEND_LISTENER, ///< Used by IChatRoomMessageSendListener. + CHAT_ROOM_MESSAGES_LISTENER, ///< Used by IChatRoomMessagesListener. + FRIEND_INVITATION_SEND_LISTENER, ///< Used by IFriendInvitationSendListener. + FRIEND_INVITATION_LIST_RETRIEVE_LISTENER, ///< Used by IFriendInvitationListRetrieveListener. + FRIEND_INVITATION_LISTENER, ///< Used by IFriendInvitationListener. + FRIEND_INVITATION_RESPOND_TO_LISTENER, ///< Used by IFriendInvitationRespondToListener. + FRIEND_ADD_LISTENER, ///< Used by IFriendAddListener. + FRIEND_DELETE_LISTENER, ///< Used by IFriendDeleteListener. + CHAT_ROOM_MESSAGES_RETRIEVE_LISTENER, ///< Used by IChatRoomMessagesRetrieveListener. + USER_FIND_LISTENER, ///< Used by IUserFindListener. + NAT_TYPE_DETECTION, ///< Used by INatTypeDetectionListener. + LISTENER_TYPE_END ///< Used for iterating over listener types. + }; + + /** + * The interface that is implemented by all specific callback listeners. + */ + class IGalaxyListener + { + public: + + virtual ~IGalaxyListener() + { + } + }; + + /** + * The class that is inherited by all specific callback listeners and provides + * a static method that returns the type of the specific listener. + */ + template class GalaxyTypeAwareListener : public IGalaxyListener + { + public: + + /** + * Returns the type of the listener. + * + * @return The type of the listener. A value of ListenerType. + */ + static uint32_t GetListenerType() + { + return type; + } + }; + + /** + * The class that enables and disables global registration of the instances of + * specific listeners. You can either use it explicitly, or implicitly by + * inheriting from a self-registering basic listener of desired type. + */ + class IListenerRegistrar + { + public: + + virtual ~IListenerRegistrar() + { + } + + /** + * Globally registers a callback listener that inherits from IGalaxyListener + * and is of any of the standard listener types specified in ListenerType. + * + * @remark Call Unregister() for all registered listeners before calling + * IGalaxy::Shutdown(). + * + * @param [in] listenerType The type of the listener. A value of ListenerType. + * @param [in] listener The specific listener of the specified type. + */ + virtual void Register(uint32_t listenerType, IGalaxyListener* listener) = 0; + + /** + * Unregisters a listener previously globally registered with Register(). + * + * @param [in] listenerType The type of the listener. A value of ListenerType. + * @param [in] listener The specific listener of the specified type. + */ + virtual void Unregister(uint32_t listenerType, IGalaxyListener* listener) = 0; + }; + + /** + * The class that is inherited by the self-registering versions of all specific + * callback listeners. An instance of a listener that derives from it + * automatically globally registers itself for proper callback notifications, + * and unregisters when destroyed, which is done with IListenerRegistrar. + */ + template class SelfRegisteringListener : public _TypeAwareListener + { + public: + + /** + * Creates an instance of SelfRegisteringListener and registers it with the + * IListenerRegistrar provided by Galaxy Peer. + * + * @remark You can provide a custom IListenerRegistrar, yet that would + * not make the listener visible for Galaxy Peer. For that the listener + * needs to be registered with the IListenerRegistrar of Galaxy Peer. + * + * @remark Delete all registered listeners before calling + * IGalaxy::Shutdown(). + * + * @param [in] _registrar The instance of IListenerRegistrar to use for registering and unregistering. Defaults to the one provided by Galaxy Peer. + */ + SelfRegisteringListener(IListenerRegistrar* _registrar = NULL) + : registrar(_registrar) + { + IListenerRegistrar* tmpRegistrar = registrar ? registrar : GalaxyFactory::GetInstance()->GetListenerRegistrar(); + if (tmpRegistrar) + tmpRegistrar->Register(_TypeAwareListener::GetListenerType(), this); + } + + /** + * Destroys the instance of SelfRegisteringListener and unregisters it with + * the instance of IListenerRegistrar that was used to register the + * listener when it was created. + */ + ~SelfRegisteringListener() + { + IListenerRegistrar* tmpRegistrar = registrar ? registrar : GalaxyFactory::GetInstance()->GetListenerRegistrar(); + if (tmpRegistrar) + tmpRegistrar->Unregister(_TypeAwareListener::GetListenerType(), this); + } + + private: + + IListenerRegistrar* registrar; ///< The instance of IListenerRegistrar that was used to register the listener when it was created. + }; + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/ILogger.h b/Source/DLLs/1.113.3/galaxy/ILogger.h new file mode 100644 index 00000000..572878cf --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/ILogger.h @@ -0,0 +1,82 @@ +#ifndef GALAXY_I_LOGGER_H +#define GALAXY_I_LOGGER_H + +/** + * @file + * Contains data structures and interfaces related to logging. + */ + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + /** + * The interface for logging. + */ + class ILogger + { + public: + + virtual ~ILogger() + { + } + + /** + * Creates a log entry with level TRACE. + * + * @param [in] format Format string. + * @param [in] ... Parameters for the format string. + */ + virtual void Trace(const char* format, ...) = 0; + + /** + * Creates a log entry with level DEBUG. + * + * @param [in] format Format string. + * @param [in] ... Parameters for the format string. + */ + virtual void Debug(const char* format, ...) = 0; + + /** + * Creates a log entry with level INFO. + * + * @param [in] format Format string. + * @param [in] ... Parameters for the format string. + */ + virtual void Info(const char* format, ...) = 0; + + /** + * Creates a log entry with level WARNING. + * + * @param [in] format Format string. + * @param [in] ... Parameters for the format string. + */ + virtual void Warning(const char* format, ...) = 0; + + /** + * Creates a log entry with level ERROR. + * + * @param [in] format Format string. + * @param [in] ... Parameters for the format string. + */ + virtual void Error(const char* format, ...) = 0; + + /** + * Creates a log entry with level FATAL. + * + * @param [in] format Format string. + * @param [in] ... Parameters for the format string. + */ + virtual void Fatal(const char* format, ...) = 0; + }; + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/IMatchmaking.h b/Source/DLLs/1.113.3/galaxy/IMatchmaking.h new file mode 100644 index 00000000..d71fb4ac --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/IMatchmaking.h @@ -0,0 +1,770 @@ +#ifndef GALAXY_I_MATCHMAKING_H +#define GALAXY_I_MATCHMAKING_H + +/** + * @file + * Contains data structures and interfaces related to matchmaking. + */ + +#include "IUser.h" +#include "IListenerRegistrar.h" + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + /** + * Lobby type. Used for specifying visibility of a lobby and protecting it. + */ + enum LobbyType + { + LOBBY_TYPE_PRIVATE = 0, ///< Only invited users are able to join the lobby. + LOBBY_TYPE_FRIENDS_ONLY = 1, ///< Visible only to friends or invitees, but not in lobby list. + LOBBY_TYPE_PUBLIC = 2, ///< Visible for friends and in lobby list. + LOBBY_TYPE_INVISIBLE_TO_FRIENDS = 3 ///< Returned by search, but not visible to friends. + }; + + /** + * Lobby topology type. Used for specifying topology of user connections in lobby. + */ + enum LobbyTopologyType + { + DEPRECATED_LOBBY_TOPOLOGY_TYPE_FCM_HOST_MIGRATION = 0, ///< All users are connected with each other. Disconnection of lobby owner results in choosing a new one. Deprecated: use LOBBY_TOPOLOGY_TYPE_FCM_OWNERSHIP_TRANSITION instead. + LOBBY_TOPOLOGY_TYPE_FCM = 1, ///< All users are connected with each other. Disconnection of lobby owner results in closing the lobby. + LOBBY_TOPOLOGY_TYPE_STAR = 2, ///< All users are connected with lobby owner. Disconnection of lobby owner results in closing the lobby. + LOBBY_TOPOLOGY_TYPE_CONNECTIONLESS = 3, ///< All users are connected only with server. Disconnection of lobby owner results in choosing a new one. + LOBBY_TOPOLOGY_TYPE_FCM_OWNERSHIP_TRANSITION = 4 ///< All users are connected with each other. Disconnection of lobby owner results in choosing a new one. + }; + + /** + * Change of the state of a lobby member. Used in notifications. + */ + enum LobbyMemberStateChange + { + LOBBY_MEMBER_STATE_CHANGED_ENTERED = 0x0001, ///< The user joined the lobby. + LOBBY_MEMBER_STATE_CHANGED_LEFT = 0x0002, ///< The user left the lobby having announced it first. + LOBBY_MEMBER_STATE_CHANGED_DISCONNECTED = 0x0004, ///< The user disconnected without leaving the lobby first. + LOBBY_MEMBER_STATE_CHANGED_KICKED = 0x0008, ///< User was kicked from the lobby. + LOBBY_MEMBER_STATE_CHANGED_BANNED = 0x0010 ///< User was kicked and banned from the lobby. + }; + + /** + * Comparison type. Used for specifying filters that are supposed to be invoked + * to validate lobby properties when requesting for a list of matching lobbies. + */ + enum LobbyComparisonType + { + LOBBY_COMPARISON_TYPE_EQUAL = 0, ///< The lobby should have a property of a value that is equal to the one specified. + LOBBY_COMPARISON_TYPE_NOT_EQUAL = 1, ///< The lobby should have a property of a value that is not equal to the one specified. + LOBBY_COMPARISON_TYPE_GREATER = 2, ///< The lobby should have a property of a value that is greater than the one specified. + LOBBY_COMPARISON_TYPE_GREATER_OR_EQUAL = 3, ///< The lobby should have a property of a value that is greater than or equal to the one specified. + LOBBY_COMPARISON_TYPE_LOWER = 4, ///< The lobby should have a property of a value that is lower than the one specified. + LOBBY_COMPARISON_TYPE_LOWER_OR_EQUAL = 5 ///< The lobby should have a property of a value that is lower than or equal to the one specified. + }; + + /** + * Lobby creating result. + */ + enum LobbyCreateResult + { + LOBBY_CREATE_RESULT_SUCCESS, ///< Lobby was created. + LOBBY_CREATE_RESULT_ERROR ///< Unexpected error. + }; + + /** + * Lobby entering result. + */ + enum LobbyEnterResult + { + LOBBY_ENTER_RESULT_SUCCESS, ///< The user has entered the lobby. + LOBBY_ENTER_RESULT_LOBBY_DOES_NOT_EXIST, ///< Specified lobby does not exist. + LOBBY_ENTER_RESULT_LOBBY_IS_FULL, ///< Specified lobby is full. + LOBBY_ENTER_RESULT_ERROR ///< Unexpected error. + }; + + /** + * Listener for the event of receiving a list of lobbies. + */ + class ILobbyListListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of receiving a list of lobbies. + * + * @param [in] lobbyCount The number of matched lobbies. + * @param [in] ioFailure The flag that indicates a failure. + */ + virtual void OnLobbyList(uint32_t lobbyCount, bool ioFailure) = 0; + }; + + /** + * Globally self-registering version of ILobbyListListener. + */ + typedef SelfRegisteringListener GlobalLobbyListListener; + + /** + * Listener for the event of creating a lobby. + */ + class ILobbyCreatedListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of creating a lobby. + * + * When the lobby is successfully created it is joined and ready to use. + * Since the lobby is entered automatically, an explicit notification + * for ILobbyEnteredListener will follow immediately. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] result lobby create result. + */ + virtual void OnLobbyCreated(const GalaxyID& lobbyID, LobbyCreateResult result) = 0; + }; + + /** + * Globally self-registering version of ILobbyCreatedListener. + */ + typedef SelfRegisteringListener GlobalLobbyCreatedListener; + + /** + * Listener for the event of entering a lobby. + */ + class ILobbyEnteredListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of entering a lobby. + * + * It is called both after joining an existing lobby and after creating one. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] result lobby enter result. + */ + virtual void OnLobbyEntered(const GalaxyID& lobbyID, LobbyEnterResult result) = 0; + }; + + /** + * Globally self-registering version of ILobbyEnteredListener. + */ + typedef SelfRegisteringListener GlobalLobbyEnteredListener; + + /** + * Listener for the event of leaving a lobby. + */ + class ILobbyLeftListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of leaving lobby. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] ioFailure The flag that indicates a failure. + */ + virtual void OnLobbyLeft(const GalaxyID& lobbyID, bool ioFailure) = 0; + }; + + /** + * Globally self-registering version of ILobbyLeftListener. + */ + typedef SelfRegisteringListener GlobalLobbyLeftListener; + + /** + * Listener for the event of receiving an updated version of lobby data. + */ + class ILobbyDataListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of receiving an updated version of lobby data. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] memberID The ID of the lobby member, valid only if it is a change in a lobby member data. + */ + virtual void OnLobbyDataUpdated(const GalaxyID& lobbyID, const GalaxyID& memberID) = 0; + }; + + /** + * Globally self-registering version of ILobbyDataListener. + */ + typedef SelfRegisteringListener GlobalLobbyDataListener; + + /** + * Listener for the event of retrieving lobby data. + */ + class ILobbyDataRetrieveListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of success in retrieving lobby data. + * + * @param [in] lobbyID The ID of the lobby. + */ + virtual void OnLobbyDataRetrieveSuccess(const GalaxyID& lobbyID) = 0; + + /** + * The reason of a failure in retrieving lobby data. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED, ///< Unspecified error. + FAILURE_REASON_LOBBY_DOES_NOT_EXIST ///< Specified lobby does not exist. + }; + + /** + * Notification for the event of a failure in retrieving lobby data. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnLobbyDataRetrieveFailure(const GalaxyID& lobbyID, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of ILobbyDataRetrieveListener. + */ + typedef SelfRegisteringListener GlobalLobbyDataRetrieveListener; + + /** + * Listener for the event of a change of the state of a lobby member. + */ + class ILobbyMemberStateListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of a change of the state of a lobby member. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] memberID The ID of the lobby member. + * @param [in] memberStateChange Change of the state of the lobby member. + */ + virtual void OnLobbyMemberStateChanged(const GalaxyID& lobbyID, const GalaxyID& memberID, LobbyMemberStateChange memberStateChange) = 0; + }; + + /** + * Globally self-registering version of ILobbyMemberStateListener. + */ + typedef SelfRegisteringListener GlobalLobbyMemberStateListener; + + /** + * Listener for the event of changing the owner of a lobby. + * + * The event occurs when a lobby member is chosen to become the new owner + * of the lobby in place of the previous owner that apparently left the lobby, + * which should be explicitly indicated in a separate notification. + * + * @remark This listener should be implemented only if the game can handle the situation + * where the lobby owner leaves the lobby for any reason (e.g. is disconnected), + * letting the other users continue playing in the same lobby with the new owner + * knowing the state of the lobby and taking the responsibility for managing it. + */ + class ILobbyOwnerChangeListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of someone else becoming the owner of a lobby. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] newOwnerID The ID of the user who became new lobby owner. + */ + virtual void OnLobbyOwnerChanged(const GalaxyID& lobbyID, const GalaxyID& newOwnerID) = 0; + }; + + /** + * Globally self-registering version of ILobbyOwnerChangeListener. + */ + typedef SelfRegisteringListener GlobalLobbyOwnerChangeListener; + + /** + * Listener for the event of receiving a lobby message. + */ + class ILobbyMessageListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of receiving a lobby message. + * + * To read the message you need to call IMatchmaking::GetLobbyMessage(). + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] senderID The ID of the sender. + * @param [in] messageID The ID of the message. + * @param [in] messageLength Length of the message. + */ + virtual void OnLobbyMessageReceived(const GalaxyID& lobbyID, const GalaxyID& senderID, uint32_t messageID, uint32_t messageLength) = 0; + }; + + /** + * Globally self-registering version of ILobbyMessageListener. + */ + typedef SelfRegisteringListener GlobalLobbyMessageListener; + + /** + * The interface for managing game lobbies. + */ + class IMatchmaking + { + public: + + virtual ~IMatchmaking() + { + } + + /** + * Creates a lobby. + * + * Depending on the lobby type specified, the lobby will be visible for + * other users and joinable either for everyone or just specific users. + * + * This call is asynchronous. Responses come to the ILobbyCreatedListener, + * as well as ILobbyEnteredListener, provided that the lobby was created + * successfully, in which case the owning user enters it automatically. + * + * @param [in] lobbyType The type of the lobby. + * @param [in] maxMembers The maximum number of members allowed for the lobby with the limit of 250 members. + * @param [in] joinable Is the lobby joinable. + * @param [in] lobbyTopologyType The type of the lobby topology. + */ + virtual void CreateLobby(LobbyType lobbyType, uint32_t maxMembers, bool joinable, LobbyTopologyType lobbyTopologyType) = 0; + + /** + * Performs a request for a list of relevant lobbies. + * + * This call is asynchronous. When the list is received, a notification will + * come to the ILobbyListListener. The notification contains only the number + * of lobbies that were found and are available for reading. + * + * In order to read subsequent lobbies, call GetLobbyByIndex(). + * + * @remark The resulting list of lobbies is filtered according to all the + * filters that were specified prior to this call and after the previous + * request for lobby list, since filters are consumed only once and not used + * again. + * + * @remark Full lobbies are never included in the list. + * + * @param [in] allowFullLobbies Are full lobbies allowed. + */ + virtual void RequestLobbyList(bool allowFullLobbies = false) = 0; + + /** + * Adds a string filter to be applied next time you call RequestLobbyList(). + * + * You can add multiple filters. All filters operate on lobby properties. + * + * @remark After each call to RequestLobbyList() all filters are cleared. + * + * @param [in] keyToMatch The key to match. + * @param [in] valueToMatch The value to match. + * @param [in] comparisonType The type of comparison. + */ + virtual void AddRequestLobbyListStringFilter(const char* keyToMatch, const char* valueToMatch, LobbyComparisonType comparisonType) = 0; + + /** + * Adds a numerical filter to be applied next time you call RequestLobbyList(). + * + * You can add multiple filters. All filters operate on lobby properties. + * + * @remark After each call to RequestLobbyList() all filters are cleared. + * + * @param [in] keyToMatch The key to match. + * @param [in] valueToMatch The value to match. + * @param [in] comparisonType The type of comparison. + */ + virtual void AddRequestLobbyListNumericalFilter(const char* keyToMatch, int32_t valueToMatch, LobbyComparisonType comparisonType) = 0; + + /** + * Adds a near value filter to be applied next time you call RequestLobbyList(). + * + * You can add multiple filters. All filters operate on lobby properties. + * + * @remark After each call to RequestLobbyList() all filters are cleared. + * + * @param [in] keyToMatch The key to match. + * @param [in] valueToBeCloseTo The value to be close to. + */ + virtual void AddRequestLobbyListNearValueFilter(const char* keyToMatch, int32_t valueToBeCloseTo) = 0; + + /** + * Returns GalaxyID of a retrieved lobby by index. + * + * Use this call to iterate over last retrieved lobbies, indexed from 0. + * + * @remark This method can be used only inside of ILobbyListListener::OnLobbyList(). + * + * @pre In order to retrieve lobbies and get their count, you need to call + * RequestLobbyList() first. + * + * @param [in] index Index as an integer in the range of [0, number of lobbies fetched). + * @return The ID of the lobby, valid only if the index is valid. + */ + virtual GalaxyID GetLobbyByIndex(uint32_t index) = 0; + + /** + * Joins a specified existing lobby. + * + * This call is asynchronous. Responses come to the ILobbyEnteredListener. + * + * For other lobby members notifications come to the ILobbyMemberStateListener. + * + * @param [in] lobbyID The ID of the lobby to join. + */ + virtual void JoinLobby(GalaxyID lobbyID) = 0; + + /** + * Leaves a specified lobby. + * + * ILobbyLeftListener will be called when lobby is left. + * For other lobby members notifications come to the ILobbyMemberStateListener. + * + * Lobby data and lobby messages will not be reachable for lobby that we left. + * + * @param [in] lobbyID The ID of the lobby to leave. + */ + virtual void LeaveLobby(GalaxyID lobbyID) = 0; + + /** + * Sets the maximum number of users that can be in a specified lobby. + * + * @param [in] lobbyID The ID of the lobby to check. + * @param [in] maxNumLobbyMembers The maximum number of members allowed for the lobby with the limit of 250 members. + * @return true if the request was scheduled for sending, false otherwise. + */ + virtual bool SetMaxNumLobbyMembers(GalaxyID lobbyID, uint32_t maxNumLobbyMembers) = 0; + + /** + * Returns the maximum number of users that can be in a specified lobby. + * + * @pre If not currently in the lobby, retrieve the data first by calling RequestLobbyData(). + * + * @param [in] lobbyID The ID of the lobby to check. + * @return The maximum number of members allowed for the lobby. + */ + virtual uint32_t GetMaxNumLobbyMembers(GalaxyID lobbyID) = 0; + + /** + * Returns the number of users in a specified lobby. + * + * @pre If not currently in the lobby, retrieve the data first by calling RequestLobbyData(). + * + * @param [in] lobbyID The ID of the lobby to check. + * @return The number of members of the lobby. + */ + virtual uint32_t GetNumLobbyMembers(GalaxyID lobbyID) = 0; + + /** + * Returns the GalaxyID of a user in a specified lobby. + * + * @pre The user must be in the lobby in order to retrieve the lobby members. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] index Index as an integer in the range of [0, number of lobby members). + * @return The ID of the lobby member, valid only if the index is valid. + */ + virtual GalaxyID GetLobbyMemberByIndex(GalaxyID lobbyID, uint32_t index) = 0; + + /** + * Sets the type of a specified lobby. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] lobbyType The type of the lobby. + * @return true if the request was scheduled for sending, false otherwise. + */ + virtual bool SetLobbyType(GalaxyID lobbyID, LobbyType lobbyType) = 0; + + /** + * Returns the type of a specified lobby. + * + * @pre If not currently in the lobby, retrieve the data first by calling RequestLobbyData(). + * + * @param [in] lobbyID The ID of the lobby. + * @return lobbyType The type of the lobby. + */ + virtual LobbyType GetLobbyType(GalaxyID lobbyID) = 0; + + /** + * Sets if a specified lobby is joinable. + * + * @remark When a lobby is not joinable, no user can join in even if there are still + * some empty slots for lobby members. The lobby is also hidden from matchmaking. + * + * @remark Newly created lobbies are joinable by default. Close a lobby by making it + * not joinable e.g. when the game has started and no new lobby members are allowed. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] joinable Is the lobby joinable. + * @return true if the request was scheduled for sending, false otherwise. + */ + virtual bool SetLobbyJoinable(GalaxyID lobbyID, bool joinable) = 0; + + /** + * Checks if a specified lobby is joinable. + * + * @pre If not currently in the lobby, retrieve the data first by calling RequestLobbyData(). + * + * @param [in] lobbyID The ID of the lobby. + * @return If the lobby is joinable. + */ + virtual bool IsLobbyJoinable(GalaxyID lobbyID) = 0; + + /** + * Refreshes info about a specified lobby. + * + * This is needed only for the lobbies that the user is not currently in, + * since for entered lobbies any info is updated automatically. + * + * This call is asynchronous. Responses come to the ILobbyDataListener. + * + * @param [in] lobbyID The ID of the lobby. + * @return true if the request was scheduled for sending, false otherwise. + */ + virtual bool RequestLobbyData(GalaxyID lobbyID) = 0; + + /** + * Returns an entry from the properties of a specified lobby. + * + * It returns an empty string if there is no such property of the lobby, or + * if the ID of the lobby is invalid. + * + * @remark This call is not thread-safe as opposed to GetLobbyDataCopy(). + * + * @pre If not currently in the lobby, retrieve the data first by calling RequestLobbyData(). + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] key The name of the property of the lobby. + * @return The value of the property, or an empty string if failed. + */ + virtual const char* GetLobbyData(GalaxyID lobbyID, const char* key) = 0; + + /** + * Copies an entry from the properties of a specified lobby. + * + * It copies an empty string if there is no such property of the lobby, or + * if the ID of the lobby is invalid. + * + * @pre If not currently in the lobby, retrieve the data first by calling RequestLobbyData(). + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] key The name of the property of the lobby. + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + */ + virtual void GetLobbyDataCopy(GalaxyID lobbyID, const char* key, char* buffer, uint32_t bufferLength) = 0; + + /** + * Creates or updates an entry in the properties of a specified lobby. + * + * The properties can be used for matchmaking or broadcasting any lobby data + * (e.g. the name of the lobby) to other Galaxy Peers. + * + * The properties are assigned to the lobby and available for matchmaking. + * Each user that is a member of the lobby will receive a notification when + * the properties of the lobby are changed. The notifications come to ILobbyDataListener. + * + * Any user that joins the lobby will be able to read the data. + * + * @remark To clear a property, set it to an empty string. + * + * @pre Only the owner of the lobby can edit its properties. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] key The name of the property of the lobby with the limit of 1023 bytes. + * @param [in] value The value of the property to set with the limit of 4095 bytes. + * @return true if the request was scheduled for sending, false otherwise. + */ + virtual bool SetLobbyData(GalaxyID lobbyID, const char* key, const char* value) = 0; + + /** + * Returns the number of entries in the properties of a specified lobby. + * + * @pre If not currently in the lobby, retrieve the data first by calling + * RequestLobbyData(). + * + * @param [in] lobbyID The ID of the lobby. + * @return The number of entries, or 0 if failed. + */ + virtual uint32_t GetLobbyDataCount(GalaxyID lobbyID) = 0; + + /** + * Returns a property of a specified lobby by index. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] index Index as an integer in the range of [0, number of entries). + * @param [in, out] key The name of the property of the lobby. + * @param [in] keyLength The length of the name of the property of the lobby. + * @param [in, out] value The value of the property of the lobby. + * @param [in] valueLength The length of the value of the property of the lobby. + * @return true if succeeded, false when there is no such property. + */ + virtual bool GetLobbyDataByIndex(GalaxyID lobbyID, uint32_t index, char* key, uint32_t keyLength, char* value, uint32_t valueLength) = 0; + + /** + * Clears a property of a specified lobby by its name. + * + * This is the same as calling SetLobbyData() and providing an empty string + * as the value of the property that is to be altered. + * + * Each user that is a member of the lobby will receive a notification when + * the properties of the lobby are changed. The notifications come to ILobbyDataListener. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] key The name of the property of the lobby. + * @return true if the request was scheduled for sending, false otherwise. + */ + virtual bool DeleteLobbyData(GalaxyID lobbyID, const char* key) = 0; + + /** + * Returns an entry from the properties of a specified member + * of a specified lobby. + * + * It returns an empty string if there is no such property of the member of + * the lobby, or if any of the specified IDs are invalid (including false + * membership). + * + * @remark This call is not thread-safe as opposed to GetLobbyMemberDataCopy(). + * + * @pre If not currently in the lobby, retrieve the data first by calling RequestLobbyData(). + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] memberID The ID of the lobby member. + * @param [in] key The name of the property of the lobby member. + * @return The value of the property, or an empty string if failed. + */ + virtual const char* GetLobbyMemberData(GalaxyID lobbyID, GalaxyID memberID, const char* key) = 0; + + /** + * Copies an entry from the properties of a specified member + * of a specified lobby. + * + * It copies an empty string if there is no such property of the member of + * the lobby, or if any of the specified IDs are invalid (including false + * membership). + * + * @pre If not currently in the lobby, retrieve the data first by calling RequestLobbyData(). + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] memberID The ID of the lobby member. + * @param [in] key The name of the property of the lobby member. + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + */ + virtual void GetLobbyMemberDataCopy(GalaxyID lobbyID, GalaxyID memberID, const char* key, char* buffer, uint32_t bufferLength) = 0; + + /** + * Creates or updates an entry in the user's properties (as a lobby member) + * in a specified lobby. + * + * The properties can be used for broadcasting any data as the lobby member data + * (e.g. the name of the user in the lobby) to other lobby members. + * + * The properties are assigned to the user as a lobby member in the lobby. + * Each user that is a member of the lobby will receive a notification when + * the lobby member properties are changed. The notifications come to ILobbyDataListener. + * + * Any user that joins the lobby will be able to read the data. + * + * @remark To clear a property, set it to an empty string. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] key The name of the property of the lobby member with the limit of 1023 bytes. + * @param [in] value The value of the property to set with the limit of 4095 bytes. + */ + virtual void SetLobbyMemberData(GalaxyID lobbyID, const char* key, const char* value) = 0; + + /** + * Returns the number of entries in the properties of a specified member + * of a specified lobby. + * + * @pre If not currently in the lobby, retrieve the data first by calling RequestLobbyData(). + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] memberID The ID of the lobby member. + * @return The number of entries, or 0 if failed. + */ + virtual uint32_t GetLobbyMemberDataCount(GalaxyID lobbyID, GalaxyID memberID) = 0; + + /** + * Returns a property of a specified lobby member by index. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] memberID The ID of the lobby member. + * @param [in] index Index as an integer in the range of [0, number of entries). + * @param [in, out] key The name of the property of the lobby member. + * @param [in] keyLength The length of the name of the property of the lobby member. + * @param [in, out] value The value of the property of the lobby member. + * @param [in] valueLength The length of the value of the property of the lobby member. + * @return true if succeeded, false when there is no such property. + */ + virtual bool GetLobbyMemberDataByIndex(GalaxyID lobbyID, GalaxyID memberID, uint32_t index, char* key, uint32_t keyLength, char* value, uint32_t valueLength) = 0; + + /** + * Clears a property of a specified lobby member by its name. + * + * This is the same as calling SetLobbyMemberData() and providing an empty + * string as the value of the property that is to be altered. + * + * Each user that is a member of the lobby will receive a notification when + * the lobby member properties are changed. The notifications come to ILobbyDataListener. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] key The name of the property of the lobby member. + */ + virtual void DeleteLobbyMemberData(GalaxyID lobbyID, const char* key) = 0; + + /** + * Returns the owner of a specified lobby. + * + * @pre If not currently in the lobby, retrieve the data first by calling RequestLobbyData(). + * + * @param [in] lobbyID The ID of the lobby. + * @return The ID of the lobby member who is also its owner, valid only when called by a member. + */ + virtual GalaxyID GetLobbyOwner(GalaxyID lobbyID) = 0; + + /** + * Sends a message to all lobby members, including the sender. + * + * For all the lobby members there comes a notification to the + * ILobbyMessageListener. Since that moment it is possible to retrieve the + * message by ID using GetLobbyMessage(). + * + * @pre The user needs to be in the lobby in order to send a message to its members. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] msg The data to send. + * @param [in] msgLength The length of the data. + * @return true if the message was scheduled for sending, false otherwise. + */ + virtual bool SendLobbyMessage(GalaxyID lobbyID, const void* data, uint32_t dataSize) = 0; + + /** + * Receives a specified message from one of the members of a specified lobby. + * + * @param [in] lobbyID The ID of the lobby. + * @param [in] messageID The ID of the message. + * @param [out] senderID The ID of the sender. + * @param [in, out] msg The buffer to pass the data to. + * @param [in] msgLength The size of the buffer. + * @return The number of bytes written to the buffer. + */ + virtual uint32_t GetLobbyMessage(GalaxyID lobbyID, uint32_t messageID, GalaxyID& senderID, char* msg, uint32_t msgLength) = 0; + }; + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/INetworking.h b/Source/DLLs/1.113.3/galaxy/INetworking.h new file mode 100644 index 00000000..0eb5e0b9 --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/INetworking.h @@ -0,0 +1,280 @@ +#ifndef GALAXY_I_NETWORKING_H +#define GALAXY_I_NETWORKING_H + +/** + * @file + * Contains data structures and interfaces related to communicating with other + * Galaxy Peers. + */ + +#include "IListenerRegistrar.h" +#include "GalaxyID.h" + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + /** + * Listener for the events related to packets that come to the client. + */ + class INetworkingListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of receiving a packet. + * + * @param [in] msgSize The length of the message. + * @param [in] channel The number of the channel used. + */ + virtual void OnP2PPacketAvailable(uint32_t msgSize, uint8_t channel) = 0; + }; + + /** + * Globally self-registering version of INetworkingListener. + */ + typedef SelfRegisteringListener GlobalNetworkingListener; + + /** + * Listener for the events related to packets that come to server (the packets + * that were addressed to a LobbyID). + */ + class IServerNetworkingListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of receiving a packet. + * + * @param [in] msgSize The length of the message. + * @param [in] channel The number of the channel used. + */ + virtual void OnServerP2PPacketAvailable(uint32_t msgSize, uint8_t channel) = 0; + }; + + /** + * Globally self-registering version of IServerNetworkingListener. + */ + typedef SelfRegisteringListener GlobalServerNetworkingListener; + + /** + * NAT types. + */ + enum NatType + { + NAT_TYPE_NONE = 0, ///< There is no NAT at all. + NAT_TYPE_FULL_CONE = 1, ///< Accepts any datagrams to a port that has been previously used. + NAT_TYPE_ADDRESS_RESTRICTED = 2, ///< Accepts datagrams to a port if the datagram source IP address belongs to a system that has been sent to. + NAT_TYPE_PORT_RESTRICTED = 3, ///< Accepts datagrams to a port if the datagram source IP address and port belongs a system that has been sent to. + NAT_TYPE_SYMMETRIC = 4, ///< A different port is chosen for every remote destination. + NAT_TYPE_UNKNOWN = 5 ///< NAT type has not been determined. + }; + + /** + * Listener for the events related to NAT type detection. + */ + class INatTypeDetectionListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of a success in NAT type detection. + * + * @param [in] natType The NAT type. + */ + virtual void OnNatTypeDetectionSuccess(NatType natType) = 0; + + /** + * Notification for the event of a failure in NAT type detection. + */ + virtual void OnNatTypeDetectionFailure() = 0; + }; + + /** + * Globally self-registering version of INatTypeDetectionListener. + */ + typedef SelfRegisteringListener GlobalNatTypeDetectionListener; + + /** + * Send type used when calling INetworking::SendP2PPacket() in order to + * specify desired reliability of the data transfer for each packet that is + * being sent. + */ + enum P2PSendType + { + P2P_SEND_UNRELIABLE = 0, ///< UDP-like packet transfer. The packet will be sent during the next call to ProcessData(). + P2P_SEND_RELIABLE = 1, ///< TCP-like packet transfer. The packet will be sent during the next call to ProcessData(). + P2P_SEND_UNRELIABLE_IMMEDIATE = 2, ///< UDP-like packet transfer. The packet will be sent instantly. + P2P_SEND_RELIABLE_IMMEDIATE = 3 ///< TCP-like packet transfer. The packet will be sent instantly. + }; + + /** + * The interface for communicating with other Galaxy Peers. + */ + class INetworking + { + public: + + virtual ~INetworking() + { + } + + /** + * Sends a P2P packet to a specified user. + * + * It is possible to communicate only with the users within the same lobby. + * It is recommended to send 1200 bytes at most in a single packet. + * + * The channel is a routing number that allows to implement + * separate layers of communication while using the same existing connection + * in order to save some network resources. + * Since there is only a single connection between each two Galaxy Peers, + * the Galaxy Peer that is supposed to receive the packet needs to know + * which channel number to use when checking for incoming packets. + * + * In order to receive the packet on the other Galaxy Peer, call there + * ReadP2PPacket() with the same channel number. + * + * Packets addressed to a user (by providing a user ID as the GalaxyID) + * need to be received with the standard networking interface. + * Packets addressed to a lobby (by providing a lobby ID as the GalaxyID) + * come to the lobby owner that also acts as the game server, thus they + * need to be received with the server networking interface. + * + * @param [in] galaxyID ID of the specified user to whom the packet is to be sent. + * @param [in] data The data to send. + * @param [in] dataSize The size of the data. + * @param [in] sendType The level of reliability of the operation. + * @param [in] channel The number of the channel to use. + * @return true if the packet was scheduled for sending, false otherwise. + */ + virtual bool SendP2PPacket(GalaxyID galaxyID, const void* data, uint32_t dataSize, P2PSendType sendType, uint8_t channel = 0) = 0; + + /** + * Reads an incoming packet that was sent from another Galaxy Peer + * by calling SendP2PPacket() with the same channel number. + * The packet that was read this way is left in the packet queue. + * + * If the buffer that is supposed to take the data is too small, + * the message will be truncated to its size. The size of the packet is + * provided in the notification about an incoming packet in either + * INetworkingListener or IServerNetworkingListener, during which this call + * is intended to be performed. + * + * This call is non-blocking and operates on the awaiting packets + * that have already come to the Galaxy Peer, thus instantly finishes, + * claiming a failure if there are no packets on the specified channel yet. + * + * @remark This call works similarly to ReadP2PPacket(), yet does not remove + * the packet from the packet queue. + * + * @param [in, out] dest The buffer to pass the data to. + * @param [in] destSize The size of the buffer. + * @param [in, out] outMsgSize The size of the message. + * @param [out] outGalaxyID The ID of the user who sent the packet. + * @param [in] channel The number of the channel to use. + * @return true if succeeded, false when there are no packets. + */ + virtual bool PeekP2PPacket(void* dest, uint32_t destSize, uint32_t* outMsgSize, GalaxyID& outGalaxyID, uint8_t channel = 0) = 0; + + /** + * Checks for any incoming packets on a specified channel. + * + * @remark Do not call this method if employing INetworkingListener and + * IServerNetworkingListener. Instead, during the notification about an + * incoming packet read packets by calling PeekP2PPacket(). + * + * @param [in, out] outMsgSize The size of the first incoming message if there is any. + * @param [in] channel The number of the channel to use. + * @return true if there are any awaiting incoming packets, false otherwise. + */ + virtual bool IsP2PPacketAvailable(uint32_t* outMsgSize, uint8_t channel = 0) = 0; + + /** + * Reads an incoming packet that was sent from another Galaxy Peer + * by calling SendP2PPacket() with the same channel number. + * The packet that was read this way is removed from the packet queue. + * + * This call is non-blocking and operates on the awaiting packets + * that have already come to the Galaxy Peer, thus instantly finishes, + * claiming a failure if there are no packets on the specified channel yet. + * + * @remark This call is equivalent to calling PeekP2PPacket(), and then + * calling PopP2PPacket(). + * + * @remark Do not call this method if employing INetworkingListener or + * IServerNetworkingListener, since the packet that the notification is + * related to is automatically removed from the packet queue right after all + * the related notifications are finished. Instead, read the incoming packet + * by calling PeekP2PPacket() during the notification. + * + * @pre If the buffer that is supposed to take the data is too small, + * the message will be truncated to its size. For that reason prior to + * reading a packet it is recommended to check for it by calling + * IsP2PPacketAvailable(), which also returns the packet size. + * + * @param [in, out] dest The buffer to pass the data to. + * @param [in] destSize The size of the buffer. + * @param [in, out] outMsgSize The size of the message. + * @param [out] outGalaxyID The ID of the user who sent the packet. + * @param [in] channel The number of the channel to use. + * @return true if succeeded, false when there are no packets. + */ + virtual bool ReadP2PPacket(void* dest, uint32_t destSize, uint32_t* outMsgSize, GalaxyID& outGalaxyID, uint8_t channel = 0) = 0; + + /** + * Removes the first packet from the packet queue. + * + * @remark Do not call this method if employing INetworkingListener or + * IServerNetworkingListener, since the packet that the notification is + * related to is automatically removed from the packet queue right after all + * the related notifications are finished. + * + * @param [in] channel The number of the channel to use. + */ + virtual void PopP2PPacket(uint8_t channel = 0) = 0; + + /** + * Retrieves current ping value in milliseconds with a specified entity, i.e. + * another member of the same lobby that the current user is in, or the lobby + * itself, in which case the returned value is the ping with the lobby owner. + * + * @param [in] galaxyID ID of the specified user or lobby to check ping with. + * @return Ping with the target entity or -1 if the target entity is not + * connected or the ping has not been determined yet. + */ + virtual int GetPingWith(GalaxyID galaxyID) = 0; + + /** + * Initiates a NAT type detection process. + * + * @remark NAT type detection is performed automatically when creating or joining a lobby. + */ + virtual void RequestNatTypeDetection() = 0; + + /** + * Retrieves determined NAT type. + * + * @pre Initial value of NAT type is NAT_TYPE_UNKNOWN. + * + * @pre NAT type detection is performed automatically when creating or joining a lobby. + * + * @pre NAT type can be detected by calling RequestNatTypeDetection() + * without creating or joining a lobby. + * + * @return The determined NAT type. + */ + virtual NatType GetNatType() = 0; + + }; + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/IStats.h b/Source/DLLs/1.113.3/galaxy/IStats.h new file mode 100644 index 00000000..77a97954 --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/IStats.h @@ -0,0 +1,800 @@ +#ifndef GALAXY_I_STATS_H +#define GALAXY_I_STATS_H + +/** + * @file + * Contains data structures and interfaces related to statistics, achievements and leaderboards. + */ + +#include "IListenerRegistrar.h" +#include "GalaxyID.h" + +namespace galaxy +{ + namespace api + { + + /** + * @addtogroup api + * @{ + */ + + /** + * The sort order of a leaderboard. + */ + enum LeaderboardSortMethod + { + LEADERBOARD_SORT_METHOD_NONE = 0, ///< No sorting method specified. + LEADERBOARD_SORT_METHOD_ASCENDING = 1, ///< Top score is lowest number. + LEADERBOARD_SORT_METHOD_DESCENDING = 2 ///< Top score is highest number. + }; + + /** + * The display type of a leaderboard. + */ + enum LeaderboardDisplayType + { + LEADERBOARD_DISPLAY_TYPE_NONE = 0, ///< Not display type specified. + LEADERBOARD_DISPLAY_TYPE_NUMBER = 1, ///< Simple numerical score. + LEADERBOARD_DISPLAY_TYPE_TIME_SECONDS = 2, ///< The score represents time, in seconds. + LEADERBOARD_DISPLAY_TYPE_TIME_MILLISECONDS = 3 ///< The score represents time, in milliseconds. + }; + + /** + * Listener for the event of retrieving statistics and achievements + * of a specified user, possibly our own. + */ + class IUserStatsAndAchievementsRetrieveListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of success in retrieving statistics + * and achievements for a specified user. + * + * To read statistics call IStats::GetStatInt() or IStats::GetStatFloat(), + * depending on the type of the statistic to read. + * + * To read achievements call IStats::GetAchievement(). + * + * @param [in] userID The ID of the user. + */ + virtual void OnUserStatsAndAchievementsRetrieveSuccess(GalaxyID userID) = 0; + + /** + * The reason of a failure in retrieving statistics and achievements. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED ///< Unspecified error. + }; + + /** + * Notification for the event of a failure in retrieving statistics + * and achievements for a specified user. + * + * @param [in] userID The ID of the user. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnUserStatsAndAchievementsRetrieveFailure(GalaxyID userID, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of IUserStatsAndAchievementsRetrieveListener. + */ + typedef SelfRegisteringListener GlobalUserStatsAndAchievementsRetrieveListener; + + /** + * Listener for the event of storing own statistics and achievements. + */ + class IStatsAndAchievementsStoreListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of success in storing statistics + * and achievements. + */ + virtual void OnUserStatsAndAchievementsStoreSuccess() = 0; + + /** + * The reason of a failure in storing statistics and achievements. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED ///< Unspecified error. + }; + + /** + * Notification for the event of a failure in storing statistics + * and achievements. + * + * @param [in] failureReason The cause of the failure. + */ + virtual void OnUserStatsAndAchievementsStoreFailure(FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of IStatsAndAchievementsStoreListener. + */ + typedef SelfRegisteringListener GlobalStatsAndAchievementsStoreListener; + + /** + * Listener for the event of changing an achievement. + */ + class IAchievementChangeListener : public GalaxyTypeAwareListener + { + public: + + // // /** + // // * Notification for the event of changing progress in unlocking + // // * a particular achievement. + // // * + // // * @param [in] name The code name of the achievement. + // // * @param [in] currentProgress Current value of progress for the achievement. + // // * @param [in] maxProgress The maximum value of progress for the achievement. + // // */ + // // void OnAchievementProgressChanged(const char* name, uint32_t currentProgress, uint32_t maxProgress) = 0; + + /** + * Notification for the event of storing changes that result in + * unlocking a particular achievement. + * + * @param [in] name The code name of the achievement. + */ + virtual void OnAchievementUnlocked(const char* name) = 0; + }; + + /** + * Globally self-registering version of IAchievementChangeListener. + */ + typedef SelfRegisteringListener GlobalAchievementChangeListener; + + /** + * Listener for the event of retrieving definitions of leaderboards. + */ + class ILeaderboardsRetrieveListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of a success in retrieving definitions of leaderboards. + * + * In order to read metadata of retrieved leaderboards, call IStats::GetLeaderboardDisplayName(), + * IStats::GetLeaderboardSortMethod(), or IStats::GetLeaderboardDisplayType(). + * + * In order to read entries, retrieve some first by calling IStats::RequestLeaderboardEntriesGlobal(), + * IStats::RequestLeaderboardEntriesAroundUser(), or IStats::RequestLeaderboardEntriesForUsers(). + */ + virtual void OnLeaderboardsRetrieveSuccess() = 0; + + /** + * The reason of a failure in retrieving definitions of leaderboards. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED ///< Unspecified error. + }; + + /** + * Notification for the event of a failure in retrieving definitions of leaderboards. + * + * @param [in] failureReason The cause of the failure. + */ + virtual void OnLeaderboardsRetrieveFailure(FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of a ILeaderboardsRetrieveListener. + */ + typedef SelfRegisteringListener GlobalLeaderboardsRetrieveListener; + + /** + * Listener for the event of retrieving requested entries of a leaderboard. + */ + class ILeaderboardEntriesRetrieveListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of a success in retrieving requested entries of a leaderboard. + * + * In order to read subsequent entries, call IStats::GetRequestedLeaderboardEntry(). + * + * @param [in] name The name of the leaderboard. + * @param [in] entryCount The number of entries that were retrieved. + */ + virtual void OnLeaderboardEntriesRetrieveSuccess(const char* name, uint32_t entryCount) = 0; + + /** + * The reason of a failure in retrieving requested entries of a leaderboard. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED, ///< Unspecified error. + FAILURE_REASON_NOT_FOUND ///< Could not find any entries for specified search criteria. + }; + + /** + * Notification for the event of a failure in retrieving requested entries of a leaderboard. + * + * @param [in] name The name of the leaderboard. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnLeaderboardEntriesRetrieveFailure(const char* name, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of a ILeaderboardEntriesRetrieveListener. + */ + typedef SelfRegisteringListener GlobalLeaderboardEntriesRetrieveListener; + + /** + * Listener for the event of updating score in a leaderboard. + */ + class ILeaderboardScoreUpdateListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of a success in setting score in a leaderboard. + * + * @param [in] name The name of the leaderboard. + * @param [in] score The score after the update. + * @param [in] oldRank Previous rank, i.e. before the update; 0 if the user had no entry yet. + * @param [in] newRank Current rank, i.e. after the update. + */ + virtual void OnLeaderboardScoreUpdateSuccess(const char* name, int32_t score, uint32_t oldRank, uint32_t newRank) = 0; + + /** + * The reason of a failure in updating score in a leaderboard. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED, ///< Unspecified error. + FAILURE_REASON_NO_IMPROVEMENT ///< Previous score was better and the update operation was not forced. + }; + + /** + * The reason of a failure in updating score in a leaderboard. + * + * @param [in] name The name of the leaderboard. + * @param [in] score The score that was attempted to set. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnLeaderboardScoreUpdateFailure(const char* name, int32_t score, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of a ILeaderboardScoreUpdateListener. + */ + typedef SelfRegisteringListener GlobalLeaderboardScoreUpdateListener; + + /** + * Listener for the event of retrieving definition of a leaderboard. + */ + class ILeaderboardRetrieveListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of a success in retrieving definition of a leaderboard. + * + * In order to read metadata of the retrieved leaderboard, call IStats::GetLeaderboardDisplayName(), + * IStats::GetLeaderboardSortMethod(), or IStats::GetLeaderboardDisplayType(). + * + * In order to read entries, retrieve some first by calling IStats::RequestLeaderboardEntriesGlobal(), + * IStats::RequestLeaderboardEntriesAroundUser(), or IStats::RequestLeaderboardEntriesForUsers(). + * + * @param [in] name The name of the leaderboard. + */ + virtual void OnLeaderboardRetrieveSuccess(const char* name) = 0; + + /** + * The reason of a failure in retrieving definition of a leaderboard. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED ///< Unspecified error. + }; + + /** + * Notification for the event of a failure in retrieving definition of a leaderboard. + * + * @param [in] name The name of the leaderboard. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnLeaderboardRetrieveFailure(const char* name, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of a ILeaderboardRetrieveListener. + */ + typedef SelfRegisteringListener GlobalLeaderboardRetrieveListener; + + /** + * Listener for the event of retrieving user time played. + */ + class IUserTimePlayedRetrieveListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of a success in retrieving user time played. + * + * In order to read user time played, call IStats::GetUserTimePlayed(). + * + * @param [in] userID The ID of the user. + */ + virtual void OnUserTimePlayedRetrieveSuccess(GalaxyID userID) = 0; + + /** + * The reason of a failure in retrieving user time played. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED ///< Unspecified error. + }; + + /** + * Notification for the event of a failure in retrieving user time played. + * + * @param [in] userID The ID of the user. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnUserTimePlayedRetrieveFailure(GalaxyID userID, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of a IUserTimePlayedRetrieveListener. + */ + typedef SelfRegisteringListener GlobalUserTimePlayedRetrieveListener; + + /** + * The interface for managing statistics, achievements and leaderboards. + */ + class IStats + { + public: + + virtual ~IStats() + { + } + + /** + * Performs a request for statistics and achievements of a specified user. + * + * This call is asynchronous. Responses come to the IUserStatsAndAchievementsRetrieveListener. + * + * @param [in] userID The ID of the user. It can be omitted when requesting for own data. + */ + virtual void RequestUserStatsAndAchievements(GalaxyID userID = GalaxyID()) = 0; + + /** + * Reads integer value of a statistic of a specified user. + * + * @pre Retrieve the statistics first by calling RequestUserStatsAndAchievements(). + * + * @param [in] name The code name of the statistic. + * @param [in] userID The ID of the user. It can be omitted when requesting for own data. + * @return The value of the statistic. + */ + virtual int32_t GetStatInt(const char* name, GalaxyID userID = GalaxyID()) = 0; + + /** + * Reads floating point value of a statistic of a specified user. + * + * @pre Retrieve the statistics first by calling RequestUserStatsAndAchievements(). + * + * @param [in] name The code name of the statistic. + * @param [in] userID The ID of the user. It can be omitted when requesting for own data. + * @return The value of the statistic. + */ + virtual float GetStatFloat(const char* name, GalaxyID userID = GalaxyID()) = 0; + + /** + * Updates a statistic with an integer value. + * + * @remark In order to make this and other changes persistent, call StoreStatsAndAchievements(). + * + * @pre Retrieve the statistics first by calling RequestUserStatsAndAchievements(). + * + * @param [in] name The code name of the statistic. + * @param [in] value The value of the statistic to set. + */ + virtual void SetStatInt(const char* name, int32_t value) = 0; + + /** + * Updates a statistic with a floating point value. + * + * @remark In order to make this and other changes persistent, call StoreStatsAndAchievements(). + * + * @pre Retrieve the statistics first by calling RequestUserStatsAndAchievements(). + * + * @param [in] name The code name of the statistic. + * @param [in] value The value of the statistic to set. + */ + virtual void SetStatFloat(const char* name, float value) = 0; + + /** + * Updates an average-rate statistic with a delta. + * + * @remark In order to make this and other changes persistent, call StoreStatsAndAchievements(). + * + * @pre Retrieve the statistics first by calling RequestUserStatsAndAchievements(). + * + * @param [in] name The code name of the statistic. + * @param [in] countThisSession The delta of the count. + * @param [in] sessionLength The delta of the session. + */ + virtual void UpdateAvgRateStat(const char* name, float countThisSession, double sessionLength) = 0; + + /** + * Reads the state of an achievement of a specified user. + * + * @pre Retrieve the achievements first by calling RequestUserStatsAndAchievements(). + * + * @param [in] name The code name of the achievement. + * @param [in, out] unlocked Indicates if the achievement has been unlocked. + * @param [out] unlockTime The time at which the achievement was unlocked. + * @param [in] userID The ID of the user. It can be omitted when requesting for own data. + */ + virtual void GetAchievement(const char* name, bool& unlocked, uint32_t& unlockTime, GalaxyID userID = GalaxyID()) = 0; + + /** + * Unlocks an achievement. The achievement is marked as unlocked at the time + * at which this message was called. + * + * @remark In order to make this and other changes persistent, call StoreStatsAndAchievements(). + * + * @pre Retrieve the achievements first by calling RequestUserStatsAndAchievements(). + * + * @param [in] name The code name of the achievement. + */ + virtual void SetAchievement(const char* name) = 0; + + /** + * Clears an achievement. + * + * @remark In order to make this and other changes persistent, call StoreStatsAndAchievements(). + * + * @pre Retrieve the achievements first by calling RequestUserStatsAndAchievements(). + * + * @param [in] name The code name of the achievement. + */ + virtual void ClearAchievement(const char* name) = 0; + + /** + * Persists all changes in statistics and achievements. + * + * This call is asynchronous. Responses come to the IStatsAndAchievementsStoreListener. + * Notifications about storing changes that result in unlocking + * achievements come to the IAchievementChangeListener. + */ + virtual void StoreStatsAndAchievements() = 0; + + /** + * Resets all statistics and achievements. + * + * This is the same as setting statistics and achievements to their + * initial values and calling StoreStatsAndAchievements(). + * + * This call is asynchronous. Responses come to the IStatsAndAchievementsStoreListener. + */ + virtual void ResetStatsAndAchievements() = 0; + + /** + * Returns display name of a specified achievement. + * + * @remark This call is not thread-safe as opposed to GetAchievementDisplayNameCopy(). + * + * @pre Retrieve the achievements first by calling RequestUserStatsAndAchievements(). + * + * @param [in] name The name of the achievement. + * @return Display name of the specified achievement. + */ + virtual const char* GetAchievementDisplayName(const char* name) = 0; + + /** + * Copies display name of a specified achievement. + * + * @pre Retrieve the achievements first by calling RequestUserStatsAndAchievements(). + * + * @param [in] name The name of the achievement. + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + */ + virtual void GetAchievementDisplayNameCopy(const char* name, char* buffer, uint32_t bufferLength) = 0; + + /** + * Returns description of a specified achievement. + * + * @remark This call is not thread-safe as opposed to GetAchievementDescriptionCopy(). + * + * @pre Retrieve the achievements first by calling RequestUserStatsAndAchievements(). + * + * @param [in] name The name of the achievement. + * @return Description of the specified achievement. + */ + virtual const char* GetAchievementDescription(const char* name) = 0; + + /** + * Copies description of a specified achievement. + * + * @pre Retrieve the achievements first by calling RequestUserStatsAndAchievements(). + * + * @param [in] name The name of the achievement. + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + */ + virtual void GetAchievementDescriptionCopy(const char* name, char* buffer, uint32_t bufferLength) = 0; + + /** + * Returns visibility status of a specified achievement. + * + * @pre Retrieve the achievements first by calling RequestUserStatsAndAchievements(). + * + * @param [in] name The name of the achievement. + * @return If the achievement is visible. + */ + virtual bool IsAchievementVisible(const char* name) = 0; + + /** + * Performs a request for definitions of leaderboards. + * + * This call is asynchronous. Responses come to the ILeaderboardsRetrieveListener. + */ + virtual void RequestLeaderboards() = 0; + + /** + * Returns display name of a specified leaderboard. + * + * @remark This call is not thread-safe as opposed to GetLeaderboardDisplayNameCopy(). + * + * @pre Retrieve definition of this particular leaderboard first by calling + * either FindLeaderboard() or FindOrCreateLeaderboard(), or definitions of all existing leaderboards + * by calling RequestLeaderboards(). + * + * @param [in] name The name of the leaderboard. + * @return Display name of the leaderboard. + */ + virtual const char* GetLeaderboardDisplayName(const char* name) = 0; + + /** + * Copies display name of a specified leaderboard. + * + * @pre Retrieve definition of this particular leaderboard first by calling + * either FindLeaderboard() or FindOrCreateLeaderboard(), or definitions of all existing leaderboards + * by calling RequestLeaderboards(). + * + * @param [in] name The name of the leaderboard. + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + */ + virtual void GetLeaderboardDisplayNameCopy(const char* name, char* buffer, uint32_t bufferLength) = 0; + + /** + * Returns sort method of a specified leaderboard. + * + * @pre Retrieve definition of this particular leaderboard first by calling + * either FindLeaderboard() or FindOrCreateLeaderboard(), or definitions of all existing leaderboards + * by calling RequestLeaderboards(). + * + * @param [in] name The name of the leaderboard. + * @return Sort method of the leaderboard. + */ + virtual LeaderboardSortMethod GetLeaderboardSortMethod(const char* name) = 0; + + /** + * Returns display type of a specified leaderboard. + * + * @pre Retrieve definition of this particular leaderboard first by calling + * either FindLeaderboard() or FindOrCreateLeaderboard(), or definitions of all existing leaderboards + * by calling RequestLeaderboards(). + * + * @param [in] name The name of the leaderboard. + * @return Display type of the leaderboard. + */ + virtual LeaderboardDisplayType GetLeaderboardDisplayType(const char* name) = 0; + + /** + * Performs a request for entries of a specified leaderboard in a global scope, + * i.e. without any specific users in the scope of interest. + * + * The entries are indexed by integers in the range of [0, number of entries). + * + * This call is asynchronous. Responses come to the ILeaderboardEntriesRetrieveListener. + * + * @pre Retrieve definition of this particular leaderboard first by calling + * either FindLeaderboard() or FindOrCreateLeaderboard(), or definitions of all existing leaderboards + * by calling RequestLeaderboards(). + * + * @param [in] name The name of the leaderboard. + * @param [in] rangeStart The index position of the entry to start with. + * @param [in] rangeEnd The index position of the entry to finish with. + */ + virtual void RequestLeaderboardEntriesGlobal(const char* name, uint32_t rangeStart, uint32_t rangeEnd) = 0; + + /** + * Performs a request for entries of a specified leaderboard for and near the specified user. + * + * The specified numbers of entries before and after the specified user are treated as hints. + * If the requested range would go beyond the set of all leaderboard entries, it is shifted + * so that it fits in the set of all leaderboard entries and preserves its size if possible. + * + * This call is asynchronous. Responses come to the ILeaderboardEntriesRetrieveListener. + * + * @remark This call will end with failure in case there is no entry for the specified user + * in the specified leaderboard. + * + * @pre Retrieve definition of this particular leaderboard first by calling + * either FindLeaderboard() or FindOrCreateLeaderboard(), or definitions of all existing leaderboards + * by calling RequestLeaderboards(). + * + * @param [in] name The name of the leaderboard. + * @param [in] countBefore The number of entries placed before the user's entry to retrieve (hint). + * @param [in] countAfter The number of entries placed after the user's entry to retrieve (hint). + * @param [in] userID The ID of the user. It can be omitted when requesting for own data. + */ + virtual void RequestLeaderboardEntriesAroundUser(const char* name, uint32_t countBefore, uint32_t countAfter, GalaxyID userID = GalaxyID()) = 0; + + /** + * Performs a request for entries of a specified leaderboard for specified users. + * + * This call is asynchronous. Responses come to the ILeaderboardEntriesRetrieveListener. + * + * @pre Retrieve definition of this particular leaderboard first by calling + * either FindLeaderboard() or FindOrCreateLeaderboard(), or definitions of all existing leaderboards + * by calling RequestLeaderboards(). + * + * @param [in] name The name of the leaderboard. + * @param [in] userArray An array with the list of IDs of the users in scope. + * @param [in] userArraySize The size of the array, i.e. the number of users in the specified list. + */ + virtual void RequestLeaderboardEntriesForUsers(const char* name, GalaxyID* userArray, uint32_t userArraySize) = 0; + + /** + * Returns data from the currently processed request for leaderboard entries. + * + * Use this call to iterate over last retrieved lobby entries, indexed from 0. + * + * @remark This method can be used only inside of + * ILeaderboardEntriesRetrieveListener::OnLeaderboardEntriesRetrieveSuccess(). + * + * @pre In order to retrieve lobbies and get their count, first you need to call + * RequestLeaderboardEntriesGlobal(), RequestLeaderboardEntriesAroundUser(), + * or RequestLeaderboardEntriesForUsers(). + * + * @param [in] index Index as an integer in the range of [0, number of entries fetched). + * @param [out] rank User's rank in the leaderboard. + * @param [out] score User's score in the leaderboard. + * @param [out] userID The ID of the user. + */ + virtual void GetRequestedLeaderboardEntry(uint32_t index, uint32_t& rank, int32_t& score, GalaxyID& userID) = 0; + + /** + * Returns data with details from the currently processed request for leaderboard entries. + * + * Use this call to iterate over last retrieved lobby entries, indexed from 0. + * + * If the buffer that is supposed to take the details data is too small, + * the details will be truncated to its size. + * + * @pre In order to retrieve lobbies and get their count, first you need to call + * RequestLeaderboardEntriesGlobal(), RequestLeaderboardEntriesAroundUser(), + * or RequestLeaderboardEntriesForUsers(). + * + * @remark This method can be used only inside of + * ILeaderboardEntriesRetrieveListener::OnLeaderboardEntriesRetrieveSuccess(). + * + * @param [in] index Index as an integer in the range of [0, number of entries fetched). + * @param [out] rank User's rank in the leaderboard. + * @param [out] score User's score in the leaderboard. + * @param [in, out] details An extra, outgoing game-defined information regarding how the user got that score. + * @param [in] detailsSize The size of passed buffer of the extra game-defined information. + * @param [out] outDetailsSize The size of the extra game-defined information. + * @param [out] userID The ID of the user. + */ + virtual void GetRequestedLeaderboardEntryWithDetails(uint32_t index, uint32_t& rank, int32_t& score, void* details, uint32_t detailsSize, uint32_t& outDetailsSize, GalaxyID& userID) = 0; + + /** + * Updates entry for own user in a specified leaderboard. + * + * This call is asynchronous. Responses come to the ILeaderboardScoreUpdateListener. + * + * @pre Retrieve definition of this particular leaderboard first by calling + * either FindLeaderboard() or FindOrCreateLeaderboard(), or definitions of all existing leaderboards + * by calling RequestLeaderboards(). + * + * @pre For this call to work while the user is logged off, the definition of the leaderboard + * must have been retrieved at least once while the user was logged on. + * + * @param [in] name The name of the leaderboard. + * @param [in] score The score to set. + * @param [in] forceUpdate If the update should be performed in case the score is worse than the previous score. + */ + virtual void SetLeaderboardScore(const char* name, int32_t score, bool forceUpdate = false) = 0; + + /** + * Updates entry with details for own user in a specified leaderboard. + * + * This call is asynchronous. Responses come to the ILeaderboardScoreUpdateListener. + * + * @pre Retrieve definition of this particular leaderboard first by calling + * either FindLeaderboard() or FindOrCreateLeaderboard(), or definitions of all existing leaderboards + * by calling RequestLeaderboards(). + * + * @pre For this call to work while the user is logged off, the definition of the leaderboard + * must have been retrieved at least once while the user was logged on. + * + * @param [in] name The name of the leaderboard. + * @param [in] score The score to set. + * @param [in] details An extra game-defined information regarding how the user got that score with the limit of 3071 bytes. + * @param [in] detailsSize The size of buffer of the extra game-defined information. + * @param [in] forceUpdate If the update should be performed in case the score is worse than the previous score. + */ + virtual void SetLeaderboardScoreWithDetails(const char* name, int32_t score, const void* details, uint32_t detailsSize, bool forceUpdate = false) = 0; + + /** + * Returns the leaderboard entry count for requested leaderboard. + * + * @pre In order to retrieve leaderboard entry count, first you need to call + * RequestLeaderboardEntriesGlobal(), RequestLeaderboardEntriesAroundUser(), + * or RequestLeaderboardEntriesForUsers(). + * + * @param [in] name The name of the leaderboard. + * @return The leaderboard entry count. + */ + virtual uint32_t GetLeaderboardEntryCount(const char* name) = 0; + + /** + * Performs a request for definition of a specified leaderboard. + * + * This call is asynchronous. Responses come to the ILeaderboardRetrieveListener. + * + * @param [in] name The name of the leaderboard. + */ + virtual void FindLeaderboard(const char* name) = 0; + + /** + * Performs a request for definition of a specified leaderboard, creating it + * if there is no such leaderboard yet. + * + * This call is asynchronous. Responses come to the ILeaderboardRetrieveListener. + * + * @remark If the leaderboard of the specified name is found, this call ends + * with success no matter if the definition of the leaderboard matches + * the parameters specified in the call to this method. + * + * @param [in] name The name of the leaderboard. + * @param [in] displayName The display name of the leaderboard. + * @param [in] sortMethod The sort method of the leaderboard. + * @param [in] displayType The display method of the leaderboard. + */ + virtual void FindOrCreateLeaderboard(const char* name, const char* displayName, const LeaderboardSortMethod& sortMethod, const LeaderboardDisplayType& displayType) = 0; + + /** + * Performs a request for user time played. + * + * This call is asynchronous. Responses come to the IUserTimePlayedRetrieveListener. + * + * @param [in] userID The ID of the user. It can be omitted when requesting for own data. + */ + virtual void RequestUserTimePlayed(GalaxyID userID = GalaxyID()) = 0; + + /** + * Reads the number of seconds played by a specified user. + * + * @pre Retrieve the statistics first by calling RequestUserTimePlayed(). + * + * @param [in] userID The ID of the user. It can be omitted when requesting for own data. + * @return The number of seconds played by the specified user. + */ + virtual uint32_t GetUserTimePlayed(GalaxyID userID = GalaxyID()) = 0; + }; + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/IStorage.h b/Source/DLLs/1.113.3/galaxy/IStorage.h new file mode 100644 index 00000000..a3f816a6 --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/IStorage.h @@ -0,0 +1,293 @@ +#ifndef GALAXY_I_STORAGE_H +#define GALAXY_I_STORAGE_H + +/** + * @file + * Contains data structures and interfaces related to storage activities + */ + +#include "GalaxyID.h" +#include "IListenerRegistrar.h" + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + /** + * ID of a shared file. + */ + typedef uint64_t SharedFileID; + + /** + * Listener for the event of sharing a file. + */ + class IFileShareListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of a success in sharing a file. + * + * @param [in] fileName The name of the file in the form of a path (see the description of IStorage::FileWrite()). + * @param [in] sharedFileID The ID of the file. + */ + virtual void OnFileShareSuccess(const char* fileName, SharedFileID sharedFileID) = 0; + + /** + * The reason of a failure in sharing a file. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED ///< Unspecified error. + }; + + /** + * Notification for the event of a failure in sharing a file. + * + * @param [in] fileName The name of the file in the form of a path (see the description of IStorage::FileWrite()). + * @param [in] failureReason The cause of the failure. + */ + virtual void OnFileShareFailure(const char* fileName, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of IFileShareListener. + */ + typedef SelfRegisteringListener GlobalFileShareListener; + + /** + * Listener for the event of downloading a shared file. + */ + class ISharedFileDownloadListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of a success in downloading a shared file. + * + * @param [in] sharedFileID The ID of the file. + * @param [in] fileName The name of the file in the form of a path (see the description of IStorage::FileWrite()). + */ + virtual void OnSharedFileDownloadSuccess(SharedFileID sharedFileID, const char* fileName) = 0; + + /** + * The reason of a failure in downloading a shared file. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED ///< Unspecified error. + }; + + /** + * Notification for the event of a failure in downloading a shared file. + * + * @param [in] sharedFileID The ID of the file. + * @param [in] failureReason The cause of the failure. + */ + virtual void OnSharedFileDownloadFailure(SharedFileID sharedFileID, FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of ISharedFileDownloadListener. + */ + typedef SelfRegisteringListener GlobalSharedFileDownloadListener; + + /** + * The interface for managing of cloud storage files. + */ + class IStorage + { + public: + + virtual ~IStorage() + { + } + + /** + * Writes data into the file. + * + * @pre The name that specifies the file can be provided in the form of a path that uses slashes + * as separators and is a valid UTF-8 string. Every part of the path must must be portable, + * i.e. it cannot refer to any special or restricted name on any of the supported platforms. + * Backslashes are not allowed. + * + * @param [in] fileName The name of the file in the form of a path (see the description of the method). + * @param [in] data The data to write. + * @param [in] dataSize The size of the data to write. + */ + virtual void FileWrite(const char* fileName, const void* data, uint32_t dataSize) = 0; + + /** + * Reads file content into the buffer. + * + * @param [in] fileName The name of the file in the form of a path (see the description of FileWrite()). + * @param [in, out] data The output buffer. + * @param [in] dataSize The size of the output buffer. + * @return The number of bytes written to the buffer. + */ + virtual uint32_t FileRead(const char* fileName, void* data, uint32_t dataSize) = 0; + + /** + * Deletes the file. + * + * @param [in] fileName The name of the file in the form of a path (see the description of FileWrite()). + */ + virtual void FileDelete(const char* fileName) = 0; + + /** + * Returns if the file exists + * + * @param [in] fileName The name of the file in the form of a path (see the description of FileWrite()). + * @return If the file exist. + */ + virtual bool FileExists(const char* fileName) = 0; + + /** + * Returns the size of the file. + * + * @param [in] fileName The name of the file in the form of a path (see the description of FileWrite()). + * @return The size of the file. + */ + virtual uint32_t GetFileSize(const char* fileName) = 0; + + /** + * Returns the timestamp of the last file modification. + * + * @param [in] fileName The name of the file in the form of a path (see the description of FileWrite()). + * @return The time of file's last modification. + */ + virtual uint32_t GetFileTimestamp(const char* fileName) = 0; + + /** + * Returns number of the files in the storage. + * + * @return The number of the files in the storage. + */ + virtual uint32_t GetFileCount() = 0; + + /** + * Returns name of the file. + * + * @param [in] index Index as an integer in the range of [0, number of files). + * @return The name of the file. + */ + virtual const char* GetFileNameByIndex(uint32_t index) = 0; + + /** + * Copies the name of the file to a buffer. + * + * @param [in] index Index as an integer in the range of [0, number of files). + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + */ + virtual void GetFileNameCopyByIndex(uint32_t index, char* buffer, uint32_t bufferLength) = 0; + + /** + * Uploads the file for sharing. + * + * This call is asynchronous. Responses come to the IFileShareListener. + * + * @param [in] fileName The name of the file in the form of a path (see the description of FileWrite()). + */ + virtual void FileShare(const char* fileName) = 0; + + /** + * Downloads previously shared file. + * + * This call is asynchronous. Responses come to the ISharedFileDownloadListener. + * + * @param [in] sharedFileID The ID of the shared file. + */ + virtual void DownloadSharedFile(SharedFileID sharedFileID) = 0; + + /** + * Gets name of downloaded shared file. + * + * @pre Download the file first by calling DownloadSharedFile(). + * + * @param [in] sharedFileID The ID of the shared file. + * @return The name of the shared file. + */ + virtual const char* GetSharedFileName(SharedFileID sharedFileID) = 0; + + /** + * Copies the name of downloaded shared file to a buffer. + * + * @pre Download the file first by calling DownloadSharedFile(). + * + * @param [in] sharedFileID The ID of the shared file. + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + */ + virtual void GetSharedFileNameCopy(SharedFileID sharedFileID, char* buffer, uint32_t bufferLength) = 0; + + /** + * Gets size of downloaded shared file. + * + * @pre Download the file first by calling DownloadSharedFile(). + * + * @param [in] sharedFileID The ID of the shared file. + * @return The size of the shared file. + */ + virtual uint32_t GetSharedFileSize(SharedFileID sharedFileID) = 0; + + /** + * Gets the owner of downloaded shared file. + * + * @pre Download the file first by calling DownloadSharedFile(). + * + * @param [in] sharedFileID The ID of the shared file. + * @return The owner of the shared file. + */ + virtual GalaxyID GetSharedFileOwner(SharedFileID sharedFileID) = 0; + + /** + * Reads downloaded shared file content into the buffer. + * + * @pre Download the file first by calling DownloadSharedFile(). + * + * @param [in] sharedFileID The ID of the shared file. + * @param [in, out] data The output buffer. + * @param [in] dataSize The size of the output buffer. + * @param [in] offset The number of bytes to skip from the beginning of the file. + * @return The number of bytes written to the buffer. + */ + virtual uint32_t SharedFileRead(SharedFileID sharedFileID, void* data, uint32_t dataSize, uint32_t offset = 0) = 0; + + /** + * Closes downloaded shared file and frees the memory. + * + * The content of the file will not be available until next download. + * + * @pre Download the file first by calling DownloadSharedFile(). + * + * @param [in] sharedFileID The ID of the shared file. + */ + virtual void SharedFileClose(SharedFileID sharedFileID) = 0; + + /** + * Returns the number of open downloaded shared files. + * + * @return The number of open downloaded shared files. + */ + virtual uint32_t GetDownloadedSharedFileCount() = 0; + + /** + * Returns the ID of the open downloaded shared file. + * + * @param [in] index Index as an integer in the range of [0, number of open downloaded shared files). + * @return The ID of the shared file. + */ + virtual SharedFileID GetDownloadedSharedFileByIndex(uint32_t index) = 0; + }; + + /** @} */ + } + } + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/IUser.h b/Source/DLLs/1.113.3/galaxy/IUser.h new file mode 100644 index 00000000..50f7fdcb --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/IUser.h @@ -0,0 +1,535 @@ +#ifndef GALAXY_I_USER_H +#define GALAXY_I_USER_H + +/** + * @file + * Contains data structures and interfaces related to user account. + */ + +#include "IListenerRegistrar.h" +#include "GalaxyID.h" + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + /** + * The ID of the session. + */ + typedef uint64_t SessionID; + + /** + * Listener for the events related to user authentication. + */ + class IAuthListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of successful sign in. + */ + virtual void OnAuthSuccess() = 0; + + /** + * Reason of authentication failure. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED = 0, ///< Undefined error. + FAILURE_REASON_GALAXY_SERVICE_NOT_AVAILABLE = 1, ///< Galaxy Service is not installed properly or fails to start. + FAILURE_REASON_GALAXY_SERVICE_NOT_SIGNED_IN = 2, ///< Galaxy Service is not signed in properly. + FAILURE_REASON_CONNECTION_FAILURE = 3, ///< Unable to communicate with backend services. + FAILURE_REASON_NO_LICENSE = 4, ///< User that is being signed in has no license for this application. + FAILURE_REASON_INVALID_CREDENTIALS = 5, ///< Unable to match client credentials (ID, secret) or user credentials (username, password). + FAILURE_REASON_GALAXY_NOT_INITIALIZED = 6, ///< Galaxy has not been initialized. + FAILURE_REASON_EXTERNAL_SERVICE_FAILURE = 7 ///< Unable to communicate with external service. + }; + + /** + * Notification for the event of unsuccessful sign in. + * + * @param [in] failureReason The cause of the failure. + */ + virtual void OnAuthFailure(FailureReason failureReason) = 0; + + /** + * Notification for the event of loosing authentication. + * + * @remark Might occur any time after successfully signing in. + */ + virtual void OnAuthLost() = 0; + }; + + /** + * Globally self-registering version of IAuthListener. + */ + typedef SelfRegisteringListener GlobalAuthListener; + + /** + * Listener for the events related to starting of other sessions. + */ + class IOtherSessionStartListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of other session being started. + */ + virtual void OnOtherSessionStarted() = 0; + }; + + /** + * Globally self-registering version of IOtherSessionStartListener. + */ + typedef SelfRegisteringListener GlobalOtherSessionStartListener; + + /** + * Listener for the event of a change of the operational state. + */ + class IOperationalStateChangeListener : public GalaxyTypeAwareListener + { + public: + + /** + * Aspect of the operational state. + */ + enum OperationalState + { + OPERATIONAL_STATE_SIGNED_IN = 0x0001, ///< User signed in. + OPERATIONAL_STATE_LOGGED_ON = 0x0002 ///< User logged on. + }; + + /** + * Notification for the event of a change of the operational state. + * + * @param [in] operationalState The sum of the bit flags representing the operational state, as defined in IOperationalStateChangeListener::OperationalState. + */ + virtual void OnOperationalStateChanged(uint32_t operationalState) = 0; + }; + + /** + * Globally self-registering version of IOperationalStateChangeListener. + */ + typedef SelfRegisteringListener GlobalOperationalStateChangeListener; + + /** + * Listener for the events related to user data changes of current user only. + * + * @remark In order to get notifications about changes to user data of all users, + * use ISpecificUserDataListener instead. + */ + class IUserDataListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of user data change. + */ + virtual void OnUserDataUpdated() = 0; + }; + + /** + * Globally self-registering version of IUserDataListener. + */ + typedef SelfRegisteringListener GlobalUserDataListener; + + /** + * Listener for the events related to user data changes. + */ + class ISpecificUserDataListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of user data change. + * + * @param [in] userID The ID of the user. + */ + virtual void OnSpecificUserDataUpdated(GalaxyID userID) = 0; + }; + + /** + * Globally self-registering version of ISpecificUserDataListener. + */ + typedef SelfRegisteringListener GlobalSpecificUserDataListener; + + /** + * Listener for the event of retrieving a requested Encrypted App Ticket. + */ + class IEncryptedAppTicketListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for an event of a success in retrieving the Encrypted App Ticket. + * + * In order to read the Encrypted App Ticket, call IUser::GetEncryptedAppTicket(). + */ + virtual void OnEncryptedAppTicketRetrieveSuccess() = 0; + + /** + * The reason of a failure in retrieving an Encrypted App Ticket. + */ + enum FailureReason + { + FAILURE_REASON_UNDEFINED = 0 ///< Unspecified error. + }; + + /** + * Notification for the event of a failure in retrieving an Encrypted App Ticket. + * + * @param [in] failureReason The cause of the failure. + */ + virtual void OnEncryptedAppTicketRetrieveFailure(FailureReason failureReason) = 0; + }; + + /** + * Globally self-registering version of IEncryptedAppTicketListener. + */ + typedef SelfRegisteringListener GlobalEncryptedAppTicketListener; + + /** + * Listener for the event of a change of current access token. + */ + class IAccessTokenListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for an event of retrieving an access token. + * + * In order to read the access token, call IUser::GetAccessToken(). + */ + virtual void OnAccessTokenChanged() = 0; + }; + + /** + * Globally self-registering version of IAccessTokenListener. + */ + typedef SelfRegisteringListener GlobalAccessTokenListener; + + /** + * The interface for handling the user account. + */ + class IUser + { + public: + + virtual ~IUser() + { + } + + /** + * Checks if the user is signed in to Galaxy. + * + * The user should be reported as signed in as soon as the authentication + * process is finished. + * + * If the user is not able to sign in or gets signed out, there might be either + * a networking issue or a limited availability of Galaxy backend services. + * + * After loosing authentication the user needs to sign in again in order + * for the Galaxy Peer to operate. + * + * @remark Information about being signed in or signed out also comes to + * the IAuthListener and the IOperationalStateChangeListener. + * + * @return true if the user is signed in, false otherwise. + */ + virtual bool SignedIn() = 0; + + /** + * Returns the ID of the user, provided that the user is signed in. + * + * @return The ID of the user. + */ + virtual GalaxyID GetGalaxyID() = 0; + + /** + * Initializes the Galaxy Peer with specified user credentials. + * + * This call is asynchronous. Responses come to the IAuthListener. + * + * Information about being signed in or signed out also comes to + * the IOperationalStateChangeListener. + * + * @warning This method is only for testing purposes and is not meant + * to be used in production environment in any way. + * + * @param [in] login The user's login. + * @param [in] password The user's password. + */ + virtual void SignIn(const char* login, const char* password) = 0; + + /** + * Initializes the Galaxy Peer based on Steam Encrypted App Ticket. + * + * This call is asynchronous. Responses come to the IAuthListener. + * + * @remark Information about being signed in or signed out also comes to + * the IOperationalStateChangeListener. + * + * @param [in] steamAppTicket The Encrypted App Ticket from the Steam API. + * @param [in] steamAppTicketSize The size of the ticket. + * @param [in] personaName The user's persona name, i.e. the username from Steam. + */ + virtual void SignIn(const void* steamAppTicket, uint32_t steamAppTicketSize, const char* personaName) = 0; + + /** + * Initializes the Galaxy Peer based on Galaxy Client authentication. + * + * This call is asynchronous. Responses come to the IAuthListener. + * + * @remark Information about being signed in or signed out also comes to + * the IOperationalStateChangeListener. + * + * @param [in] requireOnline Indicates if sing in with Galaxy backend is required. + */ + virtual void SignIn(bool requireOnline = false) = 0; + + /** + * Initializes the Galaxy Peer based on PS4 credentials. + * + * This call is asynchronous. Responses come to the IAuthListener. + * + * @remark Information about being signed in or signed out also comes to + * the IOperationalStateChangeListener. + * + * @param [in] ps4ClientID The PlayStation 4 client ID. + * @param [in] ps4TitleID The PlayStation 4 title ID. + * @param [in] ps4TitleSecret The PlayStation 4 title secret. + * @param [in] ps4TitleSecretLength The length of the title secret. + */ + virtual void SignIn(const char* ps4ClientID, const char* ps4TitleID, const char* ps4TitleSecret, uint32_t ps4TitleSecretLength) = 0; + + /** + * Initializes the Galaxy Peer based on XBOX ONE credentials. + * + * This call is asynchronous. Responses come to the IAuthListener. + * + * @remark Information about being signed in or signed out also comes to + * the IOperationalStateChangeListener. + * + * @param [in] xboxOneUserID The XBOX ONE user ID. + */ + virtual void SignIn(uint32_t xboxOneUserID) = 0; + + /** + * Retrieves/Refreshes user data storage. + * + * This call is asynchronous. Responses come to the IUserDataListener and ISpecificUserDataListener. + * + * @param [in] userID The ID of the user. It can be omitted when requesting for own data. + */ + virtual void RequestUserData(GalaxyID userID = GalaxyID()) = 0; + + /** + * Checks if user data exists. + * + * @pre Retrieve the user data first by calling RequestUserData(). + * + * @param [in] userID The ID of the user. It can be omitted when checking for own data. + * @return true if user data exists, false otherwise. + */ + virtual bool IsUserDataAvailable(GalaxyID userID = GalaxyID()) = 0; + + /** + * Returns an entry from the data storage of current user. + * + * @remark This call is not thread-safe as opposed to GetUserDataCopy(). + * + * @pre Retrieve the user data first by calling RequestUserData(). + * + * @param [in] key The name of the property of the user data storage. + * @param [in] userID The ID of the user. It can be omitted when reading own data. + * @return The value of the property, or an empty string if failed. + */ + virtual const char* GetUserData(const char* key, GalaxyID userID = GalaxyID()) = 0; + + /** + * Copies an entry from the data storage of current user. + * + * @pre Retrieve the user data first by calling RequestUserData(). + * + * @param [in] key The name of the property of the user data storage. + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + * @param [in] userID The ID of the user. It can be omitted when reading own data. + */ + virtual void GetUserDataCopy(const char* key, char* buffer, uint32_t bufferLength, GalaxyID userID = GalaxyID()) = 0; + + /** + * Creates or updates an entry in the user data storage. + * + * This call in asynchronous. Responses come to the IUserDataListener and ISpecificUserDataListener. + * + * @remark To clear a property, set it to an empty string. + * + * @pre Retrieve the user data first by calling RequestUserData(). + * + * @param [in] key The name of the property of the user data storage with the limit of 1023 bytes. + * @param [in] value The value of the property to set with the limit of 4095 bytes. + */ + virtual void SetUserData(const char* key, const char* value) = 0; + + /** + * Returns the number of entries in the user data storage + * + * @pre Retrieve the user data first by calling RequestUserData(). + * + * @param [in] userID The ID of the user. It can be omitted when reading own data. + * @return The number of entries, or 0 if failed. + */ + virtual uint32_t GetUserDataCount(GalaxyID userID = GalaxyID()) = 0; + + /** + * Returns a property from the user data storage by index. + * + * @pre Retrieve the user data first by calling RequestUserData(). + * + * @param [in] index Index as an integer in the range of [0, number of entries). + * @param [in, out] key The name of the property of the user data storage. + * @param [in] keyLength The length of the name of the property of the user data storage. + * @param [in, out] value The value of the property of the user data storage. + * @param [in] valueLength The length of the value of the property of the user data storage. + * @param [in] userID The ID of the user. It can be omitted when reading own data. + * @return true if succeeded, false when there is no such property. + */ + virtual bool GetUserDataByIndex(uint32_t index, char* key, uint32_t keyLength, char* value, uint32_t valueLength, GalaxyID userID = GalaxyID()) = 0; + + /** + * Clears a property of user data storage + * + * This is the same as calling SetUserData() and providing an empty string + * as the value of the property that is to be altered. + * + * This call in asynchronous. Responses come to the IUserDataListener and ISpecificUserDataListener. + * + * @pre Retrieve the user data first by calling RequestUserData(). + * + * @param [in] key The name of the property of the user data storage. + */ + virtual void DeleteUserData(const char* key) = 0; + + /** + * Checks if the user is logged on to Galaxy backend services. + * + * @remark Only a user that has been successfully signed in within Galaxy Service + * can be logged on to Galaxy backend services, hence a user that is logged on + * is also signed in, and a user that is not signed in is also not logged on. + * + * @remark Information about being logged on or logged off also comes to + * the IOperationalStateChangeListener. + * + * @return true if the user is logged on to Galaxy backend services, false otherwise. + */ + virtual bool IsLoggedOn() = 0; + + /** + * Performs a request for an Encrypted App Ticket. + * + * If the buffer that is supposed to take the data is too small, + * the Encrypted App Ticket will be truncated to its size. + * + * This call is asynchronous. Responses come to the IEncryptedAppTicketListener. + * + * @param [in] data The additional data to be placed within the Encrypted App Ticket with the limit of 1023 bytes. + * @param [in] dataSize The size of the additional data. + */ + virtual void RequestEncryptedAppTicket(const void* data, uint32_t dataSize) = 0; + + /** + * Returns the Encrypted App Ticket. + * + * @pre Retrieve an Encrypted App Ticket first by calling RequestEncryptedAppTicket(). + * + * @param [in, out] encryptedAppTicket The Encrypted App Ticket. + * @param [in] maxEncryptedAppTicketSize The maximum size of the Encrypted App Ticket. + * @param [out] currentEncryptedAppTicketSize The actual size of the Encrypted App Ticket. + */ + virtual void GetEncryptedAppTicket(void* encryptedAppTicket, uint32_t maxEncryptedAppTicketSize, uint32_t& currentEncryptedAppTicketSize) = 0; + + /** + * Initializes the Galaxy Peer with a specified server key. + * + * This call is asynchronous. Responses come to the IAuthListener. + * + * @warning Make sure you do not put your server key in public builds. + * + * @remark Information about being signed in or signed out also comes to + * the IOperationalStateChangeListener. + * + * @remark Signing in with a server key is meant for server-side usage, + * meaning that typically there will be no user associated to the session. + * + * @param [in] serverKey The server key. + */ + virtual void SignIn(const char* serverKey) = 0; + + /** + * Returns the ID of current session. + * + * @return The session ID. + */ + virtual SessionID GetSessionID() = 0; + + /** + * Returns the access token for current session. + * + * @remark This call is not thread-safe as opposed to GetAccessTokenCopy(). + * + * @remark The access token that is used for current session might be + * updated in the background automatically, without any request for that. + * Each time the access token is updated, a notification comes to the + * IAccessTokenListener. + * + * @return The access token. + */ + virtual const char* GetAccessToken() = 0; + + /** + * Copies the access token for current session. + * + * @remark The access token that is used for current session might be + * updated in the background automatically, without any request for that. + * Each time the access token is updated, a notification comes to the + * IAccessTokenListener. + * + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + */ + virtual void GetAccessTokenCopy(char* buffer, uint32_t bufferLength) = 0; + + /** + * Reports current access token as no longer working. + * + * This starts the process of refreshing access token, unless the process + * is already in progress. The notifications come to IAccessTokenListener. + * + * @remark The access token that is used for current session might be + * updated in the background automatically, without any request for that. + * Each time the access token is updated, a notification comes to the + * IAccessTokenListener. + * + * @remark If the specified access token is not the same as the access token + * for current session that would have been returned by GetAccessToken(), + * the report will not be accepted and no further action will be performed. + * In such case do not expect a notification to IAccessTokenListener and + * simply get the new access token by calling GetAccessToken(). + * + * @param [in] accessToken The invalid access token. + * @return true if the report was accepted, false otherwise. + */ + virtual bool ReportInvalidAccessToken(const char* accessToken) = 0; + }; + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/galaxy/IUtils.h b/Source/DLLs/1.113.3/galaxy/IUtils.h new file mode 100644 index 00000000..0b91156d --- /dev/null +++ b/Source/DLLs/1.113.3/galaxy/IUtils.h @@ -0,0 +1,233 @@ +#ifndef GALAXY_I_UTILS_H +#define GALAXY_I_UTILS_H + +/** + * @file + * Contains data structures and interfaces related to common activities. + */ + +#include "IListenerRegistrar.h" + +namespace galaxy +{ + namespace api + { + /** + * @addtogroup api + * @{ + */ + + /** + * The ID of the notification. + */ + typedef uint64_t NotificationID; + + /** + * State of the overlay + */ + enum OverlayState + { + OVERLAY_STATE_UNDEFINED = 0, + OVERLAY_STATE_NOT_SUPPORTED = 1, + OVERLAY_STATE_DISABLED = 2, + OVERLAY_STATE_FAILED_TO_INITIALIZE = 3, + OVERLAY_STATE_INITIALIZED = 4 + }; + + /** + * Listener for the event of changing overlay visibility. + */ + class IOverlayVisibilityChangeListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of changing overlay visibility. + * + * @param [in] overlayVisible Indicates if overlay is in front of the game. + */ + virtual void OnOverlayVisibilityChanged(bool overlayVisible) = 0; + }; + + /** + * Globally self-registering version of IOverlayStateChangeListener. + */ + typedef SelfRegisteringListener GlobalOverlayVisibilityChangeListener; + + /** + * Listener for the event of changing overlay state. + */ + class IOverlayInitializationStateChangeListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of changing overlay state change. + * + * @param [in] overlayState Indicates current state of the overlay. + */ + virtual void OnOverlayStateChanged(OverlayState overlayState) = 0; + }; + + /** + * Globally self-registering version of IOverlayInitializationStateChangeListener. + */ + typedef SelfRegisteringListener GlobalOverlayInitializationStateChangeListener; + + /** + * Listener for the event of changing overlay visibility. + * + * @deprecated Use IOverlayVisibilityChangeListener. + */ + class IOverlayStateChangeListener : public GalaxyTypeAwareListener<_OVERLAY_STATE_CHANGE> + { + public: + + /** + * Notification for the event of changing overlay visibility. + * + * @param [in] overlayIsActive Indicates if overlay is in front of the game. + */ + virtual void OnOverlayStateChanged(bool overlayIsActive) = 0; + }; + + /** + * @deprecated Globally self-registering version of IOverlayStateChangeListener. + */ + typedef SelfRegisteringListener GlobalOverlayStateChangeListener; + + /** + * Listener for the event of receiving a notification. + */ + class INotificationListener : public GalaxyTypeAwareListener + { + public: + + /** + * Notification for the event of receiving a notification. + * + * To read the message you need to call IUtils::GetNotification(). + * + * @param [in] notificationID The ID of the notification. + * @param [in] typeLength The size of the type of the notification. + * @param [in] contentSize The size of the content of the notification. + */ + virtual void OnNotificationReceived(NotificationID notificationID, uint32_t typeLength, uint32_t contentSize) = 0; + }; + + /** + * Globally self-registering version of INotificationListener. + */ + typedef SelfRegisteringListener GlobalNotificationListener; + + /** + * The interface for managing images. + */ + class IUtils + { + public: + + virtual ~IUtils() + { + } + + /** + * Reads width and height of the image of a specified ID. + * + * @param [in] imageID The ID of the image. + * @param [out] width The width of the image. + * @param [out] height The height of the image. + */ + virtual void GetImageSize(uint32_t imageID, int32_t& width, int32_t& height) = 0; + + /** + * Reads the image of a specified ID. + * + * @pre The size of the output buffer should be 4 * height * width * sizeof(char). + * + * @param [in] imageID The ID of the image. + * @param [in, out] buffer The output buffer. + * @param [in] bufferLength The size of the output buffer. + */ + virtual void GetImageRGBA(uint32_t imageID, unsigned char* buffer, uint32_t bufferLength) = 0; + + /** + * Register for notifications of a specified type. + * + * @remark Notification types starting "__" are reserved and cannot be used. + * + * @param [in] type The name of the type. + */ + virtual void RegisterForNotification(const char* type) = 0; + + /** + * Reads a specified notification. + * + * @param [in] notificationID The ID of the notification. + * @param [in, out] type The output buffer for the type of the notification. + * @param [in] typeLength The size of the output buffer for the type of the notification. + * @param [in, out] content The output buffer for the content of the notification. + * @param [in] contentSize The size of the output buffer for the content of the notification. + * @return The number of bytes written to the content buffer. + */ + virtual uint32_t GetNotification(NotificationID notificationID, char* type, uint32_t typeLength, void* content, uint32_t contentSize) = 0; + + /** + * Shows web page in the overlay. + * + * @pre For this call to work, the overlay needs to be initialized first. + * To check whether the overlay is initialized, call GetOverlayState(). + * + * @param [in] url The URL address of a specified web page with the limit of 2047 bytes. + */ + virtual void ShowOverlayWithWebPage(const char* url) = 0; + + /** + * Return current visibility of the overlay + * + * @remark IOverlayVisibilityChangeListener might be used to track the overlay + * visibility change. + * + * @pre For this call to work, the overlay needs to be initialized first. + * To check whether the overlay is initialized successfully, call GetOverlayState(). + * + * @return true if the overlay is in front of the game. + */ + virtual bool IsOverlayVisible() = 0; + + /** + * Return current state of the overlay + * + * @remark Basic game functionality should not rely on the overlay state, as the overlay + * may either be switched off by the user, not supported, or may fail to initialize. + * @remark IOverlayInitializationStateChangeListener might be used to track + * the overlay initialization state change. + * + * @pre In order for the overlay to be initialized successfully, first it must be enabled + * by the user in the Galaxy Client, and then successfully injected into the game. + * + * @return State of the overlay. + */ + virtual OverlayState GetOverlayState() = 0; + + /** + * Disable overlay pop-up notifications. + * + * Hides overlay pop-up notifications based on the group specified below: + * - "chat_message" - New chat messages received. + * - "friend_invitation" - Friend request received, new user added to the friend list. + * - "game_invitation" - Game invitation sent or received. + * + * @pre For this call to work, the overlay needs to be initialized first. + * To check whether the overlay is initialized successfully, call IUtils::GetOverlayState(). + * + * @param [in] popupGroup - The name of the notification pop-up group. + */ + virtual void DisableOverlayPopups(const char* popupGroup) = 0; + }; + + /** @} */ + } +} + +#endif diff --git a/Source/DLLs/1.113.3/gog/README.MD b/Source/DLLs/1.113.3/gog/README.MD new file mode 100644 index 00000000..d434061c --- /dev/null +++ b/Source/DLLs/1.113.3/gog/README.MD @@ -0,0 +1,6 @@ +Place here: + +Galaxy.dll +Galaxy64.dll +Galaxy.lib +Galaxy64.lib \ No newline at end of file diff --git a/Source/DLLs/1.113.3/x64/CMakeLists.txt b/Source/DLLs/1.113.3/x64/CMakeLists.txt new file mode 100644 index 00000000..2ea47837 --- /dev/null +++ b/Source/DLLs/1.113.3/x64/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.12) + +add_universelan_executables(${GALAXY_VERSION_NUMBER}) diff --git a/Source/DLLs/1.113.3/x64/UniverseLAN.def b/Source/DLLs/1.113.3/x64/UniverseLAN.def new file mode 100644 index 00000000..be3d931f --- /dev/null +++ b/Source/DLLs/1.113.3/x64/UniverseLAN.def @@ -0,0 +1,14 @@ +LIBRARY +EXPORTS + ??0IGalaxy@api@galaxy@@QEAA@AEBV012@@Z @1 + ??0IGalaxy@api@galaxy@@QEAA@XZ @2 + ??1IGalaxy@api@galaxy@@UEAA@XZ @3 + ??4GalaxyFactory@api@galaxy@@QEAAAEAV012@AEBV012@@Z @4 + ??4IGalaxy@api@galaxy@@QEAAAEAV012@AEBV012@@Z @5 + ??_7IGalaxy@api@galaxy@@6B@ @6 + ?CreateInstance@GalaxyFactory@api@galaxy@@SAPEAVIGalaxy@23@XZ @7 + ?GetErrorManager@GalaxyFactory@api@galaxy@@SAPEAVIErrorManager@23@XZ @8 + ?GetInstance@GalaxyFactory@api@galaxy@@SAPEAVIGalaxy@23@XZ @9 + ?ResetInstance@GalaxyFactory@api@galaxy@@SAXXZ @10 + ?errorManager@GalaxyFactory@api@galaxy@@0PEAVIErrorManager@23@EA @11 + ?instance@GalaxyFactory@api@galaxy@@0PEAVIGalaxy@23@EA @12 diff --git a/Source/DLLs/1.113.3/x86/CMakeLists.txt b/Source/DLLs/1.113.3/x86/CMakeLists.txt new file mode 100644 index 00000000..2ea47837 --- /dev/null +++ b/Source/DLLs/1.113.3/x86/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.12) + +add_universelan_executables(${GALAXY_VERSION_NUMBER}) diff --git a/Source/DLLs/1.113.3/x86/UniverseLAN.def b/Source/DLLs/1.113.3/x86/UniverseLAN.def new file mode 100644 index 00000000..6f971131 --- /dev/null +++ b/Source/DLLs/1.113.3/x86/UniverseLAN.def @@ -0,0 +1,14 @@ +LIBRARY +EXPORTS + ??0IGalaxy@api@galaxy@@QAE@ABV012@@Z @1 + ??0IGalaxy@api@galaxy@@QAE@XZ @2 + ??1IGalaxy@api@galaxy@@UAE@XZ @3 + ??4GalaxyFactory@api@galaxy@@QAEAAV012@ABV012@@Z @4 + ??4IGalaxy@api@galaxy@@QAEAAV012@ABV012@@Z @5 + ??_7IGalaxy@api@galaxy@@6B@ @6 + ?CreateInstance@GalaxyFactory@api@galaxy@@SAPAVIGalaxy@23@XZ @7 + ?GetErrorManager@GalaxyFactory@api@galaxy@@SAPAVIErrorManager@23@XZ @8 + ?GetInstance@GalaxyFactory@api@galaxy@@SAPAVIGalaxy@23@XZ @9 + ?ResetInstance@GalaxyFactory@api@galaxy@@SAXXZ @10 + ?errorManager@GalaxyFactory@api@galaxy@@0PAVIErrorManager@23@A @11 + ?instance@GalaxyFactory@api@galaxy@@0PAVIGalaxy@23@A @12 diff --git a/Source/TestCases/Source/TestCase_JoinLobby.cxx b/Source/TestCases/Source/TestCase_JoinLobby.cxx index eeef83c4..9c11626b 100644 --- a/Source/TestCases/Source/TestCase_JoinLobby.cxx +++ b/Source/TestCases/Source/TestCase_JoinLobby.cxx @@ -25,7 +25,13 @@ bool lobby_joined = false; std::unique_ptr trace{ nullptr }; DelayRunner delay_runner{}; -void OnLobbyList(uint32_t lobbyCount, LobbyListResult result) { +void OnLobbyList(uint32_t lobbyCount +#if GALAXY_BUILD_FEATURE_HAS_IMATCHMAKING_LOBBY_LIST_RESULT + , LobbyListResult result +#else + , bool ioFailure +#endif +) { auto matchmaking_ptr = GET_GALAXY_API(Matchmaking()); if (!lobbyCount) { diff --git a/Source/TestCases/Source/TestCase_JoinLobbyShowData.cxx b/Source/TestCases/Source/TestCase_JoinLobbyShowData.cxx index 6a1fc5fc..195ae501 100644 --- a/Source/TestCases/Source/TestCase_JoinLobbyShowData.cxx +++ b/Source/TestCases/Source/TestCase_JoinLobbyShowData.cxx @@ -25,13 +25,24 @@ bool lobby_joined = false; std::unique_ptr trace{ nullptr }; DelayRunner delay_runner{}; -void OnLobbyList(uint32_t lobbyCount, LobbyListResult result) { +void OnLobbyList(uint32_t lobbyCount +#if GALAXY_BUILD_FEATURE_HAS_IMATCHMAKING_LOBBY_LIST_RESULT + , LobbyListResult result +#else + , bool result +#endif +) { auto matchmaking_ptr = GET_GALAXY_API(Matchmaking()); tracer::Trace::write_all( std::format( "OnLobbyList lobbyCount: {} result: {}", - lobbyCount, magic_enum::enum_name(result) + lobbyCount, +#if GALAXY_BUILD_FEATURE_HAS_IMATCHMAKING_LOBBY_LIST_RESULT + magic_enum::enum_name(result) +#else + result +#endif )); for (uint32_t i = 0; i < lobbyCount; ++i) { diff --git a/Source/TestCases/Source/TestCase_JoinLobbyShowMessages.cxx b/Source/TestCases/Source/TestCase_JoinLobbyShowMessages.cxx index 6437f453..ac93c0e7 100644 --- a/Source/TestCases/Source/TestCase_JoinLobbyShowMessages.cxx +++ b/Source/TestCases/Source/TestCase_JoinLobbyShowMessages.cxx @@ -25,7 +25,13 @@ bool lobby_joined = false; std::unique_ptr trace{ nullptr }; DelayRunner delay_runner{}; -void OnLobbyList(uint32_t lobbyCount, LobbyListResult result) { +void OnLobbyList(uint32_t lobbyCount +#if GALAXY_BUILD_FEATURE_HAS_IMATCHMAKING_LOBBY_LIST_RESULT + , LobbyListResult result +#else + , bool result +#endif +) { auto matchmaking_ptr = GET_GALAXY_API(Matchmaking()); for (uint32_t i = 0; i < lobbyCount; ++i) { diff --git a/Source/TestCases/Source/TestCase_ListLobbiesAndLobbyData.cxx b/Source/TestCases/Source/TestCase_ListLobbiesAndLobbyData.cxx index 4281246f..b2382910 100644 --- a/Source/TestCases/Source/TestCase_ListLobbiesAndLobbyData.cxx +++ b/Source/TestCases/Source/TestCase_ListLobbiesAndLobbyData.cxx @@ -24,13 +24,24 @@ bool user_data_received = true; std::unique_ptr trace{ nullptr }; DelayRunner delay_runner{}; -void OnLobbyList(uint32_t lobbyCount, LobbyListResult result) { +void OnLobbyList(uint32_t lobbyCount +#if GALAXY_BUILD_FEATURE_HAS_IMATCHMAKING_LOBBY_LIST_RESULT + , LobbyListResult result +#else + , bool result +#endif +) { auto matchmaking_ptr = GET_GALAXY_API(Matchmaking()); tracer::Trace::write_all( std::format( "OnLobbyList lobbyCount: {} result: {}", - lobbyCount, magic_enum::enum_name(result) + lobbyCount, +#if GALAXY_BUILD_FEATURE_HAS_IMATCHMAKING_LOBBY_LIST_RESULT + magic_enum::enum_name(result) +#else + result +#endif )); for (uint32_t i = 0; i < lobbyCount; ++i) { @@ -44,7 +55,7 @@ void OnLobbyList(uint32_t lobbyCount, LobbyListResult result) { delay_runner.Add([=]() { matchmaking_ptr->RequestLobbyData(lobby_id); - }); + }); } } @@ -61,7 +72,7 @@ void OnLobbyDataRetrieveSuccess(const GalaxyID& lobbyID) { )); } - std::string result{ matchmaking_ptr->GetLobbyData(lobbyID, "timer")}; + std::string result{ matchmaking_ptr->GetLobbyData(lobbyID, "timer") }; tracer::Trace::write_all( std::format( @@ -110,7 +121,7 @@ void try_init() { auto matchmaking_ptr = GET_GALAXY_API(Matchmaking()); matchmaking_ptr->RequestLobbyList(true); - }); + }); } int main() diff --git a/Source/Vendor/unet.cmake b/Source/Vendor/unet.cmake index d0e9cc0a..7010cca2 100644 --- a/Source/Vendor/unet.cmake +++ b/Source/Vendor/unet.cmake @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.12) function(define_unet_library GALAXY_VERSION GALAXY_VERSION_NUMBER GALAXY_ARCH) - #message("-- define_unet_library Version: ${GALAXY_VERSION}") + message("-- define_unet_library Version: ${GALAXY_VERSION}") add_library(unet-lib-${GALAXY_VERSION} "${CMAKE_SOURCE_DIR}/Source/Vendor/unet/src/Context.cpp" @@ -65,7 +65,7 @@ function(define_unet_library GALAXY_VERSION GALAXY_VERSION_NUMBER GALAXY_ARCH) endif() set_target_properties(unet-lib-${GALAXY_VERSION} PROPERTIES - OUTPUT_NAME "unet-lib-${GALAXY_ARCH}" + OUTPUT_NAME "unet-lib${GALAXY_ARCH}" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/test/${GALAXY_VERSION_NUMBER}/${UNIVERSELAN_EXTRA_BIN_FOLDER}" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/test/${GALAXY_VERSION_NUMBER}/${UNIVERSELAN_EXTRA_BIN_FOLDER}" ) diff --git a/Source/Vendor/unet/include/Unet/Services/ServiceGalaxy.h b/Source/Vendor/unet/include/Unet/Services/ServiceGalaxy.h index 2388ca00..856e2996 100644 --- a/Source/Vendor/unet/include/Unet/Services/ServiceGalaxy.h +++ b/Source/Vendor/unet/include/Unet/Services/ServiceGalaxy.h @@ -14,14 +14,25 @@ namespace Unet class ServiceGalaxy* m_self; }; - class LobbyListListener : public GalaxyListener, public galaxy::api::ILobbyListListener, public galaxy::api::ILobbyDataRetrieveListener + class LobbyListListener : public GalaxyListener +#if GALAXY_BUILD_FEATURE_LOBBY_LISTENERS + , public galaxy::api::ILobbyListListener, public galaxy::api::ILobbyDataRetrieveListener +#else + , public galaxy::api::GlobalLobbyListListener, public galaxy::api::GlobalLobbyDataRetrieveListener +#endif { private: std::vector m_listDataFetch; public: LobbyListListener(ServiceGalaxy* self) { m_self = self; } - virtual void OnLobbyList(uint32_t lobbyCount, galaxy::api::LobbyListResult result) override; + virtual void OnLobbyList(uint32_t lobbyCount +#if GALAXY_BUILD_FEATURE_HAS_IMATCHMAKING_LOBBY_LIST_RESULT + , galaxy::api::LobbyListResult result +#else + , bool ioFailure +#endif + ) override; void LobbyDataUpdated(); virtual void OnLobbyDataRetrieveSuccess(const galaxy::api::GalaxyID& lobbyID) override; virtual void OnLobbyDataRetrieveFailure(const galaxy::api::GalaxyID& lobbyID, FailureReason failureReason) override; @@ -58,37 +69,44 @@ namespace Unet virtual void SetRichPresence(const char* key, const char* value) override; virtual void CreateLobby(LobbyPrivacy privacy, int maxPlayers) override; - virtual void SetLobbyPrivacy(const ServiceID &lobbyId, LobbyPrivacy privacy) override; - virtual void SetLobbyJoinable(const ServiceID &lobbyId, bool joinable) override; + virtual void SetLobbyPrivacy(const ServiceID& lobbyId, LobbyPrivacy privacy) override; + virtual void SetLobbyJoinable(const ServiceID& lobbyId, bool joinable) override; virtual void GetLobbyList() override; - virtual bool FetchLobbyInfo(const ServiceID &id) override; - virtual void JoinLobby(const ServiceID &id) override; + virtual bool FetchLobbyInfo(const ServiceID& id) override; + virtual void JoinLobby(const ServiceID& id) override; virtual void LeaveLobby() override; - virtual int GetLobbyPlayerCount(const ServiceID &lobbyId) override; - virtual void SetLobbyMaxPlayers(const ServiceID &lobbyId, int amount) override; - virtual int GetLobbyMaxPlayers(const ServiceID &lobbyId) override; + virtual int GetLobbyPlayerCount(const ServiceID& lobbyId) override; + virtual void SetLobbyMaxPlayers(const ServiceID& lobbyId, int amount) override; + virtual int GetLobbyMaxPlayers(const ServiceID& lobbyId) override; - virtual std::string GetLobbyData(const ServiceID &lobbyId, const char* name) override; - virtual int GetLobbyDataCount(const ServiceID &lobbyId) override; - virtual LobbyData GetLobbyData(const ServiceID &lobbyId, int index) override; + virtual std::string GetLobbyData(const ServiceID& lobbyId, const char* name) override; + virtual int GetLobbyDataCount(const ServiceID& lobbyId) override; + virtual LobbyData GetLobbyData(const ServiceID& lobbyId, int index) override; - virtual ServiceID GetLobbyHost(const ServiceID &lobbyId) override; + virtual ServiceID GetLobbyHost(const ServiceID& lobbyId) override; - virtual void SetLobbyData(const ServiceID &lobbyId, const char* name, const char* value) override; - virtual void RemoveLobbyData(const ServiceID &lobbyId, const char* name) override; + virtual void SetLobbyData(const ServiceID& lobbyId, const char* name, const char* value) override; + virtual void RemoveLobbyData(const ServiceID& lobbyId, const char* name) override; virtual size_t ReliablePacketLimit() override; - virtual void SendPacket(const ServiceID &peerId, const void* data, size_t size, PacketType type, uint8_t channel) override; + virtual void SendPacket(const ServiceID& peerId, const void* data, size_t size, PacketType type, uint8_t channel) override; virtual size_t ReadPacket(void* data, size_t maxSize, ServiceID* peerId, uint8_t channel) override; virtual bool IsPacketAvailable(size_t* outPacketSize, uint8_t channel) override; private: virtual void OnLobbyCreated(const galaxy::api::GalaxyID& lobbyID, galaxy::api::LobbyCreateResult result) override; virtual void OnLobbyEntered(const galaxy::api::GalaxyID& lobbyID, galaxy::api::LobbyEnterResult result) override; - virtual void OnLobbyLeft(const galaxy::api::GalaxyID& lobbyID, LobbyLeaveReason leaveReason) override; + virtual void OnLobbyLeft(const galaxy::api::GalaxyID& lobbyID +#if GALAXY_BUILD_FEATURE_HAS_IMATCHMAKING_LOBBY_LIST_RESULT + , galaxy::api::LobbyLeaveReason leaveReason +#else + , bool ioFailure +#endif + ) override; + virtual void OnLobbyMemberStateChanged(const galaxy::api::GalaxyID& lobbyID, const galaxy::api::GalaxyID& memberID, galaxy::api::LobbyMemberStateChange memberStateChange) override; virtual void OnLobbyDataRetrieveSuccess(const galaxy::api::GalaxyID& lobbyID) override; virtual void OnLobbyDataRetrieveFailure(const galaxy::api::GalaxyID& lobbyID, FailureReason failureReason) override; diff --git a/Source/Vendor/unet/src/Services/ServiceGalaxy.cpp b/Source/Vendor/unet/src/Services/ServiceGalaxy.cpp index 42bcb831..c8ad4330 100644 --- a/Source/Vendor/unet/src/Services/ServiceGalaxy.cpp +++ b/Source/Vendor/unet/src/Services/ServiceGalaxy.cpp @@ -2,13 +2,24 @@ #include #include -void Unet::LobbyListListener::OnLobbyList(uint32_t lobbyCount, galaxy::api::LobbyListResult result) +void Unet::LobbyListListener::OnLobbyList(uint32_t lobbyCount +#if GALAXY_BUILD_FEATURE_HAS_IMATCHMAKING_LOBBY_LIST_RESULT + , galaxy::api::LobbyListResult result +#else + , bool result +#endif +) { m_self->m_ctx->GetCallbacks()->OnLogDebug(strPrintF("[Galaxy] Lobby list received (%d)", (int)lobbyCount)); m_listDataFetch.clear(); - if (result != galaxy::api::LOBBY_LIST_RESULT_SUCCESS) { +#if GALAXY_BUILD_FEATURE_HAS_IMATCHMAKING_LOBBY_LIST_RESULT + if (result != galaxy::api::LOBBY_LIST_RESULT_SUCCESS) +#else + if (result) +#endif + { m_self->m_requestLobbyList->Code = Result::Error; m_self->m_ctx->GetCallbacks()->OnLogDebug(strPrintF("[Galaxy] Couldn't get lobby list due to error %d", (int)result)); return; @@ -26,9 +37,14 @@ void Unet::LobbyListListener::OnLobbyList(uint32_t lobbyCount, galaxy::api::Lobb } try { - galaxy::api::Matchmaking()->RequestLobbyData(lobbyId, this); + galaxy::api::Matchmaking()->RequestLobbyData(lobbyId +#if GALAXY_BUILD_FEATURE_LOBBY_LISTENERS + , this +#endif + ); m_listDataFetch.emplace_back(lobbyId); - } catch (const galaxy::api::IError &error) { + } + catch (const galaxy::api::IError& error) { m_self->m_ctx->GetCallbacks()->OnLogDebug(strPrintF("[Galaxy] Couldn't get lobby data: %s", error.GetMsg())); } } @@ -100,7 +116,7 @@ void Unet::ServiceGalaxy::SimulateOutage() return; } - auto &lobbyInfo = lobby->GetInfo(); + auto& lobbyInfo = lobby->GetInfo(); auto entryPoint = lobbyInfo.GetEntryPoint(Unet::ServiceType::Galaxy); if (entryPoint == nullptr) { return; @@ -108,7 +124,8 @@ void Unet::ServiceGalaxy::SimulateOutage() try { galaxy::api::Matchmaking()->LeaveLobby(entryPoint->ID); - } catch (const galaxy::api::IError &error) { + } + catch (const galaxy::api::IError& error) { m_ctx->GetCallbacks()->OnLogError(strPrintF("[Galaxy] Failed to simulate outage: %s", error.GetMsg())); } } @@ -144,14 +161,19 @@ void Unet::ServiceGalaxy::CreateLobby(LobbyPrivacy privacy, int maxPlayers) m_requestLobbyCreated = m_ctx->m_callbackCreateLobby.AddServiceRequest(this); try { - galaxy::api::Matchmaking()->CreateLobby(type, maxPlayers, true, galaxy::api::LOBBY_TOPOLOGY_TYPE_FCM, this); - } catch (const galaxy::api::IError &error) { + galaxy::api::Matchmaking()->CreateLobby(type, maxPlayers, true, galaxy::api::LOBBY_TOPOLOGY_TYPE_FCM +#if GALAXY_BUILD_FEATURE_LOBBY_LISTENERS + , this +#endif + ); + } + catch (const galaxy::api::IError& error) { m_requestLobbyCreated->Code = Result::Error; m_ctx->GetCallbacks()->OnLogDebug(strPrintF("[Galaxy] Failed to create lobby: %s", error.GetMsg())); } } -void Unet::ServiceGalaxy::SetLobbyPrivacy(const ServiceID &lobbyId, LobbyPrivacy privacy) +void Unet::ServiceGalaxy::SetLobbyPrivacy(const ServiceID& lobbyId, LobbyPrivacy privacy) { galaxy::api::LobbyType type = galaxy::api::LOBBY_TYPE_PUBLIC; switch (privacy) { @@ -162,17 +184,19 @@ void Unet::ServiceGalaxy::SetLobbyPrivacy(const ServiceID &lobbyId, LobbyPrivacy assert(lobbyId.Service == ServiceType::Galaxy); try { galaxy::api::Matchmaking()->SetLobbyType(lobbyId.ID, type); - } catch (const galaxy::api::IError &error) { + } + catch (const galaxy::api::IError& error) { m_ctx->GetCallbacks()->OnLogDebug(strPrintF("[Galaxy] Failed to set lobby privacy: %s", error.GetMsg())); } } -void Unet::ServiceGalaxy::SetLobbyJoinable(const ServiceID &lobbyId, bool joinable) +void Unet::ServiceGalaxy::SetLobbyJoinable(const ServiceID& lobbyId, bool joinable) { assert(lobbyId.Service == ServiceType::Galaxy); try { galaxy::api::Matchmaking()->SetLobbyJoinable(lobbyId.ID, joinable); - } catch (const galaxy::api::IError &error) { + } + catch (const galaxy::api::IError& error) { m_ctx->GetCallbacks()->OnLogDebug(strPrintF("[Galaxy] Failed to make lobby joinable: %s", error.GetMsg())); } } @@ -182,36 +206,51 @@ void Unet::ServiceGalaxy::GetLobbyList() m_requestLobbyList = m_ctx->m_callbackLobbyList.AddServiceRequest(this); try { - galaxy::api::Matchmaking()->RequestLobbyList(false, &m_lobbyListListener); - } catch (const galaxy::api::IError &error) { + galaxy::api::Matchmaking()->RequestLobbyList(false +#if GALAXY_BUILD_FEATURE_LOBBY_LISTENERS + , & m_lobbyListListener +#endif + ); + } + catch (const galaxy::api::IError& error) { m_requestLobbyList->Code = Result::Error; m_ctx->GetCallbacks()->OnLogDebug(strPrintF("[Galaxy] Failed to list lobbies: %s", error.GetMsg())); } } -bool Unet::ServiceGalaxy::FetchLobbyInfo(const ServiceID &id) +bool Unet::ServiceGalaxy::FetchLobbyInfo(const ServiceID& id) { assert(id.Service == ServiceType::Galaxy); try { - galaxy::api::Matchmaking()->RequestLobbyData(id.ID, this); + galaxy::api::Matchmaking()->RequestLobbyData(id.ID +#if GALAXY_BUILD_FEATURE_LOBBY_LISTENERS + , this +#endif + ); m_dataFetch.emplace_back(id.ID); return true; - } catch (const galaxy::api::IError &error) { + } + catch (const galaxy::api::IError& error) { m_ctx->GetCallbacks()->OnLogDebug(strPrintF("[Galaxy] Failed to fetch lobby info: %s", error.GetMsg())); return false; } } -void Unet::ServiceGalaxy::JoinLobby(const ServiceID &id) +void Unet::ServiceGalaxy::JoinLobby(const ServiceID& id) { assert(id.Service == ServiceType::Galaxy); m_requestLobbyJoin = m_ctx->m_callbackLobbyJoin.AddServiceRequest(this); try { - galaxy::api::Matchmaking()->JoinLobby(id.ID, this); - } catch (const galaxy::api::IError &error) { + galaxy::api::Matchmaking()->JoinLobby(id.ID +#if GALAXY_BUILD_FEATURE_LOBBY_LISTENERS + , this +#endif + ); + } + catch (const galaxy::api::IError& error) { m_requestLobbyJoin->Code = Result::Error; m_ctx->GetCallbacks()->OnLogDebug(strPrintF("[Galaxy] Failed to join lobby: %s", error.GetMsg())); } @@ -224,7 +263,7 @@ void Unet::ServiceGalaxy::LeaveLobby() return; } - auto &lobbyInfo = lobby->GetInfo(); + auto& lobbyInfo = lobby->GetInfo(); auto entryPoint = lobbyInfo.GetEntryPoint(Unet::ServiceType::Galaxy); if (entryPoint == nullptr) { return; @@ -233,49 +272,54 @@ void Unet::ServiceGalaxy::LeaveLobby() m_requestLobbyLeft = m_ctx->m_callbackLobbyLeft.AddServiceRequest(this); try { - galaxy::api::Matchmaking()->LeaveLobby(entryPoint->ID, this); - } catch (const galaxy::api::IError &error) { + galaxy::api::Matchmaking()->LeaveLobby(entryPoint->ID +#if GALAXY_BUILD_FEATURE_LOBBY_LISTENERS + , this +#endif + ); + } + catch (const galaxy::api::IError& error) { m_requestLobbyLeft->Code = Result::Error; m_ctx->GetCallbacks()->OnLogError(strPrintF("[Galaxy] Failed to leave lobby: %s", error.GetMsg())); } } -int Unet::ServiceGalaxy::GetLobbyPlayerCount(const ServiceID &lobbyId) +int Unet::ServiceGalaxy::GetLobbyPlayerCount(const ServiceID& lobbyId) { assert(lobbyId.Service == ServiceType::Galaxy); return galaxy::api::Matchmaking()->GetNumLobbyMembers(lobbyId.ID); } -void Unet::ServiceGalaxy::SetLobbyMaxPlayers(const ServiceID &lobbyId, int amount) +void Unet::ServiceGalaxy::SetLobbyMaxPlayers(const ServiceID& lobbyId, int amount) { assert(lobbyId.Service == ServiceType::Galaxy); galaxy::api::Matchmaking()->SetMaxNumLobbyMembers(lobbyId.ID, amount); } -int Unet::ServiceGalaxy::GetLobbyMaxPlayers(const ServiceID &lobbyId) +int Unet::ServiceGalaxy::GetLobbyMaxPlayers(const ServiceID& lobbyId) { assert(lobbyId.Service == ServiceType::Galaxy); return (int)galaxy::api::Matchmaking()->GetMaxNumLobbyMembers(lobbyId.ID); } -std::string Unet::ServiceGalaxy::GetLobbyData(const ServiceID &lobbyId, const char* name) +std::string Unet::ServiceGalaxy::GetLobbyData(const ServiceID& lobbyId, const char* name) { assert(lobbyId.Service == ServiceType::Galaxy); return galaxy::api::Matchmaking()->GetLobbyData(lobbyId.ID, name); } -int Unet::ServiceGalaxy::GetLobbyDataCount(const ServiceID &lobbyId) +int Unet::ServiceGalaxy::GetLobbyDataCount(const ServiceID& lobbyId) { assert(lobbyId.Service == ServiceType::Galaxy); return galaxy::api::Matchmaking()->GetLobbyDataCount(lobbyId.ID); } -Unet::LobbyData Unet::ServiceGalaxy::GetLobbyData(const ServiceID &lobbyId, int index) +Unet::LobbyData Unet::ServiceGalaxy::GetLobbyData(const ServiceID& lobbyId, int index) { assert(lobbyId.Service == ServiceType::Galaxy); @@ -291,21 +335,21 @@ Unet::LobbyData Unet::ServiceGalaxy::GetLobbyData(const ServiceID &lobbyId, int return ret; } -Unet::ServiceID Unet::ServiceGalaxy::GetLobbyHost(const ServiceID &lobbyId) +Unet::ServiceID Unet::ServiceGalaxy::GetLobbyHost(const ServiceID& lobbyId) { assert(lobbyId.Service == ServiceType::Galaxy); return ServiceID(ServiceType::Galaxy, galaxy::api::Matchmaking()->GetLobbyOwner(lobbyId.ID).ToUint64()); } -void Unet::ServiceGalaxy::SetLobbyData(const ServiceID &lobbyId, const char* name, const char* value) +void Unet::ServiceGalaxy::SetLobbyData(const ServiceID& lobbyId, const char* name, const char* value) { assert(lobbyId.Service == ServiceType::Galaxy); galaxy::api::Matchmaking()->SetLobbyData(lobbyId.ID, name, value); } -void Unet::ServiceGalaxy::RemoveLobbyData(const ServiceID &lobbyId, const char* name) +void Unet::ServiceGalaxy::RemoveLobbyData(const ServiceID& lobbyId, const char* name) { assert(lobbyId.Service == ServiceType::Galaxy); @@ -317,7 +361,7 @@ size_t Unet::ServiceGalaxy::ReliablePacketLimit() return 0; } -void Unet::ServiceGalaxy::SendPacket(const ServiceID &peerId, const void* data, size_t size, PacketType type, uint8_t channel) +void Unet::ServiceGalaxy::SendPacket(const ServiceID& peerId, const void* data, size_t size, PacketType type, uint8_t channel) { assert(peerId.Service == ServiceType::Galaxy); @@ -397,14 +441,20 @@ void Unet::ServiceGalaxy::OnLobbyEntered(const galaxy::api::GalaxyID& lobbyID, g m_ctx->GetCallbacks()->OnLogDebug("[Galaxy] Handshake sent"); } -void Unet::ServiceGalaxy::OnLobbyLeft(const galaxy::api::GalaxyID& lobbyID, LobbyLeaveReason leaveReason) +void Unet::ServiceGalaxy::OnLobbyLeft(const galaxy::api::GalaxyID& lobbyID +#if GALAXY_BUILD_FEATURE_HAS_IMATCHMAKING_LOBBY_LIST_RESULT + , galaxy::api::LobbyLeaveReason leaveReason +#else +, bool result +#endif +) { auto currentLobby = m_ctx->CurrentLobby(); if (currentLobby == nullptr) { return; } - auto &lobbyInfo = currentLobby->GetInfo(); + auto& lobbyInfo = currentLobby->GetInfo(); auto entryPoint = lobbyInfo.GetEntryPoint(ServiceType::Galaxy); if (entryPoint == nullptr) { return; @@ -414,9 +464,15 @@ void Unet::ServiceGalaxy::OnLobbyLeft(const galaxy::api::GalaxyID& lobbyID, Lobb return; } - if (leaveReason == LOBBY_LEAVE_REASON_USER_LEFT) { +#if GALAXY_BUILD_FEATURE_HAS_IMATCHMAKING_LOBBY_LIST_RESULT + if (leaveReason == LOBBY_LEAVE_REASON_USER_LEFT) +#else + if(!result) +#endif + { m_requestLobbyLeft->Code = Result::OK; - } else { + } + else { currentLobby->ServiceDisconnected(ServiceType::Galaxy); } } @@ -428,7 +484,7 @@ void Unet::ServiceGalaxy::OnLobbyMemberStateChanged(const galaxy::api::GalaxyID& return; } - auto &lobbyInfo = currentLobby->GetInfo(); + auto& lobbyInfo = currentLobby->GetInfo(); auto entryPoint = lobbyInfo.GetEntryPoint(ServiceType::Galaxy); if (entryPoint == nullptr) { return; @@ -438,9 +494,10 @@ void Unet::ServiceGalaxy::OnLobbyMemberStateChanged(const galaxy::api::GalaxyID& return; } - if (memberStateChange == galaxy::api::LOBBY_MEMBER_STATE_CHANGED_ENTERED) { + if (memberStateChange & galaxy::api::LOBBY_MEMBER_STATE_CHANGED_ENTERED) { m_ctx->GetCallbacks()->OnLogDebug(strPrintF("[Galaxy] Player entered: 0x%016llX", memberID.ToUint64())); - } else { + } + else { m_ctx->GetCallbacks()->OnLogDebug(strPrintF("[Galaxy] Player left: 0x%016llX (code %X)", memberID.ToUint64(), memberStateChange)); currentLobby->RemoveMemberService(ServiceID(ServiceType::Galaxy, memberID.ToUint64())); diff --git a/Util/.gitignore b/Util/.gitignore new file mode 100644 index 00000000..ed6b11fd --- /dev/null +++ b/Util/.gitignore @@ -0,0 +1,4 @@ +dumpbin.exe +link.exe +mspdbcore.dll +tbbmalloc.dll diff --git a/Util/README.md b/Util/README.md new file mode 100644 index 00000000..77d79f28 --- /dev/null +++ b/Util/README.md @@ -0,0 +1,20 @@ +# Def DLL + +A tool to generate module definition files + +## Example + +```shell +python3 def_dll.py C:\Windows\System32\AudioSes.dll +``` + +# Required files +``` +dumpbin.exe +link.exe +mspdbcore.dll +tbbmalloc.dll +``` + +Download [here](https://github.com/grasmanek94/UniverseLAN/files/15138422/tools-binaries.zip). +Or run `setup_def_dll_tools.ps1` diff --git a/Util/def_dll.py b/Util/def_dll.py new file mode 100644 index 00000000..461e3a19 --- /dev/null +++ b/Util/def_dll.py @@ -0,0 +1,88 @@ +# MIT License +# +# Copyright (c) 2018 Lin Min +# Modified by RafaƂ 'grasmanek94' Grasman - Copyright 2024 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import os +import sys +import shutil +import tempfile +import argparse +import subprocess + +parser = argparse.ArgumentParser(description="make dll wrapper") +parser.add_argument("--dumpbin", type=str, default="dumpbin.exe", + help="The path to dumpbin.exe provided by visual studio") +parser.add_argument("dll", type=str, help="The path to the dll file to wrap") +args = parser.parse_args() + +def extract_symbols(dll): + output = subprocess.check_output([ + args.dumpbin, "/EXPORTS", dll + ]) + output = output.decode("utf-8") + lines = output.split("\r\n") + start, end = None, None + start = next(idx for idx, line in enumerate(lines) + if all(map(lambda entry: (entry in line), + ["ordinal", "hint", "RVA", "name"]))) + 2 + lines = lines[start:] + end = next(idx for idx, line in enumerate(lines) if line == "") + lines = lines[:end] + if len(lines) == 0: + raise RuntimeError(f"No exported symbols for {dll}") + ordinal_name_pairs = [] + for line in lines: + if "(forwarded" in line: + ordinal, hint, name, *others = line.split() + elif "[NONAME]" in line: + ordinal, RVA, name, *others = line.split() + else: + ordinal, hint, RVA, name, *others = line.split() + ordinal_name_pairs.append((ordinal, name)) + return ordinal_name_pairs + +def write_file(filename, content): + with open(filename, "w") as f: + f.write(content) + +if __name__ == "__main__": + if shutil.which(args.dumpbin) is None: + raise RuntimeError("dumpbin.exe not found in PATH, " + "maybe specify its path through the --dumpbin argument?") + if not os.path.isfile(args.dll): + raise RuntimeError(f"{args.dll} is not a valid file") + + dll_name = args.dll[:-4] + ordinal_name_pairs = extract_symbols(args.dll) + ordinals = [ordinal for ordinal, _ in ordinal_name_pairs] + names = [name for _, name in ordinal_name_pairs] + ordinal_and_names = list(zip(ordinals, names)) + + # write files + def_content = f"LIBRARY\n" + def_content += f"EXPORTS\n" + for ordinal, symbol in ordinal_and_names: + #if name == '[NONAME]': + # def_content += f" ExportByOrdinal{ ordinal } @{ ordinal } NONAME\n" + #else: + def_content += f" { symbol } @{ ordinal }\n" + write_file(f"{dll_name}.def", def_content) diff --git a/Util/def_dll_drag_drop.bat b/Util/def_dll_drag_drop.bat new file mode 100644 index 00000000..82ff19d5 --- /dev/null +++ b/Util/def_dll_drag_drop.bat @@ -0,0 +1,4 @@ +@echo off +cd /d "%~dp0" +python3 "def_dll.py" "%1" +pause \ No newline at end of file diff --git a/Util/setup_def_dll_tools.ps1 b/Util/setup_def_dll_tools.ps1 new file mode 100644 index 00000000..c60ef53b --- /dev/null +++ b/Util/setup_def_dll_tools.ps1 @@ -0,0 +1,3 @@ +Invoke-WebRequest "https://github.com/grasmanek94/UniverseLAN/files/15138422/tools-binaries.zip" -OutFile "tools-binaries.zip" +Expand-Archive "tools-binaries.zip" -DestinationPath "." +Remove-Item "tools-binaries.zip" \ No newline at end of file