~ubuntu-branches/ubuntu/karmic/starvoyager/karmic

« back to all changes in this revision

Viewing changes to planet.h

  • Committer: Bazaar Package Importer
  • Author(s): Idan Sofer
  • Date: 2003-08-01 16:55:13 UTC
  • Revision ID: james.westby@ubuntu.com-20030801165513-0ueb129iym99k7tg
Tags: upstream-0.4.4
ImportĀ upstreamĀ versionĀ 0.4.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
        planet.h
 
3
        
 
4
        (c) Richard Thrippleton
 
5
        Licensing terms are in the 'LICENSE' file
 
6
        If that file is not included with this source then permission is not given to use this source in any way whatsoever.
 
7
*/
 
8
 
 
9
class sprite;
 
10
class alliance;
 
11
class equip;
 
12
class ship;
 
13
class graphic;
 
14
struct cord;
 
15
 
 
16
class planet //Planet object
 
17
{
 
18
        public:
 
19
        const static int ISIZE=256; //Count of available planets in the index
 
20
        enum {STAR=0,INHABITED=1,UNINHABITED=2}; //Planetary object types
 
21
 
 
22
        planet(char* nam,cord put,int typ,alliance* all); //Spawn a new planet
 
23
        ~planet(); //Destructor, resolves dependencies
 
24
 
 
25
        static void init(); //Initialise datastructures for the planet module
 
26
        static void purgeall(); //Cleans up and purges planet data, used after a game
 
27
        static planet* get(int indx); //Return the planet of given index
 
28
        static planet* pick(alliance* tali); //Pick a random planet of given alliance
 
29
        static planet* pickally(alliance* tali); //Pick a random planet allied to given alliance
 
30
        static planet* pickhostile(alliance* tali); //Pick a random planet hostile to given alliance
 
31
        static bool masslock(cord loc); //Return whether or not given location is mass-locked by planets
 
32
        static void saveall(); //Save all the planets to the database
 
33
        static void loadall(); //Load all the planets from the database
 
34
        static void generatename(char* put); //Generate a planetary name, put it in put
 
35
        static void shipyards(); //Randomly spawn ships
 
36
 
 
37
        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)
 
38
        void netout(int typ,unsigned char* buf); //Get type of data from planet into a network buffer
 
39
 
 
40
        int self; //Self index
 
41
        int spr; //Sprite to display for this
 
42
        cord loc; //Location
 
43
        alliance* all; //Alliance
 
44
        int typ; //Planet type 1:Sun 2:Uninhabited 3:Inhabited
 
45
 
 
46
        private:
 
47
        planet(int self); //Constructor, given self index loads the planet from the database
 
48
 
 
49
        void save(); //Save this planet to the database
 
50
        void load(); //Load this planet from the database
 
51
        void shipyard(); //Spawn a ship from the library at this planet
 
52
 
 
53
        static planet* planets[ISIZE]; //Planets in the index
 
54
 
 
55
        char nam[65]; //Name
 
56
        int rot; //Version of sprite to use
 
57
        equip* sold[8]; //Sold equipment
 
58
};