Created
July 8, 2022 19:53
-
-
Save TrueBrain/463f92f6220d535f582f52dcae08e464 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/command_func.h b/src/command_func.h | |
index 861dd480b..7539d6f54 100644 | |
--- a/src/command_func.h | |
+++ b/src/command_func.h | |
@@ -382,8 +382,18 @@ protected: | |
return MakeResult(CMD_ERROR); | |
} | |
- /* Test the command. */ | |
DoCommandFlag flags = CommandFlagsToDCFlags(cmd_flags); | |
+ | |
+ if constexpr (std::is_same_v<TileIndex, std::tuple_element_t<0, decltype(args)>>) { | |
+ TileIndex check_tile = std::get<0>(args); | |
+ /* Do not even think about executing out-of-bounds tile-commands. */ | |
+ if (check_tile != 0 && (check_tile >= MapSize() || (!IsValidTile(check_tile) && (flags & DC_ALL_TILES) == 0))) { | |
+ cur_company.Trash(); | |
+ return MakeResult(CMD_ERROR); | |
+ } | |
+ } | |
+ | |
+ /* Test the command. */ | |
Tret res = std::apply(CommandTraits<Tcmd>::proc, std::tuple_cat(std::make_tuple(flags), args)); | |
auto [exit_test, desync_log, send_net] = InternalExecuteValidateTestAndPrepExec(ExtractCommandCost(res), cmd_flags, estimate_only, network_command, cur_company); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment