Factored createTable() out into a method that can be called on the server.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@449 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -108,29 +108,20 @@ public class TableManager
|
|||||||
_tableClass = tableClass;
|
_tableClass = tableClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
// from interface ParlorProvider
|
/**
|
||||||
public void createTable (ClientObject caller, TableConfig tableConfig, GameConfig config,
|
* Creates a table for the specified creator and returns said table.
|
||||||
TableService.ResultListener listener)
|
*
|
||||||
|
* @exception InvocationException thrown if the table could not be created for any reason.
|
||||||
|
*/
|
||||||
|
public Table createTable (BodyObject creator, TableConfig tableConfig, GameConfig config)
|
||||||
throws InvocationException
|
throws InvocationException
|
||||||
{
|
{
|
||||||
BodyObject creator = (BodyObject)caller;
|
|
||||||
|
|
||||||
// if we're managing tables in a place, make sure the creator is an occupant of the place
|
|
||||||
// in which they are requesting to create a table
|
|
||||||
if (_dobj instanceof PlaceObject &&
|
|
||||||
!((PlaceObject)_dobj).occupants.contains(creator.getOid())) {
|
|
||||||
Log.warning("Requested to create a table in a place not occupied by the creator " +
|
|
||||||
"[creator=" + creator + ", ploid=" + _dobj.getOid() + "].");
|
|
||||||
throw new InvocationException(INTERNAL_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create a brand spanking new table
|
// create a brand spanking new table
|
||||||
Table table;
|
Table table;
|
||||||
try {
|
try {
|
||||||
table = _tableClass.newInstance();
|
table = _tableClass.newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.warning("Unable to create a new table instance! [tableClass=" + _tableClass +
|
Log.warning("Table.newInstance() failde [class=" + _tableClass + ", e=" + e + "].");
|
||||||
", error=" + e + "].");
|
|
||||||
throw new InvocationException(INTERNAL_ERROR);
|
throw new InvocationException(INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
table.init(_dobj.getOid(), tableConfig, config);
|
table.init(_dobj.getOid(), tableConfig, config);
|
||||||
@@ -158,10 +149,30 @@ public class TableManager
|
|||||||
|
|
||||||
// if the table has only one seat, start the game immediately
|
// if the table has only one seat, start the game immediately
|
||||||
if (table.shouldBeStarted()) {
|
if (table.shouldBeStarted()) {
|
||||||
int oid = createGame(table);
|
createGame(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
listener.requestProcessed(table.tableId);
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
// from interface ParlorProvider
|
||||||
|
public void createTable (ClientObject caller, TableConfig tableConfig, GameConfig config,
|
||||||
|
TableService.ResultListener listener)
|
||||||
|
throws InvocationException
|
||||||
|
{
|
||||||
|
BodyObject creator = (BodyObject)caller;
|
||||||
|
|
||||||
|
// if we're managing tables in a place, make sure the creator is an occupant of the place
|
||||||
|
// in which they are requesting to create a table
|
||||||
|
if (_dobj instanceof PlaceObject &&
|
||||||
|
!((PlaceObject)_dobj).occupants.contains(creator.getOid())) {
|
||||||
|
Log.warning("Requested to create a table in a place not occupied by the creator " +
|
||||||
|
"[creator=" + creator + ", ploid=" + _dobj.getOid() + "].");
|
||||||
|
throw new InvocationException(INTERNAL_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if createTable() returns, we're good to go
|
||||||
|
listener.requestProcessed(createTable(creator, tableConfig, config).tableId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// from interface ParlorProvider
|
// from interface ParlorProvider
|
||||||
|
|||||||
Reference in New Issue
Block a user