|
@@ -312,24 +312,26 @@ CommandCost CmdBuildAircraft(TileIndex t
|
|
|
v->tile = tile;
|
|
|
// u->tile = 0;
|
|
|
|
|
|
uint x = TileX(tile) * TILE_SIZE + 5;
|
|
|
uint y = TileY(tile) * TILE_SIZE + 3;
|
|
|
|
|
|
v->x_pos = u->x_pos = x;
|
|
|
v->y_pos = u->y_pos = y;
|
|
|
|
|
|
u->z_pos = GetSlopeZ(x, y);
|
|
|
v->z_pos = u->z_pos + 1;
|
|
|
|
|
|
v->running_ticks = 0;
|
|
|
|
|
|
// u->delta_x = u->delta_y = 0;
|
|
|
|
|
|
v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
|
|
|
u->vehstatus = VS_HIDDEN | VS_UNCLICKABLE | VS_SHADOW;
|
|
|
|
|
|
v->spritenum = avi->image_index;
|
|
|
// v->cargo_count = u->number_of_pieces = 0;
|
|
|
|
|
|
v->cargo_cap = avi->passenger_capacity;
|
|
|
u->cargo_cap = avi->mail_capacity;
|
|
|
|
|
|
v->cargo_type = CT_PASSENGERS;
|
|
@@ -726,29 +728,30 @@ static void CheckIfAircraftNeedsService(
|
|
|
void Aircraft::OnNewDay()
|
|
|
{
|
|
|
if (!IsNormalAircraft(this)) return;
|
|
|
|
|
|
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
|
|
|
|
|
|
CheckOrders(this);
|
|
|
|
|
|
CheckVehicleBreakdown(this);
|
|
|
AgeVehicle(this);
|
|
|
CheckIfAircraftNeedsService(this);
|
|
|
|
|
|
if (this->vehstatus & VS_STOPPED) return;
|
|
|
if (this->running_ticks == 0) return;
|
|
|
|
|
|
CommandCost cost = CommandCost(EXPENSES_AIRCRAFT_RUN, GetVehicleProperty(this, 0x0E, AircraftVehInfo(this->engine_type)->running_cost) * _price.aircraft_running / 364);
|
|
|
CommandCost cost(EXPENSES_AIRCRAFT_RUN, GetVehicleProperty(this, 0x0E, AircraftVehInfo(this->engine_type)->running_cost) * _price.aircraft_running * this->running_ticks / (364 * DAY_TICKS));
|
|
|
|
|
|
this->profit_this_year -= cost.GetCost() >> 8;
|
|
|
this->profit_this_year -= cost.GetCost();
|
|
|
this->running_ticks = 0;
|
|
|
|
|
|
SubtractMoneyFromPlayerFract(this->owner, cost);
|
|
|
|
|
|
InvalidateWindow(WC_VEHICLE_DETAILS, this->index);
|
|
|
InvalidateWindowClasses(WC_AIRCRAFT_LIST);
|
|
|
}
|
|
|
|
|
|
void AircraftYearlyLoop()
|
|
|
{
|
|
|
Vehicle *v;
|
|
|
|
|
|
FOR_ALL_VEHICLES(v) {
|
|
@@ -2137,24 +2140,26 @@ static void AircraftEventHandler(Vehicle
|
|
|
ProcessAircraftOrder(v);
|
|
|
v->HandleLoading(loop != 0);
|
|
|
|
|
|
if (v->current_order.type >= OT_LOADING) return;
|
|
|
|
|
|
AirportGoToNextPosition(v);
|
|
|
}
|
|
|
|
|
|
void Aircraft::Tick()
|
|
|
{
|
|
|
if (!IsNormalAircraft(this)) return;
|
|
|
|
|
|
if (!(this->vehstatus & VS_STOPPED)) this->running_ticks++;
|
|
|
|
|
|
if (this->subtype == AIR_HELICOPTER) HelicopterTickHandler(this);
|
|
|
|
|
|
AgeAircraftCargo(this);
|
|
|
|
|
|
for (uint i = 0; i != 2; i++) {
|
|
|
AircraftEventHandler(this, i);
|
|
|
if (this->type != VEH_AIRCRAFT) // In case it was deleted
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|