Skip to content

fix(brucegotchi): clamp setMood() bounds and expand mood variety#2556

Open
r13xr13 wants to merge 1 commit into
BruceDevices:mainfrom
r13xr13:fix/brucegotchi-mood-bounds
Open

fix(brucegotchi): clamp setMood() bounds and expand mood variety#2556
r13xr13 wants to merge 1 commit into
BruceDevices:mainfrom
r13xr13:fix/brucegotchi-mood-bounds

Conversation

@r13xr13

@r13xr13 r13xr13 commented Jun 18, 2026

Copy link
Copy Markdown

Summary

Two fixes for the Brucegotchi mood system:

setMood() out-of-bounds crash -- setMood() could index past number_of_moods causing an array overflow crash when mood indices exceed the defined array size. Adds a bounds clamp to cap at number_of_moods - 1.

Mood variety expansion -- The Brucegotchi only cycled through 2 moods (one happy, one active) making the companion feel repetitive. Expanded to cycle through 5 active moods, 4 happy moods, and 5 lonely moods.

Changes

  • mood.cpp: Add bounds clamp in setMood() -- if mood index >= number_of_moods, clamp to number_of_moods - 1
  • pwnagotchi.cpp: Replace 2-element mood arrays with full 5/4/5 arrays for active/happy/lonely states
  • mood.h, pwnagotchi.h, ui.h: Update array declarations to match new sizes

Testing

  • Verified mood cycling no longer produces out-of-range indices
  • All mood states render correctly on display

setMood() could index past number_of_moods causing an array overflow crash. Adds bounds clamp.

Expands mood variety from 2 repeating moods to cycling through 5 active / 4 happy / 5 lonely moods for more organic pwnagotchi personality.
@r13xr13 r13xr13 changed the title test fix(brucegotchi): clamp setMood() bounds and expand mood variety Jun 18, 2026

@Ninja-jr Ninja-jr 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.

Was this tested on a real live device? If so and it works, it could be ok then

@r13xr13

r13xr13 commented Jun 26, 2026 via email

Copy link
Copy Markdown
Author

@Ninja-jr

Copy link
Copy Markdown
Contributor

Ok then. Good. But it has merging conflicts that need sorted.

@r13xr13

r13xr13 commented Jun 26, 2026

Copy link
Copy Markdown
Author

Ok then. Good. But it has merging conflicts that need sorted.

Yes I'm sure like I said check the repo I have to see the diffs Here

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.

2 participants