get rid of states and code for checking numbers of players -- since

any number is allowed now.
This commit is contained in:
ehouse 2009-11-03 05:03:20 +00:00
parent 3bdfda6548
commit ed52582ea4
4 changed files with 3 additions and 62 deletions

View file

@ -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<HostRec>& sockets )
logf( XW_LOGINFO, " %s from %s", __func__, caller );
vector<HostRec>::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()
{

View file

@ -188,7 +188,6 @@ class CookieRef {
void populate( vector<HostRec> hosts );
void increasePlayerCounts( const CRefEvent* evt );
void reducePlayerCounts( int socket );
void checkCounts( const CRefEvent* evt );
void setAllConnectedTimer();
void cancelAllConnectedTimer();

View file

@ -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);

View file

@ -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 */