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


C++ Database::GeneralQueryReceive方法代码示例

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


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

示例1: Process

void WorldServer::Process()
{
	WorldConnection::Process(); 
	if (!Connected())
		return;

	ServerPacket *pack = 0; 
	while((pack = tcpc.PopPacket()))
	{
		_log(QUERYSERV__TRACE, "Received Opcode: %4X", pack->opcode); 
		switch(pack->opcode) {
			case 0: {
				break;
			}
			case ServerOP_KeepAlive: {
				break;
			}
			case ServerOP_QSPlayerLogTrades: {
				QSPlayerLogTrade_Struct *QS = (QSPlayerLogTrade_Struct*)pack->pBuffer;
				database.LogPlayerTrade(QS, QS->_detail_count);
				break;
			}
			case ServerOP_QSPlayerLogHandins: {
				QSPlayerLogHandin_Struct *QS = (QSPlayerLogHandin_Struct*)pack->pBuffer;
				database.LogPlayerHandin(QS, QS->_detail_count);
				break;
			}
			case ServerOP_QSPlayerLogNPCKills: {
				QSPlayerLogNPCKill_Struct *QS = (QSPlayerLogNPCKill_Struct*)pack->pBuffer;
				uint32 Members = pack->size - sizeof(QSPlayerLogNPCKill_Struct);
				if (Members > 0) Members = Members / sizeof(QSPlayerLogNPCKillsPlayers_Struct);
				database.LogPlayerNPCKill(QS, Members);
				break;
			}
			case ServerOP_QSPlayerLogDeletes: {
				QSPlayerLogDelete_Struct *QS = (QSPlayerLogDelete_Struct*)pack->pBuffer;
				uint32 Items = QS->char_count;
				database.LogPlayerDelete(QS, Items);
				break;
			}
			case ServerOP_QSPlayerLogMoves: {
				QSPlayerLogMove_Struct *QS = (QSPlayerLogMove_Struct*)pack->pBuffer;
				uint32 Items = QS->char_count;
				database.LogPlayerMove(QS, Items);
				break;
			}
			case ServerOP_QSPlayerLogMerchantTransactions: {
				QSMerchantLogTransaction_Struct *QS = (QSMerchantLogTransaction_Struct*)pack->pBuffer;
				uint32 Items = QS->char_count + QS->merchant_count;
				database.LogMerchantTransaction(QS, Items);
				break; 
			}
			case ServerOP_QueryServGeneric: {
				/* 
					The purpose of ServerOP_QueryServerGeneric is so that we don't have to add code to world just to relay packets
					each time we add functionality to queryserv.
				
					A ServerOP_QueryServGeneric packet has the following format:
				
					uint32 SourceZoneID
					uint32 SourceInstanceID
					char OriginatingCharacterName[0] 
						- Null terminated name of the character this packet came from. This could be just
						- an empty string if it has no meaning in the context of a particular packet.
					uint32 Type
				
					The 'Type' field is a 'sub-opcode'. A value of 0 is used for the LFGuild packets. The next feature to be added
					to queryserv would use 1, etc.
				
					Obviously, any fields in the packet following the 'Type' will be unique to the particular type of packet. The
					'Generic' in the name of this ServerOP code relates to the four header fields.
				*/

				char From[64];
				pack->SetReadPosition(8);
				pack->ReadString(From);
				uint32 Type = pack->ReadUInt32();

				switch(Type)
				{
					default:
						_log(QUERYSERV__ERROR, "Received unhandled ServerOP_QueryServGeneric", Type);
						break;
				}
				break;
			}
			case ServerOP_QSSendQuery: {
				/* Process all packets here */
				database.GeneralQueryReceive(pack);  
				break;
			}
		}
	} 
	safe_delete(pack);
	return;
}
开发者ID:bwilliams1,项目名称:Server,代码行数:96,代码来源:worldserver.cpp

示例2: HandleMessage


//.........这里部分代码省略.........
	case ServerOP_Speech: {
		Server_Speech_Struct *SSS = (Server_Speech_Struct*)p.Data();
		std::string tmp1 = SSS->from;
		std::string tmp2 = SSS->to;
		database.AddSpeech(tmp1.c_str(), tmp2.c_str(), SSS->message, SSS->minstatus, SSS->guilddbid, SSS->type);
		break;
	}
	case ServerOP_QSPlayerLogTrades: {
		QSPlayerLogTrade_Struct *QS = (QSPlayerLogTrade_Struct*)p.Data();
		database.LogPlayerTrade(QS, QS->_detail_count);
		break;
	}
	case ServerOP_QSPlayerDropItem: {
		QSPlayerDropItem_Struct *QS = (QSPlayerDropItem_Struct *) p.Data();
		database.LogPlayerDropItem(QS);
		break;
	}
	case ServerOP_QSPlayerLogHandins: {
		QSPlayerLogHandin_Struct *QS = (QSPlayerLogHandin_Struct*)p.Data();
		database.LogPlayerHandin(QS, QS->_detail_count);
		break;
	}
	case ServerOP_QSPlayerLogNPCKills: {
		QSPlayerLogNPCKill_Struct *QS = (QSPlayerLogNPCKill_Struct*)p.Data();
		uint32 Members = (uint32)(p.Length() - sizeof(QSPlayerLogNPCKill_Struct));
		if (Members > 0) Members = Members / sizeof(QSPlayerLogNPCKillsPlayers_Struct);
		database.LogPlayerNPCKill(QS, Members);
		break;
	}
	case ServerOP_QSPlayerLogDeletes: {
		QSPlayerLogDelete_Struct *QS = (QSPlayerLogDelete_Struct*)p.Data();
		uint32 Items = QS->char_count;
		database.LogPlayerDelete(QS, Items);
		break;
	}
	case ServerOP_QSPlayerLogMoves: {
		QSPlayerLogMove_Struct *QS = (QSPlayerLogMove_Struct*)p.Data();
		uint32 Items = QS->char_count;
		database.LogPlayerMove(QS, Items);
		break;
	}
	case ServerOP_QSPlayerLogMerchantTransactions: {
		QSMerchantLogTransaction_Struct *QS = (QSMerchantLogTransaction_Struct*)p.Data();
		uint32 Items = QS->char_count + QS->merchant_count;
		database.LogMerchantTransaction(QS, Items);
		break;
	}
	case ServerOP_QueryServGeneric: {
		/*
		The purpose of ServerOP_QueryServerGeneric is so that we don't have to add code to world just to relay packets
		each time we add functionality to queryserv.

		A ServerOP_QueryServGeneric packet has the following format:

		uint32 SourceZoneID
		uint32 SourceInstanceID
		char OriginatingCharacterName[0]
		- Null terminated name of the character this packet came from. This could be just
		- an empty string if it has no meaning in the context of a particular packet.
		uint32 Type

		The 'Type' field is a 'sub-opcode'. A value of 0 is used for the LFGuild packets. The next feature to be added
		to queryserv would use 1, etc.

		Obviously, any fields in the packet following the 'Type' will be unique to the particular type of packet. The
		'Generic' in the name of this ServerOP code relates to the four header fields.
		*/

		auto from = p.GetCString(8);
		uint32 Type = p.GetUInt32(8 + from.length() + 1);

		switch (Type) {
		case QSG_LFGuild: {
			ServerPacket pack;
			pack.pBuffer = (uchar*)p.Data();
			pack.opcode = opcode;
			pack.size = (uint32)p.Length();
			lfguildmanager.HandlePacket(&pack);
			pack.pBuffer = nullptr;
			break;
		}
		default:
			Log(Logs::Detail, Logs::QS_Server, "Received unhandled ServerOP_QueryServGeneric", Type);
			break;
		}
		break;
	}
	case ServerOP_QSSendQuery: {
		/* Process all packets here */
		ServerPacket pack;
		pack.pBuffer = (uchar*)p.Data();
		pack.opcode = opcode;
		pack.size = (uint32)p.Length();

		database.GeneralQueryReceive(&pack);
		pack.pBuffer = nullptr;
		break;
	}
	}
}
开发者ID:N0ctrnl,项目名称:VAServer,代码行数:101,代码来源:worldserver.cpp


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