Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
	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);
	}
Ejemplo n.º 3
0
	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;
	}