void Ship::OnNewDay() { if ((++this->day_counter & 7) == 0) { DecreaseVehicleValue(this); } CheckVehicleBreakdown(this); AgeVehicle(this); CheckIfShipNeedsService(this); CheckOrders(this); if (this->running_ticks == 0) return; CommandCost cost(EXPENSES_SHIP_RUN, this->GetRunningCost() * this->running_ticks / (DAYS_IN_YEAR * DAY_TICKS)); this->profit_this_year -= cost.GetCost(); this->running_ticks = 0; SubtractMoneyFromCompanyFract(this->owner, cost); SetWindowDirty(WC_VEHICLE_DETAILS, this->index); /* we need this for the profit */ SetWindowClassesDirty(WC_SHIPS_LIST); }
void TacticalAI::ExecFrame(double secs) { const int exec_period = 1000; if (!ship || !ship_ai) return; navpt = ship->GetNextNavPoint(); orders = ship->GetRadioOrders(); if ((int) Game::GameTime() - exec_time > exec_period) { element_index = ship->GetElementIndex(); CheckOrders(); SelectTarget(); FindThreat(); FindSupport(); if (element_index > 1) { int formation = 0; if (orders && orders->Formation() >= 0) formation = orders->Formation(); else if (navpt) formation = navpt->Formation(); FindFormationSlot(formation); } ship_ai->SetNavPoint(navpt); if (carrier_ai) carrier_ai->ExecFrame(secs); exec_time += exec_period; } }