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

Change: move "give money" from client-list to company window #8500

Merged
merged 4 commits into from Jan 5, 2021

Conversation

TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Jan 5, 2021

Motivation / Problem

While fixing a bug with INT32_MAX "Give Money" situation, I found that JGRPP included a nice patch that brings the "Give Money" button to the company window. To me, it makes so much more sense to have that button there, over anywhere else.

Description

It is mostly moving of code. I did fix the Company GUI with the Multiplayer buttons, as they were not aligned properly. As I never did anything with the new Window system before, please review carefully. Tnx :)

This removes HandleOnEditText as it was only used for GiveMoney .. that means less special code.
CcGiveMoney callback is removed, as now the Command itself generates the chat message. This means modified clients cannot prevent a chat message from being send out, and it was a rather ugly hack on the chat system.

As a bonus, this now works in single-player too! Even AIs can receive your money, if you so like.

Limitations

  • Single-player doesn't get a chat message (chat system is disabled in single-player; this could be resolved, but as you are the only player, this shouldn't be a problem)

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

src/company_gui.cpp Outdated Show resolved Hide resolved
src/company_gui.cpp Outdated Show resolved Hide resolved
src/company_cmd.cpp Outdated Show resolved Hide resolved
src/company_cmd.cpp Outdated Show resolved Hide resolved
src/company_cmd.cpp Outdated Show resolved Hide resolved
…s changing

Otherwise it can take a few OnPaint() calls before all planes are
set correctly when switching companies.
Code acted as if WWT_TEXT starts a scope; it does not.
… Company window

Currently password-lock icon + button was the same size, but this
looks really weird. Now they are in sync, even with other fonts
and languages.
@TrueBrain TrueBrain force-pushed the money-in-company-gui branch 2 times, most recently from e1c3823 to b019f6b Compare January 5, 2021 19:32
@TrueBrain TrueBrain marked this pull request as ready for review January 5, 2021 20:01
@TrueBrain TrueBrain force-pushed the money-in-company-gui branch 2 times, most recently from 47ab167 to cec902c Compare January 5, 2021 20:04
src/company_gui.cpp Outdated Show resolved Hide resolved
This is a much better location for this button, as you send
money from one company to another company, not from player
to player.

This is based on work done by JGRPP in:
JGRennison/OpenTTD-patches@f820543
and surrounding commits, which took the work from estys:
https://www.tt-forums.net/viewtopic.php?p=1183311#p1183311

We did modify it to fix several bugs and clean up the code while
here anyway.

The callback was removed, as it meant a modified client could
prevent anyone from seeing money was transfered. The message
is now generated in the command itself, making that impossible.
@TrueBrain TrueBrain merged commit 62cdadb into OpenTTD:master Jan 5, 2021
@TrueBrain TrueBrain deleted the money-in-company-gui branch January 5, 2021 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants