public bool start(int gameServerPort)
{
string accountServerAddress=Configuration.getValue("net_accountHost", "localhost");
// When the accountListenToGamePort is set, we use it.
// Otherwise, we use the accountListenToClientPort + 1 if the option is set.
// If neither, the DEFAULT_SERVER_PORT + 1 is used.
int alternativePort=Configuration.getValue("net_accountListenToClientPort", 0)+1;
if(alternativePort==1)
alternativePort=Configuration.DEFAULT_SERVER_PORT+1;
int accountServerPort=Configuration.getValue("net_accountListenToGamePort", alternativePort);
if(!start(accountServerAddress, accountServerPort))
{
Logger.Write(LogLevel.Information, "Unable to create a connection to an account server.");
return false;
}
Logger.Write(LogLevel.Information, "Connection established to the account server.");
string gameServerAddress=Configuration.getValue("net_gameHost", "localhost");
string password=Configuration.getValue("net_password", "changeMe");
// Register with the account server and send the list of maps we handle
MessageOut msg=new MessageOut(Protocol.GAMSG_REGISTER);
msg.writeString(gameServerAddress);
msg.writeInt16(gameServerPort);
msg.writeString(password);
msg.writeInt32((int)Program.itemManager.getDatabaseVersion());
Dictionary<int, MapComposite> m=MapManager.getMaps();
foreach(int map in m.Keys)
{
msg.writeInt16(map);
}
send(msg);
// initialize sync buffer
if(mSyncBuffer==null)
mSyncBuffer=new MessageOut(Protocol.GAMSG_PLAYER_SYNC);
return true;
}