[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.137,1.138 actor.h,1.76,1.77 saga.h,1.99,1.100 saveload.cpp,1.14,1.15 script.h,1.83,1.84 sfuncs.cpp,1.121,1.122
Andrew Kurushin
h00ligan at users.sourceforge.net
Sun Jun 5 09:54:31 CEST 2005
Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16093
Modified Files:
actor.cpp actor.h saga.h saveload.cpp script.h sfuncs.cpp
Log Message:
implements sfScriptClimb, sfThrowActor, sfChangeActorScene
so tunnel may be passed now
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -d -r1.137 -r1.138
--- actor.cpp 4 Jun 2005 14:37:51 -0000 1.137
+++ actor.cpp 5 Jun 2005 16:53:53 -0000 1.138
@@ -427,6 +427,7 @@
int distance;
ActorData *actor;
ObjectData *obj;
+ debug (8, "Actor::realLocation objectId=%i", objectId);
if (walkFlags & kWalkUseAngle) {
if (_vm->_scene->getFlags() & kSceneFlagISO) {
angle = (location.x + 2) & 15;
@@ -460,7 +461,7 @@
void Actor::actorFaceTowardsPoint(uint16 actorId, const Location &toLocation) {
ActorData *actor;
Location delta;
-
+ debug (8, "Actor::actorFaceTowardsPoint actorId=%i", actorId);
actor = getActor(actorId);
toLocation.delta(actor->location, delta);
@@ -802,6 +803,7 @@
ActorFrameRange *frameRange;
int state;
int speed;
+ int32 framesLeft;
Location delta;
Location addDelta;
int hitZoneIndex;
@@ -1099,15 +1101,49 @@
break;
case kActionFall:
- debug(9,"kActionFall not implemented");
-
- //todo: do it
+ if (actor->actionCycle > 0) {
+ framesLeft = actor->actionCycle--;
+ actor->finalTarget.delta(actor->location, delta);
+ delta.x /= framesLeft;
+ delta.y /= framesLeft;
+ actor->location.addXY(delta);
+ actor->fallVelocity += actor->fallAcceleration;
+ actor->fallPosition += actor->fallVelocity;
+ actor->location.z = actor->fallPosition >> 4;
+ } else {
+ actor->location = actor->finalTarget;
+ actor->currentAction = kActionFreeze;
+ _vm->_script->wakeUpActorThread(kWaitTypeWalk, actor);
+ }
break;
case kActionClimb:
- debug(9,"kActionClimb not implemented");
+ actor->cycleDelay++;
+ if (actor->cycleDelay & 3) {
+ break;
+ }
- //todo: do it
+ if (actor->location.z >= actor->finalTarget.z + ACTOR_CLIMB_SPEED) {
+ actor->location.z -= ACTOR_CLIMB_SPEED;
+ actor->actionCycle--;
+ } else {
+ if (actor->location.z <= actor->finalTarget.z - ACTOR_CLIMB_SPEED) {
+ actor->location.z += ACTOR_CLIMB_SPEED;
+ actor->actionCycle++;
+ } else {
+ actor->location.z = actor->finalTarget.z;
+ actor->currentAction = kActionFreeze;
+ _vm->_script->wakeUpActorThread(kWaitTypeWalk, actor);
+ }
+ }
+
+ frameRange = getActorFrameRange(actor->id, actor->cycleFrameSequence);
+
+ if (actor->actionCycle < 0) {
+ actor->actionCycle = frameRange->frameCount - 1;
+ }
+ actor->cycleWrap(frameRange->frameCount);
+ actor->frameNumber = frameRange->frameIndex + actor->actionCycle;
break;
}
Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.h,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- actor.h 3 Jun 2005 19:04:21 -0000 1.76
+++ actor.h 5 Jun 2005 16:53:53 -0000 1.77
@@ -49,6 +49,8 @@
#define ACTOR_LMULT 4
+#define ACTOR_CLIMB_SPEED 8
+
#define ACTOR_COLLISION_WIDTH 32
#define ACTOR_COLLISION_HEIGHT 8
@@ -287,6 +289,10 @@
uint8 cycleTimeCount;
uint8 cycleFlags;
+ int16 fallVelocity;
+ int16 fallAcceleration;
+ int16 fallPosition;
+
int32 frameNumber; // current frame number
int32 tileDirectionsAlloced;
@@ -315,6 +321,9 @@
out->writeByte(cycleDelay);
out->writeByte(cycleTimeCount);
out->writeByte(cycleFlags);
+ out->writeSint16LE(fallVelocity);
+ out->writeSint16LE(fallAcceleration);
+ out->writeSint16LE(fallPosition);
out->writeSint32LE(frameNumber);
out->writeSint32LE(tileDirectionsAlloced);
@@ -349,6 +358,13 @@
cycleDelay = in->readByte();
cycleTimeCount = in->readByte();
cycleFlags = in->readByte();
+ if (_vm->getCurrentLoadVersion() > 1) {
+ fallVelocity = in->readSint16LE();
+ fallAcceleration = in->readSint16LE();
+ fallPosition = in->readSint16LE();
+ } else {
+ fallVelocity = fallAcceleration = fallPosition = 0;
+ }
frameNumber = in->readSint32LE();
Index: saga.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.h,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -d -r1.99 -r1.100
--- saga.h 4 Jun 2005 12:25:25 -0000 1.99
+++ saga.h 5 Jun 2005 16:53:53 -0000 1.100
@@ -463,6 +463,12 @@
uint slotNumber;
};
+struct SaveGameHeader {
+ uint32 type;
+ uint32 size;
+ uint32 version;
+ char name[SAVE_TITLE_SIZE];
+};
inline int ticksToMSec(int tick) {
return tick * 1000 / kScriptTimeTicksPerSecond;
@@ -512,6 +518,9 @@
void save(const char *fileName, const char *saveName);
void load(const char *fileName);
+ uint32 getCurrentLoadVersion() {
+ return _saveHeader.version;
+ }
void fillSaveList();
char *calcSaveFileName(uint slotNumber);
@@ -605,6 +614,7 @@
uint _saveFilesCount;
SaveFileData _saveFiles[MAX_SAVES];
bool _saveMarks[MAX_SAVES];
+ SaveGameHeader _saveHeader;
Point _mousePos;
bool _leftMouseButtonPressed;
Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saveload.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- saveload.cpp 2 Jun 2005 22:14:57 -0000 1.14
+++ saveload.cpp 5 Jun 2005 16:53:53 -0000 1.15
@@ -37,17 +37,10 @@
#include "saga/scene.h"
#include "saga/render.h"
-#define CURRENT_SAGA_VER 1
+#define CURRENT_SAGA_VER 2
namespace Saga {
-struct SaveGameHeader {
- uint32 type;
- uint32 size;
- uint32 version;
- char name[SAVE_TITLE_SIZE];
-};
-
static SaveFileData emptySlot = {
"[New Save Game]", 0
};
@@ -114,7 +107,6 @@
void SagaEngine::fillSaveList() {
int i;
Common::InSaveFile *in;
- SaveGameHeader header;
char *name;
name = calcSaveFileName(MAX_SAVES);
@@ -137,12 +129,12 @@
if (_saveMarks[i]) {
name = calcSaveFileName(i);
if ((in = _saveFileMan->openForLoading(name)) != NULL) {
- in->read(&header, sizeof(header));
+ in->read(&_saveHeader, sizeof(_saveHeader));
- if (header.type != MKID('SAGA')) {
+ if (_saveHeader.type != MKID('SAGA')) {
error("SagaEngine::load wrong format");
}
- strcpy(_saveFiles[_saveFilesCount].name, header.name);
+ strcpy(_saveFiles[_saveFilesCount].name, _saveHeader.name);
_saveFiles[_saveFilesCount].slotNumber = i;
delete in;
_saveFilesCount++;
@@ -163,18 +155,17 @@
void SagaEngine::save(const char *fileName, const char *saveName) {
Common::OutSaveFile *out;
- SaveGameHeader header;
if (!(out = _saveFileMan->openForSaving(fileName))) {
return;
}
- header.type = MKID('SAGA');
- header.size = 0;
- header.version = CURRENT_SAGA_VER;
- strcpy(header.name, saveName);
+ _saveHeader.type = MKID('SAGA');
+ _saveHeader.size = 0;
+ _saveHeader.version = CURRENT_SAGA_VER;
+ strcpy(_saveHeader.name, saveName);
- out->write(&header, sizeof(header));
+ out->write(&_saveHeader, sizeof(_saveHeader));
// Surrounding scene
out->writeSint32LE(_scene->getOutsetSceneNumber());
@@ -201,15 +192,14 @@
int commonBufferSize;
int sceneNumber, insetSceneNumber;
int mapx, mapy;
- SaveGameHeader header;
if (!(in = _saveFileMan->openForLoading(fileName))) {
return;
}
- in->read(&header, sizeof(header));
+ in->read(&_saveHeader, sizeof(_saveHeader));
- if (header.type != MKID('SAGA')) {
+ if (_saveHeader.type != MKID('SAGA')) {
error("SagaEngine::load wrong format");
}
Index: script.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script.h,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- script.h 23 May 2005 02:23:34 -0000 1.83
+++ script.h 5 Jun 2005 16:53:53 -0000 1.84
@@ -514,11 +514,11 @@
void sfPlacardOff(SCRIPTFUNC_PARAMS);
void sfSetProtagState(SCRIPTFUNC_PARAMS);
void sfResumeBgdAnim(SCRIPTFUNC_PARAMS);
- void SF_throwActor(SCRIPTFUNC_PARAMS);
+ void sfThrowActor(SCRIPTFUNC_PARAMS);
void sfWaitWalk(SCRIPTFUNC_PARAMS);
void sfScriptSceneID(SCRIPTFUNC_PARAMS);
- void SF_changeActorScene(SCRIPTFUNC_PARAMS);
- void SF_climb(SCRIPTFUNC_PARAMS);
+ void sfChangeActorScene(SCRIPTFUNC_PARAMS);
+ void sfScriptClimb(SCRIPTFUNC_PARAMS);
void sfSetDoorState(SCRIPTFUNC_PARAMS);
void SF_setActorZ(SCRIPTFUNC_PARAMS);
void SF_text(SCRIPTFUNC_PARAMS);
Index: sfuncs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sfuncs.cpp,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -d -r1.121 -r1.122
--- sfuncs.cpp 5 Jun 2005 11:32:11 -0000 1.121
+++ sfuncs.cpp 5 Jun 2005 16:53:53 -0000 1.122
@@ -103,11 +103,11 @@
OPCODE(sfPlacardOff),
OPCODE(sfSetProtagState),
OPCODE(sfResumeBgdAnim),
- OPCODE(SF_throwActor),
+ OPCODE(sfThrowActor),
OPCODE(sfWaitWalk),
OPCODE(sfScriptSceneID),
- OPCODE(SF_changeActorScene),
- OPCODE(SF_climb),
+ OPCODE(sfChangeActorScene),
+ OPCODE(sfScriptClimb),
OPCODE(sfSetDoorState),
OPCODE(SF_setActorZ),
OPCODE(SF_text),
@@ -889,7 +889,7 @@
// Param4: cycle delay
void Script::sfCycleFrames(SCRIPTFUNC_PARAMS) {
int16 actorId;
- int flags;
+ int16 flags;
int cycleFrameSequence;
int cycleDelay;
ActorData *actor;
@@ -1360,17 +1360,39 @@
}
// Script function #52 (0x34)
-void Script::SF_throwActor(SCRIPTFUNC_PARAMS) {
- int param1, param2, param3, param4, param5, param6;
+// Param1: actor id
+// Param2: x
+// Param3: y
+// Param4: unknown
+// Param5: actionCycle
+// Param6: flags
+void Script::sfThrowActor(SCRIPTFUNC_PARAMS) {
+ int16 actorId;
+ ActorData *actor;
+ int16 flags;
+ int32 actionCycle;
+ Location location;
- param1 = thread->pop();
- param2 = thread->pop();
- param3 = thread->pop();
- param4 = thread->pop();
- param5 = thread->pop();
- param6 = thread->pop();
+ actorId = thread->pop();
+ location.x = thread->pop();
+ location.y = thread->pop();
+ thread->pop();
+ actionCycle = thread->pop();
+ flags = thread->pop();
- warning("STUB: SF_throwActor(%d, %d, %d, %d, %d, %d)", param1, param2, param3, param4, param5, param6);
+ actor = _vm->_actor->getActor(actorId);
+ location.z = actor->location.z;
+ actor->currentAction = kActionFall;
+ actor->actionCycle = actionCycle;
+ actor->fallAcceleration = -20;
+ actor->fallVelocity = - (actor->fallAcceleration * actor->actionCycle) / 2;
+ actor->fallPosition = actor->location.z << 4;
+
+ actor->finalTarget = location;
+ actor->actionCycle--;
+ if (!(flags & kWalkAsync)) {
+ thread->waitWalk(actor);
+ }
}
// Script function #53 (0x35)
@@ -1396,21 +1418,45 @@
}
// Script function #55 (0x37)
-void Script::SF_changeActorScene(SCRIPTFUNC_PARAMS) {
- int param1 = thread->pop();
- int param2 = thread->pop();
+// Param1: actor id
+// Param2: scene number
+void Script::sfChangeActorScene(SCRIPTFUNC_PARAMS) {
+ int16 actorId;
+ int32 sceneNumber;
+ ActorData *actor;
- error("STUB: SF_changeActorScene(%d, %d)", param1, param2);
+ actorId = thread->pop();
+ sceneNumber = thread->pop();
+ actor = _vm->_actor->getActor(actorId);
+ actor->sceneNumber = sceneNumber;
}
// Script function #56 (0x38)
-void Script::SF_climb(SCRIPTFUNC_PARAMS) {
- int param1 = thread->pop();
- int param2 = thread->pop();
- int param3 = thread->pop();
- int param4 = thread->pop();
+// Param1: actor id
+// Param2: z
+// Param3: frame seq
+// Param4: flags
+void Script::sfScriptClimb(SCRIPTFUNC_PARAMS) {
+ int16 actorId;
+ int16 z;
+ ActorData *actor;
+ uint16 flags;
+ int cycleFrameSequence;
- error("STUB: SF_climb(%d, %d, %d, %d)", param1, param2, param3, param4);
+ actorId = thread->pop();
+ z = thread->pop();
+ cycleFrameSequence = thread->pop();
+ flags = thread->pop();
+
+ actor = _vm->_actor->getActor(actorId);
+ actor->finalTarget.z = z;
+ actor->flags &= ~kFollower;
+ actor->actionCycle = 1;
+ actor->cycleFrameSequence = cycleFrameSequence;
+ actor->currentAction = kActionClimb;
+ if (!(flags & kWalkAsync)) {
+ thread->waitWalk(actor);
+ }
}
// Script function #57 (0x39)
More information about the Scummvm-git-logs
mailing list