Cppcorecheck function rules (#208)

This commit is contained in:
SyrianBallaS
2018-12-07 19:55:25 -07:00
committed by Jamiras
parent f3ea1a471e
commit 34f83db7c6
136 changed files with 1131 additions and 1122 deletions
+2 -2
View File
@@ -5,13 +5,13 @@
AlignAfterOpenBracket: true
AlignEscapedNewlinesLeft: true
AlignTrailingComments: true
AlignConsecutiveAssignments: true
AlignConsecutiveAssignments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
+3
View File
@@ -7,3 +7,6 @@
[submodule "lua"]
path = lua
url = https://github.com/lua/lua.git
[submodule "GSL"]
path = GSL
url = https://github.com/Microsoft/GSL.git
Submodule
+1
Submodule GSL added at 1995e86d1a
+1
View File
@@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.clang-format = .clang-format
.editorconfig = .editorconfig
src\ra_rules.ruleset = src\ra_rules.ruleset
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RA_Integration.Tests", "tests\RA_Integration.Tests.vcxproj", "{876DEBDF-C7C8-4713-8CEF-EBDEE65306A7}"
+27 -33
View File
@@ -67,7 +67,7 @@ void Achievement::RebuildTrigger()
SetDirtyFlag(DirtyFlags::Conditions);
}
static MemSize GetCompVariableSize(char nOperandSize)
static constexpr MemSize GetCompVariableSize(char nOperandSize) noexcept
{
switch (nOperandSize)
{
@@ -192,7 +192,7 @@ void Achievement::ParseTrigger(const char* sTrigger)
}
}
const char* Achievement::ParseLine(const char* pBuffer)
const char* Achievement::ParseLine(const char* restrict pBuffer)
{
#ifndef RA_UTEST
std::string sTemp;
@@ -203,9 +203,9 @@ const char* Achievement::ParseLine(const char* pBuffer)
if (pBuffer[0] == '/' || pBuffer[0] == '\\')
return pBuffer;
// Read ID of achievement:
// Read ID of achievement:
_ReadStringTil(sTemp, ':', pBuffer);
SetID((unsigned int)atol(sTemp.c_str()));
SetID(std::stoul(sTemp));
// parse conditions
const char* pTrigger = pBuffer;
@@ -241,13 +241,13 @@ const char* Achievement::ParseLine(const char* pBuffer)
SetAuthor(sTemp);
_ReadStringTil(sTemp, ':', pBuffer);
SetPoints((unsigned int)atol(sTemp.c_str()));
SetPoints(std::stoul(sTemp));
_ReadStringTil(sTemp, ':', pBuffer);
SetCreatedDate((time_t)atol(sTemp.c_str()));
SetCreatedDate(std::stoll(sTemp));
_ReadStringTil(sTemp, ':', pBuffer);
SetModifiedDate((time_t)atol(sTemp.c_str()));
SetModifiedDate(std::stoll(sTemp));
_ReadStringTil(sTemp, ':', pBuffer);
// SetUpvotes( (unsigned short)atol( sTemp.c_str() ) );
@@ -261,7 +261,7 @@ const char* Achievement::ParseLine(const char* pBuffer)
return pBuffer;
}
static bool HasHitCounts(const rc_condset_t* pCondSet)
static constexpr bool HasHitCounts(const rc_condset_t* pCondSet) noexcept
{
rc_condition_t* condition = pCondSet->conditions;
while (condition != nullptr)
@@ -275,7 +275,7 @@ static bool HasHitCounts(const rc_condset_t* pCondSet)
return false;
}
static bool HasHitCounts(const rc_trigger_t* pTrigger)
static constexpr bool HasHitCounts(const rc_trigger_t* pTrigger) noexcept
{
if (HasHitCounts(pTrigger->requirement))
return true;
@@ -292,7 +292,7 @@ static bool HasHitCounts(const rc_trigger_t* pTrigger)
return false;
}
bool Achievement::Test()
bool Achievement::Test() noexcept
{
if (m_pTrigger == nullptr)
return false;
@@ -318,7 +318,7 @@ bool Achievement::Test()
return bRetVal;
}
static rc_condition_t* GetTriggerCondition(rc_trigger_t* pTrigger, size_t nGroup, size_t nIndex)
static constexpr rc_condition_t* GetTriggerCondition(rc_trigger_t* pTrigger, size_t nGroup, size_t nIndex) noexcept
{
rc_condset_t* pGroup = pTrigger->requirement;
if (nGroup > 0)
@@ -346,7 +346,7 @@ static rc_condition_t* GetTriggerCondition(rc_trigger_t* pTrigger, size_t nGroup
return pCondition;
}
unsigned int Achievement::GetConditionHitCount(size_t nGroup, size_t nIndex) const
unsigned int Achievement::GetConditionHitCount(size_t nGroup, size_t nIndex) const noexcept
{
if (m_pTrigger == nullptr)
return 0U;
@@ -356,7 +356,7 @@ unsigned int Achievement::GetConditionHitCount(size_t nGroup, size_t nIndex) con
return pCondition ? pCondition->current_hits : 0U;
}
int Achievement::StoreConditionState(size_t nGroup, size_t nIndex, char *pBuffer) const
int Achievement::StoreConditionState(size_t nGroup, size_t nIndex, char* pBuffer) const noexcept
{
if (m_pTrigger != nullptr)
{
@@ -372,7 +372,8 @@ int Achievement::StoreConditionState(size_t nGroup, size_t nIndex, char *pBuffer
return snprintf(pBuffer, 128, "0:0:0:0:0:");
}
void Achievement::RestoreConditionState(size_t nGroup, size_t nIndex, unsigned int nCurrentHits, unsigned int nValue, unsigned int nPreviousValue)
void Achievement::RestoreConditionState(size_t nGroup, size_t nIndex, unsigned int nCurrentHits, unsigned int nValue,
unsigned int nPreviousValue) noexcept
{
if (m_pTrigger == nullptr)
return;
@@ -387,7 +388,7 @@ void Achievement::RestoreConditionState(size_t nGroup, size_t nIndex, unsigned i
pCondition->operand2.previous = nPreviousValue;
}
void Achievement::Clear()
void Achievement::Clear() noexcept
{
m_vConditions.Clear();
@@ -409,10 +410,10 @@ void Achievement::Clear()
ClearDirtyFlag();
m_bProgressEnabled = FALSE;
m_sProgress[0] = '\0';
m_sProgressMax[0] = '\0';
m_sProgressFmt[0] = '\0';
m_fProgressLastShown = 0.0f;
m_sProgress.clear();
m_sProgressMax.clear();
m_sProgressFmt.clear();
m_fProgressLastShown = 0.0F;
m_nTimestampCreated = 0;
m_nTimestampModified = 0;
@@ -420,23 +421,16 @@ void Achievement::Clear()
//m_nDownvotes = 0;
}
void Achievement::AddConditionGroup()
{
m_vConditions.AddGroup();
}
void Achievement::AddConditionGroup() noexcept { m_vConditions.AddGroup(); }
void Achievement::RemoveConditionGroup() { m_vConditions.RemoveLastGroup(); }
void Achievement::RemoveConditionGroup()
{
m_vConditions.RemoveLastGroup();
}
void Achievement::SetID(ra::AchievementID nID)
void Achievement::SetID(ra::AchievementID nID) noexcept
{
m_nAchievementID = nID;
SetDirtyFlag(DirtyFlags::ID);
}
void Achievement::SetActive(BOOL bActive)
void Achievement::SetActive(BOOL bActive) noexcept
{
if (m_bActive != bActive)
{
@@ -457,12 +451,12 @@ void Achievement::SetActive(BOOL bActive)
// SetDirtyFlag( Dirty_Votes );
//}
void Achievement::SetModified(BOOL bModified)
void Achievement::SetModified(BOOL bModified) noexcept
{
if (m_bModified != bModified)
{
m_bModified = bModified;
SetDirtyFlag(DirtyFlags::All); // TBD? questionable...
SetDirtyFlag(DirtyFlags::All); // TBD? questionable...
}
}
@@ -476,7 +470,7 @@ void Achievement::SetBadgeImage(const std::string& sBadgeURI)
m_sBadgeImageURI = sBadgeURI;
}
void Achievement::Reset()
void Achievement::Reset() noexcept
{
if (m_pTrigger)
{
+50 -46
View File
@@ -33,8 +33,8 @@ public:
Achievement() noexcept;
public:
void Clear();
bool Test();
void Clear() noexcept;
GSL_SUPPRESS(f.6) bool Test() noexcept;
size_t AddCondition(size_t nConditionGroup, const Condition& pNewCond);
size_t InsertCondition(size_t nConditionGroup, size_t nIndex, const Condition& pNewCond);
@@ -43,67 +43,71 @@ public:
void Set(const Achievement& rRHS);
inline BOOL Active() const { return m_bActive; }
void SetActive(BOOL bActive);
inline BOOL Active() const noexcept { return m_bActive; }
void SetActive(BOOL bActive) noexcept;
inline BOOL Modified() const { return m_bModified; }
void SetModified(BOOL bModified);
inline BOOL Modified() const noexcept { return m_bModified; }
void SetModified(BOOL bModified) noexcept;
inline BOOL GetPauseOnTrigger() const { return m_bPauseOnTrigger; }
void SetPauseOnTrigger(BOOL bPause) { m_bPauseOnTrigger = bPause; }
inline BOOL GetPauseOnTrigger() const noexcept { return m_bPauseOnTrigger; }
void SetPauseOnTrigger(BOOL bPause) noexcept { m_bPauseOnTrigger = bPause; }
inline BOOL GetPauseOnReset() const { return m_bPauseOnReset; }
void SetPauseOnReset(BOOL bPause) { m_bPauseOnReset = bPause; }
inline BOOL GetPauseOnReset() const noexcept { return m_bPauseOnReset; }
void SetPauseOnReset(BOOL bPause) noexcept { m_bPauseOnReset = bPause; }
void SetID(ra::AchievementID nID);
inline ra::AchievementID ID() const { return m_nAchievementID; }
void SetID(ra::AchievementID nID) noexcept;
inline ra::AchievementID ID() const noexcept { return m_nAchievementID; }
inline const std::string& Title() const { return m_sTitle; }
inline const std::string& Title() const noexcept { return m_sTitle; }
void SetTitle(const std::string& sTitle) { m_sTitle = sTitle; }
inline const std::string& Description() const { return m_sDescription; }
inline const std::string& Description() const noexcept { return m_sDescription; }
void SetDescription(const std::string& sDescription) { m_sDescription = sDescription; }
inline const std::string& Author() const { return m_sAuthor; }
inline const std::string& Author() const noexcept { return m_sAuthor; }
void SetAuthor(const std::string& sAuthor) { m_sAuthor = sAuthor; }
inline unsigned int Points() const { return m_nPointValue; }
void SetPoints(unsigned int nPoints) { m_nPointValue = nPoints; }
inline unsigned int Points() const noexcept { return m_nPointValue; }
void SetPoints(unsigned int nPoints) noexcept { m_nPointValue = nPoints; }
inline time_t CreatedDate() const { return m_nTimestampCreated; }
void SetCreatedDate(time_t nTimeCreated) { m_nTimestampCreated = nTimeCreated; }
inline time_t ModifiedDate() const { return m_nTimestampModified; }
void SetModifiedDate(time_t nTimeModified) { m_nTimestampModified = nTimeModified; }
inline time_t CreatedDate() const noexcept { return m_nTimestampCreated; }
void SetCreatedDate(time_t nTimeCreated) noexcept { m_nTimestampCreated = nTimeCreated; }
inline time_t ModifiedDate() const noexcept { return m_nTimestampModified; }
void SetModifiedDate(time_t nTimeModified) noexcept { m_nTimestampModified = nTimeModified; }
inline unsigned short Upvotes() const { return m_nUpvotes; }
inline unsigned short Downvotes() const { return m_nDownvotes; }
inline unsigned short Upvotes() const noexcept { return m_nUpvotes; }
inline unsigned short Downvotes() const noexcept { return m_nDownvotes; }
inline const std::string& Progress() const { return m_sProgress; }
inline const std::string& Progress() const noexcept { return m_sProgress; }
void SetProgressIndicator(const std::string& sProgress) { m_sProgress = sProgress; }
inline const std::string& ProgressMax() const { return m_sProgressMax; }
inline const std::string& ProgressMax() const noexcept { return m_sProgressMax; }
void SetProgressIndicatorMax(const std::string& sProgressMax) { m_sProgressMax = sProgressMax; }
inline const std::string& ProgressFmt() const { return m_sProgressFmt; }
inline const std::string& ProgressFmt() const noexcept { return m_sProgressFmt; }
void SetProgressIndicatorFormat(const std::string& sProgressFmt) { m_sProgressFmt = sProgressFmt; }
void AddConditionGroup();
void AddConditionGroup() noexcept;
void RemoveConditionGroup();
inline size_t NumConditionGroups() const { return m_vConditions.GroupCount(); }
inline size_t NumConditions(size_t nGroup) const { return nGroup < m_vConditions.GroupCount() ? m_vConditions.GetGroup(nGroup).Count() : 0; }
inline size_t NumConditionGroups() const noexcept { return m_vConditions.GroupCount(); }
inline size_t NumConditions(size_t nGroup) const
{
return nGroup < m_vConditions.GroupCount() ? m_vConditions.GetGroup(nGroup).Count() : 0;
}
inline const std::string& BadgeImageURI() const { return m_sBadgeImageURI; }
inline const std::string& BadgeImageURI() const noexcept { return m_sBadgeImageURI; }
void SetBadgeImage(const std::string& sFilename);
Condition& GetCondition(size_t nCondGroup, size_t i) { return m_vConditions.GetGroup(nCondGroup).GetAt(i); }
unsigned int GetConditionHitCount(size_t nCondGroup, size_t i) const;
int StoreConditionState(size_t nCondGroup, size_t i, char* pBuffer) const;
void RestoreConditionState(size_t nCondGroup, size_t i, unsigned int nCurrentHits, unsigned int nValue, unsigned int nPrevValue);
unsigned int GetConditionHitCount(size_t nCondGroup, size_t i) const noexcept;
int StoreConditionState(size_t nCondGroup, size_t i, char* pBuffer) const noexcept;
void RestoreConditionState(size_t nCondGroup, size_t i, unsigned int nCurrentHits, unsigned int nValue,
unsigned int nPrevValue) noexcept;
std::string CreateMemString() const;
std::string CreateStateString(const std::string& sSalt) const;
void Reset();
void Reset() noexcept;
// Returns the new char* offset after parsing.
const char* ParseLine(const char* sBuffer);
// Returns the new char* offset after parsing.
GSL_SUPPRESS(f.6) const char*
ParseLine(const char* restrict sBuffer); /*Doesn't throw in tests but might in Integration */
const char* ParseStateString(const char* sBuffer, const std::string& sSalt);
#ifndef RA_UTEST
@@ -128,13 +132,13 @@ public:
protected:
void ParseTrigger(const char* pTrigger);
void* m_pTrigger = nullptr; // rc_trigger_t
std::shared_ptr<unsigned char[]> m_pTriggerBuffer; // buffer for rc_trigger_t
void* m_pTrigger = nullptr; // rc_trigger_t
std::shared_ptr<unsigned char[]> m_pTriggerBuffer; // buffer for rc_trigger_t
private:
ra::AchievementID m_nAchievementID;
ConditionSet m_vConditions; // UI wrappers for trigger
ConditionSet m_vConditions; // UI wrappers for trigger
std::string m_sTitle;
std::string m_sDescription;
@@ -148,15 +152,15 @@ private:
BOOL m_bPauseOnReset{};
// Progress:
BOOL m_bProgressEnabled{}; // on/off
BOOL m_bProgressEnabled{}; // on/off
std::string m_sProgress; // How to calculate the progress so far (syntactical)
std::string m_sProgressMax; // Upper limit of the progress (syntactical? value?)
std::string m_sProgressFmt; // Format of the progress to be shown (currency? step?)
std::string m_sProgress; // How to calculate the progress so far (syntactical)
std::string m_sProgressMax; // Upper limit of the progress (syntactical? value?)
std::string m_sProgressFmt; // Format of the progress to be shown (currency? step?)
float m_fProgressLastShown{}; // The last shown progress
float m_fProgressLastShown{}; // The last shown progress
DirtyFlags m_nDirtyFlags{}; // Use for rendering when editing.
DirtyFlags m_nDirtyFlags{}; // Use for rendering when editing.
time_t m_nTimestampCreated{};
time_t m_nTimestampModified{};
+24 -51
View File
@@ -48,27 +48,19 @@ AchievementOverlay g_AchievementOverlay;
AchievementExamine g_AchExamine;
LeaderboardExamine g_LBExamine;
const COLORREF COL_TEXT = RGB(17, 102, 221);
const COLORREF COL_TEXT_HIGHLIGHT = RGB(251, 102, 0);
const COLORREF COL_SELECTED = RGB(255, 255, 255);
const COLORREF COL_TEXT_LOCKED = RGB(137, 137, 137);
const COLORREF COL_SELECTED_LOCKED = RGB(202, 202, 202);
const COLORREF COL_BLACK = RGB(0, 0, 0);
const COLORREF COL_WHITE = RGB(255, 255, 255);
const COLORREF COL_BAR = RGB(0, 40, 0);
const COLORREF COL_BAR_BG = RGB(0, 212, 0);
const COLORREF COL_POPUP = RGB(0, 0, 40);
const COLORREF COL_POPUP_BG = RGB(212, 212, 212);
const COLORREF COL_POPUP_SHADOW = RGB(0, 0, 0);
const COLORREF COL_USER_FRAME_BG = RGB(32, 32, 32);
const COLORREF COL_SELECTED_BOX_BG = RGB(22, 22, 60);
const COLORREF COL_WARNING = RGB(255, 0, 0);
const COLORREF COL_WARNING_BG = RGB(80, 0, 0);
_CONSTANT_VAR COL_TEXT_LOCKED = RGB(137, 137, 137);
_CONSTANT_VAR COL_SELECTED_LOCKED = RGB(202, 202, 202);
_CONSTANT_VAR COL_BAR = RGB(0, 40, 0);
_CONSTANT_VAR COL_BAR_BG = RGB(0, 212, 0);
_CONSTANT_VAR COL_USER_FRAME_BG = RGB(32, 32, 32);
_CONSTANT_VAR COL_SELECTED_BOX_BG = RGB(22, 22, 60);
_CONSTANT_VAR COL_WARNING = RGB(255, 0, 0);
_CONSTANT_VAR COL_WARNING_BG = RGB(80, 0, 0);
const unsigned int OVERLAY_WIDTH = 1024;
const unsigned int OVERLAY_HEIGHT = 1024;
_CONSTANT_VAR OVERLAY_WIDTH = 1024U;
_CONSTANT_VAR OVERLAY_HEIGHT = 1024U;
void AchievementOverlay::SelectNextTopLevelPage(BOOL bPressedRight)
void AchievementOverlay::SelectNextTopLevelPage(BOOL bPressedRight) noexcept
{
switch (m_Pages.at(m_nPageStackPointer))
{
@@ -94,7 +86,7 @@ void AchievementOverlay::SelectNextTopLevelPage(BOOL bPressedRight)
}
}
void AchievementOverlay::Activate()
void AchievementOverlay::Activate() noexcept
{
if (m_nTransitionState != TransitionState::Hold)
{
@@ -103,7 +95,7 @@ void AchievementOverlay::Activate()
}
}
void AchievementOverlay::Deactivate()
void AchievementOverlay::Deactivate() noexcept
{
if (m_nTransitionState != TransitionState::Off && m_nTransitionState != TransitionState::Out)
{
@@ -115,7 +107,7 @@ void AchievementOverlay::Deactivate()
}
// Returns TRUE if we are ready to exit the overlay.
BOOL AchievementOverlay::GoBack()
BOOL AchievementOverlay::GoBack() noexcept
{
if (m_nPageStackPointer == 0)
{
@@ -480,7 +472,8 @@ void AchievementOverlay::DrawAchievementsPage(HDC hDC, int nDX, int nDY, const R
const int nHeight = rcTarget.bottom - rcTarget.top;
auto& pGameContext = ra::services::ServiceLocator::Get<ra::data::GameContext>();
auto nPlayTime = static_cast<unsigned int>(ra::services::ServiceLocator::Get<ra::data::SessionTracker>().GetTotalPlaytime(pGameContext.GameId()).count());
const auto nPlayTime = static_cast<unsigned int>(
ra::services::ServiceLocator::Get<ra::data::SessionTracker>().GetTotalPlaytime(pGameContext.GameId()).count());
// title
const auto& sGameTitle = pGameContext.GameTitle();
@@ -535,7 +528,7 @@ void AchievementOverlay::DrawAchievementsPage(HDC hDC, int nDX, int nDY, const R
{
for (int i = 0; i < nAchievementsToDraw; ++i)
{
int nAchIdx = (*pnScrollOffset) + i;
const int nAchIdx = (*pnScrollOffset) + i;
if (nAchIdx < static_cast<int>(nNumberOfAchievements))
{
const BOOL bSelected = ((*pnSelectedItem) - (*pnScrollOffset) == i);
@@ -573,20 +566,8 @@ void AchievementOverlay::DrawAchievementsPage(HDC hDC, int nDX, int nDY, const R
m_nNumAchievementsBeingRendered = nAchievementsToDraw;
}
void AchievementOverlay::DrawMessagesPage(_UNUSED HDC, _UNUSED int, _UNUSED int, _UNUSED const RECT&) const
void AchievementOverlay::DrawMessagesPage(_UNUSED HDC, _UNUSED int, _UNUSED int, _UNUSED const RECT&) const noexcept
{
// for( size_t i = 0; i < 256; ++i )
// buffer[i] = (char)(i);
//
// SelectObject( hDC, hFontDesc );
// TextOut( hDC, nDX+8, 40, buffer, 32 );
// TextOut( hDC, nDX+8, 60, buffer+32, 32 );
// TextOut( hDC, nDX+8, 80, buffer+64, 32 );
// TextOut( hDC, nDX+8, 100, buffer+96, 32 );
// TextOut( hDC, nDX+8, 120, buffer+128, 32 );
// TextOut( hDC, nDX+8, 140, buffer+160, 32 );
// TextOut( hDC, nDX+8, 160, buffer+192, 32 );
// TextOut( hDC, nDX+8, 180, buffer+224, 32 );
}
void AchievementOverlay::DrawFriendsPage(HDC hDC, int nDX, _UNUSED int, const RECT& rcTarget) const
@@ -1249,7 +1230,7 @@ void AchievementOverlay::Render(HDC hRealDC, const RECT* rcDest) const
::DeleteDC(hDC);
}
void AchievementOverlay::DrawBar(HDC hDC, int nX, int nY, int nW, int nH, int nMax, int nSel) const
void AchievementOverlay::DrawBar(HDC hDC, int nX, int nY, int nW, int nH, int nMax, int nSel) const noexcept
{
HBRUSH hBarBack = static_cast<HBRUSH>(GetStockObject(DKGRAY_BRUSH));
HBRUSH hBarFront = static_cast<HBRUSH>(GetStockObject(LTGRAY_BRUSH));
@@ -1377,7 +1358,7 @@ _Use_decl_annotations_ void AchievementOverlay::DrawUserFrame(HDC hDC, int nX, i
DeleteObject(hBrush2);
}
int* AchievementOverlay::GetActiveScrollOffset() const
int* AchievementOverlay::GetActiveScrollOffset() const noexcept
{
switch (m_Pages.at(m_nPageStackPointer))
{
@@ -1403,7 +1384,7 @@ int* AchievementOverlay::GetActiveScrollOffset() const
}
}
int* AchievementOverlay::GetActiveSelectedItem() const
int* AchievementOverlay::GetActiveSelectedItem() const noexcept
{
switch (m_Pages.at(m_nPageStackPointer))
{
@@ -1429,7 +1410,7 @@ int* AchievementOverlay::GetActiveSelectedItem() const
}
}
void AchievementOverlay::OnLoad_NewRom()
void AchievementOverlay::OnLoad_NewRom() noexcept
{
m_nAchievementsSelectedItem = 0;
m_nAchievementsScrollOffset = 0;
@@ -1491,15 +1472,7 @@ void AchievementOverlay::UpdateImages() noexcept
m_hUserImage.ChangeReference(ra::ui::ImageType::UserPic, RAUsers::LocalUser().Username());
}
AchievementExamine::AchievementExamine() :
m_pSelectedAchievement(nullptr),
m_bHasData(false),
m_nTotalWinners(0),
m_nPossibleWinners(0)
{
}
void AchievementExamine::Clear()
void AchievementExamine::Clear() noexcept
{
m_pSelectedAchievement = nullptr;
m_CreatedDate.clear();
@@ -1561,7 +1534,7 @@ void AchievementExamine::OnReceiveData(rapidjson::Document& doc)
const auto nDateAwarded{ static_cast<time_t>(ra::to_signed(NextWinner["DateAwarded"].GetUint())) };
std::ostringstream oss;
oss << NextWinner["User"].GetString() << " (" << NextWinner["RAPoints"].GetUint() << ")";
RecentWinners.push_back({ oss.str(), _TimeStampToString(nDateAwarded) });
RecentWinners.emplace_back(oss.str(), _TimeStampToString(nDateAwarded));
}
m_bHasData = true;
+65 -76
View File
@@ -3,8 +3,8 @@
#pragma once
#include "RA_Achievement.h"
#include "RA_User.h"
#include "RA_Core.h" // RA_Interface
#include "RA_User.h"
#include "ui\ImageReference.hh"
@@ -12,7 +12,7 @@ class LeaderboardExamine
{
public:
void Initialize(const unsigned int nLBIDIn);
//static void CB_OnReceiveData( void* pRequestObject );
// static void CB_OnReceiveData( void* pRequestObject );
void OnReceiveData(const rapidjson::Document& doc);
public:
@@ -22,42 +22,38 @@ public:
};
extern LeaderboardExamine g_LBExamine;
class AchievementExamine
{
public:
class RecentWinnerData
{
public:
RecentWinnerData(const std::string& sUser, const std::string& sWonAt) :
m_sUser(sUser), m_sWonAt(sWonAt)
{
}
const std::string& User() const { return m_sUser; }
const std::string& WonAt() const { return m_sWonAt; }
explicit RecentWinnerData(const std::string& sUser, const std::string& sWonAt) :
m_sUser{sUser},
m_sWonAt{sWonAt}
{}
const std::string& User() const noexcept { return m_sUser; }
const std::string& WonAt() const noexcept { return m_sWonAt; }
private:
const std::string m_sUser;
const std::string m_sWonAt;
};
public:
AchievementExamine();
public:
void Initialize(const Achievement* pAchIn);
void Clear();
void Clear() noexcept;
void OnReceiveData(rapidjson::Document& doc);
bool HasData() const { return m_bHasData; }
const std::string& CreatedDate() const { return m_CreatedDate; }
const std::string& ModifiedDate() const { return m_LastModifiedDate; }
size_t NumRecentWinners() const { return RecentWinners.size(); }
bool HasData() const noexcept { return m_bHasData; }
const std::string& CreatedDate() const noexcept { return m_CreatedDate; }
const std::string& ModifiedDate() const noexcept { return m_LastModifiedDate; }
size_t NumRecentWinners() const noexcept { return RecentWinners.size(); }
const RecentWinnerData& GetRecentWinner(size_t nOffs) const { return RecentWinners.at(nOffs); }
unsigned int TotalWinners() const { return m_nTotalWinners; }
unsigned int PossibleWinners() const { return m_nPossibleWinners; }
unsigned int TotalWinners() const noexcept { return m_nTotalWinners; }
unsigned int PossibleWinners() const noexcept { return m_nPossibleWinners; }
_NODISCARD inline auto begin() noexcept { return RecentWinners.begin(); }
_NODISCARD inline auto begin() const noexcept { return RecentWinners.begin(); }
@@ -65,21 +61,20 @@ public:
_NODISCARD inline auto end() const noexcept { return RecentWinners.end(); }
private:
const Achievement* m_pSelectedAchievement;
const Achievement* m_pSelectedAchievement{};
std::string m_CreatedDate;
std::string m_LastModifiedDate;
bool m_bHasData;
bool m_bHasData{};
// Data found:
unsigned int m_nTotalWinners;
unsigned int m_nPossibleWinners;
unsigned int m_nTotalWinners{};
unsigned int m_nPossibleWinners{};
std::vector<RecentWinnerData> RecentWinners;
};
extern AchievementExamine g_AchExamine;
class AchievementOverlay
{
enum class Page
@@ -107,34 +102,31 @@ class AchievementOverlay
};
public:
void Activate();
void Deactivate();
void Activate() noexcept;
void Deactivate() noexcept;
void Render(_In_ HDC hDC, _In_ const RECT* rcDest) const;
_Success_(return)
_NODISCARD BOOL Update(_In_ const ControllerInput* input, _In_ float fDelta,
_In_ BOOL bFullScreen, _In_ BOOL bPaused);
_NODISCARD BOOL Update(_In_ const ControllerInput* input, _In_ float fDelta, _In_ BOOL bFullScreen,
_In_ BOOL bPaused);
_NODISCARD _CONSTANT_FN IsActive() const noexcept { return(m_nTransitionState != TransitionState::Off); }
_NODISCARD _CONSTANT_FN IsActive() const noexcept { return (m_nTransitionState != TransitionState::Off); }
_NODISCARD _CONSTANT_FN IsFullyVisible() const noexcept { return (m_nTransitionState == TransitionState::Hold); }
int* GetActiveScrollOffset() const;
int* GetActiveSelectedItem() const;
int* GetActiveScrollOffset() const noexcept;
int* GetActiveSelectedItem() const noexcept;
void OnLoad_NewRom();
void OnLoad_NewRom() noexcept;
void DrawAchievementsPage(HDC hDC, int nDX, int nDY, const RECT& rcTarget) const;
void DrawAchievementExaminePage(HDC hDC, int nDX, _UNUSED int, _UNUSED const RECT&) const;
void DrawMessagesPage(_UNUSED HDC, _UNUSED int, _UNUSED int, _UNUSED const RECT&) const;
void DrawMessagesPage(_UNUSED HDC, _UNUSED int, _UNUSED int, _UNUSED const RECT&) const noexcept;
void DrawFriendsPage(HDC hDC, int nDX, _UNUSED int, const RECT& rcTarget) const;
void DrawNewsPage(HDC hDC, int nDX, _UNUSED int, const RECT& rcTarget) const;
void DrawLeaderboardPage(HDC hDC, int nDX, _UNUSED int, const RECT& rcTarget) const;
void DrawLeaderboardExaminePage(HDC hDC, int nDX, _UNUSED int, _UNUSED const RECT&) const;
void DrawBar(HDC hDC, int nX, int nY, int nW, int nH, int nMax, int nSel) const;
void DrawUserFrame(_In_ HDC hDC,
_In_ int nX, _In_ int nY,
_In_ int nW, _In_ int nH) const;
void DrawBar(HDC hDC, int nX, int nY, int nW, int nH, int nMax, int nSel) const noexcept;
void DrawUserFrame(_In_ HDC hDC, _In_ int nX, _In_ int nY, _In_ int nW, _In_ int nH) const;
void DrawAchievement(HDC hDC, const Achievement* Ach, int nX, int nY, BOOL bSelected, BOOL bCanLock) const;
_NODISCARD _CONSTANT_FN CurrentPage() const noexcept { return m_Pages.at(m_nPageStackPointer); }
@@ -144,11 +136,11 @@ public:
m_Pages.at(m_nPageStackPointer) = NewPage;
}
BOOL GoBack();
void SelectNextTopLevelPage(BOOL bPressedRight);
BOOL GoBack() noexcept;
void SelectNextTopLevelPage(BOOL bPressedRight) noexcept;
void InstallNewsArticlesFromFile();
void UpdateImages() noexcept;
[[gsl::suppress(f .6)]] void UpdateImages() noexcept;
public:
struct NewsItem
@@ -164,32 +156,32 @@ public:
};
private:
inline static constexpr auto PAGE_TRANSITION_IN{ -0.200F };
inline static constexpr auto PAGE_TRANSITION_OUT{ 0.2F };
inline static constexpr auto PAGE_TRANSITION_IN{-0.200F};
inline static constexpr auto PAGE_TRANSITION_OUT{0.2F};
mutable int m_nAchievementsScrollOffset{};
mutable int m_nFriendsScrollOffset{};
mutable int m_nMessagesScrollOffset{};
mutable int m_nNewsScrollOffset{};
mutable int m_nLeaderboardScrollOffset{};
mutable int m_nAchievementsScrollOffset{};
mutable int m_nFriendsScrollOffset{};
mutable int m_nMessagesScrollOffset{};
mutable int m_nNewsScrollOffset{};
mutable int m_nLeaderboardScrollOffset{};
mutable int m_nAchievementsSelectedItem{};
mutable int m_nFriendsSelectedItem{};
mutable int m_nMessagesSelectedItem{};
mutable int m_nNewsSelectedItem{};
mutable int m_nLeaderboardSelectedItem{};
mutable int m_nAchievementsSelectedItem{};
mutable int m_nFriendsSelectedItem{};
mutable int m_nMessagesSelectedItem{};
mutable int m_nNewsSelectedItem{};
mutable int m_nLeaderboardSelectedItem{};
mutable int m_nNumAchievementsBeingRendered{};
mutable int m_nNumFriendsBeingRendered{};
mutable int m_nNumLeaderboardsBeingRendered{};
BOOL m_bInputLock{}; // Waiting for pad release
BOOL m_bInputLock{}; // Waiting for pad release
std::vector<NewsItem> m_LatestNews{};
TransitionState m_nTransitionState{};
float m_fTransitionTimer{ PAGE_TRANSITION_IN };
TransitionState m_nTransitionState{};
float m_fTransitionTimer{PAGE_TRANSITION_IN};
std::array<Page, 5> m_Pages{ Page::Achievements };
unsigned int m_nPageStackPointer{};
std::array<Page, 5> m_Pages{Page::Achievements};
unsigned int m_nPageStackPointer{};
ra::ui::ImageReference m_hOverlayBackground;
ra::ui::ImageReference m_hUserImage;
@@ -197,24 +189,21 @@ private:
};
extern AchievementOverlay g_AchievementOverlay;
// Exposed to DLL
_EXTERN_C
// Can't use restrict since the pointer is aliased
[[gsl::suppress(con.3)]]
API int _RA_UpdateOverlay(_In_ ControllerInput* pInput, _In_ float fDTime, _In_ bool Full_Screen, _In_ bool Paused);
[[gsl::suppress(con.3)]]
API void _RA_RenderOverlay(_In_ HDC hDC, _In_ RECT* rcSize);
// Exposed to DLL
extern "C" {
[[gsl::suppress(con.3)]] API int _RA_UpdateOverlay(_In_ ControllerInput* pInput, _In_ float fDTime,
_In_ bool Full_Screen, _In_ bool Paused);
[[gsl::suppress(con.3)]] API void _RA_RenderOverlay(_In_ HDC hDC, _In_ RECT* rcSize);
API bool _RA_IsOverlayFullyVisible();
_END_EXTERN_C
extern const COLORREF COL_TEXT;
extern const COLORREF COL_TEXT_HIGHLIGHT;
extern const COLORREF COL_SELECTED;
extern const COLORREF COL_WHITE;
extern const COLORREF COL_BLACK;
extern const COLORREF COL_POPUP;
extern const COLORREF COL_POPUP_BG;
extern const COLORREF COL_POPUP_SHADOW;
}
_CONSTANT_VAR COL_TEXT = RGB(17, 102, 221);
_CONSTANT_VAR COL_TEXT_HIGHLIGHT = RGB(251, 102, 0);
_CONSTANT_VAR COL_SELECTED = RGB(255, 255, 255);
_CONSTANT_VAR COL_BLACK = RGB(0, 0, 0);
_CONSTANT_VAR COL_WHITE = RGB(255, 255, 255);
_CONSTANT_VAR COL_POPUP = RGB(0, 0, 40);
_CONSTANT_VAR COL_POPUP_BG = RGB(212, 212, 212);
_CONSTANT_VAR COL_POPUP_SHADOW = RGB(0, 0, 0);
#endif // !RA_ACHIEVEMENTOVERLAY_H
+3 -3
View File
@@ -63,7 +63,7 @@ void AchievementPopup::Update(_UNUSED ControllerInput, float fDelta, _UNUSED boo
}
}
float AchievementPopup::GetYOffsetPct() const
float AchievementPopup::GetYOffsetPct() const noexcept
{
float fVal = 0.0F;
@@ -106,11 +106,11 @@ const ra::ui::drawing::ISurface& MessagePopup::GetRendered()
auto nFontTitle = pSurface->LoadFont(FONT_TO_USE, FONT_SIZE_TITLE, ra::ui::FontStyles::Normal);
const auto sTitle = ra::Widen(Title());
auto szTitle = pSurface->MeasureText(nFontTitle, sTitle);
const auto szTitle = pSurface->MeasureText(nFontTitle, sTitle);
auto nFontSubtitle = pSurface->LoadFont(FONT_TO_USE, FONT_SIZE_SUBTITLE, ra::ui::FontStyles::Normal);
const auto sSubTitle = ra::Widen(Subtitle());
auto szSubTitle = pSurface->MeasureText(nFontSubtitle, sSubTitle);
const auto szSubTitle = pSurface->MeasureText(nFontSubtitle, sSubTitle);
// create the actual surface
const int nWidth = 64 + 6 + std::max(szTitle.Width, szSubTitle.Width) + 8 + 2;
+5 -5
View File
@@ -39,10 +39,10 @@ public:
m_hMessageImage(ra::ui::ImageType::None, "")
{}
const std::string& Title() const { return m_sMessageTitle; }
const std::string& Subtitle() const { return m_sMessageSubtitle; }
PopupMessageType Type() const { return m_nMessageType; }
const ra::ui::ImageReference& Image() const { return m_hMessageImage; }
const std::string& Title() const noexcept { return m_sMessageTitle; }
const std::string& Subtitle() const noexcept { return m_sMessageSubtitle; }
PopupMessageType Type() const noexcept { return m_nMessageType; }
const ra::ui::ImageReference& Image() const noexcept { return m_hMessageImage; }
const ra::ui::drawing::ISurface& GetRendered();
@@ -61,7 +61,7 @@ public:
void Render(_In_ HDC hDC, _In_ const RECT& rcDest);
void AddMessage(MessagePopup&& msg);
float GetYOffsetPct() const;
float GetYOffsetPct() const noexcept;
bool MessagesPresent() const { return (m_vMessages.size() > 0); }
+4 -8
View File
@@ -129,14 +129,10 @@ unsigned int AchievementSet::NumActive() const
return nNumActive;
}
void AchievementSet::Clear()
void AchievementSet::Clear() noexcept
{
std::vector<Achievement>::iterator iter = m_Achievements.begin();
while (iter != m_Achievements.end())
{
iter->Clear();
iter++;
}
for (auto& ach : m_Achievements)
ach.Clear();
m_Achievements.clear();
m_bProcessingActive = TRUE;
@@ -222,7 +218,7 @@ void AchievementSet::Test()
}
}
void AchievementSet::Reset()
void AchievementSet::Reset() noexcept
{
for (Achievement& ach : m_Achievements)
ach.Reset();
+6 -6
View File
@@ -31,9 +31,9 @@ public:
#endif // !RA_UTEST
public:
void Clear();
void Clear() noexcept;
void Test();
void Reset();
void Reset() noexcept;
_Success_(return)
bool LoadFromFile(_Inout_ unsigned int nGameID);
@@ -41,10 +41,10 @@ public:
// Get Achievement at offset
Achievement& GetAchievement(size_t nIter) { return m_Achievements[nIter]; }
inline size_t NumAchievements() const { return m_Achievements.size(); }
inline size_t NumAchievements() const noexcept { return m_Achievements.size(); }
// Get Points Total
inline unsigned int PointTotal()
inline unsigned int PointTotal() noexcept
{
unsigned int total = 0U;
for (auto& ach : m_Achievements) total += ach.Points();
@@ -72,8 +72,8 @@ public:
unsigned int NumActive() const;
BOOL ProcessingActive() const { return m_bProcessingActive; }
void SetPaused(BOOL bIsPaused) { m_bProcessingActive = !bIsPaused; }
BOOL ProcessingActive() const noexcept { return m_bProcessingActive; }
void SetPaused(BOOL bIsPaused) noexcept { m_bProcessingActive = !bIsPaused; }
BOOL HasUnsavedChanges();
+2 -2
View File
@@ -39,7 +39,7 @@ size_t CodeNotes::Load(unsigned int nID)
const auto nAddr { static_cast<ra::ByteAddress>(std::stoul(sAddr, nullptr, 16)) };
const std::string& sAuthor { note["User"].GetString() }; // Author?
m_CodeNotes.try_emplace(nAddr, CodeNoteObj{ sAuthor, sNote });
m_CodeNotes.try_emplace(nAddr, CodeNoteObj(sAuthor, sNote));
}
return m_CodeNotes.size();
@@ -77,7 +77,7 @@ void CodeNotes::OnCodeNotesResponse(rapidjson::Document& doc)
void CodeNotes::Add(const ra::ByteAddress& nAddr, const std::string& sAuthor, const std::string& sNote)
{
if (m_CodeNotes.find(nAddr) == m_CodeNotes.end())
m_CodeNotes.insert(std::map<ra::ByteAddress, CodeNoteObj>::value_type(nAddr, CodeNoteObj(sAuthor, sNote)));
m_CodeNotes.try_emplace(nAddr, CodeNoteObj(sAuthor, sNote));
else
m_CodeNotes.at(nAddr).SetNote(sNote);
+6 -9
View File
@@ -10,14 +10,11 @@ public:
class CodeNoteObj
{
public:
CodeNoteObj(const std::string& sAuthor, std::string sNote) :
m_sAuthor(sAuthor), m_sNote(sNote)
{
}
explicit CodeNoteObj(const std::string& sAuthor, const std::string& sNote) : m_sAuthor{sAuthor}, m_sNote{sNote}
{}
public:
const std::string& Author() const { return m_sAuthor; }
const std::string& Note() const { return m_sNote; }
const std::string& Author() const noexcept { return m_sAuthor; }
const std::string& Note() const noexcept { return m_sNote; }
void SetNote(const std::string& sNote) { m_sNote = sNote; }
@@ -43,8 +40,8 @@ public:
return(iter != m_CodeNotes.end()) ? &iter->second : nullptr;
}
std::map<ra::ByteAddress, CodeNoteObj>::const_iterator FirstNote() const { return m_CodeNotes.begin(); }
std::map<ra::ByteAddress, CodeNoteObj>::const_iterator EndOfNotes() const { return m_CodeNotes.end(); }
_NODISCARD inline auto begin() const noexcept { return m_CodeNotes.cbegin(); }
_NODISCARD inline auto end() const noexcept { return m_CodeNotes.cend(); }
private:
std::map<ra::ByteAddress, CodeNoteObj> m_CodeNotes;
+6 -5
View File
@@ -163,13 +163,13 @@ class ConditionGroup
public:
void SerializeAppend(std::string& buffer) const;
size_t Count() const { return m_Conditions.size(); }
size_t Count() const noexcept { return m_Conditions.size(); }
void Add(const Condition& newCond) { m_Conditions.push_back(newCond); }
void Insert(size_t i, const Condition& newCond) { m_Conditions.insert(m_Conditions.begin() + i, newCond); }
Condition& GetAt(size_t i) { return m_Conditions[i]; }
const Condition& GetAt(size_t i) const { return m_Conditions[i]; }
void Clear() { m_Conditions.clear(); }
void Clear() noexcept { m_Conditions.clear(); }
void RemoveAt(size_t i);
protected:
@@ -181,9 +181,10 @@ class ConditionSet
public:
void Serialize(std::string& buffer) const;
void Clear() { m_vConditionGroups.clear(); }
size_t GroupCount() const { return m_vConditionGroups.size(); }
void AddGroup() { m_vConditionGroups.emplace_back(); }
void Clear() noexcept { m_vConditionGroups.clear(); }
size_t GroupCount() const noexcept { return m_vConditionGroups.size(); }
// TODO: Put in a type_trait for nothrow EmplaceConstructible to give a nothrow guarantee
GSL_SUPPRESS(f.6) void AddGroup() noexcept { m_vConditionGroups.emplace_back(); }
void RemoveLastGroup() { m_vConditionGroups.pop_back(); }
ConditionGroup& GetGroup(size_t i) { return m_vConditionGroups[i]; }
const ConditionGroup& GetGroup(size_t i) const { return m_vConditionGroups[i]; }
+10 -11
View File
@@ -495,7 +495,7 @@ API void CCONV _RA_ClearMemoryBanks()
// }
//}
static unsigned long long ParseVersion(const char* sVersion)
static unsigned long long ParseVersion(const char* sVersion) noexcept
{
char* pPart;
const auto major = strtoull(sVersion, &pPart, 10);
@@ -1288,7 +1288,7 @@ void CCONV _RA_InstallSharedFunctionsExt(bool(*fpIsActive)(void), void(*fpCauseU
//////////////////////////////////////////////////////////////////////////
BOOL _ReadTil(const char nChar, char buffer[], unsigned int nSize, DWORD* pCharsReadOut, FILE* pFile)
BOOL _ReadTil(const char nChar, char* buffer, unsigned int nSize, DWORD* pCharsReadOut, FILE* pFile) noexcept
{
char pNextChar = '\0';
memset(buffer, '\0', nSize);
@@ -1307,7 +1307,7 @@ BOOL _ReadTil(const char nChar, char buffer[], unsigned int nSize, DWORD* pChars
return ((*pCharsReadOut) > 0);
}
char* _ReadStringTil(char nChar, char*& pOffsetInOut, BOOL bTerminate)
char* _ReadStringTil(char nChar, char* restrict& pOffsetInOut, BOOL bTerminate) noexcept
{
char* pStartString = pOffsetInOut;
@@ -1341,8 +1341,7 @@ void _WriteBufferToFile(const std::wstring& sFileName, const std::string& raw)
ofile.write(raw.c_str(), ra::to_signed(raw.length()));
}
_Use_decl_annotations_
bool _ReadBufferFromFile(std::string& buffer, const wchar_t* const __restrict sFile)
_Use_decl_annotations_ bool _ReadBufferFromFile(std::string& buffer, const wchar_t* const restrict sFile)
{
buffer.clear();
std::ifstream file(sFile);
@@ -1358,7 +1357,7 @@ bool _ReadBufferFromFile(std::string& buffer, const wchar_t* const __restrict sF
return true;
}
char* _MallocAndBulkReadFileToBuffer(const wchar_t* sFilename, long& nFileSizeOut)
char* _MallocAndBulkReadFileToBuffer(const wchar_t* sFilename, long& nFileSizeOut) noexcept
{
nFileSizeOut = 0L;
FILE* pf = nullptr;
@@ -1416,7 +1415,7 @@ BrowseCallbackProc(_In_ HWND hwnd, _In_ UINT uMsg, _In_ _UNUSED LPARAM lParam, _
} /* namespace ra */
std::string GetFolderFromDialog() noexcept
std::string GetFolderFromDialog()
{
auto lpbi{ std::make_unique<BROWSEINFO>() };
lpbi->hwndOwner = ::GetActiveWindow();
@@ -1426,7 +1425,7 @@ std::string GetFolderFromDialog() noexcept
lpbi->lpszTitle = _T("Select ROM folder...");
if (::OleInitialize(nullptr) != S_OK)
return "";
return std::string();
lpbi->ulFlags = BIF_USENEWUI | BIF_VALIDATE;
lpbi->lpfn = ra::BrowseCallbackProc;
@@ -1445,13 +1444,13 @@ std::string GetFolderFromDialog() noexcept
if (!owner)
{
::OleUninitialize();
return "";
return std::string();
}
if (::SHGetPathFromIDList(owner.get(), lpbi->pszDisplayName) == 0)
{
::OleUninitialize();
return "";
return std::string();
}
ret = ra::Narrow(lpbi->pszDisplayName);
}
@@ -1459,7 +1458,7 @@ std::string GetFolderFromDialog() noexcept
return ret;
}
BOOL CanCausePause()
BOOL CanCausePause() noexcept
{
return (_RA_CausePause != nullptr);
}
+14 -14
View File
@@ -7,7 +7,7 @@
#include "Exports.hh"
// Non-exposed:
// Non-exposed:
extern std::wstring g_sHomeDir;
extern HINSTANCE g_hRAKeysDLL;
@@ -19,24 +19,24 @@ extern const char* g_sClientVersion;
extern const char* g_sClientName;
extern bool g_bRAMTamperedWith;
// Read a file to a malloc'd buffer. Returns nullptr on error. Owner MUST free() buffer if not nullptr.
extern char* _MallocAndBulkReadFileToBuffer(_In_z_ const wchar_t* sFilename, _Out_ long& nFileSizeOut);
// Read a file to a malloc'd buffer. Returns nullptr on error. Owner MUST free() buffer if not nullptr.
extern char* _MallocAndBulkReadFileToBuffer(_In_z_ const wchar_t* sFilename, _Out_ long& nFileSizeOut) noexcept;
// Read a file to a std::string. Returns false on error.
_Success_(return)
_NODISCARD bool _ReadBufferFromFile(_Out_ std::string& buffer, _In_ const wchar_t* const __restrict sFile);
// Read a file to a std::string. Returns false on error.
_Success_(return) _NODISCARD
bool _ReadBufferFromFile(_Out_ std::string& buffer, _In_ const wchar_t* restrict sFile);
// Read file until reaching the end of the file, or the specified char.
extern BOOL _ReadTil(const char nChar, char buffer[], unsigned int nSize, DWORD* pCharsRead, FILE* pFile);
// Read file until reaching the end of the file, or the specified char.
extern BOOL _ReadTil(const char nChar, char* buffer, unsigned int nSize, DWORD* pCharsRead, FILE* pFile) noexcept;
// Read a string til the end of the string, or nChar. bTerminate==TRUE replaces that char with \0.
extern char* _ReadStringTil(char nChar, char*& pOffsetInOut, BOOL bTerminate);
// Read a string til the end of the string, or nChar. bTerminate==TRUE replaces that char with \0.
extern char* _ReadStringTil(char nChar, char* restrict& pOffsetInOut, BOOL bTerminate) noexcept;
extern void _ReadStringTil(std::string& sValue, char nChar, const char*& pOffsetInOut);
// Write out the buffer to a file
// Write out the buffer to a file
extern void _WriteBufferToFile(const std::wstring& sFileName, const std::string& sString);
// Fetch various interim txt/data files
// Fetch various interim txt/data files
extern void _FetchGameHashLibraryFromWeb();
extern void _FetchGameTitlesFromWeb();
extern void _FetchMyProgressFromWeb();
@@ -44,10 +44,10 @@ extern void _FetchMyProgressFromWeb();
extern std::string _TimeStampToString(time_t nTime);
_NODISCARD std::string GetFolderFromDialog() noexcept;
_NODISCARD std::string GetFolderFromDialog();
void DownloadAndActivateAchievementData(unsigned int nGameID);
BOOL CanCausePause();
BOOL CanCausePause() noexcept;
void RestoreWindowPosition(HWND hDlg, const char* sDlgKey, bool bToRight, bool bToBottom);
void RememberWindowPosition(HWND hDlg, const char* sDlgKey);
+4 -4
View File
@@ -62,8 +62,8 @@ _CONSTANT_VAR MAX_BUFSIZ{ BUFSIZ*128U }; // Try not to use this one
class RARect : public RECT
{
public:
RARect() {}
RARect(LONG nX, LONG nY, LONG nW, LONG nH)
RARect() noexcept = default;
explicit RARect(LONG nX, LONG nY, LONG nW, LONG nH) noexcept
{
left = nX;
right = nX + nW;
@@ -72,8 +72,8 @@ public:
}
public:
inline int Width() const { return(right - left); }
inline int Height() const { return(bottom - top); }
_NODISCARD _CONSTANT_FN Width() const noexcept { return (right - left); }
_NODISCARD _CONSTANT_FN Height() const noexcept { return (bottom - top); }
};
class ResizeContent
+12 -11
View File
@@ -43,7 +43,7 @@ Dlg_AchievementEditor g_AchievementEditorDialog;
std::vector<ResizeContent> vDlgAchEditorResize;
POINT pDlgAchEditorMin;
INT_PTR CALLBACK AchProgressProc(HWND hDlg, UINT nMsg, WPARAM wParam, _UNUSED LPARAM)
INT_PTR CALLBACK AchProgressProc(HWND hDlg, UINT nMsg, WPARAM wParam, _UNUSED LPARAM) noexcept
{
switch (nMsg)
{
@@ -78,7 +78,7 @@ INT_PTR CALLBACK AchProgressProc(HWND hDlg, UINT nMsg, WPARAM wParam, _UNUSED LP
return FALSE;
}
Dlg_AchievementEditor::Dlg_AchievementEditor()
Dlg_AchievementEditor::Dlg_AchievementEditor() noexcept
{
for (size_t i = 0; i < MAX_CONDITIONS; ++i)
{
@@ -132,7 +132,7 @@ void Dlg_AchievementEditor::SetupColumns(HWND hList)
// bSuccess = ListView_EnableGroupView( hGroupList, FALSE );
}
BOOL Dlg_AchievementEditor::IsActive() const
BOOL Dlg_AchievementEditor::IsActive() const noexcept
{
return (g_AchievementEditorDialog.GetHWND() != nullptr) && (IsWindowVisible(g_AchievementEditorDialog.GetHWND()));
}
@@ -226,7 +226,7 @@ HWND g_hIPEEdit;
int nSelItem;
int nSelSubItem;
long _stdcall EditProc(HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK EditProc(HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam) noexcept
{
switch (nMsg)
{
@@ -290,7 +290,7 @@ long _stdcall EditProc(HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
return CallWindowProc(EOldProc, hwnd, nMsg, wParam, lParam);
}
long _stdcall DropDownProc(HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK DropDownProc(HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam) noexcept
{
if (nMsg == WM_COMMAND)
{
@@ -656,7 +656,7 @@ BOOL CreateIPE(int nItem, CondSubItems nSubItem)
}
// static
LRESULT CALLBACK Dlg_AchievementEditor::ListViewWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK Dlg_AchievementEditor::ListViewWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) noexcept
{
switch (uMsg)
{
@@ -1828,7 +1828,8 @@ void Dlg_AchievementEditor::UpdateBadge(const std::string& sNewName)
UpdateSelectedBadgeImage(sNewName.c_str());
}
_Use_decl_annotations_ void Dlg_AchievementEditor::RepopulateGroupList(const Achievement* const pCheevo)
_Use_decl_annotations_ void
Dlg_AchievementEditor::RepopulateGroupList(const Achievement* const restrict pCheevo) noexcept
{
HWND hGroupList = GetDlgItem(m_hAchievementEditorDlg, IDC_RA_ACH_GROUP);
if (hGroupList == nullptr)
@@ -1854,7 +1855,7 @@ _Use_decl_annotations_ void Dlg_AchievementEditor::RepopulateGroupList(const Ach
}
}
_Use_decl_annotations_ void Dlg_AchievementEditor::PopulateConditions(const Achievement* const pCheevo)
_Use_decl_annotations_ void Dlg_AchievementEditor::PopulateConditions(const Achievement* const restrict pCheevo)
{
HWND hCondList = GetDlgItem(m_hAchievementEditorDlg, IDC_RA_LBX_CONDITIONS);
if (hCondList == nullptr)
@@ -2047,7 +2048,7 @@ void Dlg_AchievementEditor::LoadAchievement(Achievement* pCheevo, _UNUSED BOOL)
// RedrawWindow( hList, nullptr, nullptr, RDW_INVALIDATE );
}
inline char* Dlg_AchievementEditor::LbxDataAt(unsigned int nRow, CondSubItems nCol)
inline char* Dlg_AchievementEditor::LbxDataAt(unsigned int nRow, CondSubItems nCol) noexcept
{
return m_lbxData[nRow][ra::etoi(nCol)];
}
@@ -2072,7 +2073,7 @@ void Dlg_AchievementEditor::OnLoad_NewRom()
}
}
size_t Dlg_AchievementEditor::GetSelectedConditionGroup() const
size_t Dlg_AchievementEditor::GetSelectedConditionGroup() const noexcept
{
HWND hList = GetDlgItem(g_AchievementEditorDialog.GetHWND(), IDC_RA_ACH_GROUP);
const int nSel = ListBox_GetCurSel(hList);
@@ -2085,7 +2086,7 @@ size_t Dlg_AchievementEditor::GetSelectedConditionGroup() const
return static_cast<size_t>(nSel);
}
void Dlg_AchievementEditor::SetSelectedConditionGroup(size_t nGrp) const
void Dlg_AchievementEditor::SetSelectedConditionGroup(size_t nGrp) const noexcept
{
HWND hList = GetDlgItem(g_AchievementEditorDialog.GetHWND(), IDC_RA_ACH_GROUP);
ListBox_SetCurSel(hList, static_cast<int>(nGrp));
+17 -18
View File
@@ -10,7 +10,7 @@
class BadgeNames
{
public:
void InstallAchEditorCombo(HWND hCombo) { m_hDestComboBox = hCombo; }
void InstallAchEditorCombo(HWND hCombo) noexcept { m_hDestComboBox = hCombo; }
void FetchNewBadgeNamesThreaded();
void AddNewBadgeName(const char* pStr, bool bAndSelect);
@@ -21,11 +21,10 @@ private:
};
enum class CondSubItems : std::size_t;
class Dlg_AchievementEditor
{
public:
Dlg_AchievementEditor();
Dlg_AchievementEditor() noexcept;
public:
static INT_PTR CALLBACK s_AchievementEditorProc(HWND, UINT, WPARAM, LPARAM);
@@ -35,36 +34,36 @@ public:
void OnLoad_NewRom();
void LoadAchievement(Achievement* pCheevo, _UNUSED BOOL);
inline void SetICEControl(HWND hIce) { m_hICEControl = hIce; }
inline char* LbxDataAt(unsigned int nRow, CondSubItems nCol);
inline void SetICEControl(HWND hIce) noexcept { m_hICEControl = hIce; }
inline char* LbxDataAt(unsigned int nRow, CondSubItems nCol) noexcept;
HWND GetICEControl() const { return m_hICEControl; }
HWND GetICEControl() const noexcept { return m_hICEControl; }
void InstallHWND(HWND hWnd) { m_hAchievementEditorDlg = hWnd; }
HWND GetHWND() const { return m_hAchievementEditorDlg; }
BOOL IsActive() const;
void InstallHWND(HWND hWnd) noexcept { m_hAchievementEditorDlg = hWnd; }
HWND GetHWND() const noexcept { return m_hAchievementEditorDlg; }
BOOL IsActive() const noexcept;
Achievement* ActiveAchievement() const { return m_pSelectedAchievement; }
BOOL IsPopulatingAchievementEditorData() const { return m_bPopulatingAchievementEditorData; }
void SetIgnoreEdits(BOOL bIgnore) { m_bPopulatingAchievementEditorData = bIgnore; }
Achievement* ActiveAchievement() const noexcept { return m_pSelectedAchievement; }
BOOL IsPopulatingAchievementEditorData() const noexcept { return m_bPopulatingAchievementEditorData; }
void SetIgnoreEdits(BOOL bIgnore) noexcept { m_bPopulatingAchievementEditorData = bIgnore; }
void UpdateBadge(const std::string& sNewName); // Call to set/update data
void UpdateSelectedBadgeImage(
const std::string& sBackupBadgeToUse = ""); // Call to just update the badge image/bitmap
BadgeNames& GetBadgeNames() { return m_BadgeNames; }
BadgeNames& GetBadgeNames() noexcept { return m_BadgeNames; }
size_t GetSelectedConditionGroup() const;
void SetSelectedConditionGroup(size_t nGrp) const;
size_t GetSelectedConditionGroup() const noexcept;
void SetSelectedConditionGroup(size_t nGrp) const noexcept;
ConditionGroup m_ConditionClipboard;
private:
void RepopulateGroupList(_In_ const Achievement* const pCheevo);
void PopulateConditions(_In_ const Achievement* const pCheevo);
void RepopulateGroupList(_In_ const Achievement* const restrict pCheevo) noexcept;
void PopulateConditions(_In_ const Achievement* const restrict pCheevo);
void SetupColumns(HWND hList);
static LRESULT CALLBACK ListViewWndProc(HWND, UINT, WPARAM, LPARAM);
static LRESULT CALLBACK ListViewWndProc(HWND, UINT, WPARAM, LPARAM) noexcept;
void GetListViewTooltip();
const int AddCondition(HWND hList, const Condition& Cond, unsigned int nCurrentHits);
+2 -2
View File
@@ -1055,7 +1055,7 @@ INT_PTR Dlg_Achievements::CommitAchievements(HWND hDlg)
return TRUE;
}
void Dlg_Achievements::UpdateSelectedAchievementButtons(const Achievement* Cheevo)
void Dlg_Achievements::UpdateSelectedAchievementButtons(const Achievement* restrict Cheevo) noexcept
{
if (Cheevo == nullptr)
{
@@ -1216,7 +1216,7 @@ void Dlg_Achievements::OnEditData(size_t nItem, Column nColumn, const std::strin
}
}
int Dlg_Achievements::GetSelectedAchievementIndex()
int Dlg_Achievements::GetSelectedAchievementIndex() noexcept
{
HWND hList = GetDlgItem(m_hAchievementsDlg, IDC_RA_LISTACHIEVEMENTS);
return ListView_GetSelectionMark(hList);
+4 -4
View File
@@ -28,7 +28,7 @@ public:
INT_PTR AchievementsProc(HWND, UINT, WPARAM, LPARAM);
public:
int GetSelectedAchievementIndex();
int GetSelectedAchievementIndex() noexcept;
void OnLoad_NewRom(unsigned int nGameID);
void OnGet_Achievement(const Achievement& ach);
void ReloadLBXData(int nOffset);
@@ -47,8 +47,8 @@ public:
return rowRef.at(ra::etoi(nCol));
}
inline HWND GetHWND() const { return m_hAchievementsDlg; }
void InstallHWND(HWND hWnd) { m_hAchievementsDlg = hWnd; }
inline HWND GetHWND() const noexcept { return m_hAchievementsDlg; }
void InstallHWND(HWND hWnd) noexcept { m_hAchievementsDlg = hWnd; }
private:
void SetupColumns(HWND hList);
@@ -60,7 +60,7 @@ private:
INT_PTR CommitAchievements(HWND hDlg);
void UpdateSelectedAchievementButtons(const Achievement* Cheevo);
void UpdateSelectedAchievementButtons(const Achievement* restrict Cheevo) noexcept;
private:
HWND m_hAchievementsDlg = nullptr;
+1 -1
View File
@@ -254,7 +254,7 @@ INT_PTR CALLBACK Dlg_AchievementsReporter::AchievementsReporterProc(HWND hDlg, U
}
//static
void Dlg_AchievementsReporter::DoModalDialog(HINSTANCE hInst, HWND hParent)
void Dlg_AchievementsReporter::DoModalDialog(HINSTANCE hInst, HWND hParent) noexcept
{
if (g_pActiveAchievements->NumAchievements() == 0)
MessageBox(hParent, TEXT("No ROM loaded!"), TEXT("Error"), MB_OK);
+1 -1
View File
@@ -30,7 +30,7 @@ class Dlg_AchievementsReporter
inline static constexpr std::array<int, 5> COL_SIZE{ 19, 105, 205, 75, 62 };
public:
static void DoModalDialog(HINSTANCE hInst, HWND hParent);
static void DoModalDialog(HINSTANCE hInst, HWND hParent) noexcept;
static INT_PTR CALLBACK AchievementsReporterProc(HWND, UINT, WPARAM, _UNUSED LPARAM);
public:
+5 -5
View File
@@ -18,7 +18,6 @@ namespace {
inline constexpr std::array<LPCTSTR, 4> COL_TITLE{ _T("ID"), _T("Game Title"), _T("Completion"), _T("File Path") };
inline constexpr std::array<int, 4> COL_SIZE{ 30, 230, 110, 170 };
static_assert(SIZEOF_ARRAY(COL_TITLE) == SIZEOF_ARRAY(COL_SIZE), "Must match!");
inline constexpr auto bCancelScan = false;
std::mutex mtx;
@@ -79,7 +78,7 @@ bool ListFiles(std::string path, std::string mask, std::deque<std::string>& rFil
namespace ra {
inline static void LogErrno() noexcept
GSL_SUPPRESS(f.6) inline static void LogErrno() noexcept
{
char buf[2048U]{};
strerror_s(buf, errno);
@@ -250,10 +249,11 @@ void Dlg_GameLibrary::AddTitle(const std::string& sTitle, const std::string& sFi
item.iSubItem = 3;
ListView_SetItemText(hList, item.iItem, 3, NativeStr(sFilename).data());
m_vGameEntries.push_back(GameEntry(sTitle, sFilename, nGameID));
// NB: Perfect forwarding seems to cause an access violation here, so it's using an rvalue instead
m_vGameEntries.emplace_back(GameEntry(sTitle, sFilename, nGameID));
}
void Dlg_GameLibrary::ClearTitles()
void Dlg_GameLibrary::ClearTitles() noexcept
{
nNumParsed = 0;
@@ -289,7 +289,7 @@ void Dlg_GameLibrary::ThreadedScanProc()
// May have caused a buffer overrun, this is way to big to be on the stack
auto pBuf{ std::make_unique<unsigned char[]>(6 * 1024 * 1024) };
fread(static_cast<void*>(pBuf.get()), sizeof(unsigned char), nSize, pf); //Check
fread(static_cast<void*>(pBuf.get()), sizeof(unsigned char), nSize, pf); //Check
Results.insert_or_assign(FilesToScan.front(), RAGenerateMD5(pBuf.get(), nSize));
SendMessage(g_GameLibrary.GetHWND(), WM_TIMER, 0U, 0L);
+6 -6
View File
@@ -12,9 +12,9 @@ public:
{
}
const std::string& Title() const { return m_sTitle; }
const std::string& Filename() const { return m_sFilename; }
unsigned int GameID() const { return m_nGameID; }
const std::string& Title() const noexcept { return m_sTitle; }
const std::string& Filename() const noexcept { return m_sFilename; }
unsigned int GameID() const noexcept { return m_nGameID; }
const std::string m_sTitle;
const std::string m_sFilename;
@@ -29,11 +29,11 @@ public:
INT_PTR CALLBACK GameLibraryProc(HWND, UINT, WPARAM, LPARAM);
public:
void InstallHWND(HWND hWnd) { m_hDialogBox = hWnd; }
HWND GetHWND() const { return m_hDialogBox; }
void InstallHWND(HWND hWnd) noexcept { m_hDialogBox = hWnd; }
HWND GetHWND() const noexcept { return m_hDialogBox; }
void AddTitle(const std::string& sTitle, const std::string& sFilename, unsigned int nGameID);
void ClearTitles();
void ClearTitles() noexcept;
void LoadAll();
void SaveAll();
+1 -1
View File
@@ -14,7 +14,7 @@
#include "ui\viewmodels\MessageBoxViewModel.hh"
// static
BOOL RA_Dlg_Login::DoModalLogin()
INT_PTR RA_Dlg_Login::DoModalLogin() noexcept
{
return DialogBox(g_hThisDLLInst, MAKEINTRESOURCE(IDD_RA_LOGIN), g_RAMainWnd, RA_Dlg_Login::RA_Dlg_LoginProc);
}
+2 -2
View File
@@ -5,10 +5,10 @@
class RA_Dlg_Login
{
public:
static BOOL DoModalLogin();
static INT_PTR DoModalLogin() noexcept;
public:
static INT_PTR CALLBACK RA_Dlg_LoginProc(HWND, UINT, WPARAM, LPARAM);
static INT_PTR CALLBACK RA_Dlg_LoginProc(HWND, UINT, WPARAM, [[maybe_unused]] LPARAM);
};
+1 -1
View File
@@ -458,7 +458,7 @@ INT_PTR Dlg_MemBookmark::MemBookmarkDialogProc(HWND hDlg, UINT uMsg, WPARAM wPar
return FALSE;
}
BOOL Dlg_MemBookmark::IsActive() const
BOOL Dlg_MemBookmark::IsActive() const noexcept
{
return(g_MemBookmarkDialog.GetHWND() != nullptr) && (IsWindowVisible(g_MemBookmarkDialog.GetHWND()));
}
+19 -19
View File
@@ -8,25 +8,25 @@ class MemBookmark
{
public:
void SetDescription(const std::wstring& string) { m_sDescription = string; }
void SetAddress(unsigned int nVal) { m_nAddress = nVal; }
void SetType(unsigned int nVal) { m_nType = nVal; }
void SetValue(unsigned int nVal) { m_sValue = nVal; }
void SetPrevious(unsigned int nVal) { m_sPrevious = nVal; }
void IncreaseCount() { m_nCount++; }
void ResetCount() { m_nCount = 0; }
void SetAddress(unsigned int nVal) noexcept { m_nAddress = nVal; }
void SetType(unsigned int nVal) noexcept { m_nType = nVal; }
void SetValue(unsigned int nVal) noexcept { m_sValue = nVal; }
void SetPrevious(unsigned int nVal) noexcept { m_sPrevious = nVal; }
void IncreaseCount() noexcept { m_nCount++; }
void ResetCount() noexcept { m_nCount = 0; }
void SetFrozen(bool b) { m_bFrozen = b; }
void SetDecimal(bool b) { m_bDecimal = b; }
void SetFrozen(bool b) noexcept { m_bFrozen = b; }
void SetDecimal(bool b) noexcept { m_bDecimal = b; }
inline const std::wstring& Description() const { return m_sDescription; }
unsigned int Address() const { return m_nAddress; }
unsigned int Type() const { return m_nType; }
unsigned int Value() const { return m_sValue; }
unsigned int Previous() const { return m_sPrevious; }
unsigned int Count() const { return m_nCount; }
inline const std::wstring& Description() const noexcept { return m_sDescription; }
unsigned int Address() const noexcept { return m_nAddress; }
unsigned int Type() const noexcept { return m_nType; }
unsigned int Value() const noexcept { return m_sValue; }
unsigned int Previous() const noexcept { return m_sPrevious; }
unsigned int Count() const noexcept { return m_nCount; }
bool Frozen() const { return m_bFrozen; }
bool Decimal() const { return m_bDecimal; }
bool Frozen() const noexcept { return m_bFrozen; }
bool Decimal() const noexcept { return m_bDecimal; }
private:
std::wstring m_sDescription;
@@ -55,9 +55,9 @@ public:
static INT_PTR CALLBACK s_MemBookmarkDialogProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR MemBookmarkDialogProc(HWND, UINT, WPARAM, LPARAM);
void InstallHWND(HWND hWnd) { m_hMemBookmarkDialog = hWnd; }
HWND GetHWND() const { return m_hMemBookmarkDialog; }
BOOL IsActive() const;
void InstallHWND(HWND hWnd) noexcept { m_hMemBookmarkDialog = hWnd; }
HWND GetHWND() const noexcept { return m_hMemBookmarkDialog; }
BOOL IsActive() const noexcept;
std::vector<MemBookmark*> Bookmarks() { return m_vBookmarks; }
void UpdateBookmarks(bool bForceWrite);
+178 -148
View File
@@ -2,18 +2,18 @@
#include "RA_AchievementSet.h"
#include "RA_Core.h"
#include "RA_httpthread.h"
#include "RA_Dlg_MemBookmark.h"
#include "RA_Resource.h"
#include "RA_User.h"
#include "RA_Dlg_MemBookmark.h"
#include "RA_httpthread.h"
#include "data\GameContext.hh"
#ifndef ID_OK
#define ID_OK 1024
#define ID_OK 1024
#endif
#ifndef ID_CANCEL
#define ID_CANCEL 1025
#define ID_CANCEL 1025
#endif
namespace {
@@ -21,11 +21,11 @@ namespace {
const size_t MIN_RESULTS_TO_DUMP = 500000;
const size_t MIN_SEARCH_PAGE_SIZE = 50;
}
} // namespace
Dlg_Memory g_MemoryDialog;
//static
// static
CodeNotes Dlg_Memory::m_CodeNotes;
HWND Dlg_Memory::m_hWnd = nullptr;
@@ -66,8 +66,7 @@ _NODISCARD _CONSTANT_FN GetMaxNibble(_In_ MemSize size) noexcept
}
}
INT_PTR CALLBACK MemoryViewerControl::s_MemoryDrawProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK MemoryViewerControl::s_MemoryDrawProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
@@ -93,18 +92,18 @@ INT_PTR CALLBACK MemoryViewerControl::s_MemoryDrawProc(HWND hDlg, UINT uMsg, WPA
return FALSE;
case WM_LBUTTONUP:
OnClick({ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) });
OnClick({GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)});
return FALSE;
case WM_KEYDOWN:
return(!OnKeyDown(static_cast<UINT>(LOWORD(wParam))));
return (!OnKeyDown(static_cast<UINT>(LOWORD(wParam))));
case WM_CHAR:
return(!OnEditInput(static_cast<UINT>(LOWORD(wParam))));
return (!OnEditInput(static_cast<UINT>(LOWORD(wParam))));
}
return DefWindowProc(hDlg, uMsg, wParam, lParam);
//return FALSE;
// return FALSE;
}
bool MemoryViewerControl::OnKeyDown(UINT nChar)
@@ -137,11 +136,11 @@ bool MemoryViewerControl::OnKeyDown(UINT nChar)
moveAddress(-0x10, 0);
return true;
case VK_PRIOR: // Page up (!)
case VK_PRIOR: // Page up (!)
moveAddress(-(int)(m_nDisplayedLines << 4), 0);
return true;
case VK_NEXT: // Page down (!)
case VK_NEXT: // Page down (!)
moveAddress((m_nDisplayedLines << 4), 0);
return true;
@@ -208,7 +207,6 @@ void MemoryViewerControl::moveAddress(int offset, int nibbleOff)
if (offset < 0)
{
if (m_nEditAddress > (m_nAddressOffset - 1 + (m_nDisplayedLines << 4)) && (signed)m_nEditAddress < (0x10))
{
m_nEditAddress -= offset;
@@ -238,13 +236,13 @@ void MemoryViewerControl::moveAddress(int offset, int nibbleOff)
void MemoryViewerControl::setAddress(unsigned int address)
{
m_nAddressOffset = address;
//g_MemoryDialog.SetWatchingAddress( address );
// g_MemoryDialog.SetWatchingAddress( address );
SetCaretPos();
Invalidate();
}
void MemoryViewerControl::setWatchedAddress(unsigned int address)
void MemoryViewerControl::setWatchedAddress(unsigned int address) noexcept
{
if (m_nWatchedAddress != address)
{
@@ -253,15 +251,17 @@ void MemoryViewerControl::setWatchedAddress(unsigned int address)
}
}
void MemoryViewerControl::Invalidate()
void MemoryViewerControl::Invalidate() noexcept
{
HWND hOurDlg = GetDlgItem(g_MemoryDialog.GetHWND(), IDC_RA_MEMTEXTVIEWER);
if (hOurDlg != nullptr)
{
InvalidateRect(hOurDlg, nullptr, FALSE);
// In RALibRetro, s_MemoryDrawProc doesn't seem to be getting trigger by the InvalidateRect, so explicitly force the render by calling UpdateWindow
// TODO: figure out why this is necessary and remove it. There's a similar check in Dlg_Memory::Invalidate for the search results
// In RALibRetro, s_MemoryDrawProc doesn't seem to be getting trigger by the InvalidateRect, so explicitly force
// the render by calling UpdateWindow
// TODO: figure out why this is necessary and remove it. There's a similar check in Dlg_Memory::Invalidate for
// the search results
if (g_EmulatorID == RA_Libretro)
UpdateWindow(hOurDlg);
}
@@ -316,8 +316,8 @@ bool MemoryViewerControl::OnEditInput(UINT c)
if (value != 256)
{
//value <<= 4*(maxNibble-m_nEditNibble);
//unsigned int mask = ~(15 << 4*(maxNibble - m_nEditNibble));
// value <<= 4*(maxNibble-m_nEditNibble);
// unsigned int mask = ~(15 << 4*(maxNibble - m_nEditNibble));
const bool bLowerNibble = (m_nEditNibble % 2 == 1);
unsigned int nByteAddress = m_nEditAddress;
@@ -332,7 +332,7 @@ bool MemoryViewerControl::OnEditInput(UINT c)
if (m_nDataSize == MemSize::EightBit)
{
// 8 bit
//nByteAddress = m_nEditAddress;
// nByteAddress = m_nEditAddress;
}
else if (m_nDataSize == MemSize::SixteenBit)
{
@@ -357,7 +357,7 @@ bool MemoryViewerControl::OnEditInput(UINT c)
return true;
}
void MemoryViewerControl::createEditCaret(int w, int h)
void MemoryViewerControl::createEditCaret(int w, int h) noexcept
{
if (!m_bHasCaret || ra::to_signed(m_nCaretWidth) != w || ra::to_signed(m_nCaretHeight) != h)
{
@@ -368,7 +368,7 @@ void MemoryViewerControl::createEditCaret(int w, int h)
}
}
void MemoryViewerControl::destroyEditCaret()
void MemoryViewerControl::destroyEditCaret() noexcept
{
m_bHasCaret = false;
DestroyCaret();
@@ -393,7 +393,7 @@ void MemoryViewerControl::SetCaretPos()
const int linePosition = (subAddress & ~(0xF)) / (0x10) + 4;
if (linePosition < 0 || linePosition >(int)m_nDisplayedLines - 1)
if (linePosition < 0 || linePosition > (int)m_nDisplayedLines - 1)
{
destroyEditCaret();
@@ -402,21 +402,21 @@ void MemoryViewerControl::SetCaretPos()
const int nYSpacing = linePosition;
int x = 3 + (10 * m_szFontSize.cx) + (m_nEditNibble*m_szFontSize.cx);
int y = 3 + (nYSpacing*m_szFontSize.cy);
int x = 3 + (10 * m_szFontSize.cx) + (m_nEditNibble * m_szFontSize.cx);
int y = 3 + (nYSpacing * m_szFontSize.cy);
y += m_szFontSize.cy; // Account for header
y += m_szFontSize.cy; // Account for header
switch (m_nDataSize)
{
case MemSize::EightBit:
x += 3 * m_szFontSize.cx*(subAddress & 15);
x += 3 * m_szFontSize.cx * (subAddress & 15);
break;
case MemSize::SixteenBit:
x += 5 * m_szFontSize.cx*((subAddress >> 1) & 7);
x += 5 * m_szFontSize.cx * ((subAddress >> 1) & 7);
break;
case MemSize::ThirtyTwoBit:
x += 9 * m_szFontSize.cx*((subAddress >> 2) & 3);
x += 9 * m_szFontSize.cx * ((subAddress >> 2) & 3);
break;
}
@@ -446,11 +446,11 @@ void MemoryViewerControl::OnClick(POINT point)
HWND hOurDlg = GetDlgItem(g_MemoryDialog.GetHWND(), IDC_RA_MEMTEXTVIEWER);
int x = point.x;
const int y = point.y - m_szFontSize.cy; // Adjust for header
const int y = point.y - m_szFontSize.cy; // Adjust for header
const int line = ((y - 3) / m_szFontSize.cy);
if (line == -1 || line >= (int)m_nDisplayedLines)
return; // clicked on header
return; // clicked on header
int rowLengthPx = m_nDataStartXOffset;
int inc = 1;
@@ -460,18 +460,18 @@ void MemoryViewerControl::OnClick(POINT point)
{
case MemSize::EightBit:
rowLengthPx += 47 * m_szFontSize.cx;
inc = 1; // increment mem offset by 1 each subset
sub = 3 * m_szFontSize.cx; // 2 char set plus one char space
inc = 1; // increment mem offset by 1 each subset
sub = 3 * m_szFontSize.cx; // 2 char set plus one char space
break;
case MemSize::SixteenBit:
rowLengthPx += 39 * m_szFontSize.cx;
inc = 2; // increment mem offset by 2 each subset
sub = 5 * m_szFontSize.cx; // 4 char set plus one char space
inc = 2; // increment mem offset by 2 each subset
sub = 5 * m_szFontSize.cx; // 4 char set plus one char space
break;
case MemSize::ThirtyTwoBit:
rowLengthPx += 35 * m_szFontSize.cx;
inc = 4; // increment mem offset by 4 each subset
sub = 9 * m_szFontSize.cx; // 8 char set plus one char space
inc = 4; // increment mem offset by 4 each subset
sub = 9 * m_szFontSize.cx; // 8 char set plus one char space
break;
}
@@ -479,16 +479,15 @@ void MemoryViewerControl::OnClick(POINT point)
const int nAddressRowClicked = (nTopLeft + (line << 4));
// Clamp:
if (nAddressRowClicked < 0 || nAddressRowClicked >(int)g_MemManager.TotalBankSize())
// Clamp:
if (nAddressRowClicked < 0 || nAddressRowClicked > (int)g_MemManager.TotalBankSize())
{
// ignore; clicked above limit
// ignore; clicked above limit
return;
}
m_nEditAddress = static_cast<unsigned int>(nAddressRowClicked);
if (x >= (int)m_nDataStartXOffset && x < rowLengthPx)
{
x -= m_nDataStartXOffset;
@@ -496,14 +495,13 @@ void MemoryViewerControl::OnClick(POINT point)
while (x > 0)
{
// Adjust x by one subset til we find out the correct offset:
// Adjust x by one subset til we find out the correct offset:
x -= sub;
if (x >= 0)
m_nEditAddress += inc;
else
m_nEditNibble = (x + sub) / m_szFontSize.cx;
}
}
else
{
@@ -637,7 +635,8 @@ void MemoryViewerControl::RenderMemViewer(HWND hTarget)
break;
}
DrawText(hMemDC, NativeStr(bufferNative).c_str(), ptr - bufferNative, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
DrawText(hMemDC, NativeStr(bufferNative).c_str(), ptr - bufferNative, &r,
DT_TOP | DT_LEFT | DT_NOPREFIX);
if ((ra::to_signed(m_nWatchedAddress) & ~0x0F) == addr)
{
@@ -753,35 +752,33 @@ void MemoryViewerControl::RenderMemViewer(HWND hTarget)
EndPaint(hTarget, &ps);
}
void Dlg_Memory::Init()
void Dlg_Memory::Init() noexcept
{
WNDCLASS wc;
ZeroMemory(&wc, sizeof(wc));
wc.style = CS_PARENTDC | CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
wc.lpfnWndProc = (WNDPROC)MemoryViewerControl::s_MemoryDrawProc;
WNDCLASSEX wc{sizeof(WNDCLASSEX)};
wc.style = ra::to_unsigned(CS_PARENTDC | CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS);
wc.lpfnWndProc = MemoryViewerControl::s_MemoryDrawProc;
wc.hInstance = g_hThisDLLInst;
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = nullptr;
wc.hbrBackground = GetStockBrush(WHITE_BRUSH);
wc.lpszClassName = TEXT("MemoryViewerControl");
RegisterClass(&wc);
[[maybe_unused]] const auto checkAtom = ::RegisterClassEx(&wc);
ASSERT(checkAtom != 0);
}
//static
// static
INT_PTR CALLBACK Dlg_Memory::s_MemoryProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return g_MemoryDialog.MemoryProc(hDlg, uMsg, wParam, lParam);
}
void Dlg_Memory::ClearLogOutput()
void Dlg_Memory::ClearLogOutput() noexcept
{
ListView_SetItemCount(GetDlgItem(m_hWnd, IDC_RA_MEM_LIST), 1);
EnableWindow(GetDlgItem(m_hWnd, IDC_RA_RESULTS_BACK), FALSE);
EnableWindow(GetDlgItem(m_hWnd, IDC_RA_RESULTS_FORWARD), FALSE);
}
INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
switch (nMsg)
@@ -810,8 +807,10 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
SetDlgItemText(hDlg, IDC_RA_WATCHING, TEXT("0x0000"));
SendMessage(GetDlgItem(hDlg, IDC_RA_MEMBITS), WM_SETFONT, reinterpret_cast<WPARAM>(GetStockObject(SYSTEM_FIXED_FONT)), TRUE);
SendMessage(GetDlgItem(hDlg, IDC_RA_MEMBITS_TITLE), WM_SETFONT, reinterpret_cast<WPARAM>(GetStockObject(SYSTEM_FIXED_FONT)), TRUE);
SendMessage(GetDlgItem(hDlg, IDC_RA_MEMBITS), WM_SETFONT,
reinterpret_cast<WPARAM>(GetStockObject(SYSTEM_FIXED_FONT)), TRUE);
SendMessage(GetDlgItem(hDlg, IDC_RA_MEMBITS_TITLE), WM_SETFONT,
reinterpret_cast<WPARAM>(GetStockObject(SYSTEM_FIXED_FONT)), TRUE);
// 8-bit by default:
CheckDlgButton(hDlg, IDC_RA_CBO_4BIT, BST_UNCHECKED);
@@ -823,7 +822,7 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
CheckDlgButton(hDlg, IDC_RA_MEMVIEW16BIT, BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_RA_MEMVIEW32BIT, BST_UNCHECKED);
MemoryProc(hDlg, WM_COMMAND, IDC_RA_CBO_8BIT, 0); // Imitate a buttonpress of '8-bit'
MemoryProc(hDlg, WM_COMMAND, IDC_RA_CBO_8BIT, 0); // Imitate a buttonpress of '8-bit'
g_MemoryDialog.OnLoad_NewRom();
// Add a single column for list view
@@ -836,12 +835,13 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
{
Col.iOrder = i;
Col.iSubItem = i;
ra::tstring str{ _T("Search Result") };
ra::tstring str{_T("Search Result")};
Col.pszText = str.data();
Col.cx = rc.right - rc.left - 24;
ListView_InsertColumn(GetDlgItem(hDlg, IDC_RA_MEM_LIST), i, &Col);
}
ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, IDC_RA_MEM_LIST), LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, IDC_RA_MEM_LIST),
LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
CheckDlgButton(hDlg, IDC_RA_RESULTS_HIGHLIGHT, BST_CHECKED);
@@ -862,6 +862,7 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
return TRUE;
case WM_DRAWITEM:
{
LPDRAWITEMSTRUCT pDIS;
HWND hListbox;
@@ -891,14 +892,17 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
SetTextColor(pDIS->hDC, RGB(0, 100, 150));
const unsigned int nMatches = m_SearchResults[m_nPage].m_results.MatchingAddressCount();
if (nMatches > MIN_RESULTS_TO_DUMP)
_stprintf_s(buffer, sizeof(buffer), _T("Found %u matches! (Displaying first %u results)"), nMatches, MIN_RESULTS_TO_DUMP);
_stprintf_s(buffer, sizeof(buffer),
_T("Found %u matches! (Displaying first %u results)"), nMatches,
MIN_RESULTS_TO_DUMP);
else if (nMatches == 0)
_stprintf_s(buffer, sizeof(buffer), _T("Found *ZERO* matches!"));
else
_stprintf_s(buffer, sizeof(buffer), _T("Found %u matches!"), nMatches);
}
DrawText(pDIS->hDC, buffer, _tcslen(buffer), &pDIS->rcItem, DT_SINGLELINE | DT_LEFT | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER | DT_END_ELLIPSIS);
DrawText(pDIS->hDC, buffer, _tcslen(buffer), &pDIS->rcItem,
DT_SINGLELINE | DT_LEFT | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER | DT_END_ELLIPSIS);
SetTextColor(pDIS->hDC, GetSysColor(COLOR_WINDOWTEXT));
}
else
@@ -952,11 +956,13 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
DeleteObject(hBrush);
std::wstring sBufferWide = ra::Widen(buffer);
DrawTextW(pDIS->hDC, sBufferWide.c_str(), sBufferWide.length(), &pDIS->rcItem, DT_SINGLELINE | DT_LEFT | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER | DT_END_ELLIPSIS);
DrawTextW(pDIS->hDC, sBufferWide.c_str(), sBufferWide.length(), &pDIS->rcItem,
DT_SINGLELINE | DT_LEFT | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER | DT_END_ELLIPSIS);
}
}
}
return TRUE;
}
case WM_NOTIFY:
{
@@ -976,7 +982,8 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
if (!m_SearchResults[m_nPage].m_results.GetMatchingAddress(nSelect - 2, result))
break;
ComboBox_SetText(GetDlgItem(hDlg, IDC_RA_WATCHING), NativeStr(ra::ByteAddressToString(result.nAddress)).c_str());
ComboBox_SetText(GetDlgItem(hDlg, IDC_RA_WATCHING),
NativeStr(ra::ByteAddressToString(result.nAddress)).c_str());
const CodeNotes::CodeNoteObj* pSavedNote = m_CodeNotes.FindCodeNote(result.nAddress);
if ((pSavedNote != nullptr) && (pSavedNote->Note().length() > 0))
@@ -984,7 +991,9 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
else
SetDlgItemText(hDlg, IDC_RA_MEMSAVENOTE, _T(""));
MemoryViewerControl::setAddress((result.nAddress & ~(0xf)) - ((int)(MemoryViewerControl::m_nDisplayedLines / 2) << 4) + (0x50));
MemoryViewerControl::setAddress((result.nAddress & ~(0xf)) -
((int)(MemoryViewerControl::m_nDisplayedLines / 2) << 4) +
(0x50));
MemoryViewerControl::setWatchedAddress(result.nAddress);
UpdateBits();
}
@@ -1002,19 +1011,19 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
lpmmi->ptMaxTrackSize.x = pDlgMemoryMin.x;
lpmmi->ptMinTrackSize = pDlgMemoryMin;
}
return TRUE;
return TRUE;
case WM_SIZE:
{
RARect winRect;
GetWindowRect(hDlg, &winRect);
for (ResizeContent content : vDlgMemoryResize)
for (ResizeContent& content : vDlgMemoryResize)
content.Resize(winRect.Width(), winRect.Height());
RememberWindowSize(hDlg, "Memory Inspector");
return TRUE;
}
return TRUE;
case WM_MOVE:
RememberWindowPosition(hDlg, "Memory Inspector");
@@ -1027,12 +1036,13 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
case IDC_RA_DOTEST:
{
if (g_MemManager.NumMemoryBanks() == 0)
return TRUE; // Ignored
return TRUE; // Ignored
if (g_MemManager.TotalBankSize() == 0)
return TRUE; // Handled
return TRUE; // Handled
const ComparisonType nCmpType = static_cast<ComparisonType>(ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_RA_CBO_CMPTYPE)));
const ComparisonType nCmpType =
static_cast<ComparisonType>(ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_RA_CBO_CMPTYPE)));
while (m_SearchResults.size() > m_nPage + 1)
m_SearchResults.pop_back();
@@ -1088,7 +1098,8 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
sr.m_nCompareType == srPrevious.m_nCompareType &&
sr.m_nLastQueryVal == srPrevious.m_nLastQueryVal)
{
// comparing against last value for non-equals case may result in different match highlights, keep it.
// comparing against last value for non-equals case may result in different match
// highlights, keep it.
if (!sr.m_bUseLastValue || sr.m_nCompareType == ComparisonType::Equals)
{
m_SearchResults.erase(m_SearchResults.end() - 1);
@@ -1103,8 +1114,8 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
ListView_SetItemCount(GetDlgItem(hDlg, IDC_RA_MEM_LIST), nMatches + 2);
EnableWindow(GetDlgItem(hDlg, IDC_RA_DOTEST), nMatches > 0);
return TRUE;
}
return TRUE;
case IDC_RA_MEMVIEW8BIT:
MemoryViewerControl::SetDataSize(MemSize::EightBit);
@@ -1132,7 +1143,7 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
case IDC_RA_CBO_16BIT:
case IDC_RA_CBO_32BIT:
{
MemSize nCompSize = MemSize::Nibble_Lower; // or upper, doesn't really matter
MemSize nCompSize = MemSize::Nibble_Lower; // or upper, doesn't really matter
if (SendDlgItemMessage(hDlg, IDC_RA_CBO_8BIT, BM_GETCHECK, 0, 0) == BST_CHECKED)
nCompSize = MemSize::EightBit;
else if (SendDlgItemMessage(hDlg, IDC_RA_CBO_16BIT, BM_GETCHECK, 0, 0) == BST_CHECKED)
@@ -1170,14 +1181,16 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
case IDC_RA_CBO_GIVENVAL:
case IDC_RA_CBO_LASTKNOWNVAL:
EnableWindow(GetDlgItem(hDlg, IDC_RA_TESTVAL), (IsDlgButtonChecked(hDlg, IDC_RA_CBO_GIVENVAL) == BST_CHECKED));
EnableWindow(GetDlgItem(hDlg, IDC_RA_TESTVAL),
(IsDlgButtonChecked(hDlg, IDC_RA_CBO_GIVENVAL) == BST_CHECKED));
return TRUE;
case IDC_RA_CBO_SEARCHALL:
case IDC_RA_CBO_SEARCHCUSTOM:
case IDC_RA_CBO_SEARCHSYSTEMRAM:
case IDC_RA_CBO_SEARCHGAMERAM:
EnableWindow(GetDlgItem(hDlg, IDC_RA_SEARCHRANGE), IsDlgButtonChecked(hDlg, IDC_RA_CBO_SEARCHCUSTOM) == BST_CHECKED);
EnableWindow(GetDlgItem(hDlg, IDC_RA_SEARCHRANGE),
IsDlgButtonChecked(hDlg, IDC_RA_CBO_SEARCHCUSTOM) == BST_CHECKED);
return TRUE;
case IDC_RA_ADDNOTE:
@@ -1192,22 +1205,21 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
const CodeNotes::CodeNoteObj* pSavedNote = m_CodeNotes.FindCodeNote(nAddr);
if ((pSavedNote != nullptr) && (pSavedNote->Note().length() > 0))
{
if (pSavedNote->Note().compare(sNewNote) != 0) // New note is different
if (pSavedNote->Note().compare(sNewNote) != 0) // New note is different
{
char sWarning[4096];
sprintf_s(sWarning, 4096,
"Address 0x%04x already stored with note:\n\n"
"%s\n"
"by %s\n"
"\n\n"
"Would you like to overwrite with\n\n"
"%s",
nAddr,
pSavedNote->Note().c_str(),
pSavedNote->Author().c_str(),
sNewNote.c_str());
"Address 0x%04x already stored with note:\n\n"
"%s\n"
"by %s\n"
"\n\n"
"Would you like to overwrite with\n\n"
"%s",
nAddr, pSavedNote->Note().c_str(), pSavedNote->Author().c_str(),
sNewNote.c_str());
if (MessageBoxW(hDlg, ra::Widen(sWarning).c_str(), L"Warning: overwrite note?", MB_YESNO) == IDYES)
if (MessageBoxW(hDlg, ra::Widen(sWarning).c_str(), L"Warning: overwrite note?", MB_YESNO) ==
IDYES)
m_CodeNotes.Add(nAddr, RAUsers::LocalUser().Username(), sNewNote);
}
else
@@ -1255,12 +1267,8 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
{
std::ostringstream oss;
oss << "http://" << _RA_HostName() << "/codenotes.php?g=" << pGameContext.GameId();
ShellExecute(nullptr,
_T("open"),
NativeStr(oss.str()).c_str(),
nullptr,
nullptr,
SW_SHOWNORMAL);
ShellExecute(nullptr, _T("open"), NativeStr(oss.str()).c_str(), nullptr, nullptr,
SW_SHOWNORMAL);
}
else
{
@@ -1273,7 +1281,9 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
case IDC_RA_OPENBOOKMARKS:
{
if (g_MemBookmarkDialog.GetHWND() == nullptr)
g_MemBookmarkDialog.InstallHWND(CreateDialog(g_hThisDLLInst, MAKEINTRESOURCE(IDD_RA_MEMBOOKMARK), hDlg, g_MemBookmarkDialog.s_MemBookmarkDialogProc));
g_MemBookmarkDialog.InstallHWND(CreateDialog(g_hThisDLLInst,
MAKEINTRESOURCE(IDD_RA_MEMBOOKMARK), hDlg,
g_MemBookmarkDialog.s_MemBookmarkDialogProc));
if (g_MemBookmarkDialog.GetHWND() != nullptr)
ShowWindow(g_MemBookmarkDialog.GetHWND(), SW_SHOW);
@@ -1290,7 +1300,8 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
if (sr.m_results.Summary().empty())
ListView_SetItemCount(GetDlgItem(hDlg, IDC_RA_MEM_LIST), 1);
else
ListView_SetItemCount(GetDlgItem(hDlg, IDC_RA_MEM_LIST), sr.m_results.MatchingAddressCount() + 2);
ListView_SetItemCount(GetDlgItem(hDlg, IDC_RA_MEM_LIST),
sr.m_results.MatchingAddressCount() + 2);
EnableWindow(GetDlgItem(hDlg, IDC_RA_DOTEST), sr.m_results.MatchingAddressCount() > 0);
return FALSE;
@@ -1306,7 +1317,8 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
if (sr.m_results.Summary().empty())
ListView_SetItemCount(GetDlgItem(hDlg, IDC_RA_MEM_LIST), 1);
else
ListView_SetItemCount(GetDlgItem(hDlg, IDC_RA_MEM_LIST), sr.m_results.MatchingAddressCount() + 2);
ListView_SetItemCount(GetDlgItem(hDlg, IDC_RA_MEM_LIST),
sr.m_results.MatchingAddressCount() + 2);
EnableWindow(GetDlgItem(hDlg, IDC_RA_DOTEST), sr.m_results.MatchingAddressCount() > 0);
return FALSE;
@@ -1351,12 +1363,16 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
TCHAR sAddr[64];
if (ComboBox_GetLBText(hMemWatch, nSel, sAddr) > 0)
{
ra::ByteAddress nAddr = static_cast<ra::ByteAddress>(std::strtoul(ra::Narrow(sAddr).c_str(), nullptr, 16));
ra::ByteAddress nAddr = static_cast<ra::ByteAddress>(
std::strtoul(ra::Narrow(sAddr).c_str(), nullptr, 16));
const CodeNotes::CodeNoteObj* pSavedNote = m_CodeNotes.FindCodeNote(nAddr);
if (pSavedNote != nullptr && pSavedNote->Note().length() > 0)
SetDlgItemTextW(hDlg, IDC_RA_MEMSAVENOTE, ra::Widen(pSavedNote->Note()).c_str());
SetDlgItemTextW(hDlg, IDC_RA_MEMSAVENOTE,
ra::Widen(pSavedNote->Note()).c_str());
MemoryViewerControl::setAddress((nAddr & ~(0xf)) - ((int)(MemoryViewerControl::m_nDisplayedLines / 2) << 4) + (0x50));
MemoryViewerControl::setAddress(
(nAddr & ~(0xf)) - ((int)(MemoryViewerControl::m_nDisplayedLines / 2) << 4) +
(0x50));
MemoryViewerControl::setWatchedAddress(nAddr);
UpdateBits();
}
@@ -1371,8 +1387,10 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
TCHAR sAddrBuffer[64];
GetDlgItemText(hDlg, IDC_RA_WATCHING, sAddrBuffer, 64);
ra::ByteAddress nAddr = static_cast<ra::ByteAddress>(std::strtoul(ra::Narrow(sAddrBuffer).c_str(), nullptr, 16));
MemoryViewerControl::setAddress((nAddr & ~(0xf)) - ((int)(MemoryViewerControl::m_nDisplayedLines / 2) << 4) + (0x50));
ra::ByteAddress nAddr = static_cast<ra::ByteAddress>(
std::strtoul(ra::Narrow(sAddrBuffer).c_str(), nullptr, 16));
MemoryViewerControl::setAddress(
(nAddr & ~(0xf)) - ((int)(MemoryViewerControl::m_nDisplayedLines / 2) << 4) + (0x50));
MemoryViewerControl::setWatchedAddress(nAddr);
UpdateBits();
return TRUE;
@@ -1380,7 +1398,7 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
default:
return FALSE;
//return DefWindowProc( hDlg, nMsg, wParam, lParam );
// return DefWindowProc( hDlg, nMsg, wParam, lParam );
}
case IDC_RA_MEMBANK:
@@ -1392,12 +1410,13 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
HWND hMemBanks = GetDlgItem(m_hWnd, IDC_RA_MEMBANK);
const int nSelectedIdx = ComboBox_GetCurSel(hMemBanks);
const unsigned short nBankID = static_cast<unsigned short>(ComboBox_GetItemData(hMemBanks, nSelectedIdx));
const unsigned short nBankID =
static_cast<unsigned short>(ComboBox_GetItemData(hMemBanks, nSelectedIdx));
MemoryViewerControl::m_nActiveMemBank = nBankID;
g_MemManager.ChangeActiveMemBank(nBankID);
MemoryViewerControl::Invalidate(); // Force redraw on mem viewer
MemoryViewerControl::Invalidate(); // Force redraw on mem viewer
break;
}
}
@@ -1405,7 +1424,7 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
return TRUE;
default:
return FALSE; // unhandled
return FALSE; // unhandled
}
}
@@ -1414,7 +1433,7 @@ INT_PTR Dlg_Memory::MemoryProc(HWND hDlg, UINT nMsg, WPARAM wParam, LPARAM lPara
return TRUE;
default:
return FALSE; // unhandled
return FALSE; // unhandled
}
return FALSE;
@@ -1450,15 +1469,15 @@ void Dlg_Memory::RepopulateMemNotesFromFile()
SetDlgItemText(hMemWatch, IDC_RA_WATCHING, TEXT(""));
SetDlgItemText(hMemWatch, IDC_RA_MEMSAVENOTE, TEXT(""));
while (ComboBox_DeleteString(hMemWatch, 0) != CB_ERR) {}
// Issue a fetch instead!
std::map<ra::ByteAddress, CodeNotes::CodeNoteObj>::const_iterator iter = m_CodeNotes.FirstNote();
while (iter != m_CodeNotes.EndOfNotes())
while (ComboBox_DeleteString(hMemWatch, 0) != CB_ERR)
{
const std::string sAddr = ra::ByteAddressToString(iter->first);
}
// Issue a fetch instead!
for (auto& note_entry : m_CodeNotes)
{
const std::string sAddr = ra::ByteAddressToString(note_entry.first);
ComboBox_AddString(hMemWatch, NativeStr(sAddr).c_str());
iter++;
}
if (nSize > 0)
@@ -1476,7 +1495,8 @@ void Dlg_Memory::RepopulateMemNotesFromFile()
if ((pSavedNote != nullptr) && (pSavedNote->Note().length() > 0))
{
SetDlgItemTextW(m_hWnd, IDC_RA_MEMSAVENOTE, ra::Widen(pSavedNote->Note()).c_str());
MemoryViewerControl::setAddress((nAddr & ~(0xf)) - ((int)(MemoryViewerControl::m_nDisplayedLines / 2) << 4) + (0x50));
MemoryViewerControl::setAddress((nAddr & ~(0xf)) -
((int)(MemoryViewerControl::m_nDisplayedLines / 2) << 4) + (0x50));
MemoryViewerControl::setWatchedAddress(nAddr);
}
}
@@ -1571,15 +1591,11 @@ void Dlg_Memory::UpdateBits() const
const ra::ByteAddress nAddr = MemoryViewerControl::getWatchedAddress();
const unsigned char nVal = g_MemManager.ActiveBankRAMByteRead(nAddr);
_stprintf_s(sNewValue, 64, _T(" %d %d %d %d %d %d %d %d"),
static_cast<int>((nVal & (1 << 7)) != 0),
static_cast<int>((nVal & (1 << 6)) != 0),
static_cast<int>((nVal & (1 << 5)) != 0),
static_cast<int>((nVal & (1 << 4)) != 0),
static_cast<int>((nVal & (1 << 3)) != 0),
static_cast<int>((nVal & (1 << 2)) != 0),
static_cast<int>((nVal & (1 << 1)) != 0),
static_cast<int>((nVal & (1 << 0)) != 0));
_stprintf_s(sNewValue, 64, _T(" %d %d %d %d %d %d %d %d"), static_cast<int>((nVal & (1 << 7)) != 0),
static_cast<int>((nVal & (1 << 6)) != 0), static_cast<int>((nVal & (1 << 5)) != 0),
static_cast<int>((nVal & (1 << 4)) != 0), static_cast<int>((nVal & (1 << 3)) != 0),
static_cast<int>((nVal & (1 << 2)) != 0), static_cast<int>((nVal & (1 << 1)) != 0),
static_cast<int>((nVal & (1 << 0)) != 0));
}
TCHAR sOldValue[64];
@@ -1600,18 +1616,20 @@ void Dlg_Memory::SetWatchingAddress(unsigned int nAddr)
OnWatchingMemChange();
}
BOOL Dlg_Memory::IsActive() const
BOOL Dlg_Memory::IsActive() const noexcept
{
return(g_MemoryDialog.GetHWND() != nullptr) && (IsWindowVisible(g_MemoryDialog.GetHWND()));
return (g_MemoryDialog.GetHWND() != nullptr) && (IsWindowVisible(g_MemoryDialog.GetHWND()));
}
void Dlg_Memory::ClearBanks()
void Dlg_Memory::ClearBanks() noexcept
{
if (m_hWnd == nullptr)
return;
HWND hMemBanks = GetDlgItem(m_hWnd, IDC_RA_MEMBANK);
while (ComboBox_DeleteString(hMemBanks, 0) != CB_ERR) {}
while (ComboBox_DeleteString(hMemBanks, 0) != CB_ERR)
{
}
}
void Dlg_Memory::AddBank(size_t nBankID)
@@ -1630,7 +1648,7 @@ void Dlg_Memory::AddBank(size_t nBankID)
ComboBox_SetCurSel(hMemBanks, 0);
}
bool Dlg_Memory::GetSystemMemoryRange(ra::ByteAddress& start, ra::ByteAddress& end)
bool Dlg_Memory::GetSystemMemoryRange(ra::ByteAddress& start, ra::ByteAddress& end) noexcept
{
switch (g_ConsoleID)
{
@@ -1641,7 +1659,7 @@ bool Dlg_Memory::GetSystemMemoryRange(ra::ByteAddress& start, ra::ByteAddress& e
return TRUE;
case ConsoleID::SNES:
// SNES RAM runs from $7E0000-$7FFFFF. $7E0000-$7E1FFF is LowRAM, $7E2000-$7E7FFF is
// SNES RAM runs from $7E0000-$7FFFFF. $7E0000-$7E1FFF is LowRAM, $7E2000-$7E7FFF is
// considered HighRAM, and $7E8000-$7FFFFF is considered Expanded RAM. The Memory Manager
// addresses this data from $000000-$1FFFFF. For simplicity, we'll treat LowRAM and HighRAM
// as system memory and Expanded RAM as game memory.
@@ -1667,7 +1685,7 @@ bool Dlg_Memory::GetSystemMemoryRange(ra::ByteAddress& start, ra::ByteAddress& e
return TRUE;
case ConsoleID::MegaDrive:
// Genesis RAM runs from $E00000-$FFFFFF. It's really only 64KB, and mirrored for
// Genesis RAM runs from $E00000-$FFFFFF. It's really only 64KB, and mirrored for
// each $E0-$FF lead byte. Typically, it's only accessed from $FFxxxx. I'm not sure
// what memory is represented by $10000-$1FFFF in the Memory Manager.
start = 0x0000;
@@ -1694,7 +1712,7 @@ bool Dlg_Memory::GetSystemMemoryRange(ra::ByteAddress& start, ra::ByteAddress& e
}
}
bool Dlg_Memory::GetGameMemoryRange(ra::ByteAddress& start, ra::ByteAddress& end)
bool Dlg_Memory::GetGameMemoryRange(ra::ByteAddress& start, ra::ByteAddress& end) noexcept
{
switch (g_ConsoleID)
{
@@ -1706,7 +1724,7 @@ bool Dlg_Memory::GetGameMemoryRange(ra::ByteAddress& start, ra::ByteAddress& end
return TRUE;
case ConsoleID::SNES:
// SNES RAM runs from $7E0000-$7FFFFF. $7E0000-$7E1FFF is LowRAM, $7E2000-$7E7FFF is
// SNES RAM runs from $7E0000-$7FFFFF. $7E0000-$7E1FFF is LowRAM, $7E2000-$7E7FFF is
// considered HighRAM, and $7E8000-$7FFFFF is considered Expanded RAM. The Memory Manager
// addresses this data from $000000-$1FFFFF. For simplicity, we'll treat LowRAM and HighRAM
// as system memory and Expanded RAM as game memory.
@@ -1757,7 +1775,7 @@ bool Dlg_Memory::GetGameMemoryRange(ra::ByteAddress& start, ra::ByteAddress& end
}
}
static TCHAR* ParseAddress(TCHAR* ptr, ra::ByteAddress& address)
static TCHAR* ParseAddress(TCHAR* ptr, ra::ByteAddress& address) noexcept
{
if (*ptr == '$')
++ptr;
@@ -1793,7 +1811,7 @@ static TCHAR* ParseAddress(TCHAR* ptr, ra::ByteAddress& address)
return ptr;
}
bool Dlg_Memory::GetSelectedMemoryRange(ra::ByteAddress& start, ra::ByteAddress& end)
bool Dlg_Memory::GetSelectedMemoryRange(ra::ByteAddress& start, ra::ByteAddress& end) noexcept
{
if (IsDlgButtonChecked(m_hWnd, IDC_RA_CBO_SEARCHALL) == BST_CHECKED)
{
@@ -1832,7 +1850,8 @@ bool Dlg_Memory::GetSelectedMemoryRange(ra::ByteAddress& start, ra::ByteAddress&
return FALSE;
}
void Dlg_Memory::UpdateSearchResult(const ra::services::SearchResults::Result& result, _Out_ unsigned int& nMemVal, TCHAR(&buffer)[1024])
void Dlg_Memory::UpdateSearchResult(const ra::services::SearchResults::Result& result, _Out_ unsigned int& nMemVal,
TCHAR (&buffer)[1024])
{
nMemVal = g_MemManager.ActiveBankRAMRead(result.nAddress, result.nSize);
@@ -1859,18 +1878,30 @@ void Dlg_Memory::UpdateSearchResult(const ra::services::SearchResults::Result& r
bool Dlg_Memory::CompareSearchResult(unsigned int nCurVal, unsigned int nPrevVal)
{
const unsigned int nVal = (m_SearchResults[m_nPage].m_bUseLastValue) ?
nPrevVal : m_SearchResults[m_nPage].m_nLastQueryVal;
const unsigned int nVal =
(m_SearchResults[m_nPage].m_bUseLastValue) ? nPrevVal : m_SearchResults[m_nPage].m_nLastQueryVal;
bool bResult = false;
switch (m_SearchResults[m_nPage].m_nCompareType)
{
case ComparisonType::Equals: bResult = (nCurVal == nVal); break;
case ComparisonType::LessThan: bResult = (nCurVal < nVal); break;
case ComparisonType::LessThanOrEqual: bResult = (nCurVal <= nVal); break;
case ComparisonType::GreaterThan: bResult = (nCurVal > nVal); break;
case ComparisonType::GreaterThanOrEqual: bResult = (nCurVal >= nVal); break;
case ComparisonType::NotEqualTo: bResult = (nCurVal != nVal); break;
case ComparisonType::Equals:
bResult = (nCurVal == nVal);
break;
case ComparisonType::LessThan:
bResult = (nCurVal < nVal);
break;
case ComparisonType::LessThanOrEqual:
bResult = (nCurVal <= nVal);
break;
case ComparisonType::GreaterThan:
bResult = (nCurVal > nVal);
break;
case ComparisonType::GreaterThanOrEqual:
bResult = (nCurVal >= nVal);
break;
case ComparisonType::NotEqualTo:
bResult = (nCurVal != nVal);
break;
default:
bResult = false;
break;
@@ -1878,7 +1909,6 @@ bool Dlg_Memory::CompareSearchResult(unsigned int nCurVal, unsigned int nPrevVal
return bResult;
}
void Dlg_Memory::GenerateResizes(HWND hDlg)
{
RARect windowRect;
+22 -21
View File
@@ -9,13 +9,13 @@
class MemoryViewerControl
{
public:
static INT_PTR CALLBACK s_MemoryDrawProc(HWND, UINT, WPARAM, LPARAM);
static LRESULT CALLBACK s_MemoryDrawProc(HWND, UINT, WPARAM, LPARAM);
public:
static void RenderMemViewer(HWND hTarget);
static void createEditCaret(int w, int h);
static void destroyEditCaret();
static void createEditCaret(int w, int h) noexcept;
static void destroyEditCaret() noexcept;
static void SetCaretPos();
static void OnClick(POINT point);
@@ -23,14 +23,18 @@ public:
static bool OnEditInput(UINT c);
static void setAddress(unsigned int nAddr);
static void setWatchedAddress(unsigned int nAddr);
static unsigned int getWatchedAddress() { return m_nWatchedAddress; }
static void setWatchedAddress(unsigned int nAddr) noexcept;
static unsigned int getWatchedAddress() noexcept { return m_nWatchedAddress; }
static void moveAddress(int offset, int nibbleOff);
static void editData(unsigned int nByteAddress, bool bLowerNibble, unsigned int value);
static void Invalidate();
static void Invalidate() noexcept;
static void SetDataSize(MemSize value) { m_nDataSize = value; Invalidate(); }
static MemSize GetDataSize() { return m_nDataSize; }
static void SetDataSize(MemSize value) noexcept
{
m_nDataSize = value;
Invalidate();
}
static MemSize GetDataSize() noexcept { return m_nDataSize; }
public:
static unsigned short m_nActiveMemBank;
@@ -69,18 +73,15 @@ struct SearchResult
class Dlg_Memory
{
public:
Dlg_Memory() {}
void Init() noexcept;
public:
void Init();
void ClearLogOutput();
void ClearLogOutput() noexcept;
static INT_PTR CALLBACK s_MemoryProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR MemoryProc(HWND, UINT, WPARAM, LPARAM);
void InstallHWND(HWND hWnd) { m_hWnd = hWnd; }
HWND GetHWND() const { return m_hWnd; }
void InstallHWND(HWND hWnd) noexcept { m_hWnd = hWnd; }
HWND GetHWND() const noexcept { return m_hWnd; }
void OnLoad_NewRom();
@@ -91,19 +92,19 @@ public:
void SetWatchingAddress(unsigned int nAddr);
void UpdateBits() const;
BOOL IsActive() const;
BOOL IsActive() const noexcept;
const CodeNotes& Notes() const { return m_CodeNotes; }
const CodeNotes& Notes() const noexcept { return m_CodeNotes; }
void ClearBanks();
void ClearBanks() noexcept;
void AddBank(size_t nBankID);
void GenerateResizes(HWND hDlg);
private:
bool GetSystemMemoryRange(ra::ByteAddress& start, ra::ByteAddress& end);
bool GetGameMemoryRange(ra::ByteAddress& start, ra::ByteAddress& end);
bool GetSystemMemoryRange(ra::ByteAddress& start, ra::ByteAddress& end) noexcept;
bool GetGameMemoryRange(ra::ByteAddress& start, ra::ByteAddress& end) noexcept;
bool GetSelectedMemoryRange(ra::ByteAddress& start, ra::ByteAddress& end);
bool GetSelectedMemoryRange(ra::ByteAddress& start, ra::ByteAddress& end) noexcept;
void UpdateSearchResult(const ra::services::SearchResults::Result& result, _Out_ unsigned int& nMemVal, TCHAR(&buffer)[1024]);
bool CompareSearchResult(unsigned int nCurVal, unsigned int nPrevVal);
+1
View File
@@ -407,6 +407,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SubSystem>Windows</SubSystem>
<IgnoreSpecificDefaultLibraries>libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib</IgnoreSpecificDefaultLibraries>
</Link>
<PreBuildEvent>
<Command>..\MakeBuildVer.bat</Command>
+9 -9
View File
@@ -1,14 +1,14 @@
#include "RA_Interface.h"
// Exposed, shared
// App-level:
bool (CCONV *_RA_GameIsActive) (void) = nullptr;
void (CCONV *_RA_CauseUnpause) (void) = nullptr;
void (CCONV *_RA_CausePause) (void) = nullptr;
void (CCONV *_RA_RebuildMenu) (void) = nullptr;
void (CCONV *_RA_ResetEmulation) (void) = nullptr;
void (CCONV *_RA_GetEstimatedGameTitle) (char* sNameOut) = nullptr;
void (CCONV *_RA_LoadROM) (const char* sNameOut) = nullptr;
// Exposed, shared
// App-level:
bool (CCONV *_RA_GameIsActive) (void) = nullptr;
void (CCONV *_RA_CauseUnpause) (void) = nullptr;
void (CCONV *_RA_CausePause) (void) = nullptr;
void (CCONV *_RA_RebuildMenu) (void) = nullptr;
void (CCONV *_RA_ResetEmulation) (void) = nullptr;
void (CCONV *_RA_GetEstimatedGameTitle) (char* sNameOut) = nullptr;
void (CCONV *_RA_LoadROM) (const char* sNameOut) = nullptr;
bool RA_GameIsActive()
{
+31 -25
View File
@@ -15,9 +15,9 @@ struct ControllerInput
BOOL m_bDownPressed;
BOOL m_bLeftPressed;
BOOL m_bRightPressed;
BOOL m_bConfirmPressed; // Usually C or A
BOOL m_bCancelPressed; // Usually B
BOOL m_bQuitPressed; // Usually Start
BOOL m_bConfirmPressed; // Usually C or A
BOOL m_bCancelPressed; // Usually B
BOOL m_bQuitPressed; // Usually Start
};
enum EmulatorID
@@ -40,7 +40,7 @@ enum EmulatorID
enum ConsoleID
{
UnknownConsoleID = 0,
MegaDrive = 1, // DB
MegaDrive = 1, // DB
N64 = 2,
SNES = 3,
GB = 4,
@@ -71,7 +71,7 @@ enum ConsoleID
MSX = 29,
C64 = 30,
ZX81 = 31,
//unused32 = 32,
// unused32 = 32,
SG1000 = 33,
VIC20 = 34,
Amiga = 35,
@@ -97,16 +97,18 @@ enum ConsoleID
NumConsoleIDs
};
extern bool (*_RA_GameIsActive)();
extern void (*_RA_CauseUnpause)();
extern void (*_RA_CausePause)();
extern void (*_RA_RebuildMenu)();
extern void (*_RA_GetEstimatedGameTitle)(char* sNameOut);
extern void (*_RA_ResetEmulation)();
extern void (*_RA_LoadROM)(const char* sFullPath);
extern bool(*_RA_GameIsActive)();
extern void(*_RA_CauseUnpause)();
extern void(*_RA_CausePause)();
extern void(*_RA_RebuildMenu)();
extern void(*_RA_GetEstimatedGameTitle)(char* sNameOut);
extern void(*_RA_ResetEmulation)();
extern void(*_RA_LoadROM)(const char* sFullPath);
// Shared funcs, should be implemented by emulator.
// Shared funcs, should be implemented by emulator.
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
extern bool RA_GameIsActive();
extern void RA_CauseUnpause();
extern void RA_CausePause();
@@ -114,6 +116,9 @@ extern void RA_RebuildMenu();
extern void RA_GetEstimatedGameTitle(char* sNameOut);
extern void RA_ResetEmulation();
extern void RA_LoadROM(const char* sFullPath);
#ifdef __cplusplus
}
#endif // __cplusplus
#ifndef RA_EXPORTS
@@ -126,26 +131,28 @@ extern void RA_LoadROM(const char* sFullPath);
// resource values for menu items - needed by MFC ON_COMMAND_RANGE macros
// they're not all currently used, allowing additional items without forcing recompilation of the emulators
#define IDM_RA_MENUSTART 1700
#define IDM_RA_MENUEND 1739
#define IDM_RA_MENUSTART 1700
#define IDM_RA_MENUEND 1739
// Captures the RA_DLL and installs/allocs all required information.
// Populates all function pointers so they can be used by the app.
extern void RA_Init(HWND hMainHWND, /*enum ConsoleType*/int console, const char* sClientVersion);
extern void RA_Init(HWND hMainHWND, /*enum ConsoleType*/ int console, const char* sClientVersion);
// Call with shared function pointers from app.
extern void RA_InstallSharedFunctions(bool(*fpIsActive)(void), void(*fpCauseUnpause)(void), void(*fpCausePause)(void), void(*fpRebuildMenu)(void), void(*fpEstimateTitle)(char*), void(*fpResetEmulator)(void), void(*fpLoadROM)(const char*));
extern void RA_InstallSharedFunctions(bool (*fpIsActive)(void), void (*fpCauseUnpause)(void),
void (*fpCausePause)(void), void (*fpRebuildMenu)(void),
void (*fpEstimateTitle)(char*), void (*fpResetEmulator)(void),
void (*fpLoadROM)(const char*));
// Shuts down, tidies up and deallocs the RA DLL from the app's perspective.
extern void RA_Shutdown();
// Perform one test for all achievements in the current set. Call this once per frame/cycle.
extern void RA_DoAchievementsFrame();
// Updates and renders all on-screen overlays.
extern void RA_UpdateRenderOverlay(HDC hDC, ControllerInput* pInput, float fDeltaTime, RECT* prcSize, bool Full_Screen, bool Paused);
extern void RA_UpdateRenderOverlay(HDC hDC, ControllerInput* pInput, float fDeltaTime, RECT* prcSize, bool Full_Screen,
bool Paused);
// Determines if the overlay is completely covering the screen.
extern bool RA_IsOverlayFullyVisible();
@@ -160,8 +167,8 @@ extern void RA_OnLoadNewRom(BYTE* pROMData, unsigned int nROMSize);
extern void RA_ClearMemoryBanks();
// Call once for each memory bank found, immediately after a new rom or load
//pReader is typedef unsigned char (_RAMByteReadFn)( size_t nOffset );
//pWriter is typedef void (_RAMByteWriteFn)( unsigned int nOffs, unsigned int nVal );
// pReader is typedef unsigned char (_RAMByteReadFn)( size_t nOffset );
// pWriter is typedef void (_RAMByteWriteFn)( unsigned int nOffs, unsigned int nVal );
extern void RA_InstallMemoryBank(int nBankID, void* pReader, void* pWriter, int nBankSize);
// Call this before loading a new ROM or quitting, to ensure no developer changes are lost.
@@ -200,7 +207,6 @@ extern void RA_InvokeDialog(LPARAM nID);
// Returns TRUE if HC mode is ongoing
extern int RA_HardcoreModeIsActive();
#endif //RA_EXPORTS
#endif // RA_EXPORTS
#endif // !RA_INTERFACE_H
+16 -47
View File
@@ -8,12 +8,10 @@
#include <ctime>
RA_Leaderboard::RA_Leaderboard(const ra::LeaderboardID nLeaderboardID) noexcept :
m_nID(nLeaderboardID)
{
}
RA_Leaderboard::RA_Leaderboard(const ra::LeaderboardID nLeaderboardID) noexcept : m_nID(nLeaderboardID) {}
//{"ID":"3","Mem":"STA:0xfe10=h0001_0xhf601=h0c_d0xhf601!=h0c_0xhfffb=0::CAN:0xhfe13<d0xhfe13::SUB:0xf7cc!=0_d0xf7cc=0::VAL:0xhfe24*1_0xhfe25*60_0xhfe22*3600","Format":"TIME","Title":"Green Hill Act 2","Description":"Complete this act in the fastest time!"},
//{"ID":"3","Mem":"STA:0xfe10=h0001_0xhf601=h0c_d0xhf601!=h0c_0xhfffb=0::CAN:0xhfe13<d0xhfe13::SUB:0xf7cc!=0_d0xf7cc=0::VAL:0xhfe24*1_0xhfe25*60_0xhfe22*3600","Format":"TIME","Title":"Green
//Hill Act 2","Description":"Complete this act in the fastest time!"},
void RA_Leaderboard::ParseFromString(const char* sBuffer, const char* sFormat)
{
@@ -42,7 +40,7 @@ std::string RA_Leaderboard::FormatScore(unsigned int nValue) const
return std::string(buffer);
}
void RA_Leaderboard::Reset()
void RA_Leaderboard::Reset() noexcept
{
if (m_pLeaderboard != nullptr)
{
@@ -56,7 +54,7 @@ void RA_Leaderboard::Test()
if (m_pLeaderboard != nullptr)
{
rc_lboard_t* pLboard = static_cast<rc_lboard_t*>(m_pLeaderboard);
const int nResult = rc_evaluate_lboard(pLboard, &m_nCurrentValue, rc_peek_callback, nullptr, nullptr);
const int nResult = rc_evaluate_lboard(pLboard, &m_nCurrentValue, rc_peek_callback, nullptr, nullptr);
switch (nResult)
{
default:
@@ -65,17 +63,11 @@ void RA_Leaderboard::Test()
// no change, do nothing
break;
case RC_LBOARD_STARTED:
Start();
break;
case RC_LBOARD_STARTED: Start(); break;
case RC_LBOARD_CANCELED:
Cancel();
break;
case RC_LBOARD_CANCELED: Cancel(); break;
case RC_LBOARD_TRIGGERED:
Submit(m_nCurrentValue);
break;
case RC_LBOARD_TRIGGERED: Submit(m_nCurrentValue); break;
}
}
}
@@ -97,40 +89,17 @@ void RA_Leaderboard::Submit(unsigned int nScore)
void RA_Leaderboard::SubmitRankInfo(unsigned int nRank, const std::string& sUsername, int nScore, time_t nAchieved)
{
Entry newEntry;
newEntry.m_nRank = nRank;
newEntry.m_sUsername = sUsername;
newEntry.m_nScore = nScore;
newEntry.m_TimeAchieved = nAchieved;
if (EntryExists(nRank))
return;
std::vector<Entry>::iterator iter = m_RankInfo.begin();
while (iter != m_RankInfo.end())
{
if ((*iter).m_nRank == nRank)
{
(*iter) = newEntry;
return;
}
iter++;
}
// If not found, add new entry.
m_RankInfo.push_back(newEntry);
// If not found, add new entry.
m_RankInfo.emplace_back(nRank, sUsername, nScore, nAchieved);
}
void RA_Leaderboard::SortRankInfo()
bool RA_Leaderboard::EntryExists(unsigned int nRank)
{
for (size_t i = 0; i < m_RankInfo.size(); ++i)
{
for (size_t j = i + 1; j < m_RankInfo.size(); ++j)
{
if (m_RankInfo.at(i).m_nRank > m_RankInfo.at(j).m_nRank)
{
Entry temp = m_RankInfo[i];
m_RankInfo[i] = m_RankInfo[j];
m_RankInfo[j] = temp;
}
}
}
SortRankInfo();
return (std::binary_search(m_RankInfo.begin(), m_RankInfo.end(), nRank));
}
void RA_Leaderboard::SortRankInfo() { std::sort(m_RankInfo.begin(), m_RankInfo.end()); }
+55 -18
View File
@@ -17,32 +17,46 @@ public:
void ParseFromString(const char* sBuffer, const char* sFormat);
void Test();
virtual void Reset();
virtual void Reset() noexcept;
unsigned int GetCurrentValue() const { return m_nCurrentValue; }
unsigned int GetCurrentValue() const noexcept { return m_nCurrentValue; }
ra::LeaderboardID ID() const { return m_nID; }
ra::LeaderboardID ID() const noexcept { return m_nID; }
const std::string& Title() const { return m_sTitle; }
const std::string& Title() const noexcept { return m_sTitle; }
void SetTitle(const std::string& sValue) { m_sTitle = sValue; }
const std::string& Description() const { return m_sDescription; }
const std::string& Description() const noexcept { return m_sDescription; }
void SetDescription(const std::string& sValue) { m_sDescription = sValue; }
std::string FormatScore(unsigned int nValue) const;
struct Entry
{
unsigned int m_nRank;
Entry() noexcept = default;
explicit Entry(unsigned int nRank, const std::string& sUsername, int nScore, std::time_t nAchieved) :
m_nRank{nRank},
m_sUsername{sUsername},
m_nScore{nScore},
m_TimeAchieved{nAchieved}
{}
~Entry() noexcept = default;
Entry(const Entry&) = delete;
Entry& operator=(const Entry&) = delete;
Entry(Entry&&) noexcept = default;
Entry& operator=(Entry&&) noexcept = default;
unsigned int m_nRank{};
std::string m_sUsername;
int m_nScore;
time_t m_TimeAchieved;
int m_nScore{};
std::time_t m_TimeAchieved{};
};
void SubmitRankInfo(unsigned int nRank, const std::string& sUsername, int nScore, time_t nAchieved);
void ClearRankInfo() { m_RankInfo.clear(); }
bool EntryExists(unsigned int nRank);
void ClearRankInfo() noexcept { m_RankInfo.clear(); }
const Entry& GetRankInfo(unsigned int nAt) const { return m_RankInfo.at(nAt); }
size_t GetRankInfoCount() const { return m_RankInfo.size(); }
size_t GetRankInfoCount() const noexcept { return m_RankInfo.size(); }
void SortRankInfo();
protected:
@@ -51,18 +65,41 @@ protected:
virtual void Submit(unsigned int nScore);
private:
const ra::LeaderboardID m_nID; // DB ID for this LB
const ra::LeaderboardID m_nID = ra::LeaderboardID(); // DB ID for this LB
void* m_pLeaderboard; // rc_lboard_t
std::shared_ptr<unsigned char[]> m_pLeaderboardBuffer; // buffer for rc_lboard_t
unsigned int m_nCurrentValue = 0;
void* m_pLeaderboard = nullptr; // rc_lboard_t
std::shared_ptr<unsigned char[]> m_pLeaderboardBuffer; // buffer for rc_lboard_t
unsigned int m_nCurrentValue = 0U;
int m_nFormat = 0; // A format to output. Typically "%d" for score or "%02d:%02d.%02d" for time
int m_nFormat = 0; // A format to output. Typically "%d" for score or "%02d:%02d.%02d" for time
std::string m_sTitle; // The title of the leaderboard
std::string m_sDescription; // A brief description of the leaderboard
std::string m_sTitle; // The title of the leaderboard
std::string m_sDescription; // A brief description of the leaderboard
std::vector<Entry> m_RankInfo; // Recent users ranks
std::vector<Entry> m_RankInfo; // Recent users ranks
};
// Comparison
_NODISCARD _CONSTANT_FN operator==(const RA_Leaderboard::Entry& a, const RA_Leaderboard::Entry& b) noexcept
{
return (a.m_nRank == b.m_nRank);
}
// Sorting
_NODISCARD _CONSTANT_FN operator<(const RA_Leaderboard::Entry& a, const RA_Leaderboard::Entry& b) noexcept
{
return (a.m_nRank < b.m_nRank);
}
// binary search
_NODISCARD _CONSTANT_FN operator<(unsigned int key, const RA_Leaderboard::Entry& value) noexcept
{
return key < value.m_nRank;
}
_NODISCARD _CONSTANT_FN operator<(const RA_Leaderboard::Entry& value, unsigned int key) noexcept
{
return value.m_nRank < key;
}
#endif // !RA_LEADERBOARD_H
+1 -7
View File
@@ -25,12 +25,6 @@ const int FONT_SIZE_TEXT = 16;
}
LeaderboardPopup::LeaderboardPopup()
{
Reset();
}
void LeaderboardPopup::ShowScoreboard(ra::LeaderboardID nID)
{
m_vScoreboardQueue.push(nID);
@@ -125,7 +119,7 @@ BOOL LeaderboardPopup::Deactivate(ra::LeaderboardID nLBID)
return FALSE;
}
float LeaderboardPopup::GetOffsetPct() const
float LeaderboardPopup::GetOffsetPct() const noexcept
{
float fVal = 0.0f;
+3 -6
View File
@@ -15,8 +15,6 @@ class LeaderboardPopup
};
public:
LeaderboardPopup();
void Update(_UNUSED ControllerInput, float fDelta, _UNUSED BOOL, BOOL bPaused);
void Render(_In_ HDC hDC, _In_ const RECT& rcDest);
@@ -27,14 +25,13 @@ public:
void ShowScoreboard(ra::LeaderboardID nLBID);
private:
float GetOffsetPct() const;
float GetOffsetPct() const noexcept;
private:
PopupState m_nState;
float m_fScoreboardShowTimer;
PopupState m_nState{};
float m_fScoreboardShowTimer{};
std::vector<unsigned int> m_vActiveLBIDs;
std::queue<unsigned int> m_vScoreboardQueue;
};
#endif // !RA_LEADERBOARDPOPUP_H
+1 -1
View File
@@ -30,7 +30,7 @@ void MemManager::AddMemoryBank(size_t nBankID, _RAMByteReadFn* pReader, _RAMByte
m_Banks[nBankID].Writer = pWriter;
}
void MemManager::ChangeActiveMemBank(_UNUSED unsigned short)
void MemManager::ChangeActiveMemBank(_UNUSED unsigned short) noexcept
{
ASSERT(!"Not Implemented!");
return;
+3 -5
View File
@@ -49,16 +49,14 @@ public:
public:
void ClearMemoryBanks() noexcept;
void AddMemoryBank(size_t nBankID, _RAMByteReadFn* pReader, _RAMByteWriteFn* pWriter, size_t nBankSize);
size_t NumMemoryBanks() const { return m_Banks.size(); }
size_t NumMemoryBanks() const noexcept { return m_Banks.size(); }
inline size_t BankSize(unsigned short nBank) const { return m_Banks.at(nBank).BankSize; }
//inline size_t ActiveBankSize() const { return m_Banks.at( m_nActiveMemBank ).BankSize; }
//inline unsigned short ActiveBankID() const { return m_nActiveMemBank; }
inline size_t TotalBankSize() const { return m_nTotalBankSize; }
inline size_t TotalBankSize() const noexcept { return m_nTotalBankSize; }
std::vector<size_t> GetBankIDs() const;
void ChangeActiveMemBank(_UNUSED unsigned short);
void ChangeActiveMemBank(_UNUSED unsigned short) noexcept;
unsigned char ActiveBankRAMByteRead(ra::ByteAddress nOffs) const;
void ActiveBankRAMByteWrite(ra::ByteAddress nOffs, unsigned int nVal);
+3 -3
View File
@@ -29,15 +29,15 @@ public:
m_AchievementPopups.Clear();
}
static AchievementPopup& AchievementPopups() { return m_AchievementPopups; }
static LeaderboardPopup& LeaderboardPopups() { return m_LeaderboardPopups; }
static AchievementPopup& AchievementPopups() noexcept { return m_AchievementPopups; }
static LeaderboardPopup& LeaderboardPopups() noexcept { return m_LeaderboardPopups; }
private:
static AchievementPopup m_AchievementPopups;
static LeaderboardPopup m_LeaderboardPopups;
};
// Exposed to DLL
// Exposed to DLL
_EXTERN_C
[[gsl::suppress(con.3)]]
API int _RA_UpdatePopups(_In_ ControllerInput* __restrict input, _In_ float fDTime,
+1 -5
View File
@@ -22,10 +22,6 @@ const std::string& RA_RichPresenceInterpreter::Lookup::GetText(unsigned int nVal
return m_sDefault;
}
RA_RichPresenceInterpreter::DisplayString::DisplayString()
{
}
RA_RichPresenceInterpreter::DisplayString::DisplayString(const std::string& sCondition)
{
const int nSize = rc_trigger_size(sCondition.c_str());
@@ -148,7 +144,7 @@ void RA_RichPresenceInterpreter::DisplayString::InitializeValue(RA_RichPresenceI
}
}
bool RA_RichPresenceInterpreter::DisplayString::Test()
bool RA_RichPresenceInterpreter::DisplayString::Test() noexcept
{
rc_trigger_t* pTrigger = static_cast<rc_trigger_t*>(m_pTrigger);
return pTrigger && rc_test_trigger(pTrigger, rc_peek_callback, nullptr, nullptr);
+20 -22
View File
@@ -4,20 +4,18 @@
#include "RA_Condition.h"
#include <memory>
#include <map>
#include <memory>
#include "services\TextReader.hh"
class RA_RichPresenceInterpreter
{
public:
RA_RichPresenceInterpreter() noexcept = default;
bool Load();
GSL_SUPPRESS(f.6) bool Load(); /*Test won't throw but Integration might*/
std::string GetRichPresenceString();
bool Enabled() const { return !m_vDisplayStrings.empty(); }
bool Enabled() const noexcept { return !m_vDisplayStrings.empty(); }
protected:
bool Load(ra::services::TextReader& pReader);
@@ -25,14 +23,14 @@ protected:
class Lookup
{
public:
Lookup(const std::string& sDesc);
explicit Lookup(const std::string& sDesc);
const std::string& Description() const { return m_sLookupDescription; }
const std::string& Description() const noexcept { return m_sLookupDescription; }
const std::string& GetText(unsigned int nValue) const;
void AddLookupData(unsigned int nValue, const std::string& sLookupData) { m_mLookupData[nValue] = sLookupData; }
void SetDefault(const std::string& sDefault) { m_sDefault = sDefault; }
size_t NumItems() const { return m_mLookupData.size(); }
size_t NumItems() const noexcept { return m_mLookupData.size(); }
private:
std::string m_sDefault;
@@ -43,33 +41,33 @@ protected:
class DisplayString
{
public:
DisplayString();
DisplayString(const std::string& sCondition);
void InitializeParts(const std::string& sDisplayString,
std::map<std::string, int>& mFormats, std::vector<Lookup>& vLookups);
DisplayString() noexcept = default;
explicit DisplayString(const std::string& sCondition);
void InitializeParts(const std::string& sDisplayString, std::map<std::string, int>& mFormats,
std::vector<Lookup>& vLookups);
bool Test();
bool Test() noexcept;
std::string GetDisplayString() const;
protected:
struct Part
{
std::string m_sDisplayString;
std::string m_sDisplayString;
void* m_pValue; // rc_value_t
std::shared_ptr<unsigned char[]> m_pValueBuffer; // buffer for rc_value_t
void* m_pValue; // rc_value_t
std::shared_ptr<unsigned char[]> m_pValueBuffer; // buffer for rc_value_t
const Lookup* m_pLookup = nullptr;
int m_nFormat = 0;
const Lookup* m_pLookup = nullptr;
int m_nFormat = 0;
};
private:
void InitializeValue(Part& part, const char* sValue);
std::vector<Part> m_vParts;
std::vector<Part> m_vParts;
void* m_pTrigger; // rc_trigger_t
std::shared_ptr<unsigned char[]> m_pTriggerBuffer; // buffer for rc_trigger_t
void* m_pTrigger; // rc_trigger_t
std::shared_ptr<unsigned char[]> m_pTriggerBuffer; // buffer for rc_trigger_t
};
std::vector<Lookup> m_vLookups;
+13 -10
View File
@@ -7,12 +7,13 @@
namespace ra {
_NODISCARD std::string Narrow(_In_ const std::wstring& wstr);
_NODISCARD std::string Narrow(_Inout_ std::wstring&& wstr) noexcept;
_NODISCARD std::string Narrow(_In_z_ const wchar_t* wstr);
_NODISCARD std::wstring Widen(_In_ const std::string& str);
_NODISCARD std::wstring Widen(_Inout_ std::string&& str) noexcept;
_NODISCARD std::wstring Widen(_In_z_ const char* str);
[[gsl::suppress(f.6), nodiscard]] std::string Narrow(std::wstring&& wstr) noexcept;
[[gsl::suppress(f.6), nodiscard]] std::wstring Widen(std::string&& str) noexcept;
// No-ops to help convert:
_NODISCARD std::wstring Widen(_In_z_ const wchar_t* wstr);
_NODISCARD std::wstring Widen(_In_ const std::wstring& wstr);
@@ -23,7 +24,7 @@ _NODISCARD std::string Narrow(_In_ const std::string& wstr);
/// Removes one "\r", "\n", or "\r\n" from the end of a string.
/// </summary>
/// <returns>Reference to <paramref name="str" /> for chaining.</returns>
std::string& TrimLineEnding(_Inout_ std::string& str) noexcept;
GSL_SUPPRESS(f.6) std::string& TrimLineEnding(_Inout_ std::string& str) noexcept;
// ----- ToString -----
@@ -239,7 +240,7 @@ public:
m_vPending.emplace_back(std::move(pPending));
}
void Append()
void Append() noexcept
{
// just in case one of the variadic methods gets called with 0 parameters
}
@@ -275,7 +276,7 @@ public:
{
if (sFormat.back() == 'f' || sFormat.back() == 'F')
{
int nIndex = sFormat.find('.');
const int nIndex = sFormat.find('.');
if (nIndex != std::string::npos)
{
int nPrecision = std::stoi(sFormat.c_str() + nIndex + 1);
@@ -307,7 +308,7 @@ public:
}
else
{
int nLength = strlen(arg);
const int nLength = strlen(arg);
int nPadding = std::stoi(sFormat.c_str());
nPadding -= nLength;
if (nPadding > 0)
@@ -392,7 +393,7 @@ public:
const CharT* pStart = pScan;
while (*pScan)
{
char c = static_cast<char>(*pScan);
const char c = static_cast<char>(*pScan);
sFormat.push_back(c);
if (isalpha(c))
break;
@@ -408,7 +409,7 @@ public:
if (sFormat.length() > 2 && sFormat.at(sFormat.length() - 2) == '*')
{
char c = sFormat.back();
const char c = sFormat.back();
sFormat.pop_back(); // remove 's'/'x'
sFormat.pop_back(); // remove '*'
sFormat.append(ra::ToString(value));
@@ -603,12 +604,14 @@ _NODISCARD _Success_(0 < return < strsz) inline auto __cdecl tcslen_s(_In_reads_
/// <summary>
/// Determines if <paramref name="sString" /> starts with <paramref name="sMatch" />.
/// </summary>
_NODISCARD bool StringStartsWith(_In_ const std::wstring& sString, _In_ const std::wstring& sMatch) noexcept;
[[gsl::suppress(f.6), nodiscard]]
bool StringStartsWith(_In_ const std::wstring& sString, _In_ const std::wstring& sMatch) noexcept;
/// <summary>
/// Determines if <paramref name="sString" /> ends with <paramref name="sMatch" />.
/// </summary>
_NODISCARD bool StringEndsWith(_In_ const std::wstring& sString, _In_ const std::wstring& sMatch) noexcept;
[[gsl::suppress(f.6), nodiscard]]
bool StringEndsWith(_In_ const std::wstring& sString, _In_ const std::wstring& sMatch) noexcept;
} // namespace ra
+7 -7
View File
@@ -23,17 +23,17 @@ typedef struct
class RAUser
{
public:
RAUser(const std::string& sUsername);
explicit RAUser(const std::string& sUsername);
public:
unsigned int GetScore() const { return m_nScore; }
void SetScore(unsigned int nScore) { m_nScore = nScore; }
unsigned int GetScore() const noexcept { return m_nScore; }
void SetScore(unsigned int nScore) noexcept { m_nScore = nScore; }
void SetUsername(const std::string& sUser) { m_sUsername = sUser; }
const std::string& Username() const { return m_sUsername; }
const std::string& Username() const noexcept { return m_sUsername; }
void UpdateActivity(const std::string& sAct) { m_sActivity = sAct; }
const std::string& Activity() const { return m_sActivity; }
const std::string& Activity() const noexcept { return m_sActivity; }
private:
/*const*/ std::string m_sUsername;
@@ -56,7 +56,7 @@ public:
RAUser* FindFriend(const std::string& sName);
RAUser* GetFriendByIter(size_t nOffs) { return nOffs < m_aFriends.size() ? m_aFriends[nOffs] : nullptr; }
const size_t NumFriends() const { return m_aFriends.size(); }
const size_t NumFriends() const noexcept { return m_aFriends.size(); }
const std::string& Token() const
{
@@ -71,7 +71,7 @@ private:
class RAUsers
{
public:
static LocalRAUser& LocalUser() { return ms_LocalUser; }
static LocalRAUser& LocalUser() noexcept { return ms_LocalUser; }
static BOOL DatabaseContainsUser(const std::string& sUser);
static void RegisterUser(const std::string& sUsername, RAUser* pUser) { UserDatabase[sUsername] = pUser; }
+1 -1
View File
@@ -445,7 +445,7 @@ void HttpResults::Clear()
ReleaseMutex(RAWeb::Mutex());
}
size_t HttpResults::Count() const
size_t HttpResults::Count() const noexcept
{
size_t nCount = 0;
WaitForSingleObject(RAWeb::Mutex(), INFINITE);
+8 -8
View File
@@ -68,12 +68,12 @@ public:
}
public:
const RequestType GetRequestType() const { return m_nType; }
const PostArgs& GetPostArgs() const { return m_PostArgs; }
const std::string& GetData() const { return m_sData; }
const RequestType GetRequestType() const noexcept { return m_nType; }
const PostArgs& GetPostArgs() const noexcept { return m_PostArgs; }
const std::string& GetData() const noexcept { return m_sData; }
std::string& GetResponse() { return m_sResponse; }
const std::string& GetResponse() const { return m_sResponse; }
std::string& GetResponse() noexcept { return m_sResponse; }
const std::string& GetResponse() const noexcept { return m_sResponse; }
void SetResponse(const std::string& sResponse) { m_sResponse = sResponse; }
BOOL ParseResponseToJSON(rapidjson::Document& rDocOut);
@@ -94,7 +94,7 @@ public:
const RequestObject* PeekNextItem() const;
void PushItem(RequestObject* pObj);
void Clear();
size_t Count() const;
size_t Count() const noexcept;
private:
std::deque<RequestObject*> m_aRequests;
@@ -110,12 +110,12 @@ public:
static BOOL DoBlockingImageUpload(UploadType nType, const std::string& sFilename, rapidjson::Document& ResponseOut);
static HANDLE Mutex() { return ms_hHTTPMutex; }
static HANDLE Mutex() noexcept { return ms_hHTTPMutex; }
static RequestObject* PopNextHttpResult() { return ms_LastHttpResults.PopNextItem(); }
static void SetUserAgentString();
static void SetUserAgent(const std::string& sValue) { m_sUserAgent = ra::Widen(sValue); }
static const std::wstring& GetUserAgent() { return m_sUserAgent; }
static const std::wstring& GetUserAgent() noexcept { return m_sUserAgent; }
private:
static HANDLE ms_hHTTPMutex;
+5 -20
View File
@@ -7,30 +7,15 @@
namespace ra {
namespace api {
static ra::api::IServer& Server() noexcept
GSL_SUPPRESS(f.6) static ra::api::IServer& Server() noexcept /*Service expected to exist*/
{
return ra::services::ServiceLocator::GetMutable<ra::api::IServer>();
}
Login::Response Login::Request::Call() const noexcept
{
return Server().Login(*this);
}
Logout::Response Logout::Request::Call() const noexcept
{
return Server().Logout(*this);
}
StartSession::Response StartSession::Request::Call() const noexcept
{
return Server().StartSession(*this);
}
Ping::Response Ping::Request::Call() const noexcept
{
return Server().Ping(*this);
}
Login::Response Login::Request::Call() const noexcept { return Server().Login(*this); }
Logout::Response Logout::Request::Call() const noexcept { return Server().Logout(*this); }
StartSession::Response StartSession::Request::Call() const noexcept { return Server().StartSession(*this); }
Ping::Response Ping::Request::Call() const noexcept { return Server().Ping(*this); }
} // namespace api
} // namespace ra
+2 -4
View File
@@ -24,10 +24,8 @@ struct ApiRequestBase
template<class TRequest, class TCallback>
static void CallAsync(const TRequest& request, TCallback&& callback)
{
ra::services::ServiceLocator::GetMutable<ra::services::IThreadPool>().RunAsync([request, callback = std::move(callback)]
{
callback(request.Call());
});
ra::services::ServiceLocator::GetMutable<ra::services::IThreadPool>().RunAsync(
[request, callback = std::move(callback)] { callback(request.Call()); });
}
};
-1
View File
@@ -16,7 +16,6 @@ public:
virtual const char* Name() const noexcept = 0;
// === user functions ===
virtual Login::Response Login(const Login::Request& request) noexcept = 0;
virtual Logout::Response Logout(const Logout::Request& request) noexcept = 0;
virtual StartSession::Response StartSession(const StartSession::Request& request) noexcept = 0;
+26 -23
View File
@@ -17,21 +17,23 @@ namespace api {
namespace impl {
_NODISCARD static bool HandleHttpError(_In_ const ra::services::Http::Response& httpResponse,
_Inout_ ApiResponseBase& pResponse) noexcept
_Inout_ ApiResponseBase& pResponse)
{
if (httpResponse.StatusCode() != ra::services::Http::StatusCode::OK)
{
pResponse.Result = ApiResult::Error;
pResponse.ErrorMessage = "HTTP error code " + std::to_string(ra::etoi(httpResponse.StatusCode()));
pResponse.Result = ApiResult::Error;
pResponse.ErrorMessage = ra::StringPrintf("HTTP error code: %d", ra::etoi(httpResponse.StatusCode()));
return true;
}
return false;
}
_NODISCARD static bool GetJson([[maybe_unused]] _In_ const char* sApiName, _In_ const ra::services::Http::Response& httpResponse,
_Inout_ ApiResponseBase& pResponse, _Out_ rapidjson::Document& pDocument) noexcept
_NODISCARD static bool GetJson([[maybe_unused]] _In_ const char* sApiName,
_In_ const ra::services::Http::Response& httpResponse,
_Inout_ ApiResponseBase& pResponse, _Out_ rapidjson::Document& pDocument)
{
/*this function can throw std::bad_alloc (from the strings allocator) but very low chance*/
if (HandleHttpError(httpResponse, pResponse))
{
pDocument.SetArray();
@@ -45,29 +47,29 @@ _NODISCARD static bool GetJson([[maybe_unused]] _In_ const char* sApiName, _In_
pDocument.SetArray();
RA_LOG_ERR("-- %s: Empty JSON response", sApiName);
pResponse.Result = ApiResult::Failed;
pResponse.Result = ApiResult::Failed;
pResponse.ErrorMessage = "Empty JSON response";
return false;
}
RA_LOG_INFO("-- %s Response: %s", sApiName, httpResponse.Content().c_str());
RA_LOG_INFO("-- %s Response: %s", sApiName, httpResponse.Content());
pDocument.Parse(httpResponse.Content());
if (pDocument.HasParseError())
{
RA_LOG_ERR("-- %s: JSON Parse Error encountered!", sApiName);
pResponse.Result = ApiResult::Error;
pResponse.ErrorMessage = std::string(GetParseError_En(pDocument.GetParseError())) + " (" +
std::to_string(pDocument.GetErrorOffset()) + ")";
pResponse.Result = ApiResult::Error;
pResponse.ErrorMessage =
ra::StringPrintf("%s (%zu)", GetParseError_En(pDocument.GetParseError()), pDocument.GetErrorOffset());
return false;
}
if (pDocument.HasMember("Error"))
{
pResponse.Result = ApiResult::Error;
pResponse.Result = ApiResult::Error;
pResponse.ErrorMessage = pDocument["Error"].GetString();
RA_LOG_ERR("-- %s Error: %s", sApiName, pResponse.ErrorMessage.c_str());
RA_LOG_ERR("-- %s Error: %s", sApiName, pResponse.ErrorMessage);
return false;
}
@@ -82,15 +84,16 @@ _NODISCARD static bool GetJson([[maybe_unused]] _In_ const char* sApiName, _In_
}
static void GetRequiredJsonField(_Out_ std::string& sValue, _In_ const rapidjson::Document& pDocument,
_In_ const char* const sField, _Inout_ ApiResponseBase& response) noexcept
_In_ const char* const sField, _Inout_ ApiResponseBase& response)
{
if (!pDocument.HasMember(sField))
{
sValue.clear();
response.Result = ApiResult::Error;
if (response.ErrorMessage.empty())
response.ErrorMessage = std::string(sField) + " not found in response";
response.ErrorMessage = ra::StringPrintf("%s not found in response", sField);
}
else
{
@@ -99,7 +102,7 @@ static void GetRequiredJsonField(_Out_ std::string& sValue, _In_ const rapidjson
}
static void GetOptionalJsonField(_Out_ unsigned int& nValue, _In_ const rapidjson::Document& pDocument,
_In_ const char* sField, _In_ unsigned int nDefaultValue = 0) noexcept
_In_ const char* sField, _In_ unsigned int nDefaultValue = 0)
{
if (pDocument.HasMember(sField))
nValue = pDocument[sField].GetUint();
@@ -108,7 +111,7 @@ static void GetOptionalJsonField(_Out_ unsigned int& nValue, _In_ const rapidjso
}
static void AppendUrlParam(_Inout_ std::string& sParams, _In_ const char* const sParam,
_In_ const std::string& sValue) noexcept
_In_ const std::string& sValue)
{
if (!sParams.empty() && sParams.back() != '?')
sParams.push_back('&');
@@ -120,7 +123,7 @@ static void AppendUrlParam(_Inout_ std::string& sParams, _In_ const char* const
Login::Response ConnectedServer::Login(const Login::Request& request) noexcept
{
ra::services::Http::Request httpRequest(m_sHost + "/login_app.php");
ra::services::Http::Request httpRequest(ra::StringPrintf("%s/login_app.php", m_sHost));
std::string sPostData;
AppendUrlParam(sPostData, "u", request.Username);
@@ -153,17 +156,17 @@ Login::Response ConnectedServer::Login(const Login::Request& request) noexcept
return std::move(response);
}
Logout::Response ConnectedServer::Logout(_UNUSED const Logout::Request& request) noexcept
Logout::Response ConnectedServer::Logout(_UNUSED const Logout::Request& /*request*/) noexcept
{
// update the global API pointer to a disconnected API
ra::services::ServiceLocator::Provide<ra::api::IServer>(new DisconnectedServer(m_sHost));
ra::services::ServiceLocator::Provide<ra::api::IServer>(new (std::nothrow) DisconnectedServer(m_sHost));
Logout::Response response;
response.Result = ApiResult::Success;
return std::move(response);
}
static bool DoRequest(const std::string& sHost, const char* sApiName, const char* sRequestName,
static bool DoRequest(const std::string& sHost, const char* restrict sApiName, const char* restrict sRequestName,
const std::string& sInputParams, ApiResponseBase& pResponse, rapidjson::Document& document)
{
std::string sPostData;
@@ -179,14 +182,14 @@ static bool DoRequest(const std::string& sHost, const char* sApiName, const char
}
RA_LOG_INFO("%s Request: %s", sApiName, sPostData.c_str());
ra::services::Http::Request httpRequest(sHost + "/dorequest.php");
ra::services::Http::Request httpRequest(ra::StringPrintf("%s/dorequest.php", sHost));
httpRequest.SetPostData(sPostData);
const auto httpResponse = httpRequest.Call();
return GetJson(sApiName, httpResponse, pResponse, document);
}
StartSession::Response ConnectedServer::StartSession(_UNUSED const StartSession::Request& request) noexcept
StartSession::Response ConnectedServer::StartSession(const StartSession::Request& request) noexcept
{
StartSession::Response response;
rapidjson::Document document;
@@ -208,7 +211,7 @@ StartSession::Response ConnectedServer::StartSession(_UNUSED const StartSession:
return std::move(response);
}
Ping::Response ConnectedServer::Ping(_UNUSED const Ping::Request& request) noexcept
Ping::Response ConnectedServer::Ping(const Ping::Request& request) noexcept
{
Ping::Response response;
rapidjson::Document document;
+4 -4
View File
@@ -13,10 +13,10 @@ public:
const char* Name() const noexcept override { return m_sHost.c_str(); }
Login::Response Login(const Login::Request& request) noexcept override;
Logout::Response Logout(_UNUSED const Logout::Request& request) noexcept override;
StartSession::Response StartSession(_UNUSED const StartSession::Request& request) noexcept override;
Ping::Response Ping(_UNUSED const Ping::Request& request) noexcept override;
GSL_SUPPRESS(f.6) Login::Response Login(const Login::Request& request) noexcept override;
GSL_SUPPRESS(f.6) Logout::Response Logout(_UNUSED const Logout::Request& /*request*/) noexcept override;
GSL_SUPPRESS(f.6) StartSession::Response StartSession(const StartSession::Request& request) noexcept override;
GSL_SUPPRESS(f.6) Ping::Response Ping(const Ping::Request& request) noexcept override;
private:
const std::string m_sHost;
+2 -2
View File
@@ -13,9 +13,9 @@ public:
const char* Name() const noexcept override { return "disconnected client"; }
Login::Response Login(const Login::Request& request) noexcept override;
GSL_SUPPRESS(f.6) Login::Response Login(const Login::Request& request) noexcept override;
const std::string& Host() const { return m_sHost; }
const std::string& Host() const noexcept { return m_sHost; }
private:
const std::string m_sHost;
+2 -1
View File
@@ -6,6 +6,7 @@ namespace impl {
Login::Response OfflineServer::Login(const Login::Request& request) noexcept
{
Login::Response response;
response.Result = ApiResult::Success;
response.Username = request.Username;
@@ -13,7 +14,7 @@ Login::Response OfflineServer::Login(const Login::Request& request) noexcept
return std::move(response);
}
Logout::Response OfflineServer::Logout(_UNUSED const Logout::Request& request) noexcept
Logout::Response OfflineServer::Logout(_UNUSED const Logout::Request& /*request*/) noexcept
{
Logout::Response response;
response.Result = ApiResult::Success;
+2 -2
View File
@@ -11,8 +11,8 @@ class OfflineServer : public ServerBase
public:
const char* Name() const noexcept override { return "offline client"; }
Login::Response Login(const Login::Request& request) noexcept override;
Logout::Response Logout(_UNUSED const Logout::Request& request) noexcept override;
GSL_SUPPRESS(f.6) Login::Response Login(const Login::Request& request) noexcept override;
Logout::Response Logout(_UNUSED const Logout::Request& /*request*/) noexcept override;
};
} // namespace impl
+8 -8
View File
@@ -14,36 +14,36 @@ class ServerBase : public IServer
{
public:
// === user functions ===
Login::Response Login(_UNUSED const Login::Request& request) noexcept override
GSL_SUPPRESS(f.6) Login::Response Login(_UNUSED const Login::Request& /*request*/) noexcept override
{
return UnsupportedApi<Login::Response>(Login::Name());
}
Logout::Response Logout(_UNUSED const Logout::Request& request) noexcept override
GSL_SUPPRESS(f.6) Logout::Response Logout(_UNUSED const Logout::Request& /*request*/) noexcept override
{
return UnsupportedApi<Logout::Response>(Logout::Name());
}
StartSession::Response StartSession(_UNUSED const StartSession::Request& request) noexcept override
GSL_SUPPRESS(f.6) StartSession::Response StartSession(_UNUSED const StartSession::Request& /*request*/) noexcept override
{
return UnsupportedApi<StartSession::Response>(StartSession::Name());
}
Ping::Response Ping(_UNUSED const Ping::Request& request) noexcept override
GSL_SUPPRESS(f.6) Ping::Response Ping(_UNUSED const Ping::Request& /*request*/) noexcept override
{
return UnsupportedApi<Ping::Response>(Ping::Name());
}
protected:
template<typename TResponse>
inline typename TResponse UnsupportedApi(const char* const apiName) const noexcept
GSL_SUPPRESS(f.6)
inline typename TResponse UnsupportedApi(const char* const restrict apiName) const
{
static_assert(std::is_base_of<ApiResponseBase, TResponse>::value, "TResponse must derive from ApiResponseBase");
TResponse response;
response.Result = ApiResult::Unsupported;
response.ErrorMessage = std::string(apiName) + " is not supported by " + Name();
response.Result = ApiResult::Unsupported;
response.ErrorMessage = ra::StringPrintf("%s is not supported by %s.", apiName, Name());
return std::move(response);
}
};
+16 -5
View File
@@ -4,10 +4,12 @@
<PropertyGroup Label="UserMacros">
<RA_DIR>$(SolutionDir)</RA_DIR>
<RapidJSON_IncludeDir>$(RA_DIR)rapidjson\include\</RapidJSON_IncludeDir>
<RA_SourceDir>$(RA_DIR)src\</RA_SourceDir>
<rcheevos_IncludePath>$(RA_DIR)rcheevos\include\</rcheevos_IncludePath>
<RA_SourceDir>$(RA_DIR)src\</RA_SourceDir>
<GSL_IncludeDir>$(RA_DIR)GSL\include\</GSL_IncludeDir>
<Lua_Dir>$(RA_DIR)lua\</Lua_Dir>
<RA_IncludePath>$(RA_DIR);$(RA_SourceDir);$(RapidJSON_IncludeDir);$(rcheevos_IncludePath);$(Lua_Dir)</RA_IncludePath>
<RA_IncludePath>$(RA_DIR);$(RA_SourceDir);$(RapidJSON_IncludeDir);$(rcheevos_IncludePath);$(Lua_Dir);$(GSL_IncludeDir)</RA_IncludePath>
<XPDeprecationWarning>false</XPDeprecationWarning>
</PropertyGroup>
<PropertyGroup>
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
@@ -45,6 +47,7 @@
</PostBuildEvent>
<Link>
<ProgramDatabaseFile>$(LocalDebuggerWorkingDirectory)\$(TargetName).pdb</ProgramDatabaseFile>
<IgnoreSpecificDefaultLibraries>libc.lib, libcmt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@@ -64,13 +67,21 @@
<Value>$(RA_SourceDir)</Value>
<EnvironmentVariable>true</EnvironmentVariable>
</BuildMacro>
<BuildMacro Include="RA_IncludePath">
<Value>$(RA_IncludePath)</Value>
<BuildMacro Include="GSL_IncludeDir">
<Value>$(GSL_IncludeDir)</Value>
<EnvironmentVariable>true</EnvironmentVariable>
</BuildMacro>
<BuildMacro Include="Lua_Dir">
<Value>$(Lua_Dir)</Value>
<EnvironmentVariable>true</EnvironmentVariable>
</BuildMacro>
<BuildMacro Include="RA_IncludePath">
<Value>$(RA_IncludePath)</Value>
<EnvironmentVariable>true</EnvironmentVariable>
</BuildMacro>
<BuildMacro Include="XPDeprecationWarning">
<Value>$(XPDeprecationWarning)</Value>
<EnvironmentVariable>true</EnvironmentVariable>
</BuildMacro>
</ItemGroup>
</Project>
</Project>
+1 -1
View File
@@ -24,7 +24,7 @@ void GameContext::LoadGame(unsigned int nGameId, const std::wstring& sGameTitle)
m_sGameTitle = sGameTitle;
}
bool GameContext::HasRichPresence() const
bool GameContext::HasRichPresence() const noexcept
{
return (m_pRichPresenceInterpreter != nullptr && m_pRichPresenceInterpreter->Enabled());
}
+6 -6
View File
@@ -28,17 +28,17 @@ public:
/// <summary>
/// Gets the unique identifier of the currently loaded game.
/// </summary>
unsigned int GameId() const { return m_nGameId; }
unsigned int GameId() const noexcept { return m_nGameId; }
/// <summary>
/// Gets the title of the currently loaded game.
/// </summary>
const std::wstring& GameTitle() const { return m_sGameTitle; }
const std::wstring& GameTitle() const noexcept { return m_sGameTitle; }
/// <summary>
/// Gets the hash of the currently loaded game.
/// </summary>
const std::string& GameHash() const { return m_sGameHash; }
const std::string& GameHash() const noexcept { return m_sGameHash; }
/// <summary>
/// Sets the game hash.
@@ -48,7 +48,7 @@ public:
/// <summary>
/// Gets which achievements are active.
/// </summary>
virtual AchievementSet::Type ActiveAchievementType() const
virtual AchievementSet::Type ActiveAchievementType() const noexcept
{
#ifdef RA_UTEST
return AchievementSet::Type::Core;
@@ -60,7 +60,7 @@ public:
/// <summary>
/// Determines if any achievements are currently active.
/// </summary>
virtual bool HasActiveAchievements() const
virtual bool HasActiveAchievements() const noexcept
{
#ifdef RA_UTEST
return false;
@@ -72,7 +72,7 @@ public:
/// <summary>
/// Gets whether or not the loaded game has a rich presence script.
/// </summary>
virtual bool HasRichPresence() const;
virtual bool HasRichPresence() const noexcept;
/// <summary>
/// Gets the current rich presence display string.
+4 -4
View File
@@ -47,19 +47,19 @@ void SessionTracker::LoadSessions()
if (nIndex == std::string::npos)
continue;
auto nGameId = strtoul(sLine.c_str(), nullptr, 10);
const auto nGameId = std::stoul(sLine);
auto nIndex2 = sLine.find(':', ++nIndex);
if (nIndex2 == std::string::npos)
continue;
auto nSessionStart = strtoul(&sLine[nIndex], nullptr, 10);
const auto nSessionStart = strtoul(&sLine[nIndex], nullptr, 10);
nIndex = sLine.find(':', ++nIndex2);
if (nIndex == std::string::npos)
continue;
auto nSessionLength = strtoul(&sLine[nIndex2], nullptr, 10);
const auto nSessionLength = strtoul(&sLine[nIndex2], nullptr, 10);
auto md5 = RAGenerateMD5(reinterpret_cast<const unsigned char*>(sLine.c_str()), nIndex + 1);
if (sLine[nIndex + 1] == md5.front() && sLine[nIndex + 2] == md5.back())
@@ -210,7 +210,7 @@ std::chrono::seconds SessionTracker::GetTotalPlaytime(unsigned int nGameId) cons
return tPlaytime;
}
bool SessionTracker::IsInspectingMemory() const
bool SessionTracker::IsInspectingMemory() const noexcept
{
#ifdef RA_UTEST
return false;
+2 -2
View File
@@ -40,7 +40,7 @@ public:
/// <summary>
/// Determines whether any previous session data exists.
/// </summary>
bool HasSessionData() const { return !m_vGameStats.empty(); }
bool HasSessionData() const noexcept { return !m_vGameStats.empty(); }
protected:
virtual void LoadSessions();
@@ -48,7 +48,7 @@ protected:
long WriteSessionStats(std::chrono::seconds tSessionDuration) const;
std::wstring GetCurrentActivity() const;
virtual bool IsInspectingMemory() const;
virtual bool IsInspectingMemory() const noexcept;
std::wstring m_sUsername;
+5 -5
View File
@@ -30,27 +30,27 @@ public:
/// <summary>
/// Gets the username of the current user.
/// </summary>
const std::string& GetUsername() const { return m_sUsername; }
const std::string& GetUsername() const noexcept { return m_sUsername; }
/// <summary>
/// Gets the API token for the current user.
/// </summary>
const std::string& GetApiToken() const { return m_sApiToken; }
const std::string& GetApiToken() const noexcept { return m_sApiToken; }
/// <summary>
/// Determines whether the current user is logged in.
/// </summary>
bool IsLoggedIn() const { return !m_sApiToken.empty(); }
bool IsLoggedIn() const noexcept { return !m_sApiToken.empty(); }
/// <summary>
/// Gets the number of points earned by the user.
/// </summary>
unsigned int GetScore() const { return m_nScore; }
unsigned int GetScore() const noexcept { return m_nScore; }
/// <summary>
/// Updates the number of points earned by the user.
/// </summary>
void SetScore(unsigned int nValue) { m_nScore = nValue; }
void SetScore(unsigned int nValue) noexcept { m_nScore = nValue; }
protected:
std::string m_sUsername;
+11 -8
View File
@@ -12,12 +12,12 @@
#pragma warning(disable : 4091 4191 4365 4464 4571 4619 4623 4625 4626 4768 4774 5026 5027 5039 5045)
/* Windows Stuff */
#include "windows_nodefines.h"
#include <ShlObj.h> // CommCtrl
#include <WindowsX.h>
#include <atlbase.h> // atldef.h (Windows.h), atlcore.h (tchar.h), Shlwapi.h
#include <direct.h>
#include <io.h>
#include <ShlObj.h> // CommCtrl
#include <wincodec.h>
#include <WindowsX.h>
#include <winhttp.h>
#if WIN32_LEAN_AND_MEAN
@@ -60,10 +60,10 @@
#define RAPIDJSON_HAS_STDSTRING 1
#define RAPIDJSON_NOMEMBERITERATORCLASS 1
#include <rapidjson\document.h> // has reader.h
#include <rapidjson\writer.h> // has stringbuffer.h
#include <rapidjson\error\en.h>
#include <rapidjson\istreamwrapper.h>
#include <rapidjson\ostreamwrapper.h>
#include <rapidjson\error\en.h>
#include <rapidjson\writer.h> // has stringbuffer.h
#pragma warning(pop)
#include <md5.h>
@@ -77,10 +77,13 @@
#endif /* RA_UTEST */
/* rcheevos stuff */
#pragma warning (push)
#pragma warning (disable:4201) // nameless struct
#include "rcheevos\include\rcheevos.h"
#pragma warning (pop)
#pragma warning(push)
#pragma warning(disable : 4201) // nameless struct
#include <rcheevos.h>
#pragma warning(pop)
/* gsl stuff */
#include <gsl\gsl>
#pragma warning(pop)
+21 -15
View File
@@ -1,21 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="ra_rules" Description="CppCoreCheck Class, Const Rules" ToolsVersion="15.0">
<RuleSet Name="ra_rules" ToolsVersion="15.0">
<Include Path="cppcorecheckclassrules.ruleset" Action="Default" />
<Include Path="cppcorecheckconstrules.ruleset" Action="Default" />
<Include Path="cppcorecheckfuncrules.ruleset" Action="Default" />
<Rules AnalyzerId="Microsoft.Analyzers.NativeCodeAnalysis" RuleNamespace="Microsoft.Rules.Native">
<Rule Id="C26432" Action="None" />
<Rule Id="C26433" Action="None" />
<Rule Id="C26434" Action="None" />
<Rule Id="C26435" Action="None" />
<Rule Id="C26436" Action="None" />
<Rule Id="C26443" Action="None" />
<Rule Id="C26460" Action="None" />
<Rule Id="C26461" Action="None" />
<Rule Id="C26462" Action="None" />
<Rule Id="C26463" Action="None" />
<Rule Id="C26464" Action="None" />
<Rule Id="C26496" Action="None" />
<Rule Id="C26497" Action="None" />
<Rule Id="C26498" Action="None" />
<Rule Id="C26432" Action="Warning" />
<Rule Id="C26433" Action="Warning" />
<Rule Id="C26434" Action="Warning" />
<Rule Id="C26435" Action="Warning" />
<Rule Id="C26436" Action="Warning" />
<Rule Id="C26439" Action="Warning" />
<Rule Id="C26440" Action="Warning" />
<Rule Id="C26443" Action="Warning" />
<Rule Id="C26447" Action="Warning" />
<Rule Id="C26455" Action="Warning" />
<Rule Id="C26456" Action="Warning" />
<Rule Id="C26460" Action="Warning" />
<Rule Id="C26461" Action="Warning" />
<Rule Id="C26462" Action="Warning" />
<Rule Id="C26463" Action="Warning" />
<Rule Id="C26464" Action="Warning" />
<Rule Id="C26496" Action="Warning" />
<Rule Id="C26497" Action="Warning" />
<Rule Id="C26498" Action="Warning" />
</Rules>
</RuleSet>
+4 -5
View File
@@ -62,9 +62,9 @@
<CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>$(SolutionDir)lua;$(SolutionDir)rcheevos\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ConformanceMode>true</ConformanceMode>
<WarningLevel>Level3</WarningLevel>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -72,6 +72,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Lib />
<Lib>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
</Lib>
@@ -92,9 +93,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Lib />
<Lib>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
</Lib>
<Lib />
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\rcheevos\include\rcheevos.h" />
@@ -138,4 +137,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
+3 -3
View File
@@ -48,7 +48,7 @@ public:
class Request
{
public:
explicit Request(const std::string& sUrl) noexcept
explicit Request(const std::string& sUrl)
{
const auto nIndex = sUrl.find('?');
if (nIndex == std::string::npos)
@@ -97,7 +97,7 @@ public:
/// Sets the POST data.
/// </summary>
/// <remarks>If not empty, POST request will be made, otherwise GET request wil be made.</remarks>
void SetPostData(const std::string& sValue) noexcept { m_sPostData = sValue; }
void SetPostData(const std::string& sValue) { m_sPostData = sValue; }
/// <summary>
/// Gets the POST data.
@@ -107,7 +107,7 @@ public:
/// <summary>
/// Specifies the Content-Type to send. Default: "application/x-www-form-urlencoded"
/// </summary>
void SetContentType(const std::string& sValue) noexcept { m_sContentType = sValue; }
void SetContentType(const std::string& sValue) { m_sContentType = sValue; }
/// <summary>
/// Gets the Content-Type to send. Default: "application/x-www-form-urlencoded"
+2 -2
View File
@@ -17,12 +17,12 @@ public:
/// <summary>
/// Queues work for a background thread
/// </summary>
virtual void RunAsync(std::function<void()>&& f) noexcept = 0;
virtual void RunAsync(std::function<void()>&& f) = 0;
/// <summary>
/// Queues work for a background thread to be run after a period of time
/// </summary>
virtual void ScheduleAsync(std::chrono::milliseconds nDelay, std::function<void()>&& f) noexcept = 0;
virtual void ScheduleAsync(std::chrono::milliseconds nDelay, std::function<void()>&& f) = 0;
/// <summary>
/// Sets the <see ref="IsShutdownRequested" /> flag so threads can start winding down.
+2 -2
View File
@@ -240,7 +240,7 @@ void SearchResults::ProcessBlocksNibbles(const SearchResults& srSource, unsigned
for (unsigned int i = 0; i < block.GetSize() - nPadding; ++i)
{
unsigned int nValue1 = vMemory.at(i);
const unsigned int nValue1 = vMemory.at(i);
unsigned int nValue2 = (nTestValue > 15) ? (block.GetByte(i) & 0x0F) : nTestValue;
if (Compare(nValue1 & 0x0F, nValue2, nCompareType))
@@ -383,7 +383,7 @@ void SearchResults::Initialize(const SearchResults& srSource, ComparisonType nCo
m_sSummary.append(" last known value...");
}
unsigned int SearchResults::MatchingAddressCount()
unsigned int SearchResults::MatchingAddressCount() noexcept
{
if (!m_bUnfiltered)
return m_vMatchingAddresses.size();
+26 -23
View File
@@ -36,18 +36,18 @@ public:
/// <summary>
/// Gets the number of matching addresses.
/// </summary>
unsigned int MatchingAddressCount();
unsigned int MatchingAddressCount() noexcept;
/// <summary>
/// Gets a summary of the results
/// </summary>
const std::string& Summary() const { return m_sSummary; }
const std::string& Summary() const noexcept { return m_sSummary; }
struct Result
{
unsigned int nAddress;
unsigned int nValue;
MemSize nSize;
unsigned int nAddress{};
unsigned int nValue{};
MemSize nSize{};
};
/// <summary>
@@ -61,7 +61,8 @@ public:
/// Determines whether the specified address appears in the matching address list.
/// </summary>
/// <param name="nAddress">The n address.</param>
/// <returns><c>true</c> if the specified address is in the matching address list; otherwise, <c>false</c>.</returns>
/// <returns><c>true</c> if the specified address is in the matching address list; otherwise,
/// <c>false</c>.</returns>
bool ContainsAddress(unsigned int nAddress) const;
/// <summary>
@@ -81,28 +82,27 @@ protected:
{
public:
explicit MemBlock(_In_ unsigned int nAddress, _In_ unsigned int nSize) noexcept :
nAddress{ nAddress }, nSize{ nSize }
nAddress{nAddress},
nSize{nSize}
{
if (nSize > sizeof(m_vBytes))
m_pBytes = new unsigned char[nSize];
m_pBytes = new (std::nothrow) unsigned char[nSize];
}
MemBlock(const MemBlock& other) noexcept :
MemBlock(other.nAddress, other.nSize)
MemBlock(const MemBlock& other) noexcept : MemBlock(other.nAddress, other.nSize)
{
if (nSize > sizeof(m_vBytes))
std::memcpy(m_pBytes, other.m_pBytes, nSize);
}
MemBlock& operator=(const MemBlock&) noexcept = delete;
MemBlock(MemBlock&& other) noexcept :
nAddress{ other.nAddress }, nSize{ other.nSize }
MemBlock(MemBlock&& other) noexcept : nAddress{other.nAddress}, nSize{other.nSize}
{
if (other.nSize > sizeof(m_vBytes))
{
m_pBytes = other.m_pBytes;
m_pBytes = other.m_pBytes;
other.m_pBytes = nullptr;
other.nSize = 0;
other.nSize = 0;
}
else
{
@@ -116,12 +116,12 @@ protected:
delete[] m_pBytes;
}
unsigned char* GetBytes() { return (nSize > sizeof(m_vBytes)) ? m_pBytes : &m_vBytes[0]; }
const unsigned char* GetBytes() const { return (nSize > sizeof(m_vBytes)) ? m_pBytes : &m_vBytes[0]; }
unsigned char* GetBytes() noexcept { return (nSize > sizeof(m_vBytes)) ? m_pBytes : &m_vBytes[0]; }
const unsigned char* GetBytes() const noexcept { return (nSize > sizeof(m_vBytes)) ? m_pBytes : &m_vBytes[0]; }
unsigned char GetByte(std::size_t nIndex) noexcept { return GetBytes()[nIndex]; }
unsigned char GetByte(std::size_t nIndex) const noexcept { return GetBytes()[nIndex]; }
unsigned int GetAddress() const { return nAddress; }
unsigned int GetSize() const { return nSize; }
unsigned int GetAddress() const noexcept { return nAddress; }
unsigned int GetSize() const noexcept { return nSize; }
private:
union // 8 bytes
@@ -138,10 +138,15 @@ protected:
MemBlock& AddBlock(unsigned int nAddress, unsigned int nSize);
private:
void ProcessBlocks(const SearchResults& srSource, std::function<bool(unsigned int nIndex, const unsigned char pMemory[], const unsigned char pPrev[])> testIndexFunction);
void ProcessBlocks(
const SearchResults& srSource,
std::function<bool(unsigned int nIndex, const unsigned char pMemory[], const unsigned char pPrev[])>
testIndexFunction);
void ProcessBlocksNibbles(const SearchResults& srSource, unsigned int nTestValue, ComparisonType nCompareType);
void AddMatches(unsigned int nAddressBase, const unsigned char pMemory[], const std::vector<unsigned int>& vMatches);
void AddMatchesNibbles(unsigned int nAddressBase, const unsigned char pMemory[], const std::vector<unsigned int>& vMatches);
void AddMatches(unsigned int nAddressBase, const unsigned char pMemory[],
const std::vector<unsigned int>& vMatches);
void AddMatchesNibbles(unsigned int nAddressBase, const unsigned char pMemory[],
const std::vector<unsigned int>& vMatches);
std::string m_sSummary;
std::vector<MemBlock> m_vBlocks;
@@ -154,6 +159,4 @@ private:
} // namespace services
} // namespace ra
#endif /* !SEARCHRESULTS_H */
+3 -3
View File
@@ -45,7 +45,7 @@ public:
/// </summary>
/// <returns><c>true</c> if an implementation exists, <c>false</c> if not.</returns>
template <class TClass>
static bool Exists()
static bool Exists() noexcept
{
return Service<TClass>::Exists();
}
@@ -58,7 +58,7 @@ public:
/// pointer and delete it at the end of execution or when a different implementation is provided.
/// </param>
template <class TClass>
static void Provide(TClass* pInstance)
static void Provide(TClass* pInstance) noexcept
{
Service<TClass>::s_pInstance.reset(pInstance);
}
@@ -123,7 +123,7 @@ private:
return *s_pInstance.get();
}
static bool Exists()
static bool Exists() noexcept
{
return (s_pInstance != nullptr);
}
+2 -4
View File
@@ -11,14 +11,12 @@ namespace impl {
class Clock : public ra::services::IClock
{
public:
Clock() noexcept = default;
std::chrono::system_clock::time_point Now() const override
std::chrono::system_clock::time_point Now() const noexcept override
{
return std::chrono::system_clock::now();
}
std::chrono::steady_clock::time_point UpTime() const override
std::chrono::steady_clock::time_point UpTime() const noexcept override
{
return std::chrono::steady_clock::now();
}
+1 -1
View File
@@ -51,7 +51,7 @@ static void PrepareDirectory(const ra::services::IFileSystem& pFileSystem, const
}
}
FileLocalStorage::FileLocalStorage(IFileSystem& pFileSystem) noexcept
FileLocalStorage::FileLocalStorage(IFileSystem& pFileSystem)
: m_pFileSystem(pFileSystem)
{
// Ensure all required directories are created
+1 -1
View File
@@ -12,7 +12,7 @@ namespace impl {
class FileLocalStorage : public ILocalStorage
{
public:
explicit FileLocalStorage(IFileSystem& pFileSystem) noexcept;
explicit FileLocalStorage(IFileSystem& pFileSystem);
std::chrono::system_clock::time_point GetLastModified(StorageItemType nType, const std::wstring& sKey) override;
+3 -3
View File
@@ -17,7 +17,7 @@ namespace impl {
class FileLogger : public ra::services::ILogger
{
public:
explicit FileLogger(const ra::services::IFileSystem& pFileSystem) noexcept
explicit FileLogger(const ra::services::IFileSystem& pFileSystem)
{
std::wstring sLogFilePath = pFileSystem.BaseDirectory() + L"RACache\\RALog.txt";
@@ -35,7 +35,7 @@ public:
m_pWriter->WriteLine();
}
bool IsEnabled([[maybe_unused]] LogLevel level) const override { return true; }
bool IsEnabled([[maybe_unused]] LogLevel level) const noexcept override { return true; }
void LogMessage(LogLevel level, const std::string& sMessage) const override
{
@@ -87,7 +87,7 @@ public:
}
private:
static void LogMessage(ra::services::TextWriter& pWriter, char* sTimestamp, LogLevel level,
static void LogMessage(ra::services::TextWriter& pWriter, const char* const sTimestamp, LogLevel level,
const std::string& sMessage)
{
pWriter.Write(sTimestamp);
+2 -2
View File
@@ -13,7 +13,7 @@ namespace impl {
class FileTextReader : public ra::services::TextReader
{
public:
explicit FileTextReader(const std::wstring& sFilename) noexcept
explicit FileTextReader(const std::wstring& sFilename)
: m_iStream(sFilename)
{
}
@@ -54,7 +54,7 @@ public:
return static_cast<size_t>(const_cast<std::ifstream&>(m_iStream).tellg());
}
std::ifstream& GetFStream() { return m_iStream; }
std::ifstream& GetFStream() noexcept { return m_iStream; }
private:
std::ifstream m_iStream;
+2 -2
View File
@@ -14,7 +14,7 @@ namespace impl {
class FileTextWriter : public ra::services::TextWriter
{
public:
explicit FileTextWriter(const std::wstring& sFilename, std::ios_base::openmode nMode = std::ios::out) noexcept
explicit FileTextWriter(const std::wstring& sFilename, std::ios_base::openmode nMode = std::ios::out)
: m_oStream(sFilename, std::ios::binary | nMode)
{
}
@@ -51,7 +51,7 @@ public:
m_oStream.seekp(static_cast<std::streampos>(nNewPosition));
}
std::ofstream& GetFStream() { return m_oStream; }
std::ofstream& GetFStream() noexcept { return m_oStream; }
private:
std::ofstream m_oStream;
+4 -4
View File
@@ -140,14 +140,14 @@ void JsonFileConfiguration::Save() const
SaveDocument(doc, *pWriter);
}
bool JsonFileConfiguration::IsFeatureEnabled(Feature nFeature) const
bool JsonFileConfiguration::IsFeatureEnabled(Feature nFeature) const noexcept
{
return (m_vEnabledFeatures & (1 << static_cast<int>(nFeature)));
return (m_vEnabledFeatures & (1 << ra::etoi(nFeature)));
}
void JsonFileConfiguration::SetFeatureEnabled(Feature nFeature, bool bEnabled)
void JsonFileConfiguration::SetFeatureEnabled(Feature nFeature, bool bEnabled) noexcept
{
const int bit = 1 << static_cast<int>(nFeature);
const auto bit = 1 << ra::etoi(nFeature);
if (bEnabled)
m_vEnabledFeatures |= bit;
+6 -6
View File
@@ -13,16 +13,16 @@ class JsonFileConfiguration : public IConfiguration
public:
bool Load(const std::wstring& sFilename);
const std::string& GetUsername() const override { return m_sUsername; }
const std::string& GetUsername() const noexcept override { return m_sUsername; }
void SetUsername(const std::string& sValue) override { m_sUsername = sValue; }
const std::string& GetApiToken() const override { return m_sApiToken; }
const std::string& GetApiToken() const noexcept override { return m_sApiToken; }
void SetApiToken(const std::string& sValue) override { m_sApiToken = sValue; }
bool IsFeatureEnabled(Feature nFeature) const override;
void SetFeatureEnabled(Feature nFeature, bool bEnabled) override;
bool IsFeatureEnabled(Feature nFeature) const noexcept override;
void SetFeatureEnabled(Feature nFeature, bool bEnabled) noexcept override;
unsigned int GetNumBackgroundThreads() const override { return m_nBackgroundThreads; }
const std::string& GetRomDirectory() const override { return m_sRomDirectory; }
unsigned int GetNumBackgroundThreads() const noexcept override { return m_nBackgroundThreads; }
const std::string& GetRomDirectory() const noexcept override { return m_sRomDirectory; }
void SetRomDirectory(const std::string& sValue) override { m_sRomDirectory = sValue; }
ra::ui::Position GetWindowPosition(const std::string& sPositionKey) const override;
+2 -2
View File
@@ -27,10 +27,10 @@ public:
void SubmitLeaderboardEntry(const RA_Leaderboard& lb, unsigned int nValue) const override;
void AddLeaderboard(RA_Leaderboard&& lb) override;
size_t Count() const override { return m_Leaderboards.size(); }
size_t Count() const noexcept override { return m_Leaderboards.size(); }
const RA_Leaderboard& GetLB(size_t iter) const override { return m_Leaderboards[iter]; }
RA_Leaderboard* FindLB(ra::LeaderboardID nID) override;
void Clear() override { m_Leaderboards.clear(); }
void Clear() noexcept override { m_Leaderboards.clear(); }
private:
std::vector<RA_Leaderboard> m_Leaderboards;
+1 -1
View File
@@ -13,7 +13,7 @@ namespace impl {
class StringTextReader : public ra::services::TextReader
{
public:
explicit StringTextReader(const std::string& sInput) noexcept
explicit StringTextReader(const std::string& sInput)
: m_iStream(sInput)
{
}
+3 -3
View File
@@ -48,18 +48,18 @@ public:
Write(std::string("\n"));
}
long GetPosition() const override
long GetPosition() const noexcept override
{
return m_nWritePosition;
}
void SetPosition(long nNewPosition) override
void SetPosition(long nNewPosition) noexcept override
{
assert(nNewPosition >= 0 && nNewPosition <= ra::to_signed(m_sOutput.length()));
m_nWritePosition = static_cast<size_t>(nNewPosition);
}
std::string& GetString() { return m_sOutput; }
std::string& GetString() noexcept { return m_sOutput; }
private:
std::string& m_sOutput;
+4 -4
View File
@@ -25,7 +25,7 @@ void ThreadPool::Initialize(size_t nThreads) noexcept
m_vThreads.emplace_back(&ThreadPool::RunThread, this);
}
void ThreadPool::RunThread() noexcept
void ThreadPool::RunThread()
{
do
{
@@ -62,7 +62,7 @@ void ThreadPool::RunThread() noexcept
} while (!m_bShutdownInitiated);
}
void ThreadPool::ProcessDelayedTasks() noexcept
void ThreadPool::ProcessDelayedTasks()
{
auto& pClock = ServiceLocator::Get<IClock>();
constexpr auto tZeroMilliseconds = std::chrono::milliseconds(0);
@@ -75,7 +75,7 @@ void ThreadPool::ProcessDelayedTasks() noexcept
{
std::unique_lock<std::mutex> lock(m_oMutex);
auto tNow = pClock.UpTime();
const auto tNow = pClock.UpTime();
while (!m_vDelayedTasks.empty() && m_vDelayedTasks.front().tWhen <= tNow)
{
m_vQueue.emplace_front(std::move(m_vDelayedTasks.front().fTask));
@@ -109,7 +109,7 @@ void ThreadPool::ProcessDelayedTasks() noexcept
if (m_vDelayedTasks.empty())
break;
auto tNext = m_vDelayedTasks.front().tWhen - pClock.UpTime();
const auto tNext = m_vDelayedTasks.front().tWhen - pClock.UpTime();
if (tNext > tZeroMilliseconds)
m_cvDelayedWork.wait_for(lock, tNext);
}
+22 -21
View File
@@ -14,20 +14,20 @@ class ThreadPool : public IThreadPool
{
public:
// TODO: std::condition_variable can throw std::system_error (a.k.a fatal error).
// We could just delete the compiler defaulted constructor and handle the exception in an invariant (param constructor)
// We could just delete the compiler defaulted constructor and handle the exception in an invariant (param
// constructor)
// Info: https://en.cppreference.com/w/cpp/thread/condition_variable/condition_variable
ThreadPool()
noexcept(std::is_nothrow_default_constructible_v<std::condition_variable>) = default;
ThreadPool() noexcept(std::is_nothrow_default_constructible_v<std::condition_variable>) = default;
~ThreadPool() noexcept;
ThreadPool(const ThreadPool&) noexcept = delete;
ThreadPool& operator=(const ThreadPool&) noexcept = delete;
ThreadPool(ThreadPool&&) noexcept = delete;
ThreadPool(ThreadPool&&) noexcept = delete;
ThreadPool& operator=(ThreadPool&&) noexcept = delete;
void Initialize(size_t nThreads) noexcept;
GSL_SUPPRESS(f.6) void Initialize(size_t nThreads) noexcept;
void RunAsync(std::function<void()>&& f) noexcept override
void RunAsync(std::function<void()>&& f) override
{
if (m_bShutdownInitiated)
return;
@@ -41,8 +41,8 @@ public:
m_cvWork.notify_one();
}
void ScheduleAsync(std::chrono::milliseconds nDelay, std::function<void()>&& f) noexcept override
void ScheduleAsync(std::chrono::milliseconds nDelay, std::function<void()>&& f) override
{
if (m_bShutdownInitiated)
return;
@@ -52,7 +52,7 @@ public:
const auto tWhen = ServiceLocator::Get<IClock>().UpTime() + nDelay;
bool bStartScheduler = false;
bool bNewPriority = false;
bool bNewPriority = false;
{
std::unique_lock<std::mutex> lock(m_oMutex);
@@ -66,13 +66,15 @@ public:
}
else if (tWhen < iter->tWhen)
{
// sooner than the next scheduled task, we'll need to wake the timed events thread to reset the wait time
// sooner than the next scheduled task, we'll need to wake the timed events thread to reset the wait
// time
bNewPriority = true;
}
else
{
// after the next scheduled task, find where to insert it
do {
do
{
++iter;
} while (iter != m_vDelayedTasks.end() && iter->tWhen < tWhen);
}
@@ -93,24 +95,23 @@ public:
}
}
void Shutdown(bool bWait) noexcept override;
GSL_SUPPRESS(f.6) void Shutdown(bool bWait) noexcept override;
bool IsShutdownRequested() const noexcept override
{
return m_bShutdownInitiated;
}
bool IsShutdownRequested() const noexcept override { return m_bShutdownInitiated; }
private:
void RunThread() noexcept;
void ProcessDelayedTasks() noexcept;
void RunThread();
void ProcessDelayedTasks();
std::vector<std::thread> m_vThreads;
size_t m_nThreads{ 0U };
bool m_bShutdownInitiated{ false };
size_t m_nThreads{0U};
bool m_bShutdownInitiated{false};
struct DelayedTask
{
DelayedTask(std::chrono::steady_clock::time_point tWhen, std::function<void()> fTask) : tWhen(tWhen), fTask(fTask) {};
DelayedTask(std::chrono::steady_clock::time_point tWhen, std::function<void()> fTask) :
tWhen(tWhen),
fTask(fTask){};
std::chrono::steady_clock::time_point tWhen;
std::function<void()> fTask;
+1 -1
View File
@@ -11,7 +11,7 @@ namespace impl {
class WindowsClipboard : public ra::services::IClipboard
{
public:
void SetText(const std::wstring& sValue) const override
void SetText(const std::wstring& sValue) const noexcept override
{
// allocate memory to be managed by the clipboard
const SIZE_T nSize = (sValue.length() + 1) * 2; // 16-bit characters, with null terminator
@@ -11,7 +11,7 @@ namespace impl {
class WindowsDebuggerFileLogger : public FileLogger
{
public:
explicit WindowsDebuggerFileLogger(const ra::services::IFileSystem& pFileSystem) noexcept
explicit WindowsDebuggerFileLogger(const ra::services::IFileSystem& pFileSystem)
: FileLogger(pFileSystem)
{
}
+11 -8
View File
@@ -15,21 +15,24 @@ namespace impl {
WindowsFileSystem::WindowsFileSystem() noexcept
{
// determine the home directory from the executable's path
wchar_t sBuffer[MAX_PATH];
wchar_t sBuffer[MAX_PATH]{};
GetModuleFileNameW(0, sBuffer, MAX_PATH);
PathRemoveFileSpecW(sBuffer);
m_sBaseDirectory = sBuffer;
if (m_sBaseDirectory.back() != '\\')
m_sBaseDirectory.push_back('\\');
if (!m_sBaseDirectory.empty())
{
if (m_sBaseDirectory.back() != L'\\')
m_sBaseDirectory.push_back(L'\\');
}
}
bool WindowsFileSystem::DirectoryExists(const std::wstring& sDirectory) const
bool WindowsFileSystem::DirectoryExists(const std::wstring& sDirectory) const noexcept
{
const DWORD nAttrib = GetFileAttributesW(sDirectory.c_str());
return (nAttrib != INVALID_FILE_ATTRIBUTES) && (nAttrib & FILE_ATTRIBUTE_DIRECTORY);
}
bool WindowsFileSystem::CreateDirectory(const std::wstring& sDirectory) const
bool WindowsFileSystem::CreateDirectory(const std::wstring& sDirectory) const noexcept
{
return static_cast<bool>(CreateDirectoryW(sDirectory.c_str(), nullptr));
}
@@ -55,12 +58,12 @@ size_t WindowsFileSystem::GetFilesInDirectory(const std::wstring& sDirectory, _I
return vResults.size() - nInitialSize;
}
bool WindowsFileSystem::DeleteFile(const std::wstring& sPath) const
bool WindowsFileSystem::DeleteFile(const std::wstring& sPath) const noexcept
{
return static_cast<bool>(DeleteFileW(sPath.c_str()));
}
bool WindowsFileSystem::MoveFile(const std::wstring& sOldPath, const std::wstring& sNewPath) const
bool WindowsFileSystem::MoveFile(const std::wstring& sOldPath, const std::wstring& sNewPath) const noexcept
{
return static_cast<bool>(MoveFileW(sOldPath.c_str(), sNewPath.c_str()));
}
@@ -139,7 +142,7 @@ std::unique_ptr<TextWriter> WindowsFileSystem::AppendTextFile(const std::wstring
// cannot use std::ios::app, or the SetPosition method doesn't work
// have to specify std::ios::in or the previous contents are lost
auto pWriter = std::make_unique<FileTextWriter>(sPath, std::ios::ate | std::ios::in | std::ios::out);
auto* oStream = &pWriter->GetFStream();
const std::ofstream* oStream = &pWriter->GetFStream();
if (!oStream->is_open())
{
// failed to open the file - try creating it
+6 -6
View File
@@ -15,14 +15,14 @@ namespace impl {
class WindowsFileSystem : public IFileSystem
{
public:
WindowsFileSystem() noexcept;
GSL_SUPPRESS(f.6) WindowsFileSystem() noexcept;
const std::wstring& BaseDirectory() const override { return m_sBaseDirectory; }
bool DirectoryExists(const std::wstring& sDirectory) const override;
bool CreateDirectory(const std::wstring& sDirectory) const override;
const std::wstring& BaseDirectory() const noexcept override { return m_sBaseDirectory; }
bool DirectoryExists(const std::wstring& sDirectory) const noexcept override;
bool CreateDirectory(const std::wstring& sDirectory) const noexcept override;
size_t GetFilesInDirectory(const std::wstring& sDirectory, _Inout_ std::vector<std::wstring>& vResults) const override;
bool DeleteFile(const std::wstring& sPath) const override;
bool MoveFile(const std::wstring& sOldPath, const std::wstring& sNewPath) const override;
bool DeleteFile(const std::wstring& sPath) const noexcept override;
bool MoveFile(const std::wstring& sOldPath, const std::wstring& sNewPath) const noexcept override;
int64_t GetFileSize(const std::wstring& sPath) const override;
std::chrono::system_clock::time_point GetLastModified(const std::wstring& sPath) const override;
std::unique_ptr<TextReader> OpenTextFile(const std::wstring& sPath) const override;
+1 -1
View File
@@ -20,7 +20,7 @@ public:
BindingBase& operator=(BindingBase&&) noexcept = delete;
protected:
explicit BindingBase(_Inout_ ViewModelBase& vmViewModel) noexcept :
explicit BindingBase(_Inout_ ViewModelBase& vmViewModel) :
m_vmViewModel{ vmViewModel }
{
vmViewModel.AddNotifyTarget(*this);
+10 -9
View File
@@ -24,8 +24,9 @@ public:
virtual ~IImageRepository() noexcept = default;
IImageRepository(const IImageRepository&) noexcept = delete;
IImageRepository& operator=(const IImageRepository&) noexcept = delete;
IImageRepository(IImageRepository&&) noexcept = delete;
IImageRepository& operator=(IImageRepository&&) noexcept = delete;
/// <summary>
/// Ensures an image is available locally.
/// </summary>
@@ -36,7 +37,7 @@ public:
/// <summary>Adds a reference to an image.</summary>
/// <param name="nType">Type of the image.</param>
/// <param name="sName">Name of the image.</param>
virtual void AddReference(ImageReference& pImage) noexcept = 0;
virtual void AddReference(ImageReference& pImage) = 0;
/// <summary>Releases a reference to an image.</summary>
/// <param name="nType">Type of the image.</param>
@@ -49,7 +50,7 @@ public:
/// <remarks>
/// Updates the internal state of the <see cref="ImageReference" /> if <c>true</c>.
/// </remarks>
virtual bool HasReferencedImageChanged(ImageReference& pImage) const noexcept = 0;
virtual bool HasReferencedImageChanged(ImageReference& pImage) const = 0;
protected:
IImageRepository() noexcept = default;
@@ -65,7 +66,7 @@ public:
Release();
}
explicit ImageReference(ImageType nType, const std::string& sName) noexcept
explicit ImageReference(ImageType nType, const std::string& sName)
: m_nType(nType), m_sName(sName)
{
}
@@ -78,12 +79,12 @@ public:
/// <summary>
/// Get the image type.
/// </summary>
ImageType Type() const { return m_nType; }
ImageType Type() const noexcept { return m_nType; }
/// <summary>
/// Get the image name.
/// </summary>
const std::string& Name() const { return m_sName; }
const std::string& Name() const noexcept { return m_sName; }
/// <summary>
/// Updates the referenced image.
@@ -104,7 +105,7 @@ public:
/// <summary>
/// Releases this reference image.
/// </summary>
void Release()
GSL_SUPPRESS(f.6) void Release() noexcept
{
if (m_nType != ImageType::None)
{
@@ -116,12 +117,12 @@ public:
/// <summary>
/// Gets custom data associated to the reference - used to cache data by <see cref="ISurface::DrawImage" />.
/// </summary>
unsigned long GetData() const { return m_nData; }
unsigned long GetData() const noexcept { return m_nData; }
/// <summary>
/// Sets custom data associated to the reference - used to cache data by <see cref="ISurface::DrawImage" />.
/// </summary>
void SetData(unsigned long nValue) { m_nData = nValue; }
void SetData(unsigned long nValue) noexcept { m_nData = nValue; }
private:
ImageType m_nType = ImageType::None;
+3 -2
View File
@@ -11,7 +11,7 @@ int ModelPropertyBase::s_nNextKey = 1;
std::vector<ModelPropertyBase*> ModelPropertyBase::s_vProperties;
_Use_decl_annotations_
ModelPropertyBase::ModelPropertyBase(const char* const sTypeName, const char* const sPropertyName) noexcept :
ModelPropertyBase::ModelPropertyBase(const char* const sTypeName, const char* const sPropertyName) :
m_sTypeName{ sTypeName },
m_sPropertyName{ sPropertyName }
{
@@ -32,7 +32,8 @@ ModelPropertyBase::~ModelPropertyBase() noexcept
const ModelPropertyBase* ModelPropertyBase::GetPropertyForKey(int nKey)
{
ModelPropertyBase search(nKey);
auto iter = std::lower_bound(s_vProperties.begin(), s_vProperties.end(), &search, [](const ModelPropertyBase* left, const ModelPropertyBase* right)
auto iter = std::lower_bound(s_vProperties.begin(), s_vProperties.end(),
&search, [](const ModelPropertyBase* left, const ModelPropertyBase* right) noexcept
{
return left->GetKey() < right->GetKey();
});
+8 -8
View File
@@ -8,7 +8,7 @@ namespace ui {
class ModelPropertyBase
{
public:
virtual ~ModelPropertyBase() noexcept;
GSL_SUPPRESS(f.6) virtual ~ModelPropertyBase() noexcept;
ModelPropertyBase(const ModelPropertyBase&) noexcept = delete;
ModelPropertyBase& operator=(const ModelPropertyBase&) noexcept = delete;
ModelPropertyBase(ModelPropertyBase&&) noexcept = delete;
@@ -17,17 +17,17 @@ public:
/// <summary>
/// Gets the unique identifier of the property.
/// </summary>
int GetKey() const { return m_nKey; }
int GetKey() const noexcept { return m_nKey; }
/// <summary>
/// Gets the name of the type that owns the property.
/// </summary>
const char* GetTypeName() const { return m_sTypeName; }
const char* GetTypeName() const noexcept { return m_sTypeName; }
/// <summary>
/// Gets the name of the property.
/// </summary>
const char* GetPropertyName() const { return m_sPropertyName; }
const char* GetPropertyName() const noexcept { return m_sPropertyName; }
/// <summary>
/// Gets the property for specified unique identifier.
@@ -45,7 +45,7 @@ public:
operator<(_In_ const ModelPropertyBase& that) const noexcept { return m_nKey < that.m_nKey; }
protected:
explicit ModelPropertyBase(_In_ const char* const sTypeName, _In_ const char* const sPropertyName) noexcept;
explicit ModelPropertyBase(_In_ const char* const sTypeName, _In_ const char* const sPropertyName);
explicit ModelPropertyBase(_In_ int nKey) noexcept { m_nKey = nKey; } // for binary search
@@ -62,7 +62,7 @@ template<class T>
class ModelProperty : public ModelPropertyBase
{
public:
explicit ModelProperty(const char* sTypeName, const char* sPropertyName, T tDefaultValue) noexcept
explicit ModelProperty(const char* sTypeName, const char* sPropertyName, T tDefaultValue)
: ModelPropertyBase(sTypeName, sPropertyName), m_tDefaultValue(tDefaultValue)
{
}
@@ -70,13 +70,13 @@ public:
/// <summary>
/// Gets the default value for the property.
/// </summary>
const T& GetDefaultValue() const { return m_tDefaultValue; }
const T& GetDefaultValue() const noexcept { return m_tDefaultValue; }
/// <summary>
/// Sets the default value for the property.
/// </summary>
/// <remarks>Affects all existing instances where a value has not been set, not just new instances.</remarks>
void SetDefaultValue(const T& tValue) { m_tDefaultValue = tValue; }
void SetDefaultValue(const T& tValue) noexcept(std::is_nothrow_copy_assignable_v<T>) { m_tDefaultValue = tValue; }
using ValueMap = std::unordered_map<int, T>;
+17 -28
View File
@@ -19,66 +19,55 @@ struct Size
enum class FontStyles
{
Normal = 0x00,
Bold = 0x01,
Italic = 0x02,
Underline = 0x04,
Normal = 0x00,
Bold = 0x01,
Italic = 0x02,
Underline = 0x04,
Strikethrough = 0x08,
};
union Color
{
explicit Color(unsigned char R, unsigned char G, unsigned char B) noexcept
: Color(0xFF, R, G, B)
{
}
union Color {
explicit Color(unsigned char R, unsigned char G, unsigned char B) noexcept : Color(0xFF, R, G, B) {}
explicit Color(unsigned char A, unsigned char R, unsigned char G, unsigned char B) noexcept
: Color((A << 24) | (R << 16) | (G << 8) | B)
{
}
explicit Color(unsigned char A, unsigned char R, unsigned char G, unsigned char B) noexcept :
Color((A << 24) | (R << 16) | (G << 8) | B)
{}
explicit Color(unsigned int ARGB) noexcept
{
this->ARGB = ARGB;
}
explicit Color(unsigned int ARGB) noexcept { this->ARGB = ARGB; }
Color(const Color&) noexcept = default;
Color& operator=(const Color&) noexcept = default;
Color(Color&&) noexcept = default;
Color(Color&&) noexcept = default;
Color& operator=(Color&&) noexcept = default;
bool operator!=(const Color& that)
{
return (this->ARGB != that.ARGB);
}
bool operator!=(const Color& that) const noexcept { return (this->ARGB != that.ARGB); }
/// <summary>
/// The 32-bit ARGB value.
/// </summary>
unsigned int ARGB;
unsigned int ARGB{};
struct Channel
{
/// <summary>
/// The 8-bit blue value.
/// </summary>
unsigned char B;
unsigned char B{};
/// <summary>
/// The 8-bit green value.
/// </summary>
unsigned char G;
unsigned char G{};
/// <summary>
/// The 8-bit red value.
/// </summary>
unsigned char R;
unsigned char R{};
/// <summary>
/// The 8-bit alpha value.
/// </summary>
unsigned char A;
unsigned char A{};
} Channel;
};
static_assert(sizeof(Color) == sizeof(unsigned int));
+6 -4
View File
@@ -24,13 +24,15 @@ public:
NotifyTarget(NotifyTarget&&) noexcept = default;
NotifyTarget& operator=(NotifyTarget&&) noexcept = default;
virtual void OnViewModelBoolValueChanged([[maybe_unused]] const BoolModelProperty::ChangeArgs& args) {}
virtual void OnViewModelStringValueChanged([[maybe_unused]] const StringModelProperty::ChangeArgs& args) {}
virtual void OnViewModelIntValueChanged([[maybe_unused]] const IntModelProperty::ChangeArgs& args) {}
virtual void OnViewModelBoolValueChanged([[maybe_unused]] const BoolModelProperty::ChangeArgs& args) noexcept {}
virtual void OnViewModelStringValueChanged([
[maybe_unused]] const StringModelProperty::ChangeArgs& args) noexcept
{}
virtual void OnViewModelIntValueChanged([[maybe_unused]] const IntModelProperty::ChangeArgs& args) noexcept {}
};
void AddNotifyTarget(NotifyTarget& pTarget) { m_vNotifyTargets.insert(&pTarget); }
void RemoveNotifyTarget(NotifyTarget& pTarget) { m_vNotifyTargets.erase(&pTarget); }
GSL_SUPPRESS(f.6) void RemoveNotifyTarget(NotifyTarget& pTarget) noexcept { m_vNotifyTargets.erase(&pTarget); }
private:
using NotifyTargetSet = std::set<NotifyTarget*>;
+2 -1
View File
@@ -15,9 +15,10 @@ class ISurface
{
public:
virtual ~ISurface() noexcept = default;
ISurface(const ISurface&) noexcept = delete;
ISurface& operator=(const ISurface&) noexcept = delete;
ISurface(ISurface&&) noexcept = delete;
ISurface& operator=(ISurface&&) noexcept = delete;
/// <summary>
/// Gets the width of the surface.
+12 -12
View File
@@ -7,7 +7,7 @@ namespace ui {
namespace drawing {
namespace gdi {
void GDIAlphaBitmapSurface::FillRectangle(int nX, int nY, int nWidth, int nHeight, Color nColor)
void GDIAlphaBitmapSurface::FillRectangle(int nX, int nY, int nWidth, int nHeight, Color nColor) noexcept
{
assert(nWidth != 0);
assert(nHeight != 0);
@@ -18,7 +18,7 @@ void GDIAlphaBitmapSurface::FillRectangle(int nX, int nY, int nWidth, int nHeigh
if (nStride == nWidth)
{
// doing full scanlines, just bulk fill
auto pEnd = pBits + nWidth * nHeight;
const UINT32* pEnd = pBits + nWidth * nHeight;
do
{
*pBits++ = nColor.ARGB;
@@ -29,7 +29,7 @@ void GDIAlphaBitmapSurface::FillRectangle(int nX, int nY, int nWidth, int nHeigh
// partial scanlines, have to fill in strips
while (nHeight--)
{
auto pEnd = pBits + nWidth;
const UINT32* pEnd = pBits + nWidth;
do
{
*pBits++ = nColor.ARGB;
@@ -40,7 +40,7 @@ void GDIAlphaBitmapSurface::FillRectangle(int nX, int nY, int nWidth, int nHeigh
}
}
static inline void BlendPixel(UINT32* nTarget, UINT32 nBlend)
static constexpr void BlendPixel(UINT32* nTarget, UINT32 nBlend) noexcept
{
const auto alpha = nBlend >> 24;
@@ -109,11 +109,11 @@ void GDIAlphaBitmapSurface::WriteText(int nX, int nY, int nFont, Color nColor, c
auto nLines = szText.cy;
while (nLines--)
{
auto pEnd = pBits + szText.cx;
const UINT32* pEnd = pBits + szText.cx;
do
{
UINT8 nAlpha = 0xFF - ((*pTextBits++) & 0xFF);
UINT32 pColor = (nColor.ARGB & 0x00FFFFFF) | ((nAlpha * nColor.Channel.A / 255) << 24);
const UINT8 nAlpha = 0xFF - ((*pTextBits++) & 0xFF);
const UINT32 pColor = (nColor.ARGB & 0x00FFFFFF) | ((nAlpha * nColor.Channel.A / 255) << 24);
BlendPixel(pBits, pColor);
++pBits;
} while (pBits < pEnd);
@@ -125,10 +125,10 @@ void GDIAlphaBitmapSurface::WriteText(int nX, int nY, int nFont, Color nColor, c
DeleteDC(hMemDC);
}
void GDIAlphaBitmapSurface::Blend(HDC hTargetDC, int nX, int nY) const
void GDIAlphaBitmapSurface::Blend(HDC hTargetDC, int nX, int nY) const noexcept
{
int nWidth = static_cast<int>(GetWidth());
int nHeight = static_cast<int>(GetHeight());
const int nWidth = static_cast<int>(GetWidth());
const int nHeight = static_cast<int>(GetHeight());
// copy a portion of the target surface into a buffer
HDC hMemDC = CreateCompatibleDC(hTargetDC);
@@ -163,11 +163,11 @@ void GDIAlphaBitmapSurface::Blend(HDC hTargetDC, int nX, int nY) const
DeleteDC(hMemDC);
}
void GDIAlphaBitmapSurface::SetOpacity(double fAlpha)
void GDIAlphaBitmapSurface::SetOpacity(double fAlpha) noexcept
{
assert(fAlpha >= 0.0 && fAlpha <= 1.0);
const auto nAlpha = static_cast<UINT8>(255 * fAlpha);
assert(nAlpha > 0.0); // setting opacity to 0 is irreversable - caller should just not draw it
assert(nAlpha > 0.0); // setting opacity to 0 is irreversible - caller should just not draw it
const UINT8* pEnd = reinterpret_cast<UINT8*>(m_pBits + GetWidth() * GetHeight());
UINT8* pBits = reinterpret_cast<UINT8*>(m_pBits) + 3;
+4 -4
View File
@@ -38,7 +38,7 @@ protected:
UINT32* m_pBits;
private:
HDC CreateBitmapHDC(const int nWidth, const int nHeight)
HDC CreateBitmapHDC(const int nWidth, const int nHeight) noexcept
{
BITMAPINFO bmi{};
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@@ -80,12 +80,12 @@ public:
GDIAlphaBitmapSurface(GDIAlphaBitmapSurface&&) noexcept = delete;
GDIAlphaBitmapSurface& operator=(GDIAlphaBitmapSurface&&) noexcept = delete;
void FillRectangle(int nX, int nY, int nWidth, int nHeight, Color nColor) override;
void FillRectangle(int nX, int nY, int nWidth, int nHeight, Color nColor) noexcept override;
void WriteText(int nX, int nY, int nFont, Color nColor, const std::wstring& sText) override;
void Blend(HDC hTargetDC, int nX, int nY) const;
void Blend(HDC hTargetDC, int nX, int nY) const noexcept;
void SetOpacity(double fAlpha) override;
void SetOpacity(double fAlpha) noexcept override;
};
class GDISurfaceFactory : public ISurfaceFactory
+1 -1
View File
@@ -15,7 +15,7 @@ GDISurface::GDISurface(HDC hDC, const RECT& rcDEST, ResourceRepository& pResourc
SelectObject(hDC, GetStockObject(DC_BRUSH));
}
void GDISurface::FillRectangle(int nX, int nY, int nWidth, int nHeight, Color nColor)
void GDISurface::FillRectangle(int nX, int nY, int nWidth, int nHeight, Color nColor) noexcept
{
assert(nColor.Channel.A == 0xFF);
SetDCBrushColor(m_hDC, RGB(nColor.Channel.R, nColor.Channel.G, nColor.Channel.B));
+4 -4
View File
@@ -24,10 +24,10 @@ public:
~GDISurface() noexcept = default;
size_t GetWidth() const override { return m_nWidth; }
size_t GetHeight() const override { return m_nHeight; }
size_t GetWidth() const noexcept override { return m_nWidth; }
size_t GetHeight() const noexcept override { return m_nHeight; }
void FillRectangle(int nX, int nY, int nWidth, int nHeight, Color nColor) override;
void FillRectangle(int nX, int nY, int nWidth, int nHeight, Color nColor) noexcept override;
int LoadFont(const std::string& sFont, int nFontSize, FontStyles nStyle) override;
ra::ui::Size MeasureText(int nFont, const std::wstring& sText) const override;
@@ -36,7 +36,7 @@ public:
void DrawImage(int nX, int nY, int nWidth, int nHeight, const ImageReference& pImage) override;
void DrawSurface(int nX, int nY, const ISurface& pSurface) override;
void SetOpacity(_UNUSED double) override { assert("This surface does not support opacity"); }
void SetOpacity(_UNUSED double) noexcept override { assert("This surface does not support opacity"); }
protected:
void SwitchFont(int nFont) const;
+4 -4
View File
@@ -343,7 +343,7 @@ HBITMAP ImageRepository::LoadLocalPNG(const std::wstring& sFilename, size_t nWid
return hBitmap;
}
ImageRepository::HBitmapMap* ImageRepository::GetBitmapMap(ImageType nType)
ImageRepository::HBitmapMap* ImageRepository::GetBitmapMap(ImageType nType) noexcept
{
switch (nType)
{
@@ -423,7 +423,7 @@ HBITMAP ImageRepository::GetHBitmap(const ImageReference& pImage)
return hBitmap;
}
void ImageRepository::AddReference(ImageReference& pImage) noexcept
void ImageRepository::AddReference(ImageReference& pImage)
{
if (pImage.Name().empty())
return;
@@ -462,13 +462,13 @@ void ImageRepository::ReleaseReference(ImageReference& pImage) noexcept
pImage.SetData(0ULL);
}
bool ImageRepository::HasReferencedImageChanged(ImageReference& pImage) const noexcept
bool ImageRepository::HasReferencedImageChanged(ImageReference& pImage) const
{
if (pImage.Type() == ra::ui::ImageType::None)
return false;
const auto hBitmapBefore = pImage.GetData();
GetHBitmap(pImage);
GetHBitmap(pImage); // TBD: Is the return value supposed to be discarded?
return (pImage.GetData() != hBitmapBefore);
}

Some files were not shown because too many files have changed in this diff Show More