forked from aburch/simutrans
-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathai.h
96 lines (69 loc) · 2.98 KB
/
ai.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* This file is part of the Simutrans-Extended project under the Artistic License.
* (see LICENSE.txt)
*/
#ifndef PLAYER_AI_H
#define PLAYER_AI_H
#include "simplay.h"
#include "../finder/building_placefinder.h"
#include "../descriptor/goods_desc.h"
class karte_t;
class vehicle_desc_t;
class goods_desc_t;
/**
* Search for a free location using the function find_place().
*/
class ai_building_place_with_road_finder : public building_placefinder_t {
public:
ai_building_place_with_road_finder(karte_t *welt) : building_placefinder_t(welt) {}
bool is_road_at(sint16 x, sint16 y) const;
bool is_area_ok(koord pos, sint16 b, sint16 h, climate_bits cl, uint16 allowed_regions) const OVERRIDE;
};
// AI helper functions
class ai_t : public player_t
{
protected:
// set the allowed modes of transport
bool road_transport;
bool rail_transport;
bool ship_transport;
bool air_transport;
// the shorter the faster construction will occur
sint32 construction_speed;
public:
ai_t(uint8 nr);
bool has_road_transport() const { return road_transport; }
virtual void set_road_transport( bool yesno ) { road_transport = yesno; }
bool has_rail_transport() const { return rail_transport; }
virtual void set_rail_transport( bool yesno ) { rail_transport = yesno; }
bool has_ship_transport() const { return ship_transport; }
virtual void set_ship_transport( bool yesno ) { ship_transport = yesno; }
bool has_air_transport() const { return air_transport; }
virtual void set_air_transport( bool yesno ) { air_transport = yesno; }
sint32 get_construction_speed() const { return construction_speed; }
virtual void set_construction_speed( sint32 newspeed ) { construction_speed = newspeed; }
void rdwr(loadsave_t *file) OVERRIDE;
// return true, if there is already a connection
bool is_connected(const koord star_pos, const koord end_pos, const goods_desc_t *wtyp) const;
// calls a general tool just like a human player work do
bool call_general_tool( int tool, koord k, const char *param );
// find space for stations
bool find_place(koord pos, koord &size, koord *dirs);
bool find_place(koord &start, koord &size, koord target, koord off);
// removes building markers
void clean_marker( koord place, koord size );
void set_marker( koord place, koord size );
halthandle_t get_halt( const koord haltpos ) const;
/**
* Find the first water tile using line algorithm
* start MUST be on land!
*/
koord find_shore(koord start, koord end) const;
bool find_harbour(koord &start, koord &size, koord target);
bool built_update_headquarter();
// builds a round between those two places or returns false
bool create_simple_road_transport(koord platz1, koord size1, koord platz2, koord size2, const way_desc_t *road );
/// helper method to call vehicle_builder_t::vehicle_search and fill in time-line related parameters
static const vehicle_desc_t *vehicle_search(waytype_t typ, const uint32 target_power, const sint32 target_speed, const goods_desc_t * target_freight, bool include_electric);
};
#endif