Created
October 23, 2015 03:13
-
-
Save SizzlingCalamari/bfa89787d54283d56d72 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
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) | |
template<typename BufType, typename FnType, typename ContextType> | |
bool NetMsgFuncRunner(const FnType* netHandlers, uint32_t type, BufType& buf, ContextType& context, void* data) | |
{ | |
if (type >= ARRAY_SIZE(netHandlers)) | |
{ | |
return false; | |
} | |
return netHandlers[type](buf, context, data); | |
} | |
bool NetHandlers::NetMsg_BitRead(uint32_t type, BitRead& bitbuf, SourceGameContext& context, void* data) | |
{ | |
static const NetMsgBitReadFn netHandlers[] = DECLARE_NET_HANDLER_ARRAY(BitRead); | |
return NetMsgFuncRunner(netHandlers, type, bitbuf, context, data); | |
} | |
bool NetHandlers::NetMsg_BitWrite(uint32_t type, BitWrite& bitbuf, const SourceGameContext& context, void* data) | |
{ | |
static const NetMsgBitWriteFn netHandlers[] = DECLARE_NET_HANDLER_ARRAY(BitWrite); | |
return NetMsgFuncRunner(netHandlers, type, bitbuf, context, data); | |
} | |
bool NetHandlers::NetMsg_JsonRead(uint32_t type, JsonRead& jsonbuf, SourceGameContext& context, void* data) | |
{ | |
static const NetMsgJsonReadFn netHandlers[] = DECLARE_NET_HANDLER_ARRAY(JsonRead); | |
return NetMsgFuncRunner(netHandlers, type, jsonbuf, context, data); | |
} | |
bool NetHandlers::NetMsg_JsonWrite(uint32_t type, JsonWrite& jsonbuf, const SourceGameContext& context, void* data) | |
{ | |
static const NetMsgJsonWriteFn netHandlers[] = DECLARE_NET_HANDLER_ARRAY(JsonWrite); | |
return NetMsgFuncRunner(netHandlers, type, jsonbuf, context, data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment