Commit 6f39fcb7 authored by Sophia's avatar Sophia

add null check for rooms

parent 4a4fb16c
...@@ -89,7 +89,7 @@ ygopro.stoc_follow("DUEL_START", false, (buffer, info, client) => __awaiter(void ...@@ -89,7 +89,7 @@ ygopro.stoc_follow("DUEL_START", false, (buffer, info, client) => __awaiter(void
return true; return true;
} }
const room = ROOM_all[client.rid]; const room = ROOM_all[client.rid];
if (room.hostinfo.mode === 2 || Boolean(room.windbot)) { if (!room || !room.dueling_players || room.hostinfo.mode === 2 || Boolean(room.windbot)) {
return true; return true;
} }
if (!room.startedAt) { if (!room.startedAt) {
...@@ -123,6 +123,9 @@ ygopro.stoc_follow("DUEL_START", false, (buffer, info, client) => __awaiter(void ...@@ -123,6 +123,9 @@ ygopro.stoc_follow("DUEL_START", false, (buffer, info, client) => __awaiter(void
ygopro.stoc_follow_after("GAME_MSG", false, (buffer, info, client) => __awaiter(void 0, void 0, void 0, function* () { ygopro.stoc_follow_after("GAME_MSG", false, (buffer, info, client) => __awaiter(void 0, void 0, void 0, function* () {
if (buffer.readUInt8(0) === 5 && client.pos === 0) { if (buffer.readUInt8(0) === 5 && client.pos === 0) {
const room = ROOM_all[client.rid]; const room = ROOM_all[client.rid];
if (!room || !room.dueling_players) {
return false;
}
const player = room.dueling_players.find(p => p.name === room.winner_name); const player = room.dueling_players.find(p => p.name === room.winner_name);
if (!player) { if (!player) {
return false; return false;
...@@ -174,7 +177,7 @@ ygopro.stoc_follow_after("REPLAY", false, (buffer, info, client) => __awaiter(vo ...@@ -174,7 +177,7 @@ ygopro.stoc_follow_after("REPLAY", false, (buffer, info, client) => __awaiter(vo
ygopro.ctos_follow_after("UPDATE_DECK", false, (buffer, info, client) => __awaiter(void 0, void 0, void 0, function* () { ygopro.ctos_follow_after("UPDATE_DECK", false, (buffer, info, client) => __awaiter(void 0, void 0, void 0, function* () {
try { try {
const room = ROOM_all[client.rid]; const room = ROOM_all[client.rid];
if (!room || Boolean(room.windbot)) { if (!room || Boolean(room.windbot) || !room.dueling_players) {
return false; return false;
} }
if (!room.customPlayerInformation) { if (!room.customPlayerInformation) {
......
...@@ -181,7 +181,7 @@ ygopro.stoc_follow("DUEL_START", false, async (buffer, info, client) => { ...@@ -181,7 +181,7 @@ ygopro.stoc_follow("DUEL_START", false, async (buffer, info, client) => {
} }
const room = ROOM_all[client.rid]; const room = ROOM_all[client.rid];
if (room.hostinfo.mode === 2 || Boolean(room.windbot)) { if (!room || !room.dueling_players || room.hostinfo.mode === 2 || Boolean(room.windbot)) {
return true; return true;
} }
...@@ -219,6 +219,10 @@ ygopro.stoc_follow("DUEL_START", false, async (buffer, info, client) => { ...@@ -219,6 +219,10 @@ ygopro.stoc_follow("DUEL_START", false, async (buffer, info, client) => {
ygopro.stoc_follow_after("GAME_MSG", false, async (buffer, info, client) => { ygopro.stoc_follow_after("GAME_MSG", false, async (buffer, info, client) => {
if (buffer.readUInt8(0) === 5 && client.pos === 0) { if (buffer.readUInt8(0) === 5 && client.pos === 0) {
const room = ROOM_all[client.rid]; const room = ROOM_all[client.rid];
if (!room || !room.dueling_players) {
return false;
}
const player = room.dueling_players.find(p => p.name === room.winner_name); const player = room.dueling_players.find(p => p.name === room.winner_name);
if (!player) { if (!player) {
return false; return false;
...@@ -281,7 +285,7 @@ ygopro.stoc_follow_after("REPLAY", false, async (buffer, info, client) => { ...@@ -281,7 +285,7 @@ ygopro.stoc_follow_after("REPLAY", false, async (buffer, info, client) => {
ygopro.ctos_follow_after("UPDATE_DECK", false, async (buffer, info, client) => { ygopro.ctos_follow_after("UPDATE_DECK", false, async (buffer, info, client) => {
try { try {
const room = ROOM_all[client.rid]; const room = ROOM_all[client.rid];
if (!room || Boolean(room.windbot)) { if (!room || Boolean(room.windbot) || !room.dueling_players) {
return false; return false;
} }
......
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