虎虎生威(机器人+控制)【源码】
http://img.woaidaima.com//upload/image/20170515/1494826428803068982.jpg#include "StdAfx.h"#include "servercontrolitemsink.h"
CServerControlItemSink::CServerControlItemSink(void)
{
//控制变量
m_cbControlArea=0xff; //控制区域
m_cbControlTimes=0; //控制次数
}
CServerControlItemSink::~CServerControlItemSink( void )
{
}
boolCServerControlItemSink::ExcuteControl(BYTE *cbCard)
{
//控制
if ( m_cbControlArea != 0xff && m_cbControlTimes > 0)
{
BYTE cbControlArea = { 1, 9, 17, 25,
3, 11, 19, 27,
5, 13, 21, 30,
7, 15, 23, 32,
2, 10, 18, 26,
4, 12, 20, 28,
6, 14, 22, 31,
8, 16, 24, 0 };
*cbCard= cbControlArea;
m_cbControlTimes--;
if(m_cbControlTimes == 0)
{
m_cbControlArea = 0xff;
}
return true;
}
return false;
}
//服务器控制
boolCServerControlItemSink::RecvControlReq(WORD wSubCmdID, const void * pDataBuffer, WORD wDataSize, IServerUserItem * pIServerUserItem, ITableFrame * pITableFrame)
{
ASSERT(wDataSize==sizeof(CMD_C_ControlApplication));
if (wDataSize!=sizeof(CMD_C_ControlApplication))
return false;
if(CUserRight::IsGameCheatUser(pIServerUserItem->GetUserRight())==false)return false;
// WriteExceptionLog("虎虎生威.log","虎虎生威被控制 : %s",pIServerUserItem->GetAccounts());
CMD_C_ControlApplication* pData = (CMD_C_ControlApplication*)pDataBuffer;
switch(pData->cbControlAppType)
{
case C_CA_UPDATE: //更新
{
CMD_S_ControlReturns ControlReturns;
ZeroMemory(&ControlReturns,sizeof(ControlReturns));
ControlReturns.cbReturnsType = S_CR_UPDATE_SUCCES;
ControlReturns.cbControlArea = m_cbControlArea;
ControlReturns.cbControlTimes = m_cbControlTimes;
pITableFrame->SendUserItemData(pIServerUserItem,SUB_S_ADMIN_COMMDN,&ControlReturns,sizeof(ControlReturns));
}
return true;
case C_CA_SET: //设置
{
if ( pData->cbControlArea == 0xff || pData->cbControlArea> 7 )
{
//设置失败
CMD_S_ControlReturns ControlReturns;
ZeroMemory(&ControlReturns,sizeof(ControlReturns));
ControlReturns.cbReturnsType = S_CR_FAILURE;
ControlReturns.cbControlArea = 0xff;
pITableFrame->SendUserItemData(pIServerUserItem,SUB_S_ADMIN_COMMDN,&ControlReturns,sizeof(ControlReturns));
return true;
}
m_cbControlArea = pData->cbControlArea;
m_cbControlTimes = pData->cbControlTimes;
CMD_S_ControlReturns ControlReturns;
ZeroMemory(&ControlReturns,sizeof(ControlReturns));
ControlReturns.cbReturnsType = S_CR_SET_SUCCESS;
ControlReturns.cbControlArea = m_cbControlArea;
ControlReturns.cbControlTimes = m_cbControlTimes;
pITableFrame->SendUserItemData(pIServerUserItem,SUB_S_ADMIN_COMMDN,&ControlReturns,sizeof(ControlReturns));
}
return true;
case C_CA_CANCELS: //取消
{
m_cbControlArea = 0xff;
m_cbControlTimes = 0;
CMD_S_ControlReturns ControlReturns;
ZeroMemory(&ControlReturns,sizeof(ControlReturns));
ControlReturns.cbReturnsType = S_CR_CANCEL_SUCCESS;
ControlReturns.cbControlArea = 0xff;
pITableFrame->SendUserItemData(pIServerUserItem,SUB_S_ADMIN_COMMDN,&ControlReturns,sizeof(ControlReturns));
}
return true;
}
//设置失败
CMD_S_ControlReturns ControlReturns;
ZeroMemory(&ControlReturns,sizeof(ControlReturns));
ControlReturns.cbReturnsType = S_CR_FAILURE;
ControlReturns.cbControlArea = 0xff;
pITableFrame->SendUserItemData(pIServerUserItem,SUB_S_ADMIN_COMMDN,&ControlReturns,sizeof(ControlReturns));
return true;
}
页:
[1]