[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.75,1.76 actor.h,1.38,1.39 input.cpp,1.30,1.31 render.cpp,1.45,1.46 render.h,1.20,1.21 script.h,1.47,1.48 sfuncs.cpp,1.70,1.71
Andrew Kurushin
h00ligan at users.sourceforge.net
Thu Jan 6 11:16:28 CET 2005
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/gui console.cpp,1.53,1.54 dialog.cpp,1.46,1.47 newgui.cpp,1.94,1.95 newgui.h,1.50,1.51
- Next message: [Scummvm-cvs-logs] CVS: scummvm/common system.h,1.79,1.80
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16526
Modified Files:
actor.cpp actor.h input.cpp render.cpp render.h script.h
sfuncs.cpp
Log Message:
- implement faceTowards (script function & etc)
- implement debug actor walk path (press f6)
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- actor.cpp 6 Jan 2005 14:32:14 -0000 1.75
+++ actor.cpp 6 Jan 2005 19:15:01 -0000 1.76
@@ -138,6 +138,9 @@
return;
}
+ _debugPoints = NULL;
+ _debugPointsAlloced = _debugPointsCount = 0;
+
_centerActor = _protagonist = NULL;
_lastTickMsec = 0;
@@ -193,6 +196,7 @@
ActorData *actor;
debug(9, "Actor::~Actor()");
+ free(_debugPoints);
free(_pathCell);
//release resources
for (i = 0; i < ACTORCOUNT; i++) {
@@ -299,6 +303,37 @@
}
}
+void Actor::actorFaceTowardsPoint(uint16 actorId, const ActorLocation &toLocation) {
+ ActorData *actor;
+ ActorLocation delta;
+
+ actor = getActor(actorId);
+
+ // tiled stuff
+ if (_vm->_scene->getMode() == SCENE_MODE_ISO) {
+ //todo: it
+ } else {
+ toLocation.delta(actor->location, delta);
+
+ if (ABS(delta.y) > ABS(delta.x * 2)) {
+ actor->facingDirection = (delta.y > 0) ? kDirDown : kDirUp;
+ } else {
+ actor->facingDirection = (delta.x > 0) ? kDirRight : kDirLeft;
+ }
+ }
+}
+
+void Actor::actorFaceTowardsObject(uint16 actorId, uint16 objectId) {
+ ActorData *actor;
+
+ if (IS_VALID_ACTOR_ID(objectId)) {
+ actor = getActor(objectId);
+ actorFaceTowardsPoint(actorId, actor->location);
+ } else {
+ warning("ObjectId unsupported"); //todo: do it
+ }
+}
+
ActorData *Actor::getActor(uint16 actorId) {
ActorData *actor;
@@ -556,8 +591,8 @@
//todo: dragon stuff
- if (actor->index == 2)
- debug(9, "Action: %d Flags: %x", actor->currentAction, actor->flags);
+/* if (actor->index == 2)
+ debug(9, "Action: %d Flags: %x", actor->currentAction, actor->flags);*/
switch(actor->currentAction) {
case kActionWait:
@@ -568,7 +603,7 @@
}
if (actor->targetObject != ID_NOTHING) {
- //todo: facetowardsobject
+ actorFaceTowardsObject(actor->actorId, actor->targetObject);
}
if (actor->flags & kCycle) {
@@ -829,8 +864,8 @@
actor->location.toScreenPointXYZ(actor->screenPosition);
}
- if (actor->index == 2)
- debug(9, "act: %d. x: %d y: %d", actor->index, actor->screenPosition.x, actor->screenPosition.y);
+ /*if (actor->index == 2)
+ debug(9, "act: %d. x: %d y: %d", actor->index, actor->screenPosition.x, actor->screenPosition.y);*/
}
void Actor::createDrawOrderList() {
@@ -1314,6 +1349,7 @@
int i;
Rect intersect;
+ _debugPointsCount = 0;
actor->walkStepsCount = 0;
if (fromPoint == toPoint) {
@@ -1325,7 +1361,7 @@
for (iteratorPoint.x = 0; iteratorPoint.x < _xCellCount; iteratorPoint.x++) {
maskType = _vm->_scene->getBGMaskType(iteratorPoint);
cellValue = maskType ? kPathCellBarrier : kPathCellEmpty;
- setPathCell(iteratorPoint, cellValue);
+ setPathCell(iteratorPoint, cellValue);
}
}
@@ -1343,7 +1379,16 @@
}
}
+#if 1
+ for (iteratorPoint.y = 0; iteratorPoint.y < _yCellCount; iteratorPoint.y++) {
+ for (iteratorPoint.x = 0; iteratorPoint.x < _xCellCount; iteratorPoint.x++) {
+ if (getPathCell(iteratorPoint) == kPathCellBarrier) {
+ addDebugPoint(iteratorPoint, 24);
+ }
+ }
+ }
+#endif
if (scanPathLine(fromPoint, toPoint)) {
actor->addWalkStepPoint(fromPoint);
@@ -1466,6 +1511,8 @@
if (validPathCellPoint(fromPoint)) {
setPathCell(fromPoint, 0);
+
+ addDebugPoint(fromPoint, 0x8a);
}
pathDirectionIterator = pathDirectionList.begin();
@@ -1480,7 +1527,8 @@
if (validPathCellPoint(nextPoint) &&
(getPathCell(nextPoint) == kPathCellEmpty)) {
setPathCell(nextPoint, samplePathDirection->direction);
-
+
+ addDebugPoint(nextPoint, samplePathDirection->direction + 96);
newPathDirectionIterator = pathDirectionList.pushBack();
pathDirection = newPathDirectionIterator.operator->();
pathDirection->x = nextPoint.x;
@@ -1848,6 +1896,20 @@
_pathNodeIndex = j - 1;
}
+void Actor::drawPathTest() {
+ int i;
+ SURFACE *surface;
+ surface = _vm->_gfx->getBackBuffer();
+ if (_debugPoints == NULL) {
+ return;
+ }
+
+
+ for (i = 0; i < _debugPointsCount; i++) {
+ *((byte *)surface->pixels + (_debugPoints[i].point.y * surface->pitch) + _debugPoints[i].point.x) = _debugPoints[i].color;
+ }
+}
+
/*
// Console wrappers - must be safe to run
// TODO - checkup ALL arguments, cause wrong arguments may fall function with "error"
Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- actor.h 6 Jan 2005 12:42:05 -0000 1.38
+++ actor.h 6 Jan 2005 19:15:01 -0000 1.39
@@ -123,7 +123,7 @@
struct PathDirectionData {
int direction;
- int x;
+ int x;
int y;
};
@@ -151,10 +151,10 @@
ActorLocation() {
x = y = z = 0;
}
- int distance(const ActorLocation &location) {
+ int distance(const ActorLocation &location) const {
return MAX(ABS(x - location.x), ABS(y - location.y));
}
- void delta(const ActorLocation &location, ActorLocation &result) {
+ void delta(const ActorLocation &location, ActorLocation &result) const {
result.x = x - location.x;
result.y = y - location.y;
result.z = z - location.z;
@@ -286,11 +286,15 @@
int drawActors();
void updateActorsScene(); // calls from scene loading to update Actors info
+ void drawPathTest();
+
bool actorEndWalk(uint16 actorId, bool recurse);
bool actorWalkTo(uint16 actorId, const ActorLocation &toLocation);
ActorData *getActor(uint16 actorId);
ActorFrameRange *getActorFrameRange(uint16 actorId, int frameType);
void realLocation(ActorLocation &location, uint16 objectId, uint16 walkFlags);
+ void actorFaceTowardsPoint(uint16 actorId, const ActorLocation &toLocation);
+ void actorFaceTowardsObject(uint16 actorId, uint16 objectId);
// speech
void actorSpeech(uint16 actorId, const char **strings, int stringsCount, uint16 sampleResourceId, int speechFlags);
@@ -362,6 +366,23 @@
PathNode _newPathNodeList[PATH_NODE_MAX];
int _pathNodeIndex;
+public:
+//path debug - use with care
+ struct DebugPoint {
+ Point point;
+ byte color;
+ };
+ DebugPoint *_debugPoints;
+ int _debugPointsCount;
+ int _debugPointsAlloced;
+ void addDebugPoint(const Point &point, byte color) {
+ if (_debugPointsCount + 1 > _debugPointsAlloced) {
+ _debugPointsAlloced += 1000;
+ _debugPoints = (DebugPoint*) realloc(_debugPoints, _debugPointsAlloced * sizeof(*_debugPoints));
+ }
+ _debugPoints[_debugPointsCount].color = color;
+ _debugPoints[_debugPointsCount++].point = point;
+ }
};
inline int16 quickDistance(const Point &point1, const Point &point2) {
Index: input.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/input.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- input.cpp 6 Jan 2005 14:02:52 -0000 1.30
+++ input.cpp 6 Jan 2005 19:15:01 -0000 1.31
@@ -67,6 +67,9 @@
case 285: // F4
_render->toggleFlag(RF_OBJECTMAP_TEST);
break;
+ case 287: // F6
+ _render->toggleFlag(RF_ACTOR_PATH_TEST);
+ break;
case 9: // Tab
_script->SThreadDebugStep();
break;
@@ -84,7 +87,7 @@
switch (_interface->getMode()) {
case kPanelNull:
if (_scene->isInDemo())
- _scene->skipScene();
+ _scene->skipScene();
else
_actor->abortAllSpeeches();
break;
Index: render.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/render.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- render.cpp 1 Jan 2005 16:18:36 -0000 1.45
+++ render.cpp 6 Jan 2005 19:15:01 -0000 1.46
@@ -136,6 +136,9 @@
// Draw queued actors
_vm->_actor->drawActors();
+ if (getFlags() & RF_ACTOR_PATH_TEST) {
+ _vm->_actor->drawPathTest();
+ }
}
// Draw queued text strings
Index: render.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/render.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- render.h 1 Jan 2005 16:18:36 -0000 1.20
+++ render.h 6 Jan 2005 19:15:01 -0000 1.21
@@ -38,7 +38,8 @@
RF_OBJECTMAP_TEST = 0x08,
RF_RENDERPAUSE = 0x10,
RF_GAMEPAUSE = 0x20,
- RF_PLACARD = 0x40
+ RF_PLACARD = 0x40,
+ RF_ACTOR_PATH_TEST = 0x80
};
struct BUFFER_INFO {
Index: script.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- script.h 6 Jan 2005 16:07:46 -0000 1.47
+++ script.h 6 Jan 2005 19:15:01 -0000 1.48
@@ -323,7 +323,7 @@
int sfLockUser(SCRIPTFUNC_PARAMS);
int SF_preDialog(SCRIPTFUNC_PARAMS);
int SF_killActorThreads(SCRIPTFUNC_PARAMS);
- int SF_faceTowards(SCRIPTFUNC_PARAMS);
+ int sfFaceTowards(SCRIPTFUNC_PARAMS);
int sfSetFollower(SCRIPTFUNC_PARAMS);
int SF_gotoScene(SCRIPTFUNC_PARAMS);
int SF_setObjImage(SCRIPTFUNC_PARAMS);
Index: sfuncs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sfuncs.cpp,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- sfuncs.cpp 6 Jan 2005 16:07:46 -0000 1.70
+++ sfuncs.cpp 6 Jan 2005 19:15:01 -0000 1.71
@@ -62,7 +62,7 @@
OPCODE(sfLockUser),
OPCODE(SF_preDialog),
OPCODE(SF_killActorThreads),
- OPCODE(SF_faceTowards),
+ OPCODE(sfFaceTowards),
OPCODE(sfSetFollower),
OPCODE(SF_gotoScene),
OPCODE(SF_setObjImage),
@@ -324,11 +324,19 @@
}
// Script function #14 (0x0E)
-int Script::SF_faceTowards(SCRIPTFUNC_PARAMS) {
- ScriptDataWord param1 = thread->pop();
- ScriptDataWord param2 = thread->pop();
+// Param1: actor id
+// Param2: object id
+int Script::sfFaceTowards(SCRIPTFUNC_PARAMS) {
+ int16 actorId;
+ int16 targetObject;
+ ActorData *actor;
+
+ actorId = getSWord(thread->pop());
+ targetObject = getSWord(thread->pop());
+
+ actor = _vm->_actor->getActor(actorId);
+ actor->targetObject = targetObject;
- debug(1, "stub: SF_faceTowards(%d, %d)", param1, param2);
return SUCCESS;
}
@@ -945,7 +953,7 @@
PALENTRY *pal;
EVENT event;
EVENT *q_event;
-
+
thread->wait(kWaitTypePlacard);
_vm->_interface->rememberMode();
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/gui console.cpp,1.53,1.54 dialog.cpp,1.46,1.47 newgui.cpp,1.94,1.95 newgui.h,1.50,1.51
- Next message: [Scummvm-cvs-logs] CVS: scummvm/common system.h,1.79,1.80
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list