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

Glulx Entry Points command pasting is not invoked, preventing hyperlink extensions from working #65

Open
EvanBalster opened this issue Apr 12, 2021 · 8 comments

Comments

@EvanBalster
Copy link

EvanBalster commented Apr 12, 2021

I'm trying to use the Inline Hyperlinks extension with the Flexible Windows extension and I've hit an impasse. The latter needs a newer version of Glulx Entry Points than the one which is stocked with Inform; the former stops working when the latest Glulx Entry Points are installed.

My attempts at debugging suggest that Inline Hyperlinks' behavior doesn't change much. It invokes the following Inform 6 code when clicking links, but the glulx replacement command is never processed:

if (glk_gestalt(gestalt_Hyperlinks, 0)) glk_request_hyperlink_event(gg_mainwin);

This thread suggests the issue also affected an earlier version of Glulx Entry Points, although that version also appears to depend on Dannii Willis' additions.

https://intfiction.org/t/inline-hyperlinks-is-broken-update-not-flexible-windows/11047/7

@EvanBalster
Copy link
Author

Here is a version of the now-broken extension with a few debug printouts. These merely serve to demonstrate that the Inform 7 mechanisms of Inline Hyperlinks are working as expected.

Inline Hyperlinks.txt

@curiousdannii curiousdannii changed the title Inline Hyperlinks does not work with newer Glulx Entry Points Inline Hyperlinks by Daniel Stelzer does not work with newer Glulx Entry Points Apr 12, 2021
@EvanBalster
Copy link
Author

EvanBalster commented Apr 12, 2021

By injecting printouts into the "handle glk event rule" I have zeroed in on these lines in Glulx Entry Points as the point where processing of the hyperlink seems to stop:

	if the outcome of the rulebook is the replace player input outcome:
		decide on GEP internal input replacement;
	if the outcome of the rulebook is the require input to continue outcome:
		decide on GEP internal input continuation;

The original:

	if the outcome of the rulebook is the replace player input outcome:
		decide on input replacement;
	if the outcome of the rulebook is the require input to continue outcome:
		decide on input continuation;

EDIT: I seem to have confirmed that the outcome of the handle glk rulebook is not a success with either version.

@EvanBalster
Copy link
Author

Upon further inspection, it appears that the "the handle glk event rule" is never invoked by the latest version of the extension, because the HandleGlkEvent which previously called it was replaced by a new handler in Danni Willis' Glk Events.

By extension, the following lines are never run:

follow the input-cancelling rules;
follow the command-showing rules;
follow the command-pasting rules;

This apparently breaks Glulx Entry Points' ability to inject or replace player commands. I'm inclined to call this a bug in Glulx Entry Points.

@curiousdannii
Copy link
Member

It's very possible there are a ton of bugs - the state of affairs for hyperlinks in I7 is really poor. Sorry. I'm not sure if I'll have the time to look into this any time soon.

There are other hyperlink extensions. I'm not sure which is the most up to date.

@EvanBalster
Copy link
Author

It seems like repairing the "glulx replacement command" function in Glulx Entry Points might do a lot for the hyperlink situation. :)

I'm tinkering to see if I can work out how to restore functionality to the Handle Glk Event Rule. There are two problems with this:

  • Both the Handle Glk Event Rule and the Glk Events extensions invoke the glulx input handling rules. They should probably operate on different rulebooks to avoid , but using a new rulebook in GEP would break compatibility with existing extensions (ie, broken extensions would stay broken until updated).
  • I'm not sure how to replicate the return value from HandleGlkEvent with Glk Events. I think its only effect is to either end or continue the current turn.

As a compromise on the first issue, I've implemented a small addition to GEP that patches the two handlers together and restores the command-pasting part of the hyperlinks feature:

GEP internal recursion flag is a number that varies.  GEP internal recursion flag is initially 0.

A glulx input handling rule (this is the glulx input shim rule):
	If GEP internal recursion flag is 1:
		make no decision;
	say "(IH0)";
	Now GEP internal recursion flag is 1;
	Let handler result be the value returned by glk event handling;
	Now GEP internal recursion flag is 0;
	Rule fails.
	
The glulx input shim rule is listed first in the glulx input handling rules.

...But I'm still trying to figure out how I can respect the handler result and actually submit the pasted command.

@EvanBalster
Copy link
Author

EvanBalster commented Apr 12, 2021

Here's a rather crude modification that restores the broken functionality without introducing a new rulebook. With these changes Inline Hyperlinks works again, although there are probably other better ways to fix things.

Glulx Entry Points.txt

My changes are purely additions:

GEP internal recursion flag is a number that varies.  GEP internal recursion flag is initially 0.

Stashed glk result is a number that varies.  Stashed glk result is initially 0.

A glulx input handling rule (this is the glulx input shim rule):
	If GEP internal recursion flag is 1:
		make no decision;
	Now GEP internal recursion flag is 1;
	Now stashed glk result is the value returned by glk event handling;
	Now GEP internal recursion flag is 0;
	Rule succeeds.
	
The glulx input shim rule is listed first in the glulx input handling rules.

To decide what number is the value returned by glk event result recalling (this is the unstash glk event rule):
	decide on stashed glk result.
Include (- 

  [ HandleGlkEvent ev context abortres newcmd cmdlen i ;
      for (i=0:i<3:i++) evGlobal-->i = ev-->i;
      (+ library input context +) = context;
      return (+ value returned by glk event result recalling +) ;
  ];

-) before "Glulx.i6t".

Essentially what we're doing here is intercepting Glk Events' invocation of the input handling rules so we can dispatch Glulx Entry Points' own with additional logic... collecting the result... and later returning that result from HandleGlkEvent (which allows us to submit commands).

@EvanBalster EvanBalster changed the title Inline Hyperlinks by Daniel Stelzer does not work with newer Glulx Entry Points Glulx Entry Points command pasting is not invoked, preventing hyperlink extensions from working Apr 12, 2021
@uecasm
Copy link
Contributor

uecasm commented Apr 12, 2021

The command-replacement functionality in Glulx Entry Points is broken. Use this extension instead.

@EvanBalster
Copy link
Author

The command-replacement functionality in Glulx Entry Points is broken. Use this extension instead.

Thanks, I'll give that a try! That said, I think I've worked out how to repair Glulx Entry Points and I'll be making a PR shortly.

I notice far more extensions rely on Glulx Entry Points than rely directly on Glk Input Handling... But I think there's a (tidy, robust) way to fix GEP without breaking compatibility with anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants