erkyrath / lectrote

The IF interpreter in an Electron shell
Other
248 stars 28 forks source link

Replay script input must have Unix line ends #107

Open turthalion opened 6 years ago

turthalion commented 6 years ago

Replay files need to be Unix line-endings in order to work, even on the Windows version.

If DOS line endings are used, there's no real indication, just the commands don't work, so you get things like:

Room
This is the room.

There is a satchel here.

> get satchel
You can't see any such thing.
erkyrath commented 6 years ago

This is down to the game code or the interpreter code, depending on what IF engine you're talking about.

Lectrote (and quixe/glkote) have a file-reading API. I can't remember offhand whether it accounts for Windows line endings when reading a file in text mode. It's the game or library's job to use the API, in any case.

curiousdannii commented 6 years ago

ZVM prints a single "\n".

A little more clarity on how you saw this error would help. Which file format? Are you trying to load a command list created by Lectrote or another interpreter?

I can check on my Windows box when I get home later.

turthalion commented 6 years ago

Sorry for the lack of clarity, guys. That will teach me to submit reports when I'm tired.

I wondered if we might be at the mercy of a file API that was being used...

I was running a glulx game under Windows and using two different replay scripts I'd recorded, one from WinGit and the other from Gargoyle / Git. Both produced replay scripts with DOS line ends.

I use Vim to open and tweak these files and Vim respects original line endings and does not change them, so I know no shenanigans went on there.

Lectrote / quixe doesn't play back correctly with those files.

Recordings I produce with Lectrote are Unix line-ends and work for playback.

It's not a major issue, and obviously not an issue at all if one sticks within the Lectrote family... but there may be times when the less technically savvy find a webpage with a game walkthrough, select all the text, paste it into Notepad and then get confused when they try to input it into Lectrote.

If it ups the ante at all, WinGit and Gargoyle properly replay text files with either Unix or DOS line ends. : )

curiousdannii commented 6 years ago

So I6lib correctly opens a textmode fileref for the command stream. It writes a single \n after each command. The VM can't know what OS is in use and nor should it need to. Section 6.0 of the spec says the Glk library should take care of this. Neither glkapi.js nor electrofs.js do.

When reading it uses glk_get_line_stream which should handle native line breaks. Again glkapi.js/electrofs.js do not. But the conversions should be made transparently in all the reading and writing functions, not just glk_get_line_stream.

Section 6.0 of the spec does not say that terps must handle non-native line breaks when reading in textmode, but that would be an appropriate and safe interpretation to make.

erkyrath commented 6 years ago

I forgot to follow up on this... @curiousdannii is correct that this is a electrofs issue. I don't see a node core call to convert line breaks, which is not surprising. Electrofs basically reimplements stdio (in a crude way) and so it's got the responsibility of doing that.