TRECISION: set private some members of PathFinding3D, add PathFinding3D::syncGameStream

This commit is contained in:
Strangerke 2021-05-14 21:07:27 +01:00 committed by SupSuper
parent dd0884f9b6
commit d14108efca
3 changed files with 34 additions and 34 deletions

View File

@ -910,7 +910,7 @@ void Renderer3D::paintScreen(bool flag) {
// For every box from the horizon forward...
// Copy per level
for (int liv = _vm->_pathFind->_numSortPan; liv >= 0; liv--) {
for (int liv = _vm->_pathFind->_numSortPanel; liv >= 0; liv--) {
uint16 curBox = _vm->_pathFind->_sortPan[liv]._num;
// draws all objects and animations that intersect the boundaries and refer to the current box
@ -1049,7 +1049,7 @@ PathFinding3D::PathFinding3D(TrecisionEngine *vm) : _vm(vm) {
_oldPanel = -1;
_numPathNodes = 0;
_numSortPan = 0;
_numSortPanel = 0;
_x3d = 0.0f;
_y3d = 0.0f;
_z3d = 0.0f;
@ -2248,9 +2248,9 @@ void PathFinding3D::sortPath() {
Initializes sort panel
--------------------------------------------------*/
void PathFinding3D::initSortPan() {
_numSortPan = 31;
_numSortPanel = 31;
for (int a = 1; a < _numSortPan - 1; ++a) {
for (int a = 1; a < _numSortPanel - 1; ++a) {
_sortPan[a]._min = 32000.0f;
_sortPan[a]._num = a;
}
@ -2272,7 +2272,7 @@ void PathFinding3D::initSortPan() {
float min = MIN(dist1, dist2);
for (int a = 0; a < _numSortPan; ++a) {
for (int a = 0; a < _numSortPanel; ++a) {
if (_panel[b]._flags & (1 << a)) {
if (_sortPan[a + 1]._min > min)
_sortPan[a + 1]._min = min;
@ -2283,10 +2283,10 @@ void PathFinding3D::initSortPan() {
sortPanel();
for (int b = 0; b < _numSortPan; ++b) {
for (int b = 0; b < _numSortPanel; ++b) {
if (_sortPan[b]._num == BOX_BACKGROUND) {
// now the panels go from 0 (foreground) to _numSortPan (background)
_numSortPan = b;
// now the panels go from 0 (foreground) to _numSortPanel (background)
_numSortPanel = b;
break;
}
}
@ -2378,7 +2378,7 @@ int panelCompare(const void *arg1, const void *arg2) {
Sort the panels
--------------------------------------------------*/
void PathFinding3D::sortPanel() {
qsort(&_sortPan[0], _numSortPan, sizeof(SSortPan), panelCompare);
qsort(&_sortPan[0], _numSortPanel, sizeof(SSortPan), panelCompare);
}
/*------------------------------------------------
@ -2689,7 +2689,7 @@ void PathFinding3D::actorOrder() {
// It must be copied in front of the nearest box
_vm->_actorPos = _sortPan[1]._num;
// from closest to farthest
for (int b = 1; b < _numSortPan; b++) {
for (int b = 1; b < _numSortPanel; b++) {
for (int a = 0; a < _panelNum; a++) {
// If it's not wide and belongs to this level
if (!(_panel[a]._flags & 0x80000000) && (_panel[a]._flags & (1 << (_sortPan[b]._num - 1)))) {
@ -2703,4 +2703,9 @@ void PathFinding3D::actorOrder() {
}
}
void PathFinding3D::syncGameStream(Common::Serializer &ser) {
ser.syncAsSint32LE(_curPanel);
ser.syncAsSint32LE(_oldPanel);
}
} // End of namespace Trecision

View File

@ -156,33 +156,38 @@ class PathFinding3D {
private:
TrecisionEngine *_vm;
bool pointInside(int pan, float x, float z);
SPathNode _pathNode[MAXPATHNODES];
float _invP[3][3];
int _numPathNodes;
float _x3d, _y3d, _z3d;
float _curX, _curZ;
float _lookX, _lookZ;
int _panelNum;
int _oldPanel;
bool pointInside(int pan, float x, float z);
void sortPanel();
void pointOut();
void invPointProject(int x, int y);
bool intersectLinePanel(SPan *p, float x, float y, float z);
bool intersectLineFloor(float x, float y, float z);
bool intersectLineLine(float xa, float ya, float xb, float yb, float xc, float yc, float xd, float yd);
float _invP[3][3];
int _numPathNodes;
float _x3d, _y3d, _z3d;
float _curX, _curZ;
void findShortPath();
float evalPath(int a, float destX, float destZ, int nearP);
void lookAt(float x, float z);
void buildFramelist();
void displayPath();
bool findAttachedPanel(int srcPanel, int destPanel);
void sortPath();
public:
PathFinding3D(TrecisionEngine *vm);
~PathFinding3D();
float _lookX;
float _lookZ;
int _curStep;
int _lastStep;
int _panelNum;
int _curPanel;
int _oldPanel;
int _numSortPan;
int _numSortPanel;
int8 _characterGoToPosition;
bool _characterInMovement;
@ -191,23 +196,15 @@ public:
SPan _panel[MAXPANELSINROOM];
void findPath();
void findShortPath();
float evalPath(int a, float destX, float destZ, int nearP);
void setPosition(int num);
void goToPosition(int num);
void lookAt(float x, float z);
void buildFramelist();
int nextStep();
void displayPath();
bool findAttachedPanel(int srcPanel, int destPanel);
// int pathCompare(const void *arg1, const void *arg2);
void sortPath();
void initSortPan();
void read3D(Common::SeekableReadStream *ff);
void reset(uint16 idx, float px, float pz, float theta);
void whereIs(int px, int py);
void actorOrder();
void syncGameStream(Common::Serializer &ser);
}; // end of class
} // end of namespace

View File

@ -370,9 +370,7 @@ bool TrecisionEngine::syncGameStream(Common::Serializer &ser) {
syncInventory(ser);
_actor->syncGameStream(ser);
ser.syncAsSint32LE(_pathFind->_curPanel);
ser.syncAsSint32LE(_pathFind->_oldPanel);
_pathFind->syncGameStream(ser);
for (int a = 0; a < MAXROOMS; a++) {
ser.syncBytes((byte *)_room[a]._baseName, 4);