<commit_before>// flagStay.cpp : Defines the entry point for the DLL application.
//

#include "bzfsAPI.h"
#include <map>
#include <cmath>

class FlagStayZoneHandler : public bz_CustomMapObjectHandler
{
public:
	virtual bool MapObject ( bz_ApiString object, bz_CustomMapObjectInfo *data );
};

FlagStayZoneHandler	flagStayZoneHandler;

class EventHandler : public bz_Plugin
{
public:
	virtual const char* Name (){return "Flag Stay Zones";}
	virtual void Init ( const char* cl );
	virtual void Cleanup ();
	virtual void Event ( bz_EventData *eventData );
};

BZ_PLUGIN(EventHandler)

void EventHandler::Init ( const char* /*commandLine*/ )
{
  bz_registerCustomMapObject("FLAGSTAYZONE",&flagStayZoneHandler);

  Register(bz_ePlayerUpdateEvent);
}

void EventHandler::Cleanup ( void )
{
  Flush();
  bz_removeCustomMapObject("FLAGSTAYZONE");
}

class FlagStayZone
{
public:
	FlagStayZone()
	{
		box = false;
		xMax = xMin = yMax = yMin = zMax = zMin = rad = rot = 0;
	}

	bool box;
	float xMax,xMin,yMax,yMin,zMax,zMin;
	float rad, rot;

	std::string message;
	bool pointIn ( float pos[3] )
	{
		if ( box )
		{
			if (rot == 0 || rot == 180)
			{
				if ( pos[0] > xMax || pos[0] < xMin ) return false;
				if ( pos[1] > yMax || pos[1] < yMin ) return false;
			}
			else if (rot == 90 || rot == 270)
			{
				if ( pos[1] > xMax || pos[1] < xMin ) return false;
				if ( pos[0] > yMax || pos[0] < yMin ) return false;
			}
			else // the box is rotated, maths is needed
			{
				float pi = (float)(atan(1) * 4);
				float rotRad = (rot * pi) / 180;
				float height  = (yMax - yMin);
				float width   = (xMax - xMin);

				// Center of the rectangle, we can treat this as the "fake" origin
				float cX = (xMax + xMin) / 2;
				float cY = (yMax + yMin) / 2;

				// Coordinates of original and rotated shape
				float oX[4], oY[4], rX[4], rY[4];

				// Coordinates for the original rectangle
				oX[0] = xMin - cX; oY[0] = yMax - cY;
				oX[1] = xMax - cX; oY[1] = yMax - cY;
				oX[2] = xMax - cX; oY[2] = yMin - cY;
				oX[3] = xMin - cX; oY[3] = yMin - cY;

				// Coordinates for the rotated rectangle
				rX[0] = (float)(oX[0] * cos(rotRad) - oY[0] * sin(rotRad)); rY[0] = (float)(oX[0] * sin(rotRad) + oY[0] * cos(rotRad));
				rX[1] = (float)(oX[1] * cos(rotRad) - oY[1] * sin(rotRad)); rY[1] = (float)(oX[1] * sin(rotRad) + oY[1] * cos(rotRad));
				rX[2] = (float)(oX[2] * cos(rotRad) - oY[2] * sin(rotRad)); rY[2] = (float)(oX[2] * sin(rotRad) + oY[2] * cos(rotRad));
				rX[3] = (float)(oX[3] * cos(rotRad) - oY[3] * sin(rotRad)); rY[3] = (float)(oX[3] * sin(rotRad) + oY[3] * cos(rotRad));

				// Coordinates of player relative to the "fake" origin
				float pX = pos[0] - cX;
				float pY = pos[1] - cY;<commit_msg>Provide explicit number type because Visual C++ complained about an ambiguous call to overloaded function atan.<commit_after>// flagStay.cpp : Defines the entry point for the DLL application.
//

#include "bzfsAPI.h"
#include <map>
#include <cmath>

class FlagStayZoneHandler : public bz_CustomMapObjectHandler
{
public:
	virtual bool MapObject ( bz_ApiString object, bz_CustomMapObjectInfo *data );
};

FlagStayZoneHandler	flagStayZoneHandler;

class EventHandler : public bz_Plugin
{
public:
	virtual const char* Name (){return "Flag Stay Zones";}
	virtual void Init ( const char* cl );
	virtual void Cleanup ();
	virtual void Event ( bz_EventData *eventData );
};

BZ_PLUGIN(EventHandler)

void EventHandler::Init ( const char* /*commandLine*/ )
{
  bz_registerCustomMapObject("FLAGSTAYZONE",&flagStayZoneHandler);

  Register(bz_ePlayerUpdateEvent);
}

void EventHandler::Cleanup ( void )
{
  Flush();
  bz_removeCustomMapObject("FLAGSTAYZONE");
}

class FlagStayZone
{
public:
	FlagStayZone()
	{
		box = false;
		xMax = xMin = yMax = yMin = zMax = zMin = rad = rot = 0;
	}

	bool box;
	float xMax,xMin,yMax,yMin,zMax,zMin;
	float rad, rot;

	std::string message;
	bool pointIn ( float pos[3] )
	{
		if ( box )
		{
			if (rot == 0 || rot == 180)
			{
				if ( pos[0] > xMax || pos[0] < xMin ) return false;
				if ( pos[1] > yMax || pos[1] < yMin ) return false;
			}
			else if (rot == 90 || rot == 270)
			{
				if ( pos[1] > xMax || pos[1] < xMin ) return false;
				if ( pos[0] > yMax || pos[0] < yMin ) return false;
			}
			else // the box is rotated, maths is needed
			{
				float pi = (float)(atan(1.0f) * 4);
				float rotRad = (rot * pi) / 180;
				float height  = (yMax - yMin);
				float width   = (xMax - xMin);

				// Center of the rectangle, we can treat this as the "fake" origin
				float cX = (xMax + xMin) / 2;
				float cY = (yMax + yMin) / 2;

				// Coordinates of original and rotated shape
				float oX[4], oY[4], rX[4], rY[4];

				// Coordinates for the original rectangle
				oX[0] = xMin - cX; oY[0] = yMax - cY;
				oX[1] = xMax - cX; oY[1] = yMax - cY;
				oX[2] = xMax - cX; oY[2] = yMin - cY;
				oX[3] = xMin - cX; oY[3] = yMin - cY;

				// Coordinates for the rotated rectangle
				rX[0] = (float)(oX[0] * cos(rotRad) - oY[0] * sin(rotRad)); rY[0] = (float)(oX[0] * sin(rotRad) + oY[0] * cos(rotRad));
				rX[1] = (float)(oX[1] * cos(rotRad) - oY[1] * sin(rotRad)); rY[1] = (float)(oX[1] * sin(rotRad) + oY[1] * cos(rotRad));
				rX[2] = (float)(oX[2] * cos(rotRad) - oY[2] * sin(rotRad)); rY[2] = (float)(oX[2] * sin(rotRad) + oY[2] * cos(rotRad));
				rX[3] = (float)(oX[3] * cos(rotRad) - oY[3] * sin(rotRad)); rY[3] = (float)(oX[3] * sin(rotRad) + oY[3] * cos(rotRad));

				// Coordinates of player relative to the "fake" origin
				float pX = pos[0] - cX;
				float pY = pos[1] - cY;
{'fraction_non_alphanumeric': 0.16729627630868862, 'fraction_numerical': 0.023205612520237454, 'mean_word_length': 3.2313546423135464, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2987425', 'n_tokens_mistral': 2508, 'n_tokens_neox': 2233, 'n_words': 588}