Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The transfer value in "Transfer: £[number]" can be negative. #8098

Closed
James103 opened this issue Apr 26, 2020 · 2 comments
Closed

The transfer value in "Transfer: £[number]" can be negative. #8098

James103 opened this issue Apr 26, 2020 · 2 comments

Comments

@James103
Copy link
Contributor

@James103 James103 commented Apr 26, 2020

Version of OpenTTD

1.10.0 (2fee030) and 20200426-master

Expected result

"Transfer: £[nonnegative value] / Income: £[number]"
"Transfer: £[nonnegative value] / Cost: £[number]"
"Transfer: £[nonnegative value]"

Actual result

"Transfer: £[negative value] / Income: £[number]"
"Transfer: £[negative value] / Cost: £[number]"
"Transfer: £[negative value]"

image

Steps to reproduce

Load the title game as a normal game, watch and observe.

@James103 James103 changed the title The transfer value in "Transfer: £[number] / Income: £[number]" can be negative. The transfer value in "Transfer: £[number]" can be negative. Apr 26, 2020
@nielsmh
Copy link
Contributor

@nielsmh nielsmh commented Apr 26, 2020

I don't see why this is necessarily a bug.

OpenTTD/src/economy.cpp

Lines 1211 to 1231 in e45bccb

/**
* Handle payment for transfer of the given cargo packet.
* @param cp The cargo packet to pay for; actual payment won't be made!.
* @param count The number of packets to pay for.
* @return The amount of money paid for the transfer.
*/
Money CargoPayment::PayTransfer(const CargoPacket *cp, uint count)
{
Money profit = -cp->FeederShare(count) + GetTransportedGoodsIncome(
count,
/* pay transfer vehicle the difference between the payment for the journey from
* the source to the current point, and the sum of the previous transfer payments */
DistanceManhattan(cp->SourceStationXY(), Station::Get(this->current_station)->xy),
cp->DaysInTransit(),
this->ct);
profit = profit * _settings_game.economy.feeder_payment_share / 100;
this->visual_transfer += profit; // accumulate transfer profits for whole vehicle
return profit; // account for the (virtual) profit already made for the cargo packet
}

The transfer virtual payment is calculated as the difference in the cargo packet's potential earnings so far on its route, and the earnings it would have gotten for a non-stop route from its origin to the current unload point, over the total number of transit days so far. If the packet is significantly slower, or moves backwards relative to the origin, on a hop, then that difference in potential earnings can become negative.

@Yexo
Copy link
Contributor

@Yexo Yexo commented May 31, 2020

As explained in the last comment, this is working as expected.

@Yexo Yexo closed this May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants