/*
	Event handling code 
	Made by Ismo Horppu on 1996 - 1997
*/

#include "ct2event.h"

int AddEvent (int x1, int y1, int width, int height)
{
	if (Events >= MAX_EVENTS) return -1;
	
	EI[Events].x1 = x1;
	EI[Events].x2 = x1 + width - 1;
	EI[Events].y1 = y1;
	EI[Events].y2 = y1 + height -1;
	Events++;
	
	return 0;
}

int ClearEvents (void)
{
	if (Events == 0) return -1;
	Events = 0;
	return 0;
}

int CheckEvents (int basex, int basey)
{
	int EventCounter;
	
	for (EventCounter = 0; EventCounter < Events; EventCounter++){
		if (basex >= EI[EventCounter].x1 && basex <= EI[EventCounter].x2 &&
			basey >= EI[EventCounter].y1 && basey <= EI[EventCounter].y2){
			return EventCounter;
		}
	}
	
	return -1;
}