beyond-all-reason / teiserver

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

WIP: Add rankicon parameter to CLIENTSTATUS command #273

Closed jauggy closed 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

The current protocol is this:

CLIENTSTATUS userName status

status contains bits of information including rank.

Proposed Changes

I propose to send this instead from TeiServer

CLIENTSTATUS userName status rankIcon

where rankIcon 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 will error due to the extra argument. The var/plugins/barmanager.py needs the hCLIENTSTATUS_pre signature to change (see below)

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. Fix SPADS Plugin

Before launching SPADS you will need to modify var/plugins/barmanager.py Change this line

def hCLIENTSTATUS_pre(command, userName, status):

to this

def hCLIENTSTATUS_pre(command, userName, status, rankIcon=None):

Also at the top of this function add a log:

    spads.slog("Rank icon: " + str(rankIcon), 0)

Now launch SPADS as normal

perl spads.pl etc/spads.conf

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. In the SPADS logs you will see what rank icon is being sent. 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 SPADS logs and it should be different.

jauggy commented 3 months ago

The code works but requires a DB call whenever we update the client's status. Not good