当前位置: 首页>>代码示例>>C++>>正文


C++ WriteBuffer::AppendLong方法代码示例

本文整理汇总了C++中WriteBuffer::AppendLong方法的典型用法代码示例。如果您正苦于以下问题:C++ WriteBuffer::AppendLong方法的具体用法?C++ WriteBuffer::AppendLong怎么用?C++ WriteBuffer::AppendLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WriteBuffer的用法示例。


在下文中一共展示了WriteBuffer::AppendLong方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: EncodeToBuffer

ByteBufferPtr WIMDecoder::EncodeToBuffer(RawImagePtr theImage)
{
	if(theImage->GetType()!=RawImageType_32)
		return NULL;

	RawImage32 *anImage = (RawImage32*)theImage.get();
	
	WriteBuffer aBuf;
	aBuf.AppendBytes("WIM",3); // file format identifier
	aBuf.AppendLong(32); // file subtype (32-bit raw)
	aBuf.AppendByte(anImage->GetDoTransparency()?1:0); // apply transparency bit?
	aBuf.AppendLong(anImage->GetWidth());
	aBuf.AppendLong(anImage->GetHeight());
	aBuf.AppendBytes(anImage->GetImageData(), 4*anImage->GetWidth()*anImage->GetHeight());
	return aBuf.ToByteBuffer();
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:16,代码来源:WIMDecoder.cpp

示例2: time

SPAuthCheckPrv::SPAuthCheckPrv(const char *theProduct)
{
	mAPI = NULL;
	mStatus = WS_None;
	mStartedChecking = false;
	mOnlyForceCheck = false;
	mStartTime = time(NULL);
	mGameSecondsBeforeNextCheck = 1;

	WriteBuffer aBuf;
	aBuf.Reserve(8);
	aBuf.AppendLong(0x87ab3215);
	aBuf.AppendLong(CDKey::GetMachineId());
	mEncryptKey.SetKey(aBuf.data(),aBuf.length());
	
	mAuthContext = new AuthContext;
	mCommunity = StringToWString(theProduct);
	mProductDir = L"/" + mCommunity;

	mCDKey.SetProductString(theProduct);
	mCDKey.LoadFromRegistry();
	if(!mCDKey.IsValid())
	{
		mStatus = WS_AuthServ_InvalidCDKey;
		return;
	}
		
	if(!AsyncSocket::HasInternetConnection())
	{
		mStatus = WS_NoInternetConnection;
		return;
	}

	if(WONAPICoreEx::GetInstance()==NULL)
	{
		mAPI = new WONAPICoreEx;
		mAPI->SetDoPumpThread(true);
		mAPI->Startup();
	}	

	ReadCheckFile();
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:42,代码来源:SPAuthCheck.cpp

示例3: GetRequest

ByteBufferPtr MultiPingOp::GetRequest(MultiPingStruct *theStruct)
{
	theStruct->mPingId = rand();
	theStruct->mStartPingTick = GetTickCount();

	WriteBuffer aBuf;
	aBuf.AppendByte(3);
	aBuf.AppendByte(1);
	aBuf.AppendByte(5);
	aBuf.AppendLong(theStruct->mPingId);
	aBuf.AppendBool(false);
	return aBuf.ToByteBuffer();
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:13,代码来源:MultiPingOp.cpp

示例4: WriteCheckFile

void SPAuthCheckPrv::WriteCheckFile()
{
	
	if(mGameSecondsBeforeNextCheck==1) // Remove file to force check next time
	{
		WONFile aFile(gSPAuthCheck_FileName);
		aFile.Remove();
		return;
	}

	// Write new file
	try
	{
		FileWriter aWriter;
		if(!aWriter.Open(gSPAuthCheck_FileName))
			return;

		WONFile aFile(gSPAuthCheck_FileName);

		WriteBuffer anEncrypt;
		anEncrypt.AppendString("magic");
		anEncrypt.AppendLong(aFile.GetCreateTime()); // file creation time
		anEncrypt.AppendLong(mGameSecondsBeforeNextCheck);

		ByteBufferPtr aBuf = mEncryptKey.Encrypt(anEncrypt.data(),anEncrypt.length());
		if(aBuf.get()==NULL)
			return;

		aWriter.WriteShort(aBuf->length());
		aWriter.WriteBytes(aBuf->data(),aBuf->length());
	}
	catch(FileWriterException&)
	{
	}


}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:37,代码来源:SPAuthCheck.cpp

示例5: RunHook

void InsertBannedKeyOp::RunHook()
{
	SetMessageType(DBProxyAccount);
	SetSubMessageType(MSGTYPE);
	mStatusList.clear();

	// Stores the message data
	WriteBuffer requestData;
	requestData.AppendWString(mCommunityName);
	requestData.AppendString(mProductName);
	requestData.AppendLong(mBannedUntil);

	requestData.AppendShort(mKeyList.size());
	for(std::list<std::string>::const_iterator anItr = mKeyList.begin(); anItr != mKeyList.end(); ++anItr)
		requestData.AppendString(*anItr,1);

	// Copy buffer into the class
	SetProxyRequestData(requestData.ToByteBuffer());

	DBProxyOp::RunHook();
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:21,代码来源:BannedKeyOp.cpp

示例6: AppendCommunityData

void AuthContext::AppendCommunityData(WriteBuffer &theBuf)
{
	AutoCrit aCrit(mDataCrit);
	theBuf.AppendByte(0);									// 0 community ids
	theBuf.AppendByte(mCommunityMap.size());				// num community names
	AuthLoginCommunityMap::iterator anItr = mCommunityMap.begin(); 
	while(anItr!=mCommunityMap.end())
	{
		theBuf.AppendWString(anItr->first);	// community name
		++anItr;
	}


	int aNumCommnityElementsPos = theBuf.length();
	theBuf.SkipBytes(2); 
	int aNumCommunityElements = 0;

	anItr = mCommunityMap.begin();
	while(anItr!=mCommunityMap.end()) // Append CD Keys
	{
		AuthLoginCommunityData &aData = anItr->second;
		if(aData.mCDKey.IsValid())
		{
			ByteBufferPtr aKey = anItr->second.mCDKey.GetRaw();
			if(aKey.get()!=NULL)
			{
				theBuf.AppendByte(1);			// Type = CD Key
				theBuf.AppendShort(anItr->first.length()*2 + aKey->length() + 2); // length of community + data
				theBuf.AppendWString(anItr->first);
				theBuf.AppendBytes(aKey->data(),aKey->length());
				aNumCommunityElements++;
			}
		}
		++anItr;
	}

	CDKeyCommunityJoinMap::iterator aKeyJoinItr = mCDKeyCommunityJoinMap.begin(); // Append Community Join By CDKey Info
	while(aKeyJoinItr!=mCDKeyCommunityJoinMap.end())
	{
		ByteBufferPtr aKey = aKeyJoinItr->second.GetRaw();
		if(aKey.get()!=NULL)
		{
			theBuf.AppendByte(7);			// Type = Join Community with CD Key
			theBuf.AppendShort(aKeyJoinItr->first.length()*2+2 + 4 + aKey->length()); // community name + commnityseq + key
			theBuf.AppendWString(aKeyJoinItr->first);
			theBuf.AppendLong(0);
			theBuf.AppendBytes(aKey->data(),aKey->length());
			aNumCommunityElements++;
		}
		++aKeyJoinItr;
	}

	SetCommunityUserDataMap::iterator aUserDataItr = mSetCommunityUserDataMap.begin(); // Append User Data for communities
	while(aUserDataItr!=mSetCommunityUserDataMap.end())
	{
		const ByteBuffer *aData = aUserDataItr->second;
		if(aData!=NULL)
		{
			theBuf.AppendByte(8);			// Type = SetCommunityUserData
			theBuf.AppendShort(aUserDataItr->first.length()*2+2 + 4 + aData->length()); // community name + commnityseq + key
			theBuf.AppendWString(aUserDataItr->first);
			theBuf.AppendLong(0);
			theBuf.AppendBuffer(aData);
			aNumCommunityElements++;
		}

		++aUserDataItr;
	}

	if(mSecretList.size()>0) 				// CD Keys -> append login secret
	{
		theBuf.AppendByte(6);				// Type = LoginSecret
		unsigned long aPos = theBuf.length();
		theBuf.SkipBytes(2);

		AppendLoginSecrets(theBuf);
		theBuf.SetShort(aPos,theBuf.length()-aPos-2);
		aNumCommunityElements++;
	}

	NicknameMap::iterator aNickItr = mNicknameMap.begin();
	while(aNickItr!=mNicknameMap.end())
	{
		const wstring& aKey = aNickItr->first;
		const wstring& aVal = aNickItr->second;

		theBuf.AppendByte(4); // retrieve nickname
		unsigned long aPos = theBuf.length();
		theBuf.SkipBytes(2);
		theBuf.AppendWString(aKey);
		theBuf.SetShort(aPos,theBuf.length()-aPos-2);
		aNumCommunityElements++;

		if(!aVal.empty())
		{
			theBuf.AppendByte(3); // set nickname
			unsigned long aPos = theBuf.length();
			theBuf.SkipBytes(2);
			theBuf.AppendWString(aKey);
			theBuf.AppendWString(aVal);
//.........这里部分代码省略.........
开发者ID:Joincheng,项目名称:lithtech,代码行数:101,代码来源:AuthContext.cpp


注:本文中的WriteBuffer::AppendLong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。