preserve hid when recreating games

When a device reconnects and there's no record for its
game (e.g. because an ISP's screwed up and the db and its host are
lost), recreate but keep the device's hid (position in the arrays
indicating mostly whether it's the inviter or invitee.) Tested by
running the linux scripts and deleting the games table mid-way
through, but not yet tested with android devices.
This commit is contained in:
Eric House 2017-10-07 10:14:27 -07:00
parent 2cabf2332c
commit 3e8839636e

View file

@ -649,10 +649,14 @@ SafeCref::SafeCref( const char* connName, const char* cookie, HostID hid,
nPlayersS, gameSeed, langCode,
wantsPublic || makePublic, &isDead );
/* If the reconnect doesn't check out, treat it as a connect */
/* If the reconnect doesn't check out, treat it as a connect. But
preserve the existing hid. If the DB was deleted it's important
that devices keep their places (hids) */
if ( NULL == cinfo ) {
logf( XW_LOGINFO, "%s: taking a second crack", __func__ );
m_hid = HOST_ID_NONE;
logf( XW_LOGINFO, "%s: taking a second crack; (cur hid: %d)",
__func__, hid );
assert( m_hid == hid );
// m_hid = HOST_ID_NONE; /* wrong; but why was I doing it? */
cinfo = m_mgr->getMakeCookieRef( cookie, nPlayersH, nPlayersS,
langCode, gameSeed, clientIndx,
wantsPublic, makePublic, &m_seenSeed );