MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / FindCallbackIndex

Function FindCallbackIndex

src/network/network_command.cpp:190–197  ·  view source on GitHub ↗

* Find the callback index of a callback pointer. * @param callback Address of callback to search for. * @return Callback index or std::numeric_limits ::max() if the function wasn't found in the callback list. */

Source from the content-addressed store, hash-verified

188 * @return Callback index or std::numeric_limits<size_t>::max() if the function wasn't found in the callback list.
189 */
190static size_t FindCallbackIndex(CommandCallback *callback)
191{
192 if (auto it = std::ranges::find(_callback_table, callback); it != std::end(_callback_table)) {
193 return static_cast<size_t>(std::distance(std::begin(_callback_table), it));
194 }
195
196 return std::numeric_limits<size_t>::max();
197}
198
199/**
200 * Prepare a DoCommand to be send over the network

Callers 2

SendCommandMethod · 0.85

Calls 3

findFunction · 0.50
endFunction · 0.50
beginFunction · 0.50

Tested by

no test coverage detected