• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetNumPlayers函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetNumPlayers函数的典型用法代码示例。如果您正苦于以下问题:C++ GetNumPlayers函数的具体用法?C++ GetNumPlayers怎么用?C++ GetNumPlayers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetNumPlayers函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: PlayerSelection

bool 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,代码来源:prep.c


示例2: UE_LOG

void 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,代码来源:PuzzlePresetGameMode.cpp


示例3: Q_ASSERT

void 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,代码来源:lobby.cpp


示例4: PrintStats

static 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,代码来源:statdump.c


示例5: GetNode

Visibility 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,代码来源:GameWorldBase.cpp


示例6: data

void 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,代码来源:Channel.cpp


示例7: PlayerEquipDraw

static 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,代码来源:prep.c


示例8: disconnect

void 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,代码来源:lobby.cpp


示例9: GetPlayerCenter

// TODO: reimplement in camera
Vec2i 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,代码来源:game.c


示例10: CameraInput

void 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,代码来源:camera.c


示例11: PlayerEquipUpdate

static 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,代码来源:prep.c


示例12: data

void 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,代码来源:Channel.cpp


示例13: IsEveryoneReady

bool 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,代码来源:ibattle.cpp


示例14: data

void 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,代码来源:Channel.cpp


示例15: PlayerSelectionDraw

static 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,代码来源:prep.c


示例16: data

void 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,代码来源:Channel.cpp


示例17: GetName

void 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,代码来源:Channel.cpp


示例18: GetNumPlayers

int 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,代码来源:team.cpp


示例19: SoundPlay

GameLoopData *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,代码来源:screens_end.c


示例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,代码来源:team.cpp



注:本文中的GetNumPlayers函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetNumTracks函数代码示例发布时间:2022-05-30
下一篇:
C++ GetNextWayPoint函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap