[Bug][Player] Double assignments are still possible via replay file editing

Started by IchoTolot, October 25, 2018, 02:32:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

IchoTolot

I solved a certain old format contest level exploiting this behavior. ;) This is still possible in new format NL though as the replay format didn't change.

Reproducing:

- Load a level.
- Assign a skill to a lemming.
- Assign a 2nd skill on the very next frame (for simplicity purposes) to another Lemming.
- Save the replay.
- Close NL and open the replay file with a texteditor.
- Look at the 2 skills assigned and change the frame of the 2nd skill to the frame of the first, while updating the 2nd Lemming's position to the position the Lemming had on the frame before:

Example:

Original file:

$ASSIGNMENT
  FRAME 85
  LEM_INDEX 1
  LEM_X 111
  LEM_Y 135
  LEM_DIR left
  ACTION builder
$END

$ASSIGNMENT
  FRAME 86
  LEM_INDEX 0
  LEM_X 209
  LEM_Y 151
  LEM_DIR right
  ACTION basher
$END

After editing:

$ASSIGNMENT
  FRAME 85
  LEM_INDEX 1
  LEM_X 111
  LEM_Y 135
  LEM_DIR left
  ACTION builder
$END

$ASSIGNMENT
  FRAME 85
  LEM_INDEX 0
  LEM_X 208
  LEM_Y 151
  LEM_DIR right
  ACTION basher
$END

(I've attached an example file where the first 2 assignments are a double assign)

NL will accept and load the edited file and assign both skills in the same frame to their respective Lemmings. ;)

Fix proposal:

If we have multiple assignments in the same frame in a replay file: Only execute the first assignment, while all other assignments in the same frame will be ignored.

This fix will therefore trigger no NL error and it won't be noticable. This is only discovered anyways if a user deliberatly edits a replay file to do this, as double assignments are otherwise forbidden in the player.

Nepster

Haven't yet tried to reproduce it, but here is already one change to the fix proposal:
While only the first assignment should be applied, the others should be queued instead of being ignored. This is more keeping in line with our desire to try to make the best out of a malformed replay file.

I thought we were already doing that, but perhaps some of the bug-fixes in the last two or three versions have messed with this... or I am just remembering dreams :P

IchoTolot

Quote
While only the first assignment should be applied, the others should be queued instead of being ignored.

Totally fine with that. :)

IchoTolot

Just came to my mind:

The queued up assignments then need to be checked again if they overlap with future assignments. In that case they must be delayed even further.

nin10doadict

I do agree with fixing this. It's not something that's likely to cause issues if not fixed, but imagine if someone were to make a troll level that required manually editing replays to exploit this unintended behavior...

IchoTolot

Quote from: nin10doadict on November 10, 2018, 11:07:42 PM
I do agree with fixing this. It's not something that's likely to cause issues if not fixed, but imagine if someone were to make a troll level that required manually editing replays to exploit this unintended behavior...

Well, guess how I found this out. ;)

There is already such a level!


namida

Alright, that's one case where I wouldn't at all have a problem with a player update breaking the level - after all, it clearly abuses a completely and obviously unintended mechanic. Boo to whoever thought that was a good idea. Boo.
My projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)

IchoTolot

Quote from: Dullstar on November 11, 2018, 05:06:34 AM
Now I'm curious as to how that would even work.

Basically 2 lemmings are at a position where they MUST be assigned a skill in exactly the same frame. And it has to be in these exact positions for both lems.

Otherwise you will have to assign an extra walker which will make all other attempts come short by a skill.

namida

My projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)

namida

Fixed in commit 4d68498.

Specifically - if a replay skill assignment, for any reason, cannot be applied, it gets queued instead. Double-assignments in one frame is just one possible reason that can trigger this.
My projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)