BAGEL: add const keyword to multiple variables

This commit is contained in:
Strangerke 2024-06-16 23:45:36 +01:00
parent 0143b17ca1
commit b870556f99
10 changed files with 52 additions and 53 deletions

View File

@ -186,7 +186,7 @@ Common::Error BagelEngine::saveGameStream(Common::WriteStream *stream, bool isAu
}
Common::Error BagelEngine::loadGameStream(Common::SeekableReadStream *stream) {
byte version = stream->readByte();
const byte version = stream->readByte();
if (version > SAVEGAME_VERSION)
error("Tried to load unsupported savegame version");

View File

@ -50,8 +50,8 @@ ErrorCode CBagAreaObject::detach() {
}
CBofRect CBagAreaObject::getRect() {
CBofPoint p = getPosition();
CBofSize s = getSize();
const CBofPoint p = getPosition();
const CBofSize s = getSize();
CBofRect r = CBofRect(p, s);
return r;
}

View File

@ -111,7 +111,7 @@ ErrorCode CBagel::initialize() {
Common::U32String errMsg;
if (!Common::load_engine_data("bagel.dat", "", 1, 0, errMsg)) {
GUIErrorMessage("Could not find bagel.dat data file");
Common::String msg(errMsg);
const Common::String msg(errMsg);
bofMessageBox("Engine Data", msg.c_str());
_errCode = ERR_FREAD;
return _errCode;
@ -257,7 +257,7 @@ void CBagel::showNextCDDialog(CBofWindow *parentWin, int diskId) {
cNextCDDialog.setBackdrop(pBmp);
CBofRect cRect = cNextCDDialog.getBackdrop()->getRect();
const CBofRect cRect = cNextCDDialog.getBackdrop()->getRect();
// Create the dialog box
cNextCDDialog.create("NextCD", cRect.left, cRect.top, cRect.width(), cRect.height(), parentWin);

View File

@ -476,10 +476,10 @@ void SBBasePda::getPdaState() {
#define HAND_CURSOR 1
int SBBasePda::getProperCursor(const CBofPoint &pos, CBofRect &pdaRect) const {
int wieldCursor = CBagWield::getWieldCursor();
const int wieldCursor = CBagWield::getWieldCursor();
// Assume can't click
int cursorID = NULL_CURSOR;
const int cursorID = NULL_CURSOR;
// If we're in the map, return the nullptr cursor, if on the pda but not in the
// map window, return the hand. Same rules for nomode.
@ -488,7 +488,7 @@ int SBBasePda::getProperCursor(const CBofPoint &pos, CBofRect &pdaRect) const {
case PDA_NO_MODE:
case PDA_MOO_MODE:
if (_mapWnd) {
CBofRect pdaViewRect = _mapWnd->getRect() + pdaRect.topLeft();
const CBofRect pdaViewRect = _mapWnd->getRect() + pdaRect.topLeft();
if (pdaViewRect.ptInRect(pos)) {
if (wieldCursor >= 0) {
return wieldCursor;
@ -517,7 +517,7 @@ int SBBasePda::getProperCursor(const CBofPoint &pos, CBofRect &pdaRect) const {
// Localize pda view rect
pdaViewRect = _curDisplay->getRect() + pdaRect.topLeft();
int count = objList->getCount();
const int count = objList->getCount();
for (int i = 0; i < count; ++i) {
CBagObject *curObj = objList->getNodeItem(i);
if (curObj->isActive()) {

View File

@ -51,7 +51,7 @@ ErrorCode CBagBmpObject::detach() {
}
CBofRect CBagBmpObject::getRect() {
CBofPoint curPos = getPosition();
const CBofPoint curPos = getPosition();
CBofSize size;
if (_bmp)
size = _bmp->getSize();
@ -62,7 +62,7 @@ ErrorCode CBagBmpObject::update(CBofBitmap *bmp, CBofPoint pt, CBofRect *srcRect
if (bmp) {
_transparency = maskColor;
if (srcRect) {
CBofSize size = bmp->getSize();
const CBofSize size = bmp->getSize();
if (pt.x < 0) {
srcRect->left -= pt.x;
pt.x = 0;
@ -92,9 +92,9 @@ ErrorCode CBagBmpObject::update(CBofBitmap *bmp, CBofPoint pt, CBofRect *srcRect
bool CBagBmpObject::isInside(const CBofPoint &pt) {
if (_bmp && getRect().ptInRect(pt)) {
if (_transparency >= 0) {
int x = pt.x - getRect().left;
int y = pt.y - getRect().top;
int color = _bmp->readPixel(x, y);
const int x = pt.x - getRect().left;
const int y = pt.y - getRect().top;
const int color = _bmp->readPixel(x, y);
return color != _transparency;
}

View File

@ -50,7 +50,7 @@ CBagButtonObject::~CBagButtonObject() {
}
ErrorCode CBagButtonObject::attach() {
ErrorCode errorCode = CBagSpriteObject::attach();
const ErrorCode errorCode = CBagSpriteObject::attach();
CBofSprite *curSprite = getSprite();
if (curSprite) {
@ -70,7 +70,7 @@ ErrorCode CBagButtonObject::attach() {
// If this is a slider button make sure it is in the correct position
if (_buttonType == BTN_SLIDER) {
CBofPoint NewPoint = getPosition();
int xIncrement = _slideRect.width() / (_numPos - 1);
const int xIncrement = _slideRect.width() / (_numPos - 1);
NewPoint.x = _slideRect.left + (getState() * xIncrement);
setPosition(NewPoint);
}
@ -151,10 +151,10 @@ void CBagButtonObject::onLButtonUp(uint32 flags, CBofPoint *point, void *extraIn
// Get the mouse point relative to the pan window
CBagPanWindow *pWnd = (CBagPanWindow *)extraInfo;
CBofRect r = pWnd->getSlideBitmap()->getCurrView();
const CBofRect r = pWnd->getSlideBitmap()->getCurrView();
int mLocX = point->x + r.left - pWnd->getViewPortPos().x;
int xIncrement = _slideRect.width() / (_numPos - 1);
const int mLocX = point->x + r.left - pWnd->getViewPortPos().x;
const int xIncrement = _slideRect.width() / (_numPos - 1);
int slidePos = _slideRect.left;
int i;
@ -221,9 +221,9 @@ bool CBagButtonObject::onMouseMove(uint32 /*nFlags*/, CBofPoint point, void *ext
CBofPoint NewPoint = getPosition();
CBagPanWindow *pWnd = (CBagPanWindow *)extraInfo;
CBofRect r = pWnd->getSlideBitmap()->getCurrView();
const CBofRect r = pWnd->getSlideBitmap()->getCurrView();
int mLocX = point.x + r.left - pWnd->getViewPortPos().x;
const int mLocX = point.x + r.left - pWnd->getViewPortPos().x;
int NewXPos = mLocX;
@ -238,16 +238,15 @@ bool CBagButtonObject::onMouseMove(uint32 /*nFlags*/, CBofPoint point, void *ext
// We need to set the state here as well as LButtonUP
// because there is a chance we won't get it
int xIncrement = _slideRect.width() / (_numPos - 1);
int i = (NewPoint.x - _slideRect.left) / xIncrement;
const int xIncrement = _slideRect.width() / (_numPos - 1);
const int i = (NewPoint.x - _slideRect.left) / xIncrement;
setState(i);
}
}
if (_buttonType == BTN_PUSH) {
if (getSprite() && (getSprite()->getCelCount() > 1)) {
if (!this->getRect().ptInRect(point) &&
_active && !_activeUp) {
if (!this->getRect().ptInRect(point) && _active && !_activeUp) {
_activeUp = true;
}
}
@ -324,7 +323,7 @@ ErrorCode CBagButtonObject::update(CBofBitmap *bmp, CBofPoint pt, CBofRect *srcR
}
if (getSprite() && ((getSprite()->getCelCount() > 1) || isVisible())) {
ErrorCode errorCode = CBagSpriteObject::update(bmp, pt, srcRect, maskColor);
const ErrorCode errorCode = CBagSpriteObject::update(bmp, pt, srcRect, maskColor);
setDirty(bDirty);
return errorCode;
}
@ -343,7 +342,7 @@ ParseCodes CBagButtonObject::setInfo(CBagIfstream &istr) {
bool nObjectUpdated = false;
while (!istr.eof()) {
char ch = (char)istr.peek();
const char ch = (char)istr.peek();
switch (ch) {
//
// +n - n number of slides in sprite
@ -429,7 +428,7 @@ ParseCodes CBagButtonObject::setInfo(CBagIfstream &istr) {
// No match return from function
//
default: {
ParseCodes parseCode = CBagObject::setInfo(istr);
const ParseCodes parseCode = CBagObject::setInfo(istr);
if (parseCode == PARSING_DONE) {
return PARSING_DONE;
}

View File

@ -128,7 +128,7 @@ ErrorCode CBagCharacterObject::attach() {
if (_saveState) {
// Get the current state for this object
int nState = getState();
const int nState = getState();
// If the state is not the default(0) then move to the correct frame
if (nState != 0)
@ -212,7 +212,7 @@ bool CBagCharacterObject::refreshCurrentFrame() {
}
CBofRect CBagCharacterObject::getRect() {
CBofPoint pos = getPosition();
const CBofPoint pos = getPosition();
CBofSize size;
if (_bmpBuf)
@ -236,13 +236,13 @@ void CBagCharacterObject::updatePosition() {
// disk for the position of the smack dudes.
// Check that we are going to fit
if (lSeekPos + (int32)(2 * sizeof(int32)) <= _binBufLen) {
int xPos = READ_LE_INT32(&_binBuf[lSeekPos]);
const int xPos = READ_LE_INT32(&_binBuf[lSeekPos]);
lSeekPos += sizeof(int32);
int yPos = READ_LE_INT32(&_binBuf[lSeekPos]);
const int yPos = READ_LE_INT32(&_binBuf[lSeekPos]);
// A valid number was read
if ((xPos > -1) && (yPos > -1)) {
CBofPoint newPos(xPos, yPos);
const CBofPoint newPos(xPos, yPos);
setPosition(newPos);
}
}
@ -252,7 +252,7 @@ void CBagCharacterObject::updatePosition() {
bool CBagCharacterObject::doAdvance() {
// Assume we're not advancing
bool doAdvanceFl = false;
bool pdaWandFl = (this == _pdaWand);
const bool pdaWandFl = (this == _pdaWand);
if (pdaWandFl) {
_pdaAnimating = false;
@ -322,9 +322,9 @@ bool CBagCharacterObject::doAdvance() {
bool CBagCharacterObject::isInside(const CBofPoint &point) {
if (getRect().ptInRect(point) && _charTransColor >= 0) {
if (_bmpBuf) {
int x = point.x - getRect().left;
int y = point.y - getRect().top;
int color = _bmpBuf->readPixel(x, y);
const int x = point.x - getRect().left;
const int y = point.y - getRect().top;
const int color = _bmpBuf->readPixel(x, y);
return (color != _charTransColor);
}
@ -341,9 +341,9 @@ bool CBagCharacterObject::runObject() {
ErrorCode CBagCharacterObject::update(CBofBitmap *bmp, CBofPoint pt, CBofRect * /*srcRect, unused*/, int /*maskColor, unused*/) {
// Get the original position for character
CBofPoint originalPos = getPosition();
const CBofPoint originalPos = getPosition();
bool doAdvanceFl = doAdvance();
const bool doAdvanceFl = doAdvance();
// If we have more frames advance this, else exit and detach if needed
if (!doAdvanceFl && _exitAtEnd) {
@ -353,7 +353,7 @@ ErrorCode CBagCharacterObject::update(CBofBitmap *bmp, CBofPoint pt, CBofRect *
if (_bmpBuf) {
// Get the new position for the character
CBofPoint newPos = getPosition();
const CBofPoint newPos = getPosition();
// Get access to the current sDev
// Paint in the new pos
@ -367,7 +367,7 @@ ParseCodes CBagCharacterObject::setInfo(CBagIfstream &istr) {
bool objectUpdatedFl = false;
while (!istr.eof()) {
char ch = (char)istr.peek();
const char ch = (char)istr.peek();
switch (ch) {
// SAVESTATE - Maintain the state of the character
case 'K': {
@ -494,7 +494,7 @@ ParseCodes CBagCharacterObject::setInfo(CBagIfstream &istr) {
// No match return from function
default: {
ParseCodes parseCode = CBagObject::setInfo(istr);
const ParseCodes parseCode = CBagObject::setInfo(istr);
if (parseCode == PARSING_DONE) {
return PARSING_DONE;
}
@ -516,8 +516,8 @@ ParseCodes CBagCharacterObject::setInfo(CBagIfstream &istr) {
}
void CBagCharacterObject::arrangeFrames() {
int start = getStartFrame();
int end = getEndFrame();
const int start = getStartFrame();
const int end = getEndFrame();
if (_playbackSpeed < 0) {
_startFrame = MAX(start, end);

View File

@ -406,7 +406,7 @@ ParseCodes CBagCommandObject::setInfo(CBagIfstream &istr) {
while (!istr.eof()) {
istr.eatWhite();
char ch = (char)istr.peek();
const char ch = (char)istr.peek();
switch (ch) {
//
// OBJECT
@ -467,7 +467,7 @@ ParseCodes CBagCommandObject::setInfo(CBagIfstream &istr) {
// No match return from function
//
default: {
ParseCodes parseCode = CBagObject::setInfo(istr);
const ParseCodes parseCode = CBagObject::setInfo(istr);
if (parseCode == PARSING_DONE) {
return PARSING_DONE;
}

View File

@ -76,7 +76,7 @@ ErrorCode CDevDlg::createWindow(const char *bmp, CBofWindow *wnd, CBofPalette *p
}
CBofRect bmpRect(bitmap->getRect());
CBofString className = "CDevDlg";
const CBofString className = "CDevDlg";
CBagStorageDevDlg::create(className, &bmpRect, wnd, 0);
center();
setBackdrop(bitmap);
@ -182,7 +182,7 @@ void CDevDlg::setText(CBofString &text, CBofRect *textRect) {
ErrorCode CDevDlg::onRender(CBofBitmap *bmp, CBofRect *rect) {
assert(isValidObject(this));
ErrorCode errorCode = CBagStorageDevDlg::onRender(bmp, rect);
const ErrorCode errorCode = CBagStorageDevDlg::onRender(bmp, rect);
if (_titleText != nullptr) {
_titleText->display(getBackdrop());

View File

@ -60,7 +60,7 @@ ParseCodes CBagDossierObject::setInfo(CBagIfstream &istr) {
while (!istr.eof()) {
istr.eatWhite();
char ch = (char)istr.peek();
const char ch = (char)istr.peek();
switch (ch) {
// SIZE n - n point size of the txt
@ -199,7 +199,7 @@ ParseCodes CBagDossierObject::setInfo(CBagIfstream &istr) {
// no match return from function
//
default:
ParseCodes parseCode = CBagObject::setInfo(istr);
const ParseCodes parseCode = CBagObject::setInfo(istr);
if (parseCode == PARSING_DONE) {
return PARSING_DONE;
}
@ -222,7 +222,7 @@ ParseCodes CBagDossierObject::setInfo(CBagIfstream &istr) {
// Implement attach and detach just so we can set our own attributes
ErrorCode CBagDossierObject::attach() {
ErrorCode errorCode = CBagTextObject::attach();
const ErrorCode errorCode = CBagTextObject::attach();
// Keep track of the original text rectangle (for the dossier).
if (_dosRectInitFl == false) {
@ -236,7 +236,7 @@ ErrorCode CBagDossierObject::attach() {
}
ErrorCode CBagDossierObject::detach() {
ErrorCode errorCode = CBagTextObject::detach();
const ErrorCode errorCode = CBagTextObject::detach();
setVisible(false); // Make this invisible, don't want it redrawn.
return errorCode;
@ -265,7 +265,7 @@ ErrorCode CBagDossierObject::update(CBofBitmap *bmp, CBofPoint pt, CBofRect *src
CBofRect CBagDossierObject::getRect() {
CBofRect rect;
CBofPoint pos = getPosition();
const CBofPoint pos = getPosition();
if (_showIndexFl) {
rect = _indexRect;