ScummVM API documentation
mission.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  * Based on the original sources
22  * Faery Tale II -- The Halls of the Dead
23  * (c) 1993-1996 The Wyrmkeep Entertainment Co.
24  */
25 
26 #ifndef SAGA2_MISSION_H
27 #define SAGA2_MISSION_H
28 
29 #include "saga2/objects.h"
30 
31 namespace Saga2 {
32 
33 // Used to store a record of mission knowledge that
34 // has been added to an actor, and will be deleted after
35 // the mission is destructed.
36 struct KnowledgeID {
37  ObjectID id;
38  uint16 kID;
39 };
40 
41 class ActiveMission;
42 
43 #include "common/pack-start.h"
44 
45 // Mission flags
46 enum missionFlags {
47  kInUse = (1 << 0) // this mission struct in use
48 };
49 
51  // Store the unique ID of this active mission, and the
52  // object ID of the generator.
53  uint16 missionID; // ID of this instance
54  ObjectID generatorID; // ObjectID of generator instance
55  uint16 missionScript; // script for this mission
56  uint16 missionFlags; // various mission flags
57 
58  // Specific variables relating to the mission which can
59  // be defined by the script writer.
60  uint8 missionVars[32];
61 
62  // Record what resources were created for this mission
63  ObjectID missionObjectList[32];
64  KnowledgeID missionKnowledgeList[32];
65  uint16 numObjectIDs,
66  numKnowledgeIDs;
67 
68  ActiveMission *aMission; // ActiveMission this ActiveMissionData belongs to
69 } PACKED_STRUCT;
70 
71 #include "common/pack-end.h"
72 
74 
75  friend void initMissions();
76  friend void cleanupMissions();
77 
78 public:
79 
80  ActiveMissionData _data;
81 
82 public:
83  static ActiveMission *newMission(ObjectID genID, uint16 script);
84  static int findMission(ObjectID genID);
85  static ActiveMission *missionAddress(int index);
86 
87  void read(Common::InSaveFile *in);
88  void write(Common::MemoryWriteStreamDynamic *out);
89 
90  void cleanup();
91 
92  bool spaceForObject() {
93  return _data.numObjectIDs < ARRAYSIZE(_data.missionObjectList);
94  }
95 
96  // Add record of object creation to mission
97  bool addObjectID(ObjectID objID);
98 
99  // Add record of object creation to mission
100  bool removeObjectID(ObjectID objID);
101 
102  // Add record of knowledge creation to mission
103  bool addKnowledgeID(ObjectID actor, uint16 knowledgeID);
104 
105  // Add record of knowledge creation to mission
106  bool removeKnowledgeID(ObjectID actor, uint16 knowledgeID);
107 
108  int16 getMissionID() {
109  return _data.missionID;
110  }
111 
112  uint16 getScript() {
113  return _data.missionScript;
114  }
115 };
116 
117 // Initialize the active mission list
118 void initMissions();
119 
120 void saveMissions(Common::OutSaveFile *out);
121 void loadMissions(Common::InSaveFile *in);
122 
123 // Cleanup the active mission list
124 inline void cleanupMissions() { /* do nothing */ }
125 
126 } // end of namespace Saga2
127 
128 #endif
#define ARRAYSIZE(x)
Definition: util.h:91
Definition: savefile.h:54
Definition: actor.h:32
Definition: memstream.h:194
Definition: stream.h:745
Definition: mission.h:73
Definition: mission.h:50
Definition: mission.h:36