aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorRobert Špalek2009-09-25 08:13:39 +0000
committerRobert Špalek2009-09-25 08:13:39 +0000
commitf51c81f34402c665751774b23f3734b7b7a0b2b4 (patch)
tree19ad3493d410da3c41fcf88f3dff5b7e68765b82 /engines
parentd6502a0c2416fc388a4e4e2c93315202fecaac5e (diff)
downloadscummvm-rg350-f51c81f34402c665751774b23f3734b7b7a0b2b4.tar.gz
scummvm-rg350-f51c81f34402c665751774b23f3734b7b7a0b2b4.tar.bz2
scummvm-rg350-f51c81f34402c665751774b23f3734b7b7a0b2b4.zip
Add const's to many interfaces of engines/draci/
svn-id: r44331
Diffstat (limited to 'engines')
-rw-r--r--engines/draci/animation.cpp41
-rw-r--r--engines/draci/animation.h28
-rw-r--r--engines/draci/game.cpp48
-rw-r--r--engines/draci/game.h56
-rw-r--r--engines/draci/mouse.cpp2
-rw-r--r--engines/draci/mouse.h12
-rw-r--r--engines/draci/screen.cpp12
-rw-r--r--engines/draci/screen.h8
-rw-r--r--engines/draci/script.cpp68
-rw-r--r--engines/draci/script.h72
-rw-r--r--engines/draci/sprite.cpp24
-rw-r--r--engines/draci/sprite.h8
-rw-r--r--engines/draci/surface.cpp12
-rw-r--r--engines/draci/surface.h12
14 files changed, 205 insertions, 198 deletions
diff --git a/engines/draci/animation.cpp b/engines/draci/animation.cpp
index 248cc09197..880191d90f 100644
--- a/engines/draci/animation.cpp
+++ b/engines/draci/animation.cpp
@@ -1,3 +1,4 @@
+
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
@@ -48,7 +49,7 @@ Animation::~Animation() {
deleteFrames();
}
-bool Animation::isLooping() {
+bool Animation::isLooping() const {
return _looping;
}
@@ -68,7 +69,7 @@ void Animation::setLooping(bool looping) {
looping, _id);
}
-void Animation::markDirtyRect(Surface *surface) {
+void Animation::markDirtyRect(Surface *surface) const {
// Fetch the current frame's rectangle
Drawable *frame = _frames[_currentFrame];
Common::Rect frameRect = frame->getRect();
@@ -77,8 +78,8 @@ void Animation::markDirtyRect(Surface *surface) {
frameRect.translate(_relX, _relY);
// Take animation scaling into account
- frameRect.setWidth(frameRect.width() * _scaleX);
- frameRect.setHeight(frameRect.height() * _scaleY);
+ frameRect.setWidth((int) (frameRect.width() * _scaleX));
+ frameRect.setHeight((int) (frameRect.height() * _scaleY));
// Mark the rectangle dirty on the surface
surface->markDirtyRect(frameRect);
@@ -117,7 +118,7 @@ void Animation::nextFrame(bool force) {
_currentFrame, _frames.size(), frame->getX(), frame->getY());
}
-uint Animation::nextFrameNum() {
+uint Animation::nextFrameNum() const {
if (_paused)
return _currentFrame;
@@ -157,7 +158,9 @@ void Animation::drawFrame(Surface *surface) {
// Take into account per-animation scaling and adjust the current frames dimensions
if (_scaleX != 1.0 || _scaleY != 1.0)
- frame->setScaled(scaledWidth * _scaleX, scaledHeight * _scaleY);
+ frame->setScaled(
+ (int) (scaledWidth * _scaleX),
+ (int) (scaledHeight * _scaleY));
// Draw frame
frame->drawScaled(surface, false);
@@ -175,7 +178,7 @@ void Animation::setID(int id) {
_id = id;
}
-int Animation::getID() {
+int Animation::getID() const {
return _id;
}
@@ -183,19 +186,19 @@ void Animation::setZ(uint z) {
_z = z;
}
-uint Animation::getZ() {
+uint Animation::getZ() const {
return _z;
}
-int Animation::getRelativeX() {
+int Animation::getRelativeX() const {
return _relX;
}
-int Animation::getRelativeY() {
+int Animation::getRelativeY() const {
return _relY;
}
-bool Animation::isPlaying() {
+bool Animation::isPlaying() const {
return _playing;
}
@@ -204,7 +207,7 @@ void Animation::setPlaying(bool playing) {
_playing = playing;
}
-bool Animation::isPaused() {
+bool Animation::isPaused() const {
return _paused;
}
@@ -224,11 +227,11 @@ void Animation::setScaleFactors(double scaleX, double scaleY) {
_scaleY = scaleY;
}
-double Animation::getScaleX() {
+double Animation::getScaleX() const {
return _scaleX;
}
-double Animation::getScaleY() {
+double Animation::getScaleY() const {
return _scaleY;
}
@@ -236,7 +239,7 @@ void Animation::addFrame(Drawable *frame) {
_frames.push_back(frame);
}
-int Animation::getIndex() {
+int Animation::getIndex() const {
return _index;
}
@@ -259,11 +262,11 @@ Drawable *Animation::getFrame(int frameNum) {
}
}
-uint Animation::getFrameCount() {
+uint Animation::getFrameCount() const {
return _frames.size();
}
-uint Animation::currentFrameNum() {
+uint Animation::currentFrameNum() const {
return _currentFrame;
}
@@ -614,7 +617,9 @@ int AnimationManager::getTopAnimationID(int x, int y) {
// Take into account per-animation scaling and adjust the current frames dimensions
if (anim->getScaleX() != 1.0 || anim->getScaleY() != 1.0)
- frame->setScaled(scaledWidth * anim->getScaleX(), scaledHeight * anim->getScaleY());
+ frame->setScaled(
+ (int) (scaledWidth * anim->getScaleX()),
+ (int) (scaledHeight * anim->getScaleY()));
if (frame->getRect().contains(x, y)) {
diff --git a/engines/draci/animation.h b/engines/draci/animation.h
index 5d7c0bf7b6..83161cd639 100644
--- a/engines/draci/animation.h
+++ b/engines/draci/animation.h
@@ -65,11 +65,11 @@ public:
Animation(DraciEngine *v, int index);
~Animation();
- uint getZ();
+ uint getZ() const;
void setZ(uint z);
void setID(int id);
- int getID();
+ int getID() const;
void nextFrame(bool force = false);
void drawFrame(Surface *surface);
@@ -77,31 +77,31 @@ public:
void addFrame(Drawable *frame);
Drawable *getFrame(int frameNum = kCurrentFrame);
void setCurrentFrame(uint frame);
- uint currentFrameNum();
- uint getFrameCount();
+ uint currentFrameNum() const;
+ uint getFrameCount() const;
void deleteFrames();
- bool isPlaying();
+ bool isPlaying() const;
void setPlaying(bool playing);
- bool isPaused();
+ bool isPaused() const;
void setPaused(bool paused);
- bool isLooping();
+ bool isLooping() const;
void setLooping(bool looping);
void setRelative(int relx, int rely);
- int getRelativeX();
- int getRelativeY();
+ int getRelativeX() const;
+ int getRelativeY() const;
- int getIndex();
+ int getIndex() const;
void setIndex(int index);
void setScaleFactors(double scaleX, double scaleY);
- double getScaleX();
- double getScaleY();
+ double getScaleX() const;
+ double getScaleY() const;
- void markDirtyRect(Surface *surface);
+ void markDirtyRect(Surface *surface) const;
// Animation callbacks
@@ -113,7 +113,7 @@ public:
private:
- uint nextFrameNum();
+ uint nextFrameNum() const;
/** Internal animation ID
* (as specified in the data files and the bytecode)
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 4d4755b419..6ebfb2729c 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -660,7 +660,7 @@ void Game::updateTitle() {
}
}
-int Game::getObjectWithAnimation(int animID) {
+int Game::getObjectWithAnimation(int animID) const {
for (uint i = 0; i < _info._numObjects; ++i) {
GameObject *obj = &_objects[i];
@@ -970,11 +970,11 @@ void Game::runDialogueProg(GPL2Program prog, int offset) {
_vm->_anims->deleteAfterIndex(lastAnimIndex);
}
-bool Game::isDialogueBegin() {
+bool Game::isDialogueBegin() const {
return _dialogueBegin;
}
-bool Game::shouldExitDialogue() {
+bool Game::shouldExitDialogue() const {
return _dialogueExit;
}
@@ -982,11 +982,11 @@ void Game::setDialogueExit(bool exit) {
_dialogueExit = exit;
}
-int Game::getDialogueBlockNum() {
+int Game::getDialogueBlockNum() const {
return _blockNum;
}
-int Game::getDialogueVar(int dialogueID) {
+int Game::getDialogueVar(int dialogueID) const {
return _dialogueVars[dialogueID];
}
@@ -994,23 +994,23 @@ void Game::setDialogueVar(int dialogueID, int value) {
_dialogueVars[dialogueID] = value;
}
-int Game::getCurrentDialogue() {
+int Game::getCurrentDialogue() const {
return _currentDialogue;
}
-int Game::getDialogueLastBlock() {
+int Game::getDialogueLastBlock() const {
return _lastBlock;
}
-int Game::getDialogueLinesNum() {
+int Game::getDialogueLinesNum() const {
return _dialogueLinesNum;
}
-int Game::getDialogueCurrentBlock() {
+int Game::getDialogueCurrentBlock() const {
return _currentBlock;
}
-int Game::getCurrentDialogueOffset() {
+int Game::getCurrentDialogueOffset() const {
return _dialogueOffsets[_currentDialogue];
}
@@ -1322,7 +1322,7 @@ GameObject *Game::getObject(uint objNum) {
return _objects + objNum;
}
-uint Game::getNumObjects() {
+uint Game::getNumObjects() const {
return _info._numObjects;
}
@@ -1427,7 +1427,7 @@ void Game::runGateProgram(int gate) {
setExitLoop(false);
}
-int Game::getRoomNum() {
+int Game::getRoomNum() const {
return _currentRoom._roomNum;
}
@@ -1435,7 +1435,7 @@ void Game::setRoomNum(int room) {
_newRoom = room;
}
-int Game::getGateNum() {
+int Game::getGateNum() const {
return _currentGate;
}
@@ -1451,15 +1451,15 @@ void Game::setLoopSubstatus(LoopSubstatus status) {
_loopSubstatus = status;
}
-LoopStatus Game::getLoopStatus() {
+LoopStatus Game::getLoopStatus() const {
return _loopStatus;
}
-LoopSubstatus Game::getLoopSubstatus() {
+LoopSubstatus Game::getLoopSubstatus() const {
return _loopSubstatus;
}
-int Game::getVariable(int numVar) {
+int Game::getVariable(int numVar) const {
return _variables[numVar];
}
@@ -1467,7 +1467,7 @@ void Game::setVariable(int numVar, int value) {
_variables[numVar] = value;
}
-int Game::getItemStatus(int itemID) {
+int Game::getItemStatus(int itemID) const {
return _itemStatus[itemID];
}
@@ -1475,7 +1475,7 @@ void Game::setItemStatus(int itemID, int status) {
_itemStatus[itemID] = status;
}
-int Game::getCurrentItem() {
+int Game::getCurrentItem() const {
return _currentItem;
}
@@ -1483,7 +1483,7 @@ void Game::setCurrentItem(int itemID) {
_currentItem = itemID;
}
-Person *Game::getPerson(int personID) {
+const Person *Game::getPerson(int personID) const {
return &_persons[personID];
}
@@ -1491,7 +1491,7 @@ void Game::setSpeechTick(uint tick) {
_speechTick = tick;
}
-int Game::getEscRoom() {
+int Game::getEscRoom() const {
return _currentRoom._escRoom;
}
@@ -1499,7 +1499,7 @@ void Game::schedulePalette(int paletteID) {
_scheduledPalette = paletteID;
}
-int Game::getScheduledPalette() {
+int Game::getScheduledPalette() const {
return _scheduledPalette;
}
@@ -1509,7 +1509,7 @@ int Game::getScheduledPalette() {
* all animations that have an index greater than the one marked.
*/
-int Game::getMarkedAnimationIndex() {
+int Game::getMarkedAnimationIndex() const {
return _markedAnimationIndex;
}
@@ -1530,7 +1530,7 @@ Game::~Game() {
}
-bool WalkingMap::isWalkable(int x, int y) {
+bool WalkingMap::isWalkable(int x, int y) const {
// Convert to map pixels
x = x / _deltaX;
@@ -1555,7 +1555,7 @@ bool WalkingMap::isWalkable(int x, int y) {
* TODO: Study this algorithm in more detail so it can be documented properly and
* possibly improved / simplified.
*/
-Common::Point WalkingMap::findNearestWalkable(int startX, int startY, Common::Rect searchRect) {
+Common::Point WalkingMap::findNearestWalkable(int startX, int startY, Common::Rect searchRect) const {
// If the starting point is walkable, just return that
if (searchRect.contains(startX, startY) && isWalkable(startX, startY)) {
diff --git a/engines/draci/game.h b/engines/draci/game.h
index 0197b167b6..8187438979 100644
--- a/engines/draci/game.h
+++ b/engines/draci/game.h
@@ -120,8 +120,8 @@ public:
_data = data + mapReader.pos();
}
- bool isWalkable(int x, int y);
- Common::Point findNearestWalkable(int x, int y, Common::Rect searchRect);
+ bool isWalkable(int x, int y) const;
+ Common::Point findNearestWalkable(int x, int y, Common::Rect searchRect) const;
private:
int _realWidth, _realHeight;
@@ -236,7 +236,7 @@ public:
void changeRoom(uint roomNum);
// HACK: this is only for testing
- int nextRoomNum() {
+ int nextRoomNum() const {
int n = _currentRoom._roomNum;
n = n < 37 ? n+1 : n;
@@ -248,7 +248,7 @@ public:
}
// HACK: same as above
- int prevRoomNum() {
+ int prevRoomNum() const {
int n = _currentRoom._roomNum;
n = n > 0 ? n-1 : n;
@@ -268,43 +268,43 @@ public:
void loadWalkingMap(int mapID = kDefaultRoomMap);
void loadItem(int itemID);
- uint getNumObjects();
+ uint getNumObjects() const;
GameObject *getObject(uint objNum);
- int getObjectWithAnimation(int animID);
+ int getObjectWithAnimation(int animID) const;
- int getVariable(int varNum);
+ int getVariable(int varNum) const;
void setVariable(int varNum, int value);
- Person *getPerson(int personID);
+ const Person *getPerson(int personID) const;
- int getRoomNum();
+ int getRoomNum() const;
void setRoomNum(int room);
- int getGateNum();
+ int getGateNum() const;
void setGateNum(int gate);
- int getItemStatus(int itemID);
+ int getItemStatus(int itemID) const;
void setItemStatus(int itemID, int status);
- int getCurrentItem();
+ int getCurrentItem() const;
void setCurrentItem(int itemID);
void removeItem(int itemID);
void putItem(int itemID, int position);
void addItem(int itemID);
- int getEscRoom();
+ int getEscRoom() const;
- int getMarkedAnimationIndex();
+ int getMarkedAnimationIndex() const;
void setMarkedAnimationIndex(int index);
void setLoopStatus(LoopStatus status);
void setLoopSubstatus(LoopSubstatus status);
- LoopStatus getLoopStatus();
- LoopSubstatus getLoopSubstatus();
+ LoopStatus getLoopStatus() const;
+ LoopSubstatus getLoopSubstatus() const;
- bool shouldQuit() { return _shouldQuit; }
+ bool shouldQuit() const { return _shouldQuit; }
void setQuit(bool quit) { _shouldQuit = quit; }
- bool shouldExitLoop() { return _shouldExitLoop; }
+ bool shouldExitLoop() const { return _shouldExitLoop; }
void setExitLoop(bool exit) { _shouldExitLoop = exit; }
void runGateProgram(int gate);
@@ -324,20 +324,20 @@ public:
void dialogueDone();
void runDialogueProg(GPL2Program, int offset);
- bool isDialogueBegin();
- bool shouldExitDialogue();
+ bool isDialogueBegin() const;
+ bool shouldExitDialogue() const;
void setDialogueExit(bool exit);
- int getDialogueBlockNum();
- int getDialogueVar(int dialogueID);
+ int getDialogueBlockNum() const;
+ int getDialogueVar(int dialogueID) const;
void setDialogueVar(int dialogueID, int value);
- int getCurrentDialogue();
- int getDialogueCurrentBlock();
- int getDialogueLastBlock();
- int getDialogueLinesNum();
- int getCurrentDialogueOffset();
+ int getCurrentDialogue() const;
+ int getDialogueCurrentBlock() const;
+ int getDialogueLastBlock() const;
+ int getDialogueLinesNum() const;
+ int getCurrentDialogueOffset() const;
void schedulePalette(int paletteID);
- int getScheduledPalette();
+ int getScheduledPalette() const;
private:
DraciEngine *_vm;
diff --git a/engines/draci/mouse.cpp b/engines/draci/mouse.cpp
index 53c227d626..e1b56a7961 100644
--- a/engines/draci/mouse.cpp
+++ b/engines/draci/mouse.cpp
@@ -80,7 +80,7 @@ void Mouse::cursorOff() {
CursorMan.showMouse(false);
}
-bool Mouse::isCursorOn() {
+bool Mouse::isCursorOn() const {
return CursorMan.isVisible();
}
diff --git a/engines/draci/mouse.h b/engines/draci/mouse.h
index d6df7f312d..8a6496fda9 100644
--- a/engines/draci/mouse.h
+++ b/engines/draci/mouse.h
@@ -48,18 +48,18 @@ public:
void handleEvent(Common::Event event);
void cursorOn();
void cursorOff();
- bool isCursorOn();
+ bool isCursorOn() const;
void setPosition(uint16 x, uint16 y);
- CursorType getCursorType() { return _cursorType; }
+ CursorType getCursorType() const { return _cursorType; }
void setCursorType(CursorType cur);
void loadItemCursor(int itemID, bool highlighted = false);
- bool lButtonPressed() { return _lButton; }
- bool rButtonPressed() { return _rButton; }
+ bool lButtonPressed() const { return _lButton; }
+ bool rButtonPressed() const { return _rButton; }
void lButtonSet(bool state) { _lButton = state; }
void rButtonSet(bool state) { _rButton = state; }
- uint16 getPosX() { return _x; }
- uint16 getPosY() { return _y; }
+ uint16 getPosX() const { return _x; }
+ uint16 getPosY() const { return _y; }
private:
uint16 _x, _y;
diff --git a/engines/draci/screen.cpp b/engines/draci/screen.cpp
index dbdbf15701..5d3c612978 100644
--- a/engines/draci/screen.cpp
+++ b/engines/draci/screen.cpp
@@ -60,7 +60,7 @@ void Screen::setPaletteEmpty(unsigned int numEntries) {
* start Index of the colour where replacement should start
* num Number of colours to replace
*/
-void Screen::setPalette(byte *data, uint16 start, uint16 num) {
+void Screen::setPalette(const byte *data, uint16 start, uint16 num) {
Common::MemoryReadStream pal(data, 3 * kNumColours);
pal.seek(start * 4);
@@ -85,9 +85,9 @@ void Screen::setPalette(byte *data, uint16 start, uint16 num) {
/**
* @brief Copies the current memory screen buffer to the real screen
*/
-void Screen::copyToScreen() const {
- Common::List<Common::Rect> *dirtyRects = _surface->getDirtyRects();
- Common::List<Common::Rect>::iterator it;
+void Screen::copyToScreen() {
+ const Common::List<Common::Rect> *dirtyRects = _surface->getDirtyRects();
+ Common::List<Common::Rect>::const_iterator it;
// If a full update is needed, update the whole screen
if (_surface->needsFullUpdate()) {
@@ -119,7 +119,7 @@ void Screen::copyToScreen() const {
*
* Clears the screen and marks the whole screen dirty.
*/
-void Screen::clearScreen() const {
+void Screen::clearScreen() {
byte *ptr = (byte *)_surface->getBasePtr(0, 0);
_surface->markDirty();
@@ -133,7 +133,7 @@ void Screen::clearScreen() const {
*
* Fills the screen with the specified colour and marks the whole screen dirty.
*/
-void Screen::fillScreen(uint8 colour) const {
+void Screen::fillScreen(uint8 colour) {
_surface->fill(colour);
_surface->markDirty();
}
diff --git a/engines/draci/screen.h b/engines/draci/screen.h
index 42dcf40bae..b9c3d1b4d2 100644
--- a/engines/draci/screen.h
+++ b/engines/draci/screen.h
@@ -47,11 +47,11 @@ public:
~Screen();
void setPaletteEmpty(unsigned int numEntries = kNumColours);
- void setPalette(byte *data, uint16 start, uint16 num);
+ void setPalette(const byte *data, uint16 start, uint16 num);
byte *getPalette() const;
- void copyToScreen() const;
- void clearScreen() const;
- void fillScreen(uint8 colour) const;
+ void copyToScreen();
+ void clearScreen();
+ void fillScreen(uint8 colour);
Surface *getSurface();
void drawRect(Common::Rect &r, uint8 colour);
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index 9160b92c18..645bd136b6 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -151,65 +151,65 @@ enum mathExpressionObject {
/* GPL operators */
-int Script::operAnd(int op1, int op2) {
+int Script::operAnd(int op1, int op2) const {
return op1 & op2;
}
-int Script::operOr(int op1, int op2) {
+int Script::operOr(int op1, int op2) const {
return op1 | op2;
}
-int Script::operXor(int op1, int op2) {
+int Script::operXor(int op1, int op2) const {
return op1 ^ op2;
}
-int Script::operEqual(int op1, int op2) {
+int Script::operEqual(int op1, int op2) const {
return op1 == op2;
}
-int Script::operNotEqual(int op1, int op2) {
+int Script::operNotEqual(int op1, int op2) const {
return op1 != op2;
}
-int Script::operLess(int op1, int op2) {
+int Script::operLess(int op1, int op2) const {
return op1 < op2;
}
-int Script::operGreater(int op1, int op2) {
+int Script::operGreater(int op1, int op2) const {
return op1 > op2;
}
-int Script::operGreaterOrEqual(int op1, int op2) {
+int Script::operGreaterOrEqual(int op1, int op2) const {
return op1 >= op2;
}
-int Script::operLessOrEqual(int op1, int op2) {
+int Script::operLessOrEqual(int op1, int op2) const {
return op1 <= op2;
}
-int Script::operMul(int op1, int op2) {
+int Script::operMul(int op1, int op2) const {
return op1 * op2;
}
-int Script::operAdd(int op1, int op2) {
+int Script::operAdd(int op1, int op2) const {
return op1 + op2;
}
-int Script::operSub(int op1, int op2) {
+int Script::operSub(int op1, int op2) const {
return op1 - op2;
}
-int Script::operDiv(int op1, int op2) {
+int Script::operDiv(int op1, int op2) const {
return op1 / op2;
}
-int Script::operMod(int op1, int op2) {
+int Script::operMod(int op1, int op2) const {
return op1 % op2;
}
/* GPL functions */
-int Script::funcRandom(int n) {
+int Script::funcRandom(int n) const {
// The function needs to return numbers in the [0..n-1] range so we need to deduce 1
// (RandomSource::getRandomNumber returns a number in the range [0..n])
@@ -218,58 +218,58 @@ int Script::funcRandom(int n) {
return _vm->_rnd.getRandomNumber(n);
}
-int Script::funcAtBegin(int yesno) {
+int Script::funcAtBegin(int yesno) const {
return _vm->_game->isDialogueBegin() == (bool)yesno;
}
-int Script::funcLastBlock(int blockID) {
+int Script::funcLastBlock(int blockID) const {
blockID -= 1;
return _vm->_game->getDialogueLastBlock() == blockID;
}
-int Script::funcBlockVar(int blockID) {
+int Script::funcBlockVar(int blockID) const {
blockID -= 1;
const int currentOffset = _vm->_game->getCurrentDialogueOffset();
return _vm->_game->getDialogueVar(currentOffset + blockID);
}
-int Script::funcHasBeen(int blockID) {
+int Script::funcHasBeen(int blockID) const {
blockID -= 1;
const int currentOffset = _vm->_game->getCurrentDialogueOffset();
return _vm->_game->getDialogueVar(currentOffset + blockID) > 0;
}
-int Script::funcMaxLine(int lines) {
+int Script::funcMaxLine(int lines) const {
return _vm->_game->getDialogueLinesNum() < lines;
}
-int Script::funcNot(int n) {
+int Script::funcNot(int n) const {
return !n;
}
-int Script::funcIsIcoOn(int itemID) {
+int Script::funcIsIcoOn(int itemID) const {
itemID -= 1;
return _vm->_game->getItemStatus(itemID) == 1;
}
-int Script::funcIcoStat(int itemID) {
+int Script::funcIcoStat(int itemID) const {
itemID -= 1;
int status = _vm->_game->getItemStatus(itemID);
return (status == 1) ? 1 : 2;
}
-int Script::funcIsIcoAct(int itemID) {
+int Script::funcIsIcoAct(int itemID) const {
itemID -= 1;
return _vm->_game->getCurrentItem() == itemID;
}
-int Script::funcActIco(int itemID) {
+int Script::funcActIco(int itemID) const {
// The parameter seems to be an omission in the original player since it's not
// used in the implementation of the function. It's possible that the functions were
@@ -279,7 +279,7 @@ int Script::funcActIco(int itemID) {
return _vm->_game->getCurrentItem();
}
-int Script::funcIsObjOn(int objID) {
+int Script::funcIsObjOn(int objID) const {
objID -= 1;
GameObject *obj = _vm->_game->getObject(objID);
@@ -287,7 +287,7 @@ int Script::funcIsObjOn(int objID) {
return obj->_visible;
}
-int Script::funcIsObjOff(int objID) {
+int Script::funcIsObjOff(int objID) const {
objID -= 1;
GameObject *obj = _vm->_game->getObject(objID);
@@ -297,7 +297,7 @@ int Script::funcIsObjOff(int objID) {
return !obj->_visible && obj->_location != -1;
}
-int Script::funcObjStat(int objID) {
+int Script::funcObjStat(int objID) const {
objID -= 1;
GameObject *obj = _vm->_game->getObject(objID);
@@ -313,7 +313,7 @@ int Script::funcObjStat(int objID) {
}
}
-int Script::funcIsObjAway(int objID) {
+int Script::funcIsObjAway(int objID) const {
objID -= 1;
GameObject *obj = _vm->_game->getObject(objID);
@@ -322,7 +322,7 @@ int Script::funcIsObjAway(int objID) {
return !obj->_visible && obj->_location == -1;
}
-int Script::funcActPhase(int objID) {
+int Script::funcActPhase(int objID) const {
objID -= 1;
@@ -673,7 +673,7 @@ void Script::talk(Common::Queue<int> &params) {
Text *speechFrame = reinterpret_cast<Text *>(speechAnim->getFrame());
// Fetch person info
- Person *person = _vm->_game->getPerson(personID);
+ const Person *person = _vm->_game->getPerson(personID);
// Set the string and text colour
surface->markDirtyRect(speechFrame->getRect(true));
@@ -799,7 +799,7 @@ void Script::endCurrentProgram() {
* @param reader Stream reader set to the beginning of the expression
*/
-int Script::handleMathExpression(Common::MemoryReadStream &reader) {
+int Script::handleMathExpression(Common::MemoryReadStream &reader) const {
Common::Stack<int> stk;
mathExpressionObject obj;
GPL2Operator oper;
@@ -907,7 +907,7 @@ int Script::handleMathExpression(Common::MemoryReadStream &reader) {
*
* Reference: the function equivalent to this one is called "Can()" in the original engine.
*/
-bool Script::testExpression(GPL2Program program, uint16 offset) {
+bool Script::testExpression(GPL2Program program, uint16 offset) const {
// Initialize program reader
Common::MemoryReadStream reader(program._bytecode, program._length);
@@ -935,7 +935,7 @@ bool Script::testExpression(GPL2Program program, uint16 offset) {
* @return NULL if command is not found. Otherwise, a pointer to a GPL2Command
* struct representing the command.
*/
-const GPL2Command *Script::findCommand(byte num, byte subnum) {
+const GPL2Command *Script::findCommand(byte num, byte subnum) const {
unsigned int i = 0;
while (1) {
diff --git a/engines/draci/script.h b/engines/draci/script.h
index 86abb5ee9b..2cbdff0f0e 100644
--- a/engines/draci/script.h
+++ b/engines/draci/script.h
@@ -43,8 +43,8 @@ enum {
};
typedef void (Script::* GPLHandler)(Common::Queue<int> &);
-typedef int (Script::* GPLOperatorHandler)(int, int);
-typedef int (Script::* GPLFunctionHandler)(int);
+typedef int (Script::* GPLOperatorHandler)(int, int) const;
+typedef int (Script::* GPLFunctionHandler)(int) const;
/**
* Represents a single command in the GPL scripting language bytecode.
@@ -89,7 +89,7 @@ public:
Script(DraciEngine *vm) : _vm(vm), _jump(0) { setupCommandList(); };
int run(GPL2Program program, uint16 offset);
- bool testExpression(GPL2Program, uint16 offset);
+ bool testExpression(GPL2Program, uint16 offset) const;
void endCurrentProgram();
private:
@@ -132,41 +132,41 @@ private:
void blackPalette(Common::Queue<int> &params);
void loadPalette(Common::Queue<int> &params);
- int operAnd(int op1, int op2);
- int operOr(int op1, int op2);
- int operXor(int op1, int op2);
- int operSub(int op1, int op2);
- int operAdd(int op1, int op2);
- int operDiv(int op1, int op2);
- int operMul(int op1, int op2);
- int operEqual(int op1, int op2);
- int operNotEqual(int op1, int op2);
- int operGreater(int op1, int op2);
- int operLess(int op1, int op2);
- int operGreaterOrEqual(int op1, int op2);
- int operLessOrEqual(int op1, int op2);
- int operMod(int op1, int op2);
-
- int funcRandom(int n);
- int funcNot(int n);
- int funcIsIcoOn(int iconID);
- int funcIcoStat(int iconID);
- int funcActIco(int iconID);
- int funcIsIcoAct(int iconID);
- int funcIsObjOn(int objID);
- int funcIsObjOff(int objID);
- int funcIsObjAway(int objID);
- int funcActPhase(int objID);
- int funcObjStat(int objID);
- int funcLastBlock(int blockID);
- int funcAtBegin(int yesno);
- int funcBlockVar(int blockID);
- int funcHasBeen(int blockID);
- int funcMaxLine(int lines);
+ int operAnd(int op1, int op2) const;
+ int operOr(int op1, int op2) const;
+ int operXor(int op1, int op2) const;
+ int operSub(int op1, int op2) const;
+ int operAdd(int op1, int op2) const;
+ int operDiv(int op1, int op2) const;
+ int operMul(int op1, int op2) const;
+ int operEqual(int op1, int op2) const;
+ int operNotEqual(int op1, int op2) const;
+ int operGreater(int op1, int op2) const;
+ int operLess(int op1, int op2) const;
+ int operGreaterOrEqual(int op1, int op2) const;
+ int operLessOrEqual(int op1, int op2) const;
+ int operMod(int op1, int op2) const;
+
+ int funcRandom(int n) const;
+ int funcNot(int n) const;
+ int funcIsIcoOn(int iconID) const;
+ int funcIcoStat(int iconID) const;
+ int funcActIco(int iconID) const;
+ int funcIsIcoAct(int iconID) const;
+ int funcIsObjOn(int objID) const;
+ int funcIsObjOff(int objID) const;
+ int funcIsObjAway(int objID) const;
+ int funcActPhase(int objID) const;
+ int funcObjStat(int objID) const;
+ int funcLastBlock(int blockID) const;
+ int funcAtBegin(int yesno) const;
+ int funcBlockVar(int blockID) const;
+ int funcHasBeen(int blockID) const;
+ int funcMaxLine(int lines) const;
void setupCommandList();
- const GPL2Command *findCommand(byte num, byte subnum);
- int handleMathExpression(Common::MemoryReadStream &reader);
+ const GPL2Command *findCommand(byte num, byte subnum) const;
+ int handleMathExpression(Common::MemoryReadStream &reader) const;
DraciEngine *_vm;
};
diff --git a/engines/draci/sprite.cpp b/engines/draci/sprite.cpp
index 8d21453ef6..69465307a4 100644
--- a/engines/draci/sprite.cpp
+++ b/engines/draci/sprite.cpp
@@ -56,7 +56,7 @@ static void transformToRows(byte *img, uint16 width, uint16 height) {
/**
* Constructor for loading sprites from a raw data buffer, one byte per pixel.
*/
-Sprite::Sprite(byte *raw_data, uint16 width, uint16 height, int x, int y,
+Sprite::Sprite(const byte *raw_data, uint16 width, uint16 height, int x, int y,
bool columnwise) : _data(NULL) {
_width = width;
@@ -72,21 +72,22 @@ Sprite::Sprite(byte *raw_data, uint16 width, uint16 height, int x, int y,
_mirror = false;
- _data = new byte[width * height];
+ byte *data = new byte[width * height];
- memcpy(_data, raw_data, width * height);
+ memcpy(data, raw_data, width * height);
// If the sprite is stored column-wise, transform it to row-wise
if (columnwise) {
- transformToRows(_data, width, height);
+ transformToRows(data, width, height);
}
+ _data = data;
}
/**
* Constructor for loading sprites from a sprite-formatted buffer, one byte per
* pixel.
*/
-Sprite::Sprite(byte *sprite_data, uint16 length, int x, int y, bool columnwise)
+Sprite::Sprite(const byte *sprite_data, uint16 length, int x, int y, bool columnwise)
: _data(NULL) {
_x = x;
@@ -104,14 +105,15 @@ Sprite::Sprite(byte *sprite_data, uint16 length, int x, int y, bool columnwise)
_scaledWidth = _width;
_scaledHeight = _height;
- _data = new byte[_width * _height];
+ byte *data = new byte[_width * _height];
- reader.read(_data, _width * _height);
+ reader.read(data, _width * _height);
// If the sprite is stored column-wise, transform it to row-wise
if (columnwise) {
- transformToRows(_data, _width, _height);
+ transformToRows(data, _width, _height);
}
+ _data = data;
}
Sprite::~Sprite() {
@@ -171,7 +173,7 @@ void Sprite::drawScaled(Surface *surface, bool markDirty) const {
// Get pointers to source and destination buffers
byte *dst = (byte *)surface->getBasePtr(clippedDestRect.left, clippedDestRect.top);
- byte *src = _data;
+ const byte *src = _data;
const int transparent = surface->getTransparentColour();
@@ -262,7 +264,7 @@ void Sprite::draw(Surface *surface, bool markDirty) const {
// Get pointers to source and destination buffers
byte *dst = (byte *)surface->getBasePtr(clippedDestRect.left, clippedDestRect.top);
- byte *src = _data;
+ const byte *src = _data;
const int transparent = surface->getTransparentColour();
@@ -350,7 +352,7 @@ void Text::setSpacing(uint spacing) {
_spacing = spacing;
}
-uint Text::getLength() {
+uint Text::getLength() const {
return _length;
}
diff --git a/engines/draci/sprite.h b/engines/draci/sprite.h
index 2fb668ba65..e59149de42 100644
--- a/engines/draci/sprite.h
+++ b/engines/draci/sprite.h
@@ -94,9 +94,9 @@ protected:
class Sprite : public Drawable {
public:
- Sprite(byte *raw_data, uint16 width, uint16 height, int x, int y, bool columnwise);
+ Sprite(const byte *raw_data, uint16 width, uint16 height, int x, int y, bool columnwise);
- Sprite(byte *sprite_data, uint16 length, int x, int y, bool columnwise);
+ Sprite(const byte *sprite_data, uint16 length, int x, int y, bool columnwise);
~Sprite();
@@ -114,7 +114,7 @@ public:
DrawableType getType() const { return kDrawableSprite; }
private:
- byte *_data; //!< Pointer to a buffer containing raw sprite data (row-wise)
+ const byte *_data; //!< Pointer to a buffer containing raw sprite data (row-wise)
bool _mirror;
};
@@ -130,7 +130,7 @@ public:
void setSpacing(uint spacing);
void setFont(Font *font);
- uint getLength();
+ uint getLength() const;
void draw(Surface *surface, bool markDirty = true) const;
diff --git a/engines/draci/surface.cpp b/engines/draci/surface.cpp
index a1e9b0f9ab..12fabd2ec3 100644
--- a/engines/draci/surface.cpp
+++ b/engines/draci/surface.cpp
@@ -91,7 +91,7 @@ void Surface::markClean() {
/**
* @brief Checks whether the surface needs a full update
*/
-bool Surface::needsFullUpdate() {
+bool Surface::needsFullUpdate() const {
return _fullUpdate;
}
@@ -99,14 +99,14 @@ bool Surface::needsFullUpdate() {
* @brief Fetches the surface's dirty rectangles
* @return A pointer a list of dirty rectangles
*/
-Common::List<Common::Rect> *Surface::getDirtyRects() {
+const Common::List<Common::Rect> *Surface::getDirtyRects() const {
return &_dirtyRects;
}
/**
* @brief Returns the current transparent colour of the surface
*/
-uint Surface::getTransparentColour() {
+uint Surface::getTransparentColour() const {
return _transparentColour;
}
@@ -134,7 +134,7 @@ void Surface::fill(uint colour) {
*
* @return The centered x coordinate
*/
-uint Surface::centerOnX(uint x, uint width) {
+uint Surface::centerOnX(uint x, uint width) const {
int newX = x - width / 2;
@@ -155,7 +155,7 @@ uint Surface::centerOnX(uint x, uint width) {
*
* @return The centered y coordinate
*/
-uint Surface::centerOnY(uint y, uint height) {
+uint Surface::centerOnY(uint y, uint height) const {
int newY = y - height / 2;
@@ -172,7 +172,7 @@ uint Surface::centerOnY(uint y, uint height) {
* @brief Returns a Common::Rect corresponding to the surface.
*/
-Common::Rect Surface::getRect() {
+Common::Rect Surface::getRect() const {
return Common::Rect(w, h);
}
diff --git a/engines/draci/surface.h b/engines/draci/surface.h
index ea3830a97f..5ce92bbd76 100644
--- a/engines/draci/surface.h
+++ b/engines/draci/surface.h
@@ -37,17 +37,17 @@ public:
~Surface();
void markDirtyRect(Common::Rect r);
- Common::List<Common::Rect> *getDirtyRects();
+ const Common::List<Common::Rect> *getDirtyRects() const;
void clearDirtyRects();
void markDirty();
void markClean();
- bool needsFullUpdate();
- uint getTransparentColour();
+ bool needsFullUpdate() const;
+ uint getTransparentColour() const;
void setTransparentColour(uint colour);
void fill(uint colour);
- uint centerOnY(uint y, uint height);
- uint centerOnX(uint x, uint width);
- Common::Rect getRect();
+ uint centerOnY(uint y, uint height) const;
+ uint centerOnX(uint x, uint width) const;
+ Common::Rect getRect() const;
private:
/** The current transparent colour of the surface. See getTransparentColour() and