Skip to content

Commit

Permalink
SCI: Remove the usage of NDEBUG
Browse files Browse the repository at this point in the history
We don't define NDEBUG in release builds, but we have other means
of debugging in our common code, via debug levels
  • Loading branch information
bluegr committed Sep 7, 2024
1 parent 0b4d88a commit fe2aa8b
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions engines/sci/graphics/celobj32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ void CelObj::deinit() {

template<bool FLIP, typename READER>
struct SCALER_NoScale {
#ifndef NDEBUG
const byte *_rowEdge;
#endif
const byte *_row;
READER _reader;
const int16 _lastIndex;
Expand All @@ -125,15 +123,11 @@ struct SCALER_NoScale {
_row = _reader.getRow(y - _sourceY);

if (FLIP) {
#ifndef NDEBUG
_rowEdge = _row - 1;
#endif
_row += _lastIndex - (x - _sourceX);
assert(_row > _rowEdge);
} else {
#ifndef NDEBUG
_rowEdge = _row + _lastIndex + 1;
#endif
_row += x - _sourceX;
assert(_row < _rowEdge);
}
Expand All @@ -152,10 +146,8 @@ struct SCALER_NoScale {

template<bool FLIP, typename READER>
struct SCALER_Scale {
#ifndef NDEBUG
int16 _minX;
int16 _maxX;
#endif
const byte *_row;
READER _reader;
// If _sourceBuffer is set, it contains the full (possibly scaled) source
Expand All @@ -167,18 +159,14 @@ struct SCALER_Scale {

SCALER_Scale(const CelObj &celObj, const Common::Rect &targetRect, const Common::Point &scaledPosition, const Ratio scaleX, const Ratio scaleY) :
_row(nullptr),
#ifndef NDEBUG
_minX(targetRect.left),
_maxX(targetRect.right - 1),
#endif
// The maximum width of the scaled object may not be as wide as the source
// data it requires if downscaling, so just always make the reader
// decompress an entire line of source data when scaling
_reader(celObj, celObj._width),
_sourceBuffer() {
#ifndef NDEBUG
assert(_minX <= _maxX);
#endif

// In order for scaling ratios to apply equally across objects that
// start at different positions on the screen (like the cels of a
Expand Down Expand Up @@ -316,27 +304,21 @@ int16 SCALER_Scale<FLIP, READER>::_valuesY[kCelScalerTableSize];

struct READER_Uncompressed {
private:
#ifndef NDEBUG
int16 _sourceHeight;
#endif
const byte *_pixels;
const int16 _sourceWidth;

public:
READER_Uncompressed(const CelObj &celObj, const int16) :
#ifndef NDEBUG
_sourceHeight(celObj._height),
#endif
_sourceWidth(celObj._width) {
const SciSpan<const byte> resource = celObj.getResPointer();
const uint32 pixelsOffset = resource.getUint32SEAt(celObj._celHeaderOffset + 24);
const int32 numPixels = MIN<int32>(resource.size() - pixelsOffset, celObj._width * celObj._height);

if (numPixels < celObj._width * celObj._height) {
warning("%s is truncated", celObj._info.toString().c_str());
#ifndef NDEBUG
_sourceHeight = numPixels / celObj._width;
#endif
}

_pixels = resource.getUnsafeDataAt(pixelsOffset, numPixels);
Expand Down

0 comments on commit fe2aa8b

Please sign in to comment.