- // ClientProtocol.cpp: implementation of the CClientProtocol class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "cgamehallframe.h"
- #include "ClientProtocol.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CClientProtocol::CClientProtocol()
- {
- }
- CClientProtocol::~CClientProtocol()
- {
- }
- char CClientProtocol::Anaysys(CString str)
- {
- char k=' ',ch;int i=0,i1,i2,i3;
- ch=str.GetAt(i);
- if(ch!=char(20))
- return k;
- k=str.GetAt(++i);
- name.Empty();
- switch(k)
- {
- case 'M':
- ch=str.GetAt(++i);
- while(ch!=' '&&ch!=char(20))
- {
- name+=ch;
- ch=str.GetAt(++i);
- }
- break;
- case 'O':
- ch=str.GetAt(++i);
- if(ch=='1')
- {
- right=1;
- for(i1=0;i1<4;i1++)
- for(i2=0;i2<4;i2++)
- for(i3=0;i3<4;i3++)
- {
- ch=str.GetAt(++i);
- table[i1][i2].d[i3]=(int)(ch-'0');
- }
- }
- else
- right=0;
- break;
- case 'B':
- case 'P':
- desk=0;
- ch=str.GetAt(++i);
- while(ch!=' '&&ch!=char(20))
- {
- desk=desk*10+(int)(ch-'0');
- ch=str.GetAt(++i);
- }
- ch=str.GetAt(++i);
- direct=(int)(ch-'0');
- break;
- case 'Q':
- for(i1=0;i1<4;i1++)
- {
- ch=str.GetAt(++i);
- if(ch=='1')
- {
- user.ID[i1]=1;
- i++;
- ch=str.GetAt(++i);user.name[i1].Empty();
- while(ch!=' '&&ch!=char(20))
- {
- user.name[i1]+=ch;
- ch=str.GetAt(++i);
- }
- ch=str.GetAt(++i);
- user.sex[i1].Empty();
- while(ch!=' '&&ch!=char(20))
- {
- user.sex[i1]+=ch;
- ch=str.GetAt(++i);
- }
- ch=str.GetAt(++i);
- user.score[i1].Empty();
- while(ch!=' '&&ch!=char(20))
- {
- user.score[i1]+=ch;
- ch=str.GetAt(++i);
- }
- }else
- {
- user.ID[i1]=0;
- ch=str.GetAt(++i);
- }
- }
- break;
- case 'A':
- ch=str.GetAt(++i);chat.Empty();
- while(ch!=char(20))
- {
- chat+=ch;
- ch=str.GetAt(++i);
- }
- break;
- case 'D':
- ch=str.GetAt(++i);
- if(ch=='2')
- war_kind=TRUE;
- else
- war_kind=FALSE;
- ch=str.GetAt(++i);
- r=(int)(ch-'0');
- break;
- case 'G':
- case 'R':
- case 'F':
- case 'H':
- ch=str.GetAt(++i);from.x=0;
- while(ch!=' '&&ch!=char(20))
- {
- from.x=from.x*10+(int)(ch-'0');
- ch=str.GetAt(++i);
- }
- ch=str.GetAt(++i);from.y=0;
- while(ch!=' '&&ch!=char(20))
- {
- from.y=from.y*10+(int)(ch-'0');
- ch=str.GetAt(++i);
- }
- ch=str.GetAt(++i);to.x=0;
- while(ch!=' '&&ch!=char(20))
- {
- to.x=to.x*10+(int)(ch-'0');
- ch=str.GetAt(++i);
- }
- ch=str.GetAt(++i);to.y=0;
- while(ch!=' '&&ch!=char(20))
- {
- to.y=to.y*10+(int)(ch-'0');
- ch=str.GetAt(++i);
- }
- ch=str.GetAt(++i);
- r=(int)(ch-'0');
- break;
- case 'I':
- ch=str.GetAt(++i);
- direct=(int)(ch-'0');
- r=-1;
- break;
- }
- return k;
- }