srv
This commit is contained in:
parent
1a3e16d65e
commit
2601346af3
1 changed files with 5 additions and 2 deletions
|
@ -12,6 +12,8 @@ const connections = new Set();
|
||||||
var playerCount = 0;
|
var playerCount = 0;
|
||||||
var players = []
|
var players = []
|
||||||
|
|
||||||
|
const NAME_MAXLEN = 25;
|
||||||
|
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.send('Grand Tabernacle Auto VI');
|
res.send('Grand Tabernacle Auto VI');
|
||||||
});
|
});
|
||||||
|
@ -50,6 +52,7 @@ function generatePosition(){
|
||||||
x = Math.floor(Math.random()*mapWidth);
|
x = Math.floor(Math.random()*mapWidth);
|
||||||
y = Math.floor(Math.random()*mapHeight);
|
y = Math.floor(Math.random()*mapHeight);
|
||||||
count++;
|
count++;
|
||||||
|
console.log(x,y, count);
|
||||||
if(count >= 1000){
|
if(count >= 1000){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -93,8 +96,8 @@ wss.on('connection', (socket, req) => {
|
||||||
if(username===undefined || username == null){
|
if(username===undefined || username == null){
|
||||||
username = "Soldat Inconnu"
|
username = "Soldat Inconnu"
|
||||||
}
|
}
|
||||||
if(username.length > 100){
|
if(username.length > NAME_MAXLEN){
|
||||||
username=username.substring(0, 100);
|
username=username.substring(0, NAME_MAXLEN);
|
||||||
}
|
}
|
||||||
createNewPlayer(socket, username);
|
createNewPlayer(socket, username);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue