1072 lines
28 KiB
C++
1072 lines
28 KiB
C++
|
|
#include "StdAfx.h"
|
|||
|
|
#include "ImmediateGroup.h"
|
|||
|
|
|
|||
|
|
#ifdef _DEBUG
|
|||
|
|
#define new DEBUG_NEW
|
|||
|
|
#undef THIS_FILE
|
|||
|
|
static char THIS_FILE[] = __FILE__;
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
#define INVALID_VALUE 0xFFFF //<2F><>Чֵ
|
|||
|
|
|
|||
|
|
//<2F><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
|
|||
|
|
WORD CImmediateGroup::m_wChairCount; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////
|
|||
|
|
//<2F><><EFBFBD>캯<EFBFBD><ECBAAF>
|
|||
|
|
CImmediateGroup::CImmediateGroup(DWORD dwMatchNO,tagGameMatchOption * pGameMatchOption,IImmediateGroupSink *pIImmediateGroupSink)
|
|||
|
|
{
|
|||
|
|
//ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pMatchOption=pGameMatchOption;
|
|||
|
|
m_pMatchSink=pIImmediateGroupSink;
|
|||
|
|
|
|||
|
|
//״̬<D7B4><CCAC><EFBFBD><EFBFBD>
|
|||
|
|
m_dwMatchNO=dwMatchNO;
|
|||
|
|
m_enMatchStatus=MatchStatus_Signup;
|
|||
|
|
m_dwCurBase=m_pMatchOption->MatchType.Immediate.dwInitalBase;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
ZeroMemory(&m_MatchStartTime,sizeof(m_MatchStartTime));
|
|||
|
|
|
|||
|
|
//<2F>Ƴ<EFBFBD>Ԫ<EFBFBD><D4AA>
|
|||
|
|
m_OnMatchUserMap.RemoveAll();
|
|||
|
|
m_FreeUserArray.RemoveAll();
|
|||
|
|
m_MatchTableArray.RemoveAll();
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
m_LoopTimer=0;
|
|||
|
|
m_wAndroidUserCount=0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CImmediateGroup::~CImmediateGroup()
|
|||
|
|
{
|
|||
|
|
//ɱ<><C9B1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
AllKillMatchTimer();
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>״̬
|
|||
|
|
m_wAndroidUserCount=0;
|
|||
|
|
m_enMatchStatus=MatchStatus_Null;
|
|||
|
|
|
|||
|
|
//<2F>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
for (int i=0; i<m_MatchTableArray.GetCount(); i++)
|
|||
|
|
{
|
|||
|
|
SafeDelete(m_MatchTableArray[i]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>Ƴ<EFBFBD>Ԫ<EFBFBD><D4AA>
|
|||
|
|
m_MatchTableArray.RemoveAll();
|
|||
|
|
m_OnMatchUserMap.RemoveAll();
|
|||
|
|
m_FreeUserArray.RemoveAll();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>ӿڲ<D3BF>ѯ
|
|||
|
|
VOID* CImmediateGroup::QueryInterface(REFGUID Guid, DWORD dwQueryVer)
|
|||
|
|
{
|
|||
|
|
QUERYINTERFACE(IMatchEventSink,Guid,dwQueryVer);
|
|||
|
|
QUERYINTERFACE_IUNKNOWNEX(IMatchEventSink,Guid,dwQueryVer);
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CImmediateGroup::OnUserSignUpMatch(IServerUserItem * pUserItem)
|
|||
|
|
{
|
|||
|
|
//<2F>û<EFBFBD><C3BB>ж<EFBFBD>
|
|||
|
|
ASSERT(pUserItem!=NULL);
|
|||
|
|
if (pUserItem==NULL) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>
|
|||
|
|
IServerUserItem * pIServerUserExist=NULL;
|
|||
|
|
m_OnMatchUserMap.Lookup(pUserItem->GetUserID(),pIServerUserExist);
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB>ж<EFBFBD>
|
|||
|
|
ASSERT(pIServerUserExist==NULL);
|
|||
|
|
if (pIServerUserExist!=NULL) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>
|
|||
|
|
ASSERT(m_OnMatchUserMap.GetCount()<m_pMatchOption->MatchType.Immediate.wStartUserCount);
|
|||
|
|
if (m_OnMatchUserMap.GetCount()>=m_pMatchOption->MatchType.Immediate.wStartUserCount) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (pUserItem->IsAndroidUser()==true)
|
|||
|
|
{
|
|||
|
|
if (m_wAndroidUserCount>=m_pMatchOption->MatchType.Immediate.wAndroidUserCount)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
m_wAndroidUserCount++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>óɼ<C3B3>
|
|||
|
|
tagUserInfo *pUserScore=pUserItem->GetUserInfo();
|
|||
|
|
pUserScore->dwWinCount=0L;
|
|||
|
|
pUserScore->dwLostCount=0L;
|
|||
|
|
pUserScore->dwFleeCount=0L;
|
|||
|
|
pUserScore->dwDrawCount=0L;
|
|||
|
|
pUserScore->lGrade=0L;
|
|||
|
|
pUserScore->lScore=(SCORE)m_pMatchOption->MatchType.Immediate.dwInitalScore;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ͳɼ<CDB3>
|
|||
|
|
m_pMatchSink->SendGroupUserScore(pUserItem,NULL);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>
|
|||
|
|
m_OnMatchUserMap[pUserItem->GetUserID()]=pUserItem;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>״̬
|
|||
|
|
pUserItem->SetUserMatchStatus(MUS_SIGNUP);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
pUserItem->SetSignUpTime(GetTickCount());
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD>״̬
|
|||
|
|
BYTE cbMatchStatus = MS_WAITPLAY;
|
|||
|
|
m_pMatchSink->SendData(pUserItem, MDM_GR_MATCH, SUB_GR_MATCH_STATUS, &cbMatchStatus, sizeof(cbMatchStatus));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (m_OnMatchUserMap.GetCount()>=m_pMatchOption->MatchType.Immediate.wStartUserCount)
|
|||
|
|
{
|
|||
|
|
//<2F>¼<EFBFBD>֪ͨ
|
|||
|
|
ASSERT(m_pMatchSink!=NULL);
|
|||
|
|
if (m_pMatchSink!=NULL) m_pMatchSink->SendMatchInfo(NULL);
|
|||
|
|
EfficacyStartMatch();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ
|
|||
|
|
void CImmediateGroup::EfficacyStartMatch()
|
|||
|
|
{
|
|||
|
|
m_pMatchSink->InsertNullTable();
|
|||
|
|
|
|||
|
|
//û<><C3BB><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if( m_MatchTableArray.GetCount()<m_pMatchOption->MatchType.Immediate.wStartUserCount/m_wChairCount )
|
|||
|
|
{
|
|||
|
|
if(m_OnMatchUserMap.GetCount()<m_wChairCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
|
|||
|
|
CMD_CM_SystemMessage Message;
|
|||
|
|
Message.wType=SMT_EJECT|SMT_CHAT|SMT_CLOSE_GAME;
|
|||
|
|
lstrcpyn(Message.szString,TEXT("<EFBFBD><EFBFBD>Ǹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>û<EFBFBD>ǿ<EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),CountArray(Message.szString));
|
|||
|
|
Message.wLength=CountStringBuffer(Message.szString);
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
WORD wSendSize=sizeof(Message)-sizeof(Message.szString)+Message.wLength*sizeof(TCHAR);
|
|||
|
|
m_pMatchSink->SendGroupData(MDM_CM_SYSTEM,SUB_CM_SYSTEM_MESSAGE,&Message,wSendSize, this);
|
|||
|
|
m_enMatchStatus=MatchStatus_Signup;
|
|||
|
|
return ;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_enMatchStatus=MatchStatus_Wait;
|
|||
|
|
//3<><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>øú<C3B8><C3BA><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
SetMatchGameTimer(IDI_WAITTABLE_FIRST_ROUND,3000,1,NULL);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
|
|||
|
|
CMD_CM_SystemMessage Message;
|
|||
|
|
Message.wType=SMT_CHAT;
|
|||
|
|
_sntprintf_s(Message.szString,CountArray(Message.szString),
|
|||
|
|
TEXT("<EFBFBD><EFBFBD>Ǹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %d <20><><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD>,<2C><><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),m_pMatchOption->MatchType.Immediate.wStartUserCount/m_wChairCount-m_MatchTableArray.GetCount());
|
|||
|
|
Message.wLength=CountStringBuffer(Message.szString);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
WORD wSendSize=sizeof(Message)-sizeof(Message.szString)+Message.wLength*sizeof(TCHAR);
|
|||
|
|
m_pMatchSink->SendGroupData(MDM_CM_SYSTEM,SUB_CM_SYSTEM_MESSAGE,&Message,wSendSize, this);
|
|||
|
|
return ;
|
|||
|
|
}
|
|||
|
|
//Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
|||
|
|
DWORD dwUserID=0L;
|
|||
|
|
IServerUserItem *pIServerUserItem=NULL;
|
|||
|
|
POSITION pos=m_OnMatchUserMap.GetStartPosition();
|
|||
|
|
|
|||
|
|
WORD wChairID=0;
|
|||
|
|
while (pos!=NULL)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD>û<EFBFBD>
|
|||
|
|
m_OnMatchUserMap.GetNextAssoc(pos,dwUserID,pIServerUserItem);
|
|||
|
|
ASSERT(pIServerUserItem!=NULL);
|
|||
|
|
|
|||
|
|
InsertFreeGroup(pIServerUserItem);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
pIServerUserItem->SetUserMatchStatus(MUS_MATCHING);
|
|||
|
|
pIServerUserItem->SetMatchData(this);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
TabelRequestUser(false);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>״̬
|
|||
|
|
m_enMatchStatus=MatchStatus_FirstRound;
|
|||
|
|
|
|||
|
|
//<2F><>¼ʱ<C2BC><CAB1>
|
|||
|
|
CTime::GetCurrentTime().GetAsSystemTime(m_MatchStartTime);
|
|||
|
|
|
|||
|
|
//<2F><>ʼ֪ͨ
|
|||
|
|
if (m_pMatchSink!=NULL) m_pMatchSink->OnEventMatchStart(this);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
SetMatchGameTimer(IDI_CHECK_MATCH_GROUP,1000,TIMES_INFINITY,0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BOOL CImmediateGroup::OnUserQuitMatch(IServerUserItem *pUserItem)
|
|||
|
|
{
|
|||
|
|
//<2F>û<EFBFBD><C3BB>ж<EFBFBD>
|
|||
|
|
ASSERT(pUserItem!=NULL);
|
|||
|
|
if (pUserItem==NULL) return false;
|
|||
|
|
|
|||
|
|
//ɾ<><C9BE><EFBFBD>û<EFBFBD>
|
|||
|
|
BOOL bSuccess=m_OnMatchUserMap.RemoveKey(pUserItem->GetUserID());
|
|||
|
|
if(bSuccess==false)return false;
|
|||
|
|
|
|||
|
|
if (pUserItem->IsAndroidUser())
|
|||
|
|
{
|
|||
|
|
ASSERT(m_wAndroidUserCount>0);
|
|||
|
|
if (m_wAndroidUserCount>0) m_wAndroidUserCount--;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>״̬
|
|||
|
|
pUserItem->SetUserMatchStatus(MUS_NULL);
|
|||
|
|
BYTE cbUserStatus=MatchStatus_Null;
|
|||
|
|
m_pMatchSink->SendData(pUserItem, MDM_GR_MATCH, SUB_GR_MATCH_STATUS, &cbUserStatus, sizeof(cbUserStatus));
|
|||
|
|
|
|||
|
|
return bSuccess;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ʱ<EFBFBD><CAB1>
|
|||
|
|
bool CImmediateGroup::OnTimeMessage(DWORD dwTimerID, WPARAM dwBindParameter)
|
|||
|
|
{
|
|||
|
|
//״̬У<CCAC><D0A3>
|
|||
|
|
if(m_enMatchStatus==MatchStatus_Null) return true;
|
|||
|
|
|
|||
|
|
switch(dwTimerID)
|
|||
|
|
{
|
|||
|
|
case IDI_CHECK_MATCH_GROUP:
|
|||
|
|
{
|
|||
|
|
CaptureMatchTimer();
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
case IDI_WAITTABLE_FIRST_ROUND:
|
|||
|
|
{
|
|||
|
|
if(m_enMatchStatus==MatchStatus_Wait)
|
|||
|
|
{
|
|||
|
|
EfficacyStartMatch();
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
case IDI_SWITCH_WAIT_TIME:
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
RearrangeUserSeat();
|
|||
|
|
TabelRequestUser();
|
|||
|
|
//ContinueGame((ITableFrame*)dwBindParameter);
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
case IDI_TABLE_REQUEST_USER:
|
|||
|
|
{
|
|||
|
|
TabelRequestUser();
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
case IDI_ENTER_NEXT_ROUND:
|
|||
|
|
{
|
|||
|
|
//if(m_enMatchStatus==MS_START_NEXT_ROUND)
|
|||
|
|
//{
|
|||
|
|
// //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|||
|
|
// ContinueRound();
|
|||
|
|
//}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
case IDI_ALL_DISMISS_GAME:
|
|||
|
|
{
|
|||
|
|
RearrangeUserSeat();
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
case IDI_LASTMATCHRESULT:
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
MatchOver();
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
WORD CImmediateGroup::SortMapUser(tagMatchScore score[])
|
|||
|
|
{
|
|||
|
|
INT_PTR nCount=m_OnMatchUserMap.GetCount();
|
|||
|
|
POSITION pos=m_OnMatchUserMap.GetStartPosition();
|
|||
|
|
nCount=0;
|
|||
|
|
while(pos!=NULL)
|
|||
|
|
{
|
|||
|
|
m_OnMatchUserMap.GetNextAssoc(pos,score[nCount].dwUserID, score[nCount].pUserItem);
|
|||
|
|
score[nCount].dwUserID=score[nCount].pUserItem->GetUserID();
|
|||
|
|
score[nCount].lScore = score[nCount].pUserItem->GetUserScore();
|
|||
|
|
nCount++;
|
|||
|
|
}
|
|||
|
|
for(INT_PTR i = 1;i < nCount;i++)
|
|||
|
|
{
|
|||
|
|
INT_PTR left = 0,right = i - 1;
|
|||
|
|
tagMatchScore Temp = score[i];
|
|||
|
|
while(left <= right)
|
|||
|
|
{
|
|||
|
|
INT_PTR mid = (left + right)/2;
|
|||
|
|
if (score[i].lScore > score[mid].lScore)right = mid - 1;
|
|||
|
|
else left = mid + 1;
|
|||
|
|
}
|
|||
|
|
for(INT_PTR j = i - 1;j >= left;j--)
|
|||
|
|
score[j+1] = score[j];
|
|||
|
|
score[left] = Temp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return (WORD)nCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
|||
|
|
void CImmediateGroup::RearrangeUserSeat(bool bDismissGame)
|
|||
|
|
{
|
|||
|
|
KillMatchGameTimer(IDI_SWITCH_WAIT_TIME);
|
|||
|
|
for(WORD i=0; i<m_MatchTableArray.GetCount();i++)
|
|||
|
|
{
|
|||
|
|
tagTableFrameInfo *ptagTableFrameInfo=m_MatchTableArray[i];
|
|||
|
|
ASSERT(ptagTableFrameInfo!=NULL);
|
|||
|
|
if (ptagTableFrameInfo==NULL) continue;
|
|||
|
|
|
|||
|
|
ITableFrame* pTableFrame=ptagTableFrameInfo->pTableFrame;
|
|||
|
|
ASSERT(pTableFrame!=NULL);
|
|||
|
|
if (pTableFrame==NULL) continue;
|
|||
|
|
|
|||
|
|
if (bDismissGame==false)
|
|||
|
|
{
|
|||
|
|
ptagTableFrameInfo->cbPlayCount=0;
|
|||
|
|
ptagTableFrameInfo->bRoundTableFinish=false;
|
|||
|
|
ptagTableFrameInfo->bSwtichTableFinish=false;
|
|||
|
|
ptagTableFrameInfo->bWaitForNextInnings=false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ǿ<>ƽ<EFBFBD>ɢ<EFBFBD><C9A2>Ϸ
|
|||
|
|
if (pTableFrame->IsGameStarted()==true)
|
|||
|
|
{
|
|||
|
|
if (bDismissGame==true)
|
|||
|
|
{
|
|||
|
|
bool bSuccess=pTableFrame->DismissGame();
|
|||
|
|
if (bSuccess==false)
|
|||
|
|
CTraceService::TraceString(TEXT("<EFBFBD><EFBFBD>ɢ<EFBFBD><EFBFBD>Ϸ"),TraceLevel_Exception);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
TCHAR szMessage[64]=TEXT("");
|
|||
|
|
_sntprintf_s(szMessage,CountArray(szMessage),TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λʱ,<2C><> %d <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ״̬"),pTableFrame->GetTableID());
|
|||
|
|
CTraceService::TraceString(szMessage,TraceLevel_Exception);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD>뿪
|
|||
|
|
AllUserExitTable(pTableFrame);
|
|||
|
|
}
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7>ʼ
|
|||
|
|
bool CImmediateGroup::OnEventGameStart(ITableFrame *pITableFrame, WORD wChairCount)
|
|||
|
|
{
|
|||
|
|
pITableFrame->SetCellScore(m_dwCurBase);
|
|||
|
|
KillMatchTimer(IDI_CHECK_TABLE_START,(WPARAM)pITableFrame);
|
|||
|
|
|
|||
|
|
tagTableFrameInfo *pTableFrameInfo=GetTableInterface(pITableFrame);
|
|||
|
|
pTableFrameInfo->bRoundTableFinish=false;
|
|||
|
|
pTableFrameInfo->bSwtichTableFinish=false;
|
|||
|
|
pTableFrameInfo->bWaitForNextInnings=false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>1
|
|||
|
|
pTableFrameInfo->cbPlayCount++;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>û<EFBFBD>
|
|||
|
|
SendTableUserMatchInfo(pITableFrame, INVALID_CHAIR);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
|
|||
|
|
CMD_CM_SystemMessage SystemMessage;
|
|||
|
|
ZeroMemory(&SystemMessage,sizeof(SystemMessage));
|
|||
|
|
|
|||
|
|
TCHAR szMsg[256]=TEXT("");
|
|||
|
|
_sntprintf_s(szMsg, CountArray(szMsg),TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<>ֿ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>%d<>֣<EFBFBD><D6A3><EFBFBD>"),pTableFrameInfo->cbPlayCount,m_pMatchOption->MatchType.Immediate.cbPlayCount);
|
|||
|
|
lstrcpyn(SystemMessage.szString,szMsg,CountArray(SystemMessage.szString));
|
|||
|
|
SystemMessage.wLength=CountStringBuffer(SystemMessage.szString);
|
|||
|
|
SystemMessage.wType=SMT_CHAT;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
WORD wSendSize=sizeof(SystemMessage)-sizeof(SystemMessage.szString)+SystemMessage.wLength*sizeof(TCHAR);
|
|||
|
|
pITableFrame->SendTableData(INVALID_CHAIR,SUB_GF_SYSTEM_MESSAGE, (void*)&SystemMessage,wSendSize,MDM_GF_FRAME);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|||
|
|
bool CImmediateGroup::OnEventGameEnd(ITableFrame *pITableFrame,WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbReason)
|
|||
|
|
{
|
|||
|
|
//<2F><>¼<EFBFBD><C2BC><EFBFBD>ֺ<EFBFBD><D6BA><EFBFBD>Щ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
tagTableFrameInfo * ptagTableFrameInfo=GetTableInterface(pITableFrame);
|
|||
|
|
ASSERT(ptagTableFrameInfo);
|
|||
|
|
if (ptagTableFrameInfo==NULL)return false;
|
|||
|
|
|
|||
|
|
if(m_enMatchStatus==MatchStatus_FirstRound)
|
|||
|
|
{
|
|||
|
|
FirstRoundRuleInningsGameEnd(pITableFrame);
|
|||
|
|
}
|
|||
|
|
//CheckExitMatch();
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>
|
|||
|
|
if(m_enMatchStatus==MatchStatus_Null)return true;
|
|||
|
|
|
|||
|
|
if(m_OnMatchUserMap.GetCount()>0)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>֪ͨ
|
|||
|
|
tagMatchScore *pScore = new tagMatchScore[m_OnMatchUserMap.GetCount()];
|
|||
|
|
ZeroMemory(pScore,sizeof(tagMatchScore)*m_OnMatchUserMap.GetCount());
|
|||
|
|
WORD wCount=SortMapUser(pScore);
|
|||
|
|
for (WORD i=0;i<wCount;i++)
|
|||
|
|
{
|
|||
|
|
m_pMatchSink->SendGroupUserScore(pScore[i].pUserItem,this);
|
|||
|
|
}
|
|||
|
|
SafeDeleteArray(pScore);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CImmediateGroup::OnActionUserSitDown(WORD wTableID, WORD wChairID, IServerUserItem * pIServerUserItem, bool bLookonUser)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CImmediateGroup::OnActionUserStandUp(WORD wTableID, WORD wChairID, IServerUserItem * pIServerUserItem, bool bLookonUser)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD>ͬ<EFBFBD><CDAC>
|
|||
|
|
bool CImmediateGroup::OnActionUserOnReady(WORD wTableID, WORD wChairID, IServerUserItem * pIServerUserItem, VOID * pData, WORD wDataSize)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
WORD CImmediateGroup::GetUserRank(IServerUserItem *pUserItem, ITableFrame *pITableFrame)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>
|
|||
|
|
ASSERT(pUserItem!=NULL);
|
|||
|
|
if(pUserItem==NULL) return INVALID_WORD;
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
SCORE lUserScore=pUserItem->GetUserScore();
|
|||
|
|
WORD wRank=1;
|
|||
|
|
DWORD dwUserID=0;
|
|||
|
|
IServerUserItem *pLoopUserItem=NULL;
|
|||
|
|
|
|||
|
|
if(pITableFrame==NULL)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
POSITION pos=m_OnMatchUserMap.GetStartPosition();
|
|||
|
|
while(pos!=NULL)
|
|||
|
|
{
|
|||
|
|
m_OnMatchUserMap.GetNextAssoc(pos,dwUserID, pLoopUserItem);
|
|||
|
|
if(pLoopUserItem!=pUserItem && pLoopUserItem->GetUserScore()>lUserScore)
|
|||
|
|
wRank++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ASSERT(pUserItem->GetTableID()==pITableFrame->GetTableID());
|
|||
|
|
if(pUserItem->GetTableID()!=pITableFrame->GetTableID()) return INVALID_WORD;
|
|||
|
|
|
|||
|
|
for(WORD i=0; i<m_wChairCount; i++)
|
|||
|
|
{
|
|||
|
|
pLoopUserItem=pITableFrame->GetTableUserItem(i);
|
|||
|
|
if(pLoopUserItem==NULL) continue;
|
|||
|
|
|
|||
|
|
if(pLoopUserItem!=pUserItem && pLoopUserItem->GetUserScore()>lUserScore)
|
|||
|
|
wRank++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return wRank;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ר<EFBFBD>ýӿ<C3BD>
|
|||
|
|
tagTableFrameInfo* CImmediateGroup::GetTableInterface(ITableFrame* ITable)
|
|||
|
|
{
|
|||
|
|
for (int i=0;i<m_MatchTableArray.GetCount();i++)
|
|||
|
|
{
|
|||
|
|
if (m_MatchTableArray[i]->pTableFrame==ITable)return m_MatchTableArray[i];
|
|||
|
|
}
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
void CImmediateGroup::MatchOver()
|
|||
|
|
{
|
|||
|
|
//ɾ<><C9BE><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
AllKillMatchTimer();
|
|||
|
|
KillMatchGameTimer(IDI_CHECK_MATCH_GROUP);
|
|||
|
|
KillMatchGameTimer(IDI_WAITTABLE_FIRST_ROUND);
|
|||
|
|
KillMatchGameTimer(IDI_WAITTABLE_RAND_TABLE);
|
|||
|
|
KillMatchGameTimer(IDI_SWITCH_WAIT_TIME);
|
|||
|
|
KillMatchGameTimer(IDI_ALL_DISMISS_GAME);
|
|||
|
|
KillMatchGameTimer(IDI_LASTMATCHRESULT);
|
|||
|
|
KillMatchGameTimer(IDI_TABLE_REQUEST_USER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>״̬
|
|||
|
|
ASSERT(m_enMatchStatus==MatchStatus_FirstRound);
|
|||
|
|
if(m_enMatchStatus==MatchStatus_FirstRound)
|
|||
|
|
{
|
|||
|
|
m_enMatchStatus=MatchStatus_Null;
|
|||
|
|
m_pMatchSink->OnEventMatchOver(this);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|||
|
|
void CImmediateGroup::FirstRoundRuleInningsGameEnd(ITableFrame *pITableFrame)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
tagTableFrameInfo * ptagTableFrameInfo=GetTableInterface(pITableFrame);
|
|||
|
|
ASSERT(ptagTableFrameInfo);
|
|||
|
|
if (ptagTableFrameInfo==NULL) return;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>õȴ<C3B5><C8B4>¾ֱ<C2BE>ʶ
|
|||
|
|
ptagTableFrameInfo->bWaitForNextInnings=true;
|
|||
|
|
|
|||
|
|
TCHAR szMessage[128]=TEXT("");
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (ptagTableFrameInfo->cbPlayCount>=m_pMatchOption->MatchType.Immediate.cbPlayCount)
|
|||
|
|
{
|
|||
|
|
_sntprintf_s(szMessage, CountArray(szMessage), TEXT("<EFBFBD><EFBFBD>ϲ<EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD>Ϸ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵȴ<C4B5><C8B4><EFBFBD>"),m_pMatchOption->MatchType.Immediate.cbPlayCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ϣ
|
|||
|
|
for (WORD j=0;j<m_wChairCount;j++)
|
|||
|
|
{
|
|||
|
|
IServerUserItem *pIServerUserItem=pITableFrame->GetTableUserItem(j);
|
|||
|
|
if(pIServerUserItem!=NULL)
|
|||
|
|
{
|
|||
|
|
m_pMatchSink->SendGameMessage(pIServerUserItem,szMessage,SMT_CHAT|SMT_TABLE_ROLL);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|||
|
|
InsertFreeGroup(pIServerUserItem);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ASSERT(FALSE);
|
|||
|
|
CTraceService::TraceString(TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϢΪ<EFBFBD><EFBFBD>1!"),TraceLevel_Exception);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD>ʶ
|
|||
|
|
SetRoundTableFinish(pITableFrame);
|
|||
|
|
SendWaitTip(pITableFrame);
|
|||
|
|
ptagTableFrameInfo->cbPlayCount=0;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if(m_pMatchOption->MatchType.Immediate.cbSwitchTableCount>0&&(ptagTableFrameInfo->cbPlayCount%m_pMatchOption->MatchType.Immediate.cbSwitchTableCount)==0)
|
|||
|
|
_sntprintf_s(szMessage,CountArray(szMessage),TEXT("%s"),TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><EFBFBD>Ժ<EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>..."));
|
|||
|
|
else
|
|||
|
|
_sntprintf_s(szMessage,CountArray(szMessage),TEXT("%s"),TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>..."));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ϣ
|
|||
|
|
for (WORD j=0;j<m_wChairCount;j++)
|
|||
|
|
{
|
|||
|
|
IServerUserItem *pIServerUserItem=pITableFrame->GetTableUserItem(j);
|
|||
|
|
if(pIServerUserItem!=NULL)
|
|||
|
|
{
|
|||
|
|
m_pMatchSink->SendGameMessage(pIServerUserItem, szMessage, SMT_CHAT|SMT_TABLE_ROLL);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|||
|
|
InsertFreeGroup(pIServerUserItem);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ASSERT(FALSE);
|
|||
|
|
CTraceService::TraceString(TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϢΪ<EFBFBD><EFBFBD>2!"),TraceLevel_Exception);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (CheckRoundTableFinish())
|
|||
|
|
{
|
|||
|
|
SetMatchGameTimer(IDI_LASTMATCHRESULT,5000,1,0);
|
|||
|
|
return ;
|
|||
|
|
}
|
|||
|
|
else if(ptagTableFrameInfo->bRoundTableFinish==false)
|
|||
|
|
{
|
|||
|
|
//<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>
|
|||
|
|
if(m_pMatchOption->MatchType.Immediate.cbSwitchTableCount>0&&(ptagTableFrameInfo->cbPlayCount%m_pMatchOption->MatchType.Immediate.cbSwitchTableCount)==0)
|
|||
|
|
{
|
|||
|
|
SetSwitchTableFinish(pITableFrame);
|
|||
|
|
SendWaitTip(pITableFrame);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD>
|
|||
|
|
if (CheckSwitchTableFinish())
|
|||
|
|
{
|
|||
|
|
SetMatchGameTimer(IDI_SWITCH_WAIT_TIME,5000,1,0);
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
PostMatchTimer(IDI_CONTINUE_GAME,5,(WPARAM)pITableFrame);
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|||
|
|
VOID CImmediateGroup::SendWaitTip(ITableFrame *pTableFrame, WORD wChairID/*=INVALID_CHAIR*/)
|
|||
|
|
{
|
|||
|
|
//״̬У<CCAC><D0A3>
|
|||
|
|
if(m_enMatchStatus==MatchStatus_Null || m_enMatchStatus==MatchStatus_Signup )
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
tagTableFrameInfo *pITableFameEx=GetTableInterface(pTableFrame);
|
|||
|
|
ASSERT(pITableFameEx!=NULL);
|
|||
|
|
if (pITableFameEx==NULL) return;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
WORD wPlayingTable=0;
|
|||
|
|
for(WORD i=0;i<m_MatchTableArray.GetCount();i++)
|
|||
|
|
{
|
|||
|
|
if(m_MatchTableArray[i]->pTableFrame->GetGameStatus()>=GAME_STATUS_PLAY)
|
|||
|
|
wPlayingTable++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_GR_Match_Wait_Tip WaitTip;
|
|||
|
|
ZeroMemory(&WaitTip,sizeof(WaitTip));
|
|||
|
|
WaitTip.wPlayingTable=wPlayingTable;
|
|||
|
|
WaitTip.wUserCount=(WORD)m_OnMatchUserMap.GetCount();
|
|||
|
|
WaitTip.wCurGameCount=pITableFameEx->cbPlayCount;
|
|||
|
|
WaitTip.wGameCount=m_pMatchOption->MatchType.Immediate.cbPlayCount;
|
|||
|
|
|
|||
|
|
lstrcpyn(WaitTip.szMatchName, m_pMatchOption->szMatchName,LEN_SERVER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
for(WORD i=0;i<m_wChairCount;i++)
|
|||
|
|
{
|
|||
|
|
if(wChairID!=INVALID_CHAIR && wChairID!=i) continue;
|
|||
|
|
IServerUserItem *pTableUserItem=pTableFrame->GetTableUserItem(i);
|
|||
|
|
if(pTableUserItem==NULL) continue;
|
|||
|
|
WaitTip.wCurTableRank=GetUserRank(pTableUserItem,pTableFrame);
|
|||
|
|
if(WaitTip.wCurTableRank==INVALID_WORD) continue;
|
|||
|
|
|
|||
|
|
|
|||
|
|
WaitTip.wRank=GetUserRank(pTableUserItem);
|
|||
|
|
WaitTip.lScore=pTableUserItem->GetUserScore();
|
|||
|
|
|
|||
|
|
m_pMatchSink->SendData(pTableUserItem,MDM_GR_MATCH,SUB_GR_MATCH_WAIT_TIP,&WaitTip,sizeof(WaitTip));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
for(WORD i=0;i<m_MatchTableArray.GetCount();i++)
|
|||
|
|
{
|
|||
|
|
if(pTableFrame->GetTableID()==m_MatchTableArray[i]->pTableFrame->GetTableID())continue;
|
|||
|
|
if(m_MatchTableArray[i]->pTableFrame->GetGameStatus()>=GAME_STATUS_PLAY) continue;
|
|||
|
|
for(WORD j=0;j<m_wChairCount;j++)
|
|||
|
|
{
|
|||
|
|
IServerUserItem *pTableUserItem=m_MatchTableArray[i]->pTableFrame->GetTableUserItem(j);
|
|||
|
|
if(pTableUserItem==NULL) continue;
|
|||
|
|
WaitTip.wCurTableRank=GetUserRank(pTableUserItem,m_MatchTableArray[i]->pTableFrame);
|
|||
|
|
if(WaitTip.wCurTableRank==INVALID_WORD) continue;
|
|||
|
|
|
|||
|
|
WaitTip.wRank=GetUserRank(pTableUserItem);
|
|||
|
|
WaitTip.lScore=pTableUserItem->GetUserScore();
|
|||
|
|
|
|||
|
|
m_pMatchSink->SendData(pTableUserItem,MDM_GR_MATCH,SUB_GR_MATCH_WAIT_TIP,&WaitTip,sizeof(WaitTip));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>
|
|||
|
|
void CImmediateGroup::TabelRequestUser(bool bPrecedeSit)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
|
|||
|
|
if (CheckMatchUser())
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
CTableFrameMananerArray FreeTableArray; //<2F>ձ<EFBFBD><D5B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
//<2F><><EFBFBD>Ȼ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
for (INT_PTR i=0;i<m_MatchTableArray.GetCount();i++)
|
|||
|
|
{
|
|||
|
|
if(m_MatchTableArray[i]->pTableFrame->IsGameStarted()==false&&m_MatchTableArray[i]->bRoundTableFinish==false)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
INT_PTR cbTimer=m_MatchTimerArray.GetCount();
|
|||
|
|
bool cbIsInsert=false;
|
|||
|
|
for(int j=0;j<cbTimer;j++)
|
|||
|
|
{
|
|||
|
|
//<2F>ж<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>û<EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵȴ<DAB5>
|
|||
|
|
if((m_MatchTimerArray[j]->dwTimerID==IDI_CHECK_TABLE_START||m_MatchTimerArray[j]->dwTimerID==IDI_CONTINUE_GAME)&&(ITableFrame*)(m_MatchTimerArray[j]->wParam)==m_MatchTableArray[i]->pTableFrame)
|
|||
|
|
{
|
|||
|
|
cbIsInsert=true;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if(cbIsInsert==false)
|
|||
|
|
FreeTableArray.Add(m_MatchTableArray[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
DWORD dwCurTime=(DWORD)time(NULL);
|
|||
|
|
|
|||
|
|
bool bIsContinueCheck=false;//<2F>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ԭ<><D4AD><EFBFBD><EFBFBD>true
|
|||
|
|
for (INT_PTR i=0;i<FreeTableArray.GetCount();i++)
|
|||
|
|
{
|
|||
|
|
DWORD nCurUserCount=(DWORD)m_FreeUserArray.GetCount();
|
|||
|
|
//<2F>ҵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(nCurUserCount/m_wChairCount>0)
|
|||
|
|
{
|
|||
|
|
AllUserExitTable(FreeTableArray[i]->pTableFrame);
|
|||
|
|
for (int j=0;j<m_wChairCount;j++)
|
|||
|
|
{
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
WORD wRandID=INVALID_VALUE;
|
|||
|
|
if(bPrecedeSit&&bIsContinueCheck)
|
|||
|
|
{
|
|||
|
|
wRandID=GetPrecedeSitUser(dwCurTime);
|
|||
|
|
}
|
|||
|
|
if(wRandID==INVALID_VALUE)
|
|||
|
|
{
|
|||
|
|
bIsContinueCheck=false;//<2F>Ѿ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>
|
|||
|
|
wRandID=rand()%(WORD)m_FreeUserArray.GetCount();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
IServerUserItem *pIServerUserItem=m_FreeUserArray[wRandID];
|
|||
|
|
ASSERT(pIServerUserItem!=NULL);
|
|||
|
|
if (pIServerUserItem==NULL) continue;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(pIServerUserItem->GetTableID()!=INVALID_TABLE)
|
|||
|
|
{
|
|||
|
|
for(int m=0;m<m_MatchTableArray.GetCount();m++)
|
|||
|
|
{
|
|||
|
|
if(pIServerUserItem->GetTableID()==m_MatchTableArray[m]->wTableID)
|
|||
|
|
{
|
|||
|
|
m_MatchTableArray[m]->pTableFrame->PerformStandUpAction(pIServerUserItem);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (FreeTableArray[i]->pTableFrame->PerformSitDownAction(j,pIServerUserItem))
|
|||
|
|
{
|
|||
|
|
m_FreeUserArray.RemoveAt(wRandID);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
CTraceService::TraceString(TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>"),TraceLevel_Exception);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//30<33><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>п<EFBFBD>ʼ<EFBFBD><CABC>Ϸ ˵<><CBB5><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
PostMatchTimer(IDI_CHECK_TABLE_START,30,(WPARAM)FreeTableArray[i]->pTableFrame);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return ;
|
|||
|
|
}
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
void CImmediateGroup::SendGroupBox(LPCTSTR pStrMessage)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
|
|||
|
|
CMD_CM_SystemMessage Message;
|
|||
|
|
Message.wType=SMT_EJECT|SMT_CHAT;
|
|||
|
|
lstrcpyn(Message.szString,pStrMessage,CountArray(Message.szString));
|
|||
|
|
Message.wLength=CountStringBuffer(Message.szString);
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
WORD wSendSize=sizeof(Message)-sizeof(Message.szString)+Message.wLength*sizeof(TCHAR);
|
|||
|
|
m_pMatchSink->SendGroupData(MDM_CM_SYSTEM,SUB_CM_SYSTEM_MESSAGE,&Message,wSendSize, this);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>
|
|||
|
|
void CImmediateGroup::SetRoundTableFinish(ITableFrame *pITableFrame)
|
|||
|
|
{
|
|||
|
|
tagTableFrameInfo * ptagTableFrameInfo=GetTableInterface(pITableFrame);
|
|||
|
|
ASSERT(ptagTableFrameInfo);
|
|||
|
|
if (ptagTableFrameInfo)ptagTableFrameInfo->bRoundTableFinish=true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CImmediateGroup::CheckRoundTableFinish()
|
|||
|
|
{
|
|||
|
|
for (int i=0;i<m_MatchTableArray.GetCount();i++)
|
|||
|
|
{
|
|||
|
|
if(m_MatchTableArray[i]->bRoundTableFinish==false)return false;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>
|
|||
|
|
void CImmediateGroup::SetSwitchTableFinish(ITableFrame *pITableFrame)
|
|||
|
|
{
|
|||
|
|
tagTableFrameInfo * ptagTableFrameInfo=GetTableInterface(pITableFrame);
|
|||
|
|
ASSERT(ptagTableFrameInfo);
|
|||
|
|
if (ptagTableFrameInfo)ptagTableFrameInfo->bSwtichTableFinish=true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>黻<EFBFBD><E9BBBB><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CImmediateGroup::CheckSwitchTableFinish()
|
|||
|
|
{
|
|||
|
|
for (int i=0;i<m_MatchTableArray.GetCount();i++)
|
|||
|
|
{
|
|||
|
|
if(m_MatchTableArray[i]->bSwtichTableFinish==false)return false;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>뿪
|
|||
|
|
void CImmediateGroup::AllUserExitTable(ITableFrame *pITableFrame)
|
|||
|
|
{
|
|||
|
|
ASSERT(pITableFrame!=NULL);
|
|||
|
|
if(pITableFrame)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD>뿪
|
|||
|
|
for (int i=0;i<m_wChairCount;i++)
|
|||
|
|
{
|
|||
|
|
IServerUserItem* pUserItem=pITableFrame->GetTableUserItem(i);
|
|||
|
|
if(pUserItem&&pUserItem->GetTableID()!=INVALID_TABLE)pITableFrame->PerformStandUpAction(pUserItem);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ
|
|||
|
|
void CImmediateGroup::ContinueGame(ITableFrame *pITableFrame)
|
|||
|
|
{
|
|||
|
|
if (CheckMatchUser())
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
tagTableFrameInfo * ptagTableFrameInfo=GetTableInterface(pITableFrame);
|
|||
|
|
ASSERT(ptagTableFrameInfo);
|
|||
|
|
if (ptagTableFrameInfo)
|
|||
|
|
{
|
|||
|
|
AllUserExitTable(pITableFrame);
|
|||
|
|
for(int i=0;i<m_wChairCount;i++)
|
|||
|
|
{
|
|||
|
|
IServerUserItem* pIServerUserItem=m_FreeUserArray[0];
|
|||
|
|
if(pIServerUserItem==NULL)
|
|||
|
|
{
|
|||
|
|
ASSERT(FALSE);
|
|||
|
|
CTraceService::TraceString(TEXT("<EFBFBD>յ<EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵȴ<EFBFBD><EFBFBD>б<EFBFBD><EFBFBD>С<EFBFBD>"),TraceLevel_Exception);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(pIServerUserItem->GetTableID()!=INVALID_TABLE)
|
|||
|
|
{
|
|||
|
|
for(int m=0;m<m_MatchTableArray.GetCount();m++)
|
|||
|
|
{
|
|||
|
|
if(pIServerUserItem->GetTableID()==m_MatchTableArray[m]->wTableID)
|
|||
|
|
{
|
|||
|
|
m_MatchTableArray[m]->pTableFrame->PerformStandUpAction(pIServerUserItem);
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pITableFrame->PerformSitDownAction(i,pIServerUserItem))
|
|||
|
|
{
|
|||
|
|
m_FreeUserArray.RemoveAt(0);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
CTraceService::TraceString(TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>1"),TraceLevel_Exception);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//30<33><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>п<EFBFBD>ʼ<EFBFBD><CABC>Ϸ ˵<><CBB5><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
PostMatchTimer(IDI_CHECK_TABLE_START,30,(WPARAM)pITableFrame);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CImmediateGroup::SetMatchGameTimer(DWORD dwTimerID, DWORD dwElapse, DWORD dwRepeat, WPARAM dwBindParameter)
|
|||
|
|
{
|
|||
|
|
if(m_pMatchSink)
|
|||
|
|
m_pMatchSink->SetGameTimer(dwTimerID+10*m_LoopTimer,dwElapse,dwRepeat,dwBindParameter,this);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ɱ<><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ר<EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
void CImmediateGroup::KillMatchGameTimer(DWORD dwTimerID)
|
|||
|
|
{
|
|||
|
|
if(m_pMatchSink)
|
|||
|
|
m_pMatchSink->KillGameTimer(dwTimerID+10*m_LoopTimer,this);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CImmediateGroup::CheckMatchUser()
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
|
|||
|
|
DWORD nCurUserCount=(DWORD)m_OnMatchUserMap.GetCount();
|
|||
|
|
if (nCurUserCount<m_wChairCount)
|
|||
|
|
{
|
|||
|
|
ASSERT(FALSE);
|
|||
|
|
CTraceService::TraceString(TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>..."),TraceLevel_Exception);
|
|||
|
|
return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
|
|||
|
|
CString szString;
|
|||
|
|
szString.Format(TEXT("<EFBFBD><EFBFBD>Ǹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ǿ<EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %d <20>ˣ<EFBFBD><CBA3><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>㡣<EFBFBD><E3A1A3>ӭ<EFBFBD><D3AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>μӱ<CEBC><D3B1><EFBFBD><EFBFBD><EFBFBD>"),m_wChairCount);
|
|||
|
|
SendGroupBox(szString);
|
|||
|
|
|
|||
|
|
MatchOver();
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>
|
|||
|
|
WORD CImmediateGroup::GetPrecedeSitUser(DWORD dwCurTime)
|
|||
|
|
{
|
|||
|
|
for(int i=0;i<m_FreeUserArray.GetCount();i++)
|
|||
|
|
{
|
|||
|
|
tagTimeInfo* pTimerInfo=m_FreeUserArray[i]->GetTimeInfo();
|
|||
|
|
if(dwCurTime-pTimerInfo->dwEndGameTimer>m_pMatchOption->MatchType.Immediate.wPrecedeTimer) return i;
|
|||
|
|
}
|
|||
|
|
return INVALID_VALUE;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ʵ<>ָú<D6B8><C3BA><EFBFBD><EFBFBD>ɱ<EFBFBD>֤Free<65><65>Ψһ
|
|||
|
|
void CImmediateGroup::InsertFreeGroup(IServerUserItem *pUserItem)
|
|||
|
|
{
|
|||
|
|
if( pUserItem == NULL )return;
|
|||
|
|
for(int i=0;i<m_FreeUserArray.GetCount();i++)
|
|||
|
|
{
|
|||
|
|
if( m_FreeUserArray[i] != NULL && m_FreeUserArray[i]->GetUserID()==pUserItem->GetUserID())return;
|
|||
|
|
}
|
|||
|
|
m_FreeUserArray.Add(pUserItem);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
void CImmediateGroup::SendTableUserMatchInfo(ITableFrame *pITableFrame, WORD wChairID)
|
|||
|
|
{
|
|||
|
|
//<2F><>֤<EFBFBD><D6A4><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(pITableFrame!=NULL);
|
|||
|
|
if (pITableFrame==NULL) return;
|
|||
|
|
|
|||
|
|
tagTableFrameInfo *ptagTableFrameInfo=GetTableInterface(pITableFrame);
|
|||
|
|
if (ptagTableFrameInfo==NULL) return;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
WORD wChairCount=pITableFrame->GetChairCount();
|
|||
|
|
TCHAR szMsg[256]=TEXT("");
|
|||
|
|
|
|||
|
|
if(m_enMatchStatus==MatchStatus_FirstRound)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_GR_Match_Info MatchInfo;
|
|||
|
|
ZeroMemory(&MatchInfo,sizeof(MatchInfo));
|
|||
|
|
MatchInfo.wGameCount=ptagTableFrameInfo->cbPlayCount;
|
|||
|
|
//wChairIDΪINVALID_CHAIR<49><52><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
for(WORD i=0; i<wChairCount; i++)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD>û<EFBFBD>
|
|||
|
|
if(wChairID!=INVALID_CHAIR && wChairID!=i) continue;
|
|||
|
|
IServerUserItem *pIServerUserItem=pITableFrame->GetTableUserItem(i);
|
|||
|
|
if(pIServerUserItem==NULL) continue;
|
|||
|
|
|
|||
|
|
MatchInfo.wRank=GetUserRank(pIServerUserItem,pITableFrame);
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
pITableFrame->SendTableData(i, SUB_GR_MATCH_INFO, &MatchInfo, sizeof(MatchInfo), MDM_GR_MATCH);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|||
|
|
if ((wChairID!=INVALID_CHAIR) && (ptagTableFrameInfo->bWaitForNextInnings==true))
|
|||
|
|
{
|
|||
|
|
SendWaitTip(pITableFrame,wChairID);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ר<EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
void CImmediateGroup::CaptureMatchTimer()
|
|||
|
|
{
|
|||
|
|
for(int i=0;i<m_MatchTimerArray.GetCount();i++)
|
|||
|
|
{
|
|||
|
|
if(--m_MatchTimerArray[i]->iElapse<=0)
|
|||
|
|
{
|
|||
|
|
if(m_MatchTimerArray[i]->dwTimerID==IDI_CONTINUE_GAME)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ
|
|||
|
|
ContinueGame((ITableFrame*)m_MatchTimerArray[i]->wParam);
|
|||
|
|
}
|
|||
|
|
else if(m_MatchTimerArray[i]->dwTimerID==IDI_LEAVE_TABLE)
|
|||
|
|
{
|
|||
|
|
//<2F>뿪<EFBFBD><EBBFAA><EFBFBD><EFBFBD>
|
|||
|
|
AllUserExitTable((ITableFrame*)m_MatchTimerArray[i]->wParam);
|
|||
|
|
}else if(m_MatchTimerArray[i]->dwTimerID==IDI_CHECK_TABLE_START)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ʼ<EFBFBD><CABC>Ϸ
|
|||
|
|
//CheckTableStart((ITableFrame*)m_MatchTimerArray[i]->wParam);
|
|||
|
|
}
|
|||
|
|
//ɾ<><C9BE><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
if(KillMatchTimer(i))i--;
|
|||
|
|
else ASSERT(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//Ͷ<>ݱ<EFBFBD><DDB1><EFBFBD>ר<EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
void CImmediateGroup::PostMatchTimer(DWORD dwTimerID, int iElapse, WPARAM wParam, LPARAM lParam)
|
|||
|
|
{
|
|||
|
|
tagMatchTimer* pMatchTimer=new tagMatchTimer;
|
|||
|
|
pMatchTimer->dwTimerID=dwTimerID;
|
|||
|
|
pMatchTimer->iElapse=iElapse;
|
|||
|
|
//pMatchTimer->dwRepeat=dwRepeat;
|
|||
|
|
pMatchTimer->wParam=wParam;
|
|||
|
|
pMatchTimer->lParam=lParam;
|
|||
|
|
m_MatchTimerArray.Add(pMatchTimer);
|
|||
|
|
}
|
|||
|
|
//ɱ<><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ר<EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
bool CImmediateGroup::KillMatchTimer(DWORD dwTimerID, WPARAM wParam)
|
|||
|
|
{
|
|||
|
|
for(int i=0;i<m_MatchTimerArray.GetCount();i++)
|
|||
|
|
{
|
|||
|
|
if(m_MatchTimerArray[i]->dwTimerID==dwTimerID&&m_MatchTimerArray[i]->wParam==wParam)
|
|||
|
|
{
|
|||
|
|
tagMatchTimer* pMatchTimer=m_MatchTimerArray[i];
|
|||
|
|
m_MatchTimerArray.RemoveAt(i);
|
|||
|
|
SafeDelete(pMatchTimer);
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
//ɱ<><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ר<EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
bool CImmediateGroup::KillMatchTimer(INT_PTR dwIndexID)
|
|||
|
|
{
|
|||
|
|
ASSERT(dwIndexID >= 0 && dwIndexID < m_MatchTimerArray.GetCount());
|
|||
|
|
if( dwIndexID >= 0 && dwIndexID < m_MatchTimerArray.GetCount() )
|
|||
|
|
{
|
|||
|
|
tagMatchTimer* pMatchTimer=m_MatchTimerArray[dwIndexID];
|
|||
|
|
m_MatchTimerArray.RemoveAt(dwIndexID);
|
|||
|
|
SafeDelete(pMatchTimer);
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
//ȫ<><C8AB>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ר<EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
void CImmediateGroup::AllKillMatchTimer()
|
|||
|
|
{
|
|||
|
|
for(int i=0;i<m_MatchTimerArray.GetCount();/*i++*/)
|
|||
|
|
{
|
|||
|
|
tagMatchTimer* pMatchTimer=m_MatchTimerArray[i];
|
|||
|
|
m_MatchTimerArray.RemoveAt(i);
|
|||
|
|
SafeDelete(pMatchTimer);
|
|||
|
|
}
|
|||
|
|
}
|