8000 Fix a bug in `palette_update` by glebm · Pull Request #8031 · diasurgical/DevilutionX · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix a bug in palette_update #8031

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

Merged
merged 1 commit into from
Jun 7, 2025
Merged

Fix a bug in palette_update #8031

merged 1 commit into from
Jun 7, 2025

Conversation

glebm
Copy link
Collaborator
@glebm glebm commented Jun 7, 2025

PR #8027 exposed a bug in palette_update.

The first argument in SDL palette functions always refers to the first target index (the first source index is always 0).

Fixes poison water following #8027.

PR diasurgical#8027 exposed a bug in `palette_update`.

The `first` argument in SDL palette functions always refers to the first
target index (the first source index is always 0).
@glebm glebm enabled auto-merge (rebase) June 7, 2025 13:48
Copy link
Member
@StephenCWills StephenCWills left a comment

Choose a reason for hiding this comment

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

My kneejerk reaction was that this feels wrong, because we pass first in as the very next argument. If anyone else feels skeptical, rest assured that I verified it independently by checking SDL documentation and SDL1 source code. That argument only provides the offset into the SDL_Palette data (and also the surface palette in the case of SDL1). It does not assume the offset should also apply to the color buffer that we pass in.

@glebm glebm merged commit 0b6e99f into diasurgical:master Jun 7, 2025
24 checks passed
@glebm glebm deleted the pal-upd branch June 7, 2025 22:55
@glebm
Copy link
Collaborator Author
glebm commented Jun 8, 2025

Yes, it's a rather weird API because the input and output arguments are intermixed, the order is:

  1. Output palette.
  2. Input colors.
  3. Output start index.
  4. Size.

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
0