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:
@@ -234,7 +234,7 @@ public class TableManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update the table in the lobby
|
// update the table in the lobby
|
||||||
updateTable(table);
|
updateTableInLobby(table);
|
||||||
|
|
||||||
// there is normally no success response. the client will see
|
// there is normally no success response. the client will see
|
||||||
// themselves show up in the table that they joined
|
// themselves show up in the table that they joined
|
||||||
@@ -274,7 +274,7 @@ public class TableManager
|
|||||||
if (table.isEmpty()) {
|
if (table.isEmpty()) {
|
||||||
purgeTable(table);
|
purgeTable(table);
|
||||||
} else {
|
} else {
|
||||||
updateTable(table);
|
updateTableInLobby(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
// there is normally no success response. the client will see
|
// there is normally no success response. the client will see
|
||||||
@@ -330,7 +330,7 @@ public class TableManager
|
|||||||
", table=" + table + "].");
|
", table=" + table + "].");
|
||||||
}
|
}
|
||||||
table.clearPlayerPos(position);
|
table.clearPlayerPos(position);
|
||||||
updateTable(table);
|
updateTableInLobby(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -341,7 +341,7 @@ public class TableManager
|
|||||||
{
|
{
|
||||||
// publish the table in the lobby object if desired
|
// publish the table in the lobby object if desired
|
||||||
if (shouldPublish(table)) {
|
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
|
// 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())
|
// derived class decided it was not worth publishing, see shouldPublish())
|
||||||
if (_tlobj.getTables().containsKey(table.tableId)) {
|
removeTableFromLobby(table.tableId);
|
||||||
_tlobj.removeFromTables(table.tableId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove the listener too so we do not get a request later on to update the occupants or
|
// remove the listener too so we do not get a request later on to update the occupants or
|
||||||
// unmap this table
|
// unmap this table
|
||||||
@@ -483,10 +481,10 @@ public class TableManager
|
|||||||
|
|
||||||
// and then update the lobby object that contains the table
|
// and then update the lobby object that contains the table
|
||||||
if (shouldPublish(table)) {
|
if (shouldPublish(table)) {
|
||||||
updateTable(table);
|
updateTableInLobby(table);
|
||||||
} else if (_tlobj.getTables().containsKey(table.tableId)) {
|
} else {
|
||||||
// or remove it if the table is no longer "interesting"
|
// 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
|
// update this table's occupants information and update the table
|
||||||
GameObject gameObj = (GameObject)_omgr.getObject(gameOid);
|
GameObject gameObj = (GameObject)_omgr.getObject(gameOid);
|
||||||
table.updateOccupants(gameObj);
|
table.updateOccupants(gameObj);
|
||||||
updateTable(table);
|
updateTableInLobby(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -554,7 +552,7 @@ public class TableManager
|
|||||||
if (pender.isEmpty()) {
|
if (pender.isEmpty()) {
|
||||||
purgeTable(pender);
|
purgeTable(pender);
|
||||||
} else {
|
} else {
|
||||||
updateTable(pender);
|
updateTableInLobby(pender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,7 +567,19 @@ public class TableManager
|
|||||||
return true; // we publish all tables by default
|
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()
|
// the table may not have been published, see shouldPublish()
|
||||||
if (_tlobj.getTables().containsKey(table.tableId)) {
|
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. */
|
/** Listens to all games and updates the table objects as necessary. */
|
||||||
protected class GameListener
|
protected class GameListener
|
||||||
implements ObjectDeathListener, OidListListener
|
implements ObjectDeathListener, OidListListener
|
||||||
|
|||||||
Reference in New Issue
Block a user