Page 1 of 1

Bug 177 Patch: Feeder Transfer @ accepting

Posted: 19 Aug 2006 22:52
by PandaMojo
Bug 177 Patch: Feeder Transfer @ accepting
(Massively Edited Post)

Seems to be Bug #177 - patch uploaded as a comment there.
EDIT: Maedhros seems to be working on a similar/overlapping/conflicting patch here that sounds less hackerish and may deal with this as well.

Bug Reproduction Steps:

Station in question must accept the good, and be used as the feeder dropoff point as well (I used buses dropping off passengers). The station must have 0 of the good when the dropoff occurs, and have a loading train waiting. This appears to first load the goods onto the waiting train, then immediately resell approximately that portion (1 or 2 cabins worth) of that good to the station instead of keeping it loaded.

Cause:

Since the station is empty when the feeder unloads, the dropped of cargo mantains it's original station id instead of having it's ID changed to the current one. I presume this means this ID is assigned to any/all cars loading the cargo (each passenger box counts as a seperate vehicle?), thus causing all those cars to immediately unload their cargo at this station in the next tick.

Patched solution:

Fixed the unload conditional, and after the first tick update current_order.flags to include OF_FULL_LOAD and OF_TRANSFER if it included either (unless it also included OF_UNLOAD).

Posted: 20 Aug 2006 00:09
by gkirilov
The bug on Flyspray concerns only passengers.
The train takes the passengers delivered by the buses(with the transer-and-leave-empty) and does not keep them but makes a profit at the same station without even leaving it (because the station accepts pass.). If the station does not accept passengers everything is ok - the train can be fully loaded.

Posted: 20 Aug 2006 00:45
by PandaMojo
gkirilov wrote:The bug on Flyspray concerns only passengers.
The train takes the passengers delivered by the buses(with the transer-and-leave-empty) and does not keep them but makes a profit at the same station without even leaving it (because the station accepts pass.). If the station does not accept passengers everything is ok - the train can be fully loaded.
I only noticed it with passengers, originally, since I don't typically build feeder services to a station by an industry they could be dropped off at anyways. Instead, I feed to another industry producing the same good - which is synonymous with the former only for passengers. I'm extrapolating the behavior to other cargo types on conjecture alone, actually. I'm guessing the original bug report was based off the observed behavior which only seemed reproducable with passengers :-).

I seem to have patched this bug in a 3rd manner I hadn't thought of by adding to economy.c @ 1411-1412:

Code: Select all

		/* don't unload goods that we picked up */
		if (u->current_order.flags & OF_FULL_LOAD) u->current_order.flags |= OF_TRANSFER;
After testing it, it seems to fix the problem with no ill effects. Someone more knowledgable about OpenTTD's workings should probably sanity check this, though. I'll try and get a .patch file made and upload it here.

EDIT: Patched against SVN trunk and uploaded - testing
EDIT: Whoops, got "get it compiling" project changes in there too I think - will reupload after I figure out ignoring specific files in SVN and test
EDIT: Tested against Flyspray savegame, causes looping transfer messages for a bit. Trying to find the cause :S

Posted: 20 Aug 2006 02:52
by PandaMojo
Finally fixed. Patched against SVN and tested. Should still probably be sanity checked by someone with a clue still :lol:

Will upload to first post.