mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2025-08-07 16:15:51 +02:00
Merge pull request #297 from otavepto/patch/sapps
Fix old `Steam_Apps::FillProofOfPurchaseKey()`
This commit is contained in:
commit
b7983dcda7
5 changed files with 97 additions and 35 deletions
|
@ -33,6 +33,9 @@ public ISteamApps
|
||||||
class Settings *settings{};
|
class Settings *settings{};
|
||||||
class SteamCallResults *callback_results{};
|
class SteamCallResults *callback_results{};
|
||||||
class SteamCallBacks *callbacks{};
|
class SteamCallBacks *callbacks{};
|
||||||
|
|
||||||
|
void FillProofOfPurchaseKey( AppProofOfPurchaseKeyResponse_t& data, AppId_t nAppID, bool ok_result, std::string key = "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" );
|
||||||
|
void FillProofOfPurchaseKey( AppProofOfPurchaseKeyResponse007_t& data, AppId_t nAppID, bool ok_result, std::string key = "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Steam_Apps(Settings *settings, class SteamCallResults *callback_results, class SteamCallBacks *callbacks);
|
Steam_Apps(Settings *settings, class SteamCallResults *callback_results, class SteamCallBacks *callbacks);
|
||||||
|
@ -83,6 +86,7 @@ public:
|
||||||
// You'll receive an AppProofOfPurchaseKeyResponse_t callback when
|
// You'll receive an AppProofOfPurchaseKeyResponse_t callback when
|
||||||
// the key is available (which may be immediately).
|
// the key is available (which may be immediately).
|
||||||
void RequestAppProofOfPurchaseKey( AppId_t nAppID );
|
void RequestAppProofOfPurchaseKey( AppId_t nAppID );
|
||||||
|
void RequestAppProofOfPurchaseKey_OLD( AppId_t nAppID );
|
||||||
|
|
||||||
bool GetCurrentBetaName( char *pchName, int cchNameBufferSize ); // returns current beta branch name, 'public' is the default branch
|
bool GetCurrentBetaName( char *pchName, int cchNameBufferSize ); // returns current beta branch name, 'public' is the default branch
|
||||||
bool MarkContentCorrupt( bool bMissingFilesOnly ); // signal Steam that game files seems corrupt or missing
|
bool MarkContentCorrupt( bool bMissingFilesOnly ); // signal Steam that game files seems corrupt or missing
|
||||||
|
|
|
@ -18,6 +18,50 @@
|
||||||
#include "dll/steam_apps.h"
|
#include "dll/steam_apps.h"
|
||||||
#include "sha/sha1.hpp"
|
#include "sha/sha1.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
void Steam_Apps::FillProofOfPurchaseKey( AppProofOfPurchaseKeyResponse_t& data, AppId_t nAppID, bool ok_result, std::string key )
|
||||||
|
{
|
||||||
|
data.m_nAppID = nAppID;
|
||||||
|
if (ok_result) {
|
||||||
|
// TODO maybe read this from a config file "purchased_keys.txt":
|
||||||
|
// 480=AAAAA-BBBBB-CCCCC-DDDDD
|
||||||
|
// 218620=XYZFJ-13370-98765
|
||||||
|
size_t min_len = key.size() < k_cubAppProofOfPurchaseKeyMax
|
||||||
|
? key.size()
|
||||||
|
: k_cubAppProofOfPurchaseKeyMax - 1; // -1 because we need space for null
|
||||||
|
data.m_eResult = EResult::k_EResultOK;
|
||||||
|
data.m_cchKeyLength = static_cast<uint32>(min_len);
|
||||||
|
memcpy(data.m_rgchKey, key.c_str(), min_len);
|
||||||
|
data.m_rgchKey[min_len] = 0;
|
||||||
|
} else {
|
||||||
|
data.m_eResult = EResult::k_EResultFail;
|
||||||
|
data.m_cchKeyLength = 0;
|
||||||
|
data.m_rgchKey[0] = 0;
|
||||||
|
data.m_rgchKey[1] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Steam_Apps::FillProofOfPurchaseKey( AppProofOfPurchaseKeyResponse007_t& data, AppId_t nAppID, bool ok_result, std::string key )
|
||||||
|
{
|
||||||
|
data.m_nAppID = nAppID;
|
||||||
|
if (ok_result) {
|
||||||
|
// TODO maybe read this from a config file "purchased_keys.txt":
|
||||||
|
// 480=AAAAA-BBBBB-CCCCC-DDDDD
|
||||||
|
// 218620=XYZFJ-13370-98765
|
||||||
|
size_t min_len = key.size() < k_cubAppProofOfPurchaseKeyMax
|
||||||
|
? key.size()
|
||||||
|
: k_cubAppProofOfPurchaseKeyMax - 1; // -1 because we need space for null
|
||||||
|
data.m_eResult = EResult::k_EResultOK;
|
||||||
|
memcpy(data.m_rgchKey, key.c_str(), min_len);
|
||||||
|
data.m_rgchKey[min_len] = 0;
|
||||||
|
} else {
|
||||||
|
data.m_eResult = EResult::k_EResultFail;
|
||||||
|
data.m_rgchKey[0] = 0;
|
||||||
|
data.m_rgchKey[1] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Steam_Apps::Steam_Apps(Settings *settings, class SteamCallResults *callback_results, class SteamCallBacks *callbacks)
|
Steam_Apps::Steam_Apps(Settings *settings, class SteamCallResults *callback_results, class SteamCallBacks *callbacks)
|
||||||
{
|
{
|
||||||
this->settings = settings;
|
this->settings = settings;
|
||||||
|
@ -220,28 +264,6 @@ void Steam_Apps::UninstallDLC( AppId_t nAppID )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void FillProofOfPurchaseKey( AppProofOfPurchaseKeyResponse_t& data, AppId_t nAppID, bool ok_result, std::string key = "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" )
|
|
||||||
{
|
|
||||||
data.m_nAppID = nAppID;
|
|
||||||
if (ok_result) {
|
|
||||||
// TODO maybe read this from a config file "purchased_keys.txt":
|
|
||||||
// 480=AAAAA-BBBBB-CCCCC-DDDDD
|
|
||||||
// 218620=XYZFJ-13370-98765
|
|
||||||
size_t min_len = key.size() < k_cubAppProofOfPurchaseKeyMax
|
|
||||||
? key.size() < k_cubAppProofOfPurchaseKeyMax
|
|
||||||
: k_cubAppProofOfPurchaseKeyMax - 1; // -1 because we need space for null
|
|
||||||
data.m_eResult = EResult::k_EResultOK;
|
|
||||||
data.m_cchKeyLength = static_cast<uint32>(min_len);
|
|
||||||
memcpy(data.m_rgchKey, key.c_str(), min_len);
|
|
||||||
data.m_rgchKey[min_len] = 0;
|
|
||||||
} else {
|
|
||||||
data.m_eResult = EResult::k_EResultFail;
|
|
||||||
data.m_cchKeyLength = 0;
|
|
||||||
data.m_rgchKey[0] = 0;
|
|
||||||
data.m_rgchKey[1] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request legacy cd-key for yourself or owned DLC. If you are interested in this
|
// Request legacy cd-key for yourself or owned DLC. If you are interested in this
|
||||||
// data then make sure you provide us with a list of valid keys to be distributed
|
// data then make sure you provide us with a list of valid keys to be distributed
|
||||||
// to users when they purchase the game, before the game ships.
|
// to users when they purchase the game, before the game ships.
|
||||||
|
@ -268,6 +290,28 @@ void Steam_Apps::RequestAppProofOfPurchaseKey( AppId_t nAppID )
|
||||||
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
|
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Steam_Apps::RequestAppProofOfPurchaseKey_OLD( AppId_t nAppID )
|
||||||
|
{
|
||||||
|
PRINT_DEBUG_TODO();
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||||
|
|
||||||
|
AppProofOfPurchaseKeyResponse007_t data{};
|
||||||
|
data.m_nAppID = nAppID;
|
||||||
|
|
||||||
|
// check Steam_Apps::BIsAppInstalled()
|
||||||
|
if (nAppID == 0 || nAppID == UINT32_MAX) {
|
||||||
|
FillProofOfPurchaseKey(data, nAppID, false);
|
||||||
|
} else if (nAppID == settings->get_local_game_id().AppID() || settings->hasDLC(nAppID)) {
|
||||||
|
FillProofOfPurchaseKey(data, nAppID, true);
|
||||||
|
} else {
|
||||||
|
//TODO what to do here?
|
||||||
|
FillProofOfPurchaseKey(data, nAppID, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// returns current beta branch name, 'public' is the default branch
|
// returns current beta branch name, 'public' is the default branch
|
||||||
// "true if the user is on a beta branch; otherwise, false"
|
// "true if the user is on a beta branch; otherwise, false"
|
||||||
// https://partner.steamgames.com/doc/api/ISteamApps
|
// https://partner.steamgames.com/doc/api/ISteamApps
|
||||||
|
@ -423,15 +467,15 @@ void Steam_Apps::RequestAllProofOfPurchaseKeys()
|
||||||
|
|
||||||
// DLCs
|
// DLCs
|
||||||
const auto count = settings->DLCCount();
|
const auto count = settings->DLCCount();
|
||||||
for (unsigned int i = 0; i < settings->DLCCount(); i++) {
|
for (unsigned i = 0; i < settings->DLCCount(); i++) {
|
||||||
AppId_t app_id;
|
AppId_t app_id{};
|
||||||
bool available;
|
bool available{};
|
||||||
std::string name;
|
std::string name{};
|
||||||
settings->getDLC(i, app_id, available, name);
|
if (settings->getDLC(i, app_id, available, name)) {
|
||||||
|
AppProofOfPurchaseKeyResponse_t data{};
|
||||||
AppProofOfPurchaseKeyResponse_t data{};
|
FillProofOfPurchaseKey(data, app_id, true);
|
||||||
FillProofOfPurchaseKey(data, app_id, true);
|
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
|
||||||
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// termination entry
|
// termination entry
|
||||||
|
@ -454,7 +498,7 @@ SteamAPICall_t Steam_Apps::GetFileDetails( const char* pszFileName )
|
||||||
if (file_exists_(pszFileName)) {
|
if (file_exists_(pszFileName)) {
|
||||||
data.m_eResult = k_EResultOK; //
|
data.m_eResult = k_EResultOK; //
|
||||||
std::ifstream stream(std::filesystem::u8path(pszFileName), std::ios::binary);
|
std::ifstream stream(std::filesystem::u8path(pszFileName), std::ios::binary);
|
||||||
SHA1 checksum;
|
SHA1 checksum{};
|
||||||
checksum.update(stream);
|
checksum.update(stream);
|
||||||
checksum.final().copy((char *)data.m_FileSHA, sizeof(data.m_FileSHA));
|
checksum.final().copy((char *)data.m_FileSHA, sizeof(data.m_FileSHA));
|
||||||
data.m_ulFileSize = file_size_(pszFileName);
|
data.m_ulFileSize = file_size_(pszFileName);
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
// to users when they purchase the game, before the game ships.
|
// to users when they purchase the game, before the game ships.
|
||||||
// You'll receive an AppProofOfPurchaseKeyResponse_t callback when
|
// You'll receive an AppProofOfPurchaseKeyResponse_t callback when
|
||||||
// the key is available (which may be immediately).
|
// the key is available (which may be immediately).
|
||||||
virtual void RequestAppProofOfPurchaseKey( AppId_t nAppID ) = 0;
|
virtual void RequestAppProofOfPurchaseKey_OLD( AppId_t nAppID ) = 0;
|
||||||
|
|
||||||
virtual bool GetCurrentBetaName( char *pchName, int cchNameBufferSize ) = 0; // returns current beta branch name, 'public' is the default branch
|
virtual bool GetCurrentBetaName( char *pchName, int cchNameBufferSize ) = 0; // returns current beta branch name, 'public' is the default branch
|
||||||
virtual bool MarkContentCorrupt( bool bMissingFilesOnly ) = 0; // signal Steam that game files seems corrupt or missing
|
virtual bool MarkContentCorrupt( bool bMissingFilesOnly ) = 0; // signal Steam that game files seems corrupt or missing
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
// to users when they purchase the game, before the game ships.
|
// to users when they purchase the game, before the game ships.
|
||||||
// You'll receive an AppProofOfPurchaseKeyResponse_t callback when
|
// You'll receive an AppProofOfPurchaseKeyResponse_t callback when
|
||||||
// the key is available (which may be immediately).
|
// the key is available (which may be immediately).
|
||||||
virtual void RequestAppProofOfPurchaseKey( AppId_t nAppID ) = 0;
|
virtual void RequestAppProofOfPurchaseKey_OLD( AppId_t nAppID ) = 0;
|
||||||
|
|
||||||
virtual bool GetCurrentBetaName( char *pchName, int cchNameBufferSize ) = 0; // returns current beta branch name, 'public' is the default branch
|
virtual bool GetCurrentBetaName( char *pchName, int cchNameBufferSize ) = 0; // returns current beta branch name, 'public' is the default branch
|
||||||
virtual bool MarkContentCorrupt( bool bMissingFilesOnly ) = 0; // signal Steam that game files seems corrupt or missing
|
virtual bool MarkContentCorrupt( bool bMissingFilesOnly ) = 0; // signal Steam that game files seems corrupt or missing
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
// to users when they purchase the game, before the game ships.
|
// to users when they purchase the game, before the game ships.
|
||||||
// You'll receive an AppProofOfPurchaseKeyResponse_t callback when
|
// You'll receive an AppProofOfPurchaseKeyResponse_t callback when
|
||||||
// the key is available (which may be immediately).
|
// the key is available (which may be immediately).
|
||||||
virtual void RequestAppProofOfPurchaseKey( AppId_t nAppID ) = 0;
|
virtual void RequestAppProofOfPurchaseKey_OLD( AppId_t nAppID ) = 0;
|
||||||
|
|
||||||
virtual bool GetCurrentBetaName( char *pchName, int cchNameBufferSize ) = 0; // returns current beta branch name, 'public' is the default branch
|
virtual bool GetCurrentBetaName( char *pchName, int cchNameBufferSize ) = 0; // returns current beta branch name, 'public' is the default branch
|
||||||
virtual bool MarkContentCorrupt( bool bMissingFilesOnly ) = 0; // signal Steam that game files seems corrupt or missing
|
virtual bool MarkContentCorrupt( bool bMissingFilesOnly ) = 0; // signal Steam that game files seems corrupt or missing
|
||||||
|
@ -69,4 +69,18 @@ public:
|
||||||
virtual int GetAppBuildId() = 0;
|
virtual int GetAppBuildId() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: response to RegisterActivationCode()
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
struct AppProofOfPurchaseKeyResponse007_t
|
||||||
|
{
|
||||||
|
enum { k_iCallback = k_iSteamAppsCallbacks + 13 };
|
||||||
|
EResult m_eResult;
|
||||||
|
uint32 m_nAppID;
|
||||||
|
char m_rgchKey[ k_cubAppProofOfPurchaseKeyMax ];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //ISTEAMAPPS007_H
|
#endif //ISTEAMAPPS007_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue