Commit a0863d1f authored by mercury233's avatar mercury233

fix room error

parent f9321212
...@@ -379,6 +379,21 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)-> ...@@ -379,6 +379,21 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
windbot = _.sample settings.modules.windbots windbot = _.sample settings.modules.windbots
room = Room.find_or_create_by_name('AI#' + Math.floor(Math.random() * 100000)) # 这个 AI# 没有特殊作用, 仅作为标记 room = Room.find_or_create_by_name('AI#' + Math.floor(Math.random() * 100000)) # 这个 AI# 没有特殊作用, 仅作为标记
if !room
ygopro.stoc_send_chat(client, "服务器已经爆满,请稍候再试", ygopro.constants.COLORS.RED)
ygopro.stoc_send client, 'ERROR_MSG', {
msg: 1
code: 2
}
client.end()
else if room.error
ygopro.stoc_send_chat(client, room.error, ygopro.constants.COLORS.RED)
ygopro.stoc_send client, 'ERROR_MSG', {
msg: 1
code: 2
}
client.end()
else
room.windbot = windbot room.windbot = windbot
room.private = true room.private = true
client.room = room client.room = room
...@@ -480,6 +495,21 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)-> ...@@ -480,6 +495,21 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
} }
client.end() client.end()
return return
if !room
ygopro.stoc_send_chat(client, "服务器已经爆满,请稍候再试", ygopro.constants.COLORS.RED)
ygopro.stoc_send client, 'ERROR_MSG', {
msg: 1
code: 2
}
client.end()
else if room.error
ygopro.stoc_send_chat(client, room.error, ygopro.constants.COLORS.RED)
ygopro.stoc_send client, 'ERROR_MSG', {
msg: 1
code: 2
}
client.end()
else
client.room = room client.room = room
client.room.connect(client) client.room.connect(client)
......
...@@ -432,10 +432,26 @@ ...@@ -432,10 +432,26 @@
windbot = _.sample(settings.modules.windbots); windbot = _.sample(settings.modules.windbots);
} }
room = Room.find_or_create_by_name('AI#' + Math.floor(Math.random() * 100000)); room = Room.find_or_create_by_name('AI#' + Math.floor(Math.random() * 100000));
if (!room) {
ygopro.stoc_send_chat(client, "服务器已经爆满,请稍候再试", ygopro.constants.COLORS.RED);
ygopro.stoc_send(client, 'ERROR_MSG', {
msg: 1,
code: 2
});
client.end();
} else if (room.error) {
ygopro.stoc_send_chat(client, room.error, ygopro.constants.COLORS.RED);
ygopro.stoc_send(client, 'ERROR_MSG', {
msg: 1,
code: 2
});
client.end();
} else {
room.windbot = windbot; room.windbot = windbot;
room["private"] = true; room["private"] = true;
client.room = room; client.room = room;
client.room.connect(client); client.room.connect(client);
}
} else if (info.pass.length && settings.modules.mycard_auth) { } else if (info.pass.length && settings.modules.mycard_auth) {
ygopro.stoc_send_chat(client, '正在读取用户信息...', ygopro.constants.COLORS.RED); ygopro.stoc_send_chat(client, '正在读取用户信息...', ygopro.constants.COLORS.RED);
if (info.pass.length <= 8) { if (info.pass.length <= 8) {
...@@ -538,8 +554,24 @@ ...@@ -538,8 +554,24 @@
client.end(); client.end();
return; return;
} }
if (!room) {
ygopro.stoc_send_chat(client, "服务器已经爆满,请稍候再试", ygopro.constants.COLORS.RED);
ygopro.stoc_send(client, 'ERROR_MSG', {
msg: 1,
code: 2
});
return client.end();
} else if (room.error) {
ygopro.stoc_send_chat(client, room.error, ygopro.constants.COLORS.RED);
ygopro.stoc_send(client, 'ERROR_MSG', {
msg: 1,
code: 2
});
return client.end();
} else {
client.room = room; client.room = room;
return client.room.connect(client); return client.room.connect(client);
}
}; };
if (id = users_cache[client.name]) { if (id = users_cache[client.name]) {
secret = id % 65535 + 1; secret = id % 65535 + 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment