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