OpenTTD Source  20241121-master-g67a0fccfad
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 <http://www.gnu.org/licenses/>.
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_type.h"
16 
17 enum TownAcceptanceEffect : uint8_t;
18 using HouseID = uint16_t;
19 
20 std::tuple<CommandCost, Money, TownID> CmdFoundTown(DoCommandFlag flags, TileIndex tile, TownSize size, bool city, TownLayout layout, bool random_location, uint32_t townnameparts, const std::string &text);
21 CommandCost CmdRenameTown(DoCommandFlag flags, TownID town_id, const std::string &text);
22 CommandCost CmdDoTownAction(DoCommandFlag flags, TownID town_id, uint8_t action);
23 CommandCost CmdTownGrowthRate(DoCommandFlag flags, TownID town_id, uint16_t growth_rate);
24 CommandCost CmdTownRating(DoCommandFlag flags, TownID town_id, CompanyID company_id, int16_t rating);
25 CommandCost CmdTownCargoGoal(DoCommandFlag flags, TownID town_id, TownAcceptanceEffect tae, uint32_t goal);
26 CommandCost CmdTownSetText(DoCommandFlag flags, TownID town_id, const std::string &text);
27 CommandCost CmdExpandTown(DoCommandFlag flags, TownID town_id, uint32_t grow_amount);
28 CommandCost CmdDeleteTown(DoCommandFlag flags, TownID town_id);
29 CommandCost CmdPlaceHouse(DoCommandFlag flags, TileIndex tile, HouseID house);
30 
31 DEF_CMD_TRAIT(CMD_FOUND_TOWN, CmdFoundTown, CMD_DEITY | CMD_NO_TEST, CMDT_LANDSCAPE_CONSTRUCTION) // founding random town can fail only in exec run
40 DEF_CMD_TRAIT(CMD_PLACE_HOUSE, CmdPlaceHouse, CMD_DEITY, CMDT_OTHER_MANAGEMENT)
41 
42 CommandCallback CcFoundTown;
43 void CcFoundRandomTown(Commands cmd, const CommandCost &result, Money, TownID town_id);
44 
45 #endif /* TOWN_CMD_H */
TownAcceptanceEffect
Town growth effect when delivering cargo.
Definition: cargotype.h:21
Common return value for all commands.
Definition: command_type.h:23
Types related to commands.
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:484
@ CMDT_LANDSCAPE_CONSTRUCTION
Construction and destruction of objects on the map.
Definition: command_type.h:414
@ CMDT_OTHER_MANAGEMENT
Renaming stuff, changing company colours, placing signs, etc.
Definition: command_type.h:419
DoCommandFlag
List of flags for a command.
Definition: command_type.h:374
Commands
List of commands.
Definition: command_type.h:187
@ CMD_EXPAND_TOWN
expand a town
Definition: command_type.h:287
@ CMD_DELETE_TOWN
delete a town
Definition: command_type.h:288
@ CMD_TOWN_SET_TEXT
set the custom text of a town
Definition: command_type.h:286
@ CMD_FOUND_TOWN
found a town
Definition: command_type.h:280
@ CMD_DO_TOWN_ACTION
do a action from the town detail window (like advertises or bribe)
Definition: command_type.h:282
@ CMD_TOWN_RATING
set rating of a company in a town
Definition: command_type.h:285
@ CMD_PLACE_HOUSE
place a house
Definition: command_type.h:289
@ CMD_TOWN_GROWTH_RATE
set the town growth rate
Definition: command_type.h:284
@ CMD_RENAME_TOWN
rename a town
Definition: command_type.h:281
@ CMD_TOWN_CARGO_GOAL
set the goal of a cargo for a town
Definition: command_type.h:283
@ CMD_LOCATION
the command has implicit location argument.
Definition: command_type.h:408
@ CMD_NO_TEST
the command's output may differ between test and execute due to town rating changes etc.
Definition: command_type.h:402
@ CMD_SERVER
the command can only be initiated by the server
Definition: command_type.h:397
@ CMD_STR_CTRL
the command's string may contain control strings
Definition: command_type.h:406
@ CMD_DEITY
the command may be executed by COMPANY_DEITY
Definition: command_type.h:405
@ CMD_OFFLINE
the command cannot be executed in a multiplayer game; single-player only
Definition: command_type.h:399
Types related to companies.
Owner
Enum for all companies/owners.
Definition: company_type.h:18
uint16_t HouseID
OpenTTD ID of house types.
Definition: house_type.h:13
CommandCost CmdRenameTown(DoCommandFlag flags, TownID town_id, const std::string &text)
Rename a town (server-only).
Definition: town_cmd.cpp:2992
CommandCost CmdTownGrowthRate(DoCommandFlag flags, TownID town_id, uint16_t growth_rate)
Change the growth rate of the town.
Definition: town_cmd.cpp:3093
CommandCost CmdTownRating(DoCommandFlag flags, TownID town_id, CompanyID company_id, int16_t rating)
Change the rating of a company in a town.
Definition: town_cmd.cpp:3131
CommandCost CmdTownCargoGoal(DoCommandFlag flags, TownID town_id, TownAcceptanceEffect tae, uint32_t goal)
Change the cargo goal of a town.
Definition: town_cmd.cpp:3042
CommandCost CmdDeleteTown(DoCommandFlag flags, TownID town_id)
Delete a town (scenario editor or worldgen only).
Definition: town_cmd.cpp:3193
CommandCost CmdDoTownAction(DoCommandFlag flags, TownID town_id, uint8_t action)
Do a town action.
Definition: town_cmd.cpp:3636
CommandCost CmdExpandTown(DoCommandFlag flags, TownID town_id, uint32_t grow_amount)
Expand a town (scenario editor only).
Definition: town_cmd.cpp:3156
CommandCost CmdTownSetText(DoCommandFlag flags, TownID town_id, const std::string &text)
Set a custom text in the Town window.
Definition: town_cmd.cpp:3071
std::tuple< CommandCost, Money, TownID > CmdFoundTown(DoCommandFlag 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:2115
Types related to towns.
TownLayout
Town Layouts.
Definition: town_type.h:79
TownSize
Supported initial town sizes.
Definition: town_type.h:19