Merge branch 'master' into jgrpp
Replace build and refit, and group collapse implementations Fix template creation build and refit # Conflicts: # Makefile.bundle.in # config.lib # src/animated_tile.cpp # src/blitter/32bpp_anim.hpp # src/blitter/32bpp_base.hpp # src/blitter/8bpp_base.hpp # src/blitter/null.hpp # src/build_vehicle_gui.cpp # src/command.cpp # src/command_func.h # src/console_gui.cpp # src/core/smallstack_type.hpp # src/date.cpp # src/debug.cpp # src/genworld_gui.cpp # src/ground_vehicle.hpp # src/group_gui.cpp # src/lang/korean.txt # src/linkgraph/linkgraph_gui.h # src/main_gui.cpp # src/misc_gui.cpp # src/network/core/game.h # src/network/core/packet.cpp # src/network/core/udp.cpp # src/network/core/udp.h # src/network/network_content.cpp # src/network/network_type.h # src/network/network_udp.cpp # src/newgrf_house.h # src/openttd.cpp # src/order_cmd.cpp # src/order_gui.cpp # src/os/unix/crashlog_unix.cpp # src/os/windows/crashlog_win.cpp # src/osk_gui.cpp # src/pathfinder/opf/opf_ship.cpp # src/rail_cmd.cpp # src/rail_gui.cpp # src/saveload/saveload.cpp # src/settings.cpp # src/settings_gui.cpp # src/smallmap_gui.h # src/station_base.h # src/station_cmd.cpp # src/table/gameopt_settings.ini # src/table/newgrf_debug_data.h # src/table/settings.ini # src/timetable_gui.cpp # src/toolbar_gui.cpp # src/train_gui.cpp # src/vehicle.cpp # src/vehicle_gui.cpp # src/vehiclelist.cpp # src/viewport.cpp # src/widgets/dropdown.cpp # src/window_gui.h
This commit is contained in:
@@ -1036,7 +1036,7 @@ static Train *FindGoodVehiclePos(const Train *src)
|
||||
}
|
||||
|
||||
/** Helper type for lists/vectors of trains */
|
||||
typedef SmallVector<Train *, 16> TrainList;
|
||||
typedef std::vector<Train *> TrainList;
|
||||
|
||||
/**
|
||||
* Make a backup of a train into a train list.
|
||||
@@ -1045,7 +1045,7 @@ typedef SmallVector<Train *, 16> TrainList;
|
||||
*/
|
||||
static void MakeTrainBackup(TrainList &list, Train *t)
|
||||
{
|
||||
for (; t != NULL; t = t->Next()) *list.Append() = t;
|
||||
for (; t != NULL; t = t->Next()) list.push_back(t);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1055,12 +1055,11 @@ static void MakeTrainBackup(TrainList &list, Train *t)
|
||||
static void RestoreTrainBackup(TrainList &list)
|
||||
{
|
||||
/* No train, nothing to do. */
|
||||
if (list.Length() == 0) return;
|
||||
if (list.size() == 0) return;
|
||||
|
||||
Train *prev = NULL;
|
||||
/* Iterate over the list and rebuild it. */
|
||||
for (Train **iter = list.Begin(); iter != list.End(); iter++) {
|
||||
Train *t = *iter;
|
||||
for (Train *t : list) {
|
||||
if (prev != NULL) {
|
||||
prev->SetNext(t);
|
||||
} else if (t->Previous() != NULL) {
|
||||
@@ -5309,19 +5308,25 @@ Train* CmdBuildVirtualRailVehicle(EngineID eid, bool lax_engine_check, StringID
|
||||
* Build a virtual train vehicle.
|
||||
* @param tile unused
|
||||
* @param flags type of operation
|
||||
* @param p1 the engine ID to build
|
||||
* @param p1 various bitstuffed data
|
||||
* bits 0-15: vehicle type being built.
|
||||
* bits 24-31: refit cargo type.
|
||||
* @param p2 unused
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildVirtualRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
EngineID eid = p1;
|
||||
EngineID eid = GB(p1, 0, 16);
|
||||
|
||||
if (!IsEngineBuildable(eid, VEH_TRAIN, _current_company)) {
|
||||
return_cmd_error(STR_ERROR_RAIL_VEHICLE_NOT_AVAILABLE + VEH_TRAIN);
|
||||
}
|
||||
|
||||
/* Validate the cargo type. */
|
||||
CargoID cargo = GB(p1, 24, 8);
|
||||
if (cargo >= NUM_CARGO && cargo != CT_INVALID) return CMD_ERROR;
|
||||
|
||||
bool should_execute = (flags & DC_EXEC) != 0;
|
||||
|
||||
if (should_execute) {
|
||||
@@ -5332,12 +5337,10 @@ CommandCost CmdBuildVirtualRailVehicle(TileIndex tile, DoCommandFlag flags, uint
|
||||
return_cmd_error(err);
|
||||
}
|
||||
|
||||
if (text && text[0] == 'R') {
|
||||
CargoID cargo = text[1];
|
||||
if (cargo >= NUM_CARGO) return CMD_ERROR;
|
||||
if (cargo != CT_INVALID) {
|
||||
CargoID default_cargo = Engine::Get(eid)->GetDefaultCargoType();
|
||||
if (default_cargo != cargo) {
|
||||
CommandCost refit_res = CmdRefitVehicle(tile, flags, train->index, cargo | (1 << 5), NULL);
|
||||
CommandCost refit_res = CmdRefitVehicle(tile, flags, train->index, cargo, NULL);
|
||||
if (!refit_res.Succeeded()) return refit_res;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user