Freeciv21
Develop your civilization from humble roots to a global empire
advspace.cpp
Go to the documentation of this file.
1 /*__ ___ ***************************************
2 / \ / \ Copyright (c) 1996-2020 Freeciv21 and Freeciv
3 \_ \ / __/ contributors. This file is part of Freeciv21.
4  _\ \ / /__ Freeciv21 is free software: you can redistribute it
5  \___ \____/ __/ and/or modify it under the terms of the GNU General
6  \_ _/ Public License as published by the Free Software
7  | @ @ \_ Foundation, either version 3 of the License,
8  | or (at your option) any later version.
9  _/ /\ You should have received a copy of the GNU
10  /o) (o/\ \_ General Public License along with Freeciv21.
11  \_____/ / If not, see https://www.gnu.org/licenses/.
12  \____/ ********************************************************/
13 
14 // common
15 #include "government.h"
16 #include "packets.h"
17 #include "spaceship.h"
18 
19 // server
20 #include "spacerace.h"
21 
22 #include "advspace.h"
23 
29 bool adv_spaceship_autoplace(struct player *pplayer,
30  struct player_spaceship *ship)
31 {
32  struct spaceship_component place;
33  bool retval = false;
34  bool placed;
35 
36  do {
37  placed = next_spaceship_component(pplayer, ship, &place);
38 
39  if (placed) {
40  if (do_spaceship_place(pplayer, ACT_REQ_SS_AGENT, place.type,
41  place.num)) {
42  /* A part was placed. It was placed even if the placement of future
43  * parts will fail. */
44  retval = true;
45  } else {
46  // Unable to place this part. Don't try to place it again.
47  break;
48  }
49  }
50  } while (placed);
51 
52  return retval;
53 }
bool adv_spaceship_autoplace(struct player *pplayer, struct player_spaceship *ship)
Place all available spaceship components.
Definition: advspace.cpp:29
bool do_spaceship_place(struct player *pplayer, enum action_requester from, enum spaceship_place_type type, int num)
Place a spaceship part.
Definition: spacerace.cpp:206
bool next_spaceship_component(struct player *pplayer, struct player_spaceship *ship, struct spaceship_component *fill)
Find (default) place for next spaceship component.
Definition: spaceship.cpp:79
Definition: player.h:231
enum spaceship_place_type type
Definition: spaceship.h:129