~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/vehicle_cmd.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Matthijs Kooijman, Matthijs Kooijman
  • Date: 2009-10-01 22:52:59 UTC
  • mfrom: (1.1.8 upstream) (2.1.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091001225259-5kpkp4sthbszpyif
[ Matthijs Kooijman ]
* New upstream release
* Use printf instead of echo -en in openttd-wrapper to make it POSIX
  compatible (Closes: #547758).
* Remove three patches that are now included in upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: vehicle_cmd.cpp 15718 2009-03-15 00:32:18Z rubidium $ */
 
1
/* $Id: vehicle_cmd.cpp 17598 2009-09-21 15:41:58Z rubidium $ */
2
2
 
3
3
/** @file vehicle_cmd.cpp Commands for vehicles. */
4
4
 
115
115
                InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
116
116
                InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
117
117
                InvalidateWindowClasses(vehicle_list[v->type]);
 
118
                v->MarkDirty();
118
119
        }
119
120
        return CommandCost();
120
121
}
374
375
                        continue;
375
376
                }
376
377
 
377
 
                CommandCost cost = DoCommand(tile, v->engine_type, build_argument, flags, GetCmdBuildVeh(v));
 
378
                /* In case we're building a multi headed vehicle and the maximum number of
 
379
                 * vehicles is almost reached (e.g. max trains - 1) not all vehicles would
 
380
                 * be cloned. When the non-primary engines were build they were seen as
 
381
                 * 'new' vehicles whereas they would immediately be joined with a primary
 
382
                 * engine. This caused the vehicle to be not build as 'the limit' had been
 
383
                 * reached, resulting in partially build vehicles and such. */
 
384
                DoCommandFlag build_flags = flags;
 
385
                if ((flags & DC_EXEC) && !v->IsPrimaryVehicle()) build_flags |= DC_AUTOREPLACE;
 
386
 
 
387
                CommandCost cost = DoCommand(tile, v->engine_type, build_argument, build_flags, GetCmdBuildVeh(v));
378
388
                build_argument = 3; // ensure that we only assign a number to the first engine
379
389
 
380
 
                if (CmdFailed(cost)) return cost;
 
390
                if (CmdFailed(cost)) {
 
391
                        /* Can't build a part, then sell the stuff we already made; clear up the mess */
 
392
                        if (w_front != NULL) DoCommand(w_front->tile, w_front->index, 1, flags, GetCmdSellVeh(w_front));
 
393
                        return cost;
 
394
                }
381
395
 
382
396
                total_cost.AddCost(cost);
383
397