summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorMichael Maltese <michaeljosephmaltese@gmail.com>2017-02-08 21:32:43 -0800
committerMichael Maltese <michaeljosephmaltese@gmail.com>2017-02-09 15:07:47 -0800
commit31e3424367c6bfa161ec2f338b701b65a256d9b4 (patch)
tree02656faba2a7243bb75a7892b84597de1da5dbb7 /Source/Core
parent657639899f0636474e4a9f602603f4d1a61da657 (diff)
Movie: replace magic number 8 with sizeof(ControllerState)
(Bonus points for rhyming commit message)
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/Movie.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp
index d47d8b1ac9..aa823dbd55 100644
--- a/Source/Core/Core/Movie.cpp
+++ b/Source/Core/Core/Movie.cpp
@@ -854,9 +854,9 @@ void RecordInput(GCPadStatus* PadStatus, int controllerID)
CheckPadStatus(PadStatus, controllerID);
- EnsureTmpInputSize((size_t)(s_currentByte + 8));
- memcpy(&(tmpInput[s_currentByte]), &s_padState, 8);
- s_currentByte += 8;
+ EnsureTmpInputSize((size_t)(s_currentByte + sizeof(ControllerState)));
+ memcpy(&tmpInput[s_currentByte], &s_padState, sizeof(ControllerState));
+ s_currentByte += sizeof(ControllerState);
s_totalBytes = s_currentByte;
}
@@ -1091,11 +1091,11 @@ void LoadInput(const std::string& filename)
}
else
{
- const ptrdiff_t frame = mismatch_index / 8;
+ const ptrdiff_t frame = mismatch_index / sizeof(ControllerState);
ControllerState curPadState;
- memcpy(&curPadState, &tmpInput[frame * 8], 8);
+ memcpy(&curPadState, &tmpInput[frame * sizeof(ControllerState)], sizeof(ControllerState));
ControllerState movPadState;
- memcpy(&movPadState, &movInput[frame * 8], 8);
+ memcpy(&movPadState, &movInput[frame * sizeof(ControllerState)], sizeof(ControllerState));
PanicAlertT(
"Warning: You loaded a save whose movie mismatches on frame %td. You should load "
"another save before continuing, or load this state with read-only mode off. "
@@ -1175,10 +1175,10 @@ void PlayController(GCPadStatus* PadStatus, int controllerID)
if (!IsPlayingInput() || !IsUsingPad(controllerID) || tmpInput == nullptr)
return;
- if (s_currentByte + 8 > s_totalBytes)
+ if (s_currentByte + sizeof(ControllerState) > s_totalBytes)
{
- PanicAlertT("Premature movie end in PlayController. %u + 8 > %u", (u32)s_currentByte,
- (u32)s_totalBytes);
+ PanicAlertT("Premature movie end in PlayController. %u + %zu > %u", (u32)s_currentByte,
+ sizeof(ControllerState), (u32)s_totalBytes);
EndPlayInput(!s_bReadOnly);
return;
}
@@ -1189,8 +1189,8 @@ void PlayController(GCPadStatus* PadStatus, int controllerID)
memset(PadStatus, 0, sizeof(GCPadStatus));
PadStatus->err = e;
- memcpy(&s_padState, &(tmpInput[s_currentByte]), 8);
- s_currentByte += 8;
+ memcpy(&s_padState, &tmpInput[s_currentByte], sizeof(ControllerState));
+ s_currentByte += sizeof(ControllerState);
PadStatus->triggerLeft = s_padState.TriggerL;
PadStatus->triggerRight = s_padState.TriggerR;