Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input Recording v2 #2301

Merged
merged 3 commits into from Oct 4, 2020
Merged

Input Recording v2 #2301

merged 3 commits into from Oct 4, 2020

Conversation

Ghabry
Copy link
Member

@Ghabry Ghabry commented Aug 24, 2020

A new input recording format that suites the regression test requirements. (Dependency: #2288)

The current format is just a bitfield of the pressed buttons everytime Input::Update is called. This is bad. Is enough for playback in Player but not for anything else.

The code still needs some polish but the new format looks like this. I already used it to successfully playback inputs in RPG_RT.

Format:

  • 1st line: Header
  • 2nd line: Version
  • ...nth line: Everything else

Structure: It is a simple flatfile with a linecode (1st char is the ID, 2nd char is whitespace).
The line must be empty or start with a known linecode.

  • H Header identifier <- On line 1
  • V Version identifier <- On line 2
  • N Game name
  • D Recording date
  • L LDBHash LMTHash <- CRC32 of LDB and LMT
  • C Command line
  • F FrameNum,[Pressed Keys,...]
  • # Comment
  • E RESERVED (Event execution trace)
  • M RESERVED (Move command trace)

N, D, L and C are not validated but useful for reproducible recordings.

H EasyRPG Player Record <- H - Header. Must be this string
V 2 <- V - Version information <- V - Must be 2
D 2020-08-23-23-27-37 <- D - Recording date
F 45,DECISION <- F - Frame information: First the number (from Game_System->frame), then the keys
F 0,DECISION <- The frame counter can go back to 0 when a "New Game" starts.
F 5,RIGHT
F 6,RIGHT
F 7,RIGHT
# This is a comment
F 8,RIGHT
F 9,RIGHT
F 10,RIGHT
F 11,RIGHT
F 12,RIGHT
F 13,RIGHT
F 14,RIGHT
F 31,RIGHT,UP <- Frames without input are omitted
F 32,RIGHT,UP
F 33,RIGHT,UP
F 34,RIGHT,UP
F 35,RIGHT,UP
F 36,RIGHT,UP
F 37,RIGHT,UP
F 38,RIGHT,UP
F 39,RIGHT,UP
F 40,RIGHT,UP
F 44,DECISION
F 45,DECISION
F 46,DECISION
F 47,DECISION
F 48,DECISION
F 49,DECISION
F 50,DECISION

@Ghabry Ghabry added the Has PR Dependencies This PR depends on another PR label Aug 24, 2020
@fdelapena fdelapena added Tests and removed Has PR Dependencies This PR depends on another PR labels Aug 24, 2020
@Ghabry
Copy link
Member Author

Ghabry commented Aug 25, 2020

TODO: Write the name of the game and the command line in the header section of the input file. Otherwise the replays could become impossible to replay and useless.

(The lines are not processed, just information for the user)

@fmatthew5876
Copy link
Contributor

TODO: Write the name of the game and the command line in the header section of the input file. Otherwise the replays could become impossible to replay and useless.

(The lines are not processed, just information for the user)

Put some hash in there too, not just the game name. So we identify exact version used.

@fmatthew5876 fmatthew5876 added the Awaiting Rebase Pull requests with conflicting files due to former merge label Aug 28, 2020
@Ghabry Ghabry added this to the 0.6.3 milestone Sep 1, 2020
Required for regression testing against RPG_RT.
@Ghabry Ghabry removed the Awaiting Rebase Pull requests with conflicting files due to former merge label Oct 1, 2020
@Ghabry
Copy link
Member Author

Ghabry commented Oct 1, 2020

Obtaining

N Game name
L LDBHash LMTHash <- CRC32 of LDB and LMT
C Command line

is a bit tricky. I left it out for now.
Except for C these information are not known when the input recorder is created.
For proper support this needs an Api change to our Input system

@fmatthew5876
Copy link
Contributor

So do you plan to leave this as is and improve it with hashing potentially later?

If so lets have a github issue tracking the future work.

@Ghabry
Copy link
Member Author

Ghabry commented Oct 2, 2020

Do have an idea how to provide them to input?
It should be generic enough so any arbitrary line can be written.
Maybe just a SendExtraData(enum type, StringView data) function. This wouldn't be too invasive (I don't want lots of player dependencies in input)

@Ghabry
Copy link
Member Author

Ghabry commented Oct 2, 2020

Added this metadata function, output is now:

H EasyRPG Player Recording
V 2 0.6.2
D 2020-10-02 14:59:50
C Window TestPlay --project-path /data/Spiele/RPG Maker/Unterwegs in Düsterburg --record-input b --seed 1 
L ldb 0x41de4fe6
L lmt 0x5b82d36e
N Unterwegs in Düsterburg
F 33,UP
F 34,UP
F 35,UP
F 36,UP
F 52,DECISION
L map41 0xafb048d2
F 0,DECISION
F 67,DOWN
F 68,DOWN
F 69,DOWN
F 70,DOWN
F 76,DECISION
[...] <- omission by me
F 282,DECISION
L map1 0x8b9bfda5
F 310,DOWN
F 311,DOWN
[...]
F 335,DOWN
F 336,DOWN

The CRC function is from zlib, so no unit tests needed.

>>> hex(binascii.crc32(open("RPG_RT.ldb", "rb").read()))
'0x41de4fe6'
>>> hex(binascii.crc32(open("RPG_RT.lmt", "rb").read()))
'0x5b82d36e'
>>> hex(binascii.crc32(open("Map0001.lmu", "rb").read()))
'0x8b9bfda5'
>>> hex(binascii.crc32(open("Map0041.lmu", "rb").read()))
'0xafb048d2'

…tadata to input recording files

Add CRC32 utility function for file hash calculation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants