summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-12-20 16:59:07 +0100
committerMichael Lutz <michi@icosahedron.de>2021-12-20 23:32:23 +0100
commitb11bd185e3c656c08e3f3d57eb2ada15b7ac276d (patch)
treeb3bb8a82353c1d494d2d1d1aeebb4e4a14877e4d /src/network
parent9c18236f2c691cf4f21693f2693256a31faafae8 (diff)
downloadopenttd-b11bd185e3c656c08e3f3d57eb2ada15b7ac276d.tar.xz
Fix #9756: Network command unpack proc was not generated in all cases.
The case where the callback proc takes all command results but not any of the command parameters was not handled properly.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_command.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp
index 05837f50c..d39618abf 100644
--- a/src/network/network_command.cpp
+++ b/src/network/network_command.cpp
@@ -136,7 +136,10 @@ constexpr UnpackNetworkCommandProc MakeUnpackNetworkCommandCallback() noexcept
{
/* Check if the callback matches with the command arguments. If not, don't generate an Unpack proc. */
using Tcallback = std::tuple_element_t<Tcb, decltype(_callback_tuple)>;
- if constexpr (std::is_same_v<Tcallback, CommandCallback * const> || std::is_same_v<Tcallback, CommandCallbackData * const> || std::is_same_v<typename CommandTraits<Tcmd>::CbArgs, typename CallbackArgsHelper<Tcallback>::Args>) {
+ if constexpr (std::is_same_v<Tcallback, CommandCallback * const> || // Callback type is CommandCallback.
+ std::is_same_v<Tcallback, CommandCallbackData * const> || // Callback type is CommandCallbackData.
+ std::is_same_v<typename CommandTraits<Tcmd>::CbArgs, typename CallbackArgsHelper<Tcallback>::Args> || // Callback proc takes all command return values and parameters.
+ (!std::is_void_v<typename CommandTraits<Tcmd>::RetTypes> && std::is_same_v<typename CallbackArgsHelper<typename CommandTraits<Tcmd>::RetCallbackProc const>::Args, typename CallbackArgsHelper<Tcallback>::Args>)) { // Callback return is more than CommandCost and the proc takes all return values.
return &UnpackNetworkCommand<Tcmd, Tcb>;
} else {
return nullptr;