这篇教程C++ GetNumPlayers函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetNumPlayers函数的典型用法代码示例。如果您正苦于以下问题:C++ GetNumPlayers函数的具体用法?C++ GetNumPlayers怎么用?C++ GetNumPlayers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetNumPlayers函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: PlayerSelectionbool PlayerSelection(void){ PlayerSelectionData data; memset(&data, 0, sizeof data); data.IsOK = true; GetDataFilePath(data.prefixes, "data/prefixes.txt"); GetDataFilePath(data.suffixes, "data/suffixes.txt"); GetDataFilePath(data.suffixnames, "data/suffixnames.txt"); NameGenInit(&data.g, data.prefixes, data.suffixes, data.suffixnames); // Create selection menus for each local player for (int i = 0, idx = 0; i < (int)gPlayerDatas.size; i++, idx++) { PlayerData *p = CArrayGet(&gPlayerDatas, i); if (!p->IsLocal) { idx--; continue; } PlayerSelectMenusCreate( &data.menus[idx], GetNumPlayers(false, false, true), idx, i, &gEventHandlers, &gGraphicsDevice, &data.g); } if (!gCampaign.IsClient) { NetServerOpen(&gNetServer); } GameLoopData gData = GameLoopDataNew( &data, PlayerSelectionUpdate, &data, PlayerSelectionDraw); GameLoop(&gData); if (data.IsOK) { for (int i = 0, idx = 0; i < (int)gPlayerDatas.size; i++, idx++) { PlayerData *p = CArrayGet(&gPlayerDatas, i); if (!p->IsLocal) { idx--; continue; } // For any player slots not picked, turn them into AIs if (p->inputDevice == INPUT_DEVICE_UNSET) { PlayerSetInputDevice(p, INPUT_DEVICE_AI, 0); } } } for (int i = 0; i < GetNumPlayers(false, false, true); i++) { MenuSystemTerminate(&data.menus[i].ms); } NameGenTerminate(&data.g); return data.IsOK;}
开发者ID:depoorterp,项目名称:cdogs-sdl,代码行数:59,
示例2: UE_LOGvoid APuzzlePresetGameMode::PostLogin(APlayerController* NewPlayer){ if (GetNumPlayers() >= 2) { bStartPlayersAsSpectators = true; NewPlayer->StartSpectatingOnly(); } Super::PostLogin(NewPlayer); UE_LOG(LogTemp, Warning, TEXT("Totally connected: %d"), GetNumPlayers()); UE_LOG(LogTemp, Warning, TEXT("Connected PC is spectating: %d"), NewPlayer->PlayerState->bIsSpectator);}
开发者ID:alkboda,项目名称:PuzzlePreset,代码行数:13,
示例3: Q_ASSERTvoid CatanRoom::requestStartGame(){ CatanPlayer *player = qobject_cast<CatanPlayer*>(sender()); Q_ASSERT(player); if( !player ) return; if( player != host ) return; //only the host can begin the game if( startTimer.isActive() ) return; //the game is already being started if( GetNumPlayers() < CATAN_MIN_PLAYERS ) return; //cannot start with less than 4 players //check to make sure everyone is ready. for( int i = 0; i < GetMaxPlayers(); i++ ) { CatanPlayer *occupant = players[i]; if( !occupant ) continue; if( !readyPlayers[occupant->GetID()] ) return; //cannot start the game unless all players are ready. } startTimer.setSingleShot(true); startTimer.start( CATAN_ROOM_START_TIME * 1000 ); net::Begin(NETWORK_COMMAND::SERVER_ROOM_STARTING); net::Send(getPlayers());}
开发者ID:Sassafrass,项目名称:Qt-Settlers-of-Catan,代码行数:25,
示例4: PrintStatsstatic void PrintStats(FILE *stream, wbstartstruct_t *stats){ int leveltime, partime; int i; PrintLevelName(stream, stats->epsd, stats->last); fprintf(stream, "/n"); leveltime = stats->plyr[0].stime / TICRATE; partime = stats->partime / TICRATE; fprintf(stream, "Time: %i:%02i", leveltime / 60, leveltime % 60); fprintf(stream, " (par: %i:%02i)/n", partime / 60, partime % 60); fprintf(stream, "/n"); for (i=0; i<MAXPLAYERS; ++i) { if (stats->plyr[i].in) { PrintPlayerStats(stream, stats, i); } } if (GetNumPlayers(stats) >= 2) { PrintFragsTable(stream, stats); } fprintf(stream, "/n");}
开发者ID:DooMJunkie,项目名称:wii-doom,代码行数:29,
示例5: GetNodeVisibility GameWorldBase::CalcVisiblityWithAllies(const MapPoint pt, const unsigned char player) const{ const MapNode& node = GetNode(pt); Visibility best_visibility = node.fow[player].visibility; if(best_visibility == VIS_VISIBLE) return best_visibility; /// Teamsicht aktiviert? if(GetGGS().teamView) { const GamePlayer& curPlayer = GetPlayer(player); // Dann prüfen, ob Teammitglieder evtl. eine bessere Sicht auf diesen Punkt haben for(unsigned i = 0; i < GetNumPlayers(); ++i) { if(i != player && curPlayer.IsAlly(i)) { if(node.fow[i].visibility > best_visibility) best_visibility = node.fow[i].visibility; } } } return best_visibility;}
开发者ID:Return-To-The-Roots,项目名称:s25client,代码行数:25,
示例6: datavoid Channel::LeaveNotify(ObjectGuid guid){ WorldPacket data(SMSG_USERLIST_REMOVE, 8 + 1 + 4 + GetName().size() + 1); data << ObjectGuid(guid); data << uint8(GetFlags()); data << uint32(GetNumPlayers()); data << GetName(); SendToAll(&data);}
开发者ID:BACKUPLIB,项目名称:Infinity_MaNGOS,代码行数:9,
示例7: PlayerEquipDrawstatic void PlayerEquipDraw(void *data){ const PlayerEquipData *pData = data; GraphicsBlitBkg(&gGraphicsDevice); for (int i = 0; i < GetNumPlayers(false, false, true); i++) { MenuDisplay(&pData->menus[i].ms); }}
开发者ID:depoorterp,项目名称:cdogs-sdl,代码行数:9,
示例8: disconnectvoid CatanRoom::RemovePlayer( CatanPlayer *player ){ disconnect( player, SIGNAL(requestLeaveRoom()), this, SLOT(onPlayerLeave())); disconnect( player, SIGNAL(destroyed()), this, SLOT(onPlayerDestroying())); if( players[player->GetID()] != player ) return; LOG_DEBUG("[Lobby " << GetID() << "] Removing player: " << player->GetName() << endl); //remove the player players[player->GetID()] = 0; readyPlayers[player->GetID()] = false; playerCount--; cancelStartup(player); emit removedPlayer(player); //remove this room if it is empty if( GetNumPlayers() == 0 ) { player->deleteLater(); this->deleteLater(); return; } //get a list of all the players to send the message to QVector<CatanPlayer*> playerList = getPlayers(); if( player == host ) //if this was the host { //remove the previous host disconnect( player, SIGNAL(requestStartGame()), this, SLOT(requestStartGame())); disconnect( player, SIGNAL(requestChangeConfig(QDataStream&)), this, SLOT(receivedChangeConfig(QDataStream&))); host = 0; //set the host to the next player in the list LOG_INFO("The host disconnected from lobby [" << (quint16)GetID() << "]" << endl); for( int i = 0; i < GetMaxPlayers(); i++ ) { if( players[i] ) { setHost(players[i]); break; } } if( host ) { LOG_DEBUG("New lobby host: " << host->GetName() << endl); net::Begin(NETWORK_COMMAND::SERVER_ROOM_NEW_HOST); net::AddByte(host->GetID()); net::Send(playerList); } }
开发者ID:Sassafrass,项目名称:Qt-Settlers-of-Catan,代码行数:57,
示例9: GetPlayerCenter// TODO: reimplement in cameraVec2i GetPlayerCenter( GraphicsDevice *device, const Camera *camera, const PlayerData *pData, const int playerIdx){ if (pData->ActorUID < 0) { // Player is dead return Vec2iZero(); } Vec2i center = Vec2iZero(); int w = device->cachedConfig.Res.x; int h = device->cachedConfig.Res.y; if (GetNumPlayers(PLAYER_ALIVE_OR_DYING, true, true) == 1 || GetNumPlayers(PLAYER_ALIVE_OR_DYING, false , true) == 1 || CameraIsSingleScreen()) { const Vec2i pCenter = camera->lastPosition; const Vec2i screenCenter = Vec2iNew(w / 2, device->cachedConfig.Res.y / 2); const TActor *actor = ActorGetByUID(pData->ActorUID); const Vec2i p = Vec2iNew(actor->tileItem.x, actor->tileItem.y); center = Vec2iAdd(Vec2iMinus(p, pCenter), screenCenter); } else { const int numLocalPlayers = GetNumPlayers(PLAYER_ANY, false, true); if (numLocalPlayers == 2) { center.x = playerIdx == 0 ? w / 4 : w * 3 / 4; center.y = h / 2; } else if (numLocalPlayers >= 3 && numLocalPlayers <= 4) { center.x = (playerIdx & 1) ? w * 3 / 4 : w / 4; center.y = (playerIdx >= 2) ? h * 3 / 4 : h / 4; } else { CASSERT(false, "invalid number of players"); } } return center;}
开发者ID:ChunHungLiu,项目名称:cdogs-sdl,代码行数:45,
示例10: CameraInputvoid CameraInput(Camera *camera, const int cmd, const int lastCmd){ // Control the camera if (camera->spectateMode == SPECTATE_NONE) { return; } // Arrows: pan camera // CMD1/2: choose next player to follow if (CMD_HAS_DIRECTION(cmd)) { camera->spectateMode = SPECTATE_FREE; const int pan = PAN_SPEED; if (cmd & CMD_LEFT) camera->lastPosition.x -= pan; else if (cmd & CMD_RIGHT) camera->lastPosition.x += pan; if (cmd & CMD_UP) camera->lastPosition.y -= pan; else if (cmd & CMD_DOWN) camera->lastPosition.y += pan; } else if ((AnyButton(cmd) && !AnyButton(lastCmd)) || camera->FollowNextPlayer) { // Can't follow if there are no players if (GetNumPlayers(PLAYER_ALIVE_OR_DYING, false, false) == 0) { return; } camera->spectateMode = SPECTATE_FOLLOW; // Find index of player int playerIndex = -1; CA_FOREACH(const PlayerData, p, gPlayerDatas) if (p->UID == camera->FollowPlayerUID) { playerIndex = _ca_index; break; } CA_FOREACH_END() // Get the next player by index that has an actor in the game const int d = (cmd & CMD_BUTTON1) ? 1 : -1; for (int i = playerIndex + d;; i += d) { i = CLAMP_OPPOSITE(i, 0, (int)gPlayerDatas.size - 1); // Check if clamping made us hit the termination condition if (i == playerIndex) break; const PlayerData *p = CArrayGet(&gPlayerDatas, i); if (IsPlayerAliveOrDying(p)) { // Follow this player camera->FollowPlayerUID = p->UID; camera->FollowNextPlayer = false; break; } } }}
开发者ID:CrypticGator,项目名称:cdogs-sdl,代码行数:54,
示例11: PlayerEquipUpdatestatic GameLoopResult PlayerEquipUpdate(void *data){ PlayerEquipData *pData = data; // Check if anyone pressed escape int cmds[MAX_LOCAL_PLAYERS]; memset(cmds, 0, sizeof cmds); GetPlayerCmds(&gEventHandlers, &cmds); if (EventIsEscape(&gEventHandlers, cmds, GetMenuCmd(&gEventHandlers))) { pData->IsOK = false; return UPDATE_RESULT_EXIT; } // Update menus int idx = 0; for (int i = 0; i < (int)gPlayerDatas.size; i++, idx++) { const PlayerData *p = CArrayGet(&gPlayerDatas, i); if (!p->IsLocal) { idx--; continue; } if (!MenuIsExit(&pData->menus[idx].ms)) { MenuProcessCmd(&pData->menus[idx].ms, cmds[idx]); } else if (p->weaponCount == 0) { // Check exit condition; must have selected at least one weapon // Otherwise reset the current menu pData->menus[idx].ms.current = pData->menus[idx].ms.root; } } bool isDone = true; for (int i = 0; i < GetNumPlayers(false, false, true); i++) { if (strcmp(pData->menus[i].ms.current->name, "(End)") != 0) { isDone = false; } } if (isDone) { pData->IsOK = true; return UPDATE_RESULT_EXIT; } return UPDATE_RESULT_DRAW;}
开发者ID:depoorterp,项目名称:cdogs-sdl,代码行数:52,
示例12: datavoid Channel::LeaveNotify(uint64 guid){ WorldPacket data(SMSG_USERLIST_REMOVE, 8+1+4+GetName().size()+1); data << uint64(guid); data << uint8(GetFlags()); data << uint32(GetNumPlayers()); data << GetName(); if (IsConstant()) SendToAllButOne(&data, guid); else SendToAll(&data);}
开发者ID:Alluring,项目名称:TrinityCore,代码行数:13,
示例13: IsEveryoneReadybool IBattle::IsEveryoneReady() const{ for ( unsigned int i = 0; i < GetNumPlayers(); i++ ) { User& usr = GetUser( i ); UserBattleStatus& status = usr.BattleStatus(); if ( status.IsBot() ) continue; if ( status.spectator ) continue; if ( &usr == &GetMe() ) continue; if ( !status.ready ) return false; if ( !status.sync ) return false; } return true;}
开发者ID:cleanrock,项目名称:springlobby,代码行数:13,
示例14: datavoid Channel::JoinNotify(uint64 guid){ WorldPacket data(IsConstant() ? SMSG_USERLIST_ADD : SMSG_USERLIST_UPDATE, 8 + 1 + 1 + 4 + GetName().size()); data << uint64(guid); data << uint8(GetPlayerFlags(guid)); data << uint8(GetFlags()); data << uint32(GetNumPlayers()); data << GetName(); if (IsConstant()) SendToAllButOne(&data, guid); else SendToAll(&data);}
开发者ID:Ayik0,项目名称:DeathCore_5.4.8,代码行数:14,
示例15: PlayerSelectionDrawstatic void PlayerSelectionDraw(void *data){ const PlayerSelectionData *pData = data; GraphicsBlitBkg(&gGraphicsDevice); const int w = gGraphicsDevice.cachedConfig.Res.x; const int h = gGraphicsDevice.cachedConfig.Res.y; int idx = 0; for (int i = 0; i < (int)gPlayerDatas.size; i++, idx++) { const PlayerData *p = CArrayGet(&gPlayerDatas, i); if (!p->IsLocal) { idx--; continue; } if (p->inputDevice != INPUT_DEVICE_UNSET) { MenuDisplay(&pData->menus[idx].ms); } else { Vec2i center = Vec2iZero(); const char *prompt = "Press Fire to join..."; const Vec2i offset = Vec2iScaleDiv(FontStrSize(prompt), -2); switch (GetNumPlayers(false, false, true)) { case 1: // Center of screen center = Vec2iNew(w / 2, h / 2); break; case 2: // Side by side center = Vec2iNew(idx * w / 2 + w / 4, h / 2); break; case 3: case 4: // Four corners center = Vec2iNew( (idx & 1) * w / 2 + w / 4, (idx / 2) * h / 2 + h / 4); break; default: CASSERT(false, "not implemented"); break; } FontStr(prompt, Vec2iAdd(center, offset)); } }}
开发者ID:depoorterp,项目名称:cdogs-sdl,代码行数:49,
示例16: datavoid Channel::LeaveNotify(Player* p){ if (_channelRights.flags & CHANNEL_RIGHT_CANT_SPEAK) return; if (!AccountMgr::IsPlayerAccount(p->GetSession()->GetSecurity())) return; WorldPacket data(SMSG_USERLIST_REMOVE, 8 + 1 + 4 + GetName().size()); data << uint64(p->GetGUID()); data << uint8(GetFlags()); data << uint32(GetNumPlayers()); data << GetName(); SendToAllWatching(&data);}
开发者ID:Keader,项目名称:Sunwell,代码行数:15,
示例17: GetNamevoid Channel::JoinNotify(ObjectGuid guid){ WorldPacket data; if (IsConstant()) data.Initialize(SMSG_USERLIST_ADD, 8 + 1 + 1 + 4 + GetName().size() + 1); else data.Initialize(SMSG_USERLIST_UPDATE, 8 + 1 + 1 + 4 + GetName().size() + 1); data << ObjectGuid(guid); data << uint8(GetPlayerFlags(guid)); data << uint8(GetFlags()); data << uint32(GetNumPlayers()); data << GetName(); SendToAll(&data);}
开发者ID:BACKUPLIB,项目名称:Infinity_MaNGOS,代码行数:16,
示例18: GetNumPlayersint CTeam::GetAliveMembers( void ){ int iAlive = 0; int iNumPlayers = GetNumPlayers(); for ( int i=0;i<iNumPlayers;i++ ) { if ( GetPlayer(i) && GetPlayer(i)->IsAlive() ) { iAlive++; } } return iAlive;}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:16,
示例19: SoundPlayGameLoopData *ScreenVictory(CampaignOptions *c){ SoundPlay(&gSoundDevice, StrSound("victory")); VictoryData *data; CMALLOC(data, sizeof *data); data->Campaign = c; const char *finalWordsSingle[] = { "Ha, next time I'll use my good hand", "Over already? I was just warming up...", "There's just no good opposition to be found these days!", "Well, maybe I'll just do my monthly reload then", "Woof woof", "I'll just bury the bones in the back yard, he-he", "I just wish they'd let me try bare-handed", "Rambo? Who's Rambo?", "<in Austrian accent:> I'll be back", "Gee, my trigger finger is sore", "I need more practice. I think I missed a few shots at times" }; const char *finalWordsMulti[] = { "United we stand, divided we conquer", "Nothing like good teamwork, is there?", "Which way is the camera?", "We eat bullets for breakfast and have grenades as dessert", "We're so cool we have to wear mittens", }; if (GetNumPlayers(PLAYER_ANY, false, true) == 1) { const int numWords = sizeof finalWordsSingle / sizeof(char *); data->FinalWords = finalWordsSingle[rand() % numWords]; } else { const int numWords = sizeof finalWordsMulti / sizeof(char *); data->FinalWords = finalWordsMulti[rand() % numWords]; } PlayerList *pl = PlayerListNew( PlayerListUpdate, VictoryDraw, data, true, false); pl->pos.y = 75; pl->size.y -= pl->pos.y; return PlayerListLoop(pl);}
开发者ID:cxong,项目名称:cdogs-sdl,代码行数:42,
示例20: Assert//-----------------------------------------------------------------------------// Purpose: //-----------------------------------------------------------------------------void CTeam::AwardAchievement( int iAchievement ){ Assert( iAchievement >= 0 && iAchievement < 255 ); // must fit in short CRecipientFilter filter; int iNumPlayers = GetNumPlayers(); for ( int i=0;i<iNumPlayers;i++ ) { if ( GetPlayer(i) ) { filter.AddRecipient( GetPlayer(i) ); } } UserMessageBegin( filter, "AchievementEvent" ); WRITE_SHORT( iAchievement ); MessageEnd();}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:23,
示例21: GetNumPlayersunsigned int IBattle::GetNumActivePlayers() const{ return GetNumPlayers() - m_opts.spectators;}
开发者ID:cleanrock,项目名称:springlobby,代码行数:4,
示例22: getNextPIDbool CatanRoom::AddUser( CatanUser *user ){ if( GetNumPlayers() >= config->GetMaxPlayers() ) return false; if( user->InGame() || user->InLobby() ) return false; int id = getNextPID( players ); CatanPlayer* player = new CatanPlayer(id, user, this); //set the host if( !host ) setHost( player ); players[id] = player; playerCount++; LOG_DEBUG( "Lobby player count: " << GetNumPlayers() << endl ); player->SetState(PLAYER_STATE::IN_LOBBY); //tell the current players in the room that this user has joined for( int i = 0; i < GetMaxPlayers(); i++ ) { CatanPlayer *occupant = players[i]; if( !occupant ) continue; net::Begin(NETWORK_COMMAND::SERVER_ROOM_USER_JOINED); net::AddShort(this->GetID()); net::AddByte(player->GetID()); net::AddString(player->GetName()); net::Send(occupant->GetUser()); } //tell this user about the current players in the room net::Begin(NETWORK_COMMAND::SERVER_ROOM_PLAYERS); net::AddByte(GetNumPlayers()-1); //don't include the new player //send the host first. net::AddByte(host->GetID()); net::AddString(host->GetName()); net::AddBool(readyPlayers[host->GetID()]); for( int i = 0; i < GetMaxPlayers(); i++ ) { CatanPlayer *occupant = players[i]; if( !occupant ) continue; if( occupant != host && occupant != player ) { net::AddByte(occupant->GetID()); net::AddString(occupant->GetName()); net::AddBool(readyPlayers[occupant->GetID()]); } } net::Send(user); //send the game configuration transmitConfigFull(user); //if the user gets destroyed, remove him from the room connect( player, SIGNAL(destroying()), this, SLOT(onPlayerDestroying())); connect( player, SIGNAL(requestLeaveRoom()), this, SLOT(onPlayerLeave())); connect( player, SIGNAL(readyUp(bool)), this, SLOT(readyUp(bool))); emit addedPlayer(player); return true;}
开发者ID:Sassafrass,项目名称:Qt-Settlers-of-Catan,代码行数:67,
示例23: CameraDrawvoid CameraDraw( Camera *camera, const input_device_e pausingDevice, const bool controllerUnplugged){ Vec2i centerOffset = Vec2iZero(); const int numLocalPlayersAlive = GetNumPlayers(PLAYER_ALIVE_OR_DYING, false, true); const int numLocalPlayers = GetNumPlayers(PLAYER_ANY, false, true); const int w = gGraphicsDevice.cachedConfig.Res.x; const int h = gGraphicsDevice.cachedConfig.Res.y; for (int i = 0; i < GraphicsGetScreenSize(&gGraphicsDevice.cachedConfig); i++) { gGraphicsDevice.buf[i] = COLOR2PIXEL(colorBlack); } const Vec2i noise = ScreenShakeGetDelta(camera->shake); GraphicsResetBlitClip(&gGraphicsDevice); if (numLocalPlayersAlive == 0) { // Count the number of local players with lives left // If there are none, then try to spectate if there are remote players int firstRemotePlayerUID = -1; bool hasLocalPlayerLives = false; CA_FOREACH(const PlayerData, p, gPlayerDatas) if (p->Lives > 0) { if (p->IsLocal) { hasLocalPlayerLives = true; break; } else { firstRemotePlayerUID = p->UID; } } CA_FOREACH_END() if (!hasLocalPlayerLives) { if (camera->spectateMode == SPECTATE_NONE) { // Enter spectator mode // If there are remote players, follow them if (firstRemotePlayerUID != -1) { camera->spectateMode = SPECTATE_FOLLOW; camera->FollowPlayerUID = firstRemotePlayerUID; } else { // Free-look mode camera->spectateMode = SPECTATE_FREE; } } } else { // Don't spectate camera->spectateMode = SPECTATE_NONE; } if (camera->spectateMode == SPECTATE_FOLLOW) { FollowPlayer(&camera->lastPosition, camera->FollowPlayerUID); } DoBuffer( &camera->Buffer, camera->lastPosition, X_TILES, noise, centerOffset); SoundSetEars(camera->lastPosition); }
开发者ID:CrypticGator,项目名称:cdogs-sdl,代码行数:72,
示例24: SortPlayersvoid CTeam::SortPlayers(int nSortKey, int nDir){ // Sanity checks... if (nSortKey == TM_KEY_SCORE) return; if (GetNumPlayers() <= 1) return; // Remove each player from our list, and insert it, sorted, into a temp list... CTeamPlayerList lsTemp; CTeamPlayer* pCurPlr = GetFirstPlayer(); while (pCurPlr) { CTeamPlayer* pNextPlr = GetNextPlayer(pCurPlr); m_lsPlayers.Delete(pCurPlr); // Insert the player from our main list, sorted, into our temp list... CTeamPlayer* pTmpPlr = lsTemp.GetFirst(); if (!pTmpPlr) { lsTemp.Insert(pCurPlr); } else { while (pTmpPlr) { if (nDir == TM_SORT_DESCENDING && IsGreater(pCurPlr, pTmpPlr, nSortKey)) { lsTemp.InsertBefore(pTmpPlr, pCurPlr); pTmpPlr = NULL; } else if (nDir == TM_SORT_ASCENDING && IsLess(pCurPlr, pTmpPlr, nSortKey)) { lsTemp.InsertBefore(pTmpPlr, pCurPlr); pTmpPlr = NULL; } else { pTmpPlr = pTmpPlr->GetNext(); if (!pTmpPlr) { lsTemp.InsertLast(pCurPlr); } } } } pCurPlr = pNextPlr; } // Re-insert all items into our main list... CTeamPlayer* pPlr = lsTemp.GetFirst(); while (pPlr) { CTeamPlayer* pNextPlr = pPlr->GetNext(); m_lsPlayers.InsertLast(pPlr); pPlr = pNextPlr; }}
开发者ID:Arc0re,项目名称:lithtech,代码行数:69,
示例25: switchvoid 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);//.........这里部分代码省略.........
开发者ID:Arc0re,项目名称:lithtech,代码行数:101,
示例26: Campaignstatic void Campaign(GraphicsDevice *graphics, CampaignOptions *co){ if (IsPasswordAllowed(co->Entry.Mode)) { MissionSave m; AutosaveLoadMission( &gAutosave, &m, co->Entry.Path, co->Entry.BuiltinIndex); co->MissionIndex = EnterPassword(graphics, &m); } else { co->MissionIndex = 0; } bool run = false; bool gameOver = true; do { CampaignAndMissionSetup(1, co, &gMission); if (IsGameOptionsNeeded(gCampaign.Entry.Mode)) { debug(D_NORMAL, ">> Game options/n"); if (!GameOptions(gCampaign.Entry.Mode)) { run = false; goto bail; } gCampaign.OptionsSet = true; } // Mission briefing if (IsMissionBriefingNeeded(co->Entry.Mode)) { if (!ScreenMissionBriefing(&gMission)) { run = false; goto bail; } } // Equip guns if (!PlayerEquip()) { run = false; goto bail; } // Initialise before waiting for game start; // server will send us messages GameEventsInit(&gGameEvents); if (gCampaign.IsClient) { if (!ScreenWaitForGameStart()) { run = false; goto bail; } } MapLoad(&gMap, &gMission, co); // Seed random if PVP mode (otherwise players will always spawn in same // position) if (IsPVP(co->Entry.Mode)) { srand((unsigned int)time(NULL)); } if (!gCampaign.IsClient) { MapLoadDynamic(&gMap, &gMission, &co->Setting.characters); // Note: place players first, // as bad guys are placed away from players StartPlayers(ModeMaxHealth(co->Entry.Mode), co->MissionIndex); AddAndPlacePlayers(); if (!IsPVP(co->Entry.Mode)) { InitializeBadGuys(); CreateEnemies(); } } MusicPlayGame( &gSoundDevice, gCampaign.Entry.Path, gMission.missionData->Song); run = RunGame(&gMission, &gMap); // Don't quit if all players died, that's normal for PVP modes if (IsPVP(co->Entry.Mode) && GetNumPlayers(true, false, false) == 0) { run = true; } GameEventsTerminate(&gGameEvents); const int survivingPlayers = GetNumPlayers(true, false, false); // In co-op (non-PVP) modes, at least one player must survive if (!IsPVP(co->Entry.Mode)) { gameOver = survivingPlayers == 0 || co->MissionIndex == (int)gCampaign.Setting.Missions.size - 1; }//.........这里部分代码省略.........
开发者ID:gallegretti,项目名称:cdogs-sdl,代码行数:101,
示例27: PlayerEquipbool PlayerEquip(void){ PlayerEquipData data; memset(&data, 0, sizeof data); data.IsOK = true; for (int i = 0, idx = 0; i < (int)gPlayerDatas.size; i++, idx++) { PlayerData *p = CArrayGet(&gPlayerDatas, i); if (!p->IsLocal) { idx--; continue; } // Remove unavailable weapons from players inventories RemoveUnavailableWeapons(p, &gMission.Weapons); WeaponMenuCreate( &data.menus[idx], GetNumPlayers(false, false, true), idx, i, &gEventHandlers, &gGraphicsDevice); // For AI players, pre-pick their weapons and go straight to menu end if (p->inputDevice == INPUT_DEVICE_AI) { const int lastMenuIndex = (int)data.menus[idx].ms.root->u.normal.subMenus.size - 1; data.menus[idx].ms.current = CArrayGet( &data.menus[idx].ms.root->u.normal.subMenus, lastMenuIndex); AICoopSelectWeapons(p, idx, &gMission.Weapons); } } GameLoopData gData = GameLoopDataNew( &data, PlayerEquipUpdate, &data, PlayerEquipDraw); GameLoop(&gData); for (int i = 0, idx = 0; i < (int)gPlayerDatas.size; i++, idx++) { PlayerData *p = CArrayGet(&gPlayerDatas, i); if (!p->IsLocal) { idx--; continue; } const NetMsgPlayerData d = NetMsgMakePlayerData(p); // Ready player definitions p->IsUsed = true; if (gCampaign.IsClient) { NetClientSendMsg(&gNetClient, MSG_PLAYER_DATA, &d); } else { NetServerBroadcastMsg(&gNetServer, MSG_PLAYER_DATA, &d); } } for (int i = 0; i < GetNumPlayers(false, false, true); i++) { MenuSystemTerminate(&data.menus[i].ms); } return data.IsOK;}
开发者ID:depoorterp,项目名称:cdogs-sdl,代码行数:63,
示例28: RTTR_Assertconst GamePlayer& GameWorldBase::GetPlayer(const unsigned id) const{ RTTR_Assert(id < GetNumPlayers()); return players[id];}
开发者ID:Return-To-The-Roots,项目名称:s25client,代码行数:5,
注:本文中的GetNumPlayers函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GetNumTracks函数代码示例 C++ GetNextWayPoint函数代码示例 |