35 #include "table/strings.h" 
   40 const uint32 _veh_build_proc_table[] = {
 
   47 const uint32 _veh_sell_proc_table[] = {
 
   54 const uint32 _veh_refit_proc_table[] = {
 
   61 const uint32 _send_to_depot_proc_table[] = {
 
  107     case VEH_SHIP:     num_vehicles = 1; 
break;
 
  109     default: NOT_REACHED(); 
 
  117   if (unit_num == UINT16_MAX) 
return_cmd_error(STR_ERROR_TOO_MANY_VEHICLES_IN_GAME);
 
  125     default: NOT_REACHED(); 
 
  128   if (value.Succeeded() && flags & 
DC_EXEC) {
 
  130     v->
value      = value.GetCost();
 
  173   if (ret.
Failed()) 
return ret;
 
  218   if (e->
GetGRF() != NULL) {
 
  224       *auto_refit_allowed = 
HasBit(cb_res, 14);
 
  225       int factor = 
GB(cb_res, 0, 14);
 
  226       if (factor >= 0x2000) factor -= 0x4000; 
 
  231   *auto_refit_allowed = e->info.refit_cost == 0;
 
  232   return (v == NULL || v->
cargo_type != new_cid) ? e->info.refit_cost : 0;
 
  249   int cost_factor = 
GetRefitCostFactor(v, engine_type, new_cid, new_subtype, auto_refit_allowed);
 
  252       base_price = PR_BUILD_VEHICLE_SHIP;
 
  257       base_price = PR_BUILD_VEHICLE_ROAD;
 
  262       base_price = PR_BUILD_VEHICLE_AIRCRAFT;
 
  267       base_price = (e->u.rail.railveh_type == 
RAILVEH_WAGON) ? PR_BUILD_VEHICLE_WAGON : PR_BUILD_VEHICLE_TRAIN;
 
  272     default: NOT_REACHED();
 
  274   if (cost_factor < 0) {
 
  304   uint total_capacity = 0;
 
  305   uint total_mail_capacity = 0;
 
  306   num_vehicles = num_vehicles == 0 ? UINT8_MAX : num_vehicles;
 
  316   refit_result.
Clear();
 
  319   byte actual_subtype = new_subtype;
 
  320   for (; v != NULL; v = (only_this ? NULL : v->
Next())) {
 
  332     if (!refittable && v->
cargo_type != new_cid) 
continue;
 
  335     if (actual_subtype == 0xFF) {
 
  347     uint16 mail_capacity = 0;
 
  349     total_capacity += amount;
 
  351     total_mail_capacity += mail_capacity;
 
  353     if (!refittable) 
continue;
 
  359     bool auto_refit_allowed;
 
  361     if (auto_refit && (flags & 
DC_QUERY_COST) == 0 && !auto_refit_allowed) {
 
  365       total_capacity -= amount;
 
  366       total_mail_capacity -= mail_capacity;
 
  375     cost.AddCost(refit_cost);
 
  390     result->
subtype = actual_subtype;
 
  411   refit_result.
Clear();
 
  444   if (ret.
Failed()) 
return ret;
 
  446   bool auto_refit = 
HasBit(p2, 6);
 
  464   byte new_subtype = 
GB(p2, 8, 8);
 
  469   uint8 num_vehicles = 
GB(p2, 16, 8);
 
  494       default: NOT_REACHED();
 
  529   if (ret.
Failed()) 
return ret;
 
  557       if (v->
GetGRF()->grf_version < 8) {
 
  561         if (callback < 0x400) {
 
  569               error = STR_ERROR_INCOMPATIBLE_RAIL_TYPES;
 
  605   bool do_start = 
HasBit(p1, 0);
 
  606   bool vehicle_list_window = 
HasBit(p1, 1);
 
  612   if (vehicle_list_window) {
 
  619   for (uint i = 0; i < list.
Length(); i++) {
 
  647   VehicleType vehicle_type = Extract<VehicleType, 0, 3>(p1);
 
  651   uint sell_command = GetCmdSellVeh(vehicle_type);
 
  657   bool had_success = 
false;
 
  658   for (uint i = 0; i < list.
Length(); i++) {
 
  668   return had_success ? cost : last_error;
 
  684   VehicleType vehicle_type = Extract<VehicleType, 0, 3>(p1);
 
  692   for (uint i = 0; i < list.
Length(); i++) {
 
  715     if (v->
name != NULL && strcmp(v->
name, name) == 0) 
return false;
 
  731   size_t number_position;
 
  732   for (number_position = strlen(src->
name); number_position > 0; number_position--) {
 
  735     if (src->
name[number_position - 1] < 
'0' || src->
name[number_position - 1] > 
'9') 
break;
 
  741   if (number_position == strlen(src->
name)) {
 
  745     number_position = strlen(buf);
 
  750     buf[number_position] = 
'\0';
 
  752     num = strtol(&src->
name[number_position], &endptr, 10) + 1;
 
  753     padding = endptr - &src->
name[number_position];
 
  757   for (
int max_iterations = 1000; max_iterations > 0; max_iterations--, num++) {
 
  759     seprintf(&buf[number_position], 
lastof(buf), 
"%0*d", padding, num);
 
  800   if (ret.
Failed()) 
return ret;
 
  809     } 
while ((v = v->
Next()) != NULL);
 
  837       if (w_front != NULL) 
DoCommand(w_front->
tile, w_front->
index | (1 << 20), 0, flags, GetCmdSellVeh(w_front));
 
  843     if (flags & DC_EXEC) {
 
  865         w->SetServiceIntervalIsCustom(v->ServiceIntervalIsCustom());
 
  866         w->SetServiceIntervalIsPercent(v->ServiceIntervalIsPercent());
 
  874     _new_vehicle_id = w_front->
index;
 
  877   if (flags & DC_EXEC) {
 
  895       if (flags & DC_EXEC) {
 
  930   if (flags & DC_EXEC) {
 
  945     if (flags & DC_EXEC) {
 
  969   bool had_success = 
false;
 
  970   for (uint i = 0; i < list.
Length(); i++) {
 
 1030   if (ret.
Failed()) 
return ret;
 
 1068   if (ret.
Failed()) 
return ret;
 
 1071   bool iscustom  = 
HasBit(p2, 16);
 
 1076     serv_int = 
GB(p2, 0, 16);
 
 1083     v->SetServiceInterval(serv_int);
 
 1084     v->SetServiceIntervalIsCustom(iscustom);
 
 1085     v->SetServiceIntervalIsPercent(ispercent);