OpenTTD Source: src/newgrf_generic.h Source File

OpenTTD Source 15.0-RC2

newgrf_generic.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef NEWGRF_GENERIC_H
11#define NEWGRF_GENERIC_H
12
13#include "industry_type.h"
14#include "newgrf.h"
15#include "tile_type.h"
16
17struct SpriteGroup;
18
20 enum AIConstructionEvent : uint8_t {
21 AICE_TRAIN_CHECK_RAIL_ENGINE = 0x00,
22 AICE_TRAIN_CHECK_ELRAIL_ENGINE = 0x01,
23 AICE_TRAIN_CHECK_MONORAIL_ENGINE = 0x02,
24 AICE_TRAIN_CHECK_MAGLEV_ENGINE = 0x03,
25 AICE_TRAIN_GET_RAIL_WAGON = 0x08,
26 AICE_TRAIN_GET_ELRAIL_WAGON = 0x09,
27 AICE_TRAIN_GET_MONORAIL_WAGON = 0x0A,
28 AICE_TRAIN_GET_MAGLEV_WAGON = 0x0B,
29 AICE_TRAIN_GET_RAILTYPE = 0x0F,
30
31 AICE_ROAD_CHECK_ENGINE = 0x00,
32 AICE_ROAD_GET_FIRST_ENGINE = 0x01,
33 AICE_ROAD_GET_NUMBER_ENGINES = 0x02,
34
35 AICE_SHIP_CHECK_ENGINE = 0x00,
36 AICE_SHIP_GET_FIRST_ENGINE = 0x01,
37 AICE_SHIP_GET_NUMBER_ENGINES = 0x02,
38
39 AICE_AIRCRAFT_CHECK_ENGINE = 0x00,
40
41 AICE_STATION_GET_STATION_ID = 0x00,
42};
43
44 static const IndustryType IT_AI_UNKNOWN = 0xFE;
45 static const IndustryType IT_AI_TOWN = 0xFF;
46
47void ResetGenericCallbacks();
48void AddGenericCallback(GrfSpecFeature feature, const GRFFile *file, const SpriteGroup *group);
49
50std::pair<const GRFFile *, uint16_t> GetAiPurchaseCallbackResult(GrfSpecFeature feature, CargoType cargo_type, uint8_t default_selection, IndustryType src_industry, IndustryType dst_industry, uint8_t distance, AIConstructionEvent event, uint8_t count, uint8_t station_size);
51void AmbientSoundEffectCallback(TileIndex tile);
52
54 inline void AmbientSoundEffect(TileIndex tile)
55{
56 /* Only run callback if enabled. */
57 if (!HasGrfMiscBit(GrfMiscBit::AmbientSoundCallback)) return;
58
59 AmbientSoundEffectCallback(tile);
60}
61
62#endif /* NEWGRF_GENERIC_H */
CargoType
uint8_t CargoType
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:21
industry_type.h
Types related to the industry.
newgrf.h
Base for the NewGRF implementation.
HasGrfMiscBit
bool HasGrfMiscBit(GrfMiscBit bit)
Check for grf miscellaneous bits.
Definition newgrf.h:209
GrfSpecFeature
GrfSpecFeature
Definition newgrf.h:68
GetAiPurchaseCallbackResult
std::pair< const GRFFile *, uint16_t > GetAiPurchaseCallbackResult(GrfSpecFeature feature, CargoType cargo_type, uint8_t default_selection, IndustryType src_industry, IndustryType dst_industry, uint8_t distance, AIConstructionEvent event, uint8_t count, uint8_t station_size)
'Execute' an AI purchase selection callback
Definition newgrf_generic.cpp:202
AmbientSoundEffectCallback
void AmbientSoundEffectCallback(TileIndex tile)
'Execute' the ambient sound effect callback.
Definition newgrf_generic.cpp:238
AmbientSoundEffect
void AmbientSoundEffect(TileIndex tile)
Play an ambient sound effect for an empty tile.
Definition newgrf_generic.h:54
AddGenericCallback
void AddGenericCallback(GrfSpecFeature feature, const GRFFile *file, const SpriteGroup *group)
Add a generic feature callback sprite group to the appropriate feature list.
Definition newgrf_generic.cpp:108
IT_AI_UNKNOWN
static const IndustryType IT_AI_UNKNOWN
The AI has no specific industry in mind.
Definition newgrf_generic.h:44
ResetGenericCallbacks
void ResetGenericCallbacks()
Reset all generic feature callback sprite groups.
Definition newgrf_generic.cpp:94
AIConstructionEvent
AIConstructionEvent
AI events for asking the NewGRF for information.
Definition newgrf_generic.h:20
AICE_STATION_GET_STATION_ID
@ AICE_STATION_GET_STATION_ID
Get a station ID to build.
Definition newgrf_generic.h:41
AICE_TRAIN_GET_RAIL_WAGON
@ AICE_TRAIN_GET_RAIL_WAGON
Check if we should build an engine.
Definition newgrf_generic.h:25
AICE_ROAD_CHECK_ENGINE
@ AICE_ROAD_CHECK_ENGINE
Check if we should build an engine.
Definition newgrf_generic.h:31
AICE_TRAIN_CHECK_ELRAIL_ENGINE
@ AICE_TRAIN_CHECK_ELRAIL_ENGINE
Check if we should build an engine.
Definition newgrf_generic.h:22
AICE_TRAIN_GET_RAILTYPE
@ AICE_TRAIN_GET_RAILTYPE
Check if we should build a railtype.
Definition newgrf_generic.h:29
AICE_SHIP_GET_FIRST_ENGINE
@ AICE_SHIP_GET_FIRST_ENGINE
Unused, we check all.
Definition newgrf_generic.h:36
AICE_TRAIN_CHECK_MONORAIL_ENGINE
@ AICE_TRAIN_CHECK_MONORAIL_ENGINE
Check if we should build an engine.
Definition newgrf_generic.h:23
AICE_SHIP_GET_NUMBER_ENGINES
@ AICE_SHIP_GET_NUMBER_ENGINES
Unused, we check all.
Definition newgrf_generic.h:37
AICE_TRAIN_GET_MONORAIL_WAGON
@ AICE_TRAIN_GET_MONORAIL_WAGON
Check if we should build an engine.
Definition newgrf_generic.h:27
AICE_ROAD_GET_FIRST_ENGINE
@ AICE_ROAD_GET_FIRST_ENGINE
Unused, we check all.
Definition newgrf_generic.h:32
AICE_TRAIN_CHECK_MAGLEV_ENGINE
@ AICE_TRAIN_CHECK_MAGLEV_ENGINE
Check if we should build an engine.
Definition newgrf_generic.h:24
AICE_ROAD_GET_NUMBER_ENGINES
@ AICE_ROAD_GET_NUMBER_ENGINES
Unused, we check all.
Definition newgrf_generic.h:33
AICE_AIRCRAFT_CHECK_ENGINE
@ AICE_AIRCRAFT_CHECK_ENGINE
Check if we should build an engine.
Definition newgrf_generic.h:39
AICE_TRAIN_GET_ELRAIL_WAGON
@ AICE_TRAIN_GET_ELRAIL_WAGON
Check if we should build an engine.
Definition newgrf_generic.h:26
AICE_TRAIN_CHECK_RAIL_ENGINE
@ AICE_TRAIN_CHECK_RAIL_ENGINE
Check if we should build an engine.
Definition newgrf_generic.h:21
AICE_TRAIN_GET_MAGLEV_WAGON
@ AICE_TRAIN_GET_MAGLEV_WAGON
Check if we should build an engine.
Definition newgrf_generic.h:28
AICE_SHIP_CHECK_ENGINE
@ AICE_SHIP_CHECK_ENGINE
Check if we should build an engine.
Definition newgrf_generic.h:35
IT_AI_TOWN
static const IndustryType IT_AI_TOWN
The AI actually wants to transport to/from a town, not an industry.
Definition newgrf_generic.h:45
GRFFile
Dynamic data of a loaded NewGRF.
Definition newgrf.h:114
SpriteGroup
Definition newgrf_spritegroup.h:47
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
tile_type.h
Types related to tiles.