Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/Exports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "api\IServer.hh"
#include "api\impl\OfflineServer.hh"

#include "context\IRcClient.hh"

#include "data\context\ConsoleContext.hh"
#include "data\context\EmulatorContext.hh"
#include "data\context\GameContext.hh"
Expand All @@ -25,6 +27,7 @@
#include "services\Initialization.hh"
#include "services\PerformanceCounter.hh"
#include "services\ServiceLocator.hh"
#include "services\impl\OfflineRcClient.hh"

#include "ui\drawing\gdi\GDISurface.hh"
#include "ui\viewmodels\IntegrationMenuViewModel.hh"
Expand Down Expand Up @@ -96,6 +99,7 @@ static void InitializeOfflineMode()
pConfiguration.SetFeatureEnabled(ra::services::Feature::Offline, true);

ra::services::ServiceLocator::Provide<ra::api::IServer>(std::make_unique<ra::api::impl::OfflineServer>());
ra::services::ServiceLocator::Provide<ra::context::IRcClient>(std::make_unique<ra::services::impl::OfflineRcClient>());

auto& pUserContext = ra::services::ServiceLocator::GetMutable<ra::data::context::UserContext>();
const auto& sUsername = pConfiguration.GetUsername();
Expand All @@ -111,7 +115,7 @@ static void InitializeOfflineMode()
pSessionTracker.Initialize(sUsername);
}

auto* pClient = ra::services::ServiceLocator::Get<ra::services::AchievementRuntime>().GetClient();
auto* pClient = ra::services::ServiceLocator::Get<ra::context::IRcClient>().GetClient();
pClient->user.username = rc_buffer_strcpy(&pClient->state.buffer, pUserContext.GetUsername().c_str());
pClient->user.display_name = rc_buffer_strcpy(&pClient->state.buffer, pUserContext.GetDisplayName().c_str());
pClient->user.token = rc_buffer_strcpy(&pClient->state.buffer, pConfiguration.GetApiToken().c_str());
Expand Down Expand Up @@ -369,13 +373,13 @@ API void CCONV _RA_AttemptLogin(int bBlocking)
}
else
{
auto& pClient = ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>();
auto& pRuntime = ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>();

if (bBlocking)
{
ra::services::AchievementRuntime::Synchronizer pSynchronizer;

pClient.BeginLoginWithToken(pConfiguration.GetUsername(), pConfiguration.GetApiToken(),
pRuntime.BeginLoginWithToken(pConfiguration.GetUsername(), pConfiguration.GetApiToken(),
[](int nResult, const char* sErrorMessage, rc_client_t*, void* pUserdata) {
auto* pSynchronizer = static_cast<ra::services::AchievementRuntime::Synchronizer*>(pUserdata);
Expects(pSynchronizer != nullptr);
Expand All @@ -387,13 +391,14 @@ API void CCONV _RA_AttemptLogin(int bBlocking)

pSynchronizer.Wait();

auto* pClient = ra::services::ServiceLocator::Get<ra::context::IRcClient>().GetClient();
HandleLoginResponse(pSynchronizer.GetResult(), pSynchronizer.GetErrorMessage().c_str(),
pClient.GetClient(), nullptr);
pClient, nullptr);
}
else
{
pClient.BeginLoginWithToken(pConfiguration.GetUsername(), pConfiguration.GetApiToken(),
HandleLoginResponse, static_cast<void*>(nullptr));
pRuntime.BeginLoginWithToken(pConfiguration.GetUsername(), pConfiguration.GetApiToken(),
HandleLoginResponse, static_cast<void*>(nullptr));
}
}
}
Expand Down Expand Up @@ -497,7 +502,7 @@ API void CCONV _RA_SetPaused(int bIsPaused)
{
if (bIsPaused)
{
auto* pClient = ra::services::ServiceLocator::Get<ra::services::AchievementRuntime>().GetClient();
auto* pClient = ra::services::ServiceLocator::Get<ra::context::IRcClient>().GetClient();
if (!rc_client_can_pause(pClient, nullptr))
{
ra::services::ServiceLocator::Get<ra::data::context::EmulatorContext>().Unpause();
Expand Down
4 changes: 3 additions & 1 deletion src/RA_Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "Exports.hh"

#include "context\IRcClient.hh"

#include "util\Log.hh"

#include "data\context\SessionTracker.hh"
Expand Down Expand Up @@ -148,7 +150,7 @@ static int DoShutdown()
pDesktop.CloseWindow(pWindowManager.PointerFinder);
}

ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>().Shutdown();
ra::services::ServiceLocator::GetMutable<ra::context::IRcClient>().Shutdown();

ra::services::Initialization::Shutdown();

Expand Down
13 changes: 2 additions & 11 deletions src/RA_Integration.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@
<ClCompile Include="services\AchievementRuntimeExports.cpp" />
<ClCompile Include="services\FrameEventQueue.cpp" />
<ClCompile Include="services\GameIdentifier.cpp" />
<ClCompile Include="services\Http.cpp" />
<ClCompile Include="services\impl\FileLocalStorage.cpp" />
<ClCompile Include="services\impl\JsonFileConfiguration.cpp" />
<ClCompile Include="services\impl\OfflineRcClient.cpp" />
<ClCompile Include="services\impl\ThreadPool.cpp" />
<ClCompile Include="services\impl\WindowsFileSystem.cpp" />
<ClCompile Include="services\impl\WindowsHttpRequester.cpp" />
Expand Down Expand Up @@ -255,22 +255,16 @@
<ClInclude Include="services\AchievementRuntimeExports.hh" />
<ClInclude Include="services\FrameEventQueue.hh" />
<ClInclude Include="services\GameIdentifier.hh" />
<ClInclude Include="services\Http.hh" />
<ClInclude Include="services\IAudioSystem.hh" />
<ClInclude Include="services\IClipboard.hh" />
<ClInclude Include="services\IClock.hh" />
<ClInclude Include="services\IConfiguration.hh" />
<ClInclude Include="services\IFileSystem.hh" />
<ClInclude Include="services\IHttpRequester.hh" />
<ClInclude Include="services\ILocalStorage.hh" />
<ClInclude Include="services\ILogger.hh" />
<ClInclude Include="services\impl\FileLocalStorage.hh" />
<ClInclude Include="services\impl\FileLogger.hh" />
<ClInclude Include="services\impl\FileTextReader.hh" />
<ClInclude Include="services\impl\FileTextWriter.hh" />
<ClInclude Include="services\impl\JsonFileConfiguration.hh" />
<ClInclude Include="services\impl\StringTextReader.hh" />
<ClInclude Include="services\impl\StringTextWriter.hh" />
<ClInclude Include="services\impl\OfflineRcClient.hh" />
<ClInclude Include="services\impl\ThreadPool.hh" />
<ClInclude Include="services\impl\Clock.hh" />
<ClInclude Include="services\impl\WindowsAudioSystem.hh" />
Expand All @@ -279,7 +273,6 @@
<ClInclude Include="services\impl\WindowsFileSystem.hh" />
<ClInclude Include="services\impl\WindowsHttpRequester.hh" />
<ClInclude Include="services\Initialization.hh" />
<ClInclude Include="services\IThreadPool.hh" />
<ClInclude Include="services\PerformanceCounter.hh" />
<ClInclude Include="services\search\SearchImpl.hh" />
<ClInclude Include="services\search\SearchImpl_16bit.hh" />
Expand Down Expand Up @@ -307,8 +300,6 @@
<ClInclude Include="services\search\SearchImpl_mbf32_le.hh" />
<ClInclude Include="services\ServiceLocator.hh" />
<ClInclude Include="services\SearchResults.h" />
<ClInclude Include="services\TextReader.hh" />
<ClInclude Include="services\TextWriter.hh" />
<ClInclude Include="ui\BindingBase.hh" />
<ClInclude Include="ui\drawing\gdi\GDIBitmapSurface.hh" />
<ClInclude Include="ui\drawing\gdi\GDISurface.hh" />
Expand Down
39 changes: 6 additions & 33 deletions src/RA_Integration.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@
<ClCompile Include="services\impl\WindowsHttpRequester.cpp">
<Filter>Services\Impl</Filter>
</ClCompile>
<ClCompile Include="services\Http.cpp">
<Filter>Services</Filter>
</ClCompile>
<ClCompile Include="ui\viewmodels\GameChecksumViewModel.cpp">
<Filter>UI\ViewModels</Filter>
</ClCompile>
Expand Down Expand Up @@ -423,6 +420,9 @@
<ClCompile Include="data\models\MemoryRegionsModel.cpp">
<Filter>Data\Models</Filter>
</ClCompile>
<ClCompile Include="services\impl\OfflineRcClient.cpp">
<Filter>Services\Impl</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="RA_Resource.h">
Expand Down Expand Up @@ -467,33 +467,9 @@
<ClInclude Include="services\SearchResults.h">
<Filter>Services</Filter>
</ClInclude>
<ClInclude Include="services\IFileSystem.hh">
<Filter>Services</Filter>
</ClInclude>
<ClInclude Include="services\impl\WindowsFileSystem.hh">
<Filter>Services\Impl</Filter>
</ClInclude>
<ClInclude Include="services\impl\StringTextReader.hh">
<Filter>Services\Impl</Filter>
</ClInclude>
<ClInclude Include="services\impl\StringTextWriter.hh">
<Filter>Services\Impl</Filter>
</ClInclude>
<ClInclude Include="services\impl\FileTextWriter.hh">
<Filter>Services\Impl</Filter>
</ClInclude>
<ClInclude Include="services\impl\FileTextReader.hh">
<Filter>Services\Impl</Filter>
</ClInclude>
<ClInclude Include="services\TextWriter.hh">
<Filter>Services</Filter>
</ClInclude>
<ClInclude Include="services\TextReader.hh">
<Filter>Services</Filter>
</ClInclude>
<ClInclude Include="services\IThreadPool.hh">
<Filter>Services</Filter>
</ClInclude>
<ClInclude Include="services\impl\ThreadPool.hh">
<Filter>Services\Impl</Filter>
</ClInclude>
Expand Down Expand Up @@ -554,15 +530,9 @@
<ClInclude Include="services\impl\FileLocalStorage.hh">
<Filter>Services\Impl</Filter>
</ClInclude>
<ClInclude Include="services\IHttpRequester.hh">
<Filter>Services</Filter>
</ClInclude>
<ClInclude Include="services\impl\WindowsHttpRequester.hh">
<Filter>Services\Impl</Filter>
</ClInclude>
<ClInclude Include="services\Http.hh">
<Filter>Services</Filter>
</ClInclude>
<ClInclude Include="ui\viewmodels\GameChecksumViewModel.hh">
<Filter>UI\ViewModels</Filter>
</ClInclude>
Expand Down Expand Up @@ -1067,6 +1037,9 @@
<ClInclude Include="data\models\MemoryRegionsModel.hh">
<Filter>Data\Models</Filter>
</ClInclude>
<ClInclude Include="services\impl\OfflineRcClient.hh">
<Filter>Services\Impl</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="RA_Shared.rc">
Expand Down
5 changes: 4 additions & 1 deletion src/data/context/EmulatorContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include "api\LatestClient.hh"

#include "context\IRcClient.hh"

#include "data\context\GameContext.hh"
#include "data\context\UserContext.hh"

Expand Down Expand Up @@ -712,8 +714,9 @@ void EmulatorContext::AssertIsOnDoFrameThread() const
{
#if RA_INTEGRATION_VERSION_REVISION != 0
#if !defined(RA_UTEST)
const auto* pClient = ra::services::ServiceLocator::Get<ra::context::IRcClient>().GetClient();
const auto& pRuntime = ra::services::ServiceLocator::Get<ra::services::AchievementRuntime>();
if (!pRuntime.GetClient()->state.allow_background_memory_reads &&
if (!pClient->state.allow_background_memory_reads &&
!pRuntime.IsOnDoFrameThread())
{
const auto& pGameContext = ra::services::ServiceLocator::Get<ra::data::context::GameContext>();
Expand Down
13 changes: 8 additions & 5 deletions src/data/context/GameContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "util\Log.hh"
#include "util\Strings.hh"

#include "context\IRcClient.hh"

#include "data\context\ConsoleContext.hh"
#include "data\context\EmulatorContext.hh"
#include "data\context\SessionTracker.hh"
Expand Down Expand Up @@ -133,7 +135,8 @@ bool GameContext::BeginLoadGame(unsigned int nGameId, Mode nMode, bool& bWasPaus
{
m_nGameId = 0;

rc_client_unload_game(pRuntime.GetClient());
auto* pClient = ra::services::ServiceLocator::Get<ra::context::IRcClient>().GetClient();
rc_client_unload_game(pClient);

OnActiveGameChanged();
}
Expand Down Expand Up @@ -193,8 +196,8 @@ void GameContext::FinishLoadGame(int nResult, const char* sErrorMessage, bool bW
}
else
{
auto& pClient = ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>();
auto* pGame = rc_client_get_game_info(pClient.GetClient());
const auto* pClient = ra::services::ServiceLocator::Get<ra::context::IRcClient>().GetClient();
const auto* pGame = rc_client_get_game_info(pClient);
if (pGame == nullptr || pGame->id == 0)
{
// invalid hash
Expand All @@ -213,7 +216,7 @@ void GameContext::FinishLoadGame(int nResult, const char* sErrorMessage, bool bW
else
{
rc_client_user_game_summary_t pSummary;
rc_client_get_user_game_summary(pClient.GetClient(), &pSummary);
rc_client_get_user_game_summary(pClient, &pSummary);

// show "game loaded" popup
ra::services::ServiceLocator::Get<ra::services::IAudioSystem>().PlayAudioFile(L"Overlay\\info.wav");
Expand Down Expand Up @@ -389,7 +392,7 @@ void GameContext::EndLoadGame(int nResult, bool bWasPaused, bool bShowSoftcoreWa
void GameContext::InitializeFromAchievementRuntime(const std::map<uint32_t, std::string> mAchievementDefinitions,
const std::map<uint32_t, std::string> mLeaderboardDefinitions)
{
const auto* pClient = ra::services::ServiceLocator::Get<ra::services::AchievementRuntime>().GetClient();
auto* pClient = ra::services::ServiceLocator::Get<ra::context::IRcClient>().GetClient();
const auto* pGame = rc_client_get_game_info(pClient);
m_nGameId = GetRealGameId(pGame->id);
m_sGameTitle = ra::Widen(pGame->title);
Expand Down
4 changes: 3 additions & 1 deletion src/data/context/UserContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "Exports.hh"
#include "util\Strings.hh"

#include "context\IRcClient.hh"

#include "api\impl\DisconnectedServer.hh"

#include "data\context\EmulatorContext.hh"
Expand Down Expand Up @@ -36,7 +38,7 @@ void UserContext::Logout()

_RA_ActivateGame(0U);

auto* pClient = ra::services::ServiceLocator::Get<ra::services::AchievementRuntime>().GetClient();
auto* pClient = ra::services::ServiceLocator::Get<ra::context::IRcClient>().GetClient();
rc_client_logout(pClient);

m_sUsername.clear();
Expand Down
8 changes: 5 additions & 3 deletions src/data/models/AchievementModel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "AchievementModel.hh"

#include "context\IRcClient.hh"

#include "util\Log.hh"

#include "data\context\GameContext.hh"
Expand Down Expand Up @@ -248,8 +250,7 @@ void AchievementModel::HandleStateChanged(AssetState nOldState, AssetState nNewS

void AchievementModel::SyncState()
{
auto& pRuntime = ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>();
auto* pClient = pRuntime.GetClient();
auto* pClient = ra::services::ServiceLocator::Get<ra::context::IRcClient>().GetClient();

rc_mutex_lock(&pClient->state.mutex);

Expand All @@ -265,6 +266,7 @@ void AchievementModel::SyncState()
const auto& pClock = ra::services::ServiceLocator::Get<ra::services::IClock>();
m_tUnlock = pClock.Now();

const auto& pRuntime = ra::services::ServiceLocator::Get<ra::services::AchievementRuntime>();
if (pRuntime.HasRichPresence())
SetUnlockRichPresence(pRuntime.GetRichPresenceDisplayString());
}
Expand Down Expand Up @@ -427,7 +429,7 @@ void AchievementModel::SyncTrigger()
return;
}

auto* pClient = pRuntime.GetClient();
auto* pClient = ra::services::ServiceLocator::Get<ra::context::IRcClient>().GetClient();
auto* pGame = pClient->game;
Expects(pGame != nullptr);

Expand Down
11 changes: 6 additions & 5 deletions src/data/models/LeaderboardModel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "LeaderboardModel.hh"

#include "context\IRcClient.hh"

#include "data\context\GameContext.hh"

#include "data\models\TriggerValidation.hh"
Expand Down Expand Up @@ -225,8 +227,7 @@ void LeaderboardModel::HandleStateChanged(AssetState nOldState, AssetState nNewS

void LeaderboardModel::SyncState(AssetState nNewState)
{
auto& pRuntime = ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>();
auto* pClient = pRuntime.GetClient();
auto* pClient = ra::services::ServiceLocator::Get<ra::context::IRcClient>().GetClient();

rc_mutex_lock(&pClient->state.mutex);

Expand Down Expand Up @@ -290,8 +291,8 @@ void LeaderboardModel::SyncTracker()
{
if (m_pLeaderboard->tracker)
{
auto& pRuntime = ra::services::ServiceLocator::GetMutable<ra::services::AchievementRuntime>();
auto* pGame = pRuntime.GetClient()->game;
auto* pClient = ra::services::ServiceLocator::Get<ra::context::IRcClient>().GetClient();
auto* pGame = pClient->game;

rc_client_release_leaderboard_tracker(pGame, m_pLeaderboard);
rc_client_allocate_leaderboard_tracker(pGame, m_pLeaderboard);
Expand Down Expand Up @@ -342,7 +343,7 @@ void LeaderboardModel::SyncDefinition()
return;
}

auto* pClient = pRuntime.GetClient();
auto* pClient = ra::services::ServiceLocator::Get<ra::context::IRcClient>().GetClient();
auto* pGame = pClient->game;
Expects(pGame != nullptr);

Expand Down
Loading
Loading