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

Add a method for remote admins to send chat messages from external sources #9563

Merged
merged 1 commit into from Sep 19, 2021

Conversation

ldpl
Copy link
Contributor

@ldpl ldpl commented Sep 19, 2021

Motivation / Problem

Many OpenTTD communities bridge ingame chat with discord/irc or other servers. Previously common solution for that would be to give the server client an empty name (so it doesn't prepend them with awkward Server: or smith) and make it send those external messages. In 12.0 it's no longer possible to give the server an empty name and while one could always name it ":" it's ridiculous and the appearance of the chat messages changed anyway so I decided to make a dedicated method for it. I also thought of making a more generic method but while it may be useful it would require an admin to somehow manage the formatting of messages in sync with possible future changes and external chat is a common enough use case anyway to deserve a dedicated method.

Description

Add ADMIN_EXTERNAL_CHAT packet that receives message text, sender, and source as strings as well as text colour and passes it through to the clients to show.

Screenshot from 2021-09-19 17-24-59

Simple remote admin script in python for testing: testadmin.zip

Limitations

  1. I've no idea what's up with NETWORK_GAME_ADMIN_VERSION never being incremented but this is less of a protocol change than, for example, 4a1bf70 and 4a1bf70 and those didn't do it either.
  2. External chat messages aren't sent to other connected remote admins but neither do regular chat messages from other admins.

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 touches english.txt or translations? Check the guidelines
  • 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')

Copy link
Member

@LordAro LordAro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me. I leave final approval to @TrueBrain, who can answer the questions about protocol version numbers

@TrueBrain
Copy link
Member

TrueBrain commented Sep 19, 2021

I know very little about the admin protocol. I would reason that adding a packet to the server should be without bump, as it doesn't break existing clients. In this reasoning the version is similar to the major version within semver.

So, YOLO! Let's go.

@TrueBrain TrueBrain merged commit 31cf9e8 into OpenTTD:master Sep 19, 2021
Xaroth added a commit to Xaroth/libottdadmin2 that referenced this pull request Sep 19, 2021
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

3 participants