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