[Scummvm-cvs-logs] SF.net SVN: scummvm:[44331] scummvm/trunk/engines/draci

spalek at users.sourceforge.net spalek at users.sourceforge.net
Fri Sep 25 10:13:39 CEST 2009


Revision: 44331
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44331&view=rev
Author:   spalek
Date:     2009-09-25 08:13:39 +0000 (Fri, 25 Sep 2009)

Log Message:
-----------
Add const's to many interfaces of engines/draci/

Modified Paths:
--------------
    scummvm/trunk/engines/draci/animation.cpp
    scummvm/trunk/engines/draci/animation.h
    scummvm/trunk/engines/draci/game.cpp
    scummvm/trunk/engines/draci/game.h
    scummvm/trunk/engines/draci/mouse.cpp
    scummvm/trunk/engines/draci/mouse.h
    scummvm/trunk/engines/draci/screen.cpp
    scummvm/trunk/engines/draci/screen.h
    scummvm/trunk/engines/draci/script.cpp
    scummvm/trunk/engines/draci/script.h
    scummvm/trunk/engines/draci/sprite.cpp
    scummvm/trunk/engines/draci/sprite.h
    scummvm/trunk/engines/draci/surface.cpp
    scummvm/trunk/engines/draci/surface.h

Modified: scummvm/trunk/engines/draci/animation.cpp
===================================================================
--- scummvm/trunk/engines/draci/animation.cpp	2009-09-25 07:11:19 UTC (rev 44330)
+++ scummvm/trunk/engines/draci/animation.cpp	2009-09-25 08:13:39 UTC (rev 44331)
@@ -1,3 +1,4 @@
+
 /* ScummVM - Graphic Adventure Engine
  *
  * ScummVM is the legal property of its developers, whose names
@@ -48,7 +49,7 @@
 	deleteFrames();
 }
 
-bool Animation::isLooping() {
+bool Animation::isLooping() const {
 	return _looping;
 }
 
@@ -68,7 +69,7 @@
 		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 @@
 	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 @@
 	_currentFrame, _frames.size(), frame->getX(), frame->getY());
 }
 
-uint Animation::nextFrameNum() {
+uint Animation::nextFrameNum() const {
 
 	if (_paused) 
 		return _currentFrame;
@@ -157,7 +158,9 @@
 
 		// 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 @@
 	_id = id;
 }
 
-int Animation::getID() {
+int Animation::getID() const {
 	return _id;
 }
 
@@ -183,19 +186,19 @@
 	_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 @@
 	_playing = playing;
 }
 
-bool Animation::isPaused() {
+bool Animation::isPaused() const {
 	return _paused;
 }
 
@@ -224,11 +227,11 @@
 	_scaleY = scaleY;
 }
 
-double Animation::getScaleX() {
+double Animation::getScaleX() const {
 	return _scaleX;
 }
 
-double Animation::getScaleY() {
+double Animation::getScaleY() const {
 	return _scaleY;
 }
 
@@ -236,7 +239,7 @@
 	_frames.push_back(frame);	
 }
 
-int Animation::getIndex() {
+int Animation::getIndex() const {
 	return _index;
 }
 
@@ -259,11 +262,11 @@
 	}
 }
 
-uint Animation::getFrameCount() {
+uint Animation::getFrameCount() const {
 	return _frames.size();
 }
 
-uint Animation::currentFrameNum() {
+uint Animation::currentFrameNum() const {
 	return _currentFrame;
 }
 
@@ -614,7 +617,9 @@
 
 		// 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)) {
 

Modified: scummvm/trunk/engines/draci/animation.h
===================================================================
--- scummvm/trunk/engines/draci/animation.h	2009-09-25 07:11:19 UTC (rev 44330)
+++ scummvm/trunk/engines/draci/animation.h	2009-09-25 08:13:39 UTC (rev 44331)
@@ -65,11 +65,11 @@
 	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 @@
 	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 @@
 
 private:
 	
-	uint nextFrameNum();
+	uint nextFrameNum() const;
 
 	/** Internal animation ID 
 	  *	(as specified in the data files and the bytecode)

Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp	2009-09-25 07:11:19 UTC (rev 44330)
+++ scummvm/trunk/engines/draci/game.cpp	2009-09-25 08:13:39 UTC (rev 44331)
@@ -660,7 +660,7 @@
 	}
 }	
 
-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 @@
 	_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 @@
 	_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 @@
 	_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 @@
 	return _objects + objNum;
 }
 
-uint Game::getNumObjects() {
+uint Game::getNumObjects() const {
 	return _info._numObjects;
 }
 
@@ -1427,7 +1427,7 @@
 	setExitLoop(false);
 }
 
-int Game::getRoomNum() {
+int Game::getRoomNum() const {
 	return _currentRoom._roomNum;
 }
 
@@ -1435,7 +1435,7 @@
 	_newRoom = room;
 }
 
-int Game::getGateNum() {
+int Game::getGateNum() const {
 	return _currentGate;
 }
 
@@ -1451,15 +1451,15 @@
 	_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 @@
 	_variables[numVar] = value;
 }
 
-int Game::getItemStatus(int itemID) {
+int Game::getItemStatus(int itemID) const {
 	return _itemStatus[itemID];
 }
 
@@ -1475,7 +1475,7 @@
 	_itemStatus[itemID] = status;	
 }
 
-int Game::getCurrentItem() {
+int Game::getCurrentItem() const {
 	return _currentItem;
 }
 
@@ -1483,7 +1483,7 @@
 	_currentItem = itemID;
 }
 
-Person *Game::getPerson(int personID) {
+const Person *Game::getPerson(int personID) const {
 	return &_persons[personID];
 }
 
@@ -1491,7 +1491,7 @@
 	_speechTick = tick;
 }
 
-int Game::getEscRoom() {
+int Game::getEscRoom() const {
 	return _currentRoom._escRoom;
 }
 
@@ -1499,7 +1499,7 @@
 	_scheduledPalette = paletteID;
 }
 
-int Game::getScheduledPalette() {
+int Game::getScheduledPalette() const {
 	return _scheduledPalette;
 }
 
@@ -1509,7 +1509,7 @@
  * all animations that have an index greater than the one marked.
  */
 
