From ea391d4bcfe82b5ab083a68170f71a52ce0f2623 Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Wed, 21 Sep 2011 11:37:20 +0000 Subject: [PATCH] Fixing watching game gameId!=tableId mixup. --- .../main/java/com/gempukku/lotro/hall/HallInfoVisitor.java | 2 +- .../src/main/java/com/gempukku/lotro/hall/HallServer.java | 4 ++-- .../java/com/gempukku/lotro/server/ServerResource.java | 4 +++- gemp-lotr/gemp-lotr-web/src/main/webapp/js/hallUi.js | 7 ++++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallInfoVisitor.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallInfoVisitor.java index 152d0f989..ceaf2c787 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallInfoVisitor.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallInfoVisitor.java @@ -5,7 +5,7 @@ import java.util.Set; public interface HallInfoVisitor { public void playerIsWaiting(boolean waiting); - public void visitTable(String tableId, String tableStatus, Set playerIds); + public void visitTable(String tableId, String gameId, String tableStatus, Set playerIds); public void runningPlayerGame(String gameId); } diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallServer.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallServer.java index a05b9fe93..6a6135e23 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallServer.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/hall/HallServer.java @@ -133,13 +133,13 @@ public class HallServer extends AbstractServer { Map copy = new HashMap(_awaitingTables); for (Map.Entry table : copy.entrySet()) - visitor.visitTable(table.getKey(), "Waiting", table.getValue().getPlayerNames()); + visitor.visitTable(table.getKey(), null, "Waiting", table.getValue().getPlayerNames()); Map runningCopy = new LinkedHashMap(_runningTables); for (Map.Entry runningGame : runningCopy.entrySet()) { LotroGameMediator lotroGameMediator = _lotroServer.getGameById(runningGame.getValue()); if (lotroGameMediator != null) - visitor.visitTable(runningGame.getKey(), lotroGameMediator.getGameStatus(), lotroGameMediator.getPlayersPlaying()); + visitor.visitTable(runningGame.getKey(), runningGame.getValue(), lotroGameMediator.getGameStatus(), lotroGameMediator.getPlayersPlaying()); } String playerTable = getNonFinishedPlayerTable(participantId); diff --git a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/ServerResource.java b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/ServerResource.java index 2b5864157..1788a98bd 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/ServerResource.java +++ b/gemp-lotr/gemp-lotr-web/src/main/java/com/gempukku/lotro/server/ServerResource.java @@ -553,9 +553,11 @@ public class ServerResource { } @Override - public void visitTable(String tableId, String tableStatus, Set playerIds) { + public void visitTable(String tableId, String gameId, String tableStatus, Set playerIds) { Element table = _doc.createElement("table"); table.setAttribute("id", tableId); + if (gameId != null) + table.setAttribute("gameId", gameId); table.setAttribute("status", tableStatus); table.setAttribute("players", mergeStrings(playerIds)); _hall.appendChild(table); diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/hallUi.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/hallUi.js index f73915c05..4c02d7291 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/hallUi.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/hallUi.js @@ -99,13 +99,14 @@ var GempLotrHallUI = Class.extend({ for (var i = 0; i < tables.length; i++) { var table = tables[i]; var id = table.getAttribute("id"); + var gameId = table.getAttribute("gameId"); var status = table.getAttribute("status"); var playersAttr = table.getAttribute("players"); var players = new Array(); if (playersAttr.length > 0) players = playersAttr.split(","); - var tableDiv = this.createTableDiv(id, status, players, waiting); + var tableDiv = this.createTableDiv(id, gameId, status, players, waiting); this.tablesDiv.append(tableDiv); } @@ -146,7 +147,7 @@ var GempLotrHallUI = Class.extend({ } }, - createTableDiv: function(id, status, players, waiting) { + createTableDiv: function(id, gameId, status, players, waiting) { var tableDiv = $("
"); tableDiv.css({ display: "inline-block", width: "120px", height: "120px", margin: "5px", "background-color": "#333300", color: "#ffffff"}); tableDiv.append("
" + status + "
"); @@ -177,7 +178,7 @@ var GempLotrHallUI = Class.extend({ var participantIdAppend = ""; if (participantId != null) participantIdAppend = "&participantId=" + participantId; - location.href = "/gemp-lotr/game.html?gameId=" + id + participantIdAppend; + location.href = "/gemp-lotr/game.html?gameId=" + gameId + participantIdAppend; }); tableDiv.append(but); }