Skip to content
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

ULTIMA: ULTIMA6: Fix roof drawing #5441

Merged
merged 2 commits into from Nov 19, 2023

Conversation

PushmePullyu
Copy link
Contributor

  • Fix assert on loading roof bitmap
  • Fix garbled roof drawing

Both regressions were introduced in commit c4970c9
"Fix crash in GUI on surface blit"

Fixes #14687

Note: The commit message prefix for Ultima 6 is pretty inconsistent in the log, let me know if I should change it.

Do not ignore palette when loading bitmaps via SDL_LoadBMP.

Prevents the following assert on game start when roof drawing
is enabled:

"graphics/managed_surface.cpp:298:
void Graphics::ManagedSurface::blitFromInner(const Graphics::Surface&,
 const Common::Rect&, const Common::Rect&, const byte*):
Assertion `!destFormat.isCLUT8() && srcPalette' failed."

The bug was introduced in c4970c9
"Fix crash in GUI on surface blit"

Fixes #14687
SDL_LoadBMP() was changed to convert to screen pixel format in
commit c4970c9
"Fix crash in GUI on surface blit".

The change causes roofs to be drawn garbled when game style is set to
"new style", as the blitting code expects an unconverted bitmap.

Adjust roof drawing to use ManagedSurface::blitFrom instead.
Copy link
Contributor

coderabbitai bot commented Nov 16, 2023

Walkthrough

Walkthrough

The changes involve updates to the Ultima game engine, specifically the Nuvie GUI widgets and SDL compatibility layer. The MapWindow class has been enhanced with a new sub-surface for drawing operations, optimizing the rendering of roofs by using blitting instead of direct pixel manipulation. Additionally, the loading of roof tiles has been simplified by removing a conditional check for the original game style. The SDL compatibility layer now supports palette handling during bitmap loading, improving color management during blitting.

Changes

File Summary
.../nuvie/gui/widgets/map_window.cpp Introduced _mapWinSubSurf for optimized drawing, updated drawRoofs to use blitting, and simplified loadRoofTiles.
.../nuvie/gui/widgets/map_window.h Added _mapWinSubSurf of type Graphics::ManagedSurface to MapWindow.
.../nuvie/misc/sdl_compat.cpp Enhanced SDL_LoadBMP to support palette during blitting with blitFrom.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

@mduggan mduggan merged commit eb91759 into scummvm:master Nov 19, 2023
8 checks passed
@mduggan
Copy link
Contributor

mduggan commented Nov 19, 2023

Simple enough change, and I confirmed it fixes the problem locally. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants