Esempio n. 1
1
void CPlayerManager::_PlayerEventNotify( const unsigned long &ulnID,
			const unsigned long &ulnEventType )
{
	CCriticalSection::Owner locker( m_csUsedClientList );

	switch( ulnEventType )
	{
	case enumClientConnectCreate:

		m_usedClientNode.push_back( ulnID );

		break;

	case enumClientConnectClose:

		PLAYER_MAP::iterator it;

		if ( m_thePlayers.end() != ( it = m_thePlayers.find( ulnID ) ) )
		{
			IPlayer *pPlayer = m_thePlayers[ulnID];

			ASSERT( pPlayer );

			pPlayer->Destroy( NULL );
		}

		m_usedClientNode.remove( ulnID );
		
		break;
	}
}
Esempio n. 2
0
		void TeleportTo(Vector3* position)
		{
			IPlayer* me = GetMe();
			if (!me) return;

			Player* playerMe = me->GetPlayer();
			if (!playerMe) return;

			IActor* actorMe = me->vfptr->GetActorInterface(me);
			if (!actorMe) return;

			IUE4Actor* ue4actor = playerMe->baseclass_0.m_target;
			if (!ue4actor) return;

			World* GameWorld = GetWorldObject();
			if (!GameWorld) return;

			//auto const logMsg = boost::str(boost::format("TeleportTo(%.2f,%.2f,%.2f)")
			//	% position->x % position->y % position->z);
			//Chat(logMsg);

			Rotation rot{ 0, 0, 0 };
			ue4actor->vfptr->GetRotation(ue4actor, &rot);
			GameWorld->vfptr->SendRespawnEvent(GameWorld, me->GetPlayer(), position, &rot);
			ue4actor->vfptr->LocalRespawn(ue4actor, position, &rot);
		}
Esempio n. 3
0
int CPlayerManager::Helper()
{
	while ( WAIT_OBJECT_0 != ::WaitForSingleObject( m_hQuitEvent, 0L ) )
	{
		/*
		 * Get data from role-database
		 */
		size_t dataLength = 0;
		const void *pData = m_pDBRoleClient->GetPackFromServer( dataLength );

		while( pData && dataLength )
		{
			KBlock *pBlock = ( KBlock * )( pData );

			UINT uID = pBlock->ulIdentity;

			if ( uID < m_theEnviroment.lnPlayerMaxCount )
			{
				IPlayer *pPlayer = m_thePlayers[uID];

				ASSERT( pPlayer );
				
				pPlayer->AppendData( pData );
			}

			pData = m_pDBRoleClient->GetPackFromServer( dataLength );
		}

		Sleep( 1 );
	}

	return 0;
}
Esempio n. 4
0
int main()
{
	srand((unsigned)time(NULL));

	int playerLen;
	int weaponsLen;
	GET_ARRAY_LEN(s_playerType, playerLen);
	GET_ARRAY_LEN(s_weapons, weaponsLen);

	// 假设,游戏中有十位玩家
	for (int i = 0; i < 10; i++) {
		// 获取随机玩家和武器
		int typeIndex = rand() % playerLen;
		int weaponIndex = rand() % weaponsLen;
		std::string type = s_playerType[typeIndex];
		std::string weapon = s_weapons[weaponIndex];

		// 获取玩家
		IPlayer *p = PlayerFactory::getPlayer(type);

		// 从武器库中随机分配武器
		p->assignWeapon(weapon);

		// 派玩家去执行任务
		p->mission();
	}

	getchar();

	return 0;
}
Esempio n. 5
0
void UseGuards( IPlayerFactory* f )
{
	IPlayer*  guard		=  f->CreatePlayer();

	guard->PrintPosition();

	delete guard;
}
Esempio n. 6
0
void CPlayerManager::CleanNetwork()
{
	if ( m_pDBRoleClient )
	{
		m_pDBRoleClient->Shutdown();

		m_pDBRoleClient->Cleanup();

		SAFE_RELEASE( m_pDBRoleClient );
	}

	if ( m_pPlayerServer )
	{
/*		CCriticalSection::Owner locker( m_csUsedClientList );
		
		LIST::iterator it;
		for ( it = m_usedClientNode.begin(); it != m_usedClientNode.end(); it ++ )
		{
			size_t index = *it;

			m_pPlayerServer->ShutdownClient( index );
		}
*/		
		m_pPlayerServer->CloseService();

		m_pPlayerServer->Cleanup();
		
		SAFE_RELEASE( m_pPlayerServer );
	}

	CCriticalSection::Owner lock( m_csSystemAction );

	/*
     * Repeat until stack is empty
	 */
	while ( !m_freeClientNode.empty() )
	{
		m_freeClientNode.pop();
	}

	CCriticalSection::Owner locker( m_csUsedClientList );

	m_usedClientNode.erase( m_usedClientNode.begin(), m_usedClientNode.end() );

	PLAYER_MAP::iterator it;
	for ( it = m_thePlayers.begin(); it != m_thePlayers.end(); it ++ )
	{
		IPlayer *pPlayer = ( IPlayer * )( ( *it ).second );

		ASSERT( pPlayer );

		pPlayer->Destroy( NULL );

		SAFE_DELETE( pPlayer );
	}

	m_thePlayers.erase( m_thePlayers.begin(), m_thePlayers.end() );
}
Esempio n. 7
0
bool Aimbot::IsValidEnemy( int entityNum )
{
	IPlayer * ent = ImportExport::Entities->GetPlayer (entityNum);
	if(ent != nullptr && ImportExport::User != nullptr && ent->IsValid())
	{
		return ent->IsEnemyOf( ImportExport::User ) && ent->Health() > 0 && ent->Weapon().Id() > 0;
	}
	return false;
}
Esempio n. 8
0
JNIEXPORT void android_media_omxmediaplayer_start(JNIEnv *env, jobject thiz)
{
	PPLOGI("android_media_omxmediaplayer_start()");
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		jniThrowException(env, "java/lang/IllegalStateException", NULL);
		return;
	}

	mp->start();
}
Esempio n. 9
0
JNIEXPORT jboolean android_media_omxmediaplayer_isLooping(JNIEnv *env, jobject thiz)
{
	PPLOGD("isLooping");
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		jniThrowException(env, "java/lang/IllegalStateException", NULL);
		return false;
	}

	return mp->isLooping();
}
Esempio n. 10
0
bool CVisualisation::Create(int x, int y, int w, int h)
{
  m_pInfo = new VIS_PROPS;
  #ifdef HAS_DX
  m_pInfo->device     = g_Windowing.Get3DDevice();
#else
  m_pInfo->device     = NULL;
#endif
  m_pInfo->x = x;
  m_pInfo->y = y;
  m_pInfo->width = w;
  m_pInfo->height = h;
  m_pInfo->pixelRatio = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].fPixelRatio;

  m_pInfo->name = strdup(Name().c_str());
  m_pInfo->presets = strdup(CSpecialProtocol::TranslatePath(Path()).c_str());
  m_pInfo->profile = strdup(CSpecialProtocol::TranslatePath(Profile()).c_str());
  m_pInfo->submodule = NULL;

  if (CAddonDll<DllVisualisation, Visualisation, VIS_PROPS>::Create() == ADDON_STATUS_OK)
  {
    // Start the visualisation
    CStdString strFile = URIUtils::GetFileName(g_application.CurrentFile());
    CLog::Log(LOGDEBUG, "Visualisation::Start()\n");
    try
    {
      m_pStruct->Start(m_iChannels, m_iSamplesPerSec, m_iBitsPerSample, strFile);
    }
    catch (std::exception e)
    {
      HandleException(e, "m_pStruct->Start() (CVisualisation::Create)");
      return false;
    }

    GetPresets();

    if (GetSubModules())
      m_pInfo->submodule = strdup(CSpecialProtocol::TranslatePath(m_submodules.front()).c_str());
    else
      m_pInfo->submodule = NULL;

    CreateBuffers();

    {
      CSingleLock lock(*g_application.getPlayerLock());
      IPlayer *player = g_application.getPlayer();
      if (player)
        player->RegisterAudioCallback(this);
    }

    return true;
  }
  return false;
}
Esempio n. 11
0
JNIEXPORT void JNICALL android_media_omxmediaplayer_prepareAsync
  (JNIEnv *env, jobject thiz)
{
	PPLOGI("OMXPlayer_prepareAsync");
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		jniThrowException(env, "java/lang/IllegalStateException", NULL);
		return;
	}

	mp->prepareAsync();
}
Esempio n. 12
0
JNIEXPORT void JNICALL android_media_omxmediaplayer_setVideoSurface
  (JNIEnv *env, jobject thiz, jobject surface)
{
	PPLOGI("OMXPlayer_setVideoSurface() %p", surface);
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		jniThrowException(env, "java/lang/IllegalStateException", NULL);
		return;
	}

	mp->setVideoSurface((void*)surface);
}
Esempio n. 13
0
JNIEXPORT jboolean android_media_omxmediaplayer_isPlaying(JNIEnv *env, jobject thiz)
{
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		jniThrowException(env, "java/lang/IllegalStateException", NULL);
		return false;
	}

	const jboolean is_playing = mp->isPlaying();

	PPLOGD("isPlaying: %d", is_playing);
	return is_playing;
}
Esempio n. 14
0
void CVisualisation::Stop()
{
  {
    CSingleLock lock(*g_application.getPlayerLock());
    IPlayer *player = g_application.getPlayer();
    if (player)
      player->UnRegisterAudioCallback();
  }

  if (Initialized())
  {
    CAddonDll<DllVisualisation, Visualisation, VIS_PROPS>::Stop();
  }
}
Esempio n. 15
0
/* Returns the IPlayer that matches the IService [s]; overwize returns 0 */
IPlayer *		RoomManager::operator()(IService * s) const
{

	std::deque<IPlayer *> players = this->hall_->getAllPlayers();

	for (std::deque<IPlayer *>::const_iterator it = players.begin() ;
		it != players.end() ; ++it)
	{
		IPlayer *tmp = *it;

		if (tmp && tmp->getService() == s)
			return tmp;
	}
	return 0;
}
Esempio n. 16
0
/*
 * Class:     com_gotye_meetsdk_player_OMXPlayer
 * Method:    getVideoHeight
 * Signature: ()I
 */
JNIEXPORT jint JNICALL android_media_omxmediaplayer_getVideoHeight
  (JNIEnv *env, jobject thiz)
{
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		PPLOGE("player is null, getVideoHeight failed");
		return 0;
	}
	int h;
	if (0 != mp->getVideoHeight(&h)) {
		PPLOGE("getVideoHeight failed");
		h = 0;
	}
	PPLOGI("getVideoHeight: %d", h);
	return h;
}
Esempio n. 17
0
//JNIEXPORT jint JNICALL Java_com_gotye_meetsdk_player_OMXPlayer_getVideoWidth
JNIEXPORT jint JNICALL android_media_omxmediaplayer_getVideoWidth
  (JNIEnv *env, jobject thiz)
{
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		PPLOGE("player is null, getVideoWidth failed");
		return 0;
	}
	int w;
	if (0 != mp->getVideoWidth(&w)) {
		PPLOGE("getVideoWidth failed");
		w = 0;
	}
	PPLOGI("getVideoWidth: %d", w);
	return w;
}
Esempio n. 18
0
Arbiter::Arbiter(IPlayer& player,
	std::vector<Call> const & callsView,
	Play::Tricks const & tricksView) :
	player(player), callsView(callsView), tricksView(tricksView)
{
	player.connectGameState(hand.getCardsView(), callsView, tricksView);
}
Esempio n. 19
0
JNIEXPORT jint JNICALL android_media_omxmediaplayer_getDuration
	(JNIEnv *env, jobject thiz)
{
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		PPLOGE("player is null, getDuration failed");
		return 0;
	}
	int msec;
	if (0 != mp->getDuration(&msec)) {
		PPLOGE("getDuration failed");
		msec = 0;
	}
	PPLOGI("getDuration: %d", msec);
	return msec;
}
Esempio n. 20
0
bool AutoFire::AimingAtTarget()
{
	IPlayer * user = ImportExport::User;
	if(ImportExport::AimBot->CurrentTarget() != nullptr)
	{
		idVec3 cmins = mins;
		idVec3 cmaxs = maxs;
		float zoffset = ImportExport::AimBot->TargetAimpoint().z;
		if (zoffset != 0.0f)
		{
			if (zoffset > 0.0f) 
			{
				cmaxs.z -= zoffset;
				cmins.z = -cmaxs.z;
			}
			else
			{
				cmins.z -= zoffset;
				cmaxs.z = -cmins.z;
			}
		}
		idVec3 targOrg = ImportExport::AimBot->TargetOrigin();
		idVec3 hit;
		if(CheckLineBox( targOrg + cmins, targOrg + cmaxs,
			user->EyePosition(), user->EyePosition() + (user->ViewAngles().ToMat3()[ 0 ] * user->DistanceTo( targOrg ) * 1.5f), hit))
		{
			int hitEnt = -1;
			return (user->CanSee(hit, user->Id(), &hitEnt) || hitEnt == ImportExport::AimBot->CurrentTarget()->Id());
		}
	}
	return false;
}
Esempio n. 21
0
void	GameplayEngine::treatPlayersCommands(std::queue<ICommand *>	& cmds)
{
	for (std::deque<IPlayer *>::iterator it = this->players_.begin() ;
				it != this->players_.end() ; ++it)
		{
			IPlayer *fetch = *it;

			ICommand *tmp = dynamic_cast<IClientService *>(fetch->getService())->Zpull();

			if (tmp && tmp->getType() == CommandType::MOVE)
			{
				DEBUG << "MOVE PLAYER" << std::endl;
			}
			else if (tmp && tmp->getType() == CommandType::FIRE)
			{
				DEBUG << "FIRE IN DA F****N HOLE" << std::endl;
			}
		}
}
Esempio n. 22
0
/*
 * Class:     com_gotye_meetsdk_player_OMXPlayer
 * Method:    _setDataSource
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL android_media_omxmediaplayer_setDataSource
  (JNIEnv *env, jobject thiz, jstring path)
{
	PPLOGI("OMXPlayer_setDataSource()");
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		jniThrowException(env, "java/lang/IllegalStateException", NULL);
		return;
	}

	const char *pathStr = env->GetStringUTFChars(path, NULL);
	if (pathStr == NULL) {  // Out of memory
		jniThrowException(env, "java/lang/RuntimeException", "GetStringUTFChars: Out of memory");
		return;
	}
	mp->setDataSource(pathStr);

	// Make sure that local ref is released before a potential exception
	env->ReleaseStringUTFChars(path, pathStr);
}
Esempio n. 23
0
void BusinessAction::doAction(bool bLogger)
{
	IPlayer* player = this->getPlayer();
	if (player == nullptr)
	{
		delete this;
		return;
	}

	if (bLogger)
	{
		player->runActionWithRecord(this);
	}
	else
	{
		player->runAction(this);
	}

	delete this;
}
Esempio n. 24
0
int CPlayerManager::Run()
{
	while ( WAIT_OBJECT_0 != ::WaitForSingleObject( m_hQuitEvent, 0L ) )
	{

		CCriticalSection::Owner locker( m_csUsedClientList );

		LIST::iterator it;
		for ( it = m_usedClientNode.begin(); it != m_usedClientNode.end(); it ++ )
		{
			size_t index = *it;

			/*
			 * Get data from player
			 */
			size_t datalength = 0;

			const void *pData = m_pPlayerServer->GetPackFromClient( index, datalength );

			while ( pData && datalength )
			{
				AnalyzePlayerRequire( index, pData, datalength );

				pData = m_pPlayerServer->GetPackFromClient( index, datalength );
			}

			/*
			 * Execute work
			 */
			IPlayer *pPlayer = m_thePlayers[index];

			ASSERT( pPlayer );

			pPlayer->Run();
		}

		Sleep( 1 );
	}

	return 0;
}
Esempio n. 25
0
// callled when new OMXMediaPlayer
JNIEXPORT void JNICALL android_media_omxmediaplayer_setup
  (JNIEnv *env, jobject thiz, jobject weak_this)
{
	PPLOGI("native_setup");

	IPlayer* mp = getOMXPlayerFun((void*)gPlatformInfo);
	if (mp == NULL) {
		jniThrowException(env, "java/lang/RuntimeException", "Create IPlayer failed.");
		return;
	}

	// create new listener and give it to MediaPlayer
	OMXMediaPlayerListener * player_listener = new OMXMediaPlayerListener(env, thiz, weak_this);
	//IPlayer takes responsibility to release listener.
	mp->setListener(player_listener);

	env->SetLongField(thiz, fields.listener, (int64_t)player_listener);

	// Stow our new C++ MediaPlayer in an opaque field in the Java object.
	setOMXMediaPlayer(env, thiz, mp);
	//check if it needs to release old mediaplayer.
}
Esempio n. 26
0
int main() {
	IWindow* w;
	ISurface* s;
	ILocalDeviceManager* dm;
	IPlayer* player;
	IPlayer* img;

#if HAVE_COMPSUPPORT
	IComponentManager* cm = IComponentManager::getCMInstance();
	dm = ((LocalDeviceManagerCreator*)(cm->getObject("LocalDeviceManager")))();
#else
	dm = LocalDeviceManager::getInstance();
#endif

	dm->createDevice("systemScreen(0)");
#if HAVE_COMPSUPPORT
	w = ((WindowCreator*)(cm->getObject("Window")))(10, 10, 100, 100);
#else
	w = new DFBWindow(10, 10, 100, 100);
#endif

	w->setCaps(w->getCap("ALPHACHANNEL"));
	w->draw();
	w->show();

	player = new Player("teste");
	img = new ImagePlayer("/root/bg_initializing.png");
	s = img->getSurface();
	w->renderFrom(s);

	//TODO: tests
	cout << "Player test has shown image. press enter to continue" << endl;
	getchar();
	dm->clearWidgetPools();
	cout << "Player test has released widgets. press enter to continue" << endl;
	getchar();

	return 0;
}
Esempio n. 27
0
  void WarpMapEventAction::VisitPlayer (IPlayer& visitable)
  {
    switch (GetContextType ())
    {
      case MapEventActionType::Enter:

        GetArgs ().AbortEvents (true);
        visitable.Warp (mapWorldID_, mapPoint_);

        break;

      default: break;
    }
  }
