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

📄 weatherregion.cpp

📁 网络游戏魔域的服务端与客户端完整源代码 包括详细的说明文档与开发日志
💻 CPP
字号:
// WeatherRegion.cpp: implementation of the CWeatherRegion class.
//
//////////////////////////////////////////////////////////////////////

#include "windows.h"
#include "GameMap.h"
#include "myheap.h"
#include "Weather.h"
#include "WeatherRegion.h"
#include "MapGroup.h"

MYHEAP_IMPLEMENTATION(CWeatherRegion,s_heap)
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CWeatherRegion::CWeatherRegion()
{
	m_pWeather	= NULL;
	m_pData		= NULL;
}

//////////////////////////////////////////////////////////////////////
CWeatherRegion::~CWeatherRegion()
{
	if(m_pWeather)
		delete m_pWeather;
}

//////////////////////////////////////////////////////////////////////
bool CWeatherRegion::Create(CRegionData* pData, PROCESS_ID idProcess)
{
	m_idProcess	= idProcess;
	CHECKF(pData);
	m_pData		= pData;

	m_pWeather	= new CWeather((IWeatherOwner*)this);
	CHECKF(m_pWeather);
	if(!m_pWeather->Create(pData->GetInt(REGIONDATA_DATA0), 
								abs(pData->GetInt(REGIONDATA_DATA1)), 
								pData->GetInt(REGIONDATA_DATA2), 
								pData->GetInt(REGIONDATA_DATA3),
								pData->GetInt(REGIONDATA_DATA1)>0 ? WEATHER_NORMAL_SPEED : WEATHER_FAST_SPEED ))
		return false;

	return true;
}

//////////////////////////////////////////////////////////////////////
void CWeatherRegion::BroadcastMsg(CNetMsg* pMsg, CUser* pExclude/*=NULL*/)
{
	bool	bSendNpcServer = true;
	CUserManager::Iterator pUser = UserManager()->NewEnum();
	while(pUser.Next())
	{
		if(pUser && (!pExclude || pUser->GetID() != pExclude->GetID()) && (!pUser->IsAgent() || bSendNpcServer))
		{
			if(CGameMap::IsInRegion(m_pData, pUser->GetMapID(), pUser->GetPosX(), pUser->GetPosY()))
				pUser->SendMsg(pMsg);

			if(pUser->IsAgent())
				bSendNpcServer = false;
		}
	}
}










⌨️ 快捷键说明

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