コード例 #1
0
ファイル: commonItems.cpp プロジェクト: szakats/bzflag_mirror
void GameInfo::keyCallback (std::string &data, const std::string &key)
{
  double now = bz_getCurrentTime();

  if (key == "mapfile")
    data += mapFile;
  else if ( key == "redteamscore")
    data += format("%d",bz_getTeamScore(eRedTeam));
  else if ( key == "redteamwins")
    data += format("%d",bz_getTeamWins(eRedTeam));
  else if ( key == "redteamlosses")
    data += format("%d",bz_getTeamLosses(eRedTeam));
  else if ( key == "greenteamscore")
    data += format("%d",bz_getTeamScore(eGreenTeam));
  else if ( key == "greenteamwins")
    data += format("%d",bz_getTeamWins(eGreenTeam));
  else if ( key == "greenteamlosses")
    data += format("%d",bz_getTeamLosses(eGreenTeam));
  else if ( key == "blueteamscore")
    data += format("%d",bz_getTeamScore(eBlueTeam));
  else if ( key == "blueteamwins")
    data += format("%d",bz_getTeamWins(eBlueTeam));
  else if ( key == "blueteamlosses")
    data += format("%d",bz_getTeamLosses(eBlueTeam));
  else if ( key == "purpleteamscore")
    data += format("%d",bz_getTeamScore(ePurpleTeam));
  else if ( key == "purpleteamwins")
    data += format("%d",bz_getTeamWins(ePurpleTeam));
  else if ( key == "purpleteamlosses")
    data += format("%d",bz_getTeamLosses(ePurpleTeam));
  else if ( key == "kbin")
    data += format("%f",(double)bytesIn/1024.0);
  else if ( key == "kbout")
    data += format("%f",(double)bytesOut/1024.0);
}
コード例 #2
0
ファイル: pushstats.cpp プロジェクト: Rudlandh/bzflag
	void buildStateHash(std::string &params)
	{
		int hash = sumString(mapFile);

		int i = 0;
		i += bz_getTeamScore(eRedTeam);
		i += bz_getTeamScore(eGreenTeam);
		i += bz_getTeamScore(eBlueTeam);
		i += bz_getTeamScore(ePurpleTeam);
		i += bz_getTeamWins(eRedTeam);
		i += bz_getTeamWins(eGreenTeam);
		i += bz_getTeamWins(eBlueTeam);
		i += bz_getTeamWins(ePurpleTeam);
		i += bz_getTeamLosses(eRedTeam);
		i += bz_getTeamLosses(eGreenTeam);
		i += bz_getTeamLosses(eBlueTeam);
		i += bz_getTeamLosses(ePurpleTeam);

		hash += (i * 1000);

		i = 0;
		bz_APIIntList *players = bz_newIntList();
		bz_getPlayerIndexList(players);;
		if (players && players->size())
		{
			for (unsigned int p = 0; p < players->size(); p++ )
			{
				bz_BasePlayerRecord	*player = bz_getPlayerByIndex(players->get(p));

				//int playerID = players->get(p);
				if (player)
				{
					std::string BZID = player->bzID.c_str();
					if (BZID.size())
						i += sumString(BZID);
					else
						i += sumString(std::string(player->callsign.c_str()));

					i += sumString("NONE");

					i += player->wins;
					i += player->losses;
					i += player->teamKills;

					bz_freePlayerRecord(player);
				}
			}
		}
		bz_deleteIntList(players);

		hash += (i * 100000);

		params += format("&hash=%d",hash);
	}
コード例 #3
0
ファイル: pushstats.cpp プロジェクト: Rudlandh/bzflag
	bool getPushHeader(std::string &header)
	{
		bz_ApiString host = bz_getPublicAddr();
		bz_ApiString desc = bz_getPublicDescription();

		header += "&isgameserver=1";

		header+= "&host=";
		if (host.size())
			header += host.c_str();
		else
			return false;

		header += format("&port=%s",port.c_str());
		if (desc.size())
			header += "&desc=" + std::string(desc.c_str());

		if (mapFile.size())
			header += "&map=" + mapFile;

		// game mode
		header += "&game=";
		switch(bz_getGameType())
		{
		default:
			header +="TeamFFA";
			break;
		case eCTFGame:
			header +="CTF";
			break;
		case eRabbitGame:
			header +="Rabbit";
			break;
		}

		// team scores
		header += format("&redteamscore=%d",bz_getTeamScore(eRedTeam));
		header += format("&redteamwins=%d",bz_getTeamWins(eRedTeam));
		header += format("&redteamlosses=%d",bz_getTeamLosses(eRedTeam));
		header += format("&greenteamscore=%d",bz_getTeamScore(eGreenTeam));
		header += format("&greenteamwins=%d",bz_getTeamWins(eGreenTeam));
		header += format("&greenteamlosses=%d",bz_getTeamLosses(eGreenTeam));
		header += format("&blueteamscore=%d",bz_getTeamScore(eBlueTeam));
		header += format("&blueteamwins=%d",bz_getTeamWins(eBlueTeam));
		header += format("&blueteamlosses=%d",bz_getTeamLosses(eBlueTeam));
		header += format("&purpleteamscore=%d",bz_getTeamScore(ePurpleTeam));
		header += format("&purpleteamwins=%d",bz_getTeamWins(ePurpleTeam));
		header += format("&purpleteamlosses=%d",bz_getTeamLosses(ePurpleTeam));
		return true;
	}
コード例 #4
0
ファイル: Defusal.cpp プロジェクト: allejo/Defusal
void killAllTeam(int winner, bz_eTeamType teamToKill, bz_eTeamType teamToAward)
{
	bz_APIIntList *playerList = bz_newIntList();
	bz_getPlayerIndexList(playerList);

	for ( unsigned int i = 0; i < playerList->size(); i++ ){
		int player = (*playerList)[i];
		bz_BasePlayerRecord *PlayerRecord = bz_getPlayerByIndex(player);
		if (PlayerRecord->team == teamToKill)
			bz_killPlayer(player,0,winner);
		else if(PlayerRecord->team == teamToAward)
			bz_setPlayerWins(player, (bz_getPlayerWins(player)+2));
		bz_freePlayerRecord(PlayerRecord);
	}	
		
	bz_setTeamWins (teamToAward, (bz_getTeamWins(teamToAward)+1));
	bz_setTeamLosses (teamToKill, (bz_getTeamLosses (teamToKill)+1));
	
}