lsteamclient: Copy the ServerResponded parameter for delayed callbacks.

CW-Bug-Id: #23272
This commit is contained in:
Rémi Bernon 2024-01-19 11:40:09 +01:00
parent f8abffb6ba
commit 3bf7e4d032
5 changed files with 38 additions and 4 deletions

View File

@ -389,6 +389,12 @@ void execute_pending_callbacks(void)
params.callback->call_iface_vtable.arg0, params.callback->call_iface_vtable.arg1, params.callback->call_iface_vtable.arg2) );
break;
case CALL_IFACE_VTABLE_0_SERVER_RESPONDED:
TRACE( "CALL_IFACE_VTABLE_0_SERVER_RESPONDED iface %p, server %p.\n", params.callback->server_responded.iface,
params.callback->server_responded.server );
CALL_VTBL_FUNC( params.callback->server_responded.iface, 0, void, (void *, gameserveritem_t_105 *), (params.callback->server_responded.iface,
params.callback->server_responded.server) );
break;
case CALL_IFACE_VTABLE_0_ADD_PLAYER_TO_LIST:
TRACE( "CALL_IFACE_VTABLE_0_ADD_PLAYER_TO_LIST iface %p, name %s, score %u, time_played %f.\n", params.callback->add_player_to_list.iface,
params.callback->add_player_to_list.name, params.callback->add_player_to_list.score, params.callback->add_player_to_list.time_played );

View File

@ -20,6 +20,7 @@ extern "C"
struct w_steam_iface;
extern void queue_vtable_callback( struct w_steam_iface *w_iface, enum callback_type type, uint64_t arg0, uint64_t arg1, uint64_t arg2 );
extern void queue_vtable_callback_0_server_responded( struct w_steam_iface *w_iface, gameserveritem_t_105 *server );
extern void queue_vtable_callback_0_add_player_to_list( struct w_steam_iface *w_iface, const char *pchName, int nScore, float flTimePlayed );
extern void queue_vtable_callback_0_rules_responded( struct w_steam_iface *w_iface, const char *pchRule, const char *pchValue );

View File

@ -670,7 +670,7 @@ struct SteamMatchmakingPingResponse : u_ISteamMatchmakingPingResponse
void SteamMatchmakingPingResponse::ServerResponded( gameserveritem_t_105 *server )
{
queue_vtable_callback( this->w_iface, CALL_IFACE_VTABLE_0, (intptr_t)server, 0, 0 );
queue_vtable_callback_0_server_responded( this->w_iface, server );
}
void SteamMatchmakingPingResponse::ServerFailedToRespond(void)

View File

@ -16,7 +16,7 @@ struct callback_entry
static struct list callbacks = LIST_INIT( callbacks );
static pthread_mutex_t callbacks_lock = PTHREAD_MUTEX_INITIALIZER;
extern void queue_vtable_callback( struct w_steam_iface *w_iface, enum callback_type type, uint64_t arg0, uint64_t arg1, uint64_t arg2 )
void queue_vtable_callback( struct w_steam_iface *w_iface, enum callback_type type, uint64_t arg0, uint64_t arg1, uint64_t arg2 )
{
struct callback_entry *entry;
uint32_t size = 0;
@ -38,7 +38,27 @@ extern void queue_vtable_callback( struct w_steam_iface *w_iface, enum callback_
pthread_mutex_unlock( &callbacks_lock );
}
extern void queue_vtable_callback_0_add_player_to_list( struct w_steam_iface *w_iface, const char *pchName, int nScore, float flTimePlayed )
void queue_vtable_callback_0_server_responded( struct w_steam_iface *w_iface, gameserveritem_t_105 *server )
{
uint32_t size = sizeof(*server);
struct callback_entry *entry;
size += sizeof(struct callback_entry);
if (!(entry = (struct callback_entry *)malloc( size ))) return;
entry->callback.type = CALL_IFACE_VTABLE_0_SERVER_RESPONDED;
size -= offsetof( struct callback_entry, callback );
entry->callback.size = size;
entry->callback.server_responded.iface = w_iface;
entry->callback.server_responded.server[0] = *server;
pthread_mutex_lock( &callbacks_lock );
list_add_tail( &callbacks, &entry->entry );
pthread_mutex_unlock( &callbacks_lock );
}
void queue_vtable_callback_0_add_player_to_list( struct w_steam_iface *w_iface, const char *pchName, int nScore, float flTimePlayed )
{
uint32_t name_size = strlen( pchName ) + 1, size = name_size;
struct callback_entry *entry;
@ -60,7 +80,7 @@ extern void queue_vtable_callback_0_add_player_to_list( struct w_steam_iface *w_
pthread_mutex_unlock( &callbacks_lock );
}
extern void queue_vtable_callback_0_rules_responded( struct w_steam_iface *w_iface, const char *pchRule, const char *pchValue )
void queue_vtable_callback_0_rules_responded( struct w_steam_iface *w_iface, const char *pchRule, const char *pchValue )
{
uint32_t rule_size = strlen( pchRule ) + 1, value_size = strlen( pchValue ) + 1, size = rule_size + value_size;
struct callback_entry *entry;

View File

@ -39,6 +39,7 @@ enum callback_type
CALL_IFACE_VTABLE_0,
CALL_IFACE_VTABLE_1,
CALL_IFACE_VTABLE_2,
CALL_IFACE_VTABLE_0_SERVER_RESPONDED,
CALL_IFACE_VTABLE_0_ADD_PLAYER_TO_LIST,
CALL_IFACE_VTABLE_0_RULES_RESPONDED,
};
@ -78,6 +79,12 @@ struct callback
uint64_t arg2;
} call_iface_vtable;
struct
{
struct w_steam_iface *iface;
gameserveritem_t_105 server[];
} server_responded;
struct
{
struct w_steam_iface *iface;