示例#1
0
BOOL CPlug::Serialize(vector<BYTE>* pStream)
{
	_AddToByteArray( pStream, GetPlugType() );
	_AddToByteArray( pStream, m_lOwnerType );
	_AddToByteArray( pStream, m_OwnerID );
	_AddToByteArray( pStream, static_cast<LONG>(m_bPlugEnded) );
	return TRUE;
}
//! ±àÂë
void MedalContainer::AddToByteArray(vector<BYTE> &vData)
{
	_AddToByteArray(&vData, (LONG)m_setHold.size());
	for (set<LONG>::iterator ite = m_setHold.begin(); ite != m_setHold.end(); ++ite)
	{
		_AddToByteArray(&vData, *ite);
	}
}
示例#3
0
// 添加到CByteArray
bool CCountry::AddToByteArray(vector<BYTE>* pByteArray)
{
	_AddToByteArray(pByteArray, m_lID);
	_AddToByteArray(pByteArray, m_lPower);
	_AddToByteArray(pByteArray, m_King);
	_AddToByteArray(pByteArray, m_lTechLevel);
	_AddToByteArray(pByteArray, (long)m_eState);
	return true;
}
BOOL CGoodsBaseProperties::tagAddonPropertyValue::Serialize(vector<BYTE>* pStream, BOOL b)
{
	// TODO: Add your specialized code here.
	// NOTE: Requires a correct return value to compile.
	_AddToByteArray( pStream, dwId );
	_AddToByteArray( pStream, lBaseValue );
	
	return TRUE;
}
示例#5
0
// 向CByteArray添加数据
void _AddToByteArray(vector<BYTE>* pBA, const CGUID& guid)
{
	long size = sizeof(CGUID);
	if(guid == CGUID::GUID_INVALID)
	{
		size = 0;
	}
	_AddToByteArray(pBA,(void*)&size,1);
	_AddToByteArray(pBA,(void*)&guid,size);
}
BOOL CGoodsBaseProperties::tagSuitProperty::Serialize(vector<BYTE>* pStream, BOOL b)
{
	_AddToByteArray(pStream,static_cast<DWORD>(gapType));
	_AddToByteArray( pStream, static_cast<DWORD>( vValues.size() ) );
	for( size_t i = 0; i < vValues.size(); i ++ )
	{
		vValues[i].Serialize( pStream );
	}
	return TRUE;
}
bool CGoodsBaseProperties::tagSuitProperty::Serialize(vector<uchar>* pStream, bool b)
{
	_AddToByteArray(pStream,static_cast<ulong>(gapType));
	_AddToByteArray(pStream, static_cast<ulong>(vValues.size()));
	for(size_t i = 0; i < vValues.size(); i++)
	{
		vValues[i].Serialize(pStream);
	}
	return true;
}
示例#8
0
//压数据
bool CMercenaryQuestSys::AddDataByteArray(vector<BYTE>* pByteArray)
{
	_AddToByteArray(pByteArray,m_lCurQuestID);
	_AddToByteArray(pByteArray,m_lLastQuestID);
	_AddToByteArray(pByteArray,(WORD)m_MerQuests.size());
	itMerQ it = m_MerQuests.begin();
	for(;it != m_MerQuests.end();it++)
	{
		_AddToByteArray(pByteArray,(*it).first);
		tagMerQuest &MercQuests = (*it).second;
		_AddToByteArray(pByteArray,MercQuests.dwLastUpdateTime);
		_AddToByteArray(pByteArray,(WORD)MercQuests.Quests.size());
		vector<long>::iterator itQ = MercQuests.Quests.begin();
		for(;itQ != MercQuests.Quests.end();itQ++)
		{
			_AddToByteArray(pByteArray,(*itQ));
		}
	}
	set<long>::iterator itDisband=DisbandQuests.begin();
	_AddToByteArray( pByteArray,(WORD)DisbandQuests.size() );
	for (;itDisband != DisbandQuests.end();itDisband++)
	{
		_AddToByteArray( pByteArray,(*itDisband) );
	}
	return true;
}
示例#9
0
//! 配置编码
void SpriteSystem::SetupAddToByteArray(vector<BYTE> &ByteArray)
{
	_AddToByteArray(&ByteArray, (LONG)c_mapCanUseGoodsIndex.size());
	for (map<LONG, DWORD>::iterator ite = c_mapCanUseGoodsIndex.begin(); ite != c_mapCanUseGoodsIndex.end(); ++ite)
	{
		_AddToByteArray(&ByteArray, ite->first);
		_AddToByteArray(&ByteArray, ite->second);
	}
    //战斗技能
    _AddToByteArray(&ByteArray, (LONG)c_vectorCanUseFightSkill.size());
    for (vector<LONG>::iterator ite = c_vectorCanUseFightSkill.begin(); ite != c_vectorCanUseFightSkill.end(); ++ite)
    {
        _AddToByteArray(&ByteArray, *ite);
    }
    //辅助技能
    _AddToByteArray(&ByteArray, (LONG)c_vectorCanUseAssistSkill.size());
    for (vector<LONG>::iterator ite = c_vectorCanUseAssistSkill.begin(); ite != c_vectorCanUseAssistSkill.end(); ++ite)
    {
        _AddToByteArray(&ByteArray, *ite);
    }
    //辅助道具
    _AddToByteArray(&ByteArray, (LONG)c_vectorCanUseAssistGoods.size());
    for (vector<LONG>::iterator ite = c_vectorCanUseAssistGoods.begin(); ite != c_vectorCanUseAssistGoods.end(); ++ite)
    {
        _AddToByteArray(&ByteArray, *ite);
    }
}
void CDBMailGoodsGroup::AddToByteArray(vector<BYTE>& pBA)
{
    _AddToByteArray(&pBA, m_OwnerGUID); // 拥有者ID
    _AddToByteArray(&pBA, (WORD)m_setGoodsGroup.size()); // 物品个数

    set<CDBMailGoods*>::iterator itr = m_setGoodsGroup.begin();
    for(; itr != m_setGoodsGroup.end(); itr++)
    {
        (*itr)->AddEntityDataToMsg(DB_OPER_LOAD, pBA);
    }
}
BOOL CSuitRuleFactory::Serialize(vector<BYTE>* pStream, BOOL b)
{
	_AddToByteArray( pStream, static_cast<DWORD>( m_mRules.size() ) );
	map<int,CSuitRule*>::iterator it = m_mRules.begin();
	for( ; it != m_mRules.end(); it ++ )
	{
		_AddToByteArray( pStream, (long)(it -> first) );
		it -> second -> Serialize( pStream );
	}
	return TRUE;
}
bool CIncrementShopManager::AddToByteArray( vector<BYTE>* pByteArray )
{
	long lNum = (long)m_mapLimitGoodsMap.size();
	_AddToByteArray( pByteArray, lNum );
	map<DWORD, DWORD>::iterator it = m_mapLimitGoodsMap.begin();
	for ( ; it != m_mapLimitGoodsMap.end(); ++it )
	{
		_AddToByteArray( pByteArray, it->first );
		_AddToByteArray( pByteArray, it->second );
	}
	return true;
}
示例#13
0
/// 编码
bool EmotionSetup::Serialize(vector<uchar>* pByteArray)
{
	_AddToByteArray(pByteArray, static_cast<DWORD>(s_mEmotions.size()));

	map<long, BOOL>::iterator it = s_mEmotions.begin();
	for(; it!=s_mEmotions.end(); ++it)
	{
		_AddToByteArray(pByteArray, it->first);
		_AddToByteArray(pByteArray, static_cast<long>(it->second));
	}
	return true;
}
示例#14
0
//##类的序列化,用于在游戏服务器之间传输数据
VOID CExState1::Serialize( vector<BYTE>& vOut )
{
	//##是否需要将技能的id和等级都压入?
	//##这个状态只有技能ID,不需要压入等级,但是有些其他的状态需要等级
	_AddToByteArray( &vOut, m_lID );

	//##剩余时间
	m_stStateParam.keeptime	= GetRemainedTime();

	_AddToByteArray( &vOut, &m_stStateParam, sizeof(tagExState) );

}
//##类的序列化,用于在游戏服务器之间传输数据
VOID CUseGoodsEnlargeMaxMpState::Serialize( vector<BYTE>& vOut )
{
	//##是否需要将技能的id和等级都压入?
	//##这个状态只有技能ID,不需要压入等级,但是有些其他的状态需要等级
	_AddToByteArray( &vOut, m_lID );

	//##剩余时间
	_AddToByteArray( &vOut, GetRemainedTime() );


	_AddToByteArray( &vOut, m_dwCoefficient );
}
示例#16
0
bool CMultiHpBar::AddDatatoByteArray(vector<uchar>* pByteArray)
{
    _AddToByteArray(pByteArray,m_BaseMaxHp);
    _AddToByteArray(pByteArray,(long)m_listHpBar.size());
    for (list<HpBar>::iterator it= m_listHpBar.begin();
            it!= m_listHpBar.end(); it++)
    {
        _AddToByteArray(pByteArray,(long)it->HpRange);
        //_AddToByteArray(pByteArray,it->Color);
        //_AddToByteArray(pByteArray,it->scriptname.c_str());
    }
    return true;
}
示例#17
0
BOOL CJiFen::Serialize( vector<BYTE>* pStream, BOOL b )
{
	if( m_pGoldCoins )
	{
		_AddToByteArray( pStream, static_cast<BYTE>(1) );
		m_pGoldCoins -> Serialize( pStream, b );
	}
	else
	{
		_AddToByteArray( pStream, static_cast<BYTE>(0) );
	}
	return TRUE;
}
示例#18
0
//! 把输入的参数值按类型压入uchar数组
//! 参数args必须是va_start之后的
//! 参数lType类型为eDataTypeCode
bool LogClient::ParamToByteArray(va_list& args, const LogItem& logItem, vector<uchar> &vData)
{
	switch(logItem.m_eType)
	{
	case eDTC_INT32:
		{
			long var = va_arg(args, long);
			_AddToByteArray(&vData, var);
		}
		break;
	case eDTC_FLOAT:
		{
			float *var = va_arg(args, float*);
			_AddToByteArray(&vData, *var);
		}
		break;
	case eDTC_GUID:
		{
			CGUID* var = va_arg(args, CGUID*);
			char szGUID[128] = {0};
			var->tostring(szGUID);
			_AddToByteArray(&vData, (CGUID)*var);
		}
		break;
	case eDTC_DATE:
	case eDTC_STR128:
	case eDTC_STR512:
		{
			char* var = va_arg(args, char*);
#ifdef _DEBUG
			if(eDTC_STR128 == logItem.m_eType)
			{
				assert(128 > strlen(var));
			}
			else
			{
				assert(512 > strlen(var));
			}
#endif
			_AddToByteArray(&vData, (long)strlen(var));
			_AddToByteArray(&vData, var, (long)strlen(var));
		}
		break;
	default:
		return false;
		break;
	}

	return true;
}
示例#19
0
void CDBLinkmanGroup::AddToByteArray(vector<BYTE>& pBA)
{
	_AddToByteArray(&pBA, m_GUID); // 实体ID

	_AddToByteArray(&pBA, GetOwnerGUID());

	_AddToByteArray(&pBA, (WORD)m_setLinkmanGroup.size()); // 物品个数

	set<CDBLinkMan*>::iterator itr = m_setLinkmanGroup.begin();
	for(; itr != m_setLinkmanGroup.end(); itr++)
	{
		(*itr)->AddEntityDataToMsg(DB_OPER_LOAD, pBA);
	}
}
示例#20
0
// 压数据
BOOL CRoleRecord::AddDatatoByteArray(vector<BYTE>* pByteArray)
{
	_AddToByteArray(pByteArray,m_lRoleID);
	_AddToByteArray(pByteArray,m_cRoleStep);
	_AddToByteArray(pByteArray,m_cAimNum);
	_AddToByteArray(pByteArray,m_Param,sizeof(sRoleParam)*m_cAimNum);
	//_AddToByteArray(pByteArray,(LONG)m_listRoleRecord.size());
	//for (list<CRoleRecord*>::iterator it=m_listRoleRecord.begin(); it!= m_listRoleRecord.end(); it++)
	//{
	//	_AddToByteArray(pByteArray,*it,sizeof(CRoleRecord));
	//}

	return TRUE;
}
//##类的序列化,用于在游戏服务器之间传输数据
VOID CRestoreHpState::Serialize( vector<BYTE>& vOut )
{
	//##是否需要将技能的id和等级都压入?
	//##这个状态只有技能ID,不需要压入等级,但是有些其他的状态需要等级
	_AddToByteArray( &vOut, m_lID );

	//##剩余时间
	_AddToByteArray( &vOut, GetRemainedTime() );

	//##频率
	_AddToByteArray( &vOut, m_dwFrequency );

	//##加血量
	_AddToByteArray( &vOut, m_dwHPGain );
	
}
示例#22
0
//收信
void CMailManager::SendReceiveMail(CPlayer *pPlayer)
{
	list<CGUID> lReceiveMail = pPlayer->GetReceiveMailList();
	if (lReceiveMail.size()>0 && pPlayer->GetReceiveMail())
	{		
		vector<BYTE> vectorByte;
		vectorByte.clear();


		_AddToByteArray(&vectorByte,(long)lReceiveMail.size());
		for (list<CGUID>::iterator it=lReceiveMail.begin();it!=lReceiveMail.end();++it)
		{
			map<CGUID,CMail*>::iterator mit = m_mapMail.find((*it));
			if (mit!=m_mapMail.end())
			{
				(*mit).second->AddToByteArrayForClient(vectorByte,pPlayer);

				long lGoodsNum = 0;
				for (vector<CGoods*>::iterator tit=(*mit).second->GetMGoodsContainer().begin(); tit!=(*mit).second->GetMGoodsContainer().end(); ++tit)
				{
					lGoodsNum += (*tit)->GetAmount();
				}

				GetGameLogInterface()->logT600_Receive_mail_log(pPlayer,(*mit).second->GetExID(),(*mit).second->GetWriter().c_str(),(*mit).second->GetType(),(*mit).second->GetGold(),lGoodsNum,(*mit).second->GetSGood().size(),1);
			}
		}
		SendAllMailToClient(vectorByte,pPlayer);
	} 
	else
	{
		CMessage msg(MSG_S2W_MAIL_RECEIVE);
		msg.Add(pPlayer->GetExID());
		msg.Send();
	}	
}
BOOL CGoodsBaseProperties::tagAddonProperty::Serialize(vector<BYTE>* pStream, BOOL b)
{
	// TODO: Add your specialized code here.
	// NOTE: Requires a correct return value to compile.
	_AddToByteArray( pStream, static_cast<DWORD>(gapType) );
	_AddToByteArray( pStream, static_cast<LONG>(bIsEnabled) );
	_AddToByteArray( pStream, static_cast<LONG>(bIsImplicitAttribute) );
	
	_AddToByteArray( pStream, static_cast<DWORD>( vValues.size() ) );
	for( size_t i = 0; i < vValues.size(); i ++ )
	{
		vValues[i].Serialize( pStream );
	}

	return TRUE;
}
BOOL CKitCardRuleFactory::Serialize(vector<BYTE>* pStream, BOOL b)
{	
	_AddToByteArray(pStream,static_cast<DWORD>(m_vecCardPrice.size()));
	for(int i=0;i<m_vecCardPrice.size();i++)
	{
		_AddToByteArray(pStream,&m_vecCardPrice[i],sizeof(tagCardPrice));
	}

	_AddToByteArray( pStream, static_cast<DWORD>( m_mRules.size() ) );
	map<int,CKitCardRule*>::iterator it = m_mRules.begin();
	for( ; it != m_mRules.end(); it ++ )
	{
		_AddToByteArray( pStream, (long)(it -> first) );
		it -> second -> Serialize( pStream );
	}
	return TRUE;	
}
示例#25
0
//! 编码到WS
void LinkmanGroup::Serialize_ForWS(vector<BYTE> *pVecData)
{
	//! 我添加的玩家
	_AddToByteArray(pVecData, (LONG)m_mapMeAdd.size());
	
	for (map<CGUID, tagLinkman>::iterator ite = m_mapMeAdd.begin(); ite != m_mapMeAdd.end(); ++ite)
	{
		tagLinkman_data &Linkman_data = ite->second;
		_AddToByteArray(pVecData, &Linkman_data, sizeof(tagLinkman_data));
	}
	
	//! 添加我的玩家
	_AddToByteArray(pVecData, (LONG)m_mapAddMe.size());
	for (map<CGUID, tagLinkman_DB>::iterator ite = m_mapAddMe.begin(); ite != m_mapAddMe.end(); ++ite)
	{
		_AddToByteArray(pVecData, &(ite->second), sizeof(tagLinkman_DB));
	}
}
示例#26
0
void DoW2SMailReceive( CMessage *pMsg )
{
	BYTE *ByteData = NULL;
	list<CGUID> lMailGuid;
	list<CMail*> lMailList;
	CGUID playerGuid;
	pMsg->GetGUID(playerGuid);

	long lByteDataLen = pMsg->GetLong();
	ByteData = (BYTE*)M_ALLOC(sizeof(BYTE)*lByteDataLen);	
	pMsg->GetEx(ByteData,lByteDataLen);
	time_t t_CurrentTime = time(NULL);

	CPlayer *pPlayer =  GetGame()->FindPlayer(playerGuid);
	if (pPlayer)
	{				
		long Pos = 0;
		long lNum = _GetLongFromByteArray(ByteData,Pos);
		for (int i=0; i<lNum; ++i)
		{
			tagMailParam *pMailParam = OBJ_CREATE(tagMailParam);
			GameManager::GetInstance()->GetMailManager()->DecordFromByteArray(ByteData,Pos,pMailParam);

			CMail *pMail = OBJ_CREATE_PVOID(CMail, (void*)pMailParam);

			if(!GameManager::GetInstance()->GetMailManager()->SetMapMail(pMail))
			{
				lMailGuid.push_back(pMailParam->guid);					
			}
			else
			{
				lMailList.push_back(pMail);
			}
		}
		if(lMailGuid.size()>0)
		{
			//删除邮件		
			GameManager::GetInstance()->GetMailManager()->DeleteMailToWS(lMailGuid,pPlayer);				
		}

		vector<BYTE> vectorByte;
		vectorByte.clear();

		_AddToByteArray(&vectorByte,(long)lMailList.size());
			
		pPlayer->SetReceiveMail(true);	
		for (list<CMail*>::iterator it=lMailList.begin();it!=lMailList.end();++it)
		{
			pPlayer->AddReceiveMailList((*it)->GetExID());
		}

		GameManager::GetInstance()->GetMailManager()->SendReceiveMail( pPlayer );
	}
	M_FREE(ByteData, lByteDataLen);
}
//! 发送联系人数据到WS
void LinkmanSystem::SendDataToWs(void)
{
	CMessage msgToWs(MSG_S2W_LINKMAN_DATA);
	vector<BYTE> vLinkmanData;

	//! 先给玩家总数占个位置
	_AddToByteArray(&vLinkmanData, (LONG)0L);

	//! 实际发送人数统计
	LONG lNum = 0;
	map<CGUID, VecLinkmanGroup>::iterator ite = m_mapPlayerLinkman.begin();
	for (; ite != m_mapPlayerLinkman.end(); ++ite)
	{
		if(NULL == GetGame()->FindPlayer(ite->first))
		{
			if(NULL == GetGame()->FindSavePlayer(ite->first))
				continue;
		}

		++lNum;
		//! 玩家GUID
		_AddToByteArray(&vLinkmanData, ite->first);
		VecLinkmanGroup &vLinkmanGroup = ite->second;
		//! 联系人组数
		_AddToByteArray(&vLinkmanData, (LONG)vLinkmanGroup.size());
		for (LONG i = 0; i < (long)vLinkmanGroup.size(); ++i)
		{
			//! 联系人数据
			vLinkmanGroup[i].Serialize_ForWS(&vLinkmanData);
		}
	}

	//! 在编码中替换实际人数
	memcpy(&vLinkmanData[0], &lNum, sizeof(LONG));

	msgToWs.Add((LONG)vLinkmanData.size());
	msgToWs.AddEx(&vLinkmanData[0], (long)vLinkmanData.size());
	msgToWs.Send();
}	
示例#28
0
//! 在本地记录服务器格式日志(时间自动添加)
bool LogClient::LogToHere(long LogType, ...)
{
	TableMap_ite ite = m_TableInfo.find(LogType);
	if (ite == m_TableInfo.end())
		return false;
	if (eSC_LOGSERVER == ite->second.m_SendControl)
	{
		return true;
	}

	LogTable &tmpTableInfo = ite->second;

	//string strSQL;
	va_list args;
	va_start(args, LogType);
	//bool re = GetSQL(args, tmpTableInfo, strSQL);
	vector<uchar> vByteData;
	_AddToByteArray(&vByteData, tmpTableInfo.m_tableType);

	bool re = false;

//如果是release版,则捕捉异常
#ifndef _DEBUG
	try
	{
#endif
		re = GetLogByteArray(args, tmpTableInfo, vByteData);
#ifndef _DEBUG
	}
	catch (...)
	{
		char szErrStr[128] = {0};
		sprintf(szErrStr, "在记录日志类型%d时发生了数据类型异常!!!\r\n");
		LogTxtToHere(szErrStr);
		return re;
	}
#endif
	
	va_end(args);

	char szStr[10240] = {0};
	for (size_t i = 0; i < vByteData.size(); ++i)
	{
		sprintf(szStr + 2 * i, "%d,", vByteData[i]);
	}
	m_LogFile.WirteToBuf(string(szStr));
	SetEvent(m_hEvent);
	//m_LogFile.WirteToBuf(strSQL + string("/r/n"));

	return true;
}
示例#29
0
// 添加到CByteArray为发送到客户段
bool stModuParam::AddToByteArrayForClient(vector<BYTE>* pByteArray,ModuleType eType)
{
	//添加id和等级	
	_AddToByteArray(pByteArray,(long)nID);
	_AddToByteArray(pByteArray,(long)nLvl);
	//如果是状态添加第一个定时器剩余时间到客户端
	if(eType == ModuType_Buff || eType == ModuType_DeBuff)
	{
		stModuParam::itTimer it = Timers.begin();
		if( it!=Timers.end() )
		{
			stTimerParam *pTimerParam = (*it);
			DWORD dwRemainTime = 
				pTimerParam->lFuture+pTimerParam->lInter*(pTimerParam->nCount-pTimerParam->nCalledCount);
			_AddToByteArray(pByteArray,dwRemainTime);
		}
		else
		{
			_AddToByteArray(pByteArray,(DWORD)0);
		}
	}

	return true;
}
示例#30
0
// 添加到CByteArray
bool CPlayerRanks::AddToByteArray(vector<BYTE>& ByteArray,int nAddNum)
{
    long lSize = min(nAddNum,m_PlayerRanks.size());
    _AddToByteArray(&ByteArray, lSize);
    list<tagRank>::iterator it = m_PlayerRanks.begin();
    for(; it!=m_PlayerRanks.end(); it++)
    {
        _AddToByteArray(&ByteArray, (*it).PlayerID);
        _AddToByteArray(&ByteArray, (char*)(*it).strName.c_str());
        _AddToByteArray(&ByteArray, (*it).wOccupation);
        _AddToByteArray(&ByteArray, (*it).wLevel);
        _AddToByteArray(&ByteArray, (char*)(*it).strFacName.c_str() );
    }
    return true;
}