⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 handler_cw.cpp

📁 奇迹世界 部分源代码奇迹世界 部分源代码奇迹世界 部分源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
			resMsg.m_byCategory = CW_CHAT;
			resMsg.m_byProtocol = CW_CHAT_VILLAGE_BRD;
			memset(resMsg.m_szCharNameTo, 0, MAX_CHARNAME_LENGTH);
			_tcsncpy(resMsg.m_szCharNameTo, pUser->GetCharName().c_str(), MAX_CHARNAME_LENGTH);	// 鞍篮 皋矫瘤捞骨肺 弊措肺 汗荤
			resMsg.m_szCharNameTo[MAX_CHARNAME_LENGTH-1] = '\0';
			if(pRecvMsg->m_byMsgLength >= MSG_CW_CHAT_VILLAGE_SYN::_MAX_CHATMSG_SIZE)
			{
				MessageOut(eCRITICAL_LOG, "%s CW_CHAT_VILLAGE_SYN 辨捞檬苞(%u)", pUser->GetCharName().c_str(), pRecvMsg->m_byMsgLength);
				return;
			}
			memset( resMsg.m_pszChatMsg, 0, sizeof(char) * MSG_CW_CHAT_VILLAGE_BRD::_MAX_CHATMSG_SIZE );
			_tcsncpy( resMsg.m_pszChatMsg, pRecvMsg->m_pszChatMsg, pRecvMsg->m_byMsgLength );
			resMsg.m_pszChatMsg[pRecvMsg->m_byMsgLength] = '\0';

			resMsg.m_byMsgLength = pRecvMsg->m_byMsgLength;
//			if( !ViewPortManager::Instance()->SendViewPort( pUser, (BYTE*)&resMsg, resMsg.GetSize() ) )
			if( !pChannel->SendToViewPort( pUser, (BYTE*)&resMsg, resMsg.GetSize() ) )
			{
				// SendViewPort俊辑 肺弊 巢变促
				return;
			}
			TCHAR ptszCharName[MAX_CHARNAME_LENGTH]={0,};
			_stprintf( ptszCharName, "%s", pUser->GetCharName().c_str() );
			GAMELOG->WriteVillageChat( NULL, ptszCharName, WorldServer::Instance()->GetServerKey(), pUser->GetFieldCode(), resMsg.m_pszChatMsg );
			MessageOut( eFULL_LOG, "CW_CHAT_VILLAGE_SYN_B[%s][Guid:%u][C:%u][F:%u]:%s", pUser->GetCharName().c_str(), 
																						pUser->GetGUID(), 
																						pUser->GetChannelID(), 
																						pUser->GetFieldCode(), 
																						resMsg.m_pszChatMsg );
			return;
		}
		default:
		{
#ifdef _DEBUG
			assert( !"CHAT_BATTLE_SYN - Invalid User Stat" );
#else
			MessageOut( eCRITICAL_LOG, "[%s]CHAT_BATTLE_SYN Error - No User Status[%u]!", pUser->GetCharName().c_str(), pUser->GetStatus() );
#endif
			break;
		}
	}

	if( !pZone )
	{
		MessageOut( eCRITICAL_LOG, "[%s] CW_CHAT_BATTLE_SYN Error - No Zone[C:%u][ZT:%u][ZK::%u]", pUser->GetCharName().c_str(), 
																	pUser->GetChannelID(), pUser->GetStatus(), pUser->GetZoneKey() );
		return;
	}

	pZone->SendToAll( (BYTE*)&sendMsg, sendMsg.GetSize() );

	_stprintf( ptszCharName, "%s", pUser->GetCharName().c_str() );
	GAMELOG->WriteBattleZoneChat( NULL, ptszCharName, pZone->GetKey(), WorldServer::Instance()->GetServerKey(), pUser->GetFieldCode(), sendMsg.m_pszChatMsg );
	MessageOut( eFULL_LOG, "[%s][Guid:%u][ZT:%u][ZK:%u] BattleZone Chat: %s", pUser->GetCharName().c_str(), 
																				pUser->GetGUID(), 
																				pZone->GetZoneType(), 
																				pZone->GetKey(), 
																				sendMsg.m_pszChatMsg );
}

VOID Handler_CW::OnCW_CHAT_SHOUT_SYN( User *pUser, MSG_BASE *pMsg, WORD wSize )
{
	MSG_CW_CHAT_SHOUT_SYN	*pRecvMsg = (MSG_CW_CHAT_SHOUT_SYN*)pMsg;

	if(!pUser)
	{
		MessageOut(eCRITICAL_LOG,  "CW_CHAT_SHOUT_SYN 角菩(pUser == NULL)");
		return;
	}

	// 呈 绢蠢 悼匙 家加捞衬?
	Channel *pChannel = ChannelManager::Instance()->GetChannel( pUser->GetChannelID() );
	if(!pChannel)
	{
		// 家加等 付阑 绝绢档 坷幅
		MessageOut(eCRITICAL_LOG, "%s CW_CHAT_SHOUT_SYN 角菩[Channel %u][ZT:%u][ZK:%u]", pUser->GetCharName().c_str(), 
											pUser->GetChannelID(), pUser->GetStatus(), pUser->GetZoneKey() );
		return;
	}

	Zone *pZone = pChannel->FindVillage(pUser->GetZoneKey());
	if(!pZone)
	{
/*
		// 家加等 付阑 绝绢档 坷幅
		MessageOut(eCRITICAL_LOG, "%s CW_CHAT_SHOUT_SYN 角菩[ZT:%u][ZK:%u]", pUser->GetCharName().c_str(), 
																			pUser->GetStatus(), pUser->GetZoneKey() );
		return;
*/
		// 硅撇粮牢 版快俊档 寇摹扁绰 倾侩茄促
		// 捞 版快 清泼捞电 固记捞电 鞘靛 内靛甫 掘绢 绢恫 甘牢瘤 舅酒郴具 茄促
		if( !pUser->GetFieldCode() )
		{
			MessageOut( eCRITICAL_LOG, "[%s] SHOUT Error - No Village, No FieldCode[C:%u][ZT:%u]", pUser->GetCharName().c_str(), 
																									pUser->GetChannelID(), 
																									pUser->GetStatus() );
			return;
		}

		// 盲泼 皋矫瘤 菩哦 炼赋
		MSG_CW_CHAT_SHOUT_BRD	resMsg;

		resMsg.m_byCategory = CW_CHAT;
		resMsg.m_byProtocol = CW_CHAT_SHOUT_BRD;
		memset(resMsg.m_szCharName, 0, MAX_CHARNAME_LENGTH);
		_tcsncpy(resMsg.m_szCharName, pUser->GetCharName().c_str(), MAX_CHARNAME_LENGTH-1);	// 鞍篮 皋矫瘤捞骨肺 弊措肺 汗荤
		resMsg.m_szCharName[MAX_CHARNAME_LENGTH-1] = '\0';

		if(pRecvMsg->m_byMsgLength >= MSG_CW_CHAT_SHOUT_SYN::_MAX_CHATMSG_SIZE)
		{
			MessageOut(eCRITICAL_LOG, "%s CW_CHAT_SHOUT_SYN 辨捞檬苞(%u)", pUser->GetCharName().c_str(), pRecvMsg->m_byMsgLength);
			return;
		}

		memset(resMsg.m_pszChatMsg, 0, sizeof(char) * MSG_CW_CHAT_SHOUT_BRD::_MAX_CHATMSG_SIZE);
		_tcsncpy( resMsg.m_pszChatMsg, pRecvMsg->m_pszChatMsg, pRecvMsg->m_byMsgLength );
		resMsg.m_pszChatMsg[pRecvMsg->m_byMsgLength] = '\0';

		resMsg.m_byMsgLength = pRecvMsg->m_byMsgLength;

		TCHAR ptszCharName[MAX_CHARNAME_LENGTH]={0,};
		_stprintf( ptszCharName, "%s", pUser->GetCharName().c_str() );

		// 甘 辆幅甫 掘绢具 歹 奖霸 柳青 啊瓷..窍瘤父 老窜篮 捞措肺 柳青. 恐? 东户内靛聪鳖!!
		switch( pUser->GetFieldCode() ) 
		{
			// 骇飘穷捞唱 飘傅爸俊辑 积己茄 硅撇粮(具荐甸狼 剑, 瘤窍荐肺)篮 笛促 焊辰促
			case 10001:
			case 10002:
			{
				// 娟甸篮 骇飘穷/飘傅爸 葛滴俊 傈价茄促

				// 窍唱 筋绊
				if( !pChannel->SendToOneVillage( 10001, (BYTE*)&resMsg, resMsg.GetSize() ) )	// 鞘靛 内靛甫 流立 持绰 父青
				{
					MessageOut(eCRITICAL_LOG, "%s SHOUT 角菩 in Battle[ZT:%u][ZK:%u][F:%u]", pUser->GetCharName().c_str(), 
																						pUser->GetStatus(), pUser->GetZoneKey(), 
																						10001 );
					return;
				}
				MessageOut( eCRITICAL_LOG, "SHOUT_BATTLE[%s][C:%u][F:%u]:%s", pUser->GetCharName().c_str(), 
																					pUser->GetChannelID(), 
																					10001, 
																					resMsg.m_pszChatMsg );

				// 肚 金促
				if( !pChannel->SendToOneVillage( 10002, (BYTE*)&resMsg, resMsg.GetSize() ) )	// 鞘靛 内靛甫 流立 持绰 父青
				{
					MessageOut(eCRITICAL_LOG, "%s SHOUT 角菩 in Battle[ZT:%u][ZK:%u][F:%u]", pUser->GetCharName().c_str(), 
																						pUser->GetStatus(), pUser->GetZoneKey(), 
																						10002 );
					return;
				}
				MessageOut( eCRITICAL_LOG, "SHOUT_BATTLE[%s][C:%u][F:%u]:%s", pUser->GetCharName().c_str(), 
																					pUser->GetChannelID(), 
																					10002, 
																					resMsg.m_pszChatMsg );
				break;
			}
			// 俊炮饭牢俊辑 积己茄 仇篮 俊炮饭牢栏肺
			case 10003:
			{
				if( !pChannel->SendToOneVillage( 10003, (BYTE*)&resMsg, resMsg.GetSize() ) )	// 鞘靛 内靛甫 流立 持绰 父青
				{
					MessageOut(eCRITICAL_LOG, "%s SHOUT 角菩 in Battle[ZT:%u][ZK:%u][F:%u]", pUser->GetCharName().c_str(), 
																						pUser->GetStatus(), pUser->GetZoneKey(), 
																						pUser->GetFieldCode() );
					return;
				}
				MessageOut( eCRITICAL_LOG, "SHOUT_BATTLE[%s][C:%u][F:%u]:%s", pUser->GetCharName().c_str(), 
																					pUser->GetChannelID(), 
																					pUser->GetFieldCode(), 
																					resMsg.m_pszChatMsg );
				break;
			}
			// 泅犁 捞 捞寇狼 甘篮 绝促. 蝶扼辑 捞巴苞 促弗 蔼篮 了促 坷幅
			default:
			{
				MessageOut( eCRITICAL_LOG, "[%s] SHOUT Error - 肋给等 FieldCode[C:%u][ZT:%u][F:%u]", pUser->GetCharName().c_str(), 
																									pUser->GetChannelID(), 
																									pUser->GetStatus(), 
																									pUser->GetFieldCode() );
				return;
			}
		}
		// 瘤陛 郴啊 乐绰 甘俊档 舅妨绰 拎具瘤
		Zone *pBattleZone = pChannel->FindZone( pUser->GetStatus(), pUser->GetZoneKey() );

		if( !pBattleZone )
		{
			MessageOut(eCRITICAL_LOG, "%s SHOUT 角菩 in No Battle[ZT:%u][ZK:%u]", pUser->GetCharName().c_str(), 
																				pUser->GetStatus(), pUser->GetZoneKey() );
			return;
		}

		pBattleZone->SendToAll( (BYTE*)&resMsg, resMsg.GetSize() );

		return;
	}

	// 盲泼 皋矫瘤 菩哦 炼赋
	MSG_CW_CHAT_SHOUT_BRD	resMsg;

	resMsg.m_byCategory = CW_CHAT;
	resMsg.m_byProtocol = CW_CHAT_SHOUT_BRD;
	memset(resMsg.m_szCharName, 0, MAX_CHARNAME_LENGTH);
	_tcsncpy(resMsg.m_szCharName, pUser->GetCharName().c_str(), MAX_CHARNAME_LENGTH-1);	// 鞍篮 皋矫瘤捞骨肺 弊措肺 汗荤
	resMsg.m_szCharName[MAX_CHARNAME_LENGTH-1] = '\0';

	if(pRecvMsg->m_byMsgLength >= MSG_CW_CHAT_SHOUT_SYN::_MAX_CHATMSG_SIZE)
	{
		MessageOut(eCRITICAL_LOG, "%s CW_CHAT_SHOUT_SYN 辨捞檬苞(%u)", pUser->GetCharName().c_str(), pRecvMsg->m_byMsgLength);
		return;
	}

	memset(resMsg.m_pszChatMsg, 0, sizeof(char) * MSG_CW_CHAT_SHOUT_BRD::_MAX_CHATMSG_SIZE);
	_tcsncpy( resMsg.m_pszChatMsg, pRecvMsg->m_pszChatMsg, pRecvMsg->m_byMsgLength );
	resMsg.m_pszChatMsg[pRecvMsg->m_byMsgLength] = '\0';

	resMsg.m_byMsgLength = pRecvMsg->m_byMsgLength;
//	resMsg.m_byMsgLength = pRecvMsg->m_byMsgLength;
//	memset(resMsg.m_pszChatMsg, 0, MSG_CW_CHAT_SHOUT_SYN::_MAX_CHATMSG_SIZE);
//	memcpy(resMsg.m_pszChatMsg, pRecvMsg->m_pszChatMsg, resMsg.m_byMsgLength);

	// 瘤开俊 乐绰 葛电 蜡历甸俊霸 朝妨霖促!!
	pZone->SendToAll( (BYTE*)&resMsg, resMsg.GetSize() );

	TCHAR ptszCharName[MAX_CHARNAME_LENGTH]={0,};
	_stprintf( ptszCharName, "%s", pUser->GetCharName().c_str() );
	GAMELOG->WriteShoutChat( NULL, ptszCharName, WorldServer::Instance()->GetServerKey(), pUser->GetFieldCode(), resMsg.m_pszChatMsg );
	MessageOut( eCRITICAL_LOG, "CW_CHAT_SHOUT_SYN[%s][C:%u][ZK:%u]:%s", pUser->GetCharName().c_str(), 
																		pUser->GetChannelID(), 
																		pUser->GetZoneKey(), 
																		resMsg.m_pszChatMsg );
}

// GM 傍瘤
VOID Handler_CW::OnCW_GM_NOTICE_SYN( User *pUser, MSG_BASE *pMsg, WORD wSize )
{
	MSG_CW_GM_NOTICE_SYN *pRecvMsg = (MSG_CW_GM_NOTICE_SYN*)pMsg;

	if(!pUser)
	{
		MessageOut(eCRITICAL_LOG,  "OnCW_GM_NOTICE_SYN 角菩(pUser == NULL)");
		return;
	}

	if( pRecvMsg->dwNoticeLength >= MAX_NOTICE_LEN )
	{
		MessageOut(eCRITICAL_LOG,  "傍瘤 辨捞 檬苞(%d)", pRecvMsg->dwNoticeLength );
		MSG_CW_GM_NOTICE_NAK	nakMsg;
		nakMsg.dwResultCode = MSG_CW_GM_NOTICE_NAK::ERR_NOTICE_DEFAULT;
		pUser->Send( (BYTE*)&nakMsg, sizeof(MSG_CW_GM_NOTICE_NAK) );
		return;
	}

	// GM牢瘤 魄沥
	// 措惑 蜡历啊 GM牢瘤 八荤茄促
	GM_INFO		*pGMInfo;
	pGMInfo = GMList::Instance()->FindGM((const char*)pUser->GetCharName().c_str());

	if(!pGMInfo)
	{
		// 捞 版快绰 农贰欧捞唱 橇肺配妮 鸥涝 滚弊老 啊瓷己捞 乐促
		MessageOut(eCRITICAL_LOG, "GM 酒囱 蜡历啊 傍瘤 夸没!!!(%s)", pUser->GetCharName().c_str());
		return;
	}

	MSG_CW_NOTICE_BRD noticeMsg;
	noticeMsg.m_byCategory	= CW_CHAT;
	noticeMsg.m_byProtocol	= CW_NOTICE_BRD;

	memset(noticeMsg.szMsg, 0, sizeof(char) * MAX_NOTICE_LEN);
	_tcsncpy( noticeMsg.szMsg, pRecvMsg->szNotice, pRecvMsg->dwNoticeLength );
	noticeMsg.szMsg[pRecvMsg->dwNoticeLength] = '\0';

	noticeMsg.wLen = pRecvMsg->dwNoticeLength;
//	noticeMsg.wLen			= (WORD)pRecvMsg->dwNoticeLength + 1;
//	memset(noticeMsg.szMsg, 0, sizeof(noticeMsg.szMsg));
//	memcpy( noticeMsg.szMsg, pRecvMsg->szNotice, pRecvMsg->dwNoticeLength ); 

	// GM牢瘤 犬牢登搁 傍瘤 辆幅 备喊窍咯 朝妨霖促
	switch(pRecvMsg->byNoticeType)
	{
	case MSG_CW_GM_NOTICE_SYN::NOTICE_WORLD:
		{
			// 岿靛 傈眉 傍瘤-爱绊 乐绰 葛电 蜡历甸俊霸 朝赴促
			UserManager::Instance()->SendToAll( (BYTE*)&noticeMsg, noticeMsg.GetSize() );

			char szNotice[MAX_NOTICE_LEN + 1];
			ZeroMemory( szNotice, sizeof(szNotice) );
			strncpy( szNotice, noticeMsg.szMsg, pRecvMsg->dwNoticeLength );
			MessageOut(eCRITICAL_LOG,  "-----------------------------<< 傈眉傍瘤 >>-----------------------------" );
			MessageOut(eCRITICAL_LOG,  "%s(%u)", noticeMsg.szMsg, noticeMsg.wLen );
			MessageOut(eCRITICAL_LOG,  "------------------------------------------------------------------------" );
			break;
		}
		case MSG_CW_GM_NOTICE_SYN::NOTICE_CHANNEL:
		{
			// 秦寸 蜡历啊 立加茄 盲澄俊父 朝妨霖促
			Channel *pChannel = ChannelManager::Instance()->GetChannel( pUser->GetChannelID() );
			if(!pChannel)
			{
				// 荤侩磊狼 盲澄 ID啊 撇啡促. 摹疙利牢 滚弊
				MessageOut( eCRITICAL_LOG, "荤侩磊 %s狼 盲澄 %u啊 粮犁窍瘤 臼澜!! 傍瘤 角菩!!", pUser->GetCharName().c_str(), pUser->GetChannelID() );
				return;
			}
			// 付阑, 硅撇粮 葛滴 傍瘤
			pChannel->SendToAll( (BYTE*)&noticeMsg, noticeMsg.GetSize() );

			char szNotice[MAX_NOTICE_LEN + 1];
			ZeroMemory( szNotice, sizeof(szNotice) );
			strncpy( szNotice, noticeMsg.szMsg, pRecvMsg->dwNoticeLength );
			MessageOut(eCRITICAL_LOG,  "----------------------------<< %d盲澄 傍瘤 >>----------------------------", pUser->GetChannelID() );
			MessageOut(eCRITICAL_LOG,  "%s(%u)", noticeMsg.szMsg, noticeMsg.wLen );
			MessageOut(eCRITICAL_LOG,  "------------------------------------------------------------------------" );
			break;
		}
		case MSG_CW_GM_NOTICE_SYN::NOTICE_ZONE:
		{
			// 郴啊 立加茄 瘤开俊父 傍瘤
			Channel *pChannel = ChannelManager::Instance()->GetChannel( pUser->GetChannelID() );
			if(!pChannel)
			{
				// 荤侩磊狼 盲澄 ID啊 撇啡促. 摹疙利牢 滚弊
				MessageOut( eCRITICAL_LOG, "荤侩磊 %s狼 盲澄 %u啊 粮犁窍瘤 臼澜!! 瘤开傍瘤 角菩!!", pUser->GetCharName().c_str(), pUser->GetChannelID() );
				return;
			}
			Zone *pZone = NULL;
			switch(pUser->GetStatus())
			{
				case eZONETYPE_CHARSELECT:
				{
					//捞 版快俊绰 傍瘤 陛瘤 - 穿备 妇措肺? 郴 妇措肺-_-;(己泅芒)
					MessageOut( eCRITICAL_LOG, "某腐磐 急琶 芒俊辑 傍瘤 夸没(%s)", pUser->GetCharName().c_str() );
					MSG_CW_GM_NOTICE_NAK	nakMsg;
					nakMsg.dwResultCode = MSG_CW_GM_NOTICE_NAK::ERR_NOTICE_DEFAULT;
					pUser->Send( (BYTE*)&nakMsg, sizeof(MSG_CW_GM_NOTICE_NAK) );
					return;
					break;
				}
				case eZONETYPE_VILLAGE:
				{
					pZone = pChannel->FindVillage(pUser->GetZoneKey());
					if(!pZone)
					{
						// 荤侩磊狼 Zone ID啊 撇啡促. 摹疙利牢 滚弊
						MessageOut( eCRITICAL_LOG, "荤侩磊 %s狼 付阑 %u啊 粮犁窍瘤 臼澜!! 傍瘤 角菩!!", pUser->GetCharName().c_str(), 
																						pUser->GetZoneKey() );
						return;
					}
					pZone->SendToAll( (BYTE*)&noticeMsg, noticeMsg.GetSize() );

					char szNotice[MAX_NOTICE_LEN + 1];
					ZeroMemory( szNotice, sizeof(szNotice) );
					strncpy( szNotice, noticeMsg.szMsg, pRecvMsg->dwNoticeLength );
					MessageOut(eCRITICAL_LOG,  "---------------------------<< %u盲澄 %u付阑傍瘤 >>-------------------------", 
													pUser->GetChannelID(), 
													pUser->GetZoneKey() );
					MessageOut(eCRITICAL_LOG,  "%s(%u)", noticeMsg.szMsg, noticeMsg.wLen );
					MessageOut(eCRITICAL_LOG,  "------------------------------------------------------------------------" );
					break;
				}
				case eZONETYPE_LOBBY:
				{
					pZone = pChannel->FindLobby(pUser->GetZoneKey());
					if(!pZone)
					{
						// 荤侩磊狼 Zone ID啊 撇啡促. 摹疙利牢 滚弊
						MessageOut( eCRITICAL_LOG, "荤侩磊 %s狼 Lobby %u啊 粮犁窍瘤 臼澜!! 傍瘤 角菩!!", pUser->GetCharName().c_str(), 
																						pUser->GetZoneKey() );
						return;
					}
					pZone->SendToAll( (BYTE*)&noticeMsg, noticeMsg.GetSize() );

					char szNotice[MAX_NOTICE_LEN + 1];
					ZeroMemory( szNotice, sizeof(szNotice) );
					strncpy( szNotice, noticeMsg.szMsg, pRecvMsg->dwNoticeLength );
					MessageOut(eCRITICAL_LOG,  "---------------------------<< %u盲澄 %u Lobby傍瘤 >>-------------------------", 
													pUser->GetChannelID(), 
													pUser->GetZoneKey() );
					MessageOut(eCRITICAL_LOG,  "%s(%u)", noticeMsg.szMsg, noticeMsg.wLen );
					MessageOut(eCRITICAL_LOG,  "------------------------------------------------------------------------" );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -