Skip to content

Conversation

SpaceWalkerRS
Copy link
Contributor

Pre-classic does not use Applets and initialization is very basic so none of the existing patch methods successfully apply.

Pre-classic versions do not define a constructor (all fields are initializedi in-line), and the initialization looks something like this:

public void init() {
    // game initialization happens here
}

@Override
public void run() {
    try {
        this.init();
    } catch (...) {
        // log "Failed to start RubyDung"
    }
    // run the game
}

public static void main(String[] args) {
    new Thread(new RubyDung()).start();
}

The patch I ended up with was to check for the "Failed to start RubyDung" log message in run(), and if that is found, to patch the first method invoked in run(), which is init().

@SpaceWalkerRS SpaceWalkerRS force-pushed the pre-classic-entrypoint-patch branch from ba1a42a to 2f7188b Compare September 21, 2025 12:48
if (!patched && gameMethod != gameConstructor) {
ListIterator<AbstractInsnNode> it = gameMethod.instructions.iterator();

it.add(new InsnNode(Opcodes.ACONST_NULL));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the todo, what actually is the run directory in pre-classic? If it's the working directory, then this can be new File(".") which would be better than null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm remembering right the method that is invoked here checks for null values and replaces it with new File("."). The handling for Classic uses null as well so I decided to do the same for consistency.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see

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

Successfully merging this pull request may close these issues.

3 participants