OpenTTD Source: src/town_cmd.h Source File

OpenTTD Source 15.3

town_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 TOWN_CMD_H
11#define TOWN_CMD_H
12
13#include "command_type.h"
14#include "company_type.h"
15#include "town.h"
16#include "town_type.h"
17
18enum TownAcceptanceEffect : uint8_t;
19using HouseID = uint16_t;
20
21std::tuple<CommandCost, Money, TownID> CmdFoundTown(DoCommandFlags flags, TileIndex tile, TownSize size, bool city, TownLayout layout, bool random_location, uint32_t townnameparts, const std::string &text);
22 CommandCost CmdRenameTown(DoCommandFlags flags, TownID town_id, const std::string &text);
23 CommandCost CmdDoTownAction(DoCommandFlags flags, TownID town_id, TownAction action);
24 CommandCost CmdTownGrowthRate(DoCommandFlags flags, TownID town_id, uint16_t growth_rate);
25 CommandCost CmdTownRating(DoCommandFlags flags, TownID town_id, CompanyID company_id, int16_t rating);
26 CommandCost CmdTownCargoGoal(DoCommandFlags flags, TownID town_id, TownAcceptanceEffect tae, uint32_t goal);
27 CommandCost CmdTownSetText(DoCommandFlags flags, TownID town_id, const EncodedString &text);
28 CommandCost CmdExpandTown(DoCommandFlags flags, TownID town_id, uint32_t grow_amount, TownExpandModes modes);
29 CommandCost CmdDeleteTown(DoCommandFlags flags, TownID town_id);
30 CommandCost CmdPlaceHouse(DoCommandFlags flags, TileIndex tile, HouseID house, bool house_protected, bool replace);
31
32DEF_CMD_TRAIT(CMD_FOUND_TOWN, CmdFoundTown, CommandFlags({CommandFlag::Deity, CommandFlag::NoTest}), CommandType::LandscapeConstruction) // founding random town can fail only in exec run
33DEF_CMD_TRAIT(CMD_RENAME_TOWN, CmdRenameTown, CommandFlags({CommandFlag::Deity, CommandFlag::Server}), CommandType::OtherManagement)
34DEF_CMD_TRAIT(CMD_DO_TOWN_ACTION, CmdDoTownAction, CommandFlags({CommandFlag::Location}), CommandType::LandscapeConstruction)
35DEF_CMD_TRAIT(CMD_TOWN_CARGO_GOAL, CmdTownCargoGoal, CommandFlags({CommandFlag::Deity}), CommandType::OtherManagement)
36DEF_CMD_TRAIT(CMD_TOWN_GROWTH_RATE, CmdTownGrowthRate, CommandFlags({CommandFlag::Deity}), CommandType::OtherManagement)
37DEF_CMD_TRAIT(CMD_TOWN_RATING, CmdTownRating, CommandFlags({CommandFlag::Deity}), CommandType::OtherManagement)
38DEF_CMD_TRAIT(CMD_TOWN_SET_TEXT, CmdTownSetText, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement)
39DEF_CMD_TRAIT(CMD_EXPAND_TOWN, CmdExpandTown, CommandFlags({CommandFlag::Deity}), CommandType::LandscapeConstruction)
40DEF_CMD_TRAIT(CMD_DELETE_TOWN, CmdDeleteTown, CommandFlags({CommandFlag::Offline}), CommandType::LandscapeConstruction)
41DEF_CMD_TRAIT(CMD_PLACE_HOUSE, CmdPlaceHouse, CommandFlags({CommandFlag::Deity}), CommandType::OtherManagement)
42
43 CommandCallback CcFoundTown;
44void CcFoundRandomTown(Commands cmd, const CommandCost &result, Money, TownID town_id);
45
46#endif /* TOWN_CMD_H */
TownAcceptanceEffect
TownAcceptanceEffect
Town growth effect when delivering cargo.
Definition cargotype.h:22
CommandCost
Common return value for all commands.
Definition command_type.h:24
EncodedString
Container for an encoded string, created by GetEncodedString.
Definition strings_type.h:98
EnumBitSet
Enum-as-bit-set wrapper.
Definition enum_type.hpp:177
OverflowSafeInt< int64_t >
command_type.h
Types related to commands.
CommandType::OtherManagement
@ OtherManagement
Renaming stuff, changing company colours, placing signs, etc.
CommandType::LandscapeConstruction
@ LandscapeConstruction
Construction and destruction of objects on the map.
CommandCallback
void CommandCallback(Commands cmd, const CommandCost &result, TileIndex tile)
Define a callback function for the client, after the command is finished.
Definition command_type.h:495
CommandFlag::Deity
@ Deity
the command may be executed by COMPANY_DEITY
CommandFlag::Offline
@ Offline
the command cannot be executed in a multiplayer game; single-player only
CommandFlag::Server
@ Server
the command can only be initiated by the server
CommandFlag::StrCtrl
@ StrCtrl
the command's string may contain control strings
CommandFlag::Location
@ Location
the command has implicit location argument.
CommandFlag::NoTest
@ NoTest
the command's output may differ between test and execute due to town rating changes etc.
Commands
Commands
List of commands.
Definition command_type.h:196
CMD_EXPAND_TOWN
@ CMD_EXPAND_TOWN
expand a town
Definition command_type.h:299
CMD_DELETE_TOWN
@ CMD_DELETE_TOWN
delete a town
Definition command_type.h:300
CMD_TOWN_SET_TEXT
@ CMD_TOWN_SET_TEXT
set the custom text of a town
Definition command_type.h:298
CMD_FOUND_TOWN
@ CMD_FOUND_TOWN
found a town
Definition command_type.h:292
CMD_DO_TOWN_ACTION
@ CMD_DO_TOWN_ACTION
do a action from the town detail window (like advertises or bribe)
Definition command_type.h:294
CMD_TOWN_RATING
@ CMD_TOWN_RATING
set rating of a company in a town
Definition command_type.h:297
CMD_PLACE_HOUSE
@ CMD_PLACE_HOUSE
place a house
Definition command_type.h:301
CMD_TOWN_GROWTH_RATE
@ CMD_TOWN_GROWTH_RATE
set the town growth rate
Definition command_type.h:296
CMD_RENAME_TOWN
@ CMD_RENAME_TOWN
rename a town
Definition command_type.h:293
CMD_TOWN_CARGO_GOAL
@ CMD_TOWN_CARGO_GOAL
set the goal of a cargo for a town
Definition command_type.h:295
company_type.h
Types related to companies.
HouseID
uint16_t HouseID
OpenTTD ID of house types.
Definition house_type.h:15
PoolID< uint16_t, struct TownIDTag, 64000, 0xFFFF >
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
town.h
Base of the town class.
TownAction
TownAction
Town actions of a company.
Definition town.h:247
CmdFoundTown
std::tuple< CommandCost, Money, TownID > CmdFoundTown(DoCommandFlags flags, TileIndex tile, TownSize size, bool city, TownLayout layout, bool random_location, uint32_t townnameparts, const std::string &text)
Create a new town.
Definition town_cmd.cpp:2197
CmdDoTownAction
CommandCost CmdDoTownAction(DoCommandFlags flags, TownID town_id, TownAction action)
Do a town action.
Definition town_cmd.cpp:3728
CmdPlaceHouse
CommandCost CmdPlaceHouse(DoCommandFlags flags, TileIndex tile, HouseID house, bool house_protected, bool replace)
Place an individual house.
Definition town_cmd.cpp:2947
CmdTownSetText
CommandCost CmdTownSetText(DoCommandFlags flags, TownID town_id, const EncodedString &text)
Set a custom text in the Town window.
Definition town_cmd.cpp:3172
CmdTownGrowthRate
CommandCost CmdTownGrowthRate(DoCommandFlags flags, TownID town_id, uint16_t growth_rate)
Change the growth rate of the town.
Definition town_cmd.cpp:3194
CmdDeleteTown
CommandCost CmdDeleteTown(DoCommandFlags flags, TownID town_id)
Delete a town (scenario editor or worldgen only).
Definition town_cmd.cpp:3295
CmdRenameTown
CommandCost CmdRenameTown(DoCommandFlags flags, TownID town_id, const std::string &text)
Rename a town (server-only).
Definition town_cmd.cpp:3093
CmdTownCargoGoal
CommandCost CmdTownCargoGoal(DoCommandFlags flags, TownID town_id, TownAcceptanceEffect tae, uint32_t goal)
Change the cargo goal of a town.
Definition town_cmd.cpp:3143
CmdTownRating
CommandCost CmdTownRating(DoCommandFlags flags, TownID town_id, CompanyID company_id, int16_t rating)
Change the rating of a company in a town.
Definition town_cmd.cpp:3232
CmdExpandTown
CommandCost CmdExpandTown(DoCommandFlags flags, TownID town_id, uint32_t grow_amount, TownExpandModes modes)
Expand a town (scenario editor only).
Definition town_cmd.cpp:3257
town_type.h
Types related to towns.
TownLayout
TownLayout
Town Layouts.
Definition town_type.h:81
TownSize
TownSize
Supported initial town sizes.
Definition town_type.h:21