@@ -191,7 +191,7 @@ int building_dock::trader_city_id() {
191
191
: 0 ;
192
192
}
193
193
194
- bool building_dock::is_good_accepted (e_resource r) {
194
+ bool building_dock::is_trade_accepted (e_resource r) {
195
195
return data.dock .trading_goods .is_set (r);
196
196
}
197
197
@@ -209,15 +209,14 @@ bool building_dock_accepts_ship(int ship_id, int dock_id) {
209
209
210
210
empire_city* city = g_empire.city (f->empire_city_id );
211
211
const resource_list resources = city_resource_get_available ();
212
+ int any_acceptance = 0 ;
212
213
for (auto r: resources) {
213
214
if (city->sells_resource [r.type ] || city->buys_resource [r.type ]) {
214
- if (!dock->is_good_accepted (r.type )) {
215
- dock_id = 0 ;
216
- return false ;
217
- }
215
+ any_acceptance += dock->is_trade_accepted (r.type ) ? 1 : 0 ;
218
216
}
219
217
}
220
- return true ;
218
+
219
+ return (any_acceptance > 0 );
221
220
}
222
221
223
222
building_dest map_get_free_destination_dock (int ship_id) {
@@ -227,17 +226,21 @@ building_dest map_get_free_destination_dock(int ship_id) {
227
226
int dock_id = 0 ;
228
227
for (int i = 0 ; i < 10 ; i++) {
229
228
dock_id = city_buildings_get_working_dock (i);
230
- if (!dock_id)
229
+ if (!dock_id) {
231
230
continue ;
231
+ }
232
+
232
233
if (!building_dock_accepts_ship (ship_id, dock_id)) {
233
234
dock_id = 0 ;
234
235
continue ;
235
236
}
236
237
237
238
building* dock = building_get (dock_id);
238
- if (!dock->data .dock .trade_ship_id || dock->data .dock .trade_ship_id == ship_id)
239
+ if (!dock->data .dock .trade_ship_id || dock->data .dock .trade_ship_id == ship_id) {
239
240
break ;
241
+ }
240
242
}
243
+
241
244
// BUG: when 10 docks in city, always takes last one... regardless of whether it is free
242
245
if (dock_id <= 0 )
243
246
return {0 , tile2i::invalid};
0 commit comments