roadveh_cmd.c
changeset 3054 299ca9034442
parent 3033 e4f7c60a1742
child 3069 0e6aca11c3da
equal deleted inserted replaced
3053:708bd89b6acb 3054:299ca9034442
  1292 				v->cur_speed = 0;
  1292 				v->cur_speed = 0;
  1293 				return;
  1293 				return;
  1294 			}
  1294 			}
  1295 			if (IS_BYTE_INSIDE(_m[v->tile].m5, 0x43, 0x4B)) {
  1295 			if (IS_BYTE_INSIDE(_m[v->tile].m5, 0x43, 0x4B)) {
  1296 				RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
  1296 				RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
  1297 				byte *b = &rs->status;
  1297 
  1298 
  1298 				// reached a loading bay, mark it as used and clear the usage bit
  1299 				//we have reached a loading bay, mark it as used
  1299 				SETBIT(rs->status, v->u.road.state & 2 ? 1 : 0); // occupied bay
  1300 				//and clear the usage bit (0x80) of the stop
  1300 				CLRBIT(rs->status, 7); // usage bit
  1301 				*b = (*b | ((v->u.road.state&2)?2:1)) & ~0x80;
       
  1302 			}
  1301 			}
  1303 		}
  1302 		}
  1304 
  1303 
  1305 		if (!(r & 4)) {
  1304 		if (!(r & 4)) {
  1306 			v->tile = tile;
  1305 			v->tile = tile;
  1383 	}
  1382 	}
  1384 
  1383 
  1385 	if (v->u.road.state >= 0x20 &&
  1384 	if (v->u.road.state >= 0x20 &&
  1386 			_road_veh_data_1[v->u.road.state - 0x20 + (_opt.road_side<<4)] == v->u.road.frame) {
  1385 			_road_veh_data_1[v->u.road.state - 0x20 + (_opt.road_side<<4)] == v->u.road.frame) {
  1387 		RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
  1386 		RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
  1388 		byte *b = &rs->status;
       
  1389 
  1387 
  1390 		st = GetStation(_m[v->tile].m2);
  1388 		st = GetStation(_m[v->tile].m2);
  1391 
  1389 
  1392 		if (v->current_order.type != OT_LEAVESTATION &&
  1390 		if (v->current_order.type != OT_LEAVESTATION &&
  1393 				v->current_order.type != OT_GOTO_DEPOT) {
  1391 				v->current_order.type != OT_GOTO_DEPOT) {
  1394 			Order old_order;
  1392 			Order old_order;
  1395 
  1393 
  1396 			*b &= ~0x80;
  1394 			CLRBIT(rs->status, 7);
  1397 
  1395 
  1398 			v->last_station_visited = _m[v->tile].m2;
  1396 			v->last_station_visited = _m[v->tile].m2;
  1399 
  1397 
  1400 			RoadVehArrivesAt(v, st);
  1398 			RoadVehArrivesAt(v, st);
  1401 
  1399 
  1417 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  1415 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  1418 			return;
  1416 			return;
  1419 		}
  1417 		}
  1420 
  1418 
  1421 		if (v->current_order.type != OT_GOTO_DEPOT) {
  1419 		if (v->current_order.type != OT_GOTO_DEPOT) {
  1422 			if (*b&0x80) {
  1420 			if (HASBIT(rs->status, 7)) {
  1423 				v->cur_speed = 0;
  1421 				v->cur_speed = 0;
  1424 				return;
  1422 				return;
  1425 			}
  1423 			}
  1426 			v->current_order.type = OT_NOTHING;
  1424 			v->current_order.type = OT_NOTHING;
  1427 			v->current_order.flags = 0;
  1425 			v->current_order.flags = 0;
  1428 		}
  1426 		}
  1429 		*b |= 0x80;
  1427 		SETBIT(rs->status, 7);
  1430 
  1428 
  1431 		if (rs == v->u.road.slot) {
  1429 		if (rs == v->u.road.slot) {
  1432 			//we have arrived at the correct station
  1430 			//we have arrived at the correct station
  1433 			ClearSlot(v, rs);
  1431 			ClearSlot(v, rs);
  1434 		} else if (v->u.road.slot != NULL) {
  1432 		} else if (v->u.road.slot != NULL) {