[Scummvm-cvs-logs] CVS: scummvm/saga puzzle.cpp,NONE,1.1 puzzle.h,NONE,1.1 actor.cpp,1.132,1.133 actor.h,1.72,1.73 interface.cpp,1.92,1.93 module.mk,1.24,1.25 render.cpp,1.58,1.59 resnames.h,1.26,1.27 saga.cpp,1.110,1.111 saga.h,1.91,1.92 scene.cpp,1.104,1.105 scene.h,1.54,1.55 script.h,1.82,1.83 sfuncs.cpp,1.116,1.117

Eugene Sandulenko sev at users.sourceforge.net
Sun May 22 19:25:38 CEST 2005


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22190

Modified Files:
	actor.cpp actor.h interface.cpp module.mk render.cpp 
	resnames.h saga.cpp saga.h scene.cpp scene.h script.h 
	sfuncs.cpp 
Added Files:
	puzzle.cpp puzzle.h 
Log Message:
Plug in Puzzle. Now it consists mainly of stubs but neverthless lets skip
the Puzzle and continue game pretending like you completed the Puzzle.


--- NEW FILE: puzzle.cpp ---
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2005 The ScummVM project
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header: /cvsroot/scummvm/scummvm/saga/puzzle.cpp,v 1.1 2005/05/23 02:23:33 sev Exp $
 *
 */

#include "saga/saga.h"

#include "saga/interface.h"
#include "saga/scene.h"
#include "saga/puzzle.h"
#include "saga/resnames.h"

#include "common/timer.h"

namespace Saga {

Puzzle::Puzzle(SagaEngine *vm) : _vm(vm), _solved(false), _active(false) {
}

void Puzzle::execute(void) {
	_active = true;
	Common::g_timer->installTimerProc(&hintTimerCallback, ticksToMSec(30), this);

	_solved = true; // Cheat
	exitPuzzle();
}

void Puzzle::exitPuzzle(void) {
	_active = false;

	Common::g_timer->removeTimerProc(&hintTimerCallback);

	_vm->_scene->changeScene(ITE_SCENE_LODGE, 0, kTransitionNoFade);
	_vm->_interface->setMode(kPanelMain);
}


void Puzzle::hintTimerCallback(void *refCon) {                                   
        ((Puzzle *)refCon)->hintTimer();                                         
}                                                                               

void Puzzle::hintTimer(void) {
}

void Puzzle::handleReply(int reply) {
}

void Puzzle::movePiece(Point mousePt) {
}


} // End of namespace Saga

--- NEW FILE: puzzle.h ---
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2005 The ScummVM project
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header: /cvsroot/scummvm/scummvm/saga/puzzle.h,v 1.1 2005/05/23 02:23:33 sev Exp $
 *
 */

#ifndef SAGA_PUZZLE_H_
#define SAGA_PUZZLE_H_

namespace Saga {

class Puzzle {
private:
	SagaEngine *_vm;

	bool _solved;
	bool _active;

public:
	Puzzle(SagaEngine *vm);

	void execute(void);
	void exitPuzzle(void);

	bool isSolved(void) { return _solved; }
	bool isActive(void) { return _active; }

	void handleReply(int reply);

	void movePiece(Point mousePt);

private:
	static void hintTimerCallback(void *refCon);

	void hintTimer(void);
};

} // End of namespace Saga

#endif

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -d -r1.132 -r1.133
--- actor.cpp	22 May 2005 11:59:15 -0000	1.132
+++ actor.cpp	23 May 2005 02:23:32 -0000	1.133
@@ -1298,13 +1298,19 @@
 		}
 	}
 
