From ed52582ea4d847356df12c7f42927b655e8ea4b7 Mon Sep 17 00:00:00 2001 From: ehouse Date: Tue, 3 Nov 2009 05:03:20 +0000 Subject: [PATCH] get rid of states and code for checking numbers of players -- since any number is allowed now. --- xwords4/relay/cref.cpp | 43 ++-------------------------------------- xwords4/relay/cref.h | 1 - xwords4/relay/states.cpp | 17 +--------------- xwords4/relay/states.h | 4 ---- 4 files changed, 3 insertions(+), 62 deletions(-) diff --git a/xwords4/relay/cref.cpp b/xwords4/relay/cref.cpp index 4d2c35766..432279cbf 100644 --- a/xwords4/relay/cref.cpp +++ b/xwords4/relay/cref.cpp @@ -495,10 +495,6 @@ CookieRef::handleEvents() switch( takeAction ) { - case XWA_CHKCOUNTS: - checkCounts( &evt ); - break; - case XWA_SEND_1ST_RSP: case XWA_SEND_1ST_RERSP: setAllConnectedTimer(); @@ -626,8 +622,8 @@ print_sockets( const char* caller, vector& sockets ) logf( XW_LOGINFO, " %s from %s", __func__, caller ); vector::iterator iter; for ( iter = sockets.begin(); iter != sockets.end(); ++iter ) { - logf( XW_LOGINFO, "isHost: %d; nPlayersH: %d; seed=%.4X; socket: %d", - iter->m_nPlayersS > 0, iter->m_nPlayersH, iter->m_seed, + logf( XW_LOGINFO, "nPSought: %d; nPHere: %d; seed=%.4X; socket: %d", + iter->m_nPlayersS, iter->m_nPlayersH, iter->m_seed, iter->m_socket ); } } /* print_sockets */ @@ -866,41 +862,6 @@ CookieRef::reducePlayerCounts( int socket ) } } /* reducePlayerCounts */ -/* Determine if adding this device to the game would give us too many - players. */ -void -CookieRef::checkCounts( const CRefEvent* evt ) -{ - int nPlayersH = evt->u.con.nPlayersH; - int nPlayersS = evt->u.con.nPlayersS; - HostID hid = evt->u.con.srcID; - bool success; - - logf( XW_LOGVERBOSE1, "%s: hid:%d; nPlayersS:%d; nPlayersH:%d; " - "m_nPlayersSought:%d; m_nPlayersHere:%d", __func__, - hid, nPlayersS, nPlayersH, m_nPlayersSought, m_nPlayersHere ); - - /* increasePlayerCounts() is where we actually increase the numbers. Is - that right? */ - - if ( hid == HOST_ID_SERVER ) { - success = m_nPlayersSought == 0; - } else { - success = (m_nPlayersSought == 0) /* if no server present yet */ - || (m_nPlayersSought >= m_nPlayersHere + nPlayersH); - } - logf( XW_LOGVERBOSE1, "success = %d", success ); - - CRefEvent newevt; - if ( success ) { - newevt = *evt; /* this is a gross hack!!! */ - newevt.type = XWE_OKTOSEND; - } else { - newevt.type = XWE_COUNTSBAD; - } - m_eventQueue.push_back( newevt ); -} /* checkCounts */ - void CookieRef::setAllConnectedTimer() { diff --git a/xwords4/relay/cref.h b/xwords4/relay/cref.h index c0d16524b..c1b98f724 100644 --- a/xwords4/relay/cref.h +++ b/xwords4/relay/cref.h @@ -188,7 +188,6 @@ class CookieRef { void populate( vector hosts ); void increasePlayerCounts( const CRefEvent* evt ); void reducePlayerCounts( int socket ); - void checkCounts( const CRefEvent* evt ); void setAllConnectedTimer(); void cancelAllConnectedTimer(); diff --git a/xwords4/relay/states.cpp b/xwords4/relay/states.cpp index 44c75e5aa..f9bd44b03 100644 --- a/xwords4/relay/states.cpp +++ b/xwords4/relay/states.cpp @@ -63,17 +63,7 @@ typedef struct StateTable { StateTable g_stateTable[] = { -{ XWS_INITED, XWE_CONNECTMSG, XWA_CHKCOUNTS, XWS_CHKCOUNTS_INIT }, -{ XWS_CHKCOUNTS_INIT, XWE_OKTOSEND, XWA_SEND_1ST_RSP, XWS_CHK_ALLHERE }, -{ XWS_CHKCOUNTS_INIT, XWE_COUNTSBAD, XWA_REJECT, XWS_INITED }, -{ XWS_CONNECTING, XWE_CONNECTMSG, XWA_CHKCOUNTS, XWS_CHKCOUNTS }, -{ XWS_CHKCOUNTS, XWE_OKTOSEND, XWA_SEND_1ST_RSP, XWS_CHK_ALLHERE }, -{ XWS_CHKCOUNTS, XWE_COUNTSBAD, XWA_REJECT, XWS_CONNECTING }, - -{ XWS_MISSING, XWE_CONNECTMSG, XWA_CHKCOUNTS, XWS_CHKCOUNTS_MISS }, -{ XWS_CHKCOUNTS_MISS, XWE_OKTOSEND, XWA_SEND_1ST_RSP, XWS_CHK_ALLHERE_2 }, -{ XWS_CHKCOUNTS_MISS, XWE_COUNTSBAD, XWA_REJECT, XWS_MISSING }, - +{ XWS_INITED, XWE_CONNECTMSG, XWA_SEND_1ST_RSP, XWS_CHK_ALLHERE }, { XWS_CONNECTING, XWE_CONNECTMSG, XWA_SEND_RSP, XWS_CHK_ALLHERE }, { XWS_CHK_ALLHERE, XWE_ALLHERE, XWA_SENDALLHERE, XWS_ALLCONND }, @@ -179,8 +169,6 @@ stateString( XW_RELAY_STATE state ) CASESTR(XWS_CHK_ALLHERE); CASESTR(XWS_CHK_ALLHERE_2); CASESTR(XWS_CHKCOUNTS_INIT); - CASESTR(XWS_CHKCOUNTS_MISS); - CASESTR(XWS_CHKCOUNTS); CASESTR(XWS_CLONED); default: assert(0); @@ -213,8 +201,6 @@ eventString( XW_RELAY_EVENT evt ) CASESTR(XWE_NOTIFYDISCON); CASESTR(XWE_ALLHERE); CASESTR(XWE_SOMEMISSING); - CASESTR(XWE_OKTOSEND); - CASESTR(XWE_COUNTSBAD); CASESTR(XWE_SHUTDOWN); CASESTR(XWE_CLONECHKMSG); default: @@ -231,7 +217,6 @@ actString( XW_RELAY_ACTION act ) CASESTR(XWA_NONE); CASESTR(XWA_SEND_1ST_RSP); CASESTR(XWA_SEND_1ST_RERSP); - CASESTR(XWA_CHKCOUNTS); CASESTR(XWA_REJECT); CASESTR(XWA_SEND_RSP); CASESTR(XWA_SEND_RERSP); diff --git a/xwords4/relay/states.h b/xwords4/relay/states.h index 460443af9..52c6f9c9a 100644 --- a/xwords4/relay/states.h +++ b/xwords4/relay/states.h @@ -33,7 +33,6 @@ enum { actually: 1-device game. */ ,XWS_CHKCOUNTS_MISS /* from the missing state */ - ,XWS_CHKCOUNTS /* check from any other state */ ,XWS_CLONED /* just got duplicated */ @@ -84,7 +83,6 @@ typedef enum { XWE_NONE ,XWE_OKTOSEND - ,XWE_COUNTSBAD ,XWE_ALLHERE /* notify that all expected players are arrived */ ,XWE_SOMEMISSING /* notify that some expected players are still missing */ @@ -126,8 +124,6 @@ typedef enum { ,XWA_SEND_1ST_RSP ,XWA_SEND_1ST_RERSP - ,XWA_CHKCOUNTS - ,XWA_REJECT ,XWA_SEND_RSP /* Send a connection response */