1 /* 2 * This program is free software; you can redistribute it and/or modify 3 * it under the terms of the GNU General Public License as published by 4 * the Free Software Foundation; either version 2 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software 14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 15 */ 16 17 #ifndef GENERATE_H 18 #define GENERATE_H 19 20 typedef struct GenerateFunctions GenerateFunctions; 21 22 #include "types.h" 23 #include "planets.h" 24 #include "libs/compiler.h" 25 26 #if defined(__cplusplus) 27 extern "C" { 28 #endif 29 30 /* 31 * To do (for further cleanups): 32 * - split off generateOrbital in a calculation and an activation 33 * (graphics and music) part. 34 * - make generateOrbital return a meaningful value, specifically, whether 35 * or not the player is going into orbit 36 * - for GenerateNameFunction, set the name in an argument, instead 37 * of in GLOBAL_SYS(PlanetName) 38 * - make generateName work for moons 39 * - add parameters to initNcs, reinitNpcs, and uninitNpcs, so that 40 * globals don't have to be used. 41 * - Add a reference from each world to the solar system, so that most 42 * of these functions can do with one less argument. 43 * - (maybe) don't directly call the generate functions via 44 * solarSys->genFuncs->..., but use a function for this, which first 45 * checks for solar system dependent handlers, and if this does not exist, 46 * or returns false, calls the default function. 47 */ 48 49 // Any of these functions returning true means that the action has been 50 // handled, and that the default function should not be called. 51 typedef bool (*InitNpcsFunction)(SOLARSYS_STATE *solarSys); 52 typedef bool (*ReinitNpcsFunction)(SOLARSYS_STATE *solarSys); 53 typedef bool (*UninitNpcsFunction)(SOLARSYS_STATE *solarSys); 54 typedef bool (*GeneratePlanetsFunction)(SOLARSYS_STATE *solarSys); 55 typedef bool (*GenerateMoonsFunction)(SOLARSYS_STATE *solarSys, 56 PLANET_DESC *planet); 57 typedef bool (*GenerateOrbitalFunction)(SOLARSYS_STATE *solarSys, 58 PLANET_DESC *world); 59 typedef bool (*GenerateNameFunction)(const SOLARSYS_STATE *, 60 const PLANET_DESC *world); 61 // The following functions return the number of objects being generated 62 // (or the index of the current object in some cases) 63 typedef COUNT (*GenerateMineralsFunction)(const SOLARSYS_STATE *, 64 const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); 65 typedef COUNT (*GenerateEnergyFunction)(const SOLARSYS_STATE *, 66 const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); 67 typedef COUNT (*GenerateLifeFunction)(const SOLARSYS_STATE *, 68 const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); 69 // The following functions return true if the node should be removed 70 // from the surface, i.e. picked up. 71 typedef bool (*PickupMineralsFunction)(SOLARSYS_STATE *solarSys, 72 PLANET_DESC *world, COUNT whichNode); 73 typedef bool (*PickupEnergyFunction)(SOLARSYS_STATE *solarSys, 74 PLANET_DESC *world, COUNT whichNode); 75 typedef bool (*PickupLifeFunction)(SOLARSYS_STATE *solarSys, 76 PLANET_DESC *world, COUNT whichNode); 77 78 79 struct GenerateFunctions { 80 InitNpcsFunction initNpcs; 81 // Ships in the solar system, the first time it is accessed. 82 ReinitNpcsFunction reinitNpcs; 83 // Ships in the solar system, every next time it is accessed. 84 UninitNpcsFunction uninitNpcs; 85 // When leaving the solar system. 86 GeneratePlanetsFunction generatePlanets; 87 // Layout of planets within a solar system. 88 GenerateMoonsFunction generateMoons; 89 // Layout of moons around a planet. 90 GenerateNameFunction generateName; 91 // Name of a planet. 92 GenerateOrbitalFunction generateOrbital; 93 // Characteristics of words (planets and moons). 94 GenerateMineralsFunction generateMinerals; 95 // Minerals on the planet surface. 96 GenerateEnergyFunction generateEnergy; 97 // Energy sources on the planet surface. 98 GenerateLifeFunction generateLife; 99 // Bio on the planet surface. 100 PickupMineralsFunction pickupMinerals; 101 PickupEnergyFunction pickupEnergy; 102 PickupLifeFunction pickupLife; 103 }; 104 105 #if defined(__cplusplus) 106 } 107 #endif 108 109 #endif /* GENERATE_H */ 110 111