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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file newgrf_generic.h Functions related to generic callbacks. */
|
|
|
|
|
2008-02-12 13:23:57 +00:00
|
|
|
#ifndef NEWGRF_GENERIC_H
|
|
|
|
#define NEWGRF_GENERIC_H
|
|
|
|
|
2010-01-15 16:41:15 +00:00
|
|
|
#include "industry_type.h"
|
2011-05-02 16:14:23 +00:00
|
|
|
#include "newgrf.h"
|
2011-11-04 21:05:08 +00:00
|
|
|
#include "tile_type.h"
|
2010-01-15 16:41:15 +00:00
|
|
|
|
2011-05-02 16:14:23 +00:00
|
|
|
struct SpriteGroup;
|
|
|
|
|
|
|
|
/** AI events for asking the NewGRF for information. */
|
2008-02-12 13:23:57 +00:00
|
|
|
enum AIConstructionEvent {
|
|
|
|
AICE_TRAIN_CHECK_RAIL_ENGINE = 0x00, ///< Check if we should build an engine
|
2011-05-02 16:14:23 +00:00
|
|
|
AICE_TRAIN_CHECK_ELRAIL_ENGINE = 0x01, ///< Check if we should build an engine
|
|
|
|
AICE_TRAIN_CHECK_MONORAIL_ENGINE = 0x02, ///< Check if we should build an engine
|
|
|
|
AICE_TRAIN_CHECK_MAGLEV_ENGINE = 0x03, ///< Check if we should build an engine
|
|
|
|
AICE_TRAIN_GET_RAIL_WAGON = 0x08, ///< Check if we should build an engine
|
|
|
|
AICE_TRAIN_GET_ELRAIL_WAGON = 0x09, ///< Check if we should build an engine
|
|
|
|
AICE_TRAIN_GET_MONORAIL_WAGON = 0x0A, ///< Check if we should build an engine
|
|
|
|
AICE_TRAIN_GET_MAGLEV_WAGON = 0x0B, ///< Check if we should build an engine
|
|
|
|
AICE_TRAIN_GET_RAILTYPE = 0x0F, ///< Check if we should build a railtype
|
2008-02-12 13:23:57 +00:00
|
|
|
|
|
|
|
AICE_ROAD_CHECK_ENGINE = 0x00, ///< Check if we should build an engine
|
|
|
|
AICE_ROAD_GET_FIRST_ENGINE = 0x01, ///< Unused, we check all
|
|
|
|
AICE_ROAD_GET_NUMBER_ENGINES = 0x02, ///< Unused, we check all
|
|
|
|
|
|
|
|
AICE_SHIP_CHECK_ENGINE = 0x00, ///< Check if we should build an engine
|
|
|
|
AICE_SHIP_GET_FIRST_ENGINE = 0x01, ///< Unused, we check all
|
|
|
|
AICE_SHIP_GET_NUMBER_ENGINES = 0x02, ///< Unused, we check all
|
|
|
|
|
|
|
|
AICE_AIRCRAFT_CHECK_ENGINE = 0x00, ///< Check if we should build an engine
|
|
|
|
|
|
|
|
AICE_STATION_GET_STATION_ID = 0x00, ///< Get a station ID to build
|
|
|
|
};
|
|
|
|
|
2010-07-10 10:55:16 +00:00
|
|
|
static const IndustryType IT_AI_UNKNOWN = 0xFE; ///< The AI has no specific industry in mind.
|
|
|
|
static const IndustryType IT_AI_TOWN = 0xFF; ///< The AI actually wants to transport to/from a town, not an industry.
|
|
|
|
|
2008-02-12 13:23:57 +00:00
|
|
|
void ResetGenericCallbacks();
|
2022-01-27 21:09:45 +00:00
|
|
|
void AddGenericCallback(GrfSpecFeature feature, const GRFFile *file, const SpriteGroup *group);
|
2008-02-12 13:23:57 +00:00
|
|
|
|
2022-01-27 21:09:45 +00:00
|
|
|
uint16 GetAiPurchaseCallbackResult(GrfSpecFeature feature, CargoID cargo_type, uint8 default_selection, IndustryType src_industry, IndustryType dst_industry, uint8 distance, AIConstructionEvent event, uint8 count, uint8 station_size, const GRFFile **file);
|
2023-01-29 08:28:24 +00:00
|
|
|
void AmbientSoundEffectCallback(TileIndex tile);
|
2023-03-11 02:24:50 +00:00
|
|
|
uint16 GetTownZonesCallback(Town *t);
|
2012-01-03 00:45:22 +00:00
|
|
|
|
|
|
|
/** Play an ambient sound effect for an empty tile. */
|
|
|
|
static inline void AmbientSoundEffect(TileIndex tile)
|
|
|
|
{
|
|
|
|
/* Only run callback if enabled. */
|
|
|
|
if (!HasGrfMiscBit(GMB_AMBIENT_SOUND_CALLBACK)) return;
|
|
|
|
|
|
|
|
AmbientSoundEffectCallback(tile);
|
|
|
|
}
|
2008-02-12 13:23:57 +00:00
|
|
|
|
|
|
|
#endif /* NEWGRF_GENERIC_H */
|