ScummVM API documentation
lines.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef HOPKINS_LINES_H
23 #define HOPKINS_LINES_H
24 
25 #include "hopkins/globals.h"
26 
27 #include "common/scummsys.h"
28 #include "common/str.h"
29 
30 namespace Hopkins {
31 
32 class HopkinsEngine;
33 
34 struct LigneZoneItem {
35  int _count;
36  int _bobZoneIdx;
37  int16 *_zoneData;
38 };
39 
40 #define INVALID_LINE_VALUE 1300
41 
42 #define MAX_LINES 400
43 
44 struct RouteItem;
45 
46 struct LigneItem {
47  int _lineDataEndIdx;
48  Directions _direction;
49  Directions _directionRouteInc;
50  Directions _directionRouteDec;
51  int16 *_lineData;
52 
53  int appendToRouteInc(int from, int to, RouteItem *route, int index);
54  int appendToRouteDec(int from, int to, RouteItem *route, int index);
55 };
56 
57 struct SmoothItem {
58  int _posX;
59  int _posY;
60 };
61 
62 struct SegmentItem {
63  int _minZoneLineIdx;
64  int _maxZoneLineIdx;
65 };
66 
68  bool _enabledFl;
69  int _left;
70  int _right;
71  int _top;
72  int _bottom;
73  int _minZoneLineIdx;
74  int _maxZoneLineIdx;
75  bool _squareZoneFl;
76 };
77 
78 struct ZoneItem {
79  int _destX;
80  int _destY;
81  int _spriteIndex;
82  int _verbFl1;
83  int _verbFl2;
84  int _verbFl3;
85  int _verbFl4;
86  int _verbFl5;
87  int _verbFl6;
88  int _verbFl7;
89  int _verbFl8;
90  int _verbFl9;
91  int _verbFl10;
92  bool _enabledFl;
93  int _messageId;
94 };
95 
96 struct RouteItem {
97  int16 _x;
98  int16 _y;
99  Directions _dir;
100  bool isValid() const { return _x != -1 || _y != -1; }
101  void invalidate() { _x = _y = -1; _dir = DIR_NONE; }
102  void set(int16 X, int16 Y, Directions dir) { _x = X; _y = Y; _dir = dir; }
103 };
104 
105 
107 private:
108  HopkinsEngine *_vm;
109 
110  bool _forceHideText;
111  int _hotspotTextColor;
112  int _pathFindingMaxDepth;
113  SmoothItem _smoothRoute[4000];
114  Directions _smoothMoveDirection;
115  LigneZoneItem _zoneLine[MAX_LINES+1];
116  SegmentItem _segment[101];
117  int _currentSegmentId;
118  int _maxLineIdx;
119  int _lastLine;
120  int _newLineIdx;
121  int _newLineDataIdx;
122  int _newRouteIdx;
123  int _newPosX;
124  int _newPosY;
125  int _oldMouseX, _oldMouseY;
126  int _oldRouteFromX;
127  int _oldRouteFromY;
128  int _oldRouteDestX;
129  int _oldRouteDestY;
130  int _oldZoneNum;
131 
132  byte *_largeBuf;
133  RouteItem *_testRoute0;
134  RouteItem *_testRoute1;
135  int16 *_lineBuf;
136  RouteItem _bestRoute[8001];
137  int _zoneSkipCount;
138  int _oldMouseZoneId;
139 
140  int avoidObstacle(int lineIdx, int lineDataIdx, int routeIdx, int destLineIdx, int destLineDataIdx, RouteItem *route);
141  int avoidObstacleOnSegment(int lineIdx, int lineDataIdx, int routeIdx, int destLineIdx, int destLineDataIdx, RouteItem *route, int startLineIdx, int endLineIdx);
142  int checkInventoryHotspotsRow(int posX, int minZoneNum, bool lastRow);
143  void removeZoneLine(int idx);
144  void removeLine(int idx);
145  int checkCollision(int xp, int yp);
146  bool checkCollisionLine(int xp, int yp, int *foundDataIdx, int *foundLineIdx, int startLineIdx, int endLineIdx);
147  bool checkSmoothMove(int fromX, int fromY, int destX, int destY);
148  bool makeSmoothMove(int fromX, int fromY, int destX, int destY);
149  int characterRoute(int fromX, int fromY, int destX, int destY, int startLineIdx, int endLineIdx, int routeIdx);
150  int testLine(int paramX, int paramY, int *testValue, int *foundLineIdx, int *foundDataIdx);
151  void useRoute0(int idx, int curRouteIdx);
152  void useRoute1(int idx, int curRouteIdx);
153  void useRoute2(int idx, int curRouteIdx);
154  int computeYSteps(int idx);
155  int computeRouteIdx(int lineIdx, int dataIdx, int fromX, int fromY, int destX, int destY, int routerIdx, RouteItem *route);
156 
157  bool MIRACLE(int fromX, int fromY, int lineIdx, int destLineIdx, int routeIdx);
158  bool PLAN_TEST(int paramX, int paramY, int superRouteIdx, int paramStartLineIdx, int paramEndLineIdx);
159 
160 public:
161  RouteItem *_route;
162  RouteItem *_testRoute2;
163 
164  int _bobZone[105];
165  bool _bobZoneFl[105];
166  ZoneItem _zone[106];
167  SquareZoneItem _squareZone[101];
168  LigneItem _lineItem[MAX_LINES];
169  int _linesNumb;
170 
172  ~LinesManager();
173  void clearAll();
174 
175  void setMaxLineIdx(int idx);
176  int checkInventoryHotspots(int posX, int posY);
177  void addZoneLine(int idx, int fromX, int fromY, int destX, int destY, int bobZoneIdx);
178  void loadLines(const Common::Path &file);
179  void addLine(int lineIdx, Directions direction, int fromX, int fromY, int destX, int destY);
180  void initRoute();
181  RouteItem *findRoute(int fromX, int fromY, int destX, int destY);
182  RouteItem *cityMapCarRoute(int x1, int y1, int x2, int y2);
183  void clearAllZones();
184  void initSquareZones();
185  void resetLines();
186  void resetLinesNumb();
187  void resetLastLine();
188  void enableZone(int idx);
189  void disableZone(int idx);
190  void checkZone();
191  int getMouseZone();
192  void optimizeRoute(RouteItem *route);
193 };
194 
195 } // End of namespace Hopkins
196 
197 #endif /* HOPKINS_FONT_H */
Definition: lines.h:106
Definition: lines.h:34
Definition: lines.h:96
Definition: path.h:52
Definition: lines.h:78
Definition: lines.h:57
Definition: lines.h:46
Definition: lines.h:67
Definition: anim.h:30
Definition: lines.h:62
Definition: hopkins.h:86