예제 #1
0
// 解码	
 bool CReLiveGoodsList::DecordFromByteArray(BYTE* pByte, long& pos)
{
	//复活物品数量
	
	long lNum = _GetLongFromByteArray(pByte,pos);
	for(long l=0; l<lNum; ++l )
	{
		char strTemp[256];
		tagReLiveGoods *ptgReliveGoods  = new tagReLiveGoods;
		_GetStringFromByteArray(pByte,pos,strTemp);
		ptgReliveGoods->strOrignalName = strTemp;
		ptgReliveGoods->dwIndex			 = _GetDwordFromByteArray(pByte,pos);
		ptgReliveGoods->dwNum			 = _GetDwordFromByteArray(pByte,pos);
		ptgReliveGoods->dwRecoverRatio   = _GetDwordFromByteArray(pByte,pos);
		m_lReLiveGoods.push_back(ptgReliveGoods);

	}
	//吸收经验物品
	long lENum = _GetLongFromByteArray(pByte,pos);
	for (long i=0; i<lENum; ++i)
	{	
		char strOrgName[256];
		char strTemp[1024];
		tagExpGoods *ptgExpGoods = new tagExpGoods;
		_GetStringFromByteArray(pByte,pos,strOrgName);
		ptgExpGoods->dwExpRatio = _GetLongFromByteArray(pByte,pos);
		_GetStringFromByteArray(pByte,pos,strTemp);
		ptgExpGoods->strScript = strTemp;
		_GetStringFromByteArray(pByte,pos,strTemp);
		ptgExpGoods->strHint = strTemp;
		m_mpExpGoods[strOrgName] = ptgExpGoods;
	}
	return true;
}
예제 #2
0
//解数据
bool CMercenaryQuestSys::DecordDataFromByteArray(BYTE* pByte, long& pos)
{
	m_MerQuests.clear();
	DisbandQuests.clear();
	m_lCurQuestID = _GetLongFromByteArray(pByte,pos);
	m_lMasterQuestID = _GetLongFromByteArray(pByte,pos);
	WORD wSize = _GetWordFromByteArray(pByte,pos);
	tagMerQuest MerQuest;
	for(WORD i=0;i<wSize;i++)
	{
		long lID = _GetLongFromByteArray(pByte,pos);
		long time= _GetDwordFromByteArray(pByte,pos);
		long lSize =  _GetWordFromByteArray(pByte,pos);
		MerQuest.Quests.clear();
		MerQuest.dwLastUpdateTime=time;
		for(WORD j=0;j<lSize;j++)
		{
			long lID = _GetLongFromByteArray(pByte,pos);
			MerQuest.Quests.push_back(lID);
		}
		m_MerQuests[lID] = MerQuest;

	}
	wSize=_GetWordFromByteArray(pByte,pos);
	for ( WORD i=0;i<wSize;i++ )
	{
		long lId = _GetLongFromByteArray(pByte,pos);
		DisbandQuests.insert(lId);
	}
	return true;
}
예제 #3
0
bool CGoods::tagAddonProperty::Unserialize(uchar* pStream, long& lOffset, bool b)
{
	gapType					= static_cast<eGoodsAddonProperties>( 
		_GetDwordFromByteArray(pStream, lOffset) );	
	lValues[0]=_GetLongFromByteArray(pStream,lOffset);
	lValues[1]=_GetLongFromByteArray(pStream,lOffset);
	return true;
}
예제 #4
0
//解码
void	CMailManager::DecordFromByteArray(BYTE* pByte, long& pos,tagMailParam *pMailParam)
{
	char strTemp[2048];
	if (pMailParam==NULL)
		return;
	_GetBufferFromByteArray(pByte,pos,pMailParam->guid);	
	_GetStringFromByteArray(pByte,pos,strTemp);
	pMailParam->strSubject = strTemp;
	_GetStringFromByteArray(pByte,pos,strTemp);
	pMailParam->strWriter = strTemp;
	_GetStringFromByteArray(pByte,pos,strTemp);
	pMailParam->strText = strTemp;
	_GetStringFromByteArray(pByte,pos,strTemp);
	pMailParam->strExText = strTemp;

	pMailParam->lGold = _GetLongFromByteArray(pByte,pos);
	pMailParam->tRemainTime = time_t(_GetDwordFromByteArray(pByte,pos));		
	pMailParam->bRead = _GetByteFromByteArray(pByte,pos);
	pMailParam->lType = _GetLongFromByteArray(pByte,pos);
	pMailParam->bReject = _GetByteFromByteArray(pByte,pos);
	_GetStringFromByteArray(pByte,pos,strTemp);
	pMailParam->strReceiver = strTemp;
	_GetBufferFromByteArray(pByte,pos,pMailParam->ReceiverGuid);


	long  lSNum = _GetLongFromByteArray(pByte,pos);
	for (int i=0; i<lSNum; ++i)
	{
		tagSGoods *ptgSGoods = OBJ_CREATE(tagSGoods);
		ptgSGoods->lIndex = _GetLongFromByteArray(pByte,pos);
		ptgSGoods->lNum = _GetLongFromByteArray(pByte,pos);
		pMailParam->lSGoods.push_back(ptgSGoods);
	}
	long lCNum = _GetLongFromByteArray(pByte,pos);

	for (int i=0; i<lCNum; ++i)
	{
		tagCGoods *ptgCGoods = OBJ_CREATE(tagCGoods);
		_GetBufferFromByteArray(pByte,pos,ptgCGoods->goodsguid);
		ptgCGoods->lNum = _GetLongFromByteArray(pByte,pos);
		ptgCGoods->lContainerID = _GetLongFromByteArray(pByte,pos);
		ptgCGoods->lPos = _GetLongFromByteArray(pByte,pos);
		pMailParam->lCGoods.push_back(ptgCGoods);
	}

	long lGNum = _GetLongFromByteArray(pByte,pos);
	for (int i=0; i<lGNum; ++i)
	{
		CGoods *pGoods = CGoodsFactory::UnserializeGoods(pByte,pos,25);
		if( pGoods )
		{
			CGoodsFactory::UpdateEquipmentAttr(pGoods);
			pMailParam->vMailGoods.push_back(pGoods);
		}
	}

}
예제 #5
0
// 解码
bool CCountry::DecordFromByteArray(BYTE* pByte, long& pos)
{
	m_lID = _GetByteFromByteArray(pByte, pos);
	m_lPower = _GetLongFromByteArray(pByte, pos);
	_GetBufferFromByteArray(pByte, pos, m_King);
	m_lTechLevel = _GetLongFromByteArray(pByte, pos);
	m_eState = (eState)_GetLongFromByteArray(pByte, pos);
	return true;
}
//! ½âÂë
void MedalContainer::Decode(BYTE *pData, LONG &lPos)
{
	m_setHold.clear();
	LONG lNum = _GetLongFromByteArray(pData, lPos);
	for (LONG i = 0; i < lNum; ++i)
	{
		m_setHold.insert(_GetLongFromByteArray(pData, lPos));
	}
}
bool CGoodsBaseProperties::Unserialize(uchar* pStream, long& lOffset, bool b)
{
	char strTemp[1024];

	Clear();
	m_index = _GetDwordFromByteArray(pStream, lOffset);
	m_strOriginalName = _GetStringFromByteArray(pStream, lOffset, strTemp);
	m_strName = _GetStringFromByteArray(pStream, lOffset, strTemp);
	m_dwPrice = _GetDwordFromByteArray(pStream, lOffset);
	m_dwSilverPrice = _GetDwordFromByteArray(pStream,lOffset);
	m_GoodsBaseType = static_cast<eGoodsBaseType>(_GetDwordFromByteArray(pStream,lOffset));

	//##获取图标
	ulong dwNumIconType = _GetDwordFromByteArray(pStream, lOffset);
	for(size_t i = 0; i < dwNumIconType; i++)
	{
		tagIcon iIcon;
		iIcon.itIconType = static_cast<eIconType>(_GetDwordFromByteArray(pStream, lOffset));
		iIcon.dwIconID = _GetDwordFromByteArray(pStream, lOffset);

		m_vIcons.push_back(iIcon);
	}
	//##获取附加属性
	ulong dwNumAddonProperties = _GetDwordFromByteArray(pStream, lOffset);
	for(size_t i = 0; i < dwNumAddonProperties; i++)
	{
		tagAddonProperty apAddonProperty;
		apAddonProperty.Unserialize(pStream, lOffset);
		m_vAddonProperties.push_back(apAddonProperty);
	}

	//套装属性
	dwNumAddonProperties = _GetDwordFromByteArray(pStream, lOffset);
	for(size_t i = 0; i < dwNumAddonProperties; i++)
	{
		tagSuitProperty apAddonProperty;
		apAddonProperty.Unserialize(pStream, lOffset);
		m_vSuitProperties.push_back(apAddonProperty);
	}

	//道具属性激发
	m_vTriggerProperties.clear();
	ushort wTriggerNum=_GetWordFromByteArray(pStream,lOffset);
	for(ushort i=0;i<wTriggerNum;i++)
	{
		tagTriggerProperty stTriggerProperty;
		stTriggerProperty.gapType = static_cast<eGoodsAddonProperties>(_GetWordFromByteArray(pStream,lOffset));
		stTriggerProperty.lVal1 = _GetLongFromByteArray(pStream,lOffset);
		stTriggerProperty.lVal2 = _GetLongFromByteArray(pStream,lOffset);
		stTriggerProperty.wTriggerLevel = _GetWordFromByteArray(pStream,lOffset);
		m_vTriggerProperties.push_back(stTriggerProperty);
	}

	return true;
}
예제 #8
0
// 解码
bool CBaseObject::DecordFromByteArray(BYTE* pByte, long& pos, bool bExData)
{
	m_bIsHide = (_GetByteFromByteArray(pByte, pos) != 0);
	m_lType = _GetLongFromByteArray(pByte, pos);
	_GetBufferFromByteArray(pByte,pos,m_guExID);
	/*m_lGraphicsID = */_GetLongFromByteArray(pByte, pos);

	_GetStringFromByteArray(pByte, pos, m_strName);

	return true;
}
예제 #9
0
bool CMultiHpBar::DecordDataFromByteArray(uchar* pByte, long& pos)
{
    m_BaseMaxHp= _GetLongFromByteArray(pByte,pos);
    m_listHpBar.clear();
    long size=_GetLongFromByteArray(pByte,pos);
    for (int i=0; i<size; i++)
    {
        HpBar bar;
        bar.HpRange=_GetLongFromByteArray(pByte,pos);
        m_listHpBar.push_back(bar);
    }
    return true;
}
예제 #10
0
/// 解码
bool EmotionSetup::Unserialize(uchar* pByte, long& pos)
{
	s_mEmotions.clear();
	DWORD dwSize = _GetDwordFromByteArray(pByte, pos);

	for(DWORD i=0; i<dwSize; i++)
	{
		long lID = _GetLongFromByteArray(pByte, pos);
		long bLoop = _GetLongFromByteArray(pByte, pos);

		s_mEmotions[lID] = static_cast<BOOL>(bLoop);
	}
	return true;
}
예제 #11
0
BOOL CPlug::Unserialize(BYTE* pStream, LONG& lOffset)
{
	//## Plug Type, Owner Type Owner ID会在之前就取出来。
	m_bPlugEnded	= _GetLongFromByteArray( pStream, lOffset ); 

	return TRUE;
}
예제 #12
0
//解来数据
BOOL CRoleRecord::DecordDataFromByteArray(BYTE* pByte, long& pos)
{
	m_lRoleID=_GetLongFromByteArray(pByte,pos);
	m_cRoleStep=_GetByteFromByteArray(pByte,pos);
	m_cAimNum= _GetByteFromByteArray(pByte,pos);
	_GetBufferFromByteArray(pByte,pos,m_Param,sizeof(sRoleParam)*m_cAimNum);
	return TRUE;
}
예제 #13
0
// 解码
bool CShape::DecordShapeFromByteArray(BYTE* pByte, long& pos)
{
	_GetBufferFromByteArray(pByte,pos,m_guExID);
	m_CurRgnType = (eRgnType)_GetLongFromByteArray(pByte, pos);
	m_lRegionID = _GetLongFromByteArray(pByte, pos);
	_GetBufferFromByteArray(pByte, pos, m_RegionID);
	m_fPosX = _GetFloatFromByteArray(pByte, pos);
	m_fPosY = _GetFloatFromByteArray(pByte, pos);
	m_lDir = _GetLongFromByteArray(pByte, pos);
	m_lPos = _GetLongFromByteArray(pByte, pos);
	m_lPos = 0;
	m_fSpeed = _GetFloatFromByteArray(pByte, pos);
	m_wState = _GetWordFromByteArray(pByte, pos);
	m_wAction = _GetWordFromByteArray(pByte, pos);

	return true; 
}
bool CGoodsBaseProperties::tagAddonProperty::Unserialize(uchar* pStream, long& lOffset, bool b)
{
	Clear();

	gapType = static_cast<eGoodsAddonProperties>(_GetDwordFromByteArray(pStream, lOffset));
    bIsEnabled = _GetLongFromByteArray(pStream, lOffset) ? true : false;
	bIsImplicitAttribute = _GetLongFromByteArray(pStream, lOffset) ? true : false;

	ulong dwNumAddonPropertyValues = _GetDwordFromByteArray(pStream, lOffset);
	for(size_t i = 0; i < dwNumAddonPropertyValues; i++)
	{
		tagAddonPropertyValue apvAddonPropertyValue;
		apvAddonPropertyValue.Unserialize(pStream, lOffset);
		vValues.push_back(apvAddonPropertyValue);
	}
	return true;
}
bool CGoodsBaseProperties::tagAddonPropertyValue::Unserialize(uchar* pStream, long& lOffset, bool b)
{
	Clear();

	dwId = _GetDwordFromByteArray(pStream, lOffset);
	lBaseValue = _GetLongFromByteArray(pStream, lOffset);

	return true;
}
예제 #16
0
bool CPlayerRanks::DecordFromByteArray(BYTE* pByte, long& lPos)
{
	char str[20]="";
	m_PlayerRanks.clear();
	long lSize = _GetLongFromByteArray( pByte, lPos );
	for(int i=0;i<lSize;i++)
	{
		tagRank Rank;
		Rank.nPlayerID = _GetLongFromByteArray(pByte, lPos);
		_GetStringFromByteArray(pByte, lPos, str);
		Rank.strName = str;
		Rank.wOccupation = _GetWordFromByteArray(pByte, lPos);
		Rank.wLevel = _GetWordFromByteArray(pByte, lPos);
		_GetStringFromByteArray(pByte, lPos, str);
		Rank.strFacName = str;
		m_PlayerRanks.push_back(Rank);
	}
	return true;
}
예제 #17
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);
}
BOOL CGoodsBaseProperties::tagAddonProperty::Unserialize(BYTE* pStream, LONG& lOffset, BOOL b)
{
	// TODO: Add your specialized code here.
	// NOTE: Requires a correct return value to compile.
	Clear();

	gapType					= static_cast<GOODS_ADDON_PROPERTIES>( _GetDwordFromByteArray(pStream, lOffset) );
	bIsEnabled				= _GetLongFromByteArray( pStream, lOffset );
	bIsImplicitAttribute	= _GetLongFromByteArray( pStream, lOffset );
	

	DWORD dwNumAddonPropertyValues = _GetDwordFromByteArray( pStream, lOffset );
	for( size_t i = 0; i < dwNumAddonPropertyValues; i ++ )
	{
		tagAddonPropertyValue apvAddonPropertyValue;
		apvAddonPropertyValue.Unserialize( pStream, lOffset );
		vValues.push_back( apvAddonPropertyValue );
	}
	return TRUE;
}
//从WS解码
bool CIncrementShopManager::DecordFromByteArray( BYTE* pByte, long& pos )
{
	long lNum = _GetLongFromByteArray( pByte, pos );
	for ( int i = 0; i < lNum; ++i )
	{
		DWORD dwGoodsIdx = _GetDwordFromByteArray( pByte, pos );
		DWORD dwGoodsNum = _GetDwordFromByteArray( pByte, pos );
		m_mapLimitGoodsMap[dwGoodsIdx] = dwGoodsNum;
	}
	return true;
}
BOOL CGoodsBaseProperties::tagAddonPropertyValue::Unserialize(BYTE* pStream, LONG& lOffset, BOOL b)
{
	// TODO: Add your specialized code here.
	// NOTE: Requires a correct return value to compile.
	Clear();

	dwId					= _GetDwordFromByteArray( pStream, lOffset );
	lBaseValue				= _GetLongFromByteArray( pStream, lOffset );
	
	return TRUE;
}
VOID CUseGoodsEnlargeMaxMpState::Unserialize( BYTE* pBytes, LONG& lPos )
{
	//##状态的技能ID已经被事先在CStateFactory中取出,所以不需要再次取出了
	m_dwTimeStamp	= timeGetTime();
	m_dwTimeToKeep	= _GetDwordFromByteArray( pBytes, lPos );


	m_dwCoefficient = _GetLongFromByteArray( pBytes, lPos );

	//##之后直接调用Begin就可以启动这个状态
}
예제 #22
0
void DecodeTextRes(uchar* buf, long& pos)
{
    char id[128], text[102400];
    s_texts.clear();
    long count = _GetLongFromByteArray(buf, pos);
    for (long i = 0; i < count; ++i)
    {
        _GetStringFromByteArray(buf, pos, id);
        _GetStringFromByteArray(buf, pos, text);
        s_texts[id] = text;
    }
}
예제 #23
0
BOOL CSuitRuleFactory::Unserialize(BYTE* pStream, LONG& lOffset, BOOL b)
{
	DWORD dwNum = _GetDwordFromByteArray( pStream, lOffset );
	for( DWORD i = 0; i < dwNum; i ++ )
	{
		long lVal=_GetLongFromByteArray(pStream,lOffset);
		CSuitRule* pRule=MP_NEW CSuitRule;
		pRule->Unserialize(pStream,lOffset);
		m_mRules[lVal]=pRule;
	}
	return TRUE;
}
예제 #24
0
//! 从数组中获得表结构
void LogClient::ByteArrayToTable(uchar *pData, long pos)
{
	m_TableInfo.clear();

	long tableNum = _GetLongFromByteArray(pData, pos);

	for (long i = 0; i < tableNum; ++i)
	{
		LogTable tmpTableInfo;

		_GetBufferFromByteArray(pData, pos, (void*)&tmpTableInfo, LogTableBaseDataSize);
		long itemNum = _GetLongFromByteArray(pData, pos);
		
		for (long i = 0; i < itemNum; ++i)
		{
			LogItem tmpLogItem;
			_GetBufferFromByteArray(pData, pos, (void*)&tmpLogItem, sizeof(LogItem));
			tmpTableInfo.m_vecItem.push_back(tmpLogItem);
		}
		m_TableInfo[tmpTableInfo.m_tableType] = tmpTableInfo;
	}
}
예제 #25
0
//解码
BOOL CRoleQueue::DecordQuestDataFromByteArray(BYTE* pByte, long& pos)
{
	Clean();
	m_lChapter=_GetLongFromByteArray(pByte,pos);
	LONG rolenum= _GetLongFromByteArray(pByte,pos);

	for (int a=0 ; a<rolenum; a++)
	{
		CRoleRecord* record=new CRoleRecord;
		//_GetBufferFromByteArray(pByte,pos,record,sizeof(CRoleRecord));
		record->DecordDataFromByteArray(pByte,pos);
		//m_listRoleRecord.push_back(record);
		if (!AddOneRecord(record))
		{
			delete record;
		}
	}

	LONG lExcRecordNun= _GetLongFromByteArray(pByte,pos);
	for (int a=0; a< lExcRecordNun; a++)
	{
		sExcessRecord record;
		WORD index= _GetShortFromByteArray(pByte,pos);
		_GetBufferFromByteArray(pByte,pos,&record,sizeof(sExcessRecord));
		m_mapExcessRecord[index]= record;
	}

	LONG rolerecordnum=_GetLongFromByteArray(pByte,pos);

	for (int a=0; a<rolerecordnum; a++)
	{
		LONG _long=_GetLongFromByteArray(pByte,pos);//_GetCharFromByteArray(pByte,pos);
		//m_setRoleRecord[_long]=TRUE;
		m_setRoleRecord.insert(_long);
	}
	DeleteExcessRecord();
	return FALSE;
}
예제 #26
0
void CDBCountry::Save(long msgid, BYTE* msgBuf, long& msgBufPos)
{
	// 解析消息
	WORD attrNum = _GetWordFromByteArray(msgBuf, msgBufPos); // 属性种类个数
	for(WORD i = 0; i < attrNum; i++)
	{
		WORD attrDataNum = _GetWordFromByteArray(msgBuf, msgBufPos); // 属性数据个数
		DB_COUNTRY_ATTR_TYPE type = (DB_COUNTRY_ATTR_TYPE)_GetLongFromByteArray(msgBuf, msgBufPos);//属性类型枚举值
		
		switch(type)
		{
		case DB_COUNTRY_ATTR_LONG_ID:
			{
				SetID(_GetLongFromByteArray(msgBuf, msgBufPos));
			}
			break;
		case DB_COUNTRY_ATTR_LONG_POWER:
			{
				SetPower(_GetLongFromByteArray(msgBuf, msgBufPos));
			}
			break;
		case DB_COUNTRY_ATTR_LONG_TECH_LEVEL:
			{
				SetTechLevel(_GetLongFromByteArray(msgBuf, msgBufPos));
			}
			break;
		case DB_COUNTRY_ATTR_LONG_KING:
			{
				CGUID tGuid;
				_GetBufferFromByteArray(msgBuf, msgBufPos, tGuid);
				SetKing(tGuid);
			}
			break;
		}
	}
}
BOOL CKitCardRuleFactory::Unserialize(BYTE* pStream, LONG& lOffset, BOOL b)
{
	m_vecCardPrice.clear();
	DWORD dwNum=0;
	dwNum=_GetDwordFromByteArray(pStream,lOffset);
	for(DWORD i=0;i<dwNum;i++)
	{
		tagCardPrice stPrice;
		_GetBufferFromByteArray(pStream,lOffset,&stPrice,sizeof(stPrice));
		m_vecCardPrice.push_back(stPrice);
	}

	dwNum = _GetDwordFromByteArray( pStream, lOffset );
	for( DWORD i = 0; i < dwNum; i ++ )
	{
		long lVal=_GetLongFromByteArray(pStream,lOffset);
		CKitCardRule* pRule=MP_NEW CKitCardRule;
		pRule->Unserialize(pStream,lOffset);
		m_mRules[lVal]=pRule;
	}	
	return TRUE;
}
예제 #28
0
void CDBPlayer::Load(long msgid, BYTE* msgBuf, long& msgBufPos, long bufSize)
{
    m_mapDirtyAttrData.clear();

    WORD attrNum = _GetWordFromByteArray(msgBuf, msgBufPos, bufSize); // 属性种类个数

    char varName[1024];
    for(int i=0; i<(int)attrNum; i++)
    {
        //--新格式
        //变量名字符串长度(long)
        //变量名字符串
        //变量类型(long)
        //变量数据长度(long)
        //变量数据
        long varNameLen = _GetLongFromByteArray(msgBuf, msgBufPos, bufSize);//变量名字符串长度(long)
        _GetStringFromByteArray(msgBuf, msgBufPos, varName, bufSize);//变量名字符串
        m_mapDirtyAttrData.insert(string(varName));
        long bufType = _GetLongFromByteArray(msgBuf, msgBufPos, bufSize);//变量类型(long)
        long varBufLen = _GetLongFromByteArray(msgBuf, msgBufPos, bufSize);//变量数据长度(long)

        CEntityProperty* ep = NULL;
        CDataEntityManager::EntityPropertyMapItr itr = GetDataEntityManager().GetEntityPropertyMap().find(varName);
        if(itr != GetDataEntityManager().GetEntityPropertyMap().end())
            ep = itr->second;
        else
        {
            CDataEntityManager* pdeManager = NULL;
            std::map<string, CDataEntityManager*>::iterator itr = GetGame()->GetDBEntityManager()->GetObjAttrDef().find(string("player"));
            if(itr != GetGame()->GetDBEntityManager()->GetObjAttrDef().end())
                pdeManager = itr->second;

            if(pdeManager)
            {
                CEntityProperty* templateEP = pdeManager->GetEntityProperty(varName);
                if(templateEP)
                    ep = GetDataEntityManager().CreateEntityProperty(varName, templateEP->GetDBTableName(), templateEP->GetDataType());
                else
                    AddLogText("根据属性名[%s]查找属性指针为空!", varName);
            }
        }

        assert(ep != NULL);

        switch((DATA_OBJECT_TYPE)bufType)
        {
        case DATA_OBJECT_TIME:
        {
            // 6个long值 : 年 月 日 时 分 秒
            BYTE timeValue[6*sizeof(DWORD)];
            memset(timeValue, 0, 6*sizeof(DWORD));
            _GetBufferFromByteArray(msgBuf, msgBufPos, timeValue, 6*sizeof(DWORD), bufSize);
            ep->SetBufAttr(0, timeValue, 6*sizeof(DWORD));
        }
        break;
        case DATA_OBJECT_STRING:
        {
            char varValue[1024];
            _GetStringFromByteArray(msgBuf, msgBufPos, varValue, bufSize);//变量数据
            ep->SetStringAttr(0, string((char*)varValue));
        }
        break;
        case DATA_OBJECT_FLOAT:
        case DATA_OBJECT_LONG:
        case DATA_OBJECT_SHORT:
        case DATA_OBJECT_ULONG:
        case DATA_OBJECT_USHORT:
        case DATA_OBJECT_BOOL:
        case DATA_OBJECT_CHAR:
        case DATA_OBJECT_BYTE:
        case DATA_OBJECT_WORD:
        case DATA_OBJECT_DWORD:
        {
            long value = _GetLongFromByteArray(msgBuf, msgBufPos, bufSize);//变量数据
            ep->SetLongAttr(0, (long)value);
        }
        break;
        case DATA_OBJECT_GUID:
        {
            CGUID tGUID;
            _GetBufferFromByteArray(msgBuf, msgBufPos, tGUID, bufSize);//变量数据
            ep->SetGuidAttr(0, tGUID);
        }
        break;
        case DATA_OBJECT_BUFFER:
        {
            BYTE* buf = new BYTE[varBufLen];
            _GetBufferFromByteArray(msgBuf, msgBufPos, buf, varBufLen, bufSize);//变量数据
            ep->SetBufAttr(0, buf, varBufLen);
            SAFE_DELETE_ARRAY(buf);
        }
        break;
        }
    }
}
예제 #29
0
// 解码
bool CContributeSetup::DecordFromByteArray(BYTE* pByte, long& pos)
{
	char szTemp[256];
	int i;
	long lNum;
	tagContributeItem stItem;
	
	m_vContributeItems.clear();

	lCombatLevel1 = _GetLongFromByteArray(pByte, pos);
	lCombatLevel2 = _GetLongFromByteArray(pByte, pos);

	lContribute1 = _GetLongFromByteArray(pByte, pos);
	lContribute2 = _GetLongFromByteArray(pByte, pos);

	lContributeLevel = _GetLongFromByteArray(pByte, pos);
	lContributeMultiple = _GetLongFromByteArray(pByte, pos);

	lContributeBaseValue = _GetLongFromByteArray(pByte, pos);
	lContributeMax = _GetLongFromByteArray(pByte, pos);

	lCountryCityContributeModifierLose = _GetLongFromByteArray(pByte, pos);
	lCountryCityContributeModifierGain = _GetLongFromByteArray(pByte, pos);
	lCountryCityContributeItemModifier = _GetLongFromByteArray(pByte, pos);
	

	lNum = _GetLongFromByteArray(pByte, pos);
	for(i=0; i<lNum; i++)
	{
		stItem.dwLoValue = _GetLongFromByteArray(pByte, pos);
		stItem.dwHiValue = _GetLongFromByteArray(pByte, pos);
		stItem.dwNum = _GetLongFromByteArray(pByte, pos);
		stItem.strName = _GetStringFromByteArray(pByte, pos, szTemp);

		m_vContributeItems.push_back(stItem);
	}

	return true;
}
예제 #30
0
void OnDBLoadMessage(CMessage* pMsg)
{
	BYTE Data[102400];
	pMsg->GetEx(Data,102400);

	switch(pMsg->GetType())
	{
	case MSG_DB2S_LOAD_PLAYER://保存玩家数据
		{
			BYTE buf[102400];
			pMsg->GetEx(buf, 102400);
			long pos = 0;
			long msgTimerID = _GetLongFromByteArray(buf, pos);
			CGUID id;
			_GetBufferFromByteArray(buf, pos, id);	// playerID
			CPlayer* player = GetGame()->FindPlayer(id);
			if(player)
			{
				player->DecordFromByteArray(buf, pos);
			}
			// 删除定时器
			GetGame()->DelMsgTimer(msgTimerID);
			AddLogText("从DBS读取Player数据消息...OK!");
		}
		break;
	case MSG_DB2S_LOAD_CONFEDERATION:
		{
			long msgid = pMsg->GetLong();

			//该联盟的全局唯一标识4
			CGUID lID;
			pMsg->GetGUID(lID);
			//联盟名字16
			char strName[16] = {0};
			pMsg->GetStr(strName, 15);
			//盟主帮会ID4
			CGUID lMastterID;
			pMsg->GetGUID(lMastterID);	

			GameUnion* pConf = new GameUnion(lID, lMastterID, string(strName));

			pConf->InitByWSMsg(pMsg);

			GetOrganiCtrl()->AddConfederationOrganizing(lID, pConf);

			// 删除定时器
			GetGame()->DelMsgTimer(msgid);

			char str[128];
			sprintf(str,"成功读取同盟 ID[%d]", lID);
			AddLogText(str);
		}
		break;
	case MSG_DB2S_LOAD_FACTION:
		{
			long msgid = pMsg->GetLong();

			//该帮的全局唯一标识4
			CGUID lID;
			pMsg->GetGUID(lID);
			//帮会名字16
			char strName[16] = {0};
			pMsg->GetStr(strName, 15);
			//帮主ID4
			CGUID lMastterID;
			pMsg->GetGUID(lMastterID);	

			//该帮会成立时间32
			tagTime EstablishedTime;
			pMsg->GetEx(&EstablishedTime, sizeof(tagTime));

			GameFaction* pFaction = new GameFaction(lID, lMastterID,EstablishedTime,string(strName));

			pFaction->InitByWSMsg(pMsg);

			GetOrganiCtrl()->AddConfederationOrganizing(lID, pFaction);

			// 删除定时器
			GetGame()->DelMsgTimer(msgid);

			char str[128];
			sprintf(str,"成功读取帮会 ID[%d]", lID);
			AddLogText(str);
		}
		break;
	case MSG_S2DB_LOAD_PLAYER_GOOD://保存玩家物品
		{
			pMsg->SetType(MSG_W2S_OTHER_DELGOODS);
			pMsg->SendAll();
		}
		break;
	case MSG_S2W_PLAYER_DELSKILL://gm跨服务器删除一个玩家的技能,该消息转发给下面连接的gameserver
		{
			pMsg->SetType(MSG_W2S_OTHER_DELSKILL);
			pMsg->SendAll();
		}
		break;
	case MSG_S2W_PLAYER_SETLEVEL://gm跨服务器设置一个玩家的等级,该消息转发给下面连接的gameserver
		{
			pMsg->SetType(MSG_W2S_OTHER_SETLEVEL);
			pMsg->SendAll();
		}
		break;	

	}
}