Add const's to many interfaces of engines/draci/

svn-id: r44331
This commit is contained in:
Robert Špalek 2009-09-25 08:13:39 +00:00
parent d6502a0c24
commit f51c81f344
14 changed files with 204 additions and 197 deletions

View file

@ -1,3 +1,4 @@
/* ScummVM - Graphic Adventure Engine /* ScummVM - Graphic Adventure Engine
* *
* ScummVM is the legal property of its developers, whose names * ScummVM is the legal property of its developers, whose names
@ -48,7 +49,7 @@ Animation::~Animation() {
deleteFrames(); deleteFrames();
} }
bool Animation::isLooping() { bool Animation::isLooping() const {
return _looping; return _looping;
} }
@ -68,7 +69,7 @@ void Animation::setLooping(bool looping) {
looping, _id); looping, _id);
} }
void Animation::markDirtyRect(Surface *surface) { void Animation::markDirtyRect(Surface *surface) const {
// Fetch the current frame's rectangle // Fetch the current frame's rectangle
Drawable *frame = _frames[_currentFrame]; Drawable *frame = _frames[_currentFrame];
Common::Rect frameRect = frame->getRect(); Common::Rect frameRect = frame->getRect();
@ -77,8 +78,8 @@ void Animation::markDirtyRect(Surface *surface) {
frameRect.translate(_relX, _relY); frameRect.translate(_relX, _relY);
// Take animation scaling into account // Take animation scaling into account
frameRect.setWidth(frameRect.width() * _scaleX); frameRect.setWidth((int) (frameRect.width() * _scaleX));
frameRect.setHeight(frameRect.height() * _scaleY); frameRect.setHeight((int) (frameRect.height() * _scaleY));
// Mark the rectangle dirty on the surface // Mark the rectangle dirty on the surface
surface->markDirtyRect(frameRect); surface->markDirtyRect(frameRect);
@ -117,7 +118,7 @@ void Animation::nextFrame(bool force) {
_currentFrame, _frames.size(), frame->getX(), frame->getY()); _currentFrame, _frames.size(), frame->getX(), frame->getY());
} }
uint Animation::nextFrameNum() { uint Animation::nextFrameNum() const {
if (_paused) if (_paused)
return _currentFrame; return _currentFrame;
@ -157,7 +158,9 @@ void Animation::drawFrame(Surface *surface) {
// Take into account per-animation scaling and adjust the current frames dimensions // Take into account per-animation scaling and adjust the current frames dimensions
if (_scaleX != 1.0 || _scaleY != 1.0) if (_scaleX != 1.0 || _scaleY != 1.0)
frame->setScaled(scaledWidth * _scaleX, scaledHeight * _scaleY); frame->setScaled(
(int) (scaledWidth * _scaleX),
(int) (scaledHeight * _scaleY));
// Draw frame // Draw frame
frame->drawScaled(surface, false); frame->drawScaled(surface, false);
@ -175,7 +178,7 @@ void Animation::setID(int id) {
_id = id; _id = id;
} }
int Animation::getID() { int Animation::getID() const {
return _id; return _id;
} }
@ -183,19 +186,19 @@ void Animation::setZ(uint z) {
_z = z; _z = z;
} }
uint Animation::getZ() { uint Animation::getZ() const {
return _z; return _z;
} }
int Animation::getRelativeX() { int Animation::getRelativeX() const {
return _relX; return _relX;
} }
int Animation::getRelativeY() { int Animation::getRelativeY() const {
return _relY; return _relY;
} }
bool Animation::isPlaying() { bool Animation::isPlaying() const {
return _playing; return _playing;
} }
@ -204,7 +207,7 @@ void Animation::setPlaying(bool playing) {
_playing = playing; _playing = playing;
} }
bool Animation::isPaused() { bool Animation::isPaused() const {
return _paused; return _paused;
} }
@ -224,11 +227,11 @@ void Animation::setScaleFactors(double scaleX, double scaleY) {
_scaleY = scaleY; _scaleY = scaleY;
} }
double Animation::getScaleX() { double Animation::getScaleX() const {
return _scaleX; return _scaleX;
} }
double Animation::getScaleY() { double Animation::getScaleY() const {
return _scaleY; return _scaleY;
} }
@ -236,7 +239,7 @@ void Animation::addFrame(Drawable *frame) {
_frames.push_back(frame); _frames.push_back(frame);
} }
int Animation::getIndex() { int Animation::getIndex() const {
return _index; return _index;
} }
@ -259,11 +262,11 @@ Drawable *Animation::getFrame(int frameNum) {
} }
} }
uint Animation::getFrameCount() { uint Animation::getFrameCount() const {
return _frames.size(); return _frames.size();
} }
uint Animation::currentFrameNum() { uint Animation::currentFrameNum() const {
return _currentFrame; 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 // Take into account per-animation scaling and adjust the current frames dimensions
if (anim->getScaleX() != 1.0 || anim->getScaleY() != 1.0) 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)) { if (frame->getRect().contains(x, y)) {

View file

@ -65,11 +65,11 @@ public:
Animation(DraciEngine *v, int index); Animation(DraciEngine *v, int index);
~Animation(); ~Animation();
uint getZ(); uint getZ() const;
void setZ(uint z); void setZ(uint z);
void setID(int id); void setID(int id);
int getID(); int getID() const;
void nextFrame(bool force = false); void nextFrame(bool force = false);
void drawFrame(Surface *surface); void drawFrame(Surface *surface);
@ -77,31 +77,31 @@ public:
void addFrame(Drawable *frame); void addFrame(Drawable *frame);
Drawable *getFrame(int frameNum = kCurrentFrame); Drawable *getFrame(int frameNum = kCurrentFrame);
void setCurrentFrame(uint frame); void setCurrentFrame(uint frame);
uint currentFrameNum(); uint currentFrameNum() const;
uint getFrameCount(); uint getFrameCount() const;
void deleteFrames(); void deleteFrames();
bool isPlaying(); bool isPlaying() const;
void setPlaying(bool playing); void setPlaying(bool playing);
bool isPaused(); bool isPaused() const;
void setPaused(bool paused); void setPaused(bool paused);
bool isLooping(); bool isLooping() const;
void setLooping(bool looping); void setLooping(bool looping);
void setRelative(int relx, int rely); void setRelative(int relx, int rely);
int getRelativeX(); int getRelativeX() const;
int getRelativeY(); int getRelativeY() const;
int getIndex(); int getIndex() const;
void setIndex(int index); void setIndex(int index);
void setScaleFactors(double scaleX, double scaleY); void setScaleFactors(double scaleX, double scaleY);
double getScaleX(); double getScaleX() const;
double getScaleY(); double getScaleY() const;
void markDirtyRect(Surface *surface); void markDirtyRect(Surface *surface) const;
// Animation callbacks // Animation callbacks
@ -113,7 +113,7 @@ public:
private: private:
uint nextFrameNum(); uint nextFrameNum() const;
/** Internal animation ID /** Internal animation ID
* (as specified in the data files and the bytecode) * (as specified in the data files and the bytecode)

View file

@ -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) { for (uint i = 0; i < _info._numObjects; ++i) {
GameObject *obj = &_objects[i]; GameObject *obj = &_objects[i];
@ -970,11 +970,11 @@ void Game::runDialogueProg(GPL2Program prog, int offset) {
_vm->_anims->deleteAfterIndex(lastAnimIndex); _vm->_anims->deleteAfterIndex(lastAnimIndex);
} }
bool Game::isDialogueBegin() { bool Game::isDialogueBegin() const {
return _dialogueBegin; return _dialogueBegin;
} }
bool Game::shouldExitDialogue() { bool Game::shouldExitDialogue() const {
return _dialogueExit; return _dialogueExit;
} }
@ -982,11 +982,11 @@ void Game::setDialogueExit(bool exit) {
_dialogueExit = exit; _dialogueExit = exit;
} }
int Game::getDialogueBlockNum() { int Game::getDialogueBlockNum() const {
return _blockNum; return _blockNum;
} }
int Game::getDialogueVar(int dialogueID) { int Game::getDialogueVar(int dialogueID) const {
return _dialogueVars[dialogueID]; return _dialogueVars[dialogueID];
} }
@ -994,23 +994,23 @@ void Game::setDialogueVar(int dialogueID, int value) {
_dialogueVars[dialogueID] = value; _dialogueVars[dialogueID] = value;
} }
int Game::getCurrentDialogue() { int Game::getCurrentDialogue() const {
return _currentDialogue; return _currentDialogue;
} }
int Game::getDialogueLastBlock() { int Game::getDialogueLastBlock() const {
return _lastBlock; return _lastBlock;
} }
int Game::getDialogueLinesNum() { int Game::getDialogueLinesNum() const {
return _dialogueLinesNum; return _dialogueLinesNum;
} }
int Game::getDialogueCurrentBlock() { int Game::getDialogueCurrentBlock() const {
return _currentBlock; return _currentBlock;
} }
int Game::getCurrentDialogueOffset() { int Game::getCurrentDialogueOffset() const {
return _dialogueOffsets[_currentDialogue]; return _dialogueOffsets[_currentDialogue];
} }
@ -1322,7 +1322,7 @@ GameObject *Game::getObject(uint objNum) {
return _objects + objNum; return _objects + objNum;
} }
uint Game::getNumObjects() { uint Game::getNumObjects() const {
return _info._numObjects; return _info._numObjects;
} }
@ -1427,7 +1427,7 @@ void Game::runGateProgram(int gate) {
setExitLoop(false); setExitLoop(false);
} }
int Game::getRoomNum() { int Game::getRoomNum() const {
return _currentRoom._roomNum; return _currentRoom._roomNum;
} }
@ -1435,7 +1435,7 @@ void Game::setRoomNum(int room) {
_newRoom = room; _newRoom = room;
} }
int Game::getGateNum() { int Game::getGateNum() const {
return _currentGate; return _currentGate;
} }
@ -1451,15 +1451,15 @@ void Game::setLoopSubstatus(LoopSubstatus status) {
_loopSubstatus = status; _loopSubstatus = status;
} }
LoopStatus Game::getLoopStatus() { LoopStatus Game::getLoopStatus() const {
return _loopStatus; return _loopStatus;
} }
LoopSubstatus Game::getLoopSubstatus() { LoopSubstatus Game::getLoopSubstatus() const {
return _loopSubstatus; return _loopSubstatus;
} }
int Game::getVariable(int numVar) { int Game::getVariable(int numVar) const {
return _variables[numVar]; return _variables[numVar];
} }
@ -1467,7 +1467,7 @@ void Game::setVariable(int numVar, int value) {
_variables[numVar] = value; _variables[numVar] = value;
} }
int Game::getItemStatus(int itemID) { int Game::getItemStatus(int itemID) const {
return _itemStatus[itemID]; return _itemStatus[itemID];
} }
@ -1475,7 +1475,7 @@ void Game::setItemStatus(int itemID, int status) {
_itemStatus[itemID] = status; _itemStatus[itemID] = status;
} }
int Game::getCurrentItem() { int Game::getCurrentItem() const {
return _currentItem; return _currentItem;
} }
@ -1483,7 +1483,7 @@ void Game::setCurrentItem(int itemID) {
_currentItem = itemID; _currentItem = itemID;
} }
Person *Game::getPerson(int personID) { const Person *Game::getPerson(int personID) const {
return &_persons[personID]; return &_persons[personID];
} }
@ -1491,7 +1491,7 @@ void Game::setSpeechTick(uint tick) {
_speechTick = tick; _speechTick = tick;
} }
int Game::getEscRoom() { int Game::getEscRoom() const {
return _currentRoom._escRoom; return _currentRoom._escRoom;
} }
@ -1499,7 +1499,7 @@ void Game::schedulePalette(int paletteID) {
_scheduledPalette = paletteID; _scheduledPalette = paletteID;
} }
int Game::getScheduledPalette() { int Game::getScheduledPalette() const {
return _scheduledPalette; return _scheduledPalette;
} }
@ -1509,7 +1509,7 @@ int Game::getScheduledPalette() {
* all animations that have an index greater than the one marked. * all animations that have an index greater than the one marked.
*/ */
int Game::getMarkedAnimationIndex() { int Game::getMarkedAnimationIndex() const {
return _markedAnimationIndex; 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 // Convert to map pixels
x = x / _deltaX; 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 * TODO: Study this algorithm in more detail so it can be documented properly and
* possibly improved / simplified. * 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 the starting point is walkable, just return that
if (searchRect.contains(startX, startY) && isWalkable(startX, startY)) { if (searchRect.contains(startX, startY) && isWalkable(startX, startY)) {

View file

@ -120,8 +120,8 @@ public:
_data = data + mapReader.pos(); _data = data + mapReader.pos();
} }
bool isWalkable(int x, int y); bool isWalkable(int x, int y) const;
Common::Point findNearestWalkable(int x, int y, Common::Rect searchRect); Common::Point findNearestWalkable(int x, int y, Common::Rect searchRect) const;
private: private:
int _realWidth, _realHeight; int _realWidth, _realHeight;
@ -236,7 +236,7 @@ public:
void changeRoom(uint roomNum); void changeRoom(uint roomNum);
// HACK: this is only for testing // HACK: this is only for testing
int nextRoomNum() { int nextRoomNum() const {
int n = _currentRoom._roomNum; int n = _currentRoom._roomNum;
n = n < 37 ? n+1 : n; n = n < 37 ? n+1 : n;
@ -248,7 +248,7 @@ public:
} }
// HACK: same as above // HACK: same as above
int prevRoomNum() { int prevRoomNum() const {
int n = _currentRoom._roomNum; int n = _currentRoom._roomNum;
n = n > 0 ? n-1 : n; n = n > 0 ? n-1 : n;
@ -268,43 +268,43 @@ public:
void loadWalkingMap(int mapID = kDefaultRoomMap); void loadWalkingMap(int mapID = kDefaultRoomMap);
void loadItem(int itemID); void loadItem(int itemID);
uint getNumObjects(); uint getNumObjects() const;
GameObject *getObject(uint objNum); 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); 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); void setRoomNum(int room);
int getGateNum(); int getGateNum() const;
void setGateNum(int gate); void setGateNum(int gate);
int getItemStatus(int itemID); int getItemStatus(int itemID) const;
void setItemStatus(int itemID, int status); void setItemStatus(int itemID, int status);
int getCurrentItem(); int getCurrentItem() const;
void setCurrentItem(int itemID); void setCurrentItem(int itemID);
void removeItem(int itemID); void removeItem(int itemID);
void putItem(int itemID, int position); void putItem(int itemID, int position);
void addItem(int itemID); void addItem(int itemID);
int getEscRoom(); int getEscRoom() const;
int getMarkedAnimationIndex(); int getMarkedAnimationIndex() const;
void setMarkedAnimationIndex(int index); void setMarkedAnimationIndex(int index);
void setLoopStatus(LoopStatus status); void setLoopStatus(LoopStatus status);
void setLoopSubstatus(LoopSubstatus status); void setLoopSubstatus(LoopSubstatus status);
LoopStatus getLoopStatus(); LoopStatus getLoopStatus() const;
LoopSubstatus getLoopSubstatus(); LoopSubstatus getLoopSubstatus() const;
bool shouldQuit() { return _shouldQuit; } bool shouldQuit() const { return _shouldQuit; }
void setQuit(bool quit) { _shouldQuit = quit; } void setQuit(bool quit) { _shouldQuit = quit; }
bool shouldExitLoop() { return _shouldExitLoop; } bool shouldExitLoop() const { return _shouldExitLoop; }
void setExitLoop(bool exit) { _shouldExitLoop = exit; } void setExitLoop(bool exit) { _shouldExitLoop = exit; }
void runGateProgram(int gate); void runGateProgram(int gate);
@ -324,20 +324,20 @@ public:
void dialogueDone(); void dialogueDone();
void runDialogueProg(GPL2Program, int offset); void runDialogueProg(GPL2Program, int offset);
bool isDialogueBegin(); bool isDialogueBegin() const;
bool shouldExitDialogue(); bool shouldExitDialogue() const;
void setDialogueExit(bool exit); void setDialogueExit(bool exit);
int getDialogueBlockNum(); int getDialogueBlockNum() const;
int getDialogueVar(int dialogueID); int getDialogueVar(int dialogueID) const;
void setDialogueVar(int dialogueID, int value); void setDialogueVar(int dialogueID, int value);
int getCurrentDialogue(); int getCurrentDialogue() const;
int getDialogueCurrentBlock(); int getDialogueCurrentBlock() const;
int getDialogueLastBlock(); int getDialogueLastBlock() const;
int getDialogueLinesNum(); int getDialogueLinesNum() const;
int getCurrentDialogueOffset(); int getCurrentDialogueOffset() const;
void schedulePalette(int paletteID); void schedulePalette(int paletteID);
int getScheduledPalette(); int getScheduledPalette() const;
private: private:
DraciEngine *_vm; DraciEngine *_vm;

View file

@ -80,7 +80,7 @@ void Mouse::cursorOff() {
CursorMan.showMouse(false); CursorMan.showMouse(false);
} }
bool Mouse::isCursorOn() { bool Mouse::isCursorOn() const {
return CursorMan.isVisible(); return CursorMan.isVisible();
} }

View file

@ -48,18 +48,18 @@ public:
void handleEvent(Common::Event event); void handleEvent(Common::Event event);
void cursorOn(); void cursorOn();
void cursorOff(); void cursorOff();
bool isCursorOn(); bool isCursorOn() const;
void setPosition(uint16 x, uint16 y); void setPosition(uint16 x, uint16 y);
CursorType getCursorType() { return _cursorType; } CursorType getCursorType() const { return _cursorType; }
void setCursorType(CursorType cur); void setCursorType(CursorType cur);
void loadItemCursor(int itemID, bool highlighted = false); void loadItemCursor(int itemID, bool highlighted = false);
bool lButtonPressed() { return _lButton; } bool lButtonPressed() const { return _lButton; }
bool rButtonPressed() { return _rButton; } bool rButtonPressed() const { return _rButton; }
void lButtonSet(bool state) { _lButton = state; } void lButtonSet(bool state) { _lButton = state; }
void rButtonSet(bool state) { _rButton = state; } void rButtonSet(bool state) { _rButton = state; }
uint16 getPosX() { return _x; } uint16 getPosX() const { return _x; }
uint16 getPosY() { return _y; } uint16 getPosY() const { return _y; }
private: private:
uint16 _x, _y; uint16 _x, _y;

View file

@ -60,7 +60,7 @@ void Screen::setPaletteEmpty(unsigned int numEntries) {
* start Index of the colour where replacement should start * start Index of the colour where replacement should start
* num Number of colours to replace * 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); Common::MemoryReadStream pal(data, 3 * kNumColours);
pal.seek(start * 4); 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 * @brief Copies the current memory screen buffer to the real screen
*/ */
void Screen::copyToScreen() const { void Screen::copyToScreen() {
Common::List<Common::Rect> *dirtyRects = _surface->getDirtyRects(); const Common::List<Common::Rect> *dirtyRects = _surface->getDirtyRects();
Common::List<Common::Rect>::iterator it; Common::List<Common::Rect>::const_iterator it;
// If a full update is needed, update the whole screen // If a full update is needed, update the whole screen
if (_surface->needsFullUpdate()) { if (_surface->needsFullUpdate()) {
@ -119,7 +119,7 @@ void Screen::copyToScreen() const {
* *
* Clears the screen and marks the whole screen dirty. * Clears the screen and marks the whole screen dirty.
*/ */
void Screen::clearScreen() const { void Screen::clearScreen() {
byte *ptr = (byte *)_surface->getBasePtr(0, 0); byte *ptr = (byte *)_surface->getBasePtr(0, 0);
_surface->markDirty(); _surface->markDirty();
@ -133,7 +133,7 @@ void Screen::clearScreen() const {
* *
* Fills the screen with the specified colour and marks the whole screen dirty. * 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->fill(colour);
_surface->markDirty(); _surface->markDirty();
} }

View file

@ -47,11 +47,11 @@ public:
~Screen(); ~Screen();
void setPaletteEmpty(unsigned int numEntries = kNumColours); 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; byte *getPalette() const;
void copyToScreen() const; void copyToScreen();
void clearScreen() const; void clearScreen();
void fillScreen(uint8 colour) const; void fillScreen(uint8 colour);
Surface *getSurface(); Surface *getSurface();
void drawRect(Common::Rect &r, uint8 colour); void drawRect(Common::Rect &r, uint8 colour);

View file

@ -151,65 +151,65 @@ enum mathExpressionObject {
/* GPL operators */ /* GPL operators */
int Script::operAnd(int op1, int op2) { int Script::operAnd(int op1, int op2) const {
return op1 & op2; return op1 & op2;
} }
int Script::operOr(int op1, int op2) { int Script::operOr(int op1, int op2) const {
return op1 | op2; return op1 | op2;
} }
int Script::operXor(int op1, int op2) { int Script::operXor(int op1, int op2) const {
return op1 ^ op2; return op1 ^ op2;
} }
int Script::operEqual(int op1, int op2) { int Script::operEqual(int op1, int op2) const {
return op1 == op2; return op1 == op2;
} }
int Script::operNotEqual(int op1, int op2) { int Script::operNotEqual(int op1, int op2) const {
return op1 != op2; return op1 != op2;
} }
int Script::operLess(int op1, int op2) { int Script::operLess(int op1, int op2) const {
return op1 < op2; return op1 < op2;
} }
int Script::operGreater(int op1, int op2) { int Script::operGreater(int op1, int op2) const {
return op1 > op2; return op1 > op2;
} }
int Script::operGreaterOrEqual(int op1, int op2) { int Script::operGreaterOrEqual(int op1, int op2) const {
return op1 >= op2; return op1 >= op2;
} }
int Script::operLessOrEqual(int op1, int op2) { int Script::operLessOrEqual(int op1, int op2) const {
return op1 <= op2; return op1 <= op2;
} }
int Script::operMul(int op1, int op2) { int Script::operMul(int op1, int op2) const {
return op1 * op2; return op1 * op2;
} }
int Script::operAdd(int op1, int op2) { int Script::operAdd(int op1, int op2) const {
return op1 + op2; return op1 + op2;
} }
int Script::operSub(int op1, int op2) { int Script::operSub(int op1, int op2) const {
return op1 - op2; return op1 - op2;
} }
int Script::operDiv(int op1, int op2) { int Script::operDiv(int op1, int op2) const {
return op1 / op2; return op1 / op2;
} }
int Script::operMod(int op1, int op2) { int Script::operMod(int op1, int op2) const {
return op1 % op2; return op1 % op2;
} }
/* GPL functions */ /* 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 // 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]) // (RandomSource::getRandomNumber returns a number in the range [0..n])
@ -218,58 +218,58 @@ int Script::funcRandom(int n) {
return _vm->_rnd.getRandomNumber(n); return _vm->_rnd.getRandomNumber(n);
} }
int Script::funcAtBegin(int yesno) { int Script::funcAtBegin(int yesno) const {
return _vm->_game->isDialogueBegin() == (bool)yesno; return _vm->_game->isDialogueBegin() == (bool)yesno;
} }
int Script::funcLastBlock(int blockID) { int Script::funcLastBlock(int blockID) const {
blockID -= 1; blockID -= 1;
return _vm->_game->getDialogueLastBlock() == blockID; return _vm->_game->getDialogueLastBlock() == blockID;
} }
int Script::funcBlockVar(int blockID) { int Script::funcBlockVar(int blockID) const {
blockID -= 1; blockID -= 1;
const int currentOffset = _vm->_game->getCurrentDialogueOffset(); const int currentOffset = _vm->_game->getCurrentDialogueOffset();
return _vm->_game->getDialogueVar(currentOffset + blockID); return _vm->_game->getDialogueVar(currentOffset + blockID);
} }
int Script::funcHasBeen(int blockID) { int Script::funcHasBeen(int blockID) const {
blockID -= 1; blockID -= 1;
const int currentOffset = _vm->_game->getCurrentDialogueOffset(); const int currentOffset = _vm->_game->getCurrentDialogueOffset();
return _vm->_game->getDialogueVar(currentOffset + blockID) > 0; return _vm->_game->getDialogueVar(currentOffset + blockID) > 0;
} }
int Script::funcMaxLine(int lines) { int Script::funcMaxLine(int lines) const {
return _vm->_game->getDialogueLinesNum() < lines; return _vm->_game->getDialogueLinesNum() < lines;
} }
int Script::funcNot(int n) { int Script::funcNot(int n) const {
return !n; return !n;
} }
int Script::funcIsIcoOn(int itemID) { int Script::funcIsIcoOn(int itemID) const {
itemID -= 1; itemID -= 1;
return _vm->_game->getItemStatus(itemID) == 1; return _vm->_game->getItemStatus(itemID) == 1;
} }
int Script::funcIcoStat(int itemID) { int Script::funcIcoStat(int itemID) const {
itemID -= 1; itemID -= 1;
int status = _vm->_game->getItemStatus(itemID); int status = _vm->_game->getItemStatus(itemID);
return (status == 1) ? 1 : 2; return (status == 1) ? 1 : 2;
} }
int Script::funcIsIcoAct(int itemID) { int Script::funcIsIcoAct(int itemID) const {
itemID -= 1; itemID -= 1;
return _vm->_game->getCurrentItem() == itemID; 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 // 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 // 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(); return _vm->_game->getCurrentItem();
} }
int Script::funcIsObjOn(int objID) { int Script::funcIsObjOn(int objID) const {
objID -= 1; objID -= 1;
GameObject *obj = _vm->_game->getObject(objID); GameObject *obj = _vm->_game->getObject(objID);
@ -287,7 +287,7 @@ int Script::funcIsObjOn(int objID) {
return obj->_visible; return obj->_visible;
} }
int Script::funcIsObjOff(int objID) { int Script::funcIsObjOff(int objID) const {
objID -= 1; objID -= 1;
GameObject *obj = _vm->_game->getObject(objID); GameObject *obj = _vm->_game->getObject(objID);
@ -297,7 +297,7 @@ int Script::funcIsObjOff(int objID) {
return !obj->_visible && obj->_location != -1; return !obj->_visible && obj->_location != -1;
} }
int Script::funcObjStat(int objID) { int Script::funcObjStat(int objID) const {
objID -= 1; objID -= 1;
GameObject *obj = _vm->_game->getObject(objID); 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; objID -= 1;
GameObject *obj = _vm->_game->getObject(objID); GameObject *obj = _vm->_game->getObject(objID);
@ -322,7 +322,7 @@ int Script::funcIsObjAway(int objID) {
return !obj->_visible && obj->_location == -1; return !obj->_visible && obj->_location == -1;
} }
int Script::funcActPhase(int objID) { int Script::funcActPhase(int objID) const {
objID -= 1; objID -= 1;
@ -673,7 +673,7 @@ void Script::talk(Common::Queue<int> &params) {
Text *speechFrame = reinterpret_cast<Text *>(speechAnim->getFrame()); Text *speechFrame = reinterpret_cast<Text *>(speechAnim->getFrame());
// Fetch person info // Fetch person info
Person *person = _vm->_game->getPerson(personID); const Person *person = _vm->_game->getPerson(personID);
// Set the string and text colour // Set the string and text colour
surface->markDirtyRect(speechFrame->getRect(true)); surface->markDirtyRect(speechFrame->getRect(true));
@ -799,7 +799,7 @@ void Script::endCurrentProgram() {
* @param reader Stream reader set to the beginning of the expression * @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; Common::Stack<int> stk;
mathExpressionObject obj; mathExpressionObject obj;
GPL2Operator oper; 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. * 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 // Initialize program reader
Common::MemoryReadStream reader(program._bytecode, program._length); 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 * @return NULL if command is not found. Otherwise, a pointer to a GPL2Command
* struct representing the command. * 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; unsigned int i = 0;
while (1) { while (1) {

View file

@ -43,8 +43,8 @@ enum {
}; };
typedef void (Script::* GPLHandler)(Common::Queue<int> &); typedef void (Script::* GPLHandler)(Common::Queue<int> &);
typedef int (Script::* GPLOperatorHandler)(int, int); typedef int (Script::* GPLOperatorHandler)(int, int) const;
typedef int (Script::* GPLFunctionHandler)(int); typedef int (Script::* GPLFunctionHandler)(int) const;
/** /**
* Represents a single command in the GPL scripting language bytecode. * Represents a single command in the GPL scripting language bytecode.
@ -89,7 +89,7 @@ public:
Script(DraciEngine *vm) : _vm(vm), _jump(0) { setupCommandList(); }; Script(DraciEngine *vm) : _vm(vm), _jump(0) { setupCommandList(); };
int run(GPL2Program program, uint16 offset); int run(GPL2Program program, uint16 offset);
bool testExpression(GPL2Program, uint16 offset); bool testExpression(GPL2Program, uint16 offset) const;
void endCurrentProgram(); void endCurrentProgram();
private: private:
@ -132,41 +132,41 @@ private:
void blackPalette(Common::Queue<int> &params); void blackPalette(Common::Queue<int> &params);
void loadPalette(Common::Queue<int> &params); void loadPalette(Common::Queue<int> &params);
int operAnd(int op1, int op2); int operAnd(int op1, int op2) const;
int operOr(int op1, int op2); int operOr(int op1, int op2) const;
int operXor(int op1, int op2); int operXor(int op1, int op2) const;
int operSub(int op1, int op2); int operSub(int op1, int op2) const;
int operAdd(int op1, int op2); int operAdd(int op1, int op2) const;
int operDiv(int op1, int op2); int operDiv(int op1, int op2) const;
int operMul(int op1, int op2); int operMul(int op1, int op2) const;
int operEqual(int op1, int op2); int operEqual(int op1, int op2) const;
int operNotEqual(int op1, int op2); int operNotEqual(int op1, int op2) const;
int operGreater(int op1, int op2); int operGreater(int op1, int op2) const;
int operLess(int op1, int op2); int operLess(int op1, int op2) const;
int operGreaterOrEqual(int op1, int op2); int operGreaterOrEqual(int op1, int op2) const;
int operLessOrEqual(int op1, int op2); int operLessOrEqual(int op1, int op2) const;
int operMod(int op1, int op2); int operMod(int op1, int op2) const;
int funcRandom(int n); int funcRandom(int n) const;
int funcNot(int n); int funcNot(int n) const;
int funcIsIcoOn(int iconID); int funcIsIcoOn(int iconID) const;
int funcIcoStat(int iconID); int funcIcoStat(int iconID) const;
int funcActIco(int iconID); int funcActIco(int iconID) const;
int funcIsIcoAct(int iconID); int funcIsIcoAct(int iconID) const;
int funcIsObjOn(int objID); int funcIsObjOn(int objID) const;
int funcIsObjOff(int objID); int funcIsObjOff(int objID) const;
int funcIsObjAway(int objID); int funcIsObjAway(int objID) const;
int funcActPhase(int objID); int funcActPhase(int objID) const;
int funcObjStat(int objID); int funcObjStat(int objID) const;
int funcLastBlock(int blockID); int funcLastBlock(int blockID) const;
int funcAtBegin(int yesno); int funcAtBegin(int yesno) const;
int funcBlockVar(int blockID); int funcBlockVar(int blockID) const;
int funcHasBeen(int blockID); int funcHasBeen(int blockID) const;
int funcMaxLine(int lines); int funcMaxLine(int lines) const;
void setupCommandList(); void setupCommandList();
const GPL2Command *findCommand(byte num, byte subnum); const GPL2Command *findCommand(byte num, byte subnum) const;
int handleMathExpression(Common::MemoryReadStream &reader); int handleMathExpression(Common::MemoryReadStream &reader) const;
DraciEngine *_vm; DraciEngine *_vm;
}; };

View file

@ -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. * 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) { bool columnwise) : _data(NULL) {
_width = width; _width = width;
@ -72,21 +72,22 @@ Sprite::Sprite(byte *raw_data, uint16 width, uint16 height, int x, int y,
_mirror = false; _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 the sprite is stored column-wise, transform it to row-wise
if (columnwise) { if (columnwise) {
transformToRows(_data, width, height); transformToRows(data, width, height);
} }
_data = data;
} }
/** /**
* Constructor for loading sprites from a sprite-formatted buffer, one byte per * Constructor for loading sprites from a sprite-formatted buffer, one byte per
* pixel. * 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) { : _data(NULL) {
_x = x; _x = x;
@ -104,14 +105,15 @@ Sprite::Sprite(byte *sprite_data, uint16 length, int x, int y, bool columnwise)
_scaledWidth = _width; _scaledWidth = _width;
_scaledHeight = _height; _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 the sprite is stored column-wise, transform it to row-wise
if (columnwise) { if (columnwise) {
transformToRows(_data, _width, _height); transformToRows(data, _width, _height);
} }
_data = data;
} }
Sprite::~Sprite() { Sprite::~Sprite() {
@ -171,7 +173,7 @@ void Sprite::drawScaled(Surface *surface, bool markDirty) const {
// Get pointers to source and destination buffers // Get pointers to source and destination buffers
byte *dst = (byte *)surface->getBasePtr(clippedDestRect.left, clippedDestRect.top); byte *dst = (byte *)surface->getBasePtr(clippedDestRect.left, clippedDestRect.top);
byte *src = _data; const byte *src = _data;
const int transparent = surface->getTransparentColour(); const int transparent = surface->getTransparentColour();
@ -262,7 +264,7 @@ void Sprite::draw(Surface *surface, bool markDirty) const {
// Get pointers to source and destination buffers // Get pointers to source and destination buffers
byte *dst = (byte *)surface->getBasePtr(clippedDestRect.left, clippedDestRect.top); byte *dst = (byte *)surface->getBasePtr(clippedDestRect.left, clippedDestRect.top);
byte *src = _data; const byte *src = _data;
const int transparent = surface->getTransparentColour(); const int transparent = surface->getTransparentColour();
@ -350,7 +352,7 @@ void Text::setSpacing(uint spacing) {
_spacing = spacing; _spacing = spacing;
} }
uint Text::getLength() { uint Text::getLength() const {
return _length; return _length;
} }

View file

@ -94,9 +94,9 @@ protected:
class Sprite : public Drawable { class Sprite : public Drawable {
public: 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(); ~Sprite();
@ -114,7 +114,7 @@ public:
DrawableType getType() const { return kDrawableSprite; } DrawableType getType() const { return kDrawableSprite; }
private: 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; bool _mirror;
}; };
@ -130,7 +130,7 @@ public:
void setSpacing(uint spacing); void setSpacing(uint spacing);
void setFont(Font *font); void setFont(Font *font);
uint getLength(); uint getLength() const;
void draw(Surface *surface, bool markDirty = true) const; void draw(Surface *surface, bool markDirty = true) const;

View file

@ -91,7 +91,7 @@ void Surface::markClean() {
/** /**
* @brief Checks whether the surface needs a full update * @brief Checks whether the surface needs a full update
*/ */
bool Surface::needsFullUpdate() { bool Surface::needsFullUpdate() const {
return _fullUpdate; return _fullUpdate;
} }
@ -99,14 +99,14 @@ bool Surface::needsFullUpdate() {
* @brief Fetches the surface's dirty rectangles * @brief Fetches the surface's dirty rectangles
* @return A pointer a list of 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; return &_dirtyRects;
} }
/** /**
* @brief Returns the current transparent colour of the surface * @brief Returns the current transparent colour of the surface
*/ */
uint Surface::getTransparentColour() { uint Surface::getTransparentColour() const {
return _transparentColour; return _transparentColour;
} }
@ -134,7 +134,7 @@ void Surface::fill(uint colour) {
* *
* @return The centered x coordinate * @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; int newX = x - width / 2;
@ -155,7 +155,7 @@ uint Surface::centerOnX(uint x, uint width) {
* *
* @return The centered y coordinate * @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; 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. * @brief Returns a Common::Rect corresponding to the surface.
*/ */
Common::Rect Surface::getRect() { Common::Rect Surface::getRect() const {
return Common::Rect(w, h); return Common::Rect(w, h);
} }

View file

@ -37,17 +37,17 @@ public:
~Surface(); ~Surface();
void markDirtyRect(Common::Rect r); void markDirtyRect(Common::Rect r);
Common::List<Common::Rect> *getDirtyRects(); const Common::List<Common::Rect> *getDirtyRects() const;
void clearDirtyRects(); void clearDirtyRects();
void markDirty(); void markDirty();
void markClean(); void markClean();
bool needsFullUpdate(); bool needsFullUpdate() const;
uint getTransparentColour(); uint getTransparentColour() const;
void setTransparentColour(uint colour); void setTransparentColour(uint colour);
void fill(uint colour); void fill(uint colour);
uint centerOnY(uint y, uint height); uint centerOnY(uint y, uint height) const;
uint centerOnX(uint x, uint width); uint centerOnX(uint x, uint width) const;
Common::Rect getRect(); Common::Rect getRect() const;
private: private:
/** The current transparent colour of the surface. See getTransparentColour() and /** The current transparent colour of the surface. See getTransparentColour() and