Freeciv-3.2: /fast/freeciv/nightly/S3_2/common/spaceship.h Source File

Freeciv-3.2

Loading...
Searching...
No Matches
spaceship.h
Go to the documentation of this file.
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)
6 any later version.
7
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
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* utility */
21#include "bitvector.h"
22#include "support.h" /* bool type */
23
24/* common */
25#include "fc_types.h"
26
27/**********************************************************************
28First, some ascii art showing the spaceship and relevant parts,
29including 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
4110_:::-:::-[30][20][18][16][14][10][ 6][ 4]\F2/\ P2 /:::- S=Solar Panels
42 :::-/======\/======\/======\/======\[s ][s ][s ]:::-:::-
4312_!!!-# M10 ## M6 ## M4 ## M0 #[ 2][ 8][12]!!!-!!!-
44 :::-# L3 ## H2 ## L1 ## H0 #[s ]/C0\/ C1 \:::-
4514_:::-\======/\======/\======/\======/[ 0]\F0/\ P0 /:::-
46 :::-/======\/======\/======\/======\[s ]/C2\/ C3 \:::-
4716_!!!-# M9 ## M7 ## M3 ## M1 #[ 1]\F1/\ P1 /!!!-
48 :::-# H3 ## L2 ## H1 ## L0 #[s ][s ][s ]:::-:::-
4918_:::-\======/\======/\======/\======/[ 3][ 9][13]:::-:::-
50 :::-:::-[s ][s ][s ][s ][s ][s ][s ][s ]/C6\/ C7 \:::-
5120_!!!-!!!-[31][21][19][17][15][11][ 7][ 5]\F3/\ P3 /!!!-
52 :::-:::-\++++++/:::-:::-\++++++/:::-[s ]/C10/ C11 \:::-
5322_:::-:::-# M11 #:::-:::-# M5 #:::-[23]\F5/\ P5 /:::-
54 :::-:::-# S3 #:::-:::-# S1 #:::-[s ][s ][s ]:::-:::-
5524_!!!-!!!-/++++++\!!!-!!!-/++++++\!!!-[25][27][29]!!!-!!!-
56 :::-:::-:::-:::-:::-:::-:::-:::-:::-:::-/C14/ C15 \:::-
5726_:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-\F7/\ P7 /:::-
58 :::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-:::-
5928_!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-!!!-
60
61Now, how things work:
62
63Modules and Components: player (if the client is smart enough)
64can choose which sort of each to build, but not where they are
65built. That is, first module built can be choice of H,L,S,
66but whichever it is, it is H0, L0 or S0. If you build 4 F and
670 P, they will be F0,F1,F2,F3.
68
69Structural are different: the first s must be s0, but after that
70you can in principle build any s which is adjacent (4 ways) to
71another s (but in practice the client may make the choice for you).
72Because you have to start with s0, this means each s actually
73depends on one single other s, so we just note that required s
74below, and don't have to calculate adjacency.
75
76Likewise, whether a component or module is "connected" to the
77structure depends in each case on just a single structural.
78(Actually, F2 and F3 are exceptions, which have a choice
79of two (non-dependent) structs to depend on; we choose just
80the one which must be there for P2 and P3).
81
82**********************************************************************/
83
84 enum spaceship_state {SSHIP_NONE, SSHIP_STARTED,
85 SSHIP_LAUNCHED, SSHIP_ARRIVED};
86
87#define NUM_SS_STRUCTURALS 32 /* Used in the network protocol. */
88#define NUM_SS_COMPONENTS 16
89#define NUM_SS_MODULES 12
90
91/* Used in the network protocol. */
92 BV_DEFINE(bv_spaceship_structure, NUM_SS_STRUCTURALS);
93
94 struct player_spaceship {
95 /* how many of each part built, including any "unplaced": */
96 int structurals;
97 int components;
98 int modules;
99 /* which structurals placed: (array of booleans) */
100 bv_spaceship_structure structure;
101 /* which components and modules placed: (may or may not be connected) */
102 int fuel;
103 int propulsion;
104 int habitation;
105 int life_support;
106 int solar_panels;
107 /* other stuff: */
108 enum spaceship_state state;
109 int launch_year;
110 /* derived quantities: */
111 int population;
112 int mass;
113 double support_rate;
114 double energy_rate;
115 double success_rate;
116 double travel_time;
117};
118
119 struct sship_part_info {
120 int x, y; /* position of tile centre */
121 int required; /* required for struct connection */
122};
123
124extern const struct sship_part_info structurals_info[NUM_SS_STRUCTURALS];
125extern const struct sship_part_info components_info[NUM_SS_COMPONENTS];
126extern const struct sship_part_info modules_info[NUM_SS_MODULES];
127
128void spaceship_init(struct player_spaceship *ship);
129int num_spaceship_structurals_placed(const struct player_spaceship *ship);
130
131 struct spaceship_component
132{
133 enum spaceship_place_type type;
134 int num;
135};
136
137bool next_spaceship_component(struct player *pplayer,
138 struct player_spaceship *ship,
139 struct spaceship_component *fill);
140
141#ifdef __cplusplus
142}
143#endif /* __cplusplus */
144
145#endif /* FC__SPACESHIP_H */
bitvector.h
BV_DEFINE
#define BV_DEFINE(name, bits)
Definition bitvector.h:132
incite_cost
char * incite_cost
Definition comments.c:74
fc_types.h
spaceship_place_type
spaceship_place_type
Definition fc_types.h:1297
NUM_SS_MODULES
#define NUM_SS_MODULES
Definition spaceship.h:89
num_spaceship_structurals_placed
int num_spaceship_structurals_placed(const struct player_spaceship *ship)
Definition spaceship.c:113
next_spaceship_component
bool next_spaceship_component(struct player *pplayer, struct player_spaceship *ship, struct spaceship_component *fill)
Definition spaceship.c:130
NUM_SS_COMPONENTS
#define NUM_SS_COMPONENTS
Definition spaceship.h:88
spaceship_init
void spaceship_init(struct player_spaceship *ship)
Definition spaceship.c:96
structurals_info
const struct sship_part_info structurals_info[NUM_SS_STRUCTURALS]
Definition spaceship.c:23
modules_info
const struct sship_part_info modules_info[NUM_SS_MODULES]
Definition spaceship.c:77
components_info
const struct sship_part_info components_info[NUM_SS_COMPONENTS]
Definition spaceship.c:58
NUM_SS_STRUCTURALS
#define NUM_SS_STRUCTURALS
Definition spaceship.h:87
spaceship_state
spaceship_state
Definition spaceship.h:84
SSHIP_ARRIVED
@ SSHIP_ARRIVED
Definition spaceship.h:85
SSHIP_STARTED
@ SSHIP_STARTED
Definition spaceship.h:84
SSHIP_LAUNCHED
@ SSHIP_LAUNCHED
Definition spaceship.h:85
SSHIP_NONE
@ SSHIP_NONE
Definition spaceship.h:84
player_spaceship
Definition spaceship.h:94
player_spaceship::energy_rate
double energy_rate
Definition spaceship.h:114
player_spaceship::modules
int modules
Definition spaceship.h:98
player_spaceship::mass
int mass
Definition spaceship.h:112
player_spaceship::fuel
int fuel
Definition spaceship.h:102
player_spaceship::solar_panels
int solar_panels
Definition spaceship.h:106
player_spaceship::structure
bv_spaceship_structure structure
Definition spaceship.h:100
player_spaceship::components
int components
Definition spaceship.h:97
player_spaceship::population
int population
Definition spaceship.h:111
player_spaceship::life_support
int life_support
Definition spaceship.h:105
player_spaceship::success_rate
double success_rate
Definition spaceship.h:115
player_spaceship::support_rate
double support_rate
Definition spaceship.h:113
player_spaceship::travel_time
double travel_time
Definition spaceship.h:116
player_spaceship::state
enum spaceship_state state
Definition spaceship.h:108
player_spaceship::structurals
int structurals
Definition spaceship.h:96
player_spaceship::habitation
int habitation
Definition spaceship.h:104
player_spaceship::propulsion
int propulsion
Definition spaceship.h:103
player_spaceship::launch_year
int launch_year
Definition spaceship.h:109
player
Definition player.h:247
spaceship_component
Definition spaceship.h:132
spaceship_component::type
enum spaceship_place_type type
Definition spaceship.h:133
spaceship_component::num
int num
Definition spaceship.h:134
sship_part_info
Definition spaceship.h:119
sship_part_info::y
int y
Definition spaceship.h:120
sship_part_info::required
int required
Definition spaceship.h:121
sship_part_info::x
int x
Definition spaceship.h:120
support.h