1 /**********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
13 #ifndef FC__SPACESHIP_H
14 #define FC__SPACESHIP_H
18 #endif /* __cplusplus */
21 #include "bitvector.h"
22 #include "support.h" /* bool type */
27 /**********************************************************************
28 First, some ascii art showing the spaceship and relevant parts,
29 including numbering of parts:
30 2 4 6 8 10 12 14 16 18 20 22 24 26 28
31 | | | | | | | | | | | | | |
32 :::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::- s=structural
33 2_:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::- C=component
34 :::-:::-:::-:::-:::-:::-:::-:::-:::-:::-/C12/ C13 \:::- M=module
35 4_!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-\F6/\ P6 /!!!-
36 :::-:::-\++++++/:::-:::-\++++++/:::-[s ][s ][s ]:::-:::- P=Propulsion
37 6_:::-:::-# M8 #:::-:::-# M2 #:::-[24][26][28]:::-:::- F=Fuel
38 :::-:::-# S2 #:::-:::-# S0 #:::-[s ]/C8>/ C9 \:::-
39 8_!!!-!!!-/++++++\!!!-!!!-/++++++\!!!-[22]\F4/\ P4 /!!!- H=Habitation
40 :::-:::-[s ][s ][s ][s ][s ][s ][s ][s ]/C4>/ C5 \:::- L=Life Support
41 10_:::-:::-[30][20][18][16][14][10][ 6][ 4]\F2/\ P2 /:::- S=Solar Panels
42 :::-/======\/======\/======\/======\[s ][s ][s ]:::-:::-
43 12_!!!-# M10 ## M6 ## M4 ## M0 #[ 2][ 8][12]!!!-!!!-
44 :::-# L3 ## H2 ## L1 ## H0 #[s ]/C0\/ C1 \:::-
45 14_:::-\======/\======/\======/\======/[ 0]\F0/\ P0 /:::-
46 :::-/======\/======\/======\/======\[s ]/C2\/ C3 \:::-
47 16_!!!-# M9 ## M7 ## M3 ## M1 #[ 1]\F1/\ P1 /!!!-
48 :::-# H3 ## L2 ## H1 ## L0 #[s ][s ][s ]:::-:::-
49 18_:::-\======/\======/\======/\======/[ 3][ 9][13]:::-:::-
50 :::-:::-[s ][s ][s ][s ][s ][s ][s ][s ]/C6\/ C7 \:::-
51 20_!!!-!!!-[31][21][19][17][15][11][ 7][ 5]\F3/\ P3 /!!!-
52 :::-:::-\++++++/:::-:::-\++++++/:::-[s ]/C10/ C11 \:::-
53 22_:::-:::-# M11 #:::-:::-# M5 #:::-[23]\F5/\ P5 /:::-
54 :::-:::-# S3 #:::-:::-# S1 #:::-[s ][s ][s ]:::-:::-
55 24_!!!-!!!-/++++++\!!!-!!!-/++++++\!!!-[25][27][29]!!!-!!!-
56 :::-:::-:::-:::-:::-:::-:::-:::-:::-:::-/C14/ C15 \:::-
57 26_:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-\F7/\ P7 /:::-
58 :::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-
59 28_!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-
63 Modules and Components: player (if the client is smart enough)
64 can choose which sort of each to build, but not where they are
65 built. That is, first module built can be choice of H,L,S,
66 but whichever it is, it is H0, L0 or S0. If you build 4 F and
67 0 P, they will be F0,F1,F2,F3.
69 Structural are different: the first s must be s0, but after that
70 you can in principle build any s which is adjacent (4 ways) to
71 another s (but in practice the client may make the choice for you).
72 Because you have to start with s0, this means each s actually
73 depends on one single other s, so we just note that required s
74 below, and don't have to calculate adjacency.
76 Likewise, whether a component or module is "connected" to the
77 structure depends in each case on just a single structural.
78 (Actually, F2 and F3 are exceptions, which have a choice
79 of two (non-dependent) structs to depend on; we choose just
80 the one which must be there for P2 and P3).
82 **********************************************************************/
84 enum spaceship_state
{SSHIP_NONE
, SSHIP_STARTED
,
85 SSHIP_LAUNCHED
, SSHIP_ARRIVED
};
87 #define NUM_SS_STRUCTURALS 32 /* Used in the network protocol. */
88 #define NUM_SS_COMPONENTS 16
89 #define NUM_SS_MODULES 12
91 /* Used in the network protocol. */
92 BV_DEFINE(bv_spaceship_structure
, NUM_SS_STRUCTURALS
);
94 struct player_spaceship
{
95 /* how many of each part built, including any "unplaced": */
99 /* which structurals placed: (array of booleans) */
100 bv_spaceship_structure structure
;
101 /* which components and modules placed: (may or may not be connected) */
108 enum spaceship_state state
;
110 /* derived quantities: */
119 struct sship_part_info
{
120 int x
, y
; /* position of tile centre */
121 int required
; /* required for struct connection */
124 extern const struct sship_part_info structurals_info
[NUM_SS_STRUCTURALS
];
125 extern const struct sship_part_info components_info
[NUM_SS_COMPONENTS
];
126 extern const struct sship_part_info modules_info
[NUM_SS_MODULES
];
128 void spaceship_init(struct player_spaceship
*ship
);
129 int num_spaceship_structurals_placed(const struct player_spaceship
*ship
);
131 struct spaceship_component
133 enum spaceship_place_type type
;
137 bool next_spaceship_component(struct player
*pplayer
,
138 struct player_spaceship
*ship
,
139 struct spaceship_component
*fill
);
143 #endif /* __cplusplus */
145 #endif /* FC__SPACESHIP_H */