Skip to content

bugfix for draw_h_line in graphsdl.c #101

@mikefairbank

Description

@mikefairbank

Bug: If you do MODE0:CIRCLE FILL 500,500,800 then it misses out the middle horizontal few rows of the circle.
This bug does not seem to affect the version of brandy on debian apt (version 1.23.0, Feb 2024), but does affect the latest development version of brandy, so not sure when this bug was introduced.

The bug is here, in this first if line:

static void draw_h_line(SDL_Surface *sr, int32 x1, int32 x2, int32 y, Uint32 col, Uint32 action) {
  if ((x1 < 0 || x1 >= ds.vscrwidth) && (x2 < 0 || x2 >= ds.vscrwidth )) return;  // BUG HERE.  This omits a line if x1<0 and x2>vscrwidth, which is not what we want.
  if (x1 > x2) {
    int32 tt = x1;
    x1 = x2;
    x2 = tt;
  }

I think it should be:

static void draw_h_line(SDL_Surface *sr, int32 x1, int32 x2, int32 y, Uint32 col, Uint32 action) {
  if (x1 > x2) {
    int32 tt = x1;
    x1 = x2;
    x2 = tt;
  }
  if (x1 >= ds.vscrwidth || x2 < 0) return; // FIXED LINE (and moved line)

This fixes the issue. I've already patched this in my pull request for the sector/segment implementation. So you don't need to do anything other than pull.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions