ScummVM API documentation
move_list.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 AGS_ENGINE_AC_MOVE_LIST_H
23 #define AGS_ENGINE_AC_MOVE_LIST_H
24 
25 #include "ags/lib/allegro.h" // fixed math
26 #include "ags/engine/game/savegame.h"
27 #include "ags/shared/util/geometry.h"
28 
29 namespace AGS3 {
30 
31 // Forward declaration
32 namespace AGS {
33 namespace Shared {
34 class Stream;
35 }
36 }
37 using namespace AGS; // FIXME later
38 
39 #define MAXNEEDSTAGES 256
40 #define MAXNEEDSTAGES_LEGACY 40
41 
42 enum MoveListDoneFlags {
43  kMoveListDone_X = 0x01,
44  kMoveListDone_Y = 0x02,
45  kMoveListDone_XY = kMoveListDone_X | kMoveListDone_Y
46 };
47 
48 enum MoveListSvgVersion {
49  kMoveSvgVersion_Initial = 0, // [UNSUPPORTED] from 3.5.0 pre-alpha
50  kMoveSvgVersion_350, // new pathfinder, arbitrary number of stages
51  kMoveSvgVersion_36109, // skip empty lists, progress as float
52 };
53 
54 struct MoveList {
55  int numstage = 0;
56  // Waypoints, per stage
57  Point pos[MAXNEEDSTAGES];
58  // xpermove and ypermove contain number of pixels done per a single step
59  // along x and y axes; i.e. this is a movement vector, per path stage
60  fixed xpermove[MAXNEEDSTAGES]{};
61  fixed ypermove[MAXNEEDSTAGES]{};
62  int onstage = 0; // current path stage
63  Point from; // current stage's starting position
64  // Steps made during current stage;
65  // distance passed is calculated as xpermove[onstage] * onpart;
66  // made a fractional value to let recalculate movelist dynamically
67  float onpart = 0.f;
68  uint8_t doneflag = 0u;
69  uint8_t direct = 0; // MoveCharDirect was used or not
70 
71  // Dynamic fixups, not serialized
72  // Final section move speed and steps, used when an object
73  // finishes one of the axes sooner than the other
74  fixed fin_move = 0;
75  float fin_from_part = 0.f;
76 
77  const Point &GetLastPos() const { return numstage > 0 ? pos[numstage - 1] : pos[0]; }
78 
79  // Gets a movelist's step length, in coordinate units
80  // (normally the coord unit is a game pixel)
81  float GetStepLength() const;
82  // Gets a fraction of a coordinate unit that is in progress of stepping over;
83  // (normally the coord unit is a game pixel)
84  float GetPixelUnitFraction() const;
85  // Sets a step progress to this fraction of a coordinate unit
86  void SetPixelUnitFraction(float frac);
87 
88  void ReadFromSavegame_Legacy(Shared::Stream *in);
89  AGS::Engine::HSaveError ReadFromSavegame(Shared::Stream *in, int32_t cmp_ver);
90  void WriteToSavegame(Shared::Stream *out) const;
91 };
92 
93 } // namespace AGS3
94 
95 #endif
Definition: achievements_tables.h:27
Definition: move_list.h:54
Definition: geometry.h:87
Definition: stream.h:52
Definition: error.h:110
Definition: ags.h:40