yairm210 / Unciv

Open-source Android/Desktop remake of Civ V
Mozilla Public License 2.0
8.33k stars 1.56k forks source link

Improvements to online multiplayer system #6360

Closed GGGuenni closed 5 months ago

GGGuenni commented 2 years ago

Ideas to improve the multiplayer. Some things were already planned and pursued in #9497

  1. Multiplayer lobbies: A lobby before the game starts, where everyone can choose their Civ themselves and only the leader can change game related settings
  2. Public lobbies + list: Is this worth the implementation effort? Would this even be used? Maybe ask in a Poll if people would use this
  3. Kick players: Should it be a democratic vote or leader decides? Maybe Poll this
ravignir commented 2 years ago

Imo, the most important thing is to implement some anti-cheating features.

GGGuenni commented 2 years ago

Imo, the most important thing is to implement some anti-cheating features.

Sadly not possible as far as I can tell. Players will always have the ability to modify the game files or even create a cheating version of unciv on their own repo. There is not much we can do about that. But that's one of the reasons I don't know if public lobbies would even be used.

xlenstra commented 2 years ago

I don't think we have to make it completely fool-proof, but making it more difficult might already be enough to stop most ways of cheating. Currently, in order to start a game you need to send the host your userID, which the host can then later use at any moment to log into the game and mess up your empire. One way to prevent this, is by not sharing userID's, but by sharing usernames (as you're already planning) and not making these one-to-one translatable to userID's. For example, adding a file in the dropbox saving usernames, hash-encrypted passwords and password-encrypted userID's. This will also allow users to easily sync multiplayer games across different devices; simply logging in with the same account on a different device automatically gives access to the userID, no copy+pasting between different devices required. We could then also save the username, password & userId in gameSettings.json, so we can automatically try logging in again whenever the multiplayer tab is opened.

This would, of course, still leave open the possibility for people to clone the repo and create a version where all passwords are accepted, but the only way out of that is to run all authentication server-side, which is in the current server setup impossible.

GGGuenni commented 2 years ago

One way to prevent this, is by not sharing userID's, but by sharing usernames

My current plan is to not share anything directly with the game creator but to join a game through a lobby yourself. The only thing that is displayed in-game to everyone in the lobby is currently the first 8 characters of the UUID as I do not have user names implemented yet. Ids can still always be read from the game file itself though

Login system through dropbox sounds kinda crazy but maybe worth a try if it's needed

Looks like the number one priority for me should be finding a way to handle the rate limit fiesta that is going on. Don't know what the Dropbox tos say about it but as the rate limit is enforced per User we could create multiple accounts that all access the same dropbox which can then in game be selected as different access points

SomeTroglodyte commented 2 years ago

Shouldn't #1 prio be to finish the backing storage abstraction with at least one working alternate provider, be it local UNC paths or WebDAV?

touhidurrr commented 2 years ago

Multiplayer lobbies: A lobby before the game starts, where everyone can choose their Civ themselves and only the leader can change game related settings

I will say that try not to create more type of files. Ditch Multiplayer Lobbies data to the _preview file and when the game start create the game file.

touhidurrr commented 2 years ago

Imo, the most important thing is to implement some anti-cheating features.

I was thought of implementing some on UncivServer.xyz as such that players game files won't have data about other civs. So, that they can't see others conditions and cheat. But this has some problems even if cleverly implemented.

  1. The host needs to process the game and thus needs everyones data
  2. Other's can mimic players and see game data anyways (by using others user ID)
  3. Might lead to many unknown circumstances That's why my plan never progressed.
itanasi commented 2 years ago

Another idea, turn timer? If you don't move in X time, either skip turn or resign eventually. Might need to be a Server thing unfortunately

touhidurrr commented 2 years ago

Another idea, turn timer? If you don't move in X time, either skip turn or resign eventually. Might need to be a Server thing unfortunately

It can also be manually programming in a per client basis so that clients secretly kick out a player who doesn’t move for X time. That would be a fun to know feature that would give chuckles to a programmer. Maybe kinda like using Clients to mine Crypto. (Lol)

I have always had similar Idea from mid 2021 when i started played Unciv. But for lazyness forgot it quickly. Maybe since now I have a server, I would try to implement such logic.

touhidurrr commented 2 years ago

Also now that I think about it. How would you know if this is a server or client thing if when you try to join a game, you see yourself kicked out. It would seem like seamless right? XD

itanasi commented 2 years ago

Trouble with client side is you can easily change system time.

Also, how would the system then pass the game to the next player?

touhidurrr commented 2 years ago

Trouble with client side is you can easily change system time.

Also, how would the system then pass the game to the next player?

Fetch the time from NTP or something on startup!!! Case closed!!!!

qwerty2586 commented 1 year ago

I think multiplayer server should use websockets instead of constant polling preview save each 500ms. With websockets server can distribute save instant when is pushed by other player. With some stream code, it can be started distributing even before upload is complete for example. Also with websockets server is aware who is connected and signal this info to players. Server will also have awereness who is on turn and make players skip if timeout is reached.

Here is interesting implementation of dummy websocket server. https://github.com/mafintosh/signalhub

touhidurrr commented 1 year ago

I think multiplayer server should use websockets instead of constant polling preview save each 500ms. With websockets server can distribute save instant when is pushed by other player. With some stream code, it can be started distributing even before upload is complete for example. Also with websockets server is aware who is connected and signal this info to players. Server will also have awereness who is on turn and make players skip if timeout is reached.

Here is interesting implementation of dummy websocket server. https://github.com/mafintosh/signalhub

Unciv uses free Dropbox API by default. So, no WebSocket for now. But I do think WebSocket support should be included. I am open to implement WebSocket for UncivServer.xyz if it is ever implemented. I think I also asked for it at some point or another.

itanasi commented 9 months ago

Reviving this.

Something helpful would be a Password Screen for each time you start your turn. Merge it into the "Start " screen used for Hotseat.

If no Password, can just Continue.

If a Password is set, can opt to change it or just enter password to enter the turn.

Save hashed password in the save file per civilization.

Would improve security for Hotseat and Online MP.

Civ5 screens image

ravignir commented 9 months ago

disable charts for non spectator players until the game ends.

GGGuenni commented 9 months ago

Something helpful would be a Password Screen for each time you start your turn

It is currently shown on next turn when trying to upload the file and the password hasn't been set in the options yet or the set password is wrong. Only works if the server supports auth v1 and only for multiplayer, not hotseat. (Well, I haven't checked for a while so it might not be working anymore idk 😅 ) uncivserver.xyz currently does not support auth if I'm not mistaken as there were plans to overhaul the multiplayer completely.

This is the line that triggers the AuthPopup https://github.com/yairm210/Unciv/blob/297aa3e082640428ffcab3a96cad8b07f39d60c5/core/src/com/unciv/ui/screens/worldscreen/WorldScreen.kt#L626

disable charts for non spectator players until the game ends.

I will add it to the issue description in case someone is searching for multiplayer stuff to work on

alexban01 commented 8 months ago

@itanasi I already started implementing that but then decided to stop. I even hashed the password :))

7334

github-actions[bot] commented 5 months ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 15 days.

github-actions[bot] commented 5 months ago

This issue was closed because it has been stalled for 5 days with no activity.