Freeciv21
Develop your civilization from humble roots to a global empire
aiferry.h
Go to the documentation of this file.
1 /**************************************************************************
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  part of Freeciv21. Freeciv21 is free software: you can redistribute it
4  and/or modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation, either version 3 of the
6  License, or (at your option) any later version. You should have received
7  a copy of the GNU General Public License along with Freeciv21. If not,
8  see https://www.gnu.org/licenses/.
9 **************************************************************************/
10 #pragma once
11 
12 #include "support.h" // bool type
13 
14 #include "fc_types.h"
15 
16 class PFPath;
17 struct pft_amphibious;
18 
19 bool dai_is_ferry_type(const struct unit_type *pferry, struct ai_type *ait);
20 bool dai_is_ferry(struct unit *pferry, struct ai_type *ait);
21 
22 /*
23  * Initialize ferrybaot-related statistics in the ai data.
24  */
25 void aiferry_init_stats(struct ai_type *ait, struct player *pplayer);
26 
27 /*
28  * Find the nearest boat. Can be called from inside the continents too
29  */
30 int aiferry_find_boat(struct ai_type *ait, struct unit *punit, int cap,
31  PFPath *path);
32 
33 /*
34  * How many boats are available
35  */
36 int aiferry_avail_boats(struct ai_type *ait, struct player *pplayer);
37 
38 /*
39  * Initializes aiferry stats for a new unit
40  */
41 void dai_ferry_init_ferry(struct ai_type *ait, struct unit *ferry);
42 void dai_ferry_lost(struct ai_type *ait, struct unit *punit);
43 void dai_ferry_transformed(struct ai_type *ait, struct unit *ferry,
44  const struct unit_type *old);
45 
46 /*
47  * Release the boat reserved in punit's ai.ferryboat field.
48  */
49 void aiferry_clear_boat(struct ai_type *ait, struct unit *punit);
50 
51 /*
52  * Go to the destination by hitching a ride on a boat. Will try to find
53  * a beachhead but it works better if dst_tile is on the coast.
54  * Loads a bodyguard too, if necessary.
55  */
56 bool aiferry_gobyboat(struct ai_type *ait, struct player *pplayer,
57  struct unit *punit, struct tile *dst_tile,
58  bool with_bodyguard);
59 /*
60  * Go to the destination on a particular boat. Will try to find
61  * a beachhead but it works better if ptile is on the coast.
62  */
63 bool aiferry_goto_amphibious(struct ai_type *ait, struct unit *ferry,
64  struct unit *passenger, struct tile *ptile);
65 
66 bool dai_amphibious_goto_constrained(struct ai_type *ait, struct unit *ferry,
67  struct unit *passenger,
68  struct tile *ptile,
69  struct pft_amphibious *parameter);
70 
71 bool is_boat_free(struct ai_type *ait, struct unit *boat, struct unit *punit,
72  int cap);
73 bool is_boss_of_boat(struct ai_type *ait, struct unit *punit);
74 
75 /*
76  * Main boat managing function. Gets units on board to where they want to
77  * go and then looks for new passengers or (if it fails) for a city which
78  * will build a passenger soon.
79  */
80 void dai_manage_ferryboat(struct ai_type *ait, struct player *pplayer,
81  struct unit *punit);
int aiferry_find_boat(struct ai_type *ait, struct unit *punit, int cap, PFPath *path)
Proper and real PF function for finding a boat.
Definition: aiferry.cpp:490
void dai_manage_ferryboat(struct ai_type *ait, struct player *pplayer, struct unit *punit)
It's about 12 feet square and has a capacity of almost 1000 pounds.
Definition: aiferry.cpp:1080
bool is_boat_free(struct ai_type *ait, struct unit *boat, struct unit *punit, int cap)
Runs a few checks to determine if "boat" is a free boat that can carry "cap" units of the same type a...
Definition: aiferry.cpp:438
bool dai_is_ferry_type(const struct unit_type *pferry, struct ai_type *ait)
Print the list of boats of pplayer.
Definition: aiferry.cpp:146
void aiferry_init_stats(struct ai_type *ait, struct player *pplayer)
Call to initialize the ferryboat statistics.
Definition: aiferry.cpp:84
void dai_ferry_lost(struct ai_type *ait, struct unit *punit)
Close ferry when player loses it.
Definition: aiferry.cpp:218
void dai_ferry_transformed(struct ai_type *ait, struct unit *ferry, const struct unit_type *old)
Update ferry system when unit is transformed.
Definition: aiferry.cpp:186
bool aiferry_goto_amphibious(struct ai_type *ait, struct unit *ferry, struct unit *passenger, struct tile *ptile)
Move a passenger on a ferry to a specified destination.
Definition: aiferry.cpp:724
bool is_boss_of_boat(struct ai_type *ait, struct unit *punit)
Check if unit is boss in ferry.
Definition: aiferry.cpp:470
int aiferry_avail_boats(struct ai_type *ait, struct player *pplayer)
Returns the number of available boats.
Definition: aiferry.cpp:351
bool dai_amphibious_goto_constrained(struct ai_type *ait, struct unit *ferry, struct unit *passenger, struct tile *ptile, struct pft_amphibious *parameter)
Move a passenger on a ferry to a specified destination.
Definition: aiferry.cpp:633
bool dai_is_ferry(struct unit *pferry, struct ai_type *ait)
Should unit be considered a ferry?
Definition: aiferry.cpp:157
void dai_ferry_init_ferry(struct ai_type *ait, struct unit *ferry)
Initialize new ferry when player gets it.
Definition: aiferry.cpp:165
void aiferry_clear_boat(struct ai_type *ait, struct unit *punit)
Use on a unit which no longer needs a boat.
Definition: aiferry.cpp:248
bool aiferry_gobyboat(struct ai_type *ait, struct player *pplayer, struct unit *punit, struct tile *dst_tile, bool with_bodyguard)
This function is to be called if punit needs to use a boat to get to the destination.
Definition: aiferry.cpp:759
Definition: ai.h:42
Definition: player.h:231
Definition: tile.h:42
Definition: unit.h:134