-int Game::getMarkedAnimationIndex() {
+int Game::getMarkedAnimationIndex() const {
 	return _markedAnimationIndex;
 }
 
@@ -1530,7 +1530,7 @@
 }
 
 
-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 @@
  *	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)) {

Modified: scummvm/trunk/engines/draci/game.h
===================================================================
--- scummvm/trunk/engines/draci/game.h	2009-09-25 07:11:19 UTC (rev 44330)
+++ scummvm/trunk/engines/draci/game.h	2009-09-25 08:13:39 UTC (rev 44331)
@@ -120,8 +120,8 @@
 		_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 @@
 	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 @@
 	}
 
 	// HACK: same as above
-	int prevRoomNum() { 
+	int prevRoomNum() const { 
 		int n = _currentRoom._roomNum;
 		n = n > 0 ? n-1 : n;
 
@@ -268,43 +268,43 @@
 	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 @@
 	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;

Modified: scummvm/trunk/engines/draci/mouse.cpp
===================================================================
--- scummvm/trunk/engines/draci/mouse.cpp	2009-09-25 07:11:19 UTC (rev 44330)
+++ scummvm/trunk/engines/draci/mouse.cpp	2009-09-25 08:13:39 UTC (rev 44331)
@@ -80,7 +80,7 @@
 	CursorMan.showMouse(false);
 }
 
-bool Mouse::isCursorOn() {
+bool Mouse::isCursorOn() const {
 	return CursorMan.isVisible();
 }
 

Modified: scummvm/trunk/engines/draci/mouse.h
===================================================================
--- scummvm/trunk/engines/draci/mouse.h	2009-09-25 07:11:19 UTC (rev 44330)
+++ scummvm/trunk/engines/draci/mouse.h	2009-09-25 08:13:39 UTC (rev 44331)
@@ -48,18 +48,18 @@
 	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;

Modified: scummvm/trunk/engines/draci/screen.cpp
===================================================================
--- scummvm/trunk/engines/draci/screen.cpp	2009-09-25 07:11:19 UTC (rev 44330)
+++ scummvm/trunk/engines/draci/screen.cpp	2009-09-25 08:13:39 UTC (rev 44331)
@@ -60,7 +60,7 @@
  *		  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 @@
 /**
  * @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 @@
  *
  * 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 @@
  *
  * 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();
 }

Modified: scummvm/trunk/engines/draci/screen.h
===================================================================
--- scummvm/trunk/engines/draci/screen.h	2009-09-25 07:11:19 UTC (rev 44330)
+++ scummvm/trunk/engines/draci/screen.h	2009-09-25 08:13:39 UTC (rev 44331)
@@ -47,11 +47,11 @@
 	~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);
 

Modified: scummvm/trunk/engines/draci/script.cpp
===================================================================
--- scummvm/trunk/engines/draci/script.cpp	2009-09-25 07:11:19 UTC (rev 44330)
+++ scummvm/trunk/engines/draci/script.cpp	2009-09-25 08:13:39 UTC (rev 44331)
@@ -151,65 +151,65 @@
 
 /* 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 @@
 	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 @@
 	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 @@
 	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 @@
 	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::funcIsObjAway(int objID) {
+int Script::funcIsObjAway(int objID) const {
 	objID -= 1;
 
 	GameObject *obj = _vm->_game->getObject(objID);
@@ -322,7 +322,7 @@
 	return !obj->_visible && obj->_location == -1;
 }
 
-int Script::funcActPhase(int objID) {
+int Script::funcActPhase(int objID) const {
 
 	objID -= 1;	
 
@@ -673,7 +673,7 @@
 	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 @@
  * @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 @@
  *
  * 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 @@
  * @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) {
 

Modified: scummvm/trunk/engines/draci/script.h
===================================================================
--- scummvm/trunk/engines/draci/script.h	2009-09-25 07:11:19 UTC (rev 44330)
+++ scummvm/trunk/engines/draci/script.h	2009-09-25 08:13:39 UTC (rev 44331)
@@ -43,8 +43,8 @@
 };
 
 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 @@
 	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 @@
 	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 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);
-	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 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;
 };

Modified: scummvm/trunk/engines/draci/sprite.cpp
===================================================================
--- scummvm/trunk/engines/draci/sprite.cpp	2009-09-25 07:11:19 UTC (rev 44330)
+++ scummvm/trunk/engines/draci/sprite.cpp	2009-09-25 08:13:39 UTC (rev 44331)
@@ -56,7 +56,7 @@
 /**
  *  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 @@
 
 	_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 @@
 	_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 @@
 
 	// 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 @@
 
 	// 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 @@
 	_spacing = spacing;
 }
 
-uint Text::getLength() {
+uint Text::getLength() const {
 	return _length;
 }
 

Modified: scummvm/trunk/engines/draci/sprite.h
===================================================================
--- scummvm/trunk/engines/draci/sprite.h	2009-09-25 07:11:19 UTC (rev 44330)
+++ scummvm/trunk/engines/draci/sprite.h	2009-09-25 08:13:39 UTC (rev 44331)
@@ -94,9 +94,9 @@
 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 @@
 	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 @@
 	void setSpacing(uint spacing);
 	void setFont(Font *font);
 
-	uint getLength();
+	uint getLength() const;
 
 	void draw(Surface *surface, bool markDirty = true) const;
 

Modified: scummvm/trunk/engines/draci/surface.cpp
===================================================================
--- scummvm/trunk/engines/draci/surface.cpp	2009-09-25 07:11:19 UTC (rev 44330)
+++ scummvm/trunk/engines/draci/surface.cpp	2009-09-25 08:13:39 UTC (rev 44331)
@@ -91,7 +91,7 @@
 /**
  * @brief Checks whether the surface needs a full update
  */
-bool Surface::needsFullUpdate() {
+bool Surface::needsFullUpdate() const {
 	return _fullUpdate;
 }
 
@@ -99,14 +99,14 @@
  * @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 @@
  *
  * @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 @@
  *
  * @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 @@
  * @brief Returns a Common::Rect corresponding to the surface.
  */
 
-Common::Rect Surface::getRect() {
+Common::Rect Surface::getRect() const {
 	return Common::Rect(w, h);
 }
 

Modified: scummvm/trunk/engines/draci/surface.h
===================================================================
--- scummvm/trunk/engines/draci/surface.h	2009-09-25 07:11:19 UTC (rev 44330)
+++ scummvm/trunk/engines/draci/surface.h	2009-09-25 08:13:39 UTC (rev 44331)
@@ -37,17 +37,17 @@
 	~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


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list