Commit ff90522a authored by nanahira's avatar nanahira

merge

parents 2b598a79 553b983a
......@@ -251,7 +251,7 @@ function Struct() {
this.allocate = function () {
applyClosures(priv);
priv.buf = new Buffer(priv.len);
priv.buf = Buffer.alloc(priv.len);
allocateFields();
priv.allocated = true;
return this;
......
......@@ -1292,7 +1292,7 @@ net.createServer (client) ->
ygopro.stoc_die(client, "${cloud_replay_no}")
return
redisdb.expire("replay:"+replay.replay_id, 60*60*48)
buffer=new Buffer(replay.replay_buffer,'binary')
buffer=Buffer.from(replay.replay_buffer,'binary')
zlib.unzip buffer, (err, replay_buffer) ->
if err
log.info "cloud replay unzip error: " + err
......@@ -1316,7 +1316,7 @@ net.createServer (client) ->
room=ROOM_all[client.rid]
room.watcher.write ctos_buffer if room
else
#ctos_buffer = new Buffer(0)
#ctos_buffer = Buffer.alloc(0)
ctos_message_length = 0
ctos_proto = 0
#ctos_buffer = Buffer.concat([ctos_buffer, data], ctos_buffer.length + data.length) #buffer的错误使用方式,好孩子不要学
......@@ -1384,7 +1384,7 @@ net.createServer (client) ->
# 服务端到客户端(stoc)
server.on 'data', (stoc_buffer)->
#stoc_buffer = new Buffer(0)
#stoc_buffer = Buffer.alloc(0)
stoc_message_length = 0
stoc_proto = 0
#stoc_buffer = Buffer.concat([stoc_buffer, data], stoc_buffer.length + data.length) #buffer的错误使用方式,好孩子不要学
......@@ -1570,7 +1570,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
# struct.set("version", info.version)
# buffer = struct.buffer
buffer = new Buffer(info.pass[0...8], 'base64')
buffer = Buffer.from(info.pass[0...8], 'base64')
if buffer.length != 6
ygopro.stoc_die(client, '${invalid_password_payload}')
......@@ -1673,7 +1673,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
if id = users_cache[client.name]
secret = id % 65535 + 1
decrypted_buffer = new Buffer(6)
decrypted_buffer = Buffer.allocUnsafe(6)
for i in [0, 2, 4]
decrypted_buffer.writeUInt16LE(buffer.readUInt16LE(i) ^ secret, i)
if check(decrypted_buffer)
......@@ -1692,7 +1692,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
if body and body.user
users_cache[client.name] = body.user.id
secret = body.user.id % 65535 + 1
decrypted_buffer = new Buffer(6)
decrypted_buffer = Buffer.allocUnsafe(6)
for i in [0, 2, 4]
decrypted_buffer.writeUInt16LE(buffer.readUInt16LE(i) ^ secret, i)
if check(decrypted_buffer)
......
......@@ -1676,7 +1676,7 @@
return;
}
redisdb.expire("replay:" + replay.replay_id, 60 * 60 * 48);
buffer = new Buffer(replay.replay_buffer, 'binary');
buffer = Buffer.from(replay.replay_buffer, 'binary');
zlib.unzip(buffer, function(err, replay_buffer) {
if (err) {
log.info("cloud replay unzip error: " + err);
......@@ -1971,7 +1971,7 @@
ygopro.stoc_die(client, '${invalid_password_length}');
return;
}
buffer = new Buffer(info.pass.slice(0, 8), 'base64');
buffer = Buffer.from(info.pass.slice(0, 8), 'base64');
if (buffer.length !== 6) {
ygopro.stoc_die(client, '${invalid_password_payload}');
return;
......@@ -2087,7 +2087,7 @@
};
if (id = users_cache[client.name]) {
secret = id % 65535 + 1;
decrypted_buffer = new Buffer(6);
decrypted_buffer = Buffer.allocUnsafe(6);
ref3 = [0, 2, 4];
for (m = 0, len2 = ref3.length; m < len2; m++) {
i = ref3[m];
......@@ -2111,7 +2111,7 @@
if (body && body.user) {
users_cache[client.name] = body.user.id;
secret = body.user.id % 65535 + 1;
decrypted_buffer = new Buffer(6);
decrypted_buffer = Buffer.allocUnsafe(6);
ref4 = [0, 2, 4];
for (n = 0, len3 = ref4.length; n < len3; n++) {
i = ref4[n];
......
......@@ -80,7 +80,7 @@ for name, declaration of structs_declaration
break
throw "unknown proto" if !@constants.STOC[proto]
header = new Buffer(3)
header = Buffer.allocUnsafe(3)
header.writeUInt16LE buffer.length + 1, 0
header.writeUInt8 proto, 2
socket.write header
......@@ -108,7 +108,7 @@ for name, declaration of structs_declaration
break
throw "unknown proto" if !@constants.CTOS[proto]
header = new Buffer(3)
header = Buffer.allocUnsafe(3)
header.writeUInt16LE buffer.length + 1, 0
header.writeUInt8 proto, 2
socket.write header
......
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