SCUMM: Fix UB shifting negative integers in Actor

This commit is contained in:
Colin Snover 2017-11-29 19:36:28 -06:00
parent 1871c7dfea
commit 57084b4a1b

View File

@ -565,13 +565,13 @@ int Actor::actorWalkStep() {
_pos.y -= 1; _pos.y -= 1;
} }
} else { } else {
tmpX = (_pos.x << 16) + _walkdata.xfrac + (_walkdata.deltaXFactor >> 8) * _scalex; tmpX = (_pos.x * (1 << 16)) + _walkdata.xfrac + (_walkdata.deltaXFactor / 256) * _scalex;
_walkdata.xfrac = (uint16)tmpX; _walkdata.xfrac = (uint16)tmpX;
_pos.x = (tmpX >> 16); _pos.x = (tmpX / (1 << 16));
tmpY = (_pos.y << 16) + _walkdata.yfrac + (_walkdata.deltaYFactor >> 8) * _scaley; tmpY = (_pos.y * (1 << 16)) + _walkdata.yfrac + (_walkdata.deltaYFactor / 256) * _scaley;
_walkdata.yfrac = (uint16)tmpY; _walkdata.yfrac = (uint16)tmpY;
_pos.y = (tmpY >> 16); _pos.y = (tmpY / (1 << 16));
} }
if (ABS(_pos.x - _walkdata.cur.x) > distX) { if (ABS(_pos.x - _walkdata.cur.x) > distX) {