2009-01-12 17:11:45 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
/** @file script_event.hpp Everything to handle events from the game. */
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
#ifndef SCRIPT_EVENT_HPP
|
|
|
|
#define SCRIPT_EVENT_HPP
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
#include "script_object.hpp"
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class that handles all event related functions.
|
|
|
|
* You can lookup the type, and than convert it to the real event-class.
|
|
|
|
* That way you can request more detailed information about the event.
|
|
|
|
*/
|
|
|
|
class AIEvent : public AIObject {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* The type of event. Needed to lookup the detailed class.
|
|
|
|
*/
|
|
|
|
enum AIEventType {
|
|
|
|
AI_ET_INVALID = 0,
|
|
|
|
AI_ET_TEST,
|
|
|
|
AI_ET_SUBSIDY_OFFER,
|
|
|
|
AI_ET_SUBSIDY_OFFER_EXPIRED,
|
|
|
|
AI_ET_SUBSIDY_AWARDED,
|
|
|
|
AI_ET_SUBSIDY_EXPIRED,
|
|
|
|
AI_ET_ENGINE_PREVIEW,
|
|
|
|
AI_ET_COMPANY_NEW,
|
|
|
|
AI_ET_COMPANY_IN_TROUBLE,
|
2009-09-01 12:57:04 +00:00
|
|
|
AI_ET_COMPANY_ASK_MERGER,
|
2009-01-12 17:11:45 +00:00
|
|
|
AI_ET_COMPANY_MERGER,
|
|
|
|
AI_ET_COMPANY_BANKRUPT,
|
|
|
|
AI_ET_VEHICLE_CRASHED,
|
|
|
|
AI_ET_VEHICLE_LOST,
|
|
|
|
AI_ET_VEHICLE_WAITING_IN_DEPOT,
|
|
|
|
AI_ET_VEHICLE_UNPROFITABLE,
|
|
|
|
AI_ET_INDUSTRY_OPEN,
|
|
|
|
AI_ET_INDUSTRY_CLOSE,
|
|
|
|
AI_ET_ENGINE_AVAILABLE,
|
|
|
|
AI_ET_STATION_FIRST_VEHICLE,
|
2009-02-05 17:38:47 +00:00
|
|
|
AI_ET_DISASTER_ZEPPELINER_CRASHED,
|
|
|
|
AI_ET_DISASTER_ZEPPELINER_CLEARED,
|
2010-12-29 23:44:39 +00:00
|
|
|
AI_ET_TOWN_FOUNDED,
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor of AIEvent, to get the type of event.
|
|
|
|
*/
|
|
|
|
AIEvent(AIEvent::AIEventType type) :
|
|
|
|
type(type)
|
|
|
|
{}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the event-type.
|
|
|
|
* @return The @c AIEventType.
|
|
|
|
*/
|
|
|
|
AIEventType GetEventType() { return this->type; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* The type of this event.
|
|
|
|
*/
|
|
|
|
AIEventType type;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class that handles all event related functions.
|
|
|
|
* @note it is not needed to create an instance of AIEvent to access it, as
|
|
|
|
* all members are static, and all data is stored AI-wide.
|
|
|
|
*/
|
|
|
|
class AIEventController : public AIObject {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Check if there is an event waiting.
|
|
|
|
* @return true if there is an event on the stack.
|
|
|
|
*/
|
|
|
|
static bool IsEventWaiting();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the next event.
|
|
|
|
* @return a class of the event-child issues.
|
|
|
|
*/
|
|
|
|
static AIEvent *GetNextEvent();
|
|
|
|
|
2009-02-14 20:03:06 +00:00
|
|
|
#ifndef EXPORT_SKIP
|
2009-01-12 17:11:45 +00:00
|
|
|
/**
|
|
|
|
* Insert an event to the queue for the company.
|
|
|
|
* @param event The event to insert.
|
2009-03-12 11:43:40 +00:00
|
|
|
* @note DO NOT CALL YOURSELF; leave it to the internal AI programming.
|
2009-01-12 17:11:45 +00:00
|
|
|
*/
|
|
|
|
static void InsertEvent(AIEvent *event);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Free the event pointer.
|
|
|
|
* @note DO NOT CALL YOURSELF; leave it to the internal AI programming.
|
|
|
|
*/
|
|
|
|
static void FreeEventPointer();
|
2009-02-14 20:03:06 +00:00
|
|
|
#endif /* EXPORT_SKIP */
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Create the event pointer.
|
|
|
|
*/
|
|
|
|
static void CreateEventPointer();
|
|
|
|
};
|
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
#endif /* SCRIPT_EVENT_HPP */
|