textadventures / quest

Create text adventure games
http://textadventures.co.uk/quest
MIT License
304 stars 69 forks source link

Transcript crashes games online #1054

Open KVonGit opened 6 years ago

KVonGit commented 6 years ago

Enabling a transcript online crashes (freezes) the game.

I seem to remember writing code to handle online transcripts in a dialog popup, but it was long ago and I'm not positive my recollection is correct.

KVonGit commented 6 years ago

This is the function that is missing when playing online:

// SaveTranscript added by KV to write/append to GAMENAME-transcript.html in Documents\Quest Transcripts
function SaveTranscript(data) {
    data = data + "<style>*{color:black !important;background:white !important;text-align:left !important}</style>";
    if (!webPlayer && transcriptString != '') { UIEvent("SaveTranscript", data); }
    transcriptString += data;
}

I added that to desktopplayer.js, but I'm pretty sure that I should have added it to WebPlayer\player.js as well.

KVonGit commented 2 months ago

Transcript Redux

I have been working diligently for about two weeks to come up with the best overall solution for the transcript issues I introduced in Quest 5.8.0.


Known Issues

Online

When enabling the transcript online, the game completely crashes. This is because I added a SaveTranscript() function to Player\desktop.js, but I failed to add its online counterpart to WebPlayer\player.js.

Desktop

After enabling the transcript in the desktop player, the turn scripts all cease firing until the transcript is disabled.

Also, when recording a walkthrough while the transcript is enabled, each step recorded is the HTML output from each turn.

Both Desktop and Online

There is also "scrollback" functionality that was introduced in Quest 5.8.0.

The clearScreen() function was modified to hide all the text rather than deleting it when saveClearedText is true (which is the default). If saveClearedText is false, clearScreen() uses its old method (deleting all the cleared text).

So, by default, all that text is being saved and slowing the game down exponentially each turn.


All the Details Concerning This Update

saveClearedText in PlayerController\playercore.js is now set to false by default.


CoreTypes

game.notranscript


game.ingametranscript


game.writetranscripttofile


game.transcriptenabled


Core HandleCommand modified to add player's command to transcript if game.echocommand is false


CoreFunctions ShowMenuResponse modified to add player's command to transcript if game.echocommand is false


CoreCommands view_transcript_cmd


CoreCommands transcript_on_cmd


CoreCommands transcript_off_cmd


CoreFunctions DisableTranscript()


CoreFunctions KillTranscript()


CoreFunctions ClearHtmlTranscript


PlayerController\playercore.js addText()


PlayerController\playercore.js clearScreen()


PlayerController\playercore.js showScrollback()


Player\desktop.js SaveTranscript()


WebPlayer\player.js SaveTranscript()


PlayerController\playercore.js default booleans:

    var writingTranscriptToFile = false;
    var inGameTranscript = false;
    var transcriptEnabled = false;
    var noTranscript = false;

CoreEditorGame has an added checkbox for the transcript, and a tab if that box is checked


Player\PlayerHTML.vb has modified code to fix the issue with using the transcript name entered by the player when enabling the transcript


DEPRECATED

CoreCommands - UpdateTranscriptString() [gone]


game.transcriptstring string [gone]


game.savetranscript boolean [sort of replaced with game.ingametranscript]


JS - savingTranscript boolean [replaced with inGameTranscript and saveClearedText]


JS - transcriptString string [gone]


JS - replaceTranscriptString() [gone]


JS - showTranscript() [replaced by showScrollback()]


JS - printTranscriptDiv() [replaced by printScrollback()]


Comments

I tested this extensively, to the best of my ability. I found three or four forum threads concerning all the different issues during debugging and testing, and I made sure all those issues were addressed.

I ran the web player from Visual Studio to test everything out as well. Here is a PDF of the transcript: NewTranscriptTester1-transcript.pdf

NOTE: I could not actually test saving the game, but it seemed to make it all the way to end until it found that I was not logged into the site.

I also ran the web editor from VS, just to make sure the new Transcript editor controls looked okay.

I'll submit a pull request in the morning. (I would wait to post this, too, but I don't want to lose all this. It took much longer to write than I expected, haha.)