Esempio n. 28
0
		void TeleportForward(float distance)
		{
			IPlayer* me = GetMe();
			if (!me) return;

			Player* playerMe = me->GetPlayer();
			if (!playerMe) return;

			IActor* actorMe = me->vfptr->GetActorInterface(me);
			if (!actorMe) return;

			IUE4Actor* ue4actor = playerMe->baseclass_0.m_target;
			if (!ue4actor) return;

			Vector3 position;
			Rotation rotation;
			ue4actor->vfptr->GetPosition(ue4actor, &position);
			ue4actor->vfptr->GetRotation(ue4actor, &rotation);

			// Their angles go from [0, 180) and [-0, -180), convert to [0, 360).
			float facing = rotation.yaw;
			if (facing < 0.0f)
			{
				facing += 360.0f;
			}

			facing = facing * static_cast<float>(M_PI) / 180.0f;
			float const x = std::cos(facing);
			float const y = std::sin(facing);

			// TODO: z

			position.x += distance * x;
			position.y += distance * y;

			TeleportTo(&position);
		}
Esempio n. 29
0
JNIEXPORT void android_media_omxmediaplayer_seekTo(JNIEnv *env, jobject thiz, int msec)
{
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		jniThrowException(env, "java/lang/IllegalStateException", NULL);
		return;
	}

	int playTime = 0;
	mp->getCurrentPosition(&playTime);
	int mediaDiff = msec - playTime; // msec
	mediaDiff = mediaDiff>0 ? mediaDiff : -mediaDiff;

	if(mediaDiff > 2000) // 2sec
	{
		PPLOGD("jni seekTo: %d(msec)", msec);
		mp->seekTo(msec);
		PPLOGD("jni seekTo: %d(msec) end", msec);
	}
	else
	{
		mp->notify(MEDIA_SEEK_COMPLETE, 0, 0);
	}
}
Esempio n. 30
0
int main(int argc, char* argv[])
{
    int nResult = false;
    int nRetCode = false;

    int i = 0;
    printf("%s\n", argv[0]);
    srand( (unsigned)time( NULL ) );

    memset(g_szGMCommandList, 0, MAX_GM_COUNT * MAX_GM_SIZE);
    nRetCode = ProcessArg(argc, argv);
    if (!nRetCode)
    {
        Help();
        goto Exit0;
    }


    //g_thePlayers.empty();

    for (i = g_AccoutIDMin; i <= g_AccoutIDMax; i++)
    {
        char szAccountName[0x100];

        sprintf(szAccountName, "Robot%04d", i);

        printf("Create %s ... ", szAccountName);

        IPlayer *pPlayer = new CPlayer(
            g_szServerIP, g_nServerPort,
            szAccountName
        );
        //Sleep(300);
        if (!pPlayer)
        {
            printf("fail!\n");
            continue;
        }
        printf("ok!\n");

        // flying add these, make the robot at the specified position
        if (g_nFlgSetPos)
            pPlayer->SetPos(g_ptBirthPos.x, g_ptBirthPos.y);
        // flying add these, make the robot auto attack to the NPCs
        if (g_nFlgSetAttack)
            pPlayer->SetAttack();
        pPlayer->SetSilence(g_nFlgSetSilence);
        pPlayer->SetChatTimer(g_nFlgChatTimer);
        pPlayer->ConnectToGateway();

        g_thePlayers.push_back( pPlayer );
    }

    printf("Press \'Q\' to End Program\n");

    while (true)
    {
        int ch = 0;

        PLAYER_LIST::iterator it;
        for ( it = g_thePlayers.begin(); it != g_thePlayers.end(); it ++ )
        {
            while (true)
            {
                if (!kbhit())
                    break;

                ch = getch();

                ch = toupper(ch);

                if ((ch == 'Q') || (ch == 27)) // ESC
                    break;
            }

            if ((ch == 'Q') || (ch == 27)) // ESC
                break;

            //Sleep(rand() % 40);

            CPlayer *pPlayer = (CPlayer *)(*it);

            if (pPlayer == NULL)
            {
                Sleep(100);
                continue;
            }

            if ((pPlayer->GetStatus()) != CPlayer::enumExitGame)
                continue;

            OnlineGameLib::Win32::_tstring sAccountName;

            pPlayer->GetAccountName(sAccountName);

            delete pPlayer;
            pPlayer = NULL;
            *it = NULL;
            printf("Destory %s ... ok!\n", sAccountName.c_str());

            if (g_nAddRoleFlag || g_nDeleteRoleFlag)
                continue;

            printf("ReCreate %s ... ", sAccountName.c_str());

            pPlayer = new CPlayer(
                g_szServerIP, g_nServerPort,
                sAccountName.c_str()
            );
            Sleep(300);
            if (!pPlayer)
            {
                printf("fail!\n");
                continue;
            }
            printf("ok!\n");

            pPlayer->ConnectToGateway();

            *it = pPlayer;
        }

        if ((ch == 'Q') || (ch == 27)) // ESC
            break;

        Sleep(rand() % 1000);
    }

    {
        PLAYER_LIST::iterator it;
        for ( it = g_thePlayers.begin(); it != g_thePlayers.end(); it ++ )
        {
            IPlayer *pPlayer = ( *it );

            if ( pPlayer )
            {
                delete pPlayer;
            }
        }
    }

    nResult = true;

Exit0:
    return nResult;
}