When device reconnects to a dead game, just deny the connection with a

new error message rather than allow it as if it were a normal game
only to send a game-dead message after.  This solves the problem of
how device knows not to put up welcoming message or suggestion to
invite to a game that's suddenly missing players.  BUT: this change is
incompatible with existing versions and so needs to get pushed out
before the in-use relay can be upgraded to include this code.
This commit is contained in:
Andy2 2011-07-06 06:47:25 -07:00
parent 928404be50
commit 86e3cc7286
3 changed files with 13 additions and 10 deletions

View file

@ -206,15 +206,20 @@ class SafeCref {
}
}
bool Reconnect( int socket, HostID srcID, int nPlayersH, int nPlayersS,
int seed ) {
int seed, XWREASON* errp ) {
bool success = false;
*errp = XWRELAY_ERROR_NONE;
if ( IsValid() ) {
CookieRef* cref = m_cinfo->GetRef();
assert( 0 != cref->GetCid() );
return cref->_Reconnect( socket, srcID, nPlayersH, nPlayersS,
seed, m_dead );
} else {
return false;
if ( m_dead ) {
*errp = XWRELAY_ERROR_DEADGAME;
} else {
success = cref->_Reconnect( socket, srcID, nPlayersH,
nPlayersS, seed, m_dead );
}
}
return success;
}
void Disconnect(int socket, HostID hostID ) {
if ( IsValid() ) {

View file

@ -392,12 +392,9 @@ processReconnect( unsigned char* bufp, int bufLen, int socket )
nPlayersT, gameSeed, langCode,
wantsPublic, makePublic );
success = scr.Reconnect( socket, srcID, nPlayersH, nPlayersT,
gameSeed );
gameSeed, &err );
if ( !success ) {
// Can't use XWRELAY_ERROR_NORECONN until it's been out on
// devices for a while. Reconnect() never seems to fail
// anyway now that I've fixed a bunch of bugs.
err = XWRELAY_ERROR_BADPROTO; // XWRELAY_ERROR_NORECONN
assert( err != XWRELAY_ERROR_NONE );
}
} else {
err = XWRELAY_ERROR_BADPROTO;

View file

@ -141,6 +141,7 @@ enum {
,XWRELAY_ERROR_TOO_MANY
,XWRELAY_ERROR_DELETED
,XWRELAY_ERROR_NORECONN /* you can't reconnect; reset and try CONNECTING again */
,XWRELAY_ERROR_DEADGAME /* Some device in this game has been deleted */
,XWRELAY_ERROR_LASTERR
}
#ifndef CANT_DO_TYPEDEF