void PlayerFor(const VideoMetadata *item) { if (item) { QString play_command = item->GetPlayCommand(); QString filename; if (item->IsHostSet()) filename = generate_file_url("Videos", item->GetHost(), item->GetFilename()); else filename = item->GetFilename(); if (play_command.length()) { AddPlayer(play_command, filename, item->GetPlot(), item->GetTitle(), item->GetSubtitle(), item->GetDirector(), item->GetSeason(), item->GetEpisode(), item->GetInetRef(), item->GetLength(), QString::number(item->GetYear()), QString::number(item->GetID())); } else { PlayerFor(filename, item); } } }
uint cGameWorld::ProcMsg( const sMsg& msg ) { switch( msg.m_type ) { case msgFindContainingCell: return FindContainingCell( msg.m_pt ); case msgAddPlayer: AddPlayer( msg.m_i[0] ); return 0; case msgRemovePlayer: RemovePlayer( msg.m_i[0] ); return 0; case msgAddEnt: NotifyAdd( (cGameEnt*)MsgDaemon()->Get( msg.m_i[0] )); return 0; case msgRemoveEnt: NotifyRemove( (cGameEnt*)MsgDaemon()->Get( msg.m_i[0] )); return 0; default: DP0("Bad Message got to cGameWorld\n"); return -1; } }
BOOL RecoverManager::Init() { __ENTER_FUNCTION m_Lock.Lock(); for(uint i=0;i<MAX_POOL_SIZE;i++) { GamePlayer* pPlayer = g_pPlayerPool->GetPlayer(i); if(pPlayer->GetShareMemStatus()) { g_pPlayerPool->NewPlayer(i); AddPlayer(pPlayer); } } m_Lock.Unlock(); return TRUE; __LEAVE_FUNCTION m_Lock.Unlock(); return FALSE; }
LOCAL void ICACHE_FLASH_ATTR at_tcpserver_listen(void *arg) { struct espconn *pespconn = (struct espconn *)arg; uint8_t i; printf("get tcpClient:\r\n"); for( i = 0; i < MAX_CONNS; i++ ) { if( connections[i].pespconn == 0 ) { break; } } if( i == MAX_CONNS ) { return; } connections[i].pespconn = pespconn; connections[i].cansend = 1; connections[i].id = i; pespconn->reverse = (void*)&connections[i]; espconn_regist_recvcb(pespconn, at_tcpclient_recv); espconn_regist_reconcb(pespconn, at_tcpserver_recon_cb); espconn_regist_disconcb(pespconn, at_tcpserver_discon_cb); espconn_regist_sentcb(pespconn, at_tcpclient_sent_cb); uart0_sendStr("Link\r\n"); AddPlayer( i ); }
void C4Team::RecheckPlayers() { // check all players within the team for (int32_t i=0; i<iPlayerCount; ++i) { bool fIsValid = false; int32_t id; C4PlayerInfo *pInfo; if ((id = piPlayers[i])) if ((pInfo = Game.PlayerInfos.GetPlayerInfoByID(id))) if (pInfo->GetTeam() == GetID()) if (pInfo->IsUsingTeam()) fIsValid = true; // removal will decrease iPlayerCount, which will abort the loop earlier if (!fIsValid) RemoveIndexedPlayer(i--); } // now check for any new players in the team int32_t id = 0; C4PlayerInfo *pInfo; while ((pInfo = Game.PlayerInfos.GetNextPlayerInfoByID(id))) { id = pInfo->GetID(); if (pInfo->GetTeam() == GetID()) if (pInfo->IsUsingTeam()) if (!IsPlayerIDInTeam(id)) AddPlayer(*pInfo, false); } }
bool CPlayerManager::ProcessIsAlreadyLogin(unsigned int nUserID ,unsigned nSessionID ) { // is active player CPlayer* pPlayer = NULL ; MAP_SESSIONID_PLAYERS::iterator iter_ma = m_vAllActivePlayers.begin() ; for ( ; iter_ma != m_vAllActivePlayers.end(); ++iter_ma ) { pPlayer = iter_ma->second ; if ( !pPlayer ) { CLogMgr::SharedLogMgr()->ErrorLog("Why empty active player here ?") ; continue; } if ( pPlayer->GetUserUID() == nUserID ) { pPlayer->OnAnotherClientLoginThisPeer(nSessionID) ; m_vAllActivePlayers.erase(iter_ma) ; AddPlayer(pPlayer) ; CLogMgr::SharedLogMgr()->PrintLog("other decivec login"); return true ; } } return false ; }
void Transporter::AddPassenger( Object *o ){ if( o->IsPlayer() ){ AddPlayer( static_cast< Player* >( o ) ); return; } passengers[ o->GetGUID() ] = o; }
void CasterTrunkContainer::AddPlayer(AvatarSrv* pPlayer) { if(!pPlayer) return; int32 nBranchID = m_bByNode ? pPlayer->GetNodeSrvID() : pPlayer->GetGateSrvID(); AddPlayer( pPlayer, nBranchID); }
void CAIThread::OnPlayerUpdateActive( const BYTE nPlayer ) { ASSERT( m_pBotDoc != NULL ); if ( m_pBotDoc->IsReady() ) { CPlayer* pPlayer = m_pBotDoc->GetPlayer( nPlayer ); AddPlayer( pPlayer ); } }
void PlayerFor(const QString &filename, const VideoMetadata *extraData = nullptr) { QString extension = filename.section(".", -1, -1); QDir dir_test(QString("%1/VIDEO_TS").arg(filename)); if (dir_test.exists()) extension = "VIDEO_TS"; QDir bd_dir_test(QString("%1/BDMV").arg(filename)); if (bd_dir_test.exists()) extension = "BDMV"; QString play_command = gCoreContext->GetSetting("VideoDefaultPlayer"); const FileAssociations::association_list fa_list = FileAssociations::getFileAssociation().getList(); for (FileAssociations::association_list::const_iterator p = fa_list.begin(); p != fa_list.end(); ++p) { if (p->extension.toLower() == extension.toLower() && !p->use_default) { play_command = p->playcommand; break; } } if (play_command.trimmed().isEmpty()) play_command = "Internal"; QString plot; QString title = VideoMetadata::FilenameToMeta(filename, 1); QString subtitle = VideoMetadata::FilenameToMeta(filename, 4); QString director; int season = 0; int episode = 0; QString inetref; int length = 0; QString year = QString::number(VIDEO_YEAR_DEFAULT); QString id; if (extraData) { plot = extraData->GetPlot(); title = extraData->GetTitle(); subtitle = extraData->GetSubtitle(); director = extraData->GetDirector(); season = extraData->GetSeason(); episode = extraData->GetEpisode(); inetref = extraData->GetInetRef(); length = extraData->GetLength(); year = QString::number(extraData->GetYear()); id = QString::number(extraData->GetID()); } AddPlayer(play_command, filename, plot, title, subtitle, director, season, episode, inetref, length, year, id); }
void GameData::RebuildPlayer(const int& num) { mutex.lock(); playerList.clear(); for (int i = 0; i < num; i++) { AddPlayer(); } mutex.unlock(); }
void GameScreen::AddRemotePlayer(std::string name,std::string id,float x,float y) { Player *p1 = new Player; p1->Init(name+".png"); p1->SetPosition((float)((Iw2DGetSurfaceWidth()/2)-28),(float)(Iw2DGetSurfaceHeight()/2-28)); p1->SetTarget(x,y); p1->SetVelocity(1,1); AddPlayer(id,p1); }
void CGame::RunNetGame() { #if 0 char name[20]; int i; AddPlayer(new CPlayerLocal, 1000, cfg.Get("GAME", "PlayerName", "Player")); for (i = 0; i < 2; i++) { CBasePlayer *p = CClient::Accept(cfg.Get("GAME", "ServerPwd", ""), name); AddPlayer(p, 1000, name); } m_fSingleGame = false; Run(); for (i = 0; i < 3; i++) { if (m_rgpPlayers[i] != NULL) { delete m_rgpPlayers[i]; } m_rgpPlayers[i] = NULL; } #endif }
CTeamPlayer* CTeamMgr::AddPlayer(char* sTeamName, uint32 dwPlayerID, uint32 dwFlags) { // Get the team... CTeam* pTeam = GetTeam(sTeamName); if (!pTeam) return(NULL); // Add the player to the team... return(AddPlayer(pTeam, dwPlayerID, dwFlags)); }
void CNetServerWorker::OnUserJoin(CNetServerSession* session) { AddPlayer(session->GetGUID(), session->GetUserName()); CGameSetupMessage gameSetupMessage(GetScriptInterface()); gameSetupMessage.m_Data = m_GameAttributes.get(); session->SendMessage(&gameSetupMessage); CPlayerAssignmentMessage assignMessage; ConstructPlayerAssignmentMessage(assignMessage); session->SendMessage(&assignMessage); }
void ClientNetInterface::Update(std::shared_ptr<Network> net) { net->Update(); Packet packet; while(net->GetPacket(&packet)) { u8 type = packet.ReadType(); switch(type) { case PacketType::RemoteJoin: { u16 playerID; u8 joinType; packet.Read(playerID); packet.Read(joinType); auto pmgr = PlayerManager::Get(); if(!pmgr->GetPlayer(playerID)) pmgr->AddPlayer(std::make_shared<NetPlayer>(), playerID); if(!joinType) logger << "Player " << playerID << " joined"; } break; case PacketType::RemoteLeave: { u16 playerID; u8 reason; packet.Read(playerID); packet.Read(reason); auto pmgr = PlayerManager::Get(); pmgr->RemovePlayer(playerID); if(!reason) logger << "Player " << playerID << " disconnected"; else logger << "Player " << playerID << " lost connection"; } break; case PacketType::UpdatePlayerState: OnUpdatePlayerState(packet); break; case PacketType::NewChunk: OnNewChunk(packet); break; case PacketType::RemoveChunk: OnRemoveChunk(packet); break; case PacketType::SetBlock: OnSetBlock(packet); break; case PacketType::ChunkDownload: OnChunkDownload(packet); break; case PacketType::SetChunkNeighborhood: OnSetChunkNeighborhood(packet); break; case PacketType::SetNeighborhoodTransform: OnSetNeighborhoodTransform(packet); break; } } }
Player* PlayerManager::NewPlayer(const string& strID) { Player* play = Player::create(); play->SetID(strID); play->setPosition(Point(Game()->GetConfig()->GetPlayerPosition_X(),Game()->GetConfig()->GetPlayerPosition_Y())); play->SetDestPoint(Point(Game()->GetConfig()->GetPlayerPosition_X(),Game()->GetConfig()->GetPlayerPosition_Y())); play->SetDirection(right_direction); play->Action(CodeMsg::code_player_static,right_direction); AddPlayer(play); return play; }
void ServerSession::SetSlotType(PlayerID playerSlot, ClientSlot status) { assert(status == C_STATUS_LOCAL || status == C_STATUS_OPEN); BootPlayer(playerSlot); mPlayerClients[playerSlot] = status; if (status == C_STATUS_LOCAL) { std::stringstream s; s << mPlayers[0]->GetName() << (playerSlot + 1); AddPlayer(playerSlot, C_STATUS_LOCAL, s.str(), 0); } }
void CCQuestPlayerManager::Create(CCMatchStage* pStage) { m_pStage = pStage; for (CCUIDRefCache::iterator itorObj = pStage->GetObjBegin(); itorObj != pStage->GetObjEnd(); ++itorObj) { CCUID uidChar = (*itorObj).first; CCMatchObject* pObj = CCMatchServer::GetInstance()->GetObject(uidChar); if (IsAdminGrade(pObj) && pObj->CheckPlayerFlags(CCTD_PlayerFlags_AdminHide)) continue; AddPlayer(uidChar); } }
// Teleport player to this map and this coord. bool CMap::TeleportPlayer( CPlayer* player, fPoint coord, bool TelePassenger ) { GServer->MapList.Index[player->Position->Map]->RemovePlayer( player, false ); player->Position->Map = id; player->Position->current = coord; player->Position->destiny = coord; player->Session->inGame = false; player->Position->lastMoveTime = clock(); if(player->Stats->HP<1)player->Stats->HP=player->Stats->MaxHP * 10 / 100; if(!allowpat || !TelePassenger) { if(!allowpat) player->Status->Stance=0x03; player->Ride->Drive = false; player->Ride->charid= 0; player->Ride->Ride = false; } AddPlayer( player ); BEGINPACKET( pak, 0x07a8 ); ADDWORD ( pak, player->clientid ); ADDWORD ( pak, player->Position->Map ); ADDFLOAT ( pak, player->Position->current.x*100 ); ADDFLOAT ( pak, player->Position->current.y*100 ); ADDWORD ( pak, (player->Status->Stance==0x04?0x0201:0x0001) ); player->client->SendPacket( &pak ); if( player->Ride->Drive && player->Ride->charid!=0 ) { CPlayer* otherclient = GServer->GetClientByCID( player->Ride->charid ); if( otherclient!=NULL ) { if(TelePassenger) { TeleportPlayer( otherclient, coord ); } else { otherclient->Ride->Drive = false; otherclient->Ride->charid= 0; otherclient->Ride->Ride = false; } } } GServer->pakClearUser( player ); GServer->ClearClientID( player->clientid ); player->RestartPlayerVal( ); return true; }
void CPagePlayers::OnEvent(IAGCEvent* pEvent) { AGCEventID eEvent; if (FAILED(pEvent->get_ID(&eEvent))) return; switch (eEvent) { case EventID_GameCreated: case EventID_GameDestroyed: { UpdateUI(); break; } case EventID_LoginGame: { AddPlayer(pEvent); break; } case EventID_LogoutGame: { RemovePlayer(pEvent); break; } case EventID_ShipChangesSectors: { SectorOrTeamChange(pEvent, 2, L"New Sector Name"); break; } case EventID_LeaveTeam: case EventID_JoinTeam: { SectorOrTeamChange(pEvent, 1, L"TeamName"); break; } case EventID_TeamInfoChange: { TeamInfoChange(pEvent); break; } } }
void ServerSession::HandleJoinMessage(Network::Slot clientSlot, const std::string& name) { bool playerValid = true; RefuseReason::RefuseReason reason; // Find an open slot PlayerID openPlayerID = GetPlayerSlot(C_STATUS_OPEN); if (openPlayerID == C_PLAYER_NONE) { // There are no open slots playerValid = false; reason = RefuseReason::TooManyPlayers; } // If an open slot is found, check the player's name if (playerValid) { for (PlayerID i = 0; i < mPlayers.size(); ++i) { if (mPlayers[i] != NULL && mPlayers[i]->GetName() == name) { playerValid = false; reason = RefuseReason::InvalidName; break; } } } // If the player is valid, add them to the open slot if (playerValid) { mServer->Send(clientSlot, AcceptMessage(mPlayers.size(), openPlayerID)); AddPlayer(openPlayerID, clientSlot, name, 0); } else { // Refuse the player mClientsToRemove.push_back(clientSlot); mServer->Send(clientSlot, RefuseMessage(reason)); } std::vector<ClientSlot>::iterator it = std::find(mPendingClients.begin(), mPendingClients.end(), clientSlot); if (it != mPendingClients.end()) mPendingClients.erase(it); }
void GameScreen::Init(std::string name) { Player *p1 = new Player; p1->Init(name+".png"); p1->SetPosition((float)((Iw2DGetSurfaceWidth()/2)-28),(float)(Iw2DGetSurfaceHeight()/2-28)); p1->SetTarget(p1->GetPosition().x,p1->GetPosition().y); p1->SetVelocity(1,1); Background *bg = new Background; bg->Init("bg.png",(float)Iw2DGetSurfaceWidth(),(float)Iw2DGetSurfaceHeight()); SetBackGround(bg); player = name; warpID = name + genRandom(); AddPlayer(warpID,p1); WarpClientRef->connect(warpID); }
void GameStage::UpdateSurvival() { Plane* pObj; if( Rules_GameMode == GAMEMODE_SURVIVAL ) { SurvivalDelay = (SurvivalDelay + 1) % FRAMES_PER_SECOND; if( SurvivalDelay == 0 ) { SurvivalTotalTimer++; SurvivalTimer++; pObj = 0; if( SurvivalTimer >= SurvivalArrivals[SurvivalIndex] ) { SurvivalTimer = 0; pObj = AddPlayer( (ALLEGRO_JOYSTICK*)-1 ); if( SurvivalPlayer != 0 ) { SurvivalPlayer->Score++; } if( SurvivalIndex < SURVIVAL_INTERVALS - 1 ) { SurvivalIndex++; } else { if( rand() % 3 == 0 ) { int tmpY; if( Rules_HasGround ) { tmpY = rand() % ((Framework::SystemFramework->GetDisplayHeight() / graphicsMultiplier) - 32); } else { tmpY = rand() % (Framework::SystemFramework->GetDisplayHeight() / graphicsMultiplier); } AddGameObject( new Cloud( new Vector2( Framework::SystemFramework->GetDisplayWidth(), tmpY ), (double)(rand() % 300) / 10.0, 180.0 ) ); } } } if( pObj != 0 ) { pObj->Team = (Objects.size() % 7) + 1; } } } }
/* Parse logic-specific command line arguments */ int LogicParseArgs(char ***argvptr, int *argcptr) { char **argv = *argvptr; int argc = *argcptr; /* Check for the '-player' option */ if ( strcmp(argv[1], "-player") == 0 ) { if ( ! argv[2] ) { error( "The '-player' option requires an argument!\n"); PrintUsage(); } if ( AddPlayer(argv[2]) < 0 ) exit(1); ++(*argvptr); --(*argcptr); return(0); } /* Check for the '-server' option */ if ( strcmp(argv[1], "-server") == 0 ) { if ( ! argv[2] ) { error("The '-server' option requires an argument!\n"); PrintUsage(); } if ( SetServer(argv[2]) < 0 ) exit(1); ++(*argvptr); --(*argcptr); return(0); } /* Check for the '-deathmatch' option */ if ( strcmp(argv[1], "-deathmatch") == 0 ) { if ( argv[2] && ((gDeathMatch=atoi(argv[2])) > 0) ) { ++(*argvptr); --(*argcptr); } else gDeathMatch = 8; return(0); } return(-1); }
//---Constructor CMap::CMap( const CXMLTreeNode& aNode, const Math::Vect2i& screenResolution ) : CGuiElement( aNode, screenResolution ) , m_Width_Map( aNode.GetAttribute<float>( "width_map", 0.02f ) ) , m_Height_Map( aNode.GetAttribute<float>( "height_map", 0.02f ) ) , m_Mapa( aNode.GetAttribute<CTexture>( "texture_map" ) ) // , m_Marco( aNode.GetAttribute<CTexture>( "texture_marco" ) ) , m_Cone( aNode.GetAttribute<CTexture>( "Data/textures/GUI/Textures_Test/conotrans.png" ) ) // TODO Ruly, poner esto en el xml tambien , m_Player( 0 ) { /*AddEnemys ( aNode.GetAttribute<std::string>( "texture_enemy", "" ), aNode.GetAttribute<int32>( "width_enemy", 50 ), aNode.GetAttribute<int32>( "height_enemy", 50 ), aNode.GetAttribute<std::string>( "get_position_script", "" ), aNode.GetAttribute<std::string>( "orientation", "" ) );*/ m_MinMaxMap[0] = aNode.GetAttribute<Math::Vect2f>( "pos_0_0_3d_map", Math::Vect2f( 0.f, 0.f ) ); m_MinMaxMap[1] = aNode.GetAttribute<Math::Vect2f>( "pos_1_1_3d_map", Math::Vect2f( 0.f, 0.f ) ); for ( int i = 0, count = aNode.GetNumChildren(); i < count; ++i ) { const CXMLTreeNode& pSubNewNode = aNode( i ); const std::string& NameItem = pSubNewNode.GetAttribute<std::string>( "name", "defaultItemElement" ); const std::string& TextureItem = pSubNewNode.GetAttribute<std::string>( "texture", "no_texture" ); const std::string& position_script = pSubNewNode.GetAttribute<std::string>( "get_position_script", "no_script" ); const std::string& orientation_script = pSubNewNode.GetAttribute<std::string>( "orientation", "no_script" ); uint32 WidthItem = pSubNewNode.GetAttribute<uint32>( "width", 50 ); uint32 HeightItem = pSubNewNode.GetAttribute<uint32>( "height", 50 ); float Yaw = pSubNewNode.GetAttribute<float>( "yaw", 0.f ); const std::string& tagName = pSubNewNode.GetName(); const Math::Vect3f& pos = pSubNewNode.GetAttribute<Math::Vect3f>( "pos_in_map", Math::Vect3f() ); if ( tagName == "item" ) AddItem( NameItem, TextureItem, pos, WidthItem, HeightItem, Yaw, position_script, orientation_script ); else if ( tagName == "mark_player" ) AddPlayer( NameItem, TextureItem, pos, WidthItem, HeightItem, Yaw, position_script, orientation_script ); } }
void Debug::Draw() { bool open; if (ImGui::Begin("Debug", &open, ImGuiWindowFlags_NoCollapse)) { if (ImGui::Button("Add Player")) { auto player = PlayerFactory::CreatePlayer(); auto teams = WorldDB::DEBUG_GetVectorOfTeams(); auto team = teams->operator[](0); team->AddPlayer(player); } ImGui::End(); } }
PCHStatus APlayerConnectionHandler::Update() { switch (Status){ case PCH_Offline: break; case PCH_WaitingForPlayers: { int32 ClientID; while (NetworkHandler::acceptClient(ClientID) && Status != PCH_Full) AddPlayer(ClientID); break; } case PCH_Full: int32 ClientID; NetworkHandler::acceptClient(ClientID); // Check for player disconnect // If vision device disconnected, set status to "WaitingForDevice" //this just makes sure players who DCed can reconnect even when the lobby is full. break; } return Status; }
void wxBasePlayerGameListCtrl::OnData(wxCoord x, wxCoord y, const Player &player) { wxInt32 index = HitTest(wxPoint(x, y)); if(-1 != index) { // If this is a drag happening from within the list, swap colors // instead of adding or removing. if(-1 != mDragIndex) { // Don't drop on the same person. if(index != mDragIndex) { // Get originator player. ColorType color = static_cast<ColorType>(mDragIndex); ColorMap::const_iterator it = sPlayers.find(color); if(sPlayers.end() != it) { ChangeColor(it->second, static_cast<ColorType>(index)); } } } else { ColorType color = static_cast<ColorType>(index); // See if we have to remove an existing player from the game ColorMap::const_iterator it = sPlayers.find(color); if(sPlayers.end() != it) { RemovePlayer(it->second); } // Add the new player. AddPlayer(player, color); } } }
void CTerrainMap::Upload(vec3_t player_origin, vec3_t player_angles) { CDraw32 draw; // copy completed map to mBufImage draw.SetBuffer((CPixel32*) mBufImage); draw.SetBufferSize(TM_WIDTH,TM_HEIGHT,TM_WIDTH); draw.Blit(0, 0, TM_WIDTH, TM_HEIGHT, (CPixel32*)mImage, 0, 0, TM_WIDTH); // now draw player's location on map if (player_origin) { AddPlayer(player_origin, player_angles); } draw.SetAlphaBuffer(255); R_CreateAutomapImage("*automap", (unsigned char *)draw.buffer, TM_WIDTH, TM_HEIGHT, qfalse, qfalse, qtrue, qfalse); draw.SetBuffer((CPixel32*) mImage); }