bsnes icon indicating copy to clipboard operation
bsnes copied to clipboard

bsnes/sfc/controller/justifier/justifier.cpp: probably unintended `player2` instead of `player1` in `player1`-related statement group

Open Marat-Tanalin opened this issue 1 year ago • 2 comments

Potential typo in bsnes/sfc/controller/justifier/justifier.cpp. The code contains two groups of similar statements, first group sets properties of player1, second group does the same for player2:

  player1.x = 256 / 2;
  player1.y = 240 / 2;
  player1.trigger = false;
  player2.start = false;

  player2.x = 256 / 2;
  player2.y = 240 / 2;
  player2.trigger = false;
  player2.start = false;

But the last line of the first group contains player2 instead of player1. This might be a bug, not just because of obvious grouping, but also given that the second group contains the same statement player2.start = false; too, and such duplication is unlikely intentional.

Marat-Tanalin avatar May 09 '23 15:05 Marat-Tanalin

Looks like this change was introduced in v084r05 (6227974bf68907cbeef021ed03f07adb60463a32), and probably has gone unnoticed for this long because these defaults are immediately overwritten as soon as the game reads the emulated controller state (and bsnes polls its mapped controllers).

It should probably still be fixed, though.

Screwtapello avatar May 09 '23 16:05 Screwtapello

I agree with Screwtape; why not turn player1 and player2 into two elements of an array while we're at it? Copypasta is how these kinds of mistakes happen, in my experience.

jeffythedragonslayer avatar May 27 '23 16:05 jeffythedragonslayer