Skip to content

Commit 41bb39c

Browse files
committed
wait for proxy
1 parent a212dcb commit 41bb39c

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

lib/server.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ const port = process.env.PORT || 8080
55

66
app.use(netApi({ allowOrigin: '*' }))
77

8+
app.use("/proxyCheck",(req,res,next)=>{
9+
res.send("OK")
10+
})
11+
812
app.listen(port, () => {
913
console.log(`Server is running on \x1b[34m*:${port}\x1b[0m`)
1014
})

src/scripts/Setup.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,27 @@ function Setup (game) {
5454
game.inv_bar = new InventoryBar(game)
5555
game.tl = new TabList(game)
5656
game.ls = new LoadingScreen(game)
57-
game.ls.show(`Connecting to ${game.server}...`)
57+
game.ls.show(`Waiting for proxy...`)
58+
let hostname, port, pars
59+
if (game.proxy === 'local') {
60+
hostname = document.location.hostname
61+
port = document.location.port
62+
} else if (game.proxy === 'production') {
63+
pars = game.al.get('config').proxy.split(':')
64+
hostname = pars[0]
65+
port = pars[1]
66+
} else {
67+
pars = game.proxy.split(':')
68+
hostname = pars[0]
69+
port = pars[1]
70+
}
71+
fetch(`${document.location.protocol}//${hostname}:${port}/proxyCheck`)
72+
.then(response => response.text())
73+
.then(data => {
74+
if(data=="OK"){
75+
game.ls.show(`Connecting to ${game.server}...`)
76+
}
77+
});
5878
game.distanceBasedFog.addShaderToMaterials([
5979
game.world.material,
6080
game.ent.mobMaterial,

src/scripts/rendering/DistanceBasedFog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class DistanceBasedFog {
1010
}
1111

1212
updateDistance (val) {
13-
this.farnear.x = (Math.sqrt(val)) * 16
13+
this.farnear.x = (Math.sqrt(val-1.5)) * 16
1414
this.farnear.y = (val - 1) * 16
1515
}
1616

0 commit comments

Comments
 (0)