Commit d585c032 authored by nanahira's avatar nanahira

merge

parents d4087134 306c62e1
......@@ -1106,6 +1106,7 @@ class Room
try
@process = spawn './ygopro', param, {cwd: 'ygopro'}
@process_pid = @process.pid
@process.on 'error', (err)=>
_.each @players, (player)->
ygopro.stoc_die(player, "${create_room_failed}")
......@@ -2799,7 +2800,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
deck_arena = deck_arena + 'custom'
#log.info "DECK LOG START", client.name, room.arena
if settings.modules.deck_log.local
deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.port + ' ' + client.pos + ' ' + client.ip.slice(7) + ' ' + client.name.replace(/[\/\\\?\*]/g, '_')
deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.process_pid + ' ' + client.pos + ' ' + client.ip.slice(7) + ' ' + client.name.replace(/[\/\\\?\*]/g, '_')
fs.writeFile settings.modules.deck_log.local + deck_name + '.ydk', deck_text, 'utf-8', (err) ->
if err
log.warn 'DECK SAVE ERROR', err
......@@ -3401,7 +3402,7 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
duellog = {
time: dueltime,
name: room.name + (if settings.modules.tournament_mode.show_info then (" (Duel:" + room.duel_count + ")") else ""),
roomid: room.port.toString(),
roomid: room.process_pid.toString(),
cloud_replay_id: "R#"+room.cloud_replay_id,
replay_filename: replay_filename,
roommode: room.hostinfo.mode,
......@@ -3520,16 +3521,21 @@ if settings.modules.http
else
response.writeHead(200)
roomsjson = JSON.stringify rooms: (for room in ROOM_all when room and room.established
pid: room.process.pid.toString(),
roomid: room.port.toString(),
roomid: room.process_pid.toString(),
roomname: if pass_validated then room.name else room.name.split('$', 2)[0],
roommode: room.hostinfo.mode,
needpass: (room.name.indexOf('$') != -1).toString(),
users: (for player in room.players when player.pos?
users: _.sortBy((for player in room.players when player.pos?
id: (-1).toString(),
name: player.name + (if settings.modules.http.show_ip and pass_validated and !player.is_local then (" (IP: " + player.ip.slice(7) + ")") else "") + (if settings.modules.http.show_info and room.started and player.pos != 7 and not (room.hostinfo.mode == 2 and player.pos % 2 > 0) then (" (Score:" + room.scores[player.name_vpass] + " LP:" + (if player.lp? then player.lp else room.hostinfo.start_lp) + (if room.hostinfo.mode != 2 then (" Cards:" + (if player.card_count? then player.card_count else room.hostinfo.start_hand)) else "") + ")") else ""),
name: player.name,
ip: if settings.modules.http.show_ip and pass_validated and !player.is_local then player.ip.slice(7) else null,
status: if settings.modules.http.show_info and room.started and player.pos != 7 then (
score: room.scores[player.name_vpass],
lp: if player.lp? then player.lp else room.hostinfo.start_lp,
cards: if room.hostinfo.mode != 2 then (if player.card_count? then player.card_count else room.hostinfo.start_hand) else null
) else null,
pos: player.pos
),
), "pos"),
istart: if room.started then (if settings.modules.http.show_info then ("Duel:" + room.duel_count + " " + (if room.changing_side then "Siding" else "Turn:" + (if room.turn? then room.turn else 0) + (if room.death then "/" + (if room.death > 0 then room.death - 1 else "Death") else ""))) else 'start') else 'wait'
), null, 2
response.end(addCallback(u.query.callback, roomsjson))
......@@ -3691,7 +3697,7 @@ if settings.modules.http
else if u.query.kick
kick_room_found = false
for room in ROOM_all when room and room.established and (u.query.kick == "all" or u.query.kick == room.port.toString() or u.query.kick == room.name)
for room in ROOM_all when room and room.established and (u.query.kick == "all" or u.query.kick == room.process_pid.toString() or u.query.kick == room.name)
kick_room_found = true
if room.started
room.scores[room.dueling_players[0].name_vpass] = 0
......@@ -3707,7 +3713,7 @@ if settings.modules.http
else if u.query.death
death_room_found = false
for room in ROOM_all when room and room.established and room.started and !room.death and (u.query.death == "all" or u.query.death == room.port.toString() or u.query.death == room.name)
for room in ROOM_all when room and room.established and room.started and !room.death and (u.query.death == "all" or u.query.death == room.process_pid.toString() or u.query.death == room.name)
death_room_found = true
oppo_pos = if room.hostinfo.mode == 2 then 2 else 1
if !room.changing_side and (!room.duel_count or room.turn)
......@@ -3751,7 +3757,7 @@ if settings.modules.http
else if u.query.deathcancel
death_room_found = false
for room in ROOM_all when room and room.established and room.started and room.death and (u.query.deathcancel == "all" or u.query.deathcancel == room.port.toString())
for room in ROOM_all when room and room.established and room.started and room.death and (u.query.deathcancel == "all" or u.query.deathcancel == room.process_pid.toString())
death_room_found = true
room.death = 0
ygopro.stoc_send_chat_to_room(room, "${death_cancel}", ygopro.constants.COLORS.BABYBLUE)
......
......@@ -1318,8 +1318,12 @@
} else if (name.slice(0, 3) === 'AI#') {
this.hostinfo.rule = 2;
this.hostinfo.lflist = -1;
<<<<<<< HEAD
this.hostinfo.time_limit = 0;
this.hostinfo.no_check_deck = true;
=======
this.hostinfo.time_limit = 999;
>>>>>>> mc
} else if ((param = name.match(/^(\d)(\d)(T|F)(T|F)(T|F)(\d+),(\d+),(\d+)/i))) {
this.hostinfo.rule = parseInt(param[1]);
this.hostinfo.mode = parseInt(param[2]);
......@@ -1419,6 +1423,7 @@
this.process = spawn('./ygopro', param, {
cwd: 'ygopro'
});
this.process_pid = this.process.pid;
this.process.on('error', (function(_this) {
return function(err) {
_.each(_this.players, function(player) {
......@@ -3551,7 +3556,7 @@
deck_arena = deck_arena + 'custom';
}
if (settings.modules.deck_log.local) {
deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.port + ' ' + client.pos + ' ' + client.ip.slice(7) + ' ' + client.name.replace(/[\/\\\?\*]/g, '_');
deck_name = moment().format('YYYY-MM-DD HH-mm-ss') + ' ' + room.process_pid + ' ' + client.pos + ' ' + client.ip.slice(7) + ' ' + client.name.replace(/[\/\\\?\*]/g, '_');
fs.writeFile(settings.modules.deck_log.local + deck_name + '.ydk', deck_text, 'utf-8', function(err) {
if (err) {
return log.warn('DECK SAVE ERROR', err);
......@@ -4367,7 +4372,7 @@
duellog = {
time: dueltime,
name: room.name + (settings.modules.tournament_mode.show_info ? " (Duel:" + room.duel_count + ")" : ""),
roomid: room.port.toString(),
roomid: room.process_pid.toString(),
cloud_replay_id: "R#" + room.cloud_replay_id,
replay_filename: replay_filename,
roommode: room.hostinfo.mode,
......@@ -4534,27 +4539,38 @@
room = ROOM_all[m];
if (room && room.established) {
results.push({
pid: room.process.pid.toString(),
roomid: room.port.toString(),
roomid: room.process_pid.toString(),
roomname: pass_validated ? room.name : room.name.split('$', 2)[0],
roommode: room.hostinfo.mode,
needpass: (room.name.indexOf('$') !== -1).toString(),
<<<<<<< HEAD
users: (function() {
var len3, n, ref3, results1;
ref3 = room.players;
=======
users: _.sortBy((function() {
var len3, n, ref2, results1;
ref2 = room.players;
>>>>>>> mc
results1 = [];
for (n = 0, len3 = ref3.length; n < len3; n++) {
player = ref3[n];
if (player.pos != null) {
results1.push({
id: (-1).toString(),
name: player.name + (settings.modules.http.show_ip && pass_validated && !player.is_local ? " (IP: " + player.ip.slice(7) + ")" : "") + (settings.modules.http.show_info && room.started && player.pos !== 7 && !(room.hostinfo.mode === 2 && player.pos % 2 > 0) ? " (Score:" + room.scores[player.name_vpass] + " LP:" + (player.lp != null ? player.lp : room.hostinfo.start_lp) + (room.hostinfo.mode !== 2 ? " Cards:" + (player.card_count != null ? player.card_count : room.hostinfo.start_hand) : "") + ")" : ""),
name: player.name,
ip: settings.modules.http.show_ip && pass_validated && !player.is_local ? player.ip.slice(7) : null,
status: settings.modules.http.show_info && room.started && player.pos !== 7 ? {
score: room.scores[player.name_vpass],
lp: player.lp != null ? player.lp : room.hostinfo.start_lp,
cards: room.hostinfo.mode !== 2 ? (player.card_count != null ? player.card_count : room.hostinfo.start_hand) : null
} : null,
pos: player.pos
});
}
}
return results1;
})(),
})(), "pos"),
istart: room.started ? (settings.modules.http.show_info ? "Duel:" + room.duel_count + " " + (room.changing_side ? "Siding" : "Turn:" + (room.turn != null ? room.turn : 0) + (room.death ? "/" + (room.death > 0 ? room.death - 1 : "Death") : "")) : 'start') : 'wait'
});
}
......@@ -4749,9 +4765,15 @@
response.end(addCallback(u.query.callback, "['ban ok', '" + u.query.ban + "']"));
} else if (u.query.kick) {
kick_room_found = false;
<<<<<<< HEAD
for (p = 0, len5 = ROOM_all.length; p < len5; p++) {
room = ROOM_all[p];
if (!(room && room.established && (u.query.kick === "all" || u.query.kick === room.port.toString() || u.query.kick === room.name))) {
=======
for (o = 0, len4 = ROOM_all.length; o < len4; o++) {
room = ROOM_all[o];
if (!(room && room.established && (u.query.kick === "all" || u.query.kick === room.process_pid.toString() || u.query.kick === room.name))) {
>>>>>>> mc
continue;
}
kick_room_found = true;
......@@ -4771,9 +4793,15 @@
}
} else if (u.query.death) {
death_room_found = false;
<<<<<<< HEAD
for (q = 0, len6 = ROOM_all.length; q < len6; q++) {
room = ROOM_all[q];
if (!(room && room.established && room.started && !room.death && (u.query.death === "all" || u.query.death === room.port.toString() || u.query.death === room.name))) {
=======
for (p = 0, len5 = ROOM_all.length; p < len5; p++) {
room = ROOM_all[p];
if (!(room && room.established && room.started && !room.death && (u.query.death === "all" || u.query.death === room.process_pid.toString() || u.query.death === room.name))) {
>>>>>>> mc
continue;
}
death_room_found = true;
......@@ -4833,9 +4861,15 @@
}
} else if (u.query.deathcancel) {
death_room_found = false;
<<<<<<< HEAD
for (r = 0, len7 = ROOM_all.length; r < len7; r++) {
room = ROOM_all[r];
if (!(room && room.established && room.started && room.death && (u.query.deathcancel === "all" || u.query.deathcancel === room.port.toString()))) {
=======
for (q = 0, len6 = ROOM_all.length; q < len6; q++) {
room = ROOM_all[q];
if (!(room && room.established && room.started && room.death && (u.query.deathcancel === "all" || u.query.deathcancel === room.process_pid.toString()))) {
>>>>>>> mc
continue;
}
death_room_found = true;
......
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