Skip to content

Commit

Permalink
Fix docs and avoid some allocs
Browse files Browse the repository at this point in the history
  • Loading branch information
yancouto committed Jan 15, 2024
1 parent d960195 commit 18bfe7b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Function Reference
return steam_id == my_id
end

.. function:: user.getAuthSessionTicket ()
.. function:: user.getAuthSessionTicket (identityRemote)

:param string identityRemote: String representing the remote system that will authenticate the ticket.
:returns: (`data`) A result table if successful, otherwise nil
Expand Down
13 changes: 5 additions & 8 deletions src/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,12 @@ EXTERN int luasteam_getSteamID(lua_State *L) {
// HAuthTicket GetAuthSessionTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket, const SteamNetworkingIdentity *pIdentityRemote );
EXTERN int luasteam_getAuthSessionTicket(lua_State *L) {
uint32 pcbTicket = 0;
void *pTicket = malloc(1024);
SteamNetworkingIdentity *identityRemote = new SteamNetworkingIdentity();
identityRemote->ParseString(luaL_checkstring(L, 1));
HAuthTicket ticket = SteamUser()->GetAuthSessionTicket(pTicket, 1024, &pcbTicket, identityRemote);
char pTicket[1024];
SteamNetworkingIdentity identityRemote;
identityRemote.ParseString(luaL_checkstring(L, 1));
HAuthTicket ticket = SteamUser()->GetAuthSessionTicket(pTicket, 1024, &pcbTicket, &identityRemote);

identityRemote->Clear();
free(identityRemote);
identityRemote.Clear();

if (ticket != k_HAuthTicketInvalid) {
std::string hexTicket = bufferToHex(pTicket, pcbTicket);
Expand All @@ -83,10 +82,8 @@ EXTERN int luasteam_getAuthSessionTicket(lua_State *L) {
lua_setfield(L, -2, "ticket");
lua_pushstring(L, hexTicket.c_str());
lua_setfield(L, -2, "hexTicket");
free(pTicket);
return 1;
}
free(pTicket);
lua_pushnil(L);
return 1;
}
Expand Down

0 comments on commit 18bfe7b

Please sign in to comment.