Permalink
Browse files

Cheats: Fix pointer command count offset.

2 means there's 1 line of data.  This was the actual problem.
Thanks LunaMoo.
  • Loading branch information...
unknownbrackets committed Nov 9, 2017
1 parent baf351c commit 1d348b8aa72cfb4f9a0e210b7019049dd1e2d09e
Showing with 4 additions and 4 deletions.
  1. +4 −4 Core/CwCheat.cpp
View
@@ -495,11 +495,11 @@ CheatOperation CWCheatEngine::InterpretNextCwCheat(const CheatCode &cheat, size_
addr = GetAddress(line1.part1 & 0x0FFFFFFF);
if (i < cheat.lines.size()) {
const CheatLine &line2 = cheat.lines[i++];
int count = line2.part1 & 0xFFFF;
int count = (line2.part1 & 0xFFFF) - 1;
// Clamp lines to process - previously allowed invalid counts.
// Validate lines to process - make sure we stay inside cheat.lines.
if (i + count > cheat.lines.size())
count = cheat.lines.size() - i;
return { CheatOp::Invalid };
CheatOperation op = { CheatOp::CwCheatPointerCommands, addr, 0, arg };
op.pointerCommands.offset = (int)line2.part2;
@@ -912,7 +912,7 @@ void CWCheatEngine::ExecuteOp(const CheatOperation &op, const CheatCode &cheat,
u32 base = Memory::Read_U32(op.addr + op.pointerCommands.baseOffset);
u32 val = op.val;
int type = op.pointerCommands.type;
for (int a = 1; a < op.pointerCommands.count; ++a) {
for (int a = 0; a < op.pointerCommands.count; ++a) {
const CheatLine &line = cheat.lines[i++];
switch (line.part1 >> 28) {
case 0x1: // type copy byte

0 comments on commit 1d348b8

Please sign in to comment.