forked from Warzone2100/warzone2100
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjmem.h
118 lines (88 loc) · 3.74 KB
/
objmem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
This file is part of Warzone 2100.
Copyright (C) 1999-2004 Eidos Interactive
Copyright (C) 2005-2012 Warzone 2100 Project
Warzone 2100 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Warzone 2100 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Warzone 2100; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/** @file
* Routines for managing object's memory
*/
#ifndef __INCLUDED_SRC_OBJMEM_H__
#define __INCLUDED_SRC_OBJMEM_H__
#include "objectdef.h"
/* The lists of objects allocated */
extern DROID *apsDroidLists[MAX_PLAYERS];
extern STRUCTURE *apsStructLists[MAX_PLAYERS];
extern FEATURE *apsFeatureLists[MAX_PLAYERS];
extern FLAG_POSITION *apsFlagPosLists[MAX_PLAYERS];
extern STRUCTURE *apsExtractorLists[MAX_PLAYERS];
extern BASE_OBJECT *apsSensorList[1];
extern FEATURE *apsOilList[1];
/* The list of destroyed objects */
extern BASE_OBJECT *psDestroyedObj;
/* Initialise the object heaps */
extern bool objmemInitialise(void);
/* Release the object heaps */
extern void objmemShutdown(void);
/* General housekeeping for the object system */
extern void objmemUpdate(void);
/// Generates a new, (hopefully) unique object id.
uint32_t generateNewObjectId(void);
/// Generates a new, (hopefully) unique object id, which all clients agree on.
uint32_t generateSynchronisedObjectId(void);
/* add the droid to the Droid Lists */
extern void addDroid(DROID *psDroidToAdd, DROID *pList[MAX_PLAYERS]);
/*destroy a droid */
void killDroid(DROID *psDel);
/* Remove all droids */
extern void freeAllDroids(void);
/*Remove a single Droid from its list*/
extern void removeDroid(DROID *psDroidToRemove, DROID *pList[MAX_PLAYERS]);
/*Removes all droids that may be stored in the mission lists*/
extern void freeAllMissionDroids(void);
/*Removes all droids that may be stored in the limbo lists*/
extern void freeAllLimboDroids(void);
/* add the structure to the Structure Lists */
extern void addStructure(STRUCTURE *psStructToAdd);
/* Destroy a structure */
void killStruct(STRUCTURE *psDel);
/* Remove all structures */
extern void freeAllStructs(void);
/*Remove a single Structure from a list*/
extern void removeStructureFromList(STRUCTURE *psStructToRemove,
STRUCTURE *pList[MAX_PLAYERS]);
/* add the feature to the Feature Lists */
extern void addFeature(FEATURE *psFeatureToAdd);
/* Destroy a feature */
void killFeature(FEATURE *psDel);
/* Remove all features */
extern void freeAllFeatures(void);
/* Create a new Flag Position */
extern bool createFlagPosition(FLAG_POSITION **ppsNew, UDWORD player);
/* add the Flag Position to the Flag Position Lists */
extern void addFlagPosition(FLAG_POSITION *psFlagPosToAdd);
/* Remove a Flag Position from the Lists */
extern void removeFlagPosition(FLAG_POSITION *psDel);
// free all flag positions
extern void freeAllFlagPositions(void);
extern void freeAllAssemblyPoints(void);
// Find a base object from it's id
extern BASE_OBJECT *getBaseObjFromData(unsigned id, unsigned player, OBJECT_TYPE type);
extern BASE_OBJECT *getBaseObjFromId(UDWORD id);
extern bool checkValidId(UDWORD id);
extern UDWORD getRepairIdFromFlag(FLAG_POSITION *psFlag);
void objCount(int *droids, int *structures, int *features);
#ifdef DEBUG
extern void checkFactoryFlags(void);
#endif
#endif // __INCLUDED_SRC_OBJMEM_H__