Commit 52a95565 authored by mercury233's avatar mercury233

join room by title

parent 07a64929
...@@ -261,7 +261,11 @@ ROOM_find_or_create_ai = (name)-> ...@@ -261,7 +261,11 @@ ROOM_find_or_create_ai = (name)->
ROOM_find_by_name = (name)-> ROOM_find_by_name = (name)->
result = _.find ROOM_all, (room)-> result = _.find ROOM_all, (room)->
return room and room.name == name return room and room.name == name
#log.info 'find_by_name', name, result return result
ROOM_find_by_title = (title)->
result = _.find ROOM_all, (room)->
return room and room.title == title
return result return result
ROOM_find_by_port = (port)-> ROOM_find_by_port = (port)->
...@@ -938,8 +942,9 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)-> ...@@ -938,8 +942,9 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
# 1 create public room # 1 create public room
# 2 create private room # 2 create private room
# 3 join room # 3 join room by id
# 4 join match # 4 create or join room by id (use for match)
# 5 join room by title
switch action switch action
when 1,2 when 1,2
name = crypto.createHash('md5').update(info.pass + client.name).digest('base64')[0...10].replace('+', '-').replace('/', '_') name = crypto.createHash('md5').update(info.pass + client.name).digest('base64')[0...10].replace('+', '-').replace('/', '_')
...@@ -976,6 +981,12 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)-> ...@@ -976,6 +981,12 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
room = ROOM_find_or_create_by_name('M#' + info.pass.slice(8)) room = ROOM_find_or_create_by_name('M#' + info.pass.slice(8))
room.private = true room.private = true
room.arena = settings.modules.arena_mode.mode room.arena = settings.modules.arena_mode.mode
when 5
title = info.pass.slice(8).replace(String.fromCharCode(0xFEFF), ' ')
room = ROOM_find_by_title(title)
if(!room)
ygopro.stoc_die(client, '${invalid_password_not_found}')
return
else else
ygopro.stoc_die(client, '${invalid_password_action}') ygopro.stoc_die(client, '${invalid_password_action}')
return return
......
// Generated by CoffeeScript 1.12.2 // Generated by CoffeeScript 1.12.2
(function() { (function() {
var Cloud_replay_ids, ROOM_all, ROOM_bad_ip, ROOM_ban_player, ROOM_connected_ip, ROOM_find_by_name, ROOM_find_by_port, ROOM_find_or_create_ai, ROOM_find_or_create_by_name, ROOM_find_or_create_random, ROOM_players_banned, ROOM_players_oppentlist, ROOM_unwelcome, ROOM_validate, Room, _, addCallback, ban_user, bunyan, cppversion, crypto, date, defaultconfig, execFile, fs, geoip, get_memory_usage, http, http_server, https, https_server, list, load_dialogues, load_tips, log, moment, nconf, net, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, request, requestListener, roomlist, settings, spawn, spawnSync, url, users_cache, wait_room_start, windbot_process, ygopro, zlib; var Cloud_replay_ids, ROOM_all, ROOM_bad_ip, ROOM_ban_player, ROOM_connected_ip, ROOM_find_by_name, ROOM_find_by_port, ROOM_find_by_title, ROOM_find_or_create_ai, ROOM_find_or_create_by_name, ROOM_find_or_create_random, ROOM_players_banned, ROOM_players_oppentlist, ROOM_unwelcome, ROOM_validate, Room, _, addCallback, ban_user, bunyan, cppversion, crypto, date, defaultconfig, execFile, fs, geoip, get_memory_usage, http, http_server, https, https_server, list, load_dialogues, load_tips, log, moment, nconf, net, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, request, requestListener, roomlist, settings, spawn, spawnSync, url, users_cache, wait_room_start, windbot_process, ygopro, zlib;
net = require('net'); net = require('net');
...@@ -360,6 +360,14 @@ ...@@ -360,6 +360,14 @@
return result; return result;
}; };
ROOM_find_by_title = function(title) {
var result;
result = _.find(ROOM_all, function(room) {
return room && room.title === title;
});
return result;
};
ROOM_find_by_port = function(port) { ROOM_find_by_port = function(port) {
return _.find(ROOM_all, function(room) { return _.find(ROOM_all, function(room) {
return room && room.port === port; return room && room.port === port;
...@@ -1153,7 +1161,7 @@ ...@@ -1153,7 +1161,7 @@
return (checksum & 0xFF) === 0; return (checksum & 0xFF) === 0;
}; };
finish = function(buffer) { finish = function(buffer) {
var action, j, len, name, opt1, opt2, opt3, options, ref, room; var action, j, len, name, opt1, opt2, opt3, options, ref, room, title;
action = buffer.readUInt8(1) >> 4; action = buffer.readUInt8(1) >> 4;
if (buffer !== decrypted_buffer && (action === 1 || action === 2 || action === 4)) { if (buffer !== decrypted_buffer && (action === 1 || action === 2 || action === 4)) {
ygopro.stoc_die(client, '${invalid_password_unauthorized}'); ygopro.stoc_die(client, '${invalid_password_unauthorized}');
...@@ -1202,7 +1210,16 @@ ...@@ -1202,7 +1210,16 @@
room["private"] = true; room["private"] = true;
room.arena = settings.modules.arena_mode.mode; room.arena = settings.modules.arena_mode.mode;
break; break;
case 5:
title = info.pass.slice(8).replace(String.fromCharCode(0xFEFF), ' ');
room = ROOM_find_by_title(title);
if (!room) {
ygopro.stoc_die(client, '${invalid_password_not_found}');
return;
}
break;
default: default:
console.log(1);
ygopro.stoc_die(client, '${invalid_password_action}'); ygopro.stoc_die(client, '${invalid_password_action}');
return; return;
} }
......
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