don't instantiate comms unless it'll be used. Internally it has no

idea it's not supposed to connect to relay otherwise.
This commit is contained in:
ehouse 2005-03-25 03:11:54 +00:00
parent 3fd6998c2a
commit c9f60e758c
3 changed files with 18 additions and 11 deletions

View file

@ -80,7 +80,7 @@ game_makeNewGame( MPFORMAL XWGame* game, CurGameInfo* gi,
gi->boardSize, gi->boardSize );
#ifndef XWFEATURE_STANDALONE_ONLY
if ( !!sendproc ) {
if ( !!sendproc && gi->serverRole != SERVER_STANDALONE ) {
game->comms = comms_make( MPPARM(mpool) util,
gi->serverRole != SERVER_ISCLIENT,
sendproc, closure );
@ -114,8 +114,19 @@ game_reset( MPFORMAL XWGame* game, CurGameInfo* gi, XP_U16 gameID,
checkServerRole( gi );
gi->gameID = gameID;
#ifndef XWFEATURE_STANDALONE_ONLY
if ( !!game->comms ) {
if ( gi->serverRole == SERVER_STANDALONE ) {
comms_destroy( game->comms );
game->comms = NULL;
} else {
comms_reset( game->comms, gi->serverRole != SERVER_ISCLIENT );
}
}
#endif
model_init( game->model, gi->boardSize, gi->boardSize );
server_reset( game->server );
server_reset( game->server, game->comms );
board_reset( game->board );
for ( i = 0; i < gi->nPlayers; ++i ) {
@ -127,12 +138,6 @@ game_reset( MPFORMAL XWGame* game, CurGameInfo* gi, XP_U16 gameID,
player->secondsUsed = 0;
}
#ifndef XWFEATURE_STANDALONE_ONLY
if ( !!game->comms ) {
comms_reset( game->comms, gi->serverRole != SERVER_ISCLIENT );
}
#endif
server_prefsChanged( game->server, cp );
board_prefsChanged( game->board, cp );
} /* game_reset */

View file

@ -369,13 +369,15 @@ cleanupServer( ServerCtxt* server )
} /* cleanupServer */
void
server_reset( ServerCtxt* server )
server_reset( ServerCtxt* server, CommsCtxt* comms )
{
ServerVolatiles vol = server->vol;
cleanupServer( server );
vol.comms = comms;
server->vol = vol;
initServer( server );
} /* server_reset */

View file

@ -64,7 +64,7 @@ ServerCtxt* server_makeFromStream( MPFORMAL XWStreamCtxt* stream,
void server_writeToStream( ServerCtxt* server, XWStreamCtxt* stream );
void server_reset( ServerCtxt* server );
void server_reset( ServerCtxt* server, CommsCtxt* comms );
void server_destroy( ServerCtxt* server );
void server_prefsChanged( ServerCtxt* server, CommonPrefs* cp );