-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplanet.h
58 lines (47 loc) · 2.3 KB
/
planet.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
/*
planet.h
(c) Richard Thrippleton
Licensing terms are in the 'LICENSE' file
If that file is not included with this source then permission is not given to use this source in any way whatsoever.
*/
class sprite;
class alliance;
class equip;
class ship;
class graphic;
struct cord;
class planet //Planet object
{
public:
const static int ISIZE=256; //Count of available planets in the index
enum {STAR=0,INHABITED=1,UNINHABITED=2}; //Planetary object types
planet(char* nam,cord put,int typ,alliance* all); //Spawn a new planet
~planet(); //Destructor, resolves dependencies
static void init(); //Initialise datastructures for the planet module
static void purgeall(); //Cleans up and purges planet data, used after a game
static planet* get(int indx); //Return the planet of given index
static planet* pick(alliance* tali); //Pick a random planet of given alliance
static planet* pickally(alliance* tali); //Pick a random planet allied to given alliance
static planet* pickhostile(alliance* tali); //Pick a random planet hostile to given alliance
static bool masslock(cord loc); //Return whether or not given location is mass-locked by planets
static void saveall(); //Save all the planets to the database
static void loadall(); //Load all the planets from the database
static void generatename(char* put); //Generate a planetary name, put it in put
static void shipyards(); //Randomly spawn ships
int interact(char* txt,short cmod,short opr,ship* mshp); //Handles a server request for information/action from this planet, with the given comm mode, operand and player's ship, writing the text into txt and returning the sprite index (-1 if n/a)
void netout(int typ,unsigned char* buf); //Get type of data from planet into a network buffer
int self; //Self index
int spr; //Sprite to display for this
cord loc; //Location
alliance* all; //Alliance
int typ; //Planet type 1:Sun 2:Uninhabited 3:Inhabited
private:
planet(int self); //Constructor, given self index loads the planet from the database
void save(); //Save this planet to the database
void load(); //Load this planet from the database
void shipyard(); //Spawn a ship from the library at this planet
static planet* planets[ISIZE]; //Planets in the index
char nam[65]; //Name
int rot; //Version of sprite to use
equip* sold[8]; //Sold equipment
};