Skip to content

Rewrite parts of rando, code cleanup - #423

Merged
Malkierian merged 4 commits into
HarbourMasters:develop-splitrockfrom
JeodC:rando-splitrock
Aug 8, 2026
Merged

Rewrite parts of rando, code cleanup#423
Malkierian merged 4 commits into
HarbourMasters:develop-splitrockfrom
JeodC:rando-splitrock

Conversation

@JeodC

@JeodC JeodC commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

randoCollectionId holds the item placed at a location, but the score listeners matched on it to answer world-state questions. jiggyscore_isCollected(N) returned the state of whatever check received jiggy N. Which checks broke was seed luck; on a test save, 14 of 31 world-state jiggy ids and 9 of 24 honeycombs were already wrong.

  • OnIsJiggyScoreCollected / OnIsHoneycombScoreCollected now resolve via GetCheckByJiggyId / GetCheckByHoneycombId. Supersedes the hand-written id special-cases (GV water pyramid stays, draining needs the jiggy and the token).
  • Split inventory from world state: the per-level tallies, chjiggy/chHoneycomb despawn tests and Anchor dedup read new raw accessors; jiggy/honeycomb counts and item sync still work.
  • BGS jiggy switches: actorArray_findActorFromActorId grabbed an unrelated check, played the destroy camera on it and left it collisionOff forever. Now uses FindActorByRandoCheckId and bails if already obtained.
  • Removed Boggy.cpp, the original code path drives Boggy.
  • Removed Gobi.cpp, the original code path drives Gobi.
  • FP xmas tree switch works again.
  • New files: no 100-note jingle / Bottles dialog / free extra life, and Mumbo isn't pre-paid for the bee.
  • Skip Spiral Mountain Tutorial disabled under rando (DISABLE_FOR_RANDO); its rando-side grant of 12 SM checks removed. Rationale: under Rando, Spiral Mountain is part of the challenge. Also prevents potential future bugs. Stay away from Tutorial Bottles and Tutorial Bottles can't hurt you.
  • Fixed an OOB write past RANDO_SAVE_FLAGS and inverted !IS_RANDO && !OPTION guards.
  • New: rando saves show Cheato on the file select.

Tested on a 900+/1200 seed: 15 gates where old and new disagree (5 of the 12 reported), BGS switch, FP Boggy chain, xmas tree.

Merging: #404 is superseded. Conflicts with aMannus/custom-collectible in WorldState.cpp (take mine + obtained->eligible) and Boggy.cpp/Gobi.cpp (take the delete).

@JeodC
JeodC force-pushed the rando-splitrock branch from a72f6ab to 6927700 Compare August 6, 2026 23:44

@aMannus aMannus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks great overall! Couple of notes and one question from me

Comment thread include/functions.h
Comment on lines 311 to 317
int jiggyscore_isSpawned(enum jiggy_e jiggy_id);
u32 port_jiggyscore_isCollectedRaw(enum jiggy_e jiggy_id);

// --- core2/honeycombscore.c ---
bool honeycombscore_get(enum honeycomb_e indx);
bool port_honeycombscore_getRaw(enum honeycomb_e indx);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should probably not let this block the PR in the interest of getting this fixed asap, but these will have to be replaced with proper hooks gated behind IS_RANDO down the line.

Comment thread src/port/Rando/Logic/GlitchlessLogic.cpp Outdated
Comment on lines +20 to +23
void Rando::MiscBehavior::InitFileSelectBehavior() {
REGISTER_LISTENER(OnFileSelectPortrait, EVENT_PRIORITY_NORMAL, [](IEvent* event) {
OnFileSelectPortrait* ev = (OnFileSelectPortrait*)event;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know this is following rando's structure that already exists, but this needs to be converted by registering with ShipInit down the line. Just like the port_ functions, this probably shouldn't block the PR, but noting it here so we have reference later.

Comment thread src/port/Rando/ObjectBehavior/Switch.cpp Outdated
Rando::Logic::GenerateShufflePool(saveData);
Rando::Logic::GrantStartingLoadout();
Rando::Logic::GrantFileProgressFlags();
Rando::Logic::GrantSpiralMountainChecks();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where are you applying the Spiral Mountain checks with this function removed? I don't see its new workflow to give those checks if SkipSpiralMountain is enabled.

@JeodC JeodC Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

SkipSpiralMountain is disabled for rando modes.

  • Skip Spiral Mountain Tutorial disabled under rando (DISABLE_FOR_RANDO); its rando-side grant of 12 SM checks removed. Rationale: under Rando, Spiral Mountain is part of the challenge. Also prevents potential future bugs. Stay away from Tutorial Bottles and Tutorial Bottles can't hurt you.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Personally don't think it should be disabled since we already know it can work, just needed an iteration. We also shouldn't assume on behalf of the player?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Re-enable it with v2? When I tested this branch with it still turned on it would grant me all of the vanilla tutorial abilities instead of the checks, and I just didn't feel like chasing it down right now given how much tutorial bottles has bit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non blocking for the PR but this being disabled for Rando will be a blocker for Rando V2 as a whole.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When the milestone for v2 is live I'll create an issue to attach to it as a follow-up, then. The whole idea of this was to create less problems for v2 after all.

Comment thread src/core2/ch/jiggy.c Outdated

if (jiggyscore_isCollected(local->id)) {
// if (jiggyscore_isCollected(local->id)) {
if (port_jiggyscore_isCollectedRaw(local->id)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't know how I feel about Vanilla code being replaced with a function whose code lives inside a Rando file.

If we need to replace this I think the function should live somewhere in our global functions file or maybe ShipUtils?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved to ShipUtils.cpp as suggested, and both of these call sites no longer use them at all.

  • ch/jiggy.c and ch/honeycomb.c now go through VB_COLLECTABLE_ALREADY_HELD. The default is the vanilla expression, so a vanilla-spawned collectable answers exactly as before; rando overrides only when marker->randoCheckId is set and answers from RANDO_SAVE_CHECKS, so it never touches the bitfield.
  • jiggyscore_leveltotal is back to pure decomp. VB_JIGGYSCORE_LEVEL_TOTAL already existed for romhacks, rando just registers it now. honeycombscore_get_level_total got the matching VB_HONEYCOMBSCORE_LEVEL_TOTAL.
  • Declarations moved out of functions.h into ShipUtils.h, so decomp doesn't see them either.

Decomp is now down to zero port_* score calls. The two accessors are port-only, with two consumers: Anchor's three dedup guards, and rando's two tally handlers. I would like to put them in Anchor, but then Rando would be including an Anchor header for them.

I did look at making them Anchor-only by having the tally handlers count from RANDO_SAVE_CHECKS instead, but that trades the authoritative record for a parallel one: the bitfield is what jiggyscore_setCollected writes on every pickup, whereas in Anchor a remote collect arrives as two packets (COLLECT_ITEM writes the bitfield, SET_CHECK_STATUS writes the check), so any drift would show up as a wrong jiggy count.

Comment thread src/core2/ch/honeycomb.c Outdated
local->uid = (!this->unk44_2)? D_8037DDC0 : func_802C9C40(this);
if( honeycombscore_get(local->uid)
// if( honeycombscore_get(local->uid)
if( port_honeycombscore_getRaw(local->uid)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same as my comment on port_jiggyscore_isCollectedRaw

@Malkierian
Malkierian merged commit 456d44f into HarbourMasters:develop-splitrock Aug 8, 2026
6 checks passed
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.

4 participants