Skip to content

Commit

Permalink
add util to get network message size by id
Browse files Browse the repository at this point in the history
  • Loading branch information
wootguy committed Nov 13, 2024
1 parent 23c8a38 commit 801d3b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions dlls/user_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ int GetUserMsgInfo(const char* msgname, int* size) {
return 0;
}

int GetUserMsgInfo(int id, int* size) {
for (int i = 0; i < (int)g_userMessages.size(); i++) {
UserMessage& msg = g_userMessages[i];

if (msg.id == id) {
if (size)
*size = msg.size;
return msg.id;
}
}

return 0;
}

void LinkUserMessages(void)
{
// Already taken care of?
Expand Down
1 change: 1 addition & 0 deletions dlls/user_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@ EXPORT int REG_USER_MSG(const char* name, int size);
// Find a usermsg, registered by the gamedll, with the corresponding
// msgname, and return remaining info about it (msgid, size). -metamod
EXPORT int GetUserMsgInfo(const char* msgname, int* size);
EXPORT int GetUserMsgInfo(int id, int* size);

void LinkUserMessages(void);

0 comments on commit 801d3b7

Please sign in to comment.