Skip to content

Commit

Permalink
C4GameMessage::Draw: Don't use 0 as sentinel for "no alignment specif…
Browse files Browse the repository at this point in the history
…ied"

since 0 is the value of `ALeft`.

This broke `MSG_ALeft` as it mapped to `ALeft` and was treated as
"no alignment".
  • Loading branch information
Fulgen301 committed Dec 29, 2023
1 parent fda35f1 commit a08f927
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/C4GameMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ int32_t PortraitIndent = 10;

void C4GameMessage::Draw(C4FacetEx &cgo, int32_t iPlayer)
{
int32_t alignment = dwFlags & C4GM_ALeft ? ALeft : dwFlags & C4GM_ACenter ? ACenter : dwFlags & C4GM_ARight ? ARight : 0;
int32_t alignment = dwFlags & C4GM_ALeft ? ALeft : dwFlags & C4GM_ACenter ? ACenter : dwFlags & C4GM_ARight ? ARight : -1;

// Globals or player
if (Type == C4GM_Global || ((Type == C4GM_GlobalPlayer) && (iPlayer == Player)))
Expand Down Expand Up @@ -164,15 +164,15 @@ void C4GameMessage::Draw(C4FacetEx &cgo, int32_t iPlayer)
C4Facet facet(cgo.Surface, iDrawX, iDrawY, PortraitWidth, PortraitWidth);
fctPortrait.Draw(facet);
// draw message
Application.DDraw->TextOut(sText.getData(), Game.GraphicsResource.FontRegular, 1.0, cgo.Surface, iDrawX + PortraitWidth + PortraitIndent, iDrawY, ColorDw, alignment ? alignment : ALeft);
Application.DDraw->TextOut(sText.getData(), Game.GraphicsResource.FontRegular, 1.0, cgo.Surface, iDrawX + PortraitWidth + PortraitIndent, iDrawY, ColorDw, alignment != -1 ? alignment : ALeft);
}
else
{
// message without portrait
iDrawX += cgo.Wdt / 2;
iDrawY += 2 * cgo.Hgt / 3 + 50;
if (!(dwFlags & C4GM_Bottom)) iDrawY += DrawMessageOffset;
Application.DDraw->TextOut(sText.getData(), Game.GraphicsResource.FontRegular, 1.0, cgo.Surface, iDrawX, iDrawY, ColorDw, alignment ? alignment : ACenter);
Application.DDraw->TextOut(sText.getData(), Game.GraphicsResource.FontRegular, 1.0, cgo.Surface, iDrawX, iDrawY, ColorDw, alignment != -1 ? alignment : ACenter);
}
}
// Positioned
Expand Down Expand Up @@ -224,7 +224,7 @@ void C4GameMessage::Draw(C4FacetEx &cgo, int32_t iPlayer)
cgo.Surface,
cgo.X + iTX,
cgo.Y + iTY,
ColorDw, alignment ? alignment : ACenter);
ColorDw, alignment != -1 ? alignment : ACenter);
}
}
}
Expand Down

0 comments on commit a08f927

Please sign in to comment.