mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-06 06:19:41 +00:00
(svn r6755) - Fix: Pass the newly created vehicle when checking for articulated engines. As this could result in more parts being added than previously counted, we check to see if we need to allocate more vehicles as we add parts.
This commit is contained in:
parent
cad526ef36
commit
fd3fd176e5
12
train_cmd.c
12
train_cmd.c
@ -508,10 +508,15 @@ static void AddArticulatedParts(Vehicle **vl)
|
|||||||
if (!HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_ARTIC_ENGINE)) return;
|
if (!HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_ARTIC_ENGINE)) return;
|
||||||
|
|
||||||
for (i = 1; i < 10; i++) {
|
for (i = 1; i < 10; i++) {
|
||||||
callback = GetVehicleCallback(CBID_TRAIN_ARTIC_ENGINE, i, 0, v->engine_type, NULL);
|
callback = GetVehicleCallback(CBID_TRAIN_ARTIC_ENGINE, i, 0, v->engine_type, v);
|
||||||
if (callback == CALLBACK_FAILED || callback == 0xFF) return;
|
if (callback == CALLBACK_FAILED || callback == 0xFF) return;
|
||||||
|
|
||||||
|
/* Attempt to use pre-allocated vehicles until they run out. This can happen
|
||||||
|
* if the callback returns different values depending on the cargo type. */
|
||||||
u->next = vl[i];
|
u->next = vl[i];
|
||||||
|
if (u->next == NULL) u->next = AllocateVehicle();
|
||||||
|
if (u->next == NULL) return;
|
||||||
|
|
||||||
u = u->next;
|
u = u->next;
|
||||||
|
|
||||||
engine_type = GB(callback, 0, 7);
|
engine_type = GB(callback, 0, 7);
|
||||||
@ -571,6 +576,8 @@ static int32 CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags)
|
|||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
|
memset(&vl, 0, sizeof(vl));
|
||||||
|
|
||||||
if (!AllocateVehicles(vl, num_vehicles))
|
if (!AllocateVehicles(vl, num_vehicles))
|
||||||
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
|
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
|
||||||
|
|
||||||
@ -742,6 +749,9 @@ int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
|
|
||||||
if (!(flags & DC_QUERY_COST)) {
|
if (!(flags & DC_QUERY_COST)) {
|
||||||
Vehicle *vl[12]; // Allow for upto 10 artic parts and dual-heads
|
Vehicle *vl[12]; // Allow for upto 10 artic parts and dual-heads
|
||||||
|
|
||||||
|
memset(&vl, 0, sizeof(vl));
|
||||||
|
|
||||||
if (!AllocateVehicles(vl, num_vehicles) || IsOrderPoolFull())
|
if (!AllocateVehicles(vl, num_vehicles) || IsOrderPoolFull())
|
||||||
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
|
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user