@@ -40,33 +40,36 @@ void building_shipyard::spawn_figure() {
40
40
}
41
41
42
42
int pct_workers = worker_percentage ();
43
- if (pct_workers >= 100 )
44
- data.industry .progress += 10 ;
45
- else if (pct_workers >= 75 )
46
- data.industry .progress += 8 ;
47
- else if (pct_workers >= 50 )
48
- data.industry .progress += 6 ;
49
- else if (pct_workers >= 25 )
50
- data.industry .progress += 4 ;
51
- else if (pct_workers >= 1 )
52
- data.industry .progress += 2 ;
43
+ if (pct_workers >= 100 ) data.industry .progress += 10 ;
44
+ else if (pct_workers >= 75 ) data.industry .progress += 8 ;
45
+ else if (pct_workers >= 50 ) data.industry .progress += 6 ;
46
+ else if (pct_workers >= 25 ) data.industry .progress += 4 ;
47
+ else if (pct_workers >= 1 ) data.industry .progress += 2 ;
53
48
54
- if (data.industry .progress >= 160 ) {
49
+ tile2i boat_tile;
50
+ if (data.industry .progress >= 160 && map_water_can_spawn_boat (tile (), size (), boat_tile)) {
55
51
data.industry .progress = 0 ;
56
- tile2i boat_tile;
57
- if (map_water_can_spawn_fishing_boat (tile (), size (), boat_tile)) {
52
+ data.wharf .process_type = FIGURE_NONE;
53
+ if (data.wharf .process_type == FIGURE_WARSHIP) {
54
+ figure *f = figure_create (FIGURE_WARSHIP, boat_tile, DIR_0_TOP_RIGHT);
55
+ f->action_state = FIGURE_ACTION_205_WARSHIP_CREATED;
56
+ f->set_home (&base);
57
+ base.set_figure (BUILDING_SLOT_BOAT, f);
58
+ } else if (data.wharf .process_type == FIGURE_FISHING_BOAT) {
58
59
figure *f = figure_create (FIGURE_FISHING_BOAT, boat_tile, DIR_0_TOP_RIGHT);
59
60
f->action_state = FIGURE_ACTION_190_FISHING_BOAT_CREATED;
60
61
f->set_home (&base);
61
62
base.set_figure (BUILDING_SLOT_BOAT, f);
63
+ } else {
64
+ assert (false && " building_shipyard: incorrect type requested" );
62
65
}
63
66
}
64
67
}
65
68
66
69
void building_shipyard::bind_dynamic (io_buffer *iob, size_t version) {
67
70
building_industry::bind_dynamic (iob, version);
68
71
69
- data.industry .first_material_id = RESOURCE_BARLEY ;
72
+ data.industry .first_material_id = RESOURCE_TIMBER ;
70
73
71
74
iob->bind (BIND_SIGNATURE_UINT8, &data.wharf .orientation );
72
75
iob->bind (BIND_SIGNATURE_UINT8, &data.wharf .process_type );
@@ -80,8 +83,7 @@ void building_shipyard::update_map_orientation(int orientation) {
80
83
}
81
84
82
85
bool building_shipyard::draw_ornaments_and_animations_height (painter &ctx, vec2i point, tile2i tile, color mask) {
83
- const animation_t &canim = anim (animkeys ().work );
84
- building_draw_normal_anim (ctx, point, &base, tile, canim, mask);
86
+ draw_normal_anim (ctx, point, tile, mask);
85
87
86
88
int amount = ceil ((float )base.stored_amount () / 100.0 ) - 1 ;
87
89
if (amount >= 0 ) {
@@ -107,6 +109,45 @@ void building_shipyard::on_place_update_tiles(int orientation, int variant) {
107
109
map_water_add_building (id (), tile (), size (), anim (animkeys ().base ).first_img () + orientation_rel);
108
110
}
109
111
112
+ void building_shipyard::update_day () {
113
+ if (data.wharf .process_type == FIGURE_WARSHIP && g_city.buildings .warship_boats_requested > 0 ) {
114
+ g_city.buildings .warship_boats_requested --;
115
+ return ;
116
+ }
117
+
118
+ if (data.wharf .process_type == FIGURE_FISHING_BOAT && g_city.buildings .fishing_boats_requested > 0 ) {
119
+ g_city.buildings .fishing_boats_requested --;
120
+ return ;
121
+ }
122
+
123
+ if (data.wharf .process_type == FIGURE_NONE) {
124
+ if (g_city.buildings .warship_boats_requested > 0 && base.stored_full_amount > 400 ) {
125
+ data.wharf .process_type = FIGURE_WARSHIP;
126
+ g_city.buildings .warship_boats_requested --;
127
+ return ;
128
+ }
129
+
130
+ if (g_city.buildings .fishing_boats_requested > 0 ) {
131
+ data.wharf .process_type = FIGURE_FISHING_BOAT;
132
+ g_city.buildings .fishing_boats_requested --;
133
+ return ;
134
+ }
135
+
136
+ assert (false && " Should be a correct type for build" );
137
+ }
138
+ }
139
+
140
+ void building_shipyard::update_graphic () {
141
+ xstring animkey;
142
+ switch (data.wharf .process_type ) {
143
+ case FIGURE_WARSHIP: animkey = animkeys ().work_warship ; break ;
144
+ case FIGURE_FISHING_BOAT: animkey = animkeys ().work_fishing_boat ; break ;
145
+ case FIGURE_TRANSPORT: animkey = animkeys ().work_transport ; break ;
146
+ }
147
+
148
+ set_animation (animkey);
149
+ }
150
+
110
151
void building_shipyard::update_count () const {
111
152
const bool is_active = (num_workers () > 0 && base.has_open_water_access );
112
153
g_city.buildings .track_building (type (), id (), is_active);
0 commit comments