Fix command callback generation

This commit is contained in:
dP
2024-04-23 01:22:39 +07:00
parent dc9e1d54b5
commit 28919c1cc0
4 changed files with 17 additions and 11 deletions

View File

@@ -76,6 +76,7 @@ This is usable for any OpenTTD servers
*** 14.0 *** *** 14.0 ***
- Fixed graphs with cargo selection. - Fixed graphs with cargo selection.
- Fixed measurement tooltips. - Fixed measurement tooltips.
- Fixed n-ice community login by Chucky and iSoSyS.
- Show the number of hidden vehicles in buy and autoreplace windows. - Show the number of hidden vehicles in buy and autoreplace windows.
- Added a setting to disable activate-on-release behaviour of toolbar dropdown buttons. - Added a setting to disable activate-on-release behaviour of toolbar dropdown buttons.
- Added Russian translation. - Added Russian translation.

View File

@@ -8,19 +8,20 @@ RX_COMMAND = re.compile(r'(?P<returns>CommandCost|std::tuple<CommandCost, [^>]*>
RX_DEF_TRAIT = re.compile(r'DEF_CMD_TRAIT\((?P<constant>\w+),\s+(?P<function>\w+),\s+(?P<flags>[^,]*),\s+(?P<category>\w+)\)') RX_DEF_TRAIT = re.compile(r'DEF_CMD_TRAIT\((?P<constant>\w+),\s+(?P<function>\w+),\s+(?P<flags>[^,]*),\s+(?P<category>\w+)\)')
RX_ARG = re.compile(r'(?P<type>(:?const |)[\w:]* &?)(?P<name>\w*)') RX_ARG = re.compile(r'(?P<type>(:?const |)[\w:]* &?)(?P<name>\w*)')
RX_CALLBACK = re.compile(r'void\s+(?P<name>Cc\w+)\(Commands') RX_CALLBACK = re.compile(r'void\s+(?P<name>Cc\w+)\(Commands')
RX_CALLBACK_REF = re.compile(r'CommandCallback\s+(?P<name>Cc\w+);') RX_CALLBACK_REF = re.compile(r'CommandCallback(?:Data|)\s+(?P<name>Cc\w+);')
RX_CAMEL_TO_SNAKE = re.compile(r'(?<!^)(?=[A-Z])') RX_CAMEL_TO_SNAKE = re.compile(r'(?<!^)(?=[A-Z])')
RX_CMD_CONSTANT = re.compile(r'CMD_[\w_]+') RX_CMD_CONSTANT = re.compile(r'CMD_[\w_]+')
FILES = [ FILES = [
'src/misc_cmd.h', 'misc_cmd.h',
'src/object_cmd.h', 'object_cmd.h',
'src/order_cmd.h', 'order_cmd.h',
'src/rail_cmd.h', 'rail_cmd.h',
'src/road_cmd.h', 'road_cmd.h',
'src/station_cmd.h', 'station_cmd.h',
'src/town_cmd.h', 'town_cmd.h',
'src/tunnelbridge_cmd.h', 'tunnelbridge_cmd.h',
'script/script_cmd.h',
] ]
BASE_DIR = Path(__file__).parent BASE_DIR = Path(__file__).parent
@@ -96,7 +97,7 @@ def parse_commands():
command_ids[cmd] = cid command_ids[cmd] = cid
cid += 1 cid += 1
for f in glob.glob(str(BASE_DIR / 'src' / '*_cmd.h')): for f in glob.glob(str(BASE_DIR / 'src' / '*_cmd.h')) + glob.glob(str(BASE_DIR / 'src' / '*' / '*_cmd.h')):
# for f in glob.glob(str(BASE_DIR / 'src' / 'group_cmd.h')): # for f in glob.glob(str(BASE_DIR / 'src' / 'group_cmd.h')):
includes.append(Path(f).name) includes.append(Path(f).name)
data = open(f).read() data = open(f).read()

View File

@@ -10,6 +10,7 @@
#include "../../station_cmd.h" #include "../../station_cmd.h"
#include "../../town_cmd.h" #include "../../town_cmd.h"
#include "../../tunnelbridge_cmd.h" #include "../../tunnelbridge_cmd.h"
#include "../../script/script_cmd.h"
namespace citymania { namespace citymania {
namespace cmd { namespace cmd {
@@ -42,7 +43,9 @@ static constexpr auto _callback_tuple = std::make_tuple(
&CcBuildIndustry, &CcBuildIndustry,
&CcBuildBridge, &CcBuildBridge,
&CcCreateGroup, &CcCreateGroup,
&CcAddVehicleNewGroup &CcAddVehicleNewGroup,
&CcAI,
&CcGame
); );
inline constexpr size_t _callback_tuple_size = std::tuple_size_v<decltype(_callback_tuple)>; inline constexpr size_t _callback_tuple_size = std::tuple_size_v<decltype(_callback_tuple)>;

View File

@@ -41,6 +41,7 @@
#include "../../engine_cmd.h" #include "../../engine_cmd.h"
#include "../../tunnelbridge_cmd.h" #include "../../tunnelbridge_cmd.h"
#include "../../group_cmd.h" #include "../../group_cmd.h"
#include "../../script_cmd.h"
namespace citymania { namespace citymania {
namespace cmd { namespace cmd {