Exemple #1
0
bool SpawnAtBase::MapObject (bz_ApiString object, bz_CustomMapObjectInfo *data)
{
    if (object != "BASESPAWNZONE" || !data)
    {
        return false;
    }

    BaseSpawnZone newZone;
    newZone.handleDefaultOptions(data);

    for (unsigned int i = 0; i < data->data.size(); i++)
    {
        std::string line = data->data.get(i).c_str();

        bz_APIStringList *nubs = bz_newStringList();
        nubs->tokenize(line.c_str(), " ", 0, true);

        if (nubs->size() > 0)
        {
            std::string key = bz_toupper(nubs->get(0).c_str());

            if (key == "COLOR" && nubs->size() == 2)
            {
                newZone.team = (bz_eTeamType)atoi(nubs->get(1).c_str());
            }
        }

        bz_deleteStringList(nubs);
    }

    TeamZones[newZone.team].push_back(newZone);

    return true;
}
Exemple #2
0
bool KOTHMapHandler::handle(bz_ApiString object, bz_CustomMapObjectInfo * data)
{
  if (object != "KOTH" || !data)
    return false;

  // parse all the chunks
  for (unsigned int i = 0; i < data->data.size(); i++) {
    std::string line = data->data.get(i).c_str();

    bz_APIStringList *nubs = bz_newStringList();
    nubs->tokenize(line.c_str(), " ", 0, true);

    if (nubs->size() > 0) {
      std::string key = bz_toupper(nubs->get(0).c_str());

      if (key == "BBOX" && nubs->size() > 6) {
	kothzone.box = true;
	kothzone.xMin = (float) atof(nubs->get(1).c_str());
	kothzone.xMax = (float) atof(nubs->get(2).c_str());
	kothzone.yMin = (float) atof(nubs->get(3).c_str());
	kothzone.yMax = (float) atof(nubs->get(4).c_str());
	kothzone.zMin = (float) atof(nubs->get(5).c_str());
	kothzone.zMax = (float) atof(nubs->get(6).c_str());
      } else if (key == "CYLINDER" && nubs->size() > 5) {
	kothzone.box = false;
	kothzone.rad = (float) atof(nubs->get(5).c_str());
	kothzone.xMax = (float) atof(nubs->get(1).c_str());
	kothzone.yMax = (float) atof(nubs->get(2).c_str());
	kothzone.zMin = (float) atof(nubs->get(3).c_str());
	kothzone.zMax = (float) atof(nubs->get(4).c_str());
      } else if (key == "TEAMPLAY") {
	koth.teamPlay = true;
      } else if (key == "NOSOUND") {
	koth.soundEnabled = false;
      } else if (key == "AUTOTIME" && nubs->size() == 1) {
	koth.autoTimeOn = true;
      } else if (key == "AUTOTIME" && nubs->size() > 2) {
	double temp1 = (double) atof(nubs->get(1).c_str());
	double temp2 = (double) atof(nubs->get(2).c_str());
	if (temp1 >= 1 && temp1 <= 99)
	  koth.timeMult = temp1 / 100;
	if (temp2 >= 1 && temp2 <= 99)
	  koth.timeMultMin = temp2 / 100;
	koth.autoTimeOn = true;
      } else if (key == "HOLDTIME" && nubs->size() > 1) {
	double temp = (double) atof(nubs->get(1).c_str());
	if (temp >= 1 && temp <= 7200)
	  koth.TTH = temp;
      }
    }
    bz_deleteStringList(nubs);
  }
  bz_setMaxWaitTime(0.5, "KOTH");
  return true;
}
Exemple #3
0
bool KOTHMapHandler::MapObject ( bz_ApiString object, bz_CustomMapObjectInfo *data )
{
	if (object != "KOTH" || !data)
		return false;

	kothzone.handleDefaultOptions(data);

	// parse all the chunks
	for ( unsigned int i = 0; i < data->data.size(); i++ )
	{
		std::string line = data->data.get(i).c_str();

		bz_APIStringList *nubs = bz_newStringList();
		nubs->tokenize(line.c_str()," ",0,true);

		if ( nubs->size() > 0)
		{
			std::string key = bz_toupper(nubs->get(0).c_str());

			if ( key == "TEAMPLAY")
			{
				koth.teamPlay = true;
			}
			else if ( key == "NOSOUND")
			{
				koth.soundEnabled = false;
			}
			else if ( key == "AUTOTIME" && nubs->size() == 1 )
			{
				koth.autoTimeOn = true;
			}
			else if ( key == "AUTOTIME" && nubs->size() > 2 )
			{
				double temp1 = (double)atof(nubs->get(1).c_str());
				double temp2 = (double)atof(nubs->get(2).c_str());
				if (temp1 >= 1 && temp1 <= 99)
					koth.timeMult = temp1 / 100;
				if (temp2 >= 1 && temp2 <= 99)
					koth.timeMultMin = temp2 / 100;
				koth.autoTimeOn = true;
			}
			else if ( key == "HOLDTIME" && nubs->size() > 1 )
			{
				double temp = (double)atof(nubs->get(1).c_str());
				if (temp >= 1 && temp <= 7200)
					koth.TTH = temp;
			}
		}

		bz_deleteStringList(nubs);
	}
	return true;
}
Exemple #4
0
bool FlagStayZoneHandler::MapObject ( bz_ApiString object, bz_CustomMapObjectInfo *data )
{
	if (object != "FLAGSTAYZONE" || !data)
		return false;

	FlagStayZone newZone;
	newZone.handleDefaultOptions(data);

	// parse all the chunks
	for ( unsigned int i = 0; i < data->data.size(); i++ )
	{
		std::string line = data->data.get(i).c_str();

		bz_APIStringList *nubs = bz_newStringList();
		nubs->tokenize(line.c_str()," ",0,true);

		if ( nubs->size() > 0)
		{
			std::string key = bz_toupper(nubs->get(0).c_str());

			if ( key == "FLAG" && nubs->size() > 1)
			{
				std::string flag = bz_toupper(nubs->get(1).c_str());
				newZone.flagList.push_back(flag);
			}
			else if ( key == "MESSAGE" && nubs->size() > 1 )
			{
				newZone.message = nubs->get(1).c_str();
			}
		}
	  
		bz_deleteStringList(nubs);
	}

	zoneList.push_back(newZone);
	return true;
}
Exemple #5
0
bool KeepAwayMapHandler::MapObject ( bz_ApiString object, bz_CustomMapObjectInfo *data )
{
	if (object != "KEEPAWAY" || !data)
		return false;

	// parse all the chunks
	for ( unsigned int i = 0; i < data->data.size(); i++ )
	{
		std::string line = data->data.get(i).c_str();

		bz_APIStringList *nubs = bz_newStringList();
		nubs->tokenize(line.c_str()," ",0,true);

		if ( nubs->size() > 0)
		{
			std::string key = bz_toupper(nubs->get(0).c_str());

			if ( key == "TEAMPLAY" && nubs->size() > 0 )
				keepaway.teamPlay = true;

			else if ( key == "AUTOTIME" && nubs->size() > 0 )
				keepaway.autoTimeOn = true;

			else if ( key == "AUTOTIME" && nubs->size() > 2 )
			{
				double temp1 = (double)atof(nubs->get(1).c_str());
				double temp2 = (double)atof(nubs->get(2).c_str());
				if (temp1 >= 1 && temp1 <= 99) // if parameter out of range, keeps default
					keepaway.timeMult = temp1 / 100;
				if (temp2 >= 1 && temp2 <= 99) // if parameter out of range, keeps default
					keepaway.timeMultMin = temp2 / 100;
				keepaway.autoTimeOn = true;
			}

			else if ( key == "NOSOUND" && nubs->size() > 0 )
				keepaway.soundEnabled = false;

			else if ( key == "NOFLAGRESET" && nubs->size() > 0 )
				keepaway.flagResetEnabled = false;

			else if ( key == "HOLDTIME" && nubs->size() > 1 )
			{
				double temp = (double)atof(nubs->get(1).c_str());
				if (temp >= 1 && temp <= 7200) // if parameter out of range, keeps default
					keepaway.TTH = temp;
			}

			else if ( key == "KEEPAWAYFLAGS" && nubs->size() > 1)
			{
				for (unsigned int j = 1; j < nubs->size(); j++)
				{
					std::string flag = nubs->get(j).c_str();
					if (convertFlag(flag) != "")  // must be valid flag type, reject nub otherwise
						keepaway.flagsList.push_back(flag);
				}
			}

			else if ( key == "FORCEDFLAGS" && nubs->size() > 0 )
				keepaway.forcedFlags = true;
		}
		bz_deleteStringList(nubs);
	}

	if (!keepaway.flagsList.empty())
		keepaway.flagToKeepIndex = -1; // this will increment 1 when we get to getFlag() function;
	else
	{
		keepaway.flagToKeep = ""; // map file didn't give us any flags
		keepaway.flagToKeepIndex = 0;
	}

	return true;
}
bool RabidRabbitHandler::MapObject(bz_ApiString object, bz_CustomMapObjectInfo *data)
{
  if (object == "RRSOUNDOFF")
    rrzoneinfo.soundEnabled = false;

  if (object == "RRCYCLEONDIE")
    rrzoneinfo.cycleOnDie = true;

  if (object != "RABIDRABBITZONE" || !data)
    return false;

  RabidRabbitZone newZone;

  // parse all the chunks
  for (unsigned int i = 0; i < data->data.size(); i++) {
    std::string line = data->data.get(i).c_str();

    bz_APIStringList *nubs = bz_newStringList();
    nubs->tokenize(line.c_str()," ",0,true);

    if (nubs->size() > 0) {
      std::string key = bz_toupper(nubs->get(0).c_str());

      if (key == "BBOX" && nubs->size() > 6) {
	newZone.box = true;
	newZone.xMin = (float)atof(nubs->get(1).c_str());
	newZone.xMax = (float)atof(nubs->get(2).c_str());
	newZone.yMin = (float)atof(nubs->get(3).c_str());
	newZone.yMax = (float)atof(nubs->get(4).c_str());
	newZone.zMin = (float)atof(nubs->get(5).c_str());
	newZone.zMax = (float)atof(nubs->get(6).c_str());
      } else if (key == "CYLINDER" && nubs->size() > 5) {
	newZone.box = false;
	newZone.rad = (float)atof(nubs->get(5).c_str());
	newZone.xMax =(float)atof(nubs->get(1).c_str());
	newZone.yMax =(float)atof(nubs->get(2).c_str());
	newZone.zMin =(float)atof(nubs->get(3).c_str());
	newZone.zMax =(float)atof(nubs->get(4).c_str());
      } else if (key == "RRZONEWW" && nubs->size() > 10) {
	newZone.WW = nubs->get(1);
	newZone.WWLifetime = (float)atof(nubs->get(2).c_str());
	newZone.WWPosition[0] = (float)atof(nubs->get(3).c_str());
	newZone.WWPosition[1] = (float)atof(nubs->get(4).c_str());
	newZone.WWPosition[2] = (float)atof(nubs->get(5).c_str());
	newZone.WWTilt = (float)atof(nubs->get(6).c_str());
	newZone.WWTilt = (newZone.WWTilt / 360) * (2 * (float)newZone.pi);
	newZone.WWDirection = (float)atof(nubs->get(7).c_str());
	newZone.WWDirection = (newZone.WWDirection / 360) * (2 * (float)newZone.pi);
	newZone.WWShotID = (int)atoi(nubs->get(8).c_str());
	newZone.WWDT = (float)atof(nubs->get(9).c_str());
	newZone.WWRepeat = (float)atof(nubs->get(10).c_str());
      } else if (key == "SERVERMESSAGE" && nubs->size() > 1) {
	newZone.servermessage = nubs->get(1).c_str();
      } else if (key == "ZONEKILLHUNTER") {
	if (nubs->size() > 1)
	  newZone.playermessage = nubs->get(1).c_str();
	newZone.zonekillhunter = true;
      }
    }
    bz_deleteStringList(nubs);
  }

  zoneList.push_back(newZone);
  return true;
}