コード例 #1
0
bool CTO2GameServerShell::IsCapNumberOfBodies( )
{
	switch( GetGameType( ))
	{
		case eGameTypeCooperative:
		case eGameTypeSingle:
			return true;
		default:
			return false;
	}
}
コード例 #2
0
ファイル: GameLogic.cpp プロジェクト: mobinsheng/Fighting
void GameLogic::StartGame(MainScene* s)
{
	if (m_bInit)
	{
		return;
	}

	m_pMainScene = s;

	// 初始化英雄人物
	if(!HeroManager::GetInstance()->InitHero())
	{
		return; 
	}

	// 设置玩家的英雄的ID
	m_Player->SetHeroID(HeroManager::GetInstance()->GetCurrentHero()->GetHeroID());

	if (GetGameType() == SINGLE_GAME_TYPE)
	{
		m_Player->SetUserID("Player");
	}

	if (GetGameType() == CREATE_GAME_TYPE)
	{
		m_Player->SetIsCreator(true);
	}

	if (GetGameType() == JOIN_GAME_TYPE)
	{
		m_Player->SetIsCreator(false);
	}

	m_bInit = true;

	// 设置运行标志
	IsGameRunning(true);

	MagicManager::GetInstance()->ShowLamp();

}
コード例 #3
0
ファイル: GameLogic.cpp プロジェクト: mobinsheng/Fighting
/************************************************************************
*  程序退出
************************************************************************/
void GameLogic::ExitApp()
{
	if (GetGameType() == SINGLE_GAME_TYPE)
	{
	}
	else
	{
		StopGame();
		GetNetworkModule()->Logout();
		GetNetworkModule()->Close();
	}

	Director::getInstance()->end();
}
コード例 #4
0
ファイル: GameLogic.cpp プロジェクト: mobinsheng/Fighting
/************************************************************************
*  清理函数
************************************************************************/
void GameLogic::Clean()
{
	if (GetGameType() != SINGLE_GAME_TYPE && GetNetworkModule()->IsConnect())
	{
		m_pNetwork->StopGame();
	}
	
	// 魔法管理器清理
	MagicManager::GetInstance()->Clean();

	// 英雄管理器清理
	HeroManager::GetInstance()->Clean();

	// 游戏运行标志
	m_bIsGameRunning = false;

	m_bInit = false;

	// 游类型
	m_nGameType = INVALID_GAME_TYPE;

}
コード例 #5
0
ファイル: CascBuildCfg.cpp プロジェクト: BuloZB/CascLib
static int LoadCdnBuildFile(TCascStorage * hs, PQUERY_KEY pFileBlob)
{
    LPBYTE pbLineBegin = pFileBlob->pbData;
    LPBYTE pbVarBegin;
    LPBYTE pbLineEnd = NULL;

    while(pbLineBegin != NULL)
    {
        // Get the next line
        if(!GetNextFileLine(pFileBlob, &pbLineBegin, &pbLineEnd))
            break;

        // Game name
        pbVarBegin = CheckLineVariable(pbLineBegin, pbLineEnd, "build-product");
        if(pbVarBegin != NULL)
        {
            GetGameType(hs, pbVarBegin, pbLineEnd);
            continue;
        }

        // Game build number
        pbVarBegin = CheckLineVariable(pbLineBegin, pbLineEnd, "build-name");
        if(pbVarBegin != NULL)
        {
            GetBuildNumber(hs, pbVarBegin, pbLineEnd);
            continue;
        }

        // Root
        pbVarBegin = CheckLineVariable(pbLineBegin, pbLineEnd, "root");
        if(pbVarBegin != NULL)
        {
            LoadSingleBlob(&hs->RootKey, pbVarBegin, pbLineEnd);
            continue;
        }

        // Patch
        pbVarBegin = CheckLineVariable(pbLineBegin, pbLineEnd, "patch");
        if(pbVarBegin != NULL)
        {
            LoadSingleBlob(&hs->PatchKey, pbVarBegin, pbLineEnd);
            continue;
        }

        // Download
        pbVarBegin = CheckLineVariable(pbLineBegin, pbLineEnd, "download");
        if(pbVarBegin != NULL)
        {
            LoadSingleBlob(&hs->DownloadKey, pbVarBegin, pbLineEnd);
            continue;
        }

        // Install
        pbVarBegin = CheckLineVariable(pbLineBegin, pbLineEnd, "install");
        if(pbVarBegin != NULL)
        {
            LoadSingleBlob(&hs->InstallKey, pbVarBegin, pbLineEnd);
            continue;
        }

        // Encoding keys
        pbVarBegin = CheckLineVariable(pbLineBegin, pbLineEnd, "encoding");
        if(pbVarBegin != NULL)
        {
            hs->pEncodingKeys = LoadMultipleBlobs(pbVarBegin, pbLineEnd, &hs->EncodingKeys);
            if(hs->pEncodingKeys == NULL || hs->EncodingKeys != 2)
                return ERROR_BAD_FORMAT;

            hs->EncodingKey = hs->pEncodingKeys[0];
            hs->EncodingEKey = hs->pEncodingKeys[1];
            continue;
        }
    }

    // Check the encoding keys
    if(hs->pEncodingKeys == NULL || hs->EncodingKeys == 0)
        return ERROR_BAD_FORMAT;
    return ERROR_SUCCESS;
}
コード例 #6
0
ファイル: CascFiles.cpp プロジェクト: robpaveza/CascLib
static int LoadCdnBuildFile(TCascStorage * hs, void * pvListFile)
{
    const char * szLineBegin;
    const char * szVarBegin;
    const char * szLineEnd = NULL;
    int nError = ERROR_SUCCESS;

    for(;;)
    {
        // Get the next line
        if(!ListFile_GetNextLine(pvListFile, &szLineBegin, &szLineEnd))
            break;

        // Game name
        szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "build-product");
        if(szVarBegin != NULL)
        {
            GetGameType(hs, szVarBegin, szLineEnd);
            continue;
        }

        // Game build number
        szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "build-name");
        if(szVarBegin != NULL)
        {
            GetBuildNumber(hs, szVarBegin, szLineEnd);
            continue;
        }

        // Root
        szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "root");
        if(szVarBegin != NULL)
        {
            LoadSingleBlob(&hs->RootKey, szVarBegin, szLineEnd);
            continue;
        }

        // Patch
        szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "patch");
        if(szVarBegin != NULL)
        {
            LoadSingleBlob(&hs->PatchKey, szVarBegin, szLineEnd);
            continue;
        }

        // Download
        szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "download");
        if(szVarBegin != NULL)
        {
            LoadSingleBlob(&hs->DownloadKey, szVarBegin, szLineEnd);
            continue;
        }

        // Install
        szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "install");
        if(szVarBegin != NULL)
        {
            LoadSingleBlob(&hs->InstallKey, szVarBegin, szLineEnd);
            continue;
        }

        // Encoding keys
        szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "encoding");
        if(szVarBegin != NULL)
        {
            nError = LoadMultipleBlobs(&hs->EncodingKey, szVarBegin, szLineEnd, 2);
            continue;
        }
    }

    // Check the encoding keys
    if(hs->EncodingKey.pbData == NULL || hs->EncodingKey.cbData != MD5_HASH_SIZE * 2)
        return ERROR_BAD_FORMAT;
    return nError;
}
コード例 #7
0
void CTO2GameServerShell::Update(LTFLOAT timeElapsed)
{
	// Update the main server first
	CGameServerShell::Update(timeElapsed);

	m_VersionMgr.Update();

	if (!GetServerDir())
		return;

	//if we're hosting LANOnly game, don't publish the server
	if( m_ServerGameOptions.m_bLANOnly )
		return;

	// Are we still waiting?
	static std::string status;
	switch (GetServerDir()->GetCurStatus())
	{
		case IServerDirectory::eStatus_Processing : 
			status ="";
			break;
		case IServerDirectory::eStatus_Waiting : 
			if (status.empty())
				status = GetServerDir()->GetLastRequestResultString();
			break;
		case IServerDirectory::eStatus_Error : 
			{
				
				IServerDirectory::ERequest eErrorRequest = GetServerDir()->GetLastErrorRequest();
				status = GetServerDir()->GetLastRequestResultString();
				GetServerDir()->ProcessRequestList();
			}
			break;
	};



	// Publish the server if we've waited long enough since the last directory update
	uint32 nCurTime = (uint32)GetTickCount();
	if ((m_nLastPublishTime == 0) || 
		((nCurTime - m_nLastPublishTime) > k_nRepublishDelay))
	{
		status = "";
		m_nLastPublishTime = nCurTime;
		uint32 nMax = 0;
		g_pLTServer->GetMaxConnections(nMax);

		// If not run by a dedicated server, we need to add one connection
		// for the local host.
		if( !m_ServerGameOptions.m_bDedicated )
			nMax++;

		GetServerDir()->SetActivePeer(0);

		CAutoMessage cMsg;

		// Update the summary info
		cMsg.WriteString(GetHostName());
		GetServerDir()->SetActivePeerInfo(IServerDirectory::ePeerInfo_Name, *cMsg.Read());

		char fname[_MAX_FNAME] = "";
		_splitpath( GetCurLevel(), NULL, NULL, fname, NULL );

		// Update the summary info
		cMsg.WriteString(g_pVersionMgr->GetBuild());
		cMsg.WriteString( fname );
		cMsg.Writeuint8(GetNumPlayers());
		cMsg.Writeuint8(nMax);
		cMsg.Writebool(m_ServerGameOptions.m_bUsePassword);
		cMsg.Writeuint8((uint8)GetGameType());
		cMsg.WriteString( m_ServerGameOptions.m_sModName.c_str() );

		GetServerDir()->SetActivePeerInfo(IServerDirectory::ePeerInfo_Summary, *cMsg.Read());


		// Update the details
		ServerMissionSettings sms = g_pServerMissionMgr->GetServerSettings();
		cMsg.Writebool(sms.m_bUseSkills);
		cMsg.Writebool(sms.m_bFriendlyFire);
		cMsg.Writeuint8(sms.m_nMPDifficulty);
		cMsg.Writefloat(sms.m_fPlayerDiffFactor);

		CPlayerObj* pPlayer = GetFirstNetPlayer();
	    while (pPlayer)
		{
			//has player info
			cMsg.Writebool(true);
			cMsg.WriteString(pPlayer->GetNetUniqueName());
			cMsg.Writeuint16( Min( GetPlayerPing(pPlayer), ( uint32 )65535 ));
			pPlayer = GetNextNetPlayer();
		};

		//end of player info
		cMsg.Writebool(false);

	
		cMsg.Writeuint8(sms.m_nRunSpeed);
		cMsg.Writeuint8(sms.m_nScoreLimit);
		cMsg.Writeuint8(sms.m_nTimeLimit);

		GetServerDir()->SetActivePeerInfo(IServerDirectory::ePeerInfo_Details, *cMsg.Read());

		// Update the port
		char aHostAddr[16];
		uint16 nHostPort;
		g_pLTServer->GetTcpIpAddress(aHostAddr, sizeof(aHostAddr), nHostPort);
		cMsg.Writeuint16(nHostPort);
		GetServerDir()->SetActivePeerInfo(IServerDirectory::ePeerInfo_Port, *cMsg.Read());
		
		// Tell serverdir again about info, but in service specific manner.
		PeerInfo_Service_Titan peerInfo;
		peerInfo.m_sHostName = GetHostName( );
		peerInfo.m_sCurWorld = fname; 
		peerInfo.m_nCurNumPlayers = GetNumPlayers( );
		peerInfo.m_nMaxNumPlayers = nMax;
		peerInfo.m_bUsePassword = m_ServerGameOptions.m_bUsePassword;
		peerInfo.m_sGameType = GameTypeToString( GetGameType( ));
		peerInfo.m_nScoreLimit = sms.m_nScoreLimit;
		peerInfo.m_nTimeLimit = sms.m_nTimeLimit;

		PeerInfo_Service_Titan::Player player;
		CPlayerObj::PlayerObjList::const_iterator iter = CPlayerObj::GetPlayerObjList( ).begin( );
		while( iter != CPlayerObj::GetPlayerObjList( ).end( ))
		{
			CPlayerObj* pPlayerObj = *iter;

			player.m_sName = pPlayerObj->GetNetUniqueName( );
			player.m_nScore = pPlayerObj->GetPlayerScore()->GetScore( );

			float fPing;
			g_pLTServer->GetClientPing( pPlayerObj->GetClient( ), fPing );
			player.m_nPing = ( uint16 )( fPing + 0.5f );

			peerInfo.m_PlayerList.push_back( player );

			iter++;
		}


		cMsg.Writeuint32(( uint32 )&peerInfo );
		GetServerDir()->SetActivePeerInfo(IServerDirectory::ePeerInfo_Service, *cMsg.Read());

		// Tell the world about me...
		GetServerDir()->QueueRequest(IServerDirectory::eRequest_Publish_Server);
	}
}
コード例 #8
0
ファイル: B2BaseClass.cpp プロジェクト: bsmr-games/Blood2
DBOOL B2BaseClass::InitialUpdate()
{
	if (!g_pServerDE) return DFALSE;

	DBOOL bAllow = DTRUE;
	
	DBYTE nDifficulty = GetGameDifficulty();
	DBYTE nGameType = GetGameType();

	// See if this object is allowed at this skill level
	switch (nDifficulty)
	{
		case DIFFICULTY_EASY: 
			if ((m_dwOptFlags & OPT_FLAG_EASY) == 0)
				bAllow = DFALSE;
			break;
		case DIFFICULTY_MEDIUM: 
			if ((m_dwOptFlags & OPT_FLAG_MED) == 0)
				bAllow = DFALSE;
			break;
		case DIFFICULTY_HARD: 
			if ((m_dwOptFlags & OPT_FLAG_HARD) == 0)
				bAllow = DFALSE;
			break;
		case DIFFICULTY_INSANE: 
			if ((m_dwOptFlags & OPT_FLAG_INSANE) == 0)
				bAllow = DFALSE;
			break;
	}

	// See if this object is allowed for this game type
	switch (nGameType)
	{
		case GAMETYPE_CUSTOM: 
			if ((m_dwOptFlags & OPT_FLAG_CUSTOM) == 0)
				bAllow = DFALSE;
			break;
		case GAMETYPE_SINGLE: 
			if ((m_dwOptFlags & OPT_FLAG_SINGLE) == 0)
				bAllow = DFALSE;
			break;
		case GAMETYPE_ACTION: 
			if ((m_dwOptFlags & OPT_FLAG_ACTION) == 0)
				bAllow = DFALSE;
			break;
		case GAMETYPE_BLOODBATH: 
			if ((m_dwOptFlags & OPT_FLAG_BLOODBATH) == 0)
				bAllow = DFALSE;
			break;
		case GAMETYPE_CTF: 
			if ((m_dwOptFlags & OPT_FLAG_CTF) == 0)
				bAllow = DFALSE;
			break;
		case GAMETYPE_COOP: 
			if ((m_dwOptFlags & OPT_FLAG_CTF) == 0)
				bAllow = DFALSE;
			break;
	}

	DDWORD dwFlags = g_pServerDE->GetObjectFlags(m_hObject);
	g_pServerDE->SetObjectFlags(m_hObject, dwFlags | FLAG_DONTFOLLOWSTANDING);

	return bAllow;
}
コード例 #9
0
ファイル: ClientDlg.cpp プロジェクト: OLR-xray/OLR-3.0
HRESULT WINAPI Network_MessageHandler(	PVOID pvUserContext,
										 DWORD dwMessageType,
										 PVOID pMessageData )
{
	switch (dwMessageType)
	{
	case DPN_MSGID_ENUM_HOSTS_QUERY:
		{
		}break;
	case DPN_MSGID_RETURN_BUFFER:
		{
		}break;
	case DPN_MSGID_ENUM_HOSTS_RESPONSE:
		{
			PDPNMSG_ENUM_HOSTS_RESPONSE     pEnumHostsResponseMsg;
			const DPN_APPLICATION_DESC*     pDesc;
			// HOST_NODE*                      pHostNode = NULL;
			// WCHAR*                          pwszSession = NULL;

			pEnumHostsResponseMsg			= (PDPNMSG_ENUM_HOSTS_RESPONSE) pMessageData;
			pDesc							= pEnumHostsResponseMsg->pApplicationDescription;

			// Insert each host response if it isn't already present
			net_csEnumeration.Enter			();
			BOOL	bHostRegistered			= FALSE;
			for (u32 I=0; I<net_Hosts.size(); I++)
			{
				HOST_NODE&	N = net_Hosts	[I];
				if	( pDesc->guidInstance == N.dpAppDesc.guidInstance)
				{
					// This host is already in the list
					bHostRegistered = TRUE;
					break;
				}
			}

			if (!bHostRegistered) 
			{
				// This host session is not in the list then so insert it.
				HOST_NODE	NODE;
				ZeroMemory	(&NODE, sizeof(HOST_NODE));

				// Copy the Host Address
				HRESULT hr = pEnumHostsResponseMsg->pAddressSender->Duplicate(&NODE.pHostAddress );
				memcpy(&NODE.dpAppDesc,pDesc,sizeof(DPN_APPLICATION_DESC));

				// Null out all the pointers we aren't copying
				NODE.dpAppDesc.pwszSessionName					= NULL;
				NODE.dpAppDesc.pwszPassword						= NULL;
				NODE.dpAppDesc.pvReservedData					= NULL;
				NODE.dpAppDesc.dwReservedDataSize				= 0;
//				NODE.dpAppDesc.pvApplicationReservedData		= NULL;
//				NODE.dpAppDesc.dwApplicationReservedDataSize	= 0;

				char URLA[1024];
				DWORD Len;
				Len = 1024;
				hr = NODE.pHostAddress->GetURLA(URLA, &Len);

				ConvertAddressToName(URLA, NODE.dpServerName);
				///////////////////////////////////////////////////////////
				NODE.dpServerNumPlayers = NODE.dpAppDesc.dwCurrentPlayers-1;
				///////////////////////////////////////////////////////////
				NODE.dpServerGameType = GAME_UNKNOWN;
				if (NODE.dpAppDesc.pvApplicationReservedData != 0)
				{
					char GameType[1024];
					strcpy(GameType, (char*)NODE.dpAppDesc.pvApplicationReservedData);
					if (strstr(GameType, "/")) *(strstr(GameType, "/")) = 0;

					NODE.dpServerGameType = GetGameType(GameType);
				}
				///////////////////////////////////////////////////////////


				if( pDesc->pwszSessionName)
					WideCharToMultiByte(CP_ACP,0,pDesc->pwszSessionName,-1,NODE.dpSessionName,sizeof(NODE.dpSessionName),0,0);

				net_Hosts.push_back			(NODE);
			}
			net_csEnumeration.Leave			();
		}break;
	case DPN_MSGID_INDICATE_CONNECT:
		{
		}break;
	case DPN_MSGID_CREATE_PLAYER:
		{
		}break;
	case DPN_MSGID_CONNECT_COMPLETE :
		{
		}break;
	case DPN_MSGID_DESTROY_PLAYER:
		{
		}break;
	case DPN_MSGID_ASYNC_OP_COMPLETE:
		{
		}break;
	case DPN_MSGID_RECEIVE :
		{
		}break;
	case DPN_MSGID_SEND_COMPLETE :
		{
		}break;
	case DPN_MSGID_REMOVE_PLAYER_FROM_GROUP:
		{
		}break;
	case DPN_MSGID_TERMINATE_SESSION :
		{
		}break;
	default:
		{
			//tntConsole_UrgentPrint("Unknown Message.");
		}break;
	};
	return S_OK;
};
コード例 #10
0
ファイル: ClientDlg.cpp プロジェクト: OLR-xray/OLR-3.0
void CClientDlg::AddServerToList		(SBServer server)
{
	if (!server) return;
	net_csEnumeration.Enter			();

	HOST_NODE	NewNode, *NODE = &NewNode;
	ZeroMemory	(NODE, sizeof(HOST_NODE));
	sprintf(NODE->dpCharAddress, "%s:%d", SBServerGetPublicAddress(server), SBServerGetPublicQueryPort(server));
	sprintf(NODE->dpHostName, "%s", SBServerGetPublicAddress(server));
	//---------------------------------------------------------------------
	bool new_server = true;
	for (u32 I=0; I<net_Hosts.size(); I++)
	{
		HOST_NODE&	N = net_Hosts	[I];
		//		if	( !stricmp(N.dpCharAddress, NODE->dpCharAddress))
		if (N.dpServer == server)
		{
			new_server = false;
			NODE = &N;
			break;
		}
	};
	//---------------------------------------------------------------------
	sprintf(NODE->dpServerName, "%s", SBServerGetStringValue(server, qr2_registered_key_list[HOSTNAME_KEY], NODE->dpHostName));
	//  [5/20/2005]
	char dbgStr[1024];
	sprintf(dbgStr, "%s - %s\n", NODE->dpHostName, NODE->dpServerName);
	OutputDebugString(dbgStr);
	//  [5/20/2005]

	sprintf(NODE->dpSessionName, "%s", SBServerGetStringValue(server, qr2_registered_key_list[MAPNAME_KEY], "Unknown"));
	
	NODE->dpServerGameType = GetGameType((char*)SBServerGetStringValue(server, qr2_registered_key_list[GAMETYPE_NAME_KEY], "UNKNOWN"));
	string1024 xtmp;
	strcpy(xtmp, (char*)SBServerGetStringValue(server, qr2_registered_key_list[GAMETYPE_KEY], ""));

	NODE->dpServerGameType = GetGameType((byte)SBServerGetIntValue(server, qr2_registered_key_list[GAMETYPE_KEY], 0));

	NODE->dpPassword	= SBServerGetBoolValue(server, qr2_registered_key_list[PASSWORD_KEY], SBFalse);
	NODE->dpPing = SBServerGetPing(server);
	NODE->dpServerNumPlayers = SBServerGetIntValue(server, qr2_registered_key_list[NUMPLAYERS_KEY], 0);
	NODE->dpServerMaxPlayers = SBServerGetIntValue(server, qr2_registered_key_list[MAXPLAYERS_KEY], 32);
	NODE->dpDedicated	= SBServerGetBoolValue(server, qr2_registered_key_list[DEDICATED_KEY], SBFalse) == SBTrue;
	NODE->dpFFire		= SBServerGetBoolValue(server, qr2_registered_key_list[G_FRIENDLY_FIRE_KEY], SBFalse) == SBTrue;
	NODE->dpPort		= SBServerGetIntValue(server, qr2_registered_key_list[HOSTPORT_KEY], 0);
	NODE->dpServer = server;

	char PlayerName[1024] = "";
	sprintf(PlayerName, "%s", SBServerGetPlayerStringValue(server, 0, "player", "Unknown"));

	SBBool HasFullKeys = SBServerHasFullKeys(server);
	if (new_server)
		net_Hosts.push_back(*NODE);
	else
	{
 		int x=0;
		x=x;
	}

	if (m_bQuickRefresh)
	{
		m_pGameSpyUpdateList.EnableWindow(TRUE);
		m_pGameSpyRefreshList.EnableWindow(TRUE);
		m_bQuickRefresh = false;
	};
	net_csEnumeration.Leave			();
};
コード例 #11
0
ファイル: GameLogic.cpp プロジェクト: mobinsheng/Fighting
void GameLogic::LoopGame()
{
	// 如果游戏没有运行,则不进行处理
	if (!GameLogic::GetInstance()->IsGameRunning())
	{
		return;
	}

	// 无效游戏
	if (GetGameType() == INVALID_GAME_TYPE)
	{
		return;
	}

	static int nRandomMagicInterval = 0;
	//
	++nRandomMagicInterval;
	if (nRandomMagicInterval == 500)
	{
		int xPos = Util::GetRandomNum(100,700);
		int yPos = Util::GetRandomNum(xPos,100 +xPos);
		MagicManager::GetInstance()->RandomMagic(xPos,yPos);
		MagicManager::GetInstance()->RandomMoney(xPos/2+50,yPos/2-50);
		nRandomMagicInterval = 0;
	}

	if (nRandomMagicInterval % 100 == 0)
	{
		MagicManager::GetInstance()->TowerShoot();
	}


	MagicManager::GetInstance()->UpdateMagic();

	// 魔法与英雄人物之间的碰撞检测
	MagicManager::GetInstance()->MagicCollisionDetection();

	// 单机游戏需要更新
	if (GetGameType() == SINGLE_GAME_TYPE)
	{
		HeroManager::GetInstance()->UpdateHero();
		return;
	}

	if (HeroManager::GetInstance()->GetCurrentHero() == NULL || HeroManager::GetInstance()->GetCurrentEnemy() == NULL)
	{
		return;
	}

	// 下面是联网模式下的代码

	// 英雄移动、攻击,技能攻击这三种动作,在按键按下的时候发送数据包
	if (HeroManager::GetInstance()->GetCurrentHero()->GetHeroState() == ATTACK_STATE 
		|| HeroManager::GetInstance()->GetCurrentHero()->GetHeroState() == MAGICATTACK_STATE
		|| HeroManager::GetInstance()->GetCurrentHero()->GetHeroState() == MOVE_STATE
		)
	{
	}
	else
	{
		// 其他的时候由主动发送数据包
		HeroManager::GetInstance()->SendHeroStateToServer(HeroManager::GetInstance()->GetCurrentHero());
	}

	ControlPackage ctlPack;
	DataPackage dataPack;
	PackageHead head;

	// 读取包头部
	bool bOK = GameLogic::GetInstance()->GetNetworkModule()->ReadPackageHead(head,true);

	if (bOK == false)
	{
		return;
	}

	// 如果在游戏进行中收到控制包,那么只有两种情况:
	// 1、对方暂停了游戏
	// 2、对方继续运行游戏
	// 3、对方离开了游戏
	if (head.GetPackageType() == package_control)
	{
		GameLogic::GetInstance()->GetNetworkModule()->ReadControlPackBody(head,&ctlPack);

		// 对方暂停游戏
		if (ctlPack.GetPackageCode() == code_suspend_game)
		{
			GameLogic::GetInstance()->SetSuspendState(OPPONENT_SUSPEND);
		}

		// 对方继续执行游戏
		if (ctlPack.GetPackageCode() == code_continue_game)
		{
			GameLogic::GetInstance()->SetSuspendState(NOT_SUSPEND);
		}

		// 对方离开游戏
		if (ctlPack.GetPackageCode() == code_leave)
		{
			HeroManager::GetInstance()->GetCurrentEnemy()->SetHeroState(DEATH_STATE);
			GameLogic::GetInstance()->OpponentStopGame();
			return;
		}
	}
	else if (head.GetPackageType() == package_data)
	{
		GameLogic::GetInstance()->GetNetworkModule()->ReadDataPackBody(head,&dataPack);
	}
	else
	{
		return ;
	}

	if (dataPack.m_PackageHead.GetPackageType() == package_unknown)
	{
		return;
	}

	// 对方死亡
	if (dataPack.GetState() == DEATH_STATE )
	{
		HeroManager::GetInstance()->GetCurrentEnemy()->SetBloodValue(0);
		return;
	}

	// 对方移动
	if (dataPack.GetState() == MOVE_STATE)
	{
		HeroManager::GetInstance()->HeroMove(HeroManager::GetInstance()->GetCurrentEnemy()->GetHeroID(),(tagDirecton)dataPack.GetMoveDirection());
	}
	// 对方静止
	if (dataPack.GetState() == STATIC_STATE)
	{
		HeroManager::GetInstance()->GetCurrentEnemy()->StopAnimation();
	}

	// 对方攻击
	if (dataPack.GetState() == ATTACK_STATE)
	{
		if (HeroManager::GetInstance()->GetCurrentEnemy()->GetHeroState() != ATTACK_STATE)
		{
			HeroManager::GetInstance()->GetCurrentEnemy()->StopAnimation();
		}
		HeroManager::GetInstance()->GetCurrentEnemy()->Attack();
	}

	// 对方魔法攻击
	if (dataPack.GetState() == MAGICATTACK_STATE)
	{
		if (HeroManager::GetInstance()->GetCurrentEnemy()->GetHeroState() != MAGICATTACK_STATE)
		{
			HeroManager::GetInstance()->GetCurrentEnemy()->StopAnimation();
		}

		HeroManager::GetInstance()->GetCurrentEnemy()->MagicAttack();
	}
}