{
LOGGER.debug("Got the character play info packet");
// get the channel attachment for that channel
Channel channel = action.getChannel();
ClientBean client = ClientBean.get(channel);
Handle<ClientBean> clientHandle = ClientBean.getHandle(channel);
// failcheck
if (client == null) { channel.close(); return; }
// update the login count
client.setLoginCount(action.getLoginCount());
// TODO: check mapId before directly creating a mapshard for it!
// TODO: check the following values!
// we ignore the instance number because the server needs to chose that...
int mapId = (int)action.getGameMapId();
int instanceNum = (int)action.getInstanceNumber();
DistrictRegion region = DistrictRegion.values()[(int)action.getRegion()];
DistrictLanguage language = DistrictLanguage.values()[(int)action.getLanguage()];
// TODO: enable outposts
Handle<GameAppContext> mapShardHandle = model.getOrCreateExplorable(mapId);
// let the model do the work...
//Handle<GameAppContext> mapShardHandle = model.getOrCreate(mapId, region, language, instanceNum, true);
// lets check if we were successfull with the game app creation
if (mapShardHandle == null)
{
LOGGER.warn("Was unable to create a game app! Please check the log for other errors!");
StreamTerminatorView.send(channel, ErrorCode.InternalServerError);
return;
}
// inform the model that we'r waiting for a mapshard to accept a client
model.clientWaitingFor(clientHandle, mapShardHandle);
// dont forget to update the client bean (it now has a mapshard, yay :)
client.setMapShardHandle(mapShardHandle);
LOGGER.debug("Asking a map shard to accept a client.");
mapShardHandle.get().trigger(
new LSRequest_AcceptClient(
clientHandle.getUid(),
client.getAccount(),
client.getCharacter()));
// we will notify the client when the mapshard replies.
}