Broke-out all modifications to the tables DSet into overrideable methods.

updateTables was already there, but I renamed it for consistency.
Pretty sure this doesn't booch any subclasses.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@847 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Ray Greenwell
2009-06-03 23:21:25 +00:00
parent 4521753319
commit cd138d2258
@@ -234,7 +234,7 @@ public class TableManager
}
// update the table in the lobby
updateTable(table);
updateTableInLobby(table);
// there is normally no success response. the client will see
// themselves show up in the table that they joined
@@ -274,7 +274,7 @@ public class TableManager
if (table.isEmpty()) {
purgeTable(table);
} else {
updateTable(table);
updateTableInLobby(table);
}
// there is normally no success response. the client will see
@@ -330,7 +330,7 @@ public class TableManager
", table=" + table + "].");
}
table.clearPlayerPos(position);
updateTable(table);
updateTableInLobby(table);
}
/**
@@ -341,7 +341,7 @@ public class TableManager
{
// publish the table in the lobby object if desired
if (shouldPublish(table)) {
_tlobj.addToTables(table);
addTableToLobby(table);
}
}
@@ -367,9 +367,7 @@ public class TableManager
// remove the table from the lobby object (the table may not have been published if a
// derived class decided it was not worth publishing, see shouldPublish())
if (_tlobj.getTables().containsKey(table.tableId)) {
_tlobj.removeFromTables(table.tableId);
}
removeTableFromLobby(table.tableId);
// remove the listener too so we do not get a request later on to update the occupants or
// unmap this table
@@ -483,10 +481,10 @@ public class TableManager
// and then update the lobby object that contains the table
if (shouldPublish(table)) {
updateTable(table);
} else if (_tlobj.getTables().containsKey(table.tableId)) {
updateTableInLobby(table);
} else {
// or remove it if the table is no longer "interesting"
_tlobj.removeFromTables(table.tableId);
removeTableFromLobby(table.tableId);
}
}
@@ -528,7 +526,7 @@ public class TableManager
// update this table's occupants information and update the table
GameObject gameObj = (GameObject)_omgr.getObject(gameOid);
table.updateOccupants(gameObj);
updateTable(table);
updateTableInLobby(table);
}
/**
@@ -554,7 +552,7 @@ public class TableManager
if (pender.isEmpty()) {
purgeTable(pender);
} else {
updateTable(pender);
updateTableInLobby(pender);
}
}
@@ -569,7 +567,19 @@ public class TableManager
return true; // we publish all tables by default
}
protected void updateTable (Table table)
/**
* Add the table to the lobby object, <b>after it has already been validated as being
* publishable</b>.
*/
protected void addTableToLobby (Table table)
{
_tlobj.addToTables(table);
}
/**
* Safely update the table in the lobby, if it's there.
*/
protected void updateTableInLobby (Table table)
{
// the table may not have been published, see shouldPublish()
if (_tlobj.getTables().containsKey(table.tableId)) {
@@ -577,6 +587,16 @@ public class TableManager
}
}
/**
* Safely remove the table from the lobby. Broken out for overriding.
*/
protected void removeTableFromLobby (Integer tableId)
{
if (_tlobj.getTables().containsKey(tableId)) {
_tlobj.removeFromTables(tableId);
}
}
/** Listens to all games and updates the table objects as necessary. */
protected class GameListener
implements ObjectDeathListener, OidListListener