-
Notifications
You must be signed in to change notification settings - Fork 120
Make deterministic spawn bugfix toggleable #479
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
base: main
Are you sure you want to change the base?
Changes from all commits
74ead67
6762257
9d05ebc
6167675
2e6a5c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -137,35 +137,39 @@ void clear_D_802874D8_actors() { | |
| } | ||
|
|
||
| u16 random_u16_credits(void) { | ||
| u16 temp1, temp2; | ||
| if (CVarGetInteger("gBugfixRNGReset", true) == false) { | ||
| u16 temp1, temp2; | ||
|
|
||
| if (sRandomSeed16 == 22026) { | ||
| sRandomSeed16 = 0; | ||
| } | ||
| if (sRandomSeed16 == 22026) { | ||
| sRandomSeed16 = 0; | ||
| } | ||
|
|
||
| temp1 = (sRandomSeed16 & 0x00FF) << 8; | ||
| temp1 = temp1 ^ sRandomSeed16; | ||
| temp1 = (sRandomSeed16 & 0x00FF) << 8; | ||
| temp1 = temp1 ^ sRandomSeed16; | ||
|
|
||
| sRandomSeed16 = ((temp1 & 0x00FF) << 8) + ((temp1 & 0xFF00) >> 8); | ||
| sRandomSeed16 = ((temp1 & 0x00FF) << 8) + ((temp1 & 0xFF00) >> 8); | ||
|
|
||
| temp1 = ((temp1 & 0x00FF) << 1) ^ sRandomSeed16; | ||
| temp2 = (temp1 >> 1) ^ 0xFF80; | ||
| temp1 = ((temp1 & 0x00FF) << 1) ^ sRandomSeed16; | ||
| temp2 = (temp1 >> 1) ^ 0xFF80; | ||
|
|
||
| if ((temp1 & 1) == 0) { | ||
| if (temp2 == 43605) { | ||
| sRandomSeed16 = 0; | ||
| if ((temp1 & 1) == 0) { | ||
| if (temp2 == 43605) { | ||
| sRandomSeed16 = 0; | ||
| } else { | ||
| sRandomSeed16 = temp2 ^ 0x1FF4; | ||
| } | ||
| } else { | ||
| sRandomSeed16 = temp2 ^ 0x1FF4; | ||
| sRandomSeed16 = temp2 ^ 0x8180; | ||
| } | ||
| } else { | ||
| sRandomSeed16 = temp2 ^ 0x8180; | ||
|
|
||
| return sRandomSeed16; | ||
| } | ||
|
|
||
| return sRandomSeed16; | ||
| return random_u16(); | ||
| } | ||
|
|
||
| f32 random_float_between_0_and_1(void) { | ||
| return random_u16_credits() / 65536.0f; | ||
| return random_u16_credits() / (f32) UINT16_MAX; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not identical behaviour |
||
| } | ||
|
|
||
| f32 random_who_knows(f32 arg0) { | ||
|
|
@@ -309,6 +313,7 @@ void unused_80280FA8(UNUSED CeremonyActor* actor) { | |
| } | ||
|
|
||
| void balloons_and_fireworks_init(void) { | ||
| sRandomSeed16 = 0; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be placed in? void init_segment_ending_sequences(void) {
#ifdef TARGET_N64
bzero((void*) SEG_ENDING, SEG_ENDING_SIZE);
osWritebackDCacheAll();
dma_copy((u8*) SEG_ENDING, (u8*) SEG_ENDING_ROM_START, SEG_ENDING_ROM_SIZE);
osInvalICache((void*) SEG_ENDING, SEG_ENDING_SIZE);
osInvalDCache((void*) SEG_ENDING, SEG_ENDING_SIZE);
#endif
}
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see it's static. Yea this is fine.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But it's not around a CVar? |
||
| D_802874D8.actorTimer = 0; | ||
| sPodiumActorList = (CeremonyActor*) get_next_available_memory_addr(sizeof(CeremonyActor) * 200); | ||
| bzero(sPodiumActorList, (sizeof(CeremonyActor) * 200)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -410,6 +410,12 @@ void PortMenu::AddEnhancements() { | |
| }) | ||
| .Options(UIWidgets::CheckboxOptions({ { .tooltip = "Edit the universe!" } })); | ||
| #endif | ||
|
|
||
| path = { "Enhancements", "Bugfixes", SECTION_COLUMN_1 }; | ||
| AddSidebarEntry("Enhancements", "Bugfixes", 3); | ||
| AddWidget(path, "Don't reset random seed", WIDGET_CVAR_CHECKBOX) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| .CVar("gBugfixRNGReset") | ||
| .Options(CheckboxOptions().Tooltip("The section handling of MK8 zeroes the random seed before races. Enable this to never zero the seed.").DefaultValue(true)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Racer spawns are not randomized at the start of Grand Prix. Enable this to fix random seeding.
(I think I like this one the best so far of everything I've come up with) |
||
| } | ||
|
|
||
| #ifdef __SWITCH__ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand this change.
The idea is to remove the duplicate function and use the original one. But now the random seed won't have been reset because we're now using gRandomSeed instead of sRandomSeed.
I would recommend one of two options
random_u16()and just use random_u16_credits()