OpenTTD Source: src/subsidy_cmd.h Source File

OpenTTD Source 15.0-RC2

subsidy_cmd.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 SUBSIDY_CMD_H
11#define SUBSIDY_CMD_H
12
13#include "command_type.h"
14#include "cargo_type.h"
15#include "source_type.h"
16#include "misc/endian_buffer.hpp"
17
18 CommandCost CmdCreateSubsidy(DoCommandFlags flags, CargoType cargo_type, Source src, Source dst);
19
20DEF_CMD_TRAIT(CMD_CREATE_SUBSIDY, CmdCreateSubsidy, CommandFlag::Deity, CommandType::OtherManagement)
21
22
23template <typename Tcont, typename Titer>
24inline EndianBufferWriter<Tcont, Titer> &operator <<(EndianBufferWriter<Tcont, Titer> &buffer, const Source &source)
25{
26 return buffer << source.id << source.type;
27}
28
29inline EndianBufferReader &operator >>(EndianBufferReader &buffer, Source &source)
30{
31 return buffer >> source.id >> source.type;
32}
33
34#endif /* SUBSIDY_CMD_H */
cargo_type.h
Types related to cargoes...
CargoType
uint8_t CargoType
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:21
CommandCost
Common return value for all commands.
Definition command_type.h:24
EndianBufferReader
Endian-aware buffer adapter that always reads values in little endian order.
Definition endian_buffer.hpp:145
EndianBufferWriter
Endian-aware buffer adapter that always writes values in little endian order.
Definition endian_buffer.hpp:24
EnumBitSet
Enum-as-bit-set wrapper.
Definition enum_type.hpp:177
command_type.h
Types related to commands.
CommandType::OtherManagement
@ OtherManagement
Renaming stuff, changing company colours, placing signs, etc.
CommandFlag::Deity
@ Deity
the command may be executed by COMPANY_DEITY
CMD_CREATE_SUBSIDY
@ CMD_CREATE_SUBSIDY
create a new subsidy
Definition command_type.h:311
endian_buffer.hpp
Endian-aware buffer.
source_type.h
Type for the source of cargo.
Source
A location from where cargo can come from (or go to).
Definition source_type.h:32
Source::id
SourceID id
Index of industry/town/HQ, Source::Invalid if unknown/invalid.
Definition source_type.h:36
Source::type
SourceType type
Type of source_id.
Definition source_type.h:37
CmdCreateSubsidy
CommandCost CmdCreateSubsidy(DoCommandFlags flags, CargoType cargo_type, Source src, Source dst)
Create a new subsidy.
Definition subsidy.cpp:196