-// draw speeches
+	drawSpeech();
+}
+
+void Actor::drawSpeech(void) {
 	if (isSpeaking() && _activeSpeech.playing && !_vm->_script->_skipSpeeches) {
 		int i;
 		int textDrawFlags;
 		char oneChar[2];
 		oneChar[1] = 0;
 		const char *outputString;
+		SURFACE *back_buf;
+
+		back_buf = _vm->_gfx->getBackBuffer();
 
 		if (_activeSpeech.speechFlags & kSpeakSlow) {
 			outputString = oneChar;

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.h,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- actor.h	22 May 2005 01:20:46 -0000	1.72
+++ actor.h	23 May 2005 02:23:32 -0000	1.73
@@ -471,6 +471,8 @@
 	void drawActors();
 	void updateActorsScene(int actorsEntrance);			// calls from scene loading to update Actors info
 
+	void drawSpeech();
+
 	void drawPathTest();
 
 	uint16 hitTest(const Point &testPoint, bool skipProtagonist);

Index: interface.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.cpp,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -d -r1.92 -r1.93
--- interface.cpp	22 May 2005 13:49:45 -0000	1.92
+++ interface.cpp	23 May 2005 02:23:32 -0000	1.93
@@ -30,6 +30,7 @@
 #include "saga/font.h"
 #include "saga/objectmap.h"
 #include "saga/itedata.h"
+#include "saga/puzzle.h"
 #include "saga/rscfile_mod.h"
 #include "saga/scene.h"
 #include "saga/script.h"
@@ -302,7 +303,8 @@
 		switch (keyCode) {
 		case 'x':
 			setMode(kPanelMain);
-			// FIXME: puzzle
+			if (_vm->_puzzle->isActive())
+				_vm->_puzzle->exitPuzzle();
 			break;
 
 		case 'u':
@@ -1124,7 +1126,8 @@
 
 	_vm->_script->finishDialog(ct->replyId, ct->replyFlags, ct->replyBit);
 
-	// FIXME: TODO: Puzzle
+	if (_vm->_puzzle->isActive())
+		_vm->_puzzle->handleReply(ct->replyId);
 
 	_conversePos = -1;
 }

Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/module.mk,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- module.mk	21 Apr 2005 01:30:07 -0000	1.24
+++ module.mk	23 May 2005 02:23:32 -0000	1.25
@@ -16,6 +16,7 @@
 	saga/ite_introproc.o \
 	saga/itedata.o \
 	saga/objectmap.o \
+	saga/puzzle.o \
 	saga/palanim.o \
 	saga/render.o \
 	saga/rscfile.o \

Index: render.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/render.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- render.cpp	22 May 2005 11:59:21 -0000	1.58
+++ render.cpp	23 May 2005 02:23:33 -0000	1.59
@@ -24,16 +24,15 @@
 // Main rendering loop
 #include "saga/saga.h"
 
-#include "saga/gfx.h"
 #include "saga/actor.h"
 #include "saga/font.h"
+#include "saga/gfx.h"
 #include "saga/interface.h"
-#include "saga/scene.h"
-#include "saga/text.h"
-
 #include "saga/objectmap.h"
-
+#include "saga/puzzle.h"
 #include "saga/render.h"
+#include "saga/scene.h"
+#include "saga/text.h"
 
 #include "common/timer.h"
 #include "common/system.h"
@@ -119,6 +118,12 @@
 		if (_vm->_interface->getMode() != kPanelFade) {
 			// Draw queued actors
 			_vm->_actor->drawActors();
+
+			if (_vm->_puzzle->isActive()) {
+				_vm->_puzzle->movePiece(mouse_pt);
+				_vm->_actor->drawSpeech();
+			}
+
 			if (getFlags() & RF_OBJECTMAP_TEST) {
 				if (_vm->_scene->_objectMap)
 					_vm->_scene->_objectMap->draw(backbuf_surface, mouse_pt, kITEColorBrightWhite, kITEColorBlack);

Index: resnames.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/resnames.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- resnames.h	22 May 2005 11:59:21 -0000	1.26
+++ resnames.h	23 May 2005 02:23:33 -0000	1.27
@@ -45,6 +45,8 @@
 
 // SCENES
 #define ITE_SCENE_INV -1
+#define ITE_SCENE_PUZZLE 26
+#define ITE_SCENE_LODGE 21
 
 #define ITE_DEFAULT_SCENE 32
 #define IHNM_DEFAULT_SCENE 152

Index: saga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.cpp,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- saga.cpp	18 May 2005 18:28:09 -0000	1.110
+++ saga.cpp	23 May 2005 02:23:33 -0000	1.111
@@ -44,6 +44,7 @@
 #include "saga/font.h"
 #include "saga/interface.h"
 #include "saga/isomap.h"
+#include "saga/puzzle.h"
 #include "saga/script.h"
 #include "saga/scene.h"
 #include "saga/sndres.h"
@@ -138,6 +139,7 @@
 	_render = NULL;
 	_music = NULL;
 	_sound = NULL;
+	_puzzle = NULL;
 
 
 	// The Linux version of Inherit the Earth puts all data files in an
@@ -170,6 +172,7 @@
 		_scene->endScene();
 	}
 
+	delete _puzzle;
 	delete _sndRes;
 	delete _events;
 	delete _font;
@@ -234,6 +237,7 @@
 	_palanim = new PalAnim(this);
 	_scene = new Scene(this);
 	_isoMap = new IsoMap(this);
+	_puzzle = new Puzzle(this);
 
 	if (!_scene->initialized()) {
 		warning("Couldn't initialize scene module");
@@ -245,7 +249,7 @@
 	_previousTicks = _system->getMillis();
 
 	// Initialize graphics
-	_gfx = new Gfx(_system, _vm->getDisplayWidth(), _vm->getDisplayHeight(), detector);
+	_gfx = new Gfx(_system, getDisplayWidth(), getDisplayHeight(), detector);
 
 	// Graphics driver should be initialized before console
 	_console = new Console(this);
@@ -319,10 +323,14 @@
 				msec = MAX_TIME_DELTA;
 			}
 
-			if (!_vm->_scene->isInDemo() && getGameType() == GType_ITE)
-				if (_vm->_interface->getMode() == kPanelMain ||
-						 _vm->_interface->getMode() == kPanelConverse ||
-						 _vm->_interface->getMode() == kPanelNull)
+			// Since Puzzle is actorless, we do it here
+			if (_puzzle->isActive())
+				_actor->handleSpeech(msec);
+
+			if (!_scene->isInDemo() && getGameType() == GType_ITE)
+				if (_interface->getMode() == kPanelMain ||
+						 _interface->getMode() == kPanelConverse ||
+						 _interface->getMode() == kPanelNull)
 					_actor->direct(msec);
 
 			_events->handleEvents(msec);
@@ -383,8 +391,8 @@
 		return _actor->_actorsStrings.getString(actor->nameIndex);
 		break;
 	case kGameObjectHitZone:
-		hitZone = _vm->_scene->_objectMap->getHitZone(objectIdToIndex(objectId));
-		return _vm->_scene->_sceneStrings.getString(hitZone->getNameIndex());
+		hitZone = _scene->_objectMap->getHitZone(objectIdToIndex(objectId));
+		return _scene->_sceneStrings.getString(hitZone->getNameIndex());
 	}
 	warning("SagaEngine::getObjectName name not found for 0x%X", objectId);
 	return NULL;
@@ -392,7 +400,7 @@
 
 const char *SagaEngine::getTextString(int textStringId) {
 	const char *string;
-	int lang = _vm->getFeatures() & GF_LANG_DE ? 1 : 0;
+	int lang = getFeatures() & GF_LANG_DE ? 1 : 0;
 
 	string = interfaceTextStrings[lang][textStringId];
 	if (!string)

Index: saga.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.h,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -d -r1.91 -r1.92
--- saga.h	22 May 2005 11:59:21 -0000	1.91
+++ saga.h	23 May 2005 02:23:33 -0000	1.92
@@ -55,6 +55,7 @@
 class Console;
 class Events;
 class PalAnim;
+class Puzzle;
 
 #define MIN_IMG_RLECODE    3
 #define MODEX_SCANLINE_LIMIT 200
@@ -482,6 +483,7 @@
 	Console *_console;
 	Events *_events;
 	PalAnim *_palanim;
+	Puzzle *_puzzle;
 
 
 	/** Random number generator */

Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.cpp,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- scene.cpp	22 May 2005 11:59:21 -0000	1.104
+++ scene.cpp	23 May 2005 02:23:33 -0000	1.105
@@ -32,6 +32,7 @@
 #include "saga/isomap.h"
 #include "saga/objectmap.h"
 #include "saga/palanim.h"
+#include "saga/puzzle.h"
 #include "saga/render.h"
 #include "saga/rscfile_mod.h"
 #include "saga/script.h"
@@ -620,9 +621,12 @@
 
 	// We probably don't want "followers" to go into scene -1 , 0. At the very
 	// least we don't want garbage to be drawn that early in the ITE intro.
-	if (_sceneNumber > 0)
+	if (_sceneNumber > 0 && _sceneNumber != ITE_SCENE_PUZZLE)
 		_vm->_actor->updateActorsScene(loadSceneParams->actorsEntrance);
 
+	if (_sceneNumber == ITE_SCENE_PUZZLE)
+		_vm->_puzzle->execute();
+
 	if (_sceneDescription.flags & kSceneFlagShowCursor)
 		_vm->_interface->activate();
 

Index: scene.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.h,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- scene.h	22 May 2005 11:59:21 -0000	1.54
+++ scene.h	23 May 2005 02:23:34 -0000	1.55
@@ -120,7 +120,7 @@
 
 	const SceneEntry * getEntry(int index) {
 		if ((index < 0) || (index >= entryListCount)) {
-			error("SceneEntryList::getEntry wrong index");
+			error("SceneEntryList::getEntry wrong index (%d)", index);
 		}
 		return &entryList[index];
 	}

Index: script.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script.h,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- script.h	22 May 2005 01:20:47 -0000	1.82
+++ script.h	23 May 2005 02:23:34 -0000	1.83
@@ -530,7 +530,7 @@
 	void SF_tossRif(SCRIPTFUNC_PARAMS);
 	void SF_showControls(SCRIPTFUNC_PARAMS);
 	void SF_showMap(SCRIPTFUNC_PARAMS);
-	void SF_puzzleWon(SCRIPTFUNC_PARAMS);
+	void sfPuzzleWon(SCRIPTFUNC_PARAMS);
 	void sfEnableEscape(SCRIPTFUNC_PARAMS);
 	void sfPlaySound(SCRIPTFUNC_PARAMS);
 	void SF_playLoopedSound(SCRIPTFUNC_PARAMS);

Index: sfuncs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sfuncs.cpp,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- sfuncs.cpp	22 May 2005 11:59:21 -0000	1.116
+++ sfuncs.cpp	23 May 2005 02:23:34 -0000	1.117
@@ -34,6 +34,7 @@
 #include "saga/interface.h"
 #include "saga/music.h"
 #include "saga/itedata.h"
+#include "saga/puzzle.h"
 #include "saga/render.h"
 #include "saga/sound.h"
 #include "saga/sndres.h"
@@ -118,7 +119,7 @@
 		OPCODE(SF_tossRif),
 		OPCODE(SF_showControls),
 		OPCODE(SF_showMap),
-		OPCODE(SF_puzzleWon),
+		OPCODE(sfPuzzleWon),
 		OPCODE(sfEnableEscape),
 		OPCODE(sfPlaySound),
 		OPCODE(SF_playLoopedSound),
@@ -1501,11 +1502,8 @@
 }
 
 // Script function #68 (0x44)
-void Script::SF_puzzleWon(SCRIPTFUNC_PARAMS) {
-	for (int i = 0; i < nArgs; i++)
-		thread->pop();
-
-	debug(0, "STUB: SF_puzzleWon(), %d args", nArgs);
+void Script::sfPuzzleWon(SCRIPTFUNC_PARAMS) {
+	thread->_returnValue = _vm->_puzzle->isSolved();
 }
 
 // Script function #69 (0x45)





More information about the Scummvm-git-logs mailing list