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

Fix single player quick start, add ranking icons to player lists in lobbies #117

Merged
merged 4 commits into from
Aug 25, 2024

Conversation

StenAL
Copy link

@StenAL StenAL commented Aug 22, 2024

This PR contains the following changes:

  • Use of the Enumeration class is removed. It is superseded by the more modern approach of using for-each loops which are more concise to read and don't pollute variable scopes.
  • Single player quick start now works
Before After
single-player-quick-old.webm
single-player-quick-new.webm
  • The server no longer has a busy-wait main loop, instead using a BlockingQueue, with which it can simply wait until it receives any events and then react accordingly. This saves resources and simplifies the server logic.
  • Players now have ranking icon next to their names in lobbies. This was done by creating each player as registered when they sign in. I also adjusted the default ranking for players to be more sensible at 0 instead of 10000. See the little green plus next to the player name in the below picture.
Before After
lobby-rankings-old lobby-rankings-new

Enumeration is a legacy class used for element iteration and has been
superseded by Iterator, which can be looped over using a for-each loop.
These are more concise to read and don't pollute variable scopes.
Most of the code was already in place, the regular expression matching
packages in the server needed to be adjusted a bit. Also, the game code
assumed that everyone starting a game was already in a lobby so I
modified the quick start code to join the single player lobby before
launching a game.
Instead of constantly polling for changes in the events queue and
sleeping, using a BlockingQueue, the server can simply wait until
receives any events and then react accordingly. This saves resources and
simplifies the server logic.
Registered players have a ranking icon next to their names in lobbies.

This also adjusts the default ranking to be 0, instead of 10000 to
display the basic ranking icon.

while (var3.hasMoreElements()) {
var3.nextElement().actionPerformed(var2);
for (ActionListener listener : aVector3280) {
Copy link
Owner

Choose a reason for hiding this comment

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

Could you deobfuscate aVector3280 to listeners or something else?

Copy link
Author

Choose a reason for hiding this comment

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

I have a local branch where I convert the codebase from using Vectors everywhere to Lists and that's exactly what I do there: StenAL@7befbe5

I'd prefer to do the deobfuscation as part of the follow-up PR with that commit instead of backporting the changes here if that works for you.

Copy link
Owner

Choose a reason for hiding this comment

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

Okay, fine :)


while (var3.hasMoreElements()) {
var3.nextElement().itemStateChanged(var2);
for (ItemListener listener : aVector3305) {
Copy link
Owner

Choose a reason for hiding this comment

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

See above


while (var1.hasMoreElements()) {
var1.nextElement().realSetState(false);
for (ColorCheckbox colorCheckbox : aVector1553) {
Copy link
Owner

Choose a reason for hiding this comment

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

See above?


while (var4.hasMoreElements()) {
ColorListItem var3 = var4.nextElement();
ColorListItemGroup var2 = var3.getGroup();
Copy link
Owner

Choose a reason for hiding this comment

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

See above

Copy link
Owner

@PhilippvK PhilippvK left a comment

Choose a reason for hiding this comment

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

Looks good! Would you mind deobfuscating some trivial variable names used in the foreach loops?

@PhilippvK PhilippvK merged commit 17cfc0a into PhilippvK:master Aug 25, 2024
2 checks passed
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.

2 participants