beyond-all-reason / teiserver

Middleware server for online gaming
https://www.beyondallreason.info/
MIT License
47 stars 47 forks source link

(Blocked) Add rank_icon to ADDUSER command #275

Open jauggy opened 3 months ago

jauggy commented 3 months ago

Context

Contributors use a high rank to determine their rank icon. The problem is that this makes contributors look like pro gamers and they might not be. In order to create more flexibility to rank icons, we should separate them from rank. If we can separate it from rank we could use rank icons made by Ice

1

Teiserver currently sends this for ADDUSER :

    "ADDUSER #{client.name} #{client.country} #{client.userid} #{client.lobby_client}\n"

Proposed Changes

I propose to send this instead from TeiServer

    "ADDUSER #{client.name} #{client.country} #{client.userid} #{client.lobby_client} #{client.rank_icon}\n"

where rank_icon is a string that can take these values:

But it's very flexible and can really be anything. The numeric prefix represents their chev level purely based on playtime. After that the postfix depends on if they have a special role or not. If a user has multiple roles it will pick one in this order: Moderator > Contributor > Streamer > Mentor.

Required SPADS modification

SPADS doesn't error with this modification. However I have no idea why it doesn't error.

Required Chobby Modifications

No change is required to Chobby to prevent errors. Chobby is using regex that will simply ignore the extra argument.

Test Steps

1. Launch SPADS

perl spads.pl etc/spads.conf

This is the normal command to launch spads.

2. Add TeiServer Test Users

Launch teiserver with this command (that allows running Elixir commands)

iex -S mix phx.server

In the same terminal run this to generate test users

TestScript.run()

This will generate the following users:

1Chev, 2Chev, 3Chev, 4Chev, 5Chev, 6Chev, 7Chev, 8Chev

Each of them will have a password of password. Their chev level is defined by their name.

3. Login with test users

Launch Chobby and login with any of the test users. Check via logs what rank_icon is being send (Not sure how to log this)

Now go to Teiserver website and login with root@localhost with password password Go to Users > Find the user > Edit > Change their role to include any of Moderator/Contributor/Streamer/Mentor

Relogin with that user in Chobby. Check the logs and it should be different.

jauggy commented 2 months ago

While the code in this PR works, it is currently blocked due to not knowing how to get this information into the in-game player list. Getting the data into chobby should be working fine.

Beherith commented 2 months ago

I would honestly expect SPADS to panic at this, ill have to test it on integration.

Beherith commented 2 months ago

I think I would much prefer to make this an extensible field, likely via base64'd json. There have been multiple requests to transfer additional metadata in ADDUSER.

jauggy commented 2 months ago

@Beherith just to clarify you want the last argument to be base 64 json string instead of just rank icon? Example:

    "ADDUSER #{client.name} #{client.country} #{client.userid} #{client.lobby_client} #{base64json_extradata}\n"
jauggy commented 2 months ago

I would honestly expect SPADS to panic at this, ill have to test it on integration.

I later figured out why it doesn't error. It's because there's an existing bug. Teifion does not send cpu in the ADDUSER command. BarManager.py is expecting it

def hADDUSER(command, userName, country = "nil", cpu = "nil", userID = "nil", lobbyID = "nil"):

So everything is off by one.

Also see this comment by Teifion: https://discord.com/channels/549281623154229250/564591092360675328/1172100679242887168