economy.c
changeset 555 02df8a1b7f33
parent 543 946badd71033
child 599 30da691a5561
equal deleted inserted replaced
554:a4ba0fbbf018 555:02df8a1b7f33
  1229 static bool LoadWait(const Vehicle *v, const Vehicle *u) {
  1229 static bool LoadWait(const Vehicle *v, const Vehicle *u) {
  1230 	const Vehicle *w;
  1230 	const Vehicle *w;
  1231 	const Vehicle *x;
  1231 	const Vehicle *x;
  1232 	bool has_any_cargo = false;
  1232 	bool has_any_cargo = false;
  1233 
  1233 
  1234 	if (!(u->next_order & OF_FULL_LOAD)) return false;
  1234 	if (!(u->current_order.flags & OF_FULL_LOAD)) return false;
  1235 
  1235 
  1236 	for (w = u; w != NULL; w = w->next) {
  1236 	for (w = u; w != NULL; w = w->next) {
  1237 		if (w->cargo_count != 0) {
  1237 		if (w->cargo_count != 0) {
  1238 			if (v->cargo_type == w->cargo_type &&
  1238 			if (v->cargo_type == w->cargo_type &&
  1239 					u->last_station_visited == w->cargo_source)
  1239 					u->last_station_visited == w->cargo_source)
  1244 
  1244 
  1245 	FOR_ALL_VEHICLES(x) {
  1245 	FOR_ALL_VEHICLES(x) {
  1246 		if ((x->type != VEH_Train || x->subtype == 0) && // for all locs
  1246 		if ((x->type != VEH_Train || x->subtype == 0) && // for all locs
  1247 				u->last_station_visited == x->last_station_visited && // at the same station
  1247 				u->last_station_visited == x->last_station_visited && // at the same station
  1248 				!(x->vehstatus & VS_STOPPED) && // not stopped
  1248 				!(x->vehstatus & VS_STOPPED) && // not stopped
  1249 				(x->next_order & OT_MASK) == OT_LOADING && // loading
  1249 				x->current_order.type == OT_LOADING && // loading
  1250 				u != x) { // not itself
  1250 				u != x) { // not itself
  1251 			bool other_has_any_cargo = false;
  1251 			bool other_has_any_cargo = false;
  1252 			bool has_space_for_same_type = false;
  1252 			bool has_space_for_same_type = false;
  1253 			bool other_has_same_type = false;
  1253 			bool other_has_same_type = false;
  1254 
  1254 
  1286 	int t;
  1286 	int t;
  1287 	uint count, cap;
  1287 	uint count, cap;
  1288 	byte old_player;
  1288 	byte old_player;
  1289 	bool completely_empty = true;
  1289 	bool completely_empty = true;
  1290 
  1290 
  1291 	assert((v->next_order&0x1F) == OT_LOADING);
  1291 	assert(v->current_order.type == OT_LOADING);
  1292 
  1292 
  1293 	v->cur_speed = 0;
  1293 	v->cur_speed = 0;
  1294 	old_player = _current_player;
  1294 	old_player = _current_player;
  1295 	_current_player = v->owner;
  1295 	_current_player = v->owner;
  1296 
  1296 
  1307 				// deliver goods to the station
  1307 				// deliver goods to the station
  1308 				unloading_time += v->cargo_count; /* TTDBUG: bug in original TTD */
  1308 				unloading_time += v->cargo_count; /* TTDBUG: bug in original TTD */
  1309 				profit += DeliverGoods(v->cargo_count, v->cargo_type, v->cargo_source, last_visited, v->cargo_days);
  1309 				profit += DeliverGoods(v->cargo_count, v->cargo_type, v->cargo_source, last_visited, v->cargo_days);
  1310 				result |= 1;
  1310 				result |= 1;
  1311 				v->cargo_count = 0;
  1311 				v->cargo_count = 0;
  1312 			} else if (u->next_order & OF_UNLOAD) {
  1312 			} else if (u->current_order.flags & OF_UNLOAD) {
  1313 				/* unload goods and let it wait at the station */
  1313 				/* unload goods and let it wait at the station */
  1314 				st->time_since_unload = 0;
  1314 				st->time_since_unload = 0;
  1315 
  1315 
  1316 				if ((t=ge->waiting_acceptance & 0xFFF) == 0) {
  1316 				if ((t=ge->waiting_acceptance & 0xFFF) == 0) {
  1317 					// No goods waiting at station
  1317 					// No goods waiting at station
  1333 			if (v->cargo_count != 0)
  1333 			if (v->cargo_count != 0)
  1334 				completely_empty = false;
  1334 				completely_empty = false;
  1335 		}
  1335 		}
  1336 
  1336 
  1337 		/* don't pick up goods that we unloaded */
  1337 		/* don't pick up goods that we unloaded */
  1338 		if (u->next_order & OF_UNLOAD) continue;
  1338 		if (u->current_order.flags & OF_UNLOAD) continue;
  1339 
  1339 
  1340 		/* update stats */
  1340 		/* update stats */
  1341 		ge->days_since_pickup = 0;
  1341 		ge->days_since_pickup = 0;
  1342 		t = u->max_speed;
  1342 		t = u->max_speed;
  1343 		if (u->type == VEH_Road) t >>=1;
  1343 		if (u->type == VEH_Road) t >>=1;