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

C++ GameServer函数代码示例

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

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



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

示例1: str_copy

void CServer::ProcessClientPacket(CNetChunk *pPacket)
{
	int ClientID = pPacket->m_ClientID;
	NETADDR Addr;
	CUnpacker Unpacker;
	Unpacker.Reset(pPacket->m_pData, pPacket->m_DataSize);

	// unpack msgid and system flag
	int Msg = Unpacker.GetInt();
	int Sys = Msg&1;
	Msg >>= 1;

	if(Unpacker.Error())
		return;

	if(Sys)
	{
		// system message
		if(Msg == NETMSG_INFO)
		{
			if(m_aClients[ClientID].m_State == CClient::STATE_AUTH)
			{
				char aVersion[64];
				str_copy(aVersion, Unpacker.GetString(CUnpacker::SANITIZE_CC), 64);
				bool CustClt = str_comp(aVersion, GameServer()->NetVersionCust()) == 0;
				dbg_msg("es", "%s client connected!", CustClt?"cust":"vanilla");
				if(!CustClt && str_comp(aVersion, GameServer()->NetVersion()) != 0)
				{
					// wrong version
					char aReason[256];
					str_format(aReason, sizeof(aReason), "Wrong version. Server is running '%s' and client '%s'", GameServer()->NetVersion(), aVersion);
					m_NetServer.Drop(ClientID, aReason);
					return;
				}

				const char *pPassword = Unpacker.GetString(CUnpacker::SANITIZE_CC);
				if(g_Config.m_Password[0] != 0 && str_comp(g_Config.m_Password, pPassword) != 0)
				{
					// wrong password
					m_NetServer.Drop(ClientID, "Wrong password");
					return;
				}

				m_aClients[ClientID].m_State = CClient::STATE_CONNECTING;
				m_aClients[ClientID].m_CustClt = CustClt;
				SendMap(ClientID);
			}
		}
		else if(Msg == NETMSG_REQUEST_MAP_DATA)
		{
			int Chunk = Unpacker.GetInt();
			int ChunkSize = 1024-128;
			int Offset = Chunk * ChunkSize;
			int Last = 0;

			// drop faulty map data requests
			if(Chunk < 0 || Offset > m_CurrentMapSize)
				return;

			if(Offset+ChunkSize >= m_CurrentMapSize)
			{
				ChunkSize = m_CurrentMapSize-Offset;
				if(ChunkSize < 0)
					ChunkSize = 0;
				Last = 1;
			}

			CMsgPacker Msg(NETMSG_MAP_DATA);
			Msg.AddInt(Last);
			Msg.AddInt(m_CurrentMapCrc);
			Msg.AddInt(Chunk);
			Msg.AddInt(ChunkSize);
			Msg.AddRaw(&m_pCurrentMapData[Offset], ChunkSize);
			SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID, true);

			if(g_Config.m_Debug)
			{
				char aBuf[256];
				str_format(aBuf, sizeof(aBuf), "sending chunk %d with size %d", Chunk, ChunkSize);
				Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf);
			}
		}
		else if(Msg == NETMSG_READY)
		{
			if(m_aClients[ClientID].m_State == CClient::STATE_CONNECTING)
			{
				Addr = m_NetServer.ClientAddr(ClientID);
				char aAddrStr[NETADDR_MAXSTRSIZE];
				net_addr_str(&Addr, aAddrStr, sizeof(aAddrStr));

				char aBuf[256];
				str_format(aBuf, sizeof(aBuf), "player is ready. ClientID=%x addr=%s", ClientID, aAddrStr);
				Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
				m_aClients[ClientID].m_State = CClient::STATE_READY;
				GameServer()->OnClientConnected(ClientID);
				SendConnectionReady(ClientID);
			}
		}
		else if(Msg == NETMSG_ENTERGAME)
		{
//.........这里部分代码省略.........
开发者ID:vanyagod,项目名称:FNG-Sam-za-seb9,代码行数:101,代码来源:server.cpp


示例2: GetPos

void CProjectile::Tick()
{
	float Pt = (Server()->Tick()-m_StartTick-1)/(float)Server()->TickSpeed();
	float Ct = (Server()->Tick()-m_StartTick)/(float)Server()->TickSpeed();
	vec2 PrevPos = GetPos(Pt);
	vec2 CurPos = GetPos(Ct);
	int Collide = GameServer()->Collision()->IntersectLine(PrevPos, CurPos, &CurPos, 0);
	CCharacter *OwnerChar = GameServer()->GetPlayerChar(m_Owner);
	CCharacter *TargetChr = GameServer()->m_World.IntersectCharacter(PrevPos, CurPos, 6.0f, CurPos, OwnerChar);

	m_LifeSpan--;

	if(TargetChr || Collide || m_LifeSpan < 0 || GameLayerClipped(CurPos))
	{
        int EventID = GameServer()->m_pLua->m_pEventListener->CreateEventStack();
        GameServer()->m_pLua->m_pEventListener->GetParameters(EventID)->FindFree()->Set(m_Owner);
        GameServer()->m_pLua->m_pEventListener->GetParameters(EventID)->FindFree()->Set(m_Weapon);
        GameServer()->m_pLua->m_pEventListener->GetParameters(EventID)->FindFree()->Set(CurPos.x);
        GameServer()->m_pLua->m_pEventListener->GetParameters(EventID)->FindFree()->Set(CurPos.y);
        GameServer()->m_pLua->m_pEventListener->GetParameters(EventID)->FindFree()->Set(m_StartTick);
        GameServer()->m_pLua->m_pEventListener->GetParameters(EventID)->FindFree()->Set(m_Direction.x);
        GameServer()->m_pLua->m_pEventListener->GetParameters(EventID)->FindFree()->Set(m_Direction.y);
        if (TargetChr)
            GameServer()->m_pLua->m_pEventListener->GetParameters(EventID)->FindFree()->Set(TargetChr->GetPlayer()->GetCID());
        else
            GameServer()->m_pLua->m_pEventListener->GetParameters(EventID)->FindFree()->Set(-1);
        GameServer()->m_pLua->m_pEventListener->GetParameters(EventID)->FindFree()->Set(Collide);
        GameServer()->m_pLua->m_pEventListener->GetParameters(EventID)->FindFree()->Set(m_ID);

        GameServer()->m_pLua->m_pEventListener->OnEvent("OnProjectileDestroy");

        if (GameServer()->m_pLua->m_pEventListener->GetReturns(EventID)->m_aVars[0].IsNumeric() && GameServer()->m_pLua->m_pEventListener->GetReturns(EventID)->m_aVars[0].GetInteger() == 1)
            return;

		if(m_LifeSpan >= 0 || m_Weapon == WEAPON_GRENADE)
			GameServer()->CreateSound(CurPos, m_SoundImpact);

		if(m_Explosive && GameServer()->m_pLua->m_pEventListener->GetReturns(EventID)->m_aVars[1].GetInteger() == 0)
			GameServer()->CreateExplosion(CurPos, m_Owner, m_Weapon, false);

		else if(TargetChr)
			TargetChr->TakeDamage(m_Direction * max(0.001f, m_Force), m_Damage, m_Owner, m_Weapon);

		GameServer()->m_World.DestroyEntity(this);
	}
}
开发者ID:BugsBunny1605,项目名称:N-Client,代码行数:46,代码来源:projectile.cpp


示例3: CHAR

void CGameControllerOpenFNG::HandleSacr(int Killer, int Victim, int ShrineTeam)
{//assertion: Killer >= 0, victim anyways
	CCharacter *pVictim = CHAR(Victim);

	if (!pVictim) //due to HandleFreeze, i suspect this COULD also possibly happen. 
	{
		D("no pVictim in HandleSacr(%d, %d, %d)", Killer, Victim, ShrineTeam);
		return;
	}

	int FailTeam = pVictim->GetPlayer()->GetTeam();
	bool Wrong = ShrineTeam != -1 && FailTeam == ShrineTeam;

	m_aTeamscore[1-FailTeam] += Wrong?CFG(WrongSacrTeamscore):(ShrineTeam == -1 ? CFG(SacrTeamscore) : CFG(RightSacrTeamscore));

	if (!Wrong)
	{
		if (CFG(SacrSound) == 1)
			GameServer()->CreateSoundGlobal(SOUND_CTF_CAPTURE);
		else if (CFG(SacrSound) == 2)
			GameServer()->CreateSound(pVictim->m_Pos, SOUND_CTF_CAPTURE);
	}

	if (((Wrong && CFG(WrongSacrTeamscore)) || (!Wrong && (ShrineTeam == -1 ? CFG(SacrTeamscore) : CFG(RightSacrTeamscore)))) && CFG(SacrBroadcast))
	{
		char aBuf[64];
		str_format(aBuf, sizeof aBuf, "%s sacrificed%s (%+d)", GetTeamName(1-FailTeam), Wrong?" in wrong shrine":(ShrineTeam == -1 ? "" : ", pleasing their gods"),
		                                                                           Wrong?CFG(WrongSacrTeamscore):(ShrineTeam == -1 ? CFG(SacrTeamscore):CFG(RightSacrTeamscore)));
		m_Broadcast.Update(-1, aBuf, CFG(BroadcastTime) * TS);
	}

	CPlayer *pPlKiller = TPLAYER(Killer);
	CPlayer *pPlVictim = TPLAYER(Victim);

	if (!pPlKiller || !pVictim)
		return;

	pPlKiller->m_Score += Wrong ? CFG(WrongSacrScore)
	                            : (ShrineTeam == -1 ? CFG(SacrScore)
	                                                : CFG(RightSacrScore));

	pPlVictim->m_Score += Wrong ? CFG(WrongSacrScoreVic)
	                            : (ShrineTeam == -1 ? CFG(SacrScoreVic)
	                                                : CFG(RightSacrScoreVic));

	SendFreezeKill(Killer, Victim, WEAPON_NINJA);

	if (Wrong && pPlKiller->GetCharacter() && CFG(PunishWrongSacr))
	{
		pPlKiller->GetCharacter()->Freeze(CFG(PunishWrongSacr) * TS);
		GS->CreateSound(pPlKiller->GetCharacter()->m_Pos, SOUND_PLAYER_PAIN_LONG);
		GS->SendChatTarget(pPlKiller->GetCID(), "The gods are not pleased with this sacrifice!");
	}

	if (!Wrong && pPlKiller->GetCharacter())
		pPlKiller->GetCharacter()->SetEmote(EMOTE_HAPPY, TICK + TS * 2);

	if (pPlKiller->GetCharacter() && CFG(SacrLoltext) && ((!Wrong && CFG(SacrScore)) || (Wrong && CFG(WrongSacrScore))))
	{
		char aBuf[64];
		str_format(aBuf, sizeof aBuf, "%+d", Wrong?CFG(WrongSacrScore):(ShrineTeam == -1 ? CFG(SacrScore) : CFG(RightSacrScore)));
		GS->CreateLolText(pPlKiller->GetCharacter(), false, vec2(0.f, -50.f), vec2(0.f, 0.f), 50, aBuf);
	}

	if(!Wrong && pPlKiller->GetCharacter())
		GameServer()->GetPlayerChar(Killer)->AddSpree();
}
开发者ID:FallenKN,项目名称:openfng,代码行数:67,代码来源:openfng.cpp


示例4: frandom

int CGameControllerMOD::ChooseInfectedClass(CPlayer* pPlayer)
{
	float random = frandom();
	float TotalProbInfectedClass = m_TotalProbInfectedClass;
	
	//Get information about existing infected
	int nbInfected = 0;
	bool thereIsAWitch = false;
	bool thereIsAnUndead = false;
	for(int i = 0; i < MAX_CLIENTS; i++)
	{
		CPlayer *pPlayer = GameServer()->m_apPlayers[i];
		
		if(!pPlayer) continue;
		if(pPlayer->GetTeam() == TEAM_SPECTATORS) continue;
		
		if(pPlayer->IsInfected()) nbInfected++;
		if(pPlayer->GetClass() == PLAYERCLASS_WITCH) thereIsAWitch = true;
		if(pPlayer->GetClass() == PLAYERCLASS_UNDEAD) thereIsAnUndead = true;
	}
	
	//Check if hunters are enabled
	bool hunterEnabled = true;
	if(Server()->GetClassAvailability(PLAYERCLASS_HUNTER) == 0)
	{
		TotalProbInfectedClass -= m_ClassProbability[PLAYERCLASS_HUNTER];
		hunterEnabled = false;
	}
	
	//Check if ghost are enabled
	bool ghostEnabled = true;
	if(Server()->GetClassAvailability(PLAYERCLASS_GHOST) == 0)
	{
		TotalProbInfectedClass -= m_ClassProbability[PLAYERCLASS_GHOST];
		ghostEnabled = false;
	}
	
	//Check if spider are enabled
	bool spiderEnabled = true;
	if(Server()->GetClassAvailability(PLAYERCLASS_SPIDER) == 0)
	{
		TotalProbInfectedClass -= m_ClassProbability[PLAYERCLASS_SPIDER];
		spiderEnabled = false;
	}
	
	//Check if boomers are enabled
	bool boomerEnabled = true;
	if(Server()->GetClassAvailability(PLAYERCLASS_BOOMER) == 0)
	{
		TotalProbInfectedClass -= m_ClassProbability[PLAYERCLASS_BOOMER];
		boomerEnabled = false;
	}
	
	//Check if undeads are enabled
	bool undeadEnabled = true;
	if(nbInfected < 2 || thereIsAnUndead || (Server()->GetClassAvailability(PLAYERCLASS_UNDEAD) == 0) || !pPlayer->m_WasHumanThisRound)
	{
		TotalProbInfectedClass -= m_ClassProbability[PLAYERCLASS_UNDEAD];
		undeadEnabled = false;
	}
	
	//Check if witches are enabled
	bool witchEnabled = true;
	if(nbInfected < 2 || thereIsAWitch || (Server()->GetClassAvailability(PLAYERCLASS_WITCH) == 0) || !pPlayer->m_WasHumanThisRound)
	{
		TotalProbInfectedClass -= m_ClassProbability[PLAYERCLASS_WITCH];
		witchEnabled = false;
	}
	
	random *= TotalProbInfectedClass;
	
	//Find the random class
	if(undeadEnabled)
	{
		random -= m_ClassProbability[PLAYERCLASS_UNDEAD];
		if(random < 0.0f)
		{
			GameServer()->SendBroadcast_Language(-1, "The undead is coming!");
			GameServer()->CreateSoundGlobal(SOUND_CTF_CAPTURE);
			return PLAYERCLASS_UNDEAD;
		}
	}
	
	if(witchEnabled)
	{
		random -= m_ClassProbability[PLAYERCLASS_WITCH];
		if(random < 0.0f)
		{
			GameServer()->SendBroadcast_Language(-1, "The witch is coming!");
			GameServer()->CreateSoundGlobal(SOUND_CTF_CAPTURE);
			return PLAYERCLASS_WITCH;
		}
	}
	
	if(boomerEnabled)
	{
		random -= m_ClassProbability[PLAYERCLASS_BOOMER];
		if(random < 0.0f)
		{
			return PLAYERCLASS_BOOMER;
//.........这里部分代码省略.........
开发者ID:KingteEGER,项目名称:teeworlds-infclass,代码行数:101,代码来源:mod.cpp


示例5: GameServer

void CMercenaryBomb::Reset()
{
	GameServer()->m_World.DestroyEntity(this);
}
开发者ID:necropotame,项目名称:teeworlds-infclass,代码行数:4,代码来源:merc-bomb.cpp


示例6: GameServer

void CGameControllerMOD::Tick()
{
	IGameController::Tick();
	
	m_HumanCounter = 0;
	m_InfectedCounter = 0;
	
	//Count type of players
	for(int i = 0; i < MAX_CLIENTS; i ++)
	{
		CPlayer *pPlayer = GameServer()->m_apPlayers[i];
		
		if(!pPlayer) continue;
		if(pPlayer->GetTeam() == TEAM_SPECTATORS) continue;
		
		if(pPlayer->IsInfected()) m_InfectedCounter++;
		else m_HumanCounter++;
	}
	
	m_InfectedStarted = false;
	
	//If the game can start ...
	if(m_GameOverTick == -1 && m_HumanCounter + m_InfectedCounter >= 2)
	{
		//If the infection started
		if(m_RoundStartTick + Server()->TickSpeed()*10 < Server()->Tick())
		{	
			m_InfectedStarted = true;
	
			for(int i = 0; i < MAX_CLIENTS; i ++)
			{
				CPlayer *pPlayer = GameServer()->m_apPlayers[i];
				
				if(!pPlayer) continue;
				if(pPlayer->GetTeam() == TEAM_SPECTATORS)
				{
					pPlayer->StartInfection();
				}
				else if(pPlayer->GetClass() == PLAYERCLASS_NONE)
				{
					pPlayer->SetClass(ChooseHumanClass(pPlayer));
					if(pPlayer->GetCharacter())
						pPlayer->GetCharacter()->IncreaseArmor(10);
				}
			}
			
			//If needed, infect players
			int nbInfectedNeeded = 2;
			if(m_InfectedCounter + m_HumanCounter < 4)
			{
				nbInfectedNeeded = 1;
			}
			
			while(m_InfectedCounter < nbInfectedNeeded)
			{
				float InfectionProb = 1.0/static_cast<float>(m_HumanCounter);
				float random = frandom();
				
				//Fair infection
				bool FairInfectionFound = false;
				for(int i = 0; i < MAX_CLIENTS; i ++)
				{
					CPlayer *pPlayer = GameServer()->m_apPlayers[i];
					
					if(!pPlayer) continue;
					if(pPlayer->GetTeam() == TEAM_SPECTATORS) continue;
					if(pPlayer->IsInfected()) continue;
					
					if(!Server()->IsClientInfectedBefore(i))
					{
						Server()->InfecteClient(i);
						GameServer()->m_apPlayers[i]->StartInfection();
						m_InfectedCounter++;
						m_HumanCounter--;
						
						GameServer()->SendChatTarget_Language_s(-1, "%s has been infected", Server()->ClientName(i));
						FairInfectionFound = true;
						break;
					}
				}
				
				//Unfair infection
				if(!FairInfectionFound)
				{
					for(int i = 0; i < MAX_CLIENTS; i ++)
					{
						CPlayer *pPlayer = GameServer()->m_apPlayers[i];
						
						if(!pPlayer) continue;
						if(pPlayer->GetTeam() == TEAM_SPECTATORS) continue;
						if(pPlayer->IsInfected()) continue;
						
						if(random < InfectionProb)
						{
							Server()->InfecteClient(i);
							GameServer()->m_apPlayers[i]->StartInfection();
							m_InfectedCounter++;
							m_HumanCounter--;
							
							GameServer()->SendChatTarget_Language_s(-1, "%s has been infected", Server()->ClientName(i));
//.........这里部分代码省略.........
开发者ID:KingteEGER,项目名称:teeworlds-infclass,代码行数:101,代码来源:mod.cpp


示例7: Server

void CPlayer::Tick()
{
	if(!IsDummy() && !Server()->ClientIngame(m_ClientID))
		return;

	Server()->SetClientScore(m_ClientID, m_Score);

	// do latency stuff
	{
		IServer::CClientInfo Info;
		if(Server()->GetClientInfo(m_ClientID, &Info))
		{
			m_Latency.m_Accum += Info.m_Latency;
			m_Latency.m_AccumMax = max(m_Latency.m_AccumMax, Info.m_Latency);
			m_Latency.m_AccumMin = min(m_Latency.m_AccumMin, Info.m_Latency);
		}
		// each second
		if(Server()->Tick()%Server()->TickSpeed() == 0)
		{
			m_Latency.m_Avg = m_Latency.m_Accum/Server()->TickSpeed();
			m_Latency.m_Max = m_Latency.m_AccumMax;
			m_Latency.m_Min = m_Latency.m_AccumMin;
			m_Latency.m_Accum = 0;
			m_Latency.m_AccumMin = 1000;
			m_Latency.m_AccumMax = 0;
		}
	}

	if(m_pCharacter && !m_pCharacter->IsAlive())
	{
		delete m_pCharacter;
		m_pCharacter = 0;
	}

	if(!GameServer()->m_pController->IsGamePaused())
	{
		if(!m_pCharacter && m_Team == TEAM_SPECTATORS && m_SpectatorID == SPEC_FREEVIEW)
			m_ViewPos -= vec2(clamp(m_ViewPos.x-m_LatestActivity.m_TargetX, -500.0f, 500.0f), clamp(m_ViewPos.y-m_LatestActivity.m_TargetY, -400.0f, 400.0f));

		if(!m_pCharacter && m_DieTick+Server()->TickSpeed()*3 <= Server()->Tick() && !m_DeadSpecMode)
			Respawn();

		if(m_pCharacter)
		{
			if(m_pCharacter->IsAlive())
				m_ViewPos = m_pCharacter->m_Pos;
		}
		else if(m_Spawning && m_RespawnTick <= Server()->Tick())
			TryRespawn();

		if(!m_DeadSpecMode && m_LastActionTick != Server()->Tick())
			++m_InactivityTickCounter;
	}
	else
	{
		++m_RespawnTick;
		++m_DieTick;
		++m_ScoreStartTick;
		++m_LastActionTick;
		++m_TeamChangeTick;
 	}
}
开发者ID:KingteEGER,项目名称:teeworlds,代码行数:62,代码来源:player.cpp


示例8: GameServer

void CPickup::Tick()
{
	// wait for respawn
	if(m_SpawnTick > 0)
	{
		if(Server()->Tick() > m_SpawnTick)
		{
			// respawn
			m_SpawnTick = -1;

			if(m_Type == POWERUP_WEAPON)
				GameServer()->CreateSound(m_Pos, SOUND_WEAPON_SPAWN);
		}
		else
			return;
	}
	// Check if a player intersected us
	CCharacter *pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 20.0f, 0);
	if(pChr && pChr->IsAlive())
	{
		// player picked us up, is someone was hooking us, let them go
		int RespawnTime = -1;
		switch (m_Type)
		{
			case POWERUP_HEALTH:
				if(pChr->IncreaseHealth(1))
				{
					GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
					RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
				}
				break;
				
			case POWERUP_ARMOR:
				if(pChr->IncreaseArmor(1))
				{
					GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
					RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
				}
				break;

			case POWERUP_WEAPON:
				if(m_Subtype >= 0 && m_Subtype < NUM_WEAPONS)
				{
					if(pChr->GiveWeapon(m_Subtype, 10))
					{
						RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;

						if(m_Subtype == WEAPON_GRENADE)
							GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE);
						else if(m_Subtype == WEAPON_SHOTGUN)
							GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
						else if(m_Subtype == WEAPON_RIFLE)
							GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);

						if(pChr->GetPlayer())
							GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype);
					}
				}
				break;
				
			case POWERUP_NINJA:
				{
					// activate ninja on target player
					pChr->GiveNinja();
					RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;

					// loop through all players, setting their emotes
					CEntity *apEnts[64];
					int Num = GameServer()->m_World.FindEntities(vec2(0, 0), 1000000, apEnts, 64, NETOBJTYPE_CHARACTER);
					
					for (int i = 0; i < Num; ++i)
					{
						CCharacter *pC = static_cast<CCharacter *>(apEnts[i]);
						if (pC != pChr)
							pC->SetEmote(EMOTE_SURPRISE, Server()->Tick() + Server()->TickSpeed());
					}

					pChr->SetEmote(EMOTE_ANGRY, Server()->Tick() + 1200 * Server()->TickSpeed() / 1000);
					break;
				}
				
			default:
				break;
		};

		if(RespawnTime >= 0)
		{
			dbg_msg("game", "pickup player='%d:%s' item=%d/%d",
				pChr->GetPlayer()->GetCID(), Server()->ClientName(pChr->GetPlayer()->GetCID()), m_Type, m_Subtype);
			m_SpawnTick = Server()->Tick() + Server()->TickSpeed() * RespawnTime;
		}
	}
}
开发者ID:Danyl12,项目名称:teeworlds,代码行数:93,代码来源:pickup.cpp


示例9: mem_zero

void CDragger::Move()
{
	if (m_Target && (!m_Target->IsAlive() || (m_Target->IsAlive()
			&& (m_Target->m_Super || m_Target->IsPaused()
					|| (m_Layer == LAYER_SWITCH && m_Number
							&& !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[m_Target->Team()])))))
		m_Target = 0;

	mem_zero(m_SoloEnts, sizeof(m_SoloEnts));
	CCharacter *TempEnts[MAX_CLIENTS];

	int Num = GameServer()->m_World.FindEntities(m_Pos, g_Config.m_SvDraggerRange,
			(CEntity**) m_SoloEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
	mem_copy(TempEnts, m_SoloEnts, sizeof(TempEnts));

	int Id = -1;
	int MinLen = 0;
	CCharacter *Temp;
	for (int i = 0; i < Num; i++)
	{
		Temp = m_SoloEnts[i];
		if (Temp->Team() != m_CaughtTeam)
		{
			m_SoloEnts[i] = 0;
			continue;
		}
		if (m_Layer == LAYER_SWITCH && m_Number
				&& !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Temp->Team()])
		{
			m_SoloEnts[i] = 0;
			continue;
		}
		int Res =
				m_NW ? GameServer()->Collision()->IntersectNoLaserNW(m_Pos,
								Temp->m_Pos, 0, 0) :
						GameServer()->Collision()->IntersectNoLaser(m_Pos,
								Temp->m_Pos, 0, 0);

		if (Res == 0)
		{
			int Len = length(Temp->m_Pos - m_Pos);
			if (MinLen == 0 || MinLen > Len)
			{
				MinLen = Len;
				Id = i;
			}

			if (!Temp->Teams()->m_Core.GetSolo(Temp->GetPlayer()->GetCID()))
				m_SoloEnts[i] = 0;
		}
		else
		{
			m_SoloEnts[i] = 0;
		}
	}

	if (!m_Target)
		m_Target = Id != -1 ? TempEnts[Id] : 0;

	if (m_Target)
	{
		for (int i = 0; i < MAX_CLIENTS; i++)
		{
			if (m_SoloEnts[i] == m_Target)
				m_SoloEnts[i] = 0;
		}
	}
}
开发者ID:BannZay,项目名称:ddnet,代码行数:68,代码来源:dragger.cpp


示例10: GameServer

void CDragger::Drag()
{
	if (m_Target)
	{
		CCharacter *Target = m_Target;

		for (int i = -1; i < MAX_CLIENTS; i++)
		{
			if (i >= 0)
				Target = m_SoloEnts[i];

			if (!Target)
				continue;

			int Res = 0;
			if (!m_NW)
				Res = GameServer()->Collision()->IntersectNoLaser(m_Pos,
						Target->m_Pos, 0, 0);
			else
				Res = GameServer()->Collision()->IntersectNoLaserNW(m_Pos,
						Target->m_Pos, 0, 0);
			if (Res || length(m_Pos - Target->m_Pos) > g_Config.m_SvDraggerRange)
			{
				Target = 0;
				if (i == -1)
					m_Target = 0;
				else
					m_SoloEnts[i] = 0;
			}
			else if (length(m_Pos - Target->m_Pos) > 28)
			{
				vec2 Temp = Target->Core()->m_Vel
						+ (normalize(m_Pos - Target->m_Pos) * m_Strength);
				if (Temp.x > 0
						&& ((Target->m_TileIndex == TILE_STOP
								&& Target->m_TileFlags == ROTATION_270)
								|| (Target->m_TileIndexL == TILE_STOP
										&& Target->m_TileFlagsL == ROTATION_270)
								|| (Target->m_TileIndexL == TILE_STOPS
										&& (Target->m_TileFlagsL == ROTATION_90
												|| Target->m_TileFlagsL
														== ROTATION_270))
								|| (Target->m_TileIndexL == TILE_STOPA)
								|| (Target->m_TileFIndex == TILE_STOP
										&& Target->m_TileFFlags == ROTATION_270)
								|| (Target->m_TileFIndexL == TILE_STOP
										&& Target->m_TileFFlagsL == ROTATION_270)
								|| (Target->m_TileFIndexL == TILE_STOPS
										&& (Target->m_TileFFlagsL == ROTATION_90
												|| Target->m_TileFFlagsL
														== ROTATION_270))
								|| (Target->m_TileFIndexL == TILE_STOPA)
								|| (Target->m_TileSIndex == TILE_STOP
										&& Target->m_TileSFlags == ROTATION_270)
								|| (Target->m_TileSIndexL == TILE_STOP
										&& Target->m_TileSFlagsL == ROTATION_270)
								|| (Target->m_TileSIndexL == TILE_STOPS
										&& (Target->m_TileSFlagsL == ROTATION_90
												|| Target->m_TileSFlagsL
														== ROTATION_270))
								|| (Target->m_TileSIndexL == TILE_STOPA)))
					Temp.x = 0;
				if (Temp.x < 0
						&& ((Target->m_TileIndex == TILE_STOP
								&& Target->m_TileFlags == ROTATION_90)
								|| (Target->m_TileIndexR == TILE_STOP
										&& Target->m_TileFlagsR == ROTATION_90)
								|| (Target->m_TileIndexR == TILE_STOPS
										&& (Target->m_TileFlagsR == ROTATION_90
												|| Target->m_TileFlagsR
														== ROTATION_270))
								|| (Target->m_TileIndexR == TILE_STOPA)
								|| (Target->m_TileFIndex == TILE_STOP
										&& Target->m_TileFFlags == ROTATION_90)
								|| (Target->m_TileFIndexR == TILE_STOP
										&& Target->m_TileFFlagsR == ROTATION_90)
								|| (Target->m_TileFIndexR == TILE_STOPS
										&& (Target->m_TileFFlagsR == ROTATION_90
												|| Target->m_TileFFlagsR
														== ROTATION_270))
								|| (Target->m_TileFIndexR == TILE_STOPA)
								|| (Target->m_TileSIndex == TILE_STOP
										&& Target->m_TileSFlags == ROTATION_90)
								|| (Target->m_TileSIndexR == TILE_STOP
										&& Target->m_TileSFlagsR == ROTATION_90)
								|| (Target->m_TileSIndexR == TILE_STOPS
										&& (Target->m_TileSFlagsR == ROTATION_90
												|| Target->m_TileSFlagsR
														== ROTATION_270))
								|| (Target->m_TileSIndexR == TILE_STOPA)))
					Temp.x = 0;
				if (Temp.y < 0
						&& ((Target->m_TileIndex == TILE_STOP
								&& Target->m_TileFlags == ROTATION_180)
								|| (Target->m_TileIndexB == TILE_STOP
										&& Target->m_TileFlagsB == ROTATION_180)
								|| (Target->m_TileIndexB == TILE_STOPS
										&& (Target->m_TileFlagsB == ROTATION_0
												|| Target->m_TileFlagsB
														== ROTATION_180))
//.........这里部分代码省略.........
开发者ID:BannZay,项目名称:ddnet,代码行数:101,代码来源:dragger.cpp


示例11: Server

void CDragger::Snap(int SnappingClient)
{
	if (((CGameControllerDDRace*) GameServer()->m_pController)->m_Teams.GetTeamState(
			m_CaughtTeam) == CGameTeams::TEAMSTATE_EMPTY)
		return;

	CCharacter *Target = m_Target;

	for (int i = 0; i < MAX_CLIENTS; i++)
	{
		if (m_SoloIDs[i] == -1)
			break;

		Server()->SnapFreeID(m_SoloIDs[i]);
		m_SoloIDs[i] = -1;
	}

	int pos = 0;

	for (int i = -1; i < MAX_CLIENTS; i++)
	{
		if (i >= 0)
		{
			Target = m_SoloEnts[i];

			if (!Target)
				continue;
		}

		if (Target)
		{
			if (NetworkClipped(SnappingClient, m_Pos)
					&& NetworkClipped(SnappingClient, Target->m_Pos))
				continue;
		}
		else if (NetworkClipped(SnappingClient, m_Pos))
			continue;

		CCharacter * Char = GameServer()->GetPlayerChar(SnappingClient);

		if(SnappingClient > -1 && (GameServer()->m_apPlayers[SnappingClient]->GetTeam() == -1
					|| GameServer()->m_apPlayers[SnappingClient]->IsPaused())
				&& GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID != SPEC_FREEVIEW)
			Char = GameServer()->GetPlayerChar(GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID);

		int Tick = (Server()->Tick() % Server()->TickSpeed()) % 11;
		if (Char && Char->IsAlive()
				&& (m_Layer == LAYER_SWITCH && m_Number
						&& !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()]
						&& (!Tick)))
			continue;
		if (Char && Char->IsAlive())
		{
			if (Char->Team() != m_CaughtTeam)
				continue;
		}
		else
		{
			// send to spectators only active draggers and some inactive from team 0
			if (!((Target && Target->IsAlive()) || m_CaughtTeam == 0))
				continue;
		}

		if (Char && Char->IsAlive() && Target && Target->IsAlive() && Target->GetPlayer()->GetCID() != Char->GetPlayer()->GetCID() && !Char->GetPlayer()->m_ShowOthers &&
			(Char->Teams()->m_Core.GetSolo(SnappingClient) || Char->Teams()->m_Core.GetSolo(Target->GetPlayer()->GetCID())))
		{
			continue;
		}

		CNetObj_Laser *obj;

		if (i == -1)
		{
			obj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(
					NETOBJTYPE_LASER, m_ID, sizeof(CNetObj_Laser)));
		}
		else
		{
			m_SoloIDs[pos] = Server()->SnapNewID();
			obj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem( // TODO: Have to free IDs again?
					NETOBJTYPE_LASER, m_SoloIDs[pos], sizeof(CNetObj_Laser)));
			pos++;
		}

		if (!obj)
			continue;
		obj->m_X = (int)m_Pos.x;
		obj->m_Y = (int)m_Pos.y;
		if (Target)
		{
			obj->m_FromX = (int)Target->m_Pos.x;
			obj->m_FromY = (int)Target->m_Pos.y;
		}
		else
		{
			obj->m_FromX = (int)m_Pos.x;
			obj->m_FromY = (int)m_Pos.y;
		}

		int StartTick = m_EvalTick;
//.........这里部分代码省略.........
开发者ID:BannZay,项目名称:ddnet,代码行数:101,代码来源:dragger.cpp


示例12: DirtyVisibility

void CDigitanksEntity::Think()
{
	BaseClass::Think();

	if (m_flNextDirtyOrigin > 0 && GameServer()->GetGameTime() > m_flNextDirtyOrigin)
	{
		DirtyVisibility();

		m_flNextDirtyOrigin = 0;
	}

	if (m_flNextDirtyArea > 0 && GameServer()->GetGameTime() > m_flNextDirtyArea)
	{
		CDigitanksEntity* pOther = this;

		while (true)
		{
			pOther = CBaseEntity::FindClosest<CDigitanksEntity>(GetGlobalOrigin(), pOther);

			if (!pOther)
				break;

			if (pOther == this)
				continue;

			if (pOther->Distance(GetGlobalOrigin()) > VisibleRange() + DigitanksGame()->FogPenetrationDistance())
				break;

			pOther->DirtyVisibility();
		}

		m_flNextDirtyArea = 0;
	}

	if (GameNetwork()->IsHost() && !IsAlive() && GameServer()->GetGameTime() > m_flTimeKilled + 1.0f)
	{
		GameServer()->Delete(this);

		if (DigitanksGame()->GetTerrain()->IsPointOverHole(GetGlobalOrigin()))
		{
			CWreckage* pWreckage = CreateWreckage();

			if (pWreckage)
			{
				pWreckage->FellIntoHole();
				if (DigitanksGame()->GetGameType() == GAMETYPE_ARTILLERY)
					pWreckage->SetScale(2);
			}
		}
		else if (DigitanksGame()->GetGameType() == GAMETYPE_ARTILLERY)
		{
			switch (RandomInt(0, 8))
			{
			case 0:
			case 6:
			case 7:
			case 8:
			default:
			{
				for (size_t i = 0; i < 8; i++)
				{
					CDebris* pDebris = GameServer()->Create<CDebris>("CDebris");
					pDebris->SetGlobalOrigin(GetGlobalOrigin());
				}

				CWreckage* pWreckage = CreateWreckage();
				pWreckage->SetScale(2);

				DigitanksGame()->GetOverheadCamera()->Shake(GetGlobalOrigin(), 3);
				break;
			}

			case 1:
			{
				CProjectile* pProjectile = GameServer()->Create<CLargeShell>("CLargeShell");
				pProjectile->SetOwner(NULL);
				pProjectile->SetGlobalOrigin(GetGlobalOrigin());
				pProjectile->Explode();
				break;
			}

			case 2:
			{
				CProjectile* pProjectile = GameServer()->Create<CAOEShell>("CAOEShell");
				pProjectile->SetOwner(NULL);
				pProjectile->SetGlobalOrigin(GetGlobalOrigin());
				pProjectile->Explode();
				break;
			}

			case 3:
			{
				CProjectile* pProjectile = GameServer()->Create<CClusterBomb>("CClusterBomb");
				pProjectile->SetOwner(NULL);
				pProjectile->SetGlobalOrigin(GetGlobalOrigin());
				pProjectile->Explode();
				break;
			}

			case 4:
//.........这里部分代码省略.........
开发者ID:BSVino,项目名称:Digitanks,代码行数:101,代码来源:digitanksentity.cpp


示例13: c

void CDigitanksEntity::OnRender(CGameRenderingContext* pContext) const
{
	BaseClass::OnRender(pContext);

	if (GameServer()->GetRenderer()->IsRenderingTransparent() && IsImprisoned())
	{
		CGameRenderingContext c(GameServer()->GetRenderer(), true);
		c.SetBackCulling(false);
		c.SetBlend(BLEND_ADDITIVE);
		c.Scale(GetBoundingRadius(), GetBoundingRadius(), GetBoundingRadius());
		c.Rotate((float)GameServer()->GetGameTime() * 90, Vector(0, 0, 1));

		float flVisibility = GetVisibility() * 0.6f;
		c.UseProgram("scroll");
		c.SetUniform("iTexture", 0);
		c.SetUniform("flAlpha", flVisibility);
		c.SetUniform("flTime", (float)-GameServer()->GetGameTime());
		c.SetUniform("flSpeed", 1.0f);

		c.RenderModel(m_iCageModel, this);
	}

	if (GameServer()->GetRenderer()->IsRenderingTransparent() && IsImprisoned())
	{
		CGameRenderingContext c(GameServer()->GetRenderer(), true);
		c.SetBackCulling(false);
		c.SetBlend(BLEND_ADDITIVE);
		c.Scale(GetBoundingRadius()+1, GetBoundingRadius()+1, GetBoundingRadius()+1);
		c.Rotate(-(float)GameServer()->GetGameTime() * 90, Vector(0, 0, 1));

		float flVisibility = GetVisibility() * 0.6f;
		c.UseProgram("scroll");
		c.SetUniform("iTexture", 0);
		c.SetUniform("flAlpha", flVisibility);
		c.SetUniform("flTime", (float)-GameServer()->GetGameTime());
		c.SetUniform("flSpeed", 1.0f);

		c.RenderModel(m_iCageModel);
	}

	if (!GameServer()->GetRenderer()->IsRenderingTransparent())
		return;

	if (!DigitanksGame()->GetTerrain()->GetBit(CTerrain::WorldToArraySpace(GetGlobalOrigin().x), CTerrain::WorldToArraySpace(GetGlobalOrigin().y), TB_TREE))
		return;

	if (GetVisibility() < 0.6f)
		return;

	CGameRenderingContext c(GameServer()->GetRenderer(), true);
	c.SetBlend(BLEND_NONE);
	c.SetAlpha(1);
	c.BindTexture(0);

	TStubbed("Tank outlines in trees");

	/*
	// Draw outlines of objects in trees.
	glPushAttrib( GL_ALL_ATTRIB_BITS );

	glDisable( GL_TEXTURE_2D );
	glEnable( GL_POLYGON_OFFSET_FILL );
	glPolygonOffset( -3.5f, -3.5f );

	glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
	glDepthMask(true);
	glEnable(GL_DEPTH_TEST);
	pContext->RenderModel(GetModel());

	glDisable( GL_POLYGON_OFFSET_FILL );
	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
	glDepthMask(false);
	glEnable(GL_DEPTH_TEST);
	glLineWidth( 2.0f );
	glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
	glColor3ubv( Color(0, 0, 0) );
	pContext->RenderModel(GetModel());

	glPopAttrib();
	*/
}
开发者ID:BSVino,项目名称:Digitanks,代码行数:81,代码来源:digitanksentity.cpp


示例14: GameServer

void CCharacter::Destroy()
{
	GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = 0;
	m_Alive = false;
}
开发者ID:CoolerMAN,项目名称:tdtw,代码行数:5,代码来源:character.cpp


示例15: GameServer

void CLaser::Reset()
{
	GameServer()->m_World.DestroyEntity(this);
}
开发者ID:Bloodwork28,项目名称:teeworlds-uTown,代码行数:4,代码来源:laser.cpp


示例16: IGameController

CGameControllerMOD::CGameControllerMOD(class CGameContext *pGameServer)
: IGameController(pGameServer)
{
	m_pGameType = "InfClass";
	srand (time(0));
	
	m_TotalProbInfectedClass = 0.0;
	
	m_ClassProbability[PLAYERCLASS_SMOKER] = 1.0f;
	m_TotalProbInfectedClass += m_ClassProbability[PLAYERCLASS_SMOKER];
	
	m_ClassProbability[PLAYERCLASS_HUNTER] = 0.6666f * m_ClassProbability[PLAYERCLASS_SMOKER];
	m_TotalProbInfectedClass += m_ClassProbability[PLAYERCLASS_HUNTER];
	
	m_ClassProbability[PLAYERCLASS_BOOMER] = 0.6666f * m_ClassProbability[PLAYERCLASS_SMOKER];
	m_TotalProbInfectedClass += m_ClassProbability[PLAYERCLASS_BOOMER];
	
	m_ClassProbability[PLAYERCLASS_GHOST] = 0.25f * m_ClassProbability[PLAYERCLASS_SMOKER];
	m_TotalProbInfectedClass += m_ClassProbability[PLAYERCLASS_GHOST];
	
	m_ClassProbability[PLAYERCLASS_SPIDER] = 0.25f * m_ClassProbability[PLAYERCLASS_SMOKER];
	m_TotalProbInfectedClass += m_ClassProbability[PLAYERCLASS_SPIDER];
	
	m_ClassProbability[PLAYERCLASS_WITCH] = 0.25f * m_ClassProbability[PLAYERCLASS_SMOKER];
	m_TotalProbInfectedClass += m_ClassProbability[PLAYERCLASS_WITCH];
	
	m_ClassProbability[PLAYERCLASS_UNDEAD] = 0.20f * m_ClassProbability[PLAYERCLASS_SMOKER];
	m_TotalProbInfectedClass += m_ClassProbability[PLAYERCLASS_UNDEAD];
	
	m_TotalProbHumanClass = 0.0;
	
	m_ClassProbability[PLAYERCLASS_ENGINEER] = 1.0f;
	m_TotalProbHumanClass += m_ClassProbability[PLAYERCLASS_ENGINEER];
	
	m_ClassProbability[PLAYERCLASS_SOLDIER] = 1.0f;
	m_TotalProbHumanClass += m_ClassProbability[PLAYERCLASS_SOLDIER];
	
	m_ClassProbability[PLAYERCLASS_MERCENARY] = 1.0f;
	m_TotalProbHumanClass += m_ClassProbability[PLAYERCLASS_MERCENARY];
	
	m_ClassProbability[PLAYERCLASS_SNIPER] = 1.0f;
	m_TotalProbHumanClass += m_ClassProbability[PLAYERCLASS_SNIPER];
	
	m_ClassProbability[PLAYERCLASS_SCIENTIST] = 0.5f;
	m_TotalProbHumanClass += m_ClassProbability[PLAYERCLASS_SCIENTIST];
	
	m_ClassProbability[PLAYERCLASS_NINJA] = 0.5f;
	m_TotalProbHumanClass += m_ClassProbability[PLAYERCLASS_NINJA];
	
	m_ClassProbability[PLAYERCLASS_MEDIC] = 0.5f;
	m_TotalProbHumanClass += m_ClassProbability[PLAYERCLASS_MEDIC];
	
	m_GrowingMap = 0;
	
	m_ExplosionStarted = false;
	m_MapWidth = GameServer()->Collision()->GetWidth();
	m_MapHeight = GameServer()->Collision()->GetHeight();
	m_GrowingMap = new int[m_MapWidth*m_MapHeight];
	
	m_HumanCounter = 0;
	m_InfectedCounter = 0;
	m_InfectedStarted = false;
	
	for(int j=0; j<m_MapHeight; j++)
	{
		for(int i=0; i<m_MapWidth; i++)
		{
			vec2 TilePos = vec2(16.0f, 16.0f) + vec2(i*32.0f, j*32.0f);
			if(GameServer()->Collision()->CheckPoint(TilePos))
			{
				m_GrowingMap[j*m_MapWidth+i] = 4;
			}
			else
			{
				m_GrowingMap[j*m_MapWidth+i] = 1;
			}
		}
	}
}
开发者ID:KingteEGER,项目名称:teeworlds-infclass,代码行数:79,代码来源:mod.cpp


示例17: Tick

void CLaser::Tick()
{
	if(Server()->Tick() > m_EvalTick+(Server()->TickSpeed()*GameServer()->Tuning()->m_LaserBounceDelay)/1000.0f)
		DoBounce();
}
开发者ID:Bloodwork28,项目名称:teeworlds-uTown,代码行数:5,代码来源:laser.cpp


示例18: sizeof

void CGameControllerMOD::Snap(int SnappingClient)
{
	CNetObj_GameInfo *pGameInfoObj = (CNetObj_GameInfo *)Server()->SnapNewItem(NETOBJTYPE_GAMEINFO, 0, sizeof(CNetObj_GameInfo));
	if(!pGameInfoObj)
		return;

	pGameInfoObj->m_GameFlags = m_GameFlags;
	pGameInfoObj->m_GameStateFlags = 0;
	if(m_GameOverTick != -1)
		pGameInfoObj->m_GameStateFlags |= GAMESTATEFLAG_GAMEOVER;
	if(m_SuddenDeath)
		pGameInfoObj->m_GameStateFlags |= GAMESTATEFLAG_SUDDENDEATH;
	if(GameServer()->m_World.m_Paused)
		pGameInfoObj->m_GameStateFlags |= GAMESTATEFLAG_PAUSED;
	pGameInfoObj->m_RoundStartTick = m_RoundStartTick;
	pGameInfoObj->m_WarmupTimer = m_Warmup;

	pGameInfoObj->m_ScoreLimit = g_Config.m_SvScorelimit;
	pGameInfoObj->m_TimeLimit = g_Config.m_SvTimelimit;

	pGameInfoObj->m_RoundNum = (str_length(g_Config.m_SvMaprotation) && g_Config.m_SvRoundsPerMap) ? g_Config.m_SvRoundsPerMap : 0;
	pGameInfoObj->m_RoundCurrent = m_RoundCount+1;

	//Generate class mask
	int ClassMask = 0;
	{
		int Defender = 0;
		int Medic = 0;
		int Support = 0;
		
		for(int i = 0; i < MAX_CLIENTS; i ++)
		{
			CPlayer *pPlayer = GameServer()->m_apPlayers[i];
			
			if(!pPlayer) continue;
			if(pPlayer->GetTeam() == TEAM_SPECTATORS) continue;
			
			switch(pPlayer->GetClass())
			{
				case PLAYERCLASS_NINJA:
				case PLAYERCLASS_MERCENARY:
				case PLAYERCLASS_SNIPER:
					Support++;
					break;
				case PLAYERCLASS_ENGINEER:
				case PLAYERCLASS_SOLDIER:
				case PLAYERCLASS_SCIENTIST:
					Defender++;
					break;
				case PLAYERCLASS_MEDIC:
					Medic++;
					break;
					
			}
		}
		
		if(Defender < g_Config.m_InfDefenderLimit)
			ClassMask |= CMapConverter::MASK_DEFENDER;
		if(Medic < g_Config.m_InfMedicLimit)
			ClassMask |= CMapConverter::MASK_MEDIC;
		if(Support < g_Config.m_InfSupportLimit)
			ClassMask |= CMapConverter::MASK_SUPPORT;
	}
	
	if(GameServer()->m_apPlayers[SnappingClient] && GameServer()->m_apPlayers[SnappingClient]->m_InClassChooserMenu)
	{
		int Item = GameServer()->m_apPlayers[SnappingClient]->m_MenuClassChooserItem;
		int Timer = ((CMapConverter::TIMESHIFT_MENUCLASS + (Item+1) + ClassMask*CMapConverter::TIMESHIFT_MENUCLASS_MASK)*60 + 30)*Server()->TickSpeed();
		
		pGameInfoObj->m_RoundStartTick = Server()->Tick() - Timer;
		pGameInfoObj->m_TimeLimit = 0;
	}

	CNetObj_GameData *pGameDataObj = (CNetObj_GameData *)Server()->SnapNewItem(NETOBJTYPE_GAMEDATA, 0, sizeof(CNetObj_GameData));
	if(!pGameDataObj)
		return;

	//Search for witch
	for(int i = 0; i < MAX_CLIENTS; i++)
	{
		CPlayer *pPlayer = GameServer()->m_apPlayers[i];
		
		if(!pPlayer) continue;
		if(pPlayer->GetTeam() == TEAM_SPECTATORS) continue;
		
		if(pPlayer->GetClass() == PLAYERCLASS_WITCH)
		{
			pGameDataObj->m_FlagCarrierRed = i;
		}
	}
	pGameDataObj->m_FlagCarrierBlue = FLAG_ATSTAND;
}
开发者ID:KingteEGER,项目名称:teeworlds-infclass,代码行数:92,代码来源:mod.cpp


示例19: normalize

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GameWorld函数代码示例发布时间:2022-05-30
下一篇:
C++ GameOver函数代码示例发布时间: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