2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2003-12-16 02:10:15 +00:00
|
|
|
*
|
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-12-16 02:10:15 +00:00
|
|
|
*
|
2006-02-11 10:01:01 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2003-12-16 02:10:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-04-01 12:47:09 +00:00
|
|
|
#ifndef SWORD1_ROUTER_H
|
|
|
|
#define SWORD1_ROUTER_H
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2004-10-21 12:43:49 +00:00
|
|
|
#include "sword1/object.h"
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
namespace Sword1 {
|
|
|
|
|
2006-07-23 16:13:26 +00:00
|
|
|
#include "common/pack-start.h" // START STRUCT PACKING
|
2003-12-16 02:10:15 +00:00
|
|
|
|
|
|
|
struct BarData {
|
2006-04-01 12:47:09 +00:00
|
|
|
int16 x1;
|
|
|
|
int16 y1;
|
|
|
|
int16 x2;
|
|
|
|
int16 y2;
|
|
|
|
int16 xmin;
|
|
|
|
int16 ymin;
|
|
|
|
int16 xmax;
|
|
|
|
int16 ymax;
|
|
|
|
int16 dx; // x2 - x1
|
|
|
|
int16 dy; // y2 - y1
|
|
|
|
int32 co; // co = (y1*dx) - (x1*dy) from an equation for a line y*dx = x*dy + co
|
2007-07-01 18:18:43 +00:00
|
|
|
} PACKED_STRUCT;
|
2003-12-16 02:10:15 +00:00
|
|
|
|
|
|
|
struct NodeData {
|
2006-04-01 12:47:09 +00:00
|
|
|
int16 x;
|
|
|
|
int16 y;
|
|
|
|
int16 level;
|
|
|
|
int16 prev;
|
|
|
|
int16 dist;
|
2007-07-01 18:18:43 +00:00
|
|
|
} PACKED_STRUCT;
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2006-07-23 16:13:26 +00:00
|
|
|
#include "common/pack-end.h" // END STRUCT PACKING
|
2003-12-16 02:10:15 +00:00
|
|
|
|
|
|
|
struct FloorData {
|
|
|
|
int32 nbars;
|
|
|
|
BarData *bars;
|
|
|
|
int32 nnodes;
|
|
|
|
NodeData *node;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RouteData {
|
2006-04-01 12:47:09 +00:00
|
|
|
int32 x;
|
|
|
|
int32 y;
|
|
|
|
int32 dirS;
|
|
|
|
int32 dirD;
|
2003-12-16 02:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PathData {
|
2006-04-01 12:47:09 +00:00
|
|
|
int32 x;
|
|
|
|
int32 y;
|
|
|
|
int32 dir;
|
|
|
|
int32 num;
|
2003-12-16 02:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_FRAMES_PER_CYCLE 16
|
2006-04-01 12:47:09 +00:00
|
|
|
#define NO_DIRECTIONS 8
|
2003-12-16 02:10:15 +00:00
|
|
|
#define MAX_FRAMES_PER_CHAR (MAX_FRAMES_PER_CYCLE * NO_DIRECTIONS)
|
2006-04-01 12:47:09 +00:00
|
|
|
#define ROUTE_END_FLAG 255
|
|
|
|
|
|
|
|
#define O_GRID_SIZE 200
|
2003-12-16 02:10:15 +00:00
|
|
|
#define O_ROUTE_SIZE 50
|
|
|
|
|
|
|
|
class ObjectMan;
|
|
|
|
class ResMan;
|
2004-01-11 15:47:41 +00:00
|
|
|
class Screen;
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2003-12-17 01:18:03 +00:00
|
|
|
extern int whatTarget(int32 startX, int32 startY, int32 destX, int32 destY);
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
class Router {
|
2003-12-16 02:10:15 +00:00
|
|
|
public:
|
2004-01-11 15:47:41 +00:00
|
|
|
Router(ObjectMan *pObjMan, ResMan *pResMan);
|
|
|
|
int32 routeFinder(int32 id, Object *mega, int32 x, int32 y, int32 dir);
|
2003-12-16 02:10:15 +00:00
|
|
|
void setPlayerTarget(int32 x, int32 y, int32 dir, int32 stance);
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
// these should be private but are read by Screen for debugging:
|
2006-04-01 12:47:09 +00:00
|
|
|
BarData _bars[O_GRID_SIZE];
|
|
|
|
NodeData _node[O_GRID_SIZE];
|
|
|
|
|
|
|
|
int32 _nBars;
|
|
|
|
int32 _nNodes;
|
|
|
|
|
2003-12-16 02:10:15 +00:00
|
|
|
private:
|
|
|
|
// when the player collides with another mega, we'll receive a ReRouteRequest here.
|
|
|
|
// that's why we need to remember the player's target coordinates
|
|
|
|
int32 _playerTargetX, _playerTargetY, _playerTargetDir, _playerTargetStance;
|
2006-02-21 10:22:37 +00:00
|
|
|
|
2003-12-16 02:10:15 +00:00
|
|
|
ObjectMan *_objMan;
|
|
|
|
ResMan *_resMan;
|
|
|
|
|
2006-04-01 12:47:09 +00:00
|
|
|
int32 _startX, _startY, _startDir;
|
|
|
|
int32 _targetX, _targetY, _targetDir;
|
|
|
|
int32 _scaleA, _scaleB;
|
2003-12-16 18:23:15 +00:00
|
|
|
|
|
|
|
int32 megaId;
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2003-12-16 18:23:15 +00:00
|
|
|
/*RouteData _route[O_ROUTE_SIZE];
|
2003-12-16 02:10:15 +00:00
|
|
|
//int32 _routeLength;
|
|
|
|
PathData _smoothPath[O_ROUTE_SIZE];
|
2003-12-16 18:23:15 +00:00
|
|
|
PathData _modularPath[O_ROUTE_SIZE];*/
|
2006-04-01 12:47:09 +00:00
|
|
|
RouteData _route[O_ROUTE_SIZE];
|
|
|
|
PathData _smoothPath[O_ROUTE_SIZE];
|
|
|
|
PathData _modularPath[O_ROUTE_SIZE];
|
|
|
|
int32 _routeLength;
|
2003-12-16 18:23:15 +00:00
|
|
|
|
2006-04-01 12:47:09 +00:00
|
|
|
int32 _framesPerStep, _framesPerChar;
|
|
|
|
uint8 _nWalkFrames, _nTurnFrames;
|
2003-12-17 01:18:03 +00:00
|
|
|
int32 _dx[NO_DIRECTIONS + MAX_FRAMES_PER_CHAR];
|
|
|
|
int32 _dy[NO_DIRECTIONS + MAX_FRAMES_PER_CHAR];
|
2006-04-01 12:47:09 +00:00
|
|
|
int32 _modX[NO_DIRECTIONS];
|
|
|
|
int32 _modY[NO_DIRECTIONS];
|
|
|
|
int32 _diagonalx, _diagonaly;
|
2003-12-16 18:23:15 +00:00
|
|
|
int32 standFrames;
|
|
|
|
int32 turnFramesLeft, turnFramesRight;
|
|
|
|
int32 walkFramesLeft, walkFramesRight; // left/right walking turn
|
|
|
|
int32 slowInFrames, slowOutFrames;
|
|
|
|
|
|
|
|
|
2006-04-01 12:47:09 +00:00
|
|
|
int32 LoadWalkResources(Object *mega, int32 x, int32 y, int32 dir);
|
|
|
|
int32 getRoute(void);
|
|
|
|
int32 checkTarget(int32 x, int32 y);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-04-01 12:47:09 +00:00
|
|
|
bool scan(int32 level);
|
|
|
|
int32 newCheck(int32 status, int32 x1, int32 x2, int32 y1, int32 y2);
|
|
|
|
bool check(int32 x1, int32 y1, int32 x2, int32 y2);
|
|
|
|
bool horizCheck(int32 x1, int32 y, int32 x2);
|
|
|
|
bool vertCheck(int32 x, int32 y1, int32 y2);
|
|
|
|
bool lineCheck(int32 x1, int32 y1, int32 x2, int32 y2);
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2006-04-01 12:47:09 +00:00
|
|
|
void extractRoute();
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2006-04-01 12:47:09 +00:00
|
|
|
void slidyPath();
|
|
|
|
void slidyWalkAnimator(WalkData *walkAnim);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-04-01 12:47:09 +00:00
|
|
|
int32 smoothestPath();
|
|
|
|
int32 smoothCheck(int32 best, int32 p, int32 dirS, int32 dirD);
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2006-04-01 12:47:09 +00:00
|
|
|
void solidPath();
|
|
|
|
int32 solidWalkAnimator(WalkData *walkAnim);
|
2003-12-16 02:10:15 +00:00
|
|
|
};
|
|
|
|
|
2005-07-30 21:11:48 +00:00
|
|
|
} // End of namespace Sword1
|
2004-01-11 15:47:41 +00:00
|
|
|
|
2003-12-16 02:10:15 +00:00
|
|
|
#endif //BSROUTER_H
|