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.
|
2011-12-19 20:50:54 +00:00
|
|
|
* @api ai game
|
2009-01-12 17:11:45 +00:00
|
|
|
*/
|
2011-11-29 23:15:35 +00:00
|
|
|
class ScriptEvent : public ScriptObject {
|
2009-01-12 17:11:45 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* The type of event. Needed to lookup the detailed class.
|
|
|
|
*/
|
2011-11-29 23:15:35 +00:00
|
|
|
enum ScriptEventType {
|
2011-12-02 23:40:16 +00:00
|
|
|
ET_INVALID = 0,
|
|
|
|
ET_TEST,
|
|
|
|
ET_SUBSIDY_OFFER,
|
|
|
|
ET_SUBSIDY_OFFER_EXPIRED,
|
|
|
|
ET_SUBSIDY_AWARDED,
|
|
|
|
ET_SUBSIDY_EXPIRED,
|
|
|
|
ET_ENGINE_PREVIEW,
|
|
|
|
ET_COMPANY_NEW,
|
|
|
|
ET_COMPANY_IN_TROUBLE,
|
|
|
|
ET_COMPANY_ASK_MERGER,
|
|
|
|
ET_COMPANY_MERGER,
|
|
|
|
ET_COMPANY_BANKRUPT,
|
|
|
|
ET_VEHICLE_CRASHED,
|
|
|
|
ET_VEHICLE_LOST,
|
|
|
|
ET_VEHICLE_WAITING_IN_DEPOT,
|
|
|
|
ET_VEHICLE_UNPROFITABLE,
|
|
|
|
ET_INDUSTRY_OPEN,
|
|
|
|
ET_INDUSTRY_CLOSE,
|
|
|
|
ET_ENGINE_AVAILABLE,
|
|
|
|
ET_STATION_FIRST_VEHICLE,
|
|
|
|
ET_DISASTER_ZEPPELINER_CRASHED,
|
|
|
|
ET_DISASTER_ZEPPELINER_CLEARED,
|
|
|
|
ET_TOWN_FOUNDED,
|
2011-12-13 00:43:59 +00:00
|
|
|
ET_AIRCRAFT_DEST_TOO_FAR,
|
2011-12-19 21:00:32 +00:00
|
|
|
ET_ADMIN_PORT,
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2011-11-29 23:15:35 +00:00
|
|
|
* Constructor of ScriptEvent, to get the type of event.
|
2009-01-12 17:11:45 +00:00
|
|
|
*/
|
2011-11-29 23:15:35 +00:00
|
|
|
ScriptEvent(ScriptEvent::ScriptEventType type) :
|
2009-01-12 17:11:45 +00:00
|
|
|
type(type)
|
|
|
|
{}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the event-type.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @return The @c ScriptEventType.
|
2009-01-12 17:11:45 +00:00
|
|
|
*/
|
2011-11-29 23:15:35 +00:00
|
|
|
ScriptEventType GetEventType() { return this->type; }
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* The type of this event.
|
|
|
|
*/
|
2011-11-29 23:15:35 +00:00
|
|
|
ScriptEventType type;
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class that handles all event related functions.
|
2011-12-19 20:50:54 +00:00
|
|
|
* @api ai game
|
2011-11-29 23:15:35 +00:00
|
|
|
* @note it is not needed to create an instance of ScriptEvent to access it, as
|
2009-01-12 17:11:45 +00:00
|
|
|
* all members are static, and all data is stored AI-wide.
|
|
|
|
*/
|
2011-11-29 23:15:35 +00:00
|
|
|
class ScriptEventController : public ScriptObject {
|
2009-01-12 17:11:45 +00:00
|
|
|
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.
|
|
|
|
*/
|
2011-11-29 23:15:35 +00:00
|
|
|
static ScriptEvent *GetNextEvent();
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Insert an event to the queue for the company.
|
|
|
|
* @param event The event to insert.
|
2011-11-29 23:27:26 +00:00
|
|
|
* @api -all
|
2009-01-12 17:11:45 +00:00
|
|
|
*/
|
2011-11-29 23:15:35 +00:00
|
|
|
static void InsertEvent(ScriptEvent *event);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Free the event pointer.
|
2011-11-29 23:27:26 +00:00
|
|
|
* @api -all
|
2009-01-12 17:11:45 +00:00
|
|
|
*/
|
|
|
|
static void FreeEventPointer();
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Create the event pointer.
|
|
|
|
*/
|
|
|
|
static void CreateEventPointer();
|
|
|
|
};
|
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
#endif /* SCRIPT_EVENT_HPP */
|