JohnImril / diablo_web

This project is a web-based port of the original Diablo game. The goal of this project is to bring the classic experience of Diablo to the browser with a modern tech stack, including Vite and TypeScript.
https://johnimril.github.io/diablo_web/
13 stars 1 forks source link

Multiplayer with WebRTC #49

Open Benman2785 opened 5 days ago

Benman2785 commented 5 days ago

hi,

https://github.com/Knotschi/diabloweb has WebRTC Multiplayer working - would be nice to have this too :)

JohnImril commented 4 days ago

Hi, if you look closely, you can see that this repository is only one commit ahead of the main project. And you can see that this user made fixes in the original repository later. So the changes from there are already in my project, but I have not seen the multiplayer working in the original project or in any other repository, if you notice that it works somewhere, please let me know, otherwise I will have to do it later, but there is a chance that there will be a lot of problems with it there

Benman2785 commented 4 days ago

https://github.com/d07RiV/diabloweb/commit/998629fd5d9f87ba9693cf1409cf2acea603c06e

show that one function was disabled in latest d07RiV diabloweb version: DiabloWeb

he did it because he disabled his server who served MP

And MP via WebRTC (direct connect) works well in Knotschis Fork - i can play it on my own server (https://hoffmeister.li/diabloweb/) - even from outside of my home-network :)

Benman2785 commented 4 days ago

here a working MP Game using Knotschi fork 1st device (Host) is my Desktop 2nd device is my Mobile in Firefox Browser (Samsung)(not in WLAN)(using a VPN on my root) note: VPN is needed as my mobile carrier Vodafone blocks needed ports - when using the VPN i can also join a game on https://knotschi.github.io/diabloweb/ between my PC and Mobile

Knotschi-MP_VPN

and here is the error in your version (which is linked to https://github.com/d07RiV/diabloweb/commit/998629fd5d9f87ba9693cf1409cf2acea603c06e )

JohnImril_MP_bug

Benman2785 commented 4 days ago

as its a direct connection i can even play on "my server" with my desktop and connect my phone via knotschis server (github.io) - it still works tested this while being in WLAN and VPN - both worked

JohnImril commented 4 days ago

Thank you very much, you are the hero this city needs) added wasm._SNet_InitWebsocket(); Please check that this works correctly. And what are we going to do with it?

const sock = (websocket = websocket_open(
"wss://diablo.rivsoft.net/websocket",

I don't really like that the project has URLs that I can't control. And if you see that there are improvements somewhere that I missed, then let me know right away

Benman2785 commented 3 days ago

https://github.com/d07RiV/diabloweb/commit/0c9403436f97f92ff5904f974fcadccf5f9f8909

shows that we have to use https://peerjs.com server webrtc

Benman2785 commented 3 days ago

otherwise you can include a peerjs WebRTC signaling server in your built - so that you dont relay on an outside source

Benman2785 commented 3 days ago

ah i see - you added Knotschis fix already: -but it doesnt work in your built tested it right now - it connects to peerjs - but only the host; no other player can join

Benman2785 commented 3 days ago

both Singleplayer & Multiplayer are not working correctly

  1. index*.js gives lots of errors
  2. your character isnt saved for SP & MP
  3. every time you start game it behaves its the first run (plays cinematic)
  4. WebRTC: only host joins game - but no other clients can join

i think main problem is: 3.

Benman2785 commented 3 days ago

behaviour of downloading diabdat.mpq (or spawn.mpq if not set isRetail = "true") for second time starting of game is only in Firefox // Edge/Chrome work fine

behaviour of not saving single*.sv & multi.sv & spawn_.sv is only present in Firefox

= i suspect Firefox has problems with its cache here - but this was NOT present before changes (yes there was an Firefox update today - but i dont think this is at fault here - as Knotschi fork still works fine)

Benman2785 commented 3 days ago

found the Problem with MultiPlayer:

here a peerjs.com url of your build: wss://0.peerjs.com/peerjs?key=peerjs&id=6b339bef-52be-4dc2-97e0-293c073fe190&token=06li5ac17j3k&version=1.5.4

here a peerjs.com url of Knotschi fork wss://0.peerjs.com/peerjs?key=peerjs&id=diabloweb_dDv62yHQrZJP28tBEHL_asd&token=jkdxpdtifp

somehow your build does not take the correct id and also adds a version number

ps asd was the name of my game - thats why we cant connect, as your id is unique and doesnt add the game name to a fixed string

JohnImril commented 3 days ago

thanks, isRetail will not work correctly with all launch options because it is forcibly configured to launch on its own server, but we will deal with it later, here most likely there are still discrepancies in my project and its fork, I will check and fix it