[Scummvm-cvs-logs] CVS: scummvm/saga saveload.cpp,NONE,1.1 actor.cpp,1.117,1.118 actor.h,1.63,1.64 input.cpp,1.38,1.39 interface.cpp,1.78,1.79 interface.h,1.42,1.43 isomap.h,1.19,1.20 module.mk,1.23,1.24 saga.h,1.85,1.86 scene.cpp,1.96,1.97 scene.h,1.49,1.50 script.h,1.76,1.77 sfuncs.cpp,1.102,1.103
Eugene Sandulenko
sev at users.sourceforge.net
Wed Apr 20 18:30:32 CEST 2005
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.451,2.452 object.cpp,1.231,1.232 script.cpp,1.217,1.218 script_v2.cpp,2.274,2.275 scumm.cpp,1.451,1.452 scumm.h,1.596,1.597 verbs.cpp,1.130,1.131
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.344,1.345 scumm.cpp,1.452,1.453 scumm.h,1.597,1.598 vars.cpp,1.126,1.127
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv331
Modified Files:
actor.cpp actor.h input.cpp interface.cpp interface.h isomap.h
module.mk saga.h scene.cpp scene.h script.h sfuncs.cpp
Added Files:
saveload.cpp
Log Message:
Add not yet correctly working save/load. Use key F7 for saving
and F8 for loading. Now works only within current scene and restores
to entrance #0 which is wrong.
--- NEW FILE: saveload.cpp ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2004-2005 The ScummVM project
*
* The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
*
* 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/saveload.cpp,v 1.1 2005/04/21 01:30:07 sev Exp $
*
*/
#include "stdafx.h"
#include "common/config-manager.h"
#include "common/savefile.h"
#include "common/system.h"
#include "common/file.h"
#include "saga/saga.h"
#include "saga/actor.h"
#include "saga/isomap.h"
#include "saga/resnames.h"
#include "saga/script.h"
#include "saga/interface.h"
#include "saga/scene.h"
namespace Saga {
void SagaEngine::save() {
File out;
out.open("ite.sav", File::kFileWriteMode);
out.writeSint16LE(_actor->_actorsCount);
out.writeSint16LE(_actor->_objsCount);
out.writeSint16LE(_script->_commonBufferSize);
out.writeSint16LE(_actor->getProtagState());
// Surrounding scene
out.writeSint32LE(_scene->getOutsetSceneNumber());
out.writeSint32LE(0);
// Inset scene
out.writeSint32LE(_scene->currentSceneNumber());
out.writeSint32LE(0);
uint16 i;
for (i = 0; i < _actor->_actorsCount; i++) {
ActorData *a = _actor->_actors[i];
out.writeSint32LE(a->sceneNumber);
out.writeSint16LE(a->location.x);
out.writeSint16LE(a->location.y);
out.writeSint16LE(a->location.z);
out.writeSint16LE(a->finalTarget.x);
out.writeSint16LE(a->finalTarget.y);
out.writeSint16LE(a->finalTarget.z);
out.writeByte(a->currentAction);
out.writeByte(a->facingDirection);
out.writeSint16LE(a->targetObject);
out.writeByte(a->flags & (kProtagonist | kFollower));
out.writeByte(a->frameNumber);
out.writeSint16LE(0);
}
for (i = 0; i < _actor->_objsCount; i++) {
ObjectData *o = _actor->_objs[i];
out.writeSint32LE(o->sceneNumber);
out.writeSint32LE(o->id);
out.writeSint16LE(o->location.x);
out.writeSint16LE(o->location.y);
out.writeSint16LE(o->location.z);
out.writeSint16LE(o->nameIndex);
if (o->sceneNumber == ITE_SCENE_INV) {
out.writeSint16LE(_interface->inventoryItemPosition(_actor->objIndexToId(i)));
} else {
out.writeSint16LE(0);
}
out.writeByte(0);
}
for (i = 0; i < _script->_commonBufferSize; i++)
out.writeByte(_script->_commonBuffer[i]);
out.writeSint16LE(_isoMap->getMapPosition().x);
out.writeSint16LE(_isoMap->getMapPosition().y);
out.close();
}
void SagaEngine::load() {
File out;
int actorsCount, objsCount, commonBufferSize;
int scenenum, inset;
out.open("ite.sav");
if (!out.isOpen())
return;
actorsCount = out.readSint16LE();
objsCount = out.readSint16LE();
commonBufferSize = out.readSint16LE();
_actor->setProtagState(out.readSint16LE());
// Surrounding scene
scenenum = out.readSint32LE();
out.readSint32LE();
// Inset scene
inset = out.readSint32LE();
out.readSint32LE();
uint16 i;
for (i = 0; i < actorsCount; i++) {
ActorData *a = _actor->_actors[i];
a->sceneNumber = out.readSint32LE();
a->location.x = out.readSint16LE();
a->location.y = out.readSint16LE();
a->location.z = out.readSint16LE();
a->finalTarget.x = out.readSint16LE();
a->finalTarget.y = out.readSint16LE();
a->finalTarget.z = out.readSint16LE();
a->currentAction = out.readByte();
a->facingDirection = out.readByte();
a->targetObject = out.readSint16LE();
a->flags = (a->flags & ~(kProtagonist | kFollower) | out.readByte());
a->frameNumber = out.readByte();
out.readSint16LE();
}
_interface->clearInventory();
for (i = 0; i < objsCount; i++) {
ObjectData *o = _actor->_objs[i];
int pos;
o->sceneNumber = out.readSint32LE();
o->id = out.readSint32LE();
o->location.x = out.readSint16LE();
o->location.y = out.readSint16LE();
o->location.z = out.readSint16LE();
o->nameIndex = out.readSint16LE();
pos = out.readSint16LE();
if (o->sceneNumber == ITE_SCENE_INV) {
_interface->addToInventory(_actor->objIndexToId(i), pos);
}
out.readByte();
}
for (i = 0; i < commonBufferSize; i++)
_script->_commonBuffer[i] = out.readByte();
_isoMap->getMapPosition().x = out.readSint16LE();
_isoMap->getMapPosition().y = out.readSint16LE();
out.close();
// FIXME: When save/load screen will be implemented we should
// call these after that screen left by user
_interface->draw();
// FIXME: hmmm... now we always require actorsEntrance to be defined
// so no way to restore at arbitrary position
_scene->clearSceneQueue();
_scene->changeScene(scenenum, 0);
if (inset != scenenum) {
_scene->clearSceneQueue();
_scene->changeScene(inset, 0);
}
}
} // End of namespace Saga
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- actor.cpp 20 Apr 2005 19:38:02 -0000 1.117
+++ actor.cpp 21 Apr 2005 01:30:06 -0000 1.118
@@ -180,6 +180,7 @@
_pathDirectionListAlloced = 0;
_centerActor = _protagonist = NULL;
+ _protagState = 0;
_lastTickMsec = 0;
_yCellCount = _vm->getSceneHeight();
@@ -548,6 +549,11 @@
return (_vm->_scene->canWalk(point));
}
+void Actor::setProtagState(int state) {
+ debug(0, "STUB: setProtagState(%d)", state);
+ _protagState = state;
+}
+
void Actor::updateActorsScene(int actorsEntrance) {
int i, j;
int followerDirection;
Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- actor.h 19 Apr 2005 11:07:06 -0000 1.63
+++ actor.h 21 Apr 2005 01:30:07 -0000 1.64
@@ -382,6 +382,9 @@
bool isSpeaking() {
return _activeSpeech.stringsCount > 0;
}
+
+ void setProtagState(int state);
+ int getProtagState() { return _protagState; }
private:
bool loadActorResources(ActorData *actor);
@@ -428,14 +431,16 @@
protected:
friend class IsoMap;
+ friend class SagaEngine;
int _actorsCount;
ActorData **_actors;
-private:
int _objsCount;
ObjectData **_objs;
+private:
SpeechData _activeSpeech;
+ int _protagState;
//path stuff
struct PathNode {
Index: input.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/input.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- input.cpp 18 Apr 2005 20:03:10 -0000 1.38
+++ input.cpp 21 Apr 2005 01:30:07 -0000 1.39
@@ -84,6 +84,12 @@
case 287: // F6
_render->toggleFlag(RF_ACTOR_PATH_TEST);
break;
+ case 288: // F7
+ save();
+ break;
+ case 289: // F8
+ load();
+ break;
case 9: // Tab
_script->SThreadDebugStep();
break;
Index: interface.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.cpp,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- interface.cpp 20 Apr 2005 23:42:19 -0000 1.78
+++ interface.cpp 21 Apr 2005 01:30:07 -0000 1.79
@@ -506,7 +506,13 @@
return NULL;
}
-void Interface::addToInventory(int sprite) {
+void Interface::addToInventory(int sprite, int pos) {
+ if (pos != -1) {
+ _inventory[pos] = sprite;
+ _inventoryCount++;
+ return;
+ }
+
if (_inventoryCount < _inventorySize) {
for (int i = _inventoryCount; i > 0; i--) {
_inventory[i] = _inventory[i - 1];
@@ -535,6 +541,13 @@
}
}
+void Interface::clearInventory() {
+ for (int i = 0; i < _inventoryCount; i++)
+ _inventory[i] = 0;
+
+ _inventoryCount = 0;
+}
+
int Interface::inventoryItemPosition(int sprite) {
for (int i = 0; i < _inventoryCount; i++)
if (_inventory[i] == sprite)
Index: interface.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- interface.h 20 Apr 2005 23:42:19 -0000 1.42
+++ interface.h 21 Apr 2005 01:30:07 -0000 1.43
@@ -137,8 +137,9 @@
bool processKeyCode(int keyCode);
- void addToInventory(int sprite);
+ void addToInventory(int sprite, int pos = -1);
void removeFromInventory(int sprite);
+ void clearInventory();
int inventoryItemPosition(int sprite);
void drawInventory();
Index: isomap.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/isomap.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- isomap.h 3 Apr 2005 15:32:03 -0000 1.19
+++ isomap.h 21 Apr 2005 01:30:07 -0000 1.20
@@ -167,6 +167,7 @@
void findTilePath(ActorData* actor, const Location &start, const Location &end);
bool nextTileTarget(ActorData* actor);
void setTileDoorState(int doorNumber, int doorState);
+ Point getMapPosition() { return _mapPosition; }
private:
void drawTiles(SURFACE *ds, const Location *location);
Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/module.mk,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- module.mk 28 Jan 2005 12:54:09 -0000 1.23
+++ module.mk 21 Apr 2005 01:30:07 -0000 1.24
@@ -20,6 +20,7 @@
saga/render.o \
saga/rscfile.o \
saga/saga.o \
+ saga/saveload.o \
saga/scene.o \
saga/script.o \
saga/sdebug.o \
Index: saga.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.h,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- saga.h 18 Apr 2005 20:03:12 -0000 1.85
+++ saga.h 21 Apr 2005 01:30:07 -0000 1.86
@@ -425,6 +425,9 @@
virtual ~SagaEngine();
void shutDown() { _quit = true; }
+ void save();
+ void load();
+
int _soundEnabled;
int _musicEnabled;
Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.cpp,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -d -r1.96 -r1.97
--- scene.cpp 20 Apr 2005 19:38:04 -0000 1.96
+++ scene.cpp 21 Apr 2005 01:30:07 -0000 1.97
@@ -581,6 +581,13 @@
return FAILURE;
}
+ if (_desc.flags & kSceneFlagISO) {
+ _outsetSceneNumber = _sceneNumber;
+ } else {
+ if (!(_bg.w < _vm->getDisplayWidth() || _bg.h < _vm->getSceneHeight()))
+ _outsetSceneNumber = _sceneNumber;
+ }
+
_sceneLoaded = true;
q_event = NULL;
@@ -875,7 +882,7 @@
_actionMap->load(res_data, res_data_len);
break;
case SAGA_ISO_IMAGES:
- if (!(_vm->_scene->getFlags() & kSceneFlagISO)) {
+ if (!(_desc.flags & kSceneFlagISO)) {
error("Scene::ProcessSceneResources(): not Iso mode");
}
@@ -884,7 +891,7 @@
_vm->_isoMap->loadImages(res_data, res_data_len);
break;
case SAGA_ISO_MAP:
- if (!(_vm->_scene->getFlags() & kSceneFlagISO)) {
+ if (!(_desc.flags & kSceneFlagISO)) {
error("Scene::ProcessSceneResources(): not Iso mode");
}
@@ -893,7 +900,7 @@
_vm->_isoMap->loadMap(res_data, res_data_len);
break;
case SAGA_ISO_PLATFORMS:
- if (!(_vm->_scene->getFlags() & kSceneFlagISO)) {
+ if (!(_desc.flags & kSceneFlagISO)) {
error("Scene::ProcessSceneResources(): not Iso mode");
}
@@ -902,7 +909,7 @@
_vm->_isoMap->loadPlatforms(res_data, res_data_len);
break;
case SAGA_ISO_METATILES:
- if (!(_vm->_scene->getFlags() & kSceneFlagISO)) {
+ if (!(_desc.flags & kSceneFlagISO)) {
error("Scene::ProcessSceneResources(): not Iso mode");
}
@@ -938,7 +945,7 @@
}
break;
case SAGA_ISO_MULTI:
- if (!(_vm->_scene->getFlags() & kSceneFlagISO)) {
+ if (!(_desc.flags & kSceneFlagISO)) {
error("Scene::ProcessSceneResources(): not Iso mode");
}
@@ -973,7 +980,7 @@
_vm->_render->getBufferInfo(&buf_info);
- if (_vm->_scene->getFlags() & kSceneFlagISO) {
+ if (_desc.flags & kSceneFlagISO) {
_vm->_isoMap->adjustScroll(false);
_vm->_isoMap->draw(dst_s);
} else {
Index: scene.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- scene.h 2 Apr 2005 20:04:39 -0000 1.49
+++ scene.h 21 Apr 2005 01:30:07 -0000 1.50
@@ -261,6 +261,7 @@
int getSceneLUT(int num);
int currentSceneNumber() const { return _sceneNumber; }
+ int getOutsetSceneNumber() const { return _outsetSceneNumber; }
int currentSceneResourceId() const { return _sceneResourceId; }
private:
@@ -282,6 +283,7 @@
int _firstScene;
bool _sceneLoaded;
int _sceneNumber;
+ int _outsetSceneNumber;
int _sceneResourceId;
bool _inGame;
bool _loadDesc;
Index: script.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script.h,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- script.h 18 Apr 2005 20:03:13 -0000 1.76
+++ script.h 21 Apr 2005 01:30:07 -0000 1.77
@@ -389,9 +389,13 @@
uint16 _modulesLUTEntryLen;
ModuleData *_modules;
int _modulesCount;
-
- byte* _commonBuffer;
+
+protected:
+ friend class SagaEngine;
+ byte *_commonBuffer;
uint _commonBufferSize;
+
+private:
uint _staticSize;
ScriptThreadList _threadList;
@@ -508,7 +512,7 @@
void SF_simulSpeech2(SCRIPTFUNC_PARAMS);
void sfPlacard(SCRIPTFUNC_PARAMS);
void sfPlacardOff(SCRIPTFUNC_PARAMS);
- void SF_setProtagState(SCRIPTFUNC_PARAMS);
+ void sfSetProtagState(SCRIPTFUNC_PARAMS);
void sfResumeBgdAnim(SCRIPTFUNC_PARAMS);
void SF_throwActor(SCRIPTFUNC_PARAMS);
void sfWaitWalk(SCRIPTFUNC_PARAMS);
Index: sfuncs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sfuncs.cpp,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -d -r1.102 -r1.103
--- sfuncs.cpp 18 Apr 2005 20:03:13 -0000 1.102
+++ sfuncs.cpp 21 Apr 2005 01:30:07 -0000 1.103
@@ -100,7 +100,7 @@
OPCODE(SF_simulSpeech2),
OPCODE(sfPlacard),
OPCODE(sfPlacardOff),
- OPCODE(SF_setProtagState),
+ OPCODE(sfSetProtagState),
OPCODE(sfResumeBgdAnim),
OPCODE(SF_throwActor),
OPCODE(sfWaitWalk),
@@ -1305,11 +1305,10 @@
}
// Script function #50 (0x32)
-void Script::SF_setProtagState(SCRIPTFUNC_PARAMS) {
- for (int i = 0; i < nArgs; i++)
- thread->pop();
+void Script::sfSetProtagState(SCRIPTFUNC_PARAMS) {
+ int protagState = thread->pop();
- debug(0, "STUB: SF_setProtagState(), %d args", nArgs);
+ _vm->_actor->setProtagState(protagState);
}
// Script function #51 (0x33)
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.451,2.452 object.cpp,1.231,1.232 script.cpp,1.217,1.218 script_v2.cpp,2.274,2.275 scumm.cpp,1.451,1.452 scumm.h,1.596,1.597 verbs.cpp,1.130,1.131
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.344,1.345 scumm.cpp,1.452,1.453 scumm.h,1.597,1.598 vars.cpp,1.126,1.127
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list